@plasmicapp/loader-core 1.0.70 → 1.0.71

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.
@@ -1,58 +1,4 @@
1
- import fetch from 'isomorphic-unfetch';
2
-
3
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4
- try {
5
- var info = gen[key](arg);
6
- var value = info.value;
7
- } catch (error) {
8
- reject(error);
9
- return;
10
- }
11
-
12
- if (info.done) {
13
- resolve(value);
14
- } else {
15
- Promise.resolve(value).then(_next, _throw);
16
- }
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
-
26
- function _next(value) {
27
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
28
- }
29
-
30
- function _throw(err) {
31
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
32
- }
33
-
34
- _next(undefined);
35
- });
36
- };
37
- }
38
-
39
- function _extends() {
40
- _extends = Object.assign || function (target) {
41
- for (var i = 1; i < arguments.length; i++) {
42
- var source = arguments[i];
43
-
44
- for (var key in source) {
45
- if (Object.prototype.hasOwnProperty.call(source, key)) {
46
- target[key] = source[key];
47
- }
48
- }
49
- }
50
-
51
- return target;
52
- };
53
-
54
- return _extends.apply(this, arguments);
55
- }
1
+ export { Api, PlasmicModulesFetcher } from '@plasmicapp/loader-fetcher';
56
2
 
57
3
  function _unsupportedIterableToArray(o, minLen) {
58
4
  if (!o) return;
@@ -92,868 +38,6 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
92
38
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
93
39
  }
94
40
 
