@peter.naydenov/cuts 2.1.3 → 2.1.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.
Files changed (38) hide show
  1. package/Changelog.md +28 -0
  2. package/README.md +1 -1
  3. package/coverage/lcov-report/index.html +29 -29
  4. package/coverage/lcov-report/src/findInstructions.js.html +27 -27
  5. package/coverage/lcov-report/src/index.html +25 -25
  6. package/coverage/lcov-report/src/main.js.html +129 -51
  7. package/coverage/lcov-report/src/methods/hide.js.html +127 -67
  8. package/coverage/lcov-report/src/methods/index.html +38 -38
  9. package/coverage/lcov-report/src/methods/jump.js.html +27 -12
  10. package/coverage/lcov-report/src/methods/jumpBack.js.html +10 -10
  11. package/coverage/lcov-report/src/methods/jumpsReset.js.html +3 -3
  12. package/coverage/lcov-report/src/methods/listShortcuts.js.html +5 -5
  13. package/coverage/lcov-report/src/methods/setScenes.js.html +16 -16
  14. package/coverage/lcov-report/src/methods/show.js.html +154 -76
  15. package/coverage/lcov-report/src/setInstruction.js.html +23 -11
  16. package/coverage/lcov.info +362 -314
  17. package/dist/cuts.cjs +1 -1
  18. package/dist/cuts.esm.mjs +1 -1
  19. package/dist/cuts.umd.js +1 -1
  20. package/package.json +2 -2
  21. package/src/main.js +28 -9
  22. package/src/methods/hide.js +46 -39
  23. package/src/methods/jump.js +7 -2
  24. package/src/methods/jumpBack.js +2 -2
  25. package/src/methods/jumpsReset.js +1 -1
  26. package/src/methods/setScenes.js +1 -1
  27. package/src/methods/show.js +23 -6
  28. package/src/setInstruction.js +5 -1
  29. package/test/02-cuts.test.js +339 -1
  30. package/types/main.d.ts +42 -6
  31. package/types/main.d.ts.map +1 -1
  32. package/types/methods/hide.d.ts +1 -1
  33. package/types/methods/hide.d.ts.map +1 -1
  34. package/types/methods/jump.d.ts.map +1 -1
  35. package/types/methods/setScenes.d.ts +2 -2
  36. package/types/methods/show.d.ts.map +1 -1
  37. package/types/setInstruction.d.ts.map +1 -1
  38. package/vitest.config.js +1 -1
package/Changelog.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
 
4
4
 
