@plasmicpkgs/plasmic-basic-components 0.0.140 → 0.0.142

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.
@@ -2,6 +2,36 @@ import { applySelector as applySelector$1, useSelector as useSelector$1, useSele
2
2
  import registerComponent from '@plasmicapp/host/registerComponent';
3
3
  import React, { createElement, useRef, useEffect, useContext, useState } from 'react';
4
4
 
5
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
6
+ try {
7
+ var info = gen[key](arg);
8
+ var value = info.value;
9
+ } catch (error) {
10
+ reject(error);
11
+ return;
12
+ }
13
+ if (info.done) {
14
+ resolve(value);
15
+ } else {
16
+ Promise.resolve(value).then(_next, _throw);
17
+ }
18
+ }
19
+ function _asyncToGenerator(fn) {
20
+ return function () {
21
+ var self = this,
22
+ args = arguments;
23
+ return new Promise(function (resolve, reject) {
24
+ var gen = fn.apply(self, args);
25
+ function _next(value) {
26
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
27
+ }
28
+ function _throw(err) {
29
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
30
+ }
31
+ _next(undefined);
32
+ });
33
+ };
34
+ }
5
35
  function _extends() {
6
36
  _extends = Object.assign ? Object.assign.bind() : function (target) {
7
37
  for (var i = 1; i < arguments.length; i++) {
@@ -260,6 +290,664 @@ function registerDynamicImage(loader, customDynamicImageMeta) {
260
290
  }
261
291
  }
262
292
 
293
+ function createCommonjsModule(fn, module) {
294
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
295
+ }
296
+
297
+ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
298
+ /**
299
+ * Copyright (c) 2014-present, Facebook, Inc.
300
+ *
301
+ * This source code is licensed under the MIT license found in the
302
+ * LICENSE file in the root directory of this source tree.
303
+ */
304
+
305
+ var runtime = function (exports) {
306
+
307
+ var Op = Object.prototype;
308
+ var hasOwn = Op.hasOwnProperty;
309
+ var undefined$1; // More compressible than void 0.
310
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
311
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
312
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
313
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
314
+ function define(obj, key, value) {
315
+ Object.defineProperty(obj, key, {
316
+ value: value,
317
+ enumerable: true,
318
+ configurable: true,
319
+ writable: true
320
+ });
321
+ return obj[key];
322
+ }
323
+ try {
324
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
325
+ define({}, "");
326
+ } catch (err) {
327
+ define = function define(obj, key, value) {
328
+ return obj[key] = value;
329
+ };
330
+ }
331
+ function wrap(innerFn, outerFn, self, tryLocsList) {
332
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
333
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
334
+ var generator = Object.create(protoGenerator.prototype);
335
+ var context = new Context(tryLocsList || []);
336
+
337
+ // The ._invoke method unifies the implementations of the .next,
338
+ // .throw, and .return methods.
339
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
340
+ return generator;
341
+ }
342
+ exports.wrap = wrap;
343
+
344
+ // Try/catch helper to minimize deoptimizations. Returns a completion
345
+ // record like context.tryEntries[i].completion. This interface could
346
+ // have been (and was previously) designed to take a closure to be
347
+ // invoked without arguments, but in all the cases we care about we
348
+ // already have an existing method we want to call, so there's no need
349
+ // to create a new function object. We can even get away with assuming
350
+ // the method takes exactly one argument, since that happens to be true
351
+ // in every case, so we don't have to touch the arguments object. The
352
+ // only additional allocation required is the completion record, which
353
+ // has a stable shape and so hopefully should be cheap to allocate.
354
+ function tryCatch(fn, obj, arg) {
355
+ try {
356
+ return {
357
+ type: "normal",
358
+ arg: fn.call(obj, arg)
359
+ };
360
+ } catch (err) {
361
+ return {
362
+ type: "throw",
363
+ arg: err
364
+ };
365
+ }
366
+ }
367
+ var GenStateSuspendedStart = "suspendedStart";
368
+ var GenStateSuspendedYield = "suspendedYield";
369
+ var GenStateExecuting = "executing";
370
+ var GenStateCompleted = "completed";
371
+
372
+ // Returning this object from the innerFn has the same effect as
373
+ // breaking out of the dispatch switch statement.
374
+ var ContinueSentinel = {};
375
+
376
+ // Dummy constructor functions that we use as the .constructor and
377
+ // .constructor.prototype properties for functions that return Generator
378
+ // objects. For full spec compliance, you may wish to configure your
379
+ // minifier not to mangle the names of these two functions.
380
+ function Generator() {}
381
+ function GeneratorFunction() {}
382
+ function GeneratorFunctionPrototype() {}
383
+
384
+ // This is a polyfill for %IteratorPrototype% for environments that
385
+ // don't natively support it.
386
+ var IteratorPrototype = {};
387
+ define(IteratorPrototype, iteratorSymbol, function () {
388
+ return this;
389
+ });
390
+ var getProto = Object.getPrototypeOf;
391
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
392
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
393
+ // This environment has a native %IteratorPrototype%; use it instead
394
+ // of the polyfill.
395
+ IteratorPrototype = NativeIteratorPrototype;
396
+ }
397
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
398
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
399
+ define(Gp, "constructor", GeneratorFunctionPrototype);
400
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
401
+ GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
402
+
403
+ // Helper for defining the .next, .throw, and .return methods of the
404
+ // Iterator interface in terms of a single ._invoke method.
405
+ function defineIteratorMethods(prototype) {
406
+ ["next", "throw", "return"].forEach(function (method) {
407
+ define(prototype, method, function (arg) {
408
+ return this._invoke(method, arg);
409
+ });
410
+ });
411
+ }
412
+ exports.isGeneratorFunction = function (genFun) {
413
+ var ctor = typeof genFun === "function" && genFun.constructor;
414
+ return ctor ? ctor === GeneratorFunction ||
415
+ // For the native GeneratorFunction constructor, the best we can
416
+ // do is to check its .name property.
417
+ (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
418
+ };
419
+ exports.mark = function (genFun) {
420
+ if (Object.setPrototypeOf) {
421
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
422
+ } else {
423
+ genFun.__proto__ = GeneratorFunctionPrototype;
424
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
425
+ }
426
+ genFun.prototype = Object.create(Gp);
427
+ return genFun;
428
+ };
429
+
430
+ // Within the body of any async function, `await x` is transformed to
431
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
432
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
433
+ // meant to be awaited.
434
+ exports.awrap = function (arg) {
435
+ return {
436
+ __await: arg
437
+ };
438
+ };
439
+ function AsyncIterator(generator, PromiseImpl) {
440
+ function invoke(method, arg, resolve, reject) {
441
+ var record = tryCatch(generator[method], generator, arg);
442
+ if (record.type === "throw") {
443
+ reject(record.arg);
444
+ } else {
445
+ var result = record.arg;
446
+ var value = result.value;
447
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
448
+ return PromiseImpl.resolve(value.__await).then(function (value) {
449
+ invoke("next", value, resolve, reject);
450
+ }, function (err) {
451
+ invoke("throw", err, resolve, reject);
452
+ });
453
+ }
454
+ return PromiseImpl.resolve(value).then(function (unwrapped) {
455
+ // When a yielded Promise is resolved, its final value becomes
456
+ // the .value of the Promise<{value,done}> result for the
457
+ // current iteration.
458
+ result.value = unwrapped;
459
+ resolve(result);
460
+ }, function (error) {
461
+ // If a rejected Promise was yielded, throw the rejection back
462
+ // into the async generator function so it can be handled there.
463
+ return invoke("throw", error, resolve, reject);
464
+ });
465
+ }
466
+ }
467
+ var previousPromise;
468
+ function enqueue(method, arg) {
469
+ function callInvokeWithMethodAndArg() {
470
+ return new PromiseImpl(function (resolve, reject) {
471
+ invoke(method, arg, resolve, reject);
472
+ });
473
+ }
474
+ return previousPromise =
475
+ // If enqueue has been called before, then we want to wait until
476
+ // all previous Promises have been resolved before calling invoke,
477
+ // so that results are always delivered in the correct order. If
478
+ // enqueue has not been called before, then it is important to
479
+ // call invoke immediately, without waiting on a callback to fire,
480
+ // so that the async generator function has the opportunity to do
481
+ // any necessary setup in a predictable way. This predictability
482
+ // is why the Promise constructor synchronously invokes its
483
+ // executor callback, and why async functions synchronously
484
+ // execute code before the first await. Since we implement simple
485
+ // async functions in terms of async generators, it is especially
486
+ // important to get this right, even though it requires care.
487
+ previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
488
+ // Avoid propagating failures to Promises returned by later
489
+ // invocations of the iterator.
490
+ callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
491
+ }
492
+
493
+ // Define the unified helper method that is used to implement .next,
494
+ // .throw, and .return (see defineIteratorMethods).
495
+ this._invoke = enqueue;
496
+ }
497
+ defineIteratorMethods(AsyncIterator.prototype);
498
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
499
+ return this;
500
+ });
501
+ exports.AsyncIterator = AsyncIterator;
502
+
503
+ // Note that simple async functions are implemented on top of
504
+ // AsyncIterator objects; they just return a Promise for the value of
505
+ // the final result produced by the iterator.
506
+ exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
507
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
508
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
509
+ return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
510
+ : iter.next().then(function (result) {
511
+ return result.done ? result.value : iter.next();
512
+ });
513
+ };
514
+ function makeInvokeMethod(innerFn, self, context) {
515
+ var state = GenStateSuspendedStart;
516
+ return function invoke(method, arg) {
517
+ if (state === GenStateExecuting) {
518
+ throw new Error("Generator is already running");
519
+ }
520
+ if (state === GenStateCompleted) {
521
+ if (method === "throw") {
522
+ throw arg;
523
+ }
524
+
525
+ // Be forgiving, per 25.3.3.3.3 of the spec:
526
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
527
+ return doneResult();
528
+ }
529
+ context.method = method;
530
+ context.arg = arg;
531
+ while (true) {
532
+ var delegate = context.delegate;
533
+ if (delegate) {
534
+ var delegateResult = maybeInvokeDelegate(delegate, context);
535
+ if (delegateResult) {
536
+ if (delegateResult === ContinueSentinel) continue;
537
+ return delegateResult;
538
+ }
539
+ }
540
+ if (context.method === "next") {
541
+ // Setting context._sent for legacy support of Babel's
542
+ // function.sent implementation.
543
+ context.sent = context._sent = context.arg;
544
+ } else if (context.method === "throw") {
545
+ if (state === GenStateSuspendedStart) {
546
+ state = GenStateCompleted;
547
+ throw context.arg;
548
+ }
549
+ context.dispatchException(context.arg);
550
+ } else if (context.method === "return") {
551
+ context.abrupt("return", context.arg);
552
+ }
553
+ state = GenStateExecuting;
554
+ var record = tryCatch(innerFn, self, context);
555
+ if (record.type === "normal") {
556
+ // If an exception is thrown from innerFn, we leave state ===
557
+ // GenStateExecuting and loop back for another invocation.
558
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
559
+ if (record.arg === ContinueSentinel) {
560
+ continue;
561
+ }
562
+ return {
563
+ value: record.arg,
564
+ done: context.done
565
+ };
566
+ } else if (record.type === "throw") {
567
+ state = GenStateCompleted;
568
+ // Dispatch the exception by looping back around to the
569
+ // context.dispatchException(context.arg) call above.
570
+ context.method = "throw";
571
+ context.arg = record.arg;
572
+ }
573
+ }
574
+ };
575
+ }
576
+
577
+ // Call delegate.iterator[context.method](context.arg) and handle the
578
+ // result, either by returning a { value, done } result from the
579
+ // delegate iterator, or by modifying context.method and context.arg,
580
+ // setting context.delegate to null, and returning the ContinueSentinel.
581
+ function maybeInvokeDelegate(delegate, context) {
582
+ var method = delegate.iterator[context.method];
583
+ if (method === undefined$1) {
584
+ // A .throw or .return when the delegate iterator has no .throw
585
+ // method always terminates the yield* loop.
586
+ context.delegate = null;
587
+ if (context.method === "throw") {
588
+ // Note: ["return"] must be used for ES3 parsing compatibility.
589
+ if (delegate.iterator["return"]) {
590
+ // If the delegate iterator has a return method, give it a
591
+ // chance to clean up.
592
+ context.method = "return";
593
+ context.arg = undefined$1;
594
+ maybeInvokeDelegate(delegate, context);
595
+ if (context.method === "throw") {
596
+ // If maybeInvokeDelegate(context) changed context.method from
597
+ // "return" to "throw", let that override the TypeError below.
598
+ return ContinueSentinel;
599
+ }
600
+ }
601
+ context.method = "throw";
602
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
603
+ }
604
+ return ContinueSentinel;
605
+ }
606
+ var record = tryCatch(method, delegate.iterator, context.arg);
607
+ if (record.type === "throw") {
608
+ context.method = "throw";
609
+ context.arg = record.arg;
610
+ context.delegate = null;
611
+ return ContinueSentinel;
612
+ }
613
+ var info = record.arg;
614
+ if (!info) {
615
+ context.method = "throw";
616
+ context.arg = new TypeError("iterator result is not an object");
617
+ context.delegate = null;
618
+ return ContinueSentinel;
619
+ }
620
+ if (info.done) {
621
+ // Assign the result of the finished delegate to the temporary
622
+ // variable specified by delegate.resultName (see delegateYield).
623
+ context[delegate.resultName] = info.value;
624
+
625
+ // Resume execution at the desired location (see delegateYield).
626
+ context.next = delegate.nextLoc;
627
+
628
+ // If context.method was "throw" but the delegate handled the
629
+ // exception, let the outer generator proceed normally. If
630
+ // context.method was "next", forget context.arg since it has been
631
+ // "consumed" by the delegate iterator. If context.method was
632
+ // "return", allow the original .return call to continue in the
633
+ // outer generator.
634
+ if (context.method !== "return") {
635
+ context.method = "next";
636
+ context.arg = undefined$1;
637
+ }
638
+ } else {
639
+ // Re-yield the result returned by the delegate method.
640
+ return info;
641
+ }
642
+
643
+ // The delegate iterator is finished, so forget it and continue with
644
+ // the outer generator.
645
+ context.delegate = null;
646
+ return ContinueSentinel;
647
+ }
648
+
649
+ // Define Generator.prototype.{next,throw,return} in terms of the
650
+ // unified ._invoke helper method.
651
+ defineIteratorMethods(Gp);
652
+ define(Gp, toStringTagSymbol, "Generator");
653
+
654
+ // A Generator should always return itself as the iterator object when the
655
+ // @@iterator function is called on it. Some browsers' implementations of the
656
+ // iterator prototype chain incorrectly implement this, causing the Generator
657
+ // object to not be returned from this call. This ensures that doesn't happen.
658
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
659
+ define(Gp, iteratorSymbol, function () {
660
+ return this;
661
+ });
662
+ define(Gp, "toString", function () {
663
+ return "[object Generator]";
664
+ });
665
+ function pushTryEntry(locs) {
666
+ var entry = {
667
+ tryLoc: locs[0]
668
+ };
669
+ if (1 in locs) {
670
+ entry.catchLoc = locs[1];
671
+ }
672
+ if (2 in locs) {
673
+ entry.finallyLoc = locs[2];
674
+ entry.afterLoc = locs[3];
675
+ }
676
+ this.tryEntries.push(entry);
677
+ }
678
+ function resetTryEntry(entry) {
679
+ var record = entry.completion || {};
680
+ record.type = "normal";
681
+ delete record.arg;
682
+ entry.completion = record;
683
+ }
684
+ function Context(tryLocsList) {
685
+ // The root entry object (effectively a try statement without a catch
686
+ // or a finally block) gives us a place to store values thrown from
687
+ // locations where there is no enclosing try statement.
688
+ this.tryEntries = [{
689
+ tryLoc: "root"
690
+ }];
691
+ tryLocsList.forEach(pushTryEntry, this);
692
+ this.reset(true);
693
+ }
694
+ exports.keys = function (object) {
695
+ var keys = [];
696
+ for (var key in object) {
697
+ keys.push(key);
698
+ }
699
+ keys.reverse();
700
+
701
+ // Rather than returning an object with a next method, we keep
702
+ // things simple and return the next function itself.
703
+ return function next() {
704
+ while (keys.length) {
705
+ var key = keys.pop();
706
+ if (key in object) {
707
+ next.value = key;
708
+ next.done = false;
709
+ return next;
710
+ }
711
+ }
712
+
713
+ // To avoid creating an additional object, we just hang the .value
714
+ // and .done properties off the next function object itself. This
715
+ // also ensures that the minifier will not anonymize the function.
716
+ next.done = true;
717
+ return next;
718
+ };
719
+ };
720
+ function values(iterable) {
721
+ if (iterable) {
722
+ var iteratorMethod = iterable[iteratorSymbol];
723
+ if (iteratorMethod) {
724
+ return iteratorMethod.call(iterable);
725
+ }
726
+ if (typeof iterable.next === "function") {
727
+ return iterable;
728
+ }
729
+ if (!isNaN(iterable.length)) {
730
+ var i = -1,
731
+ next = function next() {
732
+ while (++i < iterable.length) {
733
+ if (hasOwn.call(iterable, i)) {
734
+ next.value = iterable[i];
735
+ next.done = false;
736
+ return next;
737
+ }
738
+ }
739
+ next.value = undefined$1;
740
+ next.done = true;
741
+ return next;
742
+ };
743
+ return next.next = next;
744
+ }
745
+ }
746
+
747
+ // Return an iterator with no values.
748
+ return {
749
+ next: doneResult
750
+ };
751
+ }
752
+ exports.values = values;
753
+ function doneResult() {
754
+ return {
755
+ value: undefined$1,
756
+ done: true
757
+ };
758
+ }
759
+ Context.prototype = {
760
+ constructor: Context,
761
+ reset: function reset(skipTempReset) {
762
+ this.prev = 0;
763
+ this.next = 0;
764
+ // Resetting context._sent for legacy support of Babel's
765
+ // function.sent implementation.
766
+ this.sent = this._sent = undefined$1;
767
+ this.done = false;
768
+ this.delegate = null;
769
+ this.method = "next";
770
+ this.arg = undefined$1;
771
+ this.tryEntries.forEach(resetTryEntry);
772
+ if (!skipTempReset) {
773
+ for (var name in this) {
774
+ // Not sure about the optimal order of these conditions:
775
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
776
+ this[name] = undefined$1;
777
+ }
778
+ }
779
+ }
780
+ },
781
+ stop: function stop() {
782
+ this.done = true;
783
+ var rootEntry = this.tryEntries[0];
784
+ var rootRecord = rootEntry.completion;
785
+ if (rootRecord.type === "throw") {
786
+ throw rootRecord.arg;
787
+ }
788
+ return this.rval;
789
+ },
790
+ dispatchException: function dispatchException(exception) {
791
+ if (this.done) {
792
+ throw exception;
793
+ }
794
+ var context = this;
795
+ function handle(loc, caught) {
796
+ record.type = "throw";
797
+ record.arg = exception;
798
+ context.next = loc;
799
+ if (caught) {
800
+ // If the dispatched exception was caught by a catch block,
801
+ // then let that catch block handle the exception normally.
802
+ context.method = "next";
803
+ context.arg = undefined$1;
804
+ }
805
+ return !!caught;
806
+ }
807
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
808
+ var entry = this.tryEntries[i];
809
+ var record = entry.completion;
810
+ if (entry.tryLoc === "root") {
811
+ // Exception thrown outside of any try block that could handle
812
+ // it, so set the completion value of the entire function to
813
+ // throw the exception.
814
+ return handle("end");
815
+ }
816
+ if (entry.tryLoc <= this.prev) {
817
+ var hasCatch = hasOwn.call(entry, "catchLoc");
818
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
819
+ if (hasCatch && hasFinally) {
820
+ if (this.prev < entry.catchLoc) {
821
+ return handle(entry.catchLoc, true);
822
+ } else if (this.prev < entry.finallyLoc) {
823
+ return handle(entry.finallyLoc);
824
+ }
825
+ } else if (hasCatch) {
826
+ if (this.prev < entry.catchLoc) {
827
+ return handle(entry.catchLoc, true);
828
+ }
829
+ } else if (hasFinally) {
830
+ if (this.prev < entry.finallyLoc) {
831
+ return handle(entry.finallyLoc);
832
+ }
833
+ } else {
834
+ throw new Error("try statement without catch or finally");
835
+ }
836
+ }
837
+ }
838
+ },
839
+ abrupt: function abrupt(type, arg) {
840
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
841
+ var entry = this.tryEntries[i];
842
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
843
+ var finallyEntry = entry;
844
+ break;
845
+ }
846
+ }
847
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
848
+ // Ignore the finally entry if control is not jumping to a
849
+ // location outside the try/catch block.
850
+ finallyEntry = null;
851
+ }
852
+ var record = finallyEntry ? finallyEntry.completion : {};
853
+ record.type = type;
854
+ record.arg = arg;
855
+ if (finallyEntry) {
856
+ this.method = "next";
857
+ this.next = finallyEntry.finallyLoc;
858
+ return ContinueSentinel;
859
+ }
860
+ return this.complete(record);
861
+ },
862
+ complete: function complete(record, afterLoc) {
863
+ if (record.type === "throw") {
864
+ throw record.arg;
865
+ }
866
+ if (record.type === "break" || record.type === "continue") {
867
+ this.next = record.arg;
868
+ } else if (record.type === "return") {
869
+ this.rval = this.arg = record.arg;
870
+ this.method = "return";
871
+ this.next = "end";
872
+ } else if (record.type === "normal" && afterLoc) {
873
+ this.next = afterLoc;
874
+ }
875
+ return ContinueSentinel;
876
+ },
877
+ finish: function finish(finallyLoc) {
878
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
879
+ var entry = this.tryEntries[i];
880
+ if (entry.finallyLoc === finallyLoc) {
881
+ this.complete(entry.completion, entry.afterLoc);
882
+ resetTryEntry(entry);
883
+ return ContinueSentinel;
884
+ }
885
+ }
886
+ },
887
+ "catch": function _catch(tryLoc) {
888
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
889
+ var entry = this.tryEntries[i];
890
+ if (entry.tryLoc === tryLoc) {
891
+ var record = entry.completion;
892
+ if (record.type === "throw") {
893
+ var thrown = record.arg;
894
+ resetTryEntry(entry);
895
+ }
896
+ return thrown;
897
+ }
898
+ }
899
+
900
+ // The context.catch method must only be called with a location
901
+ // argument that corresponds to a known catch block.
902
+ throw new Error("illegal catch attempt");
903
+ },
904
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
905
+ this.delegate = {
906
+ iterator: values(iterable),
907
+ resultName: resultName,
908
+ nextLoc: nextLoc
909
+ };
910
+ if (this.method === "next") {
911
+ // Deliberately forget the last sent value so that we don't
912
+ // accidentally pass it on to the delegate.
913
+ this.arg = undefined$1;
914
+ }
915
+ return ContinueSentinel;
916
+ }
917
+ };
918
+
919
+ // Regardless of whether this script is executing as a CommonJS module
920
+ // or not, return the runtime object so that we can declare the variable
921
+ // regeneratorRuntime in the outer scope, which allows this module to be
922
+ // injected easily by `bin/regenerator --include-runtime script.js`.
923
+ return exports;
924
+ }(
925
+ // If this script is executing as a CommonJS module, use module.exports
926
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
927
+ // object. Either way, the resulting object will be used to initialize
928
+ // the regeneratorRuntime variable at the top of this file.
929
+ module.exports );
930
+ try {
931
+ regeneratorRuntime = runtime;
932
+ } catch (accidentalStrictMode) {
933
+ // This module should not be running in strict mode, so the above
934
+ // assignment should always work unless something is misconfigured. Just
935
+ // in case runtime.js accidentally runs in strict mode, in modern engines
936
+ // we can explicitly access globalThis. In older engines we can escape
937
+ // strict mode using a global Function call. This could conceivably fail
938
+ // if a Content Security Policy forbids using Function, but in that case
939
+ // the proper solution is to fix the accidental strict mode problem. If
940
+ // you've misconfigured your bundler to force strict mode and applied a
941
+ // CSP to forbid Function, and you're not willing to fix either of those
942
+ // problems, please detail your unique predicament in a GitHub issue.
943
+ if (typeof globalThis === "object") {
944
+ globalThis.regeneratorRuntime = runtime;
945
+ } else {
946
+ Function("r", "regeneratorRuntime = r")(runtime);
947
+ }
948
+ }
949
+ });
950
+
263
951
  function ensure(x) {
264
952
  if (x === null || x === undefined) {
265
953
  debugger;
@@ -269,6 +957,18 @@ function ensure(x) {
269
957
  }
270
958
  }
271
959
 
960
+ /**
961
+ * A common use case for embedding HTML snippets is loading/running script tags, so most of the logic here is for
962
+ * handling that.
963
+ *
964
+ * You can't just write innerHTML with some <script> tags in there. You need to explicitly add each one via the DOM API.
965
+ *
966
+ * You also can't just add the script tags and expect them to run sequentially, and sometimes there are multiple scripts
967
+ * with dependencies on each other. You have to explicitly wait for earlier ones to finish loading.
968
+ *
969
+ * One last complication is that Next.js can run the effect multiple times in development mode. There's nothing actually
970
+ * that we can/should do about that, but just something to be aware of if you are here debugging issues.
971
+ */
272
972
  function Embed(_ref) {
273
973
  var className = _ref.className,
274
974
  code = _ref.code,
@@ -280,14 +980,62 @@ function Embed(_ref) {
280
980
  if (hideInEditor && inEditor) {
281
981
  return;
282
982
  }
283
- Array.from(ensure(rootElt.current).querySelectorAll("script")).forEach(function (oldScript) {
284
- var newScript = document.createElement("script");
285
- Array.from(oldScript.attributes).forEach(function (attr) {
286
- return newScript.setAttribute(attr.name, attr.value);
287
- });
288
- newScript.appendChild(document.createTextNode(oldScript.innerHTML));
289
- ensure(oldScript.parentNode).replaceChild(newScript, oldScript);
290
- });
983
+ // Load scripts sequentially one at a time, since later scripts can depend on earlier ones.
984
+ _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
985
+ var _loop, _i, _Array$from;
986
+ return runtime_1.wrap(function _callee$(_context2) {
987
+ while (1) {
988
+ switch (_context2.prev = _context2.next) {
989
+ case 0:
990
+ _loop = /*#__PURE__*/runtime_1.mark(function _loop() {
991
+ var oldScript, newScript;
992
+ return runtime_1.wrap(function _loop$(_context) {
993
+ while (1) {
994
+ switch (_context.prev = _context.next) {
995
+ case 0:
996
+ oldScript = _Array$from[_i];
997
+ newScript = document.createElement("script"); // This doesn't actually have the effect we want, we need to explicitly wait on the load event, since all
998
+ // dynamically injected scripts are always async.
999
+ newScript.async = false;
1000
+ Array.from(oldScript.attributes).forEach(function (attr) {
1001
+ return newScript.setAttribute(attr.name, attr.value);
1002
+ });
1003
+ newScript.appendChild(document.createTextNode(oldScript.innerHTML));
1004
+ ensure(oldScript.parentNode).replaceChild(newScript, oldScript);
1005
+ // Only scripts with src will ever fire a load event.
1006
+ if (!newScript.src) {
1007
+ _context.next = 9;
1008
+ break;
1009
+ }
1010
+ _context.next = 9;
1011
+ return new Promise(function (resolve) {
1012
+ return newScript.addEventListener("load", resolve);
1013
+ });
1014
+ case 9:
1015
+ case "end":
1016
+ return _context.stop();
1017
+ }
1018
+ }
1019
+ }, _loop);
1020
+ });
1021
+ _i = 0, _Array$from = Array.from(ensure(rootElt.current).querySelectorAll("script"));
1022
+ case 2:
1023
+ if (!(_i < _Array$from.length)) {
1024
+ _context2.next = 7;
1025
+ break;
1026
+ }
1027
+ return _context2.delegateYield(_loop(), "t0", 4);
1028
+ case 4:
1029
+ _i++;
1030
+ _context2.next = 2;
1031
+ break;
1032
+ case 7:
1033
+ case "end":
1034
+ return _context2.stop();
1035
+ }
1036
+ }
1037
+ }, _callee);
1038
+ }))();
291
1039
  }, [code, hideInEditor]);
292
1040
  var effectiveCode = hideInEditor && inEditor ? "" : code;
293
1041
  return React.createElement("div", {