95
- function createCommonjsModule(fn, module) {
96
- return module = { exports: {} }, fn(module, module.exports), module.exports;
97
- }
98
-
99
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
100
- /**
101
- * Copyright (c) 2014-present, Facebook, Inc.
102
- *
103
- * This source code is licensed under the MIT license found in the
104
- * LICENSE file in the root directory of this source tree.
105
- */
106
- var runtime = function (exports) {
107
-
108
- var Op = Object.prototype;
109
- var hasOwn = Op.hasOwnProperty;
110
- var undefined$1; // More compressible than void 0.
111
-
112
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
113
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
114
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
115
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
116
-
117
- function define(obj, key, value) {
118
- Object.defineProperty(obj, key, {
119
- value: value,
120
- enumerable: true,
121
- configurable: true,
122
- writable: true
123
- });
124
- return obj[key];
125
- }
126
-
127
- try {
128
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
129
- define({}, "");
130
- } catch (err) {
131
- define = function define(obj, key, value) {
132
- return obj[key] = value;
133
- };
134
- }
135
-
136
- function wrap(innerFn, outerFn, self, tryLocsList) {
137
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
138
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
139
- var generator = Object.create(protoGenerator.prototype);
140
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
141
- // .throw, and .return methods.
142
-
143
- generator._invoke = makeInvokeMethod(innerFn, self, context);
144
- return generator;
145
- }
146
-
147
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
148
- // record like context.tryEntries[i].completion. This interface could
149
- // have been (and was previously) designed to take a closure to be
150
- // invoked without arguments, but in all the cases we care about we
151
- // already have an existing method we want to call, so there's no need
152
- // to create a new function object. We can even get away with assuming
153
- // the method takes exactly one argument, since that happens to be true
154
- // in every case, so we don't have to touch the arguments object. The
155
- // only additional allocation required is the completion record, which
156
- // has a stable shape and so hopefully should be cheap to allocate.
157
-
158
- function tryCatch(fn, obj, arg) {
159
- try {
160
- return {
161
- type: "normal",
162
- arg: fn.call(obj, arg)
163
- };
164
- } catch (err) {
165
- return {
166
- type: "throw",
167
- arg: err
168
- };
169
- }
170
- }
171
-
172
- var GenStateSuspendedStart = "suspendedStart";
173
- var GenStateSuspendedYield = "suspendedYield";
174
- var GenStateExecuting = "executing";
175
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
176
- // breaking out of the dispatch switch statement.
177
-
178
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
179
- // .constructor.prototype properties for functions that return Generator
180
- // objects. For full spec compliance, you may wish to configure your
181
- // minifier not to mangle the names of these two functions.
182
-
183
- function Generator() {}
184
-
185
- function GeneratorFunction() {}
186
-
187
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
188
- // don't natively support it.
189
-
190
-
191
- var IteratorPrototype = {};
192
-
193
- IteratorPrototype[iteratorSymbol] = function () {
194
- return this;
195
- };
196
-
197
- var getProto = Object.getPrototypeOf;
198
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
199
-
200
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
201
- // This environment has a native %IteratorPrototype%; use it instead
202
- // of the polyfill.
203
- IteratorPrototype = NativeIteratorPrototype;
204
- }
205
-
206
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
207
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
208
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
209
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
210
- // Iterator interface in terms of a single ._invoke method.
211
-
212
- function defineIteratorMethods(prototype) {
213
- ["next", "throw", "return"].forEach(function (method) {
214
- define(prototype, method, function (arg) {
215
- return this._invoke(method, arg);
216
- });
217
- });
218
- }
219
-
220
- exports.isGeneratorFunction = function (genFun) {
221
- var ctor = typeof genFun === "function" && genFun.constructor;
222
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
223
- // do is to check its .name property.
224
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
225
- };
226
-
227
- exports.mark = function (genFun) {
228
- if (Object.setPrototypeOf) {
229
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
230
- } else {
231
- genFun.__proto__ = GeneratorFunctionPrototype;
232
- define(genFun, toStringTagSymbol, "GeneratorFunction");
233
- }
234
-
235
- genFun.prototype = Object.create(Gp);
236
- return genFun;
237
- }; // Within the body of any async function, `await x` is transformed to
238
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
239
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
240
- // meant to be awaited.
241
-
242
-
243
- exports.awrap = function (arg) {
244
- return {
245
- __await: arg
246
- };
247
- };
248
-
249
- function AsyncIterator(generator, PromiseImpl) {
250
- function invoke(method, arg, resolve, reject) {
251
- var record = tryCatch(generator[method], generator, arg);
252
-
253
- if (record.type === "throw") {
254
- reject(record.arg);
255
- } else {
256
- var result = record.arg;
257
- var value = result.value;
258
-
259
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
260
- return PromiseImpl.resolve(value.__await).then(function (value) {
261
- invoke("next", value, resolve, reject);
262
- }, function (err) {
263
- invoke("throw", err, resolve, reject);
264
- });
265
- }
266
-
267
- return PromiseImpl.resolve(value).then(function (unwrapped) {
268
- // When a yielded Promise is resolved, its final value becomes
269
- // the .value of the Promise<{value,done}> result for the
270
- // current iteration.
271
- result.value = unwrapped;
272
- resolve(result);
273
- }, function (error) {
274
- // If a rejected Promise was yielded, throw the rejection back
275
- // into the async generator function so it can be handled there.
276
- return invoke("throw", error, resolve, reject);
277
- });
278
- }
279
- }
280
-
281
- var previousPromise;
282
-
283
- function enqueue(method, arg) {
284
- function callInvokeWithMethodAndArg() {
285
- return new PromiseImpl(function (resolve, reject) {
286
- invoke(method, arg, resolve, reject);
287
- });
288
- }
289
-
290
- return previousPromise = // If enqueue has been called before, then we want to wait until
291
- // all previous Promises have been resolved before calling invoke,
292
- // so that results are always delivered in the correct order. If
293
- // enqueue has not been called before, then it is important to
294
- // call invoke immediately, without waiting on a callback to fire,
295
- // so that the async generator function has the opportunity to do
296
- // any necessary setup in a predictable way. This predictability
297
- // is why the Promise constructor synchronously invokes its
298
- // executor callback, and why async functions synchronously
299
- // execute code before the first await. Since we implement simple
300
- // async functions in terms of async generators, it is especially
301
- // important to get this right, even though it requires care.
302
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
303
- // invocations of the iterator.
304
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
305
- } // Define the unified helper method that is used to implement .next,
306
- // .throw, and .return (see defineIteratorMethods).
307
-
308
-
309
- this._invoke = enqueue;
310
- }
311
-
312
- defineIteratorMethods(AsyncIterator.prototype);
313
-
314
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
315
- return this;
316
- };
317
-
318
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
319
- // AsyncIterator objects; they just return a Promise for the value of
320
- // the final result produced by the iterator.
321
-
322
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
323
- if (PromiseImpl === void 0) PromiseImpl = Promise;
324
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
325
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
326
- : iter.next().then(function (result) {
327
- return result.done ? result.value : iter.next();
328
- });
329
- };
330
-
331
- function makeInvokeMethod(innerFn, self, context) {
332
- var state = GenStateSuspendedStart;
333
- return function invoke(method, arg) {
334
- if (state === GenStateExecuting) {
335
- throw new Error("Generator is already running");
336
- }
337
-
338
- if (state === GenStateCompleted) {
339
- if (method === "throw") {
340
- throw arg;
341
- } // Be forgiving, per 25.3.3.3.3 of the spec:
342
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
343
-
344
-
345
- return doneResult();
346
- }
347
-
348
- context.method = method;
349
- context.arg = arg;
350
-
351
- while (true) {
352
- var delegate = context.delegate;
353
-
354
- if (delegate) {
355
- var delegateResult = maybeInvokeDelegate(delegate, context);
356
-
357
- if (delegateResult) {
358
- if (delegateResult === ContinueSentinel) continue;
359
- return delegateResult;
360
- }
361
- }
362
-
363
- if (context.method === "next") {
364
- // Setting context._sent for legacy support of Babel's
365
- // function.sent implementation.
366
- context.sent = context._sent = context.arg;
367
- } else if (context.method === "throw") {
368
- if (state === GenStateSuspendedStart) {
369
- state = GenStateCompleted;
370
- throw context.arg;
371
- }
372
-
373
- context.dispatchException(context.arg);
374
- } else if (context.method === "return") {
375
- context.abrupt("return", context.arg);
376
- }
377
-
378
- state = GenStateExecuting;
379
- var record = tryCatch(innerFn, self, context);
380
-
381
- if (record.type === "normal") {
382
- // If an exception is thrown from innerFn, we leave state ===
383
- // GenStateExecuting and loop back for another invocation.
384
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
385
-
386
- if (record.arg === ContinueSentinel) {
387
- continue;
388
- }
389
-
390
- return {
391
- value: record.arg,
392
- done: context.done
393
- };
394
- } else if (record.type === "throw") {
395
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
396
- // context.dispatchException(context.arg) call above.
397
-
398
- context.method = "throw";
399
- context.arg = record.arg;
400
- }
401
- }
402
- };
403
- } // Call delegate.iterator[context.method](context.arg) and handle the
404
- // result, either by returning a { value, done } result from the
405
- // delegate iterator, or by modifying context.method and context.arg,
406
- // setting context.delegate to null, and returning the ContinueSentinel.
407
-
408
-
409
- function maybeInvokeDelegate(delegate, context) {
410
- var method = delegate.iterator[context.method];
411
-
412
- if (method === undefined$1) {
413
- // A .throw or .return when the delegate iterator has no .throw
414
- // method always terminates the yield* loop.
415
- context.delegate = null;
416
-
417
- if (context.method === "throw") {
418
- // Note: ["return"] must be used for ES3 parsing compatibility.
419
- if (delegate.iterator["return"]) {
420
- // If the delegate iterator has a return method, give it a
421
- // chance to clean up.
422
- context.method = "return";
423
- context.arg = undefined$1;
424
- maybeInvokeDelegate(delegate, context);
425
-
426
- if (context.method === "throw") {
427
- // If maybeInvokeDelegate(context) changed context.method from
428
- // "return" to "throw", let that override the TypeError below.
429
- return ContinueSentinel;
430
- }
431
- }
432
-
433
- context.method = "throw";
434
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
435
- }
436
-
437
- return ContinueSentinel;
438
- }
439
-
440
- var record = tryCatch(method, delegate.iterator, context.arg);
441
-
442
- if (record.type === "throw") {
443
- context.method = "throw";
444
- context.arg = record.arg;
445
- context.delegate = null;
446
- return ContinueSentinel;
447
- }
448
-
449
- var info = record.arg;
450
-
451
- if (!info) {
452
- context.method = "throw";
453
- context.arg = new TypeError("iterator result is not an object");
454
- context.delegate = null;
455
- return ContinueSentinel;
456
- }
457
-
458
- if (info.done) {
459
- // Assign the result of the finished delegate to the temporary
460
- // variable specified by delegate.resultName (see delegateYield).
461
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
462
-
463
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
464
- // exception, let the outer generator proceed normally. If
465
- // context.method was "next", forget context.arg since it has been
466
- // "consumed" by the delegate iterator. If context.method was
467
- // "return", allow the original .return call to continue in the
468
- // outer generator.
469
-
470
- if (context.method !== "return") {
471
- context.method = "next";
472
- context.arg = undefined$1;
473
- }
474
- } else {
475
- // Re-yield the result returned by the delegate method.
476
- return info;
477
- } // The delegate iterator is finished, so forget it and continue with
478
- // the outer generator.
479
-
480
-
481
- context.delegate = null;
482
- return ContinueSentinel;
483
- } // Define Generator.prototype.{next,throw,return} in terms of the
484
- // unified ._invoke helper method.
485
-
486
-
487
- defineIteratorMethods(Gp);
488
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
489
- // @@iterator function is called on it. Some browsers' implementations of the
490
- // iterator prototype chain incorrectly implement this, causing the Generator
491
- // object to not be returned from this call. This ensures that doesn't happen.
492
- // See https://github.com/facebook/regenerator/issues/274 for more details.
493
-
494
- Gp[iteratorSymbol] = function () {
495
- return this;
496
- };
497
-
498
- Gp.toString = function () {
499
- return "[object Generator]";
500
- };
501
-
502
- function pushTryEntry(locs) {
503
- var entry = {
504
- tryLoc: locs[0]
505
- };
506
-
507
- if (1 in locs) {
508
- entry.catchLoc = locs[1];
509
- }
510
-
511
- if (2 in locs) {
512
- entry.finallyLoc = locs[2];
513
- entry.afterLoc = locs[3];
514
- }
515
-
516
- this.tryEntries.push(entry);
517
- }
518
-
519
- function resetTryEntry(entry) {
520
- var record = entry.completion || {};
521
- record.type = "normal";
522
- delete record.arg;
523
- entry.completion = record;
524
- }
525
-
526
- function Context(tryLocsList) {
527
- // The root entry object (effectively a try statement without a catch
528
- // or a finally block) gives us a place to store values thrown from
529
- // locations where there is no enclosing try statement.
530
- this.tryEntries = [{
531
- tryLoc: "root"
532
- }];
533
- tryLocsList.forEach(pushTryEntry, this);
534
- this.reset(true);
535
- }
536
-
537
- exports.keys = function (object) {
538
- var keys = [];
539
-
540
- for (var key in object) {
541
- keys.push(key);
542
- }
543
-
544
- keys.reverse(); // Rather than returning an object with a next method, we keep
545
- // things simple and return the next function itself.
546
-
547
- return function next() {
548
- while (keys.length) {
549
- var key = keys.pop();
550
-
551
- if (key in object) {
552
- next.value = key;
553
- next.done = false;
554
- return next;
555
- }
556
- } // To avoid creating an additional object, we just hang the .value
557
- // and .done properties off the next function object itself. This
558
- // also ensures that the minifier will not anonymize the function.
559
-
560
-
561
- next.done = true;
562
- return next;
563
- };
564
- };
565
-
566
- function values(iterable) {
567
- if (iterable) {
568
- var iteratorMethod = iterable[iteratorSymbol];
569
-
570
- if (iteratorMethod) {
571
- return iteratorMethod.call(iterable);
572
- }
573
-
574
- if (typeof iterable.next === "function") {
575
- return iterable;
576
- }
577
-
578
- if (!isNaN(iterable.length)) {
579
- var i = -1,
580
- next = function next() {
581
- while (++i < iterable.length) {
582
- if (hasOwn.call(iterable, i)) {
583
- next.value = iterable[i];
584
- next.done = false;
585
- return next;
586
- }
587
- }
588
-
589
- next.value = undefined$1;
590
- next.done = true;
591
- return next;
592
- };
593
-
594
- return next.next = next;
595
- }
596
- } // Return an iterator with no values.
597
-
598
-
599
- return {
600
- next: doneResult
601
- };
602
- }
603
-
604
- exports.values = values;
605
-
606
- function doneResult() {
607
- return {
608
- value: undefined$1,
609
- done: true
610
- };
611
- }
612
-
613
- Context.prototype = {
614
- constructor: Context,
615
- reset: function reset(skipTempReset) {
616
- this.prev = 0;
617
- this.next = 0; // Resetting context._sent for legacy support of Babel's
618
- // function.sent implementation.
619
-
620
- this.sent = this._sent = undefined$1;
621
- this.done = false;
622
- this.delegate = null;
623
- this.method = "next";
624
- this.arg = undefined$1;
625
- this.tryEntries.forEach(resetTryEntry);
626
-
627
- if (!skipTempReset) {
628
- for (var name in this) {
629
- // Not sure about the optimal order of these conditions:
630
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
631
- this[name] = undefined$1;
632
- }
633
- }
634
- }
635
- },
636
- stop: function stop() {
637
- this.done = true;
638
- var rootEntry = this.tryEntries[0];
639
- var rootRecord = rootEntry.completion;
640
-
641
- if (rootRecord.type === "throw") {
642
- throw rootRecord.arg;
643
- }
644
-
645
- return this.rval;
646
- },
647
- dispatchException: function dispatchException(exception) {
648
- if (this.done) {
649
- throw exception;
650
- }
651
-
652
- var context = this;
653
-
654
- function handle(loc, caught) {
655
- record.type = "throw";
656
- record.arg = exception;
657
- context.next = loc;
658
-
659
- if (caught) {
660
- // If the dispatched exception was caught by a catch block,
661
- // then let that catch block handle the exception normally.
662
- context.method = "next";
663
- context.arg = undefined$1;
664
- }
665
-
666
- return !!caught;
667
- }
668
-
669
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
670
- var entry = this.tryEntries[i];
671
- var record = entry.completion;
672
-
673
- if (entry.tryLoc === "root") {
674
- // Exception thrown outside of any try block that could handle
675
- // it, so set the completion value of the entire function to
676
- // throw the exception.
677
- return handle("end");
678
- }
679
-
680
- if (entry.tryLoc <= this.prev) {
681
- var hasCatch = hasOwn.call(entry, "catchLoc");
682
- var hasFinally = hasOwn.call(entry, "finallyLoc");
683
-
684
- if (hasCatch && hasFinally) {
685
- if (this.prev < entry.catchLoc) {
686
- return handle(entry.catchLoc, true);
687
- } else if (this.prev < entry.finallyLoc) {
688
- return handle(entry.finallyLoc);
689
- }
690
- } else if (hasCatch) {
691
- if (this.prev < entry.catchLoc) {
692
- return handle(entry.catchLoc, true);
693
- }
694
- } else if (hasFinally) {
695
- if (this.prev < entry.finallyLoc) {
696
- return handle(entry.finallyLoc);
697
- }
698
- } else {
699
- throw new Error("try statement without catch or finally");
700
- }
701
- }
702
- }
703
- },
704
- abrupt: function abrupt(type, arg) {
705
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
706
- var entry = this.tryEntries[i];
707
-
708
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
709
- var finallyEntry = entry;
710
- break;
711
- }
712
- }
713
-
714
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
715
- // Ignore the finally entry if control is not jumping to a
716
- // location outside the try/catch block.
717
- finallyEntry = null;
718
- }
719
-
720
- var record = finallyEntry ? finallyEntry.completion : {};
721
- record.type = type;
722
- record.arg = arg;
723
-
724
- if (finallyEntry) {
725
- this.method = "next";
726
- this.next = finallyEntry.finallyLoc;
727
- return ContinueSentinel;
728
- }
729
-
730
- return this.complete(record);
731
- },
732
- complete: function complete(record, afterLoc) {
733
- if (record.type === "throw") {
734
- throw record.arg;
735
- }
736
-
737
- if (record.type === "break" || record.type === "continue") {
738
- this.next = record.arg;
739
- } else if (record.type === "return") {
740
- this.rval = this.arg = record.arg;
741
- this.method = "return";
742
- this.next = "end";
743
- } else if (record.type === "normal" && afterLoc) {
744
- this.next = afterLoc;
745
- }
746
-
747
- return ContinueSentinel;
748
- },
749
- finish: function finish(finallyLoc) {
750
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
751
- var entry = this.tryEntries[i];
752
-
753
- if (entry.finallyLoc === finallyLoc) {
754
- this.complete(entry.completion, entry.afterLoc);
755
- resetTryEntry(entry);
756
- return ContinueSentinel;
757
- }
758
- }
759
- },
760
- "catch": function _catch(tryLoc) {
761
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
762
- var entry = this.tryEntries[i];
763
-
764
- if (entry.tryLoc === tryLoc) {
765
- var record = entry.completion;
766
-
767
- if (record.type === "throw") {
768
- var thrown = record.arg;
769
- resetTryEntry(entry);
770
- }
771
-
772
- return thrown;
773
- }
774
- } // The context.catch method must only be called with a location
775
- // argument that corresponds to a known catch block.
776
-
777
-
778
- throw new Error("illegal catch attempt");
779
- },
780
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
781
- this.delegate = {
782
- iterator: values(iterable),
783
- resultName: resultName,
784
- nextLoc: nextLoc
785
- };
786
-
787
- if (this.method === "next") {
788
- // Deliberately forget the last sent value so that we don't
789
- // accidentally pass it on to the delegate.
790
- this.arg = undefined$1;
791
- }
792
-
793
- return ContinueSentinel;
794
- }
795
- }; // Regardless of whether this script is executing as a CommonJS module
796
- // or not, return the runtime object so that we can declare the variable
797
- // regeneratorRuntime in the outer scope, which allows this module to be
798
- // injected easily by `bin/regenerator --include-runtime script.js`.
799
-
800
- return exports;
801
- }( // If this script is executing as a CommonJS module, use module.exports
802
- // as the regeneratorRuntime namespace. Otherwise create a new empty
803
- // object. Either way, the resulting object will be used to initialize
804
- // the regeneratorRuntime variable at the top of this file.
805
- module.exports );
806
-
807
- try {
808
- regeneratorRuntime = runtime;
809
- } catch (accidentalStrictMode) {
810
- // This module should not be running in strict mode, so the above
811
- // assignment should always work unless something is misconfigured. Just
812
- // in case runtime.js accidentally runs in strict mode, we can escape
813
- // strict mode using a global Function call. This could conceivably fail
814
- // if a Content Security Policy forbids using Function, but in that case
815
- // the proper solution is to fix the accidental strict mode problem. If
816
- // you've misconfigured your bundler to force strict mode and applied a
817
- // CSP to forbid Function, and you're not willing to fix either of those
818
- // problems, please detail your unique predicament in a GitHub issue.
819
- Function("r", "regeneratorRuntime = r")(runtime);
820
- }
821
- });
822
-
823
- var VERSION = '3';
824
- var isBrowser = typeof window !== 'undefined' && window != null && typeof window.document !== 'undefined';
825
- var Api = /*#__PURE__*/function () {
826
- function Api(opts) {
827
- var _opts$host;
828
-
829
- this.opts = opts;
830
- this.host = (_opts$host = opts.host) != null ? _opts$host : 'https://codegen.plasmic.app';
831
- }
832
-
833
- var _proto = Api.prototype;
834
-
835
- _proto.fetchLoaderData = /*#__PURE__*/function () {
836
- var _fetchLoaderData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(projectIds, opts) {
837
- var platform, preview, query, url, resp, _error$error$message, _error$error, error, json;
838
-
839
- return runtime_1.wrap(function _callee$(_context) {
840
- while (1) {
841
- switch (_context.prev = _context.next) {
842
- case 0:
843
- platform = opts.platform, preview = opts.preview;
844
- query = new URLSearchParams([['platform', platform != null ? platform : 'react']].concat(projectIds.map(function (projectId) {
845
- return ['projectId', projectId];
846
- }), opts.browserOnly ? [['browserOnly', 'true']] : [])).toString();
847
- url = this.host + "/api/v1/loader/code/" + (preview ? 'preview' : 'published') + "?" + query;
848
- _context.next = 5;
849
- return fetch(url, {
850
- method: 'GET',
851
- headers: this.makeGetHeaders()
852
- });
853
-
854
- case 5:
855
- resp = _context.sent;
856
-
857
- if (!(resp.status >= 400)) {
858
- _context.next = 11;
859
- break;
860
- }
861
-
862
- _context.next = 9;
863
- return resp.json();
864
-
865
- case 9:
866
- error = _context.sent;
867
- throw new Error((_error$error$message = error == null ? void 0 : (_error$error = error.error) == null ? void 0 : _error$error.message) != null ? _error$error$message : resp.statusText);
868
-
869
- case 11:
870
- _context.next = 13;
871
- return resp.json();
872
-
873
- case 13:
874
- json = _context.sent;
875
- return _context.abrupt("return", json);
876
-
877
- case 15:
878
- case "end":
879
- return _context.stop();
880
- }
881
- }
882
- }, _callee, this);
883
- }));
884
-
885
- function fetchLoaderData(_x, _x2) {
886
- return _fetchLoaderData.apply(this, arguments);
887
- }
888
-
889
- return fetchLoaderData;
890
- }();
891
-
892
- _proto.fetchHtmlData = /*#__PURE__*/function () {
893
- var _fetchHtmlData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(opts) {
894
- var projectId, component, embedHydrate, hydrate, query, resp, json;
895
- return runtime_1.wrap(function _callee2$(_context2) {
896
- while (1) {
897
- switch (_context2.prev = _context2.next) {
898
- case 0:
899
- projectId = opts.projectId, component = opts.component, embedHydrate = opts.embedHydrate, hydrate = opts.hydrate;
900
- query = new URLSearchParams([['projectId', projectId], ['component', component], ['embedHydrate', embedHydrate ? '1' : '0'], ['hydrate', hydrate ? '1' : '0']]).toString();
901
- _context2.next = 4;
902
- return fetch(this.host + "/api/v1/loader/html?" + query, {
903
- method: 'GET',
904
- headers: this.makeGetHeaders()
905
- });
906
-
907
- case 4:
908
- resp = _context2.sent;
909
- _context2.next = 7;
910
- return resp.json();
911
-
912
- case 7:
913
- json = _context2.sent;
914
- return _context2.abrupt("return", json);
915
-
916
- case 9:
917
- case "end":
918
- return _context2.stop();
919
- }
920
- }
921
- }, _callee2, this);
922
- }));
923
-
924
- function fetchHtmlData(_x3) {
925
- return _fetchHtmlData.apply(this, arguments);
926
- }
927
-
928
- return fetchHtmlData;
929
- }();
930
-
931
- _proto.makeGetHeaders = function makeGetHeaders() {
932
- return _extends({
933
- 'x-plasmic-loader-version': VERSION
934
- }, this.makeAuthHeaders());
935
- } // @ts-ignore
936
- ;
937
-
938
- _proto.makePostHeaders = function makePostHeaders() {
939
- return _extends({
940
- 'x-plasmic-loader-version': VERSION,
941
- 'Content-Type': 'application/json'
942
- }, this.makeAuthHeaders());
943
- };
944
-
945
- _proto.makeAuthHeaders = function makeAuthHeaders() {
946
- var tokens = this.opts.projects.map(function (p) {
947
- return p.id + ":" + p.token;
948
- }).join(',');
949
- return {
950
- 'x-plasmic-api-project-tokens': tokens
951
- };
952
- };
953
-
954
- return Api;
955
- }();
956
-
957
41
  var DepsGraph = /*#__PURE__*/function () {
958
42
  function DepsGraph(bundle, browserBuild) {
959
43
  if (browserBuild === void 0) {
@@ -1068,138 +152,12 @@ function getBundleSubset(bundle) {
1068
152
  return isSubModule(c.entry);
1069
153
  }),
1070
154
  globalGroups: bundle.globalGroups,
1071
- projects: bundle.projects
155
+ projects: bundle.projects,
156
+ activeSplits: bundle.activeSplits
1072
157
  };
1073
158
  }
