@plasmicpkgs/commerce 0.0.2 → 0.0.6

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.
@@ -169,200 +169,198 @@ function createCommonjsModule(fn, module) {
169
169
  return module = { exports: {} }, fn(module, module.exports), module.exports;
170
170
  }
171
171
 
172
- var runtime_1 = createCommonjsModule(function (module) {
173
- /**
174
- * Copyright (c) 2014-present, Facebook, Inc.
175
- *
176
- * This source code is licensed under the MIT license found in the
177
- * LICENSE file in the root directory of this source tree.
178
- */
179
-
180
- var runtime = (function (exports) {
181
-
182
- var Op = Object.prototype;
183
- var hasOwn = Op.hasOwnProperty;
184
- var undefined$1; // More compressible than void 0.
185
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
186
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
187
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
188
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
189
-
190
- function define(obj, key, value) {
191
- Object.defineProperty(obj, key, {
192
- value: value,
193
- enumerable: true,
194
- configurable: true,
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;
205
- };
206
- }
207
-
208
- function wrap(innerFn, outerFn, self, tryLocsList) {
209
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
210
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
211
- var generator = Object.create(protoGenerator.prototype);
212
- var context = new Context(tryLocsList || []);
213
-
214
- // The ._invoke method unifies the implementations of the .next,
215
- // .throw, and .return methods.
216
- generator._invoke = makeInvokeMethod(innerFn, self, context);
172
+ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
173
+ /**
174
+ * Copyright (c) 2014-present, Facebook, Inc.
175
+ *
176
+ * This source code is licensed under the MIT license found in the
177
+ * LICENSE file in the root directory of this source tree.
178
+ */
179
+ var runtime = function (exports) {
180
+
181
+ var Op = Object.prototype;
182
+ var hasOwn = Op.hasOwnProperty;
183
+ var undefined$1; // More compressible than void 0.
184
+
185
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
186
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
187
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
188
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
189
+
190
+ function define(obj, key, value) {
191
+ Object.defineProperty(obj, key, {
192
+ value: value,
193
+ enumerable: true,
194
+ configurable: true,
195
+ writable: true
196
+ });
197
+ return obj[key];
198
+ }
217
199
 
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
200
  try {
234
- return { type: "normal", arg: fn.call(obj, arg) };
201
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
202
+ define({}, "");
235
203
  } catch (err) {
236
- return { type: "throw", arg: err };
204
+ define = function define(obj, key, value) {
205
+ return obj[key] = value;
206
+ };
237
207
  }
238
- }
239
208
 
240
- var GenStateSuspendedStart = "suspendedStart";
241
- var GenStateSuspendedYield = "suspendedYield";
242
- var GenStateExecuting = "executing";
243
- var GenStateCompleted = "completed";
244
-
245
- // Returning this object from the innerFn has the same effect as
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
- IteratorPrototype[iteratorSymbol] = function () {
261
- return this;
262
- };
209
+ function wrap(innerFn, outerFn, self, tryLocsList) {
210
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
211
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
212
+ var generator = Object.create(protoGenerator.prototype);
213
+ var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
214
+ // .throw, and .return methods.
263
215
 
264
- var getProto = Object.getPrototypeOf;
265
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
266
- if (NativeIteratorPrototype &&
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
- }
216
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
217
+ return generator;
218
+ }
273
219
 
274
- var Gp = GeneratorFunctionPrototype.prototype =
275
- Generator.prototype = Object.create(IteratorPrototype);
276
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
277
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
278
- GeneratorFunction.displayName = define(
279
- GeneratorFunctionPrototype,
280
- toStringTagSymbol,
281
- "GeneratorFunction"
282
- );
283
-
284
- // Helper for defining the .next, .throw, and .return methods of the
285
- // Iterator interface in terms of a single ._invoke method.
286
- function defineIteratorMethods(prototype) {
287
- ["next", "throw", "return"].forEach(function(method) {
288
- define(prototype, method, function(arg) {
289
- return this._invoke(method, arg);
290
- });
291
- });
292
- }
220
+ exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
221
+ // record like context.tryEntries[i].completion. This interface could
222
+ // have been (and was previously) designed to take a closure to be
223
+ // invoked without arguments, but in all the cases we care about we
224
+ // already have an existing method we want to call, so there's no need
225
+ // to create a new function object. We can even get away with assuming
226
+ // the method takes exactly one argument, since that happens to be true
227
+ // in every case, so we don't have to touch the arguments object. The
228
+ // only additional allocation required is the completion record, which
229
+ // has a stable shape and so hopefully should be cheap to allocate.
230
+
231
+ function tryCatch(fn, obj, arg) {
232
+ try {
233
+ return {
234
+ type: "normal",
235
+ arg: fn.call(obj, arg)
236
+ };
237
+ } catch (err) {
238
+ return {
239
+ type: "throw",
240
+ arg: err
241
+ };
242
+ }
243
+ }
293
244
 
294
- exports.isGeneratorFunction = function(genFun) {
295
- var ctor = typeof genFun === "function" && genFun.constructor;
296
- return ctor
297
- ? ctor === GeneratorFunction ||
298
- // For the native GeneratorFunction constructor, the best we can
299
- // do is to check its .name property.
300
- (ctor.displayName || ctor.name) === "GeneratorFunction"
301
- : false;
302
- };
245
+ var GenStateSuspendedStart = "suspendedStart";
246
+ var GenStateSuspendedYield = "suspendedYield";
247
+ var GenStateExecuting = "executing";
248
+ var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
249
+ // breaking out of the dispatch switch statement.
250
+
251
+ var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
252
+ // .constructor.prototype properties for functions that return Generator
253
+ // objects. For full spec compliance, you may wish to configure your
254
+ // minifier not to mangle the names of these two functions.
255
+
256
+ function Generator() {}
257
+
258
+ function GeneratorFunction() {}
259
+
260
+ function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
261
+ // don't natively support it.
303
262
 
304
- exports.mark = function(genFun) {
305
- if (Object.setPrototypeOf) {
306
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
307
- } else {
308
- genFun.__proto__ = GeneratorFunctionPrototype;
309
- define(genFun, toStringTagSymbol, "GeneratorFunction");
263
+
264
+ var IteratorPrototype = {};
265
+
266
+ IteratorPrototype[iteratorSymbol] = function () {
267
+ return this;
268
+ };
269
+
270
+ var getProto = Object.getPrototypeOf;
271
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
272
+
273
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
274
+ // This environment has a native %IteratorPrototype%; use it instead
275
+ // of the polyfill.
276
+ IteratorPrototype = NativeIteratorPrototype;
310
277
  }
311
- genFun.prototype = Object.create(Gp);
312
- return genFun;
313
- };
314
278
 
315
- // Within the body of any async function, `await x` is transformed to
316
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
317
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
318
- // meant to be awaited.
319
- exports.awrap = function(arg) {
320
- return { __await: arg };
321
- };
279
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
280
+ GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
281
+ GeneratorFunctionPrototype.constructor = GeneratorFunction;
282
+ GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
283
+ // Iterator interface in terms of a single ._invoke method.
322
284
 
323
- function AsyncIterator(generator, PromiseImpl) {
324
- function invoke(method, arg, resolve, reject) {
325
- var record = tryCatch(generator[method], generator, arg);
326
- if (record.type === "throw") {
327
- reject(record.arg);
285
+ function defineIteratorMethods(prototype) {
286
+ ["next", "throw", "return"].forEach(function (method) {
287
+ define(prototype, method, function (arg) {
288
+ return this._invoke(method, arg);
289
+ });
290
+ });
291
+ }
292
+
293
+ exports.isGeneratorFunction = function (genFun) {
294
+ var ctor = typeof genFun === "function" && genFun.constructor;
295
+ return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
296
+ // do is to check its .name property.
297
+ (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
298
+ };
299
+
300
+ exports.mark = function (genFun) {
301
+ if (Object.setPrototypeOf) {
302
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
328
303
  } else {
329
- var result = record.arg;
330
- var value = result.value;
331
- if (value &&
332
- typeof value === "object" &&
333
- hasOwn.call(value, "__await")) {
334
- return PromiseImpl.resolve(value.__await).then(function(value) {
335
- invoke("next", value, resolve, reject);
336
- }, function(err) {
337
- invoke("throw", err, resolve, reject);
304
+ genFun.__proto__ = GeneratorFunctionPrototype;
305
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
306
+ }
307
+
308
+ genFun.prototype = Object.create(Gp);
309
+ return genFun;
310
+ }; // Within the body of any async function, `await x` is transformed to
311
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
312
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
313
+ // meant to be awaited.
314
+
315
+
316
+ exports.awrap = function (arg) {
317
+ return {
318
+ __await: arg
319
+ };
320
+ };
321
+
322
+ function AsyncIterator(generator, PromiseImpl) {
323
+ function invoke(method, arg, resolve, reject) {
324
+ var record = tryCatch(generator[method], generator, arg);
325
+
326
+ if (record.type === "throw") {
327
+ reject(record.arg);
328
+ } else {
329
+ var result = record.arg;
330
+ var value = result.value;
331
+
332
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
333
+ return PromiseImpl.resolve(value.__await).then(function (value) {
334
+ invoke("next", value, resolve, reject);
335
+ }, function (err) {
336
+ invoke("throw", err, resolve, reject);
337
+ });
338
+ }
339
+
340
+ return PromiseImpl.resolve(value).then(function (unwrapped) {
341
+ // When a yielded Promise is resolved, its final value becomes
342
+ // the .value of the Promise<{value,done}> result for the
343
+ // current iteration.
344
+ result.value = unwrapped;
345
+ resolve(result);
346
+ }, function (error) {
347
+ // If a rejected Promise was yielded, throw the rejection back
348
+ // into the async generator function so it can be handled there.
349
+ return invoke("throw", error, resolve, reject);
338
350
  });
339
351
  }
340
-
341
- return PromiseImpl.resolve(value).then(function(unwrapped) {
342
- // When a yielded Promise is resolved, its final value becomes
343
- // the .value of the Promise<{value,done}> result for the
344
- // current iteration.
345
- result.value = unwrapped;
346
- resolve(result);
347
- }, function(error) {
348
- // If a rejected Promise was yielded, throw the rejection back
349
- // into the async generator function so it can be handled there.
350
- return invoke("throw", error, resolve, reject);
351
- });
352
352
  }
353
- }
354
353
 
355
- var previousPromise;
354
+ var previousPromise;
356
355
 
357
- function enqueue(method, arg) {
358
- function callInvokeWithMethodAndArg() {
359
- return new PromiseImpl(function(resolve, reject) {
360
- invoke(method, arg, resolve, reject);
361
- });
362
- }
356
+ function enqueue(method, arg) {
357
+ function callInvokeWithMethodAndArg() {
358
+ return new PromiseImpl(function (resolve, reject) {
359
+ invoke(method, arg, resolve, reject);
360
+ });
361
+ }
363
362
 
364
- return previousPromise =
365
- // If enqueue has been called before, then we want to wait until
363
+ return previousPromise = // If enqueue has been called before, then we want to wait until
366
364
  // all previous Promises have been resolved before calling invoke,
367
365
  // so that results are always delivered in the correct order. If
368
366
  // enqueue has not been called before, then it is important to
@@ -374,549 +372,525 @@ var runtime = (function (exports) {
374
372
  // execute code before the first await. Since we implement simple
375
373
  // async functions in terms of async generators, it is especially
376
374
  // important to get this right, even though it requires care.
377
- previousPromise ? previousPromise.then(
378
- callInvokeWithMethodAndArg,
379
- // Avoid propagating failures to Promises returned by later
380
- // invocations of the iterator.
381
- callInvokeWithMethodAndArg
382
- ) : callInvokeWithMethodAndArg();
375
+ previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
376
+ // invocations of the iterator.
377
+ callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
378
+ } // Define the unified helper method that is used to implement .next,
379
+ // .throw, and .return (see defineIteratorMethods).
380
+
381
+
382
+ this._invoke = enqueue;
383
383
  }
384
384
 
385
- // Define the unified helper method that is used to implement .next,
386
- // .throw, and .return (see defineIteratorMethods).
387
- this._invoke = enqueue;
388
- }
385
+ defineIteratorMethods(AsyncIterator.prototype);
389
386
 
390
- defineIteratorMethods(AsyncIterator.prototype);
391
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
392
- return this;
393
- };
394
- exports.AsyncIterator = AsyncIterator;
395
-
396
- // Note that simple async functions are implemented on top of
397
- // AsyncIterator objects; they just return a Promise for the value of
398
- // the final result produced by the iterator.
399
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
400
- if (PromiseImpl === void 0) PromiseImpl = Promise;
401
-
402
- var iter = new AsyncIterator(
403
- wrap(innerFn, outerFn, self, tryLocsList),
404
- PromiseImpl
405
- );
406
-
407
- return exports.isGeneratorFunction(outerFn)
408
- ? iter // If outerFn is a generator, return the full iterator.
409
- : iter.next().then(function(result) {
410
- return result.done ? result.value : iter.next();
411
- });
412
- };
387
+ AsyncIterator.prototype[asyncIteratorSymbol] = function () {
388
+ return this;
389
+ };
413
390
 
414
- function makeInvokeMethod(innerFn, self, context) {
415
- var state = GenStateSuspendedStart;
391
+ exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
392
+ // AsyncIterator objects; they just return a Promise for the value of
393
+ // the final result produced by the iterator.
416
394
 
417
- return function invoke(method, arg) {
418
- if (state === GenStateExecuting) {
419
- throw new Error("Generator is already running");
420
- }
395
+ exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
396
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
397
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
398
+ return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
399
+ : iter.next().then(function (result) {
400
+ return result.done ? result.value : iter.next();
401
+ });
402
+ };
421
403
 
422
- if (state === GenStateCompleted) {
423
- if (method === "throw") {
424
- throw arg;
404
+ function makeInvokeMethod(innerFn, self, context) {
405
+ var state = GenStateSuspendedStart;
406
+ return function invoke(method, arg) {
407
+ if (state === GenStateExecuting) {
408
+ throw new Error("Generator is already running");
425
409
  }
426
410
 
427
- // Be forgiving, per 25.3.3.3.3 of the spec:
428
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
429
- return doneResult();
430
- }
411
+ if (state === GenStateCompleted) {
412
+ if (method === "throw") {
413
+ throw arg;
414
+ } // Be forgiving, per 25.3.3.3.3 of the spec:
415
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
431
416
 
432
- context.method = method;
433
- context.arg = arg;
434
417
 
435
- while (true) {
436
- var delegate = context.delegate;
437
- if (delegate) {
438
- var delegateResult = maybeInvokeDelegate(delegate, context);
439
- if (delegateResult) {
440
- if (delegateResult === ContinueSentinel) continue;
441
- return delegateResult;
442
- }
418
+ return doneResult();
443
419
  }
444
420
 
445
- if (context.method === "next") {
446
- // Setting context._sent for legacy support of Babel's
447
- // function.sent implementation.
448
- context.sent = context._sent = context.arg;
421
+ context.method = method;
422
+ context.arg = arg;
423
+
424
+ while (true) {
425
+ var delegate = context.delegate;
449
426
 
450
- } else if (context.method === "throw") {
451
- if (state === GenStateSuspendedStart) {
452
- state = GenStateCompleted;
453
- throw context.arg;
427
+ if (delegate) {
428
+ var delegateResult = maybeInvokeDelegate(delegate, context);
429
+
430
+ if (delegateResult) {
431
+ if (delegateResult === ContinueSentinel) continue;
432
+ return delegateResult;
433
+ }
454
434
  }
455
435
 
456
- context.dispatchException(context.arg);
436
+ if (context.method === "next") {
437
+ // Setting context._sent for legacy support of Babel's
438
+ // function.sent implementation.
439
+ context.sent = context._sent = context.arg;
440
+ } else if (context.method === "throw") {
441
+ if (state === GenStateSuspendedStart) {
442
+ state = GenStateCompleted;
443
+ throw context.arg;
444
+ }
457
445
 
458
- } else if (context.method === "return") {
459
- context.abrupt("return", context.arg);
460
- }
446
+ context.dispatchException(context.arg);
447
+ } else if (context.method === "return") {
448
+ context.abrupt("return", context.arg);
449
+ }
461
450
 
462
- state = GenStateExecuting;
451
+ state = GenStateExecuting;
452
+ var record = tryCatch(innerFn, self, context);
463
453
 
464
- var record = tryCatch(innerFn, self, context);
465
- if (record.type === "normal") {
466
- // If an exception is thrown from innerFn, we leave state ===
467
- // GenStateExecuting and loop back for another invocation.
468
- state = context.done
469
- ? GenStateCompleted
470
- : GenStateSuspendedYield;
454
+ if (record.type === "normal") {
455
+ // If an exception is thrown from innerFn, we leave state ===
456
+ // GenStateExecuting and loop back for another invocation.
457
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
471
458
 
472
- if (record.arg === ContinueSentinel) {
473
- continue;
474
- }
459
+ if (record.arg === ContinueSentinel) {
460
+ continue;
461
+ }
475
462
 
476
- return {
477
- value: record.arg,
478
- done: context.done
479
- };
463
+ return {
464
+ value: record.arg,
465
+ done: context.done
466
+ };
467
+ } else if (record.type === "throw") {
468
+ state = GenStateCompleted; // Dispatch the exception by looping back around to the
469
+ // context.dispatchException(context.arg) call above.
470
+
471
+ context.method = "throw";
472
+ context.arg = record.arg;
473
+ }
474
+ }
475
+ };
476
+ } // Call delegate.iterator[context.method](context.arg) and handle the
477
+ // result, either by returning a { value, done } result from the
478
+ // delegate iterator, or by modifying context.method and context.arg,
479
+ // setting context.delegate to null, and returning the ContinueSentinel.
480
+
481
+
482
+ function maybeInvokeDelegate(delegate, context) {
483
+ var method = delegate.iterator[context.method];
484
+
485
+ if (method === undefined$1) {
486
+ // A .throw or .return when the delegate iterator has no .throw
487
+ // method always terminates the yield* loop.
488
+ context.delegate = null;
489
+
490
+ if (context.method === "throw") {
491
+ // Note: ["return"] must be used for ES3 parsing compatibility.
492
+ if (delegate.iterator["return"]) {
493
+ // If the delegate iterator has a return method, give it a
494
+ // chance to clean up.
495
+ context.method = "return";
496
+ context.arg = undefined$1;
497
+ maybeInvokeDelegate(delegate, context);
498
+
499
+ if (context.method === "throw") {
500
+ // If maybeInvokeDelegate(context) changed context.method from
501
+ // "return" to "throw", let that override the TypeError below.
502
+ return ContinueSentinel;
503
+ }
504
+ }
480
505
 
481
- } else if (record.type === "throw") {
482
- state = GenStateCompleted;
483
- // Dispatch the exception by looping back around to the
484
- // context.dispatchException(context.arg) call above.
485
506
  context.method = "throw";
486
- context.arg = record.arg;
507
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
487
508
  }
509
+
510
+ return ContinueSentinel;
488
511
  }
489
- };
490
- }
491
512
 
492
- // Call delegate.iterator[context.method](context.arg) and handle the
493
- // result, either by returning a { value, done } result from the
494
- // delegate iterator, or by modifying context.method and context.arg,
495
- // setting context.delegate to null, and returning the ContinueSentinel.
496
- function maybeInvokeDelegate(delegate, context) {
497
- var method = delegate.iterator[context.method];
498
- if (method === undefined$1) {
499
- // A .throw or .return when the delegate iterator has no .throw
500
- // method always terminates the yield* loop.
501
- context.delegate = null;
513
+ var record = tryCatch(method, delegate.iterator, context.arg);
502
514
 
503
- if (context.method === "throw") {
504
- // Note: ["return"] must be used for ES3 parsing compatibility.
505
- if (delegate.iterator["return"]) {
506
- // If the delegate iterator has a return method, give it a
507
- // chance to clean up.
508
- context.method = "return";
509
- context.arg = undefined$1;
510
- maybeInvokeDelegate(delegate, context);
515
+ if (record.type === "throw") {
516
+ context.method = "throw";
517
+ context.arg = record.arg;
518
+ context.delegate = null;
519
+ return ContinueSentinel;
520
+ }
511
521
 
512
- if (context.method === "throw") {
513
- // If maybeInvokeDelegate(context) changed context.method from
514
- // "return" to "throw", let that override the TypeError below.
515
- return ContinueSentinel;
516
- }
517
- }
522
+ var info = record.arg;
518
523
 
524
+ if (!info) {
519
525
  context.method = "throw";
520
- context.arg = new TypeError(
521
- "The iterator does not provide a 'throw' method");
526
+ context.arg = new TypeError("iterator result is not an object");
527
+ context.delegate = null;
528
+ return ContinueSentinel;
522
529
  }
523
530
 
524
- return ContinueSentinel;
525
- }
531
+ if (info.done) {
532
+ // Assign the result of the finished delegate to the temporary
533
+ // variable specified by delegate.resultName (see delegateYield).
534
+ context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
526
535
 
527
- var record = tryCatch(method, delegate.iterator, context.arg);
536
+ context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
537
+ // exception, let the outer generator proceed normally. If
538
+ // context.method was "next", forget context.arg since it has been
539
+ // "consumed" by the delegate iterator. If context.method was
540
+ // "return", allow the original .return call to continue in the
541
+ // outer generator.
528
542
 
529
- if (record.type === "throw") {
530
- context.method = "throw";
531
- context.arg = record.arg;
532
- context.delegate = null;
533
- return ContinueSentinel;
534
- }
543
+ if (context.method !== "return") {
544
+ context.method = "next";
545
+ context.arg = undefined$1;
546
+ }
547
+ } else {
548
+ // Re-yield the result returned by the delegate method.
549
+ return info;
550
+ } // The delegate iterator is finished, so forget it and continue with
551
+ // the outer generator.
535
552
 
536
- var info = record.arg;
537
553
 
538
- if (! info) {
539
- context.method = "throw";
540
- context.arg = new TypeError("iterator result is not an object");
541
554
  context.delegate = null;
542
555
  return ContinueSentinel;
543
- }
556
+ } // Define Generator.prototype.{next,throw,return} in terms of the
557
+ // unified ._invoke helper method.
544
558
 
545
- if (info.done) {
546
- // Assign the result of the finished delegate to the temporary
547
- // variable specified by delegate.resultName (see delegateYield).
548
- context[delegate.resultName] = info.value;
549
-
550
- // Resume execution at the desired location (see delegateYield).
551
- context.next = delegate.nextLoc;
552
-
553
- // If context.method was "throw" but the delegate handled the
554
- // exception, let the outer generator proceed normally. If
555
- // context.method was "next", forget context.arg since it has been
556
- // "consumed" by the delegate iterator. If context.method was
557
- // "return", allow the original .return call to continue in the
558
- // outer generator.
559
- if (context.method !== "return") {
560
- context.method = "next";
561
- context.arg = undefined$1;
562
- }
563
559
 
564
- } else {
565
- // Re-yield the result returned by the delegate method.
566
- return info;
567
- }
568
-
569
- // The delegate iterator is finished, so forget it and continue with
570
- // the outer generator.
571
- context.delegate = null;
572
- return ContinueSentinel;
573
- }
560
+ defineIteratorMethods(Gp);
561
+ define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
562
+ // @@iterator function is called on it. Some browsers' implementations of the
563
+ // iterator prototype chain incorrectly implement this, causing the Generator
564
+ // object to not be returned from this call. This ensures that doesn't happen.
565
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
574
566
 
575
- // Define Generator.prototype.{next,throw,return} in terms of the
576
- // unified ._invoke helper method.
577
- defineIteratorMethods(Gp);
567
+ Gp[iteratorSymbol] = function () {
568
+ return this;
569
+ };
578
570
 
579
- define(Gp, toStringTagSymbol, "Generator");
571
+ Gp.toString = function () {
572
+ return "[object Generator]";
573
+ };
580
574
 
581
- // A Generator should always return itself as the iterator object when the
582
- // @@iterator function is called on it. Some browsers' implementations of the
583
- // iterator prototype chain incorrectly implement this, causing the Generator
584
- // object to not be returned from this call. This ensures that doesn't happen.
585
- // See https://github.com/facebook/regenerator/issues/274 for more details.
586
- Gp[iteratorSymbol] = function() {
587
- return this;
588
- };
575
+ function pushTryEntry(locs) {
576
+ var entry = {
577
+ tryLoc: locs[0]
578
+ };
589
579
 
590
- Gp.toString = function() {
591
- return "[object Generator]";
592
- };
580
+ if (1 in locs) {
581
+ entry.catchLoc = locs[1];
582
+ }
593
583
 
594
- function pushTryEntry(locs) {
595
- var entry = { tryLoc: locs[0] };
584
+ if (2 in locs) {
585
+ entry.finallyLoc = locs[2];
586
+ entry.afterLoc = locs[3];
587
+ }
596
588
 
597
- if (1 in locs) {
598
- entry.catchLoc = locs[1];
589
+ this.tryEntries.push(entry);
599
590
  }
600
591
 
601
- if (2 in locs) {
602
- entry.finallyLoc = locs[2];
603
- entry.afterLoc = locs[3];
592
+ function resetTryEntry(entry) {
593
+ var record = entry.completion || {};
594
+ record.type = "normal";
595
+ delete record.arg;
596
+ entry.completion = record;
604
597
  }
605
598
 
606
- this.tryEntries.push(entry);
607
- }
608
-
609
- function resetTryEntry(entry) {
610
- var record = entry.completion || {};
611
- record.type = "normal";
612
- delete record.arg;
613
- entry.completion = record;
614
- }
615
-
616
- function Context(tryLocsList) {
617
- // The root entry object (effectively a try statement without a catch
618
- // or a finally block) gives us a place to store values thrown from
619
- // locations where there is no enclosing try statement.
620
- this.tryEntries = [{ tryLoc: "root" }];
621
- tryLocsList.forEach(pushTryEntry, this);
622
- this.reset(true);
623
- }
624
-
625
- exports.keys = function(object) {
626
- var keys = [];
627
- for (var key in object) {
628
- keys.push(key);
599
+ function Context(tryLocsList) {
600
+ // The root entry object (effectively a try statement without a catch
601
+ // or a finally block) gives us a place to store values thrown from
602
+ // locations where there is no enclosing try statement.
603
+ this.tryEntries = [{
604
+ tryLoc: "root"
605
+ }];
606
+ tryLocsList.forEach(pushTryEntry, this);
607
+ this.reset(true);
629
608
  }
630
- keys.reverse();
631
-
632
- // Rather than returning an object with a next method, we keep
633
- // things simple and return the next function itself.
634
- return function next() {
635
- while (keys.length) {
636
- var key = keys.pop();
637
- if (key in object) {
638
- next.value = key;
639
- next.done = false;
640
- return next;
641
- }
642
- }
643
609
 
644
- // To avoid creating an additional object, we just hang the .value
645
- // and .done properties off the next function object itself. This
646
- // also ensures that the minifier will not anonymize the function.
647
- next.done = true;
648
- return next;
649
- };
650
- };
610
+ exports.keys = function (object) {
611
+ var keys = [];
651
612
 
652
- function values(iterable) {
653
- if (iterable) {
654
- var iteratorMethod = iterable[iteratorSymbol];
655
- if (iteratorMethod) {
656
- return iteratorMethod.call(iterable);
613
+ for (var key in object) {
614
+ keys.push(key);
657
615
  }
658
616
 
659
- if (typeof iterable.next === "function") {
660
- return iterable;
661
- }
617
+ keys.reverse(); // Rather than returning an object with a next method, we keep
618
+ // things simple and return the next function itself.
662
619
 
663
- if (!isNaN(iterable.length)) {
664
- var i = -1, next = function next() {
665
- while (++i < iterable.length) {
666
- if (hasOwn.call(iterable, i)) {
667
- next.value = iterable[i];
668
- next.done = false;
669
- return next;
670
- }
671
- }
620
+ return function next() {
621
+ while (keys.length) {
622
+ var key = keys.pop();
672
623
 
673
- next.value = undefined$1;
674
- next.done = true;
624
+ if (key in object) {
625
+ next.value = key;
626
+ next.done = false;
627
+ return next;
628
+ }
629
+ } // To avoid creating an additional object, we just hang the .value
630
+ // and .done properties off the next function object itself. This
631
+ // also ensures that the minifier will not anonymize the function.
675
632
 
676
- return next;
677
- };
678
633
 
679
- return next.next = next;
680
- }
681
- }
634
+ next.done = true;
635
+ return next;
636
+ };
637
+ };
682
638
 
683
- // Return an iterator with no values.
684
- return { next: doneResult };
685
- }
686
- exports.values = values;
639
+ function values(iterable) {
640
+ if (iterable) {
641
+ var iteratorMethod = iterable[iteratorSymbol];
687
642
 
688
- function doneResult() {
689
- return { value: undefined$1, done: true };
690
- }
643
+ if (iteratorMethod) {
644
+ return iteratorMethod.call(iterable);
645
+ }
691
646
 
692
- Context.prototype = {
693
- constructor: Context,
694
-
695
- reset: function(skipTempReset) {
696
- this.prev = 0;
697
- this.next = 0;
698
- // Resetting context._sent for legacy support of Babel's
699
- // function.sent implementation.
700
- this.sent = this._sent = undefined$1;
701
- this.done = false;
702
- this.delegate = null;
703
-
704
- this.method = "next";
705
- this.arg = undefined$1;
706
-
707
- this.tryEntries.forEach(resetTryEntry);
708
-
709
- if (!skipTempReset) {
710
- for (var name in this) {
711
- // Not sure about the optimal order of these conditions:
712
- if (name.charAt(0) === "t" &&
713
- hasOwn.call(this, name) &&
714
- !isNaN(+name.slice(1))) {
715
- this[name] = undefined$1;
716
- }
647
+ if (typeof iterable.next === "function") {
648
+ return iterable;
717
649
  }
718
- }
719
- },
720
650
 
721
- stop: function() {
722
- this.done = true;
651
+ if (!isNaN(iterable.length)) {
652
+ var i = -1,
653
+ next = function next() {
654
+ while (++i < iterable.length) {
655
+ if (hasOwn.call(iterable, i)) {
656
+ next.value = iterable[i];
657
+ next.done = false;
658
+ return next;
659
+ }
660
+ }
723
661
 
724
- var rootEntry = this.tryEntries[0];
725
- var rootRecord = rootEntry.completion;
726
- if (rootRecord.type === "throw") {
727
- throw rootRecord.arg;
728
- }
662
+ next.value = undefined$1;
663
+ next.done = true;
664
+ return next;
665
+ };
729
666
 
730
- return this.rval;
731
- },
667
+ return next.next = next;
668
+ }
669
+ } // Return an iterator with no values.
732
670
 
733
- dispatchException: function(exception) {
734
- if (this.done) {
735
- throw exception;
736
- }
737
671
 
738
- var context = this;
739
- function handle(loc, caught) {
740
- record.type = "throw";
741
- record.arg = exception;
742
- context.next = loc;
672
+ return {
673
+ next: doneResult
674
+ };
675
+ }
743
676
 
744
- if (caught) {
745
- // If the dispatched exception was caught by a catch block,
746
- // then let that catch block handle the exception normally.
747
- context.method = "next";
748
- context.arg = undefined$1;
749
- }
677
+ exports.values = values;
750
678
 
751
- return !! caught;
752
- }
679
+ function doneResult() {
680
+ return {
681
+ value: undefined$1,
682
+ done: true
683
+ };
684
+ }
685
+
686
+ Context.prototype = {
687
+ constructor: Context,
688
+ reset: function reset(skipTempReset) {
689
+ this.prev = 0;
690
+ this.next = 0; // Resetting context._sent for legacy support of Babel's
691
+ // function.sent implementation.
753
692
 
754
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
755
- var entry = this.tryEntries[i];
756
- var record = entry.completion;
693
+ this.sent = this._sent = undefined$1;
694
+ this.done = false;
695
+ this.delegate = null;
696
+ this.method = "next";
697
+ this.arg = undefined$1;
698
+ this.tryEntries.forEach(resetTryEntry);
757
699
 
758
- if (entry.tryLoc === "root") {
759
- // Exception thrown outside of any try block that could handle
760
- // it, so set the completion value of the entire function to
761
- // throw the exception.
762
- return handle("end");
700
+ if (!skipTempReset) {
701
+ for (var name in this) {
702
+ // Not sure about the optimal order of these conditions:
703
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
704
+ this[name] = undefined$1;
705
+ }
706
+ }
763
707
  }
708
+ },
709
+ stop: function stop() {
710
+ this.done = true;
711
+ var rootEntry = this.tryEntries[0];
712
+ var rootRecord = rootEntry.completion;
764
713
 
765
- if (entry.tryLoc <= this.prev) {
766
- var hasCatch = hasOwn.call(entry, "catchLoc");
767
- var hasFinally = hasOwn.call(entry, "finallyLoc");
714
+ if (rootRecord.type === "throw") {
715
+ throw rootRecord.arg;
716
+ }
768
717
 
769
- if (hasCatch && hasFinally) {
770
- if (this.prev < entry.catchLoc) {
771
- return handle(entry.catchLoc, true);
772
- } else if (this.prev < entry.finallyLoc) {
773
- return handle(entry.finallyLoc);
774
- }
718
+ return this.rval;
719
+ },
720
+ dispatchException: function dispatchException(exception) {
721
+ if (this.done) {
722
+ throw exception;
723
+ }
775
724
 
776
- } else if (hasCatch) {
777
- if (this.prev < entry.catchLoc) {
778
- return handle(entry.catchLoc, true);
779
- }
725
+ var context = this;
780
726
 
781
- } else if (hasFinally) {
782
- if (this.prev < entry.finallyLoc) {
783
- return handle(entry.finallyLoc);
784
- }
727
+ function handle(loc, caught) {
728
+ record.type = "throw";
729
+ record.arg = exception;
730
+ context.next = loc;
785
731
 
786
- } else {
787
- throw new Error("try statement without catch or finally");
732
+ if (caught) {
733
+ // If the dispatched exception was caught by a catch block,
734
+ // then let that catch block handle the exception normally.
735
+ context.method = "next";
736
+ context.arg = undefined$1;
788
737
  }
789
- }
790
- }
791
- },
792
738
 
793
- abrupt: function(type, arg) {
794
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
795
- var entry = this.tryEntries[i];
796
- if (entry.tryLoc <= this.prev &&
797
- hasOwn.call(entry, "finallyLoc") &&
798
- this.prev < entry.finallyLoc) {
799
- var finallyEntry = entry;
800
- break;
739
+ return !!caught;
801
740
  }
802
- }
803
741
 
804
- if (finallyEntry &&
805
- (type === "break" ||
806
- type === "continue") &&
807
- finallyEntry.tryLoc <= arg &&
808
- arg <= finallyEntry.finallyLoc) {
809
- // Ignore the finally entry if control is not jumping to a
810
- // location outside the try/catch block.
811
- finallyEntry = null;
812
- }
742
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
743
+ var entry = this.tryEntries[i];
744
+ var record = entry.completion;
813
745
 
814
- var record = finallyEntry ? finallyEntry.completion : {};
815
- record.type = type;
816
- record.arg = arg;
746
+ if (entry.tryLoc === "root") {
747
+ // Exception thrown outside of any try block that could handle
748
+ // it, so set the completion value of the entire function to
749
+ // throw the exception.
750
+ return handle("end");
751
+ }
817
752
 
818
- if (finallyEntry) {
819
- this.method = "next";
820
- this.next = finallyEntry.finallyLoc;
821
- return ContinueSentinel;
822
- }
753
+ if (entry.tryLoc <= this.prev) {
754
+ var hasCatch = hasOwn.call(entry, "catchLoc");
755
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
823
756
 
824
- return this.complete(record);
825
- },
757
+ if (hasCatch && hasFinally) {
758
+ if (this.prev < entry.catchLoc) {
759
+ return handle(entry.catchLoc, true);
760
+ } else if (this.prev < entry.finallyLoc) {
761
+ return handle(entry.finallyLoc);
762
+ }
763
+ } else if (hasCatch) {
764
+ if (this.prev < entry.catchLoc) {
765
+ return handle(entry.catchLoc, true);
766
+ }
767
+ } else if (hasFinally) {
768
+ if (this.prev < entry.finallyLoc) {
769
+ return handle(entry.finallyLoc);
770
+ }
771
+ } else {
772
+ throw new Error("try statement without catch or finally");
773
+ }
774
+ }
775
+ }
776
+ },
777
+ abrupt: function abrupt(type, arg) {
778
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
779
+ var entry = this.tryEntries[i];
826
780
 
827
- complete: function(record, afterLoc) {
828
- if (record.type === "throw") {
829
- throw record.arg;
830
- }
781
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
782
+ var finallyEntry = entry;
783
+ break;
784
+ }
785
+ }
831
786
 
832
- if (record.type === "break" ||
833
- record.type === "continue") {
834
- this.next = record.arg;
835
- } else if (record.type === "return") {
836
- this.rval = this.arg = record.arg;
837
- this.method = "return";
838
- this.next = "end";
839
- } else if (record.type === "normal" && afterLoc) {
840
- this.next = afterLoc;
841
- }
787
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
788
+ // Ignore the finally entry if control is not jumping to a
789
+ // location outside the try/catch block.
790
+ finallyEntry = null;
791
+ }
842
792
 
843
- return ContinueSentinel;
844
- },
793
+ var record = finallyEntry ? finallyEntry.completion : {};
794
+ record.type = type;
795
+ record.arg = arg;
845
796
 
846
- finish: function(finallyLoc) {
847
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
848
- var entry = this.tryEntries[i];
849
- if (entry.finallyLoc === finallyLoc) {
850
- this.complete(entry.completion, entry.afterLoc);
851
- resetTryEntry(entry);
797
+ if (finallyEntry) {
798
+ this.method = "next";
799
+ this.next = finallyEntry.finallyLoc;
852
800
  return ContinueSentinel;
853
801
  }
854
- }
855
- },
856
802
 
857
- "catch": function(tryLoc) {
858
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
859
- var entry = this.tryEntries[i];
860
- if (entry.tryLoc === tryLoc) {
861
- var record = entry.completion;
862
- if (record.type === "throw") {
863
- var thrown = record.arg;
803
+ return this.complete(record);
804
+ },
805
+ complete: function complete(record, afterLoc) {
806
+ if (record.type === "throw") {
807
+ throw record.arg;
808
+ }
809
+
810
+ if (record.type === "break" || record.type === "continue") {
811
+ this.next = record.arg;
812
+ } else if (record.type === "return") {
813
+ this.rval = this.arg = record.arg;
814
+ this.method = "return";
815
+ this.next = "end";
816
+ } else if (record.type === "normal" && afterLoc) {
817
+ this.next = afterLoc;
818
+ }
819
+
820
+ return ContinueSentinel;
821
+ },
822
+ finish: function finish(finallyLoc) {
823
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
824
+ var entry = this.tryEntries[i];
825
+
826
+ if (entry.finallyLoc === finallyLoc) {
827
+ this.complete(entry.completion, entry.afterLoc);
864
828
  resetTryEntry(entry);
829
+ return ContinueSentinel;
865
830
  }
866
- return thrown;
867
831
  }
868
- }
832
+ },
833
+ "catch": function _catch(tryLoc) {
834
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
835
+ var entry = this.tryEntries[i];
869
836
 
870
- // The context.catch method must only be called with a location
871
- // argument that corresponds to a known catch block.
872
- throw new Error("illegal catch attempt");
873
- },
837
+ if (entry.tryLoc === tryLoc) {
838
+ var record = entry.completion;
874
839
 
875
- delegateYield: function(iterable, resultName, nextLoc) {
876
- this.delegate = {
877
- iterator: values(iterable),
878
- resultName: resultName,
879
- nextLoc: nextLoc
880
- };
840
+ if (record.type === "throw") {
841
+ var thrown = record.arg;
842
+ resetTryEntry(entry);
843
+ }
881
844
 
882
- if (this.method === "next") {
883
- // Deliberately forget the last sent value so that we don't
884
- // accidentally pass it on to the delegate.
885
- this.arg = undefined$1;
886
- }
845
+ return thrown;
846
+ }
847
+ } // The context.catch method must only be called with a location
848
+ // argument that corresponds to a known catch block.
887
849
 
888
- return ContinueSentinel;
889
- }
890
- };
891
850
 
892
- // Regardless of whether this script is executing as a CommonJS module
893
- // or not, return the runtime object so that we can declare the variable
894
- // regeneratorRuntime in the outer scope, which allows this module to be
895
- // injected easily by `bin/regenerator --include-runtime script.js`.
896
- return exports;
851
+ throw new Error("illegal catch attempt");
852
+ },
853
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
854
+ this.delegate = {
855
+ iterator: values(iterable),
856
+ resultName: resultName,
857
+ nextLoc: nextLoc
858
+ };
859
+
860
+ if (this.method === "next") {
861
+ // Deliberately forget the last sent value so that we don't
862
+ // accidentally pass it on to the delegate.
863
+ this.arg = undefined$1;
864
+ }
865
+
866
+ return ContinueSentinel;
867
+ }
868
+ }; // Regardless of whether this script is executing as a CommonJS module
869
+ // or not, return the runtime object so that we can declare the variable
870
+ // regeneratorRuntime in the outer scope, which allows this module to be
871
+ // injected easily by `bin/regenerator --include-runtime script.js`.
897
872
 
898
- }(
899
- // If this script is executing as a CommonJS module, use module.exports
873
+ return exports;
874
+ }( // If this script is executing as a CommonJS module, use module.exports
900
875
  // as the regeneratorRuntime namespace. Otherwise create a new empty
901
876
  // object. Either way, the resulting object will be used to initialize
902
877
  // the regeneratorRuntime variable at the top of this file.
903
- module.exports
904
- ));
905
-
906
- try {
907
- regeneratorRuntime = runtime;
908
- } catch (accidentalStrictMode) {
909
- // This module should not be running in strict mode, so the above
910
- // assignment should always work unless something is misconfigured. Just
911
- // in case runtime.js accidentally runs in strict mode, we can escape
912
- // strict mode using a global Function call. This could conceivably fail
913
- // if a Content Security Policy forbids using Function, but in that case
914
- // the proper solution is to fix the accidental strict mode problem. If
915
- // you've misconfigured your bundler to force strict mode and applied a
916
- // CSP to forbid Function, and you're not willing to fix either of those
917
- // problems, please detail your unique predicament in a GitHub issue.
918
- Function("r", "regeneratorRuntime = r")(runtime);
919
- }
878
+ module.exports );
879
+
880
+ try {
881
+ regeneratorRuntime = runtime;
882
+ } catch (accidentalStrictMode) {
883
+ // This module should not be running in strict mode, so the above
884
+ // assignment should always work unless something is misconfigured. Just
885
+ // in case runtime.js accidentally runs in strict mode, we can escape
886
+ // strict mode using a global Function call. This could conceivably fail
887
+ // if a Content Security Policy forbids using Function, but in that case
888
+ // the proper solution is to fix the accidental strict mode problem. If
889
+ // you've misconfigured your bundler to force strict mode and applied a
890
+ // CSP to forbid Function, and you're not willing to fix either of those
891
+ // problems, please detail your unique predicament in a GitHub issue.
892
+ Function("r", "regeneratorRuntime = r")(runtime);
893
+ }
920
894
  });
921
895
 
922
896
  var ProductContext = /*#__PURE__*/React.createContext(undefined);
@@ -933,6 +907,7 @@ function useProduct() {
933
907
  return useContext(ProductContext);
934
908
  }
935
909
 
910
+ var _excluded = ["children"];
936
911
  var Commerce = /*#__PURE__*/createContext({});
937
912
  function CoreCommerceProvider(_ref) {
938
913
  var provider = _ref.provider,
@@ -960,7 +935,7 @@ function CoreCommerceProvider(_ref) {
960
935
  function getCommerceProvider(provider) {
961
936
  return function CommerceProvider(_ref2) {
962
937
  var children = _ref2.children,
963
- props = _objectWithoutPropertiesLoose(_ref2, ["children"]);
938
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded);
964
939
 
965
940
  return React.createElement(CoreCommerceProvider, {
966
941
  provider: _extends({}, provider, props)
@@ -1287,7 +1262,6 @@ var fn$1 = function fn(provider) {
1287
1262
 
1288
1263
  var useSearch = function useSearch(input) {
1289
1264
  var hook = useHook(fn$1);
1290
- console.log("dale", "commerce", input);
1291
1265
  return useSWRHook(_extends({
1292
1266
  fetcher: fetcher$1
1293
1267
  }, hook))(input);
@@ -1312,17 +1286,47 @@ var productCollectionMeta = {
1312
1286
  name: "plasmic-commerce-product-media"
1313
1287
  }],
1314
1288
  styles: {
1315
- width: "100%"
1289
+ width: "100%",
1290
+ minWidth: 0
1316
1291
  }
1317
1292
  }]
1318
1293
  },
1319
1294
  count: "number",
1320
- categoryId: "string",
1321
- brandId: "string"
1295
+ category: {
1296
+ type: "choice",
1297
+ options: function options(props, ctx) {
1298
+ var _ctx$categories$map;
1299
+
1300
+ return (_ctx$categories$map = ctx == null ? void 0 : ctx.categories.map(function (category) {
1301
+ return {
1302
+ label: category.name,
1303
+ value: category.id
1304
+ };
1305
+ })) != null ? _ctx$categories$map : [];
1306
+ }
1307
+ },
1308
+ brand: {
1309
+ type: "choice",
1310
+ options: function options(props, ctx) {
1311
+ var _ctx$brands$map;
1312
+
1313
+ return (_ctx$brands$map = ctx == null ? void 0 : ctx.brands.map(function (brand) {
1314
+ return {
1315
+ label: brand.name,
1316
+ value: brand.entityId
1317
+ };
1318
+ })) != null ? _ctx$brands$map : [];
1319
+ }
1320
+ },
1321
+ noLayout: "boolean"
1322
1322
  },
1323
1323
  defaultStyles: {
1324
1324
  display: "grid",
1325
- gridTemplateColumns: "1fr 1fr 1fr 1fr"
1325
+ gridTemplateColumns: "1fr 1fr 1fr 1fr",
1326
+ gridRowGap: "8px",
1327
+ gridColumnGap: "8px",
1328
+ padding: "8px",
1329
+ maxWidth: "100%"
1326
1330
  },
1327
1331
  importPath: "commerce-providers/commerce",
1328
1332
  importName: "ProductCollection"
@@ -1332,24 +1336,40 @@ function ProductCollection(props) {
1332
1336
  var className = props.className,
1333
1337
  children = props.children,
1334
1338
  count = props.count,
1335
- categoryId = props.categoryId,
1336
- brandId = props.brandId;
1339
+ category = props.category,
1340
+ brand = props.brand,
1341
+ noLayout = props.noLayout,
1342
+ setControlContextData = props.setControlContextData;
1337
1343
 
1338
1344
  var _useSearch = useSearch({
1339
- categoryId: categoryId,
1340
- brandId: brandId,
1345
+ categoryId: category,
1346
+ brandId: brand,
1341
1347
  count: count
1342
1348
  }),
1343
1349
  data = _useSearch.data;
1344
1350
 
1345
- return React.createElement("div", {
1346
- className: className
1347
- }, data == null ? void 0 : data.products.map(function (product, i) {
1351
+ var _useCategories = useCategories({}),
1352
+ categories = _useCategories.data;
1353
+
1354
+ var _useBrands = useBrands({}),
1355
+ brands = _useBrands.data;
1356
+
1357
+ if (categories && brands) {
1358
+ setControlContextData == null ? void 0 : setControlContextData({
1359
+ categories: categories,
1360
+ brands: brands
1361
+ });
1362
+ }
1363
+
1364
+ var renderedData = data == null ? void 0 : data.products.map(function (product, i) {
1348
1365
  return React.createElement(ProductProvider, {
1349
1366
  product: product,
1350
1367
  key: product.id
1351
1368
  }, repeatedElement(i === 0, children));
1352
- }));
1369
+ });
1370
+ return noLayout ? React.createElement(React.Fragment, null, renderedData) : React.createElement("div", {
1371
+ className: className
1372
+ }, renderedData);
1353
1373
  }
1354
1374
 
1355
1375
  function registerProductCollection(loader, customProductCollectionMeta) {
@@ -1365,8 +1385,6 @@ var productMediaMeta = {
1365
1385
  name: "plasmic-commerce-product-media",
1366
1386
  displayName: "Product Media",
1367
1387
  props: {
1368
- children: "slot",
1369
- style: "object",
1370
1388
  mediaIndex: "number"
1371
1389
  },
1372
1390
  importPath: "commerce-providers/commerce",
@@ -1376,7 +1394,6 @@ function ProductMedia(props) {
1376
1394
  var _image$url;
1377
1395
 
1378
1396
  var className = props.className,
1379
- style = props.style,
1380
1397
  _props$mediaIndex = props.mediaIndex,
1381
1398
  mediaIndex = _props$mediaIndex === void 0 ? 0 : _props$mediaIndex;
1382
1399
  var product = useProduct();
@@ -1385,8 +1402,7 @@ function ProductMedia(props) {
1385
1402
  alt: (product == null ? void 0 : product.name) || 'Product Image',
1386
1403
  src: product ? (_image$url = image == null ? void 0 : image.url) != null ? _image$url : "" : placeholderImage,
1387
1404
  loading: 'lazy',
1388
- className: className,
1389
- style: style
1405
+ className: className
1390
1406
  });
1391
1407
  }
1392
1408
  function registerProductMedia(loader, customProductMediaMeta) {
@@ -1483,6 +1499,11 @@ function ProductPrice(props) {
1483
1499
  var className = props.className;
1484
1500
  var product = useProduct();
1485
1501
  var form = useFormContext();
1502
+
1503
+ if (!product) {
1504
+ throw new Error("This component must be within a product context.");
1505
+ }
1506
+
1486
1507
  var watchProductVariant = form.watch("ProductVariant", product == null ? void 0 : product.variants[0].id);
1487
1508
 
1488
1509
  var _usePrice = usePrice({
@@ -1771,33 +1792,63 @@ var product = {
1771
1792
  __proto__: null
1772
1793
  };
1773
1794
 
1774
- var fetcher$3 = mutationFetcher;
1795
+ var fetcher$3 = SWRFetcher;
1775
1796
 
1776
1797
  var fn$3 = function fn(provider) {
1798
+ var _provider$site;
1799
+
1800
+ return (_provider$site = provider.site) == null ? void 0 : _provider$site.useCategories;
1801
+ };
1802
+
1803
+ var useCategories = function useCategories(input) {
1804
+ var hook = useHook(fn$3);
1805
+ return useSWRHook(_extends({
1806
+ fetcher: fetcher$3
1807
+ }, hook))(input);
1808
+ };
1809
+
1810
+ var fetcher$4 = SWRFetcher;
1811
+
1812
+ var fn$4 = function fn(provider) {
1813
+ var _provider$site;
1814
+
1815
+ return (_provider$site = provider.site) == null ? void 0 : _provider$site.useBrands;
1816
+ };
1817
+
1818
+ var useBrands = function useBrands(input) {
1819
+ var hook = useHook(fn$4);
1820
+ return useSWRHook(_extends({
1821
+ fetcher: fetcher$4
1822
+ }, hook))(input);
1823
+ };
1824
+
1825
+ var fetcher$5 = mutationFetcher;
1826
+
1827
+ var fn$5 = function fn(provider) {
1777
1828
  var _provider$cart;
1778
1829
 
1779
1830
  return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useRemoveItem;
1780
1831
  };
1781
1832
 
1782
1833
  var useRemoveItem = function useRemoveItem(input) {
1783
- var hook = useHook(fn$3);
1834
+ var hook = useHook(fn$5);
1784
1835
  return useMutationHook(_extends({
1785
- fetcher: fetcher$3
1836
+ fetcher: fetcher$5
1786
1837
  }, hook))(input);
1787
1838
  };
1788
1839
 
1789
- var fetcher$4 = mutationFetcher;
1840
+ var fetcher$6 = mutationFetcher;
1790
1841
 
1791
- var fn$4 = function fn(provider) {
1842
+ var fn$6 = function fn(provider) {
1792
1843
  var _provider$cart;
1793
1844
 
1794
1845
  return (_provider$cart = provider.cart) == null ? void 0 : _provider$cart.useUpdateItem;
1795
1846
  };
1796
1847
 
1797
1848
  var useUpdateItem = function useUpdateItem(input) {
1798
- var hook = useHook(fn$4);
1849
+ var hook = useHook(fn$6);
1799
1850
  return useMutationHook(_extends({
1800
- fetcher: fetcher$4
1851
+ fetcher: fetcher$6
1801
1852
  }, hook))(input);
1802
1853
  };
1803
1854
 
@@ -1824,5 +1875,5 @@ function registerAll(loader) {
1824
1875
  registerProductVariantPicker(loader);
1825
1876
  }
1826
1877
 
1827
- export { cart as CartType, CommerceError, CoreCommerceProvider, FetcherError, product as ProductTypes, site as SiteTypes, ValidationError, fetcher$1 as fetcher, getCommerceProvider, registerAll, useAddItem, useCart, useCommerce, useRemoveItem, useSearch, useUpdateItem, x };
1878
+ export { cart as CartType, CommerceError, CoreCommerceProvider, FetcherError, product as ProductTypes, site as SiteTypes, ValidationError, fetcher$1 as fetcher, getCommerceProvider, registerAll, useAddItem, useBrands, useCart, useCategories, useCommerce, useRemoveItem, useSearch, useUpdateItem, x };
1828
1879
  //# sourceMappingURL=commerce.esm.js.map