@mr-aftab-ahmad-khan/statemesh 0.1.0

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 ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - Initial public release.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aftab Ahmad Khan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # statemesh
2
+
3
+ **Topics:** `fsm` · `mern-packages` · `merndev` · `nodejs` · `npm-pm` · `observability` · `statemesh` · `typescript` · `workflow`
4
+
5
+ statemesh — Minimal finite state machine with transitions. See `src/index.ts` for the public API surface.
6
+
7
+ ## License
8
+
9
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ StateMesh: () => StateMesh,
24
+ statemesh: () => statemesh
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+ var StateMesh = class {
28
+ constructor(def, st) {
29
+ this.def = def;
30
+ this.st = st;
31
+ }
32
+ def;
33
+ st;
34
+ get state() {
35
+ return this.st;
36
+ }
37
+ async send(ev) {
38
+ const next = this.def.transitions[this.st]?.[ev];
39
+ if (!next) throw new Error("statemesh: illegal " + ev);
40
+ this.st = next;
41
+ }
42
+ };
43
+ var statemesh = (d) => new StateMesh(d, d.initial);
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ StateMesh,
47
+ statemesh
48
+ });
49
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export interface SMDef<S extends string, E extends string> { initial: S; transitions: Record<S, Partial<Record<E, S>>>; }\nexport class StateMesh<S extends string, E extends string> {\nconstructor(private def: SMDef<S,E>, private st: S) {}\nget state(){return this.st}\nasync send(ev: E){ const next=this.def.transitions[this.st]?.[ev]; if(!next)throw new Error(\"statemesh: illegal \"+ev); this.st=next; }\n}\nexport const statemesh = <S extends string, E extends string>(d: SMDef<S,E>) => new StateMesh(d, d.initial);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,IAAM,YAAN,MAAoD;AAAA,EAC3D,YAAoB,KAAyB,IAAO;AAAhC;AAAyB;AAAA,EAAQ;AAAA,EAAjC;AAAA,EAAyB;AAAA,EAC7C,IAAI,QAAO;AAAC,WAAO,KAAK;AAAA,EAAE;AAAA,EAC1B,MAAM,KAAK,IAAM;AAAE,UAAM,OAAK,KAAK,IAAI,YAAY,KAAK,EAAE,IAAI,EAAE;AAAG,QAAG,CAAC,KAAK,OAAM,IAAI,MAAM,wBAAsB,EAAE;AAAG,SAAK,KAAG;AAAA,EAAM;AACrI;AACO,IAAM,YAAY,CAAqC,MAAkB,IAAI,UAAU,GAAG,EAAE,OAAO;","names":[]}
@@ -0,0 +1,14 @@
1
+ interface SMDef<S extends string, E extends string> {
2
+ initial: S;
3
+ transitions: Record<S, Partial<Record<E, S>>>;
4
+ }
5
+ declare class StateMesh<S extends string, E extends string> {
6
+ private def;
7
+ private st;
8
+ constructor(def: SMDef<S, E>, st: S);
9
+ get state(): S;
10
+ send(ev: E): Promise<void>;
11
+ }
12
+ declare const statemesh: <S extends string, E extends string>(d: SMDef<S, E>) => StateMesh<S, E>;
13
+
14
+ export { type SMDef, StateMesh, statemesh };
@@ -0,0 +1,14 @@
1
+ interface SMDef<S extends string, E extends string> {
2
+ initial: S;
3
+ transitions: Record<S, Partial<Record<E, S>>>;
4
+ }
5
+ declare class StateMesh<S extends string, E extends string> {
6
+ private def;
7
+ private st;
8
+ constructor(def: SMDef<S, E>, st: S);
9
+ get state(): S;
10
+ send(ev: E): Promise<void>;
11
+ }
12
+ declare const statemesh: <S extends string, E extends string>(d: SMDef<S, E>) => StateMesh<S, E>;
13
+
14
+ export { type SMDef, StateMesh, statemesh };
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ // src/index.ts
2
+ var StateMesh = class {
3
+ constructor(def, st) {
4
+ this.def = def;
5
+ this.st = st;
6
+ }
7
+ def;
8
+ st;
9
+ get state() {
10
+ return this.st;
11
+ }
12
+ async send(ev) {
13
+ const next = this.def.transitions[this.st]?.[ev];
14
+ if (!next) throw new Error("statemesh: illegal " + ev);
15
+ this.st = next;
16
+ }
17
+ };
18
+ var statemesh = (d) => new StateMesh(d, d.initial);
19
+ export {
20
+ StateMesh,
21
+ statemesh
22
+ };
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export interface SMDef<S extends string, E extends string> { initial: S; transitions: Record<S, Partial<Record<E, S>>>; }\nexport class StateMesh<S extends string, E extends string> {\nconstructor(private def: SMDef<S,E>, private st: S) {}\nget state(){return this.st}\nasync send(ev: E){ const next=this.def.transitions[this.st]?.[ev]; if(!next)throw new Error(\"statemesh: illegal \"+ev); this.st=next; }\n}\nexport const statemesh = <S extends string, E extends string>(d: SMDef<S,E>) => new StateMesh(d, d.initial);\n"],"mappings":";AACO,IAAM,YAAN,MAAoD;AAAA,EAC3D,YAAoB,KAAyB,IAAO;AAAhC;AAAyB;AAAA,EAAQ;AAAA,EAAjC;AAAA,EAAyB;AAAA,EAC7C,IAAI,QAAO;AAAC,WAAO,KAAK;AAAA,EAAE;AAAA,EAC1B,MAAM,KAAK,IAAM;AAAE,UAAM,OAAK,KAAK,IAAI,YAAY,KAAK,EAAE,IAAI,EAAE;AAAG,QAAG,CAAC,KAAK,OAAM,IAAI,MAAM,wBAAsB,EAAE;AAAG,SAAK,KAAG;AAAA,EAAM;AACrI;AACO,IAAM,YAAY,CAAqC,MAAkB,IAAI,UAAU,GAAG,EAAE,OAAO;","names":[]}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@mr-aftab-ahmad-khan/statemesh",
3
+ "version": "0.1.0",
4
+ "description": "statemesh — Minimal finite state machine with transitions.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE",
21
+ "CHANGELOG.md"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsup",
25
+ "test": "vitest run",
26
+ "typecheck": "tsc --noEmit",
27
+ "prepublishOnly": "npm run build"
28
+ },
29
+ "keywords": [
30
+ "fsm",
31
+ "mern-packages",
32
+ "merndev",
33
+ "nodejs",
34
+ "npm-pm",
35
+ "observability",
36
+ "statemesh",
37
+ "typescript",
38
+ "workflow"
39
+ ],
40
+ "devDependencies": {
41
+ "@types/node": "^20.11.0",
42
+ "tsup": "^8.0.0",
43
+ "typescript": "^5.4.0",
44
+ "vitest": "^1.4.0"
45
+ },
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "author": "Aftab Ahmad Khan (https://github.com/aftab-ahmad-khan-dev)",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/NPM-Packages-Modules/mern.git",
53
+ "directory": "statemesh"
54
+ },
55
+ "bugs": {
56
+ "url": "https://github.com/NPM-Packages-Modules/mern/issues"
57
+ },
58
+ "homepage": "https://github.com/NPM-Packages-Modules/mern/tree/main/statemesh",
59
+ "publishConfig": {
60
+ "access": "public"
61
+ }
62
+ }