1074
159
 
1075
- var PlasmicModulesFetcher = /*#__PURE__*/function () {
1076
- function PlasmicModulesFetcher(opts) {
1077
- this.opts = opts;
1078
- this.curFetch = undefined;
1079
- this.api = new Api({
1080
- projects: opts.projects,
1081
- host: opts.host
1082
- });
1083
- }
1084
-
1085
- var _proto = PlasmicModulesFetcher.prototype;
1086
-
1087
- _proto.fetchAllData = /*#__PURE__*/function () {
1088
- var _fetchAllData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1089
- var cachedData, data;
1090
- return runtime_1.wrap(function _callee$(_context) {
1091
- while (1) {
1092
- switch (_context.prev = _context.next) {
1093
- case 0:
1094
- if (!this.opts.cache) {
1095
- _context.next = 6;
1096
- break;
1097
- }
1098
-
1099
- _context.next = 3;
1100
- return this.opts.cache.get();
1101
-
1102
- case 3:
1103
- cachedData = _context.sent;
1104
-
1105
- if (!cachedData) {
1106
- _context.next = 6;
1107
- break;
1108
- }
1109
-
1110
- return _context.abrupt("return", cachedData);
1111
-
1112
- case 6:
1113
- if (!this.curFetch) {
1114
- _context.next = 10;
1115
- break;
1116
- }
1117
-
1118
- _context.next = 9;
1119
- return this.curFetch;
1120
-
1121
- case 9:
1122
- return _context.abrupt("return", _context.sent);
1123
-
1124
- case 10:
1125
- console.debug('Plasmic: doing a fresh fetch...');
1126
- this.curFetch = this.doFetch();
1127
- _context.next = 14;
1128
- return this.curFetch;
1129
-
1130
- case 14:
1131
- data = _context.sent;
1132
- this.curFetch = undefined;
1133
- return _context.abrupt("return", data);
1134
-
1135
- case 17:
1136
- case "end":
1137
- return _context.stop();
1138
- }
1139
- }
1140
- }, _callee, this);
1141
- }));
1142
-
1143
- function fetchAllData() {
1144
- return _fetchAllData.apply(this, arguments);
1145
- }
1146
-
1147
- return fetchAllData;
1148
- }();
1149
-
1150
- _proto.doFetch = /*#__PURE__*/function () {
1151
- var _doFetch = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1152
- var _this = this;
1153
-
1154
- var data;
1155
- return runtime_1.wrap(function _callee2$(_context2) {
1156
- while (1) {
1157
- switch (_context2.prev = _context2.next) {
1158
- case 0:
1159
- _context2.next = 2;
1160
- return this.api.fetchLoaderData(this.opts.projects.map(function (p) {
1161
- return p.version && !_this.opts.preview ? p.id + "@" + p.version : p.id;
1162
- }), {
1163
- platform: this.opts.platform,
1164
- preview: this.opts.preview,
1165
- browserOnly: isBrowser
1166
- });
1167
-
1168
- case 2:
1169
- data = _context2.sent;
1170
-
1171
- if (!this.opts.cache) {
1172
- _context2.next = 6;
1173
- break;
1174
- }
1175
-
1176
- _context2.next = 6;
1177
- return this.opts.cache.set(data);
1178
-
1179
- case 6:
1180
- console.debug("Plasmic: fetched designs for " + data.projects.map(function (p) {
1181
- return "\"" + p.name + "\" (" + p.id + "@" + p.version + ")";
1182
- }).join(', '));
1183
- return _context2.abrupt("return", data);
1184
-
1185
- case 8:
1186
- case "end":
1187
- return _context2.stop();
1188
- }
1189
- }
1190
- }, _callee2, this);
1191
- }));
1192
-
1193
- function doFetch() {
1194
- return _doFetch.apply(this, arguments);
1195
- }
1196
-
1197
- return doFetch;
1198
- }();
1199
-
1200
- return PlasmicModulesFetcher;
1201
- }();
1202
-
160
+ var isBrowser = typeof window !== 'undefined' && window != null && typeof window.document !== 'undefined';
1203
161
  var Registry = /*#__PURE__*/function () {
1204
162
  function Registry() {
1205
163
  this.loadedModules = {};
@@ -1340,5 +298,5 @@ function resolvePath(path, from) {
1340
298
  }
1341
299
  }
1342
300
 
1343
- export { Api, PlasmicModulesFetcher, Registry, getBundleSubset };
301
+ export { Registry, getBundleSubset };
1344
302
  //# sourceMappingURL=loader-core.esm.js.map