jssm 5.113.0 → 5.119.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/README.md +31 -7
- package/custom-elements.json +138 -0
- package/dist/cdn/viz.js +24901 -0
- package/dist/deno/README.md +31 -7
- package/dist/deno/jssm.d.ts +70 -5
- package/dist/deno/jssm.js +1 -1
- package/dist/deno/jssm_constants.d.ts +58 -1
- package/dist/deno/jssm_viz.d.ts +57 -7
- package/dist/deno/version.d.ts +13 -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/dist/wc/viz.define.js +6 -0
- package/dist/wc/viz.js +135 -0
- package/jssm.es5.d.cts +143 -4
- package/jssm.es6.d.ts +143 -4
- package/jssm_viz.es5.d.cts +127 -10
- package/jssm_viz.es6.d.ts +127 -10
- package/package.json +36 -6
package/jssm_viz.es5.d.cts
CHANGED
|
@@ -546,7 +546,18 @@ declare type JssmHistory<mDT> = circular_buffer<[StateType$1, mDT]>;
|
|
|
546
546
|
*/
|
|
547
547
|
declare type JssmRng = () => number;
|
|
548
548
|
|
|
549
|
+
/**
|
|
550
|
+
* The published semantic version of the jssm package this build was cut from.
|
|
551
|
+
* Mirrored from `package.json` by `src/buildjs/makever.cjs` at build time.
|
|
552
|
+
* Useful for runtime diagnostics and for embedding in serialized machine
|
|
553
|
+
* snapshots so that deserializers can detect version-skew.
|
|
554
|
+
*/
|
|
549
555
|
declare const version: string;
|
|
556
|
+
/**
|
|
557
|
+
* The Unix epoch timestamp (in milliseconds) at which this build was produced,
|
|
558
|
+
* written by `src/buildjs/makever.cjs`. Useful for distinguishing builds
|
|
559
|
+
* with the same `version` string during development, and for diagnostic logs.
|
|
560
|
+
*/
|
|
550
561
|
declare const build_time: number;
|
|
551
562
|
|
|
552
563
|
declare type StateType = string;
|
|
@@ -1177,6 +1188,49 @@ declare class Machine<mDT> {
|
|
|
1177
1188
|
* @returns An array of theme name strings.
|
|
1178
1189
|
*/
|
|
1179
1190
|
all_themes(): FslTheme[];
|
|
1191
|
+
/** List the character ranges accepted by the FSL grammar in any but the
|
|
1192
|
+
* first position of a state name (atom). Each entry is an inclusive
|
|
1193
|
+
* `{from, to}` range of single Unicode characters.
|
|
1194
|
+
*
|
|
1195
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1196
|
+
*
|
|
1197
|
+
* @example
|
|
1198
|
+
* const m = sm`a -> b;`;
|
|
1199
|
+
* m.all_state_name_chars().some(r => '+' >= r.from && '+' <= r.to); // true
|
|
1200
|
+
*/
|
|
1201
|
+
all_state_name_chars(): ReadonlyArray<{
|
|
1202
|
+
from: string;
|
|
1203
|
+
to: string;
|
|
1204
|
+
}>;
|
|
1205
|
+
/** List the character ranges accepted by the FSL grammar in the first
|
|
1206
|
+
* position of a state name (atom). Narrower than
|
|
1207
|
+
* {@link all_state_name_chars}: notably omits `+`, `(`, `)`, `&`, `#`, `@`.
|
|
1208
|
+
*
|
|
1209
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1210
|
+
*
|
|
1211
|
+
* @example
|
|
1212
|
+
* const m = sm`a -> b;`;
|
|
1213
|
+
* m.all_state_name_first_chars().some(r => '+' >= r.from && '+' <= r.to); // false
|
|
1214
|
+
*/
|
|
1215
|
+
all_state_name_first_chars(): ReadonlyArray<{
|
|
1216
|
+
from: string;
|
|
1217
|
+
to: string;
|
|
1218
|
+
}>;
|
|
1219
|
+
/** List the character ranges accepted inside a single-quoted FSL action
|
|
1220
|
+
* label without escaping. Space is allowed; the apostrophe `'` is
|
|
1221
|
+
* explicitly excluded since it terminates the label.
|
|
1222
|
+
*
|
|
1223
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1224
|
+
*
|
|
1225
|
+
* @example
|
|
1226
|
+
* const m = sm`a -> b;`;
|
|
1227
|
+
* m.all_action_label_chars().some(r => ' ' >= r.from && ' ' <= r.to); // true
|
|
1228
|
+
* m.all_action_label_chars().some(r => "'" >= r.from && "'" <= r.to); // false
|
|
1229
|
+
*/
|
|
1230
|
+
all_action_label_chars(): ReadonlyArray<{
|
|
1231
|
+
from: string;
|
|
1232
|
+
to: string;
|
|
1233
|
+
}>;
|
|
1180
1234
|
/** Get the active theme(s) for this machine. Always stored as an array
|
|
1181
1235
|
* internally; the union return type exists for setter compatibility.
|
|
1182
1236
|
* @returns The current theme or array of themes.
|
|
@@ -1270,10 +1324,23 @@ declare class Machine<mDT> {
|
|
|
1270
1324
|
*
|
|
1271
1325
|
*/
|
|
1272
1326
|
list_exits(whichState?: StateType): Array<StateType>;
|
|
1273
|
-
/** Get the transitions available from a state
|
|
1274
|
-
*
|
|
1327
|
+
/** Get the transitions available from a state for use by the probabilistic
|
|
1328
|
+
* walk system.
|
|
1329
|
+
*
|
|
1330
|
+
* If any exit declares a `probability`, only those probability-bearing
|
|
1331
|
+
* exits are returned, so that non-probability peers cannot dilute the
|
|
1332
|
+
* declared distribution. If no exit declares a `probability`, every
|
|
1333
|
+
* legal (non-forced) exit is returned, which `weighted_rand_select`
|
|
1334
|
+
* treats as equal weight. Forced-only exits (`~>`) are always excluded,
|
|
1335
|
+
* since they cannot be taken by an ordinary `transition()` call.
|
|
1336
|
+
*
|
|
1337
|
+
* Fixes StoneCypher/fsl#1325, in which the function previously returned
|
|
1338
|
+
* every exit unconditionally — including forced-only exits and exits
|
|
1339
|
+
* with no `probability`, which distorted the weighted distribution.
|
|
1340
|
+
*
|
|
1275
1341
|
* @param whichState - The state to inspect.
|
|
1276
|
-
* @returns An array of {@link JssmTransition} edges exiting the state
|
|
1342
|
+
* @returns An array of {@link JssmTransition} edges exiting the state,
|
|
1343
|
+
* filtered as described above. May be empty.
|
|
1277
1344
|
* @throws {JssmError} If the state does not exist.
|
|
1278
1345
|
*/
|
|
1279
1346
|
probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
|
|
@@ -2252,30 +2319,49 @@ declare function style_for_state<T>(u_jssm: Machine<T>, state: string): string;
|
|
|
2252
2319
|
/**
|
|
2253
2320
|
* Render a {@link jssm.Machine} as a graphviz dot string.
|
|
2254
2321
|
*
|
|
2322
|
+
* An optional `footer` may be supplied via `opts.footer`; it is emitted
|
|
2323
|
+
* verbatim just before the closing `}` of the dot source, after all
|
|
2324
|
+
* arrange declarations. This is a function-argument-only feature for
|
|
2325
|
+
* the moment — a machine-attribute equivalent is planned as a follow-up.
|
|
2326
|
+
*
|
|
2255
2327
|
* ```typescript
|
|
2256
2328
|
* import { sm } from 'jssm';
|
|
2257
2329
|
* import { machine_to_dot } from 'jssm/viz';
|
|
2258
2330
|
*
|
|
2259
2331
|
* const dot = machine_to_dot(sm`a -> b;`);
|
|
2260
2332
|
* // 'digraph G { ... }'
|
|
2333
|
+
*
|
|
2334
|
+
* const dot_with_footer = machine_to_dot(sm`a -> b;`, { footer: 'labelloc="b"; label="caption";' });
|
|
2335
|
+
* // 'digraph G { ... labelloc="b"; label="caption"; }'
|
|
2261
2336
|
* ```
|
|
2262
2337
|
*
|
|
2263
2338
|
* @param u_jssm The machine to render.
|
|
2339
|
+
* @param opts Optional rendering options.
|
|
2340
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}`.
|
|
2264
2341
|
* @returns A complete graphviz dot source string.
|
|
2265
2342
|
*/
|
|
2266
|
-
declare function machine_to_dot<T>(u_jssm: Machine<T
|
|
2343
|
+
declare function machine_to_dot<T>(u_jssm: Machine<T>, opts?: {
|
|
2344
|
+
footer?: string;
|
|
2345
|
+
}): string;
|
|
2267
2346
|
/**
|
|
2268
2347
|
* Render an FSL string directly to graphviz dot source.
|
|
2269
2348
|
*
|
|
2270
2349
|
* ```typescript
|
|
2271
2350
|
* import { fsl_to_dot } from 'jssm/viz';
|
|
2272
2351
|
* const dot = fsl_to_dot('a -> b;');
|
|
2352
|
+
*
|
|
2353
|
+
* const dot_with_footer = fsl_to_dot('a -> b;', { footer: 'label="caption";' });
|
|
2354
|
+
* // 'digraph G { ... label="caption"; }'
|
|
2273
2355
|
* ```
|
|
2274
2356
|
*
|
|
2275
2357
|
* @param fsl The FSL source.
|
|
2358
|
+
* @param opts Optional rendering options.
|
|
2359
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}`.
|
|
2276
2360
|
* @returns A complete graphviz dot source string.
|
|
2277
2361
|
*/
|
|
2278
|
-
declare function fsl_to_dot(fsl: string
|
|
2362
|
+
declare function fsl_to_dot(fsl: string, opts?: {
|
|
2363
|
+
footer?: string;
|
|
2364
|
+
}): string;
|
|
2279
2365
|
/**
|
|
2280
2366
|
* Render a graphviz dot source string to SVG using `@viz-js/viz`. The
|
|
2281
2367
|
* underlying viz instance is lazy-initialized on first call and cached for
|
|
@@ -2283,42 +2369,73 @@ declare function fsl_to_dot(fsl: string): string;
|
|
|
2283
2369
|
*
|
|
2284
2370
|
* ```typescript
|
|
2285
2371
|
* const svg = await dot_to_svg('digraph G { a -> b }');
|
|
2372
|
+
* const svg_neato = await dot_to_svg('digraph G { a -> b }', { engine: 'neato' });
|
|
2286
2373
|
* ```
|
|
2287
2374
|
*
|
|
2288
2375
|
* @param dot Graphviz dot source.
|
|
2376
|
+
* @param options Optional renderer overrides.
|
|
2377
|
+
* @param options.engine Graphviz layout engine to use (e.g. `'dot'`,
|
|
2378
|
+
* `'neato'`, `'circo'`). Unrecognized engine names cause `@viz-js/viz`
|
|
2379
|
+
* to throw at render time.
|
|
2289
2380
|
* @returns A promise resolving to an SVG XML string.
|
|
2290
2381
|
*/
|
|
2291
|
-
declare function dot_to_svg(dot: string
|
|
2382
|
+
declare function dot_to_svg(dot: string, options?: {
|
|
2383
|
+
engine?: string;
|
|
2384
|
+
}): Promise<string>;
|
|
2292
2385
|
/**
|
|
2293
2386
|
* Render an FSL string directly to SVG.
|
|
2294
2387
|
*
|
|
2388
|
+
* ```typescript
|
|
2389
|
+
* const svg = await fsl_to_svg_string('a -> b;');
|
|
2390
|
+
* const svg_neato = await fsl_to_svg_string('a -> b;', { engine: 'neato' });
|
|
2391
|
+
* ```
|
|
2392
|
+
*
|
|
2295
2393
|
* @param fsl The FSL source.
|
|
2394
|
+
* @param opts Optional rendering options.
|
|
2395
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}` of the intermediate dot source.
|
|
2396
|
+
* @param opts.engine Graphviz layout engine to use (e.g. `'dot'`, `'neato'`, `'circo'`).
|
|
2397
|
+
* Unrecognized engine names cause `@viz-js/viz` to throw at render time.
|
|
2296
2398
|
* @returns A promise resolving to an SVG XML string.
|
|
2297
2399
|
*/
|
|
2298
|
-
declare function fsl_to_svg_string(fsl: string
|
|
2400
|
+
declare function fsl_to_svg_string(fsl: string, opts?: {
|
|
2401
|
+
footer?: string;
|
|
2402
|
+
engine?: string;
|
|
2403
|
+
}): Promise<string>;
|
|
2299
2404
|
/**
|
|
2300
2405
|
* Render a {@link jssm.Machine} to SVG.
|
|
2301
2406
|
*
|
|
2302
2407
|
* @param u_jssm The machine to render.
|
|
2408
|
+
* @param opts Optional rendering options.
|
|
2409
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}` of the intermediate dot source.
|
|
2303
2410
|
* @returns A promise resolving to an SVG XML string.
|
|
2304
2411
|
*/
|
|
2305
|
-
declare function machine_to_svg_string<T>(u_jssm: Machine<T
|
|
2412
|
+
declare function machine_to_svg_string<T>(u_jssm: Machine<T>, opts?: {
|
|
2413
|
+
footer?: string;
|
|
2414
|
+
}): Promise<string>;
|
|
2306
2415
|
/**
|
|
2307
2416
|
* Render an FSL string directly to a parsed `SVGSVGElement`.
|
|
2308
2417
|
*
|
|
2309
2418
|
* @param fsl The FSL source.
|
|
2419
|
+
* @param opts Optional rendering options.
|
|
2420
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}` of the intermediate dot source.
|
|
2310
2421
|
* @returns A promise resolving to a parsed `SVGSVGElement`.
|
|
2311
2422
|
* @throws {JssmError} if no `DOMParser` is available (Node without `configure`).
|
|
2312
2423
|
*/
|
|
2313
|
-
declare function fsl_to_svg_element(fsl: string
|
|
2424
|
+
declare function fsl_to_svg_element(fsl: string, opts?: {
|
|
2425
|
+
footer?: string;
|
|
2426
|
+
}): Promise<SVGSVGElement>;
|
|
2314
2427
|
/**
|
|
2315
2428
|
* Render a {@link jssm.Machine} to a parsed `SVGSVGElement`.
|
|
2316
2429
|
*
|
|
2317
2430
|
* @param u_jssm The machine to render.
|
|
2431
|
+
* @param opts Optional rendering options.
|
|
2432
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}` of the intermediate dot source.
|
|
2318
2433
|
* @returns A promise resolving to a parsed `SVGSVGElement`.
|
|
2319
2434
|
* @throws {JssmError} if no `DOMParser` is available (Node without `configure`).
|
|
2320
2435
|
*/
|
|
2321
|
-
declare function machine_to_svg_element<T>(u_jssm: Machine<T
|
|
2436
|
+
declare function machine_to_svg_element<T>(u_jssm: Machine<T>, opts?: {
|
|
2437
|
+
footer?: string;
|
|
2438
|
+
}): Promise<SVGSVGElement>;
|
|
2322
2439
|
/**
|
|
2323
2440
|
* Compatibility wrapper for {@link machine_to_dot}, retained from
|
|
2324
2441
|
* jssm-viz. Will be removed in the next major.
|
package/jssm_viz.es6.d.ts
CHANGED
|
@@ -546,7 +546,18 @@ declare type JssmHistory<mDT> = circular_buffer<[StateType$1, mDT]>;
|
|
|
546
546
|
*/
|
|
547
547
|
declare type JssmRng = () => number;
|
|
548
548
|
|
|
549
|
+
/**
|
|
550
|
+
* The published semantic version of the jssm package this build was cut from.
|
|
551
|
+
* Mirrored from `package.json` by `src/buildjs/makever.cjs` at build time.
|
|
552
|
+
* Useful for runtime diagnostics and for embedding in serialized machine
|
|
553
|
+
* snapshots so that deserializers can detect version-skew.
|
|
554
|
+
*/
|
|
549
555
|
declare const version: string;
|
|
556
|
+
/**
|
|
557
|
+
* The Unix epoch timestamp (in milliseconds) at which this build was produced,
|
|
558
|
+
* written by `src/buildjs/makever.cjs`. Useful for distinguishing builds
|
|
559
|
+
* with the same `version` string during development, and for diagnostic logs.
|
|
560
|
+
*/
|
|
550
561
|
declare const build_time: number;
|
|
551
562
|
|
|
552
563
|
declare type StateType = string;
|
|
@@ -1177,6 +1188,49 @@ declare class Machine<mDT> {
|
|
|
1177
1188
|
* @returns An array of theme name strings.
|
|
1178
1189
|
*/
|
|
1179
1190
|
all_themes(): FslTheme[];
|
|
1191
|
+
/** List the character ranges accepted by the FSL grammar in any but the
|
|
1192
|
+
* first position of a state name (atom). Each entry is an inclusive
|
|
1193
|
+
* `{from, to}` range of single Unicode characters.
|
|
1194
|
+
*
|
|
1195
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1196
|
+
*
|
|
1197
|
+
* @example
|
|
1198
|
+
* const m = sm`a -> b;`;
|
|
1199
|
+
* m.all_state_name_chars().some(r => '+' >= r.from && '+' <= r.to); // true
|
|
1200
|
+
*/
|
|
1201
|
+
all_state_name_chars(): ReadonlyArray<{
|
|
1202
|
+
from: string;
|
|
1203
|
+
to: string;
|
|
1204
|
+
}>;
|
|
1205
|
+
/** List the character ranges accepted by the FSL grammar in the first
|
|
1206
|
+
* position of a state name (atom). Narrower than
|
|
1207
|
+
* {@link all_state_name_chars}: notably omits `+`, `(`, `)`, `&`, `#`, `@`.
|
|
1208
|
+
*
|
|
1209
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1210
|
+
*
|
|
1211
|
+
* @example
|
|
1212
|
+
* const m = sm`a -> b;`;
|
|
1213
|
+
* m.all_state_name_first_chars().some(r => '+' >= r.from && '+' <= r.to); // false
|
|
1214
|
+
*/
|
|
1215
|
+
all_state_name_first_chars(): ReadonlyArray<{
|
|
1216
|
+
from: string;
|
|
1217
|
+
to: string;
|
|
1218
|
+
}>;
|
|
1219
|
+
/** List the character ranges accepted inside a single-quoted FSL action
|
|
1220
|
+
* label without escaping. Space is allowed; the apostrophe `'` is
|
|
1221
|
+
* explicitly excluded since it terminates the label.
|
|
1222
|
+
*
|
|
1223
|
+
* @returns An array of `{from, to}` inclusive character ranges.
|
|
1224
|
+
*
|
|
1225
|
+
* @example
|
|
1226
|
+
* const m = sm`a -> b;`;
|
|
1227
|
+
* m.all_action_label_chars().some(r => ' ' >= r.from && ' ' <= r.to); // true
|
|
1228
|
+
* m.all_action_label_chars().some(r => "'" >= r.from && "'" <= r.to); // false
|
|
1229
|
+
*/
|
|
1230
|
+
all_action_label_chars(): ReadonlyArray<{
|
|
1231
|
+
from: string;
|
|
1232
|
+
to: string;
|
|
1233
|
+
}>;
|
|
1180
1234
|
/** Get the active theme(s) for this machine. Always stored as an array
|
|
1181
1235
|
* internally; the union return type exists for setter compatibility.
|
|
1182
1236
|
* @returns The current theme or array of themes.
|
|
@@ -1270,10 +1324,23 @@ declare class Machine<mDT> {
|
|
|
1270
1324
|
*
|
|
1271
1325
|
*/
|
|
1272
1326
|
list_exits(whichState?: StateType): Array<StateType>;
|
|
1273
|
-
/** Get the transitions available from a state
|
|
1274
|
-
*
|
|
1327
|
+
/** Get the transitions available from a state for use by the probabilistic
|
|
1328
|
+
* walk system.
|
|
1329
|
+
*
|
|
1330
|
+
* If any exit declares a `probability`, only those probability-bearing
|
|
1331
|
+
* exits are returned, so that non-probability peers cannot dilute the
|
|
1332
|
+
* declared distribution. If no exit declares a `probability`, every
|
|
1333
|
+
* legal (non-forced) exit is returned, which `weighted_rand_select`
|
|
1334
|
+
* treats as equal weight. Forced-only exits (`~>`) are always excluded,
|
|
1335
|
+
* since they cannot be taken by an ordinary `transition()` call.
|
|
1336
|
+
*
|
|
1337
|
+
* Fixes StoneCypher/fsl#1325, in which the function previously returned
|
|
1338
|
+
* every exit unconditionally — including forced-only exits and exits
|
|
1339
|
+
* with no `probability`, which distorted the weighted distribution.
|
|
1340
|
+
*
|
|
1275
1341
|
* @param whichState - The state to inspect.
|
|
1276
|
-
* @returns An array of {@link JssmTransition} edges exiting the state
|
|
1342
|
+
* @returns An array of {@link JssmTransition} edges exiting the state,
|
|
1343
|
+
* filtered as described above. May be empty.
|
|
1277
1344
|
* @throws {JssmError} If the state does not exist.
|
|
1278
1345
|
*/
|
|
1279
1346
|
probable_exits_for(whichState: StateType): Array<JssmTransition<StateType, mDT>>;
|
|
@@ -2252,30 +2319,49 @@ declare function style_for_state<T>(u_jssm: Machine<T>, state: string): string;
|
|
|
2252
2319
|
/**
|
|
2253
2320
|
* Render a {@link jssm.Machine} as a graphviz dot string.
|
|
2254
2321
|
*
|
|
2322
|
+
* An optional `footer` may be supplied via `opts.footer`; it is emitted
|
|
2323
|
+
* verbatim just before the closing `}` of the dot source, after all
|
|
2324
|
+
* arrange declarations. This is a function-argument-only feature for
|
|
2325
|
+
* the moment — a machine-attribute equivalent is planned as a follow-up.
|
|
2326
|
+
*
|
|
2255
2327
|
* ```typescript
|
|
2256
2328
|
* import { sm } from 'jssm';
|
|
2257
2329
|
* import { machine_to_dot } from 'jssm/viz';
|
|
2258
2330
|
*
|
|
2259
2331
|
* const dot = machine_to_dot(sm`a -> b;`);
|
|
2260
2332
|
* // 'digraph G { ... }'
|
|
2333
|
+
*
|
|
2334
|
+
* const dot_with_footer = machine_to_dot(sm`a -> b;`, { footer: 'labelloc="b"; label="caption";' });
|
|
2335
|
+
* // 'digraph G { ... labelloc="b"; label="caption"; }'
|
|
2261
2336
|
* ```
|
|
2262
2337
|
*
|
|
2263
2338
|
* @param u_jssm The machine to render.
|
|
2339
|
+
* @param opts Optional rendering options.
|
|
2340
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}`.
|
|
2264
2341
|
* @returns A complete graphviz dot source string.
|
|
2265
2342
|
*/
|
|
2266
|
-
declare function machine_to_dot<T>(u_jssm: Machine<T
|
|
2343
|
+
declare function machine_to_dot<T>(u_jssm: Machine<T>, opts?: {
|
|
2344
|
+
footer?: string;
|
|
2345
|
+
}): string;
|
|
2267
2346
|
/**
|
|
2268
2347
|
* Render an FSL string directly to graphviz dot source.
|
|
2269
2348
|
*
|
|
2270
2349
|
* ```typescript
|
|
2271
2350
|
* import { fsl_to_dot } from 'jssm/viz';
|
|
2272
2351
|
* const dot = fsl_to_dot('a -> b;');
|
|
2352
|
+
*
|
|
2353
|
+
* const dot_with_footer = fsl_to_dot('a -> b;', { footer: 'label="caption";' });
|
|
2354
|
+
* // 'digraph G { ... label="caption"; }'
|
|
2273
2355
|
* ```
|
|
2274
2356
|
*
|
|
2275
2357
|
* @param fsl The FSL source.
|
|
2358
|
+
* @param opts Optional rendering options.
|
|
2359
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}`.
|
|
2276
2360
|
* @returns A complete graphviz dot source string.
|
|
2277
2361
|
*/
|
|
2278
|
-
declare function fsl_to_dot(fsl: string
|
|
2362
|
+
declare function fsl_to_dot(fsl: string, opts?: {
|
|
2363
|
+
footer?: string;
|
|
2364
|
+
}): string;
|
|
2279
2365
|
/**
|
|
2280
2366
|
* Render a graphviz dot source string to SVG using `@viz-js/viz`. The
|
|
2281
2367
|
* underlying viz instance is lazy-initialized on first call and cached for
|
|
@@ -2283,42 +2369,73 @@ declare function fsl_to_dot(fsl: string): string;
|
|
|
2283
2369
|
*
|
|
2284
2370
|
* ```typescript
|
|
2285
2371
|
* const svg = await dot_to_svg('digraph G { a -> b }');
|
|
2372
|
+
* const svg_neato = await dot_to_svg('digraph G { a -> b }', { engine: 'neato' });
|
|
2286
2373
|
* ```
|
|
2287
2374
|
*
|
|
2288
2375
|
* @param dot Graphviz dot source.
|
|
2376
|
+
* @param options Optional renderer overrides.
|
|
2377
|
+
* @param options.engine Graphviz layout engine to use (e.g. `'dot'`,
|
|
2378
|
+
* `'neato'`, `'circo'`). Unrecognized engine names cause `@viz-js/viz`
|
|
2379
|
+
* to throw at render time.
|
|
2289
2380
|
* @returns A promise resolving to an SVG XML string.
|
|
2290
2381
|
*/
|
|
2291
|
-
declare function dot_to_svg(dot: string
|
|
2382
|
+
declare function dot_to_svg(dot: string, options?: {
|
|
2383
|
+
engine?: string;
|
|
2384
|
+
}): Promise<string>;
|
|
2292
2385
|
/**
|
|
2293
2386
|
* Render an FSL string directly to SVG.
|
|
2294
2387
|
*
|
|
2388
|
+
* ```typescript
|
|
2389
|
+
* const svg = await fsl_to_svg_string('a -> b;');
|
|
2390
|
+
* const svg_neato = await fsl_to_svg_string('a -> b;', { engine: 'neato' });
|
|
2391
|
+
* ```
|
|
2392
|
+
*
|
|
2295
2393
|
* @param fsl The FSL source.
|
|
2394
|
+
* @param opts Optional rendering options.
|
|
2395
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}` of the intermediate dot source.
|
|
2396
|
+
* @param opts.engine Graphviz layout engine to use (e.g. `'dot'`, `'neato'`, `'circo'`).
|
|
2397
|
+
* Unrecognized engine names cause `@viz-js/viz` to throw at render time.
|
|
2296
2398
|
* @returns A promise resolving to an SVG XML string.
|
|
2297
2399
|
*/
|
|
2298
|
-
declare function fsl_to_svg_string(fsl: string
|
|
2400
|
+
declare function fsl_to_svg_string(fsl: string, opts?: {
|
|
2401
|
+
footer?: string;
|
|
2402
|
+
engine?: string;
|
|
2403
|
+
}): Promise<string>;
|
|
2299
2404
|
/**
|
|
2300
2405
|
* Render a {@link jssm.Machine} to SVG.
|
|
2301
2406
|
*
|
|
2302
2407
|
* @param u_jssm The machine to render.
|
|
2408
|
+
* @param opts Optional rendering options.
|
|
2409
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}` of the intermediate dot source.
|
|
2303
2410
|
* @returns A promise resolving to an SVG XML string.
|
|
2304
2411
|
*/
|
|
2305
|
-
declare function machine_to_svg_string<T>(u_jssm: Machine<T
|
|
2412
|
+
declare function machine_to_svg_string<T>(u_jssm: Machine<T>, opts?: {
|
|
2413
|
+
footer?: string;
|
|
2414
|
+
}): Promise<string>;
|
|
2306
2415
|
/**
|
|
2307
2416
|
* Render an FSL string directly to a parsed `SVGSVGElement`.
|
|
2308
2417
|
*
|
|
2309
2418
|
* @param fsl The FSL source.
|
|
2419
|
+
* @param opts Optional rendering options.
|
|
2420
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}` of the intermediate dot source.
|
|
2310
2421
|
* @returns A promise resolving to a parsed `SVGSVGElement`.
|
|
2311
2422
|
* @throws {JssmError} if no `DOMParser` is available (Node without `configure`).
|
|
2312
2423
|
*/
|
|
2313
|
-
declare function fsl_to_svg_element(fsl: string
|
|
2424
|
+
declare function fsl_to_svg_element(fsl: string, opts?: {
|
|
2425
|
+
footer?: string;
|
|
2426
|
+
}): Promise<SVGSVGElement>;
|
|
2314
2427
|
/**
|
|
2315
2428
|
* Render a {@link jssm.Machine} to a parsed `SVGSVGElement`.
|
|
2316
2429
|
*
|
|
2317
2430
|
* @param u_jssm The machine to render.
|
|
2431
|
+
* @param opts Optional rendering options.
|
|
2432
|
+
* @param opts.footer Optional verbatim dot source inserted just before the closing `}` of the intermediate dot source.
|
|
2318
2433
|
* @returns A promise resolving to a parsed `SVGSVGElement`.
|
|
2319
2434
|
* @throws {JssmError} if no `DOMParser` is available (Node without `configure`).
|
|
2320
2435
|
*/
|
|
2321
|
-
declare function machine_to_svg_element<T>(u_jssm: Machine<T
|
|
2436
|
+
declare function machine_to_svg_element<T>(u_jssm: Machine<T>, opts?: {
|
|
2437
|
+
footer?: string;
|
|
2438
|
+
}): Promise<SVGSVGElement>;
|
|
2322
2439
|
/**
|
|
2323
2440
|
* Compatibility wrapper for {@link machine_to_dot}, retained from
|
|
2324
2441
|
* jssm-viz. Will be removed in the next major.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jssm",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.119.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=10.0.0"
|
|
6
6
|
},
|
|
@@ -33,7 +33,17 @@
|
|
|
33
33
|
"default": "./dist/jssm_viz.mjs"
|
|
34
34
|
},
|
|
35
35
|
"browser": "./dist/jssm_viz.iife.cjs"
|
|
36
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"./wc/viz": {
|
|
38
|
+
"import": "./dist/wc/viz.js",
|
|
39
|
+
"default": "./dist/wc/viz.js"
|
|
40
|
+
},
|
|
41
|
+
"./wc/viz/define": {
|
|
42
|
+
"import": "./dist/wc/viz.define.js",
|
|
43
|
+
"default": "./dist/wc/viz.define.js"
|
|
44
|
+
},
|
|
45
|
+
"./cdn/viz": "./dist/cdn/viz.js",
|
|
46
|
+
"./custom-elements.json": "./custom-elements.json"
|
|
37
47
|
},
|
|
38
48
|
"autoupdate": {
|
|
39
49
|
"source": "git",
|
|
@@ -48,6 +58,10 @@
|
|
|
48
58
|
]
|
|
49
59
|
},
|
|
50
60
|
"type": "module",
|
|
61
|
+
"sideEffects": [
|
|
62
|
+
"./dist/wc/*.define.js",
|
|
63
|
+
"./dist/cdn/**"
|
|
64
|
+
],
|
|
51
65
|
"files": [
|
|
52
66
|
"dist/jssm.es5.cjs",
|
|
53
67
|
"dist/jssm.es5.iife.js",
|
|
@@ -55,6 +69,9 @@
|
|
|
55
69
|
"dist/jssm_viz.cjs",
|
|
56
70
|
"dist/jssm_viz.iife.cjs",
|
|
57
71
|
"dist/jssm_viz.mjs",
|
|
72
|
+
"dist/wc/viz.js",
|
|
73
|
+
"dist/wc/viz.define.js",
|
|
74
|
+
"dist/cdn/viz.js",
|
|
58
75
|
"dist/deno/jssm.js",
|
|
59
76
|
"dist/deno/*.d.ts",
|
|
60
77
|
"dist/deno/README.md",
|
|
@@ -62,7 +79,8 @@
|
|
|
62
79
|
"jssm.es6.d.ts",
|
|
63
80
|
"jssm_viz.es5.d.cts",
|
|
64
81
|
"jssm_viz.es6.d.ts",
|
|
65
|
-
"MIGRATING-jssm-viz.md"
|
|
82
|
+
"MIGRATING-jssm-viz.md",
|
|
83
|
+
"custom-elements.json"
|
|
66
84
|
],
|
|
67
85
|
"description": "A Javascript finite state machine (FSM) with a terse DSL and a simple API. Most FSMs are one-liners. Fast, easy, powerful, well tested, typed with TypeScript, and visualizations. MIT License.",
|
|
68
86
|
"main": "dist/jssm.es5.cjs",
|
|
@@ -79,20 +97,24 @@
|
|
|
79
97
|
"jest-stoch": "jest -c jest-stoch.config.cjs --color --verbose",
|
|
80
98
|
"jest-dragon": "jest -c jest-dragon.config.cjs --color --verbose",
|
|
81
99
|
"jest-spec": "jest -c jest-spec.config.cjs --color --verbose",
|
|
82
|
-
"jest": "
|
|
100
|
+
"jest-wc": "jest -c jest-wc.config.cjs --color --verbose",
|
|
101
|
+
"jest": "npm run jest-stoch && npm run jest-spec && npm run jest-wc",
|
|
83
102
|
"test": "npm run make && npm run jest",
|
|
84
|
-
"clean": "rm -rf dist && rm -rf docs && cd coverage && rm -rf cloc && cd .. && rm -f src/ts/fsl_parser.ts && rm -f src/ts/version.ts && rm -f *.d.ts && mkdir dist && mkdir docs && cd coverage && mkdir cloc && cd .. && rm -f ./src/tools/jssm.es5.iife.nonmin.js",
|
|
103
|
+
"clean": "rm -rf dist && rm -rf docs && cd coverage && rm -rf cloc && cd .. && rm -f src/ts/fsl_parser.ts && rm -f src/ts/version.ts && rm -f *.d.ts && mkdir dist && cd dist && mkdir wc && mkdir cdn && cd .. && mkdir docs && cd coverage && mkdir cloc && cd .. && rm -f ./src/tools/jssm.es5.iife.nonmin.js",
|
|
85
104
|
"peg": "rm -f src/ts/fsl_parser.js && pegjs src/ts/fsl_parser.peg && node src/buildjs/fixparser.cjs",
|
|
105
|
+
"build:cem": "custom-elements-manifest analyze --config custom-elements-manifest.config.mjs",
|
|
86
106
|
"make_cjs": "rollup -c rollup.config.es5.js",
|
|
87
107
|
"make_es6": "rollup -c rollup.config.es6.js",
|
|
88
108
|
"make_iife": "rollup -c rollup.config.iife.js",
|
|
89
109
|
"make_deno": "rollup -c rollup.config.deno.js && cp dist/es6/*.d.ts dist/deno",
|
|
90
110
|
"make_viz_cjs": "rollup -c rollup.config.viz.es5.js",
|
|
91
111
|
"make_viz_es6": "rollup -c rollup.config.viz.es6.js",
|
|
112
|
+
"make_wc_viz_es6": "rollup -c rollup.config.wc.viz.es6.js",
|
|
113
|
+
"make_wc_viz_cdn": "rollup -c rollup.config.wc.viz.cdn.js",
|
|
92
114
|
"make_viz_iife": "rollup -c rollup.config.viz.iife.js",
|
|
93
115
|
"typescript": "tsc --build tsconfig.json",
|
|
94
116
|
"makever": "node src/buildjs/makever.cjs",
|
|
95
|
-
"make": "npm run clean && npm run makever && npm run peg && npm run typescript && npm run make_iife && npm run make_es6 && npm run make_deno && npm run make_cjs && npm run make_viz_iife && npm run make_viz_es6 && npm run make_viz_cjs && npm run minify && npm run min_iife && npm run min_es6 && npm run min_cjs && npm run min_deno && npm run min_viz_iife && npm run min_viz_es6 && npm run min_viz_cjs && rm ./dist/es6/*.nonmin.js",
|
|
117
|
+
"make": "npm run clean && npm run makever && npm run peg && npm run build:cem && npm run typescript && npm run make_iife && npm run make_es6 && npm run make_deno && npm run make_cjs && npm run make_viz_iife && npm run make_viz_es6 && npm run make_viz_cjs && npm run make_wc_viz_es6 && npm run make_wc_viz_cdn && npm run minify && npm run min_iife && npm run min_es6 && npm run min_cjs && npm run min_deno && npm run min_viz_iife && npm run min_viz_es6 && npm run min_viz_cjs && rm ./dist/es6/*.nonmin.js",
|
|
96
118
|
"eslint": "eslint --color src/ts/jssm.ts src/ts/jssm_types.ts src/ts/tests/*.ts",
|
|
97
119
|
"audit": "text_audit -r -t major MAJOR wasteful WASTEFUL any mixed fixme FIXME checkme CHECKME testme TESTME stochable STOCHABLE todo TODO comeback COMEBACK whargarbl WHARGARBL -g ./src/ts/**/*.{js,ts}",
|
|
98
120
|
"vet": "npm run eslint && npm run audit",
|
|
@@ -161,6 +183,7 @@
|
|
|
161
183
|
},
|
|
162
184
|
"homepage": "https://stonecypher.github.io/jssm/",
|
|
163
185
|
"devDependencies": {
|
|
186
|
+
"@custom-elements-manifest/analyzer": "^0.10.4",
|
|
164
187
|
"@knodes/typedoc-plugin-pages": "^0.22.5",
|
|
165
188
|
"@rollup/plugin-commonjs": "^28.0.1",
|
|
166
189
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
@@ -187,6 +210,7 @@
|
|
|
187
210
|
"jest-environment-jsdom": "^30.3.0",
|
|
188
211
|
"jest-json-reporter2": "^1.1.0",
|
|
189
212
|
"jsdom": "^24.1.0",
|
|
213
|
+
"lit": "^3.2.1",
|
|
190
214
|
"pegjs": "^0.10.0",
|
|
191
215
|
"picocolors": "^1.0.0",
|
|
192
216
|
"rollup": "^4.24.0",
|
|
@@ -205,6 +229,12 @@
|
|
|
205
229
|
"circular_buffer_js": "^1.10.0",
|
|
206
230
|
"reduce-to-639-1": "^1.1.0"
|
|
207
231
|
},
|
|
232
|
+
"peerDependencies": {
|
|
233
|
+
"lit": ">=3"
|
|
234
|
+
},
|
|
235
|
+
"peerDependenciesMeta": {
|
|
236
|
+
"lit": { "optional": true }
|
|
237
|
+
},
|
|
208
238
|
"optionalDependencies": {
|
|
209
239
|
"@viz-js/viz": "^3.26.0"
|
|
210
240
|
}
|