scjson 0.3.2 → 0.3.5
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/README.md +37 -1
- package/dist/harness.d.ts +8 -0
- package/dist/harness.js +96 -0
- package/dist/scjsonProps.d.ts +2 -2
- package/dist/scjsonProps.js +2 -2
- package/package.json +23 -4
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<p align="center"><img src="https://raw.githubusercontent.com/SoftOboros/scjson/main/scjson.png" alt="scjson logo" width="200"/></p>
|
|
2
|
+
|
|
1
3
|
# scjson JavaScript Package
|
|
2
4
|
|
|
3
5
|
This directory contains the JavaScript implementation of **scjson**, a format for representing SCXML state machines in JSON. The package provides a command line interface to convert between `.scxml` and `.scjson` files and to validate documents against the project's schema.
|
|
@@ -45,6 +47,40 @@ scjson xml path/to/machine.scjson
|
|
|
45
47
|
scjson validate path/to/dir -r
|
|
46
48
|
```
|
|
47
49
|
|
|
50
|
+
## Harness CLI (SCION)
|
|
51
|
+
|
|
52
|
+
The package also ships a harness CLI that executes SCXML using the SCION engine
|
|
53
|
+
and emits JSONL traces compatible with compare tooling.
|
|
54
|
+
|
|
55
|
+
Install peer dependency:
|
|
56
|
+
```bash
|
|
57
|
+
npm i scion-core
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Usage:
|
|
61
|
+
```bash
|
|
62
|
+
npx scjson-scion-trace -I path/to/chart.(scxml|scjson) -e path/to/events.jsonl [--xml]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Quick check (from this repo):
|
|
66
|
+
```bash
|
|
67
|
+
cd js
|
|
68
|
+
npm ci
|
|
69
|
+
npm run harness:sample
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Flags:
|
|
73
|
+
- `--leaf-only` – emit leaf-only configurations (SCION already reports atomic states)
|
|
74
|
+
- `--omit-delta` – clear `datamodelDelta`
|
|
75
|
+
- `--omit-transitions` – clear `firedTransitions`
|
|
76
|
+
- `--strip-step0-noise` – at step 0, clear `datamodelDelta` and `firedTransitions`
|
|
77
|
+
- `--strip-step0-states` – at step 0, clear `enteredStates` and `exitedStates`
|
|
78
|
+
|
|
79
|
+
Notes:
|
|
80
|
+
- `.scjson` input is converted to SCXML internally before execution.
|
|
81
|
+
- SCION does not model time; `{"advance_time": N}` control tokens emit a
|
|
82
|
+
synthetic step to keep streams progressing.
|
|
83
|
+
|
|
48
84
|
## Conversion Functions
|
|
49
85
|
```js
|
|
50
86
|
/**
|
|
@@ -329,4 +365,4 @@ docker pull iraa/scjson:latest
|
|
|
329
365
|
```
|
|
330
366
|
|
|
331
367
|
|
|
332
|
-
All source code in this directory is released under the BSD
|
|
368
|
+
All source code in this directory is released under the BSD 1-Clause license. See [LICENSE](./LICENSE) and [LEGAL.md](./LEGAL.md) for details.
|
package/dist/harness.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent Name: js-scion-harness
|
|
4
|
+
*
|
|
5
|
+
* Part of the scjson project.
|
|
6
|
+
* Developed by Softoboros Technology Inc.
|
|
7
|
+
* Licensed under the BSD 1-Clause License.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const node_child_process_1 = require("node:child_process");
|
|
11
|
+
const node_readline_1 = require("node:readline");
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
13
|
+
function parseArgs(argv) {
|
|
14
|
+
const norm = {
|
|
15
|
+
leafOnly: false,
|
|
16
|
+
omitDelta: false,
|
|
17
|
+
omitTransitions: false,
|
|
18
|
+
stripStep0Noise: false,
|
|
19
|
+
stripStep0States: false,
|
|
20
|
+
};
|
|
21
|
+
const pass = [];
|
|
22
|
+
for (let i = 0; i < argv.length; i++) {
|
|
23
|
+
const a = argv[i];
|
|
24
|
+
switch (a) {
|
|
25
|
+
case '--leaf-only':
|
|
26
|
+
norm.leafOnly = true;
|
|
27
|
+
break;
|
|
28
|
+
case '--omit-delta':
|
|
29
|
+
norm.omitDelta = true;
|
|
30
|
+
break;
|
|
31
|
+
case '--omit-transitions':
|
|
32
|
+
norm.omitTransitions = true;
|
|
33
|
+
break;
|
|
34
|
+
case '--strip-step0-noise':
|
|
35
|
+
norm.stripStep0Noise = true;
|
|
36
|
+
break;
|
|
37
|
+
case '--strip-step0-states':
|
|
38
|
+
norm.stripStep0States = true;
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
pass.push(a);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { pass, norm };
|
|
46
|
+
}
|
|
47
|
+
function normalizeStep(obj, norm) {
|
|
48
|
+
if (!obj || typeof obj !== 'object')
|
|
49
|
+
return obj;
|
|
50
|
+
const out = { ...obj };
|
|
51
|
+
const step = typeof out.step === 'number' ? out.step : -1;
|
|
52
|
+
if (norm.omitDelta)
|
|
53
|
+
out.datamodelDelta = {};
|
|
54
|
+
if (norm.omitTransitions)
|
|
55
|
+
out.firedTransitions = [];
|
|
56
|
+
if (step === 0 && norm.stripStep0Noise) {
|
|
57
|
+
out.datamodelDelta = {};
|
|
58
|
+
out.firedTransitions = [];
|
|
59
|
+
}
|
|
60
|
+
if (step === 0 && norm.stripStep0States) {
|
|
61
|
+
out.enteredStates = [];
|
|
62
|
+
out.exitedStates = [];
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
async function main() {
|
|
67
|
+
const argv = process.argv.slice(2);
|
|
68
|
+
const { pass, norm } = parseArgs(argv);
|
|
69
|
+
const runner = (0, node_path_1.resolve)(__dirname, '../../tools/scion-runner/scion-trace.cjs');
|
|
70
|
+
const runPipe = (cmd, args) => new Promise((resolve) => {
|
|
71
|
+
const proc = (0, node_child_process_1.spawn)(cmd, args, { stdio: ['inherit', 'pipe', 'inherit'] });
|
|
72
|
+
const rl = (0, node_readline_1.createInterface)({ input: proc.stdout });
|
|
73
|
+
let failed = false;
|
|
74
|
+
rl.on('line', (line) => {
|
|
75
|
+
const s = line.trim();
|
|
76
|
+
if (!s)
|
|
77
|
+
return;
|
|
78
|
+
try {
|
|
79
|
+
const obj = JSON.parse(s);
|
|
80
|
+
const normed = normalizeStep(obj, norm);
|
|
81
|
+
process.stdout.write(JSON.stringify(normed) + '\n');
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
failed = true;
|
|
85
|
+
process.stderr.write(String(e) + '\n');
|
|
86
|
+
process.stdout.write(line + '\n');
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
proc.on('close', (code) => resolve(code !== null && code !== void 0 ? code : (failed ? 1 : 0)));
|
|
90
|
+
});
|
|
91
|
+
const code = await runPipe('node', [runner, ...pass]);
|
|
92
|
+
if (code !== 0) {
|
|
93
|
+
await runPipe('python', ['-m', 'scjson.cli', 'engine-trace', ...pass]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
void main();
|
package/dist/scjsonProps.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Agent Name: ts-props
|
|
3
3
|
*
|
|
4
4
|
* Part of the scjson project.
|
|
5
5
|
* Developed by Softoboros Technology Inc.
|
|
6
6
|
* Licensed under the BSD 1-Clause License.
|
|
7
|
-
|
|
7
|
+
*/
|
|
8
8
|
/**
|
|
9
9
|
* update a datamodel location with an expression or value.
|
|
10
10
|
*/
|
package/dist/scjsonProps.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Agent Name: ts-props
|
|
4
4
|
*
|
|
5
5
|
* Part of the scjson project.
|
|
6
6
|
* Developed by Softoboros Technology Inc.
|
|
7
7
|
* Licensed under the BSD 1-Clause License.
|
|
8
|
-
|
|
8
|
+
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.TransitionTypeDatatypeProps = exports.defaultTransition = exports.defaultState = exports.defaultSend = exports.defaultScxml = exports.defaultScript = exports.defaultRaise = exports.defaultParam = exports.defaultParallel = exports.defaultOnexit = exports.defaultOnentry = exports.defaultLog = exports.defaultInvoke = exports.defaultInitial = exports.defaultIf = exports.HistoryTypeDatatypeProps = exports.defaultHistory = exports.defaultForeach = exports.defaultFinalize = exports.defaultFinal = exports.ExmodeDatatypeProps = exports.defaultElseif = exports.defaultElse = exports.defaultDonedata = exports.defaultDatamodel = exports.defaultData = exports.defaultContent = exports.defaultCancel = exports.BooleanDatatypeProps = exports.BindingDatatypeProps = exports.AssignTypeDatatypeProps = exports.defaultAssign = void 0;
|
|
11
11
|
/** Instantiate a default object of type AssignProps */
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scjson",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "A JSON-based serialization of SCXML (State Chart XML).",
|
|
3
|
+
"version": "0.3.5",
|
|
4
|
+
"description": "A JSON-based serialization of SCXML (State Chart XML) with SCXML/SCML execution tooling and converters.",
|
|
5
5
|
"author": "Softoboros Technology Inc. <ira@softoboros.com>",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/SoftOboros/scjson"
|
|
9
|
+
},
|
|
6
10
|
"license": "BSD-1-Clause",
|
|
7
11
|
"main": "dist/index.js",
|
|
8
12
|
"types": "dist/index.d.ts",
|
|
@@ -37,12 +41,24 @@
|
|
|
37
41
|
"LICENSE"
|
|
38
42
|
],
|
|
39
43
|
"bin": {
|
|
40
|
-
"scjson": "bin/scjson.js"
|
|
44
|
+
"scjson": "bin/scjson.js",
|
|
45
|
+
"scjson-scion-trace": "dist/harness.js"
|
|
41
46
|
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"scxml",
|
|
49
|
+
"statecharts",
|
|
50
|
+
"state-machine",
|
|
51
|
+
"scjson",
|
|
52
|
+
"scml",
|
|
53
|
+
"execution"
|
|
54
|
+
],
|
|
42
55
|
"scripts": {
|
|
43
56
|
"build": "tsc",
|
|
57
|
+
"postbuild": "node ../tools/scion-runner/extract.cjs",
|
|
44
58
|
"test": "jest",
|
|
45
|
-
"lint": "eslint"
|
|
59
|
+
"lint": "eslint",
|
|
60
|
+
"harness:sample": "node dist/harness.js -I ../tests/exec/toggle.scxml -e ../tests/exec/toggle.events.jsonl --xml --leaf-only --omit-delta --strip-step0-noise",
|
|
61
|
+
"ci:harness": "npm run build && npm run harness:sample"
|
|
46
62
|
},
|
|
47
63
|
"dependencies": {
|
|
48
64
|
"ajv": "^8.17.1",
|
|
@@ -50,6 +66,9 @@
|
|
|
50
66
|
"eslint": "^9.31.0",
|
|
51
67
|
"fast-xml-parser": "^5.2.5"
|
|
52
68
|
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"scion-core": "^2.6.0"
|
|
71
|
+
},
|
|
53
72
|
"devDependencies": {
|
|
54
73
|
"@babel/parser": "^7.28.0",
|
|
55
74
|
"@babel/types": "^7.28.2",
|