@plasmicapp/react-web 0.2.140 → 0.2.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.d.ts +29 -30
- package/dist/auth/PlasmicPageGuard.d.ts +6 -4
- package/dist/react-web.cjs.development.js +952 -114
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +952 -114
- package/dist/react-web.esm.js.map +1 -1
- package/dist/states/graph.d.ts +10 -4
- package/dist/states/helpers.d.ts +7 -9
- package/dist/states/valtio.d.ts +3 -1
- package/dist/stories/UseDollarState.stories.d.ts +7 -0
- package/package.json +2 -2
- package/skinny/dist/auth/PlasmicPageGuard.d.ts +6 -4
- package/skinny/dist/{collection-utils-43f97262.js → collection-utils-b5d4be02.js} +4 -4
- package/skinny/dist/{collection-utils-43f97262.js.map → collection-utils-b5d4be02.js.map} +1 -1
- package/skinny/dist/{common-9ebe374e.js → common-c2744215.js} +40 -2
- package/skinny/dist/{common-9ebe374e.js.map → common-c2744215.js.map} +1 -1
- package/skinny/dist/index.js +219 -90
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/plume/button/index.js +2 -2
- package/skinny/dist/plume/checkbox/index.js +4 -4
- package/skinny/dist/plume/menu/index.js +5 -5
- package/skinny/dist/plume/menu-button/index.js +4 -4
- package/skinny/dist/plume/select/index.js +5 -5
- package/skinny/dist/plume/switch/index.js +4 -4
- package/skinny/dist/plume/text-input/index.js +2 -2
- package/skinny/dist/plume/triggered-overlay/index.js +4 -4
- package/skinny/dist/{plume-utils-d9811bf3.js → plume-utils-653f4b8a.js} +2 -2
- package/skinny/dist/{plume-utils-d9811bf3.js.map → plume-utils-653f4b8a.js.map} +1 -1
- package/skinny/dist/{props-utils-228208e6.js → props-utils-70c2d02a.js} +2 -2
- package/skinny/dist/{props-utils-228208e6.js.map → props-utils-70c2d02a.js.map} +1 -1
- package/skinny/dist/{react-utils-7bc53870.js → react-utils-76d05959.js} +2 -2
- package/skinny/dist/{react-utils-7bc53870.js.map → react-utils-76d05959.js.map} +1 -1
- package/skinny/dist/render/PlasmicImg/index.js +2 -2
- package/skinny/dist/states/graph.d.ts +10 -4
- package/skinny/dist/states/helpers.d.ts +7 -9
- package/skinny/dist/states/valtio.d.ts +3 -1
- package/skinny/dist/stories/UseDollarState.stories.d.ts +7 -0
|
@@ -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
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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 (
|
|
54
|
-
|
|
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
|
}
|
|
@@ -1517,19 +2279,12 @@ function useTrigger(trigger, opts) {
|
|
|
1517
2279
|
var ARRAY_SYMBOL = /*#__PURE__*/Symbol("[]");
|
|
1518
2280
|
var PLASMIC_STATE_PROXY_SYMBOL = /*#__PURE__*/Symbol("plasmic.state.proxy");
|
|
1519
2281
|
|
|
1520
|
-
function generateStateOnChangeProp($state,
|
|
1521
|
-
return function (val
|
|
1522
|
-
return set($state,
|
|
2282
|
+
function generateStateOnChangeProp($state, path) {
|
|
2283
|
+
return function (val) {
|
|
2284
|
+
return set($state, path, val);
|
|
1523
2285
|
};
|
|
1524
2286
|
}
|
|
1525
|
-
|
|
1526
|
-
* This function generate the state value prop for repeated states
|
|
1527
|
-
* Example:
|
|
1528
|
-
* - parent[][].counter[].count
|
|
1529
|
-
* We need to pass `parent[index1][index2].counter to the child component
|
|
1530
|
-
*/
|
|
1531
|
-
function generateStateValueProp($state, path // ["parent", 0, 1, "counter"]
|
|
1532
|
-
) {
|
|
2287
|
+
function generateStateValueProp($state, path) {
|
|
1533
2288
|
return _get($state, path);
|
|
1534
2289
|
}
|
|
1535
2290
|
var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
@@ -1547,6 +2302,14 @@ function shallowEqual(a1, a2) {
|
|
|
1547
2302
|
}
|
|
1548
2303
|
return true;
|
|
1549
2304
|
}
|
|
2305
|
+
/**
|
|
2306
|
+
* Shallow comparison of arrays.
|
|
2307
|
+
*/
|
|
2308
|
+
function arrayEq(xs, ys) {
|
|
2309
|
+
return xs.length === ys.length && xs.every(function (_, index) {
|
|
2310
|
+
return xs[index] === ys[index];
|
|
2311
|
+
});
|
|
2312
|
+
}
|
|
1550
2313
|
function isNum(value) {
|
|
1551
2314
|
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
1552
2315
|
}
|
|
@@ -1609,69 +2372,84 @@ function assignValue(object, key, value) {
|
|
|
1609
2372
|
var UNINITIALIZED = /*#__PURE__*/Symbol("plasmic.unitialized");
|
|
1610
2373
|
var StateSpecNode = /*#__PURE__*/function () {
|
|
1611
2374
|
function StateSpecNode(specs) {
|
|
1612
|
-
this.
|
|
1613
|
-
this.
|
|
1614
|
-
this.
|
|
2375
|
+
this._specs = specs;
|
|
2376
|
+
this._edges = new Map();
|
|
2377
|
+
this._state = {};
|
|
1615
2378
|
}
|
|
1616
2379
|
var _proto = StateSpecNode.prototype;
|
|
2380
|
+
_proto.setSpecs = function setSpecs(specs) {
|
|
2381
|
+
this._specs = specs;
|
|
2382
|
+
};
|
|
2383
|
+
_proto.edges = function edges() {
|
|
2384
|
+
return this._edges;
|
|
2385
|
+
};
|
|
2386
|
+
_proto.state = function state() {
|
|
2387
|
+
return this._state;
|
|
2388
|
+
};
|
|
1617
2389
|
_proto.hasEdge = function hasEdge(key) {
|
|
1618
|
-
return this.
|
|
2390
|
+
return this._edges.has(key);
|
|
1619
2391
|
};
|
|
1620
2392
|
_proto.addEdge = function addEdge(key, node) {
|
|
1621
|
-
this.
|
|
2393
|
+
this._edges.set(key, node);
|
|
2394
|
+
};
|
|
2395
|
+
_proto.clearEdges = function clearEdges() {
|
|
2396
|
+
this._edges = new Map();
|
|
1622
2397
|
};
|
|
1623
2398
|
_proto.children = function children() {
|
|
1624
|
-
return this.
|
|
2399
|
+
return this._edges.values();
|
|
1625
2400
|
};
|
|
1626
2401
|
_proto.makeTransition = function makeTransition(key) {
|
|
1627
2402
|
key = isNum(key) ? ARRAY_SYMBOL : key;
|
|
1628
|
-
return this.
|
|
2403
|
+
return this._edges.get(key);
|
|
1629
2404
|
};
|
|
1630
2405
|
_proto.isLeaf = function isLeaf() {
|
|
1631
|
-
return this.
|
|
2406
|
+
return this._edges.size === 0;
|
|
1632
2407
|
};
|
|
1633
2408
|
_proto.hasArrayTransition = function hasArrayTransition() {
|
|
1634
|
-
return this.
|
|
2409
|
+
return this._edges.has(ARRAY_SYMBOL);
|
|
1635
2410
|
};
|
|
1636
2411
|
_proto.getSpec = function getSpec() {
|
|
1637
|
-
return this.
|
|
2412
|
+
return this._specs[0];
|
|
1638
2413
|
};
|
|
1639
2414
|
_proto.getAllSpecs = function getAllSpecs() {
|
|
1640
|
-
return this.
|
|
2415
|
+
return this._specs;
|
|
1641
2416
|
};
|
|
1642
2417
|
_proto.getState = function getState(path) {
|
|
1643
|
-
return this.
|
|
2418
|
+
return this._state[JSON.stringify(path)];
|
|
2419
|
+
};
|
|
2420
|
+
_proto.getInitFunc = function getInitFunc(stateCell) {
|
|
2421
|
+
var _stateCell$registered;
|
|
2422
|
+
return (_stateCell$registered = stateCell.registeredInitFunc) != null ? _stateCell$registered : this.getSpec().initFunc;
|
|
1644
2423
|
};
|
|
1645
2424
|
_proto.clearStates = function clearStates() {
|
|
1646
|
-
this.
|
|
2425
|
+
this._state = {};
|
|
1647
2426
|
};
|
|
1648
2427
|
_proto.states = function states() {
|
|
1649
|
-
return Object.values(this.
|
|
2428
|
+
return Object.values(this._state);
|
|
1650
2429
|
};
|
|
1651
2430
|
_proto.hasState = function hasState(path) {
|
|
1652
2431
|
var key = JSON.stringify(path);
|
|
1653
|
-
return key in this.
|
|
2432
|
+
return key in this._state;
|
|
1654
2433
|
};
|
|
1655
2434
|
_proto.createStateCell = function createStateCell(path) {
|
|
1656
2435
|
var key = JSON.stringify(path);
|
|
1657
|
-
this.
|
|
2436
|
+
this._state[key] = {
|
|
1658
2437
|
listeners: [],
|
|
1659
2438
|
initialValue: UNINITIALIZED,
|
|
1660
|
-
registeredInitFunc: this.getSpec().initFunc,
|
|
1661
2439
|
path: path
|
|
1662
2440
|
};
|
|
1663
2441
|
};
|
|
1664
2442
|
_proto.setInitialValue = function setInitialValue(path, value) {
|
|
1665
2443
|
var key = JSON.stringify(path);
|
|
1666
|
-
this.
|
|
2444
|
+
this._state[key].initialValue = value;
|
|
1667
2445
|
};
|
|
1668
2446
|
_proto.getInitialValue = function getInitialValue(path) {
|
|
1669
2447
|
var key = JSON.stringify(path);
|
|
1670
|
-
return this.
|
|
2448
|
+
return this._state[key].initialValue;
|
|
1671
2449
|
};
|
|
1672
2450
|
_proto.addListener = function addListener(path, f) {
|
|
1673
2451
|
var key = JSON.stringify(path);
|
|
1674
|
-
this.
|
|
2452
|
+
this._state[key].listeners.push(f);
|
|
1675
2453
|
};
|
|
1676
2454
|
return StateSpecNode;
|
|
1677
2455
|
}();
|
|
@@ -1706,14 +2484,43 @@ function buildTree(specs) {
|
|
|
1706
2484
|
};
|
|
1707
2485
|
return rec([]);
|
|
1708
2486
|
}
|
|
1709
|
-
function
|
|
2487
|
+
function updateTree(root, specs) {
|
|
2488
|
+
var internalSpec = specs.map(function (spec) {
|
|
2489
|
+
return _extends({}, spec, {
|
|
2490
|
+
pathObj: transformPathStringToObj(spec.path),
|
|
2491
|
+
isRepeated: spec.path.split(".").some(function (part) {
|
|
2492
|
+
return part.endsWith("[]");
|
|
2493
|
+
})
|
|
2494
|
+
});
|
|
2495
|
+
});
|
|
2496
|
+
var rec = function rec(oldNode, currentPath) {
|
|
2497
|
+
var nodeSpecs = internalSpec.filter(function (spec) {
|
|
2498
|
+
return shallowEqual(currentPath, spec.pathObj.slice(0, currentPath.length));
|
|
2499
|
+
});
|
|
2500
|
+
var node = oldNode != null ? oldNode : new StateSpecNode(nodeSpecs);
|
|
2501
|
+
node.setSpecs(nodeSpecs);
|
|
2502
|
+
var oldEdges = oldNode == null ? void 0 : oldNode.edges();
|
|
2503
|
+
node.clearEdges();
|
|
2504
|
+
node.getAllSpecs().forEach(function (spec) {
|
|
2505
|
+
if (spec.pathObj.length > currentPath.length) {
|
|
2506
|
+
var nextKey = spec.pathObj[currentPath.length];
|
|
2507
|
+
if (!node.hasEdge(nextKey)) {
|
|
2508
|
+
node.addEdge(nextKey, rec(oldEdges == null ? void 0 : oldEdges.get(nextKey), [].concat(currentPath, [nextKey])));
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
});
|
|
2512
|
+
return node;
|
|
2513
|
+
};
|
|
2514
|
+
return rec(root, []);
|
|
2515
|
+
}
|
|
2516
|
+
function getStateCells(root) {
|
|
1710
2517
|
var leaves = [];
|
|
1711
2518
|
var rec = function rec(node) {
|
|
1712
2519
|
for (var _iterator = _createForOfIteratorHelperLoose(node.children()), _step; !(_step = _iterator()).done;) {
|
|
1713
2520
|
var child = _step.value;
|
|
1714
2521
|
rec(child);
|
|
1715
2522
|
}
|
|
1716
|
-
if (node.isLeaf()) {
|
|
2523
|
+
if (node.isLeaf() && node.getAllSpecs().length > 0) {
|
|
1717
2524
|
leaves.push(node);
|
|
1718
2525
|
}
|
|
1719
2526
|
};
|
|
@@ -1728,7 +2535,6 @@ function findStateCell(root, pathStr, repetitionIndex) {
|
|
|
1728
2535
|
var part = _step2.value;
|
|
1729
2536
|
if (typeof part === "symbol") {
|
|
1730
2537
|
if (!root.hasArrayTransition() || !repetitionIndex || currRepIndex > repetitionIndex.length) {
|
|
1731
|
-
console.log(root);
|
|
1732
2538
|
throw new Error("transition not found: pathStr " + pathStr + " part " + (typeof part === "symbol" ? "[]" : part));
|
|
1733
2539
|
}
|
|
1734
2540
|
realPath.push(repetitionIndex[currRepIndex++]);
|
|
@@ -1783,7 +2589,7 @@ function initializeStateValue($$state, initialSpecNode, initialStatePath, proxyR
|
|
|
1783
2589
|
set(proxyRoot, initialStatePath, newValue);
|
|
1784
2590
|
});
|
|
1785
2591
|
});
|
|
1786
|
-
var initialValue = initialSpecNode.getState(initialStatePath)
|
|
2592
|
+
var initialValue = initialSpecNode.getInitFunc(initialSpecNode.getState(initialStatePath))($$state.props, $state, $$state.ctx);
|
|
1787
2593
|
initialSpecNode.setInitialValue(initialStatePath, clone(initialValue));
|
|
1788
2594
|
var initialSpec = initialSpecNode.getSpec();
|
|
1789
2595
|
var value = initialSpec.isImmutable ? mkUntrackedValue(initialValue) : clone(initialValue);
|
|
@@ -1796,7 +2602,8 @@ function initializeStateValue($$state, initialSpecNode, initialStatePath, proxyR
|
|
|
1796
2602
|
return initialValue;
|
|
1797
2603
|
}
|
|
1798
2604
|
function create$StateProxy($$state, leafHandlers) {
|
|
1799
|
-
var
|
|
2605
|
+
var proxyRoot;
|
|
2606
|
+
var rec = function rec(currPath, currNode, isOutside, initialObject) {
|
|
1800
2607
|
var getNextPath = function getNextPath(property) {
|
|
1801
2608
|
return [].concat(currPath, [isNum$1(property) ? +property : property]);
|
|
1802
2609
|
};
|
|
@@ -1812,7 +2619,7 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1812
2619
|
//we are always in a leaf, since we only have two cases:
|
|
1813
2620
|
// 1 - delete properties outside the state tree
|
|
1814
2621
|
// 2 - delete indices in repeated implicit states, but these can't be exposed, so they don't have onChangeProp
|
|
1815
|
-
(_$$state$props$spec$o = (_$$state$props2 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o.call(_$$state$props2, _get(
|
|
2622
|
+
(_$$state$props$spec$o = (_$$state$props2 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o.call(_$$state$props2, _get(proxyRoot, currPath.slice(spec.pathObj.length)));
|
|
1816
2623
|
}
|
|
1817
2624
|
return Reflect.deleteProperty(target, property);
|
|
1818
2625
|
},
|
|
@@ -1820,7 +2627,6 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1820
2627
|
if (property === PLASMIC_STATE_PROXY_SYMBOL) {
|
|
1821
2628
|
return true;
|
|
1822
2629
|
}
|
|
1823
|
-
proxyRoot = proxyRoot == null ? receiver : proxyRoot;
|
|
1824
2630
|
var nextPath = getNextPath(property);
|
|
1825
2631
|
if (isOutside || currNode.isLeaf()) {
|
|
1826
2632
|
return Reflect.get(target, property, receiver);
|
|
@@ -1828,15 +2634,14 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1828
2634
|
var nextNode = currNode.makeTransition(property);
|
|
1829
2635
|
if (nextNode != null && nextNode.isLeaf()) {
|
|
1830
2636
|
var _leafHandlers$get, _leafHandlers;
|
|
1831
|
-
return (_leafHandlers$get = (_leafHandlers = leafHandlers(nextNode, nextPath
|
|
2637
|
+
return (_leafHandlers$get = (_leafHandlers = leafHandlers(nextNode, nextPath)).get) == null ? void 0 : _leafHandlers$get.call(_leafHandlers, target, property, receiver);
|
|
1832
2638
|
} else if (nextNode && !(property in target)) {
|
|
1833
|
-
target[property] = rec(nextPath, nextNode, false,
|
|
2639
|
+
target[property] = rec(nextPath, nextNode, false, undefined);
|
|
1834
2640
|
}
|
|
1835
2641
|
return Reflect.get(target, property, receiver);
|
|
1836
2642
|
},
|
|
1837
2643
|
set: function set$1(target, property, value, receiver) {
|
|
1838
2644
|
var _nextNode, _nextNode2;
|
|
1839
|
-
proxyRoot = proxyRoot == null ? receiver : proxyRoot;
|
|
1840
2645
|
var nextPath = getNextPath(property);
|
|
1841
2646
|
var nextNode = currNode.makeTransition(property);
|
|
1842
2647
|
if (property === "registerInitFunc" && currPath.length === 0) {
|
|
@@ -1849,7 +2654,7 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1849
2654
|
}
|
|
1850
2655
|
if ((_nextNode = nextNode) != null && _nextNode.isLeaf()) {
|
|
1851
2656
|
var _leafHandlers$set, _leafHandlers2;
|
|
1852
|
-
(_leafHandlers$set = (_leafHandlers2 = leafHandlers(nextNode, nextPath
|
|
2657
|
+
(_leafHandlers$set = (_leafHandlers2 = leafHandlers(nextNode, nextPath)).set) == null ? void 0 : _leafHandlers$set.call(_leafHandlers2, target, property, value, receiver);
|
|
1853
2658
|
}
|
|
1854
2659
|
if (!isOutside && !currNode.isLeaf() && !nextNode) {
|
|
1855
2660
|
// can't set an unknown field in $state
|
|
@@ -1861,7 +2666,7 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1861
2666
|
nextNode = currNode;
|
|
1862
2667
|
}
|
|
1863
2668
|
if (canProxy(value)) {
|
|
1864
|
-
target[property] = rec(nextPath, nextNode, isOutside || currNode.isLeaf(),
|
|
2669
|
+
target[property] = rec(nextPath, nextNode, isOutside || currNode.isLeaf(), value);
|
|
1865
2670
|
} else if (!isOutside && !currNode.isLeaf() && !((_nextNode2 = nextNode) != null && _nextNode2.isLeaf())) {
|
|
1866
2671
|
throw new Error("inserting a primitive value into a non-leaf");
|
|
1867
2672
|
} else {
|
|
@@ -1880,6 +2685,9 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1880
2685
|
};
|
|
1881
2686
|
var baseObject = !isOutside && !currNode.isLeaf() ? currNode.hasArrayTransition() ? [] : {} : Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject != null ? initialObject : {}));
|
|
1882
2687
|
var proxyObj = new Proxy(baseObject, handlers);
|
|
2688
|
+
if (currPath.length === 0) {
|
|
2689
|
+
proxyRoot = proxyObj;
|
|
2690
|
+
}
|
|
1883
2691
|
if (initialObject) {
|
|
1884
2692
|
Reflect.ownKeys(initialObject).forEach(function (key) {
|
|
1885
2693
|
var desc = Object.getOwnPropertyDescriptor(initialObject, key);
|
|
@@ -1892,62 +2700,90 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1892
2700
|
}
|
|
1893
2701
|
return proxyObj;
|
|
1894
2702
|
};
|
|
1895
|
-
return rec([], $$state.rootSpecTree, false, undefined
|
|
2703
|
+
return rec([], $$state.rootSpecTree, false, undefined);
|
|
1896
2704
|
}
|
|
1897
2705
|
var mkUntrackedValue = function mkUntrackedValue(o) {
|
|
1898
2706
|
return o != null && typeof o === "object" ? valtio.ref(o) : o;
|
|
1899
2707
|
};
|
|
1900
|
-
function useDollarState(specs, props, $ctx) {
|
|
2708
|
+
function useDollarState(specs, props, $ctx, opts) {
|
|
1901
2709
|
var $$state = React__default.useRef(function () {
|
|
1902
2710
|
var rootSpecTree = buildTree(specs);
|
|
1903
2711
|
return {
|
|
1904
2712
|
rootSpecTree: rootSpecTree,
|
|
1905
|
-
specTreeLeaves:
|
|
2713
|
+
specTreeLeaves: getStateCells(rootSpecTree),
|
|
1906
2714
|
stateValues: valtio.proxy({}),
|
|
1907
2715
|
props: {},
|
|
1908
2716
|
ctx: {},
|
|
1909
|
-
|
|
2717
|
+
specs: [],
|
|
2718
|
+
registrationsQueue: valtio.proxy([])
|
|
1910
2719
|
};
|
|
1911
2720
|
}()).current;
|
|
1912
2721
|
$$state.props = props;
|
|
1913
2722
|
$$state.ctx = $ctx != null ? $ctx : {};
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
initializeStateValue($$state, node, path, proxyRoot);
|
|
1920
|
-
} else if (!spec.valueProp) {
|
|
1921
|
-
set(proxyRoot, path, spec.initVal);
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
return {
|
|
1925
|
-
get: function get(target, property, receiver) {
|
|
2723
|
+
$$state.specs = specs;
|
|
2724
|
+
var create$State = function create$State() {
|
|
2725
|
+
var $state = Object.assign(create$StateProxy($$state, function (node, path) {
|
|
2726
|
+
if (!node.hasState(path)) {
|
|
2727
|
+
node.createStateCell(path);
|
|
1926
2728
|
var spec = node.getSpec();
|
|
1927
|
-
if (spec.
|
|
1928
|
-
|
|
1929
|
-
} else {
|
|
1930
|
-
|
|
2729
|
+
if (spec.initFunc) {
|
|
2730
|
+
initializeStateValue($$state, node, path, $state);
|
|
2731
|
+
} else if (!spec.valueProp) {
|
|
2732
|
+
set($state, path, spec.initVal);
|
|
1931
2733
|
}
|
|
1932
2734
|
}
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2735
|
+
return {
|
|
2736
|
+
get: function get(target, property, receiver) {
|
|
2737
|
+
var spec = node.getSpec();
|
|
2738
|
+
if (spec.valueProp) {
|
|
2739
|
+
return $$state.props[spec.valueProp];
|
|
2740
|
+
} else {
|
|
2741
|
+
return Reflect.get(target, property, receiver);
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
};
|
|
2745
|
+
}), {
|
|
2746
|
+
registerInitFunc: function registerInitFunc(pathStr, f, repetitionIndex) {
|
|
2747
|
+
var _findStateCell = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex),
|
|
2748
|
+
node = _findStateCell.node,
|
|
2749
|
+
realPath = _findStateCell.realPath;
|
|
2750
|
+
if (!node.hasState(realPath)) {
|
|
2751
|
+
node.createStateCell(realPath);
|
|
2752
|
+
}
|
|
2753
|
+
if (!deepEqual(node.getState(realPath).initialValue, f($$state.props, $state, $$state.ctx))) {
|
|
2754
|
+
$$state.registrationsQueue.push(mkUntrackedValue({
|
|
2755
|
+
node: node,
|
|
2756
|
+
path: realPath,
|
|
2757
|
+
f: f
|
|
2758
|
+
}));
|
|
2759
|
+
}
|
|
1948
2760
|
}
|
|
2761
|
+
});
|
|
2762
|
+
return $state;
|
|
2763
|
+
};
|
|
2764
|
+
var ref = React__default.useRef(undefined);
|
|
2765
|
+
if (!ref.current) {
|
|
2766
|
+
ref.current = create$State();
|
|
2767
|
+
}
|
|
2768
|
+
var $state = ref.current;
|
|
2769
|
+
if (opts != null && opts.inCanvas) {
|
|
2770
|
+
$$state.rootSpecTree = updateTree($$state.rootSpecTree, specs);
|
|
2771
|
+
var newLeaves = getStateCells($$state.rootSpecTree);
|
|
2772
|
+
if (!arrayEq(newLeaves, $$state.specTreeLeaves)) {
|
|
2773
|
+
$state = ref.current = create$State();
|
|
2774
|
+
$$state.specTreeLeaves = newLeaves;
|
|
1949
2775
|
}
|
|
1950
|
-
|
|
2776
|
+
// we need to eager initialize all states in canvas to populate the data picker
|
|
2777
|
+
$$state.specTreeLeaves.forEach(function (node) {
|
|
2778
|
+
var spec = node.getSpec();
|
|
2779
|
+
if (spec.isRepeated || node.hasState(spec.pathObj)) {
|
|
2780
|
+
return;
|
|
2781
|
+
}
|
|
2782
|
+
node.createStateCell(spec.pathObj);
|
|
2783
|
+
var init = spec.valueProp ? $$state.props[spec.valueProp] : spec.initFunc ? initializeStateValue($$state, node, spec.pathObj, $state) : spec.initVal;
|
|
2784
|
+
set($state, spec.pathObj, init);
|
|
2785
|
+
});
|
|
2786
|
+
}
|
|
1951
2787
|
// For each spec with an initFunc, evaluate it and see if
|
|
1952
2788
|
// the init value has changed. If so, reset its state.
|
|
1953
2789
|
var resetSpecs = [];
|
|
@@ -1959,10 +2795,11 @@ function useDollarState(specs, props, $ctx) {
|
|
|
1959
2795
|
};
|
|
1960
2796
|
});
|
|
1961
2797
|
}).forEach(function (_ref2) {
|
|
1962
|
-
var
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
2798
|
+
var node = _ref2.node,
|
|
2799
|
+
stateCell = _ref2.stateCell;
|
|
2800
|
+
var initFunc = node.getInitFunc(stateCell);
|
|
2801
|
+
if (initFunc) {
|
|
2802
|
+
var newInit = initFunc(props, $state, $ctx != null ? $ctx : {});
|
|
1966
2803
|
if (!deepEqual(newInit, stateCell.initialValue)) {
|
|
1967
2804
|
resetSpecs.push({
|
|
1968
2805
|
stateCell: stateCell,
|
|
@@ -1987,16 +2824,16 @@ function useDollarState(specs, props, $ctx) {
|
|
|
1987
2824
|
});
|
|
1988
2825
|
}, [props, resetSpecs]);
|
|
1989
2826
|
useIsomorphicLayoutEffect$1(function () {
|
|
1990
|
-
$$state.registrationsQueue.
|
|
1991
|
-
var
|
|
1992
|
-
|
|
1993
|
-
|
|
2827
|
+
while ($$state.registrationsQueue.length) {
|
|
2828
|
+
var _$$state$registration = $$state.registrationsQueue.shift(),
|
|
2829
|
+
node = _$$state$registration.node,
|
|
2830
|
+
path = _$$state$registration.path,
|
|
2831
|
+
f = _$$state$registration.f;
|
|
1994
2832
|
var stateCell = node.getState(path);
|
|
1995
2833
|
stateCell.registeredInitFunc = f;
|
|
1996
2834
|
reInitializeState(node, stateCell);
|
|
1997
|
-
}
|
|
1998
|
-
|
|
1999
|
-
}, [$$state.registrationsQueue]);
|
|
2835
|
+
}
|
|
2836
|
+
}, [$$state.registrationsQueue.length]);
|
|
2000
2837
|
// immediately initialize exposed non-private states
|
|
2001
2838
|
useIsomorphicLayoutEffect$1(function () {
|
|
2002
2839
|
$$state.specTreeLeaves.forEach(function (node) {
|
|
@@ -2011,6 +2848,7 @@ function useDollarState(specs, props, $ctx) {
|
|
|
2011
2848
|
valtio.useSnapshot($$state.stateValues, {
|
|
2012
2849
|
sync: true
|
|
2013
2850
|
});
|
|
2851
|
+
valtio.useSnapshot($$state.registrationsQueue);
|
|
2014
2852
|
return $state;
|
|
2015
2853
|
}
|
|
2016
2854
|
|
|
@@ -3410,7 +4248,6 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
|
|
|
3410
4248
|
};
|
|
3411
4249
|
}
|
|
3412
4250
|
|
|
3413
|
-
exports.get = _get;
|
|
3414
4251
|
Object.defineProperty(exports, 'PlasmicDataSourceContextProvider', {
|
|
3415
4252
|
enumerable: true,
|
|
3416
4253
|
get: function () {
|
|
@@ -3423,6 +4260,7 @@ Object.defineProperty(exports, 'useCurrentUser', {
|
|
|
3423
4260
|
return dataSourcesContext.useCurrentUser;
|
|
3424
4261
|
}
|
|
3425
4262
|
});
|
|
4263
|
+
exports.get = _get;
|
|
3426
4264
|
exports.DropdownMenu = DropdownMenu;
|
|
3427
4265
|
exports.PlasmicHead = PlasmicHead;
|
|
3428
4266
|
exports.PlasmicIcon = PlasmicIcon;
|