jssm 5.119.0 → 5.120.2
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 +66 -7
- package/dist/cdn/viz.js +1 -1
- package/dist/cli/fsl-render.cjs +9 -0
- package/dist/cli/fsl.cjs +8 -0
- package/dist/deno/README.md +66 -7
- package/dist/deno/jssm.js +1 -1
- package/dist/jssm.es5.cjs +1 -1
- package/dist/jssm.es5.iife.js +1 -1
- package/dist/jssm.es6.mjs +1 -1
- package/dist/jssm_viz.cjs +1 -1
- package/dist/jssm_viz.iife.cjs +1 -1
- package/dist/jssm_viz.mjs +1 -1
- package/package.json +35 -19
package/dist/cli/fsl.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var fs=require("fs");var path=require("path");var child_process=require("child_process");var _a;const IS_WINDOWS=process.platform==="win32";const PATH_SEP=IS_WINDOWS?";":":";const PATHEXT=IS_WINDOWS?((_a=process.env.PATHEXT)!==null&&_a!==void 0?_a:".COM;.EXE;.BAT;.CMD").split(";").map(s=>s.toLowerCase()):[""];async function findPluginOnPath(subcommand,pathEnv=process.env.PATH){if(!pathEnv)return null;const dirs=pathEnv.split(PATH_SEP).filter(d=>d.length>0);const baseName=`fsl-${subcommand}`;const NODE_EXTS=[".cjs",".mjs",".js"];const exts=IS_WINDOWS?[...PATHEXT,...NODE_EXTS]:["",...NODE_EXTS];for(const dir of dirs){for(const ext of exts){const candidate=path.join(dir,baseName+ext);try{const st=await fs.promises.stat(candidate);if(st.isFile())return candidate}catch(_a){}}}return null}function isInProcessEligible(resolvedPath){const ext=path.extname(resolvedPath).toLowerCase();if(ext!==".js"&&ext!==".mjs"&&ext!==".cjs")return false;const norm=resolvedPath.replace(/\\/g,"/");return norm.includes("/node_modules/")}async function invokeInProcess(pluginPath,argv){var _a,_b;const originalExit=process.exit;const originalArgv=process.argv;let interceptedExit=null;const ExitInterception=Symbol("ExitInterception");process.exit=code=>{interceptedExit=typeof code==="number"?code:0;throw ExitInterception};process.argv=[originalArgv[0],pluginPath,...argv];let result;try{const mod=await import(pluginPath);const cli=mod&&((_a=mod.default)!==null&&_a!==void 0?_a:mod);if(typeof cli!=="function"){process.stderr.write(`fsl: error: plugin ${pluginPath} is missing default cli() export\n`);result=2}else{const r=await cli(argv);result=typeof r==="number"?r:0}}catch(e){if(e===ExitInterception){result=interceptedExit}else{process.stderr.write(`fsl: error: plugin threw: ${(_b=e.message)!==null&&_b!==void 0?_b:String(e)}\n`);result=2}}process.exit=originalExit;process.argv=originalArgv;return result}async function invokeBySpawn(pluginPath,argv){return new Promise(res=>{const ext=path.extname(pluginPath).toLowerCase();const isCmdScript=IS_WINDOWS&&(ext===".cmd"||ext===".bat");const isNodeScript=ext===".cjs"||ext===".mjs"||ext===".js";const[spawnCmd,spawnArgs]=isCmdScript?["cmd.exe",["/c",pluginPath,...argv]]:isNodeScript?[process.execPath,[pluginPath,...argv]]:[pluginPath,argv];const child=child_process.spawn(spawnCmd,spawnArgs,{stdio:"inherit"});child.on("exit",code=>res(code));child.on("error",err=>{process.stderr.write(`fsl: error: failed to spawn plugin: ${err.message}\n`);res(2)})})}const RESERVED_FLAGS=new Set(["--help","-h","--version","-V"]);const RESERVED_NAMES=new Set(["help","version"]);const getDispatcherVersion=()=>"5.120.2";const printDispatcherHelp=()=>{process.stdout.write(`fsl — finite-state language toolchain dispatcher\n\nUsage:\n fsl <subcommand> [options] [args...]\n fsl [--help|--version]\n\nBuilt-in subcommands (resolved via PATH):\n render Render FSL machines to SVG, DOT, PNG, JPEG, or HTML\n\nDiscovery:\n Any \`fsl-<name>\` executable on PATH is dispatched when you run\n \`fsl <name>\`. Third-party plugins follow the same contract as\n first-party ones.\n\n See: https://github.com/StoneCypher/jssm\n`)};async function dispatch(argv){let verbose=false;if(argv[0]==="--verbose"){verbose=true;argv=argv.slice(1)}if(argv.length===0||RESERVED_FLAGS.has(argv[0])){if(argv[0]==="--version"||argv[0]==="-V"){process.stdout.write(`fsl ${getDispatcherVersion()}\n`);return 0}printDispatcherHelp();return 0}const subcommand=argv[0];const rest=argv.slice(1);if(RESERVED_NAMES.has(subcommand)){if(subcommand==="version"){process.stdout.write(`fsl ${getDispatcherVersion()}\n`);return 0}printDispatcherHelp();return 0}const pluginPath=await findPluginOnPath(subcommand);if(!pluginPath){process.stderr.write(`fsl: '${subcommand}' is not a known subcommand and no \`fsl-${subcommand}\` was found on PATH\n`);return 1}if(verbose){process.stderr.write(`fsl: resolved '${subcommand}' to ${pluginPath}\n`)}if(isInProcessEligible(pluginPath)){return invokeInProcess(pluginPath,rest)}return invokeBySpawn(pluginPath,rest)}
|
|
3
|
+
/**
|
|
4
|
+
* Binary entry for `fsl` (and its alias `jssm`). Forwards argv to
|
|
5
|
+
* `dispatch()` and exits with the returned code.
|
|
6
|
+
*
|
|
7
|
+
* The shebang (`#!/usr/bin/env node`) is added by rollup at build time.
|
|
8
|
+
*/async function main(){const argv=process.argv.slice(2);const code=await dispatch(argv);process.exit(code)}void main();
|
package/dist/deno/README.md
CHANGED
|
@@ -18,10 +18,10 @@ Please edit the file it's derived from, instead: `./src/md/readme_base.md`
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
* Generated for version 5.
|
|
21
|
+
* Generated for version 5.120.2 at 5/16/2026, 5:12:50 PM
|
|
22
22
|
|
|
23
23
|
-->
|
|
24
|
-
# jssm 5.
|
|
24
|
+
# jssm 5.120.2
|
|
25
25
|
|
|
26
26
|
[**Try the live editor**](https://stonecypher.github.io/jssm-viz-demo/graph_explorer.html) ·
|
|
27
27
|
[Documentation](https://stonecypher.github.io/jssm/docs/) ·
|
|
@@ -120,6 +120,65 @@ usage patterns.
|
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
|
|
123
|
+
<br/>
|
|
124
|
+
|
|
125
|
+
## Command-line interface
|
|
126
|
+
|
|
127
|
+
`jssm` ships a CLI for rendering FSL machines to images and other formats.
|
|
128
|
+
|
|
129
|
+
### Installation
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
npm install -g jssm
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
This installs three binaries: `fsl` (the dispatcher), `jssm` (alias for `fsl`), and `fsl-render` (the render plugin).
|
|
136
|
+
|
|
137
|
+
### Render
|
|
138
|
+
|
|
139
|
+
Render a single machine to SVG (default):
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
fsl render machine.fsl
|
|
143
|
+
# → machine.svg next to input
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Specify a format:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
fsl render machine.fsl --target=png --width=800
|
|
150
|
+
fsl render machine.fsl --target=dot --stdout > machine.dot
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Render multiple machines:
|
|
154
|
+
|
|
155
|
+
```sh
|
|
156
|
+
fsl render *.fsl --target=svg --out-dir=./diagrams
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Pipe FSL via stdin:
|
|
160
|
+
|
|
161
|
+
```sh
|
|
162
|
+
cat machine.fsl | fsl render --target=dot | dot -Tpng > out.png
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Plugin architecture
|
|
166
|
+
|
|
167
|
+
Every `fsl-<name>` executable on PATH is dispatched when you run `fsl <name>`. Third-party plugins follow the same contract as first-party `fsl-render`. See `notes/superpowers/specs/2026-05-12-fsl-cli-design.md` for the contract.
|
|
168
|
+
|
|
169
|
+
### Library API
|
|
170
|
+
|
|
171
|
+
The same render functions are available programmatically:
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
import { render, renderSet } from 'jssm/cli';
|
|
175
|
+
|
|
176
|
+
const result = await render(fslText, { target: 'svg' });
|
|
177
|
+
if (result.kind === 'text') console.log(result.content);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
123
182
|
<br/>
|
|
124
183
|
|
|
125
184
|
## Web Components
|
|
@@ -222,7 +281,7 @@ That decision shows up everywhere downstream:
|
|
|
222
281
|
or run `npm run benny` against your own machine.
|
|
223
282
|
|
|
224
283
|
- **More thoroughly tested than any other JavaScript state-machine
|
|
225
|
-
library.** 5,
|
|
284
|
+
library.** 5,990 tests at 100.0% line coverage
|
|
226
285
|
([report](https://coveralls.io/github/StoneCypher/jssm)), plus
|
|
227
286
|
fuzz testing via `fast-check`, with parser test data across ten natural
|
|
228
287
|
languages and Emoji.
|
|
@@ -355,11 +414,11 @@ If your contribution is missing here, please open an issue.
|
|
|
355
414
|
|
|
356
415
|
<br/>
|
|
357
416
|
|
|
358
|
-
***5,
|
|
417
|
+
***5,990 tests***, run 56,777 times.
|
|
359
418
|
|
|
360
|
-
- 5,
|
|
361
|
-
- 513 fuzz tests with
|
|
362
|
-
-
|
|
419
|
+
- 5,477 specs with 100.0% coverage
|
|
420
|
+
- 513 fuzz tests with 20.2% coverage
|
|
421
|
+
- 4,280 TypeScript lines - 1.4 tests per line, 13.3 generated tests per line
|
|
363
422
|
|
|
364
423
|
[](https://github.com/StoneCypher/jssm/actions)
|
|
365
424
|
[](https://www.npmjs.com/package/jssm)
|