@plasmicapp/react-web 0.2.248 → 0.2.249

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
@@ -2160,7 +2160,9 @@ function create$StateProxy($$state, leafHandlers) {
2160
2160
  var nextPath = getNextPath(property);
2161
2161
  var nextNode = currNode.makeTransition(property);
2162
2162
  var nextSpec = nextNode === null || nextNode === void 0 ? void 0 : nextNode.getSpec();
2163
- if (property === "registerInitFunc" && currPath.length === 0) {
2163
+ if ((property === "registerInitFunc" ||
2164
+ property === "eagerInitializeStates") &&
2165
+ currPath.length === 0) {
2164
2166
  return Reflect.set(target, property, value, receiver);
2165
2167
  }
2166
2168
  if (!nextNode && currNode.hasArrayTransition()) {
@@ -2307,8 +2309,7 @@ function useDollarState(specs) {
2307
2309
  }
2308
2310
  },
2309
2311
  };
2310
- }), {
2311
- registerInitFunc: function (pathStr, f, repetitionIndex, overrideEnv) {
2312
+ }), __assign({ registerInitFunc: function (pathStr, f, repetitionIndex, overrideEnv) {
2312
2313
  var _a = findStateCell($$state.rootSpecTree, pathStr, repetitionIndex), node = _a.node, realPath = _a.realPath;
2313
2314
  var stateCell = getStateCellFrom$StateRoot($state, realPath);
2314
2315
  var env = overrideEnv
@@ -2324,10 +2325,37 @@ function useDollarState(specs) {
2324
2325
  : undefined,
2325
2326
  }));
2326
2327
  }
2327
- },
2328
- });
2328
+ } }, ((opts === null || opts === void 0 ? void 0 : opts.inCanvas)
2329
+ ? {
2330
+ eagerInitializeStates: function (specs) {
2331
+ // we need to eager initialize all states in canvas to populate the data picker
2332
+ $$state.specTreeLeaves.forEach(function (node) {
2333
+ var _a, _b;
2334
+ var spec = node.getSpec();
2335
+ if (spec.isRepeated) {
2336
+ return;
2337
+ }
2338
+ var stateCell = getStateCellFrom$StateRoot($state, spec.pathObj);
2339
+ var newSpec = specs.find(function (sp) { return sp.path === spec.path; });
2340
+ if (!newSpec ||
2341
+ (stateCell.initFuncHash === ((_a = newSpec === null || newSpec === void 0 ? void 0 : newSpec.initFuncHash) !== null && _a !== void 0 ? _a : "") &&
2342
+ stateCell.initialValue !== UNINITIALIZED)) {
2343
+ return;
2344
+ }
2345
+ stateCell.initFunc = newSpec.initFunc;
2346
+ stateCell.initFuncHash = (_b = newSpec.initFuncHash) !== null && _b !== void 0 ? _b : "";
2347
+ var init = spec.valueProp
2348
+ ? $$state.env.$props[spec.valueProp]
2349
+ : spec.initFunc
2350
+ ? initializeStateValue($$state, stateCell, $state)
2351
+ : spec.initVal;
2352
+ set($state, spec.pathObj, init);
2353
+ });
2354
+ },
2355
+ }
2356
+ : {})));
2329
2357
  return $state;
2330
- }, []);
2358
+ }, [opts === null || opts === void 0 ? void 0 : opts.inCanvas]);
2331
2359
  var ref = React.useRef(undefined);
2332
2360
  if (!ref.current) {
2333
2361
  ref.current = create$State();
@@ -2350,29 +2378,6 @@ function useDollarState(specs) {
2350
2378
  }
2351
2379
  });
2352
2380
  }
2353
- // we need to eager initialize all states in canvas to populate the data picker
2354
- $$state.specTreeLeaves.forEach(function (node) {
2355
- var _a, _b;
2356
- var spec = node.getSpec();
2357
- if (spec.isRepeated) {
2358
- return;
2359
- }
2360
- var stateCell = getStateCellFrom$StateRoot($state, spec.pathObj);
2361
- var newSpec = specs.find(function (sp) { return sp.path === spec.path; });
2362
- if (!newSpec ||
2363
- (stateCell.initFuncHash === ((_a = newSpec === null || newSpec === void 0 ? void 0 : newSpec.initFuncHash) !== null && _a !== void 0 ? _a : "") &&
2364
- stateCell.initialValue !== UNINITIALIZED)) {
2365
- return;
2366
- }
2367
- stateCell.initFunc = newSpec.initFunc;
2368
- stateCell.initFuncHash = (_b = newSpec.initFuncHash) !== null && _b !== void 0 ? _b : "";
2369
- var init = spec.valueProp
2370
- ? $$state.env.$props[spec.valueProp]
2371
- : spec.initFunc
2372
- ? initializeStateValue($$state, stateCell, $state)
2373
- : spec.initVal;
2374
- set($state, spec.pathObj, init);
2375
- });
2376
2381
  }
2377
2382
  // For each spec with an initFunc, evaluate it and see if
2378
2383
  // the init value has changed. If so, reset its state.