Skip to content

Commit 851bfe6

Browse files
authored
Update libs, cleanup. (#32)
1 parent 20aec29 commit 851bfe6

File tree

9 files changed

+1979
-2618
lines changed

9 files changed

+1979
-2618
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ stages:
104104
- task: GitHubRelease@1
105105
displayName: "Update GitHub release"
106106
inputs:
107-
gitHubConnection: "mocoding-software"
107+
gitHubConnection: "github.com_offbeatful"
108108
repositoryName: "mocoding-software/redux-automata"
109109
action: edit
110110
tag: "v$(Build.BuildNumber)"

package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,35 @@
4545
],
4646
"homepage": "https://github.com/mocoding-software/redux-automata#readme",
4747
"devDependencies": {
48-
"@babel/core": "^7.9.6",
49-
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
50-
"@babel/plugin-transform-runtime": "^7.9.6",
51-
"@babel/preset-env": "^7.9.6",
52-
"@babel/preset-typescript": "^7.9.0",
53-
"@types/jest": "^25.2.1",
54-
"@types/node": "^13.13.5",
55-
"@typescript-eslint/eslint-plugin": "^2.31.0",
56-
"@typescript-eslint/parser": "^2.31.0",
57-
"eslint": "^7.0.0",
58-
"eslint-config-prettier": "^6.11.0",
48+
"@babel/core": "^7.14.8",
49+
"@babel/plugin-proposal-object-rest-spread": "^7.14.7",
50+
"@babel/plugin-transform-runtime": "^7.14.5",
51+
"@babel/preset-env": "^7.14.8",
52+
"@babel/preset-typescript": "^7.14.5",
53+
"@types/jest": "^26.0.24",
54+
"@types/node": "^16.4.0",
55+
"@typescript-eslint/eslint-plugin": "^4.28.4",
56+
"@typescript-eslint/parser": "^4.28.4",
57+
"eslint": "^7.31.0",
58+
"eslint-config-prettier": "^8.3.0",
5959
"eslint-plugin-only-warn": "^1.0.2",
60-
"eslint-plugin-prettier": "^3.1.3",
61-
"jest": "^26.0.1",
60+
"eslint-plugin-prettier": "^3.4.0",
61+
"jest": "^27.0.6",
6262
"jest-sonar-reporter": "^2.0.0",
63-
"prettier": "^2.0.5",
63+
"prettier": "^2.3.2",
6464
"rimraf": "^3.0.2",
65-
"rollup": "^2.8.0",
65+
"rollup": "^2.53.3",
6666
"rollup-plugin-babel": "^4.4.0",
6767
"rollup-plugin-node-resolve": "^5.2.0",
6868
"rollup-plugin-replace": "^2.2.0",
69-
"rollup-plugin-terser": "^5.3.0",
70-
"rollup-plugin-typescript2": "^0.27.1",
71-
"ts-jest": "^26.0.0",
72-
"typescript": "^3.9.2"
69+
"rollup-plugin-terser": "^7.0.2",
70+
"rollup-plugin-typescript2": "^0.30.0",
71+
"ts-jest": "^27.0.4",
72+
"typescript": "^4.3.5"
7373
},
7474
"dependencies": {
75-
"@babel/runtime": "^7.9.6",
76-
"redux": "^4.0.5"
75+
"@babel/runtime": "^7.14.8",
76+
"redux": "^4.1.0"
7777
},
7878
"jestSonar": {
7979
"reportPath": ".coverage",

src/core/Automata.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export class Automata<TState> implements StateMachineOptions<TState> {
5353
if (!existingState) throw new Error("State should be previously defined using this.state(...) method.");
5454

5555
this.initial = Object.assign(state({} as TState, undefined), {
56-
// eslint-disable-next-line @typescript-eslint/camelcase
5756
__sm_state: existingState.stateName,
5857
});
5958
}

src/core/automataMiddleware.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ import { ACTION_TYPE_PREFIX, ActionPayload, PayloadAction } from "./common";
44
export function automataMiddleware<D extends Redux.Dispatch, S>(
55
api: Redux.MiddlewareAPI<D, S>,
66
): (next: Redux.Dispatch) => Redux.Dispatch {
7-
return (next: Redux.Dispatch) => <A extends PayloadAction<ActionPayload>>(action: A) => {
8-
if (!action.type.startsWith(ACTION_TYPE_PREFIX)) return next(action);
7+
return (next: Redux.Dispatch) =>
8+
<A extends PayloadAction<ActionPayload>>(action: A) => {
9+
if (!action.type.startsWith(ACTION_TYPE_PREFIX)) return next(action);
910

10-
let dispatching = true;
11+
let dispatching = true;
1112

12-
Object.assign(action, {
13-
dispatch: <DispatchedAction extends Redux.Action>(a: DispatchedAction): DispatchedAction => {
14-
if (dispatching) setTimeout(() => api.dispatch(a), 0);
15-
else return api.dispatch(a);
16-
return a;
17-
},
18-
});
13+
Object.assign(action, {
14+
dispatch: <DispatchedAction extends Redux.Action>(a: DispatchedAction): DispatchedAction => {
15+
if (dispatching) setTimeout(() => api.dispatch(a), 0);
16+
else return api.dispatch(a);
17+
return a;
18+
},
19+
});
1920

20-
const deferred = next(action);
21-
dispatching = false;
22-
return deferred;
23-
};
21+
const deferred = next(action);
22+
dispatching = false;
23+
return deferred;
24+
};
2425
}

src/core/automataReducer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as Redux from "redux";
22
import { Automata } from "./Automata";
3-
import { ACTION_TYPE_PREFIX, ActionPayload, AutomataState, LocalStore } from "./common";
3+
import { ACTION_TYPE_PREFIX, AutomataState, LocalStore } from "./common";
44

55
export function automataReducer<TState>(automata: Automata<TState>): Redux.Reducer<TState> {
66
if (automata.initial.__sm_state === undefined)
@@ -13,7 +13,7 @@ export function automataReducer<TState>(automata: Automata<TState>): Redux.Reduc
1313

1414
if (!currentNode) throw new Error("Can't find initial state.");
1515

16-
return <TPayload extends ActionPayload>(state: AutomataState<TState> = automata.initial, action: Redux.AnyAction) => {
16+
return (state: AutomataState<TState> = automata.initial, action: Redux.AnyAction) => {
1717
// skip if not state machine;
1818
if (typeof action.type !== "string" || !action.type.startsWith(ACTION_TYPE_PREFIX)) return state;
1919

@@ -31,7 +31,6 @@ export function automataReducer<TState>(automata: Automata<TState>): Redux.Reduc
3131

3232
automata.current = state;
3333
newState = nextNode.entry(state, action.payload);
34-
// eslint-disable-next-line @typescript-eslint/camelcase
3534
newState.__sm_state = nextNode.entry.stateName;
3635
automata.current = newState;
3736
}

src/core/options/ActionOptions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import { Arc, ArcCreator } from "./common";
1111
import { StateOptionsEx } from "./StateOptionsEx";
1212

1313
export class ActionOptions<TState, TAction>
14-
implements ActionFluentOptions<TState, TAction>, ArcCreator<TState, TAction> {
14+
implements ActionFluentOptions<TState, TAction>, ArcCreator<TState, TAction>
15+
{
1516
private transitions: TransitionMethod<TState, TAction>[] = [];
1617
private targetState?: string;
1718

src/task-automata/createTaskAutomation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface TaskAutomation<
77
TResult,
88
TInput = void,
99
TError extends Error = Error,
10-
TState extends TaskState<TResult, TError> = TaskState<TResult, TError>
10+
TState extends TaskState<TResult, TError> = TaskState<TResult, TError>,
1111
> {
1212
reducer: Redux.Reducer<TState>;
1313
start: ActionDefinition<TInput>;
@@ -19,7 +19,7 @@ export function createTaskAutomation<
1919
TResult,
2020
TInput = void,
2121
TError extends Error = Error,
22-
TState extends TaskState<TResult, TError> = TaskState<TResult, TError>
22+
TState extends TaskState<TResult, TError> = TaskState<TResult, TError>,
2323
>(
2424
dataName: string,
2525
processTask: Task<TResult, TInput>,

test/noop.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("Noop", () => {
4646
test("On Execute Test", () => {
4747
store.dispatch(UpdateMessage());
4848

49-
return new Promise((accept) => setTimeout(accept, 1)).then(() => {
49+
return new Promise((accept) => setTimeout(accept, 1, undefined)).then(() => {
5050
const currentState = store.getState() as AutomataState<TestState>;
5151
expect(currentState.__sm_state).toBe(Active.stateName);
5252
});

0 commit comments

Comments
 (0)