@plasmicapp/loader-react 1.0.253 → 1.0.255

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.
Files changed (50) hide show
  1. package/dist/PlasmicComponent.d.ts +19 -19
  2. package/dist/PlasmicRootProvider.d.ts +92 -92
  3. package/dist/bundles.d.ts +7 -7
  4. package/dist/component-lookup.d.ts +21 -21
  5. package/dist/global-variants.d.ts +13 -13
  6. package/dist/index.d.ts +15 -12
  7. package/dist/index.js +1464 -5
  8. package/dist/index.js.map +7 -0
  9. package/dist/loader-react-server.d.ts +72 -72
  10. package/dist/loader.d.ts +173 -173
  11. package/dist/prepass.d.ts +43 -43
  12. package/dist/react-server.d.ts +5 -0
  13. package/dist/react-server.js +473 -0
  14. package/dist/react-server.js.map +7 -0
  15. package/dist/render.d.ts +27 -27
  16. package/dist/shared-exports.d.ts +6 -0
  17. package/dist/usePlasmicComponent.d.ts +15 -15
  18. package/dist/utils.d.ts +30 -30
  19. package/dist/variation.d.ts +9 -9
  20. package/package.json +22 -54
  21. package/dist/index-react-server.d.ts +0 -5
  22. package/dist/index-shared.d.ts +0 -6
  23. package/dist/loader-react.cjs.development.js +0 -2748
  24. package/dist/loader-react.cjs.development.js.map +0 -1
  25. package/dist/loader-react.cjs.production.min.js +0 -2
  26. package/dist/loader-react.cjs.production.min.js.map +0 -1
  27. package/dist/loader-react.esm.js +0 -2666
  28. package/dist/loader-react.esm.js.map +0 -1
  29. package/dist-react-server/PlasmicComponent.d.ts +0 -19
  30. package/dist-react-server/PlasmicRootProvider.d.ts +0 -92
  31. package/dist-react-server/bundles.d.ts +0 -7
  32. package/dist-react-server/component-lookup.d.ts +0 -21
  33. package/dist-react-server/global-variants.d.ts +0 -13
  34. package/dist-react-server/index-react-server.d.ts +0 -5
  35. package/dist-react-server/index-shared.d.ts +0 -6
  36. package/dist-react-server/index.d.ts +0 -12
  37. package/dist-react-server/index.js +0 -8
  38. package/dist-react-server/loader-react-server.d.ts +0 -72
  39. package/dist-react-server/loader-react.cjs.development.js +0 -1315
  40. package/dist-react-server/loader-react.cjs.development.js.map +0 -1
  41. package/dist-react-server/loader-react.cjs.production.min.js +0 -2
  42. package/dist-react-server/loader-react.cjs.production.min.js.map +0 -1
  43. package/dist-react-server/loader-react.esm.js +0 -1306
  44. package/dist-react-server/loader-react.esm.js.map +0 -1
  45. package/dist-react-server/loader.d.ts +0 -173
  46. package/dist-react-server/prepass.d.ts +0 -43
  47. package/dist-react-server/render.d.ts +0 -27
  48. package/dist-react-server/usePlasmicComponent.d.ts +0 -15
  49. package/dist-react-server/utils.d.ts +0 -30
  50. package/dist-react-server/variation.d.ts +0 -9
