@plasmicapp/react-web 0.2.178 → 0.2.180

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 (35) hide show
  1. package/dist/all.d.ts +2 -2
  2. package/dist/react-web.cjs.development.js +135 -11
  3. package/dist/react-web.cjs.development.js.map +1 -1
  4. package/dist/react-web.cjs.production.min.js +1 -1
  5. package/dist/react-web.cjs.production.min.js.map +1 -1
  6. package/dist/react-web.esm.js +135 -11
  7. package/dist/react-web.esm.js.map +1 -1
  8. package/dist/states/errors.d.ts +13 -0
  9. package/dist/states/types.d.ts +4 -0
  10. package/dist/stories/UseDollarState.stories.d.ts +1 -0
  11. package/package.json +4 -4
  12. package/skinny/dist/{collection-utils-719bb030.js → collection-utils-0bfbb8a8.js} +4 -4
  13. package/skinny/dist/{collection-utils-719bb030.js.map → collection-utils-0bfbb8a8.js.map} +1 -1
  14. package/skinny/dist/{common-dd6b46fb.js → common-125681b4.js} +18 -2
  15. package/skinny/dist/{common-dd6b46fb.js.map → common-125681b4.js.map} +1 -1
  16. package/skinny/dist/index.js +84 -17
  17. package/skinny/dist/index.js.map +1 -1
  18. package/skinny/dist/plume/button/index.js +2 -2
  19. package/skinny/dist/plume/checkbox/index.js +4 -4
  20. package/skinny/dist/plume/menu/index.js +5 -5
  21. package/skinny/dist/plume/menu-button/index.js +4 -4
  22. package/skinny/dist/plume/select/index.js +5 -5
  23. package/skinny/dist/plume/switch/index.js +4 -4
  24. package/skinny/dist/plume/text-input/index.js +2 -2
  25. package/skinny/dist/plume/triggered-overlay/index.js +4 -4
  26. package/skinny/dist/{plume-utils-43df92e6.js → plume-utils-427ac667.js} +2 -2
  27. package/skinny/dist/{plume-utils-43df92e6.js.map → plume-utils-427ac667.js.map} +1 -1
  28. package/skinny/dist/{props-utils-eaa18f66.js → props-utils-5092839e.js} +2 -2
  29. package/skinny/dist/{props-utils-eaa18f66.js.map → props-utils-5092839e.js.map} +1 -1
  30. package/skinny/dist/{react-utils-628465ba.js → react-utils-091cf05d.js} +2 -2
  31. package/skinny/dist/{react-utils-628465ba.js.map → react-utils-091cf05d.js.map} +1 -1
  32. package/skinny/dist/render/PlasmicImg/index.js +2 -2
  33. package/skinny/dist/states/errors.d.ts +13 -0
  34. package/skinny/dist/states/types.d.ts +4 -0
  35. package/skinny/dist/stories/UseDollarState.stories.d.ts +1 -0
package/dist/all.d.ts CHANGED
@@ -11388,7 +11388,7 @@ declare type ExternalComponentHelpers<P> = {
11388
11388
  isDefaultExport: true;
11389
11389
  });
11390
11390
  declare type StyleSection = "visibility" | "typography" | "sizing" | "spacing" | "background" | "transform" | "transitions" | "layout" | "overflow" | "border" | "shadows" | "effects";
