@plasmicapp/react-web 0.2.352 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.352",
3
+ "version": "0.2.353",
4
4
  "description": "plasmic library for rendering in the presentational style",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
@@ -168,5 +168,5 @@
168
168
  "react": ">=16.8.0",
169
169
  "react-dom": ">=16.8.0"
170
170
  },
171
- "gitHead": "ceaa65b07eecbbc65adfd49094bd166c0fcbd614"
171
+ "gitHead": "149908327f810128f94fc24c7131f85f84da2acc"
172
172
  }
@@ -1063,12 +1063,23 @@ function initializeStateValue($$state, initialStateCell, proxyRoot) {
1063
1063
  });
1064
1064
  });
1065
1065
  var initialValue = invokeInitFuncBackwardsCompatible(initialStateCell.initFunc, __assign({ $state: $state }, ((_a = initialStateCell.overrideEnv) !== null && _a !== void 0 ? _a : $$state.env)));
1066
- initialStateCell.initialValue = clone(initialValue);
1067
1066
  var initialSpec = initialStateCell.node.getSpec();
1068
- var value = initialSpec.isImmutable
1069
- ? mkUntrackedValue(initialValue)
1070
- : clone(initialValue);
1071
- set(proxyRoot, initialStateCell.path, value);
1067
+ // Try to clone initialValue. It can fail if it's a PlasmicUndefinedDataProxy
1068
+ // and we still want to clear some states and return the initialValue.
1069
+ try {
1070
+ var clonedValue = clone(initialValue);
1071
+ initialStateCell.initialValue = clonedValue;
1072
+ var value = initialSpec.isImmutable
1073
+ ? mkUntrackedValue(initialValue)
1074
+ : clonedValue;
1075
+ set(proxyRoot, initialStateCell.path, value);
1076
+ }
1077
+ catch (_d) {
1078
+ // Setting the state to undefined to make sure it gets re-initialized
1079
+ // in case it changes values.
1080
+ initialStateCell.initialValue = undefined;
1081
+ set(proxyRoot, initialStateCell.path, undefined);
1082
+ }
1072
1083
  //immediately fire onChange
1073
1084
  if (initialSpec.onChangeProp) {
1074
1085
  (_c = (_b = $$state.env.$props)[initialSpec.onChangeProp]) === null || _c === void 0 ? void 0 : _c.call(_b, initialValue);
@@ -1240,7 +1251,9 @@ function useDollarState(specs) {
1240
1251
  var isMounted = React__default.useCallback(function () { return mountedRef.current; }, []);
1241
1252
  React__default.useEffect(function () {
1242
1253
  mountedRef.current = true;
1243
- return function () { return (mountedRef.current = false); };
1254
+ return function () {
1255
+ mountedRef.current = false;
1256
+ };
1244
1257
  }, []);
1245
1258
  var pendingUpdate = React__default.useRef(false);
1246
1259
  var forceUpdate = React__default.useCallback(function () {
@@ -1278,9 +1291,9 @@ function useDollarState(specs) {
1278
1291
  }
1279
1292
  return {
1280
1293
  get: function () {
1281
- var spec = stateCell.node.getSpec();
1282
- if (spec.valueProp) {
1283
- var valueProp = $$state.env.$props[spec.valueProp];
1294
+ var currSpec = stateCell.node.getSpec();
1295
+ if (currSpec.valueProp) {
1296
+ var valueProp = $$state.env.$props[currSpec.valueProp];
1284
1297
  subscribeToValtio($$state, stateCell.path, stateCell.node);
1285
1298
  return valueProp;
1286
1299
  }
@@ -1292,10 +1305,10 @@ function useDollarState(specs) {
1292
1305
  }), __assign({ registerInitFunc: function (pathStr, f, repetitionIndex, overrideEnv) {
1293
1306
  var _a = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex), node = _a.node, realPath = _a.realPath;
1294
1307
  var stateCell = getStateCellFrom$StateRoot($state, realPath);
1295
- var env = overrideEnv
1308
+ var innerEnv = overrideEnv
1296
1309
  ? envFieldsAreNonNill(overrideEnv)
1297
1310
  : $$state.env;
1298
- if (!deepEqual(stateCell.initialValue, f(__assign({ $state: $state }, env)))) {
1311
+ if (!deepEqual(stateCell.initialValue, f(__assign({ $state: $state }, innerEnv)))) {
1299
1312
  $$state.registrationsQueue.push({
1300
1313
  node: node,
1301
1314
  path: realPath,
@@ -1311,7 +1324,7 @@ function useDollarState(specs) {
1311
1324
  }
1312
1325
  } }, ((opts === null || opts === void 0 ? void 0 : opts.inCanvas)
1313
1326
  ? {
1314
- eagerInitializeStates: function (specs) {
1327
+ eagerInitializeStates: function (stateSpecs) {
1315
1328
  // we need to eager initialize all states in canvas to populate the data picker
1316
1329
  $$state.specTreeLeaves.forEach(function (node) {
1317
1330
  var _a, _b;
@@ -1320,7 +1333,7 @@ function useDollarState(specs) {
1320
1333
  return;
1321
1334
  }
1322
1335
  var stateCell = getStateCellFrom$StateRoot($state, spec.pathObj);
1323
- var newSpec = specs.find(function (sp) { return sp.path === spec.path; });
1336
+ var newSpec = stateSpecs.find(function (sp) { return sp.path === spec.path; });
1324
1337
  if (!newSpec ||
1325
1338
  (stateCell.initFuncHash === ((_a = newSpec === null || newSpec === void 0 ? void 0 : newSpec.initFuncHash) !== null && _a !== void 0 ? _a : "") &&
1326
1339
  stateCell.initialValue !== UNINITIALIZED)) {