@plasmicapp/react-web 0.2.141 → 0.2.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/all.d.ts +23 -21
  2. package/dist/auth/PlasmicPageGuard.d.ts +6 -4
  3. package/dist/react-web.cjs.development.js +786 -24
  4. package/dist/react-web.cjs.development.js.map +1 -1
  5. package/dist/react-web.cjs.production.min.js +1 -1
  6. package/dist/react-web.cjs.production.min.js.map +1 -1
  7. package/dist/react-web.esm.js +786 -24
  8. package/dist/react-web.esm.js.map +1 -1
  9. package/package.json +3 -3
  10. package/skinny/dist/auth/PlasmicPageGuard.d.ts +6 -4
  11. package/skinny/dist/{collection-utils-43f97262.js → collection-utils-b5d4be02.js} +4 -4
  12. package/skinny/dist/{collection-utils-43f97262.js.map → collection-utils-b5d4be02.js.map} +1 -1
  13. package/skinny/dist/{common-9ebe374e.js → common-c2744215.js} +40 -2
  14. package/skinny/dist/{common-9ebe374e.js.map → common-c2744215.js.map} +1 -1
  15. package/skinny/dist/index.js +66 -8
  16. package/skinny/dist/index.js.map +1 -1
  17. package/skinny/dist/plume/button/index.js +2 -2
  18. package/skinny/dist/plume/checkbox/index.js +4 -4
  19. package/skinny/dist/plume/menu/index.js +5 -5
  20. package/skinny/dist/plume/menu-button/index.js +4 -4
  21. package/skinny/dist/plume/select/index.js +5 -5
  22. package/skinny/dist/plume/switch/index.js +4 -4
  23. package/skinny/dist/plume/text-input/index.js +2 -2
  24. package/skinny/dist/plume/triggered-overlay/index.js +4 -4
  25. package/skinny/dist/{plume-utils-d9811bf3.js → plume-utils-653f4b8a.js} +2 -2
  26. package/skinny/dist/{plume-utils-d9811bf3.js.map → plume-utils-653f4b8a.js.map} +1 -1
  27. package/skinny/dist/{props-utils-228208e6.js → props-utils-70c2d02a.js} +2 -2
  28. package/skinny/dist/{props-utils-228208e6.js.map → props-utils-70c2d02a.js.map} +1 -1
  29. package/skinny/dist/{react-utils-7bc53870.js → react-utils-76d05959.js} +2 -2
  30. package/skinny/dist/{react-utils-7bc53870.js.map → react-utils-76d05959.js.map} +1 -1
  31. package/skinny/dist/render/PlasmicImg/index.js +2 -2
@@ -5,12 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
7
  var classNames$1 = _interopDefault(require('classnames'));
8
+ var dataSourcesContext = require('@plasmicapp/data-sources-context');
8
9
  var React = require('react');
9
10
  var React__default = _interopDefault(React);
10
11
  var _get = _interopDefault(require('dlv'));
11
12
  var ReactDOM = require('react-dom');
12
13
  var ReactDOM__default = _interopDefault(ReactDOM);
13
- var dataSourcesContext = require('@plasmicapp/data-sources-context');
14
14
  var ssr = require('@react-aria/ssr');
15
15
  var focus = require('@react-aria/focus');
16
16
  var clone = _interopDefault(require('clone'));
@@ -31,31 +31,36 @@ var select$1 = require('@react-stately/select');
31
31
  var _switch = require('@react-aria/switch');
32
32
  var overlays = require('@react-aria/overlays');
33
33
 
