@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
package/dist/react-web.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import classNames$1 from 'classnames';
|
|
2
|
+
import { usePlasmicDataSourceContext, PlasmicDataSourceContextProvider } from '@plasmicapp/data-sources-context';
|
|
3
|
+
export { PlasmicDataSourceContextProvider, useCurrentUser } from '@plasmicapp/data-sources-context';
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import React__default, { forwardRef, createElement, Fragment, isValidElement, useContext, createContext, useState, useRef, useMemo, useLayoutEffect, useEffect, useImperativeHandle, useCallback, cloneElement } from 'react';
|
|
4
6
|
import _get from 'dlv';
|
|
5
7
|
export { default as get } from 'dlv';
|
|
6
8
|
import ReactDOM__default, { createPortal } from 'react-dom';
|
|
7
|
-
import { PlasmicDataSourceContextProvider } from '@plasmicapp/data-sources-context';
|
|
8
|
-
export { PlasmicDataSourceContextProvider, useCurrentUser } from '@plasmicapp/data-sources-context';
|
|
9
9
|
import { SSRProvider, useIsSSR as useIsSSR$1 } from '@react-aria/ssr';
|
|
10
10
|
import { useFocusRing, useFocusable, FocusScope } from '@react-aria/focus';
|
|
11
11
|
import clone from 'clone';
|
|
@@ -26,31 +26,36 @@ import { useSelectState } from '@react-stately/select';
|
|
|
26
26
|
import { useSwitch as useSwitch$1 } from '@react-aria/switch';
|
|
27
27
|
import { useOverlay, useOverlayPosition, DismissButton } from '@react-aria/overlays';
|
|
28
28
|
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function canUserViewPage() {
|
|
37
|
-
if (!dataSourceCtxValue) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if (!dataSourceCtxValue.user) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
if (!("roleId" in dataSourceCtxValue.user)) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return validRoles.includes(dataSourceCtxValue.user.roleId);
|
|
29
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
30
|
+
try {
|
|
31
|
+
var info = gen[key](arg);
|
|
32
|
+
var value = info.value;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
reject(error);
|
|
35
|
+
return;
|
|
47
36
|
}
|
|
48
|
-
if (
|
|
49
|
-
|
|
37
|
+
if (info.done) {
|
|
38
|
+
resolve(value);
|
|
39
|
+
} else {
|
|
40
|
+
Promise.resolve(value).then(_next, _throw);
|
|
50
41
|
}
|
|
51
|
-
return children;
|
|
52
42
|
}
|
|
53
|
-
|
|
43
|
+
function _asyncToGenerator(fn) {
|
|
44
|
+
return function () {
|
|
45
|
+
var self = this,
|
|
46
|
+
args = arguments;
|
|
47
|
+
return new Promise(function (resolve, reject) {
|
|
48
|
+
var gen = fn.apply(self, args);
|
|
49
|
+
function _next(value) {
|
|
50
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
51
|
+
}
|
|
52
|
+
function _throw(err) {
|
|
53
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
54
|
+
}
|
|
55
|
+
_next(undefined);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
}
|
|
54
59
|
function _extends() {
|
|
55
60
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
56
61
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -109,6 +114,763 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
109
114
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
110
115
|
}
|
|
111
116
|
|
|
117
|
+
function createCommonjsModule(fn, module) {
|
|
118
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
122
|
+
/**
|
|
123
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
124
|
+
*
|
|
125
|
+
* This source code is licensed under the MIT license found in the
|
|
126
|
+
* LICENSE file in the root directory of this source tree.
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
var runtime = function (exports) {
|
|
130
|
+
|
|
131
|
+
var Op = Object.prototype;
|
|
132
|
+
var hasOwn = Op.hasOwnProperty;
|
|
133
|
+
var undefined$1; // More compressible than void 0.
|
|
134
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
135
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
136
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
137
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
138
|
+
function define(obj, key, value) {
|
|
139
|
+
Object.defineProperty(obj, key, {
|
|
140
|
+
value: value,
|
|
141
|
+
enumerable: true,
|
|
142
|
+
configurable: true,
|
|
143
|
+
writable: true
|
|
144
|
+
});
|
|
145
|
+
return obj[key];
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
149
|
+
define({}, "");
|
|
150
|
+
} catch (err) {
|
|
151
|
+
define = function define(obj, key, value) {
|
|
152
|
+
return obj[key] = value;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
156
|
+
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
157
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
158
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
159
|
+
var context = new Context(tryLocsList || []);
|
|
160
|
+
|
|
161
|
+
// The ._invoke method unifies the implementations of the .next,
|
|
162
|
+
// .throw, and .return methods.
|
|
163
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
164
|
+
return generator;
|
|
165
|
+
}
|
|
166
|
+
exports.wrap = wrap;
|
|
167
|
+
|
|
168
|
+
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
169
|
+
// record like context.tryEntries[i].completion. This interface could
|
|
170
|
+
// have been (and was previously) designed to take a closure to be
|
|
171
|
+
// invoked without arguments, but in all the cases we care about we
|
|
172
|
+
// already have an existing method we want to call, so there's no need
|
|
173
|
+
// to create a new function object. We can even get away with assuming
|
|
174
|
+
// the method takes exactly one argument, since that happens to be true
|
|
175
|
+
// in every case, so we don't have to touch the arguments object. The
|
|
176
|
+
// only additional allocation required is the completion record, which
|
|
177
|
+
// has a stable shape and so hopefully should be cheap to allocate.
|
|
178
|
+
function tryCatch(fn, obj, arg) {
|
|
179
|
+
try {
|
|
180
|
+
return {
|
|
181
|
+
type: "normal",
|
|
182
|
+
arg: fn.call(obj, arg)
|
|
183
|
+
};
|
|
184
|
+
} catch (err) {
|
|
185
|
+
return {
|
|
186
|
+
type: "throw",
|
|
187
|
+
arg: err
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
192
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
193
|
+
var GenStateExecuting = "executing";
|
|
194
|
+
var GenStateCompleted = "completed";
|
|
195
|
+
|
|
196
|
+
// Returning this object from the innerFn has the same effect as
|
|
197
|
+
// breaking out of the dispatch switch statement.
|
|
198
|
+
var ContinueSentinel = {};
|
|
199
|
+
|
|
200
|
+
// Dummy constructor functions that we use as the .constructor and
|
|
201
|
+
// .constructor.prototype properties for functions that return Generator
|
|
202
|
+
// objects. For full spec compliance, you may wish to configure your
|
|
203
|
+
// minifier not to mangle the names of these two functions.
|
|
204
|
+
function Generator() {}
|
|
205
|
+
function GeneratorFunction() {}
|
|
206
|
+
function GeneratorFunctionPrototype() {}
|
|
207
|
+
|
|
208
|
+
// This is a polyfill for %IteratorPrototype% for environments that
|
|
209
|
+
// don't natively support it.
|
|
210
|
+
var IteratorPrototype = {};
|
|
211
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
212
|
+
return this;
|
|
213
|
+
});
|
|
214
|
+
var getProto = Object.getPrototypeOf;
|
|
215
|
+
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
216
|
+
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
217
|
+
// This environment has a native %IteratorPrototype%; use it instead
|
|
218
|
+
// of the polyfill.
|
|
219
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
220
|
+
}
|
|
221
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
222
|
+
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
223
|
+
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
224
|
+
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
225
|
+
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
226
|
+
|
|
227
|
+
// Helper for defining the .next, .throw, and .return methods of the
|
|
228
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
229
|
+
function defineIteratorMethods(prototype) {
|
|
230
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
231
|
+
define(prototype, method, function (arg) {
|
|
232
|
+
return this._invoke(method, arg);
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
exports.isGeneratorFunction = function (genFun) {
|
|
237
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
238
|
+
return ctor ? ctor === GeneratorFunction ||
|
|
239
|
+
// For the native GeneratorFunction constructor, the best we can
|
|
240
|
+
// do is to check its .name property.
|
|
241
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
242
|
+
};
|
|
243
|
+
exports.mark = function (genFun) {
|
|
244
|
+
if (Object.setPrototypeOf) {
|
|
245
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
246
|
+
} else {
|
|
247
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
248
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
249
|
+
}
|
|
250
|
+
genFun.prototype = Object.create(Gp);
|
|
251
|
+
return genFun;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// Within the body of any async function, `await x` is transformed to
|
|
255
|
+
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
256
|
+
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
257
|
+
// meant to be awaited.
|
|
258
|
+
exports.awrap = function (arg) {
|
|
259
|
+
return {
|
|
260
|
+
__await: arg
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
264
|
+
function invoke(method, arg, resolve, reject) {
|
|
265
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
266
|
+
if (record.type === "throw") {
|
|
267
|
+
reject(record.arg);
|
|
268
|
+
} else {
|
|
269
|
+
var result = record.arg;
|
|
270
|
+
var value = result.value;
|
|
271
|
+
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
272
|
+
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
273
|
+
invoke("next", value, resolve, reject);
|
|
274
|
+
}, function (err) {
|
|
275
|
+
invoke("throw", err, resolve, reject);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
279
|
+
// When a yielded Promise is resolved, its final value becomes
|
|
280
|
+
// the .value of the Promise<{value,done}> result for the
|
|
281
|
+
// current iteration.
|
|
282
|
+
result.value = unwrapped;
|
|
283
|
+
resolve(result);
|
|
284
|
+
}, function (error) {
|
|
285
|
+
// If a rejected Promise was yielded, throw the rejection back
|
|
286
|
+
// into the async generator function so it can be handled there.
|
|
287
|
+
return invoke("throw", error, resolve, reject);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
var previousPromise;
|
|
292
|
+
function enqueue(method, arg) {
|
|
293
|
+
function callInvokeWithMethodAndArg() {
|
|
294
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
295
|
+
invoke(method, arg, resolve, reject);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return previousPromise =
|
|
299
|
+
// If enqueue has been called before, then we want to wait until
|
|
300
|
+
// all previous Promises have been resolved before calling invoke,
|
|
301
|
+
// so that results are always delivered in the correct order. If
|
|
302
|
+
// enqueue has not been called before, then it is important to
|
|
303
|
+
// call invoke immediately, without waiting on a callback to fire,
|
|
304
|
+
// so that the async generator function has the opportunity to do
|
|
305
|
+
// any necessary setup in a predictable way. This predictability
|
|
306
|
+
// is why the Promise constructor synchronously invokes its
|
|
307
|
+
// executor callback, and why async functions synchronously
|
|
308
|
+
// execute code before the first await. Since we implement simple
|
|
309
|
+
// async functions in terms of async generators, it is especially
|
|
310
|
+
// important to get this right, even though it requires care.
|
|
311
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
312
|
+
// Avoid propagating failures to Promises returned by later
|
|
313
|
+
// invocations of the iterator.
|
|
314
|
+
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Define the unified helper method that is used to implement .next,
|
|
318
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
319
|
+
this._invoke = enqueue;
|
|
320
|
+
}
|
|
321
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
322
|
+
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
323
|
+
return this;
|
|
324
|
+
});
|
|
325
|
+
exports.AsyncIterator = AsyncIterator;
|
|
326
|
+
|
|
327
|
+
// Note that simple async functions are implemented on top of
|
|
328
|
+
// AsyncIterator objects; they just return a Promise for the value of
|
|
329
|
+
// the final result produced by the iterator.
|
|
330
|
+
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
331
|
+
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
332
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
333
|
+
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
334
|
+
: iter.next().then(function (result) {
|
|
335
|
+
return result.done ? result.value : iter.next();
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
339
|
+
var state = GenStateSuspendedStart;
|
|
340
|
+
return function invoke(method, arg) {
|
|
341
|
+
if (state === GenStateExecuting) {
|
|
342
|
+
throw new Error("Generator is already running");
|
|
343
|
+
}
|
|
344
|
+
if (state === GenStateCompleted) {
|
|
345
|
+
if (method === "throw") {
|
|
346
|
+
throw arg;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
350
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
351
|
+
return doneResult();
|
|
352
|
+
}
|
|
353
|
+
context.method = method;
|
|
354
|
+
context.arg = arg;
|
|
355
|
+
while (true) {
|
|
356
|
+
var delegate = context.delegate;
|
|
357
|
+
if (delegate) {
|
|
358
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
359
|
+
if (delegateResult) {
|
|
360
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
361
|
+
return delegateResult;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (context.method === "next") {
|
|
365
|
+
// Setting context._sent for legacy support of Babel's
|
|
366
|
+
// function.sent implementation.
|
|
367
|
+
context.sent = context._sent = context.arg;
|
|
368
|
+
} else if (context.method === "throw") {
|
|
369
|
+
if (state === GenStateSuspendedStart) {
|
|
370
|
+
state = GenStateCompleted;
|
|
371
|
+
throw context.arg;
|
|
372
|
+
}
|
|
373
|
+
context.dispatchException(context.arg);
|
|
374
|
+
} else if (context.method === "return") {
|
|
375
|
+
context.abrupt("return", context.arg);
|
|
376
|
+
}
|
|
377
|
+
state = GenStateExecuting;
|
|
378
|
+
var record = tryCatch(innerFn, self, context);
|
|
379
|
+
if (record.type === "normal") {
|
|
380
|
+
// If an exception is thrown from innerFn, we leave state ===
|
|
381
|
+
// GenStateExecuting and loop back for another invocation.
|
|
382
|
+
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
383
|
+
if (record.arg === ContinueSentinel) {
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
value: record.arg,
|
|
388
|
+
done: context.done
|
|
389
|
+
};
|
|
390
|
+
} else if (record.type === "throw") {
|
|
391
|
+
state = GenStateCompleted;
|
|
392
|
+
// Dispatch the exception by looping back around to the
|
|
393
|
+
// context.dispatchException(context.arg) call above.
|
|
394
|
+
context.method = "throw";
|
|
395
|
+
context.arg = record.arg;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
402
|
+
// result, either by returning a { value, done } result from the
|
|
403
|
+
// delegate iterator, or by modifying context.method and context.arg,
|
|
404
|
+
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
405
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
406
|
+
var method = delegate.iterator[context.method];
|
|
407
|
+
if (method === undefined$1) {
|
|
408
|
+
// A .throw or .return when the delegate iterator has no .throw
|
|
409
|
+
// method always terminates the yield* loop.
|
|
410
|
+
context.delegate = null;
|
|
411
|
+
if (context.method === "throw") {
|
|
412
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
413
|
+
if (delegate.iterator["return"]) {
|
|
414
|
+
// If the delegate iterator has a return method, give it a
|
|
415
|
+
// chance to clean up.
|
|
416
|
+
context.method = "return";
|
|
417
|
+
context.arg = undefined$1;
|
|
418
|
+
maybeInvokeDelegate(delegate, context);
|
|
419
|
+
if (context.method === "throw") {
|
|
420
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
421
|
+
// "return" to "throw", let that override the TypeError below.
|
|
422
|
+
return ContinueSentinel;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
context.method = "throw";
|
|
426
|
+
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
427
|
+
}
|
|
428
|
+
return ContinueSentinel;
|
|
429
|
+
}
|
|
430
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
431
|
+
if (record.type === "throw") {
|
|
432
|
+
context.method = "throw";
|
|
433
|
+
context.arg = record.arg;
|
|
434
|
+
context.delegate = null;
|
|
435
|
+
return ContinueSentinel;
|
|
436
|
+
}
|
|
437
|
+
var info = record.arg;
|
|
438
|
+
if (!info) {
|
|
439
|
+
context.method = "throw";
|
|
440
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
441
|
+
context.delegate = null;
|
|
442
|
+
return ContinueSentinel;
|
|
443
|
+
}
|
|
444
|
+
if (info.done) {
|
|
445
|
+
// Assign the result of the finished delegate to the temporary
|
|
446
|
+
// variable specified by delegate.resultName (see delegateYield).
|
|
447
|
+
context[delegate.resultName] = info.value;
|
|
448
|
+
|
|
449
|
+
// Resume execution at the desired location (see delegateYield).
|
|
450
|
+
context.next = delegate.nextLoc;
|
|
451
|
+
|
|
452
|
+
// If context.method was "throw" but the delegate handled the
|
|
453
|
+
// exception, let the outer generator proceed normally. If
|
|
454
|
+
// context.method was "next", forget context.arg since it has been
|
|
455
|
+
// "consumed" by the delegate iterator. If context.method was
|
|
456
|
+
// "return", allow the original .return call to continue in the
|
|
457
|
+
// outer generator.
|
|
458
|
+
if (context.method !== "return") {
|
|
459
|
+
context.method = "next";
|
|
460
|
+
context.arg = undefined$1;
|
|
461
|
+
}
|
|
462
|
+
} else {
|
|
463
|
+
// Re-yield the result returned by the delegate method.
|
|
464
|
+
return info;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// The delegate iterator is finished, so forget it and continue with
|
|
468
|
+
// the outer generator.
|
|
469
|
+
context.delegate = null;
|
|
470
|
+
return ContinueSentinel;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
474
|
+
// unified ._invoke helper method.
|
|
475
|
+
defineIteratorMethods(Gp);
|
|
476
|
+
define(Gp, toStringTagSymbol, "Generator");
|
|
477
|
+
|
|
478
|
+
// A Generator should always return itself as the iterator object when the
|
|
479
|
+
// @@iterator function is called on it. Some browsers' implementations of the
|
|
480
|
+
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
481
|
+
// object to not be returned from this call. This ensures that doesn't happen.
|
|
482
|
+
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
483
|
+
define(Gp, iteratorSymbol, function () {
|
|
484
|
+
return this;
|
|
485
|
+
});
|
|
486
|
+
define(Gp, "toString", function () {
|
|
487
|
+
return "[object Generator]";
|
|
488
|
+
});
|
|
489
|
+
function pushTryEntry(locs) {
|
|
490
|
+
var entry = {
|
|
491
|
+
tryLoc: locs[0]
|
|
492
|
+
};
|
|
493
|
+
if (1 in locs) {
|
|
494
|
+
entry.catchLoc = locs[1];
|
|
495
|
+
}
|
|
496
|
+
if (2 in locs) {
|
|
497
|
+
entry.finallyLoc = locs[2];
|
|
498
|
+
entry.afterLoc = locs[3];
|
|
499
|
+
}
|
|
500
|
+
this.tryEntries.push(entry);
|
|
501
|
+
}
|
|
502
|
+
function resetTryEntry(entry) {
|
|
503
|
+
var record = entry.completion || {};
|
|
504
|
+
record.type = "normal";
|
|
505
|
+
delete record.arg;
|
|
506
|
+
entry.completion = record;
|
|
507
|
+
}
|
|
508
|
+
function Context(tryLocsList) {
|
|
509
|
+
// The root entry object (effectively a try statement without a catch
|
|
510
|
+
// or a finally block) gives us a place to store values thrown from
|
|
511
|
+
// locations where there is no enclosing try statement.
|
|
512
|
+
this.tryEntries = [{
|
|
513
|
+
tryLoc: "root"
|
|
514
|
+
}];
|
|
515
|
+
tryLocsList.forEach(pushTryEntry, this);
|
|
516
|
+
this.reset(true);
|
|
517
|
+
}
|
|
518
|
+
exports.keys = function (object) {
|
|
519
|
+
var keys = [];
|
|
520
|
+
for (var key in object) {
|
|
521
|
+
keys.push(key);
|
|
522
|
+
}
|
|
523
|
+
keys.reverse();
|
|
524
|
+
|
|
525
|
+
// Rather than returning an object with a next method, we keep
|
|
526
|
+
// things simple and return the next function itself.
|
|
527
|
+
return function next() {
|
|
528
|
+
while (keys.length) {
|
|
529
|
+
var key = keys.pop();
|
|
530
|
+
if (key in object) {
|
|
531
|
+
next.value = key;
|
|
532
|
+
next.done = false;
|
|
533
|
+
return next;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// To avoid creating an additional object, we just hang the .value
|
|
538
|
+
// and .done properties off the next function object itself. This
|
|
539
|
+
// also ensures that the minifier will not anonymize the function.
|
|
540
|
+
next.done = true;
|
|
541
|
+
return next;
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
function values(iterable) {
|
|
545
|
+
if (iterable) {
|
|
546
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
547
|
+
if (iteratorMethod) {
|
|
548
|
+
return iteratorMethod.call(iterable);
|
|
549
|
+
}
|
|
550
|
+
if (typeof iterable.next === "function") {
|
|
551
|
+
return iterable;
|
|
552
|
+
}
|
|
553
|
+
if (!isNaN(iterable.length)) {
|
|
554
|
+
var i = -1,
|
|
555
|
+
next = function next() {
|
|
556
|
+
while (++i < iterable.length) {
|
|
557
|
+
if (hasOwn.call(iterable, i)) {
|
|
558
|
+
next.value = iterable[i];
|
|
559
|
+
next.done = false;
|
|
560
|
+
return next;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
next.value = undefined$1;
|
|
564
|
+
next.done = true;
|
|
565
|
+
return next;
|
|
566
|
+
};
|
|
567
|
+
return next.next = next;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// Return an iterator with no values.
|
|
572
|
+
return {
|
|
573
|
+
next: doneResult
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
exports.values = values;
|
|
577
|
+
function doneResult() {
|
|
578
|
+
return {
|
|
579
|
+
value: undefined$1,
|
|
580
|
+
done: true
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
Context.prototype = {
|
|
584
|
+
constructor: Context,
|
|
585
|
+
reset: function reset(skipTempReset) {
|
|
586
|
+
this.prev = 0;
|
|
587
|
+
this.next = 0;
|
|
588
|
+
// Resetting context._sent for legacy support of Babel's
|
|
589
|
+
// function.sent implementation.
|
|
590
|
+
this.sent = this._sent = undefined$1;
|
|
591
|
+
this.done = false;
|
|
592
|
+
this.delegate = null;
|
|
593
|
+
this.method = "next";
|
|
594
|
+
this.arg = undefined$1;
|
|
595
|
+
this.tryEntries.forEach(resetTryEntry);
|
|
596
|
+
if (!skipTempReset) {
|
|
597
|
+
for (var name in this) {
|
|
598
|
+
// Not sure about the optimal order of these conditions:
|
|
599
|
+
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
600
|
+
this[name] = undefined$1;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
stop: function stop() {
|
|
606
|
+
this.done = true;
|
|
607
|
+
var rootEntry = this.tryEntries[0];
|
|
608
|
+
var rootRecord = rootEntry.completion;
|
|
609
|
+
if (rootRecord.type === "throw") {
|
|
610
|
+
throw rootRecord.arg;
|
|
611
|
+
}
|
|
612
|
+
return this.rval;
|
|
613
|
+
},
|
|
614
|
+
dispatchException: function dispatchException(exception) {
|
|
615
|
+
if (this.done) {
|
|
616
|
+
throw exception;
|
|
617
|
+
}
|
|
618
|
+
var context = this;
|
|
619
|
+
function handle(loc, caught) {
|
|
620
|
+
record.type = "throw";
|
|
621
|
+
record.arg = exception;
|
|
622
|
+
context.next = loc;
|
|
623
|
+
if (caught) {
|
|
624
|
+
// If the dispatched exception was caught by a catch block,
|
|
625
|
+
// then let that catch block handle the exception normally.
|
|
626
|
+
context.method = "next";
|
|
627
|
+
context.arg = undefined$1;
|
|
628
|
+
}
|
|
629
|
+
return !!caught;
|
|
630
|
+
}
|
|
631
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
632
|
+
var entry = this.tryEntries[i];
|
|
633
|
+
var record = entry.completion;
|
|
634
|
+
if (entry.tryLoc === "root") {
|
|
635
|
+
// Exception thrown outside of any try block that could handle
|
|
636
|
+
// it, so set the completion value of the entire function to
|
|
637
|
+
// throw the exception.
|
|
638
|
+
return handle("end");
|
|
639
|
+
}
|
|
640
|
+
if (entry.tryLoc <= this.prev) {
|
|
641
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
642
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
643
|
+
if (hasCatch && hasFinally) {
|
|
644
|
+
if (this.prev < entry.catchLoc) {
|
|
645
|
+
return handle(entry.catchLoc, true);
|
|
646
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
647
|
+
return handle(entry.finallyLoc);
|
|
648
|
+
}
|
|
649
|
+
} else if (hasCatch) {
|
|
650
|
+
if (this.prev < entry.catchLoc) {
|
|
651
|
+
return handle(entry.catchLoc, true);
|
|
652
|
+
}
|
|
653
|
+
} else if (hasFinally) {
|
|
654
|
+
if (this.prev < entry.finallyLoc) {
|
|
655
|
+
return handle(entry.finallyLoc);
|
|
656
|
+
}
|
|
657
|
+
} else {
|
|
658
|
+
throw new Error("try statement without catch or finally");
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
abrupt: function abrupt(type, arg) {
|
|
664
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
665
|
+
var entry = this.tryEntries[i];
|
|
666
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
667
|
+
var finallyEntry = entry;
|
|
668
|
+
break;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
672
|
+
// Ignore the finally entry if control is not jumping to a
|
|
673
|
+
// location outside the try/catch block.
|
|
674
|
+
finallyEntry = null;
|
|
675
|
+
}
|
|
676
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
677
|
+
record.type = type;
|
|
678
|
+
record.arg = arg;
|
|
679
|
+
if (finallyEntry) {
|
|
680
|
+
this.method = "next";
|
|
681
|
+
this.next = finallyEntry.finallyLoc;
|
|
682
|
+
return ContinueSentinel;
|
|
683
|
+
}
|
|
684
|
+
return this.complete(record);
|
|
685
|
+
},
|
|
686
|
+
complete: function complete(record, afterLoc) {
|
|
687
|
+
if (record.type === "throw") {
|
|
688
|
+
throw record.arg;
|
|
689
|
+
}
|
|
690
|
+
if (record.type === "break" || record.type === "continue") {
|
|
691
|
+
this.next = record.arg;
|
|
692
|
+
} else if (record.type === "return") {
|
|
693
|
+
this.rval = this.arg = record.arg;
|
|
694
|
+
this.method = "return";
|
|
695
|
+
this.next = "end";
|
|
696
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
697
|
+
this.next = afterLoc;
|
|
698
|
+
}
|
|
699
|
+
return ContinueSentinel;
|
|
700
|
+
},
|
|
701
|
+
finish: function finish(finallyLoc) {
|
|
702
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
703
|
+
var entry = this.tryEntries[i];
|
|
704
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
705
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
706
|
+
resetTryEntry(entry);
|
|
707
|
+
return ContinueSentinel;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
"catch": function _catch(tryLoc) {
|
|
712
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
713
|
+
var entry = this.tryEntries[i];
|
|
714
|
+
if (entry.tryLoc === tryLoc) {
|
|
715
|
+
var record = entry.completion;
|
|
716
|
+
if (record.type === "throw") {
|
|
717
|
+
var thrown = record.arg;
|
|
718
|
+
resetTryEntry(entry);
|
|
719
|
+
}
|
|
720
|
+
return thrown;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// The context.catch method must only be called with a location
|
|
725
|
+
// argument that corresponds to a known catch block.
|
|
726
|
+
throw new Error("illegal catch attempt");
|
|
727
|
+
},
|
|
728
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
729
|
+
this.delegate = {
|
|
730
|
+
iterator: values(iterable),
|
|
731
|
+
resultName: resultName,
|
|
732
|
+
nextLoc: nextLoc
|
|
733
|
+
};
|
|
734
|
+
if (this.method === "next") {
|
|
735
|
+
// Deliberately forget the last sent value so that we don't
|
|
736
|
+
// accidentally pass it on to the delegate.
|
|
737
|
+
this.arg = undefined$1;
|
|
738
|
+
}
|
|
739
|
+
return ContinueSentinel;
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
// Regardless of whether this script is executing as a CommonJS module
|
|
744
|
+
// or not, return the runtime object so that we can declare the variable
|
|
745
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
746
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
747
|
+
return exports;
|
|
748
|
+
}(
|
|
749
|
+
// If this script is executing as a CommonJS module, use module.exports
|
|
750
|
+
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
751
|
+
// object. Either way, the resulting object will be used to initialize
|
|
752
|
+
// the regeneratorRuntime variable at the top of this file.
|
|
753
|
+
module.exports );
|
|
754
|
+
try {
|
|
755
|
+
regeneratorRuntime = runtime;
|
|
756
|
+
} catch (accidentalStrictMode) {
|
|
757
|
+
// This module should not be running in strict mode, so the above
|
|
758
|
+
// assignment should always work unless something is misconfigured. Just
|
|
759
|
+
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
760
|
+
// we can explicitly access globalThis. In older engines we can escape
|
|
761
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
762
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
763
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
764
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
765
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
766
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
767
|
+
if (typeof globalThis === "object") {
|
|
768
|
+
globalThis.regeneratorRuntime = runtime;
|
|
769
|
+
} else {
|
|
770
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
function triggerLogin(_x, _x2) {
|
|
776
|
+
return _triggerLogin.apply(this, arguments);
|
|
777
|
+
}
|
|
778
|
+
function _triggerLogin() {
|
|
779
|
+
_triggerLogin = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(appId, authorizeEndpoint) {
|
|
780
|
+
var sha256, _sha, continueTo, state, code_verifier, code_challenge, params, url;
|
|
781
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
782
|
+
while (1) {
|
|
783
|
+
switch (_context2.prev = _context2.next) {
|
|
784
|
+
case 0:
|
|
785
|
+
_sha = function _sha3() {
|
|
786
|
+
_sha = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(text) {
|
|
787
|
+
var encoder, data, hashBuffer, hashArray, hashHex;
|
|
788
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
789
|
+
while (1) {
|
|
790
|
+
switch (_context.prev = _context.next) {
|
|
791
|
+
case 0:
|
|
792
|
+
encoder = new TextEncoder();
|
|
793
|
+
data = encoder.encode(text);
|
|
794
|
+
_context.next = 4;
|
|
795
|
+
return crypto.subtle.digest("SHA-256", data);
|
|
796
|
+
case 4:
|
|
797
|
+
hashBuffer = _context.sent;
|
|
798
|
+
hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
799
|
+
hashHex = hashArray.map(function (b) {
|
|
800
|
+
return b.toString(16).padStart(2, "0");
|
|
801
|
+
}).join("");
|
|
802
|
+
return _context.abrupt("return", hashHex);
|
|
803
|
+
case 8:
|
|
804
|
+
case "end":
|
|
805
|
+
return _context.stop();
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}, _callee);
|
|
809
|
+
}));
|
|
810
|
+
return _sha.apply(this, arguments);
|
|
811
|
+
};
|
|
812
|
+
sha256 = function _sha2(_x3) {
|
|
813
|
+
return _sha.apply(this, arguments);
|
|
814
|
+
};
|
|
815
|
+
continueTo = window.location.href;
|
|
816
|
+
state = JSON.stringify({
|
|
817
|
+
continueTo: continueTo
|
|
818
|
+
});
|
|
819
|
+
code_verifier = crypto.randomUUID();
|
|
820
|
+
localStorage.setItem("code_verifier", code_verifier);
|
|
821
|
+
_context2.next = 8;
|
|
822
|
+
return sha256(code_verifier);
|
|
823
|
+
case 8:
|
|
824
|
+
code_challenge = _context2.sent;
|
|
825
|
+
params = new URLSearchParams();
|
|
826
|
+
params.set("client_id", appId);
|
|
827
|
+
params.set("state", state);
|
|
828
|
+
params.set("response_type", "code");
|
|
829
|
+
params.set("code_challenge", code_challenge);
|
|
830
|
+
params.set("code_challenge_method", "S256");
|
|
831
|
+
url = authorizeEndpoint + "?" + params.toString();
|
|
832
|
+
window.location.href = url;
|
|
833
|
+
case 17:
|
|
834
|
+
case "end":
|
|
835
|
+
return _context2.stop();
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}, _callee2);
|
|
839
|
+
}));
|
|
840
|
+
return _triggerLogin.apply(this, arguments);
|
|
841
|
+
}
|
|
842
|
+
function PlasmicPageGuard(props) {
|
|
843
|
+
var appId = props.appId,
|
|
844
|
+
authorizeEndpoint = props.authorizeEndpoint,
|
|
845
|
+
validRoles = props.validRoles,
|
|
846
|
+
children = props.children;
|
|
847
|
+
var dataSourceCtxValue = usePlasmicDataSourceContext();
|
|
848
|
+
React__default.useEffect(function () {
|
|
849
|
+
if (dataSourceCtxValue && "isUserLoading" in dataSourceCtxValue && !dataSourceCtxValue.isUserLoading && !dataSourceCtxValue.user) {
|
|
850
|
+
triggerLogin(appId, authorizeEndpoint);
|
|
851
|
+
}
|
|
852
|
+
}, [dataSourceCtxValue, appId, authorizeEndpoint]);
|
|
853
|
+
function canUserViewPage() {
|
|
854
|
+
if (!dataSourceCtxValue) {
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
if (!dataSourceCtxValue.user) {
|
|
858
|
+
return false;
|
|
859
|
+
}
|
|
860
|
+
if (!("roleId" in dataSourceCtxValue.user)) {
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
return validRoles.includes(dataSourceCtxValue.user.roleId);
|
|
864
|
+
}
|
|
865
|
+
if (!dataSourceCtxValue || dataSourceCtxValue.isUserLoading || !dataSourceCtxValue.user) {
|
|
866
|
+
return null;
|
|
867
|
+
}
|
|
868
|
+
if (!canUserViewPage()) {
|
|
869
|
+
return React__default.createElement("div", null, "You don't have access to this page");
|
|
870
|
+
}
|
|
871
|
+
return children;
|
|
872
|
+
}
|
|
873
|
+
|
|
112
874
|
function notNil(x) {
|
|
113
875
|
return x != null;
|
|
114
876
|
}
|
|
@@ -1512,19 +2274,12 @@ function useTrigger(trigger, opts) {
|
|
|
1512
2274
|
var ARRAY_SYMBOL = /*#__PURE__*/Symbol("[]");
|
|
1513
2275
|
var PLASMIC_STATE_PROXY_SYMBOL = /*#__PURE__*/Symbol("plasmic.state.proxy");
|
|
1514
2276
|
|
|
1515
|
-
function generateStateOnChangeProp($state,
|
|
1516
|
-
return function (val
|
|
1517
|
-
return set($state,
|
|
2277
|
+
function generateStateOnChangeProp($state, path) {
|
|
2278
|
+
return function (val) {
|
|
2279
|
+
return set($state, path, val);
|
|
1518
2280
|
};
|
|
1519
2281
|
}
|
|
1520
|
-
|
|
1521
|
-
* This function generate the state value prop for repeated states
|
|
1522
|
-
* Example:
|
|
1523
|
-
* - parent[][].counter[].count
|
|
1524
|
-
* We need to pass `parent[index1][index2].counter to the child component
|
|
1525
|
-
*/
|
|
1526
|
-
function generateStateValueProp($state, path // ["parent", 0, 1, "counter"]
|
|
1527
|
-
) {
|
|
2282
|
+
function generateStateValueProp($state, path) {
|
|
1528
2283
|
return _get($state, path);
|
|
1529
2284
|
}
|
|
1530
2285
|
var useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
@@ -1542,6 +2297,14 @@ function shallowEqual(a1, a2) {
|
|
|
1542
2297
|
}
|
|
1543
2298
|
return true;
|
|
1544
2299
|
}
|
|
2300
|
+
/**
|
|
2301
|
+
* Shallow comparison of arrays.
|
|
2302
|
+
*/
|
|
2303
|
+
function arrayEq(xs, ys) {
|
|
2304
|
+
return xs.length === ys.length && xs.every(function (_, index) {
|
|
2305
|
+
return xs[index] === ys[index];
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
1545
2308
|
function isNum(value) {
|
|
1546
2309
|
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
1547
2310
|
}
|
|
@@ -1604,69 +2367,84 @@ function assignValue(object, key, value) {
|
|
|
1604
2367
|
var UNINITIALIZED = /*#__PURE__*/Symbol("plasmic.unitialized");
|
|
1605
2368
|
var StateSpecNode = /*#__PURE__*/function () {
|
|
1606
2369
|
function StateSpecNode(specs) {
|
|
1607
|
-
this.
|
|
1608
|
-
this.
|
|
1609
|
-
this.
|
|
2370
|
+
this._specs = specs;
|
|
2371
|
+
this._edges = new Map();
|
|
2372
|
+
this._state = {};
|
|
1610
2373
|
}
|
|
1611
2374
|
var _proto = StateSpecNode.prototype;
|
|
2375
|
+
_proto.setSpecs = function setSpecs(specs) {
|
|
2376
|
+
this._specs = specs;
|
|
2377
|
+
};
|
|
2378
|
+
_proto.edges = function edges() {
|
|
2379
|
+
return this._edges;
|
|
2380
|
+
};
|
|
2381
|
+
_proto.state = function state() {
|
|
2382
|
+
return this._state;
|
|
2383
|
+
};
|
|
1612
2384
|
_proto.hasEdge = function hasEdge(key) {
|
|
1613
|
-
return this.
|
|
2385
|
+
return this._edges.has(key);
|
|
1614
2386
|
};
|
|
1615
2387
|
_proto.addEdge = function addEdge(key, node) {
|
|
1616
|
-
this.
|
|
2388
|
+
this._edges.set(key, node);
|
|
2389
|
+
};
|
|
2390
|
+
_proto.clearEdges = function clearEdges() {
|
|
2391
|
+
this._edges = new Map();
|
|
1617
2392
|
};
|
|
1618
2393
|
_proto.children = function children() {
|
|
1619
|
-
return this.
|
|
2394
|
+
return this._edges.values();
|
|
1620
2395
|
};
|
|
1621
2396
|
_proto.makeTransition = function makeTransition(key) {
|
|
1622
2397
|
key = isNum(key) ? ARRAY_SYMBOL : key;
|
|
1623
|
-
return this.
|
|
2398
|
+
return this._edges.get(key);
|
|
1624
2399
|
};
|
|
1625
2400
|
_proto.isLeaf = function isLeaf() {
|
|
1626
|
-
return this.
|
|
2401
|
+
return this._edges.size === 0;
|
|
1627
2402
|
};
|
|
1628
2403
|
_proto.hasArrayTransition = function hasArrayTransition() {
|
|
1629
|
-
return this.
|
|
2404
|
+
return this._edges.has(ARRAY_SYMBOL);
|
|
1630
2405
|
};
|
|
1631
2406
|
_proto.getSpec = function getSpec() {
|
|
1632
|
-
return this.
|
|
2407
|
+
return this._specs[0];
|
|
1633
2408
|
};
|
|
1634
2409
|
_proto.getAllSpecs = function getAllSpecs() {
|
|
1635
|
-
return this.
|
|
2410
|
+
return this._specs;
|
|
1636
2411
|
};
|
|
1637
2412
|
_proto.getState = function getState(path) {
|
|
1638
|
-
return this.
|
|
2413
|
+
return this._state[JSON.stringify(path)];
|
|
2414
|
+
};
|
|
2415
|
+
_proto.getInitFunc = function getInitFunc(stateCell) {
|
|
2416
|
+
var _stateCell$registered;
|
|
2417
|
+
return (_stateCell$registered = stateCell.registeredInitFunc) != null ? _stateCell$registered : this.getSpec().initFunc;
|
|
1639
2418
|
};
|
|
1640
2419
|
_proto.clearStates = function clearStates() {
|
|
1641
|
-
this.
|
|
2420
|
+
this._state = {};
|
|
1642
2421
|
};
|
|
1643
2422
|
_proto.states = function states() {
|
|
1644
|
-
return Object.values(this.
|
|
2423
|
+
return Object.values(this._state);
|
|
1645
2424
|
};
|
|
1646
2425
|
_proto.hasState = function hasState(path) {
|
|
1647
2426
|
var key = JSON.stringify(path);
|
|
1648
|
-
return key in this.
|
|
2427
|
+
return key in this._state;
|
|
1649
2428
|
};
|
|
1650
2429
|
_proto.createStateCell = function createStateCell(path) {
|
|
1651
2430
|
var key = JSON.stringify(path);
|
|
1652
|
-
this.
|
|
2431
|
+
this._state[key] = {
|
|
1653
2432
|
listeners: [],
|
|
1654
2433
|
initialValue: UNINITIALIZED,
|
|
1655
|
-
registeredInitFunc: this.getSpec().initFunc,
|
|
1656
2434
|
path: path
|
|
1657
2435
|
};
|
|
1658
2436
|
};
|
|
1659
2437
|
_proto.setInitialValue = function setInitialValue(path, value) {
|
|
1660
2438
|
var key = JSON.stringify(path);
|
|
1661
|
-
this.
|
|
2439
|
+
this._state[key].initialValue = value;
|
|
1662
2440
|
};
|
|
1663
2441
|
_proto.getInitialValue = function getInitialValue(path) {
|
|
1664
2442
|
var key = JSON.stringify(path);
|
|
1665
|
-
return this.
|
|
2443
|
+
return this._state[key].initialValue;
|
|
1666
2444
|
};
|
|
1667
2445
|
_proto.addListener = function addListener(path, f) {
|
|
1668
2446
|
var key = JSON.stringify(path);
|
|
1669
|
-
this.
|
|
2447
|
+
this._state[key].listeners.push(f);
|
|
1670
2448
|
};
|
|
1671
2449
|
return StateSpecNode;
|
|
1672
2450
|
}();
|
|
@@ -1701,14 +2479,43 @@ function buildTree(specs) {
|
|
|
1701
2479
|
};
|
|
1702
2480
|
return rec([]);
|
|
1703
2481
|
}
|
|
1704
|
-
function
|
|
2482
|
+
function updateTree(root, specs) {
|
|
2483
|
+
var internalSpec = specs.map(function (spec) {
|
|
2484
|
+
return _extends({}, spec, {
|
|
2485
|
+
pathObj: transformPathStringToObj(spec.path),
|
|
2486
|
+
isRepeated: spec.path.split(".").some(function (part) {
|
|
2487
|
+
return part.endsWith("[]");
|
|
2488
|
+
})
|
|
2489
|
+
});
|
|
2490
|
+
});
|
|
2491
|
+
var rec = function rec(oldNode, currentPath) {
|
|
2492
|
+
var nodeSpecs = internalSpec.filter(function (spec) {
|
|
2493
|
+
return shallowEqual(currentPath, spec.pathObj.slice(0, currentPath.length));
|
|
2494
|
+
});
|
|
2495
|
+
var node = oldNode != null ? oldNode : new StateSpecNode(nodeSpecs);
|
|
2496
|
+
node.setSpecs(nodeSpecs);
|
|
2497
|
+
var oldEdges = oldNode == null ? void 0 : oldNode.edges();
|
|
2498
|
+
node.clearEdges();
|
|
2499
|
+
node.getAllSpecs().forEach(function (spec) {
|
|
2500
|
+
if (spec.pathObj.length > currentPath.length) {
|
|
2501
|
+
var nextKey = spec.pathObj[currentPath.length];
|
|
2502
|
+
if (!node.hasEdge(nextKey)) {
|
|
2503
|
+
node.addEdge(nextKey, rec(oldEdges == null ? void 0 : oldEdges.get(nextKey), [].concat(currentPath, [nextKey])));
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
});
|
|
2507
|
+
return node;
|
|
2508
|
+
};
|
|
2509
|
+
return rec(root, []);
|
|
2510
|
+
}
|
|
2511
|
+
function getStateCells(root) {
|
|
1705
2512
|
var leaves = [];
|
|
1706
2513
|
var rec = function rec(node) {
|
|
1707
2514
|
for (var _iterator = _createForOfIteratorHelperLoose(node.children()), _step; !(_step = _iterator()).done;) {
|
|
1708
2515
|
var child = _step.value;
|
|
1709
2516
|
rec(child);
|
|
1710
2517
|
}
|
|
1711
|
-
if (node.isLeaf()) {
|
|
2518
|
+
if (node.isLeaf() && node.getAllSpecs().length > 0) {
|
|
1712
2519
|
leaves.push(node);
|
|
1713
2520
|
}
|
|
1714
2521
|
};
|
|
@@ -1723,7 +2530,6 @@ function findStateCell(root, pathStr, repetitionIndex) {
|
|
|
1723
2530
|
var part = _step2.value;
|
|
1724
2531
|
if (typeof part === "symbol") {
|
|
1725
2532
|
if (!root.hasArrayTransition() || !repetitionIndex || currRepIndex > repetitionIndex.length) {
|
|
1726
|
-
console.log(root);
|
|
1727
2533
|
throw new Error("transition not found: pathStr " + pathStr + " part " + (typeof part === "symbol" ? "[]" : part));
|
|
1728
2534
|
}
|
|
1729
2535
|
realPath.push(repetitionIndex[currRepIndex++]);
|
|
@@ -1778,7 +2584,7 @@ function initializeStateValue($$state, initialSpecNode, initialStatePath, proxyR
|
|
|
1778
2584
|
set(proxyRoot, initialStatePath, newValue);
|
|
1779
2585
|
});
|
|
1780
2586
|
});
|
|
1781
|
-
var initialValue = initialSpecNode.getState(initialStatePath)
|
|
2587
|
+
var initialValue = initialSpecNode.getInitFunc(initialSpecNode.getState(initialStatePath))($$state.props, $state, $$state.ctx);
|
|
1782
2588
|
initialSpecNode.setInitialValue(initialStatePath, clone(initialValue));
|
|
1783
2589
|
var initialSpec = initialSpecNode.getSpec();
|
|
1784
2590
|
var value = initialSpec.isImmutable ? mkUntrackedValue(initialValue) : clone(initialValue);
|
|
@@ -1791,7 +2597,8 @@ function initializeStateValue($$state, initialSpecNode, initialStatePath, proxyR
|
|
|
1791
2597
|
return initialValue;
|
|
1792
2598
|
}
|
|
1793
2599
|
function create$StateProxy($$state, leafHandlers) {
|
|
1794
|
-
var
|
|
2600
|
+
var proxyRoot;
|
|
2601
|
+
var rec = function rec(currPath, currNode, isOutside, initialObject) {
|
|
1795
2602
|
var getNextPath = function getNextPath(property) {
|
|
1796
2603
|
return [].concat(currPath, [isNum$1(property) ? +property : property]);
|
|
1797
2604
|
};
|
|
@@ -1807,7 +2614,7 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1807
2614
|
//we are always in a leaf, since we only have two cases:
|
|
1808
2615
|
// 1 - delete properties outside the state tree
|
|
1809
2616
|
// 2 - delete indices in repeated implicit states, but these can't be exposed, so they don't have onChangeProp
|
|
1810
|
-
(_$$state$props$spec$o = (_$$state$props2 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o.call(_$$state$props2, _get(
|
|
2617
|
+
(_$$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)));
|
|
1811
2618
|
}
|
|
1812
2619
|
return Reflect.deleteProperty(target, property);
|
|
1813
2620
|
},
|
|
@@ -1815,7 +2622,6 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1815
2622
|
if (property === PLASMIC_STATE_PROXY_SYMBOL) {
|
|
1816
2623
|
return true;
|
|
1817
2624
|
}
|
|
1818
|
-
proxyRoot = proxyRoot == null ? receiver : proxyRoot;
|
|
1819
2625
|
var nextPath = getNextPath(property);
|
|
1820
2626
|
if (isOutside || currNode.isLeaf()) {
|
|
1821
2627
|
return Reflect.get(target, property, receiver);
|
|
@@ -1823,15 +2629,14 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1823
2629
|
var nextNode = currNode.makeTransition(property);
|
|
1824
2630
|
if (nextNode != null && nextNode.isLeaf()) {
|
|
1825
2631
|
var _leafHandlers$get, _leafHandlers;
|
|
1826
|
-
return (_leafHandlers$get = (_leafHandlers = leafHandlers(nextNode, nextPath
|
|
2632
|
+
return (_leafHandlers$get = (_leafHandlers = leafHandlers(nextNode, nextPath)).get) == null ? void 0 : _leafHandlers$get.call(_leafHandlers, target, property, receiver);
|
|
1827
2633
|
} else if (nextNode && !(property in target)) {
|
|
1828
|
-
target[property] = rec(nextPath, nextNode, false,
|
|
2634
|
+
target[property] = rec(nextPath, nextNode, false, undefined);
|
|
1829
2635
|
}
|
|
1830
2636
|
return Reflect.get(target, property, receiver);
|
|
1831
2637
|
},
|
|
1832
2638
|
set: function set$1(target, property, value, receiver) {
|
|
1833
2639
|
var _nextNode, _nextNode2;
|
|
1834
|
-
proxyRoot = proxyRoot == null ? receiver : proxyRoot;
|
|
1835
2640
|
var nextPath = getNextPath(property);
|
|
1836
2641
|
var nextNode = currNode.makeTransition(property);
|
|
1837
2642
|
if (property === "registerInitFunc" && currPath.length === 0) {
|
|
@@ -1844,7 +2649,7 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1844
2649
|
}
|
|
1845
2650
|
if ((_nextNode = nextNode) != null && _nextNode.isLeaf()) {
|
|
1846
2651
|
var _leafHandlers$set, _leafHandlers2;
|
|
1847
|
-
(_leafHandlers$set = (_leafHandlers2 = leafHandlers(nextNode, nextPath
|
|
2652
|
+
(_leafHandlers$set = (_leafHandlers2 = leafHandlers(nextNode, nextPath)).set) == null ? void 0 : _leafHandlers$set.call(_leafHandlers2, target, property, value, receiver);
|
|
1848
2653
|
}
|
|
1849
2654
|
if (!isOutside && !currNode.isLeaf() && !nextNode) {
|
|
1850
2655
|
// can't set an unknown field in $state
|
|
@@ -1856,7 +2661,7 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1856
2661
|
nextNode = currNode;
|
|
1857
2662
|
}
|
|
1858
2663
|
if (canProxy(value)) {
|
|
1859
|
-
target[property] = rec(nextPath, nextNode, isOutside || currNode.isLeaf(),
|
|
2664
|
+
target[property] = rec(nextPath, nextNode, isOutside || currNode.isLeaf(), value);
|
|
1860
2665
|
} else if (!isOutside && !currNode.isLeaf() && !((_nextNode2 = nextNode) != null && _nextNode2.isLeaf())) {
|
|
1861
2666
|
throw new Error("inserting a primitive value into a non-leaf");
|
|
1862
2667
|
} else {
|
|
@@ -1875,6 +2680,9 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1875
2680
|
};
|
|
1876
2681
|
var baseObject = !isOutside && !currNode.isLeaf() ? currNode.hasArrayTransition() ? [] : {} : Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject != null ? initialObject : {}));
|
|
1877
2682
|
var proxyObj = new Proxy(baseObject, handlers);
|
|
2683
|
+
if (currPath.length === 0) {
|
|
2684
|
+
proxyRoot = proxyObj;
|
|
2685
|
+
}
|
|
1878
2686
|
if (initialObject) {
|
|
1879
2687
|
Reflect.ownKeys(initialObject).forEach(function (key) {
|
|
1880
2688
|
var desc = Object.getOwnPropertyDescriptor(initialObject, key);
|
|
@@ -1887,62 +2695,90 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
1887
2695
|
}
|
|
1888
2696
|
return proxyObj;
|
|
1889
2697
|
};
|
|
1890
|
-
return rec([], $$state.rootSpecTree, false, undefined
|
|
2698
|
+
return rec([], $$state.rootSpecTree, false, undefined);
|
|
1891
2699
|
}
|
|
1892
2700
|
var mkUntrackedValue = function mkUntrackedValue(o) {
|
|
1893
2701
|
return o != null && typeof o === "object" ? ref(o) : o;
|
|
1894
2702
|
};
|
|
1895
|
-
function useDollarState(specs, props, $ctx) {
|
|
2703
|
+
function useDollarState(specs, props, $ctx, opts) {
|
|
1896
2704
|
var $$state = React__default.useRef(function () {
|
|
1897
2705
|
var rootSpecTree = buildTree(specs);
|
|
1898
2706
|
return {
|
|
1899
2707
|
rootSpecTree: rootSpecTree,
|
|
1900
|
-
specTreeLeaves:
|
|
2708
|
+
specTreeLeaves: getStateCells(rootSpecTree),
|
|
1901
2709
|
stateValues: proxy({}),
|
|
1902
2710
|
props: {},
|
|
1903
2711
|
ctx: {},
|
|
1904
|
-
|
|
2712
|
+
specs: [],
|
|
2713
|
+
registrationsQueue: proxy([])
|
|
1905
2714
|
};
|
|
1906
2715
|
}()).current;
|
|
1907
2716
|
$$state.props = props;
|
|
1908
2717
|
$$state.ctx = $ctx != null ? $ctx : {};
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
initializeStateValue($$state, node, path, proxyRoot);
|
|
1915
|
-
} else if (!spec.valueProp) {
|
|
1916
|
-
set(proxyRoot, path, spec.initVal);
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
|
-
return {
|
|
1920
|
-
get: function get(target, property, receiver) {
|
|
2718
|
+
$$state.specs = specs;
|
|
2719
|
+
var create$State = function create$State() {
|
|
2720
|
+
var $state = Object.assign(create$StateProxy($$state, function (node, path) {
|
|
2721
|
+
if (!node.hasState(path)) {
|
|
2722
|
+
node.createStateCell(path);
|
|
1921
2723
|
var spec = node.getSpec();
|
|
1922
|
-
if (spec.
|
|
1923
|
-
|
|
1924
|
-
} else {
|
|
1925
|
-
|
|
2724
|
+
if (spec.initFunc) {
|
|
2725
|
+
initializeStateValue($$state, node, path, $state);
|
|
2726
|
+
} else if (!spec.valueProp) {
|
|
2727
|
+
set($state, path, spec.initVal);
|
|
1926
2728
|
}
|
|
1927
2729
|
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2730
|
+
return {
|
|
2731
|
+
get: function get(target, property, receiver) {
|
|
2732
|
+
var spec = node.getSpec();
|
|
2733
|
+
if (spec.valueProp) {
|
|
2734
|
+
return $$state.props[spec.valueProp];
|
|
2735
|
+
} else {
|
|
2736
|
+
return Reflect.get(target, property, receiver);
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
}), {
|
|
2741
|
+
registerInitFunc: function registerInitFunc(pathStr, f, repetitionIndex) {
|
|
2742
|
+
var _findStateCell = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex),
|
|
2743
|
+
node = _findStateCell.node,
|
|
2744
|
+
realPath = _findStateCell.realPath;
|
|
2745
|
+
if (!node.hasState(realPath)) {
|
|
2746
|
+
node.createStateCell(realPath);
|
|
2747
|
+
}
|
|
2748
|
+
if (!deepEqual(node.getState(realPath).initialValue, f($$state.props, $state, $$state.ctx))) {
|
|
2749
|
+
$$state.registrationsQueue.push(mkUntrackedValue({
|
|
2750
|
+
node: node,
|
|
2751
|
+
path: realPath,
|
|
2752
|
+
f: f
|
|
2753
|
+
}));
|
|
2754
|
+
}
|
|
1943
2755
|
}
|
|
2756
|
+
});
|
|
2757
|
+
return $state;
|
|
2758
|
+
};
|
|
2759
|
+
var ref = React__default.useRef(undefined);
|
|
2760
|
+
if (!ref.current) {
|
|
2761
|
+
ref.current = create$State();
|
|
2762
|
+
}
|
|
2763
|
+
var $state = ref.current;
|
|
2764
|
+
if (opts != null && opts.inCanvas) {
|
|
2765
|
+
$$state.rootSpecTree = updateTree($$state.rootSpecTree, specs);
|
|
2766
|
+
var newLeaves = getStateCells($$state.rootSpecTree);
|
|
2767
|
+
if (!arrayEq(newLeaves, $$state.specTreeLeaves)) {
|
|
2768
|
+
$state = ref.current = create$State();
|
|
2769
|
+
$$state.specTreeLeaves = newLeaves;
|
|
1944
2770
|
}
|
|
1945
|
-
|
|
2771
|
+
// we need to eager initialize all states in canvas to populate the data picker
|
|
2772
|
+
$$state.specTreeLeaves.forEach(function (node) {
|
|
2773
|
+
var spec = node.getSpec();
|
|
2774
|
+
if (spec.isRepeated || node.hasState(spec.pathObj)) {
|
|
2775
|
+
return;
|
|
2776
|
+
}
|
|
2777
|
+
node.createStateCell(spec.pathObj);
|
|
2778
|
+
var init = spec.valueProp ? $$state.props[spec.valueProp] : spec.initFunc ? initializeStateValue($$state, node, spec.pathObj, $state) : spec.initVal;
|
|
2779
|
+
set($state, spec.pathObj, init);
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
1946
2782
|
// For each spec with an initFunc, evaluate it and see if
|
|
1947
2783
|
// the init value has changed. If so, reset its state.
|
|
1948
2784
|
var resetSpecs = [];
|
|
@@ -1954,10 +2790,11 @@ function useDollarState(specs, props, $ctx) {
|
|
|
1954
2790
|
};
|
|
1955
2791
|
});
|
|
1956
2792
|
}).forEach(function (_ref2) {
|
|
1957
|
-
var
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2793
|
+
var node = _ref2.node,
|
|
2794
|
+
stateCell = _ref2.stateCell;
|
|
2795
|
+
var initFunc = node.getInitFunc(stateCell);
|
|
2796
|
+
if (initFunc) {
|
|
2797
|
+
var newInit = initFunc(props, $state, $ctx != null ? $ctx : {});
|
|
1961
2798
|
if (!deepEqual(newInit, stateCell.initialValue)) {
|
|
1962
2799
|
resetSpecs.push({
|
|
1963
2800
|
stateCell: stateCell,
|
|
@@ -1982,16 +2819,16 @@ function useDollarState(specs, props, $ctx) {
|
|
|
1982
2819
|
});
|
|
1983
2820
|
}, [props, resetSpecs]);
|
|
1984
2821
|
useIsomorphicLayoutEffect$1(function () {
|
|
1985
|
-
$$state.registrationsQueue.
|
|
1986
|
-
var
|
|
1987
|
-
|
|
1988
|
-
|
|
2822
|
+
while ($$state.registrationsQueue.length) {
|
|
2823
|
+
var _$$state$registration = $$state.registrationsQueue.shift(),
|
|
2824
|
+
node = _$$state$registration.node,
|
|
2825
|
+
path = _$$state$registration.path,
|
|
2826
|
+
f = _$$state$registration.f;
|
|
1989
2827
|
var stateCell = node.getState(path);
|
|
1990
2828
|
stateCell.registeredInitFunc = f;
|
|
1991
2829
|
reInitializeState(node, stateCell);
|
|
1992
|
-
}
|
|
1993
|
-
|
|
1994
|
-
}, [$$state.registrationsQueue]);
|
|
2830
|
+
}
|
|
2831
|
+
}, [$$state.registrationsQueue.length]);
|
|
1995
2832
|
// immediately initialize exposed non-private states
|
|
1996
2833
|
useIsomorphicLayoutEffect$1(function () {
|
|
1997
2834
|
$$state.specTreeLeaves.forEach(function (node) {
|
|
@@ -2006,6 +2843,7 @@ function useDollarState(specs, props, $ctx) {
|
|
|
2006
2843
|
useSnapshot($$state.stateValues, {
|
|
2007
2844
|
sync: true
|
|
2008
2845
|
});
|
|
2846
|
+
useSnapshot($$state.registrationsQueue);
|
|
2009
2847
|
return $state;
|
|
2010
2848
|
}
|
|
2011
2849
|
|