@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.
- package/Changelog.md +28 -0
- package/README.md +1 -1
- package/coverage/lcov-report/index.html +29 -29
- package/coverage/lcov-report/src/findInstructions.js.html +27 -27
- package/coverage/lcov-report/src/index.html +25 -25
- package/coverage/lcov-report/src/main.js.html +129 -51
- package/coverage/lcov-report/src/methods/hide.js.html +127 -67
- package/coverage/lcov-report/src/methods/index.html +38 -38
- package/coverage/lcov-report/src/methods/jump.js.html +27 -12
- package/coverage/lcov-report/src/methods/jumpBack.js.html +10 -10
- package/coverage/lcov-report/src/methods/jumpsReset.js.html +3 -3
- package/coverage/lcov-report/src/methods/listShortcuts.js.html +5 -5
- package/coverage/lcov-report/src/methods/setScenes.js.html +16 -16
- package/coverage/lcov-report/src/methods/show.js.html +154 -76
- package/coverage/lcov-report/src/setInstruction.js.html +23 -11
- package/coverage/lcov.info +362 -314
- package/dist/cuts.cjs +1 -1
- package/dist/cuts.esm.mjs +1 -1
- package/dist/cuts.umd.js +1 -1
- package/package.json +2 -2
- package/src/main.js +28 -9
- package/src/methods/hide.js +46 -39
- package/src/methods/jump.js +7 -2
- package/src/methods/jumpBack.js +2 -2
- package/src/methods/jumpsReset.js +1 -1
- package/src/methods/setScenes.js +1 -1
- package/src/methods/show.js +23 -6
- package/src/setInstruction.js +5 -1
- package/test/02-cuts.test.js +339 -1
- package/types/main.d.ts +42 -6
- package/types/main.d.ts.map +1 -1
- package/types/methods/hide.d.ts +1 -1
- package/types/methods/hide.d.ts.map +1 -1
- package/types/methods/jump.d.ts.map +1 -1
- package/types/methods/setScenes.d.ts +2 -2
- package/types/methods/show.d.ts.map +1 -1
- package/types/setInstruction.d.ts.map +1 -1
- package/vitest.config.js +1 -1
package/test/02-cuts.test.js
CHANGED
|
@@ -98,6 +98,75 @@ describe ( 'Cuts integration', () => {
|
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
|
|
101
|
+
it ( 'beforeHide with async function that resolves to false', async () => {
|
|
102
|
+
// Regression test: beforeHide returning a Promise was ignored — the
|
|
103
|
+
// return value was never awaited, so async blocking (e.g. confirm dialog)
|
|
104
|
+
// could not work. Navigation proceeded before the Promise resolved.
|
|
105
|
+
const script = cuts ();
|
|
106
|
+
const calls = [];
|
|
107
|
+
const scenes = [
|
|
108
|
+
{
|
|
109
|
+
name: 'top'
|
|
110
|
+
, scene: {
|
|
111
|
+
show: ({task}) => { calls.push('show top'); task.done() },
|
|
112
|
+
hide: ({task}) => { calls.push('hide top'); task.done() },
|
|
113
|
+
// Async beforeHide that blocks:
|
|
114
|
+
'beforeHide': ({ done }) => Promise.resolve().then ( () => done ( false ) ),
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'other'
|
|
119
|
+
, scene: {
|
|
120
|
+
show: ({task}) => { calls.push('show other'); task.done() },
|
|
121
|
+
hide: ({task}) => { calls.push('hide other'); task.done() }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
script.setScenes ( scenes );
|
|
127
|
+
await script.show ({ scene: 'top' });
|
|
128
|
+
expect ( calls ).toEqual (['show top']);
|
|
129
|
+
|
|
130
|
+
await script.show ({ scene: 'other' }); // blocked by async beforeHide
|
|
131
|
+
expect ( calls ).toEqual (['show top']); // 'show other' never fired
|
|
132
|
+
expect ( script.getState().scene ).toEqual ( 'top' );
|
|
133
|
+
}) // it beforeHide with async function that resolves to false
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
it ( 'beforeHide with async function that resolves to true', async () => {
|
|
138
|
+
const script = cuts ();
|
|
139
|
+
const calls = [];
|
|
140
|
+
const scenes = [
|
|
141
|
+
{
|
|
142
|
+
name: 'top'
|
|
143
|
+
, scene: {
|
|
144
|
+
show: ({task}) => { calls.push('show top'); task.done() },
|
|
145
|
+
hide: ({task}) => { calls.push('hide top'); task.done() },
|
|
146
|
+
// Async beforeHide that allows navigation:
|
|
147
|
+
'beforeHide': ({ done }) => Promise.resolve().then ( () => done ( true ) ),
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'other'
|
|
152
|
+
, scene: {
|
|
153
|
+
show: ({task}) => { calls.push('show other'); task.done() },
|
|
154
|
+
hide: ({task}) => { calls.push('hide other'); task.done() }
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
];
|
|
158
|
+
|
|
159
|
+
script.setScenes ( scenes );
|
|
160
|
+
await script.show ({ scene: 'top' });
|
|
161
|
+
expect ( calls ).toEqual (['show top']);
|
|
162
|
+
|
|
163
|
+
await script.show ({ scene: 'other' }); // allowed by async beforeHide
|
|
164
|
+
expect ( calls ).toEqual (['show top', 'hide top', 'show other']);
|
|
165
|
+
expect ( script.getState().scene ).toEqual ( 'other' );
|
|
166
|
+
}) // it beforeHide with async function that resolves to true
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
101
170
|
it ( 'Call no existing scene', async () => {
|
|
102
171
|
const script = cuts ({ logLevel : 1 });
|
|
103
172
|
const calls = [];
|
|
@@ -455,7 +524,7 @@ describe ( 'Cuts integration', () => {
|
|
|
455
524
|
await script.show ({ scene: 'overlay' });
|
|
456
525
|
expect ( calls ).toEqual (['show overlay']);
|
|
457
526
|
expect ( script.getState().scene ).toEqual ( 'overlay' );
|
|
458
|
-
expect ( script.getState().parents ).toEqual ( [
|
|
527
|
+
expect ( script.getState().parents ).toEqual ( [] ); // No underlying scene to remember
|
|
459
528
|
}) // it Show scene with wildcard parent as the very first scene
|
|
460
529
|
|
|
461
530
|
|
|
@@ -658,4 +727,273 @@ describe ( 'Cuts integration', () => {
|
|
|
658
727
|
|
|
659
728
|
|
|
660
729
|
|
|
730
|
+
it ( 'hide() with the default single step climbs to the parent and restores its shortcuts context', async () => {
|
|
731
|
+
// Regression test: hide() used to leave currentScene/currentParents pointing at
|
|
732
|
+
// the just-hidden scene instead of climbing to its (still visible) parent, so
|
|
733
|
+
// NEITHER scene's shortcuts context was active afterward.
|
|
734
|
+
const seen = [];
|
|
735
|
+
const script = cuts();
|
|
736
|
+
const scenes = [
|
|
737
|
+
{
|
|
738
|
+
name: 'A'
|
|
739
|
+
, scene: {
|
|
740
|
+
show : ({task}) => task.done(),
|
|
741
|
+
hide : ({task}) => task.done(),
|
|
742
|
+
'@ping' : () => seen.push ( 'A' )
|
|
743
|
+
}
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
name: 'B'
|
|
747
|
+
, scene: {
|
|
748
|
+
show : ({task}) => task.done(),
|
|
749
|
+
hide : ({task}) => task.done(),
|
|
750
|
+
parents: ['A'],
|
|
751
|
+
'@ping' : () => seen.push ( 'B' )
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
];
|
|
755
|
+
|
|
756
|
+
script.setScenes ( scenes );
|
|
757
|
+
await script.show ({ scene: 'A' });
|
|
758
|
+
await script.show ({ scene: 'B' });
|
|
759
|
+
|
|
760
|
+
await script.hide (); // default endSteps = 1
|
|
761
|
+
expect ( script.getState() ).toEqual ({ scene: 'A', parents: [], opened: true });
|
|
762
|
+
|
|
763
|
+
script.emit ( '@ping' );
|
|
764
|
+
expect ( seen ).toEqual ([ 'A' ]);
|
|
765
|
+
}) // it hide() with the default single step climbs to the parent and restores its shortcuts context
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
it ( 'hide(n) climbs exactly n levels', async () => {
|
|
770
|
+
const calls = [];
|
|
771
|
+
const script = cuts();
|
|
772
|
+
const scenes = [
|
|
773
|
+
{ name: 'top' , scene: { show: ({task}) => { calls.push('show top'); task.done() }, hide: ({task}) => { calls.push('hide top'); task.done() } } },
|
|
774
|
+
{ name: 'mid' , scene: { show: ({task}) => { calls.push('show mid'); task.done() }, hide: ({task}) => { calls.push('hide mid'); task.done() }, parents: ['top'] } },
|
|
775
|
+
{ name: 'deep', scene: { show: ({task}) => { calls.push('show deep'); task.done() }, hide: ({task}) => { calls.push('hide deep'); task.done() }, parents: ['top', 'mid'] } }
|
|
776
|
+
];
|
|
777
|
+
|
|
778
|
+
script.setScenes ( scenes );
|
|
779
|
+
await script.show ({ scene: 'deep' });
|
|
780
|
+
calls.length = 0;
|
|
781
|
+
|
|
782
|
+
await script.hide ( 2 );
|
|
783
|
+
expect ( calls ).toEqual ([ 'hide deep', 'hide mid' ]);
|
|
784
|
+
expect ( script.getState() ).toEqual ({ scene: 'top', parents: [], opened: true });
|
|
785
|
+
}) // it hide(n) climbs exactly n levels
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
it ( 'SSR first load records the scene\'s parents, so leaving it hides them too', async () => {
|
|
790
|
+
// Regression test: the SSR branch of show() set currentScene but never
|
|
791
|
+
// currentParents, so navigating away from a deep SSR-loaded scene skipped
|
|
792
|
+
// hiding its ancestors entirely, leaving them stale in the DOM.
|
|
793
|
+
const calls = [];
|
|
794
|
+
const script = cuts();
|
|
795
|
+
const scenes = [
|
|
796
|
+
{ name: 'top' , scene: { show: ({task}) => { calls.push('show top'); task.done() }, hide: ({task}) => { calls.push('hide top'); task.done() } } },
|
|
797
|
+
{ name: 'mid' , scene: { show: ({task}) => { calls.push('show mid'); task.done() }, hide: ({task}) => { calls.push('hide mid'); task.done() }, parents: ['top'] } },
|
|
798
|
+
{ name: 'deep', scene: { show: ({task}) => { calls.push('show deep'); task.done() }, hide: ({task}) => { calls.push('hide deep'); task.done() }, parents: ['top', 'mid'] } },
|
|
799
|
+
{ name: 'other', scene: { show: ({task}) => { calls.push('show other'); task.done() }, hide: ({task}) => { calls.push('hide other'); task.done() } } }
|
|
800
|
+
];
|
|
801
|
+
|
|
802
|
+
script.setScenes ( scenes );
|
|
803
|
+
await script.show ({ scene: 'deep', options: { ssr: true } });
|
|
804
|
+
expect ( script.getState() ).toEqual ({ scene: 'deep', parents: [ 'top', 'mid' ], opened: true });
|
|
805
|
+
|
|
806
|
+
calls.length = 0;
|
|
807
|
+
await script.show ({ scene: 'other' });
|
|
808
|
+
expect ( calls ).toEqual ([ 'hide deep', 'hide mid', 'hide top', 'show other' ]);
|
|
809
|
+
}) // it SSR first load records the scene's parents, so leaving it hides them too
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
it ( 'afterShow return value has no effect on the completed show()', async () => {
|
|
814
|
+
// Regression test: setScenes.js's typedef documented afterShow as
|
|
815
|
+
// 'returns false to cancel', but show() never read its return value, so
|
|
816
|
+
// the scene was always shown regardless. The typedef is now corrected to
|
|
817
|
+
// describe the actual (README-documented) fire-and-forget behavior.
|
|
818
|
+
const calls = [];
|
|
819
|
+
const script = cuts();
|
|
820
|
+
const scenes = [
|
|
821
|
+
{
|
|
822
|
+
name: 'top'
|
|
823
|
+
, scene: {
|
|
824
|
+
show : ({task}) => { calls.push('show'); task.done() },
|
|
825
|
+
hide : ({task}) => task.done(),
|
|
826
|
+
afterShow : () => { calls.push('afterShow'); return false }
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
];
|
|
830
|
+
|
|
831
|
+
script.setScenes ( scenes );
|
|
832
|
+
await script.show ({ scene: 'top' });
|
|
833
|
+
|
|
834
|
+
expect ( calls ).toEqual ([ 'show', 'afterShow' ]);
|
|
835
|
+
expect ( script.getState() ).toEqual ({ scene: 'top', parents: [], opened: true });
|
|
836
|
+
}) // it afterShow return value has no effect on the completed show()
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
it ( 'hide() honors beforeHide, same as show() does', async () => {
|
|
841
|
+
// Regression test: hide() used to ignore beforeHide entirely, so it could
|
|
842
|
+
// never be blocked - even though show() already respected it when navigating
|
|
843
|
+
// away to a different scene.
|
|
844
|
+
const calls = [];
|
|
845
|
+
const script = cuts();
|
|
846
|
+
const scenes = [
|
|
847
|
+
{
|
|
848
|
+
name: 'top'
|
|
849
|
+
, scene: {
|
|
850
|
+
show : ({task}) => { calls.push('show top'); task.done() },
|
|
851
|
+
hide : ({task}) => { calls.push('hide top'); task.done() },
|
|
852
|
+
beforeHide : ({ done }) => { calls.push('beforeHide'); done ( false ) }
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
];
|
|
856
|
+
|
|
857
|
+
script.setScenes ( scenes );
|
|
858
|
+
await script.show ({ scene: 'top' });
|
|
859
|
+
calls.length = 0;
|
|
860
|
+
|
|
861
|
+
await script.hide ();
|
|
862
|
+
expect ( calls ).toEqual ([ 'beforeHide' ]); // hide() never actually ran
|
|
863
|
+
expect ( script.getState() ).toEqual ({ scene: 'top', parents: [], opened: true });
|
|
864
|
+
}) // it hide() honors beforeHide, same as show() does
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
it ( 'jump() does not record a jump-stack entry when the navigation is blocked', async () => {
|
|
869
|
+
// Regression test: jump() pushed onto the jump stack unconditionally, even when
|
|
870
|
+
// the underlying show() was blocked (eg. by beforeHide) and nothing actually
|
|
871
|
+
// changed - leaving a phantom entry that desynced jumpBack() from real history.
|
|
872
|
+
const calls = [];
|
|
873
|
+
const script = cuts();
|
|
874
|
+
let block = true;
|
|
875
|
+
const scenes = [
|
|
876
|
+
{
|
|
877
|
+
name: 'home'
|
|
878
|
+
, scene: {
|
|
879
|
+
show : ({task}) => { calls.push('show home'); task.done() },
|
|
880
|
+
hide : ({task}) => { calls.push('hide home'); task.done() },
|
|
881
|
+
beforeHide : ({ done }) => done ( !block )
|
|
882
|
+
}
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
name: 'settings'
|
|
886
|
+
, scene: {
|
|
887
|
+
show : ({task}) => { calls.push('show settings'); task.done() },
|
|
888
|
+
hide : ({task}) => { calls.push('hide settings'); task.done() }
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
name: 'other'
|
|
893
|
+
, scene: {
|
|
894
|
+
show : ({task}) => { calls.push('show other'); task.done() },
|
|
895
|
+
hide : ({task}) => { calls.push('hide other'); task.done() }
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
];
|
|
899
|
+
|
|
900
|
+
script.setScenes ( scenes );
|
|
901
|
+
await script.show ({ scene: 'home' });
|
|
902
|
+
|
|
903
|
+
await script.jump ({ scene: 'settings' }); // blocked by beforeHide - no stack entry
|
|
904
|
+
expect ( script.getState().scene ).toEqual ( 'home' );
|
|
905
|
+
|
|
906
|
+
block = false;
|
|
907
|
+
await script.jump ({ scene: 'other' }); // succeeds - exactly one real stack entry
|
|
908
|
+
expect ( script.getState().scene ).toEqual ( 'other' );
|
|
909
|
+
|
|
910
|
+
calls.length = 0;
|
|
911
|
+
await script.jumpBack ();
|
|
912
|
+
expect ( calls ).toEqual ([ 'hide other', 'show home' ]);
|
|
913
|
+
expect ( script.getState().scene ).toEqual ( 'home' );
|
|
914
|
+
|
|
915
|
+
calls.length = 0;
|
|
916
|
+
await script.jumpBack (); // stack should already be empty - true no-op
|
|
917
|
+
expect ( calls ).toEqual ([]);
|
|
918
|
+
expect ( script.getState().scene ).toEqual ( 'home' );
|
|
919
|
+
}) // it jump() does not record a jump-stack entry when the navigation is blocked
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
it ( 'Navigating from a wildcard overlay to an unrelated scene hides the scene it was covering', async () => {
|
|
924
|
+
// Regression test: findInstructions is a lazy generator, and show() passed it
|
|
925
|
+
// state.currentParents by reference. getStep's wildcard climb (state.currentParents.pop())
|
|
926
|
+
// mutated that same array mid-iteration, corrupting the generator's still-pending reads
|
|
927
|
+
// and silently dropping the 'hide' instruction for the scene the overlay was covering -
|
|
928
|
+
// leaking it as permanently visible.
|
|
929
|
+
const calls = [];
|
|
930
|
+
const script = cuts();
|
|
931
|
+
const scenes = [
|
|
932
|
+
{ name: 'G', scene: { show: ({task}) => { calls.push('show G'); task.done() }, hide: ({task}) => { calls.push('hide G'); task.done() } } },
|
|
933
|
+
{ name: 'OV', scene: { show: ({task}) => { calls.push('show OV'); task.done() }, hide: ({task}) => { calls.push('hide OV'); task.done() }, parents: ['*'] } },
|
|
934
|
+
{ name: 'D', scene: { show: ({task}) => { calls.push('show D'); task.done() }, hide: ({task}) => { calls.push('hide D'); task.done() } } }
|
|
935
|
+
];
|
|
936
|
+
|
|
937
|
+
script.setScenes ( scenes );
|
|
938
|
+
await script.show ({ scene: 'G' });
|
|
939
|
+
await script.show ({ scene: 'OV' });
|
|
940
|
+
calls.length = 0;
|
|
941
|
+
|
|
942
|
+
await script.show ({ scene: 'D' });
|
|
943
|
+
expect ( calls ).toEqual ([ 'hide OV', 'hide G', 'show D' ]);
|
|
944
|
+
expect ( script.getState() ).toEqual ({ scene: 'D', parents: [], opened: true });
|
|
945
|
+
}) // it Navigating from a wildcard overlay to an unrelated scene hides the scene it was covering
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
it ( 'Showing a wildcard overlay with no underlying scene does not crash later navigation', async () => {
|
|
950
|
+
// Regression test: showing an overlay when state.currentScene was null recorded a
|
|
951
|
+
// literal 'null' placeholder in currentParents. Navigating away from it later crashed,
|
|
952
|
+
// because findInstructions/getStep treated that placeholder as a real scene name to hide.
|
|
953
|
+
const script = cuts();
|
|
954
|
+
const scenes = [
|
|
955
|
+
{ name: 'F', scene: { show: ({task}) => task.done(), hide: ({task}) => task.done() } },
|
|
956
|
+
{ name: 'OV', scene: { show: ({task}) => task.done(), hide: ({task}) => task.done(), parents: ['*'] } },
|
|
957
|
+
{ name: 'A', scene: { show: ({task}) => task.done(), hide: ({task}) => task.done() } }
|
|
958
|
+
];
|
|
959
|
+
|
|
960
|
+
script.setScenes ( scenes );
|
|
961
|
+
await script.show ({ scene: 'F' });
|
|
962
|
+
await script.hide ( 1 ); // back to nothing - currentScene becomes null
|
|
963
|
+
await script.show ({ scene: 'OV' }); // overlay with no underlying scene
|
|
964
|
+
|
|
965
|
+
expect ( script.getState() ).toEqual ({ scene: 'OV', parents: [], opened: true });
|
|
966
|
+
|
|
967
|
+
await script.show ({ scene: 'A' }); // used to throw
|
|
968
|
+
expect ( script.getState() ).toEqual ({ scene: 'A', parents: [], opened: true });
|
|
969
|
+
}) // it Showing a wildcard overlay with no underlying scene does not crash later navigation
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
it ( 'Re-showing the same wildcard overlay does not push it onto its own ancestor chain', async () => {
|
|
974
|
+
// Regression test: showing an overlay while it was ALREADY the current scene pushed
|
|
975
|
+
// it onto its own currentParents (self-reference). A later hide() would then pop that
|
|
976
|
+
// self-reference and report the overlay as still current, even though it had just been
|
|
977
|
+
// hidden - a state/reality desync.
|
|
978
|
+
const script = cuts();
|
|
979
|
+
const visible = new Set();
|
|
980
|
+
const scenes = [
|
|
981
|
+
{ name: 'C', scene: { show: ({task}) => { visible.add('C'); task.done() }, hide: ({task}) => { visible.delete('C'); task.done() } } },
|
|
982
|
+
{ name: 'OV', scene: { show: ({task}) => { visible.add('OV'); task.done() }, hide: ({task}) => { visible.delete('OV'); task.done() }, parents: ['*'] } }
|
|
983
|
+
];
|
|
984
|
+
|
|
985
|
+
script.setScenes ( scenes );
|
|
986
|
+
await script.show ({ scene: 'C' });
|
|
987
|
+
await script.show ({ scene: 'OV' });
|
|
988
|
+
await script.show ({ scene: 'OV' }); // show the same overlay again while already current
|
|
989
|
+
|
|
990
|
+
expect ( script.getState() ).toEqual ({ scene: 'OV', parents: [ 'C' ], opened: true });
|
|
991
|
+
|
|
992
|
+
await script.hide ( 1 );
|
|
993
|
+
expect ( script.getState() ).toEqual ({ scene: 'C', parents: [], opened: true });
|
|
994
|
+
expect ( [...visible] ).toEqual ([ 'C' ]); // OV must actually be gone, matching reported state
|
|
995
|
+
}) // it Re-showing the same wildcard overlay does not push it onto its own ancestor chain
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
|
|
661
999
|
}) // describe
|
package/types/main.d.ts
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
|
+
export type CutsConfig = {
|
|
2
|
+
/**
|
|
3
|
+
* - Logging level. `1` emits '@app-error' events; `0` silences them silently.
|
|
4
|
+
*/
|
|
5
|
+
logLevel?: 0 | 1;
|
|
6
|
+
};
|
|
7
|
+
export type pluginNames = 'Key' | 'Click' | 'Form' | 'Hover' | 'Scroll';
|
|
8
|
+
export type CutsState = {
|
|
9
|
+
/**
|
|
10
|
+
* - current scene name
|
|
11
|
+
*/
|
|
12
|
+
scene: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* - current parent scene names
|
|
15
|
+
*/
|
|
16
|
+
parents: Array<string> | null;
|
|
17
|
+
/**
|
|
18
|
+
* - whether the scene manager is opened
|
|
19
|
+
*/
|
|
20
|
+
opened: boolean;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Cuts
|
|
24
|
+
* @param {CutsConfig} [cfg] - configuration object
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {Object} CutsConfig
|
|
28
|
+
* @property {0|1} [logLevel=1] - Logging level. `1` emits '@app-error' events; `0` silences them silently.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {'Key'|'Click'|'Form'|'Hover'|'Scroll'} pluginNames
|
|
32
|
+
* @description List of available shortcut plugins.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {Object} CutsState
|
|
36
|
+
* @property {string|null} scene - current scene name
|
|
37
|
+
* @property {Array.<string>|null} parents - current parent scene names
|
|
38
|
+
* @property {boolean} opened - whether the scene manager is opened
|
|
39
|
+
*/
|
|
1
40
|
declare function main(cfg?: {}): {
|
|
2
|
-
hide: (endSteps?: number | string) => Promise<
|
|
41
|
+
hide: (endSteps?: number | string) => Promise<void>;
|
|
3
42
|
listShortcuts: (sceneName: string) => (Array<string> | null);
|
|
4
43
|
setScenes: (list: import("./methods/setScenes.js").sceneDescription[]) => void;
|
|
5
44
|
show: ({ scene: requestedScene, options }: {
|
|
@@ -74,12 +113,9 @@ declare function main(cfg?: {}): {
|
|
|
74
113
|
/**
|
|
75
114
|
* Get the current state of the application
|
|
76
115
|
* @function getState
|
|
77
|
-
* @returns {
|
|
78
|
-
* - scene: current scene name
|
|
79
|
-
* - parents: current parent scene names
|
|
80
|
-
* - opened: boolean indicating if the application is opened
|
|
116
|
+
* @returns {CutsState} current scene, parents, and opened flag
|
|
81
117
|
*/
|
|
82
|
-
getState: () =>
|
|
118
|
+
getState: () => CutsState;
|
|
83
119
|
/**
|
|
84
120
|
* @function emit
|
|
85
121
|
* @description Emit an event
|
package/types/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.js"],"names":[],"mappings":"AA4CG,YAAkB,UAAU,GAC5B;;;;IAAiB,QAAQ,AAAzB,CACF,EADa,CAAC,GAAC,CAAC,CAChB;CAAA,CAAA;AAGE,YAAiD,WAAW,GAAlD,KAAK,GAAC,OAAO,GAAC,MAAM,GAAC,OAAO,GAAC,QAAQ,CAAa;AAK5D,YAAkB,SAAS,GAC3B;;;;IAAwB,KAAK,EAAlB,MAAM,GAAC,IAAI,CACtB;;;;IAAgC,OAAO,EAA5B,KAAK,CAAE,MAAM,CAAC,GAAC,IAAI,CAC9B;;;;IAAoB,MAAM,EAAf,OAAO,CACpB;CAAA,CAAA;AApBD;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;;GAKG;AAEH,iBAAS,IAAI,CAAG,GAAG,KAAK;;;;;;;;;;;;;;;;;IA2ChB;;;;;;;;;;;;;;OAcG;2BAPQ,KAAK,+CAAc,KACjB,OAAO,CAAE,UAAU,CAAC;IAajC;;;;;OAKG;4BAFQ,GAAC;IAKZ;;;;OAIG;2BADU,GAAC;IAId;;;;OAIG;oBAFQ,MAAM;IAKjB;;;;OAIG;sBADU,KAAK,CAAE,MAAM,CAAC;IAI3B;;;;;;OAMG;+CAFQ,GAAC;IAKZ;;;;;OAKG;gCAFQ,MAAM;IAKhB;;;;OAIG;oBADU,SAAS;IAUtB;;;;;;OAMG;kBAHQ,MAAM,WACH,GAAC,EAAA;EAOvB;eAIc,IAAI"}
|
package/types/methods/hide.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hide.d.ts","sourceRoot":"","sources":["../../src/methods/hide.js"],"names":[],"mappings":"AAIA,iBAAS,IAAI,CAAG,YAAY,KAAA,EAAE,KAAK,KAAA,eAIxB,MAAM,GAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"hide.d.ts","sourceRoot":"","sources":["../../src/methods/hide.js"],"names":[],"mappings":"AAIA,iBAAS,IAAI,CAAG,YAAY,KAAA,EAAE,KAAK,KAAA,eAIxB,MAAM,GAAC,MAAM,KACX,OAAO,CAAC,IAAI,CAAC,CA0DxB;eAIa,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jump.d.ts","sourceRoot":"","sources":["../../src/methods/jump.js"],"names":[],"mappings":"AAAA,iBAAS,IAAI,CAAG,KAAK,KAAA,EAAE,IAAI,KAAA,eAKpB;IAAwB,KAAK,EAArB,MAAM,CACd;CAAA,
|
|
1
|
+
{"version":3,"file":"jump.d.ts","sourceRoot":"","sources":["../../src/methods/jump.js"],"names":[],"mappings":"AAAA,iBAAS,IAAI,CAAG,KAAK,KAAA,EAAE,IAAI,KAAA,eAKpB;IAAwB,KAAK,EAArB,MAAM,CACd;CAAA,mCAaN;eAIc,IAAI"}
|
|
@@ -10,7 +10,7 @@ export type SceneObject = {
|
|
|
10
10
|
*/
|
|
11
11
|
: Function;
|
|
12
12
|
/**
|
|
13
|
-
* ():
|
|
13
|
+
* ({dependencies: *, done: function}):void} [afterShow] - run after the scene is shown. Optional. Fire-and-forget - its return value is not used, and it cannot cancel or affect the already-completed 'show';
|
|
14
14
|
*/
|
|
15
15
|
: Function;
|
|
16
16
|
/**
|
|
@@ -47,7 +47,7 @@ export type sceneDescription = {
|
|
|
47
47
|
/**
|
|
48
48
|
* @typedef {Object} SceneObject
|
|
49
49
|
* @property {function({task: AskObject, dependencies: *}): void} show - load interface and prerequisites for the scene;
|
|
50
|
-
* @property {function():
|
|
50
|
+
* @property {function({dependencies: *, done: function}):void} [afterShow] - run after the scene is shown. Optional. Fire-and-forget - its return value is not used, and it cannot cancel or affect the already-completed 'show';
|
|
51
51
|
* @property {function({task: AskObject, dependencies: *}): void} hide - Reverse the settings from 'show';
|
|
52
52
|
* @property {function():void} [beforeHide] - Run before scene is hidden. Optional;
|
|
53
53
|
* @property {Array.<string>} [parents] - list of parent scene names.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../src/methods/show.js"],"names":[],"mappings":"AAIA,iBAAS,IAAI,CAAG,YAAY,KAAA,EAAE,KAAK,KAAA,wCAKhC;IAAwB,KAAK,EAArB,MAAM,CACd;IAAyB,OAAO,AAAhC,CAEA,EADA;QAAiC,GAAG,EAA5B,OAAO,CACf;KAAA,CAAA;CAAA,
|
|
1
|
+
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../src/methods/show.js"],"names":[],"mappings":"AAIA,iBAAS,IAAI,CAAG,YAAY,KAAA,EAAE,KAAK,KAAA,wCAKhC;IAAwB,KAAK,EAArB,MAAM,CACd;IAAyB,OAAO,AAAhC,CAEA,EADA;QAAiC,GAAG,EAA5B,OAAO,CACf;KAAA,CAAA;CAAA,mCAsIF;eAIc,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setInstruction.d.ts","sourceRoot":"","sources":["../src/setInstruction.js"],"names":[],"mappings":"AAEA,iBAAS,cAAc,CAAG,YAAY,KAAA,2BAKpB,GAAC,EAAA,
|
|
1
|
+
{"version":3,"file":"setInstruction.d.ts","sourceRoot":"","sources":["../src/setInstruction.js"],"names":[],"mappings":"AAEA,iBAAS,cAAc,CAAG,YAAY,KAAA,2BAKpB,GAAC,EAAA,cAcjB;eAIa,cAAc"}
|
package/vitest.config.js
CHANGED
|
@@ -3,7 +3,7 @@ import { defineConfig } from 'vitest/config'
|
|
|
3
3
|
export default defineConfig({
|
|
4
4
|
test: {
|
|
5
5
|
environment: 'node',
|
|
6
|
-
exclude: ['test-e2e/**', 'node_modules/**'],
|
|
6
|
+
exclude: ['test-e2e/**', '**/node_modules/**'],
|
|
7
7
|
coverage: {
|
|
8
8
|
provider: 'v8',
|
|
9
9
|
reporter: ['lcov', 'text-summary'],
|