@praxisjs/fsm 0.1.1 → 0.2.1
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 +26 -0
- package/dist/decorators.d.ts +2 -4
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +11 -24
- package/dist/decorators.js.map +1 -1
- package/dist/machine.d.ts.map +1 -1
- package/dist/machine.js +1 -1
- package/dist/machine.js.map +1 -1
- package/package.json +3 -3
- package/src/decorators.ts +12 -30
- package/src/machine.ts +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @praxisjs/fsm
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [f52354d]
|
|
8
|
+
- @praxisjs/core@0.4.0
|
|
9
|
+
|
|
10
|
+
## 0.2.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- bb0d4f8: **Refactor decorator system and component architecture across PraxisJS packages**
|
|
15
|
+
|
|
16
|
+
- Replaced legacy decorator signatures (`constructor`, `target`, `propertyKey`, method descriptor) with the standard TC39 decorator context API (`ClassDecoratorContext`, `ClassFieldDecoratorContext`, `ClassMethodDecoratorContext`) across `@praxisjs/decorators`, `@praxisjs/store`, `@praxisjs/concurrent`, `@praxisjs/router`, `@praxisjs/motion`, `@praxisjs/di`, and `@praxisjs/fsm`.
|
|
17
|
+
- Introduced `StatefulComponent` and `StatelessComponent` as the new base classes, replacing the deprecated `BaseComponent`/`Function Component` pattern, across `@praxisjs/core`, `@praxisjs/runtime`, `@praxisjs/devtools`, and templates.
|
|
18
|
+
- Implemented core rendering functionality in `@praxisjs/runtime` (`mountChildren`, `mountComponent`, reactive scope management) and removed the deprecated `renderer.ts`.
|
|
19
|
+
- Refactored `@praxisjs/jsx` to delegate rendering to `@praxisjs/runtime` and improved type safety with `flattenChildren` and `isComponent` utilities.
|
|
20
|
+
- Updated internal module structure with new `internal` exports in `package.json` files for shared utilities and types.
|
|
21
|
+
- Removed `experimentalDecorators`/`emitDecoratorMetadata` from `tsconfig.json` in favor of native decorator support.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [bb0d4f8]
|
|
26
|
+
- @praxisjs/core@0.3.0
|
|
27
|
+
- @praxisjs/shared@0.2.0
|
|
28
|
+
|
|
3
29
|
## 0.1.1
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/decorators.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { type MachineDefinition } from "./machine";
|
|
2
|
-
export declare function Transition(machineProp: string, event: string): (
|
|
3
|
-
export declare function StateMachine<S extends string, E extends string>(definition: MachineDefinition<S, E>, propertyKey?: string): (
|
|
4
|
-
prototype: object;
|
|
5
|
-
}) => void;
|
|
2
|
+
export declare function Transition(machineProp: string, event: string): (value: (...args: unknown[]) => unknown, _context: ClassMethodDecoratorContext) => (...args: unknown[]) => unknown;
|
|
3
|
+
export declare function StateMachine<S extends string, E extends string>(definition: MachineDefinition<S, E>, propertyKey?: string): (value: abstract new (...args: unknown[]) => unknown, _context: ClassDecoratorContext) => void;
|
|
6
4
|
//# sourceMappingURL=decorators.d.ts.map
|
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEhF,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,IAEzD,
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEhF,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,IAEzD,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACtC,UAAU,2BAA2B,KACpC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAUnC;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC7D,UAAU,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,EACnC,WAAW,SAAY,IAEN,OAAO,QAAQ,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,UAAU,qBAAqB,KAAG,IAAI,CAW7G"}
|
package/dist/decorators.js
CHANGED
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
import { createMachine } from "./machine";
|
|
2
2
|
export function Transition(machineProp, event) {
|
|
3
|
-
return function (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
console.warn(`[Transition] "${machineProp}" is not a state machine.`);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (machine.send(event))
|
|
16
|
-
return original.apply(this, args);
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(this, methodKey, {
|
|
19
|
-
value: bound,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true,
|
|
22
|
-
});
|
|
23
|
-
return bound;
|
|
24
|
-
},
|
|
3
|
+
return function (value, _context) {
|
|
4
|
+
return function (...args) {
|
|
5
|
+
const machine = this[machineProp];
|
|
6
|
+
if (!machine) {
|
|
7
|
+
console.warn(`[Transition] "${machineProp}" is not a state machine.`);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (machine.send(event))
|
|
11
|
+
return value.apply(this, args);
|
|
25
12
|
};
|
|
26
13
|
};
|
|
27
14
|
}
|
|
28
15
|
export function StateMachine(definition, propertyKey = "machine") {
|
|
29
|
-
return function (
|
|
16
|
+
return function (value, _context) {
|
|
30
17
|
const machines = new WeakMap();
|
|
31
|
-
Object.defineProperty(
|
|
18
|
+
Object.defineProperty(value.prototype, propertyKey, {
|
|
32
19
|
get() {
|
|
33
20
|
if (!machines.has(this))
|
|
34
21
|
machines.set(this, createMachine(definition));
|
package/dist/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAwC,MAAM,WAAW,CAAC;AAEhF,MAAM,UAAU,UAAU,CAAC,WAAmB,EAAE,KAAa;IAC3D,OAAO,UACL,
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAwC,MAAM,WAAW,CAAC;AAEhF,MAAM,UAAU,UAAU,CAAC,WAAmB,EAAE,KAAa;IAC3D,OAAO,UACL,KAAsC,EACtC,QAAqC;QAErC,OAAO,UAAyC,GAAG,IAAe;YAChE,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAwC,CAAC;YACzE,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CAAC,iBAAiB,WAAW,2BAA2B,CAAC,CAAC;gBACtE,OAAO;YACT,CAAC;YACD,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC1D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,UAAmC,EACnC,WAAW,GAAG,SAAS;IAEvB,OAAO,UAAU,KAAmD,EAAE,QAA+B;QACnG,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAyB,CAAC;QACtD,MAAM,CAAC,cAAc,CAAE,KAA+B,CAAC,SAAS,EAAE,WAAW,EAAE;YAC7E,GAAG;gBACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;oBAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;gBACvE,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAkB,CAAC;YAC7C,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/machine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,MAAM,CAC/D,CAAC,EACD;IACE,EAAE,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CACF,CAAC;AAEF,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM;IACnE,OAAO,EAAE,CAAC,CAAC;IACX,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC;CACnD;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM;IACzD,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACnB,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,CAAC,CAAC;QAAC,EAAE,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IACxB,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IACvB,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IACtB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC9D,UAAU,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAClC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CA8Bf"}
|
package/dist/machine.js
CHANGED
package/dist/machine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machine.js","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"machine.js","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AA2B3D,MAAM,UAAU,aAAa,CAC3B,UAAmC;IAEnC,MAAM,MAAM,GAAG,MAAM,CAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,MAAM,CAAs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U,CAAC,OAAO,CAAC,CAAC;YAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACjB,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@praxisjs/fsm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"typescript": "^5.9.3"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@praxisjs/core": "0.
|
|
18
|
-
"@praxisjs/shared": "0.
|
|
17
|
+
"@praxisjs/core": "0.4.0",
|
|
18
|
+
"@praxisjs/shared": "0.2.0"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "tsc",
|
package/src/decorators.ts
CHANGED
|
@@ -2,34 +2,16 @@ import { createMachine, type Machine, type MachineDefinition } from "./machine";
|
|
|
2
2
|
|
|
3
3
|
export function Transition(machineProp: string, event: string) {
|
|
4
4
|
return function (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const machine = this[machineProp] as
|
|
16
|
-
| Machine<string, string>
|
|
17
|
-
| undefined;
|
|
18
|
-
if (!machine) {
|
|
19
|
-
console.warn(
|
|
20
|
-
`[Transition] "${machineProp}" is not a state machine.`,
|
|
21
|
-
);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (machine.send(event)) return original.apply(this, args);
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(this, methodKey, {
|
|
27
|
-
value: bound,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true,
|
|
30
|
-
});
|
|
31
|
-
return bound;
|
|
32
|
-
},
|
|
5
|
+
value: (...args: unknown[]) => unknown,
|
|
6
|
+
_context: ClassMethodDecoratorContext,
|
|
7
|
+
): (...args: unknown[]) => unknown {
|
|
8
|
+
return function (this: Record<string, unknown>, ...args: unknown[]) {
|
|
9
|
+
const machine = this[machineProp] as Machine<string, string> | undefined;
|
|
10
|
+
if (!machine) {
|
|
11
|
+
console.warn(`[Transition] "${machineProp}" is not a state machine.`);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (machine.send(event)) return value.apply(this, args);
|
|
33
15
|
};
|
|
34
16
|
};
|
|
35
17
|
}
|
|
@@ -38,9 +20,9 @@ export function StateMachine<S extends string, E extends string>(
|
|
|
38
20
|
definition: MachineDefinition<S, E>,
|
|
39
21
|
propertyKey = "machine",
|
|
40
22
|
) {
|
|
41
|
-
return function (
|
|
23
|
+
return function (value: abstract new (...args: unknown[]) => unknown, _context: ClassDecoratorContext): void {
|
|
42
24
|
const machines = new WeakMap<object, Machine<S, E>>();
|
|
43
|
-
Object.defineProperty(
|
|
25
|
+
Object.defineProperty((value as { prototype: object }).prototype, propertyKey, {
|
|
44
26
|
get(this: object): Machine<S, E> {
|
|
45
27
|
if (!machines.has(this)) machines.set(this, createMachine(definition));
|
|
46
28
|
return machines.get(this) as Machine<S, E>;
|
package/src/machine.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { signal, computed } from "@praxisjs/core";
|
|
1
|
+
import { signal, computed } from "@praxisjs/core/internal";
|
|
2
2
|
import type { Computed } from "@praxisjs/shared";
|
|
3
3
|
|
|
4
|
-
export type StateMap<S extends string, E extends string> = Record<
|
|
4
|
+
export type StateMap<S extends string, E extends string> = Record<
|
|
5
|
+
S,
|
|
6
|
+
{
|
|
5
7
|
on?: Partial<Record<E, S>>;
|
|
6
8
|
onEnter?: () => void;
|
|
7
9
|
onExit?: () => void;
|
|
8
|
-
}
|
|
10
|
+
}
|
|
11
|
+
>;
|
|
9
12
|
|
|
10
13
|
export interface MachineDefinition<S extends string, E extends string> {
|
|
11
14
|
initial: S;
|