state-machine-cat 15.0.1 → 15.0.3-beta-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/README.md +7 -7
- package/dist/cli/actions.mjs +15 -3
- package/dist/cli/file-name-to-stream.mjs +3 -3
- package/dist/parse/smcat/smcat-parser.mjs +404 -231
- package/dist/parse/smcat-ast.validate.mjs +1 -1
- package/dist/render/dot/index.mjs +8 -6
- package/dist/render/dot/utl.mjs +15 -6
- package/dist/version.mjs +1 -1
- package/package.json +3 -3
- package/types/state-machine-cat.d.mts +1 -1
package/README.md
CHANGED
|
@@ -38,10 +38,10 @@ To enable me to make state charts ...
|
|
|
38
38
|
|
|
39
39
|
- ... that look _good_
|
|
40
40
|
- ... with the least effort possible
|
|
41
|
-
- ...
|
|
41
|
+
- ... without having to interact with drag and drop tools. Entering text
|
|
42
42
|
is fine, doing my own layout is not.
|
|
43
43
|
- ... without having to dive into GraphViz `dot` each time. GraphViz is cool,
|
|
44
|
-
but
|
|
44
|
+
but was not designed to write & maintain conceptual documents in
|
|
45
45
|
(_You'll know what I'm talking about if you ever tried to get it to draw nested nodes. Or edges between those._ )
|
|
46
46
|
|
|
47
47
|
## Usage
|
|
@@ -88,7 +88,7 @@ smcat -T dot docs/sample.smcat -o - | dot -T svg -odoc/sample.svg
|
|
|
88
88
|
Leaving the options at the default settings usually deliver the best
|
|
89
89
|
results already, so if they bewilder you: don't worry.
|
|
90
90
|
|
|
91
|
-
When you pass the `--desugar` (
|
|
91
|
+
When you pass the `--desugar` (experimental) switch, state-machine-cat will,
|
|
92
92
|
before rendering, transform some pseudo states into transitions - see
|
|
93
93
|
[de-sugaring state machines](docs/desugar.md) for details.
|
|
94
94
|
|
|
@@ -371,7 +371,7 @@ a => Aahnohd: [hit by meteorite];
|
|
|
371
371
|
- Labels have the same restriction as activities, except they allow for `,` too.
|
|
372
372
|
- State declaration precedence is: deep wins from shallow; explicit wins from
|
|
373
373
|
implicit
|
|
374
|
-
- It's possible to declare the same state multiple times on the same level,
|
|
374
|
+
- It's possible to declare the same state multiple times on the same level, but
|
|
375
375
|
smcat will take the last declaration into account only. For example:
|
|
376
376
|
|
|
377
377
|
This
|
|
@@ -471,7 +471,7 @@ playing => playing: ingest food;
|
|
|
471
471
|
playing => playing [type=internal]: ingest drink;
|
|
472
472
|
```
|
|
473
473
|
|
|
474
|
-
<img width="346" alt="internal transition" src="docs/pics/13internal_transition.png">
|
|
474
|
+
<img width="346" alt="internal transition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/13internal_transition.png">
|
|
475
475
|
|
|
476
476
|
#### marking states _active_
|
|
477
477
|
|
|
@@ -534,7 +534,7 @@ As of version 7.4.0 you can use the keyword `class` as an extended keyword on
|
|
|
534
534
|
both states and transitions. When you render `svg` or `dot` you'll see what you
|
|
535
535
|
entered there in the output in the `class` attributes of their respective
|
|
536
536
|
elements, along with the type of element (either 'state' or 'transition') and
|
|
537
|
-
optionally the type of state or
|
|
537
|
+
optionally the type of state or transition (e.g. for state: 'initial', 'regular',
|
|
538
538
|
'final' etc.).
|
|
539
539
|
|
|
540
540
|
For example, this ...
|
|
@@ -638,7 +638,7 @@ The values you can use for the `type` of a state:
|
|
|
638
638
|
#### grammar
|
|
639
639
|
|
|
640
640
|
I made the parser with peggy - you can find it at
|
|
641
|
-
[src/parse/smcat-parser.peggy](src/parse/smcat/smcat-parser.peggy), and
|
|
641
|
+
[src/parse/smcat/smcat-parser.peggy](src/parse/smcat/smcat-parser.peggy), and
|
|
642
642
|
railroad diagrams generated from these on [state-machine-cat.js.org/grammar.html](https://state-machine-cat.js.org/grammar.html)
|
|
643
643
|
|
|
644
644
|
## Status
|
package/dist/cli/actions.mjs
CHANGED
|
@@ -27,16 +27,28 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
27
27
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
|
|
29
29
|
`;
|
|
30
|
+
const MAX_INPUT_BYTES = 4_194_304;
|
|
31
|
+
const ONE_MEGA_BYTE = 1_048_576;
|
|
30
32
|
function getStream(pStream) {
|
|
31
33
|
return new Promise((pResolve, pReject) => {
|
|
32
|
-
let
|
|
34
|
+
let lInputString = "";
|
|
35
|
+
let lInputLength = 0;
|
|
33
36
|
pStream
|
|
34
37
|
.on("data", (pChunk) => {
|
|
35
|
-
|
|
38
|
+
lInputLength += Buffer.byteLength(pChunk);
|
|
39
|
+
if (lInputLength > MAX_INPUT_BYTES) {
|
|
40
|
+
pStream.destroy(
|
|
41
|
+
new Error(
|
|
42
|
+
`\n Input exceeds maximum sane size of ${Math.round(MAX_INPUT_BYTES / ONE_MEGA_BYTE)} Mb. Cowardly refusing to continue.\n`,
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
} else {
|
|
46
|
+
lInputString += pChunk;
|
|
47
|
+
}
|
|
36
48
|
})
|
|
37
49
|
.on("error", pReject)
|
|
38
50
|
.on("end", () => {
|
|
39
|
-
pResolve(
|
|
51
|
+
pResolve(lInputString);
|
|
40
52
|
});
|
|
41
53
|
});
|
|
42
54
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createReadStream, createWriteStream } from "node:fs";
|
|
2
2
|
export function getOutStream(pOutputTo) {
|
|
3
3
|
if ("-" === pOutputTo) {
|
|
4
4
|
return process.stdout;
|
|
5
5
|
}
|
|
6
|
-
return
|
|
6
|
+
return createWriteStream(pOutputTo);
|
|
7
7
|
}
|
|
8
8
|
export function getInStream(pInputFrom) {
|
|
9
9
|
if ("-" === pInputFrom) {
|
|
10
10
|
return process.stdin;
|
|
11
11
|
}
|
|
12
|
-
return
|
|
12
|
+
return createReadStream(pInputFrom);
|
|
13
13
|
}
|