Skip to content

Commit ff05502

Browse files
committed
Distribution package
1 parent 1dfd92d commit ff05502

File tree

18 files changed

+44
-45
lines changed

18 files changed

+44
-45
lines changed

VERSION

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
PureMVC Typescript Utility - State Machine
22
--------------------------------------------------------------------------
3-
Release Date: 2/24/25
3+
Release Date: 4/13/25
44
Platform: Typescript
5-
Version: 1
5+
Version: 1
66
Revision: 0
7-
Authors: Neil Manuell <neil.manuell@puremvc.org>
8-
: Cliff Hall <cliff.hall@puremvc.org>
7+
Minor: 0
8+
Authors: Cliff Hall <cliff.hall@puremvc.org>
9+
: Neil Manuell <neil.manuell@puremvc.org>
910
--------------------------------------------------------------------------
1011

11-
1.0 Initial port from the AS3 source.
12+
1.0.0 Initial port from the AS3 source.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ class FSMInjector extends puremvc_typescript_multicore_framework_1.Notifier {
1313
}
1414
inject() {
1515
const stateMachine = new StateMachine_1.StateMachine();
16+
stateMachine.initializeNotifier(this.multitonKey);
1617
for (const state of this.states) {
1718
stateMachine.registerState(state, this.isInitial(state.name));
1819
}
1920
// Register the StateMachine with the facade
2021
this.facade.registerMediator(stateMachine);
22+
return stateMachine;
2123
}
2224
get states() {
23-
if (this.stateList == null) {
25+
if (this.stateList === null) {
2426
this.stateList = [];
2527
for (const stateDef of this.fsmConfig.states) {
2628
const state = this.createState(stateDef);
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ class State {
1010
this.changed = changed || null;
1111
}
1212
defineTransition(action, target) {
13-
if (this.getTarget(action) != null)
13+
if (this.getTarget(action) !== undefined)
1414
return;
1515
this.transitions[action] = target;
1616
}
17-
removeTransition(action) {
18-
this.transitions[action] = undefined;
19-
}
2017
getTarget(action) {
2118
return action ? this.transitions[action] : undefined;
2219
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ class StateMachine extends puremvc_typescript_multicore_framework_1.Mediator {
1515
this.transitionTo(this.initial, null);
1616
}
1717
registerState(state, initial = false) {
18-
if (state == null || this.states[state.name] != null)
18+
if (state === null || this.states[state.name] != null)
1919
return;
2020
this.states[state.name] = state;
2121
if (initial)
2222
this.initial = state;
2323
}
24+
getState(name) {
25+
return this.states[name];
26+
}
2427
removeState(stateName) {
2528
const state = this.states[stateName];
26-
if (state == null)
29+
if (state === null)
2730
return;
2831
delete this.states[stateName];
2932
}
@@ -47,7 +50,7 @@ class StateMachine extends puremvc_typescript_multicore_framework_1.Mediator {
4750
}
4851
this.currentState = nextState;
4952
if (nextState.changed) {
50-
if (this.currentState.changed != null) {
53+
if (this.currentState.changed !== null) {
5154
this.sendNotification(this.currentState.changed, data);
5255
}
5356
}
@@ -74,9 +77,6 @@ class StateMachine extends puremvc_typescript_multicore_framework_1.Mediator {
7477
get viewComponent() {
7578
return this.currentState;
7679
}
77-
set viewComponent(state) {
78-
this.currentState = state;
79-
}
8080
}
8181
exports.StateMachine = StateMachine;
8282
StateMachine.NAME = "StateMachine";

bin/cjs/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
exports.State = exports.FSMInjector = exports.StateMachine = void 0;
4-
var StateMachine_1 = require("./StateMachine");
4+
var StateMachine_1 = require("./fsm/StateMachine");
55
Object.defineProperty(exports, "StateMachine", { enumerable: true, get: function () { return StateMachine_1.StateMachine; } });
6-
var FSMInjector_1 = require("./FSMInjector");
6+
var FSMInjector_1 = require("./fsm/FSMInjector");
77
Object.defineProperty(exports, "FSMInjector", { enumerable: true, get: function () { return FSMInjector_1.FSMInjector; } });
8-
var State_1 = require("./State");
8+
var State_1 = require("./fsm/State");
99
Object.defineProperty(exports, "State", { enumerable: true, get: function () { return State_1.State; } });
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ export class FSMInjector extends Notifier {
1010
}
1111
inject() {
1212
const stateMachine = new StateMachine();
13+
stateMachine.initializeNotifier(this.multitonKey);
1314
for (const state of this.states) {
1415
stateMachine.registerState(state, this.isInitial(state.name));
1516
}
1617
// Register the StateMachine with the facade
1718
this.facade.registerMediator(stateMachine);
19+
return stateMachine;
1820
}
1921
get states() {
20-
if (this.stateList == null) {
22+
if (this.stateList === null) {
2123
this.stateList = [];
2224
for (const stateDef of this.fsmConfig.states) {
2325
const state = this.createState(stateDef);
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ export class State {
77
this.changed = changed || null;
88
}
99
defineTransition(action, target) {
10-
if (this.getTarget(action) != null)
10+
if (this.getTarget(action) !== undefined)
1111
return;
1212
this.transitions[action] = target;
1313
}
14-
removeTransition(action) {
15-
this.transitions[action] = undefined;
16-
}
1714
getTarget(action) {
1815
return action ? this.transitions[action] : undefined;
1916
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ export class StateMachine extends Mediator {
1212
this.transitionTo(this.initial, null);
1313
}
1414
registerState(state, initial = false) {
15-
if (state == null || this.states[state.name] != null)
15+
if (state === null || this.states[state.name] != null)
1616
return;
1717
this.states[state.name] = state;
1818
if (initial)
1919
this.initial = state;
2020
}
21+
getState(name) {
22+
return this.states[name];
23+
}
2124
removeState(stateName) {
2225
const state = this.states[stateName];
23-
if (state == null)
26+
if (state === null)
2427
return;
2528
delete this.states[stateName];
2629
}
@@ -44,7 +47,7 @@ export class StateMachine extends Mediator {
4447
}
4548
this.currentState = nextState;
4649
if (nextState.changed) {
47-
if (this.currentState.changed != null) {
50+
if (this.currentState.changed !== null) {
4851
this.sendNotification(this.currentState.changed, data);
4952
}
5053
}
@@ -71,9 +74,6 @@ export class StateMachine extends Mediator {
7174
get viewComponent() {
7275
return this.currentState;
7376
}
74-
set viewComponent(state) {
75-
this.currentState = state;
76-
}
7777
}
7878
StateMachine.NAME = "StateMachine";
7979
StateMachine.ACTION = StateMachine.NAME + "/notes/action";

bin/esm/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { StateMachine } from "./StateMachine";
2-
export { FSMInjector } from "./FSMInjector";
3-
export { State } from "./State";
1+
export { StateMachine } from "./fsm/StateMachine";
2+
export { FSMInjector } from "./fsm/FSMInjector";
3+
export { State } from "./fsm/State";
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { Notifier } from "@puremvc/puremvc-typescript-multicore-framework";
22
import { State } from "./State";
3-
import { FSM, StateDef } from "./types";
3+
import { StateMachine } from "./StateMachine";
4+
import { FSM, StateDef } from "../types";
45
export declare class FSMInjector extends Notifier {
56
private fsmConfig;
67
private stateList;
78
constructor(multitonKey: string, fsmConfig: FSM);
8-
inject(): void;
9+
inject(): StateMachine;
910
protected get states(): State[];
1011
protected createState(stateDef: StateDef): State;
1112
protected isInitial(stateName: string): boolean;

0 commit comments

Comments
 (0)