5
+ ## 2.1.5 ( 2026-07-09 )
6
+ - [x] Types: `CutsConfig` is now an exported type in `types/main.d.ts` with `logLevel?: 0 | 1`. Previously only documented in README, not in the type declarations;
7
+ - [x] Types: `pluginNames` is now an exported union type (`'Key'|'Click'|'Form'|'Hover'|'Scroll'`) in `types/main.d.ts`, matching the values accepted by `loadPlugins`;
8
+ - [x] Types: new exported `CutsState` type in `types/main.d.ts` (`{ scene, parents, opened }`), used as the return type of `getState()`;
9
+ - [x] Types: `getState()` now returns `CutsState` instead of untyped `Object` — IntelliSense now autocompletes `{ scene, parents, opened }`;
10
+ - [x] Types: `hide()` return type corrected to `Promise<void>` instead of `Promise<any>`;
11
+ - [x] Fix: `jumpBack()` function body renamed from `jumpReset` to `jumpsReset` — implementation now matches the exported name;
12
+ - [x] Types: `jumpBack()` parameter default documented as `@param {number} [options.hops=1]` instead of the previous non-standard `{hops}=...` form;
13
+ - [x] Types: `hide()` `@param` annotation now clarifies the default (`1` = current scene only) and the `'*'` wildcard meaning;
14
+ - [x] Docs: README note on `logLevel` type updated from `logLevel: number` to `logLevel?: 0 | 1` to match the new typedef;
15
+ - [x] Fix: `beforeHide` now works correctly when it returns a Promise. Previously the return value was ignored entirely — async blocking logic (e.g. confirm dialogs) was silently broken, and the navigation proceeded before the Promise resolved. Both `show()` and `hide()` now detect Promise returns and await them before calling `unloadTask.done`. Errors in the Promise chain are caught and treated as `done(false)`;
16
+ - [x] Fix: scene functions (`show`/`hide`) that reject without being caught no longer produce unhandled promise rejections. `setInstruction` wraps the returned promise with `.catch(() => {})`. `jump()` and `jumpBack()` do the same on their `show()` call;
17
+ - [x] Tests: two new regression tests for async `beforeHide` — one verifying navigation is blocked when the Promise resolves to `false`, one verifying it proceeds when the Promise resolves to `true`;
18
+
19
+
20
+
21
+ ## 2.1.4 ( 2026-07-09 )
22
+ - [x] Fix: `hide()` with the default single step (or any `endSteps` short of the full chain) left `currentScene`/`currentParents` pointing at the just-hidden scene instead of climbing to its still-visible parent, so no scene's shortcuts context was active afterward. This affected every nested scene, not only wildcard overlays - the 2.1.3 fix was scoped too narrowly. `hide()` is rewritten to climb the recorded ancestor chain directly, which also removes the need for the wildcard-specific special-casing from 2.1.3;
23
+ - [x] Fix: server-side-rendered (`options.ssr: true`) first loads never recorded the scene's `parents`, so navigating away from a deep SSR-loaded scene skipped hiding its ancestors entirely, leaving them stale;
24
+ - [x] Docs: `afterShow`'s typedef claimed it could return `false` to cancel the show - it never could (the return value was always ignored) and the README never documented that behavior either. The typedef now describes the actual fire-and-forget contract;
25
+ - [x] Fix: `hide()` never checked `beforeHide`, so it always bypassed the "prevent navigation away" guard that `show()` already respected - calling `hide()` directly could skip it entirely even when it returned `false`;
26
+ - [x] Fix: `jump()` pushed onto the jump stack unconditionally, even when the underlying navigation was blocked (eg. by `beforeHide`) or failed - leaving a phantom entry that desynced `jumpBack()` from what actually happened;
27
+ - [x] Fix: `show()` passed `state.currentParents` into `findInstructions` by reference; since `findInstructions` is a lazy generator, mutating that same array mid-iteration (as the wildcard-overlay climb in `getStep` now does) corrupted its still-pending computation and silently dropped a `hide` step, leaking the scene an overlay was covering as permanently visible after navigating elsewhere;
28
+ - [x] Fix: showing a wildcard-overlay scene with no underlying scene (`currentScene` was `null`) recorded a literal `null` placeholder in `currentParents`, which crashed any later navigation away from it;
29
+ - [x] Fix: re-showing a wildcard-overlay scene while it was already current pushed it onto its own ancestor chain, so a later `hide()` reported the overlay as still current even though it had actually just been hidden;
30
+
31
+
32
+
5
33
  ## 2.1.3 ( 2026-07-09 )
6
34
  - [x] Fix: `getState()` returned a live reference to `state.currentParents` instead of a copy; a caller mutating the returned array corrupted cuts' own internal state;
7
35
  - [x] Fix: `hide()` on a wildcard-overlay scene left `currentScene`/`currentParents` pointing at the (now-hidden) overlay instead of climbing back to the scene it was shown on top of, so that scene's shortcuts context never reactivated;
package/README.md CHANGED
@@ -206,7 +206,7 @@ const script = cuts ();
206
206
  const script = cuts ({ logLevel: 0 });
