@plasmicapp/react-web 0.2.109 → 0.2.112

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.
Files changed (77) hide show
  1. package/dist/all.d.ts +30 -13
  2. package/dist/index-common.d.ts +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/react-web.cjs.development.js +378 -349
  5. package/dist/react-web.cjs.development.js.map +1 -1
  6. package/dist/react-web.cjs.production.min.js +1 -1
  7. package/dist/react-web.cjs.production.min.js.map +1 -1
  8. package/dist/react-web.esm.js +375 -349
  9. package/dist/react-web.esm.js.map +1 -1
  10. package/dist/render/elements.d.ts +5 -0
  11. package/dist/states/helpers.d.ts +5 -0
  12. package/dist/states/index.d.ts +1 -1
  13. package/dist/states/valtio.d.ts +16 -0
  14. package/dist/stories/UseDollarState.stories.d.ts +11 -0
  15. package/package.json +6 -2
  16. package/skinny/dist/collection-utils-42de4441.js +244 -0
  17. package/skinny/dist/collection-utils-42de4441.js.map +1 -0
  18. package/skinny/dist/{collection-utils-3487dd27.js → collection-utils-bf37b8fb.js} +5 -5
  19. package/skinny/dist/collection-utils-bf37b8fb.js.map +1 -0
  20. package/skinny/dist/common-98719219.js +68 -0
  21. package/skinny/dist/common-98719219.js.map +1 -0
  22. package/skinny/dist/common-9efbae57.js +201 -0
  23. package/skinny/dist/common-9efbae57.js.map +1 -0
  24. package/skinny/dist/context-4ca6f5cd.js +6 -0
  25. package/skinny/dist/context-4ca6f5cd.js.map +1 -0
  26. package/skinny/dist/index-common.d.ts +1 -1
  27. package/skinny/dist/index.d.ts +1 -1
  28. package/skinny/dist/index.js +17 -4
  29. package/skinny/dist/index.js.map +1 -1
  30. package/skinny/dist/plume/checkbox/index.js +2 -1
  31. package/skinny/dist/plume/checkbox/index.js.map +1 -1
  32. package/skinny/dist/plume/menu/index.js +2 -1
  33. package/skinny/dist/plume/menu/index.js.map +1 -1
  34. package/skinny/dist/plume/menu-button/index.js +2 -1
  35. package/skinny/dist/plume/menu-button/index.js.map +1 -1
  36. package/skinny/dist/plume/select/index.js +2 -1
  37. package/skinny/dist/plume/select/index.js.map +1 -1
  38. package/skinny/dist/plume/switch/index.js +2 -1
  39. package/skinny/dist/plume/switch/index.js.map +1 -1
  40. package/skinny/dist/plume-utils-1e225de5.js +25 -0
  41. package/skinny/dist/plume-utils-1e225de5.js.map +1 -0
  42. package/skinny/dist/plume-utils-d2476af1.js +35 -0
  43. package/skinny/dist/plume-utils-d2476af1.js.map +1 -0
  44. package/skinny/dist/props-utils-c60d3105.js +8 -0
  45. package/skinny/dist/props-utils-c60d3105.js.map +1 -0
  46. package/skinny/dist/props-utils-cac0cccf.js +8 -0
  47. package/skinny/dist/props-utils-cac0cccf.js.map +1 -0
  48. package/skinny/dist/react-utils-6050fadc.js +201 -0
  49. package/skinny/dist/react-utils-6050fadc.js.map +1 -0
  50. package/skinny/dist/react-utils-b5dc6320.js +155 -0
  51. package/skinny/dist/react-utils-b5dc6320.js.map +1 -0
  52. package/skinny/dist/render/PlasmicHead/index.js +14 -9
  53. package/skinny/dist/render/PlasmicHead/index.js.map +1 -1
  54. package/skinny/dist/render/elements.d.ts +5 -0
  55. package/skinny/dist/ssr-68913b60.js +107 -0
  56. package/skinny/dist/ssr-68913b60.js.map +1 -0
  57. package/skinny/dist/{ssr-84e27ffb.js → ssr-d3321868.js} +9 -4
  58. package/skinny/dist/ssr-d3321868.js.map +1 -0
  59. package/skinny/dist/{ssr-b1615b80.js → ssr-f4053cdd.js} +1 -1
  60. package/skinny/dist/{ssr-84e27ffb.js.map → ssr-f4053cdd.js.map} +1 -1
  61. package/skinny/dist/states/helpers.d.ts +5 -0
  62. package/skinny/dist/states/index.d.ts +1 -1
  63. package/skinny/dist/states/valtio copy.d.ts +15 -0
  64. package/skinny/dist/states/valtio.d.ts +16 -0
  65. package/skinny/dist/stories/UseDollarState.stories.d.ts +11 -0
  66. package/skinny/dist/stories/UseDollarState.test.d.ts +11 -0
  67. package/skinny/dist/stories/UseDollarState2.stories.d.ts +7 -0
  68. package/skinny/dist/collection-utils-3487dd27.js.map +0 -1
  69. package/skinny/dist/ssr-14264281.js +0 -158
  70. package/skinny/dist/ssr-14264281.js.map +0 -1
  71. package/skinny/dist/ssr-5141fc77.js +0 -158
  72. package/skinny/dist/ssr-5141fc77.js.map +0 -1
  73. package/skinny/dist/ssr-579df58f.js +0 -158
  74. package/skinny/dist/ssr-579df58f.js.map +0 -1
  75. package/skinny/dist/ssr-b1615b80.js.map +0 -1
  76. package/skinny/dist/ssr-d2fd94f2.js +0 -31
  77. package/skinny/dist/ssr-d2fd94f2.js.map +0 -1
@@ -5,10 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
7
  var classNames$1 = _interopDefault(require('classnames'));
8
+ var _get = _interopDefault(require('dlv'));
8
9
  var React = require('react');
9
10
  var React__default = _interopDefault(React);
10
11
  var ReactDOM = require('react-dom');
11
12
  var ReactDOM__default = _interopDefault(ReactDOM);
13
+ var dataSourcesContext = require('@plasmicapp/data-sources-context');
12
14
  var ssr = require('@react-aria/ssr');
13
15
  var focus = require('@react-aria/focus');
14
16
  var checkbox = require('@react-aria/checkbox');
@@ -25,8 +27,9 @@ var listbox = require('@react-aria/listbox');
25
27
  var select$1 = require('@react-stately/select');
