@plasmicapp/react-web 0.2.306 → 0.2.309
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/index.cjs.js +35 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/react-web.esm.js +35 -8
- package/dist/react-web.esm.js.map +1 -1
- package/package.json +3 -3
- package/skinny/dist/index.js +35 -8
- package/skinny/dist/index.js.map +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -2000,6 +2000,7 @@ function findStateCell(root, pathStr, repetitionIndex) {
|
|
|
2000
2000
|
};
|
|
2001
2001
|
}
|
|
2002
2002
|
|
|
2003
|
+
var defer = setTimeout;
|
|
2003
2004
|
function isNum$1(value) {
|
|
2004
2005
|
return typeof value === "symbol" ? false : !isNaN(+value);
|
|
2005
2006
|
}
|
|
@@ -2290,6 +2291,22 @@ function useDollarState(specs) {
|
|
|
2290
2291
|
rest[_i - 1] = arguments[_i];
|
|
2291
2292
|
}
|
|
2292
2293
|
var _a = extractDollarStateParametersBackwardCompatible.apply(void 0, __spreadArray([], __read(rest), false)), env = _a.env, opts = _a.opts;
|
|
2294
|
+
var _b = __read(React.useState(), 2), setState = _b[1];
|
|
2295
|
+
var mountedRef = React.useRef(false);
|
|
2296
|
+
var isMounted = React.useCallback(function () { return mountedRef.current; }, []);
|
|
2297
|
+
React.useEffect(function () {
|
|
2298
|
+
mountedRef.current = true;
|
|
2299
|
+
return function () { return (mountedRef.current = false); };
|
|
2300
|
+
}, []);
|
|
2301
|
+
var pendingUpdate = React.useRef(false);
|
|
2302
|
+
var forceUpdate = React.useCallback(function () {
|
|
2303
|
+
return defer(function () {
|
|
2304
|
+
if (isMounted()) {
|
|
2305
|
+
setState([]);
|
|
2306
|
+
pendingUpdate.current = false;
|
|
2307
|
+
}
|
|
2308
|
+
});
|
|
2309
|
+
}, []);
|
|
2293
2310
|
var $$state = React.useRef((function () {
|
|
2294
2311
|
var rootSpecTree = buildTree(specs);
|
|
2295
2312
|
return {
|
|
@@ -2298,7 +2315,7 @@ function useDollarState(specs) {
|
|
|
2298
2315
|
stateValues: valtio.proxy({}),
|
|
2299
2316
|
env: envFieldsAreNonNill(env),
|
|
2300
2317
|
specs: [],
|
|
2301
|
-
registrationsQueue:
|
|
2318
|
+
registrationsQueue: [],
|
|
2302
2319
|
stateInitializationEnv: { stack: [], visited: new Set() },
|
|
2303
2320
|
};
|
|
2304
2321
|
})()).current;
|
|
@@ -2335,14 +2352,18 @@ function useDollarState(specs) {
|
|
|
2335
2352
|
? envFieldsAreNonNill(overrideEnv)
|
|
2336
2353
|
: $$state.env;
|
|
2337
2354
|
if (!deepEqual(stateCell.initialValue, f(__assign({ $state: $state }, env)))) {
|
|
2338
|
-
$$state.registrationsQueue.push(
|
|
2355
|
+
$$state.registrationsQueue.push({
|
|
2339
2356
|
node: node,
|
|
2340
2357
|
path: realPath,
|
|
2341
2358
|
f: f,
|
|
2342
2359
|
overrideEnv: overrideEnv
|
|
2343
2360
|
? envFieldsAreNonNill(overrideEnv)
|
|
2344
2361
|
: undefined,
|
|
2345
|
-
})
|
|
2362
|
+
});
|
|
2363
|
+
if (!pendingUpdate.current) {
|
|
2364
|
+
pendingUpdate.current = true;
|
|
2365
|
+
forceUpdate();
|
|
2366
|
+
}
|
|
2346
2367
|
}
|
|
2347
2368
|
} }, ((opts === null || opts === void 0 ? void 0 : opts.inCanvas)
|
|
2348
2369
|
? {
|
|
@@ -2413,9 +2434,16 @@ function useDollarState(specs) {
|
|
|
2413
2434
|
getStateCells($state, $$state.rootSpecTree).forEach(function (stateCell) {
|
|
2414
2435
|
var _a;
|
|
2415
2436
|
if (stateCell.initFunc) {
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2437
|
+
try {
|
|
2438
|
+
var newInit = invokeInitFuncBackwardsCompatible(stateCell.initFunc, __assign({ $state: $state }, ((_a = stateCell.overrideEnv) !== null && _a !== void 0 ? _a : envFieldsAreNonNill(env))));
|
|
2439
|
+
if (!deepEqual(newInit, stateCell.initialValue)) {
|
|
2440
|
+
resetSpecs.push({ stateCell: stateCell });
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
catch (_b) {
|
|
2444
|
+
// Exception may be thrown from initFunc -- for example, if it tries to access $queries
|
|
2445
|
+
// that are still loading. We swallow those here, since we're only interested in
|
|
2446
|
+
// checking if the init value has changed, not in handling these errors.
|
|
2419
2447
|
}
|
|
2420
2448
|
}
|
|
2421
2449
|
});
|
|
@@ -2432,7 +2460,7 @@ function useDollarState(specs) {
|
|
|
2432
2460
|
stateCell.overrideEnv = overrideEnv;
|
|
2433
2461
|
reInitializeState(stateCell);
|
|
2434
2462
|
}
|
|
2435
|
-
}
|
|
2463
|
+
});
|
|
2436
2464
|
// immediately initialize exposed non-private states
|
|
2437
2465
|
useIsomorphicLayoutEffect(function () {
|
|
2438
2466
|
$$state.specTreeLeaves.forEach(function (node) {
|
|
@@ -2445,7 +2473,6 @@ function useDollarState(specs) {
|
|
|
2445
2473
|
}, []);
|
|
2446
2474
|
// Re-render if any value changed in one of these objects
|
|
2447
2475
|
valtio.useSnapshot($$state.stateValues, { sync: true });
|
|
2448
|
-
valtio.useSnapshot($$state.registrationsQueue, { sync: true });
|
|
2449
2476
|
return $state;
|
|
2450
2477
|
}
|
|
2451
2478
|
|