@plasmicpkgs/plasmic-graphcms 0.0.11

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.
@@ -0,0 +1,1053 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var registerComponent = _interopDefault(require('@plasmicapp/host/registerComponent'));
8
+ var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGlobalContext'));
9
+ var host = require('@plasmicapp/host');
10
+ var query = require('@plasmicapp/query');
11
+ var graphqlRequest = require('graphql-request');
12
+ var L = _interopDefault(require('lodash'));
13
+ var React = require('react');
14
+ var React__default = _interopDefault(React);
15
+
16
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17
+ try {
18
+ var info = gen[key](arg);
19
+ var value = info.value;
20
+ } catch (error) {
21
+ reject(error);
22
+ return;
23
+ }
24
+
25
+ if (info.done) {
26
+ resolve(value);
27
+ } else {
28
+ Promise.resolve(value).then(_next, _throw);
29
+ }
30
+ }
31
+
32
+ function _asyncToGenerator(fn) {
33
+ return function () {
34
+ var self = this,
35
+ args = arguments;
36
+ return new Promise(function (resolve, reject) {
37
+ var gen = fn.apply(self, args);
38
+
39
+ function _next(value) {
40
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
41
+ }
42
+
43
+ function _throw(err) {
44
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
45
+ }
46
+
47
+ _next(undefined);
48
+ });
49
+ };
50
+ }
51
+
52
+ function _taggedTemplateLiteralLoose(strings, raw) {
53
+ if (!raw) {
54
+ raw = strings.slice(0);
55
+ }
56
+
57
+ strings.raw = raw;
58
+ return strings;
59
+ }
60
+
61
+ function createCommonjsModule(fn, module) {
62
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
63
+ }
64
+
65
+ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
66
+ /**
67
+ * Copyright (c) 2014-present, Facebook, Inc.
68
+ *
69
+ * This source code is licensed under the MIT license found in the
70
+ * LICENSE file in the root directory of this source tree.
71
+ */
72
+ var runtime = function (exports) {
73
+
74
+ var Op = Object.prototype;
75
+ var hasOwn = Op.hasOwnProperty;
76
+ var undefined$1; // More compressible than void 0.
77
+
78
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
79
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
80
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
81
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
82
+
83
+ function define(obj, key, value) {
84
+ Object.defineProperty(obj, key, {
85
+ value: value,
86
+ enumerable: true,
87
+ configurable: true,
88
+ writable: true
89
+ });
90
+ return obj[key];
91
+ }
92
+
93
+ try {
94
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
95
+ define({}, "");
96
+ } catch (err) {
97
+ define = function define(obj, key, value) {
98
+ return obj[key] = value;
99
+ };
100
+ }
101
+
102
+ function wrap(innerFn, outerFn, self, tryLocsList) {
103
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
104
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
105
+ var generator = Object.create(protoGenerator.prototype);
106
+ var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
107
+ // .throw, and .return methods.
108
+
109
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
110
+ return generator;
111
+ }
112
+
113
+ exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
114
+ // record like context.tryEntries[i].completion. This interface could
115
+ // have been (and was previously) designed to take a closure to be
116
+ // invoked without arguments, but in all the cases we care about we
117
+ // already have an existing method we want to call, so there's no need
118
+ // to create a new function object. We can even get away with assuming
119
+ // the method takes exactly one argument, since that happens to be true
120
+ // in every case, so we don't have to touch the arguments object. The
121
+ // only additional allocation required is the completion record, which
122
+ // has a stable shape and so hopefully should be cheap to allocate.
123
+
124
+ function tryCatch(fn, obj, arg) {
125
+ try {
126
+ return {
127
+ type: "normal",
128
+ arg: fn.call(obj, arg)
129
+ };
130
+ } catch (err) {
131
+ return {
132
+ type: "throw",
133
+ arg: err
134
+ };
135
+ }
136
+ }
137
+
138
+ var GenStateSuspendedStart = "suspendedStart";
139
+ var GenStateSuspendedYield = "suspendedYield";
140
+ var GenStateExecuting = "executing";
141
+ var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
142
+ // breaking out of the dispatch switch statement.
143
+
144
+ var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
145
+ // .constructor.prototype properties for functions that return Generator
146
+ // objects. For full spec compliance, you may wish to configure your
147
+ // minifier not to mangle the names of these two functions.
148
+
149
+ function Generator() {}
150
+
151
+ function GeneratorFunction() {}
152
+
153
+ function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
154
+ // don't natively support it.
155
+
156
+
157
+ var IteratorPrototype = {};
158
+ define(IteratorPrototype, iteratorSymbol, function () {
159
+ return this;
160
+ });
161
+ var getProto = Object.getPrototypeOf;
162
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
163
+
164
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
165
+ // This environment has a native %IteratorPrototype%; use it instead
166
+ // of the polyfill.
167
+ IteratorPrototype = NativeIteratorPrototype;
168
+ }
169
+
170
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
171
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
172
+ define(Gp, "constructor", GeneratorFunctionPrototype);
173
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
174
+ GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
175
+ // Iterator interface in terms of a single ._invoke method.
176
+
177
+ function defineIteratorMethods(prototype) {
178
+ ["next", "throw", "return"].forEach(function (method) {
179
+ define(prototype, method, function (arg) {
180
+ return this._invoke(method, arg);
181
+ });
182
+ });
183
+ }
184
+
185
+ exports.isGeneratorFunction = function (genFun) {
186
+ var ctor = typeof genFun === "function" && genFun.constructor;
187
+ return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
188
+ // do is to check its .name property.
189
+ (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
190
+ };
191
+
192
+ exports.mark = function (genFun) {
193
+ if (Object.setPrototypeOf) {
194
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
195
+ } else {
196
+ genFun.__proto__ = GeneratorFunctionPrototype;
197
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
198
+ }
199
+
200
+ genFun.prototype = Object.create(Gp);
201
+ return genFun;
202
+ }; // Within the body of any async function, `await x` is transformed to
203
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
204
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
205
+ // meant to be awaited.
206
+
207
+
208
+ exports.awrap = function (arg) {
209
+ return {
210
+ __await: arg
211
+ };
212
+ };
213
+
214
+ function AsyncIterator(generator, PromiseImpl) {
215
+ function invoke(method, arg, resolve, reject) {
216
+ var record = tryCatch(generator[method], generator, arg);
217
+
218
+ if (record.type === "throw") {
219
+ reject(record.arg);
220
+ } else {
221
+ var result = record.arg;
222
+ var value = result.value;
223
+
224
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
225
+ return PromiseImpl.resolve(value.__await).then(function (value) {
226
+ invoke("next", value, resolve, reject);
227
+ }, function (err) {
228
+ invoke("throw", err, resolve, reject);
229
+ });
230
+ }
231
+
232
+ return PromiseImpl.resolve(value).then(function (unwrapped) {
233
+ // When a yielded Promise is resolved, its final value becomes
234
+ // the .value of the Promise<{value,done}> result for the
235
+ // current iteration.
236
+ result.value = unwrapped;
237
+ resolve(result);
238
+ }, function (error) {
239
+ // If a rejected Promise was yielded, throw the rejection back
240
+ // into the async generator function so it can be handled there.
241
+ return invoke("throw", error, resolve, reject);
242
+ });
243
+ }
244
+ }
245
+
246
+ var previousPromise;
247
+
248
+ function enqueue(method, arg) {
249
+ function callInvokeWithMethodAndArg() {
250
+ return new PromiseImpl(function (resolve, reject) {
251
+ invoke(method, arg, resolve, reject);
252
+ });
253
+ }
254
+
255
+ return previousPromise = // If enqueue has been called before, then we want to wait until
256
+ // all previous Promises have been resolved before calling invoke,
257
+ // so that results are always delivered in the correct order. If
258
+ // enqueue has not been called before, then it is important to
259
+ // call invoke immediately, without waiting on a callback to fire,
260
+ // so that the async generator function has the opportunity to do
261
+ // any necessary setup in a predictable way. This predictability
262
+ // is why the Promise constructor synchronously invokes its
263
+ // executor callback, and why async functions synchronously
264
+ // execute code before the first await. Since we implement simple
265
+ // async functions in terms of async generators, it is especially
266
+ // important to get this right, even though it requires care.
267
+ previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
268
+ // invocations of the iterator.
269
+ callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
270
+ } // Define the unified helper method that is used to implement .next,
271
+ // .throw, and .return (see defineIteratorMethods).
272
+
273
+
274
+ this._invoke = enqueue;
275
+ }
276
+
277
+ defineIteratorMethods(AsyncIterator.prototype);
278
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
279
+ return this;
280
+ });
281
+ exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
282
+ // AsyncIterator objects; they just return a Promise for the value of
283
+ // the final result produced by the iterator.
284
+
285
+ exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
286
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
287
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
288
+ return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
289
+ : iter.next().then(function (result) {
290
+ return result.done ? result.value : iter.next();
291
+ });
292
+ };
293
+
294
+ function makeInvokeMethod(innerFn, self, context) {
295
+ var state = GenStateSuspendedStart;
296
+ return function invoke(method, arg) {
297
+ if (state === GenStateExecuting) {
298
+ throw new Error("Generator is already running");
299
+ }
300
+
301
+ if (state === GenStateCompleted) {
302
+ if (method === "throw") {
303
+ throw arg;
304
+ } // Be forgiving, per 25.3.3.3.3 of the spec:
305
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
306
+
307
+
308
+ return doneResult();
309
+ }
310
+
311
+ context.method = method;
312
+ context.arg = arg;
313
+
314
+ while (true) {
315
+ var delegate = context.delegate;
316
+
317
+ if (delegate) {
318
+ var delegateResult = maybeInvokeDelegate(delegate, context);
319
+
320
+ if (delegateResult) {
321
+ if (delegateResult === ContinueSentinel) continue;
322
+ return delegateResult;
323
+ }
324
+ }
325
+
326
+ if (context.method === "next") {
327
+ // Setting context._sent for legacy support of Babel's
328
+ // function.sent implementation.
329
+ context.sent = context._sent = context.arg;
330
+ } else if (context.method === "throw") {
331
+ if (state === GenStateSuspendedStart) {
332
+ state = GenStateCompleted;
333
+ throw context.arg;
334
+ }
335
+
336
+ context.dispatchException(context.arg);
337
+ } else if (context.method === "return") {
338
+ context.abrupt("return", context.arg);
339
+ }
340
+
341
+ state = GenStateExecuting;
342
+ var record = tryCatch(innerFn, self, context);
343
+
344
+ if (record.type === "normal") {
345
+ // If an exception is thrown from innerFn, we leave state ===
346
+ // GenStateExecuting and loop back for another invocation.
347
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
348
+
349
+ if (record.arg === ContinueSentinel) {
350
+ continue;
351
+ }
352
+
353
+ return {
354
+ value: record.arg,
355
+ done: context.done
356
+ };
357
+ } else if (record.type === "throw") {
358
+ state = GenStateCompleted; // Dispatch the exception by looping back around to the
359
+ // context.dispatchException(context.arg) call above.
360
+
361
+ context.method = "throw";
362
+ context.arg = record.arg;
363
+ }
364
+ }
365
+ };
366
+ } // Call delegate.iterator[context.method](context.arg) and handle the
367
+ // result, either by returning a { value, done } result from the
368
+ // delegate iterator, or by modifying context.method and context.arg,
369
+ // setting context.delegate to null, and returning the ContinueSentinel.
370
+
371
+
372
+ function maybeInvokeDelegate(delegate, context) {
373
+ var method = delegate.iterator[context.method];
374
+
375
+ if (method === undefined$1) {
376
+ // A .throw or .return when the delegate iterator has no .throw
377
+ // method always terminates the yield* loop.
378
+ context.delegate = null;
379
+
380
+ if (context.method === "throw") {
381
+ // Note: ["return"] must be used for ES3 parsing compatibility.
382
+ if (delegate.iterator["return"]) {
383
+ // If the delegate iterator has a return method, give it a
384
+ // chance to clean up.
385
+ context.method = "return";
386
+ context.arg = undefined$1;
387
+ maybeInvokeDelegate(delegate, context);
388
+
389
+ if (context.method === "throw") {
390
+ // If maybeInvokeDelegate(context) changed context.method from
391
+ // "return" to "throw", let that override the TypeError below.
392
+ return ContinueSentinel;
393
+ }
394
+ }
395
+
396
+ context.method = "throw";
397
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
398
+ }
399
+
400
+ return ContinueSentinel;
401
+ }
402
+
403
+ var record = tryCatch(method, delegate.iterator, context.arg);
404
+
405
+ if (record.type === "throw") {
406
+ context.method = "throw";
407
+ context.arg = record.arg;
408
+ context.delegate = null;
409
+ return ContinueSentinel;
410
+ }
411
+
412
+ var info = record.arg;
413
+
414
+ if (!info) {
415
+ context.method = "throw";
416
+ context.arg = new TypeError("iterator result is not an object");
417
+ context.delegate = null;
418
+ return ContinueSentinel;
419
+ }
420
+
421
+ if (info.done) {
422
+ // Assign the result of the finished delegate to the temporary
423
+ // variable specified by delegate.resultName (see delegateYield).
424
+ context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
425
+
426
+ context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
427
+ // exception, let the outer generator proceed normally. If
428
+ // context.method was "next", forget context.arg since it has been
429
+ // "consumed" by the delegate iterator. If context.method was
430
+ // "return", allow the original .return call to continue in the
431
+ // outer generator.
432
+
433
+ if (context.method !== "return") {
434
+ context.method = "next";
435
+ context.arg = undefined$1;
436
+ }
437
+ } else {
438
+ // Re-yield the result returned by the delegate method.
439
+ return info;
440
+ } // The delegate iterator is finished, so forget it and continue with
441
+ // the outer generator.
442
+
443
+
444
+ context.delegate = null;
445
+ return ContinueSentinel;
446
+ } // Define Generator.prototype.{next,throw,return} in terms of the
447
+ // unified ._invoke helper method.
448
+
449
+
450
+ defineIteratorMethods(Gp);
451
+ define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
452
+ // @@iterator function is called on it. Some browsers' implementations of the
453
+ // iterator prototype chain incorrectly implement this, causing the Generator
454
+ // object to not be returned from this call. This ensures that doesn't happen.
455
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
456
+
457
+ define(Gp, iteratorSymbol, function () {
458
+ return this;
459
+ });
460
+ define(Gp, "toString", function () {
461
+ return "[object Generator]";
462
+ });
463
+
464
+ function pushTryEntry(locs) {
465
+ var entry = {
466
+ tryLoc: locs[0]
467
+ };
468
+
469
+ if (1 in locs) {
470
+ entry.catchLoc = locs[1];
471
+ }
472
+
473
+ if (2 in locs) {
474
+ entry.finallyLoc = locs[2];
475
+ entry.afterLoc = locs[3];
476
+ }
477
+
478
+ this.tryEntries.push(entry);
479
+ }
480
+
481
+ function resetTryEntry(entry) {
482
+ var record = entry.completion || {};
483
+ record.type = "normal";
484
+ delete record.arg;
485
+ entry.completion = record;
486
+ }
487
+
488
+ function Context(tryLocsList) {
489
+ // The root entry object (effectively a try statement without a catch
490
+ // or a finally block) gives us a place to store values thrown from
491
+ // locations where there is no enclosing try statement.
492
+ this.tryEntries = [{
493
+ tryLoc: "root"
494
+ }];
495
+ tryLocsList.forEach(pushTryEntry, this);
496
+ this.reset(true);
497
+ }
498
+
499
+ exports.keys = function (object) {
500
+ var keys = [];
501
+
502
+ for (var key in object) {
503
+ keys.push(key);
504
+ }
505
+
506
+ keys.reverse(); // Rather than returning an object with a next method, we keep
507
+ // things simple and return the next function itself.
508
+
509
+ return function next() {
510
+ while (keys.length) {
511
+ var key = keys.pop();
512
+
513
+ if (key in object) {
514
+ next.value = key;
515
+ next.done = false;
516
+ return next;
517
+ }
518
+ } // To avoid creating an additional object, we just hang the .value
519
+ // and .done properties off the next function object itself. This
520
+ // also ensures that the minifier will not anonymize the function.
521
+
522
+
523
+ next.done = true;
524
+ return next;
525
+ };
526
+ };
527
+
528
+ function values(iterable) {
529
+ if (iterable) {
530
+ var iteratorMethod = iterable[iteratorSymbol];
531
+
532
+ if (iteratorMethod) {
533
+ return iteratorMethod.call(iterable);
534
+ }
535
+
536
+ if (typeof iterable.next === "function") {
537
+ return iterable;
538
+ }
539
+
540
+ if (!isNaN(iterable.length)) {
541
+ var i = -1,
542
+ next = function next() {
543
+ while (++i < iterable.length) {
544
+ if (hasOwn.call(iterable, i)) {
545
+ next.value = iterable[i];
546
+ next.done = false;
547
+ return next;
548
+ }
549
+ }
550
+
551
+ next.value = undefined$1;
552
+ next.done = true;
553
+ return next;
554
+ };
555
+
556
+ return next.next = next;
557
+ }
558
+ } // Return an iterator with no values.
559
+
560
+
561
+ return {
562
+ next: doneResult
563
+ };
564
+ }
565
+
566
+ exports.values = values;
567
+
568
+ function doneResult() {
569
+ return {
570
+ value: undefined$1,
571
+ done: true
572
+ };
573
+ }
574
+
575
+ Context.prototype = {
576
+ constructor: Context,
577
+ reset: function reset(skipTempReset) {
578
+ this.prev = 0;
579
+ this.next = 0; // Resetting context._sent for legacy support of Babel's
580
+ // function.sent implementation.
581
+
582
+ this.sent = this._sent = undefined$1;
583
+ this.done = false;
584
+ this.delegate = null;
585
+ this.method = "next";
586
+ this.arg = undefined$1;
587
+ this.tryEntries.forEach(resetTryEntry);
588
+
589
+ if (!skipTempReset) {
590
+ for (var name in this) {
591
+ // Not sure about the optimal order of these conditions:
592
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
593
+ this[name] = undefined$1;
594
+ }
595
+ }
596
+ }
597
+ },
598
+ stop: function stop() {
599
+ this.done = true;
600
+ var rootEntry = this.tryEntries[0];
601
+ var rootRecord = rootEntry.completion;
602
+
603
+ if (rootRecord.type === "throw") {
604
+ throw rootRecord.arg;
605
+ }
606
+
607
+ return this.rval;
608
+ },
609
+ dispatchException: function dispatchException(exception) {
610
+ if (this.done) {
611
+ throw exception;
612
+ }
613
+
614
+ var context = this;
615
+
616
+ function handle(loc, caught) {
617
+ record.type = "throw";
618
+ record.arg = exception;
619
+ context.next = loc;
620
+
621
+ if (caught) {
622
+ // If the dispatched exception was caught by a catch block,
623
+ // then let that catch block handle the exception normally.
624
+ context.method = "next";
625
+ context.arg = undefined$1;
626
+ }
627
+
628
+ return !!caught;
629
+ }
630
+
631
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
632
+ var entry = this.tryEntries[i];
633
+ var record = entry.completion;
634
+
635
+ if (entry.tryLoc === "root") {
636
+ // Exception thrown outside of any try block that could handle
637
+ // it, so set the completion value of the entire function to
638
+ // throw the exception.
639
+ return handle("end");
640
+ }
641
+
642
+ if (entry.tryLoc <= this.prev) {
643
+ var hasCatch = hasOwn.call(entry, "catchLoc");
644
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
645
+
646
+ if (hasCatch && hasFinally) {
647
+ if (this.prev < entry.catchLoc) {
648
+ return handle(entry.catchLoc, true);
649
+ } else if (this.prev < entry.finallyLoc) {
650
+ return handle(entry.finallyLoc);
651
+ }
652
+ } else if (hasCatch) {
653
+ if (this.prev < entry.catchLoc) {
654
+ return handle(entry.catchLoc, true);
655
+ }
656
+ } else if (hasFinally) {
657
+ if (this.prev < entry.finallyLoc) {
658
+ return handle(entry.finallyLoc);
659
+ }
660
+ } else {
661
+ throw new Error("try statement without catch or finally");
662
+ }
663
+ }
664
+ }
665
+ },
666
+ abrupt: function abrupt(type, arg) {
667
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
668
+ var entry = this.tryEntries[i];
669
+
670
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
671
+ var finallyEntry = entry;
672
+ break;
673
+ }
674
+ }
675
+
676
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
677
+ // Ignore the finally entry if control is not jumping to a
678
+ // location outside the try/catch block.
679
+ finallyEntry = null;
680
+ }
681
+
682
+ var record = finallyEntry ? finallyEntry.completion : {};
683
+ record.type = type;
684
+ record.arg = arg;
685
+
686
+ if (finallyEntry) {
687
+ this.method = "next";
688
+ this.next = finallyEntry.finallyLoc;
689
+ return ContinueSentinel;
690
+ }
691
+
692
+ return this.complete(record);
693
+ },
694
+ complete: function complete(record, afterLoc) {
695
+ if (record.type === "throw") {
696
+ throw record.arg;
697
+ }
698
+
699
+ if (record.type === "break" || record.type === "continue") {
700
+ this.next = record.arg;
701
+ } else if (record.type === "return") {
702
+ this.rval = this.arg = record.arg;
703
+ this.method = "return";
704
+ this.next = "end";
705
+ } else if (record.type === "normal" && afterLoc) {
706
+ this.next = afterLoc;
707
+ }
708
+
709
+ return ContinueSentinel;
710
+ },
711
+ finish: function finish(finallyLoc) {
712
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
713
+ var entry = this.tryEntries[i];
714
+
715
+ if (entry.finallyLoc === finallyLoc) {
716
+ this.complete(entry.completion, entry.afterLoc);
717
+ resetTryEntry(entry);
718
+ return ContinueSentinel;
719
+ }
720
+ }
721
+ },
722
+ "catch": function _catch(tryLoc) {
723
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
724
+ var entry = this.tryEntries[i];
725
+
726
+ if (entry.tryLoc === tryLoc) {
727
+ var record = entry.completion;
728
+
729
+ if (record.type === "throw") {
730
+ var thrown = record.arg;
731
+ resetTryEntry(entry);
732
+ }
733
+
734
+ return thrown;
735
+ }
736
+ } // The context.catch method must only be called with a location
737
+ // argument that corresponds to a known catch block.
738
+
739
+
740
+ throw new Error("illegal catch attempt");
741
+ },
742
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
743
+ this.delegate = {
744
+ iterator: values(iterable),
745
+ resultName: resultName,
746
+ nextLoc: nextLoc
747
+ };
748
+
749
+ if (this.method === "next") {
750
+ // Deliberately forget the last sent value so that we don't
751
+ // accidentally pass it on to the delegate.
752
+ this.arg = undefined$1;
753
+ }
754
+
755
+ return ContinueSentinel;
756
+ }
757
+ }; // Regardless of whether this script is executing as a CommonJS module
758
+ // or not, return the runtime object so that we can declare the variable
759
+ // regeneratorRuntime in the outer scope, which allows this module to be
760
+ // injected easily by `bin/regenerator --include-runtime script.js`.
761
+
762
+ return exports;
763
+ }( // If this script is executing as a CommonJS module, use module.exports
764
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
765
+ // object. Either way, the resulting object will be used to initialize
766
+ // the regeneratorRuntime variable at the top of this file.
767
+ module.exports );
768
+
769
+ try {
770
+ regeneratorRuntime = runtime;
771
+ } catch (accidentalStrictMode) {
772
+ // This module should not be running in strict mode, so the above
773
+ // assignment should always work unless something is misconfigured. Just
774
+ // in case runtime.js accidentally runs in strict mode, in modern engines
775
+ // we can explicitly access globalThis. In older engines we can escape
776
+ // strict mode using a global Function call. This could conceivably fail
777
+ // if a Content Security Policy forbids using Function, but in that case
778
+ // the proper solution is to fix the accidental strict mode problem. If
779
+ // you've misconfigured your bundler to force strict mode and applied a
780
+ // CSP to forbid Function, and you're not willing to fix either of those
781
+ // problems, please detail your unique predicament in a GitHub issue.
782
+ if (typeof globalThis === "object") {
783
+ globalThis.regeneratorRuntime = runtime;
784
+ } else {
785
+ Function("r", "regeneratorRuntime = r")(runtime);
786
+ }
787
+ }
788
+ });
789
+
790
+ var _templateObject;
791
+ function ensure(x) {
792
+ if (x === null || x === undefined) {
793
+ debugger;
794
+ throw new Error("Value must not be undefined or null");
795
+ } else {
796
+ return x;
797
+ }
798
+ }
799
+ var modulePath = "@plasmicpkgs/plasmic-graphcms";
800
+ var CredentialsContext = /*#__PURE__*/React__default.createContext(undefined);
801
+ var GraphCMSCredentialsProviderMeta = {
802
+ name: "GraphCMSCredentialsProvider",
803
+ displayName: "GraphCMS Credentials Provider",
804
+ description: "Permanent Auth Tokens are used for controlling access to querying, mutating content, and comes in the form of Bearer token authentication.[get your Auth Token](https://graphcms.com/docs/api-reference/basics/authorization#permanent-auth-tokens).",
805
+ importName: "GraphCMSCredentialsProvider",
806
+ importPath: modulePath,
807
+ props: {
808
+ apiUrl: {
809
+ type: "string",
810
+ displayName: "API url",
811
+ description: "API url of your GraphCMS ",
812
+ defaultValue: "https://api-us-west-2.graphcms.com/v2/cl3ua8gpwdni001z10ucc482i/master"
813
+ },
814
+ authToken: {
815
+ type: "string",
816
+ displayName: "Auth Token ",
817
+ description: "Auth Token",
818
+ defaultValue: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImdjbXMtbWFpbi1wcm9kdWN0aW9uIn0.eyJ2ZXJzaW9uIjozLCJpYXQiOjE2NTQwMDg5NzUsImF1ZCI6WyJodHRwczovL2FwaS11cy13ZXN0LTIuZ3JhcGhjbXMuY29tL3YyL2NsM3VhOGdwd2RuaTAwMXoxMHVjYzQ4MmkvbWFzdGVyIiwiaHR0cHM6Ly9tYW5hZ2VtZW50LW5leHQuZ3JhcGhjbXMuY29tIl0sImlzcyI6Imh0dHBzOi8vbWFuYWdlbWVudC5ncmFwaGNtcy5jb20vIiwic3ViIjoiMWU2NGY0ZDMtODE3Yy00OTdkLWE4YTQtNzA4OTY4Zjg3OTc3IiwianRpIjoiY2thNWoyZW9iMDN0YzAxd2gwZGZkNjdyeSJ9.bWr3rpqT7UmJ5NwoEVatkW_QsqxC8tB-zxdcTecIVR19oS5tcoxbbmwe946B-57Zmqrnc5rNntj9UjN065RqEDFM0iPhy4BCgDHCFfNUuHg5Mmq1qu8-j_ZSN90aJfwVmMNYH9GuOYFiOCd6uytLe8fPcQRWOKpXEcO8q4BusrreCvwkwXIaZV2dq-FOJ4LdBdKcRWwfQWeMdthVzBxrlrxogP_xEYQuMNdfbe5tGWgVsRVDN7eQjB1w9Srqc9T_NgY6x-aL8rPmobcZ1IMdUj9klPPm_dINMzrhZS4OR-HXHPwdnSFObgPeJDPI6YEo2SFAg78PMCNZNRT2DtfDVC4F7cLboxaNUNY4r6Z2d9uBu2N1o05zIXra6Q4JIA--0xBfELTUcmU06Ococioyui8PCI5r_QlRSSlnxrdb85Ht00yMDBRGHPtySGUNiEy9Lq5RcoW1a41bJRmZ-z1Q8zluOUHrgwcIb2DN8xKB9YThPce7ytnFcVajH0K3Hnd57m7SukCgZACmULt_EK0NYTUe1BBmTC8eg9ZBM3lplPWSUzBKWgajGTUNK50KRWokAke_UCEf0gssR3MYLIo5PVN131-bD57nccEPBkegYmmZUACRoYHyI_gQYC-0---MXCS6BV7cK1D-_yDbiBrCCixyKNBYCmhxuZOxVcWu4dk"
819
+ }
820
+ }
821
+ };
822
+ function GraphCMSCredentialsProvider(_ref) {
823
+ var apiUrl = _ref.apiUrl,
824
+ authToken = _ref.authToken,
825
+ children = _ref.children;
826
+ return React__default.createElement(CredentialsContext.Provider, {
827
+ value: {
828
+ apiUrl: apiUrl,
829
+ authToken: authToken
830
+ }
831
+ }, children);
832
+ }
833
+ var GraphCMSFetcherMeta = {
834
+ name: "GraphCMSFetcher",
835
+ displayName: "GraphCMS Fetcher",
836
+ importName: "GraphCMSFetcher",
837
+ importPath: modulePath,
838
+ description: "Fetches GraphCMS data and repeats content of children once for every row fetched. ",
839
+ defaultStyles: {
840
+ display: "grid",
841
+ gridTemplateColumns: "1fr 1fr 1fr 1fr",
842
+ gridRowGap: "8px",
843
+ gridColumnGap: "8px",
844
+ padding: "8px",
845
+ maxWidth: "100%"
846
+ },
847
+ props: {
848
+ children: {
849
+ type: "slot",
850
+ defaultValue: {
851
+ type: "vbox",
852
+ styles: {
853
+ padding: "8px"
854
+ },
855
+ children: {
856
+ type: "component",
857
+ name: "GraphCMSField"
858
+ }
859
+ }
860
+ },
861
+ query: {
862
+ type: "code",
863
+ lang: "graphql",
864
+ endpoint: function endpoint(props, ctx) {
865
+ var _ctx$endpoint;
866
+
867
+ return (_ctx$endpoint = ctx == null ? void 0 : ctx.endpoint) != null ? _ctx$endpoint : "";
868
+ },
869
+ headers: function headers(props, ctx) {
870
+ var _ctx$headers;
871
+
872
+ return (_ctx$headers = ctx == null ? void 0 : ctx.headers) != null ? _ctx$headers : "";
873
+ }
874
+ },
875
+ noLayout: {
876
+ type: "boolean",
877
+ displayName: "No layout",
878
+ description: "When set, GraphCMS Fetcher will not layout its children; instead, the layout set on its parent element will be used. Useful if you want to set flex gap or control container tag type.",
879
+ defaultValue: false
880
+ }
881
+ }
882
+ };
883
+ function GraphCMSFetcher(_ref2) {
884
+ var query$1 = _ref2.query,
885
+ children = _ref2.children,
886
+ className = _ref2.className,
887
+ noLayout = _ref2.noLayout,
888
+ setControlContextData = _ref2.setControlContextData;
889
+ var creds = ensure(React.useContext(CredentialsContext));
890
+ var cacheKey = JSON.stringify({
891
+ query: query$1,
892
+ creds: creds
893
+ });
894
+ var headers = {
895
+ Authorization: "Bearer " + creds.authToken
896
+ };
897
+ var client = new graphqlRequest.GraphQLClient(creds.apiUrl, {
898
+ headers: headers
899
+ });
900
+
901
+ var _usePlasmicQueryData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
902
+ var entryRequest;
903
+ return runtime_1.wrap(function _callee$(_context) {
904
+ while (1) {
905
+ switch (_context.prev = _context.next) {
906
+ case 0:
907
+ if (query$1) {
908
+ _context.next = 2;
909
+ break;
910
+ }
911
+
912
+ return _context.abrupt("return", null);
913
+
914
+ case 2:
915
+ entryRequest = graphqlRequest.gql(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", "\n "])), query$1);
916
+ _context.next = 5;
917
+ return client.request(entryRequest);
918
+
919
+ case 5:
920
+ return _context.abrupt("return", _context.sent);
921
+
922
+ case 6:
923
+ case "end":
924
+ return _context.stop();
925
+ }
926
+ }
927
+ }, _callee);
928
+ }))),
929
+ data = _usePlasmicQueryData.data;
930
+
931
+ setControlContextData == null ? void 0 : setControlContextData({
932
+ endpoint: creds.apiUrl,
933
+ headers: headers
934
+ });
935
+
936
+ if (!query$1) {
937
+ return React__default.createElement("div", null, "Please make a query in order to fetch data ");
938
+ }
939
+
940
+ if (!creds.apiUrl || !creds.authToken) {
941
+ return React__default.createElement("div", null, "Please specify a valid API Credentials: API Url, Auth Token");
942
+ }
943
+
944
+ var renderedData = Object.values(data != null ? data : {}).flatMap(function (model, i) {
945
+ return model.map(function (item, j) {
946
+ return React__default.createElement(host.DataProvider, {
947
+ key: JSON.stringify(item),
948
+ name: "GraphCMSItem",
949
+ data: item
950
+ }, host.repeatedElement(i === 0 && j === 0, children));
951
+ });
952
+ });
953
+ return noLayout ? React__default.createElement(React__default.Fragment, null, " ", renderedData, " ") : React__default.createElement("div", {
954
+ className: className
955
+ }, " ", renderedData, " ");
956
+ }
957
+ var GraphCMSFieldMeta = {
958
+ name: "GraphCMSField",
959
+ displayName: "GraphCMS Field",
960
+ importName: "GraphCMSField",
961
+ importPath: modulePath,
962
+ props: {
963
+ path: {
964
+ type: "dataSelector",
965
+ data: function data(props, ctx) {
966
+ var _ctx$data;
967
+
968
+ return (_ctx$data = ctx == null ? void 0 : ctx.data) != null ? _ctx$data : {};
969
+ },
970
+ displayName: "Field",
971
+ description: "Field to be displayed."
972
+ }
973
+ }
974
+ };
975
+ function GraphCMSField(_ref4) {
976
+ var _data$mimeType;
977
+
978
+ var className = _ref4.className,
979
+ path = _ref4.path,
980
+ setControlContextData = _ref4.setControlContextData;
981
+ var item = host.useSelector("GraphCMSItem");
982
+
983
+ if (!item) {
984
+ return React__default.createElement("div", null, "GraphCMSField must be used within a GraphCMSFetcher ");
985
+ }
986
+
987
+ setControlContextData == null ? void 0 : setControlContextData({
988
+ data: item
989
+ });
990
+
991
+ if (!path) {
992
+ return React__default.createElement("div", null, "Please specify a valid path or select a field.");
993
+ } // We need to improve this check by making an introspection query
994
+
995
+
996
+ var isRichText = function isRichText(data) {
997
+ return "html" in data;
998
+ };
999
+
1000
+ var data = L.get(item, path);
1001
+
1002
+ if (typeof data === "object" && (_data$mimeType = data.mimeType) != null && _data$mimeType.startsWith("image")) {
1003
+ return React__default.createElement("img", {
1004
+ src: data.url,
1005
+ className: className
1006
+ });
1007
+ } else if (typeof data === "object" && isRichText(data)) {
1008
+ return React__default.createElement("div", {
1009
+ className: className,
1010
+ dangerouslySetInnerHTML: {
1011
+ __html: data.html
1012
+ }
1013
+ });
1014
+ } else if (!data || typeof data === "object") {
1015
+ return React__default.createElement("div", {
1016
+ className: className
1017
+ }, "Please specify a valid field.");
1018
+ } else {
1019
+ return React__default.createElement("div", {
1020
+ className: className
1021
+ }, " ", data, " ");
1022
+ }
1023
+ }
1024
+
1025
+ function registerAll(loader) {
1026
+ var _registerComponent = function _registerComponent(Component, defaultMeta) {
1027
+ if (loader) {
1028
+ loader.registerComponent(Component, defaultMeta);
1029
+ } else {
1030
+ registerComponent(Component, defaultMeta);
1031
+ }
1032
+ };
1033
+
1034
+ if (loader) {
1035
+ loader.registerGlobalContext(GraphCMSCredentialsProvider, GraphCMSCredentialsProviderMeta);
1036
+ } else {
1037
+ registerGlobalContext(GraphCMSCredentialsProvider, GraphCMSCredentialsProviderMeta);
1038
+ }
1039
+
1040
+ _registerComponent(GraphCMSFetcher, GraphCMSFetcherMeta);
1041
+
1042
+ _registerComponent(GraphCMSField, GraphCMSFieldMeta);
1043
+ }
1044
+
1045
+ exports.GraphCMSCredentialsProvider = GraphCMSCredentialsProvider;
1046
+ exports.GraphCMSCredentialsProviderMeta = GraphCMSCredentialsProviderMeta;
1047
+ exports.GraphCMSFetcher = GraphCMSFetcher;
1048
+ exports.GraphCMSFetcherMeta = GraphCMSFetcherMeta;
1049
+ exports.GraphCMSField = GraphCMSField;
1050
+ exports.GraphCMSFieldMeta = GraphCMSFieldMeta;
1051
+ exports.ensure = ensure;
1052
+ exports.registerAll = registerAll;
1053
+ //# sourceMappingURL=plasmic-graphcms.cjs.development.js.map