@plasmicapp/react-web 0.2.133 → 0.2.134

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.
@@ -8,6 +8,7 @@ import { PlasmicDataSourceContextProvider } from '@plasmicapp/data-sources-conte
8
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
+ import clone from 'clone';
11
12
  import deepEqual from 'fast-deep-equal';
12
13
  import { proxy, ref, useSnapshot } from 'valtio';
13
14
  import { subscribeKey } from 'valtio/utils';
@@ -1974,7 +1975,7 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
1974
1975
  var path = _ref2.path,
1975
1976
  spec = _ref2.spec;
1976
1977
  var unsubscribe = subscribeKey(_get($$state.stateValues, path.slice(-1)), path.slice(-1)[0], function () {
1977
- return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, $$state.ctx, getIndexes(path, spec))));
1978
+ return saveValue($$state, initialStatePath, initialSpec, initialSpec.initFunc($$state.props, $state, $$state.ctx, getIndexes(path, spec)));
1978
1979
  });
1979
1980
  $$state.unsubscriptionsByState[initialStateKey].push(unsubscribe);
1980
1981
  });
@@ -1983,27 +1984,25 @@ function initializeStateValue($$state, initialStatePath, initialSpec) {
1983
1984
  return initialValue;
1984
1985
  }
1985
1986
 
1986
- function saveStateInitialValue($$state, path, spec, initialValue) {
1987
- // array states are a special case.Wwe listen for changes in the array and in the array cells.
1988
- // for example: $state.people.push(...), $state.people.splice(...), $state.people[0] = ...
1989
- // that's why we need to track the array object
1990
- if (spec.isArray && Array.isArray(initialValue)) {
1991
- var array = initialValue.map(function (val) {
1992
- return mkUntrackedValue(val);
1993
- });
1994
-
1995
- set($$state.stateValues, path, array); // we need to make the array untracked for initStateValues
1996
- // so we can distinguish between stateValue and initStateValue.
1997
- // otherwise they would reference the same array.
1998
-
1999
-
2000
- set($$state.initStateValues, path, mkUntrackedValue(array));
1987
+ function saveValue($$state, path, spec, value) {
1988
+ if (spec.isImmutable) {
1989
+ set($$state.stateValues, path, mkUntrackedValue(value));
2001
1990
  } else {
1991
+ set($$state.stateValues, path, value);
1992
+ }
1993
+ }
1994
+
1995
+ function saveStateInitialValue($$state, path, spec, initialValue) {
1996
+ if (spec.isImmutable) {
2002
1997
  var untrackedValue = mkUntrackedValue(initialValue);
2003
1998
 
2004
1999
  set($$state.stateValues, path, untrackedValue);
2005
2000
 
2006
- set($$state.initStateValues, path, untrackedValue);
2001
+ set($$state.initStateValues, path, clone(untrackedValue));
2002
+ } else {
2003
+ set($$state.stateValues, path, clone(initialValue));
2004
+
2005
+ set($$state.initStateValues, path, clone(initialValue));
2007
2006
  }
2008
2007
  }
2009
2008
 
@@ -2048,8 +2047,8 @@ function useDollarState(specs, props, $ctx) {
2048
2047
  return _get($$state.stateValues, path);
2049
2048
  }
2050
2049
  },
2051
- set: function set$1(_t, _p, value) {
2052
- set($$state.stateValues, path, mkUntrackedValue(value));
2050
+ set: function set(_t, _p, value) {
2051
+ saveValue($$state, path, spec, value);
2053
2052
 
2054
2053
  if (spec.onChangeProp) {
2055
2054
  var _$$state$props$spec$o3, _$$state$props3;
@@ -2152,8 +2151,8 @@ function useCanvasDollarState(specs, props, $ctx) {
2152
2151
  get: function get() {
2153
2152
  return _get($$state.stateValues, path);
2154
2153
  },
2155
- set: function set$1(_t, _p, value) {
2156
- set($$state.stateValues, path, mkUntrackedValue(value));
2154
+ set: function set(_t, _p, value) {
2155
+ saveValue($$state, path, spec, value);
2157
2156
 
2158
2157
  if (spec.onChangeProp) {
2159
2158
  var _$$state$props$spec$o5, _$$state$props5;