jssm 5.137.0 → 5.138.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 +7 -7
- package/custom-elements.json +300 -0
- package/dist/cdn/instance.js +292 -7
- package/dist/cdn/viz.js +1 -1
- package/dist/cli/fsl-render.cjs +1 -1
- package/dist/cli/fsl.cjs +1 -1
- package/dist/deno/README.md +7 -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/dist/wc/instance.js +291 -6
- package/package.json +1 -1
package/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.138.0 at 5/28/2026, 7:32:08 AM
|
|
22
22
|
|
|
23
23
|
-->
|
|
24
|
-
# jssm 5.
|
|
24
|
+
# jssm 5.138.0
|
|
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/) ·
|
|
@@ -281,7 +281,7 @@ That decision shows up everywhere downstream:
|
|
|
281
281
|
or run `npm run benny` against your own machine.
|
|
282
282
|
|
|
283
283
|
- **More thoroughly tested than any other JavaScript state-machine
|
|
284
|
-
library.** 6,
|
|
284
|
+
library.** 6,349 tests at 100.0% line coverage
|
|
285
285
|
([report](https://coveralls.io/github/StoneCypher/jssm)), plus
|
|
286
286
|
fuzz testing via `fast-check`, with parser test data across ten natural
|
|
287
287
|
languages and Emoji.
|
|
@@ -414,11 +414,11 @@ If your contribution is missing here, please open an issue.
|
|
|
414
414
|
|
|
415
415
|
<br/>
|
|
416
416
|
|
|
417
|
-
***6,
|
|
417
|
+
***6,349 tests***, run 57,136 times.
|
|
418
418
|
|
|
419
|
-
- 5,
|
|
420
|
-
- 513 fuzz tests with 3.
|
|
421
|
-
- 5,
|
|
419
|
+
- 5,836 specs with 100.0% coverage
|
|
420
|
+
- 513 fuzz tests with 3.6% coverage
|
|
421
|
+
- 5,288 TypeScript lines - 1.2 tests per line, 10.8 generated tests per line
|
|
422
422
|
|
|
423
423
|
[](https://github.com/StoneCypher/jssm/actions)
|
|
424
424
|
[](https://www.npmjs.com/package/jssm)
|
package/custom-elements.json
CHANGED
|
@@ -2,6 +2,254 @@
|
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
3
|
"readme": "",
|
|
4
4
|
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/ts/wc/jssm_hook_wc.ts",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "function",
|
|
11
|
+
"name": "make_hook_proxy",
|
|
12
|
+
"return": {
|
|
13
|
+
"type": {
|
|
14
|
+
"text": ""
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"parameters": [
|
|
18
|
+
{
|
|
19
|
+
"name": "ctx",
|
|
20
|
+
"type": {
|
|
21
|
+
"text": "{ data?: TData; from?: string; to?: string; action?: string }"
|
|
22
|
+
},
|
|
23
|
+
"description": "Raw hook context passed by jssm."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "machine",
|
|
27
|
+
"type": {
|
|
28
|
+
"text": "{ state(): unknown }"
|
|
29
|
+
},
|
|
30
|
+
"description": "The owning machine; used for the `state()` accessor."
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"description": "Build a JssmHookProxy that wraps an arbitrary hook context object.\n\nThe context shape varies by hook kind (`from`/`to`/`action` may be absent\nfor transition-kind hooks), so this normalizes the shape via optional\nfields and exposes mutable `data` while keeping the rest read-only.\n\nThe `machine` parameter is used only for `state()`, so unit tests can\nsubstitute any object with a `state(): unknown` method."
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"kind": "function",
|
|
37
|
+
"name": "compile_inline_body",
|
|
38
|
+
"return": {
|
|
39
|
+
"type": {
|
|
40
|
+
"text": ""
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"parameters": [
|
|
44
|
+
{
|
|
45
|
+
"name": "body",
|
|
46
|
+
"type": {
|
|
47
|
+
"text": "string"
|
|
48
|
+
},
|
|
49
|
+
"description": "Trimmed textContent of the `<jssm-hook>` element."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "debug_id",
|
|
53
|
+
"type": {
|
|
54
|
+
"text": "string"
|
|
55
|
+
},
|
|
56
|
+
"description": "Identifier appended to the synthetic sourceURL."
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"description": "Compile a textContent body into a callable user handler.\n\nUses dynamic function construction — the same primitive browsers use\ninternally for `<a onclick=\"...\">` and `setTimeout(stringBody, ms)`.\nStrict CSP without `'unsafe-eval'` blocks this and the call will throw;\nconsumers should fall back to the `handler=\"name\"` form there.\n\nPrepends a `//# sourceURL=` comment so devtools surface a meaningful name\nin stack traces instead of `anonymous`."
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"kind": "function",
|
|
63
|
+
"name": "resolve_named_handler",
|
|
64
|
+
"return": {
|
|
65
|
+
"type": {
|
|
66
|
+
"text": ""
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"parameters": [
|
|
70
|
+
{
|
|
71
|
+
"name": "name",
|
|
72
|
+
"type": {
|
|
73
|
+
"text": "string"
|
|
74
|
+
},
|
|
75
|
+
"description": "The handler name from the `handler=\"\"` attribute."
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "registry",
|
|
79
|
+
"optional": true,
|
|
80
|
+
"type": {
|
|
81
|
+
"text": "JssmHookRegistry"
|
|
82
|
+
},
|
|
83
|
+
"description": "Optional in-WC registry to consult first."
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"description": "Resolve a `handler=\"name\"` attribute to a callable by consulting first the\noptional in-WC registry, then `globalThis[name]`. Throws a clear error if\nneither resolves."
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"kind": "function",
|
|
90
|
+
"name": "normalize_hook_kind",
|
|
91
|
+
"return": {
|
|
92
|
+
"type": {
|
|
93
|
+
"text": ""
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"parameters": [
|
|
97
|
+
{
|
|
98
|
+
"name": "raw",
|
|
99
|
+
"type": {
|
|
100
|
+
"text": "string | null | undefined"
|
|
101
|
+
},
|
|
102
|
+
"description": "The raw attribute value, or null if not present."
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"description": "Validate and normalize a `<jssm-hook kind=\"...\">` value, defaulting to\n`\"hook\"` when the attribute is absent. Throws on unknown kinds rather\nthan silently doing nothing later."
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"kind": "function",
|
|
109
|
+
"name": "parse_hook_element",
|
|
110
|
+
"return": {
|
|
111
|
+
"type": {
|
|
112
|
+
"text": ""
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"parameters": [
|
|
116
|
+
{
|
|
117
|
+
"name": "el",
|
|
118
|
+
"type": {
|
|
119
|
+
"text": "HTMLElement"
|
|
120
|
+
},
|
|
121
|
+
"description": "The `<jssm-hook>` element to parse."
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "debug_id",
|
|
125
|
+
"type": {
|
|
126
|
+
"text": "string"
|
|
127
|
+
},
|
|
128
|
+
"description": "Identifier used in the inline body's sourceURL."
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "registry",
|
|
132
|
+
"optional": true,
|
|
133
|
+
"type": {
|
|
134
|
+
"text": "JssmHookRegistry"
|
|
135
|
+
},
|
|
136
|
+
"description": "Optional in-WC registry of named handlers."
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"description": "Parse a single `<jssm-hook>` element into a JssmHookInstallSpec.\n\nValidates the mutual-exclusion rule between `handler=\"name\"` and inline\nbody, defaults `kind` to `\"hook\"`, resolves named handlers against the\noptional registry then `globalThis`, and compiles inline bodies via\ndynamic function construction. Conditional-required attributes (e.g.\n`from`/`to` for `kind=\"hook\"`) are NOT validated here — `set_hook` will\nthrow with its own clear errors on missing pieces, which keeps the\nerror surface single-sourced."
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"kind": "function",
|
|
143
|
+
"name": "wrap_user_handler",
|
|
144
|
+
"return": {
|
|
145
|
+
"type": {
|
|
146
|
+
"text": ""
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"parameters": [
|
|
150
|
+
{
|
|
151
|
+
"name": "spec",
|
|
152
|
+
"type": {
|
|
153
|
+
"text": "JssmHookInstallSpec"
|
|
154
|
+
},
|
|
155
|
+
"description": "The parsed install spec carrying the user handler."
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"name": "machine",
|
|
159
|
+
"type": {
|
|
160
|
+
"text": "{ state(): unknown }"
|
|
161
|
+
},
|
|
162
|
+
"description": "The owning machine; used by the proxy's `state()`."
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"description": "Wrap a JssmHookUserHandler so that jssm's native hook contract is\nsatisfied: the user gets a friendly proxy, the proxy's mutated `data`\nbecomes the `HookComplexResult.data`, and an explicit `false` return\ncancels the transition.\n\nAny non-`false` return — including `undefined`, `true`, or an arbitrary\nobject — allows the transition. This matches the contract spelled out\nin the issue (#641): \"return false cancels; anything else allows\"."
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"kind": "function",
|
|
169
|
+
"name": "build_hook_descriptor",
|
|
170
|
+
"return": {
|
|
171
|
+
"type": {
|
|
172
|
+
"text": ""
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"parameters": [
|
|
176
|
+
{
|
|
177
|
+
"name": "spec",
|
|
178
|
+
"type": {
|
|
179
|
+
"text": "JssmHookInstallSpec"
|
|
180
|
+
},
|
|
181
|
+
"description": "The parsed install spec."
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "wrapped",
|
|
185
|
+
"type": {
|
|
186
|
+
"text": "(ctx: RawHookContext) => unknown"
|
|
187
|
+
},
|
|
188
|
+
"description": "The wrapped (friendly-proxy) handler from {@link wrap_user_handler}.\n * "
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"description": "Build the typed descriptor object passed to `machine.set_hook` (and later\nto `machine.remove_hook` for cleanup) from a parsed JssmHookInstallSpec\nand the wrapped handler.\n\nFor kinds that need `from`/`to`/`action`, the descriptor includes those.\nMissing required keys produce `undefined` here; jssm's `set_hook` will\nsurface the error with its own clear message so we don't duplicate\nvalidation.\n\nReturn type is `unknown` because jssm's `HookDescription` is a\ndiscriminated union and our runtime-discriminator value can't be tracked\nby TypeScript across the build. The WC casts at the `set_hook` call site."
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
"exports": [
|
|
195
|
+
{
|
|
196
|
+
"kind": "js",
|
|
197
|
+
"name": "make_hook_proxy",
|
|
198
|
+
"declaration": {
|
|
199
|
+
"name": "make_hook_proxy",
|
|
200
|
+
"module": "src/ts/wc/jssm_hook_wc.ts"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"kind": "js",
|
|
205
|
+
"name": "compile_inline_body",
|
|
206
|
+
"declaration": {
|
|
207
|
+
"name": "compile_inline_body",
|
|
208
|
+
"module": "src/ts/wc/jssm_hook_wc.ts"
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"kind": "js",
|
|
213
|
+
"name": "resolve_named_handler",
|
|
214
|
+
"declaration": {
|
|
215
|
+
"name": "resolve_named_handler",
|
|
216
|
+
"module": "src/ts/wc/jssm_hook_wc.ts"
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"kind": "js",
|
|
221
|
+
"name": "normalize_hook_kind",
|
|
222
|
+
"declaration": {
|
|
223
|
+
"name": "normalize_hook_kind",
|
|
224
|
+
"module": "src/ts/wc/jssm_hook_wc.ts"
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"kind": "js",
|
|
229
|
+
"name": "parse_hook_element",
|
|
230
|
+
"declaration": {
|
|
231
|
+
"name": "parse_hook_element",
|
|
232
|
+
"module": "src/ts/wc/jssm_hook_wc.ts"
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"kind": "js",
|
|
237
|
+
"name": "wrap_user_handler",
|
|
238
|
+
"declaration": {
|
|
239
|
+
"name": "wrap_user_handler",
|
|
240
|
+
"module": "src/ts/wc/jssm_hook_wc.ts"
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"kind": "js",
|
|
245
|
+
"name": "build_hook_descriptor",
|
|
246
|
+
"declaration": {
|
|
247
|
+
"name": "build_hook_descriptor",
|
|
248
|
+
"module": "src/ts/wc/jssm_hook_wc.ts"
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
]
|
|
252
|
+
},
|
|
5
253
|
{
|
|
6
254
|
"kind": "javascript-module",
|
|
7
255
|
"path": "src/ts/wc/jssm_instance_wc.ts",
|
|
@@ -94,6 +342,36 @@
|
|
|
94
342
|
"default": "undefined",
|
|
95
343
|
"description": "The underlying machine instance, constructed at `connectedCallback`.\r\nExposed raw (not proxied) per the #639/#648 design decision so that\r\nconsumers can use the full Machine API directly.\r\n\r\nMarked optional because Lit will instantiate the element before\r\n`connectedCallback` runs; the instance is guaranteed present after\r\nconnection."
|
|
96
344
|
},
|
|
345
|
+
{
|
|
346
|
+
"kind": "field",
|
|
347
|
+
"name": "registry",
|
|
348
|
+
"type": {
|
|
349
|
+
"text": "JssmHookRegistry"
|
|
350
|
+
},
|
|
351
|
+
"readonly": true,
|
|
352
|
+
"default": "new Map()",
|
|
353
|
+
"description": "Per-instance registry of named hook handlers consulted before\r\n`globalThis` when resolving `<jssm-hook handler=\"name\">`.\r\n\r\nInitialized to an empty `Map`; consumers may populate it before the\r\nelement connects to provide handlers without polluting global scope —\r\nuseful for module-scoped SPAs where strict CSP blocks inline-body hooks."
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"kind": "field",
|
|
357
|
+
"name": "_installed_hooks",
|
|
358
|
+
"type": {
|
|
359
|
+
"text": "unknown[]"
|
|
360
|
+
},
|
|
361
|
+
"privacy": "private",
|
|
362
|
+
"default": "[]",
|
|
363
|
+
"description": "Descriptors for hooks this WC installed at connect time, used in\r\n`disconnectedCallback` to call `remove_hook` for each so the underlying\r\nmachine doesn't leak handlers when the element is detached.\r\n\r\nCaptured at install time because `remove_hook` matches by descriptor\r\nshape (not handler identity), and we need to record the wrapped handler\r\nwe passed to `set_hook` to undo the registration cleanly. Stored as\r\n`unknown[]` and cast at the call site because jssm's `HookDescription`\r\nis a discriminated union whose discriminator is only known at runtime."
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"kind": "field",
|
|
367
|
+
"name": "_hook_debug_counter",
|
|
368
|
+
"type": {
|
|
369
|
+
"text": "number"
|
|
370
|
+
},
|
|
371
|
+
"privacy": "private",
|
|
372
|
+
"default": "0",
|
|
373
|
+
"description": "Counter used to give each compiled inline-body hook a unique debug id\r\nfor its `//# sourceURL=jssm-hook:N` annotation. Per-instance so that\r\nmultiple `<jssm-instance>` elements on a page don't share numbering."
|
|
374
|
+
},
|
|
97
375
|
{
|
|
98
376
|
"kind": "field",
|
|
99
377
|
"name": "_action_listeners",
|
|
@@ -150,6 +428,28 @@
|
|
|
150
428
|
},
|
|
151
429
|
"description": "Convenience wrapper for `machine.state()`. Returns the current\r\nstate's name."
|
|
152
430
|
},
|
|
431
|
+
{
|
|
432
|
+
"kind": "method",
|
|
433
|
+
"name": "_install_declarative_hooks",
|
|
434
|
+
"privacy": "private",
|
|
435
|
+
"return": {
|
|
436
|
+
"type": {
|
|
437
|
+
"text": "void"
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
"description": "Discover every direct-child `<jssm-hook>` element and install each\r\nagainst the owned machine. Handlers are wrapped with the friendly-proxy\r\nadapter that lets user code write `m.data = ...` and return `false` to\r\ncancel — see make_hook_proxy and the issue (#641) doc-comment\r\nfor the full contract.\r\n\r\nDirect children only (the `:scope > jssm-hook` selector) so that nested\r\n`<jssm-instance>` elements don't have their child hooks installed on\r\nthe outer machine.\r\n\r\nTracks every installed descriptor in `_installed_hooks` so that\r\n`disconnectedCallback` can remove them on detach."
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"kind": "method",
|
|
444
|
+
"name": "_hook_id_prefix",
|
|
445
|
+
"privacy": "private",
|
|
446
|
+
"return": {
|
|
447
|
+
"type": {
|
|
448
|
+
"text": "string"
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
"description": "Prefix used in synthetic `//# sourceURL=jssm-hook:<prefix><n>` annotations\r\nfor inline-body hooks compiled by this element. Includes the element's\r\n`id` when present so multi-instance pages can tell sources apart in\r\ndevtools."
|
|
452
|
+
},
|
|
153
453
|
{
|
|
154
454
|
"kind": "method",
|
|
155
455
|
"name": "_discover_jssm_actions",
|