207
207
  ```
208
208
 
209
- The option is also exposed in `types/main.d.ts` as `logLevel: number`.
209
+ The option is also exposed in `types/main.d.ts` as `logLevel?: 0 | 1`.
210
210
 
211
211
  ### Custom events via `emit`
212
212
 
@@ -23,30 +23,30 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">85.71% </span>
26
+ <span class="strong">95.65% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>198/231</span>
28
+ <span class='fraction'>242/253</span>
29
29
  </div>
30
30
 
31
31
 
32
32
  <div class='fl pad1y space-right2'>
33
- <span class="strong">80% </span>
33
+ <span class="strong">92.7% </span>
34
34
  <span class="quiet">Branches</span>
35
- <span class='fraction'>60/75</span>
35
+ <span class='fraction'>89/96</span>
36
36
  </div>
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">75.51% </span>
40
+ <span class="strong">79.62% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>37/49</span>
42
+ <span class='fraction'>43/54</span>
43
43
  </div>
44
44
 
45
45
 
46
46
  <div class='fl pad1y space-right2'>
47
- <span class="strong">88.38% </span>
47
+ <span class="strong">98.6% </span>
48
48
  <span class="quiet">Lines</span>
49
- <span class='fraction'>175/198</span>
49
+ <span class='fraction'>212/215</span>
50
50
  </div>
51
51
 
52
52
 
@@ -80,32 +80,32 @@
80
80
  </thead>
81
81
  <tbody><tr>
82
82
  <td class="file high" data-value="src"><a href="src/index.html">src</a></td>
83
- <td data-value="93.33" class="pic high">
84
- <div class="chart"><div class="cover-fill" style="width: 93%"></div><div class="cover-empty" style="width: 7%"></div></div>
83
+ <td data-value="95.32" class="pic high">
84
+ <div class="chart"><div class="cover-fill" style="width: 95%"></div><div class="cover-empty" style="width: 5%"></div></div>
85
85
  </td>
86
- <td data-value="93.33" class="pct high">93.33%</td>
87
- <td data-value="105" class="abs high">98/105</td>
88
- <td data-value="95.23" class="pct high">95.23%</td>
89
- <td data-value="21" class="abs high">20/21</td>
90
- <td data-value="72" class="pct medium">72%</td>
91
- <td data-value="25" class="abs medium">18/25</td>
86
+ <td data-value="95.32" class="pct high">95.32%</td>
87
+ <td data-value="107" class="abs high">102/107</td>
88
+ <td data-value="92" class="pct high">92%</td>
89
+ <td data-value="25" class="abs high">23/25</td>
90
+ <td data-value="76.92" class="pct medium">76.92%</td>
91
+ <td data-value="26" class="abs medium">20/26</td>
92
92
  <td data-value="100" class="pct high">100%</td>
93
- <td data-value="83" class="abs high">83/83</td>
93
+ <td data-value="84" class="abs high">84/84</td>
94
94
  </tr>
95
95
 
96
96
  <tr>
97
- <td class="file medium" data-value="src/methods"><a href="src/methods/index.html">src/methods</a></td>
98
- <td data-value="79.36" class="pic medium">
99
- <div class="chart"><div class="cover-fill" style="width: 79%"></div><div class="cover-empty" style="width: 21%"></div></div>
97
+ <td class="file high" data-value="src/methods"><a href="src/methods/index.html">src/methods</a></td>
98
+ <td data-value="95.89" class="pic high">
99
+ <div class="chart"><div class="cover-fill" style="width: 95%"></div><div class="cover-empty" style="width: 5%"></div></div>
100
100
  </td>
101
- <td data-value="79.36" class="pct medium">79.36%</td>
102
- <td data-value="126" class="abs medium">100/126</td>
103
- <td data-value="74.07" class="pct medium">74.07%</td>
104
- <td data-value="54" class="abs medium">40/54</td>
105
- <td data-value="79.16" class="pct medium">79.16%</td>
106
- <td data-value="24" class="abs medium">19/24</td>
107
- <td data-value="80" class="pct high">80%</td>
108
- <td data-value="115" class="abs high">92/115</td>
101
+ <td data-value="95.89" class="pct high">95.89%</td>
102
+ <td data-value="146" class="abs high">140/146</td>
103
+ <td data-value="92.95" class="pct high">92.95%</td>
104
+ <td data-value="71" class="abs high">66/71</td>
105
+ <td data-value="82.14" class="pct high">82.14%</td>
106
+ <td data-value="28" class="abs high">23/28</td>
107
+ <td data-value="97.7" class="pct high">97.7%</td>
108
+ <td data-value="131" class="abs high">128/131</td>
109
109
  </tr>
110
110
 
111
111
  </tbody>
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2026-04-09T15:47:31.753Z
119
+ at 2026-07-09T15:42:10.120Z
120
120
  </div>
121
121
  <script src="prettify.js"></script>
122
122
  <script>
@@ -23,9 +23,9 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">98.3% </span>
26
+ <span class="strong">100% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>58/59</span>
28
+ <span class='fraction'>59/59</span>
29
29
  </div>
30
30
 
31
31
 
@@ -37,9 +37,9 @@
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">88.88% </span>
40
+ <span class="strong">100% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>8/9</span>
42
+ <span class='fraction'>9/9</span>
43
43
  </div>
44
44
 
45
45
 
@@ -165,38 +165,38 @@
165
165
  <span class="cline-any cline-neutral">&nbsp;</span>
166
166
  <span class="cline-any cline-neutral">&nbsp;</span>
167
167
  <span class="cline-any cline-neutral">&nbsp;</span>
168
- <span class="cline-any cline-yes">25x</span>
168
+ <span class="cline-any cline-yes">51x</span>
169
169
  <span class="cline-any cline-neutral">&nbsp;</span>
170
+ <span class="cline-any cline-yes">51x</span>
171
+ <span class="cline-any cline-yes">25x</span>
172
+ <span class="cline-any cline-yes">25x</span>
170
173
  <span class="cline-any cline-yes">25x</span>
171
- <span class="cline-any cline-yes">7x</span>
172
- <span class="cline-any cline-yes">7x</span>
173
- <span class="cline-any cline-yes">7x</span>
174
174
  <span class="cline-any cline-neutral">&nbsp;</span>
175
175
  <span class="cline-any cline-neutral">&nbsp;</span>
176
+ <span class="cline-any cline-yes">26x</span>
176
177
  <span class="cline-any cline-yes">18x</span>
177
- <span class="cline-any cline-yes">11x</span>
178
- <span class="cline-any cline-yes">11x</span>
179
- <span class="cline-any cline-yes">2x</span>
180
- <span class="cline-any cline-yes">4x</span>
181
- <span class="cline-any cline-yes">2x</span>
182
- <span class="cline-any cline-yes">2x</span>
183
- <span class="cline-any cline-yes">2x</span>
178
+ <span class="cline-any cline-yes">18x</span>
179
+ <span class="cline-any cline-yes">3x</span>
180
+ <span class="cline-any cline-yes">5x</span>
181
+ <span class="cline-any cline-yes">3x</span>
182
+ <span class="cline-any cline-yes">3x</span>
183
+ <span class="cline-any cline-yes">3x</span>
184
184
  <span class="cline-any cline-neutral">&nbsp;</span>
185
- <span class="cline-any cline-yes">9x</span>
186
- <span class="cline-any cline-yes">9x</span>
187
- <span class="cline-any cline-yes">9x</span>
185
+ <span class="cline-any cline-yes">15x</span>
186
+ <span class="cline-any cline-yes">15x</span>
187
+ <span class="cline-any cline-yes">15x</span>
188
188
  <span class="cline-any cline-neutral">&nbsp;</span>
189
- <span class="cline-any cline-yes">11x</span>
190
- <span class="cline-any cline-yes">11x</span>
189
+ <span class="cline-any cline-yes">18x</span>
190
+ <span class="cline-any cline-yes">18x</span>
191
191
  <span class="cline-any cline-neutral">&nbsp;</span>
192
192
  <span class="cline-any cline-neutral">&nbsp;</span>
193
- <span class="cline-any cline-yes">7x</span>
194
- <span class="cline-any cline-yes">3x</span>
195
- <span class="cline-any cline-yes">3x</span>
193
+ <span class="cline-any cline-yes">8x</span>
194
+ <span class="cline-any cline-yes">4x</span>
195
+ <span class="cline-any cline-yes">4x</span>
196
196
  <span class="cline-any cline-yes">4x</span>
197
197
  <span class="cline-any cline-neutral">&nbsp;</span>
198
- <span class="cline-any cline-yes">3x</span>
199
- <span class="cline-any cline-yes">3x</span>
198
+ <span class="cline-any cline-yes">4x</span>
199
+ <span class="cline-any cline-yes">4x</span>
200
200
  <span class="cline-any cline-neutral">&nbsp;</span>
201
201
  <span class="cline-any cline-neutral">&nbsp;</span>
202
202
  <span class="cline-any cline-yes">4x</span>
@@ -257,7 +257,7 @@ function* findInstructions ( currentName, currentParents, targetName, targetPare
257
257
  let backToName, backIndex=null, isNoParent=true;
258
258
  &nbsp;
259
259
  if ( currentName === null ) { // When the scene manager is just started
260
- yield* targetParents.map ( <span class="fstat-no" title="function not covered" >name </span>=&gt; <span class="cstat-no" title="statement not covered" >[ name, 'show' ])</span>
260
+ yield* targetParents.map ( name =&gt; [ name, 'show' ])
261
261
  yield [ targetName, 'show' ]
262
262
  return
263
263
  }
@@ -337,7 +337,7 @@ export default findInstructions
337
337
  <div class='footer quiet pad2 space-top1 center small'>
338
338
  Code coverage generated by
339
339
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
340
- at 2026-04-09T15:47:31.753Z
340
+ at 2026-07-09T15:42:10.120Z
341
341
  </div>
342
342
  <script src="../prettify.js"></script>
343
343
  <script>
@@ -23,30 +23,30 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">93.33% </span>
26
+ <span class="strong">95.32% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>98/105</span>
28
+ <span class='fraction'>102/107</span>
29
29
  </div>
30
30
 
31
31
 
32
32
  <div class='fl pad1y space-right2'>
33
- <span class="strong">95.23% </span>
33
+ <span class="strong">92% </span>
34
34
  <span class="quiet">Branches</span>
35
- <span class='fraction'>20/21</span>
35
+ <span class='fraction'>23/25</span>
36
36
  </div>
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">72% </span>
40
+ <span class="strong">76.92% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>18/25</span>
42
+ <span class='fraction'>20/26</span>
43
43
  </div>
44
44
 
45
45
 
46
46
  <div class='fl pad1y space-right2'>
47
47
  <span class="strong">100% </span>
48
48
  <span class="quiet">Lines</span>
49
- <span class='fraction'>83/83</span>
49
+ <span class='fraction'>84/84</span>
50
50
  </div>
51
51
 
52
52
 
@@ -80,32 +80,32 @@
80
80
  </thead>
81
81
  <tbody><tr>
82
82
  <td class="file high" data-value="findInstructions.js"><a href="findInstructions.js.html">findInstructions.js</a></td>
83
- <td data-value="98.3" class="pic high">
84
- <div class="chart"><div class="cover-fill" style="width: 98%"></div><div class="cover-empty" style="width: 2%"></div></div>
83
+ <td data-value="100" class="pic high">
84
+ <div class="chart"><div class="cover-fill cover-full" style="width: 100%"></div><div class="cover-empty" style="width: 0%"></div></div>
85
85
  </td>
86
- <td data-value="98.3" class="pct high">98.3%</td>
87
- <td data-value="59" class="abs high">58/59</td>
86
+ <td data-value="100" class="pct high">100%</td>
87
+ <td data-value="59" class="abs high">59/59</td>
88
88
  <td data-value="100" class="pct high">100%</td>
89
89
  <td data-value="16" class="abs high">16/16</td>
90
- <td data-value="88.88" class="pct high">88.88%</td>
91
- <td data-value="9" class="abs high">8/9</td>
90
+ <td data-value="100" class="pct high">100%</td>
91
+ <td data-value="9" class="abs high">9/9</td>
92
92
  <td data-value="100" class="pct high">100%</td>
93
93
  <td data-value="47" class="abs high">47/47</td>
94
94
  </tr>
95
95
 
96
96
  <tr>
97
97
  <td class="file high" data-value="main.js"><a href="main.js.html">main.js</a></td>
98
- <td data-value="85" class="pic high">
99
- <div class="chart"><div class="cover-fill" style="width: 85%"></div><div class="cover-empty" style="width: 15%"></div></div>
98
+ <td data-value="88.09" class="pic high">
99
+ <div class="chart"><div class="cover-fill" style="width: 88%"></div><div class="cover-empty" style="width: 12%"></div></div>
100
100
  </td>
101
- <td data-value="85" class="pct high">85%</td>
102
- <td data-value="40" class="abs high">34/40</td>
103
- <td data-value="80" class="pct high">80%</td>
104
- <td data-value="5" class="abs high">4/5</td>
105
- <td data-value="53.84" class="pct medium">53.84%</td>
106
- <td data-value="13" class="abs medium">7/13</td>
101
+ <td data-value="88.09" class="pct high">88.09%</td>
102
+ <td data-value="42" class="abs high">37/42</td>
103
+ <td data-value="77.77" class="pct medium">77.77%</td>
104
+ <td data-value="9" class="abs medium">7/9</td>
105
+ <td data-value="61.53" class="pct medium">61.53%</td>
106
+ <td data-value="13" class="abs medium">8/13</td>
107
107
  <td data-value="100" class="pct high">100%</td>
108
- <td data-value="30" class="abs high">30/30</td>
108
+ <td data-value="31" class="abs high">31/31</td>
109
109
  </tr>
110
110
 
111
111
  <tr>
@@ -117,8 +117,8 @@
117
117
  <td data-value="6" class="abs high">6/6</td>
118
118
  <td data-value="100" class="pct high">100%</td>
119
119
  <td data-value="0" class="abs high">0/0</td>
120
- <td data-value="100" class="pct high">100%</td>
121
- <td data-value="3" class="abs high">3/3</td>
120
+ <td data-value="75" class="pct medium">75%</td>
121
+ <td data-value="4" class="abs medium">3/4</td>
122
122
  <td data-value="100" class="pct high">100%</td>
123
123
  <td data-value="6" class="abs high">6/6</td>
124
124
  </tr>
@@ -131,7 +131,7 @@
131
131
  <div class='footer quiet pad2 space-top1 center small'>
132
132
  Code coverage generated by
133
133
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
134
- at 2026-04-09T15:47:31.753Z
134
+ at 2026-07-09T15:42:10.120Z
135
135
  </div>
136
136
  <script src="../prettify.js"></script>
137
137
  <script>