@plasmicpkgs/commerce 0.0.5 → 0.0.8
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.md +21 -0
- package/dist/commerce.cjs.development.js +917 -706
- package/dist/commerce.cjs.development.js.map +1 -1
- package/dist/commerce.cjs.production.min.js +1 -1
- package/dist/commerce.cjs.production.min.js.map +1 -1
- package/dist/commerce.d.ts +3 -1
- package/dist/commerce.esm.js +886 -705
- package/dist/commerce.esm.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/product/use-product.d.ts +5 -0
- package/dist/registerAddToCartButton.d.ts +1 -0
- package/dist/registerCart.d.ts +10 -0
- package/dist/registerProductBox.d.ts +13 -0
- package/dist/registerProductCollection.d.ts +5 -0
- package/dist/registerProductLink.d.ts +12 -0
- package/dist/registerProductPrice.d.ts +1 -1
- package/dist/types/product.d.ts +13 -0
- package/dist/utils/types.d.ts +3 -1
- package/dist/utils/use-extra-features.d.ts +1 -0
- package/package.json +4 -3
- package/dist/registerUseCart.d.ts +0 -9
package/dist/commerce.esm.js
CHANGED
|
@@ -165,205 +165,240 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
165
165
|
return target;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
function
|
|
169
|
-
|
|
168
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
169
|
+
if (!o) return;
|
|
170
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
171
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
172
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
173
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
174
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
170
175
|
}
|
|
171
176
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
writable: true
|
|
196
|
-
});
|
|
197
|
-
return obj[key];
|
|
198
|
-
}
|
|
199
|
-
try {
|
|
200
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
201
|
-
define({}, "");
|
|
202
|
-
} catch (err) {
|
|
203
|
-
define = function(obj, key, value) {
|
|
204
|
-
return obj[key] = value;
|
|
177
|
+
function _arrayLikeToArray(arr, len) {
|
|
178
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
179
|
+
|
|
180
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
181
|
+
|
|
182
|
+
return arr2;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
186
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
187
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
188
|
+
|
|
189
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
190
|
+
if (it) o = it;
|
|
191
|
+
var i = 0;
|
|
192
|
+
return function () {
|
|
193
|
+
if (i >= o.length) return {
|
|
194
|
+
done: true
|
|
195
|
+
};
|
|
196
|
+
return {
|
|
197
|
+
done: false,
|
|
198
|
+
value: o[i++]
|
|
199
|
+
};
|
|
205
200
|
};
|
|
206
201
|
}
|
|
207
202
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
203
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function createCommonjsModule(fn, module) {
|
|
207
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
208
|
+
}
|
|
213
209
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
211
|
+
/**
|
|
212
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
213
|
+
*
|
|
214
|
+
* This source code is licensed under the MIT license found in the
|
|
215
|
+
* LICENSE file in the root directory of this source tree.
|
|
216
|
+
*/
|
|
217
|
+
var runtime = function (exports) {
|
|
218
|
+
|
|
219
|
+
var Op = Object.prototype;
|
|
220
|
+
var hasOwn = Op.hasOwnProperty;
|
|
221
|
+
var undefined$1; // More compressible than void 0.
|
|
222
|
+
|
|
223
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
224
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
225
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
226
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
227
|
+
|
|
228
|
+
function define(obj, key, value) {
|
|
229
|
+
Object.defineProperty(obj, key, {
|
|
230
|
+
value: value,
|
|
231
|
+
enumerable: true,
|
|
232
|
+
configurable: true,
|
|
233
|
+
writable: true
|
|
234
|
+
});
|
|
235
|
+
return obj[key];
|
|
236
|
+
}
|
|
217
237
|
|
|
218
|
-
return generator;
|
|
219
|
-
}
|
|
220
|
-
exports.wrap = wrap;
|
|
221
|
-
|
|
222
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
223
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
224
|
-
// have been (and was previously) designed to take a closure to be
|
|
225
|
-
// invoked without arguments, but in all the cases we care about we
|
|
226
|
-
// already have an existing method we want to call, so there's no need
|
|
227
|
-
// to create a new function object. We can even get away with assuming
|
|
228
|
-
// the method takes exactly one argument, since that happens to be true
|
|
229
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
230
|
-
// only additional allocation required is the completion record, which
|
|
231
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
232
|
-
function tryCatch(fn, obj, arg) {
|
|
233
238
|
try {
|
|
234
|
-
|
|
239
|
+
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
240
|
+
define({}, "");
|
|
235
241
|
} catch (err) {
|
|
236
|
-
|
|
242
|
+
define = function define(obj, key, value) {
|
|
243
|
+
return obj[key] = value;
|
|
244
|
+
};
|
|
237
245
|
}
|
|
238
|
-
}
|
|
239
246
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// breaking out of the dispatch switch statement.
|
|
247
|
-
var ContinueSentinel = {};
|
|
248
|
-
|
|
249
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
250
|
-
// .constructor.prototype properties for functions that return Generator
|
|
251
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
252
|
-
// minifier not to mangle the names of these two functions.
|
|
253
|
-
function Generator() {}
|
|
254
|
-
function GeneratorFunction() {}
|
|
255
|
-
function GeneratorFunctionPrototype() {}
|
|
256
|
-
|
|
257
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
258
|
-
// don't natively support it.
|
|
259
|
-
var IteratorPrototype = {};
|
|
260
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
261
|
-
return this;
|
|
262
|
-
});
|
|
247
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
248
|
+
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
249
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
250
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
251
|
+
var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
|
|
252
|
+
// .throw, and .return methods.
|
|
263
253
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
NativeIteratorPrototype !== Op &&
|
|
268
|
-
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
269
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
270
|
-
// of the polyfill.
|
|
271
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
272
|
-
}
|
|
254
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
255
|
+
return generator;
|
|
256
|
+
}
|
|
273
257
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
|
|
258
|
+
exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
|
|
259
|
+
// record like context.tryEntries[i].completion. This interface could
|
|
260
|
+
// have been (and was previously) designed to take a closure to be
|
|
261
|
+
// invoked without arguments, but in all the cases we care about we
|
|
262
|
+
// already have an existing method we want to call, so there's no need
|
|
263
|
+
// to create a new function object. We can even get away with assuming
|
|
264
|
+
// the method takes exactly one argument, since that happens to be true
|
|
265
|
+
// in every case, so we don't have to touch the arguments object. The
|
|
266
|
+
// only additional allocation required is the completion record, which
|
|
267
|
+
// has a stable shape and so hopefully should be cheap to allocate.
|
|
268
|
+
|
|
269
|
+
function tryCatch(fn, obj, arg) {
|
|
270
|
+
try {
|
|
271
|
+
return {
|
|
272
|
+
type: "normal",
|
|
273
|
+
arg: fn.call(obj, arg)
|
|
274
|
+
};
|
|
275
|
+
} catch (err) {
|
|
276
|
+
return {
|
|
277
|
+
type: "throw",
|
|
278
|
+
arg: err
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
294
282
|
|
|
295
|
-
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
283
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
284
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
285
|
+
var GenStateExecuting = "executing";
|
|
286
|
+
var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
|
|
287
|
+
// breaking out of the dispatch switch statement.
|
|
288
|
+
|
|
289
|
+
var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
|
|
290
|
+
// .constructor.prototype properties for functions that return Generator
|
|
291
|
+
// objects. For full spec compliance, you may wish to configure your
|
|
292
|
+
// minifier not to mangle the names of these two functions.
|
|
293
|
+
|
|
294
|
+
function Generator() {}
|
|
295
|
+
|
|
296
|
+
function GeneratorFunction() {}
|
|
297
|
+
|
|
298
|
+
function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
|
|
299
|
+
// don't natively support it.
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
var IteratorPrototype = {};
|
|
303
|
+
|
|
304
|
+
IteratorPrototype[iteratorSymbol] = function () {
|
|
305
|
+
return this;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
var getProto = Object.getPrototypeOf;
|
|
309
|
+
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
304
310
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
310
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
311
|
+
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
312
|
+
// This environment has a native %IteratorPrototype%; use it instead
|
|
313
|
+
// of the polyfill.
|
|
314
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
311
315
|
}
|
|
312
|
-
genFun.prototype = Object.create(Gp);
|
|
313
|
-
return genFun;
|
|
314
|
-
};
|
|
315
316
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
return { __await: arg };
|
|
322
|
-
};
|
|
317
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
318
|
+
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
319
|
+
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
320
|
+
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
321
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
323
322
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
323
|
+
function defineIteratorMethods(prototype) {
|
|
324
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
325
|
+
define(prototype, method, function (arg) {
|
|
326
|
+
return this._invoke(method, arg);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
exports.isGeneratorFunction = function (genFun) {
|
|
332
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
333
|
+
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
334
|
+
// do is to check its .name property.
|
|
335
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
exports.mark = function (genFun) {
|
|
339
|
+
if (Object.setPrototypeOf) {
|
|
340
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
329
341
|
} else {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
342
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
343
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
genFun.prototype = Object.create(Gp);
|
|
347
|
+
return genFun;
|
|
348
|
+
}; // Within the body of any async function, `await x` is transformed to
|
|
349
|
+
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
350
|
+
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
351
|
+
// meant to be awaited.
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
exports.awrap = function (arg) {
|
|
355
|
+
return {
|
|
356
|
+
__await: arg
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
361
|
+
function invoke(method, arg, resolve, reject) {
|
|
362
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
363
|
+
|
|
364
|
+
if (record.type === "throw") {
|
|
365
|
+
reject(record.arg);
|
|
366
|
+
} else {
|
|
367
|
+
var result = record.arg;
|
|
368
|
+
var value = result.value;
|
|
369
|
+
|
|
370
|
+
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
371
|
+
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
372
|
+
invoke("next", value, resolve, reject);
|
|
373
|
+
}, function (err) {
|
|
374
|
+
invoke("throw", err, resolve, reject);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
379
|
+
// When a yielded Promise is resolved, its final value becomes
|
|
380
|
+
// the .value of the Promise<{value,done}> result for the
|
|
381
|
+
// current iteration.
|
|
382
|
+
result.value = unwrapped;
|
|
383
|
+
resolve(result);
|
|
384
|
+
}, function (error) {
|
|
385
|
+
// If a rejected Promise was yielded, throw the rejection back
|
|
386
|
+
// into the async generator function so it can be handled there.
|
|
387
|
+
return invoke("throw", error, resolve, reject);
|
|
339
388
|
});
|
|
340
389
|
}
|
|
341
|
-
|
|
342
|
-
return PromiseImpl.resolve(value).then(function(unwrapped) {
|
|
343
|
-
// When a yielded Promise is resolved, its final value becomes
|
|
344
|
-
// the .value of the Promise<{value,done}> result for the
|
|
345
|
-
// current iteration.
|
|
346
|
-
result.value = unwrapped;
|
|
347
|
-
resolve(result);
|
|
348
|
-
}, function(error) {
|
|
349
|
-
// If a rejected Promise was yielded, throw the rejection back
|
|
350
|
-
// into the async generator function so it can be handled there.
|
|
351
|
-
return invoke("throw", error, resolve, reject);
|
|
352
|
-
});
|
|
353
390
|
}
|
|
354
|
-
}
|
|
355
391
|
|
|
356
|
-
|
|
392
|
+
var previousPromise;
|
|
357
393
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
394
|
+
function enqueue(method, arg) {
|
|
395
|
+
function callInvokeWithMethodAndArg() {
|
|
396
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
397
|
+
invoke(method, arg, resolve, reject);
|
|
398
|
+
});
|
|
399
|
+
}
|
|
364
400
|
|
|
365
|
-
|
|
366
|
-
// If enqueue has been called before, then we want to wait until
|
|
401
|
+
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
367
402
|
// all previous Promises have been resolved before calling invoke,
|
|
368
403
|
// so that results are always delivered in the correct order. If
|
|
369
404
|
// enqueue has not been called before, then it is important to
|
|
@@ -375,554 +410,525 @@ var runtime = (function (exports) {
|
|
|
375
410
|
// execute code before the first await. Since we implement simple
|
|
376
411
|
// async functions in terms of async generators, it is especially
|
|
377
412
|
// important to get this right, even though it requires care.
|
|
378
|
-
previousPromise ? previousPromise.then(
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
413
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
|
|
414
|
+
// invocations of the iterator.
|
|
415
|
+
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
416
|
+
} // Define the unified helper method that is used to implement .next,
|
|
417
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
this._invoke = enqueue;
|
|
384
421
|
}
|
|
385
422
|
|
|
386
|
-
|
|
387
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
388
|
-
this._invoke = enqueue;
|
|
389
|
-
}
|
|
423
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
390
424
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
});
|
|
395
|
-
exports.AsyncIterator = AsyncIterator;
|
|
396
|
-
|
|
397
|
-
// Note that simple async functions are implemented on top of
|
|
398
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
399
|
-
// the final result produced by the iterator.
|
|
400
|
-
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
401
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
402
|
-
|
|
403
|
-
var iter = new AsyncIterator(
|
|
404
|
-
wrap(innerFn, outerFn, self, tryLocsList),
|
|
405
|
-
PromiseImpl
|
|
406
|
-
);
|
|
407
|
-
|
|
408
|
-
return exports.isGeneratorFunction(outerFn)
|
|
409
|
-
? iter // If outerFn is a generator, return the full iterator.
|
|
410
|
-
: iter.next().then(function(result) {
|
|
411
|
-
return result.done ? result.value : iter.next();
|
|
412
|
-
});
|
|
413
|
-
};
|
|
425
|
+
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
426
|
+
return this;
|
|
427
|
+
};
|
|
414
428
|
|
|
415
|
-
|
|
416
|
-
|
|
429
|
+
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
430
|
+
// AsyncIterator objects; they just return a Promise for the value of
|
|
431
|
+
// the final result produced by the iterator.
|
|
417
432
|
|
|
418
|
-
|
|
419
|
-
if (
|
|
420
|
-
|
|
421
|
-
|
|
433
|
+
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
434
|
+
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
435
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
436
|
+
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
437
|
+
: iter.next().then(function (result) {
|
|
438
|
+
return result.done ? result.value : iter.next();
|
|
439
|
+
});
|
|
440
|
+
};
|
|
422
441
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
442
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
443
|
+
var state = GenStateSuspendedStart;
|
|
444
|
+
return function invoke(method, arg) {
|
|
445
|
+
if (state === GenStateExecuting) {
|
|
446
|
+
throw new Error("Generator is already running");
|
|
426
447
|
}
|
|
427
448
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
449
|
+
if (state === GenStateCompleted) {
|
|
450
|
+
if (method === "throw") {
|
|
451
|
+
throw arg;
|
|
452
|
+
} // Be forgiving, per 25.3.3.3.3 of the spec:
|
|
453
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
432
454
|
|
|
433
|
-
context.method = method;
|
|
434
|
-
context.arg = arg;
|
|
435
455
|
|
|
436
|
-
|
|
437
|
-
var delegate = context.delegate;
|
|
438
|
-
if (delegate) {
|
|
439
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
440
|
-
if (delegateResult) {
|
|
441
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
442
|
-
return delegateResult;
|
|
443
|
-
}
|
|
456
|
+
return doneResult();
|
|
444
457
|
}
|
|
445
458
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
459
|
+
context.method = method;
|
|
460
|
+
context.arg = arg;
|
|
461
|
+
|
|
462
|
+
while (true) {
|
|
463
|
+
var delegate = context.delegate;
|
|
450
464
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
465
|
+
if (delegate) {
|
|
466
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
467
|
+
|
|
468
|
+
if (delegateResult) {
|
|
469
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
470
|
+
return delegateResult;
|
|
471
|
+
}
|
|
455
472
|
}
|
|
456
473
|
|
|
457
|
-
|
|
474
|
+
if (context.method === "next") {
|
|
475
|
+
// Setting context._sent for legacy support of Babel's
|
|
476
|
+
// function.sent implementation.
|
|
477
|
+
context.sent = context._sent = context.arg;
|
|
478
|
+
} else if (context.method === "throw") {
|
|
479
|
+
if (state === GenStateSuspendedStart) {
|
|
480
|
+
state = GenStateCompleted;
|
|
481
|
+
throw context.arg;
|
|
482
|
+
}
|
|
458
483
|
|
|
459
|
-
|
|
460
|
-
context.
|
|
461
|
-
|
|
484
|
+
context.dispatchException(context.arg);
|
|
485
|
+
} else if (context.method === "return") {
|
|
486
|
+
context.abrupt("return", context.arg);
|
|
487
|
+
}
|
|
462
488
|
|
|
463
|
-
|
|
489
|
+
state = GenStateExecuting;
|
|
490
|
+
var record = tryCatch(innerFn, self, context);
|
|
464
491
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
state = context.done
|
|
470
|
-
? GenStateCompleted
|
|
471
|
-
: GenStateSuspendedYield;
|
|
492
|
+
if (record.type === "normal") {
|
|
493
|
+
// If an exception is thrown from innerFn, we leave state ===
|
|
494
|
+
// GenStateExecuting and loop back for another invocation.
|
|
495
|
+
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
472
496
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
497
|
+
if (record.arg === ContinueSentinel) {
|
|
498
|
+
continue;
|
|
499
|
+
}
|
|
476
500
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
501
|
+
return {
|
|
502
|
+
value: record.arg,
|
|
503
|
+
done: context.done
|
|
504
|
+
};
|
|
505
|
+
} else if (record.type === "throw") {
|
|
506
|
+
state = GenStateCompleted; // Dispatch the exception by looping back around to the
|
|
507
|
+
// context.dispatchException(context.arg) call above.
|
|
508
|
+
|
|
509
|
+
context.method = "throw";
|
|
510
|
+
context.arg = record.arg;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
} // Call delegate.iterator[context.method](context.arg) and handle the
|
|
515
|
+
// result, either by returning a { value, done } result from the
|
|
516
|
+
// delegate iterator, or by modifying context.method and context.arg,
|
|
517
|
+
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
521
|
+
var method = delegate.iterator[context.method];
|
|
522
|
+
|
|
523
|
+
if (method === undefined$1) {
|
|
524
|
+
// A .throw or .return when the delegate iterator has no .throw
|
|
525
|
+
// method always terminates the yield* loop.
|
|
526
|
+
context.delegate = null;
|
|
527
|
+
|
|
528
|
+
if (context.method === "throw") {
|
|
529
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
530
|
+
if (delegate.iterator["return"]) {
|
|
531
|
+
// If the delegate iterator has a return method, give it a
|
|
532
|
+
// chance to clean up.
|
|
533
|
+
context.method = "return";
|
|
534
|
+
context.arg = undefined$1;
|
|
535
|
+
maybeInvokeDelegate(delegate, context);
|
|
536
|
+
|
|
537
|
+
if (context.method === "throw") {
|
|
538
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
539
|
+
// "return" to "throw", let that override the TypeError below.
|
|
540
|
+
return ContinueSentinel;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
481
543
|
|
|
482
|
-
} else if (record.type === "throw") {
|
|
483
|
-
state = GenStateCompleted;
|
|
484
|
-
// Dispatch the exception by looping back around to the
|
|
485
|
-
// context.dispatchException(context.arg) call above.
|
|
486
544
|
context.method = "throw";
|
|
487
|
-
context.arg =
|
|
545
|
+
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
488
546
|
}
|
|
547
|
+
|
|
548
|
+
return ContinueSentinel;
|
|
489
549
|
}
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
550
|
|
|
493
|
-
|
|
494
|
-
// result, either by returning a { value, done } result from the
|
|
495
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
496
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
497
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
498
|
-
var method = delegate.iterator[context.method];
|
|
499
|
-
if (method === undefined$1) {
|
|
500
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
501
|
-
// method always terminates the yield* loop.
|
|
502
|
-
context.delegate = null;
|
|
551
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
503
552
|
|
|
504
|
-
if (
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
context.arg = undefined$1;
|
|
511
|
-
maybeInvokeDelegate(delegate, context);
|
|
553
|
+
if (record.type === "throw") {
|
|
554
|
+
context.method = "throw";
|
|
555
|
+
context.arg = record.arg;
|
|
556
|
+
context.delegate = null;
|
|
557
|
+
return ContinueSentinel;
|
|
558
|
+
}
|
|
512
559
|
|
|
513
|
-
|
|
514
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
515
|
-
// "return" to "throw", let that override the TypeError below.
|
|
516
|
-
return ContinueSentinel;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
560
|
+
var info = record.arg;
|
|
519
561
|
|
|
562
|
+
if (!info) {
|
|
520
563
|
context.method = "throw";
|
|
521
|
-
context.arg = new TypeError(
|
|
522
|
-
|
|
564
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
565
|
+
context.delegate = null;
|
|
566
|
+
return ContinueSentinel;
|
|
523
567
|
}
|
|
524
568
|
|
|
525
|
-
|
|
526
|
-
|
|
569
|
+
if (info.done) {
|
|
570
|
+
// Assign the result of the finished delegate to the temporary
|
|
571
|
+
// variable specified by delegate.resultName (see delegateYield).
|
|
572
|
+
context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
|
|
527
573
|
|
|
528
|
-
|
|
574
|
+
context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
|
|
575
|
+
// exception, let the outer generator proceed normally. If
|
|
576
|
+
// context.method was "next", forget context.arg since it has been
|
|
577
|
+
// "consumed" by the delegate iterator. If context.method was
|
|
578
|
+
// "return", allow the original .return call to continue in the
|
|
579
|
+
// outer generator.
|
|
529
580
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
581
|
+
if (context.method !== "return") {
|
|
582
|
+
context.method = "next";
|
|
583
|
+
context.arg = undefined$1;
|
|
584
|
+
}
|
|
585
|
+
} else {
|
|
586
|
+
// Re-yield the result returned by the delegate method.
|
|
587
|
+
return info;
|
|
588
|
+
} // The delegate iterator is finished, so forget it and continue with
|
|
589
|
+
// the outer generator.
|
|
536
590
|
|
|
537
|
-
var info = record.arg;
|
|
538
591
|
|
|
539
|
-
if (! info) {
|
|
540
|
-
context.method = "throw";
|
|
541
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
542
592
|
context.delegate = null;
|
|
543
593
|
return ContinueSentinel;
|
|
544
|
-
}
|
|
594
|
+
} // Define Generator.prototype.{next,throw,return} in terms of the
|
|
595
|
+
// unified ._invoke helper method.
|
|
545
596
|
|
|
546
|
-
if (info.done) {
|
|
547
|
-
// Assign the result of the finished delegate to the temporary
|
|
548
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
549
|
-
context[delegate.resultName] = info.value;
|
|
550
|
-
|
|
551
|
-
// Resume execution at the desired location (see delegateYield).
|
|
552
|
-
context.next = delegate.nextLoc;
|
|
553
|
-
|
|
554
|
-
// If context.method was "throw" but the delegate handled the
|
|
555
|
-
// exception, let the outer generator proceed normally. If
|
|
556
|
-
// context.method was "next", forget context.arg since it has been
|
|
557
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
558
|
-
// "return", allow the original .return call to continue in the
|
|
559
|
-
// outer generator.
|
|
560
|
-
if (context.method !== "return") {
|
|
561
|
-
context.method = "next";
|
|
562
|
-
context.arg = undefined$1;
|
|
563
|
-
}
|
|
564
597
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
598
|
+
defineIteratorMethods(Gp);
|
|
599
|
+
define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
|
|
600
|
+
// @@iterator function is called on it. Some browsers' implementations of the
|
|
601
|
+
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
602
|
+
// object to not be returned from this call. This ensures that doesn't happen.
|
|
603
|
+
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
569
604
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
return ContinueSentinel;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
577
|
-
// unified ._invoke helper method.
|
|
578
|
-
defineIteratorMethods(Gp);
|
|
605
|
+
Gp[iteratorSymbol] = function () {
|
|
606
|
+
return this;
|
|
607
|
+
};
|
|
579
608
|
|
|
580
|
-
|
|
609
|
+
Gp.toString = function () {
|
|
610
|
+
return "[object Generator]";
|
|
611
|
+
};
|
|
581
612
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
587
|
-
define(Gp, iteratorSymbol, function() {
|
|
588
|
-
return this;
|
|
589
|
-
});
|
|
613
|
+
function pushTryEntry(locs) {
|
|
614
|
+
var entry = {
|
|
615
|
+
tryLoc: locs[0]
|
|
616
|
+
};
|
|
590
617
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
618
|
+
if (1 in locs) {
|
|
619
|
+
entry.catchLoc = locs[1];
|
|
620
|
+
}
|
|
594
621
|
|
|
595
|
-
|
|
596
|
-
|
|
622
|
+
if (2 in locs) {
|
|
623
|
+
entry.finallyLoc = locs[2];
|
|
624
|
+
entry.afterLoc = locs[3];
|
|
625
|
+
}
|
|
597
626
|
|
|
598
|
-
|
|
599
|
-
entry.catchLoc = locs[1];
|
|
627
|
+
this.tryEntries.push(entry);
|
|
600
628
|
}
|
|
601
629
|
|
|
602
|
-
|
|
603
|
-
entry.
|
|
604
|
-
|
|
630
|
+
function resetTryEntry(entry) {
|
|
631
|
+
var record = entry.completion || {};
|
|
632
|
+
record.type = "normal";
|
|
633
|
+
delete record.arg;
|
|
634
|
+
entry.completion = record;
|
|
605
635
|
}
|
|
606
636
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
function Context(tryLocsList) {
|
|
618
|
-
// The root entry object (effectively a try statement without a catch
|
|
619
|
-
// or a finally block) gives us a place to store values thrown from
|
|
620
|
-
// locations where there is no enclosing try statement.
|
|
621
|
-
this.tryEntries = [{ tryLoc: "root" }];
|
|
622
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
623
|
-
this.reset(true);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
exports.keys = function(object) {
|
|
627
|
-
var keys = [];
|
|
628
|
-
for (var key in object) {
|
|
629
|
-
keys.push(key);
|
|
637
|
+
function Context(tryLocsList) {
|
|
638
|
+
// The root entry object (effectively a try statement without a catch
|
|
639
|
+
// or a finally block) gives us a place to store values thrown from
|
|
640
|
+
// locations where there is no enclosing try statement.
|
|
641
|
+
this.tryEntries = [{
|
|
642
|
+
tryLoc: "root"
|
|
643
|
+
}];
|
|
644
|
+
tryLocsList.forEach(pushTryEntry, this);
|
|
645
|
+
this.reset(true);
|
|
630
646
|
}
|
|
631
|
-
keys.reverse();
|
|
632
|
-
|
|
633
|
-
// Rather than returning an object with a next method, we keep
|
|
634
|
-
// things simple and return the next function itself.
|
|
635
|
-
return function next() {
|
|
636
|
-
while (keys.length) {
|
|
637
|
-
var key = keys.pop();
|
|
638
|
-
if (key in object) {
|
|
639
|
-
next.value = key;
|
|
640
|
-
next.done = false;
|
|
641
|
-
return next;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
647
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
// also ensures that the minifier will not anonymize the function.
|
|
648
|
-
next.done = true;
|
|
649
|
-
return next;
|
|
650
|
-
};
|
|
651
|
-
};
|
|
648
|
+
exports.keys = function (object) {
|
|
649
|
+
var keys = [];
|
|
652
650
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
656
|
-
if (iteratorMethod) {
|
|
657
|
-
return iteratorMethod.call(iterable);
|
|
651
|
+
for (var key in object) {
|
|
652
|
+
keys.push(key);
|
|
658
653
|
}
|
|
659
654
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
}
|
|
655
|
+
keys.reverse(); // Rather than returning an object with a next method, we keep
|
|
656
|
+
// things simple and return the next function itself.
|
|
663
657
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
if (hasOwn.call(iterable, i)) {
|
|
668
|
-
next.value = iterable[i];
|
|
669
|
-
next.done = false;
|
|
670
|
-
return next;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
658
|
+
return function next() {
|
|
659
|
+
while (keys.length) {
|
|
660
|
+
var key = keys.pop();
|
|
673
661
|
|
|
674
|
-
|
|
675
|
-
|
|
662
|
+
if (key in object) {
|
|
663
|
+
next.value = key;
|
|
664
|
+
next.done = false;
|
|
665
|
+
return next;
|
|
666
|
+
}
|
|
667
|
+
} // To avoid creating an additional object, we just hang the .value
|
|
668
|
+
// and .done properties off the next function object itself. This
|
|
669
|
+
// also ensures that the minifier will not anonymize the function.
|
|
676
670
|
|
|
677
|
-
return next;
|
|
678
|
-
};
|
|
679
671
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
672
|
+
next.done = true;
|
|
673
|
+
return next;
|
|
674
|
+
};
|
|
675
|
+
};
|
|
683
676
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
exports.values = values;
|
|
677
|
+
function values(iterable) {
|
|
678
|
+
if (iterable) {
|
|
679
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
688
680
|
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
681
|
+
if (iteratorMethod) {
|
|
682
|
+
return iteratorMethod.call(iterable);
|
|
683
|
+
}
|
|
692
684
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
reset: function(skipTempReset) {
|
|
697
|
-
this.prev = 0;
|
|
698
|
-
this.next = 0;
|
|
699
|
-
// Resetting context._sent for legacy support of Babel's
|
|
700
|
-
// function.sent implementation.
|
|
701
|
-
this.sent = this._sent = undefined$1;
|
|
702
|
-
this.done = false;
|
|
703
|
-
this.delegate = null;
|
|
704
|
-
|
|
705
|
-
this.method = "next";
|
|
706
|
-
this.arg = undefined$1;
|
|
707
|
-
|
|
708
|
-
this.tryEntries.forEach(resetTryEntry);
|
|
709
|
-
|
|
710
|
-
if (!skipTempReset) {
|
|
711
|
-
for (var name in this) {
|
|
712
|
-
// Not sure about the optimal order of these conditions:
|
|
713
|
-
if (name.charAt(0) === "t" &&
|
|
714
|
-
hasOwn.call(this, name) &&
|
|
715
|
-
!isNaN(+name.slice(1))) {
|
|
716
|
-
this[name] = undefined$1;
|
|
717
|
-
}
|
|
685
|
+
if (typeof iterable.next === "function") {
|
|
686
|
+
return iterable;
|
|
718
687
|
}
|
|
719
|
-
}
|
|
720
|
-
},
|
|
721
688
|
|
|
722
|
-
|
|
723
|
-
|
|
689
|
+
if (!isNaN(iterable.length)) {
|
|
690
|
+
var i = -1,
|
|
691
|
+
next = function next() {
|
|
692
|
+
while (++i < iterable.length) {
|
|
693
|
+
if (hasOwn.call(iterable, i)) {
|
|
694
|
+
next.value = iterable[i];
|
|
695
|
+
next.done = false;
|
|
696
|
+
return next;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
724
699
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
}
|
|
700
|
+
next.value = undefined$1;
|
|
701
|
+
next.done = true;
|
|
702
|
+
return next;
|
|
703
|
+
};
|
|
730
704
|
|
|
731
|
-
|
|
732
|
-
|
|
705
|
+
return next.next = next;
|
|
706
|
+
}
|
|
707
|
+
} // Return an iterator with no values.
|
|
733
708
|
|
|
734
|
-
dispatchException: function(exception) {
|
|
735
|
-
if (this.done) {
|
|
736
|
-
throw exception;
|
|
737
|
-
}
|
|
738
709
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
context.next = loc;
|
|
710
|
+
return {
|
|
711
|
+
next: doneResult
|
|
712
|
+
};
|
|
713
|
+
}
|
|
744
714
|
|
|
745
|
-
|
|
746
|
-
// If the dispatched exception was caught by a catch block,
|
|
747
|
-
// then let that catch block handle the exception normally.
|
|
748
|
-
context.method = "next";
|
|
749
|
-
context.arg = undefined$1;
|
|
750
|
-
}
|
|
715
|
+
exports.values = values;
|
|
751
716
|
|
|
752
|
-
|
|
753
|
-
|
|
717
|
+
function doneResult() {
|
|
718
|
+
return {
|
|
719
|
+
value: undefined$1,
|
|
720
|
+
done: true
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
Context.prototype = {
|
|
725
|
+
constructor: Context,
|
|
726
|
+
reset: function reset(skipTempReset) {
|
|
727
|
+
this.prev = 0;
|
|
728
|
+
this.next = 0; // Resetting context._sent for legacy support of Babel's
|
|
729
|
+
// function.sent implementation.
|
|
754
730
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
731
|
+
this.sent = this._sent = undefined$1;
|
|
732
|
+
this.done = false;
|
|
733
|
+
this.delegate = null;
|
|
734
|
+
this.method = "next";
|
|
735
|
+
this.arg = undefined$1;
|
|
736
|
+
this.tryEntries.forEach(resetTryEntry);
|
|
758
737
|
|
|
759
|
-
if (
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
738
|
+
if (!skipTempReset) {
|
|
739
|
+
for (var name in this) {
|
|
740
|
+
// Not sure about the optimal order of these conditions:
|
|
741
|
+
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
742
|
+
this[name] = undefined$1;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
764
745
|
}
|
|
746
|
+
},
|
|
747
|
+
stop: function stop() {
|
|
748
|
+
this.done = true;
|
|
749
|
+
var rootEntry = this.tryEntries[0];
|
|
750
|
+
var rootRecord = rootEntry.completion;
|
|
765
751
|
|
|
766
|
-
if (
|
|
767
|
-
|
|
768
|
-
|
|
752
|
+
if (rootRecord.type === "throw") {
|
|
753
|
+
throw rootRecord.arg;
|
|
754
|
+
}
|
|
769
755
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
756
|
+
return this.rval;
|
|
757
|
+
},
|
|
758
|
+
dispatchException: function dispatchException(exception) {
|
|
759
|
+
if (this.done) {
|
|
760
|
+
throw exception;
|
|
761
|
+
}
|
|
776
762
|
|
|
777
|
-
|
|
778
|
-
if (this.prev < entry.catchLoc) {
|
|
779
|
-
return handle(entry.catchLoc, true);
|
|
780
|
-
}
|
|
763
|
+
var context = this;
|
|
781
764
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
765
|
+
function handle(loc, caught) {
|
|
766
|
+
record.type = "throw";
|
|
767
|
+
record.arg = exception;
|
|
768
|
+
context.next = loc;
|
|
786
769
|
|
|
787
|
-
|
|
788
|
-
|
|
770
|
+
if (caught) {
|
|
771
|
+
// If the dispatched exception was caught by a catch block,
|
|
772
|
+
// then let that catch block handle the exception normally.
|
|
773
|
+
context.method = "next";
|
|
774
|
+
context.arg = undefined$1;
|
|
789
775
|
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
},
|
|
793
776
|
|
|
794
|
-
|
|
795
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
796
|
-
var entry = this.tryEntries[i];
|
|
797
|
-
if (entry.tryLoc <= this.prev &&
|
|
798
|
-
hasOwn.call(entry, "finallyLoc") &&
|
|
799
|
-
this.prev < entry.finallyLoc) {
|
|
800
|
-
var finallyEntry = entry;
|
|
801
|
-
break;
|
|
777
|
+
return !!caught;
|
|
802
778
|
}
|
|
803
|
-
}
|
|
804
779
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
finallyEntry.tryLoc <= arg &&
|
|
809
|
-
arg <= finallyEntry.finallyLoc) {
|
|
810
|
-
// Ignore the finally entry if control is not jumping to a
|
|
811
|
-
// location outside the try/catch block.
|
|
812
|
-
finallyEntry = null;
|
|
813
|
-
}
|
|
780
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
781
|
+
var entry = this.tryEntries[i];
|
|
782
|
+
var record = entry.completion;
|
|
814
783
|
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
784
|
+
if (entry.tryLoc === "root") {
|
|
785
|
+
// Exception thrown outside of any try block that could handle
|
|
786
|
+
// it, so set the completion value of the entire function to
|
|
787
|
+
// throw the exception.
|
|
788
|
+
return handle("end");
|
|
789
|
+
}
|
|
818
790
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
return ContinueSentinel;
|
|
823
|
-
}
|
|
791
|
+
if (entry.tryLoc <= this.prev) {
|
|
792
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
793
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
824
794
|
|
|
825
|
-
|
|
826
|
-
|
|
795
|
+
if (hasCatch && hasFinally) {
|
|
796
|
+
if (this.prev < entry.catchLoc) {
|
|
797
|
+
return handle(entry.catchLoc, true);
|
|
798
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
799
|
+
return handle(entry.finallyLoc);
|
|
800
|
+
}
|
|
801
|
+
} else if (hasCatch) {
|
|
802
|
+
if (this.prev < entry.catchLoc) {
|
|
803
|
+
return handle(entry.catchLoc, true);
|
|
804
|
+
}
|
|
805
|
+
} else if (hasFinally) {
|
|
806
|
+
if (this.prev < entry.finallyLoc) {
|
|
807
|
+
return handle(entry.finallyLoc);
|
|
808
|
+
}
|
|
809
|
+
} else {
|
|
810
|
+
throw new Error("try statement without catch or finally");
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
abrupt: function abrupt(type, arg) {
|
|
816
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
817
|
+
var entry = this.tryEntries[i];
|
|
827
818
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
819
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
820
|
+
var finallyEntry = entry;
|
|
821
|
+
break;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
832
824
|
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
this.method = "return";
|
|
839
|
-
this.next = "end";
|
|
840
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
841
|
-
this.next = afterLoc;
|
|
842
|
-
}
|
|
825
|
+
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
826
|
+
// Ignore the finally entry if control is not jumping to a
|
|
827
|
+
// location outside the try/catch block.
|
|
828
|
+
finallyEntry = null;
|
|
829
|
+
}
|
|
843
830
|
|
|
844
|
-
|
|
845
|
-
|
|
831
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
832
|
+
record.type = type;
|
|
833
|
+
record.arg = arg;
|
|
846
834
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
if (entry.finallyLoc === finallyLoc) {
|
|
851
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
852
|
-
resetTryEntry(entry);
|
|
835
|
+
if (finallyEntry) {
|
|
836
|
+
this.method = "next";
|
|
837
|
+
this.next = finallyEntry.finallyLoc;
|
|
853
838
|
return ContinueSentinel;
|
|
854
839
|
}
|
|
855
|
-
}
|
|
856
|
-
},
|
|
857
840
|
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
if (
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
841
|
+
return this.complete(record);
|
|
842
|
+
},
|
|
843
|
+
complete: function complete(record, afterLoc) {
|
|
844
|
+
if (record.type === "throw") {
|
|
845
|
+
throw record.arg;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
if (record.type === "break" || record.type === "continue") {
|
|
849
|
+
this.next = record.arg;
|
|
850
|
+
} else if (record.type === "return") {
|
|
851
|
+
this.rval = this.arg = record.arg;
|
|
852
|
+
this.method = "return";
|
|
853
|
+
this.next = "end";
|
|
854
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
855
|
+
this.next = afterLoc;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
return ContinueSentinel;
|
|
859
|
+
},
|
|
860
|
+
finish: function finish(finallyLoc) {
|
|
861
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
862
|
+
var entry = this.tryEntries[i];
|
|
863
|
+
|
|
864
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
865
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
865
866
|
resetTryEntry(entry);
|
|
867
|
+
return ContinueSentinel;
|
|
866
868
|
}
|
|
867
|
-
return thrown;
|
|
868
869
|
}
|
|
869
|
-
}
|
|
870
|
+
},
|
|
871
|
+
"catch": function _catch(tryLoc) {
|
|
872
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
873
|
+
var entry = this.tryEntries[i];
|
|
870
874
|
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
throw new Error("illegal catch attempt");
|
|
874
|
-
},
|
|
875
|
+
if (entry.tryLoc === tryLoc) {
|
|
876
|
+
var record = entry.completion;
|
|
875
877
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
nextLoc: nextLoc
|
|
881
|
-
};
|
|
878
|
+
if (record.type === "throw") {
|
|
879
|
+
var thrown = record.arg;
|
|
880
|
+
resetTryEntry(entry);
|
|
881
|
+
}
|
|
882
882
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
//
|
|
886
|
-
|
|
887
|
-
}
|
|
883
|
+
return thrown;
|
|
884
|
+
}
|
|
885
|
+
} // The context.catch method must only be called with a location
|
|
886
|
+
// argument that corresponds to a known catch block.
|
|
888
887
|
|
|
889
|
-
return ContinueSentinel;
|
|
890
|
-
}
|
|
891
|
-
};
|
|
892
888
|
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
889
|
+
throw new Error("illegal catch attempt");
|
|
890
|
+
},
|
|
891
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
892
|
+
this.delegate = {
|
|
893
|
+
iterator: values(iterable),
|
|
894
|
+
resultName: resultName,
|
|
895
|
+
nextLoc: nextLoc
|
|
896
|
+
};
|
|
897
|
+
|
|
898
|
+
if (this.method === "next") {
|
|
899
|
+
// Deliberately forget the last sent value so that we don't
|
|
900
|
+
// accidentally pass it on to the delegate.
|
|
901
|
+
this.arg = undefined$1;
|
|
902
|
+
}
|
|
898
903
|
|
|
899
|
-
|
|
900
|
-
|
|
904
|
+
return ContinueSentinel;
|
|
905
|
+
}
|
|
906
|
+
}; // Regardless of whether this script is executing as a CommonJS module
|
|
907
|
+
// or not, return the runtime object so that we can declare the variable
|
|
908
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
909
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
910
|
+
|
|
911
|
+
return exports;
|
|
912
|
+
}( // If this script is executing as a CommonJS module, use module.exports
|
|
901
913
|
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
902
914
|
// object. Either way, the resulting object will be used to initialize
|
|
903
915
|
// the regeneratorRuntime variable at the top of this file.
|
|
904
|
-
module.exports
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
919
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
920
|
-
if (typeof globalThis === "object") {
|
|
921
|
-
globalThis.regeneratorRuntime = runtime;
|
|
922
|
-
} else {
|
|
916
|
+
module.exports );
|
|
917
|
+
|
|
918
|
+
try {
|
|
919
|
+
regeneratorRuntime = runtime;
|
|
920
|
+
} catch (accidentalStrictMode) {
|
|
921
|
+
// This module should not be running in strict mode, so the above
|
|
922
|
+
// assignment should always work unless something is misconfigured. Just
|
|
923
|
+
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
924
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
925
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
926
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
927
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
928
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
929
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
923
930
|
Function("r", "regeneratorRuntime = r")(runtime);
|
|
924
931
|
}
|
|
925
|
-
}
|
|
926
932
|
});
|
|
927
933
|
|
|
928
934
|
var ProductContext = /*#__PURE__*/React.createContext(undefined);
|
|
@@ -1208,10 +1214,9 @@ var addToCartButtonMeta = {
|
|
|
1208
1214
|
}]
|
|
1209
1215
|
}
|
|
1210
1216
|
},
|
|
1211
|
-
importPath: "
|
|
1217
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1212
1218
|
importName: "AddToCartButton"
|
|
1213
1219
|
};
|
|
1214
|
-
|
|
1215
1220
|
function AddToCartButton(props) {
|
|
1216
1221
|
var children = props.children;
|
|
1217
1222
|
var product = useProduct();
|
|
@@ -1222,12 +1227,13 @@ function AddToCartButton(props) {
|
|
|
1222
1227
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1223
1228
|
var _form$getValues$Produ;
|
|
1224
1229
|
|
|
1225
|
-
var quantity, variantId;
|
|
1230
|
+
var quantity, _form$getValues$Produ2, variantId;
|
|
1231
|
+
|
|
1226
1232
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1227
1233
|
while (1) {
|
|
1228
1234
|
switch (_context.prev = _context.next) {
|
|
1229
1235
|
case 0:
|
|
1230
|
-
quantity = (_form$getValues$Produ =
|
|
1236
|
+
quantity = +((_form$getValues$Produ = form.getValues()["ProductQuantity"]) != null ? _form$getValues$Produ : 1);
|
|
1231
1237
|
|
|
1232
1238
|
if (!(isNaN(quantity) || quantity < 1)) {
|
|
1233
1239
|
_context.next = 3;
|
|
@@ -1244,7 +1250,7 @@ function AddToCartButton(props) {
|
|
|
1244
1250
|
break;
|
|
1245
1251
|
}
|
|
1246
1252
|
|
|
1247
|
-
variantId = form.getValues()["ProductVariant"];
|
|
1253
|
+
variantId = (_form$getValues$Produ2 = form.getValues()["ProductVariant"]) != null ? _form$getValues$Produ2 : product.variants[0].id;
|
|
1248
1254
|
_context.next = 7;
|
|
1249
1255
|
return addItem({
|
|
1250
1256
|
productId: product.id,
|
|
@@ -1275,7 +1281,6 @@ function AddToCartButton(props) {
|
|
|
1275
1281
|
}
|
|
1276
1282
|
}) : null;
|
|
1277
1283
|
}
|
|
1278
|
-
|
|
1279
1284
|
function registerAddToCartButton(loader, customAddToCartButtonMeta) {
|
|
1280
1285
|
var doRegisterComponent = function doRegisterComponent() {
|
|
1281
1286
|
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
@@ -1289,16 +1294,148 @@ var fetcher$1 = SWRFetcher;
|
|
|
1289
1294
|
var fn$1 = function fn(provider) {
|
|
1290
1295
|
var _provider$products;
|
|
1291
1296
|
|
|
1292
|
-
return (_provider$products = provider.products) == null ? void 0 : _provider$products.
|
|
1297
|
+
return (_provider$products = provider.products) == null ? void 0 : _provider$products.useProduct;
|
|
1293
1298
|
};
|
|
1294
1299
|
|
|
1295
|
-
var
|
|
1300
|
+
var useProduct$1 = function useProduct(input) {
|
|
1296
1301
|
var hook = useHook(fn$1);
|
|
1297
1302
|
return useSWRHook(_extends({
|
|
1298
1303
|
fetcher: fetcher$1
|
|
1299
1304
|
}, hook))(input);
|
|
1300
1305
|
};
|
|
1301
1306
|
|
|
1307
|
+
var productBoxMeta = {
|
|
1308
|
+
name: "plasmic-commerce-product-box",
|
|
1309
|
+
displayName: "Product Box",
|
|
1310
|
+
props: {
|
|
1311
|
+
children: {
|
|
1312
|
+
type: "slot",
|
|
1313
|
+
defaultValue: [{
|
|
1314
|
+
type: "vbox",
|
|
1315
|
+
children: [{
|
|
1316
|
+
type: "component",
|
|
1317
|
+
name: "plasmic-commerce-product-text-field",
|
|
1318
|
+
props: {
|
|
1319
|
+
field: "name"
|
|
1320
|
+
}
|
|
1321
|
+
}, {
|
|
1322
|
+
type: "component",
|
|
1323
|
+
name: "plasmic-commerce-product-media"
|
|
1324
|
+
}],
|
|
1325
|
+
styles: {
|
|
1326
|
+
width: "100%",
|
|
1327
|
+
minWidth: 0
|
|
1328
|
+
}
|
|
1329
|
+
}]
|
|
1330
|
+
},
|
|
1331
|
+
noLayout: "boolean",
|
|
1332
|
+
id: {
|
|
1333
|
+
type: "string",
|
|
1334
|
+
description: "Fetch a product by its slug or ID"
|
|
1335
|
+
}
|
|
1336
|
+
},
|
|
1337
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1338
|
+
importName: "ProductBox"
|
|
1339
|
+
};
|
|
1340
|
+
function ProductBox(props) {
|
|
1341
|
+
var className = props.className,
|
|
1342
|
+
children = props.children,
|
|
1343
|
+
noLayout = props.noLayout,
|
|
1344
|
+
id = props.id;
|
|
1345
|
+
|
|
1346
|
+
var _useProduct = useProduct$1({
|
|
1347
|
+
id: id
|
|
1348
|
+
}),
|
|
1349
|
+
data = _useProduct.data,
|
|
1350
|
+
error = _useProduct.error,
|
|
1351
|
+
isLoading = _useProduct.isLoading;
|
|
1352
|
+
|
|
1353
|
+
if (!id) {
|
|
1354
|
+
return React.createElement("span", null, "You must set the id prop");
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
if (error) {
|
|
1358
|
+
throw new CommerceError({
|
|
1359
|
+
message: error.message,
|
|
1360
|
+
code: error.code
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
if (isLoading) {
|
|
1365
|
+
return React.createElement("span", null, "Loading...");
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
if (!data) {
|
|
1369
|
+
throw new Error("Product not found!");
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
var renderedData = React.createElement(ProductProvider, {
|
|
1373
|
+
product: data
|
|
1374
|
+
}, children);
|
|
1375
|
+
return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
|
|
1376
|
+
className: className
|
|
1377
|
+
}, renderedData);
|
|
1378
|
+
}
|
|
1379
|
+
function registerProductBox(loader, customProductBoxMeta) {
|
|
1380
|
+
var doRegisterComponent = function doRegisterComponent() {
|
|
1381
|
+
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
1382
|
+
};
|
|
1383
|
+
|
|
1384
|
+
doRegisterComponent(ProductBox, customProductBoxMeta != null ? customProductBoxMeta : productBoxMeta);
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
var fetcher$2 = SWRFetcher;
|
|
1388
|
+
|
|
1389
|
+
var fn$2 = function fn(provider) {
|
|
1390
|
+
var _provider$products;
|
|
1391
|
+
|
|
1392
|
+
return (_provider$products = provider.products) == null ? void 0 : _provider$products.useSearch;
|
|
1393
|
+
};
|
|
1394
|
+
|
|
1395
|
+
var useSearch = function useSearch(input) {
|
|
1396
|
+
var hook = useHook(fn$2);
|
|
1397
|
+
return useSWRHook(_extends({
|
|
1398
|
+
fetcher: fetcher$2
|
|
1399
|
+
}, hook))(input);
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
var fetcher$3 = SWRFetcher;
|
|
1403
|
+
|
|
1404
|
+
var fn$3 = function fn(provider) {
|
|
1405
|
+
var _provider$site;
|
|
1406
|
+
|
|
1407
|
+
return (_provider$site = provider.site) == null ? void 0 : _provider$site.useCategories;
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1410
|
+
var useCategories = function useCategories(input) {
|
|
1411
|
+
var hook = useHook(fn$3);
|
|
1412
|
+
return useSWRHook(_extends({
|
|
1413
|
+
fetcher: fetcher$3
|
|
1414
|
+
}, hook))(input);
|
|
1415
|
+
};
|
|
1416
|
+
|
|
1417
|
+
var fetcher$4 = SWRFetcher;
|
|
1418
|
+
|
|
1419
|
+
var fn$4 = function fn(provider) {
|
|
1420
|
+
var _provider$site;
|
|
1421
|
+
|
|
1422
|
+
return (_provider$site = provider.site) == null ? void 0 : _provider$site.useBrands;
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
var useBrands = function useBrands(input) {
|
|
1426
|
+
var hook = useHook(fn$4);
|
|
1427
|
+
return useSWRHook(_extends({
|
|
1428
|
+
fetcher: fetcher$4
|
|
1429
|
+
}, hook))(input);
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1432
|
+
var useCommerceExtraFeatures = function useCommerceExtraFeatures() {
|
|
1433
|
+
var _useCommerce = useCommerce(),
|
|
1434
|
+
providerRef = _useCommerce.providerRef;
|
|
1435
|
+
|
|
1436
|
+
return providerRef.current.extraFeatures;
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1302
1439
|
var productCollectionMeta = {
|
|
1303
1440
|
name: "plasmic-commerce-product-collection",
|
|
1304
1441
|
displayName: "Product Collection",
|
|
@@ -1337,6 +1474,14 @@ var productCollectionMeta = {
|
|
|
1337
1474
|
})) != null ? _ctx$categories$map : [];
|
|
1338
1475
|
}
|
|
1339
1476
|
},
|
|
1477
|
+
includeSubCategories: {
|
|
1478
|
+
type: "boolean",
|
|
1479
|
+
hidden: function hidden(props, ctx) {
|
|
1480
|
+
var _ctx$features;
|
|
1481
|
+
|
|
1482
|
+
return !(ctx != null && (_ctx$features = ctx.features) != null && _ctx$features.includeSubCategories);
|
|
1483
|
+
}
|
|
1484
|
+
},
|
|
1340
1485
|
brand: {
|
|
1341
1486
|
type: "choice",
|
|
1342
1487
|
options: function options(props, ctx) {
|
|
@@ -1349,7 +1494,8 @@ var productCollectionMeta = {
|
|
|
1349
1494
|
};
|
|
1350
1495
|
})) != null ? _ctx$brands$map : [];
|
|
1351
1496
|
}
|
|
1352
|
-
}
|
|
1497
|
+
},
|
|
1498
|
+
noLayout: "boolean"
|
|
1353
1499
|
},
|
|
1354
1500
|
defaultStyles: {
|
|
1355
1501
|
display: "grid",
|
|
@@ -1359,48 +1505,54 @@ var productCollectionMeta = {
|
|
|
1359
1505
|
padding: "8px",
|
|
1360
1506
|
maxWidth: "100%"
|
|
1361
1507
|
},
|
|
1362
|
-
importPath: "
|
|
1508
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1363
1509
|
importName: "ProductCollection"
|
|
1364
1510
|
};
|
|
1365
|
-
|
|
1366
1511
|
function ProductCollection(props) {
|
|
1367
1512
|
var className = props.className,
|
|
1368
1513
|
children = props.children,
|
|
1369
1514
|
count = props.count,
|
|
1370
1515
|
category = props.category,
|
|
1516
|
+
includeSubCategories = props.includeSubCategories,
|
|
1371
1517
|
brand = props.brand,
|
|
1518
|
+
noLayout = props.noLayout,
|
|
1372
1519
|
setControlContextData = props.setControlContextData;
|
|
1373
1520
|
|
|
1521
|
+
var _useCategories = useCategories(),
|
|
1522
|
+
categories = _useCategories.data;
|
|
1523
|
+
|
|
1524
|
+
var _useBrands = useBrands(),
|
|
1525
|
+
brands = _useBrands.data;
|
|
1526
|
+
|
|
1374
1527
|
var _useSearch = useSearch({
|
|
1375
1528
|
categoryId: category,
|
|
1376
1529
|
brandId: brand,
|
|
1377
|
-
count: count
|
|
1530
|
+
count: count,
|
|
1531
|
+
categories: categories != null ? categories : [],
|
|
1532
|
+
includeSubCategories: includeSubCategories
|
|
1378
1533
|
}),
|
|
1379
1534
|
data = _useSearch.data;
|
|
1380
1535
|
|
|
1381
|
-
var
|
|
1382
|
-
categories = _useCategories.data;
|
|
1383
|
-
|
|
1384
|
-
var _useBrands = useBrands({}),
|
|
1385
|
-
brands = _useBrands.data;
|
|
1536
|
+
var features = useCommerceExtraFeatures();
|
|
1386
1537
|
|
|
1387
1538
|
if (categories && brands) {
|
|
1388
1539
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1389
1540
|
categories: categories,
|
|
1390
|
-
brands: brands
|
|
1541
|
+
brands: brands,
|
|
1542
|
+
features: features
|
|
1391
1543
|
});
|
|
1392
1544
|
}
|
|
1393
1545
|
|
|
1394
|
-
|
|
1395
|
-
className: className
|
|
1396
|
-
}, data == null ? void 0 : data.products.map(function (product, i) {
|
|
1546
|
+
var renderedData = data == null ? void 0 : data.products.map(function (product, i) {
|
|
1397
1547
|
return React.createElement(ProductProvider, {
|
|
1398
1548
|
product: product,
|
|
1399
1549
|
key: product.id
|
|
1400
1550
|
}, repeatedElement(i === 0, children));
|
|
1401
|
-
})
|
|
1551
|
+
});
|
|
1552
|
+
return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
|
|
1553
|
+
className: className
|
|
1554
|
+
}, renderedData);
|
|
1402
1555
|
}
|
|
1403
|
-
|
|
1404
1556
|
function registerProductCollection(loader, customProductCollectionMeta) {
|
|
1405
1557
|
var doRegisterComponent = function doRegisterComponent() {
|
|
1406
1558
|
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
@@ -1409,6 +1561,69 @@ function registerProductCollection(loader, customProductCollectionMeta) {
|
|
|
1409
1561
|
doRegisterComponent(ProductCollection, customProductCollectionMeta != null ? customProductCollectionMeta : productCollectionMeta);
|
|
1410
1562
|
}
|
|
1411
1563
|
|
|
1564
|
+
var productLinkMeta = {
|
|
1565
|
+
name: "plasmic-commerce-product-link",
|
|
1566
|
+
displayName: "Product Link",
|
|
1567
|
+
props: {
|
|
1568
|
+
children: "slot",
|
|
1569
|
+
linkDest: {
|
|
1570
|
+
type: "string",
|
|
1571
|
+
defaultValueHint: "products/{slug}",
|
|
1572
|
+
description: "Set the link destination. You can use {slug} to replace by the product slug"
|
|
1573
|
+
}
|
|
1574
|
+
},
|
|
1575
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1576
|
+
importName: "ProductLink"
|
|
1577
|
+
};
|
|
1578
|
+
function ProductLink(props) {
|
|
1579
|
+
var className = props.className,
|
|
1580
|
+
children = props.children,
|
|
1581
|
+
linkDest = props.linkDest;
|
|
1582
|
+
var product = useProduct();
|
|
1583
|
+
|
|
1584
|
+
var resolveLink = function resolveLink(linkDest) {
|
|
1585
|
+
var _linkDest$match;
|
|
1586
|
+
|
|
1587
|
+
if (!product || !linkDest) {
|
|
1588
|
+
return undefined;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
var regex = /{[^}]*}/;
|
|
1592
|
+
var regexAll = new RegExp(regex, "g");
|
|
1593
|
+
var matches = (_linkDest$match = linkDest.match(regexAll)) != null ? _linkDest$match : [];
|
|
1594
|
+
var resolvedLink = linkDest;
|
|
1595
|
+
|
|
1596
|
+
for (var _iterator = _createForOfIteratorHelperLoose(matches), _step; !(_step = _iterator()).done;) {
|
|
1597
|
+
var match = _step.value;
|
|
1598
|
+
var field = match.slice(1, -1);
|
|
1599
|
+
|
|
1600
|
+
if (!(field in product)) {
|
|
1601
|
+
return undefined;
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
resolvedLink = resolvedLink.replace(regex, product[field]);
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
return resolvedLink;
|
|
1608
|
+
};
|
|
1609
|
+
|
|
1610
|
+
return React.createElement("a", {
|
|
1611
|
+
className: className,
|
|
1612
|
+
href: resolveLink(linkDest),
|
|
1613
|
+
style: {
|
|
1614
|
+
color: "inherit",
|
|
1615
|
+
textDecoration: "inherit"
|
|
1616
|
+
}
|
|
1617
|
+
}, children);
|
|
1618
|
+
}
|
|
1619
|
+
function registerProductLink(loader, customProductLinkMeta) {
|
|
1620
|
+
var doRegisterComponent = function doRegisterComponent() {
|
|
1621
|
+
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
1622
|
+
};
|
|
1623
|
+
|
|
1624
|
+
doRegisterComponent(ProductLink, customProductLinkMeta != null ? customProductLinkMeta : productLinkMeta);
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1412
1627
|
var placeholderImage = "https://static1.plasmic.app/commerce/lightweight-jacket-0.png";
|
|
1413
1628
|
var productMediaMeta = {
|
|
1414
1629
|
name: "plasmic-commerce-product-media",
|
|
@@ -1416,7 +1631,7 @@ var productMediaMeta = {
|
|
|
1416
1631
|
props: {
|
|
1417
1632
|
mediaIndex: "number"
|
|
1418
1633
|
},
|
|
1419
|
-
importPath: "
|
|
1634
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1420
1635
|
importName: "ProductMedia"
|
|
1421
1636
|
};
|
|
1422
1637
|
function ProductMedia(props) {
|
|
@@ -1521,10 +1736,10 @@ var productPriceMeta = {
|
|
|
1521
1736
|
name: "plasmic-commerce-product-price",
|
|
1522
1737
|
displayName: "Product Price",
|
|
1523
1738
|
props: {},
|
|
1524
|
-
importPath: "
|
|
1739
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1525
1740
|
importName: "ProductPrice"
|
|
1526
1741
|
};
|
|
1527
|
-
function
|
|
1742
|
+
function ProductPriceComponent(props) {
|
|
1528
1743
|
var className = props.className;
|
|
1529
1744
|
var product = useProduct();
|
|
1530
1745
|
var form = useFormContext();
|
|
@@ -1550,7 +1765,7 @@ function registerProductPrice(loader, customProductPriceMeta) {
|
|
|
1550
1765
|
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
1551
1766
|
};
|
|
1552
1767
|
|
|
1553
|
-
doRegisterComponent(
|
|
1768
|
+
doRegisterComponent(ProductPriceComponent, customProductPriceMeta != null ? customProductPriceMeta : productPriceMeta);
|
|
1554
1769
|
}
|
|
1555
1770
|
|
|
1556
1771
|
var productQuantityMeta = {
|
|
@@ -1567,7 +1782,7 @@ var productQuantityMeta = {
|
|
|
1567
1782
|
}]
|
|
1568
1783
|
}
|
|
1569
1784
|
},
|
|
1570
|
-
importPath: "
|
|
1785
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1571
1786
|
importName: "ProductQuantity"
|
|
1572
1787
|
};
|
|
1573
1788
|
function ProductQuantity(props) {
|
|
@@ -1605,7 +1820,7 @@ var productTextFieldMeta = {
|
|
|
1605
1820
|
options: ["id", "name", "description", "sku", "slug", "path"]
|
|
1606
1821
|
}
|
|
1607
1822
|
},
|
|
1608
|
-
importPath: "
|
|
1823
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1609
1824
|
importName: "ProductTextField"
|
|
1610
1825
|
};
|
|
1611
1826
|
function ProductTextField(props) {
|
|
@@ -1656,7 +1871,7 @@ var productVariantPickerMeta = {
|
|
|
1656
1871
|
name: "plasmic-commerce-product-variant-picker",
|
|
1657
1872
|
displayName: "Product Variant Picker",
|
|
1658
1873
|
props: {},
|
|
1659
|
-
importPath: "
|
|
1874
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1660
1875
|
importName: "ProductVariantPicker"
|
|
1661
1876
|
};
|
|
1662
1877
|
function ProductVariantPicker(props) {
|
|
@@ -1689,7 +1904,7 @@ function registerProductVariantPicker(loader, customProductVariantPickerMeta) {
|
|
|
1689
1904
|
doRegisterComponent(ProductVariantPicker, customProductVariantPickerMeta != null ? customProductVariantPickerMeta : productVariantPickerMeta);
|
|
1690
1905
|
}
|
|
1691
1906
|
|
|
1692
|
-
var fetcher$
|
|
1907
|
+
var fetcher$5 = /*#__PURE__*/function () {
|
|
1693
1908
|
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
|
|
1694
1909
|
var options, cartId, fetch;
|
|
1695
1910
|
return runtime_1.wrap(function _callee$(_context) {
|
|
@@ -1730,7 +1945,7 @@ var fetcher$2 = /*#__PURE__*/function () {
|
|
|
1730
1945
|
};
|
|
1731
1946
|
}();
|
|
1732
1947
|
|
|
1733
|
-
var fn$
|
|
1948
|
+
var fn$5 = function fn(provider) {
|
|
1734
1949
|
var _provider$cart;
|
|
1735
1950
|
|
|
1736
1951
|
return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useCart;
|
|
@@ -1739,12 +1954,12 @@ var fn$2 = function fn(provider) {
|
|
|
1739
1954
|
var useCart = function useCart(input) {
|
|
1740
1955
|
var _hook$fetcher;
|
|
1741
1956
|
|
|
1742
|
-
var hook = useHook(fn$
|
|
1957
|
+
var hook = useHook(fn$5);
|
|
1743
1958
|
|
|
1744
1959
|
var _useCommerce = useCommerce(),
|
|
1745
1960
|
cartCookie = _useCommerce.cartCookie;
|
|
1746
1961
|
|
|
1747
|
-
var fetcherFn = (_hook$fetcher = hook.fetcher) != null ? _hook$fetcher : fetcher$
|
|
1962
|
+
var fetcherFn = (_hook$fetcher = hook.fetcher) != null ? _hook$fetcher : fetcher$5;
|
|
1748
1963
|
|
|
1749
1964
|
var wrapper = function wrapper(context) {
|
|
1750
1965
|
context.input.cartId = Cookies.get(cartCookie);
|
|
@@ -1756,20 +1971,19 @@ var useCart = function useCart(input) {
|
|
|
1756
1971
|
}))(input);
|
|
1757
1972
|
};
|
|
1758
1973
|
|
|
1759
|
-
var
|
|
1760
|
-
name: "plasmic-commerce-
|
|
1761
|
-
displayName: "
|
|
1974
|
+
var cartMeta = {
|
|
1975
|
+
name: "plasmic-commerce-cart",
|
|
1976
|
+
displayName: "Cart",
|
|
1762
1977
|
props: {
|
|
1763
1978
|
field: {
|
|
1764
1979
|
type: "choice",
|
|
1765
1980
|
options: ["Size", "Total Price"]
|
|
1766
1981
|
}
|
|
1767
1982
|
},
|
|
1768
|
-
importPath: "
|
|
1769
|
-
importName: "
|
|
1983
|
+
importPath: "@plasmicpkgs/commerce",
|
|
1984
|
+
importName: "Cart"
|
|
1770
1985
|
};
|
|
1771
|
-
|
|
1772
|
-
function UseCartComponent(props) {
|
|
1986
|
+
function CartComponent(props) {
|
|
1773
1987
|
var _data$totalPrice, _data$currency$code;
|
|
1774
1988
|
|
|
1775
1989
|
var className = props.className,
|
|
@@ -1802,82 +2016,47 @@ function UseCartComponent(props) {
|
|
|
1802
2016
|
className: className
|
|
1803
2017
|
}, value);
|
|
1804
2018
|
}
|
|
1805
|
-
|
|
1806
|
-
function registerUseCart(loader, customUseCartMeta) {
|
|
2019
|
+
function registerCart(loader, customCartMeta) {
|
|
1807
2020
|
var doRegisterComponent = function doRegisterComponent() {
|
|
1808
2021
|
return loader ? loader.registerComponent.apply(loader, arguments) : registerComponent.apply(void 0, arguments);
|
|
1809
2022
|
};
|
|
1810
2023
|
|
|
1811
|
-
doRegisterComponent(
|
|
2024
|
+
doRegisterComponent(CartComponent, customCartMeta != null ? customCartMeta : cartMeta);
|
|
1812
2025
|
}
|
|
1813
2026
|
|
|
1814
|
-
var x = function x() {
|
|
1815
|
-
return 2;
|
|
1816
|
-
};
|
|
1817
|
-
|
|
1818
2027
|
|
|
1819
2028
|
|
|
1820
2029
|
var product = {
|
|
1821
2030
|
__proto__: null
|
|
1822
2031
|
};
|
|
1823
2032
|
|
|
1824
|
-
var fetcher$
|
|
1825
|
-
|
|
1826
|
-
var fn$3 = function fn(provider) {
|
|
1827
|
-
var _provider$site;
|
|
1828
|
-
|
|
1829
|
-
return (_provider$site = provider.site) == null ? void 0 : _provider$site.useCategories;
|
|
1830
|
-
};
|
|
1831
|
-
|
|
1832
|
-
var useCategories = function useCategories(input) {
|
|
1833
|
-
var hook = useHook(fn$3);
|
|
1834
|
-
return useSWRHook(_extends({
|
|
1835
|
-
fetcher: fetcher$3
|
|
1836
|
-
}, hook))(input);
|
|
1837
|
-
};
|
|
1838
|
-
|
|
1839
|
-
var fetcher$4 = SWRFetcher;
|
|
1840
|
-
|
|
1841
|
-
var fn$4 = function fn(provider) {
|
|
1842
|
-
var _provider$site;
|
|
1843
|
-
|
|
1844
|
-
return (_provider$site = provider.site) == null ? void 0 : _provider$site.useBrands;
|
|
1845
|
-
};
|
|
1846
|
-
|
|
1847
|
-
var useBrands = function useBrands(input) {
|
|
1848
|
-
var hook = useHook(fn$4);
|
|
1849
|
-
return useSWRHook(_extends({
|
|
1850
|
-
fetcher: fetcher$4
|
|
1851
|
-
}, hook))(input);
|
|
1852
|
-
};
|
|
1853
|
-
|
|
1854
|
-
var fetcher$5 = mutationFetcher;
|
|
2033
|
+
var fetcher$6 = mutationFetcher;
|
|
1855
2034
|
|
|
1856
|
-
var fn$
|
|
2035
|
+
var fn$6 = function fn(provider) {
|
|
1857
2036
|
var _provider$cart;
|
|
1858
2037
|
|
|
1859
2038
|
return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useRemoveItem;
|
|
1860
2039
|
};
|
|
1861
2040
|
|
|
1862
2041
|
var useRemoveItem = function useRemoveItem(input) {
|
|
1863
|
-
var hook = useHook(fn$
|
|
2042
|
+
var hook = useHook(fn$6);
|
|
1864
2043
|
return useMutationHook(_extends({
|
|
1865
|
-
fetcher: fetcher$
|
|
2044
|
+
fetcher: fetcher$6
|
|
1866
2045
|
}, hook))(input);
|
|
1867
2046
|
};
|
|
1868
2047
|
|
|
1869
|
-
var fetcher$
|
|
2048
|
+
var fetcher$7 = mutationFetcher;
|
|
1870
2049
|
|
|
1871
|
-
var fn$
|
|
2050
|
+
var fn$7 = function fn(provider) {
|
|
1872
2051
|
var _provider$cart;
|
|
1873
2052
|
|
|
1874
2053
|
return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useUpdateItem;
|
|
1875
2054
|
};
|
|
1876
2055
|
|
|
1877
2056
|
var useUpdateItem = function useUpdateItem(input) {
|
|
1878
|
-
var hook = useHook(fn$
|
|
2057
|
+
var hook = useHook(fn$7);
|
|
1879
2058
|
return useMutationHook(_extends({
|
|
1880
|
-
fetcher: fetcher$
|
|
2059
|
+
fetcher: fetcher$7
|
|
1881
2060
|
}, hook))(input);
|
|
1882
2061
|
};
|
|
1883
2062
|
|
|
@@ -1898,11 +2077,13 @@ function registerAll(loader) {
|
|
|
1898
2077
|
registerTextField(loader);
|
|
1899
2078
|
registerProductPrice(loader);
|
|
1900
2079
|
registerProductMedia(loader);
|
|
1901
|
-
|
|
2080
|
+
registerCart(loader);
|
|
1902
2081
|
registerAddToCartButton(loader);
|
|
1903
2082
|
registerProductQuantity(loader);
|
|
1904
2083
|
registerProductVariantPicker(loader);
|
|
2084
|
+
registerProductBox(loader);
|
|
2085
|
+
registerProductLink(loader);
|
|
1905
2086
|
}
|
|
1906
2087
|
|
|
1907
|
-
export { cart as CartType, CommerceError, CoreCommerceProvider, FetcherError, product as ProductTypes, site as SiteTypes, ValidationError, fetcher$
|
|
2088
|
+
export { AddToCartButton, CartComponent, cart as CartType, CommerceError, CoreCommerceProvider, FetcherError, ProductBox, ProductCollection, ProductLink, ProductMedia, ProductPriceComponent, ProductQuantity, ProductTextField, product as ProductTypes, ProductVariantPicker, site as SiteTypes, ValidationError, addToCartButtonMeta, cartMeta, fetcher$2 as fetcher, getCommerceProvider, productBoxMeta, productCollectionMeta, productLinkMeta, productMediaMeta, productPriceMeta, productQuantityMeta, productTextFieldMeta, productVariantPickerMeta, registerAddToCartButton, registerAll, registerCart, registerProductBox, registerProductCollection, registerProductLink, registerProductMedia, registerProductPrice, registerProductQuantity, registerProductVariantPicker, registerTextField, useAddItem, useBrands, useCart, useCategories, useCommerce, useProduct$1 as useProduct, useRemoveItem, useSearch, useUpdateItem };
|
|
1908
2089
|
//# sourceMappingURL=commerce.esm.js.map
|