@plasmicapp/loader-gatsby 1.0.66 → 1.0.69

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,1154 +0,0 @@
1
- import { convertBundlesToComponentRenderData, initPlasmicLoader as initPlasmicLoader$1 } from '@plasmicapp/loader-react';
2
- export { PlasmicCanvasContext, PlasmicCanvasHost, PlasmicComponent, PlasmicRootProvider, repeatedElement, usePlasmicComponent } from '@plasmicapp/loader-react';
3
- import * as Gatsby from 'gatsby';
4
- import * as React from 'react';
5
- import * as ReactDom from 'react-dom';
6
-
7
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8
- try {
9
- var info = gen[key](arg);
10
- var value = info.value;
11
- } catch (error) {
12
- reject(error);
13
- return;
14
- }
15
-
16
- if (info.done) {
17
- resolve(value);
18
- } else {
19
- Promise.resolve(value).then(_next, _throw);
20
- }
21
- }
22
-
23
- function _asyncToGenerator(fn) {
24
- return function () {
25
- var self = this,
26
- args = arguments;
27
- return new Promise(function (resolve, reject) {
28
- var gen = fn.apply(self, args);
29
-
30
- function _next(value) {
31
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
32
- }
33
-
34
- function _throw(err) {
35
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
36
- }
37
-
38
- _next(undefined);
39
- });
40
- };
41
- }
42
-
43
- function _extends() {
44
- _extends = Object.assign || function (target) {
45
- for (var i = 1; i < arguments.length; i++) {
46
- var source = arguments[i];
47
-
48
- for (var key in source) {
49
- if (Object.prototype.hasOwnProperty.call(source, key)) {
50
- target[key] = source[key];
51
- }
52
- }
53
- }
54
-
55
- return target;
56
- };
57
-
58
- return _extends.apply(this, arguments);
59
- }
60
-
61
- function _unsupportedIterableToArray(o, minLen) {
62
- if (!o) return;
63
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
64
- var n = Object.prototype.toString.call(o).slice(8, -1);
65
- if (n === "Object" && o.constructor) n = o.constructor.name;
66
- if (n === "Map" || n === "Set") return Array.from(o);
67
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
68
- }
69
-
70
- function _arrayLikeToArray(arr, len) {
71
- if (len == null || len > arr.length) len = arr.length;
72
-
73
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
74
-
75
- return arr2;
76
- }
77
-
78
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
79
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
80
- if (it) return (it = it.call(o)).next.bind(it);
81
-
82
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
83
- if (it) o = it;
84
- var i = 0;
85
- return function () {
86
- if (i >= o.length) return {
87
- done: true
88
- };
89
- return {
90
- done: false,
91
- value: o[i++]
92
- };
93
- };
94
- }
95
-
96
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
97
- }
98
-
99
- function createCommonjsModule(fn, module) {
100
- return module = { exports: {} }, fn(module, module.exports), module.exports;
101
- }
102
-
103
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
104
- /**
105
- * Copyright (c) 2014-present, Facebook, Inc.
106
- *
107
- * This source code is licensed under the MIT license found in the
108
- * LICENSE file in the root directory of this source tree.
109
- */
110
- var runtime = function (exports) {
111
-
112
- var Op = Object.prototype;
113
- var hasOwn = Op.hasOwnProperty;
114
- var undefined$1; // More compressible than void 0.
115
-
116
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
117
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
118
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
119
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
120
-
121
- function define(obj, key, value) {
122
- Object.defineProperty(obj, key, {
123
- value: value,
124
- enumerable: true,
125
- configurable: true,
126
- writable: true
127
- });
128
- return obj[key];
129
- }
130
-
131
- try {
132
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
133
- define({}, "");
134
- } catch (err) {
135
- define = function define(obj, key, value) {
136
- return obj[key] = value;
137
- };
138
- }
139
-
140
- function wrap(innerFn, outerFn, self, tryLocsList) {
141
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
142
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
143
- var generator = Object.create(protoGenerator.prototype);
144
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
145
- // .throw, and .return methods.
146
-
147
- generator._invoke = makeInvokeMethod(innerFn, self, context);
148
- return generator;
149
- }
150
-
151
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
152
- // record like context.tryEntries[i].completion. This interface could
153
- // have been (and was previously) designed to take a closure to be
154
- // invoked without arguments, but in all the cases we care about we
155
- // already have an existing method we want to call, so there's no need
156
- // to create a new function object. We can even get away with assuming
157
- // the method takes exactly one argument, since that happens to be true
158
- // in every case, so we don't have to touch the arguments object. The
159
- // only additional allocation required is the completion record, which
160
- // has a stable shape and so hopefully should be cheap to allocate.
161
-
162
- function tryCatch(fn, obj, arg) {
163
- try {
164
- return {
165
- type: "normal",
166
- arg: fn.call(obj, arg)
167
- };
168
- } catch (err) {
169
- return {
170
- type: "throw",
171
- arg: err
172
- };
173
- }
174
- }
175
-
176
- var GenStateSuspendedStart = "suspendedStart";
177
- var GenStateSuspendedYield = "suspendedYield";
178
- var GenStateExecuting = "executing";
179
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
180
- // breaking out of the dispatch switch statement.
181
-
182
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
183
- // .constructor.prototype properties for functions that return Generator
184
- // objects. For full spec compliance, you may wish to configure your
185
- // minifier not to mangle the names of these two functions.
186
-
187
- function Generator() {}
188
-
189
- function GeneratorFunction() {}
190
-
191
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
192
- // don't natively support it.
193
-
194
-
195
- var IteratorPrototype = {};
196
-
197
- IteratorPrototype[iteratorSymbol] = function () {
198
- return this;
199
- };
200
-
201
- var getProto = Object.getPrototypeOf;
202
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
203
-
204
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
205
- // This environment has a native %IteratorPrototype%; use it instead
206
- // of the polyfill.
207
- IteratorPrototype = NativeIteratorPrototype;
208
- }
209
-
210
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
211
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
212
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
213
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
214
- // Iterator interface in terms of a single ._invoke method.
215
-
216
- function defineIteratorMethods(prototype) {
217
- ["next", "throw", "return"].forEach(function (method) {
218
- define(prototype, method, function (arg) {
219
- return this._invoke(method, arg);
220
- });
221
- });
222
- }
223
-
224
- exports.isGeneratorFunction = function (genFun) {
225
- var ctor = typeof genFun === "function" && genFun.constructor;
226
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
227
- // do is to check its .name property.
228
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
229
- };
230
-
231
- exports.mark = function (genFun) {
232
- if (Object.setPrototypeOf) {
233
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
234
- } else {
235
- genFun.__proto__ = GeneratorFunctionPrototype;
236
- define(genFun, toStringTagSymbol, "GeneratorFunction");
237
- }
238
-
239
- genFun.prototype = Object.create(Gp);
240
- return genFun;
241
- }; // Within the body of any async function, `await x` is transformed to
242
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
243
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
244
- // meant to be awaited.
245
-
246
-
247
- exports.awrap = function (arg) {
248
- return {
249
- __await: arg
250
- };
251
- };
252
-
253
- function AsyncIterator(generator, PromiseImpl) {
254
- function invoke(method, arg, resolve, reject) {
255
- var record = tryCatch(generator[method], generator, arg);
256
-
257
- if (record.type === "throw") {
258
- reject(record.arg);
259
- } else {
260
- var result = record.arg;
261
- var value = result.value;
262
-
263
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
264
- return PromiseImpl.resolve(value.__await).then(function (value) {
265
- invoke("next", value, resolve, reject);
266
- }, function (err) {
267
- invoke("throw", err, resolve, reject);
268
- });
269
- }
270
-
271
- return PromiseImpl.resolve(value).then(function (unwrapped) {
272
- // When a yielded Promise is resolved, its final value becomes
273
- // the .value of the Promise<{value,done}> result for the
274
- // current iteration.
275
- result.value = unwrapped;
276
- resolve(result);
277
- }, function (error) {
278
- // If a rejected Promise was yielded, throw the rejection back
279
- // into the async generator function so it can be handled there.
280
- return invoke("throw", error, resolve, reject);
281
- });
282
- }
283
- }
284
-
285
- var previousPromise;
286
-
287
- function enqueue(method, arg) {
288
- function callInvokeWithMethodAndArg() {
289
- return new PromiseImpl(function (resolve, reject) {
290
- invoke(method, arg, resolve, reject);
291
- });
292
- }
293
-
294
- return previousPromise = // If enqueue has been called before, then we want to wait until
295
- // all previous Promises have been resolved before calling invoke,
296
- // so that results are always delivered in the correct order. If
297
- // enqueue has not been called before, then it is important to
298
- // call invoke immediately, without waiting on a callback to fire,
299
- // so that the async generator function has the opportunity to do
300
- // any necessary setup in a predictable way. This predictability
301
- // is why the Promise constructor synchronously invokes its
302
- // executor callback, and why async functions synchronously
303
- // execute code before the first await. Since we implement simple
304
- // async functions in terms of async generators, it is especially
305
- // important to get this right, even though it requires care.
306
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
307
- // invocations of the iterator.
308
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
309
- } // Define the unified helper method that is used to implement .next,
310
- // .throw, and .return (see defineIteratorMethods).
311
-
312
-
313
- this._invoke = enqueue;
314
- }
315
-
316
- defineIteratorMethods(AsyncIterator.prototype);
317
-
318
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
319
- return this;
320
- };
321
-
322
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
323
- // AsyncIterator objects; they just return a Promise for the value of
324
- // the final result produced by the iterator.
325
-
326
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
327
- if (PromiseImpl === void 0) PromiseImpl = Promise;
328
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
329
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
330
- : iter.next().then(function (result) {
331
- return result.done ? result.value : iter.next();
332
- });
333
- };
334
-
335
- function makeInvokeMethod(innerFn, self, context) {
336
- var state = GenStateSuspendedStart;
337
- return function invoke(method, arg) {
338
- if (state === GenStateExecuting) {
339
- throw new Error("Generator is already running");
340
- }
341
-
342
- if (state === GenStateCompleted) {
343
- if (method === "throw") {
344
- throw arg;
345
- } // Be forgiving, per 25.3.3.3.3 of the spec:
346
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
347
-
348
-
349
- return doneResult();
350
- }
351
-
352
- context.method = method;
353
- context.arg = arg;
354
-
355
- while (true) {
356
- var delegate = context.delegate;
357
-
358
- if (delegate) {
359
- var delegateResult = maybeInvokeDelegate(delegate, context);
360
-
361
- if (delegateResult) {
362
- if (delegateResult === ContinueSentinel) continue;
363
- return delegateResult;
364
- }
365
- }
366
-
367
- if (context.method === "next") {
368
- // Setting context._sent for legacy support of Babel's
369
- // function.sent implementation.
370
- context.sent = context._sent = context.arg;
371
- } else if (context.method === "throw") {
372
- if (state === GenStateSuspendedStart) {
373
- state = GenStateCompleted;
374
- throw context.arg;
375
- }
376
-
377
- context.dispatchException(context.arg);
378
- } else if (context.method === "return") {
379
- context.abrupt("return", context.arg);
380
- }
381
-
382
- state = GenStateExecuting;
383
- var record = tryCatch(innerFn, self, context);
384
-
385
- if (record.type === "normal") {
386
- // If an exception is thrown from innerFn, we leave state ===
387
- // GenStateExecuting and loop back for another invocation.
388
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
389
-
390
- if (record.arg === ContinueSentinel) {
391
- continue;
392
- }
393
-
394
- return {
395
- value: record.arg,
396
- done: context.done
397
- };
398
- } else if (record.type === "throw") {
399
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
400
- // context.dispatchException(context.arg) call above.
401
-
402
- context.method = "throw";
403
- context.arg = record.arg;
404
- }
405
- }
406
- };
407
- } // Call delegate.iterator[context.method](context.arg) and handle the
408
- // result, either by returning a { value, done } result from the
409
- // delegate iterator, or by modifying context.method and context.arg,
410
- // setting context.delegate to null, and returning the ContinueSentinel.
411
-
412
-
413
- function maybeInvokeDelegate(delegate, context) {
414
- var method = delegate.iterator[context.method];
415
-
416
- if (method === undefined$1) {
417
- // A .throw or .return when the delegate iterator has no .throw
418
- // method always terminates the yield* loop.
419
- context.delegate = null;
420
-
421
- if (context.method === "throw") {
422
- // Note: ["return"] must be used for ES3 parsing compatibility.
423
- if (delegate.iterator["return"]) {
424
- // If the delegate iterator has a return method, give it a
425
- // chance to clean up.
426
- context.method = "return";
427
- context.arg = undefined$1;
428
- maybeInvokeDelegate(delegate, context);
429
-
430
- if (context.method === "throw") {
431
- // If maybeInvokeDelegate(context) changed context.method from
432
- // "return" to "throw", let that override the TypeError below.
433
- return ContinueSentinel;
434
- }
435
- }
436
-
437
- context.method = "throw";
438
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
439
- }
440
-
441
- return ContinueSentinel;
442
- }
443
-
444
- var record = tryCatch(method, delegate.iterator, context.arg);
445
-
446
- if (record.type === "throw") {
447
- context.method = "throw";
448
- context.arg = record.arg;
449
- context.delegate = null;
450
- return ContinueSentinel;
451
- }
452
-
453
- var info = record.arg;
454
-
455
- if (!info) {
456
- context.method = "throw";
457
- context.arg = new TypeError("iterator result is not an object");
458
- context.delegate = null;
459
- return ContinueSentinel;
460
- }
461
-
462
- if (info.done) {
463
- // Assign the result of the finished delegate to the temporary
464
- // variable specified by delegate.resultName (see delegateYield).
465
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
466
-
467
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
468
- // exception, let the outer generator proceed normally. If
469
- // context.method was "next", forget context.arg since it has been
470
- // "consumed" by the delegate iterator. If context.method was
471
- // "return", allow the original .return call to continue in the
472
- // outer generator.
473
-
474
- if (context.method !== "return") {
475
- context.method = "next";
476
- context.arg = undefined$1;
477
- }
478
- } else {
479
- // Re-yield the result returned by the delegate method.
480
- return info;
481
- } // The delegate iterator is finished, so forget it and continue with
482
- // the outer generator.
483
-
484
-
485
- context.delegate = null;
486
- return ContinueSentinel;
487
- } // Define Generator.prototype.{next,throw,return} in terms of the
488
- // unified ._invoke helper method.
489
-
490
-
491
- defineIteratorMethods(Gp);
492
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
493
- // @@iterator function is called on it. Some browsers' implementations of the
494
- // iterator prototype chain incorrectly implement this, causing the Generator
495
- // object to not be returned from this call. This ensures that doesn't happen.
496
- // See https://github.com/facebook/regenerator/issues/274 for more details.
497
-
498
- Gp[iteratorSymbol] = function () {
499
- return this;
500
- };
501
-
502
- Gp.toString = function () {
503
- return "[object Generator]";
504
- };
505
-
506
- function pushTryEntry(locs) {
507
- var entry = {
508
- tryLoc: locs[0]
509
- };
510
-
511
- if (1 in locs) {
512
- entry.catchLoc = locs[1];
513
- }
514
-
515
- if (2 in locs) {
516
- entry.finallyLoc = locs[2];
517
- entry.afterLoc = locs[3];
518
- }
519
-
520
- this.tryEntries.push(entry);
521
- }
522
-
523
- function resetTryEntry(entry) {
524
- var record = entry.completion || {};
525
- record.type = "normal";
526
- delete record.arg;
527
- entry.completion = record;
528
- }
529
-
530
- function Context(tryLocsList) {
531
- // The root entry object (effectively a try statement without a catch
532
- // or a finally block) gives us a place to store values thrown from
533
- // locations where there is no enclosing try statement.
534
- this.tryEntries = [{
535
- tryLoc: "root"
536
- }];
537
- tryLocsList.forEach(pushTryEntry, this);
538
- this.reset(true);
539
- }
540
-
541
- exports.keys = function (object) {
542
- var keys = [];
543
-
544
- for (var key in object) {
545
- keys.push(key);
546
- }
547
-
548
- keys.reverse(); // Rather than returning an object with a next method, we keep
549
- // things simple and return the next function itself.
550
-
551
- return function next() {
552
- while (keys.length) {
553
- var key = keys.pop();
554
-
555
- if (key in object) {
556
- next.value = key;
557
- next.done = false;
558
- return next;
559
- }
560
- } // To avoid creating an additional object, we just hang the .value
561
- // and .done properties off the next function object itself. This
562
- // also ensures that the minifier will not anonymize the function.
563
-
564
-
565
- next.done = true;
566
- return next;
567
- };
568
- };
569
-
570
- function values(iterable) {
571
- if (iterable) {
572
- var iteratorMethod = iterable[iteratorSymbol];
573
-
574
- if (iteratorMethod) {
575
- return iteratorMethod.call(iterable);
576
- }
577
-
578
- if (typeof iterable.next === "function") {
579
- return iterable;
580
- }
581
-
582
- if (!isNaN(iterable.length)) {
583
- var i = -1,
584
- next = function next() {
585
- while (++i < iterable.length) {
586
- if (hasOwn.call(iterable, i)) {
587
- next.value = iterable[i];
588
- next.done = false;
589
- return next;
590
- }
591
- }
592
-
593
- next.value = undefined$1;
594
- next.done = true;
595
- return next;
596
- };
597
-
598
- return next.next = next;
599
- }
600
- } // Return an iterator with no values.
601
-
602
-
603
- return {
604
- next: doneResult
605
- };
606
- }
607
-
608
- exports.values = values;
609
-
610
- function doneResult() {
611
- return {
612
- value: undefined$1,
613
- done: true
614
- };
615
- }
616
-
617
- Context.prototype = {
618
- constructor: Context,
619
- reset: function reset(skipTempReset) {
620
- this.prev = 0;
621
- this.next = 0; // Resetting context._sent for legacy support of Babel's
622
- // function.sent implementation.
623
-
624
- this.sent = this._sent = undefined$1;
625
- this.done = false;
626
- this.delegate = null;
627
- this.method = "next";
628
- this.arg = undefined$1;
629
- this.tryEntries.forEach(resetTryEntry);
630
-
631
- if (!skipTempReset) {
632
- for (var name in this) {
633
- // Not sure about the optimal order of these conditions:
634
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
635
- this[name] = undefined$1;
636
- }
637
- }
638
- }
639
- },
640
- stop: function stop() {
641
- this.done = true;
642
- var rootEntry = this.tryEntries[0];
643
- var rootRecord = rootEntry.completion;
644
-
645
- if (rootRecord.type === "throw") {
646
- throw rootRecord.arg;
647
- }
648
-
649
- return this.rval;
650
- },
651
- dispatchException: function dispatchException(exception) {
652
- if (this.done) {
653
- throw exception;
654
- }
655
-
656
- var context = this;
657
-
658
- function handle(loc, caught) {
659
- record.type = "throw";
660
- record.arg = exception;
661
- context.next = loc;
662
-
663
- if (caught) {
664
- // If the dispatched exception was caught by a catch block,
665
- // then let that catch block handle the exception normally.
666
- context.method = "next";
667
- context.arg = undefined$1;
668
- }
669
-
670
- return !!caught;
671
- }
672
-
673
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
674
- var entry = this.tryEntries[i];
675
- var record = entry.completion;
676
-
677
- if (entry.tryLoc === "root") {
678
- // Exception thrown outside of any try block that could handle
679
- // it, so set the completion value of the entire function to
680
- // throw the exception.
681
- return handle("end");
682
- }
683
-
684
- if (entry.tryLoc <= this.prev) {
685
- var hasCatch = hasOwn.call(entry, "catchLoc");
686
- var hasFinally = hasOwn.call(entry, "finallyLoc");
687
-
688
- if (hasCatch && hasFinally) {
689
- if (this.prev < entry.catchLoc) {
690
- return handle(entry.catchLoc, true);
691
- } else if (this.prev < entry.finallyLoc) {
692
- return handle(entry.finallyLoc);
693
- }
694
- } else if (hasCatch) {
695
- if (this.prev < entry.catchLoc) {
696
- return handle(entry.catchLoc, true);
697
- }
698
- } else if (hasFinally) {
699
- if (this.prev < entry.finallyLoc) {
700
- return handle(entry.finallyLoc);
701
- }
702
- } else {
703
- throw new Error("try statement without catch or finally");
704
- }
705
- }
706
- }
707
- },
708
- abrupt: function abrupt(type, arg) {
709
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
710
- var entry = this.tryEntries[i];
711
-
712
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
713
- var finallyEntry = entry;
714
- break;
715
- }
716
- }
717
-
718
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
719
- // Ignore the finally entry if control is not jumping to a
720
- // location outside the try/catch block.
721
- finallyEntry = null;
722
- }
723
-
724
- var record = finallyEntry ? finallyEntry.completion : {};
725
- record.type = type;
726
- record.arg = arg;
727
-
728
- if (finallyEntry) {
729
- this.method = "next";
730
- this.next = finallyEntry.finallyLoc;
731
- return ContinueSentinel;
732
- }
733
-
734
- return this.complete(record);
735
- },
736
- complete: function complete(record, afterLoc) {
737
- if (record.type === "throw") {
738
- throw record.arg;
739
- }
740
-
741
- if (record.type === "break" || record.type === "continue") {
742
- this.next = record.arg;
743
- } else if (record.type === "return") {
744
- this.rval = this.arg = record.arg;
745
- this.method = "return";
746
- this.next = "end";
747
- } else if (record.type === "normal" && afterLoc) {
748
- this.next = afterLoc;
749
- }
750
-
751
- return ContinueSentinel;
752
- },
753
- finish: function finish(finallyLoc) {
754
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
755
- var entry = this.tryEntries[i];
756
-
757
- if (entry.finallyLoc === finallyLoc) {
758
- this.complete(entry.completion, entry.afterLoc);
759
- resetTryEntry(entry);
760
- return ContinueSentinel;
761
- }
762
- }
763
- },
764
- "catch": function _catch(tryLoc) {
765
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
766
- var entry = this.tryEntries[i];
767
-
768
- if (entry.tryLoc === tryLoc) {
769
- var record = entry.completion;
770
-
771
- if (record.type === "throw") {
772
- var thrown = record.arg;
773
- resetTryEntry(entry);
774
- }
775
-
776
- return thrown;
777
- }
778
- } // The context.catch method must only be called with a location
779
- // argument that corresponds to a known catch block.
780
-
781
-
782
- throw new Error("illegal catch attempt");
783
- },
784
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
785
- this.delegate = {
786
- iterator: values(iterable),
787
- resultName: resultName,
788
- nextLoc: nextLoc
789
- };
790
-
791
- if (this.method === "next") {
792
- // Deliberately forget the last sent value so that we don't
793
- // accidentally pass it on to the delegate.
794
- this.arg = undefined$1;
795
- }
796
-
797
- return ContinueSentinel;
798
- }
799
- }; // Regardless of whether this script is executing as a CommonJS module
800
- // or not, return the runtime object so that we can declare the variable
801
- // regeneratorRuntime in the outer scope, which allows this module to be
802
- // injected easily by `bin/regenerator --include-runtime script.js`.
803
-
804
- return exports;
805
- }( // If this script is executing as a CommonJS module, use module.exports
806
- // as the regeneratorRuntime namespace. Otherwise create a new empty
807
- // object. Either way, the resulting object will be used to initialize
808
- // the regeneratorRuntime variable at the top of this file.
809
- module.exports );
810
-
811
- try {
812
- regeneratorRuntime = runtime;
813
- } catch (accidentalStrictMode) {
814
- // This module should not be running in strict mode, so the above
815
- // assignment should always work unless something is misconfigured. Just
816
- // in case runtime.js accidentally runs in strict mode, we can escape
817
- // strict mode using a global Function call. This could conceivably fail
818
- // if a Content Security Policy forbids using Function, but in that case
819
- // the proper solution is to fix the accidental strict mode problem. If
820
- // you've misconfigured your bundler to force strict mode and applied a
821
- // CSP to forbid Function, and you're not willing to fix either of those
822
- // problems, please detail your unique predicament in a GitHub issue.
823
- Function("r", "regeneratorRuntime = r")(runtime);
824
- }
825
- });
826
-
827
- var secretRequire;
828
-
829
- try {
830
- // Secretly use require without webpack knowing
831
- secretRequire = /*#__PURE__*/eval("require");
832
- } catch (err) {
833
- secretRequire = undefined;
834
- }
835
-
836
- function serverRequire(module) {
837
- if (!secretRequire) {
838
- throw new Error("Unexpected serverRequire() -- can only do this from a Node server!");
839
- }
840
-
841
- return secretRequire(module);
842
- }
843
-
844
- var PLASMIC_NODE_NAME = "plasmicData";
845
- var PLASMIC_DATA_TYPE = "\n type " + PLASMIC_NODE_NAME + " implements Node {\n name: String!\n projectId: String!\n path: String\n isPage: Boolean!\n renderData: JSON!\n }\n\n type Query {\n plasmicComponents(componentNames: [String]!): JSON\n plasmicOptions: JSON\n }\n";
846
- var SOURCE_WAIT_TIME = 3000; // 3 seconds
847
-
848
- var SOURCE_MAX_WAIT_TIME = 10000; // 10 seconds
849
-
850
- var allPaths = [];
851
- var sourceNodes = /*#__PURE__*/function () {
852
- var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref2, opts) {
853
- var actions, createContentDigest, reporter, createNode, createTypes, deleteNode, allComponents, refreshData, debounce, triggerSourcing, PlasmicRemoteChangeWatcher, watcher;
854
- return runtime_1.wrap(function _callee2$(_context2) {
855
- while (1) {
856
- switch (_context2.prev = _context2.next) {
857
- case 0:
858
- actions = _ref2.actions, createContentDigest = _ref2.createContentDigest, reporter = _ref2.reporter;
859
- createNode = actions.createNode, createTypes = actions.createTypes, deleteNode = actions.deleteNode;
860
- createTypes(PLASMIC_DATA_TYPE);
861
- allComponents = [];
862
-
863
- refreshData = /*#__PURE__*/function () {
864
- var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
865
- var PLASMIC, components, _loop, _iterator, _step, _iterator2, _step2, component, renderData, curComponent, componentMeta, componentNode;
866
-
867
- return runtime_1.wrap(function _callee$(_context) {
868
- while (1) {
869
- switch (_context.prev = _context.next) {
870
- case 0:
871
- reporter.info("[Plasmic Loader] - Creating nodes");
872
- PLASMIC = initPlasmicLoader$1({
873
- projects: opts.projects,
874
- preview: opts.preview,
875
- host: opts.host,
876
- platform: "gatsby"
877
- });
878
- _context.next = 4;
879
- return PLASMIC.fetchComponents();
880
-
881
- case 4:
882
- components = _context.sent;
883
-
884
- _loop = function _loop() {
885
- var component = _step.value;
886
- var hasComponent = components.some(function (c) {
887
- return c.name === component.name;
888
- });
889
- /**
890
- * We shouldn't delete nodes that will be updated, if we delete all nodes
891
- * and then create it again, this could case the graphql layer to have no
892
- * plasmic data for some time, but this can be enough time to a re render
893
- * causing components that call a graphql query to plasmic data to crash
894
- * */
895
-
896
- if (!hasComponent) {
897
- deleteNode(component);
898
- reporter.verbose("[Plasmic Loader] - Deleted node " + component.name);
899
- }
900
- };
901
-
902
- // const getNodeId = (projectId, componentName) =>
903
- // createNodeId(`@plasmicapp/loader-gatsby/${projectId}-${componentName}`);
904
- for (_iterator = _createForOfIteratorHelperLoose(allComponents); !(_step = _iterator()).done;) {
905
- _loop();
906
- }
907
-
908
- allComponents = [];
909
- _iterator2 = _createForOfIteratorHelperLoose(components);
910
-
911
- case 9:
912
- if ((_step2 = _iterator2()).done) {
913
- _context.next = 22;
914
- break;
915
- }
916
-
917
- component = _step2.value;
918
- _context.next = 13;
919
- return PLASMIC.fetchComponentData({
920
- name: component.name,
921
- projectId: component.projectId
922
- });
923
-
924
- case 13:
925
- renderData = _context.sent;
926
- curComponent = _extends({}, component, {
927
- renderData: renderData
928
- });
929
- componentMeta = {
930
- // We use the same id as curComponent.id since loader-react might
931
- // expect the id to match plasmic component uuid.
932
- // id: getNodeId(component.projectId, component.name),
933
- parent: null,
934
- children: [],
935
- internal: {
936
- type: PLASMIC_NODE_NAME,
937
- contentDigest: createContentDigest(curComponent)
938
- }
939
- };
940
- componentNode = Object.assign({}, curComponent, componentMeta);
941
- createNode(componentNode);
942
- reporter.verbose("[Plasmic Loader] - Created component node " + component.name);
943
- allComponents.push(componentNode);
944
-
945
- case 20:
946
- _context.next = 9;
947
- break;
948
-
949
- case 22:
950
- case "end":
951
- return _context.stop();
952
- }
953
- }
954
- }, _callee);
955
- }));
956
-
957
- return function refreshData() {
958
- return _ref4.apply(this, arguments);
959
- };
960
- }();
961
-
962
- if (process.env.NODE_ENV !== "production") {
963
- debounce = serverRequire("lodash/debounce");
964
- triggerSourcing = debounce(refreshData, SOURCE_WAIT_TIME, {
965
- maxWait: SOURCE_MAX_WAIT_TIME
966
- });
967
- PlasmicRemoteChangeWatcher = serverRequire("@plasmicapp/watcher").PlasmicRemoteChangeWatcher;
968
- watcher = new PlasmicRemoteChangeWatcher({
969
- projects: opts.projects,
970
- host: opts.host
971
- });
972
- watcher.subscribe({
973
- onUpdate: function onUpdate() {
974
- if (opts.preview) {
975
- triggerSourcing();
976
- }
977
- },
978
- onPublish: function onPublish() {
979
- if (!opts.preview) {
980
- triggerSourcing();
981
- }
982
- }
983
- });
984
- }
985
-
986
- _context2.next = 8;
987
- return refreshData();
988
-
989
- case 8:
990
- case "end":
991
- return _context2.stop();
992
- }
993
- }
994
- }, _callee2);
995
- }));
996
-
997
- return function sourceNodes(_x, _x2) {
998
- return _ref3.apply(this, arguments);
999
- };
1000
- }();
1001
- var createResolvers = function createResolvers(_ref5, opts) {
1002
- var createResolvers = _ref5.createResolvers;
1003
- createResolvers({
1004
- Query: {
1005
- plasmicComponents: {
1006
- resolve: function resolve(source, args, context, info) {
1007
- var componentNames = args.componentNames;
1008
- var components = context.nodeModel.getAllNodes({
1009
- type: PLASMIC_NODE_NAME
1010
- });
1011
- var bundles = [];
1012
- var compMetas = [];
1013
-
1014
- for (var _iterator3 = _createForOfIteratorHelperLoose(components), _step3; !(_step3 = _iterator3()).done;) {
1015
- var component = _step3.value;
1016
-
1017
- if (componentNames.includes(component.name) || componentNames.includes(component.path) || componentNames.includes(component.path + "/")) {
1018
- var _component$renderData;
1019
-
1020
- var bundle = (_component$renderData = component.renderData) == null ? void 0 : _component$renderData.bundle;
1021
-
1022
- if (bundle) {
1023
- bundles.push(bundle);
1024
- compMetas.push(component);
1025
- }
1026
- }
1027
- }
1028
-
1029
- return convertBundlesToComponentRenderData(bundles, compMetas);
1030
- }
1031
- },
1032
- plasmicOptions: {
1033
- resolve: function resolve() {
1034
- return {
1035
- projects: opts.projects,
1036
- preview: opts.preview,
1037
- host: opts.host
1038
- };
1039
- }
1040
- }
1041
- }
1042
- });
1043
- };
1044
- var createPages = /*#__PURE__*/function () {
1045
- var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(_ref6, opts) {
1046
- var graphql, actions, reporter, defaultPlasmicPage, ignorePaths, createPage, deletePage, result, pages, _iterator4, _step4, path, _iterator5, _step5, page, _path;
1047
-
1048
- return runtime_1.wrap(function _callee3$(_context3) {
1049
- while (1) {
1050
- switch (_context3.prev = _context3.next) {
1051
- case 0:
1052
- graphql = _ref6.graphql, actions = _ref6.actions, reporter = _ref6.reporter;
1053
- defaultPlasmicPage = opts.defaultPlasmicPage;
1054
- ignorePaths = opts.ignorePaths || [];
1055
-
1056
- if (!defaultPlasmicPage) {
1057
- _context3.next = 31;
1058
- break;
1059
- }
1060
-
1061
- reporter.info("[Plasmic Loader] - Creating pages");
1062
- createPage = actions.createPage, deletePage = actions.deletePage;
1063
- _context3.next = 8;
1064
- return graphql("\n query {\n allPlasmicData(filter: { isPage: { eq: true } }) {\n nodes {\n path\n }\n }\n }\n ");
1065
-
1066
- case 8:
1067
- result = _context3.sent;
1068
- pages = result.data.allPlasmicData.nodes;
1069
- _iterator4 = _createForOfIteratorHelperLoose(allPaths);
1070
-
1071
- case 11:
1072
- if ((_step4 = _iterator4()).done) {
1073
- _context3.next = 18;
1074
- break;
1075
- }
1076
-
1077
- path = _step4.value;
1078
- _context3.next = 15;
1079
- return deletePage({
1080
- path: path,
1081
- component: defaultPlasmicPage
1082
- });
1083
-
1084
- case 15:
1085
- reporter.verbose("[Plasmic Loader] - Deleted page " + path);
1086
-
1087
- case 16:
1088
- _context3.next = 11;
1089
- break;
1090
-
1091
- case 18:
1092
- allPaths = [];
1093
- _iterator5 = _createForOfIteratorHelperLoose(pages);
1094
-
1095
- case 20:
1096
- if ((_step5 = _iterator5()).done) {
1097
- _context3.next = 31;
1098
- break;
1099
- }
1100
-
1101
- page = _step5.value;
1102
- _path = page.path;
1103
-
1104
- if (!(ignorePaths.includes(_path) || ignorePaths.includes(_path + "/"))) {
1105
- _context3.next = 25;
1106
- break;
1107
- }
1108
-
1109
- return _context3.abrupt("continue", 29);
1110
-
1111
- case 25:
1112
- allPaths.push(page.path);
1113
- _context3.next = 28;
1114
- return createPage({
1115
- path: page.path,
1116
- component: defaultPlasmicPage
1117
- });
1118
-
1119
- case 28:
1120
- reporter.verbose("[Plasmic Loader] - Created page " + page.path);
1121
-
1122
- case 29:
1123
- _context3.next = 20;
1124
- break;
1125
-
1126
- case 31:
1127
- case "end":
1128
- return _context3.stop();
1129
- }
1130
- }
1131
- }, _callee3);
1132
- }));
1133
-
1134
- return function createPages(_x3, _x4) {
1135
- return _ref7.apply(this, arguments);
1136
- };
1137
- }();
1138
-
1139
- function initPlasmicLoader(opts) {
1140
- var loader = initPlasmicLoader$1(_extends({
1141
- onClientSideFetch: "warn"
1142
- }, opts, {
1143
- platform: "gatsby"
1144
- }));
1145
- loader.registerModules({
1146
- react: React,
1147
- "react-dom": ReactDom,
1148
- gatsby: Gatsby
1149
- });
1150
- return loader;
1151
- }
1152
-
1153
- export { createPages, createResolvers, initPlasmicLoader, sourceNodes };
1154
- //# sourceMappingURL=loader-gatsby.esm.js.map