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