@plasmicapp/react-web 0.2.103 → 0.2.104

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 (46) hide show
  1. package/dist/all.d.ts +118 -105
  2. package/dist/plume/menu-button/menu-trigger.d.ts +1 -1
  3. package/dist/react-web.cjs.development.js +218 -126
  4. package/dist/react-web.cjs.development.js.map +1 -1
  5. package/dist/react-web.cjs.production.min.js +1 -1
  6. package/dist/react-web.cjs.production.min.js.map +1 -1
  7. package/dist/react-web.esm.js +218 -126
  8. package/dist/react-web.esm.js.map +1 -1
  9. package/dist/render/triggers.d.ts +4 -4
  10. package/dist/states/index.d.ts +3 -1
  11. package/dist/stories/UseDollarState.stories.d.ts +7 -0
  12. package/package.json +20 -19
  13. package/skinny/dist/collection-utils-57c273dc.js +238 -0
  14. package/skinny/dist/collection-utils-57c273dc.js.map +1 -0
  15. package/skinny/dist/common-182a0b0c.js +201 -0
  16. package/skinny/dist/common-182a0b0c.js.map +1 -0
  17. package/skinny/dist/index.js +63 -43
  18. package/skinny/dist/index.js.map +1 -1
  19. package/skinny/dist/plume/button/index.js +5 -5
  20. package/skinny/dist/plume/button/index.js.map +1 -1
  21. package/skinny/dist/plume/checkbox/index.js +6 -6
  22. package/skinny/dist/plume/checkbox/index.js.map +1 -1
  23. package/skinny/dist/plume/menu/index.js +11 -11
  24. package/skinny/dist/plume/menu/index.js.map +1 -1
  25. package/skinny/dist/plume/menu-button/index.js +6 -6
  26. package/skinny/dist/plume/menu-button/index.js.map +1 -1
  27. package/skinny/dist/plume/menu-button/menu-trigger.d.ts +1 -1
  28. package/skinny/dist/plume/select/index.js +11 -11
  29. package/skinny/dist/plume/select/index.js.map +1 -1
  30. package/skinny/dist/plume/switch/index.js +6 -6
  31. package/skinny/dist/plume/switch/index.js.map +1 -1
  32. package/skinny/dist/plume/text-input/index.js +5 -5
  33. package/skinny/dist/plume/text-input/index.js.map +1 -1
  34. package/skinny/dist/plume/triggered-overlay/index.js +7 -7
  35. package/skinny/dist/plume/triggered-overlay/index.js.map +1 -1
  36. package/skinny/dist/plume-utils-623b91cc.js +35 -0
  37. package/skinny/dist/plume-utils-623b91cc.js.map +1 -0
  38. package/skinny/dist/props-utils-b2ad4997.js +8 -0
  39. package/skinny/dist/props-utils-b2ad4997.js.map +1 -0
  40. package/skinny/dist/react-utils-35cb2a4e.js +201 -0
  41. package/skinny/dist/react-utils-35cb2a4e.js.map +1 -0
  42. package/skinny/dist/render/PlasmicImg/index.js +3 -3
  43. package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
  44. package/skinny/dist/render/triggers.d.ts +4 -4
  45. package/skinny/dist/states/index.d.ts +3 -1
  46. package/skinny/dist/stories/UseDollarState.stories.d.ts +7 -0
@@ -3167,8 +3167,8 @@ function mkProxy(specs, maybeHandlers) {
3167
3167
  };
3168
3168
  };
3169
3169
 