11391
- interface ComponentMeta<P> {
11391
+ interface CodeComponentMeta<P> {
11392
11392
  /**
11393
11393
  * Any unique string name used to identify that component. Each component
11394
11394
  * should be registered with a different `meta.name`, even if they have the
@@ -11515,7 +11515,7 @@ interface RefActionRegistration<P> {
11515
11515
  }
11516
11516
  interface ComponentRegistration {
11517
11517
  component: React.ComponentType<any>;
11518
- meta: ComponentMeta<any>;
11518
+ meta: CodeComponentMeta<any>;
11519
11519
  }
11520
11520
  declare global {
11521
11521
  interface Window {
@@ -76,6 +76,79 @@ function _extends() {
76
76
  };
77
77
  return _extends.apply(this, arguments);
78
78
  }
79
+ function _inheritsLoose(subClass, superClass) {
80
+ subClass.prototype = Object.create(superClass.prototype);
81
+ subClass.prototype.constructor = subClass;
82
+ _setPrototypeOf(subClass, superClass);
83
+ }
84
+ function _getPrototypeOf(o) {
85
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
86
+ return o.__proto__ || Object.getPrototypeOf(o);
87
+ };
88
+ return _getPrototypeOf(o);
89
+ }
90
+ function _setPrototypeOf(o, p) {
91
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
92
+ o.__proto__ = p;
93
+ return o;
94
+ };
95
+ return _setPrototypeOf(o, p);
96
+ }
97
+ function _isNativeReflectConstruct() {
98
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
99
+ if (Reflect.construct.sham) return false;
100
+ if (typeof Proxy === "function") return true;
101
+ try {
102
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
103
+ return true;
104
+ } catch (e) {
105
+ return false;
106
+ }
107
+ }
108
+ function _construct(Parent, args, Class) {
109
+ if (_isNativeReflectConstruct()) {
110
+ _construct = Reflect.construct.bind();
111
+ } else {
112
+ _construct = function _construct(Parent, args, Class) {
113
+ var a = [null];
114
+ a.push.apply(a, args);
115
+ var Constructor = Function.bind.apply(Parent, a);
116
+ var instance = new Constructor();
117
+ if (Class) _setPrototypeOf(instance, Class.prototype);
118
+ return instance;
119
+ };
120
+ }
121
+ return _construct.apply(null, arguments);
122
+ }
123
+ function _isNativeFunction(fn) {
124
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
125
+ }
126
+ function _wrapNativeSuper(Class) {
127
+ var _cache = typeof Map === "function" ? new Map() : undefined;
128
+ _wrapNativeSuper = function _wrapNativeSuper(Class) {
129
+ if (Class === null || !_isNativeFunction(Class)) return Class;
130
+ if (typeof Class !== "function") {
131
+ throw new TypeError("Super expression must either be null or a function");
132
+ }
133
+ if (typeof _cache !== "undefined") {
134
+ if (_cache.has(Class)) return _cache.get(Class);
135
+ _cache.set(Class, Wrapper);
136
+ }
137
+ function Wrapper() {
138
+ return _construct(Class, arguments, _getPrototypeOf(this).constructor);
139
+ }
140
+ Wrapper.prototype = Object.create(Class.prototype, {
141
+ constructor: {
142
+ value: Wrapper,
143
+ enumerable: false,
144
+ writable: true,
145
+ configurable: true
146
+ }
147
+ });
148
+ return _setPrototypeOf(Wrapper, Class);
149
+ };
150
+ return _wrapNativeSuper(Class);
151
+ }
79
152
  function _objectWithoutPropertiesLoose(source, excluded) {
80
153
  if (source == null) return {};
81
154
  var target = {};
@@ -2310,6 +2383,28 @@ var ARRAY_SYMBOL = /*#__PURE__*/Symbol("[]");
2310
2383
  var PLASMIC_STATE_PROXY_SYMBOL = /*#__PURE__*/Symbol("plasmic.state.proxy");
2311
2384
  var UNINITIALIZED = /*#__PURE__*/Symbol("plasmic.unitialized");
2312
2385
 
2386
+ var CyclicStatesReferencesError = /*#__PURE__*/function (_Error2) {
2387
+ _inheritsLoose(CyclicStatesReferencesError, _Error2);
2388
+ function CyclicStatesReferencesError(stateAccessCycle) {
2389
+ return _Error2.call(this, "Cyclic reference found in state initialization: " + stateAccessCycle.join(" -> ")) || this;
2390
+ }
2391
+ return CyclicStatesReferencesError;
2392
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
2393
+ var InvalidOperation = /*#__PURE__*/function (_Error3) {
2394
+ _inheritsLoose(InvalidOperation, _Error3);
2395
+ function InvalidOperation(msg) {
2396
+ return _Error3.call(this, msg) || this;
2397
+ }
2398
+ return InvalidOperation;
2399
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
2400
+ var UnknownError = /*#__PURE__*/function (_Error4) {
2401
+ _inheritsLoose(UnknownError, _Error4);
2402
+ function UnknownError(msg) {
2403
+ return _Error4.call(this, msg) || this;
2404
+ }
2405
+ return UnknownError;
2406
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
2407
+
2313
2408
  var StateSpecNode = /*#__PURE__*/function () {
2314
2409
  function StateSpecNode(specs) {
2315
2410
  this._specs = specs;
@@ -2483,7 +2578,7 @@ function getStateCell(target, property) {
2483
2578
  }
2484
2579
  function tryGetStateCellFrom$StateRoot($state, path) {
2485
2580
  if (path.length === 0) {
2486
- throw new Error("expected a path with length greater than 0");
2581
+ throw new UnknownError("expected a path with length greater than 0");
2487
2582
  }
2488
2583
  var target = _get($state, path.slice(0, -1));
2489
2584
  _get(target, path.slice(-1)); // create state cell;
@@ -2494,15 +2589,33 @@ function getStateCellFrom$StateRoot($state, path) {
2494
2589
  }
2495
2590
  function initializeStateValue($$state, initialStateCell, proxyRoot) {
2496
2591
  var _initialStateCell$ove2;
2592
+ var initialStateName = initialStateCell.node.getSpec().path;
2497
2593
  var stateAccess = new Set();
2594
+ $$state.stateInitializationEnv.visited.add(initialStateName);
2595
+ $$state.stateInitializationEnv.stack.push(initialStateName);
2498
2596
  var $state = create$StateProxy($$state, function (internalStateCell) {
2499
2597
  return {
2500
2598
  get: function get() {
2599
+ var spec = internalStateCell.node.getSpec();
2600
+ if ($$state.stateInitializationEnv.visited.has(spec.path)) {
2601
+ // cyclic reference found
2602
+ var stateAccessCycle = [spec.path];
2603
+ while ($$state.stateInitializationEnv.stack.length > 0) {
2604
+ var curr = $$state.stateInitializationEnv.stack.pop();
2605
+ if (!curr) {
2606
+ break;
2607
+ }
2608
+ stateAccessCycle.push(curr);
2609
+ if (curr === spec.path) {
2610
+ throw new CyclicStatesReferencesError(stateAccessCycle);
2611
+ }
2612
+ }
2613
+ throw new UnknownError("Internal error: cycle not found");
2614
+ }
2501
2615
  var stateCell = getStateCellFrom$StateRoot(proxyRoot, internalStateCell.path);
2502
2616
  stateAccess.add({
2503
2617
  stateCell: stateCell
2504
2618
  });
2505
- var spec = stateCell.node.getSpec();
2506
2619
  if (spec.valueProp) {
2507
2620
  return $$state.env.$props[spec.valueProp];
2508
2621
  } else if (spec.initFunc && stateCell.initialValue === UNINITIALIZED) {
@@ -2511,7 +2624,7 @@ function initializeStateValue($$state, initialStateCell, proxyRoot) {
2511
2624
  return _get(proxyRoot, stateCell.path);
2512
2625
  },
2513
2626
  set: function set() {
2514
- throw new Error("Cannot update state values during initialization");
2627
+ throw new InvalidOperation("Cannot update state values during initialization");
2515
2628
  }
2516
2629
  };
2517
2630
  });
@@ -2537,6 +2650,8 @@ function initializeStateValue($$state, initialStateCell, proxyRoot) {
2537
2650
  var _$$state$env$$props$i, _$$state$env$$props;
2538
2651
  (_$$state$env$$props$i = (_$$state$env$$props = $$state.env.$props)[initialSpec.onChangeProp]) == null ? void 0 : _$$state$env$$props$i.call(_$$state$env$$props, initialValue);
2539
2652
  }
2653
+ $$state.stateInitializationEnv.visited["delete"](initialStateName);
2654
+ $$state.stateInitializationEnv.stack.pop();
2540
2655
  return initialValue;
2541
2656
  }
2542
2657
  function create$StateProxy($$state, leafHandlers) {
@@ -2549,7 +2664,7 @@ function create$StateProxy($$state, leafHandlers) {
2549
2664
  var handlers = {
2550
2665
  deleteProperty: function deleteProperty(target, property) {
2551
2666
  if (!isOutside && !currNode.isLeaf() && !currNode.hasArrayTransition() && !isNum(property)) {
2552
- throw new Error("Can't delete a property in the middle of the state spec");
2667
+ throw new InvalidOperation("Can't delete a property in the middle of the state spec");
2553
2668
  }
2554
2669
  delete _get($$state.stateValues, currPath)[property];
2555
2670
  if (spec.onChangeProp) {
@@ -2610,7 +2725,7 @@ function create$StateProxy($$state, leafHandlers) {
2610
2725
  if (canProxy(value)) {
2611
2726
  target[property] = rec(nextPath, nextNode, isOutside || currNode.isLeaf(), value);
2612
2727
  } else if (!isOutside && !currNode.isLeaf() && !((_nextNode2 = nextNode) != null && _nextNode2.isLeaf())) {
2613
- throw new Error("inserting a primitive value into a non-leaf");
2728
+ throw new InvalidOperation("inserting a primitive value into a non-leaf");
2614
2729
  } else {
2615
2730
  Reflect.set(target, property, value, receiver);
2616
2731
  }
@@ -2716,7 +2831,11 @@ function useDollarState(specs) {
2716
2831
  stateValues: valtio.proxy({}),
2717
2832
  env: envFieldsAreNonNill(env),
2718
2833
  specs: [],
2719
- registrationsQueue: valtio.proxy([])
2834
+ registrationsQueue: valtio.proxy([]),
2835
+ stateInitializationEnv: {
2836
+ stack: [],
2837
+ visited: new Set()
2838
+ }
2720
2839
  };
2721
2840
  }()).current;
2722
2841
  $$state.env = envFieldsAreNonNill(env);
@@ -2931,11 +3050,16 @@ function getStateCells($state, root) {
2931
3050
  return getStateCells($state[key], ensure(root.makeTransition(ARRAY_SYMBOL)));
2932
3051
  }));
2933
3052
  } else {
2934
- return [].concat(stateCells, [].concat(root.edges().entries()).flatMap(function (_ref2) {
2935
- var key = _ref2[0],
2936
- child = _ref2[1];
2937
- return typeof key === "string" && key in $state ? getStateCells($state[key], child) : [];
2938
- }));
3053
+ var childrenStateCells = [];
3054
+ for (var _iterator3 = _createForOfIteratorHelperLoose(root.edges().entries()), _step3; !(_step3 = _iterator3()).done;) {
3055
+ var _step3$value = _step3.value,
3056
+ key = _step3$value[0],
3057
+ child = _step3$value[1];
3058
+ if (typeof key === "string" && key in $state) {
3059
+ childrenStateCells.push.apply(childrenStateCells, getStateCells($state[key], child));
3060
+ }
3061
+ }
3062
+ return [].concat(stateCells, childrenStateCells);
2939
3063
  }
2940
3064
  }
2941
3065
  function getStateCellsInPlasmicProxy(obj) {