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