@plasmicapp/loader-react 1.0.202 → 1.0.204
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.
- package/dist/loader-react.cjs.development.js +162 -536
- package/dist/loader-react.cjs.development.js.map +1 -1
- package/dist/loader-react.cjs.production.min.js +1 -1
- package/dist/loader-react.cjs.production.min.js.map +1 -1
- package/dist/loader-react.esm.js +162 -536
- package/dist/loader-react.esm.js.map +1 -1
- package/dist/loader.d.ts +1 -0
- package/package.json +7 -6
package/dist/loader-react.esm.js
CHANGED
|
@@ -24,83 +24,66 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
24
24
|
reject(error);
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
27
|
if (info.done) {
|
|
29
28
|
resolve(value);
|
|
30
29
|
} else {
|
|
31
30
|
Promise.resolve(value).then(_next, _throw);
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
|
|
35
33
|
function _asyncToGenerator(fn) {
|
|
36
34
|
return function () {
|
|
37
35
|
var self = this,
|
|
38
|
-
|
|
36
|
+
args = arguments;
|
|
39
37
|
return new Promise(function (resolve, reject) {
|
|
40
38
|
var gen = fn.apply(self, args);
|
|
41
|
-
|
|
42
39
|
function _next(value) {
|
|
43
40
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
44
41
|
}
|
|
45
|
-
|
|
46
42
|
function _throw(err) {
|
|
47
43
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
48
44
|
}
|
|
49
|
-
|
|
50
45
|
_next(undefined);
|
|
51
46
|
});
|
|
52
47
|
};
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
function _extends() {
|
|
56
|
-
_extends = Object.assign
|
|
50
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
57
51
|
for (var i = 1; i < arguments.length; i++) {
|
|
58
52
|
var source = arguments[i];
|
|
59
|
-
|
|
60
53
|
for (var key in source) {
|
|
61
54
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
62
55
|
target[key] = source[key];
|
|
63
56
|
}
|
|
64
57
|
}
|
|
65
58
|
}
|
|
66
|
-
|
|
67
59
|
return target;
|
|
68
60
|
};
|
|
69
|
-
|
|
70
61
|
return _extends.apply(this, arguments);
|
|
71
62
|
}
|
|
72
|
-
|
|
73
63
|
function _inheritsLoose(subClass, superClass) {
|
|
74
64
|
subClass.prototype = Object.create(superClass.prototype);
|
|
75
65
|
subClass.prototype.constructor = subClass;
|
|
76
|
-
|
|
77
66
|
_setPrototypeOf(subClass, superClass);
|
|
78
67
|
}
|
|
79
|
-
|
|
80
68
|
function _setPrototypeOf(o, p) {
|
|
81
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
69
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
82
70
|
o.__proto__ = p;
|
|
83
71
|
return o;
|
|
84
72
|
};
|
|
85
|
-
|
|
86
73
|
return _setPrototypeOf(o, p);
|
|
87
74
|
}
|
|
88
|
-
|
|
89
75
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
90
76
|
if (source == null) return {};
|
|
91
77
|
var target = {};
|
|
92
78
|
var sourceKeys = Object.keys(source);
|
|
93
79
|
var key, i;
|
|
94
|
-
|
|
95
80
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
96
81
|
key = sourceKeys[i];
|
|
97
82
|
if (excluded.indexOf(key) >= 0) continue;
|
|
98
83
|
target[key] = source[key];
|
|
99
84
|
}
|
|
100
|
-
|
|
101
85
|
return target;
|
|
102
86
|
}
|
|
103
|
-
|
|
104
87
|
function _unsupportedIterableToArray(o, minLen) {
|
|
105
88
|
if (!o) return;
|
|
106
89
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -109,19 +92,14 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
109
92
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
110
93
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
111
94
|
}
|
|
112
|
-
|
|
113
95
|
function _arrayLikeToArray(arr, len) {
|
|
114
96
|
if (len == null || len > arr.length) len = arr.length;
|
|
115
|
-
|
|
116
97
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
117
|
-
|
|
118
98
|
return arr2;
|
|
119
99
|
}
|
|
120
|
-
|
|
121
100
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
122
101
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
123
102
|
if (it) return (it = it.call(o)).next.bind(it);
|
|
124
|
-
|
|
125
103
|
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
126
104
|
if (it) o = it;
|
|
127
105
|
var i = 0;
|
|
@@ -135,7 +113,6 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
135
113
|
};
|
|
136
114
|
};
|
|
137
115
|
}
|
|
138
|
-
|
|
139
116
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
140
117
|
}
|
|
141
118
|
|
|
@@ -146,17 +123,13 @@ function getUsedComps(allComponents, entryCompIds) {
|
|
|
146
123
|
return [meta.id, meta];
|
|
147
124
|
}));
|
|
148
125
|
var usedComps = [];
|
|
149
|
-
|
|
150
126
|
while (q.length > 0) {
|
|
151
127
|
var _q$splice = q.splice(0, 1),
|
|
152
|
-
|
|
153
|
-
|
|
128
|
+
id = _q$splice[0];
|
|
154
129
|
var meta = componentMetaById.get(id);
|
|
155
|
-
|
|
156
130
|
if (!meta) {
|
|
157
131
|
continue;
|
|
158
132
|
}
|
|
159
|
-
|
|
160
133
|
usedComps.push(meta);
|
|
161
134
|
meta.usedComponents.forEach(function (usedCompId) {
|
|
162
135
|
if (!seenIds.has(usedCompId)) {
|
|
@@ -165,10 +138,8 @@ function getUsedComps(allComponents, entryCompIds) {
|
|
|
165
138
|
}
|
|
166
139
|
});
|
|
167
140
|
}
|
|
168
|
-
|
|
169
141
|
return usedComps;
|
|
170
142
|
}
|
|
171
|
-
|
|
172
143
|
function prepComponentData(bundle, compMetas, opts) {
|
|
173
144
|
if (compMetas.length === 0) {
|
|
174
145
|
return {
|
|
@@ -177,7 +148,6 @@ function prepComponentData(bundle, compMetas, opts) {
|
|
|
177
148
|
remoteFontUrls: []
|
|
178
149
|
};
|
|
179
150
|
}
|
|
180
|
-
|
|
181
151
|
var usedComps = getUsedComps(bundle.components, compMetas.map(function (compMeta) {
|
|
182
152
|
return compMeta.id;
|
|
183
153
|
}));
|
|
@@ -209,33 +179,28 @@ function prepComponentData(bundle, compMetas, opts) {
|
|
|
209
179
|
}
|
|
210
180
|
function mergeBundles(target, from) {
|
|
211
181
|
var _from$activeSplits$fi;
|
|
212
|
-
|
|
213
182
|
var existingCompIds = new Set(target.components.map(function (c) {
|
|
214
183
|
return c.id;
|
|
215
184
|
}));
|
|
216
185
|
var newCompMetas = from.components.filter(function (m) {
|
|
217
186
|
return !existingCompIds.has(m.id);
|
|
218
187
|
});
|
|
219
|
-
|
|
220
188
|
if (newCompMetas.length > 0) {
|
|
221
189
|
target = _extends({}, target, {
|
|
222
190
|
components: [].concat(target.components, newCompMetas)
|
|
223
191
|
});
|
|
224
192
|
}
|
|
225
|
-
|
|
226
193
|
var existingProjects = new Set(target.projects.map(function (p) {
|
|
227
194
|
return p.id;
|
|
228
195
|
}));
|
|
229
196
|
var newProjects = from.projects.filter(function (p) {
|
|
230
197
|
return !existingProjects.has(p.id);
|
|
231
198
|
});
|
|
232
|
-
|
|
233
199
|
if (newProjects.length > 0) {
|
|
234
200
|
target = _extends({}, target, {
|
|
235
201
|
projects: [].concat(target.projects, newProjects)
|
|
236
202
|
});
|
|
237
203
|
}
|
|
238
|
-
|
|
239
204
|
var existingModules = {
|
|
240
205
|
browser: new Set(target.modules.browser.map(function (m) {
|
|
241
206
|
return m.fileName;
|
|
@@ -252,7 +217,6 @@ function mergeBundles(target, from) {
|
|
|
252
217
|
return !existingModules.server.has(m.fileName);
|
|
253
218
|
})
|
|
254
219
|
};
|
|
255
|
-
|
|
256
220
|
if (newModules.browser.length > 0 || newModules.server.length > 0) {
|
|
257
221
|
target = _extends({}, target, {
|
|
258
222
|
modules: {
|
|
@@ -261,51 +225,43 @@ function mergeBundles(target, from) {
|
|
|
261
225
|
}
|
|
262
226
|
});
|
|
263
227
|
}
|
|
264
|
-
|
|
265
228
|
var existingGlobalIds = new Set(target.globalGroups.map(function (g) {
|
|
266
229
|
return g.id;
|
|
267
230
|
}));
|
|
268
231
|
var newGlobals = from.globalGroups.filter(function (g) {
|
|
269
232
|
return !existingGlobalIds.has(g.id);
|
|
270
233
|
});
|
|
271
|
-
|
|
272
234
|
if (newGlobals.length > 0) {
|
|
273
235
|
target = _extends({}, target, {
|
|
274
236
|
globalGroups: [].concat(target.globalGroups, newGlobals)
|
|
275
237
|
});
|
|
276
238
|
}
|
|
277
|
-
|
|
278
239
|
var existingExternals = new Set(target.external);
|
|
279
240
|
var newExternals = target.external.filter(function (x) {
|
|
280
241
|
return !existingExternals.has(x);
|
|
281
242
|
});
|
|
282
|
-
|
|
283
243
|
if (newExternals.length > 0) {
|
|
284
244
|
target = _extends({}, target, {
|
|
285
245
|
external: [].concat(target.external, newExternals)
|
|
286
246
|
});
|
|
287
247
|
}
|
|
288
|
-
|
|
289
248
|
var existingSplitIds = new Set(target.activeSplits.map(function (s) {
|
|
290
249
|
return s.id;
|
|
291
250
|
}));
|
|
292
251
|
var newSplits = (_from$activeSplits$fi = from.activeSplits.filter(function (s) {
|
|
293
252
|
return !existingSplitIds.has(s.id);
|
|
294
253
|
})) != null ? _from$activeSplits$fi : [];
|
|
295
|
-
|
|
296
254
|
if (newSplits.length > 0) {
|
|
297
255
|
target = _extends({}, target, {
|
|
298
256
|
activeSplits: [].concat(target.activeSplits, newSplits)
|
|
299
257
|
});
|
|
300
258
|
}
|
|
301
|
-
|
|
302
259
|
return target;
|
|
303
260
|
}
|
|
304
261
|
var convertBundlesToComponentRenderData = function convertBundlesToComponentRenderData(bundles, compMetas) {
|
|
305
262
|
if (bundles.length === 0) {
|
|
306
263
|
return null;
|
|
307
264
|
}
|
|
308
|
-
|
|
309
265
|
var mergedBundles = bundles.reduce(function (prev, cur) {
|
|
310
266
|
return mergeBundles(prev, cur);
|
|
311
267
|
});
|
|
@@ -323,17 +279,16 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
323
279
|
* This source code is licensed under the MIT license found in the
|
|
324
280
|
* LICENSE file in the root directory of this source tree.
|
|
325
281
|
*/
|
|
282
|
+
|
|
326
283
|
var runtime = function (exports) {
|
|
327
284
|
|
|
328
285
|
var Op = Object.prototype;
|
|
329
286
|
var hasOwn = Op.hasOwnProperty;
|
|
330
287
|
var undefined$1; // More compressible than void 0.
|
|
331
|
-
|
|
332
288
|
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
333
289
|
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
334
290
|
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
335
291
|
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
336
|
-
|
|
337
292
|
function define(obj, key, value) {
|
|
338
293
|
Object.defineProperty(obj, key, {
|
|
339
294
|
value: value,
|
|
@@ -343,7 +298,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
343
298
|
});
|
|
344
299
|
return obj[key];
|
|
345
300
|
}
|
|
346
|
-
|
|
347
301
|
try {
|
|
348
302
|
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
349
303
|
define({}, "");
|
|
@@ -352,19 +306,20 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
352
306
|
return obj[key] = value;
|
|
353
307
|
};
|
|
354
308
|
}
|
|
355
|
-
|
|
356
309
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
357
310
|
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
358
311
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
359
312
|
var generator = Object.create(protoGenerator.prototype);
|
|
360
|
-
var context = new Context(tryLocsList || []);
|
|
361
|
-
// .throw, and .return methods.
|
|
313
|
+
var context = new Context(tryLocsList || []);
|
|
362
314
|
|
|
315
|
+
// The ._invoke method unifies the implementations of the .next,
|
|
316
|
+
// .throw, and .return methods.
|
|
363
317
|
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
364
318
|
return generator;
|
|
365
319
|
}
|
|
320
|
+
exports.wrap = wrap;
|
|
366
321
|
|
|
367
|
-
|
|
322
|
+
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
368
323
|
// record like context.tryEntries[i].completion. This interface could
|
|
369
324
|
// have been (and was previously) designed to take a closure to be
|
|
370
325
|
// invoked without arguments, but in all the cases we care about we
|
|
@@ -374,7 +329,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
374
329
|
// in every case, so we don't have to touch the arguments object. The
|
|
375
330
|
// only additional allocation required is the completion record, which
|
|
376
331
|
// has a stable shape and so hopefully should be cheap to allocate.
|
|
377
|
-
|
|
378
332
|
function tryCatch(fn, obj, arg) {
|
|
379
333
|
try {
|
|
380
334
|
return {
|
|
@@ -388,46 +342,44 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
388
342
|
};
|
|
389
343
|
}
|
|
390
344
|
}
|
|
391
|
-
|
|
392
345
|
var GenStateSuspendedStart = "suspendedStart";
|
|
393
346
|
var GenStateSuspendedYield = "suspendedYield";
|
|
394
347
|
var GenStateExecuting = "executing";
|
|
395
|
-
var GenStateCompleted = "completed";
|
|
348
|
+
var GenStateCompleted = "completed";
|
|
349
|
+
|
|
350
|
+
// Returning this object from the innerFn has the same effect as
|
|
396
351
|
// breaking out of the dispatch switch statement.
|
|
352
|
+
var ContinueSentinel = {};
|
|
397
353
|
|
|
398
|
-
|
|
354
|
+
// Dummy constructor functions that we use as the .constructor and
|
|
399
355
|
// .constructor.prototype properties for functions that return Generator
|
|
400
356
|
// objects. For full spec compliance, you may wish to configure your
|
|
401
357
|
// minifier not to mangle the names of these two functions.
|
|
402
|
-
|
|
403
358
|
function Generator() {}
|
|
404
|
-
|
|
405
359
|
function GeneratorFunction() {}
|
|
360
|
+
function GeneratorFunctionPrototype() {}
|
|
406
361
|
|
|
407
|
-
|
|
362
|
+
// This is a polyfill for %IteratorPrototype% for environments that
|
|
408
363
|
// don't natively support it.
|
|
409
|
-
|
|
410
|
-
|
|
411
364
|
var IteratorPrototype = {};
|
|
412
365
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
413
366
|
return this;
|
|
414
367
|
});
|
|
415
368
|
var getProto = Object.getPrototypeOf;
|
|
416
369
|
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
417
|
-
|
|
418
370
|
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
419
371
|
// This environment has a native %IteratorPrototype%; use it instead
|
|
420
372
|
// of the polyfill.
|
|
421
373
|
IteratorPrototype = NativeIteratorPrototype;
|
|
422
374
|
}
|
|
423
|
-
|
|
424
375
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
425
376
|
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
426
377
|
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
427
378
|
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
428
|
-
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
429
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
379
|
+
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
430
380
|
|
|
381
|
+
// Helper for defining the .next, .throw, and .return methods of the
|
|
382
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
431
383
|
function defineIteratorMethods(prototype) {
|
|
432
384
|
["next", "throw", "return"].forEach(function (method) {
|
|
433
385
|
define(prototype, method, function (arg) {
|
|
@@ -435,14 +387,13 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
435
387
|
});
|
|
436
388
|
});
|
|
437
389
|
}
|
|
438
|
-
|
|
439
390
|
exports.isGeneratorFunction = function (genFun) {
|
|
440
391
|
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
441
|
-
return ctor ? ctor === GeneratorFunction ||
|
|
392
|
+
return ctor ? ctor === GeneratorFunction ||
|
|
393
|
+
// For the native GeneratorFunction constructor, the best we can
|
|
442
394
|
// do is to check its .name property.
|
|
443
395
|
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
444
396
|
};
|
|
445
|
-
|
|
446
397
|
exports.mark = function (genFun) {
|
|
447
398
|
if (Object.setPrototypeOf) {
|
|
448
399
|
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
@@ -450,31 +401,27 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
450
401
|
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
451
402
|
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
452
403
|
}
|
|
453
|
-
|
|
454
404
|
genFun.prototype = Object.create(Gp);
|
|
455
405
|
return genFun;
|
|
456
|
-
};
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
// Within the body of any async function, `await x` is transformed to
|
|
457
409
|
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
458
410
|
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
459
411
|
// meant to be awaited.
|
|
460
|
-
|
|
461
|
-
|
|
462
412
|
exports.awrap = function (arg) {
|
|
463
413
|
return {
|
|
464
414
|
__await: arg
|
|
465
415
|
};
|
|
466
416
|
};
|
|
467
|
-
|
|
468
417
|
function AsyncIterator(generator, PromiseImpl) {
|
|
469
418
|
function invoke(method, arg, resolve, reject) {
|
|
470
419
|
var record = tryCatch(generator[method], generator, arg);
|
|
471
|
-
|
|
472
420
|
if (record.type === "throw") {
|
|
473
421
|
reject(record.arg);
|
|
474
422
|
} else {
|
|
475
423
|
var result = record.arg;
|
|
476
424
|
var value = result.value;
|
|
477
|
-
|
|
478
425
|
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
479
426
|
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
480
427
|
invoke("next", value, resolve, reject);
|
|
@@ -482,7 +429,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
482
429
|
invoke("throw", err, resolve, reject);
|
|
483
430
|
});
|
|
484
431
|
}
|
|
485
|
-
|
|
486
432
|
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
487
433
|
// When a yielded Promise is resolved, its final value becomes
|
|
488
434
|
// the .value of the Promise<{value,done}> result for the
|
|
@@ -496,17 +442,15 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
496
442
|
});
|
|
497
443
|
}
|
|
498
444
|
}
|
|
499
|
-
|
|
500
445
|
var previousPromise;
|
|
501
|
-
|
|
502
446
|
function enqueue(method, arg) {
|
|
503
447
|
function callInvokeWithMethodAndArg() {
|
|
504
448
|
return new PromiseImpl(function (resolve, reject) {
|
|
505
449
|
invoke(method, arg, resolve, reject);
|
|
506
450
|
});
|
|
507
451
|
}
|
|
508
|
-
|
|
509
|
-
|
|
452
|
+
return previousPromise =
|
|
453
|
+
// If enqueue has been called before, then we want to wait until
|
|
510
454
|
// all previous Promises have been resolved before calling invoke,
|
|
511
455
|
// so that results are always delivered in the correct order. If
|
|
512
456
|
// enqueue has not been called before, then it is important to
|
|
@@ -518,24 +462,25 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
518
462
|
// execute code before the first await. Since we implement simple
|
|
519
463
|
// async functions in terms of async generators, it is especially
|
|
520
464
|
// important to get this right, even though it requires care.
|
|
521
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
465
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
466
|
+
// Avoid propagating failures to Promises returned by later
|
|
522
467
|
// invocations of the iterator.
|
|
523
468
|
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
524
|
-
}
|
|
525
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
526
|
-
|
|
469
|
+
}
|
|
527
470
|
|
|
471
|
+
// Define the unified helper method that is used to implement .next,
|
|
472
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
528
473
|
this._invoke = enqueue;
|
|
529
474
|
}
|
|
530
|
-
|
|
531
475
|
defineIteratorMethods(AsyncIterator.prototype);
|
|
532
476
|
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
533
477
|
return this;
|
|
534
478
|
});
|
|
535
|
-
exports.AsyncIterator = AsyncIterator;
|
|
479
|
+
exports.AsyncIterator = AsyncIterator;
|
|
480
|
+
|
|
481
|
+
// Note that simple async functions are implemented on top of
|
|
536
482
|
// AsyncIterator objects; they just return a Promise for the value of
|
|
537
483
|
// the final result produced by the iterator.
|
|
538
|
-
|
|
539
484
|
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
540
485
|
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
541
486
|
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
@@ -544,39 +489,32 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
544
489
|
return result.done ? result.value : iter.next();
|
|
545
490
|
});
|
|
546
491
|
};
|
|
547
|
-
|
|
548
492
|
function makeInvokeMethod(innerFn, self, context) {
|
|
549
493
|
var state = GenStateSuspendedStart;
|
|
550
494
|
return function invoke(method, arg) {
|
|
551
495
|
if (state === GenStateExecuting) {
|
|
552
496
|
throw new Error("Generator is already running");
|
|
553
497
|
}
|
|
554
|
-
|
|
555
498
|
if (state === GenStateCompleted) {
|
|
556
499
|
if (method === "throw") {
|
|
557
500
|
throw arg;
|
|
558
|
-
}
|
|
559
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
560
|
-
|
|
501
|
+
}
|
|
561
502
|
|
|
503
|
+
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
504
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
562
505
|
return doneResult();
|
|
563
506
|
}
|
|
564
|
-
|
|
565
507
|
context.method = method;
|
|
566
508
|
context.arg = arg;
|
|
567
|
-
|
|
568
509
|
while (true) {
|
|
569
510
|
var delegate = context.delegate;
|
|
570
|
-
|
|
571
511
|
if (delegate) {
|
|
572
512
|
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
573
|
-
|
|
574
513
|
if (delegateResult) {
|
|
575
514
|
if (delegateResult === ContinueSentinel) continue;
|
|
576
515
|
return delegateResult;
|
|
577
516
|
}
|
|
578
517
|
}
|
|
579
|
-
|
|
580
518
|
if (context.method === "next") {
|
|
581
519
|
// Setting context._sent for legacy support of Babel's
|
|
582
520
|
// function.sent implementation.
|
|
@@ -586,51 +524,44 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
586
524
|
state = GenStateCompleted;
|
|
587
525
|
throw context.arg;
|
|
588
526
|
}
|
|
589
|
-
|
|
590
527
|
context.dispatchException(context.arg);
|
|
591
528
|
} else if (context.method === "return") {
|
|
592
529
|
context.abrupt("return", context.arg);
|
|
593
530
|
}
|
|
594
|
-
|
|
595
531
|
state = GenStateExecuting;
|
|
596
532
|
var record = tryCatch(innerFn, self, context);
|
|
597
|
-
|
|
598
533
|
if (record.type === "normal") {
|
|
599
534
|
// If an exception is thrown from innerFn, we leave state ===
|
|
600
535
|
// GenStateExecuting and loop back for another invocation.
|
|
601
536
|
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
602
|
-
|
|
603
537
|
if (record.arg === ContinueSentinel) {
|
|
604
538
|
continue;
|
|
605
539
|
}
|
|
606
|
-
|
|
607
540
|
return {
|
|
608
541
|
value: record.arg,
|
|
609
542
|
done: context.done
|
|
610
543
|
};
|
|
611
544
|
} else if (record.type === "throw") {
|
|
612
|
-
state = GenStateCompleted;
|
|
545
|
+
state = GenStateCompleted;
|
|
546
|
+
// Dispatch the exception by looping back around to the
|
|
613
547
|
// context.dispatchException(context.arg) call above.
|
|
614
|
-
|
|
615
548
|
context.method = "throw";
|
|
616
549
|
context.arg = record.arg;
|
|
617
550
|
}
|
|
618
551
|
}
|
|
619
552
|
};
|
|
620
|
-
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
621
556
|
// result, either by returning a { value, done } result from the
|
|
622
557
|
// delegate iterator, or by modifying context.method and context.arg,
|
|
623
558
|
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
624
|
-
|
|
625
|
-
|
|
626
559
|
function maybeInvokeDelegate(delegate, context) {
|
|
627
560
|
var method = delegate.iterator[context.method];
|
|
628
|
-
|
|
629
561
|
if (method === undefined$1) {
|
|
630
562
|
// A .throw or .return when the delegate iterator has no .throw
|
|
631
563
|
// method always terminates the yield* loop.
|
|
632
564
|
context.delegate = null;
|
|
633
|
-
|
|
634
565
|
if (context.method === "throw") {
|
|
635
566
|
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
636
567
|
if (delegate.iterator["return"]) {
|
|
@@ -639,51 +570,45 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
639
570
|
context.method = "return";
|
|
640
571
|
context.arg = undefined$1;
|
|
641
572
|
maybeInvokeDelegate(delegate, context);
|
|
642
|
-
|
|
643
573
|
if (context.method === "throw") {
|
|
644
574
|
// If maybeInvokeDelegate(context) changed context.method from
|
|
645
575
|
// "return" to "throw", let that override the TypeError below.
|
|
646
576
|
return ContinueSentinel;
|
|
647
577
|
}
|
|
648
578
|
}
|
|
649
|
-
|
|
650
579
|
context.method = "throw";
|
|
651
580
|
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
652
581
|
}
|
|
653
|
-
|
|
654
582
|
return ContinueSentinel;
|
|
655
583
|
}
|
|
656
|
-
|
|
657
584
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
658
|
-
|
|
659
585
|
if (record.type === "throw") {
|
|
660
586
|
context.method = "throw";
|
|
661
587
|
context.arg = record.arg;
|
|
662
588
|
context.delegate = null;
|
|
663
589
|
return ContinueSentinel;
|
|
664
590
|
}
|
|
665
|
-
|
|
666
591
|
var info = record.arg;
|
|
667
|
-
|
|
668
592
|
if (!info) {
|
|
669
593
|
context.method = "throw";
|
|
670
594
|
context.arg = new TypeError("iterator result is not an object");
|
|
671
595
|
context.delegate = null;
|
|
672
596
|
return ContinueSentinel;
|
|
673
597
|
}
|
|
674
|
-
|
|
675
598
|
if (info.done) {
|
|
676
599
|
// Assign the result of the finished delegate to the temporary
|
|
677
600
|
// variable specified by delegate.resultName (see delegateYield).
|
|
678
|
-
context[delegate.resultName] = info.value;
|
|
601
|
+
context[delegate.resultName] = info.value;
|
|
679
602
|
|
|
680
|
-
|
|
603
|
+
// Resume execution at the desired location (see delegateYield).
|
|
604
|
+
context.next = delegate.nextLoc;
|
|
605
|
+
|
|
606
|
+
// If context.method was "throw" but the delegate handled the
|
|
681
607
|
// exception, let the outer generator proceed normally. If
|
|
682
608
|
// context.method was "next", forget context.arg since it has been
|
|
683
609
|
// "consumed" by the delegate iterator. If context.method was
|
|
684
610
|
// "return", allow the original .return call to continue in the
|
|
685
611
|
// outer generator.
|
|
686
|
-
|
|
687
612
|
if (context.method !== "return") {
|
|
688
613
|
context.method = "next";
|
|
689
614
|
context.arg = undefined$1;
|
|
@@ -691,54 +616,49 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
691
616
|
} else {
|
|
692
617
|
// Re-yield the result returned by the delegate method.
|
|
693
618
|
return info;
|
|
694
|
-
}
|
|
695
|
-
// the outer generator.
|
|
696
|
-
|
|
619
|
+
}
|
|
697
620
|
|
|
621
|
+
// The delegate iterator is finished, so forget it and continue with
|
|
622
|
+
// the outer generator.
|
|
698
623
|
context.delegate = null;
|
|
699
624
|
return ContinueSentinel;
|
|
700
|
-
}
|
|
701
|
-
// unified ._invoke helper method.
|
|
702
|
-
|
|
625
|
+
}
|
|
703
626
|
|
|
627
|
+
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
628
|
+
// unified ._invoke helper method.
|
|
704
629
|
defineIteratorMethods(Gp);
|
|
705
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
630
|
+
define(Gp, toStringTagSymbol, "Generator");
|
|
631
|
+
|
|
632
|
+
// A Generator should always return itself as the iterator object when the
|
|
706
633
|
// @@iterator function is called on it. Some browsers' implementations of the
|
|
707
634
|
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
708
635
|
// object to not be returned from this call. This ensures that doesn't happen.
|
|
709
636
|
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
710
|
-
|
|
711
637
|
define(Gp, iteratorSymbol, function () {
|
|
712
638
|
return this;
|
|
713
639
|
});
|
|
714
640
|
define(Gp, "toString", function () {
|
|
715
641
|
return "[object Generator]";
|
|
716
642
|
});
|
|
717
|
-
|
|
718
643
|
function pushTryEntry(locs) {
|
|
719
644
|
var entry = {
|
|
720
645
|
tryLoc: locs[0]
|
|
721
646
|
};
|
|
722
|
-
|
|
723
647
|
if (1 in locs) {
|
|
724
648
|
entry.catchLoc = locs[1];
|
|
725
649
|
}
|
|
726
|
-
|
|
727
650
|
if (2 in locs) {
|
|
728
651
|
entry.finallyLoc = locs[2];
|
|
729
652
|
entry.afterLoc = locs[3];
|
|
730
653
|
}
|
|
731
|
-
|
|
732
654
|
this.tryEntries.push(entry);
|
|
733
655
|
}
|
|
734
|
-
|
|
735
656
|
function resetTryEntry(entry) {
|
|
736
657
|
var record = entry.completion || {};
|
|
737
658
|
record.type = "normal";
|
|
738
659
|
delete record.arg;
|
|
739
660
|
entry.completion = record;
|
|
740
661
|
}
|
|
741
|
-
|
|
742
662
|
function Context(tryLocsList) {
|
|
743
663
|
// The root entry object (effectively a try statement without a catch
|
|
744
664
|
// or a finally block) gives us a place to store values thrown from
|
|
@@ -749,97 +669,84 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
749
669
|
tryLocsList.forEach(pushTryEntry, this);
|
|
750
670
|
this.reset(true);
|
|
751
671
|
}
|
|
752
|
-
|
|
753
672
|
exports.keys = function (object) {
|
|
754
673
|
var keys = [];
|
|
755
|
-
|
|
756
674
|
for (var key in object) {
|
|
757
675
|
keys.push(key);
|
|
758
676
|
}
|
|
677
|
+
keys.reverse();
|
|
759
678
|
|
|
760
|
-
|
|
679
|
+
// Rather than returning an object with a next method, we keep
|
|
761
680
|
// things simple and return the next function itself.
|
|
762
|
-
|
|
763
681
|
return function next() {
|
|
764
682
|
while (keys.length) {
|
|
765
683
|
var key = keys.pop();
|
|
766
|
-
|
|
767
684
|
if (key in object) {
|
|
768
685
|
next.value = key;
|
|
769
686
|
next.done = false;
|
|
770
687
|
return next;
|
|
771
688
|
}
|
|
772
|
-
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
// To avoid creating an additional object, we just hang the .value
|
|
773
692
|
// and .done properties off the next function object itself. This
|
|
774
693
|
// also ensures that the minifier will not anonymize the function.
|
|
775
|
-
|
|
776
|
-
|
|
777
694
|
next.done = true;
|
|
778
695
|
return next;
|
|
779
696
|
};
|
|
780
697
|
};
|
|
781
|
-
|
|
782
698
|
function values(iterable) {
|
|
783
699
|
if (iterable) {
|
|
784
700
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
785
|
-
|
|
786
701
|
if (iteratorMethod) {
|
|
787
702
|
return iteratorMethod.call(iterable);
|
|
788
703
|
}
|
|
789
|
-
|
|
790
704
|
if (typeof iterable.next === "function") {
|
|
791
705
|
return iterable;
|
|
792
706
|
}
|
|
793
|
-
|
|
794
707
|
if (!isNaN(iterable.length)) {
|
|
795
708
|
var i = -1,
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
709
|
+
next = function next() {
|
|
710
|
+
while (++i < iterable.length) {
|
|
711
|
+
if (hasOwn.call(iterable, i)) {
|
|
712
|
+
next.value = iterable[i];
|
|
713
|
+
next.done = false;
|
|
714
|
+
return next;
|
|
715
|
+
}
|
|
802
716
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
return next;
|
|
808
|
-
};
|
|
809
|
-
|
|
717
|
+
next.value = undefined$1;
|
|
718
|
+
next.done = true;
|
|
719
|
+
return next;
|
|
720
|
+
};
|
|
810
721
|
return next.next = next;
|
|
811
722
|
}
|
|
812
|
-
}
|
|
813
|
-
|
|
723
|
+
}
|
|
814
724
|
|
|
725
|
+
// Return an iterator with no values.
|
|
815
726
|
return {
|
|
816
727
|
next: doneResult
|
|
817
728
|
};
|
|
818
729
|
}
|
|
819
|
-
|
|
820
730
|
exports.values = values;
|
|
821
|
-
|
|
822
731
|
function doneResult() {
|
|
823
732
|
return {
|
|
824
733
|
value: undefined$1,
|
|
825
734
|
done: true
|
|
826
735
|
};
|
|
827
736
|
}
|
|
828
|
-
|
|
829
737
|
Context.prototype = {
|
|
830
738
|
constructor: Context,
|
|
831
739
|
reset: function reset(skipTempReset) {
|
|
832
740
|
this.prev = 0;
|
|
833
|
-
this.next = 0;
|
|
741
|
+
this.next = 0;
|
|
742
|
+
// Resetting context._sent for legacy support of Babel's
|
|
834
743
|
// function.sent implementation.
|
|
835
|
-
|
|
836
744
|
this.sent = this._sent = undefined$1;
|
|
837
745
|
this.done = false;
|
|
838
746
|
this.delegate = null;
|
|
839
747
|
this.method = "next";
|
|
840
748
|
this.arg = undefined$1;
|
|
841
749
|
this.tryEntries.forEach(resetTryEntry);
|
|
842
|
-
|
|
843
750
|
if (!skipTempReset) {
|
|
844
751
|
for (var name in this) {
|
|
845
752
|
// Not sure about the optimal order of these conditions:
|
|
@@ -853,50 +760,40 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
853
760
|
this.done = true;
|
|
854
761
|
var rootEntry = this.tryEntries[0];
|
|
855
762
|
var rootRecord = rootEntry.completion;
|
|
856
|
-
|
|
857
763
|
if (rootRecord.type === "throw") {
|
|
858
764
|
throw rootRecord.arg;
|
|
859
765
|
}
|
|
860
|
-
|
|
861
766
|
return this.rval;
|
|
862
767
|
},
|
|
863
768
|
dispatchException: function dispatchException(exception) {
|
|
864
769
|
if (this.done) {
|
|
865
770
|
throw exception;
|
|
866
771
|
}
|
|
867
|
-
|
|
868
772
|
var context = this;
|
|
869
|
-
|
|
870
773
|
function handle(loc, caught) {
|
|
871
774
|
record.type = "throw";
|
|
872
775
|
record.arg = exception;
|
|
873
776
|
context.next = loc;
|
|
874
|
-
|
|
875
777
|
if (caught) {
|
|
876
778
|
// If the dispatched exception was caught by a catch block,
|
|
877
779
|
// then let that catch block handle the exception normally.
|
|
878
780
|
context.method = "next";
|
|
879
781
|
context.arg = undefined$1;
|
|
880
782
|
}
|
|
881
|
-
|
|
882
783
|
return !!caught;
|
|
883
784
|
}
|
|
884
|
-
|
|
885
785
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
886
786
|
var entry = this.tryEntries[i];
|
|
887
787
|
var record = entry.completion;
|
|
888
|
-
|
|
889
788
|
if (entry.tryLoc === "root") {
|
|
890
789
|
// Exception thrown outside of any try block that could handle
|
|
891
790
|
// it, so set the completion value of the entire function to
|
|
892
791
|
// throw the exception.
|
|
893
792
|
return handle("end");
|
|
894
793
|
}
|
|
895
|
-
|
|
896
794
|
if (entry.tryLoc <= this.prev) {
|
|
897
795
|
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
898
796
|
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
899
|
-
|
|
900
797
|
if (hasCatch && hasFinally) {
|
|
901
798
|
if (this.prev < entry.catchLoc) {
|
|
902
799
|
return handle(entry.catchLoc, true);
|
|
@@ -920,36 +817,30 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
920
817
|
abrupt: function abrupt(type, arg) {
|
|
921
818
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
922
819
|
var entry = this.tryEntries[i];
|
|
923
|
-
|
|
924
820
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
925
821
|
var finallyEntry = entry;
|
|
926
822
|
break;
|
|
927
823
|
}
|
|
928
824
|
}
|
|
929
|
-
|
|
930
825
|
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
931
826
|
// Ignore the finally entry if control is not jumping to a
|
|
932
827
|
// location outside the try/catch block.
|
|
933
828
|
finallyEntry = null;
|
|
934
829
|
}
|
|
935
|
-
|
|
936
830
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
937
831
|
record.type = type;
|
|
938
832
|
record.arg = arg;
|
|
939
|
-
|
|
940
833
|
if (finallyEntry) {
|
|
941
834
|
this.method = "next";
|
|
942
835
|
this.next = finallyEntry.finallyLoc;
|
|
943
836
|
return ContinueSentinel;
|
|
944
837
|
}
|
|
945
|
-
|
|
946
838
|
return this.complete(record);
|
|
947
839
|
},
|
|
948
840
|
complete: function complete(record, afterLoc) {
|
|
949
841
|
if (record.type === "throw") {
|
|
950
842
|
throw record.arg;
|
|
951
843
|
}
|
|
952
|
-
|
|
953
844
|
if (record.type === "break" || record.type === "continue") {
|
|
954
845
|
this.next = record.arg;
|
|
955
846
|
} else if (record.type === "return") {
|
|
@@ -959,13 +850,11 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
959
850
|
} else if (record.type === "normal" && afterLoc) {
|
|
960
851
|
this.next = afterLoc;
|
|
961
852
|
}
|
|
962
|
-
|
|
963
853
|
return ContinueSentinel;
|
|
964
854
|
},
|
|
965
855
|
finish: function finish(finallyLoc) {
|
|
966
856
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
967
857
|
var entry = this.tryEntries[i];
|
|
968
|
-
|
|
969
858
|
if (entry.finallyLoc === finallyLoc) {
|
|
970
859
|
this.complete(entry.completion, entry.afterLoc);
|
|
971
860
|
resetTryEntry(entry);
|
|
@@ -976,21 +865,18 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
976
865
|
"catch": function _catch(tryLoc) {
|
|
977
866
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
978
867
|
var entry = this.tryEntries[i];
|
|
979
|
-
|
|
980
868
|
if (entry.tryLoc === tryLoc) {
|
|
981
869
|
var record = entry.completion;
|
|
982
|
-
|
|
983
870
|
if (record.type === "throw") {
|
|
984
871
|
var thrown = record.arg;
|
|
985
872
|
resetTryEntry(entry);
|
|
986
873
|
}
|
|
987
|
-
|
|
988
874
|
return thrown;
|
|
989
875
|
}
|
|
990
|
-
}
|
|
991
|
-
// argument that corresponds to a known catch block.
|
|
992
|
-
|
|
876
|
+
}
|
|
993
877
|
|
|
878
|
+
// The context.catch method must only be called with a location
|
|
879
|
+
// argument that corresponds to a known catch block.
|
|
994
880
|
throw new Error("illegal catch attempt");
|
|
995
881
|
},
|
|
996
882
|
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
@@ -999,27 +885,26 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
999
885
|
resultName: resultName,
|
|
1000
886
|
nextLoc: nextLoc
|
|
1001
887
|
};
|
|
1002
|
-
|
|
1003
888
|
if (this.method === "next") {
|
|
1004
889
|
// Deliberately forget the last sent value so that we don't
|
|
1005
890
|
// accidentally pass it on to the delegate.
|
|
1006
891
|
this.arg = undefined$1;
|
|
1007
892
|
}
|
|
1008
|
-
|
|
1009
893
|
return ContinueSentinel;
|
|
1010
894
|
}
|
|
1011
|
-
};
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
// Regardless of whether this script is executing as a CommonJS module
|
|
1012
898
|
// or not, return the runtime object so that we can declare the variable
|
|
1013
899
|
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
1014
900
|
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
1015
|
-
|
|
1016
901
|
return exports;
|
|
1017
|
-
}(
|
|
902
|
+
}(
|
|
903
|
+
// If this script is executing as a CommonJS module, use module.exports
|
|
1018
904
|
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
1019
905
|
// object. Either way, the resulting object will be used to initialize
|
|
1020
906
|
// the regeneratorRuntime variable at the top of this file.
|
|
1021
907
|
module.exports );
|
|
1022
|
-
|
|
1023
908
|
try {
|
|
1024
909
|
regeneratorRuntime = runtime;
|
|
1025
910
|
} catch (accidentalStrictMode) {
|
|
@@ -1043,8 +928,7 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
1043
928
|
|
|
1044
929
|
function useForceUpdate() {
|
|
1045
930
|
var _React$useState = useState(0),
|
|
1046
|
-
|
|
1047
|
-
|
|
931
|
+
setTick = _React$useState[1];
|
|
1048
932
|
var update = useCallback(function () {
|
|
1049
933
|
setTick(function (tick) {
|
|
1050
934
|
return tick + 1;
|
|
@@ -1059,11 +943,9 @@ function useStableLookupSpecs() {
|
|
|
1059
943
|
for (var _len = arguments.length, specs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1060
944
|
specs[_key] = arguments[_key];
|
|
1061
945
|
}
|
|
1062
|
-
|
|
1063
946
|
var _React$useState2 = useState(specs),
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
947
|
+
stableSpecs = _React$useState2[0],
|
|
948
|
+
setStableSpecs = _React$useState2[1];
|
|
1067
949
|
useEffect(function () {
|
|
1068
950
|
if (specs.length !== stableSpecs.length || specs.some(function (s, i) {
|
|
1069
951
|
return !areLookupSpecsEqual(s, stableSpecs[i]);
|
|
@@ -1073,34 +955,27 @@ function useStableLookupSpecs() {
|
|
|
1073
955
|
}, [specs, stableSpecs]);
|
|
1074
956
|
return stableSpecs;
|
|
1075
957
|
}
|
|
1076
|
-
|
|
1077
958
|
function areLookupSpecsEqual(spec1, spec2) {
|
|
1078
959
|
if (spec1 === spec2) {
|
|
1079
960
|
return true;
|
|
1080
961
|
}
|
|
1081
|
-
|
|
1082
962
|
if (typeof spec1 !== typeof spec2) {
|
|
1083
963
|
return false;
|
|
1084
964
|
}
|
|
1085
|
-
|
|
1086
965
|
var fullSpec1 = toFullLookup(spec1);
|
|
1087
966
|
var fullSpec2 = toFullLookup(spec2);
|
|
1088
967
|
return (isNameSpec(fullSpec1) && isNameSpec(fullSpec2) && fullSpec1.name === fullSpec2.name && fullSpec1.isCode === fullSpec2.isCode || isPathSpec(fullSpec1) && isPathSpec(fullSpec2) && fullSpec1.path === fullSpec2.path) && fullSpec1.projectId === fullSpec2.projectId;
|
|
1089
968
|
}
|
|
1090
|
-
|
|
1091
969
|
function isNameSpec(lookup) {
|
|
1092
970
|
return 'name' in lookup;
|
|
1093
971
|
}
|
|
1094
|
-
|
|
1095
972
|
function isPathSpec(lookup) {
|
|
1096
973
|
return 'path' in lookup;
|
|
1097
974
|
}
|
|
1098
|
-
|
|
1099
975
|
function toFullLookup(lookup) {
|
|
1100
976
|
var namePart = typeof lookup === 'string' ? lookup : lookup.name;
|
|
1101
977
|
var projectId = typeof lookup === 'string' ? undefined : lookup.projectId;
|
|
1102
978
|
var codeComponent = typeof lookup === 'string' ? undefined : lookup.isCode;
|
|
1103
|
-
|
|
1104
979
|
if (codeComponent !== true && namePart.startsWith('/')) {
|
|
1105
980
|
return {
|
|
1106
981
|
path: normalizePath(namePart),
|
|
@@ -1115,16 +990,13 @@ function toFullLookup(lookup) {
|
|
|
1115
990
|
};
|
|
1116
991
|
}
|
|
1117
992
|
}
|
|
1118
|
-
|
|
1119
993
|
function normalizePath(path) {
|
|
1120
994
|
return path.trim();
|
|
1121
995
|
}
|
|
1122
|
-
|
|
1123
996
|
function normalizeName(name) {
|
|
1124
997
|
// Not a full normalization, but should be good enough
|
|
1125
998
|
return pascalcase(name).trim();
|
|
1126
999
|
}
|
|
1127
|
-
|
|
1128
1000
|
function useIsMounted() {
|
|
1129
1001
|
var ref = useRef(false);
|
|
1130
1002
|
var isMounted = useCallback(function () {
|
|
@@ -1148,31 +1020,25 @@ function useIsMounted() {
|
|
|
1148
1020
|
* - `matchesPagePath("/hello/[name]", "/")` -> `false`
|
|
1149
1021
|
* - `matchesPagePath("/", "")` -> `{params: {}}`
|
|
1150
1022
|
*/
|
|
1151
|
-
|
|
1152
1023
|
function matchesPagePath(pagePath, lookup) {
|
|
1153
1024
|
var _lookup$match;
|
|
1154
|
-
|
|
1155
1025
|
// Remove trailing slashes from both `pagePath` and `lookup`.
|
|
1156
1026
|
pagePath = pagePath.replace(/^\/*/, '').replace(/\/*$/, '');
|
|
1157
|
-
lookup = lookup.replace(/^\/*/, '').replace(/\/*$/, '');
|
|
1027
|
+
lookup = lookup.replace(/^\/*/, '').replace(/\/*$/, '');
|
|
1028
|
+
// paramNames will contain a list of parameter names; e.g. if pagePath
|
|
1158
1029
|
// is "/products/[slug]/[variant]" it will contain ["slug", "variant"].
|
|
1159
|
-
|
|
1160
1030
|
var paramNames = (pagePath.match(/\[([^\]]*)\]/g) || []).map(function (group) {
|
|
1161
1031
|
return group.slice(1, -1);
|
|
1162
1032
|
});
|
|
1163
1033
|
var pagePathRegExp = new RegExp('^' + pagePath.replace(/\[[^\]]*\]/g, '([^/]+)') + '$');
|
|
1164
1034
|
var maybeVals = (_lookup$match = lookup.match(pagePathRegExp)) == null ? void 0 : _lookup$match.slice(1);
|
|
1165
|
-
|
|
1166
1035
|
if (!maybeVals) {
|
|
1167
1036
|
return false;
|
|
1168
1037
|
}
|
|
1169
|
-
|
|
1170
1038
|
var params = {};
|
|
1171
|
-
|
|
1172
1039
|
for (var i = 0; i < paramNames.length; i++) {
|
|
1173
1040
|
params[paramNames[i]] = maybeVals[i];
|
|
1174
1041
|
}
|
|
1175
|
-
|
|
1176
1042
|
return {
|
|
1177
1043
|
params: params
|
|
1178
1044
|
};
|
|
@@ -1180,15 +1046,12 @@ function matchesPagePath(pagePath, lookup) {
|
|
|
1180
1046
|
function isDynamicPagePath(path) {
|
|
1181
1047
|
return !!path.match(/\[[^/]*\]/);
|
|
1182
1048
|
}
|
|
1183
|
-
|
|
1184
1049
|
function matchesCompMeta(lookup, meta) {
|
|
1185
1050
|
if (lookup.projectId && meta.projectId !== lookup.projectId) {
|
|
1186
1051
|
return false;
|
|
1187
1052
|
}
|
|
1188
|
-
|
|
1189
1053
|
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));
|
|
1190
1054
|
}
|
|
1191
|
-
|
|
1192
1055
|
function getCompMetas(metas, lookup) {
|
|
1193
1056
|
var full = toFullLookup(lookup);
|
|
1194
1057
|
return metas.filter(function (meta) {
|
|
@@ -1197,18 +1060,16 @@ function getCompMetas(metas, lookup) {
|
|
|
1197
1060
|
if (isNameSpec(full) || !meta.path) {
|
|
1198
1061
|
return meta;
|
|
1199
1062
|
}
|
|
1200
|
-
|
|
1201
1063
|
var match = matchesPagePath(meta.path, full.path);
|
|
1202
|
-
|
|
1203
1064
|
if (!match) {
|
|
1204
1065
|
return meta;
|
|
1205
1066
|
}
|
|
1206
|
-
|
|
1207
1067
|
return _extends({}, meta, {
|
|
1208
1068
|
params: match.params
|
|
1209
1069
|
});
|
|
1210
1070
|
}).sort(function (meta1, meta2) {
|
|
1211
|
-
return (
|
|
1071
|
+
return (
|
|
1072
|
+
// We sort the matched component metas by the number of path params, so
|
|
1212
1073
|
// if there are two pages `/products/foo` and `/products/[slug]`,
|
|
1213
1074
|
// the first one will have higher precedence.
|
|
1214
1075
|
Array.from(Object.keys(meta1.params || {})).length - Array.from(Object.keys(meta2.params || {})).length
|
|
@@ -1232,56 +1093,42 @@ function getFirstCompMeta(metas, lookup) {
|
|
|
1232
1093
|
var filtered = getCompMetas(metas, lookup);
|
|
1233
1094
|
return filtered.length === 0 ? undefined : filtered[0];
|
|
1234
1095
|
}
|
|
1235
|
-
|
|
1236
1096
|
var ComponentLookup = /*#__PURE__*/function () {
|
|
1237
1097
|
function ComponentLookup(bundle, registry) {
|
|
1238
1098
|
this.bundle = bundle;
|
|
1239
1099
|
this.registry = registry;
|
|
1240
1100
|
}
|
|
1241
|
-
|
|
1242
1101
|
var _proto = ComponentLookup.prototype;
|
|
1243
|
-
|
|
1244
1102
|
_proto.getComponentMeta = function getComponentMeta(spec) {
|
|
1245
1103
|
var compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
1246
1104
|
return compMeta;
|
|
1247
1105
|
};
|
|
1248
|
-
|
|
1249
1106
|
_proto.getComponent = function getComponent(spec, opts) {
|
|
1250
1107
|
if (opts === void 0) {
|
|
1251
1108
|
opts = {};
|
|
1252
1109
|
}
|
|
1253
|
-
|
|
1254
1110
|
var compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
1255
|
-
|
|
1256
1111
|
if (!compMeta) {
|
|
1257
1112
|
throw new Error("Component not found: " + spec);
|
|
1258
1113
|
}
|
|
1259
|
-
|
|
1260
1114
|
var moduleName = compMeta.entry;
|
|
1261
|
-
|
|
1262
1115
|
if (!this.registry.hasModule(moduleName, opts)) {
|
|
1263
1116
|
throw new Error("Component not yet fetched: " + compMeta.name);
|
|
1264
1117
|
}
|
|
1265
|
-
|
|
1266
1118
|
var entry = this.registry.load(moduleName, {
|
|
1267
1119
|
forceOriginal: opts.forceOriginal
|
|
1268
1120
|
});
|
|
1269
1121
|
return !opts.forceOriginal && typeof (entry == null ? void 0 : entry.getPlasmicComponent) === 'function' ? entry.getPlasmicComponent() : entry["default"];
|
|
1270
1122
|
};
|
|
1271
|
-
|
|
1272
1123
|
_proto.hasComponent = function hasComponent(spec) {
|
|
1273
1124
|
var compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
1274
|
-
|
|
1275
1125
|
if (compMeta) {
|
|
1276
1126
|
return this.registry.hasModule(compMeta.entry);
|
|
1277
1127
|
}
|
|
1278
|
-
|
|
1279
1128
|
return false;
|
|
1280
1129
|
};
|
|
1281
|
-
|
|
1282
1130
|
_proto.getGlobalContexts = function getGlobalContexts() {
|
|
1283
1131
|
var _this = this;
|
|
1284
|
-
|
|
1285
1132
|
var customGlobalMetas = this.bundle.globalGroups.filter(function (m) {
|
|
1286
1133
|
return m.type === 'global-user-defined';
|
|
1287
1134
|
});
|
|
@@ -1292,39 +1139,32 @@ var ComponentLookup = /*#__PURE__*/function () {
|
|
|
1292
1139
|
};
|
|
1293
1140
|
});
|
|
1294
1141
|
};
|
|
1295
|
-
|
|
1296
1142
|
_proto.getGlobalContextsProvider = function getGlobalContextsProvider(spec) {
|
|
1297
1143
|
var compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
1298
1144
|
var projectMeta = compMeta ? this.bundle.projects.find(function (x) {
|
|
1299
1145
|
return x.id === compMeta.projectId;
|
|
1300
1146
|
}) : undefined;
|
|
1301
|
-
|
|
1302
1147
|
if (!projectMeta || !projectMeta.globalContextsProviderFileName || !this.registry.hasModule(projectMeta.globalContextsProviderFileName)) {
|
|
1303
1148
|
return undefined;
|
|
1304
1149
|
}
|
|
1305
|
-
|
|
1306
1150
|
var entry = this.registry.load(projectMeta.globalContextsProviderFileName);
|
|
1307
1151
|
return typeof (entry == null ? void 0 : entry.getPlasmicComponent) === 'function' ? entry.getPlasmicComponent() : entry["default"];
|
|
1308
1152
|
};
|
|
1309
|
-
|
|
1310
1153
|
_proto.getRootProvider = function getRootProvider() {
|
|
1311
1154
|
var entry = this.registry.load('root-provider.js');
|
|
1312
1155
|
return entry["default"];
|
|
1313
1156
|
};
|
|
1314
|
-
|
|
1315
1157
|
_proto.getCss = function getCss() {
|
|
1316
1158
|
// We can probably always get the modules from the browser build
|
|
1317
1159
|
return this.bundle.modules.browser.filter(function (mod) {
|
|
1318
1160
|
return mod.type === 'asset' && mod.fileName.endsWith('css');
|
|
1319
1161
|
});
|
|
1320
1162
|
};
|
|
1321
|
-
|
|
1322
1163
|
_proto.getRemoteFonts = function getRemoteFonts() {
|
|
1323
1164
|
return this.bundle.projects.flatMap(function (p) {
|
|
1324
1165
|
return p.remoteFonts;
|
|
1325
1166
|
});
|
|
1326
1167
|
};
|
|
1327
|
-
|
|
1328
1168
|
return ComponentLookup;
|
|
1329
1169
|
}();
|
|
1330
1170
|
|
|
@@ -1335,7 +1175,7 @@ function getPlasmicCookieValues() {
|
|
|
1335
1175
|
return cookie.split('=');
|
|
1336
1176
|
}).map(function (_ref) {
|
|
1337
1177
|
var key = _ref[0],
|
|
1338
|
-
|
|
1178
|
+
value = _ref[1];
|
|
1339
1179
|
return [key.split(':')[1], value];
|
|
1340
1180
|
}));
|
|
1341
1181
|
}
|
|
@@ -1346,7 +1186,6 @@ function ensureVariationCookies(variation) {
|
|
|
1346
1186
|
if (variation === void 0) {
|
|
1347
1187
|
variation = {};
|
|
1348
1188
|
}
|
|
1349
|
-
|
|
1350
1189
|
Object.keys(variation).map(function (variationKey) {
|
|
1351
1190
|
var sliceId = variation[variationKey];
|
|
1352
1191
|
updatePlasmicCookieValue(variationKey, sliceId);
|
|
@@ -1356,18 +1195,15 @@ var getGlobalVariantsFromSplits = function getGlobalVariantsFromSplits(splits, v
|
|
|
1356
1195
|
var globalVariants = [];
|
|
1357
1196
|
Object.keys(variation).map(function (variationKey) {
|
|
1358
1197
|
var _variationKey$split = variationKey.split('.'),
|
|
1359
|
-
|
|
1360
|
-
|
|
1198
|
+
splitId = _variationKey$split[1];
|
|
1361
1199
|
var sliceId = variation[variationKey];
|
|
1362
1200
|
var split = splits.find(function (s) {
|
|
1363
1201
|
return s.id === splitId || s.externalId === splitId;
|
|
1364
1202
|
});
|
|
1365
|
-
|
|
1366
1203
|
if (split) {
|
|
1367
1204
|
var slice = split.slices.find(function (s) {
|
|
1368
1205
|
return s.id === sliceId || s.externalId === sliceId;
|
|
1369
1206
|
});
|
|
1370
|
-
|
|
1371
1207
|
if (slice) {
|
|
1372
1208
|
slice.contents.map(function (x) {
|
|
1373
1209
|
globalVariants.push({
|
|
@@ -1385,19 +1221,15 @@ var mergeGlobalVariantsSpec = function mergeGlobalVariantsSpec(target, from) {
|
|
|
1385
1221
|
var result = [].concat(target);
|
|
1386
1222
|
var existingGlobalVariants = new Set(target.map(function (t) {
|
|
1387
1223
|
var _t$projectId;
|
|
1388
|
-
|
|
1389
1224
|
return t.name + "-" + ((_t$projectId = t.projectId) != null ? _t$projectId : '');
|
|
1390
1225
|
}));
|
|
1391
1226
|
var newGlobals = from.filter(function (t) {
|
|
1392
1227
|
var _t$projectId2;
|
|
1393
|
-
|
|
1394
1228
|
return !existingGlobalVariants.has(t.name + "-" + ((_t$projectId2 = t.projectId) != null ? _t$projectId2 : ''));
|
|
1395
1229
|
});
|
|
1396
|
-
|
|
1397
1230
|
if (newGlobals.length > 0) {
|
|
1398
1231
|
result = [].concat(result, newGlobals);
|
|
1399
1232
|
}
|
|
1400
|
-
|
|
1401
1233
|
return result;
|
|
1402
1234
|
};
|
|
1403
1235
|
|
|
@@ -1406,31 +1238,27 @@ var PlasmicRootContext = /*#__PURE__*/createContext(undefined);
|
|
|
1406
1238
|
* PlasmicRootProvider should be used at the root of your page
|
|
1407
1239
|
* or application.
|
|
1408
1240
|
*/
|
|
1409
|
-
|
|
1410
1241
|
function PlasmicRootProvider(props) {
|
|
1411
1242
|
var globalVariants = props.globalVariants,
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1243
|
+
prefetchedData = props.prefetchedData,
|
|
1244
|
+
children = props.children,
|
|
1245
|
+
skipCss = props.skipCss,
|
|
1246
|
+
skipFonts = props.skipFonts,
|
|
1247
|
+
prefetchedQueryData = props.prefetchedQueryData,
|
|
1248
|
+
suspenseForQueryData = props.suspenseForQueryData,
|
|
1249
|
+
globalContextsProps = props.globalContextsProps,
|
|
1250
|
+
variation = props.variation,
|
|
1251
|
+
translator = props.translator,
|
|
1252
|
+
Head = props.Head,
|
|
1253
|
+
pageParams = props.pageParams,
|
|
1254
|
+
pageQuery = props.pageQuery;
|
|
1424
1255
|
var loader = props.loader.__internal;
|
|
1425
|
-
|
|
1426
1256
|
if (prefetchedData) {
|
|
1427
1257
|
loader.registerPrefetchedBundle(prefetchedData == null ? void 0 : prefetchedData.bundle);
|
|
1428
1258
|
}
|
|
1429
|
-
|
|
1430
1259
|
var _React$useState = useState(loader.getActiveSplits()),
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1260
|
+
splits = _React$useState[0],
|
|
1261
|
+
setSplits = _React$useState[1];
|
|
1434
1262
|
var forceUpdate = useForceUpdate();
|
|
1435
1263
|
var watcher = useMemo(function () {
|
|
1436
1264
|
return {
|
|
@@ -1457,10 +1285,11 @@ function PlasmicRootProvider(props) {
|
|
|
1457
1285
|
},
|
|
1458
1286
|
variation: variation
|
|
1459
1287
|
});
|
|
1460
|
-
}, [loader, variation]);
|
|
1461
|
-
|
|
1288
|
+
}, [loader, variation]);
|
|
1289
|
+
// @ts-ignore
|
|
1462
1290
|
var user = props.user,
|
|
1463
|
-
|
|
1291
|
+
userAuthToken = props.userAuthToken,
|
|
1292
|
+
isUserLoading = props.isUserLoading;
|
|
1464
1293
|
var value = useMemo(function () {
|
|
1465
1294
|
return {
|
|
1466
1295
|
globalVariants: mergeGlobalVariantsSpec(globalVariants != null ? globalVariants : [], getGlobalVariantsFromSplits(splits, variation != null ? variation : {})),
|
|
@@ -1470,9 +1299,10 @@ function PlasmicRootProvider(props) {
|
|
|
1470
1299
|
translator: translator,
|
|
1471
1300
|
Head: Head,
|
|
1472
1301
|
user: user,
|
|
1473
|
-
userAuthToken: userAuthToken
|
|
1302
|
+
userAuthToken: userAuthToken,
|
|
1303
|
+
isUserLoading: isUserLoading
|
|
1474
1304
|
};
|
|
1475
|
-
}, [globalVariants, variation, globalContextsProps, loader, splits, translator, Head, user, userAuthToken]);
|
|
1305
|
+
}, [globalVariants, variation, globalContextsProps, loader, splits, translator, Head, user, userAuthToken, isUserLoading]);
|
|
1476
1306
|
return createElement(PlasmicQueryDataProvider, {
|
|
1477
1307
|
prefetchedCache: prefetchedQueryData,
|
|
1478
1308
|
suspense: suspenseForQueryData
|
|
@@ -1491,16 +1321,13 @@ function PlasmicRootProvider(props) {
|
|
|
1491
1321
|
* Inject all css modules as <style/> tags. We can't use the usual styleInjector postcss
|
|
1492
1322
|
* uses because that doesn't work on the server side for SSR.
|
|
1493
1323
|
*/
|
|
1494
|
-
|
|
1495
1324
|
var PlasmicCss = /*#__PURE__*/memo(function PlasmicCss(props) {
|
|
1496
1325
|
var loader = props.loader,
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1326
|
+
prefetchedData = props.prefetchedData,
|
|
1327
|
+
skipFonts = props.skipFonts;
|
|
1500
1328
|
var _React$useState2 = useState(!!prefetchedData),
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1329
|
+
useScopedCss = _React$useState2[0],
|
|
1330
|
+
setUseScopedCss = _React$useState2[1];
|
|
1504
1331
|
var builtCss = buildCss(loader, {
|
|
1505
1332
|
scopedCompMetas: useScopedCss && prefetchedData ? prefetchedData.bundle.components : undefined,
|
|
1506
1333
|
skipFonts: skipFonts
|
|
@@ -1527,35 +1354,30 @@ var PlasmicCss = /*#__PURE__*/memo(function PlasmicCss(props) {
|
|
|
1527
1354
|
}
|
|
1528
1355
|
});
|
|
1529
1356
|
});
|
|
1530
|
-
|
|
1531
1357
|
function buildCss(loader, opts) {
|
|
1532
1358
|
var scopedCompMetas = opts.scopedCompMetas,
|
|
1533
|
-
|
|
1359
|
+
skipFonts = opts.skipFonts;
|
|
1534
1360
|
var cssFiles = scopedCompMetas && new Set(['entrypoint.css'].concat(scopedCompMetas.map(function (c) {
|
|
1535
1361
|
return c.cssFile;
|
|
1536
1362
|
})));
|
|
1537
1363
|
var cssModules = loader.getLookup().getCss().filter(function (f) {
|
|
1538
1364
|
return !cssFiles || cssFiles.has(f.fileName);
|
|
1539
1365
|
});
|
|
1540
|
-
|
|
1541
1366
|
var getPri = function getPri(fileName) {
|
|
1542
1367
|
return fileName === 'entrypoint.css' ? 0 : 1;
|
|
1543
1368
|
};
|
|
1544
|
-
|
|
1545
1369
|
var compareModules = function compareModules(a, b) {
|
|
1546
1370
|
return getPri(a.fileName) !== getPri(b.fileName) ? getPri(a.fileName) - getPri(b.fileName) : a.fileName.localeCompare(b.fileName);
|
|
1547
1371
|
};
|
|
1548
|
-
|
|
1549
1372
|
cssModules.sort(compareModules);
|
|
1550
|
-
var remoteFonts = loader.getLookup().getRemoteFonts();
|
|
1551
|
-
|
|
1373
|
+
var remoteFonts = loader.getLookup().getRemoteFonts();
|
|
1374
|
+
// Make sure the @import statements come at the front of css
|
|
1552
1375
|
return "\n " + (skipFonts ? '' : remoteFonts.map(function (f) {
|
|
1553
1376
|
return "@import url('" + f.url + "');";
|
|
1554
1377
|
}).join('\n')) + "\n " + cssModules.map(function (mod) {
|
|
1555
1378
|
return mod.source;
|
|
1556
1379
|
}).join('\n') + "\n ";
|
|
1557
1380
|
}
|
|
1558
|
-
|
|
1559
1381
|
function usePlasmicRootContext() {
|
|
1560
1382
|
return useContext(PlasmicRootContext);
|
|
1561
1383
|
}
|
|
@@ -1575,13 +1397,10 @@ function usePlasmicRootContext() {
|
|
|
1575
1397
|
function createUseGlobalVariant(name, projectId) {
|
|
1576
1398
|
return function () {
|
|
1577
1399
|
var _rootContext$globalVa;
|
|
1578
|
-
|
|
1579
1400
|
var rootContext = usePlasmicRootContext();
|
|
1580
|
-
|
|
1581
1401
|
if (!rootContext) {
|
|
1582
1402
|
return undefined;
|
|
1583
1403
|
}
|
|
1584
|
-
|
|
1585
1404
|
var loader = rootContext.loader;
|
|
1586
1405
|
var spec = [].concat(loader.getGlobalVariants(), (_rootContext$globalVa = rootContext.globalVariants) != null ? _rootContext$globalVa : []).find(function (spec) {
|
|
1587
1406
|
return spec.name === name && (!spec.projectId || spec.projectId === projectId);
|
|
@@ -1639,20 +1458,15 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1639
1458
|
}
|
|
1640
1459
|
});
|
|
1641
1460
|
}
|
|
1642
|
-
|
|
1643
1461
|
var _proto = InternalPlasmicComponentLoader.prototype;
|
|
1644
|
-
|
|
1645
1462
|
_proto.setGlobalVariants = function setGlobalVariants(globalVariants) {
|
|
1646
1463
|
this.globalVariants = globalVariants;
|
|
1647
1464
|
};
|
|
1648
|
-
|
|
1649
1465
|
_proto.getGlobalVariants = function getGlobalVariants() {
|
|
1650
1466
|
return this.globalVariants;
|
|
1651
1467
|
};
|
|
1652
|
-
|
|
1653
1468
|
_proto.registerModules = function registerModules(modules) {
|
|
1654
1469
|
var _this = this;
|
|
1655
|
-
|
|
1656
1470
|
if (Object.keys(modules).some(function (name) {
|
|
1657
1471
|
return _this.registry.getRegisteredModule(name) !== modules[name];
|
|
1658
1472
|
})) {
|
|
@@ -1660,72 +1474,59 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1660
1474
|
console.warn('Calling PlasmicComponentLoader.registerModules() after Plasmic component has rendered; starting over.');
|
|
1661
1475
|
this.registry.clear();
|
|
1662
1476
|
}
|
|
1663
|
-
|
|
1664
1477
|
for (var _i = 0, _Object$keys = Object.keys(modules); _i < _Object$keys.length; _i++) {
|
|
1665
1478
|
var key = _Object$keys[_i];
|
|
1666
1479
|
this.registry.register(key, modules[key]);
|
|
1667
1480
|
}
|
|
1668
1481
|
}
|
|
1669
1482
|
};
|
|
1670
|
-
|
|
1671
1483
|
_proto.substituteComponent = function substituteComponent(component, name) {
|
|
1672
1484
|
if (!this.registry.isEmpty()) {
|
|
1673
1485
|
console.warn('Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over.');
|
|
1674
1486
|
this.registry.clear();
|
|
1675
1487
|
}
|
|
1676
|
-
|
|
1677
1488
|
this.subs.push({
|
|
1678
1489
|
lookup: name,
|
|
1679
1490
|
component: component
|
|
1680
1491
|
});
|
|
1681
1492
|
};
|
|
1682
|
-
|
|
1683
1493
|
_proto.registerComponent = function registerComponent$1(component, meta) {
|
|
1684
1494
|
var _meta$importPath;
|
|
1685
|
-
|
|
1686
1495
|
this.substituteComponent(component, {
|
|
1687
1496
|
name: meta.name,
|
|
1688
1497
|
isCode: true
|
|
1689
|
-
});
|
|
1690
|
-
|
|
1498
|
+
});
|
|
1499
|
+
// Import path is not used as we will use component substitution
|
|
1691
1500
|
registerComponent(component, _extends({}, meta, {
|
|
1692
1501
|
importPath: (_meta$importPath = meta.importPath) != null ? _meta$importPath : ''
|
|
1693
1502
|
}));
|
|
1694
1503
|
};
|
|
1695
|
-
|
|
1696
1504
|
_proto.registerGlobalContext = function registerGlobalContext$1(context, meta) {
|
|
1697
1505
|
var _meta$importPath2;
|
|
1698
|
-
|
|
1699
1506
|
this.substituteComponent(context, {
|
|
1700
1507
|
name: meta.name,
|
|
1701
1508
|
isCode: true
|
|
1702
|
-
});
|
|
1703
|
-
|
|
1509
|
+
});
|
|
1510
|
+
// Import path is not used as we will use component substitution
|
|
1704
1511
|
registerGlobalContext(context, _extends({}, meta, {
|
|
1705
1512
|
importPath: (_meta$importPath2 = meta.importPath) != null ? _meta$importPath2 : ''
|
|
1706
1513
|
}));
|
|
1707
1514
|
};
|
|
1708
|
-
|
|
1709
1515
|
_proto.registerTrait = function registerTrait$1(trait, meta) {
|
|
1710
1516
|
registerTrait(trait, meta);
|
|
1711
1517
|
};
|
|
1712
|
-
|
|
1713
1518
|
_proto.registerPrefetchedBundle = function registerPrefetchedBundle(bundle) {
|
|
1714
1519
|
this.mergeBundle(bundle);
|
|
1715
1520
|
};
|
|
1716
|
-
|
|
1717
1521
|
_proto.subscribePlasmicRoot = function subscribePlasmicRoot(watcher) {
|
|
1718
1522
|
this.roots.push(watcher);
|
|
1719
1523
|
};
|
|
1720
|
-
|
|
1721
1524
|
_proto.unsubscribePlasmicRoot = function unsubscribePlasmicRoot(watcher) {
|
|
1722
1525
|
var index = this.roots.indexOf(watcher);
|
|
1723
|
-
|
|
1724
1526
|
if (index >= 0) {
|
|
1725
1527
|
this.roots.splice(index, 1);
|
|
1726
1528
|
}
|
|
1727
1529
|
};
|
|
1728
|
-
|
|
1729
1530
|
_proto.clearCache = function clearCache() {
|
|
1730
1531
|
this.bundle = {
|
|
1731
1532
|
modules: {
|
|
@@ -1740,38 +1541,31 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1740
1541
|
};
|
|
1741
1542
|
this.registry.clear();
|
|
1742
1543
|
};
|
|
1743
|
-
|
|
1744
1544
|
_proto.maybeGetCompMetas = function maybeGetCompMetas() {
|
|
1745
1545
|
for (var _len = arguments.length, specs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1746
1546
|
specs[_key] = arguments[_key];
|
|
1747
1547
|
}
|
|
1748
|
-
|
|
1749
1548
|
return _maybeGetCompMetas(this.bundle.components, specs);
|
|
1750
1549
|
};
|
|
1751
|
-
|
|
1752
1550
|
_proto.maybeFetchComponentData = /*#__PURE__*/function () {
|
|
1753
1551
|
var _maybeFetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1754
1552
|
var _this2 = this;
|
|
1755
|
-
|
|
1756
1553
|
var _parseFetchComponentD,
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1554
|
+
specs,
|
|
1555
|
+
opts,
|
|
1556
|
+
returnWithSpecsToFetch,
|
|
1557
|
+
_this$maybeGetCompMet,
|
|
1558
|
+
existingMetas,
|
|
1559
|
+
missingSpecs,
|
|
1560
|
+
_args2 = arguments;
|
|
1765
1561
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1766
1562
|
while (1) {
|
|
1767
1563
|
switch (_context2.prev = _context2.next) {
|
|
1768
1564
|
case 0:
|
|
1769
1565
|
_parseFetchComponentD = parseFetchComponentDataArgs.apply(void 0, _args2), specs = _parseFetchComponentD.specs, opts = _parseFetchComponentD.opts;
|
|
1770
|
-
|
|
1771
1566
|
returnWithSpecsToFetch = /*#__PURE__*/function () {
|
|
1772
1567
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(specsToFetch) {
|
|
1773
1568
|
var _this2$maybeGetCompMe, existingMetas2, missingSpecs2;
|
|
1774
|
-
|
|
1775
1569
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1776
1570
|
while (1) {
|
|
1777
1571
|
switch (_context.prev = _context.next) {
|
|
@@ -1780,20 +1574,15 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1780
1574
|
return _this2.fetchMissingData({
|
|
1781
1575
|
missingSpecs: specsToFetch
|
|
1782
1576
|
});
|
|
1783
|
-
|
|
1784
1577
|
case 2:
|
|
1785
1578
|
_this2$maybeGetCompMe = _this2.maybeGetCompMetas.apply(_this2, specs), existingMetas2 = _this2$maybeGetCompMe.found, missingSpecs2 = _this2$maybeGetCompMe.missing;
|
|
1786
|
-
|
|
1787
1579
|
if (!(missingSpecs2.length > 0)) {
|
|
1788
1580
|
_context.next = 5;
|
|
1789
1581
|
break;
|
|
1790
1582
|
}
|
|
1791
|
-
|
|
1792
1583
|
return _context.abrupt("return", null);
|
|
1793
|
-
|
|
1794
1584
|
case 5:
|
|
1795
1585
|
return _context.abrupt("return", prepComponentData(_this2.bundle, existingMetas2, opts));
|
|
1796
|
-
|
|
1797
1586
|
case 6:
|
|
1798
1587
|
case "end":
|
|
1799
1588
|
return _context.stop();
|
|
@@ -1801,41 +1590,31 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1801
1590
|
}
|
|
1802
1591
|
}, _callee);
|
|
1803
1592
|
}));
|
|
1804
|
-
|
|
1805
1593
|
return function returnWithSpecsToFetch(_x) {
|
|
1806
1594
|
return _ref.apply(this, arguments);
|
|
1807
1595
|
};
|
|
1808
1596
|
}();
|
|
1809
|
-
|
|
1810
1597
|
if (!this.opts.alwaysFresh) {
|
|
1811
1598
|
_context2.next = 6;
|
|
1812
1599
|
break;
|
|
1813
1600
|
}
|
|
1814
|
-
|
|
1815
1601
|
_context2.next = 5;
|
|
1816
1602
|
return returnWithSpecsToFetch(specs);
|
|
1817
|
-
|
|
1818
1603
|
case 5:
|
|
1819
1604
|
return _context2.abrupt("return", _context2.sent);
|
|
1820
|
-
|
|
1821
1605
|
case 6:
|
|
1822
1606
|
// Else we only fetch actually missing specs
|
|
1823
1607
|
_this$maybeGetCompMet = this.maybeGetCompMetas.apply(this, specs), existingMetas = _this$maybeGetCompMet.found, missingSpecs = _this$maybeGetCompMet.missing;
|
|
1824
|
-
|
|
1825
1608
|
if (!(missingSpecs.length === 0)) {
|
|
1826
1609
|
_context2.next = 9;
|
|
1827
1610
|
break;
|
|
1828
1611
|
}
|
|
1829
|
-
|
|
1830
1612
|
return _context2.abrupt("return", prepComponentData(this.bundle, existingMetas, opts));
|
|
1831
|
-
|
|
1832
1613
|
case 9:
|
|
1833
1614
|
_context2.next = 11;
|
|
1834
1615
|
return returnWithSpecsToFetch(missingSpecs);
|
|
1835
|
-
|
|
1836
1616
|
case 11:
|
|
1837
1617
|
return _context2.abrupt("return", _context2.sent);
|
|
1838
|
-
|
|
1839
1618
|
case 12:
|
|
1840
1619
|
case "end":
|
|
1841
1620
|
return _context2.stop();
|
|
@@ -1843,24 +1622,20 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1843
1622
|
}
|
|
1844
1623
|
}, _callee2, this);
|
|
1845
1624
|
}));
|
|
1846
|
-
|
|
1847
1625
|
function maybeFetchComponentData() {
|
|
1848
1626
|
return _maybeFetchComponentData.apply(this, arguments);
|
|
1849
1627
|
}
|
|
1850
|
-
|
|
1851
1628
|
return maybeFetchComponentData;
|
|
1852
1629
|
}();
|
|
1853
|
-
|
|
1854
1630
|
_proto.fetchComponentData = /*#__PURE__*/function () {
|
|
1855
1631
|
var _fetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1856
1632
|
var _parseFetchComponentD2,
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1633
|
+
specs,
|
|
1634
|
+
opts,
|
|
1635
|
+
data,
|
|
1636
|
+
_this$maybeGetCompMet2,
|
|
1637
|
+
missingSpecs,
|
|
1638
|
+
_args3 = arguments;
|
|
1864
1639
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1865
1640
|
while (1) {
|
|
1866
1641
|
switch (_context3.prev = _context3.next) {
|
|
@@ -1868,21 +1643,16 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1868
1643
|
_parseFetchComponentD2 = parseFetchComponentDataArgs.apply(void 0, _args3), specs = _parseFetchComponentD2.specs, opts = _parseFetchComponentD2.opts;
|
|
1869
1644
|
_context3.next = 3;
|
|
1870
1645
|
return this.maybeFetchComponentData(specs, opts);
|
|
1871
|
-
|
|
1872
1646
|
case 3:
|
|
1873
1647
|
data = _context3.sent;
|
|
1874
|
-
|
|
1875
1648
|
if (data) {
|
|
1876
1649
|
_context3.next = 7;
|
|
1877
1650
|
break;
|
|
1878
1651
|
}
|
|
1879
|
-
|
|
1880
1652
|
_this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this, specs), missingSpecs = _this$maybeGetCompMet2.missing;
|
|
1881
1653
|
throw new Error("Unable to find components " + missingSpecs.map(getLookupSpecName).join(', '));
|
|
1882
|
-
|
|
1883
1654
|
case 7:
|
|
1884
1655
|
return _context3.abrupt("return", data);
|
|
1885
|
-
|
|
1886
1656
|
case 8:
|
|
1887
1657
|
case "end":
|
|
1888
1658
|
return _context3.stop();
|
|
@@ -1890,14 +1660,11 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1890
1660
|
}
|
|
1891
1661
|
}, _callee3, this);
|
|
1892
1662
|
}));
|
|
1893
|
-
|
|
1894
1663
|
function fetchComponentData() {
|
|
1895
1664
|
return _fetchComponentData.apply(this, arguments);
|
|
1896
1665
|
}
|
|
1897
|
-
|
|
1898
1666
|
return fetchComponentData;
|
|
1899
1667
|
}();
|
|
1900
|
-
|
|
1901
1668
|
_proto.fetchPages = /*#__PURE__*/function () {
|
|
1902
1669
|
var _fetchPages = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(opts) {
|
|
1903
1670
|
var data;
|
|
@@ -1910,13 +1677,11 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1910
1677
|
});
|
|
1911
1678
|
_context4.next = 3;
|
|
1912
1679
|
return this.fetchAllData();
|
|
1913
|
-
|
|
1914
1680
|
case 3:
|
|
1915
1681
|
data = _context4.sent;
|
|
1916
1682
|
return _context4.abrupt("return", data.components.filter(function (comp) {
|
|
1917
1683
|
return comp.isPage && comp.path && ((opts == null ? void 0 : opts.includeDynamicPages) || !isDynamicPagePath(comp.path));
|
|
1918
1684
|
}));
|
|
1919
|
-
|
|
1920
1685
|
case 5:
|
|
1921
1686
|
case "end":
|
|
1922
1687
|
return _context4.stop();
|
|
@@ -1924,14 +1689,11 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1924
1689
|
}
|
|
1925
1690
|
}, _callee4, this);
|
|
1926
1691
|
}));
|
|
1927
|
-
|
|
1928
1692
|
function fetchPages(_x2) {
|
|
1929
1693
|
return _fetchPages.apply(this, arguments);
|
|
1930
1694
|
}
|
|
1931
|
-
|
|
1932
1695
|
return fetchPages;
|
|
1933
1696
|
}();
|
|
1934
|
-
|
|
1935
1697
|
_proto.fetchComponents = /*#__PURE__*/function () {
|
|
1936
1698
|
var _fetchComponents = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
|
|
1937
1699
|
var data;
|
|
@@ -1944,11 +1706,9 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1944
1706
|
});
|
|
1945
1707
|
_context5.next = 3;
|
|
1946
1708
|
return this.fetchAllData();
|
|
1947
|
-
|
|
1948
1709
|
case 3:
|
|
1949
1710
|
data = _context5.sent;
|
|
1950
1711
|
return _context5.abrupt("return", data.components);
|
|
1951
|
-
|
|
1952
1712
|
case 5:
|
|
1953
1713
|
case "end":
|
|
1954
1714
|
return _context5.stop();
|
|
@@ -1956,31 +1716,25 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1956
1716
|
}
|
|
1957
1717
|
}, _callee5, this);
|
|
1958
1718
|
}));
|
|
1959
|
-
|
|
1960
1719
|
function fetchComponents() {
|
|
1961
1720
|
return _fetchComponents.apply(this, arguments);
|
|
1962
1721
|
}
|
|
1963
|
-
|
|
1964
1722
|
return fetchComponents;
|
|
1965
1723
|
}();
|
|
1966
|
-
|
|
1967
1724
|
_proto.getLookup = function getLookup() {
|
|
1968
1725
|
return new ComponentLookup(this.bundle, this.registry);
|
|
1969
1726
|
};
|
|
1970
|
-
|
|
1971
1727
|
_proto.getActiveSplits = function getActiveSplits() {
|
|
1972
1728
|
return this.bundle.activeSplits;
|
|
1973
1729
|
};
|
|
1974
|
-
|
|
1975
1730
|
_proto.trackConversion = function trackConversion(value) {
|
|
1976
1731
|
if (value === void 0) {
|
|
1977
1732
|
value = 0;
|
|
1978
1733
|
}
|
|
1979
|
-
|
|
1980
1734
|
this.tracker.trackConversion(value);
|
|
1981
|
-
}
|
|
1735
|
+
}
|
|
1736
|
+
// @ts-ignore
|
|
1982
1737
|
;
|
|
1983
|
-
|
|
1984
1738
|
_proto.fetchMissingData =
|
|
1985
1739
|
/*#__PURE__*/
|
|
1986
1740
|
function () {
|
|
@@ -1996,7 +1750,6 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1996
1750
|
}).join(', ');
|
|
1997
1751
|
});
|
|
1998
1752
|
return _context6.abrupt("return", this.fetchAllData());
|
|
1999
|
-
|
|
2000
1753
|
case 2:
|
|
2001
1754
|
case "end":
|
|
2002
1755
|
return _context6.stop();
|
|
@@ -2004,18 +1757,14 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2004
1757
|
}
|
|
2005
1758
|
}, _callee6, this);
|
|
2006
1759
|
}));
|
|
2007
|
-
|
|
2008
1760
|
function fetchMissingData(_x3) {
|
|
2009
1761
|
return _fetchMissingData.apply(this, arguments);
|
|
2010
1762
|
}
|
|
2011
|
-
|
|
2012
1763
|
return fetchMissingData;
|
|
2013
1764
|
}();
|
|
2014
|
-
|
|
2015
1765
|
_proto.maybeReportClientSideFetch = function maybeReportClientSideFetch(mkMsg) {
|
|
2016
1766
|
if (isBrowser && this.opts.onClientSideFetch) {
|
|
2017
1767
|
var msg = mkMsg();
|
|
2018
|
-
|
|
2019
1768
|
if (this.opts.onClientSideFetch === 'warn') {
|
|
2020
1769
|
console.warn(msg);
|
|
2021
1770
|
} else {
|
|
@@ -2023,7 +1772,6 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2023
1772
|
}
|
|
2024
1773
|
}
|
|
2025
1774
|
};
|
|
2026
|
-
|
|
2027
1775
|
_proto.getActiveVariation = /*#__PURE__*/function () {
|
|
2028
1776
|
var _getActiveVariation2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(opts) {
|
|
2029
1777
|
return runtime_1.wrap(function _callee7$(_context7) {
|
|
@@ -2032,12 +1780,10 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2032
1780
|
case 0:
|
|
2033
1781
|
_context7.next = 2;
|
|
2034
1782
|
return this.fetchAllData();
|
|
2035
|
-
|
|
2036
1783
|
case 2:
|
|
2037
1784
|
return _context7.abrupt("return", getActiveVariation(_extends({}, opts, {
|
|
2038
1785
|
splits: this.bundle.activeSplits
|
|
2039
1786
|
})));
|
|
2040
|
-
|
|
2041
1787
|
case 3:
|
|
2042
1788
|
case "end":
|
|
2043
1789
|
return _context7.stop();
|
|
@@ -2045,14 +1791,11 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2045
1791
|
}
|
|
2046
1792
|
}, _callee7, this);
|
|
2047
1793
|
}));
|
|
2048
|
-
|
|
2049
1794
|
function getActiveVariation$1(_x4) {
|
|
2050
1795
|
return _getActiveVariation2.apply(this, arguments);
|
|
2051
1796
|
}
|
|
2052
|
-
|
|
2053
1797
|
return getActiveVariation$1;
|
|
2054
1798
|
}();
|
|
2055
|
-
|
|
2056
1799
|
_proto.getTeamIds = function getTeamIds() {
|
|
2057
1800
|
return uniq(this.bundle.projects.map(function (p) {
|
|
2058
1801
|
return p.teamId ? "" + p.teamId + (p.indirect ? '@indirect' : '') : null;
|
|
@@ -2060,17 +1803,14 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2060
1803
|
return !!x;
|
|
2061
1804
|
}));
|
|
2062
1805
|
};
|
|
2063
|
-
|
|
2064
1806
|
_proto.getProjectIds = function getProjectIds() {
|
|
2065
1807
|
return uniq(this.bundle.projects.map(function (p) {
|
|
2066
1808
|
return "" + p.id + (p.indirect ? '@indirect' : '');
|
|
2067
1809
|
}));
|
|
2068
1810
|
};
|
|
2069
|
-
|
|
2070
1811
|
_proto.trackRender = function trackRender(opts) {
|
|
2071
1812
|
this.tracker.trackRender(opts);
|
|
2072
1813
|
};
|
|
2073
|
-
|
|
2074
1814
|
_proto.fetchAllData = /*#__PURE__*/function () {
|
|
2075
1815
|
var _fetchAllData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
2076
1816
|
var bundle;
|
|
@@ -2080,7 +1820,6 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2080
1820
|
case 0:
|
|
2081
1821
|
_context8.next = 2;
|
|
2082
1822
|
return this.ensureFetcher().fetchAllData();
|
|
2083
|
-
|
|
2084
1823
|
case 2:
|
|
2085
1824
|
bundle = _context8.sent;
|
|
2086
1825
|
this.tracker.trackFetch();
|
|
@@ -2089,7 +1828,6 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2089
1828
|
return watcher.onDataFetched == null ? void 0 : watcher.onDataFetched();
|
|
2090
1829
|
});
|
|
2091
1830
|
return _context8.abrupt("return", bundle);
|
|
2092
|
-
|
|
2093
1831
|
case 7:
|
|
2094
1832
|
case "end":
|
|
2095
1833
|
return _context8.stop();
|
|
@@ -2097,22 +1835,17 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2097
1835
|
}
|
|
2098
1836
|
}, _callee8, this);
|
|
2099
1837
|
}));
|
|
2100
|
-
|
|
2101
1838
|
function fetchAllData() {
|
|
2102
1839
|
return _fetchAllData.apply(this, arguments);
|
|
2103
1840
|
}
|
|
2104
|
-
|
|
2105
1841
|
return fetchAllData;
|
|
2106
1842
|
}();
|
|
2107
|
-
|
|
2108
1843
|
_proto.mergeBundle = function mergeBundle(bundle) {
|
|
2109
1844
|
this.bundle = mergeBundles(bundle, this.bundle);
|
|
2110
1845
|
this.refreshRegistry();
|
|
2111
1846
|
};
|
|
2112
|
-
|
|
2113
1847
|
_proto.refreshRegistry = function refreshRegistry() {
|
|
2114
1848
|
var _this3 = this;
|
|
2115
|
-
|
|
2116
1849
|
var _loop = function _loop() {
|
|
2117
1850
|
var sub = _step.value;
|
|
2118
1851
|
var metas = getCompMetas(_this3.bundle.components, sub.lookup);
|
|
@@ -2120,51 +1853,41 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2120
1853
|
_this3.substitutedComponents[meta.id] = sub.component;
|
|
2121
1854
|
});
|
|
2122
1855
|
};
|
|
2123
|
-
|
|
2124
1856
|
// Once we have received data, we register components to
|
|
2125
1857
|
// substitute. We had to wait for data to do this so
|
|
2126
1858
|
// that we can look up the right module name to substitute
|
|
2127
1859
|
// in component meta.
|
|
2128
1860
|
for (var _iterator = _createForOfIteratorHelperLoose(this.subs), _step; !(_step = _iterator()).done;) {
|
|
2129
1861
|
_loop();
|
|
2130
|
-
}
|
|
1862
|
+
}
|
|
1863
|
+
// We also swap global variants' useXXXGlobalVariant() hook with
|
|
2131
1864
|
// a fake one that just reads from the PlasmicRootContext. Because
|
|
2132
1865
|
// global variant values are not supplied by the generated global variant
|
|
2133
1866
|
// context providers, but instead by <PlasmicRootProvider/> and by
|
|
2134
1867
|
// PlasmicComponentLoader.setGlobalVariants(), we redirect these
|
|
2135
1868
|
// hooks to read from them instead.
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
1869
|
for (var _iterator2 = _createForOfIteratorHelperLoose(this.bundle.globalGroups), _step2; !(_step2 = _iterator2()).done;) {
|
|
2139
1870
|
var globalGroup = _step2.value;
|
|
2140
|
-
|
|
2141
1871
|
if (globalGroup.type !== 'global-screen') {
|
|
2142
1872
|
this.substitutedGlobalVariantHooks[globalGroup.id] = createUseGlobalVariant(globalGroup.name, globalGroup.projectId);
|
|
2143
1873
|
}
|
|
2144
1874
|
}
|
|
2145
|
-
|
|
2146
1875
|
this.registry.updateModules(this.bundle);
|
|
2147
1876
|
};
|
|
2148
|
-
|
|
2149
1877
|
_proto.ensureFetcher = function ensureFetcher() {
|
|
2150
1878
|
if (!this.fetcher) {
|
|
2151
1879
|
throw new Error("You must first call PlasmicComponentLoader.init()");
|
|
2152
1880
|
}
|
|
2153
|
-
|
|
2154
1881
|
return this.fetcher;
|
|
2155
1882
|
};
|
|
2156
|
-
|
|
2157
1883
|
return InternalPlasmicComponentLoader;
|
|
2158
1884
|
}();
|
|
2159
|
-
|
|
2160
1885
|
function _maybeGetCompMetas(metas, specs) {
|
|
2161
1886
|
var found = new Set();
|
|
2162
1887
|
var missing = [];
|
|
2163
|
-
|
|
2164
1888
|
for (var _iterator3 = _createForOfIteratorHelperLoose(specs), _step3; !(_step3 = _iterator3()).done;) {
|
|
2165
1889
|
var spec = _step3.value;
|
|
2166
1890
|
var filteredMetas = getCompMetas(metas, spec);
|
|
2167
|
-
|
|
2168
1891
|
if (filteredMetas.length > 0) {
|
|
2169
1892
|
filteredMetas.forEach(function (meta) {
|
|
2170
1893
|
return found.add(meta);
|
|
@@ -2173,7 +1896,6 @@ function _maybeGetCompMetas(metas, specs) {
|
|
|
2173
1896
|
missing.push(spec);
|
|
2174
1897
|
}
|
|
2175
1898
|
}
|
|
2176
|
-
|
|
2177
1899
|
return {
|
|
2178
1900
|
found: Array.from(found.keys()),
|
|
2179
1901
|
missing: missing
|
|
@@ -2183,8 +1905,6 @@ function _maybeGetCompMetas(metas, specs) {
|
|
|
2183
1905
|
* Library for fetching component data, and registering
|
|
2184
1906
|
* custom components.
|
|
2185
1907
|
*/
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
1908
|
var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
2189
1909
|
function PlasmicComponentLoader(internal) {
|
|
2190
1910
|
this.warnedRegisterComponent = false;
|
|
@@ -2198,14 +1918,10 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2198
1918
|
* app. If you'd like to reactively change the global variants,
|
|
2199
1919
|
* you should specify them via <PlasmicRootProvider />
|
|
2200
1920
|
*/
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
1921
|
var _proto2 = PlasmicComponentLoader.prototype;
|
|
2204
|
-
|
|
2205
1922
|
_proto2.setGlobalVariants = function setGlobalVariants(globalVariants) {
|
|
2206
1923
|
this.__internal.setGlobalVariants(globalVariants);
|
|
2207
1924
|
};
|
|
2208
|
-
|
|
2209
1925
|
_proto2.registerModules = function registerModules(modules) {
|
|
2210
1926
|
this.__internal.registerModules(modules);
|
|
2211
1927
|
}
|
|
@@ -2213,13 +1929,10 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2213
1929
|
* Register custom components that should be swapped in for
|
|
2214
1930
|
* components defined in your project. You can use this to
|
|
2215
1931
|
* swap in / substitute a Plasmic component with a "real" component.
|
|
2216
|
-
|
|
2217
|
-
;
|
|
2218
|
-
|
|
1932
|
+
*/;
|
|
2219
1933
|
_proto2.substituteComponent = function substituteComponent(component, name) {
|
|
2220
1934
|
this.__internal.substituteComponent(component, name);
|
|
2221
1935
|
};
|
|
2222
|
-
|
|
2223
1936
|
_proto2.registerComponent = function registerComponent(component, metaOrName) {
|
|
2224
1937
|
// 'props' is a required field in CodeComponentMeta
|
|
2225
1938
|
if (metaOrName && typeof metaOrName === 'object' && 'props' in metaOrName) {
|
|
@@ -2230,15 +1943,12 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2230
1943
|
console.warn("PlasmicLoader: Using deprecated method `registerComponent` for component substitution. " + "Please consider using `substituteComponent` instead.");
|
|
2231
1944
|
this.warnedRegisterComponent = true;
|
|
2232
1945
|
}
|
|
2233
|
-
|
|
2234
1946
|
this.substituteComponent(component, metaOrName);
|
|
2235
1947
|
}
|
|
2236
1948
|
};
|
|
2237
|
-
|
|
2238
1949
|
_proto2.registerGlobalContext = function registerGlobalContext(context, meta) {
|
|
2239
1950
|
this.__internal.registerGlobalContext(context, meta);
|
|
2240
1951
|
};
|
|
2241
|
-
|
|
2242
1952
|
_proto2.registerTrait = function registerTrait(trait, meta) {
|
|
2243
1953
|
this.__internal.registerTrait(trait, meta);
|
|
2244
1954
|
}
|
|
@@ -2256,22 +1966,18 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2256
1966
|
*
|
|
2257
1967
|
* Throws an Error if a specified component to fetch does not exist in
|
|
2258
1968
|
* the Plasmic project.
|
|
2259
|
-
|
|
2260
|
-
;
|
|
2261
|
-
|
|
1969
|
+
*/;
|
|
2262
1970
|
_proto2.fetchComponentData =
|
|
2263
1971
|
/*#__PURE__*/
|
|
2264
1972
|
function () {
|
|
2265
1973
|
var _fetchComponentData2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9() {
|
|
2266
1974
|
var _this$__internal;
|
|
2267
|
-
|
|
2268
1975
|
var _args9 = arguments;
|
|
2269
1976
|
return runtime_1.wrap(function _callee9$(_context9) {
|
|
2270
1977
|
while (1) {
|
|
2271
1978
|
switch (_context9.prev = _context9.next) {
|
|
2272
1979
|
case 0:
|
|
2273
1980
|
return _context9.abrupt("return", (_this$__internal = this.__internal).fetchComponentData.apply(_this$__internal, _args9));
|
|
2274
|
-
|
|
2275
1981
|
case 1:
|
|
2276
1982
|
case "end":
|
|
2277
1983
|
return _context9.stop();
|
|
@@ -2279,11 +1985,9 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2279
1985
|
}
|
|
2280
1986
|
}, _callee9, this);
|
|
2281
1987
|
}));
|
|
2282
|
-
|
|
2283
1988
|
function fetchComponentData() {
|
|
2284
1989
|
return _fetchComponentData2.apply(this, arguments);
|
|
2285
1990
|
}
|
|
2286
|
-
|
|
2287
1991
|
return fetchComponentData;
|
|
2288
1992
|
}()
|
|
2289
1993
|
/**
|
|
@@ -2292,20 +1996,17 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2292
1996
|
* page and want to check if a specific path had been defined for Plasmic.
|
|
2293
1997
|
*/
|
|
2294
1998
|
;
|
|
2295
|
-
|
|
2296
1999
|
_proto2.maybeFetchComponentData =
|
|
2297
2000
|
/*#__PURE__*/
|
|
2298
2001
|
function () {
|
|
2299
2002
|
var _maybeFetchComponentData2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10() {
|
|
2300
2003
|
var _this$__internal2;
|
|
2301
|
-
|
|
2302
2004
|
var _args10 = arguments;
|
|
2303
2005
|
return runtime_1.wrap(function _callee10$(_context10) {
|
|
2304
2006
|
while (1) {
|
|
2305
2007
|
switch (_context10.prev = _context10.next) {
|
|
2306
2008
|
case 0:
|
|
2307
2009
|
return _context10.abrupt("return", (_this$__internal2 = this.__internal).maybeFetchComponentData.apply(_this$__internal2, _args10));
|
|
2308
|
-
|
|
2309
2010
|
case 1:
|
|
2310
2011
|
case "end":
|
|
2311
2012
|
return _context10.stop();
|
|
@@ -2313,18 +2014,15 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2313
2014
|
}
|
|
2314
2015
|
}, _callee10, this);
|
|
2315
2016
|
}));
|
|
2316
|
-
|
|
2317
2017
|
function maybeFetchComponentData() {
|
|
2318
2018
|
return _maybeFetchComponentData2.apply(this, arguments);
|
|
2319
2019
|
}
|
|
2320
|
-
|
|
2321
2020
|
return maybeFetchComponentData;
|
|
2322
2021
|
}()
|
|
2323
2022
|
/**
|
|
2324
2023
|
* Returns all the page component metadata for these projects.
|
|
2325
2024
|
*/
|
|
2326
2025
|
;
|
|
2327
|
-
|
|
2328
2026
|
_proto2.fetchPages =
|
|
2329
2027
|
/*#__PURE__*/
|
|
2330
2028
|
function () {
|
|
@@ -2334,7 +2032,6 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2334
2032
|
switch (_context11.prev = _context11.next) {
|
|
2335
2033
|
case 0:
|
|
2336
2034
|
return _context11.abrupt("return", this.__internal.fetchPages(opts));
|
|
2337
|
-
|
|
2338
2035
|
case 1:
|
|
2339
2036
|
case "end":
|
|
2340
2037
|
return _context11.stop();
|
|
@@ -2342,18 +2039,15 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2342
2039
|
}
|
|
2343
2040
|
}, _callee11, this);
|
|
2344
2041
|
}));
|
|
2345
|
-
|
|
2346
2042
|
function fetchPages(_x5) {
|
|
2347
2043
|
return _fetchPages2.apply(this, arguments);
|
|
2348
2044
|
}
|
|
2349
|
-
|
|
2350
2045
|
return fetchPages;
|
|
2351
2046
|
}()
|
|
2352
2047
|
/**
|
|
2353
2048
|
* Returns all components metadata for these projects.
|
|
2354
2049
|
*/
|
|
2355
2050
|
;
|
|
2356
|
-
|
|
2357
2051
|
_proto2.fetchComponents =
|
|
2358
2052
|
/*#__PURE__*/
|
|
2359
2053
|
function () {
|
|
@@ -2363,7 +2057,6 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2363
2057
|
switch (_context12.prev = _context12.next) {
|
|
2364
2058
|
case 0:
|
|
2365
2059
|
return _context12.abrupt("return", this.__internal.fetchComponents());
|
|
2366
|
-
|
|
2367
2060
|
case 1:
|
|
2368
2061
|
case "end":
|
|
2369
2062
|
return _context12.stop();
|
|
@@ -2371,14 +2064,11 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2371
2064
|
}
|
|
2372
2065
|
}, _callee12, this);
|
|
2373
2066
|
}));
|
|
2374
|
-
|
|
2375
2067
|
function fetchComponents() {
|
|
2376
2068
|
return _fetchComponents2.apply(this, arguments);
|
|
2377
2069
|
}
|
|
2378
|
-
|
|
2379
2070
|
return fetchComponents;
|
|
2380
2071
|
}();
|
|
2381
|
-
|
|
2382
2072
|
_proto2._getActiveVariation = /*#__PURE__*/function () {
|
|
2383
2073
|
var _getActiveVariation3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(opts) {
|
|
2384
2074
|
return runtime_1.wrap(function _callee13$(_context13) {
|
|
@@ -2386,7 +2076,6 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2386
2076
|
switch (_context13.prev = _context13.next) {
|
|
2387
2077
|
case 0:
|
|
2388
2078
|
return _context13.abrupt("return", this.__internal.getActiveVariation(opts));
|
|
2389
|
-
|
|
2390
2079
|
case 1:
|
|
2391
2080
|
case "end":
|
|
2392
2081
|
return _context13.stop();
|
|
@@ -2394,14 +2083,11 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2394
2083
|
}
|
|
2395
2084
|
}, _callee13, this);
|
|
2396
2085
|
}));
|
|
2397
|
-
|
|
2398
2086
|
function _getActiveVariation(_x6) {
|
|
2399
2087
|
return _getActiveVariation3.apply(this, arguments);
|
|
2400
2088
|
}
|
|
2401
|
-
|
|
2402
2089
|
return _getActiveVariation;
|
|
2403
2090
|
}();
|
|
2404
|
-
|
|
2405
2091
|
_proto2.getActiveVariation = /*#__PURE__*/function () {
|
|
2406
2092
|
var _getActiveVariation4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(opts) {
|
|
2407
2093
|
return runtime_1.wrap(function _callee14$(_context14) {
|
|
@@ -2424,7 +2110,6 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2424
2110
|
}
|
|
2425
2111
|
}
|
|
2426
2112
|
}));
|
|
2427
|
-
|
|
2428
2113
|
case 1:
|
|
2429
2114
|
case "end":
|
|
2430
2115
|
return _context14.stop();
|
|
@@ -2432,45 +2117,34 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2432
2117
|
}
|
|
2433
2118
|
}, _callee14, this);
|
|
2434
2119
|
}));
|
|
2435
|
-
|
|
2436
2120
|
function getActiveVariation(_x7) {
|
|
2437
2121
|
return _getActiveVariation4.apply(this, arguments);
|
|
2438
2122
|
}
|
|
2439
|
-
|
|
2440
2123
|
return getActiveVariation;
|
|
2441
2124
|
}();
|
|
2442
|
-
|
|
2443
2125
|
_proto2.getExternalVariation = function getExternalVariation(variation) {
|
|
2444
2126
|
return getExternalIds(this.getActiveSplits(), variation);
|
|
2445
2127
|
};
|
|
2446
|
-
|
|
2447
2128
|
_proto2.getActiveSplits = function getActiveSplits() {
|
|
2448
2129
|
return this.__internal.getActiveSplits();
|
|
2449
2130
|
};
|
|
2450
|
-
|
|
2451
2131
|
_proto2.trackConversion = function trackConversion(value) {
|
|
2452
2132
|
if (value === void 0) {
|
|
2453
2133
|
value = 0;
|
|
2454
2134
|
}
|
|
2455
|
-
|
|
2456
2135
|
this.__internal.trackConversion(value);
|
|
2457
2136
|
};
|
|
2458
|
-
|
|
2459
2137
|
_proto2.clearCache = function clearCache() {
|
|
2460
2138
|
return this.__internal.clearCache();
|
|
2461
2139
|
};
|
|
2462
|
-
|
|
2463
2140
|
return PlasmicComponentLoader;
|
|
2464
2141
|
}();
|
|
2465
|
-
|
|
2466
2142
|
function parseFetchComponentDataArgs() {
|
|
2467
2143
|
var specs;
|
|
2468
2144
|
var opts;
|
|
2469
|
-
|
|
2470
2145
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2471
2146
|
args[_key2] = arguments[_key2];
|
|
2472
2147
|
}
|
|
2473
|
-
|
|
2474
2148
|
if (Array.isArray(args[0])) {
|
|
2475
2149
|
specs = args[0];
|
|
2476
2150
|
opts = args[1];
|
|
@@ -2478,7 +2152,6 @@ function parseFetchComponentDataArgs() {
|
|
|
2478
2152
|
specs = args;
|
|
2479
2153
|
opts = undefined;
|
|
2480
2154
|
}
|
|
2481
|
-
|
|
2482
2155
|
return {
|
|
2483
2156
|
specs: specs,
|
|
2484
2157
|
opts: opts
|
|
@@ -2495,18 +2168,14 @@ function parseFetchComponentDataArgs() {
|
|
|
2495
2168
|
* You can set forceOriginal to true if you want to return the Plasmic-generated
|
|
2496
2169
|
* component instead.
|
|
2497
2170
|
*/
|
|
2498
|
-
|
|
2499
2171
|
function usePlasmicComponent(spec, opts) {
|
|
2500
2172
|
if (opts === void 0) {
|
|
2501
2173
|
opts = {};
|
|
2502
2174
|
}
|
|
2503
|
-
|
|
2504
2175
|
var rootContext = usePlasmicRootContext();
|
|
2505
|
-
|
|
2506
2176
|
if (!rootContext) {
|
|
2507
2177
|
throw new Error("You can only use usePlasmicComponent if wrapped in <PlasmicRootProvider />");
|
|
2508
2178
|
}
|
|
2509
|
-
|
|
2510
2179
|
var loader = rootContext.loader;
|
|
2511
2180
|
var lookup = loader.getLookup();
|
|
2512
2181
|
var component = lookup.hasComponent(spec) ? lookup.getComponent(spec, opts) : undefined;
|
|
@@ -2522,12 +2191,10 @@ function usePlasmicComponent(spec, opts) {
|
|
|
2522
2191
|
case 0:
|
|
2523
2192
|
_context.next = 2;
|
|
2524
2193
|
return loader.fetchComponentData(stableSpec);
|
|
2525
|
-
|
|
2526
2194
|
case 2:
|
|
2527
2195
|
if (isMounted()) {
|
|
2528
2196
|
forceUpdate();
|
|
2529
2197
|
}
|
|
2530
|
-
|
|
2531
2198
|
case 3:
|
|
2532
2199
|
case "end":
|
|
2533
2200
|
return _context.stop();
|
|
@@ -2540,27 +2207,25 @@ function usePlasmicComponent(spec, opts) {
|
|
|
2540
2207
|
return component;
|
|
2541
2208
|
}
|
|
2542
2209
|
|
|
2543
|
-
var _excluded = ["loader", "globalContextsProps", "variation", "userAuthToken"];
|
|
2210
|
+
var _excluded = ["loader", "globalContextsProps", "variation", "userAuthToken", "isUserLoading"];
|
|
2544
2211
|
var PlasmicComponentContext = /*#__PURE__*/createContext(false);
|
|
2545
2212
|
function PlasmicComponent(props) {
|
|
2546
2213
|
var component = props.component,
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2214
|
+
projectId = props.projectId,
|
|
2215
|
+
componentProps = props.componentProps,
|
|
2216
|
+
forceOriginal = props.forceOriginal;
|
|
2550
2217
|
var rootContext = usePlasmicRootContext();
|
|
2551
2218
|
var isRootLoader = !useContext(PlasmicComponentContext);
|
|
2552
|
-
|
|
2553
2219
|
if (!rootContext) {
|
|
2554
2220
|
// no existing PlasmicRootProvider
|
|
2555
2221
|
throw new Error("You must use <PlasmicRootProvider/> at the root of your app");
|
|
2556
2222
|
}
|
|
2557
|
-
|
|
2558
2223
|
var loader = rootContext.loader,
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2224
|
+
globalContextsProps = rootContext.globalContextsProps,
|
|
2225
|
+
variation = rootContext.variation,
|
|
2226
|
+
userAuthToken = rootContext.userAuthToken,
|
|
2227
|
+
isUserLoading = rootContext.isUserLoading,
|
|
2228
|
+
rest = _objectWithoutPropertiesLoose(rootContext, _excluded);
|
|
2564
2229
|
var Component = usePlasmicComponent({
|
|
2565
2230
|
name: component,
|
|
2566
2231
|
projectId: projectId,
|
|
@@ -2574,7 +2239,6 @@ function PlasmicComponent(props) {
|
|
|
2574
2239
|
name: component,
|
|
2575
2240
|
projectId: projectId
|
|
2576
2241
|
});
|
|
2577
|
-
|
|
2578
2242
|
if (meta) {
|
|
2579
2243
|
loader.trackRender({
|
|
2580
2244
|
renderCtx: {
|
|
@@ -2593,9 +2257,7 @@ function PlasmicComponent(props) {
|
|
|
2593
2257
|
if (!Component) {
|
|
2594
2258
|
return null;
|
|
2595
2259
|
}
|
|
2596
|
-
|
|
2597
2260
|
var element = createElement(Component, Object.assign({}, componentProps));
|
|
2598
|
-
|
|
2599
2261
|
if (isRootLoader) {
|
|
2600
2262
|
// If this is the root PlasmicComponent, then wrap the content with the
|
|
2601
2263
|
// react-web's PlasmicRootProvider. We are doing this here, instead of
|
|
@@ -2611,7 +2273,10 @@ function PlasmicComponent(props) {
|
|
|
2611
2273
|
name: component,
|
|
2612
2274
|
projectId: projectId
|
|
2613
2275
|
});
|
|
2614
|
-
element = createElement(ReactWebRootProvider, Object.assign({}, rest
|
|
2276
|
+
element = createElement(ReactWebRootProvider, Object.assign({}, rest, {
|
|
2277
|
+
userAuthToken: userAuthToken,
|
|
2278
|
+
isUserLoading: isUserLoading
|
|
2279
|
+
}), createElement(MaybeWrap, {
|
|
2615
2280
|
cond: !!GlobalContextsProvider,
|
|
2616
2281
|
wrapper: function wrapper(children) {
|
|
2617
2282
|
return createElement(GlobalContextsProvider, Object.assign({}, globalContextsProps), children);
|
|
@@ -2620,12 +2285,10 @@ function PlasmicComponent(props) {
|
|
|
2620
2285
|
value: true
|
|
2621
2286
|
}, element)));
|
|
2622
2287
|
}
|
|
2623
|
-
|
|
2624
2288
|
return element;
|
|
2625
|
-
}, [Component, componentProps, loader, isRootLoader, component, projectId, globalContextsProps, userAuthToken]);
|
|
2289
|
+
}, [Component, componentProps, loader, isRootLoader, component, projectId, globalContextsProps, userAuthToken, isUserLoading]);
|
|
2626
2290
|
return element;
|
|
2627
2291
|
}
|
|
2628
|
-
|
|
2629
2292
|
function MaybeWrap(props) {
|
|
2630
2293
|
return props.cond ? props.wrapper(props.children) : props.children;
|
|
2631
2294
|
}
|
|
@@ -2666,7 +2329,6 @@ function MaybeWrap(props) {
|
|
|
2666
2329
|
* in this element tree.
|
|
2667
2330
|
* @returns an object mapping query key to fetched data
|
|
2668
2331
|
*/
|
|
2669
|
-
|
|
2670
2332
|
function extractPlasmicQueryData(_x) {
|
|
2671
2333
|
return _extractPlasmicQueryData.apply(this, arguments);
|
|
2672
2334
|
}
|
|
@@ -2674,7 +2336,6 @@ function extractPlasmicQueryData(_x) {
|
|
|
2674
2336
|
* Runs react-ssr-prepass on `element`, while isolating rendering errors
|
|
2675
2337
|
* as much as possible for each PlasmicComponent instance.
|
|
2676
2338
|
*/
|
|
2677
|
-
|
|
2678
2339
|
function _extractPlasmicQueryData() {
|
|
2679
2340
|
_extractPlasmicQueryData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(element) {
|
|
2680
2341
|
var cache, queryCache;
|
|
@@ -2688,32 +2349,27 @@ function _extractPlasmicQueryData() {
|
|
|
2688
2349
|
return plasmicPrepass(React__default.createElement(PlasmicPrepassContext, {
|
|
2689
2350
|
cache: cache
|
|
2690
2351
|
}, element));
|
|
2691
|
-
|
|
2692
2352
|
case 4:
|
|
2693
2353
|
_context.next = 9;
|
|
2694
2354
|
break;
|
|
2695
|
-
|
|
2696
2355
|
case 6:
|
|
2697
2356
|
_context.prev = 6;
|
|
2698
2357
|
_context.t0 = _context["catch"](1);
|
|
2699
2358
|
console.warn("PLASMIC: Error encountered while pre-rendering", _context.t0);
|
|
2700
|
-
|
|
2701
2359
|
case 9:
|
|
2702
2360
|
queryCache = Object.fromEntries(Array.from(cache.entries()).filter(function (_ref3) {
|
|
2703
2361
|
var key = _ref3[0],
|
|
2704
|
-
|
|
2362
|
+
val = _ref3[1];
|
|
2705
2363
|
return !key.startsWith('$swr$') && val !== undefined;
|
|
2706
2364
|
}));
|
|
2707
2365
|
_context.prev = 10;
|
|
2708
2366
|
return _context.abrupt("return", JSON.parse(JSON.stringify(queryCache, function (key, value) {
|
|
2709
2367
|
return value !== undefined ? value : null;
|
|
2710
2368
|
})));
|
|
2711
|
-
|
|
2712
2369
|
case 14:
|
|
2713
2370
|
_context.prev = 14;
|
|
2714
2371
|
_context.t1 = _context["catch"](10);
|
|
2715
2372
|
return _context.abrupt("return", queryCache);
|
|
2716
|
-
|
|
2717
2373
|
case 17:
|
|
2718
2374
|
case "end":
|
|
2719
2375
|
return _context.stop();
|
|
@@ -2723,7 +2379,6 @@ function _extractPlasmicQueryData() {
|
|
|
2723
2379
|
}));
|
|
2724
2380
|
return _extractPlasmicQueryData.apply(this, arguments);
|
|
2725
2381
|
}
|
|
2726
|
-
|
|
2727
2382
|
function plasmicPrepass(_x2) {
|
|
2728
2383
|
return _plasmicPrepass.apply(this, arguments);
|
|
2729
2384
|
}
|
|
@@ -2733,7 +2388,6 @@ function plasmicPrepass(_x2) {
|
|
|
2733
2388
|
* an error boundary. Makes it possible to isolate rendering errors while still
|
|
2734
2389
|
* finishing as much data fetched as possible.
|
|
2735
2390
|
*/
|
|
2736
|
-
|
|
2737
2391
|
function _plasmicPrepass() {
|
|
2738
2392
|
_plasmicPrepass = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(element) {
|
|
2739
2393
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
@@ -2742,7 +2396,6 @@ function _plasmicPrepass() {
|
|
|
2742
2396
|
case 0:
|
|
2743
2397
|
_context2.next = 2;
|
|
2744
2398
|
return prepass(buildPlasmicPrepassElement(element));
|
|
2745
|
-
|
|
2746
2399
|
case 2:
|
|
2747
2400
|
case "end":
|
|
2748
2401
|
return _context2.stop();
|
|
@@ -2752,11 +2405,9 @@ function _plasmicPrepass() {
|
|
|
2752
2405
|
}));
|
|
2753
2406
|
return _plasmicPrepass.apply(this, arguments);
|
|
2754
2407
|
}
|
|
2755
|
-
|
|
2756
2408
|
function buildPlasmicPrepassElement(element) {
|
|
2757
2409
|
return React__default.createElement(GenericErrorBoundary, null, processReactElement(element));
|
|
2758
2410
|
}
|
|
2759
|
-
|
|
2760
2411
|
function processReactElement(element) {
|
|
2761
2412
|
if (element.type === PlasmicComponent) {
|
|
2762
2413
|
return React__default.cloneElement(element, processPlasmicComponentProps(element.props));
|
|
@@ -2764,44 +2415,34 @@ function processReactElement(element) {
|
|
|
2764
2415
|
return React__default.cloneElement(element, processComponentProps(element.props));
|
|
2765
2416
|
}
|
|
2766
2417
|
}
|
|
2767
|
-
|
|
2768
2418
|
function processComponentProps(props) {
|
|
2769
2419
|
if (!props || typeof props !== 'object') {
|
|
2770
2420
|
return props;
|
|
2771
2421
|
}
|
|
2772
|
-
|
|
2773
2422
|
return Object.fromEntries(Object.entries(props).map(function (_ref) {
|
|
2774
2423
|
var k = _ref[0],
|
|
2775
|
-
|
|
2424
|
+
v = _ref[1];
|
|
2776
2425
|
return [k, React__default.isValidElement(v) ? processReactElement(v) : v];
|
|
2777
2426
|
}));
|
|
2778
2427
|
}
|
|
2779
|
-
|
|
2780
2428
|
var GenericErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
2781
2429
|
_inheritsLoose(GenericErrorBoundary, _React$Component);
|
|
2782
|
-
|
|
2783
2430
|
function GenericErrorBoundary(props) {
|
|
2784
2431
|
return _React$Component.call(this, props) || this;
|
|
2785
2432
|
}
|
|
2786
|
-
|
|
2787
2433
|
var _proto = GenericErrorBoundary.prototype;
|
|
2788
|
-
|
|
2789
2434
|
_proto.componentDidCatch = function componentDidCatch(error) {
|
|
2790
2435
|
console.log("Plasmic: Encountered error while prepass rendering:", error);
|
|
2791
2436
|
};
|
|
2792
|
-
|
|
2793
2437
|
_proto.render = function render() {
|
|
2794
2438
|
return React__default.createElement(React__default.Fragment, null, this.props.children);
|
|
2795
2439
|
};
|
|
2796
|
-
|
|
2797
2440
|
return GenericErrorBoundary;
|
|
2798
2441
|
}(React__default.Component);
|
|
2799
2442
|
/**
|
|
2800
2443
|
* To process the componentProps passed to PlasmicComponent, wrap any
|
|
2801
2444
|
* React element we find in <GenericErrorBoundary />.
|
|
2802
2445
|
*/
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
2446
|
function processPlasmicComponentProps(x) {
|
|
2806
2447
|
if (!x) {
|
|
2807
2448
|
return x;
|
|
@@ -2814,14 +2455,13 @@ function processPlasmicComponentProps(x) {
|
|
|
2814
2455
|
} else if (isLiteralObject(x)) {
|
|
2815
2456
|
return Object.fromEntries(Object.entries(x).map(function (_ref2) {
|
|
2816
2457
|
var key = _ref2[0],
|
|
2817
|
-
|
|
2458
|
+
val = _ref2[1];
|
|
2818
2459
|
return [key, processPlasmicComponentProps(val)];
|
|
2819
2460
|
}));
|
|
2820
2461
|
} else {
|
|
2821
2462
|
return x;
|
|
2822
2463
|
}
|
|
2823
2464
|
}
|
|
2824
|
-
|
|
2825
2465
|
function isLiteralObject(obj) {
|
|
2826
2466
|
return !!obj && typeof obj === 'object' && obj.constructor === Object;
|
|
2827
2467
|
}
|
|
@@ -2829,7 +2469,6 @@ function isLiteralObject(obj) {
|
|
|
2829
2469
|
function renderToElement(_x, _x2, _x3, _x4) {
|
|
2830
2470
|
return _renderToElement.apply(this, arguments);
|
|
2831
2471
|
}
|
|
2832
|
-
|
|
2833
2472
|
function _renderToElement() {
|
|
2834
2473
|
_renderToElement = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(loader, target, lookup, opts) {
|
|
2835
2474
|
return runtime_1.wrap(function _callee$(_context) {
|
|
@@ -2839,14 +2478,12 @@ function _renderToElement() {
|
|
|
2839
2478
|
if (opts === void 0) {
|
|
2840
2479
|
opts = {};
|
|
2841
2480
|
}
|
|
2842
|
-
|
|
2843
2481
|
return _context.abrupt("return", new Promise(function (resolve) {
|
|
2844
2482
|
var element = makeElement(loader, lookup, opts);
|
|
2845
2483
|
ReactDOM.render(element, target, function () {
|
|
2846
2484
|
return resolve();
|
|
2847
2485
|
});
|
|
2848
2486
|
}));
|
|
2849
|
-
|
|
2850
2487
|
case 2:
|
|
2851
2488
|
case "end":
|
|
2852
2489
|
return _context.stop();
|
|
@@ -2856,19 +2493,16 @@ function _renderToElement() {
|
|
|
2856
2493
|
}));
|
|
2857
2494
|
return _renderToElement.apply(this, arguments);
|
|
2858
2495
|
}
|
|
2859
|
-
|
|
2860
2496
|
function renderToString(loader, lookup, opts) {
|
|
2861
2497
|
if (opts === void 0) {
|
|
2862
2498
|
opts = {};
|
|
2863
2499
|
}
|
|
2864
|
-
|
|
2865
2500
|
var element = makeElement(loader, lookup, opts);
|
|
2866
2501
|
return renderToString$1(element);
|
|
2867
2502
|
}
|
|
2868
2503
|
function extractPlasmicQueryDataFromElement(_x5, _x6, _x7) {
|
|
2869
2504
|
return _extractPlasmicQueryDataFromElement.apply(this, arguments);
|
|
2870
2505
|
}
|
|
2871
|
-
|
|
2872
2506
|
function _extractPlasmicQueryDataFromElement() {
|
|
2873
2507
|
_extractPlasmicQueryDataFromElement = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(loader, lookup, opts) {
|
|
2874
2508
|
var element;
|
|
@@ -2879,10 +2513,8 @@ function _extractPlasmicQueryDataFromElement() {
|
|
|
2879
2513
|
if (opts === void 0) {
|
|
2880
2514
|
opts = {};
|
|
2881
2515
|
}
|
|
2882
|
-
|
|
2883
2516
|
element = makeElement(loader, lookup, opts);
|
|
2884
2517
|
return _context2.abrupt("return", extractPlasmicQueryData(element));
|
|
2885
|
-
|
|
2886
2518
|
case 3:
|
|
2887
2519
|
case "end":
|
|
2888
2520
|
return _context2.stop();
|
|
@@ -2892,11 +2524,9 @@ function _extractPlasmicQueryDataFromElement() {
|
|
|
2892
2524
|
}));
|
|
2893
2525
|
return _extractPlasmicQueryDataFromElement.apply(this, arguments);
|
|
2894
2526
|
}
|
|
2895
|
-
|
|
2896
2527
|
function hydrateFromElement(_x8, _x9, _x10, _x11) {
|
|
2897
2528
|
return _hydrateFromElement.apply(this, arguments);
|
|
2898
2529
|
}
|
|
2899
|
-
|
|
2900
2530
|
function _hydrateFromElement() {
|
|
2901
2531
|
_hydrateFromElement = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(loader, target, lookup, opts) {
|
|
2902
2532
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
@@ -2906,14 +2536,12 @@ function _hydrateFromElement() {
|
|
|
2906
2536
|
if (opts === void 0) {
|
|
2907
2537
|
opts = {};
|
|
2908
2538
|
}
|
|
2909
|
-
|
|
2910
2539
|
return _context3.abrupt("return", new Promise(function (resolve) {
|
|
2911
2540
|
var element = makeElement(loader, lookup, opts);
|
|
2912
2541
|
ReactDOM.hydrate(element, target, function () {
|
|
2913
2542
|
return resolve();
|
|
2914
2543
|
});
|
|
2915
2544
|
}));
|
|
2916
|
-
|
|
2917
2545
|
case 2:
|
|
2918
2546
|
case "end":
|
|
2919
2547
|
return _context3.stop();
|
|
@@ -2923,12 +2551,10 @@ function _hydrateFromElement() {
|
|
|
2923
2551
|
}));
|
|
2924
2552
|
return _hydrateFromElement.apply(this, arguments);
|
|
2925
2553
|
}
|
|
2926
|
-
|
|
2927
2554
|
function makeElement(loader, lookup, opts) {
|
|
2928
2555
|
if (opts === void 0) {
|
|
2929
2556
|
opts = {};
|
|
2930
2557
|
}
|
|
2931
|
-
|
|
2932
2558
|
return React__default.createElement(PlasmicRootProvider, {
|
|
2933
2559
|
loader: loader,
|
|
2934
2560
|
prefetchedData: opts.prefetchedData,
|