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