Skip to content

Commit

Permalink
lint: format code style (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD authored Sep 19, 2023
2 parents e83abcc + 68b16be commit 3da84da
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 128 deletions.
8 changes: 2 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@
"*.njk": "html",
"ssh-config": "ssh_config"
},
"markdownlint.ignore": [
"**/CHANGELOG.md"
],
"markdownlint.ignore": ["**/CHANGELOG.md"],
"cSpell.language": "en,fa,fa-IR",
"cSpell.words": [
"Alwatr"
],
"cSpell.words": ["Alwatr"],
"typescript.tsdk": "node_modules/typescript/lib",
"git.autoStash": true,
"git.branchProtection": ["main", "next"],
Expand Down
20 changes: 9 additions & 11 deletions demo/server-context/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Server Context</title>
<script type="module" src="./server-context.js"></script>
</head>
<body>

</body>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Server Context</title>
<script type="module" src="./server-context.js"></script>
</head>
<body></body>
</html>
2 changes: 1 addition & 1 deletion demo/signal/multithread-context/share-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import type {Stringifyable} from '@alwatr/type';

interface Message {
type: string;
payload: Stringifyable
payload: Stringifyable;
}
export const messageContext = new AlwatrMultithreadContextSignal<Message>({name: 'demo.message'});
3 changes: 0 additions & 3 deletions demo/signal/simple/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function clickEventSubscribeHandler(): void {
}
clickEvent.subscribe(clickEventSubscribeHandler);


// button 2
const clickEvent2 = new AlwatrSignal({name: 'button-2-click-event'});
document.getElementById('myButton2')?.addEventListener('click', () => clickEvent2.notify({clickedBy: 'BTN_2'}));
Expand All @@ -17,14 +16,12 @@ function clickEvent2SubscribeHandler(detail: unknown): void {
}
clickEvent2.subscribe(clickEvent2SubscribeHandler);


// button 3
document.getElementById('myButton3')?.addEventListener('click', () => {
clickEvent.subscribe(clickEventSubscribeHandler);
clickEvent2.subscribe(clickEvent2SubscribeHandler);
});