34
- function PlasmicPageGuard(props) {
35
- var children = props.children,
36
- dataSourceCtxValue = props.dataSourceCtxValue,
37
- validRoles = props.validRoles;
38
- if (!dataSourceCtxValue || dataSourceCtxValue.isUserLoading) {
39
- return null;
40
- }
41
- function canUserViewPage() {
42
- if (!dataSourceCtxValue) {
43
- return false;
44
- }
45
- if (!dataSourceCtxValue.user) {
46
- return false;
47
- }
48
- if (!("roleId" in dataSourceCtxValue.user)) {
49
- return false;
50
- }
51
- return validRoles.includes(dataSourceCtxValue.user.roleId);
34
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
35
+ try {
36
+ var info = gen[key](arg);
37
+ var value = info.value;
38
+ } catch (error) {
39
+ reject(error);
40
+ return;
52
41
  }
53
- if (!canUserViewPage()) {
54
- return React__default.createElement("div", null, "You don't have access to this page");
42
+ if (info.done) {
43
+ resolve(value);
44
+ } else {
45
+ Promise.resolve(value).then(_next, _throw);
55
46
  }
56
- return children;
57
47
  }
58
-
48
+ function _asyncToGenerator(fn) {
49
+ return function () {
50
+ var self = this,
51
+ args = arguments;
52
+ return new Promise(function (resolve, reject) {
53
+ var gen = fn.apply(self, args);
54
+ function _next(value) {
55
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
56
+ }
57
+ function _throw(err) {
58
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
59
+ }
60
+ _next(undefined);
61
+ });
62
+ };
63
+ }
59
64
  function _extends() {
60
65
  _extends = Object.assign ? Object.assign.bind() : function (target) {
61
66
  for (var i = 1; i < arguments.length; i++) {
@@ -114,6 +119,763 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
114
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.");
115
120
  }
116
121
 
122
+ function createCommonjsModule(fn, module) {
123
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
124
+ }
125
+
126
+ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
127
+ /**
128
+ * Copyright (c) 2014-present, Facebook, Inc.
129
+ *
130
+ * This source code is licensed under the MIT license found in the
131
+ * LICENSE file in the root directory of this source tree.
132
+ */
133
+
134
+ var runtime = function (exports) {
135
+
136
+ var Op = Object.prototype;
137
+ var hasOwn = Op.hasOwnProperty;
138
+ var undefined$1; // More compressible than void 0.
139
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
140
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
141
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
142
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
143
+ function define(obj, key, value) {
144
+ Object.defineProperty(obj, key, {
145
+ value: value,
146
+ enumerable: true,
147
+ configurable: true,
148
+ writable: true
149
+ });
150
+ return obj[key];
151
+ }
152
+ try {
153
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
154
+ define({}, "");
155
+ } catch (err) {
156
+ define = function define(obj, key, value) {
157
+ return obj[key] = value;
158
+ };
159
+ }
160
+ function wrap(innerFn, outerFn, self, tryLocsList) {
161
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
162
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
163
+ var generator = Object.create(protoGenerator.prototype);
164
+ var context = new Context(tryLocsList || []);
165
+
166
+ // The ._invoke method unifies the implementations of the .next,
167
+ // .throw, and .return methods.
168
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
169
+ return generator;
170
+ }
171
+ exports.wrap = wrap;
172
+
173
+ // Try/catch helper to minimize deoptimizations. Returns a completion
174
+ // record like context.tryEntries[i].completion. This interface could
175
+ // have been (and was previously) designed to take a closure to be
176
+ // invoked without arguments, but in all the cases we care about we
177
+ // already have an existing method we want to call, so there's no need
178
+ // to create a new function object. We can even get away with assuming
179
+ // the method takes exactly one argument, since that happens to be true
180
+ // in every case, so we don't have to touch the arguments object. The
181
+ // only additional allocation required is the completion record, which
182
+ // has a stable shape and so hopefully should be cheap to allocate.
183
+ function tryCatch(fn, obj, arg) {
184
+ try {
185
+ return {
186
+ type: "normal",
187
+ arg: fn.call(obj, arg)
188
+ };
189
+ } catch (err) {
190
+ return {
191
+ type: "throw",
192
+ arg: err
193
+ };
194
+ }
195
+ }
196
+ var GenStateSuspendedStart = "suspendedStart";
197
+ var GenStateSuspendedYield = "suspendedYield";
198
+ var GenStateExecuting = "executing";
199
+ var GenStateCompleted = "completed";
200
+
201
+ // Returning this object from the innerFn has the same effect as
202
+ // breaking out of the dispatch switch statement.
203
+ var ContinueSentinel = {};
204
+
205
+ // Dummy constructor functions that we use as the .constructor and
206
+ // .constructor.prototype properties for functions that return Generator
207
+ // objects. For full spec compliance, you may wish to configure your
208
+ // minifier not to mangle the names of these two functions.
209
+ function Generator() {}
210
+ function GeneratorFunction() {}
211
+ function GeneratorFunctionPrototype() {}
212
+
213
+ // This is a polyfill for %IteratorPrototype% for environments that
214
+ // don't natively support it.
215
+ var IteratorPrototype = {};
216
+ define(IteratorPrototype, iteratorSymbol, function () {
217
+ return this;
218
+ });
219
+ var getProto = Object.getPrototypeOf;
220
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
221
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
222
+ // This environment has a native %IteratorPrototype%; use it instead
223
+ // of the polyfill.
224
+ IteratorPrototype = NativeIteratorPrototype;
225
+ }
226
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
227
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
228
+ define(Gp, "constructor", GeneratorFunctionPrototype);
229
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
230
+ GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
231
+
232
+ // Helper for defining the .next, .throw, and .return methods of the
233
+ // Iterator interface in terms of a single ._invoke method.
234
+ function defineIteratorMethods(prototype) {
235
+ ["next", "throw", "return"].forEach(function (method) {
236
+ define(prototype, method, function (arg) {
237
+ return this._invoke(method, arg);
238
+ });
239
+ });
240
+ }
241
+ exports.isGeneratorFunction = function (genFun) {
242
+ var ctor = typeof genFun === "function" && genFun.constructor;
243
+ return ctor ? ctor === GeneratorFunction ||
244
+ // For the native GeneratorFunction constructor, the best we can
245
+ // do is to check its .name property.
246
+ (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
247
+ };
248
+ exports.mark = function (genFun) {
249
+ if (Object.setPrototypeOf) {
250
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
251
+ } else {
252
+ genFun.__proto__ = GeneratorFunctionPrototype;
253
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
254
+ }
255
+ genFun.prototype = Object.create(Gp);
256
+ return genFun;
257
+ };
258
+
259
+ // Within the body of any async function, `await x` is transformed to
260
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
261
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
262
+ // meant to be awaited.
263
+ exports.awrap = function (arg) {
264
+ return {
265
+ __await: arg
266
+ };
267
+ };
268
+ function AsyncIterator(generator, PromiseImpl) {
269
+ function invoke(method, arg, resolve, reject) {
270
+ var record = tryCatch(generator[method], generator, arg);
271
+ if (record.type === "throw") {
272
+ reject(record.arg);
273
+ } else {
274
+ var result = record.arg;
275
+ var value = result.value;
276
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
277
+ return PromiseImpl.resolve(value.__await).then(function (value) {
278
+ invoke("next", value, resolve, reject);
279
+ }, function (err) {
280
+ invoke("throw", err, resolve, reject);
281
+ });
282
+ }
283
+ return PromiseImpl.resolve(value).then(function (unwrapped) {
284
+ // When a yielded Promise is resolved, its final value becomes
285
+ // the .value of the Promise<{value,done}> result for the
286
+ // current iteration.
287
+ result.value = unwrapped;
288
+ resolve(result);
289
+ }, function (error) {
290
+ // If a rejected Promise was yielded, throw the rejection back
291
+ // into the async generator function so it can be handled there.
292
+ return invoke("throw", error, resolve, reject);
293
+ });
294
+ }
295
+ }
296
+ var previousPromise;
297
+ function enqueue(method, arg) {
298
+ function callInvokeWithMethodAndArg() {
299
+ return new PromiseImpl(function (resolve, reject) {
300
+ invoke(method, arg, resolve, reject);
301
+ });
302
+ }
303
+ return previousPromise =
304
+ // If enqueue has been called before, then we want to wait until
305
+ // all previous Promises have been resolved before calling invoke,
306
+ // so that results are always delivered in the correct order. If
307
+ // enqueue has not been called before, then it is important to
308
+ // call invoke immediately, without waiting on a callback to fire,
309
+ // so that the async generator function has the opportunity to do
310
+ // any necessary setup in a predictable way. This predictability
311
+ // is why the Promise constructor synchronously invokes its
312
+ // executor callback, and why async functions synchronously
313
+ // execute code before the first await. Since we implement simple
314
+ // async functions in terms of async generators, it is especially
315
+ // important to get this right, even though it requires care.
316
+ previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
317
+ // Avoid propagating failures to Promises returned by later
318
+ // invocations of the iterator.
319
+ callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
320
+ }
321
+
322
+ // Define the unified helper method that is used to implement .next,
323
+ // .throw, and .return (see defineIteratorMethods).
324
+ this._invoke = enqueue;
325
+ }
326
+ defineIteratorMethods(AsyncIterator.prototype);
327
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
328
+ return this;
329
+ });
330
+ exports.AsyncIterator = AsyncIterator;
331
+
332
+ // Note that simple async functions are implemented on top of
333
+ // AsyncIterator objects; they just return a Promise for the value of
334
+ // the final result produced by the iterator.
335
+ exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
336
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
337
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
338
+ return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
339
+ : iter.next().then(function (result) {
340
+ return result.done ? result.value : iter.next();
341
+ });
342
+ };
343
+ function makeInvokeMethod(innerFn, self, context) {
344
+ var state = GenStateSuspendedStart;
345
+ return function invoke(method, arg) {
346
+ if (state === GenStateExecuting) {
347
+ throw new Error("Generator is already running");
348
+ }
349
+ if (state === GenStateCompleted) {
350
+ if (method === "throw") {
351
+ throw arg;
352
+ }
353
+
354
+ // Be forgiving, per 25.3.3.3.3 of the spec:
355
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
356
+ return doneResult();
357
+ }
358
+ context.method = method;
359
+ context.arg = arg;
360
+ while (true) {
361
+ var delegate = context.delegate;
362
+ if (delegate) {
363
+ var delegateResult = maybeInvokeDelegate(delegate, context);
364
+ if (delegateResult) {
365
+ if (delegateResult === ContinueSentinel) continue;
366
+ return delegateResult;
367
+ }
368
+ }
369
+ if (context.method === "next") {
370
+ // Setting context._sent for legacy support of Babel's
371
+ // function.sent implementation.
372
+ context.sent = context._sent = context.arg;
373
+ } else if (context.method === "throw") {
374
+ if (state === GenStateSuspendedStart) {
375
+ state = GenStateCompleted;
376
+ throw context.arg;
377
+ }
378
+ context.dispatchException(context.arg);
379
+ } else if (context.method === "return") {
380
+ context.abrupt("return", context.arg);
381
+ }
382
+ state = GenStateExecuting;
383
+ var record = tryCatch(innerFn, self, context);
384
+ if (record.type === "normal") {
385
+ // If an exception is thrown from innerFn, we leave state ===
386
+ // GenStateExecuting and loop back for another invocation.
387
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
388
+ if (record.arg === ContinueSentinel) {
389
+ continue;
390
+ }
391
+ return {
392
+ value: record.arg,
393
+ done: context.done
394
+ };
395
+ } else if (record.type === "throw") {
396
+ state = GenStateCompleted;
397
+ // Dispatch the exception by looping back around to the
398
+ // context.dispatchException(context.arg) call above.
399
+ context.method = "throw";
400
+ context.arg = record.arg;
401
+ }
402
+ }
403
+ };
404
+ }
405
+
406
+ // Call delegate.iterator[context.method](context.arg) and handle the
407
+ // result, either by returning a { value, done } result from the
408
+ // delegate iterator, or by modifying context.method and context.arg,
409
+ // setting context.delegate to null, and returning the ContinueSentinel.
410
+ function maybeInvokeDelegate(delegate, context) {
411
+ var method = delegate.iterator[context.method];
412
+ if (method === undefined$1) {
413
+ // A .throw or .return when the delegate iterator has no .throw
414
+ // method always terminates the yield* loop.
415
+ context.delegate = null;
416
+ if (context.method === "throw") {
417
+ // Note: ["return"] must be used for ES3 parsing compatibility.
418
+ if (delegate.iterator["return"]) {
419
+ // If the delegate iterator has a return method, give it a
420
+ // chance to clean up.
421
+ context.method = "return";
422
+ context.arg = undefined$1;
423
+ maybeInvokeDelegate(delegate, context);
424
+ if (context.method === "throw") {
425
+ // If maybeInvokeDelegate(context) changed context.method from
426
+ // "return" to "throw", let that override the TypeError below.
427
+ return ContinueSentinel;
428
+ }
429
+ }
430
+ context.method = "throw";
431
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
432
+ }
433
+ return ContinueSentinel;
434
+ }
435
+ var record = tryCatch(method, delegate.iterator, context.arg);
436
+ if (record.type === "throw") {
437
+ context.method = "throw";
438
+ context.arg = record.arg;
439
+ context.delegate = null;
440
+ return ContinueSentinel;
441
+ }
442
+ var info = record.arg;
443
+ if (!info) {
444
+ context.method = "throw";
445
+ context.arg = new TypeError("iterator result is not an object");
446
+ context.delegate = null;
447
+ return ContinueSentinel;
448
+ }
449
+ if (info.done) {
450
+ // Assign the result of the finished delegate to the temporary
451
+ // variable specified by delegate.resultName (see delegateYield).
452
+ context[delegate.resultName] = info.value;
453
+
454
+ // Resume execution at the desired location (see delegateYield).
455
+ context.next = delegate.nextLoc;
456
+
457
+ // If context.method was "throw" but the delegate handled the
458
+ // exception, let the outer generator proceed normally. If
459
+ // context.method was "next", forget context.arg since it has been
460
+ // "consumed" by the delegate iterator. If context.method was
461
+ // "return", allow the original .return call to continue in the
462
+ // outer generator.
463
+ if (context.method !== "return") {
464
+ context.method = "next";
465
+ context.arg = undefined$1;
466
+ }
467
+ } else {
468
+ // Re-yield the result returned by the delegate method.
469
+ return info;
470
+ }
471
+
472
+ // The delegate iterator is finished, so forget it and continue with
473
+ // the outer generator.
474
+ context.delegate = null;
475
+ return ContinueSentinel;
476
+ }
477
+
478
+ // Define Generator.prototype.{next,throw,return} in terms of the
479
+ // unified ._invoke helper method.
480
+ defineIteratorMethods(Gp);
481
+ define(Gp, toStringTagSymbol, "Generator");
482
+
483
+ // A Generator should always return itself as the iterator object when the
484
+ // @@iterator function is called on it. Some browsers' implementations of the
485
+ // iterator prototype chain incorrectly implement this, causing the Generator
486
+ // object to not be returned from this call. This ensures that doesn't happen.
487
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
488
+ define(Gp, iteratorSymbol, function () {
489
+ return this;
490
+ });
491
+ define(Gp, "toString", function () {
492
+ return "[object Generator]";
493
+ });
494
+ function pushTryEntry(locs) {
495
+ var entry = {
496
+ tryLoc: locs[0]
497
+ };
498
+ if (1 in locs) {
499
+ entry.catchLoc = locs[1];
500
+ }
501
+ if (2 in locs) {
502
+ entry.finallyLoc = locs[2];
503
+ entry.afterLoc = locs[3];
504
+ }
505
+ this.tryEntries.push(entry);
506
+ }
507
+ function resetTryEntry(entry) {
508
+ var record = entry.completion || {};
509
+ record.type = "normal";
510
+ delete record.arg;
511
+ entry.completion = record;
512
+ }
513
+ function Context(tryLocsList) {
514
+ // The root entry object (effectively a try statement without a catch
515
+ // or a finally block) gives us a place to store values thrown from
516
+ // locations where there is no enclosing try statement.
517
+ this.tryEntries = [{
518
+ tryLoc: "root"
519
+ }];
520
+ tryLocsList.forEach(pushTryEntry, this);
521
+ this.reset(true);
522
+ }
523
+ exports.keys = function (object) {
524
+ var keys = [];
525
+ for (var key in object) {
526
+ keys.push(key);
527
+ }
528
+ keys.reverse();
529
+
530
+ // Rather than returning an object with a next method, we keep
531
+ // things simple and return the next function itself.
532
+ return function next() {
533
+ while (keys.length) {
534
+ var key = keys.pop();
535
+ if (key in object) {
536
+ next.value = key;
537
+ next.done = false;
538
+ return next;
539
+ }
540
+ }
541
+
542
+ // To avoid creating an additional object, we just hang the .value
543
+ // and .done properties off the next function object itself. This
544
+ // also ensures that the minifier will not anonymize the function.
545
+ next.done = true;
546
+ return next;
547
+ };
548
+ };
549
+ function values(iterable) {
550
+ if (iterable) {
551
+ var iteratorMethod = iterable[iteratorSymbol];
552
+ if (iteratorMethod) {
553
+ return iteratorMethod.call(iterable);
554
+ }
555
+ if (typeof iterable.next === "function") {
556
+ return iterable;
557
+ }
558
+ if (!isNaN(iterable.length)) {
559
+ var i = -1,
560
+ next = function next() {
561
+ while (++i < iterable.length) {
562
+ if (hasOwn.call(iterable, i)) {
563
+ next.value = iterable[i];
564
+ next.done = false;
565
+ return next;
566
+ }
567
+ }
568
+ next.value = undefined$1;
569
+ next.done = true;
570
+ return next;
571
+ };
572
+ return next.next = next;
573
+ }
574
+ }
575
+
576
+ // Return an iterator with no values.
577
+ return {
578
+ next: doneResult
579
+ };
580
+ }
581
+ exports.values = values;
582
+ function doneResult() {
583
+ return {
584
+ value: undefined$1,
585
+ done: true
586
+ };
587
+ }
588
+ Context.prototype = {
589
+ constructor: Context,
590
+ reset: function reset(skipTempReset) {
591
+ this.prev = 0;
592
+ this.next = 0;
593
+ // Resetting context._sent for legacy support of Babel's
594
+ // function.sent implementation.
595
+ this.sent = this._sent = undefined$1;
596
+ this.done = false;
597
+ this.delegate = null;
598
+ this.method = "next";
599
+ this.arg = undefined$1;
600
+ this.tryEntries.forEach(resetTryEntry);
601
+ if (!skipTempReset) {
602
+ for (var name in this) {
603
+ // Not sure about the optimal order of these conditions:
604
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
605
+ this[name] = undefined$1;
606
+ }
607
+ }
608
+ }
609
+ },
610
+ stop: function stop() {
611
+ this.done = true;
612
+ var rootEntry = this.tryEntries[0];
613
+ var rootRecord = rootEntry.completion;
614
+ if (rootRecord.type === "throw") {
615
+ throw rootRecord.arg;
616
+ }
617
+ return this.rval;
618
+ },
619
+ dispatchException: function dispatchException(exception) {
620
+ if (this.done) {
621
+ throw exception;
622
+ }
623
+ var context = this;
624
+ function handle(loc, caught) {
625
+ record.type = "throw";
626
+ record.arg = exception;
627
+ context.next = loc;
628
+ if (caught) {
629
+ // If the dispatched exception was caught by a catch block,
630
+ // then let that catch block handle the exception normally.
631
+ context.method = "next";
632
+ context.arg = undefined$1;
633
+ }
634
+ return !!caught;
635
+ }
636
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
637
+ var entry = this.tryEntries[i];
638
+ var record = entry.completion;
639
+ if (entry.tryLoc === "root") {
640
+ // Exception thrown outside of any try block that could handle
641
+ // it, so set the completion value of the entire function to
642
+ // throw the exception.
643
+ return handle("end");
644
+ }
645
+ if (entry.tryLoc <= this.prev) {
646
+ var hasCatch = hasOwn.call(entry, "catchLoc");
647
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
648
+ if (hasCatch && hasFinally) {
649
+ if (this.prev < entry.catchLoc) {
650
+ return handle(entry.catchLoc, true);
651
+ } else if (this.prev < entry.finallyLoc) {
652
+ return handle(entry.finallyLoc);
653
+ }
654
+ } else if (hasCatch) {
655
+ if (this.prev < entry.catchLoc) {
656
+ return handle(entry.catchLoc, true);
657
+ }
658
+ } else if (hasFinally) {
659
+ if (this.prev < entry.finallyLoc) {
660
+ return handle(entry.finallyLoc);
661
+ }
662
+ } else {
663
+ throw new Error("try statement without catch or finally");
664
+ }
665
+ }
666
+ }
667
+ },
668
+ abrupt: function abrupt(type, arg) {
669
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
670
+ var entry = this.tryEntries[i];
671
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
672
+ var finallyEntry = entry;
673
+ break;
674
+ }
675
+ }
676
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
677
+ // Ignore the finally entry if control is not jumping to a
678
+ // location outside the try/catch block.
679
+ finallyEntry = null;
680
+ }
681
+ var record = finallyEntry ? finallyEntry.completion : {};
682
+ record.type = type;
683
+ record.arg = arg;
684
+ if (finallyEntry) {
685
+ this.method = "next";
686
+ this.next = finallyEntry.finallyLoc;
687
+ return ContinueSentinel;
688
+ }
689
+ return this.complete(record);
690
+ },
691
+ complete: function complete(record, afterLoc) {
692
+ if (record.type === "throw") {
693
+ throw record.arg;
694
+ }
695
+ if (record.type === "break" || record.type === "continue") {
696
+ this.next = record.arg;
697
+ } else if (record.type === "return") {
698
+ this.rval = this.arg = record.arg;
699
+ this.method = "return";
700
+ this.next = "end";
701
+ } else if (record.type === "normal" && afterLoc) {
702
+ this.next = afterLoc;
703
+ }
704
+ return ContinueSentinel;
705
+ },
706
+ finish: function finish(finallyLoc) {
707
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
708
+ var entry = this.tryEntries[i];
709
+ if (entry.finallyLoc === finallyLoc) {
710
+ this.complete(entry.completion, entry.afterLoc);
711
+ resetTryEntry(entry);
712
+ return ContinueSentinel;
713
+ }
714
+ }
715
+ },
716
+ "catch": function _catch(tryLoc) {
717
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
718
+ var entry = this.tryEntries[i];
719
+ if (entry.tryLoc === tryLoc) {
720
+ var record = entry.completion;
721
+ if (record.type === "throw") {
722
+ var thrown = record.arg;
723
+ resetTryEntry(entry);
724
+ }
725
+ return thrown;
726
+ }
727
+ }
728
+
729
+ // The context.catch method must only be called with a location
730
+ // argument that corresponds to a known catch block.
731
+ throw new Error("illegal catch attempt");
732
+ },
733
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
734
+ this.delegate = {
735
+ iterator: values(iterable),
736
+ resultName: resultName,
737
+ nextLoc: nextLoc
738
+ };
739
+ if (this.method === "next") {
740
+ // Deliberately forget the last sent value so that we don't
741
+ // accidentally pass it on to the delegate.
742
+ this.arg = undefined$1;
743
+ }
744
+ return ContinueSentinel;
745
+ }
746
+ };
747
+
748
+ // Regardless of whether this script is executing as a CommonJS module
749
+ // or not, return the runtime object so that we can declare the variable
750
+ // regeneratorRuntime in the outer scope, which allows this module to be
751
+ // injected easily by `bin/regenerator --include-runtime script.js`.
752
+ return exports;
753
+ }(
754
+ // If this script is executing as a CommonJS module, use module.exports
755
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
756
+ // object. Either way, the resulting object will be used to initialize
757
+ // the regeneratorRuntime variable at the top of this file.
758
+ module.exports );
759
+ try {
760
+ regeneratorRuntime = runtime;
761
+ } catch (accidentalStrictMode) {
762
+ // This module should not be running in strict mode, so the above
763
+ // assignment should always work unless something is misconfigured. Just
764
+ // in case runtime.js accidentally runs in strict mode, in modern engines
765
+ // we can explicitly access globalThis. In older engines we can escape
766
+ // strict mode using a global Function call. This could conceivably fail
767
+ // if a Content Security Policy forbids using Function, but in that case
768
+ // the proper solution is to fix the accidental strict mode problem. If
769
+ // you've misconfigured your bundler to force strict mode and applied a
770
+ // CSP to forbid Function, and you're not willing to fix either of those
771
+ // problems, please detail your unique predicament in a GitHub issue.
772
+ if (typeof globalThis === "object") {
773
+ globalThis.regeneratorRuntime = runtime;
774
+ } else {
775
+ Function("r", "regeneratorRuntime = r")(runtime);
776
+ }
777
+ }
778
+ });
779
+
780
+ function triggerLogin(_x, _x2) {
781
+ return _triggerLogin.apply(this, arguments);
782
+ }
783
+ function _triggerLogin() {
784
+ _triggerLogin = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(appId, authorizeEndpoint) {
785
+ var sha256, _sha, continueTo, state, code_verifier, code_challenge, params, url;
786
+ return runtime_1.wrap(function _callee2$(_context2) {
787
+ while (1) {
788
+ switch (_context2.prev = _context2.next) {
789
+ case 0:
790
+ _sha = function _sha3() {
791
+ _sha = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(text) {
792
+ var encoder, data, hashBuffer, hashArray, hashHex;
793
+ return runtime_1.wrap(function _callee$(_context) {
794
+ while (1) {
795
+ switch (_context.prev = _context.next) {
796
+ case 0:
797
+ encoder = new TextEncoder();
798
+ data = encoder.encode(text);
799
+ _context.next = 4;
800
+ return crypto.subtle.digest("SHA-256", data);
801
+ case 4:
802
+ hashBuffer = _context.sent;
803
+ hashArray = Array.from(new Uint8Array(hashBuffer));
804
+ hashHex = hashArray.map(function (b) {
805
+ return b.toString(16).padStart(2, "0");
806
+ }).join("");
807
+ return _context.abrupt("return", hashHex);
808
+ case 8:
809
+ case "end":
810
+ return _context.stop();
811
+ }
812
+ }
813
+ }, _callee);
814
+ }));
815
+ return _sha.apply(this, arguments);
816
+ };
817
+ sha256 = function _sha2(_x3) {
818
+ return _sha.apply(this, arguments);
819
+ };
820
+ continueTo = window.location.href;
821
+ state = JSON.stringify({
822
+ continueTo: continueTo
823
+ });
824
+ code_verifier = crypto.randomUUID();
825
+ localStorage.setItem("code_verifier", code_verifier);
826
+ _context2.next = 8;
827
+ return sha256(code_verifier);
828
+ case 8:
829
+ code_challenge = _context2.sent;
830
+ params = new URLSearchParams();
831
+ params.set("client_id", appId);
832
+ params.set("state", state);
833
+ params.set("response_type", "code");
834
+ params.set("code_challenge", code_challenge);
835
+ params.set("code_challenge_method", "S256");
836
+ url = authorizeEndpoint + "?" + params.toString();
837
+ window.location.href = url;
838
+ case 17:
839
+ case "end":
840
+ return _context2.stop();
841
+ }
842
+ }
843
+ }, _callee2);
844
+ }));
845
+ return _triggerLogin.apply(this, arguments);
846
+ }
847
+ function PlasmicPageGuard(props) {
848
+ var appId = props.appId,
849
+ authorizeEndpoint = props.authorizeEndpoint,
850
+ validRoles = props.validRoles,
851
+ children = props.children;
852
+ var dataSourceCtxValue = dataSourcesContext.usePlasmicDataSourceContext();
853
+ React__default.useEffect(function () {
854
+ if (dataSourceCtxValue && "isUserLoading" in dataSourceCtxValue && !dataSourceCtxValue.isUserLoading && !dataSourceCtxValue.user) {
855
+ triggerLogin(appId, authorizeEndpoint);
856
+ }
857
+ }, [dataSourceCtxValue, appId, authorizeEndpoint]);
858
+ function canUserViewPage() {
859
+ if (!dataSourceCtxValue) {
860
+ return false;
861
+ }
862
+ if (!dataSourceCtxValue.user) {
863
+ return false;
864
+ }
865
+ if (!("roleId" in dataSourceCtxValue.user)) {
866
+ return false;
867
+ }
868
+ return validRoles.includes(dataSourceCtxValue.user.roleId);
869
+ }
870
+ if (!dataSourceCtxValue || dataSourceCtxValue.isUserLoading || !dataSourceCtxValue.user) {
871
+ return null;
872
+ }
873
+ if (!canUserViewPage()) {
874
+ return React__default.createElement("div", null, "You don't have access to this page");
875
+ }
876
+ return children;
877
+ }
878
+
117
879
  function notNil(x) {
118
880
  return x != null;
119
881
  }
@@ -3486,7 +4248,6 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
3486
4248
  };
3487
4249
  }
3488
4250
 
3489
- exports.get = _get;
3490
4251
  Object.defineProperty(exports, 'PlasmicDataSourceContextProvider', {
3491
4252
  enumerable: true,
3492
4253
  get: function () {
@@ -3499,6 +4260,7 @@ Object.defineProperty(exports, 'useCurrentUser', {
3499
4260
  return dataSourcesContext.useCurrentUser;
3500
4261
  }
3501
4262
  });
4263
+ exports.get = _get;
3502
4264
  exports.DropdownMenu = DropdownMenu;
3503
4265
  exports.PlasmicHead = PlasmicHead;
3504
4266
  exports.PlasmicIcon = PlasmicIcon;