@plasmicapp/react-web 0.2.351 → 0.2.353

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 CHANGED
@@ -2155,12 +2155,23 @@ function initializeStateValue($$state, initialStateCell, proxyRoot) {
2155
2155
  });
2156
2156
  });
2157
2157
  var initialValue = invokeInitFuncBackwardsCompatible(initialStateCell.initFunc, __assign({ $state: $state }, ((_a = initialStateCell.overrideEnv) !== null && _a !== void 0 ? _a : $$state.env)));
2158
- initialStateCell.initialValue = clone(initialValue);
2159
2158
  var initialSpec = initialStateCell.node.getSpec();
2160
- var value = initialSpec.isImmutable
2161
- ? mkUntrackedValue(initialValue)
2162
- : clone(initialValue);
2163
- set(proxyRoot, initialStateCell.path, value);
2159
+ // Try to clone initialValue. It can fail if it's a PlasmicUndefinedDataProxy
2160
+ // and we still want to clear some states and return the initialValue.
2161
+ try {
2162
+ var clonedValue = clone(initialValue);
2163
+ initialStateCell.initialValue = clonedValue;
2164
+ var value = initialSpec.isImmutable
2165
+ ? mkUntrackedValue(initialValue)
2166
+ : clonedValue;
2167
+ set(proxyRoot, initialStateCell.path, value);
2168
+ }
2169
+ catch (_d) {
2170
+ // Setting the state to undefined to make sure it gets re-initialized
2171
+ // in case it changes values.
2172
+ initialStateCell.initialValue = undefined;
2173
+ set(proxyRoot, initialStateCell.path, undefined);
2174
+ }
2164
2175
  //immediately fire onChange
2165
2176
  if (initialSpec.onChangeProp) {
2166
2177
  (_c = (_b = $$state.env.$props)[initialSpec.onChangeProp]) === null || _c === void 0 ? void 0 : _c.call(_b, initialValue);
@@ -2332,7 +2343,9 @@ function useDollarState(specs) {
2332
2343
  var isMounted = React.useCallback(function () { return mountedRef.current; }, []);
2333
2344
  React.useEffect(function () {
2334
2345
  mountedRef.current = true;
2335
- return function () { return (mountedRef.current = false); };
2346
+ return function () {
2347
+ mountedRef.current = false;
2348
+ };
2336
2349
  }, []);
2337
2350
  var pendingUpdate = React.useRef(false);
2338
2351
  var forceUpdate = React.useCallback(function () {
@@ -2370,9 +2383,9 @@ function useDollarState(specs) {
2370
2383
  }
2371
2384
  return {
2372
2385
  get: function () {
2373
- var spec = stateCell.node.getSpec();
2374
- if (spec.valueProp) {
2375
- var valueProp = $$state.env.$props[spec.valueProp];
2386
+ var currSpec = stateCell.node.getSpec();
2387
+ if (currSpec.valueProp) {
2388
+ var valueProp = $$state.env.$props[currSpec.valueProp];
2376
2389
  subscribeToValtio($$state, stateCell.path, stateCell.node);
2377
2390
  return valueProp;
2378
2391
  }
@@ -2384,10 +2397,10 @@ function useDollarState(specs) {
2384
2397
  }), __assign({ registerInitFunc: function (pathStr, f, repetitionIndex, overrideEnv) {
2385
2398
  var _a = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex), node = _a.node, realPath = _a.realPath;
2386
2399
  var stateCell = getStateCellFrom$StateRoot($state, realPath);
2387
- var env = overrideEnv
2400
+ var innerEnv = overrideEnv
2388
2401
  ? envFieldsAreNonNill(overrideEnv)
2389
2402
  : $$state.env;
2390
- if (!deepEqual(stateCell.initialValue, f(__assign({ $state: $state }, env)))) {
2403
+ if (!deepEqual(stateCell.initialValue, f(__assign({ $state: $state }, innerEnv)))) {
2391
2404
  $$state.registrationsQueue.push({
2392
2405
  node: node,
2393
2406
  path: realPath,
@@ -2403,7 +2416,7 @@ function useDollarState(specs) {
2403
2416
  }
2404
2417
  } }, ((opts === null || opts === void 0 ? void 0 : opts.inCanvas)
2405
2418
  ? {
2406
- eagerInitializeStates: function (specs) {
2419
+ eagerInitializeStates: function (stateSpecs) {
2407
2420
  // we need to eager initialize all states in canvas to populate the data picker
2408
2421
  $$state.specTreeLeaves.forEach(function (node) {
2409
2422
  var _a, _b;
@@ -2412,7 +2425,7 @@ function useDollarState(specs) {
2412
2425
  return;
2413
2426
  }
2414
2427
  var stateCell = getStateCellFrom$StateRoot($state, spec.pathObj);
2415
- var newSpec = specs.find(function (sp) { return sp.path === spec.path; });
2428
+ var newSpec = stateSpecs.find(function (sp) { return sp.path === spec.path; });
2416
2429
  if (!newSpec ||
2417
2430
  (stateCell.initFuncHash === ((_a = newSpec === null || newSpec === void 0 ? void 0 : newSpec.initFuncHash) !== null && _a !== void 0 ? _a : "") &&
2418
2431
  stateCell.initialValue !== UNINITIALIZED)) {