@plasmicapp/loader-nextjs 1.0.265 → 1.0.267

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,882 @@
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
+ require('server-only');
8
+ var reactServer = require('@plasmicapp/loader-react/react-server');
9
+ var path = _interopDefault(require('path'));
10
+
11
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
12
+ try {
13
+ var info = gen[key](arg);
14
+ var value = info.value;
15
+ } catch (error) {
16
+ reject(error);
17
+ return;
18
+ }
19
+ if (info.done) {
20
+ resolve(value);
21
+ } else {
22
+ Promise.resolve(value).then(_next, _throw);
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
+ function _next(value) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
33
+ }
34
+ function _throw(err) {
35
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
36
+ }
37
+ _next(undefined);
38
+ });
39
+ };
40
+ }
41
+ function _extends() {
42
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
43
+ for (var i = 1; i < arguments.length; i++) {
44
+ var source = arguments[i];
45
+ for (var key in source) {
46
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
47
+ target[key] = source[key];
48
+ }
49
+ }
50
+ }
51
+ return target;
52
+ };
53
+ return _extends.apply(this, arguments);
54
+ }
55
+
56
+ function createCommonjsModule(fn, module) {
57
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
58
+ }
59
+
60
+ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
61
+ /**
62
+ * Copyright (c) 2014-present, Facebook, Inc.
63
+ *
64
+ * This source code is licensed under the MIT license found in the
65
+ * LICENSE file in the root directory of this source tree.
66
+ */
67
+
68
+ var runtime = function (exports) {
69
+
70
+ var Op = Object.prototype;
71
+ var hasOwn = Op.hasOwnProperty;
72
+ var undefined$1; // More compressible than void 0.
73
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
74
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
75
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
76
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
77
+ function define(obj, key, value) {
78
+ Object.defineProperty(obj, key, {
79
+ value: value,
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true
83
+ });
84
+ return obj[key];
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
+ function wrap(innerFn, outerFn, self, tryLocsList) {
95
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
96
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
97
+ var generator = Object.create(protoGenerator.prototype);
98
+ var context = new Context(tryLocsList || []);
99
+
100
+ // The ._invoke method unifies the implementations of the .next,
101
+ // .throw, and .return methods.
102
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
103
+ return generator;
104
+ }
105
+ exports.wrap = wrap;
106
+
107
+ // Try/catch helper to minimize deoptimizations. Returns a completion
108
+ // record like context.tryEntries[i].completion. This interface could
109
+ // have been (and was previously) designed to take a closure to be
110
+ // invoked without arguments, but in all the cases we care about we
111
+ // already have an existing method we want to call, so there's no need
112
+ // to create a new function object. We can even get away with assuming
113
+ // the method takes exactly one argument, since that happens to be true
114
+ // in every case, so we don't have to touch the arguments object. The
115
+ // only additional allocation required is the completion record, which
116
+ // has a stable shape and so hopefully should be cheap to allocate.
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
+ var GenStateSuspendedStart = "suspendedStart";
131
+ var GenStateSuspendedYield = "suspendedYield";
132
+ var GenStateExecuting = "executing";
133
+ var GenStateCompleted = "completed";
134
+
135
+ // Returning this object from the innerFn has the same effect as
136
+ // breaking out of the dispatch switch statement.
137
+ var ContinueSentinel = {};
138
+
139
+ // Dummy constructor functions that we use as the .constructor and
140
+ // .constructor.prototype properties for functions that return Generator
141
+ // objects. For full spec compliance, you may wish to configure your
142
+ // minifier not to mangle the names of these two functions.
143
+ function Generator() {}
144
+ function GeneratorFunction() {}
145
+ function GeneratorFunctionPrototype() {}
146
+
147
+ // This is a polyfill for %IteratorPrototype% for environments that
148
+ // don't natively support it.
149
+ var IteratorPrototype = {};
150
+ define(IteratorPrototype, iteratorSymbol, function () {
151
+ return this;
152
+ });
153
+ var getProto = Object.getPrototypeOf;
154
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
155
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
156
+ // This environment has a native %IteratorPrototype%; use it instead
157
+ // of the polyfill.
158
+ IteratorPrototype = NativeIteratorPrototype;
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");
165
+
166
+ // Helper for defining the .next, .throw, and .return methods of the
167
+ // Iterator interface in terms of a single ._invoke method.
168
+ function defineIteratorMethods(prototype) {
169
+ ["next", "throw", "return"].forEach(function (method) {
170
+ define(prototype, method, function (arg) {
171
+ return this._invoke(method, arg);
172
+ });
173
+ });
174
+ }
175
+ exports.isGeneratorFunction = function (genFun) {
176
+ var ctor = typeof genFun === "function" && genFun.constructor;
177
+ return ctor ? ctor === GeneratorFunction ||
178
+ // For the native GeneratorFunction constructor, the best we can
179
+ // do is to check its .name property.
180
+ (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
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
+ genFun.prototype = Object.create(Gp);
190
+ return genFun;
191
+ };
192
+
193
+ // Within the body of any async function, `await x` is transformed to
194
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
195
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
196
+ // meant to be awaited.
197
+ exports.awrap = function (arg) {
198
+ return {
199
+ __await: arg
200
+ };
201
+ };
202
+ function AsyncIterator(generator, PromiseImpl) {
203
+ function invoke(method, arg, resolve, reject) {
204
+ var record = tryCatch(generator[method], generator, arg);
205
+ if (record.type === "throw") {
206
+ reject(record.arg);
207
+ } else {
208
+ var result = record.arg;
209
+ var value = result.value;
210
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
211
+ return PromiseImpl.resolve(value.__await).then(function (value) {
212
+ invoke("next", value, resolve, reject);
213
+ }, function (err) {
214
+ invoke("throw", err, resolve, reject);
215
+ });
216
+ }
217
+ return PromiseImpl.resolve(value).then(function (unwrapped) {
218
+ // When a yielded Promise is resolved, its final value becomes
219
+ // the .value of the Promise<{value,done}> result for the
220
+ // current iteration.
221
+ result.value = unwrapped;
222
+ resolve(result);
223
+ }, function (error) {
224
+ // If a rejected Promise was yielded, throw the rejection back
225
+ // into the async generator function so it can be handled there.
226
+ return invoke("throw", error, resolve, reject);
227
+ });
228
+ }
229
+ }
230
+ var previousPromise;
231
+ function enqueue(method, arg) {
232
+ function callInvokeWithMethodAndArg() {
233
+ return new PromiseImpl(function (resolve, reject) {
234
+ invoke(method, arg, resolve, reject);
235
+ });
236
+ }
237
+ return previousPromise =
238
+ // If enqueue has been called before, then we want to wait until
239
+ // all previous Promises have been resolved before calling invoke,
240
+ // so that results are always delivered in the correct order. If
241
+ // enqueue has not been called before, then it is important to
242
+ // call invoke immediately, without waiting on a callback to fire,
243
+ // so that the async generator function has the opportunity to do
244
+ // any necessary setup in a predictable way. This predictability
245
+ // is why the Promise constructor synchronously invokes its
246
+ // executor callback, and why async functions synchronously
247
+ // execute code before the first await. Since we implement simple
248
+ // async functions in terms of async generators, it is especially
249
+ // important to get this right, even though it requires care.
250
+ previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
251
+ // Avoid propagating failures to Promises returned by later
252
+ // invocations of the iterator.
253
+ callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
254
+ }
255
+
256
+ // Define the unified helper method that is used to implement .next,
257
+ // .throw, and .return (see defineIteratorMethods).
258
+ this._invoke = enqueue;
259
+ }
260
+ defineIteratorMethods(AsyncIterator.prototype);
261
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
262
+ return this;
263
+ });
264
+ exports.AsyncIterator = AsyncIterator;
265
+
266
+ // Note that simple async functions are implemented on top of
267
+ // AsyncIterator objects; they just return a Promise for the value of
268
+ // the final result produced by the iterator.
269
+ exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
270
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
271
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
272
+ return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
273
+ : iter.next().then(function (result) {
274
+ return result.done ? result.value : iter.next();
275
+ });
276
+ };
277
+ function makeInvokeMethod(innerFn, self, context) {
278
+ var state = GenStateSuspendedStart;
279
+ return function invoke(method, arg) {
280
+ if (state === GenStateExecuting) {
281
+ throw new Error("Generator is already running");
282
+ }
283
+ if (state === GenStateCompleted) {
284
+ if (method === "throw") {
285
+ throw arg;
286
+ }
287
+
288
+ // Be forgiving, per 25.3.3.3.3 of the spec:
289
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
290
+ return doneResult();
291
+ }
292
+ context.method = method;
293
+ context.arg = arg;
294
+ while (true) {
295
+ var delegate = context.delegate;
296
+ if (delegate) {
297
+ var delegateResult = maybeInvokeDelegate(delegate, context);
298
+ if (delegateResult) {
299
+ if (delegateResult === ContinueSentinel) continue;
300
+ return delegateResult;
301
+ }
302
+ }
303
+ if (context.method === "next") {
304
+ // Setting context._sent for legacy support of Babel's
305
+ // function.sent implementation.
306
+ context.sent = context._sent = context.arg;
307
+ } else if (context.method === "throw") {
308
+ if (state === GenStateSuspendedStart) {
309
+ state = GenStateCompleted;
310
+ throw context.arg;
311
+ }
312
+ context.dispatchException(context.arg);
313
+ } else if (context.method === "return") {
314
+ context.abrupt("return", context.arg);
315
+ }
316
+ state = GenStateExecuting;
317
+ var record = tryCatch(innerFn, self, context);
318
+ if (record.type === "normal") {
319
+ // If an exception is thrown from innerFn, we leave state ===
320
+ // GenStateExecuting and loop back for another invocation.
321
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
322
+ if (record.arg === ContinueSentinel) {
323
+ continue;
324
+ }
325
+ return {
326
+ value: record.arg,
327
+ done: context.done
328
+ };
329
+ } else if (record.type === "throw") {
330
+ state = GenStateCompleted;
331
+ // Dispatch the exception by looping back around to the
332
+ // context.dispatchException(context.arg) call above.
333
+ context.method = "throw";
334
+ context.arg = record.arg;
335
+ }
336
+ }
337
+ };
338
+ }
339
+
340
+ // Call delegate.iterator[context.method](context.arg) and handle the
341
+ // result, either by returning a { value, done } result from the
342
+ // delegate iterator, or by modifying context.method and context.arg,
343
+ // setting context.delegate to null, and returning the ContinueSentinel.
344
+ function maybeInvokeDelegate(delegate, context) {
345
+ var method = delegate.iterator[context.method];
346
+ if (method === undefined$1) {
347
+ // A .throw or .return when the delegate iterator has no .throw
348
+ // method always terminates the yield* loop.
349
+ context.delegate = null;
350
+ if (context.method === "throw") {
351
+ // Note: ["return"] must be used for ES3 parsing compatibility.
352
+ if (delegate.iterator["return"]) {
353
+ // If the delegate iterator has a return method, give it a
354
+ // chance to clean up.
355
+ context.method = "return";
356
+ context.arg = undefined$1;
357
+ maybeInvokeDelegate(delegate, context);
358
+ if (context.method === "throw") {
359
+ // If maybeInvokeDelegate(context) changed context.method from
360
+ // "return" to "throw", let that override the TypeError below.
361
+ return ContinueSentinel;
362
+ }
363
+ }
364
+ context.method = "throw";
365
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
366
+ }
367
+ return ContinueSentinel;
368
+ }
369
+ var record = tryCatch(method, delegate.iterator, context.arg);
370
+ if (record.type === "throw") {
371
+ context.method = "throw";
372
+ context.arg = record.arg;
373
+ context.delegate = null;
374
+ return ContinueSentinel;
375
+ }
376
+ var info = record.arg;
377
+ if (!info) {
378
+ context.method = "throw";
379
+ context.arg = new TypeError("iterator result is not an object");
380
+ context.delegate = null;
381
+ return ContinueSentinel;
382
+ }
383
+ if (info.done) {
384
+ // Assign the result of the finished delegate to the temporary
385
+ // variable specified by delegate.resultName (see delegateYield).
386
+ context[delegate.resultName] = info.value;
387
+
388
+ // Resume execution at the desired location (see delegateYield).
389
+ context.next = delegate.nextLoc;
390
+
391
+ // If context.method was "throw" but the delegate handled the
392
+ // exception, let the outer generator proceed normally. If
393
+ // context.method was "next", forget context.arg since it has been
394
+ // "consumed" by the delegate iterator. If context.method was
395
+ // "return", allow the original .return call to continue in the
396
+ // outer generator.
397
+ if (context.method !== "return") {
398
+ context.method = "next";
399
+ context.arg = undefined$1;
400
+ }
401
+ } else {
402
+ // Re-yield the result returned by the delegate method.
403
+ return info;
404
+ }
405
+
406
+ // The delegate iterator is finished, so forget it and continue with
407
+ // the outer generator.
408
+ context.delegate = null;
409
+ return ContinueSentinel;
410
+ }
411
+
412
+ // Define Generator.prototype.{next,throw,return} in terms of the
413
+ // unified ._invoke helper method.
414
+ defineIteratorMethods(Gp);
415
+ define(Gp, toStringTagSymbol, "Generator");
416
+
417
+ // A Generator should always return itself as the iterator object when the
418
+ // @@iterator function is called on it. Some browsers' implementations of the
419
+ // iterator prototype chain incorrectly implement this, causing the Generator
420
+ // object to not be returned from this call. This ensures that doesn't happen.
421
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
422
+ define(Gp, iteratorSymbol, function () {
423
+ return this;
424
+ });
425
+ define(Gp, "toString", function () {
426
+ return "[object Generator]";
427
+ });
428
+ function pushTryEntry(locs) {
429
+ var entry = {
430
+ tryLoc: locs[0]
431
+ };
432
+ if (1 in locs) {
433
+ entry.catchLoc = locs[1];
434
+ }
435
+ if (2 in locs) {
436
+ entry.finallyLoc = locs[2];
437
+ entry.afterLoc = locs[3];
438
+ }
439
+ this.tryEntries.push(entry);
440
+ }
441
+ function resetTryEntry(entry) {
442
+ var record = entry.completion || {};
443
+ record.type = "normal";
444
+ delete record.arg;
445
+ entry.completion = record;
446
+ }
447
+ function Context(tryLocsList) {
448
+ // The root entry object (effectively a try statement without a catch
449
+ // or a finally block) gives us a place to store values thrown from
450
+ // locations where there is no enclosing try statement.
451
+ this.tryEntries = [{
452
+ tryLoc: "root"
453
+ }];
454
+ tryLocsList.forEach(pushTryEntry, this);
455
+ this.reset(true);
456
+ }
457
+ exports.keys = function (object) {
458
+ var keys = [];
459
+ for (var key in object) {
460
+ keys.push(key);
461
+ }
462
+ keys.reverse();
463
+
464
+ // Rather than returning an object with a next method, we keep
465
+ // things simple and return the next function itself.
466
+ return function next() {
467
+ while (keys.length) {
468
+ var key = keys.pop();
469
+ if (key in object) {
470
+ next.value = key;
471
+ next.done = false;
472
+ return next;
473
+ }
474
+ }
475
+
476
+ // To avoid creating an additional object, we just hang the .value
477
+ // and .done properties off the next function object itself. This
478
+ // also ensures that the minifier will not anonymize the function.
479
+ next.done = true;
480
+ return next;
481
+ };
482
+ };
483
+ function values(iterable) {
484
+ if (iterable) {
485
+ var iteratorMethod = iterable[iteratorSymbol];
486
+ if (iteratorMethod) {
487
+ return iteratorMethod.call(iterable);
488
+ }
489
+ if (typeof iterable.next === "function") {
490
+ return iterable;
491
+ }
492
+ if (!isNaN(iterable.length)) {
493
+ var i = -1,
494
+ next = function next() {
495
+ while (++i < iterable.length) {
496
+ if (hasOwn.call(iterable, i)) {
497
+ next.value = iterable[i];
498
+ next.done = false;
499
+ return next;
500
+ }
501
+ }
502
+ next.value = undefined$1;
503
+ next.done = true;
504
+ return next;
505
+ };
506
+ return next.next = next;
507
+ }
508
+ }
509
+
510
+ // Return an iterator with no values.
511
+ return {
512
+ next: doneResult
513
+ };
514
+ }
515
+ exports.values = values;
516
+ function doneResult() {
517
+ return {
518
+ value: undefined$1,
519
+ done: true
520
+ };
521
+ }
522
+ Context.prototype = {
523
+ constructor: Context,
524
+ reset: function reset(skipTempReset) {
525
+ this.prev = 0;
526
+ this.next = 0;
527
+ // Resetting context._sent for legacy support of Babel's
528
+ // function.sent implementation.
529
+ this.sent = this._sent = undefined$1;
530
+ this.done = false;
531
+ this.delegate = null;
532
+ this.method = "next";
533
+ this.arg = undefined$1;
534
+ this.tryEntries.forEach(resetTryEntry);
535
+ if (!skipTempReset) {
536
+ for (var name in this) {
537
+ // Not sure about the optimal order of these conditions:
538
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
539
+ this[name] = undefined$1;
540
+ }
541
+ }
542
+ }
543
+ },
544
+ stop: function stop() {
545
+ this.done = true;
546
+ var rootEntry = this.tryEntries[0];
547
+ var rootRecord = rootEntry.completion;
548
+ if (rootRecord.type === "throw") {
549
+ throw rootRecord.arg;
550
+ }
551
+ return this.rval;
552
+ },
553
+ dispatchException: function dispatchException(exception) {
554
+ if (this.done) {
555
+ throw exception;
556
+ }
557
+ var context = this;
558
+ function handle(loc, caught) {
559
+ record.type = "throw";
560
+ record.arg = exception;
561
+ context.next = loc;
562
+ if (caught) {
563
+ // If the dispatched exception was caught by a catch block,
564
+ // then let that catch block handle the exception normally.
565
+ context.method = "next";
566
+ context.arg = undefined$1;
567
+ }
568
+ return !!caught;
569
+ }
570
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
571
+ var entry = this.tryEntries[i];
572
+ var record = entry.completion;
573
+ if (entry.tryLoc === "root") {
574
+ // Exception thrown outside of any try block that could handle
575
+ // it, so set the completion value of the entire function to
576
+ // throw the exception.
577
+ return handle("end");
578
+ }
579
+ if (entry.tryLoc <= this.prev) {
580
+ var hasCatch = hasOwn.call(entry, "catchLoc");
581
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
582
+ if (hasCatch && hasFinally) {
583
+ if (this.prev < entry.catchLoc) {
584
+ return handle(entry.catchLoc, true);
585
+ } else if (this.prev < entry.finallyLoc) {
586
+ return handle(entry.finallyLoc);
587
+ }
588
+ } else if (hasCatch) {
589
+ if (this.prev < entry.catchLoc) {
590
+ return handle(entry.catchLoc, true);
591
+ }
592
+ } else if (hasFinally) {
593
+ if (this.prev < entry.finallyLoc) {
594
+ return handle(entry.finallyLoc);
595
+ }
596
+ } else {
597
+ throw new Error("try statement without catch or finally");
598
+ }
599
+ }
600
+ }
601
+ },
602
+ abrupt: function abrupt(type, arg) {
603
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
604
+ var entry = this.tryEntries[i];
605
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
606
+ var finallyEntry = entry;
607
+ break;
608
+ }
609
+ }
610
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
611
+ // Ignore the finally entry if control is not jumping to a
612
+ // location outside the try/catch block.
613
+ finallyEntry = null;
614
+ }
615
+ var record = finallyEntry ? finallyEntry.completion : {};
616
+ record.type = type;
617
+ record.arg = arg;
618
+ if (finallyEntry) {
619
+ this.method = "next";
620
+ this.next = finallyEntry.finallyLoc;
621
+ return ContinueSentinel;
622
+ }
623
+ return this.complete(record);
624
+ },
625
+ complete: function complete(record, afterLoc) {
626
+ if (record.type === "throw") {
627
+ throw record.arg;
628
+ }
629
+ if (record.type === "break" || record.type === "continue") {
630
+ this.next = record.arg;
631
+ } else if (record.type === "return") {
632
+ this.rval = this.arg = record.arg;
633
+ this.method = "return";
634
+ this.next = "end";
635
+ } else if (record.type === "normal" && afterLoc) {
636
+ this.next = afterLoc;
637
+ }
638
+ return ContinueSentinel;
639
+ },
640
+ finish: function finish(finallyLoc) {
641
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
642
+ var entry = this.tryEntries[i];
643
+ if (entry.finallyLoc === finallyLoc) {
644
+ this.complete(entry.completion, entry.afterLoc);
645
+ resetTryEntry(entry);
646
+ return ContinueSentinel;
647
+ }
648
+ }
649
+ },
650
+ "catch": function _catch(tryLoc) {
651
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
652
+ var entry = this.tryEntries[i];
653
+ if (entry.tryLoc === tryLoc) {
654
+ var record = entry.completion;
655
+ if (record.type === "throw") {
656
+ var thrown = record.arg;
657
+ resetTryEntry(entry);
658
+ }
659
+ return thrown;
660
+ }
661
+ }
662
+
663
+ // The context.catch method must only be called with a location
664
+ // argument that corresponds to a known catch block.
665
+ throw new Error("illegal catch attempt");
666
+ },
667
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
668
+ this.delegate = {
669
+ iterator: values(iterable),
670
+ resultName: resultName,
671
+ nextLoc: nextLoc
672
+ };
673
+ if (this.method === "next") {
674
+ // Deliberately forget the last sent value so that we don't
675
+ // accidentally pass it on to the delegate.
676
+ this.arg = undefined$1;
677
+ }
678
+ return ContinueSentinel;
679
+ }
680
+ };
681
+
682
+ // Regardless of whether this script is executing as a CommonJS module
683
+ // or not, return the runtime object so that we can declare the variable
684
+ // regeneratorRuntime in the outer scope, which allows this module to be
685
+ // injected easily by `bin/regenerator --include-runtime script.js`.
686
+ return exports;
687
+ }(
688
+ // If this script is executing as a CommonJS module, use module.exports
689
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
690
+ // object. Either way, the resulting object will be used to initialize
691
+ // the regeneratorRuntime variable at the top of this file.
692
+ module.exports );
693
+ try {
694
+ regeneratorRuntime = runtime;
695
+ } catch (accidentalStrictMode) {
696
+ // This module should not be running in strict mode, so the above
697
+ // assignment should always work unless something is misconfigured. Just
698
+ // in case runtime.js accidentally runs in strict mode, in modern engines
699
+ // we can explicitly access globalThis. In older engines we can escape
700
+ // strict mode using a global Function call. This could conceivably fail
701
+ // if a Content Security Policy forbids using Function, but in that case
702
+ // the proper solution is to fix the accidental strict mode problem. If
703
+ // you've misconfigured your bundler to force strict mode and applied a
704
+ // CSP to forbid Function, and you're not willing to fix either of those
705
+ // problems, please detail your unique predicament in a GitHub issue.
706
+ if (typeof globalThis === "object") {
707
+ globalThis.regeneratorRuntime = runtime;
708
+ } else {
709
+ Function("r", "regeneratorRuntime = r")(runtime);
710
+ }
711
+ }
712
+ });
713
+
714
+ var secretRequire;
715
+ try {
716
+ // Secretly use require without webpack knowing
717
+ secretRequire = /*#__PURE__*/eval('require');
718
+ } catch (err) {
719
+ secretRequire = undefined;
720
+ }
721
+ function serverRequire(module) {
722
+ if (!secretRequire) {
723
+ throw new Error("Unexpected serverRequire() -- can only do this from a Node server!");
724
+ }
725
+ return secretRequire(module);
726
+ }
727
+ function serverRequireFs() {
728
+ return serverRequire('fs');
729
+ }
730
+
731
+ var FileCache = /*#__PURE__*/function () {
732
+ function FileCache(filePath) {
733
+ this.filePath = filePath;
734
+ }
735
+ var _proto = FileCache.prototype;
736
+ _proto.get = /*#__PURE__*/function () {
737
+ var _get = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
738
+ var fs, data;
739
+ return runtime_1.wrap(function _callee$(_context) {
740
+ while (1) {
741
+ switch (_context.prev = _context.next) {
742
+ case 0:
743
+ fs = serverRequireFs();
744
+ _context.prev = 1;
745
+ _context.next = 4;
746
+ return fs.promises.mkdir(path.dirname(this.filePath), {
747
+ recursive: true
748
+ });
749
+ case 4:
750
+ _context.next = 6;
751
+ return fs.promises.readFile(this.filePath);
752
+ case 6:
753
+ data = _context.sent.toString();
754
+ return _context.abrupt("return", JSON.parse(data));
755
+ case 10:
756
+ _context.prev = 10;
757
+ _context.t0 = _context["catch"](1);
758
+ return _context.abrupt("return", undefined);
759
+ case 13:
760
+ case "end":
761
+ return _context.stop();
762
+ }
763
+ }
764
+ }, _callee, this, [[1, 10]]);
765
+ }));
766
+ function get() {
767
+ return _get.apply(this, arguments);
768
+ }
769
+ return get;
770
+ }();
771
+ _proto.set = /*#__PURE__*/function () {
772
+ var _set = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(data) {
773
+ var fs;
774
+ return runtime_1.wrap(function _callee2$(_context2) {
775
+ while (1) {
776
+ switch (_context2.prev = _context2.next) {
777
+ case 0:
778
+ fs = serverRequireFs();
779
+ _context2.prev = 1;
780
+ _context2.next = 4;
781
+ return fs.promises.writeFile(this.filePath, JSON.stringify(data));
782
+ case 4:
783
+ _context2.next = 9;
784
+ break;
785
+ case 6:
786
+ _context2.prev = 6;
787
+ _context2.t0 = _context2["catch"](1);
788
+ console.warn("Error writing to Plasmic cache: " + _context2.t0);
789
+ case 9:
790
+ case "end":
791
+ return _context2.stop();
792
+ }
793
+ }
794
+ }, _callee2, this, [[1, 6]]);
795
+ }));
796
+ function set(_x) {
797
+ return _set.apply(this, arguments);
798
+ }
799
+ return set;
800
+ }();
801
+ _proto.clear = function clear() {
802
+ var fs = serverRequireFs();
803
+ try {
804
+ fs.unlinkSync(this.filePath);
805
+ } catch (err) {}
806
+ };
807
+ return FileCache;
808
+ }();
809
+ function makeCache(opts) {
810
+ var cacheDir = path.resolve(process.cwd(), '.next', '.plasmic');
811
+ var cachePath = path.join(cacheDir, "plasmic-" + [].concat(opts.projects.map(function (p) {
812
+ var _p$version;
813
+ return p.id + "@" + ((_p$version = p.version) != null ? _p$version : '');
814
+ })).sort().join('-') + (opts.preview ? '-preview' : '') + "-cache.json");
815
+ return new FileCache(cachePath);
816
+ }
817
+ function initPlasmicLoaderWithCache(initFn, opts) {
818
+ var isBrowser = typeof window !== 'undefined';
819
+ var isProd = "development" === 'production';
820
+ var cache = isBrowser || isProd ? undefined : makeCache(opts);
821
+ var loader = initFn(_extends({
822
+ onClientSideFetch: 'warn'
823
+ }, opts, {
824
+ cache: cache,
825
+ platform: 'nextjs',
826
+ // For Nextjs 12, revalidate may in fact re-use an existing instance
827
+ // of PlasmicComponentLoader that's already in memory, so we need to
828
+ // make sure we don't re-use the data cached in memory.
829
+ // We also enforce this for dev mode, so that we don't have to restart
830
+ // the dev server, in case getStaticProps() re-uses the same PlasmicComponentLoader
831
+ alwaysFresh: !isBrowser
832
+ }));
833
+ {
834
+ var stringOpts = JSON.stringify(opts);
835
+ if (process.env.PLASMIC_OPTS && process.env.PLASMIC_OPTS !== stringOpts) {
836
+ console.warn("PLASMIC: We detected that you created a new PlasmicLoader with different configurations. You may need to restart your dev server.\n");
837
+ }
838
+ process.env.PLASMIC_OPTS = stringOpts;
839
+ }
840
+ if (cache) {
841
+ {
842
+ if (process.env.PLASMIC_WATCHED !== 'true') {
843
+ process.env.PLASMIC_WATCHED = 'true';
844
+ console.log("Subscribing to Plasmic changes...");
845
+ // Import using serverRequire, so webpack doesn't bundle us into client bundle
846
+ try {
847
+ var PlasmicRemoteChangeWatcher = serverRequire('@plasmicapp/watcher').PlasmicRemoteChangeWatcher;
848
+ var watcher = new PlasmicRemoteChangeWatcher({
849
+ projects: opts.projects,
850
+ host: opts.host
851
+ });
852
+ var clearCache = function clearCache() {
853
+ cache.clear();
854
+ loader.clearCache();
855
+ };
856
+ watcher.subscribe({
857
+ onUpdate: function onUpdate() {
858
+ if (opts.preview) {
859
+ clearCache();
860
+ }
861
+ },
862
+ onPublish: function onPublish() {
863
+ if (!opts.preview) {
864
+ clearCache();
865
+ }
866
+ }
867
+ });
868
+ } catch (e) {
869
+ console.warn("Couldn't subscribe to Plasmic changes", e);
870
+ }
871
+ }
872
+ }
873
+ }
874
+ return loader;
875
+ }
876
+
877
+ function initPlasmicLoader(opts) {
878
+ return initPlasmicLoaderWithCache(reactServer.initPlasmicLoader, opts);
879
+ }
880
+
881
+ exports.initPlasmicLoader = initPlasmicLoader;
882
+ //# sourceMappingURL=loader-nextjs.cjs.development.js.map