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