26
28
  var _switch = require('@react-aria/switch');
27
29
  var overlays = require('@react-aria/overlays');
28
- var _get = _interopDefault(require('dlv'));
29
- var dset = require('dset');
30
+ var deepEqual = _interopDefault(require('fast-deep-equal'));
31
+ var valtio = require('valtio');
32
+ var utils = require('valtio/utils');
30
33
 
31
34
  function _extends() {
32
35
  _extends = Object.assign || function (target) {
@@ -692,6 +695,14 @@ function mergeVariants(v1, v2) {
692
695
  return _extends({}, v1, v2);
693
696
  }
694
697
 
698
+ function mergeVariantsWithStates(variants, $state, linkedStates) {
699
+ return _extends({}, variants, Object.fromEntries(linkedStates.map(function (_ref) {
700
+ var variantGroup = _ref.variantGroup,
701
+ statePath = _ref.statePath;
702
+ return [variantGroup, _get($state, statePath)];
703
+ })));
704
+ }
705
+
695
706
  function mergeArgs(a1, a2) {
696
707
  if (!a1 || !a2) {
697
708
  return a1 || a2 || {};
@@ -717,7 +728,7 @@ function mergeFlexOverrides(o1, o2) {
717
728
  }
718
729
 
719
730
  function mergeFlexOverride(fo1, fo2) {
720
- var _o1$props, _ref;
731
+ var _o1$props, _ref2;
721
732
 
722
733
  if (!fo1) {
723
734
  return fo2;
@@ -753,7 +764,7 @@ function mergeFlexOverride(fo1, fo2) {
753
764
  } // "as" will take precedence
754
765
 
755
766
 
756
- var as = (_ref = o2.type === "as" ? o2.as : undefined) != null ? _ref : o1.type === "as" ? o1.as : undefined;
767
+ var as = (_ref2 = o2.type === "as" ? o2.as : undefined) != null ? _ref2 : o1.type === "as" ? o1.as : undefined;
757
768
  return _extends({
758
769
  props: props,
759
770
  wrap: wrap,
@@ -819,9 +830,12 @@ function PlasmicHead(props) {
819
830
  console.warn("Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider."); // TODO: Link to doc about Head.
820
831
 
821
832
  return null;
822
- }
833
+ } // Helmet does not support React.Fragments, so we need to use `[<meta />,
834
+ // <meta />]` instead of `<><meta /><meta /></>`.
823
835
 
824
- return React.createElement(Head, null, props.image ? React.createElement(React.Fragment, null, React.createElement("meta", {
836
+
837
+ return React.createElement(Head, null, props.image ? [React.createElement("meta", {
838
+ key: "twitter:card",
825
839
  name: "twitter:card",
826
840
  content: "summary_large_image"
827
841
  }), React.createElement("meta", {
@@ -832,10 +846,11 @@ function PlasmicHead(props) {
832
846
  key: "twitter:image",
833
847
  name: "twitter:image",
834
848
  content: props.image
835
- })) : React.createElement("meta", {
849
+ })] : React.createElement("meta", {
850
+ key: "twitter:card",
836
851
  name: "twitter:card",
837
852
  content: "summary"
838
- }), props.title && React.createElement(React.Fragment, null, React.createElement("title", {
853
+ }), props.title && [React.createElement("title", {
839
854
  key: "title"
840
855
  }, props.title), React.createElement("meta", {
841
856
  key: "og:title",
@@ -845,7 +860,7 @@ function PlasmicHead(props) {
845
860
  key: "twitter:title",
846
861
  property: "twitter:title",
847
862
  content: props.title
848
- })), props.description && React.createElement(React.Fragment, null, React.createElement("meta", {
863
+ })], props.description && [React.createElement("meta", {
849
864
  key: "description",
850
865
  name: "description",
851
866
  content: props.description
@@ -857,7 +872,8 @@ function PlasmicHead(props) {
857
872
  key: "twitter:description",
858
873
  name: "twitter:description",
859
874
  content: props.description
860
- })), props.canonical && React.createElement("link", {
875
+ })], props.canonical && React.createElement("link", {
876
+ key: "canonical",
861
877
  ref: "canonical",
862
878
  href: props.canonical
863
879
  }));
@@ -865,7 +881,7 @@ function PlasmicHead(props) {
865
881
  var plasmicHeadMeta = {
866
882
  name: "hostless-plasmic-head",
867
883
  displayName: "Head",
868
- description: "Used to add page metadata to HEAD tag",
884
+ description: "Used to add page metadata to HTML <head />.",
869
885
  importName: "PlasmicHead",
870
886
  importPath: "@plasmicapp/react-web",
871
887
  isRepeatable: false,
@@ -1533,19 +1549,27 @@ function createUseScreenVariants(isMulti, screenQueries) {
1533
1549
  var PlasmicRootContext = /*#__PURE__*/React.createContext(undefined);
1534
1550
  function PlasmicRootProvider(props) {
1535
1551
  var platform = props.platform,
1536
- children = props.children;
1552
+ children = props.children,
1553
+ userAuthToken = props.userAuthToken;
1537
1554
  var context = React.useMemo(function () {
1538
1555
  return {
1539
1556
  platform: platform
1540
1557
  };
1541
1558
  }, [platform]);
1559
+ var dataSourceContextValue = React.useMemo(function () {
1560
+ return {
1561
+ userAuthToken: userAuthToken
1562
+ };
1563
+ }, [userAuthToken]);
1542
1564
  return React.createElement(PlasmicRootContext.Provider, {
1543
1565
  value: context
1544
- }, React.createElement(ssr.SSRProvider, null, React.createElement(PlasmicTranslatorContext.Provider, {
1566
+ }, React.createElement(ssr.SSRProvider, null, React.createElement(dataSourcesContext.PlasmicDataSourceContextProvider, {
1567
+ value: dataSourceContextValue
1568
+ }, React.createElement(PlasmicTranslatorContext.Provider, {
1545
1569
  value: props.translator
1546
1570
  }, React.createElement(PlasmicHeadContext.Provider, {
1547
1571
  value: props.Head
1548
- }, children))));
1572
+ }, children)))));
1549
1573
  }
1550
1574
  var useIsSSR = ssr.useIsSSR;
1551
1575
  function useHasPlasmicRoot() {
@@ -3212,7 +3236,7 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
3212
3236
 
3213
3237
  function generateStateOnChangeProp($state, stateName, dataReps) {
3214
3238
  return function (val, path) {
3215
- return dset.dset($state, [stateName].concat(dataReps, path), val);
3239
+ return set($state, [stateName].concat(dataReps, path), val);
3216
3240
  };
3217
3241
  }
3218
3242
  /**
@@ -3226,8 +3250,51 @@ function generateStateValueProp($state, path // ["parent", 0, 1, "counter"]
3226
3250
  ) {
3227
3251
  return _get($state, path);
3228
3252
  }
3253
+ /**
3254
+ * Forked from https://github.com/lukeed/dset
3255
+ * Changes: fixed setting a deep value to a proxy object
3256
+ */
3257
+
3258
+ function set(obj, keys, val) {
3259
+ keys = keys.split ? keys.split(".") : keys;
3260
+ var i = 0,
3261
+ l = keys.length,
3262
+ t = obj,
3263
+ x,
3264
+ k;
3265
+
3266
+ while (i < l) {
3267
+ k = keys[i++];
3268
+ if (k === "__proto__" || k === "constructor" || k === "prototype") break;
3269
+
3270
+ if (i === l) {
3271
+ t[k] = val;
3272
+ t = t[k];
3273
+ } else {
3274
+ if (typeof (x = t[k]) === typeof keys) {
3275
+ t = t[k] = x;
3276
+ } else if (keys[i] * 0 !== 0 || !!~("" + keys[i]).indexOf(".")) {
3277
+ t[k] = {};
3278
+ t = t[k];
3279
+ } else {
3280
+ t[k] = [];
3281
+ t = t[k];
3282
+ }
3283
+ }
3284
+ }
3285
+ }
3286
+
3287
+ var mkUntrackedValue = function mkUntrackedValue(o) {
3288
+ return typeof o === "object" ? valtio.ref(o) : o;
3289
+ };
3290
+
3291
+ var transformPathStringToObj = function transformPathStringToObj(str) {
3292
+ var splitStatePathPart = function splitStatePathPart(state) {
3293
+ return state.endsWith("[]") ? [].concat(splitStatePathPart(state.slice(0, -2)), ["[]"]) : [state];
3294
+ };
3229
3295
 
3230
- var UNINITIALIZED = /*#__PURE__*/Symbol("plasmic.unitialized");
3296
+ return str.split(".").flatMap(splitStatePathPart);
3297
+ };
3231
3298
 
3232
3299
  function shallowEqual(a1, a2) {
3233
3300
  if (a1.length !== a2.length) {
@@ -3243,145 +3310,144 @@ function shallowEqual(a1, a2) {
3243
3310
  return true;
3244
3311
  }
3245
3312
 
3246
- var isNum = function isNum(value) {
3313
+ function isNum(value) {
3247
3314
  return typeof value === "symbol" ? false : !isNaN(+value);
3248
- };
3315
+ }
3249
3316
 
3250
- function mkProxy(specs, maybeHandlers) {
3251
- var handlers = maybeHandlers != null ? maybeHandlers : function () {
3252
- return {
3253
- get: function get(target, property) {
3254
- return target[property];
3255
- },
3256
- set: function set(target, property, value) {
3257
- return (target[property] = value) || true;
3258
- }
3259
- };
3260
- };
3317
+ function saveNewState($$state, path, spec) {
3318
+ var key = JSON.stringify(path);
3319
+ $$state.existingStates.set(key, {
3320
+ path: path,
3321
+ specKey: spec.path
3322
+ });
3323
+
3324
+ if (!$$state.statesInstanceBySpec.has(spec.path)) {
3325
+ $$state.statesInstanceBySpec.set(spec.path, []);
3326
+ }
3261
3327
 
3262
- var getNextParts = function getNextParts(currPath) {
3263
- return Object.fromEntries(Object.values(specs).filter(function (spec) {
3328
+ $$state.statesInstanceBySpec.get(spec.path).push({
3329
+ path: path,
3330
+ specKey: spec.path
3331
+ });
3332
+ }
3333
+
3334
+ function create$StateProxy($$state, handlers) {
3335
+ var getNextKeyToSpecMap = function getNextKeyToSpecMap(currPath) {
3336
+ return new Map(Object.entries(Object.values($$state.specsByKey).filter(function (spec) {
3264
3337
  return shallowEqual(currPath.map(function (p) {
3265
3338
  return isNum(p) ? "[]" : p;
3266
- }), spec.path.slice(0, currPath.length));
3267
- }).map(function (spec) {
3268
- var nextPart = spec.path[currPath.length];
3269
-
3270
- if (spec.path.length === currPath.length + 1) {
3271
- return [nextPart, {
3272
- isLast: true,
3273
- specKey: spec.pathStr
3274
- }];
3275
- } else {
3276
- return [nextPart, {
3277
- isLast: false,
3278
- specKey: spec.pathStr
3279
- }];
3339
+ }), spec.pathObj.slice(0, currPath.length));
3340
+ }).reduce(function (agg, spec) {
3341
+ var nextKey = spec.pathObj[currPath.length];
3342
+
3343
+ if (!(nextKey in agg)) {
3344
+ agg[nextKey] = [];
3280
3345
  }
3281
- }));
3282
- };
3283
- /**
3284
- * We use this function when we're setting a value in the middle of the state path.
3285
- * We can't just set the value, because we need to keep the proxy properties, so
3286
- * we use the specs to walk through the object and just set the value in the end of the path
3287
- **/
3288
3346
 
3347
+ agg[nextKey].push(spec);
3348
+ return agg;
3349
+ }, {})));
3350
+ };
3289
3351
 
3290
- var cloneValue = function cloneValue(target, currPath, value) {
3291
- if (typeof value !== "object") {
3292
- return;
3293
- }
3352
+ var rec = function rec(currPath) {
3353
+ var nextKeyToSpecs = getNextKeyToSpecMap(currPath);
3294
3354
 
3295
- var nextParts = getNextParts(currPath);
3355
+ var getSpecForProperty = function getSpecForProperty(property) {
3356
+ var _nextKeyToSpecs$get, _nextKeyToSpecs$get2;
3296
3357
 
3297
- for (var _i = 0, _Object$entries = Object.entries(nextParts); _i < _Object$entries.length; _i++) {
3298
- var _Object$entries$_i = _Object$entries[_i],
3299
- nextPart = _Object$entries$_i[0],
3300
- _Object$entries$_i$ = _Object$entries$_i[1],
3301
- isLast = _Object$entries$_i$.isLast,
3302
- specKey = _Object$entries$_i$.specKey;
3358
+ return nextKeyToSpecs.has("[]") && isNum(property) ? (_nextKeyToSpecs$get = nextKeyToSpecs.get("[]")) == null ? void 0 : _nextKeyToSpecs$get[0] : typeof property === "string" && nextKeyToSpecs.has(property) ? (_nextKeyToSpecs$get2 = nextKeyToSpecs.get(property)) == null ? void 0 : _nextKeyToSpecs$get2[0] : undefined;
3359
+ };
3303
3360
 
3304
- if (nextPart === "[]" && Array.isArray(value)) {
3305
- for (var i = 0; i < value.length; i++) {
3306
- cloneValue(target[i], [].concat(currPath, [i]), value[i]);
3307
- }
3308
- } else if (nextPart in value) {
3309
- if (isLast) {
3310
- var _handlers$set, _handlers;
3311
-
3312
- handlers == null ? void 0 : (_handlers$set = (_handlers = handlers({
3313
- specKey: specKey,
3314
- path: [].concat(currPath, [nextPart])
3315
- })).set) == null ? void 0 : _handlers$set.call(_handlers, target, nextPart, value[nextPart], undefined);
3316
- } else {
3317
- cloneValue(target[nextPart], [].concat(currPath, [nextPart]), value[nextPart]);
3318
- }
3319
- }
3320
- }
3321
- };
3361
+ var getNextPath = function getNextPath(property) {
3362
+ return [].concat(currPath, [isNum(property) ? +property : property]);
3363
+ };
3322
3364
 
3323
- var rec = function rec(currPath) {
3324
- var nextParts = getNextParts(currPath);
3325
- return new Proxy("[]" in nextParts ? [] : {}, {
3365
+ return new Proxy(nextKeyToSpecs.has("[]") ? [] : {}, {
3326
3366
  deleteProperty: function deleteProperty(target, property) {
3327
- if ("[]" in nextParts && isNum(property)) {
3328
- var _handlers$deletePrope, _handlers2;
3329
-
3330
- delete target[property];
3331
- handlers == null ? void 0 : (_handlers$deletePrope = (_handlers2 = handlers({
3332
- path: [].concat(currPath, [+property]),
3333
- specKey: nextParts["[]"].specKey
3334
- })).deleteProperty) == null ? void 0 : _handlers$deletePrope.call(_handlers2, target, property);
3335
- } else {
3336
- throw new Error("You can't delete a non-repeated property in the middle of the path");
3337
- }
3367
+ var prefixPath = getNextPath(property);
3368
+ var specKeysToUpdate = new Set();
3369
+ $$state.existingStates.forEach(function (_ref) {
3370
+ var path = _ref.path,
3371
+ specKey = _ref.specKey;
3372
+
3373
+ if (path.length >= prefixPath.length && shallowEqual(path.slice(0, prefixPath.length), prefixPath)) {
3374
+ deleteState($$state, path);
3375
+ specKeysToUpdate.add(specKey);
3376
+ }
3377
+ });
3378
+ specKeysToUpdate.forEach(function (specKey) {
3379
+ var spec = $$state.specsByKey[specKey];
3338
3380
 
3339
- return true;
3381
+ if (spec.onChangeProp) {
3382
+ var _$$state$props$spec$o, _$$state$props;
3383
+
3384
+ (_$$state$props$spec$o = (_$$state$props = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o.call(_$$state$props, _get($$state.stateValues, currPath), currPath);
3385
+ }
3386
+ });
3387
+ return Reflect.deleteProperty(target, property);
3340
3388
  },
3341
3389
  get: function get(target, property, receiver) {
3342
- if ("[]" in nextParts && isNum(property)) {
3343
- if (!(property in target)) {
3344
- target[property] = rec([].concat(currPath, [+property]));
3345
- }
3346
- } else if (property in nextParts) {
3347
- if (nextParts[property].isLast) {
3348
- var _handlers$get, _handlers3;
3349
-
3350
- return target[property] = handlers == null ? void 0 : (_handlers$get = (_handlers3 = handlers({
3351
- path: [].concat(currPath, [property]),
3352
- specKey: nextParts[property].specKey
3353
- })).get) == null ? void 0 : _handlers$get.call(_handlers3, target, property, receiver);
3390
+ var spec = getSpecForProperty(property);
3391
+
3392
+ if (spec && typeof property !== "symbol") {
3393
+ var nextPath = getNextPath(property);
3394
+
3395
+ if (spec.pathObj.length === currPath.length + 1) {
3396
+ var _handlers$get, _handlers;
3397
+
3398
+ // reached the end of the spec
3399
+ target[property] = (_handlers$get = (_handlers = handlers(nextPath, spec)).get) == null ? void 0 : _handlers$get.call(_handlers, target, property, receiver);
3354
3400
  } else if (!(property in target)) {
3355
- target[property] = rec([].concat(currPath, [property]));
3401
+ target[property] = rec(nextPath);
3356
3402
  }
3357
3403
  }
3358
3404
 
3359
- return target[property];
3405
+ return Reflect.get(target, property, receiver);
3360
3406
  },
3361
- set: function set(target, property, value, receiver) {
3362
- if ("[]" in nextParts && isNum(property)) {
3363
- if (!(property in target)) {
3364
- target[property] = rec([].concat(currPath, [+property]));
3365
- }
3366
- } else if (property in nextParts) {
3367
- if (nextParts[property].isLast) {
3368
- var _handlers$set2, _handlers$set3, _handlers4;
3369
-
3370
- target[property] = value;
3371
- return (_handlers$set2 = (_handlers$set3 = (_handlers4 = handlers({
3372
- path: [].concat(currPath, [property]),
3373
- specKey: nextParts[property].specKey
3374
- })).set) == null ? void 0 : _handlers$set3.call(_handlers4, target, property, value, receiver)) != null ? _handlers$set2 : false;
3407
+ set: function set$1(target, property, value, receiver) {
3408
+ var spec = getSpecForProperty(property);
3409
+ var nextPath = getNextPath(property);
3410
+
3411
+ if (spec && typeof property !== "symbol") {
3412
+ if (spec.pathObj.length === currPath.length + 1) {
3413
+ var _handlers$set, _handlers2;
3414
+
3415
+ // reached the end of the spec
3416
+ target[property] = (_handlers$set = (_handlers2 = handlers(nextPath, spec)).set) == null ? void 0 : _handlers$set.call(_handlers2, target, property, value, receiver);
3417
+ return Reflect.set(target, property, value, receiver);
3418
+ } else if (typeof value === "object") {
3419
+ target[property] = rec(nextPath);
3420
+
3421
+ for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
3422
+ var key = _Object$keys[_i];
3423
+ target[property][key] = value[key];
3424
+ }
3425
+
3426
+ return true;
3375
3427
  }
3376
3428
  }
3377
3429
 
3378
- if (property === "registerInitFunc") {
3379
- target[property] = value;
3380
- } else if (typeof value === "object") {
3381
- cloneValue(target[property], [].concat(currPath, [isNum(property) ? +property : property]), value);
3430
+ if (property === "registerInitFunc" && currPath.length === 0) {
3431
+ return Reflect.set(target, property, value, receiver);
3382
3432
  }
3383
3433
 
3384
- return true;
3434
+ if (nextKeyToSpecs.has("[]")) {
3435
+ var _nextKeyToSpecs$get3;
3436
+
3437
+ set($$state.stateValues, nextPath, value);
3438
+
3439
+ (_nextKeyToSpecs$get3 = nextKeyToSpecs.get("[]")) == null ? void 0 : _nextKeyToSpecs$get3.forEach(function (spec) {
3440
+ if (spec != null && spec.onChangeProp) {
3441
+ var _$$state$props$spec$o2, _$$state$props2;
3442
+
3443
+ (_$$state$props$spec$o2 = (_$$state$props2 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o2.call(_$$state$props2, value, nextPath);
3444
+ }
3445
+ });
3446
+ return Reflect.set(target, property, value, receiver);
3447
+ } // invalid setting a value that doesn't make part of the spec
3448
+
3449
+
3450
+ return false;
3385
3451
  }
3386
3452
  });
3387
3453
  };
@@ -3389,136 +3455,136 @@ function mkProxy(specs, maybeHandlers) {
3389
3455
  return rec([]);
3390
3456
  }
3391
3457
 
3392
- function cloneProxy(specs, states, obj) {
3393
- var newObj = mkProxy(specs);
3394
- Object.values(states).forEach(function (_ref) {
3395
- var path = _ref.path;
3458
+ var deleteState = function deleteState($$state, path) {
3459
+ var _$$state$unsubscripti;
3396
3460
 
3397
- dset.dset(newObj, path, _get(obj, path));
3461
+ var key = JSON.stringify(path);
3462
+ (_$$state$unsubscripti = $$state.unsubscriptionsByState[key]) == null ? void 0 : _$$state$unsubscripti.forEach(function (f) {
3463
+ return f();
3398
3464
  });
3399
- return newObj;
3400
- }
3465
+ delete $$state.unsubscriptionsByState[key];
3466
+ $$state.existingStates["delete"](key); // delete get($$state.stateValues, path.slice(-1))[path.slice(-1)[0]];
3467
+ // delete get($$state.initStateValues, path.slice(-1))[path.slice(-1)[0]];
3468
+ };
3401
3469
 
3402
- function saveState(state, states) {
3403
- states[JSON.stringify(state.path)] = state;
3404
- }
3470
+ var getIndexes = function getIndexes(path, spec) {
3471
+ var indexes = [];
3405
3472
 
3406
- function hasState(state, states) {
3407
- return JSON.stringify(state.path) in states;
3408
- }
3473
+ if (path.length !== spec.pathObj.length) {
3474
+ throw new Error("Unexpected error: state path and spec path have different lengths");
3475
+ }
3409
3476
 
3410
- var transformPathStringToObj = function transformPathStringToObj(str) {
3411
- // "c[][]" -> ["c", "[]", "[]"]
3412
- var splitStatePathPart = function splitStatePathPart(state) {
3413
- return state.endsWith("[]") ? [].concat(splitStatePathPart(state.slice(0, -2)), ["[]"]) : [state];
3414
- };
3477
+ for (var i = 0; i < spec.pathObj.length; i++) {
3478
+ if (spec.pathObj[i] === "[]") {
3479
+ indexes.push(path[i]);
3480
+ }
3481
+ }
3415
3482
 
3416
- return str.split(".").flatMap(splitStatePathPart);
3483
+ return indexes;
3417
3484
  };
3418
3485
 
3419
- function useVanillaDollarState(_specs, props) {
3420
- var forceRender = React__default.useState(0)[1];
3421
- var $$state = React__default.useMemo(function () {
3422
- var specs = Object.fromEntries(_specs.map(function (_ref2) {
3423
- var pathStr = _ref2.path,
3424
- spec = _objectWithoutPropertiesLoose(_ref2, ["path"]);
3425
-
3426
- return [pathStr, _extends({}, spec, {
3427
- pathStr: pathStr,
3428
- path: transformPathStringToObj(pathStr),
3429
- isRepeated: pathStr.split(".").some(function (part) {
3430
- return part.endsWith("[]");
3431
- })
3432
- })];
3433
- }));
3434
- return {
3435
- stateValues: mkProxy(specs),
3436
- initStateDeps: {},
3437
- initStateValues: mkProxy(specs),
3438
- states: {},
3439
- specs: specs
3440
- };
3441
- }, []);
3442
- var $state = Object.assign(mkProxy($$state.specs, function (state) {
3443
- return {
3444
- deleteProperty: function deleteProperty(_target, _property) {
3445
- var prefixPath = state.path;
3446
-
3447
- for (var _i2 = 0, _Object$entries2 = Object.entries($$state.states); _i2 < _Object$entries2.length; _i2++) {
3448
- var _Object$entries2$_i = _Object$entries2[_i2],
3449
- key = _Object$entries2$_i[0],
3450
- existingState = _Object$entries2$_i[1];
3486
+ function initializeStateValue($$state, initialStatePath, initialSpec) {
3487
+ var _$$state$unsubscripti2;
3451
3488
 
3452
- if (existingState.path.length >= prefixPath.length && shallowEqual(existingState.path.slice(0, prefixPath.length), prefixPath)) {
3453
- delete $$state.states[key];
3454
- }
3455
- }
3456
-
3457
- forceRender(function (r) {
3458
- return r + 1;
3489
+ var initialStateKey = JSON.stringify(initialStatePath);
3490
+ var stateAccess = new Set();
3491
+ var $state = create$StateProxy($$state, function (path, spec) {
3492
+ return {
3493
+ get: function get() {
3494
+ var key = JSON.stringify(path);
3495
+ stateAccess.add({
3496
+ path: path,
3497
+ spec: spec
3459
3498
  });
3460
- return true;
3461
- },
3462
- get: function get(_target, _property) {
3463
- var spec = $$state.specs[state.specKey];
3464
3499
 
3465
3500
  if (spec.valueProp) {
3466
- if (!spec.isRepeated) {
3467
- return props[spec.valueProp];
3468
- } else {
3469
- return _get(props[spec.valueProp], state.path.slice(1));
3470
- }
3501
+ return !spec.isRepeated ? $$state.props[spec.valueProp] : _get($$state.props[spec.valueProp], path.slice(1));
3471
3502
  }
3472
3503
 
3473
- if (!hasState(state, $$state.states)) {
3474
- var _spec$initVal;
3504
+ if ($$state.existingStates.has(key)) {
3505
+ // is already initialized
3506
+ return _get($$state.stateValues, path);
3507
+ } else if (spec.initFunc) {
3508
+ initializeStateValue($$state, path, spec);
3509
+ }
3475
3510
 
3476
- saveState(state, $$state.states);
3511
+ return _get($$state.stateValues, path);
3512
+ },
3513
+ set: function set() {
3514
+ throw new Error("Cannot update state values during initialization");
3515
+ }
3516
+ };
3517
+ });
3518
+ (_$$state$unsubscripti2 = $$state.unsubscriptionsByState[initialStateKey]) == null ? void 0 : _$$state$unsubscripti2.forEach(function (f) {
3519
+ return f();
3520
+ });
3521
+ $$state.unsubscriptionsByState[initialStateKey] = [];
3522
+ stateAccess.forEach(function (_ref2) {
3523
+ var path = _ref2.path,
3524
+ spec = _ref2.spec;
3525
+ var unsubscribe = utils.subscribeKey(_get($$state.stateValues, path.slice(-1)), path.slice(-1)[0], function () {
3526
+ return set($$state.stateValues, initialStatePath, mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(path, spec))));
3527
+ });
3528
+ $$state.unsubscriptionsByState[initialStateKey].push(unsubscribe);
3529
+ });
3530
+ var untrackedInitialValue = mkUntrackedValue(initialSpec.initFunc($$state.props, $state, getIndexes(initialStatePath, initialSpec)));
3477
3531
 
3478
- dset.dset($$state.stateValues, state.path, spec.initFunc ? UNINITIALIZED : (_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined);
3532
+ set($$state.initStateValues, initialStatePath, untrackedInitialValue);
3479
3533
 
3480
- var deps = spec.initFunc ? fillUninitializedStateValues($$state.specs, props, $$state.stateValues, $$state.states) : {};
3534
+ set($$state.stateValues, initialStatePath, untrackedInitialValue);
3481
3535
 
3482
- dset.dset($$state.initStateValues, state.path, _get($$state.stateValues, state.path));
3536
+ return untrackedInitialValue;
3537
+ }
3483
3538
 
3484
- $$state.initStateDeps = _extends({}, $$state.initStateDeps, deps);
3485
- forceRender(function (r) {
3486
- return r + 1;
3487
- });
3488
- return spec.initFunc ? spec.initFunc(props, $state) : spec.initVal;
3489
- }
3539
+ function useDollarState(specs, props) {
3540
+ var $$state = React__default.useRef(valtio.proxy({
3541
+ stateValues: {},
3542
+ initStateValues: {},
3543
+ specsByKey: Object.fromEntries(specs.map(function (spec) {
3544
+ return [spec.path, _extends({}, spec, {
3545
+ pathObj: transformPathStringToObj(spec.path),
3546
+ isRepeated: spec.path.split(".").some(function (part) {
3547
+ return part.endsWith("[]");
3548
+ })
3549
+ })];
3550
+ })),
3551
+ statesInstanceBySpec: new Map(),
3552
+ existingStates: new Map(),
3553
+ unsubscriptionsByState: {},
3554
+ props: undefined,
3555
+ registrationsQueue: []
3556
+ })).current;
3557
+ $$state.props = mkUntrackedValue(props);
3558
+ var $state = React__default.useRef(Object.assign(create$StateProxy($$state, function (path, spec) {
3559
+ var key = JSON.stringify(path);
3490
3560
 
3491
- return _get($$state.stateValues, state.path);
3492
- },
3493
- set: function set(_target, _property, newValue) {
3494
- if (newValue !== _get($$state.stateValues, state.path)) {
3495
- saveState(state, $$state.states);
3561
+ if (!$$state.existingStates.has(key)) {
3562
+ var _spec$initVal;
3496
3563
 
3497
- dset.dset($$state.stateValues, state.path, newValue);
3564
+ saveNewState($$state, path, spec);
3565
+ var untrackedValue = !spec.initFunc ? mkUntrackedValue((_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined) : initializeStateValue($$state, path, spec);
3498
3566
 
3499
- for (var _i3 = 0, _Object$entries3 = Object.entries($$state.initStateDeps); _i3 < _Object$entries3.length; _i3++) {
3500
- var _Object$entries3$_i = _Object$entries3[_i3],
3501
- key = _Object$entries3$_i[0],
3502
- deps = _Object$entries3$_i[1];
3567
+ set($$state.stateValues, path, untrackedValue);
3503
3568
 
3504
- if (deps.includes(JSON.stringify(state.path))) {
3505
- dset.dset($$state.stateValues, JSON.parse(key), UNINITIALIZED);
3506
- }
3507
- }
3569
+ set($$state.initStateValues, path, untrackedValue);
3570
+ }
3508
3571
 
3509
- var newDeps = fillUninitializedStateValues($$state.specs, props, $$state.stateValues, $$state.states);
3510
- $$state.initStateDeps = _extends({}, $$state.initStateDeps, newDeps);
3511
- forceRender(function (r) {
3512
- return r + 1;
3513
- });
3572
+ return {
3573
+ get: function get() {
3574
+ if (spec.valueProp) {
3575
+ var value = !spec.isRepeated ? $$state.props[spec.valueProp] : _get($$state.props[spec.valueProp], path.slice(1));
3576
+ return value;
3577
+ } else {
3578
+ return _get($$state.stateValues, path);
3514
3579
  }
3515
-
3516
- var spec = $$state.specs[state.specKey];
3580
+ },
3581
+ set: function set$1(_t, _p, value) {
3582
+ set($$state.stateValues, path, mkUntrackedValue(value));
3517
3583
 
3518
3584
  if (spec.onChangeProp) {
3519
- var _props$spec$onChangeP;
3585
+ var _$$state$props$spec$o3, _$$state$props3;
3520
3586
 
3521
- (_props$spec$onChangeP = props[spec.onChangeProp]) == null ? void 0 : _props$spec$onChangeP.call(props, newValue, state.path);
3587
+ (_$$state$props$spec$o3 = (_$$state$props3 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o3.call(_$$state$props3, value, path);
3522
3588
  }
3523
3589
 
3524
3590
  return true;
@@ -3526,157 +3592,117 @@ function useVanillaDollarState(_specs, props) {
3526
3592
  };
3527
3593
  }), {
3528
3594
  registerInitFunc: function registerInitFunc(pathStr, f) {
3529
- if (Object.values($$state.states).filter(function (_ref3) {
3530
- var specKey = _ref3.specKey;
3531
- return specKey === pathStr;
3532
- }).some(function (_ref4) {
3533
- var path = _ref4.path;
3534
- return _get($$state.stateValues, path) !== f(props, $state);
3595
+ var _$$state$statesInstan;
3596
+
3597
+ if ((_$$state$statesInstan = $$state.statesInstanceBySpec.get(pathStr)) != null && _$$state$statesInstan.some(function (_ref3) {
3598
+ var path = _ref3.path,
3599
+ specKey = _ref3.specKey;
3600
+ return !deepEqual(_get($$state.initStateValues, path), f(props, $state, getIndexes(path, $$state.specsByKey[specKey])));
3535
3601
  })) {
3536
- $$state.specs[pathStr] = _extends({}, $$state.specs[pathStr], {
3537
- initFunc: f
3538
- });
3539
- forceRender(function (r) {
3540
- return r + 1;
3602
+ $$state.registrationsQueue.push({
3603
+ pathStr: pathStr,
3604
+ f: f
3541
3605
  });
3542
3606
  }
3543
3607
  }
3544
- }); // For each spec with an initFunc, evaluate it and see if
3608
+ })).current; // For each spec with an initFunc, evaluate it and see if
3545
3609
  // the init value has changed. If so, reset its state.
3546
3610
 
3547
- var newStateValues = undefined;
3548
3611
  var resetSpecs = [];
3549
-
3550
- for (var _i4 = 0, _Object$values = Object.values($$state.states); _i4 < _Object$values.length; _i4++) {
3551
- var _Object$values$_i = _Object$values[_i4],
3552
- path = _Object$values$_i.path,
3553
- specKey = _Object$values$_i.specKey;
3554
- var spec = $$state.specs[specKey];
3612
+ $$state.existingStates.forEach(function (_ref4) {
3613
+ var path = _ref4.path,
3614
+ specKey = _ref4.specKey;
3615
+ var spec = $$state.specsByKey[specKey];
3555
3616
 
3556
3617
  if (spec.initFunc) {
3557
- var newInit = spec.initFunc(props, $state);
3618
+ var newInit = spec.initFunc(props, $state, getIndexes(path, spec));
3558
3619
 
3559
- if (newInit !== _get($$state.initStateValues, path)) {
3560
- console.log("init changed for " + JSON.stringify(path) + " from " + _get($$state.initStateValues, path) + " to " + newInit + "; resetting state");
3620
+ if (!deepEqual(newInit, _get($$state.initStateValues, path))) {
3561
3621
  resetSpecs.push({
3562
3622
  path: path,
3563
- specKey: specKey
3623
+ spec: spec
3564
3624
  });
3565
-
3566
- if (!newStateValues) {
3567
- newStateValues = cloneProxy($$state.specs, $$state.states, $$state.stateValues);
3568
- }
3569
-
3570
- dset.dset(newStateValues, path, UNINITIALIZED);
3571
3625
  }
3572
3626
  }
3573
- }
3574
-
3627
+ });
3575
3628
  React__default.useLayoutEffect(function () {
3576
- if (newStateValues !== undefined) {
3577
- var newDeps = fillUninitializedStateValues($$state.specs, props, newStateValues, $$state.states);
3578
- var initStateValues = cloneProxy($$state.specs, $$state.states, $$state.initStateValues);
3579
- resetSpecs.forEach(function (_ref5) {
3580
- var path = _ref5.path;
3581
-
3582
- dset.dset(initStateValues, path, _get(newStateValues, path));
3583
- });
3584
- $$state.stateValues = cloneProxy($$state.specs, $$state.states, newStateValues);
3585
- $$state.initStateValues = initStateValues;
3586
- $$state.initStateDeps = _extends({}, $$state.initStateDeps, newDeps);
3587
- forceRender(function (r) {
3588
- return r + 1;
3589
- });
3590
-
3591
- for (var _iterator = _createForOfIteratorHelperLoose(resetSpecs), _step; !(_step = _iterator()).done;) {
3592
- var _step$value = _step.value,
3593
- _path = _step$value.path,
3594
- _specKey = _step$value.specKey;
3595
- var _spec = $$state.specs[_specKey];
3629
+ resetSpecs.forEach(function (_ref5) {
3630
+ var path = _ref5.path,
3631
+ spec = _ref5.spec;
3632
+ var newInit = initializeStateValue($$state, path, spec);
3596
3633
 
3597
- if (_spec.onChangeProp) {
3598
- var _props$_spec$onChange;
3634
+ if (spec.onChangeProp) {
3635
+ var _$$state$props$spec$o4, _$$state$props4;
3599
3636
 
3600
- console.log("Firing onChange for reset init value: " + _spec.path, _get(newStateValues, _path));
3601
- (_props$_spec$onChange = props[_spec.onChangeProp]) == null ? void 0 : _props$_spec$onChange.call(props, _get(newStateValues, _path));
3602
- }
3637
+ (_$$state$props$spec$o4 = (_$$state$props4 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o4.call(_$$state$props4, newInit, path);
3603
3638
  }
3604
- }
3605
- }, [newStateValues, props, resetSpecs, $$state.specs]);
3606
- /* *
3607
- * Initialize all known states. (we need to do it for repeated states
3608
- * because they're created only after the first get/set operation)
3609
- * If we don't initialize them, we won't be able to consume the repeated states properly.
3610
- * For example, let's say the consumer is just mapping the repeated states. The first operation
3611
- * is to get the length of the array which will always be 0 because the existing states
3612
- * weren't allocated yet -- they're only stored in internal state)
3613
- * */
3614
-
3615
- for (var _i5 = 0, _Object$values2 = Object.values($$state.states); _i5 < _Object$values2.length; _i5++) {
3616
- var _path2 = _Object$values2[_i5].path;
3617
-
3618
- _get($state, _path2);
3619
- }
3639
+ });
3640
+ }, [props, resetSpecs]);
3641
+ React__default.useLayoutEffect(function () {
3642
+ $$state.registrationsQueue.forEach(function (_ref6) {
3643
+ var f = _ref6.f,
3644
+ pathStr = _ref6.pathStr;
3645
+ $$state.specsByKey[pathStr].initFunc = f;
3646
+ });
3647
+ $$state.registrationsQueue = [];
3648
+ }, [$$state.registrationsQueue]); // Re-render if any value changed in one of these objects
3620
3649
 
3650
+ valtio.useSnapshot($$state.stateValues, {
3651
+ sync: true
3652
+ });
3653
+ valtio.useSnapshot($$state.specsByKey, {
3654
+ sync: true
3655
+ });
3621
3656
  return $state;
3622
3657
  }
3623
3658
 
3624
- function fillUninitializedStateValues(specs, props, stateValues, states) {
3625
- var stateAccessStack = [new Set()];
3626
- var initFuncDeps = {};
3627
- var $state = Object.assign(mkProxy(specs, function (state) {
3659
+ function useCanvasDollarState(specs, props) {
3660
+ var $$state = valtio.proxy({
3661
+ stateValues: {},
3662
+ initStateValues: {},
3663
+ specsByKey: Object.fromEntries(specs.map(function (spec) {
3664
+ return [spec.path, _extends({}, spec, {
3665
+ pathObj: transformPathStringToObj(spec.path),
3666
+ isRepeated: spec.path.split(".").some(function (part) {
3667
+ return part.endsWith("[]");
3668
+ })
3669
+ })];
3670
+ })),
3671
+ statesInstanceBySpec: new Map(),
3672
+ existingStates: new Map(),
3673
+ unsubscriptionsByState: {},
3674
+ props: undefined,
3675
+ registrationsQueue: []
3676
+ });
3677
+ $$state.props = mkUntrackedValue(props);
3678
+ var $state = create$StateProxy($$state, function (path, spec) {
3628
3679
  return {
3629
- get: function get(_target, _property) {
3630
- var spec = specs[state.specKey];
3631
-
3632
- if (spec.valueProp) {
3633
- if (!spec.isRepeated) {
3634
- return props[spec.valueProp];
3635
- } else {
3636
- return _get(props[spec.valueProp], state.path.slice(1));
3637
- }
3638
- }
3639
-
3640
- var value = _get(stateValues, state.path);
3641
-
3642
- if (value === UNINITIALIZED) {
3643
- // This value has a init expression; need to be evaluated.
3644
- value = tracked(state);
3680
+ get: function get() {
3681
+ return _get($$state.stateValues, path);
3682
+ },
3683
+ set: function set$1(_t, _p, value) {
3684
+ set($$state.stateValues, path, mkUntrackedValue(value));
3645
3685
 
3646
- dset.dset(stateValues, state.path, value);
3647
- } // Record that this field had just been accessed; for
3648
- // trackInit() to know what fields were used to compute
3649
- // the init value
3686
+ if (spec.onChangeProp) {
3687
+ var _$$state$props$spec$o5, _$$state$props5;
3650
3688
 
3689
+ (_$$state$props$spec$o5 = (_$$state$props5 = $$state.props)[spec.onChangeProp]) == null ? void 0 : _$$state$props$spec$o5.call(_$$state$props5, value, path);
3690
+ }
3651
3691
 
3652
- stateAccessStack[stateAccessStack.length - 1].add(JSON.stringify(state.path));
3653
- return value;
3654
- },
3655
- set: function set() {
3656
- throw new Error("Cannot update state values during initialization");
3692
+ return true;
3657
3693
  }
3658
3694
  };
3659
- }), {
3660
- registerInitFunc: function registerInitFunc() {}
3661
3695
  });
3662
3696
 
3663
- function tracked(state) {
3664
- stateAccessStack.push(new Set());
3665
- var res = specs[state.specKey].initFunc(props, $state);
3666
- var deps = stateAccessStack.pop();
3667
- initFuncDeps[JSON.stringify(state.path)] = [].concat(deps.values());
3668
- return res;
3669
- }
3670
-
3671
- for (var _i6 = 0, _Object$values3 = Object.values(states); _i6 < _Object$values3.length; _i6++) {
3672
- var path = _Object$values3[_i6].path;
3697
+ for (var _iterator = _createForOfIteratorHelperLoose(specs), _step; !(_step = _iterator()).done;) {
3698
+ var spec = _step.value;
3699
+ var path = transformPathStringToObj(spec.path);
3700
+ var init = spec.valueProp ? $$state.props[spec.valueProp] : spec.initVal ? spec.initVal : spec.initFunc ? initializeStateValue($$state, path, $$state.specsByKey[spec.path]) : undefined;
3673
3701
 
3674
- if (_get(stateValues, path) === UNINITIALIZED) {
3675
- _get($state, path);
3676
- }
3702
+ set($state, path, init);
3677
3703
  }
3678
3704
 
3679
- return initFuncDeps;
3705
+ return $state;
3680
3706
  }
3681
3707
 
3682
3708
  exports.DropdownMenu = DropdownMenu;
@@ -3701,14 +3727,17 @@ exports.generateStateValueProp = generateStateValueProp;
3701
3727
  exports.getDataProps = getDataProps;
3702
3728
  exports.hasVariant = hasVariant;
3703
3729
  exports.makeFragment = makeFragment;
3730
+ exports.mergeVariantsWithStates = mergeVariantsWithStates;
3704
3731
  exports.omit = omit;
3705
3732
  exports.pick = pick;
3706
3733
  exports.plasmicHeadMeta = plasmicHeadMeta;
3707
3734
  exports.renderPlasmicSlot = renderPlasmicSlot;
3735
+ exports.set = set;
3708
3736
  exports.setPlumeStrictMode = setPlumeStrictMode;
3709
3737
  exports.useButton = useButton;
3738
+ exports.useCanvasDollarState = useCanvasDollarState;
3710
3739
  exports.useCheckbox = useCheckbox;
3711
- exports.useDollarState = useVanillaDollarState;
3740
+ exports.useDollarState = useDollarState;
3712
3741
  exports.useIsSSR = useIsSSR;
3713
3742
  exports.useMenu = useMenu;
3714
3743
  exports.useMenuButton = useMenuButton;