@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.
- package/dist/all.d.ts +2 -2
- package/dist/react-web.cjs.development.js +135 -11
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +135 -11
- package/dist/react-web.esm.js.map +1 -1
- package/dist/states/errors.d.ts +13 -0
- package/dist/states/types.d.ts +4 -0
- package/dist/stories/UseDollarState.stories.d.ts +1 -0
- package/package.json +4 -4
- package/skinny/dist/{collection-utils-719bb030.js → collection-utils-0bfbb8a8.js} +4 -4
- package/skinny/dist/{collection-utils-719bb030.js.map → collection-utils-0bfbb8a8.js.map} +1 -1
- package/skinny/dist/{common-dd6b46fb.js → common-125681b4.js} +18 -2
- package/skinny/dist/{common-dd6b46fb.js.map → common-125681b4.js.map} +1 -1
- package/skinny/dist/index.js +84 -17
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/plume/button/index.js +2 -2
- package/skinny/dist/plume/checkbox/index.js +4 -4
- package/skinny/dist/plume/menu/index.js +5 -5
- package/skinny/dist/plume/menu-button/index.js +4 -4
- package/skinny/dist/plume/select/index.js +5 -5
- package/skinny/dist/plume/switch/index.js +4 -4
- package/skinny/dist/plume/text-input/index.js +2 -2
- package/skinny/dist/plume/triggered-overlay/index.js +4 -4
- package/skinny/dist/{plume-utils-43df92e6.js → plume-utils-427ac667.js} +2 -2
- package/skinny/dist/{plume-utils-43df92e6.js.map → plume-utils-427ac667.js.map} +1 -1
- package/skinny/dist/{props-utils-eaa18f66.js → props-utils-5092839e.js} +2 -2
- package/skinny/dist/{props-utils-eaa18f66.js.map → props-utils-5092839e.js.map} +1 -1
- package/skinny/dist/{react-utils-628465ba.js → react-utils-091cf05d.js} +2 -2
- package/skinny/dist/{react-utils-628465ba.js.map → react-utils-091cf05d.js.map} +1 -1
- package/skinny/dist/render/PlasmicImg/index.js +2 -2
- package/skinny/dist/states/errors.d.ts +13 -0
- package/skinny/dist/states/types.d.ts +4 -0
- package/skinny/dist/stories/UseDollarState.stories.d.ts +1 -0
package/dist/react-web.esm.js
CHANGED
|
@@ -71,6 +71,79 @@ function _extends() {
|
|
|
71
71
|
};
|
|
72
72
|
return _extends.apply(this, arguments);
|
|
73
73
|
}
|
|
74
|
+
function _inheritsLoose(subClass, superClass) {
|
|
75
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
76
|
+
subClass.prototype.constructor = subClass;
|
|
77
|
+
_setPrototypeOf(subClass, superClass);
|
|
78
|
+
}
|
|
79
|
+
function _getPrototypeOf(o) {
|
|
80
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
81
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
82
|
+
};
|
|
83
|
+
return _getPrototypeOf(o);
|
|
84
|
+
}
|
|
85
|
+
function _setPrototypeOf(o, p) {
|
|
86
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
87
|
+
o.__proto__ = p;
|
|
88
|
+
return o;
|
|
89
|
+
};
|
|
90
|
+
return _setPrototypeOf(o, p);
|
|
91
|
+
}
|
|
92
|
+
function _isNativeReflectConstruct() {
|
|
93
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
94
|
+
if (Reflect.construct.sham) return false;
|
|
95
|
+
if (typeof Proxy === "function") return true;
|
|
96
|
+
try {
|
|
97
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
98
|
+
return true;
|
|
99
|
+
} catch (e) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function _construct(Parent, args, Class) {
|
|
104
|
+
if (_isNativeReflectConstruct()) {
|
|
105
|
+
_construct = Reflect.construct.bind();
|
|
106
|
+
} else {
|
|
107
|
+
_construct = function _construct(Parent, args, Class) {
|
|
108
|
+
var a = [null];
|
|
109
|
+
a.push.apply(a, args);
|
|
110
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
111
|
+
var instance = new Constructor();
|
|
112
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
113
|
+
return instance;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return _construct.apply(null, arguments);
|
|
117
|
+
}
|
|
118
|
+
function _isNativeFunction(fn) {
|
|
119
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
120
|
+
}
|
|
121
|
+
function _wrapNativeSuper(Class) {
|
|
122
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
123
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
124
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
125
|
+
if (typeof Class !== "function") {
|
|
126
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
127
|
+
}
|
|
128
|
+
if (typeof _cache !== "undefined") {
|
|
129
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
130
|
+
_cache.set(Class, Wrapper);
|
|
131
|
+
}
|
|
132
|
+
function Wrapper() {
|
|
133
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
134
|
+
}
|
|
135
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
136
|
+
constructor: {
|
|
137
|
+
value: Wrapper,
|
|
138
|
+
enumerable: false,
|
|
139
|
+
writable: true,
|
|
140
|
+
configurable: true
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
144
|
+
};
|
|
145
|
+
return _wrapNativeSuper(Class);
|
|
146
|
+
}
|
|
74
147
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
75
148
|
if (source == null) return {};
|
|
76
149
|
var target = {};
|
|
@@ -2305,6 +2378,28 @@ var ARRAY_SYMBOL = /*#__PURE__*/Symbol("[]");
|
|
|
2305
2378
|
var PLASMIC_STATE_PROXY_SYMBOL = /*#__PURE__*/Symbol("plasmic.state.proxy");
|
|
2306
2379
|
var UNINITIALIZED = /*#__PURE__*/Symbol("plasmic.unitialized");
|
|
2307
2380
|
|
|
2381
|
+
var CyclicStatesReferencesError = /*#__PURE__*/function (_Error2) {
|
|
2382
|
+
_inheritsLoose(CyclicStatesReferencesError, _Error2);
|
|
2383
|
+
function CyclicStatesReferencesError(stateAccessCycle) {
|
|
2384
|
+
return _Error2.call(this, "Cyclic reference found in state initialization: " + stateAccessCycle.join(" -> ")) || this;
|
|
2385
|
+
}
|
|
2386
|
+
return CyclicStatesReferencesError;
|
|
2387
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
2388
|
+
var InvalidOperation = /*#__PURE__*/function (_Error3) {
|
|
2389
|
+
_inheritsLoose(InvalidOperation, _Error3);
|
|
2390
|
+
function InvalidOperation(msg) {
|
|
2391
|
+
return _Error3.call(this, msg) || this;
|
|
2392
|
+
}
|
|
2393
|
+
return InvalidOperation;
|
|
2394
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
2395
|
+
var UnknownError = /*#__PURE__*/function (_Error4) {
|
|
2396
|
+
_inheritsLoose(UnknownError, _Error4);
|
|
2397
|
+
function UnknownError(msg) {
|
|
2398
|
+
return _Error4.call(this, msg) || this;
|
|
2399
|
+
}
|
|
2400
|
+
return UnknownError;
|
|
2401
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
2402
|
+
|
|
2308
2403
|
var StateSpecNode = /*#__PURE__*/function () {
|
|
2309
2404
|
function StateSpecNode(specs) {
|
|
2310
2405
|
this._specs = specs;
|
|
@@ -2478,7 +2573,7 @@ function getStateCell(target, property) {
|
|
|
2478
2573
|
}
|
|
2479
2574
|
function tryGetStateCellFrom$StateRoot($state, path) {
|
|
2480
2575
|
if (path.length === 0) {
|
|
2481
|
-
throw new
|
|
2576
|
+
throw new UnknownError("expected a path with length greater than 0");
|
|
2482
2577
|
}
|
|
2483
2578
|
var target = _get($state, path.slice(0, -1));
|
|
2484
2579
|
_get(target, path.slice(-1)); // create state cell;
|
|
@@ -2489,15 +2584,33 @@ function getStateCellFrom$StateRoot($state, path) {
|
|
|
2489
2584
|
}
|
|
2490
2585
|
function initializeStateValue($$state, initialStateCell, proxyRoot) {
|
|
2491
2586
|
var _initialStateCell$ove2;
|
|
2587
|
+
var initialStateName = initialStateCell.node.getSpec().path;
|
|
2492
2588
|
var stateAccess = new Set();
|
|
2589
|
+
$$state.stateInitializationEnv.visited.add(initialStateName);
|
|
2590
|
+
$$state.stateInitializationEnv.stack.push(initialStateName);
|
|
2493
2591
|
var $state = create$StateProxy($$state, function (internalStateCell) {
|
|
2494
2592
|
return {
|
|
2495
2593
|
get: function get() {
|
|
2594
|
+
var spec = internalStateCell.node.getSpec();
|
|
2595
|
+
if ($$state.stateInitializationEnv.visited.has(spec.path)) {
|
|
2596
|
+
// cyclic reference found
|
|
2597
|
+
var stateAccessCycle = [spec.path];
|
|
2598
|
+
while ($$state.stateInitializationEnv.stack.length > 0) {
|
|
2599
|
+
var curr = $$state.stateInitializationEnv.stack.pop();
|
|
2600
|
+
if (!curr) {
|
|
2601
|
+
break;
|
|
2602
|
+
}
|
|
2603
|
+
stateAccessCycle.push(curr);
|
|
2604
|
+
if (curr === spec.path) {
|
|
2605
|
+
throw new CyclicStatesReferencesError(stateAccessCycle);
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
throw new UnknownError("Internal error: cycle not found");
|
|
2609
|
+
}
|
|
2496
2610
|
var stateCell = getStateCellFrom$StateRoot(proxyRoot, internalStateCell.path);
|
|
2497
2611
|
stateAccess.add({
|
|
2498
2612
|
stateCell: stateCell
|
|
2499
2613
|
});
|
|
2500
|
-
var spec = stateCell.node.getSpec();
|
|
2501
2614
|
if (spec.valueProp) {
|
|
2502
2615
|
return $$state.env.$props[spec.valueProp];
|
|
2503
2616
|
} else if (spec.initFunc && stateCell.initialValue === UNINITIALIZED) {
|
|
@@ -2506,7 +2619,7 @@ function initializeStateValue($$state, initialStateCell, proxyRoot) {
|
|
|
2506
2619
|
return _get(proxyRoot, stateCell.path);
|
|
2507
2620
|
},
|
|
2508
2621
|
set: function set() {
|
|
2509
|
-
throw new
|
|
2622
|
+
throw new InvalidOperation("Cannot update state values during initialization");
|
|
2510
2623
|
}
|
|
2511
2624
|
};
|
|
2512
2625
|
});
|
|
@@ -2532,6 +2645,8 @@ function initializeStateValue($$state, initialStateCell, proxyRoot) {
|
|
|
2532
2645
|
var _$$state$env$$props$i, _$$state$env$$props;
|
|
2533
2646
|
(_$$state$env$$props$i = (_$$state$env$$props = $$state.env.$props)[initialSpec.onChangeProp]) == null ? void 0 : _$$state$env$$props$i.call(_$$state$env$$props, initialValue);
|
|
2534
2647
|
}
|
|
2648
|
+
$$state.stateInitializationEnv.visited["delete"](initialStateName);
|
|
2649
|
+
$$state.stateInitializationEnv.stack.pop();
|
|
2535
2650
|
return initialValue;
|
|
2536
2651
|
}
|
|
2537
2652
|
function create$StateProxy($$state, leafHandlers) {
|
|
@@ -2544,7 +2659,7 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
2544
2659
|
var handlers = {
|
|
2545
2660
|
deleteProperty: function deleteProperty(target, property) {
|
|
2546
2661
|
if (!isOutside && !currNode.isLeaf() && !currNode.hasArrayTransition() && !isNum(property)) {
|
|
2547
|
-
throw new
|
|
2662
|
+
throw new InvalidOperation("Can't delete a property in the middle of the state spec");
|
|
2548
2663
|
}
|
|
2549
2664
|
delete _get($$state.stateValues, currPath)[property];
|
|
2550
2665
|
if (spec.onChangeProp) {
|
|
@@ -2605,7 +2720,7 @@ function create$StateProxy($$state, leafHandlers) {
|
|
|
2605
2720
|
if (canProxy(value)) {
|
|
2606
2721
|
target[property] = rec(nextPath, nextNode, isOutside || currNode.isLeaf(), value);
|
|
2607
2722
|
} else if (!isOutside && !currNode.isLeaf() && !((_nextNode2 = nextNode) != null && _nextNode2.isLeaf())) {
|
|
2608
|
-
throw new
|
|
2723
|
+
throw new InvalidOperation("inserting a primitive value into a non-leaf");
|
|
2609
2724
|
} else {
|
|
2610
2725
|
Reflect.set(target, property, value, receiver);
|
|
2611
2726
|
}
|
|
@@ -2711,7 +2826,11 @@ function useDollarState(specs) {
|
|
|
2711
2826
|
stateValues: proxy({}),
|
|
2712
2827
|
env: envFieldsAreNonNill(env),
|
|
2713
2828
|
specs: [],
|
|
2714
|
-
registrationsQueue: proxy([])
|
|
2829
|
+
registrationsQueue: proxy([]),
|
|
2830
|
+
stateInitializationEnv: {
|
|
2831
|
+
stack: [],
|
|
2832
|
+
visited: new Set()
|
|
2833
|
+
}
|
|
2715
2834
|
};
|
|
2716
2835
|
}()).current;
|
|
2717
2836
|
$$state.env = envFieldsAreNonNill(env);
|
|
@@ -2926,11 +3045,16 @@ function getStateCells($state, root) {
|
|
|
2926
3045
|
return getStateCells($state[key], ensure(root.makeTransition(ARRAY_SYMBOL)));
|
|
2927
3046
|
}));
|
|
2928
3047
|
} else {
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
3048
|
+
var childrenStateCells = [];
|
|
3049
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(root.edges().entries()), _step3; !(_step3 = _iterator3()).done;) {
|
|
3050
|
+
var _step3$value = _step3.value,
|
|
3051
|
+
key = _step3$value[0],
|
|
3052
|
+
child = _step3$value[1];
|
|
3053
|
+
if (typeof key === "string" && key in $state) {
|
|
3054
|
+
childrenStateCells.push.apply(childrenStateCells, getStateCells($state[key], child));
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
return [].concat(stateCells, childrenStateCells);
|
|
2934
3058
|
}
|
|
2935
3059
|
}
|
|
2936
3060
|
function getStateCellsInPlasmicProxy(obj) {
|