@@ -1,1315 +0,0 @@
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 loaderCore = require('@plasmicapp/loader-core');
9
- var pascalcase = _interopDefault(require('pascalcase'));
10
- require('react');
11
-
12
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
- try {
14
- var info = gen[key](arg);
15
- var value = info.value;
16
- } catch (error) {
17
- reject(error);
18
- return;
19
- }
20
- if (info.done) {
21
- resolve(value);
22
- } else {
23
- Promise.resolve(value).then(_next, _throw);
24
- }
25
- }
26
- function _asyncToGenerator(fn) {
27
- return function () {
28
- var self = this,
29
- args = arguments;
30
- return new Promise(function (resolve, reject) {
31
- var gen = fn.apply(self, args);
32
- function _next(value) {
33
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
34
- }
35
- function _throw(err) {
36
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
37
- }
38
- _next(undefined);
39
- });
40
- };
41
- }
42
- function _extends() {
43
- _extends = Object.assign ? Object.assign.bind() : function (target) {
44
- for (var i = 1; i < arguments.length; i++) {
45
- var source = arguments[i];
46
- for (var key in source) {
47
- if (Object.prototype.hasOwnProperty.call(source, key)) {
48
- target[key] = source[key];
49
- }
50
- }
51
- }
52
- return target;
53
- };
54
- return _extends.apply(this, arguments);
55
- }
56
-
57
- function createCommonjsModule(fn, module) {
58
- return module = { exports: {} }, fn(module, module.exports), module.exports;
59
- }
60
-
61
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
62
- /**
63
- * Copyright (c) 2014-present, Facebook, Inc.
64
- *
65
- * This source code is licensed under the MIT license found in the
66
- * LICENSE file in the root directory of this source tree.
67
- */
68
-
69
- var runtime = function (exports) {
70
-
71
- var Op = Object.prototype;
72
- var hasOwn = Op.hasOwnProperty;
73
- var undefined$1; // More compressible than void 0.
74
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
75
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
76
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
77
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
78
- function define(obj, key, value) {
79
- Object.defineProperty(obj, key, {
80
- value: value,
81
- enumerable: true,
82
- configurable: true,
83
- writable: true
84
- });
85
- return obj[key];
86
- }
87
- try {
88
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
89
- define({}, "");
90
- } catch (err) {
91
- define = function define(obj, key, value) {
92
- return obj[key] = value;
93
- };
94
- }
95
- function wrap(innerFn, outerFn, self, tryLocsList) {
96
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
97
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
98
- var generator = Object.create(protoGenerator.prototype);
99
- var context = new Context(tryLocsList || []);
100
-
101
- // The ._invoke method unifies the implementations of the .next,
102
- // .throw, and .return methods.
103
- generator._invoke = makeInvokeMethod(innerFn, self, context);
104
- return generator;
105
- }
106
- exports.wrap = wrap;
107
-
108
- // Try/catch helper to minimize deoptimizations. Returns a completion
109
- // record like context.tryEntries[i].completion. This interface could
110
- // have been (and was previously) designed to take a closure to be
111
- // invoked without arguments, but in all the cases we care about we
112
- // already have an existing method we want to call, so there's no need
113
- // to create a new function object. We can even get away with assuming
114
- // the method takes exactly one argument, since that happens to be true
115
- // in every case, so we don't have to touch the arguments object. The
116
- // only additional allocation required is the completion record, which
117
- // has a stable shape and so hopefully should be cheap to allocate.
118
- function tryCatch(fn, obj, arg) {
119
- try {
120
- return {
121
- type: "normal",
122
- arg: fn.call(obj, arg)
123
- };
124
- } catch (err) {
125
- return {
126
- type: "throw",
127
- arg: err
128
- };
129
- }
130
- }
131
- var GenStateSuspendedStart = "suspendedStart";
132
- var GenStateSuspendedYield = "suspendedYield";
133
- var GenStateExecuting = "executing";
134
- var GenStateCompleted = "completed";
135
-
136
- // Returning this object from the innerFn has the same effect as
137
- // breaking out of the dispatch switch statement.
138
- var ContinueSentinel = {};
139
-
140
- // Dummy constructor functions that we use as the .constructor and
141
- // .constructor.prototype properties for functions that return Generator
142
- // objects. For full spec compliance, you may wish to configure your
143
- // minifier not to mangle the names of these two functions.
144
- function Generator() {}
145
- function GeneratorFunction() {}
146
- function GeneratorFunctionPrototype() {}
147
-
148
- // This is a polyfill for %IteratorPrototype% for environments that
149
- // don't natively support it.
150
- var IteratorPrototype = {};
151
- define(IteratorPrototype, iteratorSymbol, function () {
152
- return this;
153
- });
154
- var getProto = Object.getPrototypeOf;
155
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
156
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
157
- // This environment has a native %IteratorPrototype%; use it instead
158
- // of the polyfill.
159
- IteratorPrototype = NativeIteratorPrototype;
160
- }
161
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
162
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
163
- define(Gp, "constructor", GeneratorFunctionPrototype);
164
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
165
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
166
-
167
- // Helper for defining the .next, .throw, and .return methods of the
168
- // Iterator interface in terms of a single ._invoke method.
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
- exports.isGeneratorFunction = function (genFun) {
177
- var ctor = typeof genFun === "function" && genFun.constructor;
178
- return ctor ? ctor === GeneratorFunction ||
179
- // 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
- exports.mark = function (genFun) {
184
- if (Object.setPrototypeOf) {
185
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
186
- } else {
187
- genFun.__proto__ = GeneratorFunctionPrototype;
188
- define(genFun, toStringTagSymbol, "GeneratorFunction");
189
- }
190
- genFun.prototype = Object.create(Gp);
191
- return genFun;
192
- };
193
-
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
- exports.awrap = function (arg) {
199
- return {
200
- __await: arg
201
- };
202
- };
203
- function AsyncIterator(generator, PromiseImpl) {
204
- function invoke(method, arg, resolve, reject) {
205
- var record = tryCatch(generator[method], generator, arg);
206
- if (record.type === "throw") {
207
- reject(record.arg);
208
- } else {
209
- var result = record.arg;
210
- var value = result.value;
211
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
212
- return PromiseImpl.resolve(value.__await).then(function (value) {
213
- invoke("next", value, resolve, reject);
214
- }, function (err) {
215
- invoke("throw", err, resolve, reject);
216
- });
217
- }
218
- return PromiseImpl.resolve(value).then(function (unwrapped) {
219
- // When a yielded Promise is resolved, its final value becomes
220
- // the .value of the Promise<{value,done}> result for the
221
- // current iteration.
222
- result.value = unwrapped;
223
- resolve(result);
224
- }, function (error) {
225
- // If a rejected Promise was yielded, throw the rejection back
226
- // into the async generator function so it can be handled there.
227
- return invoke("throw", error, resolve, reject);
228
- });
229
- }
230
- }
231
- var previousPromise;
232
- function enqueue(method, arg) {
233
- function callInvokeWithMethodAndArg() {
234
- return new PromiseImpl(function (resolve, reject) {
235
- invoke(method, arg, resolve, reject);
236
- });
237
- }
238
- return previousPromise =
239
- // If enqueue has been called before, then we want to wait until
240
- // all previous Promises have been resolved before calling invoke,
241
- // so that results are always delivered in the correct order. If
242
- // enqueue has not been called before, then it is important to
243
- // call invoke immediately, without waiting on a callback to fire,
244
- // so that the async generator function has the opportunity to do
245
- // any necessary setup in a predictable way. This predictability
246
- // is why the Promise constructor synchronously invokes its
247
- // executor callback, and why async functions synchronously
248
- // execute code before the first await. Since we implement simple
249
- // async functions in terms of async generators, it is especially
250
- // important to get this right, even though it requires care.
251
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
252
- // Avoid propagating failures to Promises returned by later
253
- // invocations of the iterator.
254
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
255
- }
256
-
257
- // Define the unified helper method that is used to implement .next,
258
- // .throw, and .return (see defineIteratorMethods).
259
- this._invoke = enqueue;
260
- }
261
- defineIteratorMethods(AsyncIterator.prototype);
262
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
263
- return this;
264
- });
265
- exports.AsyncIterator = AsyncIterator;
266
-
267
- // Note that simple async functions are implemented on top of
268
- // AsyncIterator objects; they just return a Promise for the value of
269
- // the final result produced by the iterator.
270
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
271
- if (PromiseImpl === void 0) PromiseImpl = Promise;
272
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
273
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
274
- : iter.next().then(function (result) {
275
- return result.done ? result.value : iter.next();
276
- });
277
- };
278
- function makeInvokeMethod(innerFn, self, context) {
279
- var state = GenStateSuspendedStart;
280
- return function invoke(method, arg) {
281
- if (state === GenStateExecuting) {
282
- throw new Error("Generator is already running");
283
- }
284
- if (state === GenStateCompleted) {
285
- if (method === "throw") {
286
- throw arg;
287
- }
288
-
289
- // Be forgiving, per 25.3.3.3.3 of the spec:
290
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
291
- return doneResult();
292
- }
293
- context.method = method;
294
- context.arg = arg;
295
- while (true) {
296
- var delegate = context.delegate;
297
- if (delegate) {
298
- var delegateResult = maybeInvokeDelegate(delegate, context);
299
- if (delegateResult) {
300
- if (delegateResult === ContinueSentinel) continue;
301
- return delegateResult;
302
- }
303
- }
304
- if (context.method === "next") {
305
- // Setting context._sent for legacy support of Babel's
306
- // function.sent implementation.
307
- context.sent = context._sent = context.arg;
308
- } else if (context.method === "throw") {
309
- if (state === GenStateSuspendedStart) {
310
- state = GenStateCompleted;
311
- throw context.arg;
312
- }
313
- context.dispatchException(context.arg);
314
- } else if (context.method === "return") {
315
- context.abrupt("return", context.arg);
316
- }
317
- state = GenStateExecuting;
318
- var record = tryCatch(innerFn, self, context);
319
- if (record.type === "normal") {
320
- // If an exception is thrown from innerFn, we leave state ===
321
- // GenStateExecuting and loop back for another invocation.
322
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
323
- if (record.arg === ContinueSentinel) {
324
- continue;
325
- }
326
- return {
327
- value: record.arg,
328
- done: context.done
329
- };
330
- } else if (record.type === "throw") {
331
- state = GenStateCompleted;
332
- // Dispatch the exception by looping back around to the
333
- // context.dispatchException(context.arg) call above.
334
- context.method = "throw";
335
- context.arg = record.arg;
336
- }
337
- }
338
- };
339
- }
340
-
341
- // Call delegate.iterator[context.method](context.arg) and handle the
342
- // result, either by returning a { value, done } result from the
343
- // delegate iterator, or by modifying context.method and context.arg,
344
- // setting context.delegate to null, and returning the ContinueSentinel.
345
- function maybeInvokeDelegate(delegate, context) {
346
- var method = delegate.iterator[context.method];
347
- if (method === undefined$1) {
348
- // A .throw or .return when the delegate iterator has no .throw
349
- // method always terminates the yield* loop.
350
- context.delegate = null;
351
- if (context.method === "throw") {
352
- // Note: ["return"] must be used for ES3 parsing compatibility.
353
- if (delegate.iterator["return"]) {
354
- // If the delegate iterator has a return method, give it a
355
- // chance to clean up.
356
- context.method = "return";
357
- context.arg = undefined$1;
358
- maybeInvokeDelegate(delegate, context);
359
- if (context.method === "throw") {
360
- // If maybeInvokeDelegate(context) changed context.method from
361
- // "return" to "throw", let that override the TypeError below.
362
- return ContinueSentinel;
363
- }
364
- }
365
- context.method = "throw";
366
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
367
- }
368
- return ContinueSentinel;
369
- }
370
- var record = tryCatch(method, delegate.iterator, context.arg);
371
- if (record.type === "throw") {
372
- context.method = "throw";
373
- context.arg = record.arg;
374
- context.delegate = null;
375
- return ContinueSentinel;
376
- }
377
- var info = record.arg;
378
- if (!info) {
379
- context.method = "throw";
380
- context.arg = new TypeError("iterator result is not an object");
381
- context.delegate = null;
382
- return ContinueSentinel;
383
- }
384
- if (info.done) {
385
- // Assign the result of the finished delegate to the temporary
386
- // variable specified by delegate.resultName (see delegateYield).
387
- context[delegate.resultName] = info.value;
388
-
389
- // Resume execution at the desired location (see delegateYield).
390
- context.next = delegate.nextLoc;
391
-
392
- // If context.method was "throw" but the delegate handled the
393
- // exception, let the outer generator proceed normally. If
394
- // context.method was "next", forget context.arg since it has been
395
- // "consumed" by the delegate iterator. If context.method was
396
- // "return", allow the original .return call to continue in the
397
- // outer generator.
398
- if (context.method !== "return") {
399
- context.method = "next";
400
- context.arg = undefined$1;
401
- }
402
- } else {
403
- // Re-yield the result returned by the delegate method.
404
- return info;
405
- }
406
-
407
- // The delegate iterator is finished, so forget it and continue with
408
- // the outer generator.
409
- context.delegate = null;
410
- return ContinueSentinel;
411
- }
412
-
413
- // Define Generator.prototype.{next,throw,return} in terms of the
414
- // unified ._invoke helper method.
415
- defineIteratorMethods(Gp);
416
- define(Gp, toStringTagSymbol, "Generator");
417
-
418
- // A Generator should always return itself as the iterator object when the
419
- // @@iterator function is called on it. Some browsers' implementations of the
420
- // iterator prototype chain incorrectly implement this, causing the Generator
421
- // object to not be returned from this call. This ensures that doesn't happen.
422
- // See https://github.com/facebook/regenerator/issues/274 for more details.
423
- define(Gp, iteratorSymbol, function () {
424
- return this;
425
- });
426
- define(Gp, "toString", function () {
427
- return "[object Generator]";
428
- });
429
- function pushTryEntry(locs) {
430
- var entry = {
431
- tryLoc: locs[0]
432
- };
433
- if (1 in locs) {
434
- entry.catchLoc = locs[1];
435
- }
436
- if (2 in locs) {
437
- entry.finallyLoc = locs[2];
438
- entry.afterLoc = locs[3];
439
- }
440
- this.tryEntries.push(entry);
441
- }
442
- function resetTryEntry(entry) {
443
- var record = entry.completion || {};
444
- record.type = "normal";
445
- delete record.arg;
446
- entry.completion = record;
447
- }
448
- function Context(tryLocsList) {
449
- // The root entry object (effectively a try statement without a catch
450
- // or a finally block) gives us a place to store values thrown from
451
- // locations where there is no enclosing try statement.
452
- this.tryEntries = [{
453
- tryLoc: "root"
454
- }];
455
- tryLocsList.forEach(pushTryEntry, this);
456
- this.reset(true);
457
- }
458
- exports.keys = function (object) {
459
- var keys = [];
460
- for (var key in object) {
461
- keys.push(key);
462
- }
463
- keys.reverse();
464
-
465
- // Rather than returning an object with a next method, we keep
466
- // things simple and return the next function itself.
467
- return function next() {
468
- while (keys.length) {
469
- var key = keys.pop();
470
- if (key in object) {
471
- next.value = key;
472
- next.done = false;
473
- return next;
474
- }
475
- }
476
-
477
- // To avoid creating an additional object, we just hang the .value
478
- // and .done properties off the next function object itself. This
479
- // also ensures that the minifier will not anonymize the function.
480
- next.done = true;
481
- return next;
482
- };
483
- };
484
- function values(iterable) {
485
- if (iterable) {
486
- var iteratorMethod = iterable[iteratorSymbol];
487
- if (iteratorMethod) {
488
- return iteratorMethod.call(iterable);
489
- }
490
- if (typeof iterable.next === "function") {
491
- return iterable;
492
- }
493
- if (!isNaN(iterable.length)) {
494
- var i = -1,
495
- next = function next() {
496
- while (++i < iterable.length) {
497
- if (hasOwn.call(iterable, i)) {
498
- next.value = iterable[i];
499
- next.done = false;
500
- return next;
501
- }
502
- }
503
- next.value = undefined$1;
504
- next.done = true;
505
- return next;
506
- };
507
- return next.next = next;
508
- }
509
- }
510
-
511
- // Return an iterator with no values.
512
- return {
513
- next: doneResult
514
- };
515
- }
516
- exports.values = values;
517
- function doneResult() {
518
- return {
519
- value: undefined$1,
520
- done: true
521
- };
522
- }
523
- Context.prototype = {
524
- constructor: Context,
525
- reset: function reset(skipTempReset) {
526
- this.prev = 0;
527
- this.next = 0;
528
- // Resetting context._sent for legacy support of Babel's
529
- // function.sent implementation.
530
- this.sent = this._sent = undefined$1;
531
- this.done = false;
532
- this.delegate = null;
533
- this.method = "next";
534
- this.arg = undefined$1;
535
- this.tryEntries.forEach(resetTryEntry);
536
- if (!skipTempReset) {
537
- for (var name in this) {
538
- // Not sure about the optimal order of these conditions:
539
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
540
- this[name] = undefined$1;
541
- }
542
- }
543
- }
544
- },
545
- stop: function stop() {
546
- this.done = true;
547
- var rootEntry = this.tryEntries[0];
548
- var rootRecord = rootEntry.completion;
549
- if (rootRecord.type === "throw") {
550
- throw rootRecord.arg;
551
- }
552
- return this.rval;
553
- },
554
- dispatchException: function dispatchException(exception) {
555
- if (this.done) {
556
- throw exception;
557
- }
558
- var context = this;
559
- function handle(loc, caught) {
560
- record.type = "throw";
561
- record.arg = exception;
562
- context.next = loc;
563
- if (caught) {
564
- // If the dispatched exception was caught by a catch block,
565
- // then let that catch block handle the exception normally.
566
- context.method = "next";
567
- context.arg = undefined$1;
568
- }
569
- return !!caught;
570
- }
571
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
572
- var entry = this.tryEntries[i];
573
- var record = entry.completion;
574
- if (entry.tryLoc === "root") {
575
- // Exception thrown outside of any try block that could handle
576
- // it, so set the completion value of the entire function to
577
- // throw the exception.
578
- return handle("end");
579
- }
580
- if (entry.tryLoc <= this.prev) {
581
- var hasCatch = hasOwn.call(entry, "catchLoc");
582
- var hasFinally = hasOwn.call(entry, "finallyLoc");
583
- if (hasCatch && hasFinally) {
584
- if (this.prev < entry.catchLoc) {
585
- return handle(entry.catchLoc, true);
586
- } else if (this.prev < entry.finallyLoc) {
587
- return handle(entry.finallyLoc);
588
- }
589
- } else if (hasCatch) {
590
- if (this.prev < entry.catchLoc) {
591
- return handle(entry.catchLoc, true);
592
- }
593
- } else if (hasFinally) {
594
- if (this.prev < entry.finallyLoc) {
595
- return handle(entry.finallyLoc);
596
- }
597
- } else {
598
- throw new Error("try statement without catch or finally");
599
- }
600
- }
601
- }
602
- },
603
- abrupt: function abrupt(type, arg) {
604
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
605
- var entry = this.tryEntries[i];
606
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
607
- var finallyEntry = entry;
608
- break;
609
- }
610
- }
611
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
612
- // Ignore the finally entry if control is not jumping to a
613
- // location outside the try/catch block.
614
- finallyEntry = null;
615
- }
616
- var record = finallyEntry ? finallyEntry.completion : {};
617
- record.type = type;
618
- record.arg = arg;
619
- if (finallyEntry) {
620
- this.method = "next";
621
- this.next = finallyEntry.finallyLoc;
622
- return ContinueSentinel;
623
- }
624
- return this.complete(record);
625
- },
626
- complete: function complete(record, afterLoc) {
627
- if (record.type === "throw") {
628
- throw record.arg;
629
- }
630
- if (record.type === "break" || record.type === "continue") {
631
- this.next = record.arg;
632
- } else if (record.type === "return") {
633
- this.rval = this.arg = record.arg;
634
- this.method = "return";
635
- this.next = "end";
636
- } else if (record.type === "normal" && afterLoc) {
637
- this.next = afterLoc;
638
- }
639
- return ContinueSentinel;
640
- },
641
- finish: function finish(finallyLoc) {
642
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
643
- var entry = this.tryEntries[i];
644
- if (entry.finallyLoc === finallyLoc) {
645
- this.complete(entry.completion, entry.afterLoc);
646
- resetTryEntry(entry);
647
- return ContinueSentinel;
648
- }
649
- }
650
- },
651
- "catch": function _catch(tryLoc) {
652
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
653
- var entry = this.tryEntries[i];
654
- if (entry.tryLoc === tryLoc) {
655
- var record = entry.completion;
656
- if (record.type === "throw") {
657
- var thrown = record.arg;
658
- resetTryEntry(entry);
659
- }
660
- return thrown;
661
- }
662
- }
663
-
664
- // The context.catch method must only be called with a location
665
- // argument that corresponds to a known catch block.
666
- throw new Error("illegal catch attempt");
667
- },
668
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
669
- this.delegate = {
670
- iterator: values(iterable),
671
- resultName: resultName,
672
- nextLoc: nextLoc
673
- };
674
- if (this.method === "next") {
675
- // Deliberately forget the last sent value so that we don't
676
- // accidentally pass it on to the delegate.
677
- this.arg = undefined$1;
678
- }
679
- return ContinueSentinel;
680
- }
681
- };
682
-
683
- // Regardless of whether this script is executing as a CommonJS module
684
- // or not, return the runtime object so that we can declare the variable
685
- // regeneratorRuntime in the outer scope, which allows this module to be
686
- // injected easily by `bin/regenerator --include-runtime script.js`.
687
- return exports;
688
- }(
689
- // If this script is executing as a CommonJS module, use module.exports
690
- // as the regeneratorRuntime namespace. Otherwise create a new empty
691
- // object. Either way, the resulting object will be used to initialize
692
- // the regeneratorRuntime variable at the top of this file.
693
- module.exports );
694
- try {
695
- regeneratorRuntime = runtime;
696
- } catch (accidentalStrictMode) {
697
- // This module should not be running in strict mode, so the above
698
- // assignment should always work unless something is misconfigured. Just
699
- // in case runtime.js accidentally runs in strict mode, in modern engines
700
- // we can explicitly access globalThis. In older engines we can escape
701
- // strict mode using a global Function call. This could conceivably fail
702
- // if a Content Security Policy forbids using Function, but in that case
703
- // the proper solution is to fix the accidental strict mode problem. If
704
- // you've misconfigured your bundler to force strict mode and applied a
705
- // CSP to forbid Function, and you're not willing to fix either of those
706
- // problems, please detail your unique predicament in a GitHub issue.
707
- if (typeof globalThis === "object") {
708
- globalThis.regeneratorRuntime = runtime;
709
- } else {
710
- Function("r", "regeneratorRuntime = r")(runtime);
711
- }
712
- }
713
- });
714
-
715
- function getUsedComps(allComponents, entryCompIds) {
716
- var q = [].concat(entryCompIds);
717
- var seenIds = new Set(entryCompIds);
718
- var componentMetaById = new Map(allComponents.map(function (meta) {
719
- return [meta.id, meta];
720
- }));
721
- var usedComps = [];
722
- while (q.length > 0) {
723
- var _q$splice = q.splice(0, 1),
724
- id = _q$splice[0];
725
- var meta = componentMetaById.get(id);
726
- if (!meta) {
727
- continue;
728
- }
729
- usedComps.push(meta);
730
- meta.usedComponents.forEach(function (usedCompId) {
731
- if (!seenIds.has(usedCompId)) {
732
- seenIds.add(usedCompId);
733
- q.push(usedCompId);
734
- }
735
- });
736
- }
737
- return usedComps;
738
- }
739
- function prepComponentData(bundle, compMetas, opts) {
740
- if (compMetas.length === 0) {
741
- return {
742
- entryCompMetas: bundle.components,
743
- bundle: bundle,
744
- remoteFontUrls: []
745
- };
746
- }
747
- var usedComps = getUsedComps(bundle.components, compMetas.map(function (compMeta) {
748
- return compMeta.id;
749
- }));
750
- var compPaths = usedComps.map(function (compMeta) {
751
- return compMeta.entry;
752
- });
753
- var subBundle = loaderCore.getBundleSubset(bundle, ['entrypoint.css'].concat(compPaths, ['root-provider.js'], bundle.projects.map(function (x) {
754
- return x.globalContextsProviderFileName;
755
- }).filter(function (x) {
756
- return !!x;
757
- }), bundle.components.filter(function (c) {
758
- return c.isGlobalContextProvider;
759
- }).map(function (c) {
760
- return c.entry;
761
- }), bundle.globalGroups.map(function (g) {
762
- return g.contextFile;
763
- })), opts);
764
- var remoteFontUrls = [];
765
- subBundle.projects.forEach(function (p) {
766
- return remoteFontUrls.push.apply(remoteFontUrls, p.remoteFonts.map(function (f) {
767
- return f.url;
768
- }));
769
- });
770
- return {
771
- entryCompMetas: compMetas,
772
- bundle: subBundle,
773
- remoteFontUrls: remoteFontUrls
774
- };
775
- }
776
- function mergeBundles(target, from) {
777
- var _from$activeSplits$fi;
778
- var existingCompIds = new Set(target.components.map(function (c) {
779
- return c.id;
780
- }));
781
- var newCompMetas = from.components.filter(function (m) {
782
- return !existingCompIds.has(m.id);
783
- });
784
- if (newCompMetas.length > 0) {
785
- target = _extends({}, target, {
786
- components: [].concat(target.components, newCompMetas)
787
- });
788
- }
789
- var existingProjects = new Set(target.projects.map(function (p) {
790
- return p.id;
791
- }));
792
- var newProjects = from.projects.filter(function (p) {
793
- return !existingProjects.has(p.id);
794
- });
795
- if (newProjects.length > 0) {
796
- target = _extends({}, target, {
797
- projects: [].concat(target.projects, newProjects)
798
- });
799
- }
800
- var existingModules = {
801
- browser: new Set(target.modules.browser.map(function (m) {
802
- return m.fileName;
803
- })),
804
- server: new Set(target.modules.server.map(function (m) {
805
- return m.fileName;
806
- }))
807
- };
808
- var newModules = {
809
- browser: from.modules.browser.filter(function (m) {
810
- return !existingModules.browser.has(m.fileName);
811
- }),
812
- server: from.modules.server.filter(function (m) {
813
- return !existingModules.server.has(m.fileName);
814
- })
815
- };
816
- if (newModules.browser.length > 0 || newModules.server.length > 0) {
817
- target = _extends({}, target, {
818
- modules: {
819
- browser: [].concat(target.modules.browser, newModules.browser),
820
- server: [].concat(target.modules.server, newModules.server)
821
- }
822
- });
823
- }
824
- var existingGlobalIds = new Set(target.globalGroups.map(function (g) {
825
- return g.id;
826
- }));
827
- var newGlobals = from.globalGroups.filter(function (g) {
828
- return !existingGlobalIds.has(g.id);
829
- });
830
- if (newGlobals.length > 0) {
831
- target = _extends({}, target, {
832
- globalGroups: [].concat(target.globalGroups, newGlobals)
833
- });
834
- }
835
- var existingExternals = new Set(target.external);
836
- var newExternals = target.external.filter(function (x) {
837
- return !existingExternals.has(x);
838
- });
839
- if (newExternals.length > 0) {
840
- target = _extends({}, target, {
841
- external: [].concat(target.external, newExternals)
842
- });
843
- }
844
- var existingSplitIds = new Set(target.activeSplits.map(function (s) {
845
- return s.id;
846
- }));
847
- var newSplits = (_from$activeSplits$fi = from.activeSplits.filter(function (s) {
848
- return !existingSplitIds.has(s.id);
849
- })) != null ? _from$activeSplits$fi : [];
850
- if (newSplits.length > 0) {
851
- target = _extends({}, target, {
852
- activeSplits: [].concat(target.activeSplits, newSplits)
853
- });
854
- }
855
- return target;
856
- }
857
- var convertBundlesToComponentRenderData = function convertBundlesToComponentRenderData(bundles, compMetas) {
858
- if (bundles.length === 0) {
859
- return null;
860
- }
861
- var mergedBundles = bundles.reduce(function (prev, cur) {
862
- return mergeBundles(prev, cur);
863
- });
864
- return prepComponentData(mergedBundles, compMetas);
865
- };
866
-
867
- var isBrowser = typeof window !== 'undefined';
868
- function isNameSpec(lookup) {
869
- return 'name' in lookup;
870
- }
871
- function toFullLookup(lookup) {
872
- var namePart = typeof lookup === 'string' ? lookup : lookup.name;
873
- var projectId = typeof lookup === 'string' ? undefined : lookup.projectId;
874
- var codeComponent = typeof lookup === 'string' ? undefined : lookup.isCode;
875
- if (codeComponent !== true && namePart.startsWith('/')) {
876
- return {
877
- path: normalizePath(namePart),
878
- projectId: projectId
879
- };
880
- } else {
881
- return {
882
- name: codeComponent ? namePart : normalizeName(namePart),
883
- rawName: namePart.trim(),
884
- projectId: projectId,
885
- isCode: codeComponent
886
- };
887
- }
888
- }
889
- function normalizePath(path) {
890
- return path.trim();
891
- }
892
- function normalizeName(name) {
893
- // Not a full normalization, but should be good enough
894
- return pascalcase(name).trim();
895
- }
896
- /**
897
- * Check if `lookup` resolves to `pagePath`. If it's a match, return an object
898
- * containing path params; otherwise, returns false.
899
- *
900
- * For example,
901
- * - `matchesPagePath("/hello/[name]", "/hello/world")` -> `{params: {name:
902
- * "world"}}`
903
- * - `matchesPagePath("/hello/[name]", "/")` -> `false`
904
- * - `matchesPagePath("/", "")` -> `{params: {}}`
905
- */
906
- function matchesPagePath(pagePath, lookup) {
907
- var _lookup$match;
908
- // Remove trailing slashes from both `pagePath` and `lookup`.
909
- pagePath = pagePath.replace(/^\/*/, '').replace(/\/*$/, '');
910
- lookup = lookup.replace(/^\/*/, '').replace(/\/*$/, '');
911
- // paramNames will contain a list of parameter names; e.g. if pagePath
912
- // is "/products/[slug]/[variant]" it will contain ["slug", "variant"].
913
- var paramNames = (pagePath.match(/\[([^\]]*)\]/g) || []).map(function (group) {
914
- return group.slice(1, -1);
915
- });
916
- var pagePathRegExp = new RegExp('^' + pagePath.replace(/\[[^\]]*\]/g, '([^/]+)') + '$');
917
- var maybeVals = (_lookup$match = lookup.match(pagePathRegExp)) == null ? void 0 : _lookup$match.slice(1);
918
- if (!maybeVals) {
919
- return false;
920
- }
921
- var params = {};
922
- for (var i = 0; i < paramNames.length; i++) {
923
- params[paramNames[i]] = maybeVals[i];
924
- }
925
- return {
926
- params: params
927
- };
928
- }
929
- function isDynamicPagePath(path) {
930
- return !!path.match(/\[[^/]*\]/);
931
- }
932
- function matchesCompMeta(lookup, meta) {
933
- if (lookup.projectId && meta.projectId !== lookup.projectId) {
934
- return false;
935
- }
936
- return isNameSpec(lookup) ? (lookup.name === meta.name || lookup.rawName === meta.name || lookup.rawName === meta.displayName) && (lookup.isCode == null || lookup.isCode === meta.isCode) : !!(meta.path && matchesPagePath(meta.path, lookup.path));
937
- }
938
- function getCompMetas(metas, lookup) {
939
- var full = toFullLookup(lookup);
940
- return metas.filter(function (meta) {
941
- return matchesCompMeta(full, meta);
942
- }).map(function (meta) {
943
- if (isNameSpec(full) || !meta.path) {
944
- return meta;
945
- }
946
- var match = matchesPagePath(meta.path, full.path);
947
- if (!match) {
948
- return meta;
949
- }
950
- return _extends({}, meta, {
951
- params: match.params
952
- });
953
- }).sort(function (meta1, meta2) {
954
- return (
955
- // We sort the matched component metas by the number of path params, so
956
- // if there are two pages `/products/foo` and `/products/[slug]`,
957
- // the first one will have higher precedence.
958
- Array.from(Object.keys(meta1.params || {})).length - Array.from(Object.keys(meta2.params || {})).length
959
- );
960
- });
961
- }
962
- function getLookupSpecName(lookup) {
963
- if (typeof lookup === 'string') {
964
- return lookup;
965
- } else if (lookup.projectId) {
966
- return lookup.name + " (project " + lookup.projectId + ")";
967
- } else {
968
- return lookup.name;
969
- }
970
- }
971
-
972
- /** Subset of loader functionality that works on React Server Components. */
973
- var ReactServerPlasmicComponentLoader = /*#__PURE__*/function () {
974
- function ReactServerPlasmicComponentLoader(args) {
975
- this.bundle = {
976
- modules: {
977
- browser: [],
978
- server: []
979
- },
980
- components: [],
981
- globalGroups: [],
982
- external: [],
983
- projects: [],
984
- activeSplits: []
985
- };
986
- this.opts = args.opts;
987
- this.fetcher = args.fetcher;
988
- this.tracker = args.tracker;
989
- this.onBundleMerged = args.onBundleMerged;
990
- this.onBundleFetched = args.onBundleFetched;
991
- }
992
- var _proto = ReactServerPlasmicComponentLoader.prototype;
993
- _proto.maybeGetCompMetas = function maybeGetCompMetas() {
994
- var found = new Set();
995
- var missing = [];
996
- for (var _len = arguments.length, specs = new Array(_len), _key = 0; _key < _len; _key++) {
997
- specs[_key] = arguments[_key];
998
- }
999
- for (var _i = 0, _specs = specs; _i < _specs.length; _i++) {
1000
- var spec = _specs[_i];
1001
- var filteredMetas = getCompMetas(this.bundle.components, spec);
1002
- if (filteredMetas.length > 0) {
1003
- filteredMetas.forEach(function (meta) {
1004
- return found.add(meta);
1005
- });
1006
- } else {
1007
- missing.push(spec);
1008
- }
1009
- }
1010
- return {
1011
- found: Array.from(found.keys()),
1012
- missing: missing
1013
- };
1014
- };
1015
- _proto.maybeFetchComponentData = /*#__PURE__*/function () {
1016
- var _maybeFetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1017
- var _this = this;
1018
- var _parseFetchComponentD,
1019
- specs,
1020
- opts,
1021
- returnWithSpecsToFetch,
1022
- _this$maybeGetCompMet2,
1023
- existingMetas,
1024
- missingSpecs,
1025
- _args2 = arguments;
1026
- return runtime_1.wrap(function _callee2$(_context2) {
1027
- while (1) {
1028
- switch (_context2.prev = _context2.next) {
1029
- case 0:
1030
- _parseFetchComponentD = parseFetchComponentDataArgs.apply(void 0, _args2), specs = _parseFetchComponentD.specs, opts = _parseFetchComponentD.opts;
1031
- returnWithSpecsToFetch = /*#__PURE__*/function () {
1032
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(specsToFetch) {
1033
- var _this$maybeGetCompMet, existingMetas2, missingSpecs2;
1034
- return runtime_1.wrap(function _callee$(_context) {
1035
- while (1) {
1036
- switch (_context.prev = _context.next) {
1037
- case 0:
1038
- _context.next = 2;
1039
- return _this.fetchMissingData({
1040
- missingSpecs: specsToFetch
1041
- });
1042
- case 2:
1043
- _this$maybeGetCompMet = _this.maybeGetCompMetas.apply(_this, specs), existingMetas2 = _this$maybeGetCompMet.found, missingSpecs2 = _this$maybeGetCompMet.missing;
1044
- if (!(missingSpecs2.length > 0)) {
1045
- _context.next = 5;
1046
- break;
1047
- }
1048
- return _context.abrupt("return", null);
1049
- case 5:
1050
- return _context.abrupt("return", prepComponentData(_this.bundle, existingMetas2, opts));
1051
- case 6:
1052
- case "end":
1053
- return _context.stop();
1054
- }
1055
- }
1056
- }, _callee);
1057
- }));
1058
- return function returnWithSpecsToFetch(_x) {
1059
- return _ref.apply(this, arguments);
1060
- };
1061
- }();
1062
- if (!this.opts.alwaysFresh) {
1063
- _context2.next = 6;
1064
- break;
1065
- }
1066
- _context2.next = 5;
1067
- return returnWithSpecsToFetch(specs);
1068
- case 5:
1069
- return _context2.abrupt("return", _context2.sent);
1070
- case 6:
1071
- // Else we only fetch actually missing specs
1072
- _this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this, specs), existingMetas = _this$maybeGetCompMet2.found, missingSpecs = _this$maybeGetCompMet2.missing;
1073
- if (!(missingSpecs.length === 0)) {
1074
- _context2.next = 9;
1075
- break;
1076
- }
1077
- return _context2.abrupt("return", prepComponentData(this.bundle, existingMetas, opts));
1078
- case 9:
1079
- _context2.next = 11;
1080
- return returnWithSpecsToFetch(missingSpecs);
1081
- case 11:
1082
- return _context2.abrupt("return", _context2.sent);
1083
- case 12:
1084
- case "end":
1085
- return _context2.stop();
1086
- }
1087
- }
1088
- }, _callee2, this);
1089
- }));
1090
- function maybeFetchComponentData() {
1091
- return _maybeFetchComponentData.apply(this, arguments);
1092
- }
1093
- return maybeFetchComponentData;
1094
- }();
1095
- _proto.fetchComponentData = /*#__PURE__*/function () {
1096
- var _fetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
1097
- var _parseFetchComponentD2,
1098
- specs,
1099
- opts,
1100
- data,
1101
- _this$maybeGetCompMet3,
1102
- missingSpecs,
1103
- _args3 = arguments;
1104
- return runtime_1.wrap(function _callee3$(_context3) {
1105
- while (1) {
1106
- switch (_context3.prev = _context3.next) {
1107
- case 0:
1108
- _parseFetchComponentD2 = parseFetchComponentDataArgs.apply(void 0, _args3), specs = _parseFetchComponentD2.specs, opts = _parseFetchComponentD2.opts;
1109
- _context3.next = 3;
1110
- return this.maybeFetchComponentData(specs, opts);
1111
- case 3:
1112
- data = _context3.sent;
1113
- if (data) {
1114
- _context3.next = 7;
1115
- break;
1116
- }
1117
- _this$maybeGetCompMet3 = this.maybeGetCompMetas.apply(this, specs), missingSpecs = _this$maybeGetCompMet3.missing;
1118
- throw new Error("Unable to find components " + missingSpecs.map(getLookupSpecName).join(', '));
1119
- case 7:
1120
- return _context3.abrupt("return", data);
1121
- case 8:
1122
- case "end":
1123
- return _context3.stop();
1124
- }
1125
- }
1126
- }, _callee3, this);
1127
- }));
1128
- function fetchComponentData() {
1129
- return _fetchComponentData.apply(this, arguments);
1130
- }
1131
- return fetchComponentData;
1132
- }();
1133
- _proto.fetchPages = /*#__PURE__*/function () {
1134
- var _fetchPages = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(opts) {
1135
- var data;
1136
- return runtime_1.wrap(function _callee4$(_context4) {
1137
- while (1) {
1138
- switch (_context4.prev = _context4.next) {
1139
- case 0:
1140
- this.maybeReportClientSideFetch(function () {
1141
- return "Plasmic: fetching all page metadata in the browser";
1142
- });
1143
- _context4.next = 3;
1144
- return this.fetchAllData();
1145
- case 3:
1146
- data = _context4.sent;
1147
- return _context4.abrupt("return", data.components.filter(function (comp) {
1148
- return comp.isPage && comp.path && ((opts == null ? void 0 : opts.includeDynamicPages) || !isDynamicPagePath(comp.path));
1149
- }));
1150
- case 5:
1151
- case "end":
1152
- return _context4.stop();
1153
- }
1154
- }
1155
- }, _callee4, this);
1156
- }));
1157
- function fetchPages(_x2) {
1158
- return _fetchPages.apply(this, arguments);
1159
- }
1160
- return fetchPages;
1161
- }();
1162
- _proto.fetchComponents = /*#__PURE__*/function () {
1163
- var _fetchComponents = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
1164
- var data;
1165
- return runtime_1.wrap(function _callee5$(_context5) {
1166
- while (1) {
1167
- switch (_context5.prev = _context5.next) {
1168
- case 0:
1169
- this.maybeReportClientSideFetch(function () {
1170
- return "Plasmic: fetching all component metadata in the browser";
1171
- });
1172
- _context5.next = 3;
1173
- return this.fetchAllData();
1174
- case 3:
1175
- data = _context5.sent;
1176
- return _context5.abrupt("return", data.components);
1177
- case 5:
1178
- case "end":
1179
- return _context5.stop();
1180
- }
1181
- }
1182
- }, _callee5, this);
1183
- }));
1184
- function fetchComponents() {
1185
- return _fetchComponents.apply(this, arguments);
1186
- }
1187
- return fetchComponents;
1188
- }();
1189
- _proto.getActiveSplits = function getActiveSplits() {
1190
- return this.bundle.activeSplits;
1191
- };
1192
- _proto.fetchMissingData = /*#__PURE__*/function () {
1193
- var _fetchMissingData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(opts) {
1194
- return runtime_1.wrap(function _callee6$(_context6) {
1195
- while (1) {
1196
- switch (_context6.prev = _context6.next) {
1197
- case 0:
1198
- // TODO: do better than just fetching everything
1199
- this.maybeReportClientSideFetch(function () {
1200
- return "Plasmic: fetching missing components in the browser: " + opts.missingSpecs.map(function (spec) {
1201
- return getLookupSpecName(spec);
1202
- }).join(', ');
1203
- });
1204
- return _context6.abrupt("return", this.fetchAllData());
1205
- case 2:
1206
- case "end":
1207
- return _context6.stop();
1208
- }
1209
- }
1210
- }, _callee6, this);
1211
- }));
1212
- function fetchMissingData(_x3) {
1213
- return _fetchMissingData.apply(this, arguments);
1214
- }
1215
- return fetchMissingData;
1216
- }();
1217
- _proto.maybeReportClientSideFetch = function maybeReportClientSideFetch(mkMsg) {
1218
- if (isBrowser && this.opts.onClientSideFetch) {
1219
- var msg = mkMsg();
1220
- if (this.opts.onClientSideFetch === 'warn') {
1221
- console.warn(msg);
1222
- } else {
1223
- throw new Error(msg);
1224
- }
1225
- }
1226
- };
1227
- _proto.fetchAllData = /*#__PURE__*/function () {
1228
- var _fetchAllData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
1229
- var _this$onBundleFetched;
1230
- var bundle;
1231
- return runtime_1.wrap(function _callee7$(_context7) {
1232
- while (1) {
1233
- switch (_context7.prev = _context7.next) {
1234
- case 0:
1235
- _context7.next = 2;
1236
- return this.fetcher.fetchAllData();
1237
- case 2:
1238
- bundle = _context7.sent;
1239
- this.tracker.trackFetch();
1240
- this.mergeBundle(bundle);
1241
- (_this$onBundleFetched = this.onBundleFetched) == null ? void 0 : _this$onBundleFetched.call(this);
1242
- return _context7.abrupt("return", bundle);
1243
- case 7:
1244
- case "end":
1245
- return _context7.stop();
1246
- }
1247
- }
1248
- }, _callee7, this);
1249
- }));
1250
- function fetchAllData() {
1251
- return _fetchAllData.apply(this, arguments);
1252
- }
1253
- return fetchAllData;
1254
- }();
1255
- _proto.mergeBundle = function mergeBundle(bundle) {
1256
- var _this$onBundleMerged;
1257
- this.bundle = mergeBundles(bundle, this.bundle);
1258
- (_this$onBundleMerged = this.onBundleMerged) == null ? void 0 : _this$onBundleMerged.call(this);
1259
- };
1260
- _proto.getBundle = function getBundle() {
1261
- return this.bundle;
1262
- };
1263
- _proto.clearCache = function clearCache() {
1264
- this.bundle = {
1265
- modules: {
1266
- browser: [],
1267
- server: []
1268
- },
1269
- components: [],
1270
- globalGroups: [],
1271
- external: [],
1272
- projects: [],
1273
- activeSplits: []
1274
- };
1275
- };
1276
- return ReactServerPlasmicComponentLoader;
1277
- }();
1278
- function parseFetchComponentDataArgs() {
1279
- var specs;
1280
- var opts;
1281
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1282
- args[_key2] = arguments[_key2];
1283
- }
1284
- if (Array.isArray(args[0])) {
1285
- specs = args[0];
1286
- opts = args[1];
1287
- } else {
1288
- specs = args;
1289
- opts = undefined;
1290
- }
1291
- return {
1292
- specs: specs,
1293
- opts: opts
1294
- };
1295
- }
1296
-
1297
- function initPlasmicLoader(opts) {
1298
- return new ReactServerPlasmicComponentLoader({
1299
- opts: opts,
1300
- fetcher: new loaderCore.PlasmicModulesFetcher(opts),
1301
- tracker: new loaderCore.PlasmicTracker({
1302
- projectIds: opts.projects.map(function (p) {
1303
- return p.id;
1304
- }),
1305
- platform: opts.platform,
1306
- preview: opts.preview
1307
- })
1308
- });
1309
- }
1310
-
1311
- exports.ReactServerPlasmicComponentLoader = ReactServerPlasmicComponentLoader;
1312
- exports.convertBundlesToComponentRenderData = convertBundlesToComponentRenderData;
1313
- exports.initPlasmicLoader = initPlasmicLoader;
1314
- exports.matchesPagePath = matchesPagePath;
1315
- //# sourceMappingURL=loader-react.cjs.development.js.map