@plasmicapp/loader-core 1.0.100 → 1.0.102

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.
@@ -1,1268 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var loaderFetcher = require('@plasmicapp/loader-fetcher');
8
- var fetch = _interopDefault(require('@plasmicapp/isomorphic-unfetch'));
9
-
10
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
11
- try {
12
- var info = gen[key](arg);
13
- var value = info.value;
14
- } catch (error) {
15
- reject(error);
16
- return;
17
- }
18
- if (info.done) {
19
- resolve(value);
20
- } else {
21
- Promise.resolve(value).then(_next, _throw);
22
- }
23
- }
24
- function _asyncToGenerator(fn) {
25
- return function () {
26
- var self = this,
27
- args = arguments;
28
- return new Promise(function (resolve, reject) {
29
- var gen = fn.apply(self, args);
30
- function _next(value) {
31
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
32
- }
33
- function _throw(err) {
34
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
35
- }
36
- _next(undefined);
37
- });
38
- };
39
- }
40
- function _extends() {
41
- _extends = Object.assign ? Object.assign.bind() : function (target) {
42
- for (var i = 1; i < arguments.length; i++) {
43
- var source = arguments[i];
44
- for (var key in source) {
45
- if (Object.prototype.hasOwnProperty.call(source, key)) {
46
- target[key] = source[key];
47
- }
48
- }
49
- }
50
- return target;
51
- };
52
- return _extends.apply(this, arguments);
53
- }
54
- function _unsupportedIterableToArray(o, minLen) {
55
- if (!o) return;
56
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
57
- var n = Object.prototype.toString.call(o).slice(8, -1);
58
- if (n === "Object" && o.constructor) n = o.constructor.name;
59
- if (n === "Map" || n === "Set") return Array.from(o);
60
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
61
- }
62
- function _arrayLikeToArray(arr, len) {
63
- if (len == null || len > arr.length) len = arr.length;
64
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
65
- return arr2;
66
- }
67
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
68
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
69
- if (it) return (it = it.call(o)).next.bind(it);
70
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
71
- if (it) o = it;
72
- var i = 0;
73
- return function () {
74
- if (i >= o.length) return {
75
- done: true
76
- };
77
- return {
78
- done: false,
79
- value: o[i++]
80
- };
81
- };
82
- }
83
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
84
- }
85
-
86
- var DepsGraph = /*#__PURE__*/function () {
87
- function DepsGraph(bundle, browserBuild) {
88
- this.bundle = bundle;
89
- this.browserBuild = browserBuild;
90
- this.dependsOn = {};
91
- this.dependedBy = {};
92
- this.rebuildGraph();
93
- }
94
- var _proto = DepsGraph.prototype;
95
- _proto.getTransitiveDependers = function getTransitiveDependers(name) {
96
- return this.transitiveCrawl(name, this.dependedBy);
97
- };
98
- _proto.getTransitiveDeps = function getTransitiveDeps(name) {
99
- if (!(name in this.dependsOn)) {
100
- return [];
101
- }
102
- return this.transitiveCrawl(name, this.dependsOn);
103
- };
104
- _proto.transitiveCrawl = function transitiveCrawl(name, edges) {
105
- var deps = new Set();
106
- var crawl = function crawl(dep) {
107
- if (deps.has(dep)) {
108
- return;
109
- }
110
- deps.add(dep);
111
- for (var _iterator = _createForOfIteratorHelperLoose((_edges$dep = edges[dep]) != null ? _edges$dep : []), _step; !(_step = _iterator()).done;) {
112
- var _edges$dep;
113
- var subdep = _step.value;
114
- crawl(subdep);
115
- }
116
- };
117
- for (var _iterator2 = _createForOfIteratorHelperLoose(edges[name]), _step2; !(_step2 = _iterator2()).done;) {
118
- var dep = _step2.value;
119
- crawl(dep);
120
- }
121
- return Array.from(deps);
122
- };
123
- _proto.rebuildGraph = function rebuildGraph() {
124
- this.dependedBy = {};
125
- this.dependsOn = {};
126
- for (var _iterator3 = _createForOfIteratorHelperLoose(this.browserBuild ? this.bundle.modules.browser : this.bundle.modules.server), _step3; !(_step3 = _iterator3()).done;) {
127
- var mod = _step3.value;
128
- if (mod.type === 'code') {
129
- for (var _iterator4 = _createForOfIteratorHelperLoose(mod.imports), _step4; !(_step4 = _iterator4()).done;) {
130
- var imported = _step4.value;
131
- if (!(mod.fileName in this.dependsOn)) {
132
- this.dependsOn[mod.fileName] = [imported];
133
- } else {
134
- this.dependsOn[mod.fileName].push(imported);
135
- }
136
- if (!(imported in this.dependedBy)) {
137
- this.dependedBy[imported] = [mod.fileName];
138
- } else {
139
- this.dependedBy[imported].push(mod.fileName);
140
- }
141
- }
142
- }
143
- }
144
- };
145
- return DepsGraph;
146
- }();
147
-
148
- /**
149
- * Get sub-bundle including only modules that are reachable from `names`.
150
- * @param opts.target by default, will target the browser modules. Can request
151
- * the server modules instead.
152
- */
153
- function getBundleSubset(bundle, names, opts) {
154
- var _opts$target;
155
- var namesSet = new Set(names);
156
- var target = (_opts$target = opts == null ? void 0 : opts.target) != null ? _opts$target : 'browser';
157
- var forBrowser = target === 'browser';
158
- var graph = new DepsGraph(bundle, forBrowser);
159
- var deps = new Set(names.flatMap(function (name) {
160
- return graph.getTransitiveDeps(name);
161
- }));
162
- var isSubModule = function isSubModule(fileName) {
163
- return deps.has(fileName) || namesSet.has(fileName);
164
- };
165
- var modules = bundle.modules[target];
166
- var filteredModules = modules.filter(function (mod) {
167
- return isSubModule(mod.fileName);
168
- });
169
- return {
170
- modules: {
171
- browser: forBrowser ? filteredModules : [],
172
- server: forBrowser ? [] : filteredModules
173
- },
174
- external: bundle.external.filter(function (dep) {
175
- return deps.has(dep);
176
- }),
177
- components: bundle.components.filter(function (c) {
178
- return isSubModule(c.entry);
179
- }),
180
- globalGroups: bundle.globalGroups,
181
- projects: bundle.projects,
182
- activeSplits: bundle.activeSplits
183
- };
184
- }
185
-
186
- var isBrowser = typeof window !== 'undefined' && window != null && typeof window.document !== 'undefined';
187
- var Registry = /*#__PURE__*/function () {
188
- function Registry() {
189
- this.loadedModules = {};
190
- this.registeredModules = {};
191
- this.modules = {};
192
- }
193
- var _proto = Registry.prototype;
194
- _proto.register = function register(name, module) {
195
- this.registeredModules[name] = module;
196
- };
197
- _proto.isEmpty = function isEmpty() {
198
- return Object.keys(this.loadedModules).length === 0;
199
- };
200
- _proto.clear = function clear() {
201
- this.loadedModules = {};
202
- };
203
- _proto.getRegisteredModule = function getRegisteredModule(name) {
204
- return this.registeredModules[name];
205
- };
206
- _proto.hasModule = function hasModule(name, opts) {
207
- if (opts === void 0) {
208
- opts = {};
209
- }
210
- if (name in this.registeredModules && !opts.forceOriginal) {
211
- return true;
212
- }
213
- return name in this.modules;
214
- };
215
- _proto.load = function load(name, opts) {
216
- var _this = this;
217
- if (opts === void 0) {
218
- opts = {};
219
- }
220
- if (name in this.registeredModules && !opts.forceOriginal) {
221
- return this.registeredModules[name];
222
- }
223
- if (name in this.loadedModules) {
224
- return this.loadedModules[name];
225
- }
226
- if (!(name in this.modules)) {
227
- throw new Error("Unknown module " + name);
228
- }
229
- var code = this.modules[name];
230
- var requireFn = isBrowser ? function (dep) {
231
- var normalizedDep = resolvePath(dep, name);
232
- return _this.load(normalizedDep);
233
- } : function (dep) {
234
- try {
235
- var normalizedDep = resolvePath(dep, name);
236
- return _this.load(normalizedDep);
237
- } catch (err) {
238
- try {
239
- // Might be a nodeJs module such as tty
240
- return eval('require')(dep);
241
- } catch (_unused) {
242
- throw err;
243
- }
244
- }
245
- };
246
- var func;
247
- try {
248
- func = new Function('require', 'exports', code);
249
- } catch (err) {
250
- throw new Error("PLASMIC: Failed to create function for " + name + ": " + err);
251
- }
252
- var exports = {};
253
- this.loadedModules[name] = exports;
254
- try {
255
- func(requireFn, exports);
256
- } catch (err) {
257
- // Delete exports from loadedModules, so subsequent uses don't incorrectly
258
- // believe that this module has been loaded.
259
- delete this.loadedModules[name];
260
- throw new Error("PLASMIC: Failed to load " + name + ": " + err);
261
- }
262
- return exports;
263
- };
264
- _proto.updateModules = function updateModules(bundle) {
265
- var updated = false;
266
- for (var _iterator = _createForOfIteratorHelperLoose(isBrowser ? bundle.modules.browser : bundle.modules.server), _step; !(_step = _iterator()).done;) {
267
- var mod = _step.value;
268
- if (mod.type === 'code' && mod.code !== this.modules[mod.fileName]) {
269
- this.modules[mod.fileName] = mod.code;
270
- updated = true;
271
- }
272
- }
273
- if (updated) {
274
- // TODO: do something more efficient than tearing everything down?
275
- this.clear();
276
- }
277
- };
278
- return Registry;
279
- }();
280
- function resolvePath(path, from) {
281
- var fromParts = from.split('/');
282
- var pathParts = path.split('/');
283
- if (pathParts.length === 0) {
284
- return path;
285
- }
286
- if (pathParts[0] === '.') {
287
- return [].concat(fromParts.slice(0, fromParts.length - 1), pathParts.slice(1)).join('/');
288
- } else if (pathParts[0] === '..') {
289
- var count = 0;
290
- for (var _iterator2 = _createForOfIteratorHelperLoose(pathParts), _step2; !(_step2 = _iterator2()).done;) {
291
- var part = _step2.value;
292
- if (part === '..') {
293
- count += 1;
294
- } else {
295
- break;
296
- }
297
- }
298
- return [].concat(fromParts.slice(0, fromParts.length - count - 1), pathParts.slice(count)).join('/');
299
- } else {
300
- return path;
301
- }
302
- }
303
-
304
- function createCommonjsModule(fn, module) {
305
- return module = { exports: {} }, fn(module, module.exports), module.exports;
306
- }
307
-
308
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
309
- /**
310
- * Copyright (c) 2014-present, Facebook, Inc.
311
- *
312
- * This source code is licensed under the MIT license found in the
313
- * LICENSE file in the root directory of this source tree.
314
- */
315
-
316
- var runtime = function (exports) {
317
-
318
- var Op = Object.prototype;
319
- var hasOwn = Op.hasOwnProperty;
320
- var undefined$1; // More compressible than void 0.
321
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
322
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
323
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
324
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
325
- function define(obj, key, value) {
326
- Object.defineProperty(obj, key, {
327
- value: value,
328
- enumerable: true,
329
- configurable: true,
330
- writable: true
331
- });
332
- return obj[key];
333
- }
334
- try {
335
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
336
- define({}, "");
337
- } catch (err) {
338
- define = function define(obj, key, value) {
339
- return obj[key] = value;
340
- };
341
- }
342
- function wrap(innerFn, outerFn, self, tryLocsList) {
343
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
344
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
345
- var generator = Object.create(protoGenerator.prototype);
346
- var context = new Context(tryLocsList || []);
347
-
348
- // The ._invoke method unifies the implementations of the .next,
349
- // .throw, and .return methods.
350
- generator._invoke = makeInvokeMethod(innerFn, self, context);
351
- return generator;
352
- }
353
- exports.wrap = wrap;
354
-
355
- // Try/catch helper to minimize deoptimizations. Returns a completion
356
- // record like context.tryEntries[i].completion. This interface could
357
- // have been (and was previously) designed to take a closure to be
358
- // invoked without arguments, but in all the cases we care about we
359
- // already have an existing method we want to call, so there's no need
360
- // to create a new function object. We can even get away with assuming
361
- // the method takes exactly one argument, since that happens to be true
362
- // in every case, so we don't have to touch the arguments object. The
363
- // only additional allocation required is the completion record, which
364
- // has a stable shape and so hopefully should be cheap to allocate.
365
- function tryCatch(fn, obj, arg) {
366
- try {
367
- return {
368
- type: "normal",
369
- arg: fn.call(obj, arg)
370
- };
371
- } catch (err) {
372
- return {
373
- type: "throw",
374
- arg: err
375
- };
376
- }
377
- }
378
- var GenStateSuspendedStart = "suspendedStart";
379
- var GenStateSuspendedYield = "suspendedYield";
380
- var GenStateExecuting = "executing";
381
- var GenStateCompleted = "completed";
382
-
383
- // Returning this object from the innerFn has the same effect as
384
- // breaking out of the dispatch switch statement.
385
- var ContinueSentinel = {};
386
-
387
- // Dummy constructor functions that we use as the .constructor and
388
- // .constructor.prototype properties for functions that return Generator
389
- // objects. For full spec compliance, you may wish to configure your
390
- // minifier not to mangle the names of these two functions.
391
- function Generator() {}
392
- function GeneratorFunction() {}
393
- function GeneratorFunctionPrototype() {}
394
-
395
- // This is a polyfill for %IteratorPrototype% for environments that
396
- // don't natively support it.
397
- var IteratorPrototype = {};
398
- define(IteratorPrototype, iteratorSymbol, function () {
399
- return this;
400
- });
401
- var getProto = Object.getPrototypeOf;
402
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
403
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
404
- // This environment has a native %IteratorPrototype%; use it instead
405
- // of the polyfill.
406
- IteratorPrototype = NativeIteratorPrototype;
407
- }
408
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
409
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
410
- define(Gp, "constructor", GeneratorFunctionPrototype);
411
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
412
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
413
-
414
- // Helper for defining the .next, .throw, and .return methods of the
415
- // Iterator interface in terms of a single ._invoke method.
416
- function defineIteratorMethods(prototype) {
417
- ["next", "throw", "return"].forEach(function (method) {
418
- define(prototype, method, function (arg) {
419
- return this._invoke(method, arg);
420
- });
421
- });
422
- }
423
- exports.isGeneratorFunction = function (genFun) {
424
- var ctor = typeof genFun === "function" && genFun.constructor;
425
- return ctor ? ctor === GeneratorFunction ||
426
- // For the native GeneratorFunction constructor, the best we can
427
- // do is to check its .name property.
428
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
429
- };
430
- exports.mark = function (genFun) {
431
- if (Object.setPrototypeOf) {
432
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
433
- } else {
434
- genFun.__proto__ = GeneratorFunctionPrototype;
435
- define(genFun, toStringTagSymbol, "GeneratorFunction");
436
- }
437
- genFun.prototype = Object.create(Gp);
438
- return genFun;
439
- };
440
-
441
- // Within the body of any async function, `await x` is transformed to
442
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
443
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
444
- // meant to be awaited.
445
- exports.awrap = function (arg) {
446
- return {
447
- __await: arg
448
- };
449
- };
450
- function AsyncIterator(generator, PromiseImpl) {
451
- function invoke(method, arg, resolve, reject) {
452
- var record = tryCatch(generator[method], generator, arg);
453
- if (record.type === "throw") {
454
- reject(record.arg);
455
- } else {
456
- var result = record.arg;
457
- var value = result.value;
458
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
459
- return PromiseImpl.resolve(value.__await).then(function (value) {
460
- invoke("next", value, resolve, reject);
461
- }, function (err) {
462
- invoke("throw", err, resolve, reject);
463
- });
464
- }
465
- return PromiseImpl.resolve(value).then(function (unwrapped) {
466
- // When a yielded Promise is resolved, its final value becomes
467
- // the .value of the Promise<{value,done}> result for the
468
- // current iteration.
469
- result.value = unwrapped;
470
- resolve(result);
471
- }, function (error) {
472
- // If a rejected Promise was yielded, throw the rejection back
473
- // into the async generator function so it can be handled there.
474
- return invoke("throw", error, resolve, reject);
475
- });
476
- }
477
- }
478
- var previousPromise;
479
- function enqueue(method, arg) {
480
- function callInvokeWithMethodAndArg() {
481
- return new PromiseImpl(function (resolve, reject) {
482
- invoke(method, arg, resolve, reject);
483
- });
484
- }
485
- return previousPromise =
486
- // If enqueue has been called before, then we want to wait until
487
- // all previous Promises have been resolved before calling invoke,
488
- // so that results are always delivered in the correct order. If
489
- // enqueue has not been called before, then it is important to
490
- // call invoke immediately, without waiting on a callback to fire,
491
- // so that the async generator function has the opportunity to do
492
- // any necessary setup in a predictable way. This predictability
493
- // is why the Promise constructor synchronously invokes its
494
- // executor callback, and why async functions synchronously
495
- // execute code before the first await. Since we implement simple
496
- // async functions in terms of async generators, it is especially
497
- // important to get this right, even though it requires care.
498
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
499
- // Avoid propagating failures to Promises returned by later
500
- // invocations of the iterator.
501
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
502
- }
503
-
504
- // Define the unified helper method that is used to implement .next,
505
- // .throw, and .return (see defineIteratorMethods).
506
- this._invoke = enqueue;
507
- }
508
- defineIteratorMethods(AsyncIterator.prototype);
509
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
510
- return this;
511
- });
512
- exports.AsyncIterator = AsyncIterator;
513
-
514
- // Note that simple async functions are implemented on top of
515
- // AsyncIterator objects; they just return a Promise for the value of
516
- // the final result produced by the iterator.
517
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
518
- if (PromiseImpl === void 0) PromiseImpl = Promise;
519
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
520
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
521
- : iter.next().then(function (result) {
522
- return result.done ? result.value : iter.next();
523
- });
524
- };
525
- function makeInvokeMethod(innerFn, self, context) {
526
- var state = GenStateSuspendedStart;
527
- return function invoke(method, arg) {
528
- if (state === GenStateExecuting) {
529
- throw new Error("Generator is already running");
530
- }
531
- if (state === GenStateCompleted) {
532
- if (method === "throw") {
533
- throw arg;
534
- }
535
-
536
- // Be forgiving, per 25.3.3.3.3 of the spec:
537
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
538
- return doneResult();
539
- }
540
- context.method = method;
541
- context.arg = arg;
542
- while (true) {
543
- var delegate = context.delegate;
544
- if (delegate) {
545
- var delegateResult = maybeInvokeDelegate(delegate, context);
546
- if (delegateResult) {
547
- if (delegateResult === ContinueSentinel) continue;
548
- return delegateResult;
549
- }
550
- }
551
- if (context.method === "next") {
552
- // Setting context._sent for legacy support of Babel's
553
- // function.sent implementation.
554
- context.sent = context._sent = context.arg;
555
- } else if (context.method === "throw") {
556
- if (state === GenStateSuspendedStart) {
557
- state = GenStateCompleted;
558
- throw context.arg;
559
- }
560
- context.dispatchException(context.arg);
561
- } else if (context.method === "return") {
562
- context.abrupt("return", context.arg);
563
- }
564
- state = GenStateExecuting;
565
- var record = tryCatch(innerFn, self, context);
566
- if (record.type === "normal") {
567
- // If an exception is thrown from innerFn, we leave state ===
568
- // GenStateExecuting and loop back for another invocation.
569
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
570
- if (record.arg === ContinueSentinel) {
571
- continue;
572
- }
573
- return {
574
- value: record.arg,
575
- done: context.done
576
- };
577
- } else if (record.type === "throw") {
578
- state = GenStateCompleted;
579
- // Dispatch the exception by looping back around to the
580
- // context.dispatchException(context.arg) call above.
581
- context.method = "throw";
582
- context.arg = record.arg;
583
- }
584
- }
585
- };
586
- }
587
-
588
- // Call delegate.iterator[context.method](context.arg) and handle the
589
- // result, either by returning a { value, done } result from the
590
- // delegate iterator, or by modifying context.method and context.arg,
591
- // setting context.delegate to null, and returning the ContinueSentinel.
592
- function maybeInvokeDelegate(delegate, context) {
593
- var method = delegate.iterator[context.method];
594
- if (method === undefined$1) {
595
- // A .throw or .return when the delegate iterator has no .throw
596
- // method always terminates the yield* loop.
597
- context.delegate = null;
598
- if (context.method === "throw") {
599
- // Note: ["return"] must be used for ES3 parsing compatibility.
600
- if (delegate.iterator["return"]) {
601
- // If the delegate iterator has a return method, give it a
602
- // chance to clean up.
603
- context.method = "return";
604
- context.arg = undefined$1;
605
- maybeInvokeDelegate(delegate, context);
606
- if (context.method === "throw") {
607
- // If maybeInvokeDelegate(context) changed context.method from
608
- // "return" to "throw", let that override the TypeError below.
609
- return ContinueSentinel;
610
- }
611
- }
612
- context.method = "throw";
613
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
614
- }
615
- return ContinueSentinel;
616
- }
617
- var record = tryCatch(method, delegate.iterator, context.arg);
618
- if (record.type === "throw") {
619
- context.method = "throw";
620
- context.arg = record.arg;
621
- context.delegate = null;
622
- return ContinueSentinel;
623
- }
624
- var info = record.arg;
625
- if (!info) {
626
- context.method = "throw";
627
- context.arg = new TypeError("iterator result is not an object");
628
- context.delegate = null;
629
- return ContinueSentinel;
630
- }
631
- if (info.done) {
632
- // Assign the result of the finished delegate to the temporary
633
- // variable specified by delegate.resultName (see delegateYield).
634
- context[delegate.resultName] = info.value;
635
-
636
- // Resume execution at the desired location (see delegateYield).
637
- context.next = delegate.nextLoc;
638
-
639
- // If context.method was "throw" but the delegate handled the
640
- // exception, let the outer generator proceed normally. If
641
- // context.method was "next", forget context.arg since it has been
642
- // "consumed" by the delegate iterator. If context.method was
643
- // "return", allow the original .return call to continue in the
644
- // outer generator.
645
- if (context.method !== "return") {
646
- context.method = "next";
647
- context.arg = undefined$1;
648
- }
649
- } else {
650
- // Re-yield the result returned by the delegate method.
651
- return info;
652
- }
653
-
654
- // The delegate iterator is finished, so forget it and continue with
655
- // the outer generator.
656
- context.delegate = null;
657
- return ContinueSentinel;
658
- }
659
-
660
- // Define Generator.prototype.{next,throw,return} in terms of the
661
- // unified ._invoke helper method.
662
- defineIteratorMethods(Gp);
663
- define(Gp, toStringTagSymbol, "Generator");
664
-
665
- // A Generator should always return itself as the iterator object when the
666
- // @@iterator function is called on it. Some browsers' implementations of the
667
- // iterator prototype chain incorrectly implement this, causing the Generator
668
- // object to not be returned from this call. This ensures that doesn't happen.
669
- // See https://github.com/facebook/regenerator/issues/274 for more details.
670
- define(Gp, iteratorSymbol, function () {
671
- return this;
672
- });
673
- define(Gp, "toString", function () {
674
- return "[object Generator]";
675
- });
676
- function pushTryEntry(locs) {
677
- var entry = {
678
- tryLoc: locs[0]
679
- };
680
- if (1 in locs) {
681
- entry.catchLoc = locs[1];
682
- }
683
- if (2 in locs) {
684
- entry.finallyLoc = locs[2];
685
- entry.afterLoc = locs[3];
686
- }
687
- this.tryEntries.push(entry);
688
- }
689
- function resetTryEntry(entry) {
690
- var record = entry.completion || {};
691
- record.type = "normal";
692
- delete record.arg;
693
- entry.completion = record;
694
- }
695
- function Context(tryLocsList) {
696
- // The root entry object (effectively a try statement without a catch
697
- // or a finally block) gives us a place to store values thrown from
698
- // locations where there is no enclosing try statement.
699
- this.tryEntries = [{
700
- tryLoc: "root"
701
- }];
702
- tryLocsList.forEach(pushTryEntry, this);
703
- this.reset(true);
704
- }
705
- exports.keys = function (object) {
706
- var keys = [];
707
- for (var key in object) {
708
- keys.push(key);
709
- }
710
- keys.reverse();
711
-
712
- // Rather than returning an object with a next method, we keep
713
- // things simple and return the next function itself.
714
- return function next() {
715
- while (keys.length) {
716
- var key = keys.pop();
717
- if (key in object) {
718
- next.value = key;
719
- next.done = false;
720
- return next;
721
- }
722
- }
723
-
724
- // To avoid creating an additional object, we just hang the .value
725
- // and .done properties off the next function object itself. This
726
- // also ensures that the minifier will not anonymize the function.
727
- next.done = true;
728
- return next;
729
- };
730
- };
731
- function values(iterable) {
732
- if (iterable) {
733
- var iteratorMethod = iterable[iteratorSymbol];
734
- if (iteratorMethod) {
735
- return iteratorMethod.call(iterable);
736
- }
737
- if (typeof iterable.next === "function") {
738
- return iterable;
739
- }
740
- if (!isNaN(iterable.length)) {
741
- var i = -1,
742
- next = function next() {
743
- while (++i < iterable.length) {
744
- if (hasOwn.call(iterable, i)) {
745
- next.value = iterable[i];
746
- next.done = false;
747
- return next;
748
- }
749
- }
750
- next.value = undefined$1;
751
- next.done = true;
752
- return next;
753
- };
754
- return next.next = next;
755
- }
756
- }
757
-
758
- // Return an iterator with no values.
759
- return {
760
- next: doneResult
761
- };
762
- }
763
- exports.values = values;
764
- function doneResult() {
765
- return {
766
- value: undefined$1,
767
- done: true
768
- };
769
- }
770
- Context.prototype = {
771
- constructor: Context,
772
- reset: function reset(skipTempReset) {
773
- this.prev = 0;
774
- this.next = 0;
775
- // Resetting context._sent for legacy support of Babel's
776
- // function.sent implementation.
777
- this.sent = this._sent = undefined$1;
778
- this.done = false;
779
- this.delegate = null;
780
- this.method = "next";
781
- this.arg = undefined$1;
782
- this.tryEntries.forEach(resetTryEntry);
783
- if (!skipTempReset) {
784
- for (var name in this) {
785
- // Not sure about the optimal order of these conditions:
786
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
787
- this[name] = undefined$1;
788
- }
789
- }
790
- }
791
- },
792
- stop: function stop() {
793
- this.done = true;
794
- var rootEntry = this.tryEntries[0];
795
- var rootRecord = rootEntry.completion;
796
- if (rootRecord.type === "throw") {
797
- throw rootRecord.arg;
798
- }
799
- return this.rval;
800
- },
801
- dispatchException: function dispatchException(exception) {
802
- if (this.done) {
803
- throw exception;
804
- }
805
- var context = this;
806
- function handle(loc, caught) {
807
- record.type = "throw";
808
- record.arg = exception;
809
- context.next = loc;
810
- if (caught) {
811
- // If the dispatched exception was caught by a catch block,
812
- // then let that catch block handle the exception normally.
813
- context.method = "next";
814
- context.arg = undefined$1;
815
- }
816
- return !!caught;
817
- }
818
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
819
- var entry = this.tryEntries[i];
820
- var record = entry.completion;
821
- if (entry.tryLoc === "root") {
822
- // Exception thrown outside of any try block that could handle
823
- // it, so set the completion value of the entire function to
824
- // throw the exception.
825
- return handle("end");
826
- }
827
- if (entry.tryLoc <= this.prev) {
828
- var hasCatch = hasOwn.call(entry, "catchLoc");
829
- var hasFinally = hasOwn.call(entry, "finallyLoc");
830
- if (hasCatch && hasFinally) {
831
- if (this.prev < entry.catchLoc) {
832
- return handle(entry.catchLoc, true);
833
- } else if (this.prev < entry.finallyLoc) {
834
- return handle(entry.finallyLoc);
835
- }
836
- } else if (hasCatch) {
837
- if (this.prev < entry.catchLoc) {
838
- return handle(entry.catchLoc, true);
839
- }
840
- } else if (hasFinally) {
841
- if (this.prev < entry.finallyLoc) {
842
- return handle(entry.finallyLoc);
843
- }
844
- } else {
845
- throw new Error("try statement without catch or finally");
846
- }
847
- }
848
- }
849
- },
850
- abrupt: function abrupt(type, arg) {
851
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
852
- var entry = this.tryEntries[i];
853
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
854
- var finallyEntry = entry;
855
- break;
856
- }
857
- }
858
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
859
- // Ignore the finally entry if control is not jumping to a
860
- // location outside the try/catch block.
861
- finallyEntry = null;
862
- }
863
- var record = finallyEntry ? finallyEntry.completion : {};
864
- record.type = type;
865
- record.arg = arg;
866
- if (finallyEntry) {
867
- this.method = "next";
868
- this.next = finallyEntry.finallyLoc;
869
- return ContinueSentinel;
870
- }
871
- return this.complete(record);
872
- },
873
- complete: function complete(record, afterLoc) {
874
- if (record.type === "throw") {
875
- throw record.arg;
876
- }
877
- if (record.type === "break" || record.type === "continue") {
878
- this.next = record.arg;
879
- } else if (record.type === "return") {
880
- this.rval = this.arg = record.arg;
881
- this.method = "return";
882
- this.next = "end";
883
- } else if (record.type === "normal" && afterLoc) {
884
- this.next = afterLoc;
885
- }
886
- return ContinueSentinel;
887
- },
888
- finish: function finish(finallyLoc) {
889
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
890
- var entry = this.tryEntries[i];
891
- if (entry.finallyLoc === finallyLoc) {
892
- this.complete(entry.completion, entry.afterLoc);
893
- resetTryEntry(entry);
894
- return ContinueSentinel;
895
- }
896
- }
897
- },
898
- "catch": function _catch(tryLoc) {
899
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
900
- var entry = this.tryEntries[i];
901
- if (entry.tryLoc === tryLoc) {
902
- var record = entry.completion;
903
- if (record.type === "throw") {
904
- var thrown = record.arg;
905
- resetTryEntry(entry);
906
- }
907
- return thrown;
908
- }
909
- }
910
-
911
- // The context.catch method must only be called with a location
912
- // argument that corresponds to a known catch block.
913
- throw new Error("illegal catch attempt");
914
- },
915
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
916
- this.delegate = {
917
- iterator: values(iterable),
918
- resultName: resultName,
919
- nextLoc: nextLoc
920
- };
921
- if (this.method === "next") {
922
- // Deliberately forget the last sent value so that we don't
923
- // accidentally pass it on to the delegate.
924
- this.arg = undefined$1;
925
- }
926
- return ContinueSentinel;
927
- }
928
- };
929
-
930
- // Regardless of whether this script is executing as a CommonJS module
931
- // or not, return the runtime object so that we can declare the variable
932
- // regeneratorRuntime in the outer scope, which allows this module to be
933
- // injected easily by `bin/regenerator --include-runtime script.js`.
934
- return exports;
935
- }(
936
- // If this script is executing as a CommonJS module, use module.exports
937
- // as the regeneratorRuntime namespace. Otherwise create a new empty
938
- // object. Either way, the resulting object will be used to initialize
939
- // the regeneratorRuntime variable at the top of this file.
940
- module.exports );
941
- try {
942
- regeneratorRuntime = runtime;
943
- } catch (accidentalStrictMode) {
944
- // This module should not be running in strict mode, so the above
945
- // assignment should always work unless something is misconfigured. Just
946
- // in case runtime.js accidentally runs in strict mode, in modern engines
947
- // we can explicitly access globalThis. In older engines we can escape
948
- // strict mode using a global Function call. This could conceivably fail
949
- // if a Content Security Policy forbids using Function, but in that case
950
- // the proper solution is to fix the accidental strict mode problem. If
951
- // you've misconfigured your bundler to force strict mode and applied a
952
- // CSP to forbid Function, and you're not willing to fix either of those
953
- // problems, please detail your unique predicament in a GitHub issue.
954
- if (typeof globalThis === "object") {
955
- globalThis.regeneratorRuntime = runtime;
956
- } else {
957
- Function("r", "regeneratorRuntime = r")(runtime);
958
- }
959
- }
960
- });
961
-
962
- var isBrowser$1 = typeof window !== 'undefined' && window != null && typeof window.document !== 'undefined';
963
- function getPlasmicCookieValues() {
964
- if (!isBrowser$1) {
965
- return {};
966
- }
967
- return Object.fromEntries(document.cookie.split('; ').filter(function (cookie) {
968
- return cookie.includes('plasmic:');
969
- }).map(function (cookie) {
970
- return cookie.split('=');
971
- }).map(function (_ref) {
972
- var key = _ref[0],
973
- value = _ref[1];
974
- return [key.split(':')[1], value];
975
- }));
976
- }
977
- function getVariationCookieValues() {
978
- var cookies = getPlasmicCookieValues();
979
- return Object.fromEntries(Object.keys(cookies).map(function (key) {
980
- return [key.split('.')[1], cookies[key]];
981
- }).filter(function (val) {
982
- return !!val[0];
983
- }));
984
- }
985
- // https://stackoverflow.com/a/8809472
986
- function generateUUID() {
987
- // Public Domain/MIT
988
- var d = new Date().getTime(); //Timestamp
989
- var d2 = typeof performance !== 'undefined' && performance.now && performance.now() * 1000 || 0; //Time in microseconds since page-load or 0 if unsupported
990
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
991
- var r = Math.random() * 16; //random number between 0 and 16
992
- if (d > 0) {
993
- //Use timestamp until depleted
994
- r = (d + r) % 16 | 0;
995
- d = Math.floor(d / 16);
996
- } else {
997
- //Use microseconds since page-load if supported
998
- r = (d2 + r) % 16 | 0;
999
- d2 = Math.floor(d2 / 16);
1000
- }
1001
- return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
1002
- });
1003
- }
1004
- function getDistinctId() {
1005
- if (!isBrowser$1) {
1006
- return 'LOADER-SERVER';
1007
- }
1008
- return generateUUID();
1009
- }
1010
- function getCampaignParams() {
1011
- var _window = window,
1012
- location = _window.location;
1013
- var params = {};
1014
- try {
1015
- var url = new URL(location.href);
1016
- var CAMPAIGN_KEYWORDS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'gclid'];
1017
- CAMPAIGN_KEYWORDS.forEach(function (keyword) {
1018
- var value = url.searchParams.get(keyword);
1019
- if (value) {
1020
- params[keyword] = value;
1021
- }
1022
- });
1023
- } catch (err) {}
1024
- return params;
1025
- }
1026
- function getLocationMeta() {
1027
- var _window2 = window,
1028
- location = _window2.location;
1029
- var _document = document,
1030
- referrer = _document.referrer;
1031
- return _extends({
1032
- url: location.href,
1033
- host: location.host,
1034
- pathname: location.pathname,
1035
- referrer: referrer
1036
- }, getCampaignParams());
1037
- }
1038
- function getScreenMeta() {
1039
- var _window3 = window,
1040
- screen = _window3.screen;
1041
- return {
1042
- screen_height: screen.height,
1043
- screen_width: screen.width,
1044
- viewport_height: window.innerHeight,
1045
- viewport_width: window.innerWidth
1046
- };
1047
- }
1048
- function getOS(userAgent) {
1049
- if (/Windows/i.test(userAgent)) {
1050
- if (/Phone/.test(userAgent) || /WPDesktop/.test(userAgent)) {
1051
- return 'Windows Phone';
1052
- }
1053
- return 'Windows';
1054
- } else if (/(iPhone|iPad|iPod)/.test(userAgent)) {
1055
- return 'iOS';
1056
- } else if (/Android/.test(userAgent)) {
1057
- return 'Android';
1058
- } else if (/(BlackBerry|PlayBook|BB10)/i.test(userAgent)) {
1059
- return 'BlackBerry';
1060
- } else if (/Mac/i.test(userAgent)) {
1061
- return 'Mac OS X';
1062
- } else if (/Linux/.test(userAgent)) {
1063
- return 'Linux';
1064
- } else if (/CrOS/.test(userAgent)) {
1065
- return 'Chrome OS';
1066
- } else {
1067
- return '';
1068
- }
1069
- }
1070
- function getDeviceInfo(userAgent) {
1071
- var PATTERNS = [{
1072
- device: 'iPhone',
1073
- patterns: [/iPhone/]
1074
- }, {
1075
- device: 'iPad',
1076
- patterns: [/iPad/]
1077
- }, {
1078
- device: 'iPod Touch',
1079
- patterns: [/iPod/]
1080
- }, {
1081
- device: 'Windows Phone',
1082
- patterns: [/Windows Phone/i, /WPDesktop/]
1083
- }, {
1084
- device: 'Android',
1085
- patterns: [/Android/]
1086
- }];
1087
- var match = PATTERNS.find(function (pattern) {
1088
- return pattern.patterns.some(function (expr) {
1089
- return expr.test(userAgent);
1090
- });
1091
- });
1092
- var device = match == null ? void 0 : match.device;
1093
- return {
1094
- device: device != null ? device : '',
1095
- deviceType: device ? 'Mobile' : 'Desktop',
1096
- os: getOS(userAgent)
1097
- };
1098
- }
1099
- function getUserAgentMeta() {
1100
- var _window4 = window,
1101
- navigator = _window4.navigator;
1102
- var userAgent = navigator.userAgent;
1103
- return _extends({}, getDeviceInfo(userAgent));
1104
- }
1105
- function getWindowMeta() {
1106
- if (!isBrowser$1) {
1107
- return {};
1108
- }
1109
- return _extends({}, getLocationMeta(), getScreenMeta(), getUserAgentMeta());
1110
- }
1111
- var isProduction = "development" === 'production';
1112
- function getEnvMeta() {
1113
- return {
1114
- isBrowser: isBrowser$1,
1115
- isProduction: isProduction
1116
- };
1117
- }
1118
- function rawSplitVariation(variation) {
1119
- var rawVariations = {};
1120
- Object.keys(variation).forEach(function (variationKey) {
1121
- var _variationKey$split = variationKey.split('.'),
1122
- splitId = _variationKey$split[1];
1123
- if (splitId) {
1124
- rawVariations[splitId] = variation[variationKey];
1125
- }
1126
- });
1127
- return rawVariations;
1128
- }
1129
- var POLL_TIME = 5000;
1130
- function throttled(func) {
1131
- var timerId = undefined;
1132
- return function (param) {
1133
- if (timerId) {
1134
- // will already be taken care of next time we run
1135
- return;
1136
- }
1137
- if (isBrowser$1) {
1138
- timerId = window.requestAnimationFrame(function () {
1139
- timerId = undefined;
1140
- func(param);
1141
- });
1142
- } else {
1143
- timerId = setTimeout(function () {
1144
- timerId = undefined;
1145
- func(param);
1146
- }, POLL_TIME);
1147
- }
1148
- };
1149
- }
1150
-
1151
- var API_ENDPOINT = 'https://analytics.plasmic.app/capture';
1152
- var API_PUBLIC_KEY = 'phc_BRvYTAoMoam9fDHfrIneF67KdtMJagLVVCM6ELNYd4n';
1153
- var TRACKER_VERSION = 3;
1154
- var PlasmicTracker = /*#__PURE__*/function () {
1155
- function PlasmicTracker(opts) {
1156
- var _this = this;
1157
- this.opts = opts;
1158
- this.eventQueue = [];
1159
- this.sendEvents = throttled( /*#__PURE__*/function () {
1160
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(transport) {
1161
- var events, body, stringBody;
1162
- return runtime_1.wrap(function _callee$(_context) {
1163
- while (1) {
1164
- switch (_context.prev = _context.next) {
1165
- case 0:
1166
- if (!(_this.eventQueue.length === 0)) {
1167
- _context.next = 2;
1168
- break;
1169
- }
1170
- return _context.abrupt("return");
1171
- case 2:
1172
- events = [].concat(_this.eventQueue);
1173
- _this.eventQueue.length = 0;
1174
- body = {
1175
- api_key: API_PUBLIC_KEY,
1176
- batch: events
1177
- };
1178
- try {
1179
- stringBody = JSON.stringify(body);
1180
- if (transport === 'beacon') {
1181
- // Triggers warning: https://chromestatus.com/feature/5629709824032768
1182
- window.navigator.sendBeacon(API_ENDPOINT, stringBody);
1183
- } else {
1184
- fetch(API_ENDPOINT, {
1185
- method: 'POST',
1186
- headers: {
1187
- Accept: 'application/json'
1188
- },
1189
- body: stringBody
1190
- }).then(function () {})["catch"](function () {});
1191
- }
1192
- } catch (err) {}
1193
- case 6:
1194
- case "end":
1195
- return _context.stop();
1196
- }
1197
- }
1198
- }, _callee);
1199
- }));
1200
- return function (_x) {
1201
- return _ref.apply(this, arguments);
1202
- };
1203
- }());
1204
- }
1205
- var _proto = PlasmicTracker.prototype;
1206
- _proto.trackRender = function trackRender(opts) {
1207
- var _opts$renderCtx, _opts$variation;
1208
- this.enqueue({
1209
- event: '$render',
1210
- properties: _extends({}, this.getProperties(), (_opts$renderCtx = opts == null ? void 0 : opts.renderCtx) != null ? _opts$renderCtx : {}, rawSplitVariation((_opts$variation = opts == null ? void 0 : opts.variation) != null ? _opts$variation : {}))
1211
- });
1212
- };
1213
- _proto.trackFetch = function trackFetch() {
1214
- this.enqueue({
1215
- event: '$fetch',
1216
- properties: this.getProperties()
1217
- });
1218
- };
1219
- _proto.trackConversion = function trackConversion(value) {
1220
- if (value === void 0) {
1221
- value = 0;
1222
- }
1223
- this.enqueue({
1224
- event: '$conversion',
1225
- properties: _extends({}, this.getProperties(), {
1226
- value: value
1227
- })
1228
- });
1229
- };
1230
- _proto.getProperties = function getProperties() {
1231
- var _Date$now;
1232
- return _extends({
1233
- distinct_id: getDistinctId()
1234
- }, getWindowMeta(), getEnvMeta(), this.getContextMeta(), getVariationCookieValues(), {
1235
- timestamp: (_Date$now = Date.now()) != null ? _Date$now : +new Date(),
1236
- trackerVersion: TRACKER_VERSION
1237
- });
1238
- };
1239
- _proto.enqueue = function enqueue(event) {
1240
- this.eventQueue.push(event);
1241
- this.sendEvents('fetch');
1242
- };
1243
- _proto.getContextMeta = function getContextMeta() {
1244
- return {
1245
- platform: this.opts.platform,
1246
- preview: this.opts.preview,
1247
- projectIds: this.opts.projectIds
1248
- };
1249
- };
1250
- return PlasmicTracker;
1251
- }();
1252
-
1253
- Object.defineProperty(exports, 'Api', {
1254
- enumerable: true,
1255
- get: function () {
1256
- return loaderFetcher.Api;
1257
- }
1258
- });
1259
- Object.defineProperty(exports, 'PlasmicModulesFetcher', {
1260
- enumerable: true,
1261
- get: function () {
1262
- return loaderFetcher.PlasmicModulesFetcher;
1263
- }
1264
- });
1265
- exports.PlasmicTracker = PlasmicTracker;
1266
- exports.Registry = Registry;
1267
- exports.getBundleSubset = getBundleSubset;
1268
- //# sourceMappingURL=loader-core.cjs.development.js.map