Comparing version 6.0.1 to 7.0.0
@@ -0,1 +1,5 @@ | ||
## 6.0.1 | ||
Making sure that we check gets send to the `call` generator helper. | ||
## 6.0.0 | ||
@@ -2,0 +6,0 @@ |
@@ -1,15 +0,15 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _ = require("../"); | ||
var _ = require('../'); | ||
var _constants = require("../constants"); | ||
var _constants = require('../constants'); | ||
var _helpers = require("../helpers"); | ||
var _helpers = require('../helpers'); | ||
var create = function create() { | ||
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "app"; | ||
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'app'; | ||
return _.Machine.create(name, { | ||
state: { idle: { run: "running" } }, | ||
state: { idle: { run: 'running' } }, | ||
transitions: {} | ||
@@ -19,12 +19,12 @@ }); | ||
describe("Given the Stent library", function () { | ||
describe('Given the Stent library', function () { | ||
beforeEach(function () { | ||
_.Machine.flush(); | ||
}); | ||
describe("when creating a new machine", function () { | ||
it("should have the machine with its name set up", function () { | ||
expect(create("foo").name).to.equal("foo"); | ||
describe('when creating a new machine', function () { | ||
it('should have the machine with its name set up', function () { | ||
expect(create('foo').name).to.equal('foo'); | ||
}); | ||
describe("and we have a middleware attached", function () { | ||
it("should trigger the middleware hook", function () { | ||
describe('and we have a middleware attached', function () { | ||
it('should trigger the middleware hook', function () { | ||
var spy = sinon.spy(); | ||
@@ -35,7 +35,7 @@ | ||
}); | ||
create("xxxa"); | ||
create('xxxa'); | ||
expect(spy).to.be.calledOnce.and.to.be.calledWith(sinon.match({ name: "xxxa" })); | ||
expect(spy).to.be.calledOnce.and.to.be.calledWith(sinon.match({ name: 'xxxa' })); | ||
}); | ||
it("should call the onMiddlewareRegister hook if available", function () { | ||
it('should call the onMiddlewareRegister hook if available', function () { | ||
var spy = sinon.spy(); | ||
@@ -54,33 +54,33 @@ | ||
}); | ||
describe("when `getting a machine", function () { | ||
it("should return the machine if it exists", function () { | ||
create("bar"); | ||
var foo = create("foo"); | ||
describe('when `getting a machine', function () { | ||
it('should return the machine if it exists', function () { | ||
create('bar'); | ||
var foo = create('foo'); | ||
expect(_.Machine.get("bar").name).to.equal("bar"); | ||
expect(_.Machine.get(foo).name).to.equal("foo"); | ||
expect(_.Machine.get('bar').name).to.equal('bar'); | ||
expect(_.Machine.get(foo).name).to.equal('foo'); | ||
}); | ||
it("should throw an error if the machine does not exist", function () { | ||
create("bar"); | ||
it('should throw an error if the machine does not exist', function () { | ||
create('bar'); | ||
expect(_.Machine.get.bind(_.Machine, "baz")).to.throw((0, _constants.ERROR_MISSING_MACHINE)("baz")); | ||
expect(_.Machine.get.bind(_.Machine, 'baz')).to.throw((0, _constants.ERROR_MISSING_MACHINE)('baz')); | ||
}); | ||
}); | ||
describe("when creating a machine without a name", function () { | ||
it("should be possible to fetch it by using the machine itself or the its generated name", function () { | ||
describe('when creating a machine without a name', function () { | ||
it('should be possible to fetch it by using the machine itself or the its generated name', function () { | ||
var machine = _.Machine.create({ | ||
state: { name: "idle" }, | ||
transitions: { idle: { run: "running" } } | ||
state: { name: 'idle' }, | ||
transitions: { idle: { run: 'running' } } | ||
}); | ||
expect(_.Machine.get(machine).state.name).to.equal("idle"); | ||
expect(_.Machine.get(machine.name).state.name).to.equal("idle"); | ||
expect(_.Machine.get(machine).state.name).to.equal('idle'); | ||
expect(_.Machine.get(machine.name).state.name).to.equal('idle'); | ||
}); | ||
}); | ||
describe("when we fire two actions one after each other", function () { | ||
describe("and we use the .latest version of the action", function () { | ||
it("should cancel the first action and only work with the second one", function (done) { | ||
describe('when we fire two actions one after each other', function () { | ||
describe('and we use the .latest version of the action', function () { | ||
it('should cancel the first action and only work with the second one', function (done) { | ||
var backend = sinon.stub(); | ||
backend.withArgs("s").returns("salad"); | ||
backend.withArgs("st").returns("stent"); | ||
backend.withArgs('s').returns('salad'); | ||
backend.withArgs('st').returns('stent'); | ||
@@ -96,3 +96,3 @@ var api = function api(char) { | ||
var machine = _.Machine.create({ | ||
state: { name: "x" }, | ||
state: { name: 'x' }, | ||
transitions: { | ||
@@ -111,6 +111,6 @@ x: { | ||
match = _context.sent; | ||
return _context.abrupt("return", { name: "y", match: match }); | ||
return _context.abrupt('return', { name: 'y', match: match }); | ||
case 4: | ||
case "end": | ||
case 'end': | ||
return _context.stop(); | ||
@@ -123,3 +123,3 @@ } | ||
y: { | ||
noway: "x" | ||
'noway': 'x' | ||
} | ||
@@ -129,7 +129,7 @@ } | ||
machine.type.latest("s"); | ||
machine.type.latest("st"); | ||
machine.type.latest('s'); | ||
machine.type.latest('st'); | ||
setTimeout(function () { | ||
expect(machine.state).to.deep.equal({ name: "y", match: "stent" }); | ||
expect(machine.state).to.deep.equal({ name: 'y', match: 'stent' }); | ||
done(); | ||
@@ -140,18 +140,18 @@ }, 20); | ||
}); | ||
describe("when using the `destroy` method", function () { | ||
it("should delete the machine", function () { | ||
_.Machine.create("foo", { state: {}, transitions: {} }); | ||
var B = _.Machine.create("bar", { state: {}, transitions: {} }); | ||
describe('when using the `destroy` method', function () { | ||
it('should delete the machine', function () { | ||
_.Machine.create('foo', { state: {}, transitions: {} }); | ||
var B = _.Machine.create('bar', { state: {}, transitions: {} }); | ||
expect(_typeof(_.Machine.machines.foo)).to.equal("object"); | ||
_.Machine.destroy("foo"); | ||
expect(_typeof(_.Machine.machines.foo)).to.equal("undefined"); | ||
expect(_typeof(_.Machine.machines.foo)).to.equal('object'); | ||
_.Machine.destroy('foo'); | ||
expect(_typeof(_.Machine.machines.foo)).to.equal('undefined'); | ||
expect(_typeof(_.Machine.machines.bar)).to.equal("object"); | ||
expect(_typeof(_.Machine.machines.bar)).to.equal('object'); | ||
_.Machine.destroy(B); | ||
expect(_typeof(_.Machine.machines.bar)).to.equal("undefined"); | ||
expect(_typeof(_.Machine.machines.bar)).to.equal('undefined'); | ||
}); | ||
describe("and the machine does not exist", function () { | ||
it("should throw an error", function () { | ||
expect(_.Machine.destroy.bind(_.Machine, "foo")).to.throw("foo"); | ||
describe('and the machine does not exist', function () { | ||
it('should throw an error', function () { | ||
expect(_.Machine.destroy.bind(_.Machine, 'foo')).to.throw('foo'); | ||
}); | ||
@@ -158,0 +158,0 @@ }); |
@@ -14,3 +14,3 @@ 'use strict'; | ||
var ERROR_WRONG_STATE_FORMAT = exports.ERROR_WRONG_STATE_FORMAT = function ERROR_WRONG_STATE_FORMAT(state) { | ||
var serialized = (typeof state === 'undefined' ? 'undefined' : _typeof(state)) === "object" ? JSON.stringify(state, null, 2) : state; | ||
var serialized = (typeof state === 'undefined' ? 'undefined' : _typeof(state)) === 'object' ? JSON.stringify(state, null, 2) : state; | ||
@@ -22,3 +22,3 @@ return 'The state should be an object and it should always have at least "name" property. You passed ' + serialized; | ||
}; | ||
var ERROR_NOT_SUPPORTED_HANDLER_TYPE = exports.ERROR_NOT_SUPPORTED_HANDLER_TYPE = "Wrong handler type passed. Please read the docs https://github.com/krasimir/stent"; | ||
var ERROR_NOT_SUPPORTED_HANDLER_TYPE = exports.ERROR_NOT_SUPPORTED_HANDLER_TYPE = 'Wrong handler type passed. Please read the docs https://github.com/krasimir/stent'; | ||
var ERROR_RESERVED_WORD_USED_AS_ACTION = exports.ERROR_RESERVED_WORD_USED_AS_ACTION = function ERROR_RESERVED_WORD_USED_AS_ACTION(word) { | ||
@@ -32,15 +32,15 @@ return 'Sorry, you can\'t use ' + word + ' as a name for an action. It is reserved.'; | ||
// middlewares | ||
var MIDDLEWARE_PROCESS_ACTION = exports.MIDDLEWARE_PROCESS_ACTION = "onActionDispatched"; | ||
var MIDDLEWARE_ACTION_PROCESSED = exports.MIDDLEWARE_ACTION_PROCESSED = "onActionProcessed"; | ||
var MIDDLEWARE_STATE_WILL_CHANGE = exports.MIDDLEWARE_STATE_WILL_CHANGE = "onStateWillChange"; | ||
var MIDDLEWARE_PROCESS_STATE_CHANGE = exports.MIDDLEWARE_PROCESS_STATE_CHANGE = "onStateChanged"; | ||
var MIDDLEWARE_GENERATOR_STEP = exports.MIDDLEWARE_GENERATOR_STEP = "onGeneratorStep"; | ||
var MIDDLEWARE_GENERATOR_END = exports.MIDDLEWARE_GENERATOR_END = "onGeneratorEnd"; | ||
var MIDDLEWARE_GENERATOR_RESUMED = exports.MIDDLEWARE_GENERATOR_RESUMED = "onGeneratorResumed"; | ||
var MIDDLEWARE_MACHINE_CREATED = exports.MIDDLEWARE_MACHINE_CREATED = "onMachineCreated"; | ||
var MIDDLEWARE_MACHINE_CONNECTED = exports.MIDDLEWARE_MACHINE_CONNECTED = "onMachineConnected"; | ||
var MIDDLEWARE_MACHINE_DISCONNECTED = exports.MIDDLEWARE_MACHINE_DISCONNECTED = "onMachineDisconnected"; | ||
var MIDDLEWARE_REGISTERED = exports.MIDDLEWARE_REGISTERED = "onMiddlewareRegister"; | ||
var MIDDLEWARE_PROCESS_ACTION = exports.MIDDLEWARE_PROCESS_ACTION = 'onActionDispatched'; | ||
var MIDDLEWARE_ACTION_PROCESSED = exports.MIDDLEWARE_ACTION_PROCESSED = 'onActionProcessed'; | ||
var MIDDLEWARE_STATE_WILL_CHANGE = exports.MIDDLEWARE_STATE_WILL_CHANGE = 'onStateWillChange'; | ||
var MIDDLEWARE_PROCESS_STATE_CHANGE = exports.MIDDLEWARE_PROCESS_STATE_CHANGE = 'onStateChanged'; | ||
var MIDDLEWARE_GENERATOR_STEP = exports.MIDDLEWARE_GENERATOR_STEP = 'onGeneratorStep'; | ||
var MIDDLEWARE_GENERATOR_END = exports.MIDDLEWARE_GENERATOR_END = 'onGeneratorEnd'; | ||
var MIDDLEWARE_GENERATOR_RESUMED = exports.MIDDLEWARE_GENERATOR_RESUMED = 'onGeneratorResumed'; | ||
var MIDDLEWARE_MACHINE_CREATED = exports.MIDDLEWARE_MACHINE_CREATED = 'onMachineCreated'; | ||
var MIDDLEWARE_MACHINE_CONNECTED = exports.MIDDLEWARE_MACHINE_CONNECTED = 'onMachineConnected'; | ||
var MIDDLEWARE_MACHINE_DISCONNECTED = exports.MIDDLEWARE_MACHINE_DISCONNECTED = 'onMachineDisconnected'; | ||
var MIDDLEWARE_REGISTERED = exports.MIDDLEWARE_REGISTERED = 'onMiddlewareRegister'; | ||
// misc | ||
var DEVTOOLS_KEY = exports.DEVTOOLS_KEY = "__hello__stent__"; | ||
var DEVTOOLS_KEY = exports.DEVTOOLS_KEY = '__hello__stent__'; |
@@ -1,21 +0,21 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _connect = require("../connect"); | ||
var _connect = require('../connect'); | ||
var _connect2 = _interopRequireDefault(_connect); | ||
var _call = require("../generators/call"); | ||
var _call = require('../generators/call'); | ||
var _call2 = _interopRequireDefault(_call); | ||
var _ = require("../../"); | ||
var _ = require('../../'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var IDLE = "IDLE"; | ||
var END = "END"; | ||
var FAILURE = "FAILURE"; | ||
var IDLE = 'IDLE'; | ||
var END = 'END'; | ||
var FAILURE = 'FAILURE'; | ||
var makeState = function makeState() { | ||
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "INVALID"; | ||
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'INVALID'; | ||
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
@@ -26,8 +26,8 @@ | ||
describe("Given the call helper", function () { | ||
describe('Given the call helper', function () { | ||
beforeEach(function () { | ||
_.Machine.flush(); | ||
}); | ||
describe("when calling it with a non-function argument", function () { | ||
it("should catch the error and transition to Failure state with a meaningful error message", function (done) { | ||
describe('when calling it with a non-function argument', function () { | ||
it('should catch the error and transition to Failure state with a meaningful error message', function (done) { | ||
var _transitions; | ||
@@ -38,3 +38,3 @@ | ||
var machine = _.Machine.create("A", { | ||
var machine = _.Machine.create('A', { | ||
state: makeState(IDLE), | ||
@@ -61,3 +61,3 @@ transitions: (_transitions = {}, _transitions[IDLE] = { | ||
_context.prev = 7; | ||
_context.t0 = _context["catch"](0); | ||
_context.t0 = _context['catch'](0); | ||
_context.next = 11; | ||
@@ -67,3 +67,3 @@ return makeState(FAILURE, _context.t0); | ||
case 11: | ||
case "end": | ||
case 'end': | ||
return _context.stop(); | ||
@@ -81,3 +81,3 @@ } | ||
(0, _connect2.default)().with("A").mapSilent(function (A) { | ||
(0, _connect2.default)().with('A').mapSilent(function (A) { | ||
expect(A.state.name).to.equal(FAILURE); | ||
@@ -84,0 +84,0 @@ expect(A.state.error.message).to.equal(errMessage); |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -9,9 +9,9 @@ exports.__esModule = true; | ||
var _handleMiddleware = require("./handleMiddleware"); | ||
var _handleMiddleware = require('./handleMiddleware'); | ||
var _handleMiddleware2 = _interopRequireDefault(_handleMiddleware); | ||
var _constants = require("../constants"); | ||
var _constants = require('../constants'); | ||
var _updateState = require("./updateState"); | ||
var _updateState = require('./updateState'); | ||
@@ -43,3 +43,3 @@ var _updateState2 = _interopRequireDefault(_updateState); | ||
// yield call | ||
if (_typeof(result.value) === "object" && result.value.__type === "call") { | ||
if (_typeof(result.value) === 'object' && result.value.__type === 'call') { | ||
var _result$value = result.value, | ||
@@ -51,3 +51,3 @@ func = _result$value.func, | ||
if (!func) { | ||
var error = (0, _constants.ERROR_GENERATOR_FUNC_CALL_FAILED)(typeof func === "undefined" ? "undefined" : _typeof(func)); | ||
var error = (0, _constants.ERROR_GENERATOR_FUNC_CALL_FAILED)(typeof func === 'undefined' ? 'undefined' : _typeof(func)); | ||
(0, _handleMiddleware2.default)(_constants.MIDDLEWARE_GENERATOR_RESUMED, machine, error); | ||
@@ -66,3 +66,3 @@ return iterate(generatorThrow(generator, new Error(error))); | ||
// promise | ||
if (typeof funcResult.then !== "undefined") { | ||
if (typeof funcResult.then !== 'undefined') { | ||
funcResult.then(function (result) { | ||
@@ -76,3 +76,3 @@ (0, _handleMiddleware2.default)(_constants.MIDDLEWARE_GENERATOR_RESUMED, machine, result); | ||
// generator | ||
} else if (typeof funcResult.next === "function") { | ||
} else if (typeof funcResult.next === 'function') { | ||
try { | ||
@@ -79,0 +79,0 @@ cancelInsideGenerator = handleGenerator(machine, funcResult, function (generatorResult) { |
@@ -164,3 +164,5 @@ 'use strict'; | ||
}); | ||
var mappingFunction = sinon.stub().returns({}); | ||
var mappingFunction = sinon.stub().returns(function () { | ||
return { counter: machine.state.counter }; | ||
}); | ||
var ConnectedComponent = (0, _connect2.default)(Comp).with('C').map(mappingFunction); | ||
@@ -197,3 +199,3 @@ | ||
describe('when we connect without mapping', function () { | ||
it('should detach from the machines', function () { | ||
it('should render correctly', function () { | ||
var Component = function (_React$Component2) { | ||
@@ -230,6 +232,5 @@ _inherits(Component, _React$Component2); | ||
// 1 - initial render | ||
// 2 - default mapping call | ||
// 3 - because of machine's action run | ||
// 4 - because of machine's action stop | ||
expect(connectedWrapper.find('p').text()).to.equal('Rendered 4 times'); | ||
// 2 - because of machine's action run | ||
// 3 - because of machine's action stop | ||
expect(connectedWrapper.find('p').text()).to.equal('Rendered 3 times'); | ||
}); | ||
@@ -372,7 +373,2 @@ }); | ||
var ConnectedIssue13 = (0, _connect2.default)(Issue13).with('issue13').map(function (_ref2) { | ||
var startProcess = _ref2.startProcess; | ||
return { startProcess: startProcess }; | ||
}); | ||
_.Machine.create('issue13', { | ||
@@ -385,2 +381,7 @@ state: { name: 'init' }, | ||
var ConnectedIssue13 = (0, _connect2.default)(Issue13).with('issue13').map(function (_ref2) { | ||
var startProcess = _ref2.startProcess; | ||
return { startProcess: startProcess }; | ||
}); | ||
(0, _enzyme.mount)(_react2.default.createElement(ConnectedIssue13, null)); | ||
@@ -387,0 +388,0 @@ }); |
@@ -14,41 +14,34 @@ 'use strict'; | ||
var mapFunc = function mapFunc(done, once, silent) { | ||
return function (_React$Component) { | ||
_inherits(StentConnect, _React$Component); | ||
var _connect; | ||
function StentConnect() { | ||
_classCallCheck(this, StentConnect); | ||
var mapping = 'map'; | ||
var dependencies = {}; | ||
var listener = function listener() {}; | ||
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); | ||
if (once) mapping = 'mapOnce'; | ||
if (silent) mapping = 'mapSilent'; | ||
var disconnect = (_connect = (0, _connect3.default)({ | ||
meta: { component: Component.name } | ||
})).with.apply(_connect, names)[mapping](function () { | ||
if (done) { | ||
listener(dependencies = done.apply(undefined, arguments)); | ||
} else { | ||
listener({}); | ||
} | ||
}); | ||
return function StentConnect(props) { | ||
var _useState = (0, _react.useState)(dependencies), | ||
state = _useState[0], | ||
setState = _useState[1]; | ||
StentConnect.prototype.componentWillMount = function componentWillMount() { | ||
var _connect, | ||
_this2 = this; | ||
(0, _react.useEffect)(function () { | ||
listener = setState; | ||
return function () { | ||
disconnect(); | ||
}; | ||
}, []); | ||
var mapping = 'map'; | ||
if (once) mapping = 'mapOnce'; | ||
if (silent) mapping = 'mapSilent'; | ||
this._disconnect = (_connect = (0, _connect3.default)({ | ||
meta: { component: Component.name } | ||
})).with.apply(_connect, names)[mapping](function () { | ||
if (!done) { | ||
_this2.forceUpdate(); | ||
} else { | ||
_this2.setState(done.apply(undefined, arguments)); | ||
} | ||
}); | ||
}; | ||
StentConnect.prototype.componentWillUnmount = function componentWillUnmount() { | ||
this._disconnect(); | ||
}; | ||
StentConnect.prototype.render = function render() { | ||
return _react2.default.createElement(Component, _extends({}, this.state, this.props)); | ||
}; | ||
return StentConnect; | ||
}(_react2.default.Component);; | ||
return _react2.default.createElement(Component, _extends({}, state, props)); | ||
}; | ||
}; | ||
@@ -80,8 +73,2 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
module.exports = exports['default']; |
{ | ||
"name": "stent", | ||
"version": "6.0.1", | ||
"version": "7.0.0", | ||
"description": "Stent is combining the ideas of redux with the concept of state machines", | ||
@@ -9,3 +9,3 @@ "main": "lib", | ||
"test": "./node_modules/.bin/mocha --require babel-register --require babel-polyfill --require test/setup.js --require jsdom-global/register --reporter spec --slow 100 './src/**/**.spec.{js,jsx}'", | ||
"test:watch": "./node_modules/.bin/mocha --require babel-register --require babel-polyfill --require test/setup.js --require jsdom-global/register --reporter spec --slow 100 --watch --watch-extensions jx,jsx,json './src/**/**.spec.{js,jsx}'", | ||
"test-watch": "./node_modules/.bin/mocha --require babel-register --require babel-polyfill --require test/setup.js --require jsdom-global/register --reporter spec --slow 100 --watch --watch-extensions jx,jsx,json './src/**/**.spec.{js,jsx}'", | ||
"t": "mocha ./test/setup.js ./test/specs/**/*.spec.js", | ||
@@ -47,5 +47,6 @@ "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --require babel-register --require babel-polyfill --require test/setup.js --require jsdom-global/register --reporter xunit --reporter-options output=reports/test-results.xml './src/**/**.spec.{js,jsx}'", | ||
"browserify": "^14.4.0", | ||
"chai": "3.5.0", | ||
"chai-enzyme": "0.6.1", | ||
"enzyme": "2.7.1", | ||
"chai": "4.2.0", | ||
"chai-enzyme": "1.0.0-beta.1", | ||
"enzyme": "3.10.0", | ||
"enzyme-adapter-react-16": "1.14.0", | ||
"istanbul": "1.1.0-alpha.1", | ||
@@ -55,5 +56,5 @@ "jsdom": "9.8.3", | ||
"mocha": "3.2.0", | ||
"react": "15.4.2", | ||
"react-addons-test-utils": "15.4.2", | ||
"react-dom": "15.4.2", | ||
"react": "16.9.0", | ||
"react-addons-test-utils": "15.6.2", | ||
"react-dom": "16.9.0", | ||
"sinon": "2.0.0", | ||
@@ -60,0 +61,0 @@ "sinon-chai": "2.9.0", |
@@ -1,21 +0,20 @@ | ||
import { Machine } from "../"; | ||
import { ERROR_MISSING_MACHINE } from "../constants"; | ||
import { call } from "../helpers"; | ||
import { Machine } from '../'; | ||
import { ERROR_MISSING_MACHINE } from '../constants'; | ||
import { call } from '../helpers'; | ||
const create = (name = "app") => | ||
Machine.create(name, { | ||
state: { idle: { run: "running" } }, | ||
transitions: {} | ||
}); | ||
const create = (name = 'app') => Machine.create(name, { | ||
state: { idle: { run: 'running' } }, | ||
transitions: {} | ||
}) | ||
describe("Given the Stent library", function() { | ||
describe('Given the Stent library', function () { | ||
beforeEach(() => { | ||
Machine.flush(); | ||
}); | ||
describe("when creating a new machine", function() { | ||
it("should have the machine with its name set up", function() { | ||
expect(create("foo").name).to.equal("foo"); | ||
describe('when creating a new machine', function () { | ||
it('should have the machine with its name set up', function () { | ||
expect(create('foo').name).to.equal('foo'); | ||
}); | ||
describe("and we have a middleware attached", function() { | ||
it("should trigger the middleware hook", function() { | ||
describe('and we have a middleware attached', function () { | ||
it('should trigger the middleware hook', function () { | ||
const spy = sinon.spy(); | ||
@@ -26,11 +25,9 @@ | ||
}); | ||
create("xxxa"); | ||
create('xxxa'); | ||
expect(spy).to.be.calledOnce.and.to.be.calledWith( | ||
sinon.match({ name: "xxxa" }) | ||
); | ||
expect(spy).to.be.calledOnce.and.to.be.calledWith(sinon.match({ name: 'xxxa'})); | ||
}); | ||
it("should call the onMiddlewareRegister hook if available", function() { | ||
it('should call the onMiddlewareRegister hook if available', function () { | ||
const spy = sinon.spy(); | ||
Machine.addMiddleware({ | ||
@@ -47,54 +44,53 @@ onMiddlewareRegister: spy | ||
}); | ||
describe("when `getting a machine", function() { | ||
it("should return the machine if it exists", function() { | ||
create("bar"); | ||
const foo = create("foo"); | ||
describe('when `getting a machine', function () { | ||
it('should return the machine if it exists', function () { | ||
create('bar'); | ||
const foo = create('foo'); | ||
expect(Machine.get("bar").name).to.equal("bar"); | ||
expect(Machine.get(foo).name).to.equal("foo"); | ||
expect(Machine.get('bar').name).to.equal('bar'); | ||
expect(Machine.get(foo).name).to.equal('foo'); | ||
}); | ||
it("should throw an error if the machine does not exist", function() { | ||
create("bar"); | ||
it('should throw an error if the machine does not exist', function () { | ||
create('bar'); | ||
expect(Machine.get.bind(Machine, "baz")).to.throw( | ||
ERROR_MISSING_MACHINE("baz") | ||
); | ||
expect(Machine.get.bind(Machine, 'baz')).to.throw(ERROR_MISSING_MACHINE('baz')); | ||
}); | ||
}); | ||
describe("when creating a machine without a name", function() { | ||
it("should be possible to fetch it by using the machine itself or the its generated name", function() { | ||
describe('when creating a machine without a name', function () { | ||
it('should be possible to fetch it by using the machine itself or the its generated name', function () { | ||
const machine = Machine.create({ | ||
state: { name: "idle" }, | ||
transitions: { idle: { run: "running" } } | ||
state: { name: 'idle' }, | ||
transitions: { idle: { run: 'running' } } | ||
}); | ||
expect(Machine.get(machine).state.name).to.equal("idle"); | ||
expect(Machine.get(machine.name).state.name).to.equal("idle"); | ||
expect(Machine.get(machine).state.name).to.equal('idle'); | ||
expect(Machine.get(machine.name).state.name).to.equal('idle'); | ||
}); | ||
}); | ||
describe("when we fire two actions one after each other", function() { | ||
describe("and we use the .latest version of the action", function() { | ||
it("should cancel the first action and only work with the second one", function(done) { | ||
describe('when we fire two actions one after each other', function () { | ||
describe('and we use the .latest version of the action', function () { | ||
it('should cancel the first action and only work with the second one', | ||
function (done) { | ||
const backend = sinon.stub(); | ||
backend.withArgs("s").returns("salad"); | ||
backend.withArgs("st").returns("stent"); | ||
backend.withArgs('s').returns('salad'); | ||
backend.withArgs('st').returns('stent'); | ||
const api = function(char) { | ||
const api = function (char) { | ||
return new Promise(resolve => { | ||
setTimeout(() => resolve(backend(char)), 10); | ||
}); | ||
}; | ||
} | ||
const machine = Machine.create({ | ||
state: { name: "x" }, | ||
state: { name: 'x' }, | ||
transitions: { | ||
x: { | ||
type: function*(state, letter) { | ||
type: function * (state, letter) { | ||
const match = yield call(api, letter); | ||
return { name: "y", match }; | ||
return { name: 'y', match }; | ||
} | ||
}, | ||
y: { | ||
noway: "x" | ||
'noway': 'x' | ||
} | ||
@@ -104,7 +100,7 @@ } | ||
machine.type.latest("s"); | ||
machine.type.latest("st"); | ||
machine.type.latest('s'); | ||
machine.type.latest('st'); | ||
setTimeout(function() { | ||
expect(machine.state).to.deep.equal({ name: "y", match: "stent" }); | ||
setTimeout(function () { | ||
expect(machine.state).to.deep.equal({ name: 'y', match: 'stent' }); | ||
done(); | ||
@@ -115,18 +111,18 @@ }, 20); | ||
}); | ||
describe("when using the `destroy` method", function() { | ||
it("should delete the machine", function() { | ||
Machine.create("foo", { state: {}, transitions: {} }); | ||
const B = Machine.create("bar", { state: {}, transitions: {} }); | ||
describe('when using the `destroy` method', function () { | ||
it('should delete the machine', function () { | ||
Machine.create('foo', { state: {}, transitions: {} }); | ||
const B = Machine.create('bar', { state: {}, transitions: {} }); | ||
expect(typeof Machine.machines.foo).to.equal("object"); | ||
Machine.destroy("foo"); | ||
expect(typeof Machine.machines.foo).to.equal("undefined"); | ||
expect(typeof Machine.machines.foo).to.equal('object'); | ||
Machine.destroy('foo'); | ||
expect(typeof Machine.machines.foo).to.equal('undefined'); | ||
expect(typeof Machine.machines.bar).to.equal("object"); | ||
expect(typeof Machine.machines.bar).to.equal('object'); | ||
Machine.destroy(B); | ||
expect(typeof Machine.machines.bar).to.equal("undefined"); | ||
expect(typeof Machine.machines.bar).to.equal('undefined'); | ||
}); | ||
describe("and the machine does not exist", function() { | ||
it("should throw an error", function() { | ||
expect(Machine.destroy.bind(Machine, "foo")).to.throw("foo"); | ||
describe('and the machine does not exist', function () { | ||
it('should throw an error', function () { | ||
expect(Machine.destroy.bind(Machine, 'foo')).to.throw('foo'); | ||
}); | ||
@@ -136,1 +132,2 @@ }); | ||
}); | ||
// errors | ||
export const ERROR_MISSING_MACHINE = name => | ||
`There's no machine with name ${name}`; | ||
export const ERROR_MISSING_STATE = | ||
'Configuration error: missing initial "state"'; | ||
export const ERROR_MISSING_TRANSITIONS = | ||
'Configuration error: missing "transitions"'; | ||
export const ERROR_MISSING_MACHINE = name => `There's no machine with name ${ name }`; | ||
export const ERROR_MISSING_STATE = 'Configuration error: missing initial "state"'; | ||
export const ERROR_MISSING_TRANSITIONS = 'Configuration error: missing "transitions"'; | ||
export const ERROR_WRONG_STATE_FORMAT = state => { | ||
const serialized = | ||
typeof state === "object" ? JSON.stringify(state, null, 2) : state; | ||
const serialized = typeof state === 'object' ? JSON.stringify(state, null, 2) : state; | ||
return `The state should be an object and it should always have at least "name" property. You passed ${serialized}`; | ||
}; | ||
export const ERROR_UNCOVERED_STATE = state => | ||
`You just transitioned the machine to a state (${state}) which is not defined or it has no actions. This means that the machine is stuck.`; | ||
export const ERROR_NOT_SUPPORTED_HANDLER_TYPE = | ||
"Wrong handler type passed. Please read the docs https://github.com/krasimir/stent"; | ||
export const ERROR_RESERVED_WORD_USED_AS_ACTION = word => | ||
`Sorry, you can't use ${word} as a name for an action. It is reserved.`; | ||
export const ERROR_GENERATOR_FUNC_CALL_FAILED = type => | ||
`The argument passed to \`call\` is falsy (${type})`; | ||
return `The state should be an object and it should always have at least "name" property. You passed ${ serialized }`; | ||
} | ||
export const ERROR_UNCOVERED_STATE = state => `You just transitioned the machine to a state (${ state }) which is not defined or it has no actions. This means that the machine is stuck.`; | ||
export const ERROR_NOT_SUPPORTED_HANDLER_TYPE = 'Wrong handler type passed. Please read the docs https://github.com/krasimir/stent'; | ||
export const ERROR_RESERVED_WORD_USED_AS_ACTION = word => `Sorry, you can't use ${ word } as a name for an action. It is reserved.`; | ||
export const ERROR_GENERATOR_FUNC_CALL_FAILED = type => `The argument passed to \`call\` is falsy (${type})`; | ||
// middlewares | ||
export const MIDDLEWARE_PROCESS_ACTION = "onActionDispatched"; | ||
export const MIDDLEWARE_ACTION_PROCESSED = "onActionProcessed"; | ||
export const MIDDLEWARE_STATE_WILL_CHANGE = "onStateWillChange"; | ||
export const MIDDLEWARE_PROCESS_STATE_CHANGE = "onStateChanged"; | ||
export const MIDDLEWARE_GENERATOR_STEP = "onGeneratorStep"; | ||
export const MIDDLEWARE_GENERATOR_END = "onGeneratorEnd"; | ||
export const MIDDLEWARE_GENERATOR_RESUMED = "onGeneratorResumed"; | ||
export const MIDDLEWARE_MACHINE_CREATED = "onMachineCreated"; | ||
export const MIDDLEWARE_MACHINE_CONNECTED = "onMachineConnected"; | ||
export const MIDDLEWARE_MACHINE_DISCONNECTED = "onMachineDisconnected"; | ||
export const MIDDLEWARE_REGISTERED = "onMiddlewareRegister"; | ||
export const MIDDLEWARE_PROCESS_ACTION = 'onActionDispatched'; | ||
export const MIDDLEWARE_ACTION_PROCESSED = 'onActionProcessed'; | ||
export const MIDDLEWARE_STATE_WILL_CHANGE = 'onStateWillChange'; | ||
export const MIDDLEWARE_PROCESS_STATE_CHANGE = 'onStateChanged'; | ||
export const MIDDLEWARE_GENERATOR_STEP = 'onGeneratorStep'; | ||
export const MIDDLEWARE_GENERATOR_END = 'onGeneratorEnd'; | ||
export const MIDDLEWARE_GENERATOR_RESUMED = 'onGeneratorResumed'; | ||
export const MIDDLEWARE_MACHINE_CREATED = 'onMachineCreated'; | ||
export const MIDDLEWARE_MACHINE_CONNECTED = 'onMachineConnected'; | ||
export const MIDDLEWARE_MACHINE_DISCONNECTED = 'onMachineDisconnected'; | ||
export const MIDDLEWARE_REGISTERED = 'onMiddlewareRegister'; | ||
// misc | ||
export const DEVTOOLS_KEY = "__hello__stent__"; | ||
export const DEVTOOLS_KEY = '__hello__stent__'; |
@@ -1,27 +0,27 @@ | ||
import connect from "../connect"; | ||
import call from "../generators/call"; | ||
import { Machine } from "../../"; | ||
import connect from '../connect'; | ||
import call from '../generators/call'; | ||
import { Machine } from '../../'; | ||
const IDLE = "IDLE"; | ||
const END = "END"; | ||
const FAILURE = "FAILURE"; | ||
const IDLE = 'IDLE'; | ||
const END = 'END'; | ||
const FAILURE = 'FAILURE'; | ||
const makeState = function(name = "INVALID", error = null) { | ||
const makeState = function(name = 'INVALID', error = null) { | ||
return { name, error }; | ||
}; | ||
describe("Given the call helper", function() { | ||
describe('Given the call helper', function () { | ||
beforeEach(() => { | ||
Machine.flush(); | ||
}); | ||
describe("when calling it with a non-function argument", function() { | ||
it("should catch the error and transition to Failure state with a meaningful error message", function(done) { | ||
describe('when calling it with a non-function argument', function () { | ||
it('should catch the error and transition to Failure state with a meaningful error message', function (done) { | ||
const missingFunc = undefined; | ||
const errMessage = "The argument passed to `call` is falsy (undefined)"; | ||
const machine = Machine.create("A", { | ||
const machine = Machine.create('A', { | ||
state: makeState(IDLE), | ||
transitions: { | ||
[IDLE]: { | ||
run: function* run() { | ||
run: function * run () { | ||
try { | ||
@@ -46,3 +46,3 @@ // throw new Error(errMessage) | ||
connect() | ||
.with("A") | ||
.with('A') | ||
.mapSilent(A => { | ||
@@ -49,0 +49,0 @@ expect(A.state.name).to.equal(FAILURE); |
@@ -1,16 +0,6 @@ | ||
import handleMiddleware from "./handleMiddleware"; | ||
import { | ||
MIDDLEWARE_GENERATOR_STEP, | ||
MIDDLEWARE_GENERATOR_END, | ||
MIDDLEWARE_GENERATOR_RESUMED, | ||
ERROR_GENERATOR_FUNC_CALL_FAILED | ||
} from "../constants"; | ||
import updateState from "./updateState"; | ||
import handleMiddleware from './handleMiddleware'; | ||
import { MIDDLEWARE_GENERATOR_STEP, MIDDLEWARE_GENERATOR_END, MIDDLEWARE_GENERATOR_RESUMED, ERROR_GENERATOR_FUNC_CALL_FAILED } from '../constants'; | ||
import updateState from './updateState'; | ||
export default function handleGenerator( | ||
machine, | ||
generator, | ||
done, | ||
resultOfPreviousOperation | ||
) { | ||
export default function handleGenerator(machine, generator, done, resultOfPreviousOperation) { | ||
const generatorNext = (gen, res) => !canceled && gen.next(res); | ||
@@ -21,9 +11,9 @@ const generatorThrow = (gen, error) => !canceled && gen.throw(error); | ||
canceled = true; | ||
}; | ||
} | ||
var canceled = false; | ||
var cancelInsideGenerator; | ||
const iterate = function(result) { | ||
const iterate = function (result) { | ||
if (canceled) return; | ||
if (!result.done) { | ||
@@ -33,3 +23,3 @@ handleMiddleware(MIDDLEWARE_GENERATOR_STEP, machine, result.value); | ||
// yield call | ||
if (typeof result.value === "object" && result.value.__type === "call") { | ||
if (typeof result.value === 'object' && result.value.__type === 'call') { | ||
const { func, args } = result.value; | ||
@@ -50,5 +40,5 @@ | ||
} | ||
// promise | ||
if (typeof funcResult.then !== "undefined") { | ||
if (typeof funcResult.then !== 'undefined') { | ||
funcResult.then( | ||
@@ -64,17 +54,9 @@ result => { | ||
); | ||
// generator | ||
} else if (typeof funcResult.next === "function") { | ||
// generator | ||
} else if (typeof funcResult.next === 'function') { | ||
try { | ||
cancelInsideGenerator = handleGenerator( | ||
machine, | ||
funcResult, | ||
generatorResult => { | ||
handleMiddleware( | ||
MIDDLEWARE_GENERATOR_RESUMED, | ||
machine, | ||
generatorResult | ||
); | ||
iterate(generatorNext(generator, generatorResult)); | ||
} | ||
); | ||
cancelInsideGenerator = handleGenerator(machine, funcResult, generatorResult => { | ||
handleMiddleware(MIDDLEWARE_GENERATOR_RESUMED, machine, generatorResult); | ||
iterate(generatorNext(generator, generatorResult)); | ||
}); | ||
} catch (error) { | ||
@@ -88,3 +70,3 @@ return iterate(generatorThrow(generator, error)); | ||
// a return statement of the normal function | ||
// a return statement of the normal function | ||
} else { | ||
@@ -95,4 +77,4 @@ updateState(machine, result.value); | ||
} | ||
// the end of the generator (return statement) | ||
// the end of the generator (return statement) | ||
} else { | ||
@@ -107,2 +89,2 @@ handleMiddleware(MIDDLEWARE_GENERATOR_END, machine, result.value); | ||
return cancelGenerator; | ||
} | ||
} |
@@ -109,3 +109,5 @@ import React from 'react'; | ||
}); | ||
const mappingFunction = sinon.stub().returns({}); | ||
const mappingFunction = sinon.stub().returns(() => { | ||
return { counter: machine.state.counter }; | ||
}); | ||
const ConnectedComponent = connect(Comp).with('C').map(mappingFunction); | ||
@@ -143,3 +145,3 @@ | ||
describe('when we connect without mapping', function () { | ||
it('should detach from the machines', function () { | ||
it('should render correctly', function () { | ||
class Component extends React.Component { | ||
@@ -161,6 +163,5 @@ constructor(props) { | ||
// 1 - initial render | ||
// 2 - default mapping call | ||
// 3 - because of machine's action run | ||
// 4 - because of machine's action stop | ||
expect(connectedWrapper.find('p').text()).to.equal('Rendered 4 times'); | ||
// 2 - because of machine's action run | ||
// 3 - because of machine's action stop | ||
expect(connectedWrapper.find('p').text()).to.equal('Rendered 3 times'); | ||
}); | ||
@@ -256,5 +257,2 @@ }); | ||
const ConnectedIssue13 = connect(Issue13).with('issue13') | ||
.map(({ startProcess }) => ({ startProcess })); | ||
Machine.create('issue13', { | ||
@@ -267,2 +265,5 @@ state: { name: 'init' }, | ||
const ConnectedIssue13 = connect(Issue13).with('issue13') | ||
.map(({ startProcess }) => ({ startProcess })); | ||
mount(<ConnectedIssue13 />); | ||
@@ -269,0 +270,0 @@ |
@@ -1,2 +0,2 @@ | ||
import React from 'react'; | ||
import React, { useEffect, useState } from 'react'; | ||
import connect from '../helpers/connect'; | ||
@@ -7,27 +7,31 @@ | ||
const mapFunc = (done, once, silent) => { | ||
return class StentConnect extends React.Component { | ||
componentWillMount() { | ||
var mapping = 'map'; | ||
let mapping = 'map'; | ||
let dependencies = {}; | ||
let listener = () => {}; | ||
if (once) mapping = 'mapOnce'; | ||
if (silent) mapping = 'mapSilent'; | ||
if (once) mapping = 'mapOnce'; | ||
if (silent) mapping = 'mapSilent'; | ||
this._disconnect = connect({ | ||
meta: { component: Component.name } | ||
}).with(...names)[mapping] | ||
((...deps) => { | ||
if (!done) { | ||
this.forceUpdate(); | ||
} else { | ||
this.setState(done(...deps)); | ||
} | ||
}) | ||
} | ||
componentWillUnmount() { | ||
this._disconnect(); | ||
} | ||
render() { | ||
return <Component {...this.state} {...this.props} />; | ||
} | ||
};; | ||
let disconnect = connect({ | ||
meta: { component: Component.name } | ||
}).with(...names)[mapping] | ||
((...deps) => { | ||
if (done) { | ||
listener(dependencies = done(...deps)); | ||
} else { | ||
listener({}); | ||
} | ||
}) | ||
return function StentConnect(props) { | ||
const [ state, setState ] = useState(dependencies); | ||
useEffect(() => { | ||
listener = setState; | ||
return () => { | ||
disconnect(); | ||
} | ||
}, []); | ||
return <Component {...state} {...props} />; | ||
} | ||
} | ||
@@ -34,0 +38,0 @@ |
@@ -15,3 +15,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.stent = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var ERROR_WRONG_STATE_FORMAT = exports.ERROR_WRONG_STATE_FORMAT = function ERROR_WRONG_STATE_FORMAT(state) { | ||
var serialized = (typeof state === 'undefined' ? 'undefined' : _typeof(state)) === "object" ? JSON.stringify(state, null, 2) : state; | ||
var serialized = (typeof state === 'undefined' ? 'undefined' : _typeof(state)) === 'object' ? JSON.stringify(state, null, 2) : state; | ||
@@ -23,3 +23,3 @@ return 'The state should be an object and it should always have at least "name" property. You passed ' + serialized; | ||
}; | ||
var ERROR_NOT_SUPPORTED_HANDLER_TYPE = exports.ERROR_NOT_SUPPORTED_HANDLER_TYPE = "Wrong handler type passed. Please read the docs https://github.com/krasimir/stent"; | ||
var ERROR_NOT_SUPPORTED_HANDLER_TYPE = exports.ERROR_NOT_SUPPORTED_HANDLER_TYPE = 'Wrong handler type passed. Please read the docs https://github.com/krasimir/stent'; | ||
var ERROR_RESERVED_WORD_USED_AS_ACTION = exports.ERROR_RESERVED_WORD_USED_AS_ACTION = function ERROR_RESERVED_WORD_USED_AS_ACTION(word) { | ||
@@ -33,16 +33,16 @@ return 'Sorry, you can\'t use ' + word + ' as a name for an action. It is reserved.'; | ||
// middlewares | ||
var MIDDLEWARE_PROCESS_ACTION = exports.MIDDLEWARE_PROCESS_ACTION = "onActionDispatched"; | ||
var MIDDLEWARE_ACTION_PROCESSED = exports.MIDDLEWARE_ACTION_PROCESSED = "onActionProcessed"; | ||
var MIDDLEWARE_STATE_WILL_CHANGE = exports.MIDDLEWARE_STATE_WILL_CHANGE = "onStateWillChange"; | ||
var MIDDLEWARE_PROCESS_STATE_CHANGE = exports.MIDDLEWARE_PROCESS_STATE_CHANGE = "onStateChanged"; | ||
var MIDDLEWARE_GENERATOR_STEP = exports.MIDDLEWARE_GENERATOR_STEP = "onGeneratorStep"; | ||
var MIDDLEWARE_GENERATOR_END = exports.MIDDLEWARE_GENERATOR_END = "onGeneratorEnd"; | ||
var MIDDLEWARE_GENERATOR_RESUMED = exports.MIDDLEWARE_GENERATOR_RESUMED = "onGeneratorResumed"; | ||
var MIDDLEWARE_MACHINE_CREATED = exports.MIDDLEWARE_MACHINE_CREATED = "onMachineCreated"; | ||
var MIDDLEWARE_MACHINE_CONNECTED = exports.MIDDLEWARE_MACHINE_CONNECTED = "onMachineConnected"; | ||
var MIDDLEWARE_MACHINE_DISCONNECTED = exports.MIDDLEWARE_MACHINE_DISCONNECTED = "onMachineDisconnected"; | ||
var MIDDLEWARE_REGISTERED = exports.MIDDLEWARE_REGISTERED = "onMiddlewareRegister"; | ||
var MIDDLEWARE_PROCESS_ACTION = exports.MIDDLEWARE_PROCESS_ACTION = 'onActionDispatched'; | ||
var MIDDLEWARE_ACTION_PROCESSED = exports.MIDDLEWARE_ACTION_PROCESSED = 'onActionProcessed'; | ||
var MIDDLEWARE_STATE_WILL_CHANGE = exports.MIDDLEWARE_STATE_WILL_CHANGE = 'onStateWillChange'; | ||
var MIDDLEWARE_PROCESS_STATE_CHANGE = exports.MIDDLEWARE_PROCESS_STATE_CHANGE = 'onStateChanged'; | ||
var MIDDLEWARE_GENERATOR_STEP = exports.MIDDLEWARE_GENERATOR_STEP = 'onGeneratorStep'; | ||
var MIDDLEWARE_GENERATOR_END = exports.MIDDLEWARE_GENERATOR_END = 'onGeneratorEnd'; | ||
var MIDDLEWARE_GENERATOR_RESUMED = exports.MIDDLEWARE_GENERATOR_RESUMED = 'onGeneratorResumed'; | ||
var MIDDLEWARE_MACHINE_CREATED = exports.MIDDLEWARE_MACHINE_CREATED = 'onMachineCreated'; | ||
var MIDDLEWARE_MACHINE_CONNECTED = exports.MIDDLEWARE_MACHINE_CONNECTED = 'onMachineConnected'; | ||
var MIDDLEWARE_MACHINE_DISCONNECTED = exports.MIDDLEWARE_MACHINE_DISCONNECTED = 'onMachineDisconnected'; | ||
var MIDDLEWARE_REGISTERED = exports.MIDDLEWARE_REGISTERED = 'onMiddlewareRegister'; | ||
// misc | ||
var DEVTOOLS_KEY = exports.DEVTOOLS_KEY = "__hello__stent__"; | ||
var DEVTOOLS_KEY = exports.DEVTOOLS_KEY = '__hello__stent__'; | ||
},{}],2:[function(require,module,exports){ | ||
@@ -347,3 +347,3 @@ 'use strict'; | ||
},{"./handleAction":5}],7:[function(require,module,exports){ | ||
"use strict"; | ||
'use strict'; | ||
@@ -356,9 +356,9 @@ exports.__esModule = true; | ||
var _handleMiddleware = require("./handleMiddleware"); | ||
var _handleMiddleware = require('./handleMiddleware'); | ||
var _handleMiddleware2 = _interopRequireDefault(_handleMiddleware); | ||
var _constants = require("../constants"); | ||
var _constants = require('../constants'); | ||
var _updateState = require("./updateState"); | ||
var _updateState = require('./updateState'); | ||
@@ -390,3 +390,3 @@ var _updateState2 = _interopRequireDefault(_updateState); | ||
// yield call | ||
if (_typeof(result.value) === "object" && result.value.__type === "call") { | ||
if (_typeof(result.value) === 'object' && result.value.__type === 'call') { | ||
var _result$value = result.value, | ||
@@ -398,3 +398,3 @@ func = _result$value.func, | ||
if (!func) { | ||
var error = (0, _constants.ERROR_GENERATOR_FUNC_CALL_FAILED)(typeof func === "undefined" ? "undefined" : _typeof(func)); | ||
var error = (0, _constants.ERROR_GENERATOR_FUNC_CALL_FAILED)(typeof func === 'undefined' ? 'undefined' : _typeof(func)); | ||
(0, _handleMiddleware2.default)(_constants.MIDDLEWARE_GENERATOR_RESUMED, machine, error); | ||
@@ -413,3 +413,3 @@ return iterate(generatorThrow(generator, new Error(error))); | ||
// promise | ||
if (typeof funcResult.then !== "undefined") { | ||
if (typeof funcResult.then !== 'undefined') { | ||
funcResult.then(function (result) { | ||
@@ -423,3 +423,3 @@ (0, _handleMiddleware2.default)(_constants.MIDDLEWARE_GENERATOR_RESUMED, machine, result); | ||
// generator | ||
} else if (typeof funcResult.next === "function") { | ||
} else if (typeof funcResult.next === 'function') { | ||
try { | ||
@@ -426,0 +426,0 @@ cancelInsideGenerator = handleGenerator(machine, funcResult, function (generatorResult) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
401077
22
89
5363