@plasmicapp/loader-core 1.0.99 → 1.0.101

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