3170
- var rec = function rec(currPath) {
3171
- var nextParts = Object.fromEntries(specs.filter(function (spec) {
3170
+ var getNextParts = function getNextParts(currPath) {
3171
+ return Object.fromEntries(Object.values(specs).filter(function (spec) {
3172
3172
  return shallowEqual(currPath.map(function (p) {
3173
3173
  return isNum(p) ? "[]" : p;
3174
3174
  }), spec.path.slice(0, currPath.length));
@@ -3178,16 +3178,74 @@ function mkProxy(specs, maybeHandlers) {
3178
3178
  if (spec.path.length === currPath.length + 1) {
3179
3179
  return [nextPart, {
3180
3180
  isLast: true,
3181
- spec: spec
3181
+ specKey: spec.pathStr
3182
3182
  }];
3183
3183
  } else {
3184
3184
  return [nextPart, {
3185
3185
  isLast: false,
3186
- spec: spec
3186
+ specKey: spec.pathStr
3187
3187
  }];
3188
3188
  }
3189
3189
  }));
3190
+ };
3191
+ /**
3192
+ * We use this function when we're setting a value in the middle of the state path.
3193
+ * We can't just set the value, because we need to keep the proxy properties, so
3194
+ * we use the specs to walk through the object and just set the value in the end of the path
3195
+ **/
3196
+
3197
+
3198
+ var cloneValue = function cloneValue(target, currPath, value) {
3199
+ if (typeof value !== "object") {
3200
+ return;
3201
+ }
3202
+
3203
+ var nextParts = getNextParts(currPath);
3204
+
3205
+ for (var _i = 0, _Object$entries = Object.entries(nextParts); _i < _Object$entries.length; _i++) {
3206
+ var _Object$entries$_i = _Object$entries[_i],
3207
+ nextPart = _Object$entries$_i[0],
3208
+ _Object$entries$_i$ = _Object$entries$_i[1],
3209
+ isLast = _Object$entries$_i$.isLast,
3210
+ specKey = _Object$entries$_i$.specKey;
3211
+
3212
+ if (nextPart === "[]" && Array.isArray(value)) {
3213
+ for (var i = 0; i < value.length; i++) {
3214
+ cloneValue(target[i], [].concat(currPath, [i]), value[i]);
3215
+ }
3216
+ } else if (nextPart in value) {
3217
+ if (isLast) {
3218
+ var _handlers$set, _handlers;
3219
+
3220
+ handlers == null ? void 0 : (_handlers$set = (_handlers = handlers({
3221
+ specKey: specKey,
3222
+ path: [].concat(currPath, [nextPart])
3223
+ })).set) == null ? void 0 : _handlers$set.call(_handlers, target, nextPart, value[nextPart], undefined);
3224
+ } else {
3225
+ cloneValue(target[nextPart], [].concat(currPath, [nextPart]), value[nextPart]);
3226
+ }
3227
+ }
3228
+ }
3229
+ };
3230
+
3231
+ var rec = function rec(currPath) {
3232
+ var nextParts = getNextParts(currPath);
3190
3233
  return new Proxy("[]" in nextParts ? [] : {}, {
3234
+ deleteProperty: function deleteProperty(target, property) {
3235
+ if ("[]" in nextParts && isNum(property)) {
3236
+ var _handlers$deletePrope, _handlers2;
3237
+
3238
+ delete target[property];
3239
+ handlers == null ? void 0 : (_handlers$deletePrope = (_handlers2 = handlers({
3240
+ path: [].concat(currPath, [+property]),
3241
+ specKey: nextParts["[]"].specKey
3242
+ })).deleteProperty) == null ? void 0 : _handlers$deletePrope.call(_handlers2, target, property);
3243
+ } else {
3244
+ throw new Error("You can't delete a non-repeated property in the middle of the path");
3245
+ }
3246
+
3247
+ return true;
3248
+ },
3191
3249
  get: function get(target, property, receiver) {
3192
3250
  if ("[]" in nextParts && isNum(property)) {
3193
3251
  if (!(property in target)) {
@@ -3195,12 +3253,12 @@ function mkProxy(specs, maybeHandlers) {
3195
3253
  }
3196
3254
  } else if (property in nextParts) {
3197
3255
  if (nextParts[property].isLast) {
3198
- var _handlers$get, _handlers;
3256
+ var _handlers$get, _handlers3;
3199
3257
 
3200
- return handlers == null ? void 0 : (_handlers$get = (_handlers = handlers({
3258
+ return target[property] = handlers == null ? void 0 : (_handlers$get = (_handlers3 = handlers({
3201
3259
  path: [].concat(currPath, [property]),
3202
- spec: nextParts[property].spec
3203
- })).get) == null ? void 0 : _handlers$get.call(_handlers, target, property, receiver);
3260
+ specKey: nextParts[property].specKey
3261
+ })).get) == null ? void 0 : _handlers$get.call(_handlers3, target, property, receiver);
3204
3262
  } else if (!(property in target)) {
3205
3263
  target[property] = rec([].concat(currPath, [property]));
3206
3264
  }
@@ -3209,21 +3267,29 @@ function mkProxy(specs, maybeHandlers) {
3209
3267
  return target[property];
3210
3268
  },
3211
3269
  set: function set(target, property, value, receiver) {
3212
- if (!(property in target) && property in nextParts) {
3270
+ if ("[]" in nextParts && isNum(property)) {
3271
+ if (!(property in target)) {
3272
+ target[property] = rec([].concat(currPath, [+property]));
3273
+ }
3274
+ } else if (property in nextParts) {
3213
3275
  if (nextParts[property].isLast) {
3214
- var _handlers$set, _handlers$set2, _handlers2;
3276
+ var _handlers$set2, _handlers$set3, _handlers4;
3215
3277
 
3216
- return (_handlers$set = (_handlers$set2 = (_handlers2 = handlers({
3278
+ target[property] = value;
3279
+ return (_handlers$set2 = (_handlers$set3 = (_handlers4 = handlers({
3217
3280
  path: [].concat(currPath, [property]),
3218
- spec: nextParts[property].spec
3219
- })).set) == null ? void 0 : _handlers$set2.call(_handlers2, target, property, value, receiver)) != null ? _handlers$set : false;
3220
- } else {
3221
- throw new Error("You can't set a value in the middle of the path");
3281
+ specKey: nextParts[property].specKey
3282
+ })).set) == null ? void 0 : _handlers$set3.call(_handlers4, target, property, value, receiver)) != null ? _handlers$set2 : false;
3222
3283
  }
3223
- } else {
3284
+ }
3285
+
3286
+ if (property === "registerInitFunc") {
3224
3287
  target[property] = value;
3225
- return true;
3288
+ } else if (typeof value === "object") {
3289
+ cloneValue(target[property], [].concat(currPath, [isNum(property) ? +property : property]), value);
3226
3290
  }
3291
+
3292
+ return true;
3227
3293
  }
3228
3294
  });
3229
3295
  };
@@ -3259,133 +3325,141 @@ var transformPathStringToObj = function transformPathStringToObj(str) {
3259
3325
  };
3260
3326
 
3261
3327
  function useVanillaDollarState(_specs, props) {
3262
- var specs = _specs.map(function (_ref2) {
3263
- var pathStr = _ref2.path,
3264
- spec = _objectWithoutPropertiesLoose(_ref2, ["path"]);
3265
-
3266
- return _extends({}, spec, {
3267
- pathStr: pathStr,
3268
- path: transformPathStringToObj(pathStr),
3269
- isRepeated: pathStr.split(".").some(function (part) {
3270
- return part.endsWith("[]");
3271
- })
3272
- });
3273
- });
3274
-
3275
- var _React$useState = React__default.useState(function () {
3276
- var stateValues = mkProxy(specs);
3277
- var initStates = {};
3278
-
3279
- for (var _iterator = _createForOfIteratorHelperLoose(specs), _step; !(_step = _iterator()).done;) {
3280
- var spec = _step.value;
3281
-
3282
- if (spec.valueProp || spec.isRepeated) {
3283
- continue;
3284
- } else if (spec.initFunc) {
3285
- dset(stateValues, spec.path, UNINITIALIZED);
3286
- } else {
3287
- var _spec$initVal;
3288
-
3289
- dset(stateValues, spec.path, (_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined);
3290
- }
3291
-
3292
- saveState({
3293
- path: spec.path,
3294
- spec: spec
3295
- }, initStates);
3296
- }
3297
-
3298
- var deps = fillUninitializedStateValues(specs, props, stateValues, initStates);
3328
+ var forceRender = React__default.useState(0)[1];
3329
+ var $$state = React__default.useMemo(function () {
3330
+ var specs = Object.fromEntries(_specs.map(function (_ref2) {
3331
+ var pathStr = _ref2.path,
3332
+ spec = _objectWithoutPropertiesLoose(_ref2, ["path"]);
3333
+
3334
+ return [pathStr, _extends({}, spec, {
3335
+ pathStr: pathStr,
3336
+ path: transformPathStringToObj(pathStr),
3337
+ isRepeated: pathStr.split(".").some(function (part) {
3338
+ return part.endsWith("[]");
3339
+ })
3340
+ })];
3341
+ }));
3299
3342
  return {
3300
- stateValues: stateValues,
3301
- initStateDeps: deps,
3302
- initStateValues: cloneProxy(specs, initStates, stateValues),
3303
- states: initStates
3343
+ stateValues: mkProxy(specs),
3344
+ initStateDeps: {},
3345
+ initStateValues: mkProxy(specs),
3346
+ states: {},
3347
+ specs: specs
3304
3348
  };
3305
- }),
3306
- $$state = _React$useState[0],
3307
- set$$State = _React$useState[1];
3308
-
3309
- var $state = mkProxy(specs, function (state) {
3349
+ }, []);
3350
+ var $state = Object.assign(mkProxy($$state.specs, function (state) {
3310
3351
  return {
3352
+ deleteProperty: function deleteProperty(_target, _property) {
3353
+ var prefixPath = state.path;
3354
+
3355
+ for (var _i2 = 0, _Object$entries2 = Object.entries($$state.states); _i2 < _Object$entries2.length; _i2++) {
3356
+ var _Object$entries2$_i = _Object$entries2[_i2],
3357
+ key = _Object$entries2$_i[0],
3358
+ existingState = _Object$entries2$_i[1];
3359
+
3360
+ if (existingState.path.length >= prefixPath.length && shallowEqual(existingState.path.slice(0, prefixPath.length), prefixPath)) {
3361
+ delete $$state.states[key];
3362
+ }
3363
+ }
3364
+
3365
+ forceRender(function (r) {
3366
+ return r + 1;
3367
+ });
3368
+ return true;
3369
+ },
3311
3370
  get: function get(_target, _property) {
3312
- if (state.spec.valueProp) {
3313
- if (!state.spec.isRepeated) {
3314
- return props[state.spec.valueProp];
3371
+ var spec = $$state.specs[state.specKey];
3372
+
3373
+ if (spec.valueProp) {
3374
+ if (!spec.isRepeated) {
3375
+ return props[spec.valueProp];
3315
3376
  } else {
3316
- return _get(props[state.spec.valueProp], state.path.slice(1));
3377
+ return _get(props[spec.valueProp], state.path.slice(1));
3317
3378
  }
3318
3379
  }
3319
3380
 
3320
3381
  if (!hasState(state, $$state.states)) {
3321
- var _state$spec$initVal;
3382
+ var _spec$initVal;
3322
3383
 
3323
3384
  saveState(state, $$state.states);
3324
3385
 
3325
- dset($$state.stateValues, state.path, state.spec.initFunc ? UNINITIALIZED : (_state$spec$initVal = state.spec.initVal) != null ? _state$spec$initVal : undefined);
3386
+ dset($$state.stateValues, state.path, spec.initFunc ? UNINITIALIZED : (_spec$initVal = spec.initVal) != null ? _spec$initVal : undefined);
3326
3387
 
3327
- var deps = state.spec.initFunc ? fillUninitializedStateValues(specs, props, $$state.stateValues, $$state.states) : {};
3388
+ var deps = spec.initFunc ? fillUninitializedStateValues($$state.specs, props, $$state.stateValues, $$state.states) : {};
3328
3389
 
3329
3390
  dset($$state.initStateValues, state.path, _get($$state.stateValues, state.path));
3330
3391
 
3331
- set$$State(function (prev) {
3332
- return {
3333
- initStateValues: cloneProxy(specs, prev.states, prev.stateValues),
3334
- stateValues: cloneProxy(specs, prev.states, prev.initStateValues),
3335
- initStateDeps: _extends({}, prev.initStateDeps, deps),
3336
- states: _extends({}, prev.states)
3337
- };
3392
+ $$state.initStateDeps = _extends({}, $$state.initStateDeps, deps);
3393
+ forceRender(function (r) {
3394
+ return r + 1;
3338
3395
  });
3396
+ return spec.initFunc ? spec.initFunc(props, $state) : spec.initVal;
3339
3397
  }
3340
3398
 
3341
3399
  return _get($$state.stateValues, state.path);
3342
3400
  },
3343
3401
  set: function set(_target, _property, newValue) {
3344
- saveState(state, $$state.states);
3345
-
3346
3402
  if (newValue !== _get($$state.stateValues, state.path)) {
3403
+ saveState(state, $$state.states);
3404
+
3347
3405
  dset($$state.stateValues, state.path, newValue);
3348
3406
 
3349
- for (var _i = 0, _Object$entries = Object.entries($$state.initStateDeps); _i < _Object$entries.length; _i++) {
3350
- var _Object$entries$_i = _Object$entries[_i],
3351
- key = _Object$entries$_i[0],
3352
- deps = _Object$entries$_i[1];
3407
+ for (var _i3 = 0, _Object$entries3 = Object.entries($$state.initStateDeps); _i3 < _Object$entries3.length; _i3++) {
3408
+ var _Object$entries3$_i = _Object$entries3[_i3],
3409
+ key = _Object$entries3$_i[0],
3410
+ deps = _Object$entries3$_i[1];
3353
3411
 
3354
3412
  if (deps.includes(JSON.stringify(state.path))) {
3355
3413
  dset($$state.stateValues, JSON.parse(key), UNINITIALIZED);
3356
3414
  }
3357
3415
  }
3358
3416
 
3359
- var newDeps = fillUninitializedStateValues(specs, props, $$state.stateValues, $$state.states);
3360
- set$$State(function (prev) {
3361
- return {
3362
- initStateValues: _extends({}, prev.initStateValues),
3363
- stateValues: cloneProxy(specs, prev.states, prev.stateValues),
3364
- initStateDeps: _extends({}, prev.initStateDeps, newDeps),
3365
- states: _extends({}, prev.states)
3366
- };
3417
+ var newDeps = fillUninitializedStateValues($$state.specs, props, $$state.stateValues, $$state.states);
3418
+ $$state.initStateDeps = _extends({}, $$state.initStateDeps, newDeps);
3419
+ forceRender(function (r) {
3420
+ return r + 1;
3367
3421
  });
3422
+ }
3368
3423
 
3369
- if (state.spec.onChangeProp) {
3370
- var _props$state$spec$onC;
3424
+ var spec = $$state.specs[state.specKey];
3371
3425
 
3372
- (_props$state$spec$onC = props[state.spec.onChangeProp]) == null ? void 0 : _props$state$spec$onC.call(props, newValue, state.path);
3373
- }
3426
+ if (spec.onChangeProp) {
3427
+ var _props$spec$onChangeP;
3428
+
3429
+ (_props$spec$onChangeP = props[spec.onChangeProp]) == null ? void 0 : _props$spec$onChangeP.call(props, newValue, state.path);
3374
3430
  }
3375
3431
 
3376
3432
  return true;
3377
3433
  }
3378
3434
  };
3435
+ }), {
3436
+ registerInitFunc: function registerInitFunc(pathStr, f) {
3437
+ if (Object.values($$state.states).filter(function (_ref3) {
3438
+ var specKey = _ref3.specKey;
3439
+ return specKey === pathStr;
3440
+ }).some(function (_ref4) {
3441
+ var path = _ref4.path;
3442
+ return _get($$state.stateValues, path) !== f(props, $state);
3443
+ })) {
3444
+ $$state.specs[pathStr] = _extends({}, $$state.specs[pathStr], {
3445
+ initFunc: f
3446
+ });
3447
+ forceRender(function (r) {
3448
+ return r + 1;
3449
+ });
3450
+ }
3451
+ }
3379
3452
  }); // For each spec with an initFunc, evaluate it and see if
3380
3453
  // the init value has changed. If so, reset its state.
3381
3454
 
3382
3455
  var newStateValues = undefined;
3383
3456
  var resetSpecs = [];
3384
3457
 
3385
- for (var _i2 = 0, _Object$values = Object.values($$state.states); _i2 < _Object$values.length; _i2++) {
3386
- var _Object$values$_i = _Object$values[_i2],
3458
+ for (var _i4 = 0, _Object$values = Object.values($$state.states); _i4 < _Object$values.length; _i4++) {
3459
+ var _Object$values$_i = _Object$values[_i4],
3387
3460
  path = _Object$values$_i.path,
3388
- spec = _Object$values$_i.spec;
3461
+ specKey = _Object$values$_i.specKey;
3462
+ var spec = $$state.specs[specKey];
3389
3463
 
3390
3464
  if (spec.initFunc) {
3391
3465
  var newInit = spec.initFunc(props, $state);
@@ -3394,11 +3468,11 @@ function useVanillaDollarState(_specs, props) {
3394
3468
  console.log("init changed for " + JSON.stringify(path) + " from " + _get($$state.initStateValues, path) + " to " + newInit + "; resetting state");
3395
3469
  resetSpecs.push({
3396
3470
  path: path,
3397
- spec: spec
3471
+ specKey: specKey
3398
3472
  });
3399
3473
 
3400
3474
  if (!newStateValues) {
3401
- newStateValues = cloneProxy(specs, $$state.states, $$state.stateValues);
3475
+ newStateValues = cloneProxy($$state.specs, $$state.states, $$state.stateValues);
3402
3476
  }
3403
3477
 
3404
3478
  dset(newStateValues, path, UNINITIALIZED);
@@ -3408,26 +3482,25 @@ function useVanillaDollarState(_specs, props) {
3408
3482
 
3409
3483
  React__default.useLayoutEffect(function () {
3410
3484
  if (newStateValues !== undefined) {
3411
- var newDeps = fillUninitializedStateValues(specs, props, newStateValues, $$state.states);
3412
- set$$State(function (prev) {
3413
- var initStateValues = cloneProxy(specs, prev.states, prev.initStateValues);
3414
- resetSpecs.forEach(function (_ref3) {
3415
- var path = _ref3.path;
3485
+ var newDeps = fillUninitializedStateValues($$state.specs, props, newStateValues, $$state.states);
3486
+ var initStateValues = cloneProxy($$state.specs, $$state.states, $$state.initStateValues);
3487
+ resetSpecs.forEach(function (_ref5) {
3488
+ var path = _ref5.path;
3416
3489
 
3417
- dset(initStateValues, path, _get(newStateValues, path));
3418
- });
3419
- return {
3420
- stateValues: cloneProxy(specs, prev.states, newStateValues),
3421
- initStateDeps: _extends({}, prev.initStateDeps, newDeps),
3422
- initStateValues: initStateValues,
3423
- states: _extends({}, prev.states)
3424
- };
3490
+ dset(initStateValues, path, _get(newStateValues, path));
3491
+ });
3492
+ $$state.stateValues = cloneProxy($$state.specs, $$state.states, newStateValues);
3493
+ $$state.initStateValues = initStateValues;
3494
+ $$state.initStateDeps = _extends({}, $$state.initStateDeps, newDeps);
3495
+ forceRender(function (r) {
3496
+ return r + 1;
3425
3497
  });
3426
3498
 
3427
- for (var _iterator2 = _createForOfIteratorHelperLoose(resetSpecs), _step2; !(_step2 = _iterator2()).done;) {
3428
- var _step2$value = _step2.value,
3429
- _path = _step2$value.path,
3430
- _spec = _step2$value.spec;
3499
+ for (var _iterator = _createForOfIteratorHelperLoose(resetSpecs), _step; !(_step = _iterator()).done;) {
3500
+ var _step$value = _step.value,
3501
+ _path = _step$value.path,
3502
+ _specKey = _step$value.specKey;
3503
+ var _spec = $$state.specs[_specKey];
3431
3504
 
3432
3505
  if (_spec.onChangeProp) {
3433
3506
  var _props$_spec$onChange;
@@ -3437,21 +3510,38 @@ function useVanillaDollarState(_specs, props) {
3437
3510
  }
3438
3511
  }
3439
3512
  }
3440
- }, [newStateValues, props, resetSpecs, specs]);
3513
+ }, [newStateValues, props, resetSpecs, $$state.specs]);
3514
+ /* *
3515
+ * Initialize all known states. (we need to do it for repeated states
3516
+ * because they're created only after the first get/set operation)
3517
+ * If we don't initialize them, we won't be able to consume the repeated states properly.
3518
+ * For example, let's say the consumer is just mapping the repeated states. The first operation
3519
+ * is to get the length of the array which will always be 0 because the existing states
3520
+ * weren't allocated yet -- they're only stored in internal state)
3521
+ * */
3522
+
3523
+ for (var _i5 = 0, _Object$values2 = Object.values($$state.states); _i5 < _Object$values2.length; _i5++) {
3524
+ var _path2 = _Object$values2[_i5].path;
3525
+
3526
+ _get($state, _path2);
3527
+ }
3528
+
3441
3529
  return $state;
3442
3530
  }
3443
3531
 
3444
3532
  function fillUninitializedStateValues(specs, props, stateValues, states) {
3445
3533
  var stateAccessStack = [new Set()];
3446
3534
  var initFuncDeps = {};
3447
- var $state = mkProxy(specs, function (state) {
3535
+ var $state = Object.assign(mkProxy(specs, function (state) {
3448
3536
  return {
3449
3537
  get: function get(_target, _property) {
3450
- if (state.spec.valueProp) {
3451
- if (!state.spec.isRepeated) {
3452
- return props[state.spec.valueProp];
3538
+ var spec = specs[state.specKey];
3539
+
3540
+ if (spec.valueProp) {
3541
+ if (!spec.isRepeated) {
3542
+ return props[spec.valueProp];
3453
3543
  } else {
3454
- return _get(props[state.spec.valueProp], state.path.slice(1));
3544
+ return _get(props[spec.valueProp], state.path.slice(1));
3455
3545
  }
3456
3546
  }
3457
3547
 
@@ -3474,18 +3564,20 @@ function fillUninitializedStateValues(specs, props, stateValues, states) {
3474
3564
  throw new Error("Cannot update state values during initialization");
3475
3565
  }
3476
3566
  };
3567
+ }), {
3568
+ registerInitFunc: function registerInitFunc() {}
3477
3569
  });
3478
3570
 
3479
3571
  function tracked(state) {
3480
3572
  stateAccessStack.push(new Set());
3481
- var res = state.spec.initFunc(props, $state);
3573
+ var res = specs[state.specKey].initFunc(props, $state);
3482
3574
  var deps = stateAccessStack.pop();
3483
3575
  initFuncDeps[JSON.stringify(state.path)] = [].concat(deps.values());
3484
3576
  return res;
3485
3577
  }
3486
3578
 
3487
- for (var _i3 = 0, _Object$values2 = Object.values(states); _i3 < _Object$values2.length; _i3++) {
3488
- var path = _Object$values2[_i3].path;
3579
+ for (var _i6 = 0, _Object$values3 = Object.values(states); _i6 < _Object$values3.length; _i6++) {
3580
+ var path = _Object$values3[_i6].path;
3489
3581
 
3490
3582
  if (_get(stateValues, path) === UNINITIALIZED) {
3491
3583
  _get($state, path);