@plasmicpkgs/plasmic-content-stack 0.0.2

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