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