// button 4
document.getElementById('myButton4')?.addEventListener('click', () => {
clickEvent.unsubscribe(clickEventSubscribeHandler);
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Refresh" content="0; URL=/demo/" />
Expand Down
58 changes: 29 additions & 29 deletions packages/fsm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,46 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Bug Fixes

* **fms:** import path ([f6770a0](https://github.com/AliMD/alwatr-signal/commit/f6770a07fdf6855ccd63a85822d44d5ef9c72dee))
* **fsm:** action maybe async ([50efffa](https://github.com/AliMD/alwatr-signal/commit/50efffa34a2ea5a3515561d7425da0c109631f36))
* **fsm:** autoSignalUnsubscribe type ([f7db30b](https://github.com/AliMD/alwatr-signal/commit/f7db30bf5a90ff3d163f036b313a412a5149ff2b))
* **fsm:** call render states function in there own this ([a950478](https://github.com/AliMD/alwatr-signal/commit/a95047811366e375785b2cd8fb176b1176638cab))
* **fsm:** fix order of `initFsmInstance` args ([3b60138](https://github.com/AliMD/alwatr-signal/commit/3b60138ecebcbcb4d732e4d1a3e79f5b8661ae47))
* **fsm:** initial exec actions ([e7dd5c8](https://github.com/AliMD/alwatr-signal/commit/e7dd5c8aaf9760c9856e4392cc899020f7e796d9))
* **fsm:** last reported bugs in set state ([e7435c8](https://github.com/AliMD/alwatr-signal/commit/e7435c870a054b0ec3e4004f13c6db7610610be0))
* **fsm:** review reset process ([af6e81c](https://github.com/AliMD/alwatr-signal/commit/af6e81c068b467d8b3aa96f2431e13ac479f018c))
* **fsm:** run init entry actions ([777ae45](https://github.com/AliMD/alwatr-signal/commit/777ae459f2b77f79696daf3a0ca355d6d78e57d3))
* new logger api ([9d83a7d](https://github.com/AliMD/alwatr-signal/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
- **fms:** import path ([f6770a0](https://github.com/AliMD/alwatr-signal/commit/f6770a07fdf6855ccd63a85822d44d5ef9c72dee))
- **fsm:** action maybe async ([50efffa](https://github.com/AliMD/alwatr-signal/commit/50efffa34a2ea5a3515561d7425da0c109631f36))
- **fsm:** autoSignalUnsubscribe type ([f7db30b](https://github.com/AliMD/alwatr-signal/commit/f7db30bf5a90ff3d163f036b313a412a5149ff2b))
- **fsm:** call render states function in there own this ([a950478](https://github.com/AliMD/alwatr-signal/commit/a95047811366e375785b2cd8fb176b1176638cab))
- **fsm:** fix order of `initFsmInstance` args ([3b60138](https://github.com/AliMD/alwatr-signal/commit/3b60138ecebcbcb4d732e4d1a3e79f5b8661ae47))
- **fsm:** initial exec actions ([e7dd5c8](https://github.com/AliMD/alwatr-signal/commit/e7dd5c8aaf9760c9856e4392cc899020f7e796d9))
- **fsm:** last reported bugs in set state ([e7435c8](https://github.com/AliMD/alwatr-signal/commit/e7435c870a054b0ec3e4004f13c6db7610610be0))
- **fsm:** review reset process ([af6e81c](https://github.com/AliMD/alwatr-signal/commit/af6e81c068b467d8b3aa96f2431e13ac479f018c))
- **fsm:** run init entry actions ([777ae45](https://github.com/AliMD/alwatr-signal/commit/777ae459f2b77f79696daf3a0ca355d6d78e57d3))
- new logger api ([9d83a7d](https://github.com/AliMD/alwatr-signal/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))

### Features

* **fsm:** add `signalRecord` to config ([1a35291](https://github.com/AliMD/alwatr-signal/commit/1a352915fba978da141513517655d1e07350c3ec))
* **fsm:** add unsubscribe ([85ed3c3](https://github.com/AliMD/alwatr-signal/commit/85ed3c3439e1f40c2760f6011df112242f10be06))
* **fsm:** callback in provider signals ([772818b](https://github.com/AliMD/alwatr-signal/commit/772818baa7953b6fbb4d4128fcee76733f42cc2d))
* **fsm:** custom signal callback ([47c22e9](https://github.com/AliMD/alwatr-signal/commit/47c22e92a8a8085148b44b316d649b695ff8071a))
* **fsm:** destroy and expire api ([e1a1c15](https://github.com/AliMD/alwatr-signal/commit/e1a1c150d81f4428718bd18f039235c7fce9caf2))
* **fsm:** new types ([2866e3b](https://github.com/AliMD/alwatr-signal/commit/2866e3bd5ff56fd2b5bddcaed3673a5868bae4bb))
* **fsm:** rewrite state machine ([7f24695](https://github.com/AliMD/alwatr-signal/commit/7f246959e5a80b21c1c4b21e895e75f8fbe56798))
* **fsm:** subscribe ([2af4f44](https://github.com/AliMD/alwatr-signal/commit/2af4f44f0e8a2dee39cde10dcaa3281075632e6a))
- **fsm:** add `signalRecord` to config ([1a35291](https://github.com/AliMD/alwatr-signal/commit/1a352915fba978da141513517655d1e07350c3ec))
- **fsm:** add unsubscribe ([85ed3c3](https://github.com/AliMD/alwatr-signal/commit/85ed3c3439e1f40c2760f6011df112242f10be06))
- **fsm:** callback in provider signals ([772818b](https://github.com/AliMD/alwatr-signal/commit/772818baa7953b6fbb4d4128fcee76733f42cc2d))
- **fsm:** custom signal callback ([47c22e9](https://github.com/AliMD/alwatr-signal/commit/47c22e92a8a8085148b44b316d649b695ff8071a))
- **fsm:** destroy and expire api ([e1a1c15](https://github.com/AliMD/alwatr-signal/commit/e1a1c150d81f4428718bd18f039235c7fce9caf2))
- **fsm:** new types ([2866e3b](https://github.com/AliMD/alwatr-signal/commit/2866e3bd5ff56fd2b5bddcaed3673a5868bae4bb))
- **fsm:** rewrite state machine ([7f24695](https://github.com/AliMD/alwatr-signal/commit/7f246959e5a80b21c1c4b21e895e75f8fbe56798))
- **fsm:** subscribe ([2af4f44](https://github.com/AliMD/alwatr-signal/commit/2af4f44f0e8a2dee39cde10dcaa3281075632e6a))

# 0.30.0 (2023-03-06)

### Bug Fixes

* **fsm:** every signal mather ([0dc504d](https://github.com/AliMD/alwatr-signal/commit/0dc504dacbb1ec68f154244619d644ff8e43cc04))
* **fsm:** remove additional import ([231337b](https://github.com/AliMD/alwatr-signal/commit/231337b95ee7b046fe35429f50931ddf85be291f))
* **fsm:** update context in transition bug ([28a21d0](https://github.com/AliMD/alwatr-signal/commit/28a21d00d903b6189d814303c72ba6e784852f33))
- **fsm:** every signal mather ([0dc504d](https://github.com/AliMD/alwatr-signal/commit/0dc504dacbb1ec68f154244619d644ff8e43cc04))
- **fsm:** remove additional import ([231337b](https://github.com/AliMD/alwatr-signal/commit/231337b95ee7b046fe35429f50931ddf85be291f))
- **fsm:** update context in transition bug ([28a21d0](https://github.com/AliMD/alwatr-signal/commit/28a21d00d903b6189d814303c72ba6e784852f33))

### Features

* Alwatr Finite State Machines ([d5900b4](https://github.com/AliMD/alwatr-signal/commit/d5900b4ee8685b120188888871405853f5a69417))
* **fsm:** $all and $self state ([69adf41](https://github.com/AliMD/alwatr-signal/commit/69adf41064ca0f55497484c50e298ebc26c42dcc))
* **fsm:** enhance types ([3b13046](https://github.com/AliMD/alwatr-signal/commit/3b130463a102f59c38603b0de470be5c87ee88c9))
* **fsm:** make simple state machine ([ff9ae1c](https://github.com/AliMD/alwatr-signal/commit/ff9ae1ca04156e8b811899ff0f62480e1c37af72))
* **fsm:** new state context type with {to, from, by} ([11423e6](https://github.com/AliMD/alwatr-signal/commit/11423e6a89159b92e82cfd1e774ad37983581090))
* **fsm:** rewrite with signal power ([01a1651](https://github.com/AliMD/alwatr-signal/commit/01a1651e231a817d5eebb54cf84d51d620bfd6e8))
* **fsm:** share state events ([de42522](https://github.com/AliMD/alwatr-signal/commit/de42522a97fdf6be8bee73d91a35820e2a5e6efb))
* **fsm:** transition with partial context set ([823377e](https://github.com/AliMD/alwatr-signal/commit/823377e65028ea3e713f060ae678776c609c1661))
- Alwatr Finite State Machines ([d5900b4](https://github.com/AliMD/alwatr-signal/commit/d5900b4ee8685b120188888871405853f5a69417))
- **fsm:** $all and $self state ([69adf41](https://github.com/AliMD/alwatr-signal/commit/69adf41064ca0f55497484c50e298ebc26c42dcc))
- **fsm:** enhance types ([3b13046](https://github.com/AliMD/alwatr-signal/commit/3b130463a102f59c38603b0de470be5c87ee88c9))
- **fsm:** make simple state machine ([ff9ae1c](https://github.com/AliMD/alwatr-signal/commit/ff9ae1ca04156e8b811899ff0f62480e1c37af72))
- **fsm:** new state context type with {to, from, by} ([11423e6](https://github.com/AliMD/alwatr-signal/commit/11423e6a89159b92e82cfd1e774ad37983581090))
- **fsm:** rewrite with signal power ([01a1651](https://github.com/AliMD/alwatr-signal/commit/01a1651e231a817d5eebb54cf84d51d620bfd6e8))
- **fsm:** share state events ([de42522](https://github.com/AliMD/alwatr-signal/commit/de42522a97fdf6be8bee73d91a35820e2a5e6efb))
- **fsm:** transition with partial context set ([823377e](https://github.com/AliMD/alwatr-signal/commit/823377e65028ea3e713f060ae678776c609c1661))

# [1.0.0](https://github.com/AliMD/alwatr-signal/compare/v0.32.0...v1.0.0) (2023-06-14)

Expand Down
20 changes: 10 additions & 10 deletions packages/fsm/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export abstract class FiniteStateMachineBase<S extends string, E extends string>

protected _initialState: S;

constructor(config: {name: string, loggerPrefix?: string, initialState: S}) {
constructor(config: {name: string; loggerPrefix?: string; initialState: S}) {
config.loggerPrefix ??= 'fsm';
super(config);
this._initialState = config.initialState;
Expand All @@ -53,20 +53,20 @@ export abstract class FiniteStateMachineBase<S extends string, E extends string>

if (toState == null) {
this._logger.incident?.(
'transition',
'invalid_target_state',
'Defined target state for this event not found in state config',
{
fromState,
event,
},
'transition',
'invalid_target_state',
'Defined target state for this event not found in state config',
{
fromState,
event,
},
);
return;
}

const eventDetail: StateEventDetail<S, E> = {from: fromState, event, to: toState};

if (await this._shouldTransition(eventDetail) !== true) return;
if ((await this._shouldTransition(eventDetail)) !== true) return;

this._notify(toState);

Expand All @@ -91,7 +91,7 @@ export abstract class FiniteStateMachineBase<S extends string, E extends string>
if (`_on_${eventDetail.from}_${eventDetail.event}` in this) {
this._$execAction(`_on_${eventDetail.from}_${eventDetail.event}`, eventDetail);
}
else {
else {
this._$execAction(`_on_all_${eventDetail.event}`, eventDetail);
}
}
Expand Down
26 changes: 13 additions & 13 deletions packages/server-context/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Bug Fixes

* **server-context:** convert some `super` to `this` ([3a79736](https://github.com/AliMD/alwatr-signal/commit/3a7973658daf2ee364aced0c7c4880041dfc9a1a))
* **server-context:** export `server-context` to use ([b71c9a5](https://github.com/AliMD/alwatr-signal/commit/b71c9a5efa35ac4b5e53fd5cd966277abd7ff592))
- **server-context:** convert some `super` to `this` ([3a79736](https://github.com/AliMD/alwatr-signal/commit/3a7973658daf2ee364aced0c7c4880041dfc9a1a))
- **server-context:** export `server-context` to use ([b71c9a5](https://github.com/AliMD/alwatr-signal/commit/b71c9a5efa35ac4b5e53fd5cd966277abd7ff592))

### Features

* **server-context:** AlwatrServerContext ([2ca976a](https://github.com/AliMD/alwatr-signal/commit/2ca976afd50b3022a264eef880274a9e1496056a))
* **server-context:** dynamic extra state/event type ([1cb6db1](https://github.com/AliMD/alwatr-signal/commit/1cb6db1573f9349edecdc7d73e66243cadea40d4))
- **server-context:** AlwatrServerContext ([2ca976a](https://github.com/AliMD/alwatr-signal/commit/2ca976afd50b3022a264eef880274a9e1496056a))
- **server-context:** dynamic extra state/event type ([1cb6db1](https://github.com/AliMD/alwatr-signal/commit/1cb6db1573f9349edecdc7d73e66243cadea40d4))

# 1.0.0 (2023-06-14)

Expand All @@ -43,23 +43,23 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline

### Bug Fixes

* **context:** compatible with new storage api ([5251ff0](https://github.com/AliMD/alwatr-signal/commit/5251ff005624720e091cdbc40e6b0142743428cb))
- **context:** compatible with new storage api ([5251ff0](https://github.com/AliMD/alwatr-signal/commit/5251ff005624720e091cdbc40e6b0142743428cb))

# 0.31.0 (2023-05-08)

### Bug Fixes

* build issues ([e1060bc](https://github.com/AliMD/alwatr-signal/commit/e1060bccbfe3c775c32b85e9b8eb601e48b2998c))
* **context:** merge request option issue ([e24e695](https://github.com/AliMD/alwatr-signal/commit/e24e695a8c25ab1dcb1c351a3ae0434e921610d0))
* new logger api ([9d83a7d](https://github.com/AliMD/alwatr-signal/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
* packages and refs ([eea2382](https://github.com/AliMD/alwatr-signal/commit/eea2382e459ccaa3e7b4b329d9c196eda146a08e))
- build issues ([e1060bc](https://github.com/AliMD/alwatr-signal/commit/e1060bccbfe3c775c32b85e9b8eb601e48b2998c))
- **context:** merge request option issue ([e24e695](https://github.com/AliMD/alwatr-signal/commit/e24e695a8c25ab1dcb1c351a3ae0434e921610d0))
- new logger api ([9d83a7d](https://github.com/AliMD/alwatr-signal/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
- packages and refs ([eea2382](https://github.com/AliMD/alwatr-signal/commit/eea2382e459ccaa3e7b4b329d9c196eda146a08e))

### Features

* **context:** add `requestIfNotComplete` ([580d5c9](https://github.com/AliMD/alwatr-signal/commit/580d5c9c74f1c8921b45d402641df9444f438547))
* **context:** awesome server context ([c001c58](https://github.com/AliMD/alwatr-signal/commit/c001c58a2b1b4e13fd1c34b5128031fd640a98e1))
* **context:** new package ([98ee43d](https://github.com/AliMD/alwatr-signal/commit/98ee43d83b1ad5b3806ec6053c5cac70912000b3))
* **context:** simple context api ([2a1b152](https://github.com/AliMD/alwatr-signal/commit/2a1b152380f267a6b173f08bbbe10295325b1fd8))
- **context:** add `requestIfNotComplete` ([580d5c9](https://github.com/AliMD/alwatr-signal/commit/580d5c9c74f1c8921b45d402641df9444f438547))
- **context:** awesome server context ([c001c58](https://github.com/AliMD/alwatr-signal/commit/c001c58a2b1b4e13fd1c34b5128031fd640a98e1))
- **context:** new package ([98ee43d](https://github.com/AliMD/alwatr-signal/commit/98ee43d83b1ad5b3806ec6053c5cac70912000b3))
- **context:** simple context api ([2a1b152](https://github.com/AliMD/alwatr-signal/commit/2a1b152380f267a6b173f08bbbe10295325b1fd8))

# [1.0.0](https://github.com/AliMD/alwatr-signal/compare/v0.32.0...v1.0.0) (2023-06-14)

Expand Down
2 changes: 1 addition & 1 deletion packages/server-context/src/api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {AlwatrServiceResponse} from '@alwatr/type';
export abstract class AlwatrApiRequestBase<
T extends AlwatrServiceResponse = AlwatrServiceResponse,
ExtraState extends string = never,
ExtraEvent extends string = never
ExtraEvent extends string = never,
> extends AlwatrServerRequestBase<ExtraState, ExtraEvent> {
protected _responseJson?: T;

Expand Down
4 changes: 2 additions & 2 deletions packages/server-context/src/server-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ExtraEvent = 'cacheNotFound';
export type ServerContextEvent = ServerRequestEvent | ExtraEvent;

export abstract class AlwatrServerContextBase<
T extends AlwatrServiceResponse = AlwatrServiceResponse
T extends AlwatrServiceResponse = AlwatrServiceResponse,
> extends AlwatrApiRequestBase<T, ExtraState, ExtraEvent> {
protected _context?: T;
constructor(protected override _config: ServerRequestConfig) {
Expand Down Expand Up @@ -126,7 +126,7 @@ export abstract class AlwatrServerContextBase<
}

export class AlwatrServerContext<
T extends AlwatrServiceResponse = AlwatrServiceResponse
T extends AlwatrServiceResponse = AlwatrServiceResponse,
> extends AlwatrServerContextBase<T> {
/**
* Current state.
Expand Down
2 changes: 1 addition & 1 deletion packages/server-context/src/server-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type ServerRequestEvent = 'request' | 'requestFailed' | 'requestSuccess';

export abstract class AlwatrServerRequestBase<
ExtraState extends string = never,
ExtraEvent extends string = never
ExtraEvent extends string = never,
> extends FiniteStateMachineBase<ServerRequestState | ExtraState, ServerRequestEvent | ExtraEvent> {
protected _$fetchOptions?: FetchOptions;
protected _response?: Response;
Expand Down
Loading

0 comments on commit 3da84da

Please sign in to comment.