@xstate/react 1.2.1 → 1.2.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4b31cefb`](https://github.com/davidkpiano/xstate/commit/4b31cefb3d3497e5515314046639df7e27dbe9e8) [#1780](https://github.com/davidkpiano/xstate/pull/1780) Thanks [@Andarist](https://github.com/Andarist)! - Fixed an issue with some external packages not being bundled correctly into the UMD bundles.
8
+
3
9
  ## 1.2.1
4
10
 
5
11
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@xstate/fsm"),require("use-subscription")):"function"==typeof define&&define.amd?define(["exports","react","@xstate/fsm","use-subscription"],t):t((e=e||self).XStateReactFSM={},e.React,e.fsm,e.useSubscription)}(this,(function(e,t,r,n){"use strict";
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@xstate/fsm")):"function"==typeof define&&define.amd?define(["exports","react","@xstate/fsm"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).XStateReactFSM={},e.React,e.XStateFSM)}(this,(function(e,t,r){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=n(t);
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation. All rights reserved.
4
4
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -12,4 +12,17 @@
12
12
 
13
13
  See the Apache Version 2.0 License for specific language governing permissions
14
14
  and limitations under the License.
15
- ***************************************************************************** */var u=function(e){var t;return e.subscribe((function(e){t=e})).unsubscribe(),t};e.useMachine=function(e,n){var i,c,o=(i=function(){return r.interpret(r.createMachine(e.config,n||e._options)).start()},(c=t.useRef()).current||(c.current={v:i()}),c.current.v),s=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,u,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){u={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(u)throw u.error}}return c}(t.useState((function(){return u(o)})),2),f=s[0],a=s[1];return t.useEffect((function(){n&&(o._machine._options=n)})),t.useEffect((function(){return o.subscribe(a),function(){o.stop()}}),[]),[f,o.send,o]},e.useService=function(e){var r=t.useMemo((function(){var t=u(e);return{getCurrentValue:function(){return t},subscribe:function(r){return e.subscribe((function(e){!1!==e.changed&&(t=e,r())})).unsubscribe}}}),[e]);return[n.useSubscription(r),e.send,e]},Object.defineProperty(e,"__esModule",{value:!0})}));
15
+ ***************************************************************************** */function o(e){var t={exports:{}};return e(t,t.exports),t.exports
16
+ /*
17
+ object-assign
18
+ (c) Sindre Sorhus
19
+ @license MIT
20
+ */}var i=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function f(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var s=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,n,u=f(e),o=1;o<arguments.length;o++){for(var s in r=Object(arguments[o]))c.call(r,s)&&(u[s]=r[s]);if(i){n=i(r);for(var l=0;l<n.length;l++)a.call(r,n[l])&&(u[n[l]]=r[n[l]])}}return u},l={useSubscription:function(e){var t=e.getCurrentValue,r=e.subscribe,n=u.default.useState((function(){return{getCurrentValue:t,subscribe:r,value:t()}}));e=n[0];var o=n[1];return n=e.value,e.getCurrentValue===t&&e.subscribe===r||(n=t(),o({getCurrentValue:t,subscribe:r,value:n})),u.default.useDebugValue(n),u.default.useEffect((function(){function e(){if(!n){var e=t();o((function(n){return n.getCurrentValue!==t||n.subscribe!==r||n.value===e?n:s({},n,{value:e})}))}}var n=!1,u=r(e);return e(),function(){n=!0,u()}}),[t,r]),n}},b=(o((function(e,t){})),o((function(e){e.exports=l})));
21
+ /** @license React v1.4.1
22
+ * use-subscription.production.min.js
23
+ *
24
+ * Copyright (c) Facebook, Inc. and its affiliates.
25
+ *
26
+ * This source code is licensed under the MIT license found in the
27
+ * LICENSE file in the root directory of this source tree.
28
+ */var p=function(e){var t;return e.subscribe((function(e){t=e})).unsubscribe(),t};e.useMachine=function(e,n){var u,o,i=(u=function(){return r.interpret(r.createMachine(e.config,n||e._options)).start()},(o=t.useRef()).current||(o.current={v:u()}),o.current.v),c=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,u,o=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(e){u={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(u)throw u.error}}return i}(t.useState((function(){return p(i)})),2),a=c[0],f=c[1];return t.useEffect((function(){n&&(i._machine._options=n)})),t.useEffect((function(){return i.subscribe(f),function(){i.stop()}}),[]),[a,i.send,i]},e.useService=function(e){var r=t.useMemo((function(){var t=p(e);return{getCurrentValue:function(){return t},subscribe:function(r){return e.subscribe((function(e){!1!==e.changed&&(t=e,r())})).unsubscribe}}}),[e]);return[b.useSubscription(r),e.send,e]},Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -1,4 +1,4 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-isomorphic-layout-effect"),require("xstate")):"function"==typeof define&&define.amd?define(["exports","react","use-isomorphic-layout-effect","xstate"],e):e((t=t||self).XStateReact={},t.React,t.useIsomorphicLayoutEffect,t.XState)}(this,(function(t,e,n,r){"use strict";n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("xstate")):"function"==typeof define&&define.amd?define(["exports","react","xstate"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XStateReact={},t.React,t.XState)}(this,(function(t,e,n){"use strict";
2
2
  /*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation. All rights reserved.
4
4
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -12,5 +12,4 @@
12
12
 
13
13
  See the Apache Version 2.0 License for specific language governing permissions
14
14
  and limitations under the License.
15
- ***************************************************************************** */
16
- var c,o=function(){return(o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var c in e=arguments[n])Object.prototype.hasOwnProperty.call(e,c)&&(t[c]=e[c]);return t}).apply(this,arguments)};function u(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,c,o=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)u.push(r.value)}catch(t){c={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(c)throw c.error}}return u}function i(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(u(arguments[e]));return t}function f(t){var n=e.useRef();return n.current||(n.current={v:t()}),n.current.v}function a(t,e){var n,r,c=u([[],[]],2),o=c[0],i=c[1];try{for(var f=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}(t),a=f.next();!a.done;a=f.next()){var s=a.value;e(s)?o.push(s):i.push(s)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}return[o,i]}function s(t,e){var n=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return function(){return t.apply(void 0,i(e))}};return Object.defineProperties(n,{name:{value:"effect:"+t.name},__effect:{value:e}}),n}function l(t,e){(0,t.exec)(e.context,e._event.data,{action:t,state:e,_event:e._event})()}!function(t){t[t.Effect=1]="Effect",t[t.LayoutEffect=2]="LayoutEffect"}(c||(c={}));var v=function(){};function p(t,r){void 0===r&&(r=function(t){return function(t){return"state"in t}(t)?t.state:void 0});var c=e.useRef(t),o=e.useRef([]),i=u(e.useState((function(){return r(t)})),2),a=i[0],s=i[1],l=f((function(){return function(t){var e=c.current;(function(t){return"deferred"in t})(e)&&e.deferred?o.current.push(t):e.send(t)}}));return n((function(){c.current=t,s(r(t));for(var e=t.subscribe({next:function(t){return s(t)},error:v,complete:v});o.current.length>0;){var n=o.current.shift();t.send(n)}return function(){e.unsubscribe()}}),[t]),[a,l]}t.asEffect=function(t){return s(t,c.Effect)},t.asLayoutEffect=function(t){return s(t,c.LayoutEffect)},t.useActor=p,t.useMachine=function(t,s){void 0===s&&(s={});var v=f((function(){return"function"==typeof t?t():t})),p=s.context,y=s.guards,d=s.actions,h=s.activities,b=s.services,g=s.delays,x=s.state,m=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var c=0;for(r=Object.getOwnPropertySymbols(t);c<r.length;c++)e.indexOf(r[c])<0&&Object.prototype.propertyIsEnumerable.call(t,r[c])&&(n[r[c]]=t[r[c]])}return n}(s,["context","guards","actions","activities","services","delays","state"]),O=u(f((function(){var t={context:p,guards:y,actions:d,activities:h,services:b,delays:g},e=v.withConfig(t,o(o({},v.context),p));return[e,r.interpret(e,o({deferEvents:!0},m))]})),2),E=O[0],S=O[1],j=u(e.useState((function(){var t=E.initialState;return x?r.State.create(x):t})),2),_=j[0],w=j[1],P=e.useRef([]),R=e.useRef([]);return n((function(){return S.onTransition((function(t){var e,n,r=void 0===t.changed&&Object.keys(t.children).length;if((t.changed||r)&&w(t),t.actions.length){var o=u(a(t.actions.filter((function(t){return"function"==typeof t.exec&&"__effect"in t.exec})),(function(t){return t.exec.__effect===c.Effect})),2),f=o[0],s=o[1];(e=P.current).push.apply(e,i(f.map((function(e){return[e,t]})))),(n=R.current).push.apply(n,i(s.map((function(e){return[e,t]}))))}})).start(x?r.State.create(x):void 0),function(){S.stop()}}),[]),e.useEffect((function(){Object.assign(S.machine.options.actions,d)}),[d]),e.useEffect((function(){Object.assign(S.machine.options.services,b)}),[b]),n((function(){for(;R.current.length;){var t=u(R.current.shift(),2);l(t[0],t[1])}}),[_]),e.useEffect((function(){for(;P.current.length;){var t=u(P.current.shift(),2);l(t[0],t[1])}}),[_]),[_,S.send,S]},t.useService=function(t){return[u(p(t,(function(){return 0!==("status"in t?t.status:t._status)?t.state:t.machine.initialState})),1)[0],t.send]},Object.defineProperty(t,"__esModule",{value:!0})}));
15
+ ***************************************************************************** */var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function o(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,u=n.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(r=u.next()).done;)c.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=u.return)&&n.call(u)}finally{if(o)throw o.error}}return c}function u(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(o(arguments[e]));return t}var c,i=e.useLayoutEffect;function f(t){var n=e.useRef();return n.current||(n.current={v:t()}),n.current.v}function a(t,e){var n,r,u=o([[],[]],2),c=u[0],i=u[1];try{for(var f=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t),a=f.next();!a.done;a=f.next()){var s=a.value;e(s)?c.push(s):i.push(s)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}return[c,i]}function s(t,e){var n=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return function(){return t.apply(void 0,u(e))}};return Object.defineProperties(n,{name:{value:"effect:"+t.name},__effect:{value:e}}),n}function l(t,e){(0,t.exec)(e.context,e._event.data,{action:t,state:e,_event:e._event})()}!function(t){t[t.Effect=1]="Effect",t[t.LayoutEffect=2]="LayoutEffect"}(c||(c={}));var v=function(){};function p(t,n){void 0===n&&(n=function(t){return function(t){return"state"in t}(t)?t.state:void 0});var r=e.useRef(t),u=e.useRef([]),c=o(e.useState((function(){return n(t)})),2),a=c[0],s=c[1],l=f((function(){return function(t){var e=r.current;(function(t){return"deferred"in t})(e)&&e.deferred?u.current.push(t):e.send(t)}}));return i((function(){r.current=t,s(n(t));for(var e=t.subscribe({next:function(t){return s(t)},error:v,complete:v});u.current.length>0;){var o=u.current.shift();t.send(o)}return function(){e.unsubscribe()}}),[t]),[a,l]}t.asEffect=function(t){return s(t,c.Effect)},t.asLayoutEffect=function(t){return s(t,c.LayoutEffect)},t.useActor=p,t.useMachine=function(t,s){void 0===s&&(s={});var v=f((function(){return"function"==typeof t?t():t})),p=s.context,d=s.guards,y=s.actions,h=s.activities,b=s.services,g=s.delays,x=s.state,m=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(s,["context","guards","actions","activities","services","delays","state"]),O=o(f((function(){var t={context:p,guards:d,actions:y,activities:h,services:b,delays:g},e=v.withConfig(t,r(r({},v.context),p));return[e,n.interpret(e,r({deferEvents:!0},m))]})),2),E=O[0],S=O[1],j=o(e.useState((function(){var t=E.initialState;return x?n.State.create(x):t})),2),_=j[0],w=j[1],R=e.useRef([]),P=e.useRef([]);return i((function(){return S.onTransition((function(t){var e,n,r=void 0===t.changed&&Object.keys(t.children).length;if((t.changed||r)&&w(t),t.actions.length){var i=o(a(t.actions.filter((function(t){return"function"==typeof t.exec&&"__effect"in t.exec})),(function(t){return t.exec.__effect===c.Effect})),2),f=i[0],s=i[1];(e=R.current).push.apply(e,u(f.map((function(e){return[e,t]})))),(n=P.current).push.apply(n,u(s.map((function(e){return[e,t]}))))}})).start(x?n.State.create(x):void 0),function(){S.stop()}}),[]),e.useEffect((function(){Object.assign(S.machine.options.actions,y)}),[y]),e.useEffect((function(){Object.assign(S.machine.options.services,b)}),[b]),i((function(){for(;P.current.length;){var t=o(P.current.shift(),2);l(t[0],t[1])}}),[_]),e.useEffect((function(){for(;R.current.length;){var t=o(R.current.shift(),2);l(t[0],t[1])}}),[_]),[_,S.send,S]},t.useService=function(t){return[o(p(t,(function(){return 0!==("status"in t?t.status:t._status)?t.state:t.machine.initialState})),1)[0],t.send]},Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xstate/react",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "XState tools for React",
5
5
  "keywords": [
6
6
  "state",
@@ -61,6 +61,8 @@
61
61
  "use-subscription": "^1.3.0"
62
62
  },
63
63
  "devDependencies": {
64
+ "@rollup/plugin-commonjs": "^17.0.0",
65
+ "@rollup/plugin-node-resolve": "^11.0.1",
64
66
  "@testing-library/react": "^8.0.9",
65
67
  "@types/jsdom": "^12.2.3",
66
68
  "@types/react": "^16.9.11",
@@ -72,10 +74,10 @@
72
74
  "lerna-alias": "3.0.3-0",
73
75
  "react": "^16.12.0",
74
76
  "react-dom": "^16.12.0",
75
- "rollup": "^1.26.3",
77
+ "rollup": "^2.35.1",
76
78
  "rollup-plugin-replace": "^2.2.0",
77
79
  "rollup-plugin-terser": "^5.1.2",
78
- "rollup-plugin-typescript2": "^0.25.2",
80
+ "rollup-plugin-typescript2": "^0.29.0",
79
81
  "ts-jest": "^26.4.0",
80
82
  "typescript": "^4.1.2",
81
83
  "xstate": "*"