@peter.naydenov/cuts 1.5.0 → 2.0.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/Changelog.md +53 -7
- package/Migration.guide.md +93 -0
- package/README.md +30 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/findInstructions.js.html +352 -0
- package/coverage/lcov-report/src/index.html +146 -0
- package/coverage/lcov-report/src/main.js.html +610 -0
- package/coverage/lcov-report/src/methods/hide.js.html +244 -0
- package/coverage/lcov-report/src/methods/index.html +206 -0
- package/coverage/lcov-report/src/methods/jump.js.html +148 -0
- package/coverage/lcov-report/src/methods/jumpBack.js.html +157 -0
- package/coverage/lcov-report/src/methods/jumpsReset.js.html +133 -0
- package/coverage/lcov-report/src/methods/listShortcuts.js.html +148 -0
- package/coverage/lcov-report/src/methods/setScenes.js.html +313 -0
- package/coverage/lcov-report/src/methods/show.js.html +466 -0
- package/coverage/lcov-report/src/setInstruction.js.html +157 -0
- package/coverage/lcov.info +461 -0
- package/cypress/support/component-index.html +11 -0
- package/dist/cuts.cjs +1 -1
- package/dist/cuts.esm.mjs +1 -1
- package/dist/cuts.umd.js +1 -1
- package/package.json +12 -12
- package/src/findInstructions.js +0 -6
- package/src/main.js +13 -6
- package/src/methods/setScenes.js +27 -11
- package/src/methods/show.js +26 -27
- package/test/01-general.cy.js +348 -0
- package/test/blue.vue +13 -0
- package/test/dummy.vue +34 -0
- package/test/gray.vue +12 -0
- package/test/red.vue +11 -0
- package/tsconfig.json +13 -10
- package/types/findInstructions.d.ts.map +1 -1
- package/types/main.d.ts +2 -2
- package/types/main.d.ts.map +1 -1
- package/types/methods/setScenes.d.ts +20 -4
- package/types/methods/setScenes.d.ts.map +1 -1
- package/types/methods/show.d.ts.map +1 -1
- package/test-vitest/01-findPosition.test.js +0 -119
- package/test-vitest/02-cuts.test.js +0 -56
package/test/gray.vue
ADDED
package/test/red.vue
ADDED
package/tsconfig.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"include": ["./src/**/*"],
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
"exclude": ["./test-vitest/**/*"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"checkJs": false,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"emitDeclarationOnly": true,
|
|
9
|
+
"outDir": "types",
|
|
10
|
+
"declarationMap": true,
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"target": "ES2022",
|
|
13
|
+
"module": "ES2022",
|
|
14
|
+
"skipLibCheck": true
|
|
15
|
+
}
|
|
13
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findInstructions.d.ts","sourceRoot":"","sources":["../src/findInstructions.js"],"names":[],"mappings":";AAGA;;;;;;;;GAQG;AACH,+CANW,MAAM,GAAC,IAAI,kBACX,KAAK,CAAE,MAAM,CAAC,cACd,MAAM,iBACN,KAAK,CAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"findInstructions.d.ts","sourceRoot":"","sources":["../src/findInstructions.js"],"names":[],"mappings":";AAGA;;;;;;;;GAQG;AACH,+CANW,MAAM,GAAC,IAAI,kBACX,KAAK,CAAE,MAAM,CAAC,cACd,MAAM,iBACN,KAAK,CAAE,MAAM,CAAC,sCAyExB"}
|
package/types/main.d.ts
CHANGED
|
@@ -18,10 +18,10 @@ declare function main(cfg?: {
|
|
|
18
18
|
hops?: number;
|
|
19
19
|
}, ...args?: any[]) => Promise<any> | undefined;
|
|
20
20
|
jumpsReset: () => void;
|
|
21
|
-
loadPlugins(plugins: Array<"Key" | "Click" | "Form">): Promise<Function[]>;
|
|
21
|
+
loadPlugins(plugins: Array<"Key" | "Click" | "Form" | "Hover" | "Scroll">): Promise<Function[]>;
|
|
22
22
|
setDependencies(deps: any): void;
|
|
23
23
|
getDependencies(): any;
|
|
24
|
-
setNote(note: string):
|
|
24
|
+
setNote(note: string): void;
|
|
25
25
|
listScenes(): Array<string>;
|
|
26
26
|
enablePlugin(plugin: Function, options?: any): void;
|
|
27
27
|
disablePlugin(pluginName: string): void;
|
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":";AAsCA;;;;;;;;;;;;;;;;;;;yBA8CmB,KAAK,+CAAc,GACjB,OAAO,CAAE,UAAU,CAAC;0BAgBtB,GAAC;uBAQC,GAAC;kBAMH,MAAM;kBAQJ,KAAK,CAAE,MAAM,CAAC;6CAQhB,GAAC;8BAQD,MAAM;;gBAuBL,MAAM,WACH,GAAC,EAAA;EAKvB"}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
export default setScenes;
|
|
2
|
+
export type AskObject = {
|
|
3
|
+
/**
|
|
4
|
+
* - Mark the task as done
|
|
5
|
+
*/
|
|
6
|
+
done: Function;
|
|
7
|
+
};
|
|
2
8
|
export type SceneObject = {
|
|
3
9
|
/**
|
|
4
10
|
* - load interface and prerequisites for the scene;
|
|
5
11
|
*/
|
|
6
|
-
show:
|
|
12
|
+
show: (arg0: {
|
|
13
|
+
task: AskObject;
|
|
14
|
+
dependencies: any;
|
|
15
|
+
}) => void;
|
|
7
16
|
/**
|
|
8
17
|
* - run after scene is loaded. Optional. Returns true to continue loading, false to cancel;
|
|
9
18
|
*/
|
|
@@ -11,7 +20,10 @@ export type SceneObject = {
|
|
|
11
20
|
/**
|
|
12
21
|
* - Reverse the settings from 'show';
|
|
13
22
|
*/
|
|
14
|
-
hide: (
|
|
23
|
+
hide: (arg0: {
|
|
24
|
+
task: AskObject;
|
|
25
|
+
dependencies: any;
|
|
26
|
+
}) => void;
|
|
15
27
|
/**
|
|
16
28
|
* - Run before scene is hidden. Optional;
|
|
17
29
|
*/
|
|
@@ -35,11 +47,15 @@ export type sceneDescription = {
|
|
|
35
47
|
*/
|
|
36
48
|
scene: SceneObject;
|
|
37
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {Object} AskObject
|
|
52
|
+
* @property {function} done - Mark the task as done
|
|
53
|
+
*/
|
|
38
54
|
/**
|
|
39
55
|
* @typedef {Object} SceneObject
|
|
40
|
-
* @property {function} show - load interface and prerequisites for the scene;
|
|
56
|
+
* @property {function({task: AskObject, dependencies: *}): void} show - load interface and prerequisites for the scene;
|
|
41
57
|
* @property {function():boolean} [afterShow] - run after scene is loaded. Optional. Returns true to continue loading, false to cancel;
|
|
42
|
-
* @property {function():void} hide - Reverse the settings from 'show';
|
|
58
|
+
* @property {function({task: AskObject, dependencies: *}): void} hide - Reverse the settings from 'show';
|
|
43
59
|
* @property {function():void} [beforeHide] - Run before scene is hidden. Optional;
|
|
44
60
|
* @property {Array.<string>} [parents] - list of parent scene names.
|
|
45
61
|
* @property {*} ... - shortcut descriptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setScenes.d.ts","sourceRoot":"","sources":["../../src/methods/setScenes.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setScenes.d.ts","sourceRoot":"","sources":["../../src/methods/setScenes.js"],"names":[],"mappings":";;;;;;;;;;;UASc,CAAS,IAAkC,EAAlC;QAAC,IAAI,EAAE,SAAS,CAAC;QAAC,YAAY,EAAE,GAAC,CAAA;KAAC,KAAG,IAAI;;;;gBAClD,MAAW,OAAO;;;;UAClB,CAAS,IAAkC,EAAlC;QAAC,IAAI,EAAE,SAAS,CAAC;QAAC,YAAY,EAAE,GAAC,CAAA;KAAC,KAAG,IAAI;;;;iBAClD,MAAW,IAAI;;;;cACf,KAAK,CAAE,MAAM,CAAC;;;;QACd,GAAC;;;;;;UAOD,MAAM;;;;WACN,WAAW;;AAnBzB;;;GAGG;AACH;;;;;;;;GAQG;AAIH;;;;GAIG;AAKH,4DAOgC,MAJhB,gBAAgB,EAII,UAkClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../src/methods/show.js"],"names":[],"mappings":";AAIA,2FAKG;IAAwB,KAAK,EAArB,MAAM;IACW,OAAO,GAChC;QAAiC,GAAG,EAA5B,OAAO;KACf;CAAA,
|
|
1
|
+
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../src/methods/show.js"],"names":[],"mappings":";AAIA,2FAKG;IAAwB,KAAK,EAArB,MAAM;IACW,OAAO,GAChC;QAAiC,GAAG,EAA5B,OAAO;KACf;CAAA,mCA4GF"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import findInstructions from "../src/findInstructions.js"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe ( 'Find a Position', () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
it ( 'Switch top level scenes', () => {
|
|
11
|
-
let result = []
|
|
12
|
-
let g = findInstructions ( 'old', [], 'new', [] )
|
|
13
|
-
|
|
14
|
-
for (const n of g) { result.push(n) }
|
|
15
|
-
|
|
16
|
-
expect(result.length).toBe ( 2 )
|
|
17
|
-
expect(result[0][0]).toBe ( 'old' )
|
|
18
|
-
expect(result[0][1]).toBe ( 'hide' )
|
|
19
|
-
|
|
20
|
-
expect(result[1][0]).toBe ( 'new' )
|
|
21
|
-
expect(result[1][1]).toBe ( 'show' )
|
|
22
|
-
}) // it switch top level scenes
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
it ( 'Switch from child scene to top level scene', () => {
|
|
27
|
-
let result = []
|
|
28
|
-
let g = findInstructions ( 'old', ['one', 'two'], 'new', [] )
|
|
29
|
-
|
|
30
|
-
for (const n of g) { result.push(n) }
|
|
31
|
-
|
|
32
|
-
expect(result[0]).toEqual(['old', 'hide'])
|
|
33
|
-
expect(result[1]).toEqual(['two', 'hide'])
|
|
34
|
-
expect(result[2]).toEqual(['one', 'hide'])
|
|
35
|
-
expect(result[3]).toEqual(['new', 'show'])
|
|
36
|
-
}) // it switch from child scene to top level scene
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
it ( 'Switch to child scene', () => {
|
|
41
|
-
let result = []
|
|
42
|
-
let g = findInstructions ( 'old', ['bla'], 'new', ['old', 'two', 'three'])
|
|
43
|
-
for (const n of g) { result.push(n) }
|
|
44
|
-
|
|
45
|
-
expect(result).toHaveLength(3)
|
|
46
|
-
expect(result[0]).toEqual(['two', 'show'])
|
|
47
|
-
expect(result[1]).toEqual(['three', 'show'])
|
|
48
|
-
expect(result[2]).toEqual(['new', 'show'])
|
|
49
|
-
}) // it switch to child scene
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
it ( 'From child scene to other siblings scene', () => {
|
|
54
|
-
let result = []
|
|
55
|
-
let g = findInstructions('old', ['two', 'three'], 'new', ['two', 'three'])
|
|
56
|
-
for (const n of g) { result.push(n) }
|
|
57
|
-
|
|
58
|
-
expect(result).toHaveLength ( 2 )
|
|
59
|
-
expect(result[0]).toEqual(['old', 'hide'])
|
|
60
|
-
expect(result[1]).toEqual(['new', 'show'])
|
|
61
|
-
}) // it from top level scene to not own child scene
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
it ( 'From top level scene to not own child scene', () => {
|
|
66
|
-
let result = []
|
|
67
|
-
let g = findInstructions('old', undefined, 'new', ['two', 'three'])
|
|
68
|
-
for (const n of g) { result.push(n) }
|
|
69
|
-
|
|
70
|
-
expect(result).toHaveLength(3)
|
|
71
|
-
expect(result[0]).toEqual(['old', 'hide'])
|
|
72
|
-
expect(result[1]).toEqual(['two', 'show'])
|
|
73
|
-
expect(result[2]).toEqual(['three', 'show'])
|
|
74
|
-
}) // it from top level scene to not own child scene
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
it ( 'Long chain of parents', () => {
|
|
79
|
-
let result = []
|
|
80
|
-
let g = findInstructions('old', ['one', 'branch'], 'new', ['one', 'two', 'three'])
|
|
81
|
-
for (const n of g) { result.push(n) }
|
|
82
|
-
|
|
83
|
-
expect(result).toHaveLength(5)
|
|
84
|
-
expect(result[0]).toEqual(['old', 'hide'])
|
|
85
|
-
expect(result[1]).toEqual(['branch', 'hide'])
|
|
86
|
-
expect(result[2]).toEqual(['two', 'show'])
|
|
87
|
-
expect(result[3]).toEqual(['three', 'show'])
|
|
88
|
-
expect(result[4]).toEqual(['new', 'show'])
|
|
89
|
-
}) // it long chain of parents
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
it ( 'Different branches', () => {
|
|
94
|
-
let result = []
|
|
95
|
-
let g = findInstructions('old', ['something', 'branch'], 'new', ['one', 'two', 'three'])
|
|
96
|
-
for (const n of g) { result.push(n) }
|
|
97
|
-
|
|
98
|
-
expect(result).toHaveLength(7)
|
|
99
|
-
expect(result[0]).toEqual(['old', 'hide'])
|
|
100
|
-
expect(result[1]).toEqual(['branch', 'hide'])
|
|
101
|
-
expect(result[2]).toEqual(['something', 'hide'])
|
|
102
|
-
expect(result[3]).toEqual(['one', 'show'])
|
|
103
|
-
expect(result[4]).toEqual(['two', 'show'])
|
|
104
|
-
expect(result[5]).toEqual(['three', 'show'])
|
|
105
|
-
expect(result[6]).toEqual(['new', 'show'])
|
|
106
|
-
}) // it long chain of parents
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
it ( 'Target scene is in the list of parents of the current scene', () => {
|
|
111
|
-
let result = []
|
|
112
|
-
let g = findInstructions ( 'token-get-role', ['tokens', 'token-pop'], 'tokens', [] )
|
|
113
|
-
for (const n of g) { result.push(n) }
|
|
114
|
-
expect ( result ).toHaveLength ( 2 )
|
|
115
|
-
expect ( result[0] ).toEqual ( [ 'token-get-role', 'hide' ])
|
|
116
|
-
expect ( result[1] ).toEqual ( [ 'token-pop', 'hide' ])
|
|
117
|
-
}) // it Target scene is in the list of parents of the current scene
|
|
118
|
-
|
|
119
|
-
}) // describe
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import cuts from "../src/main.js"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe ( 'Cuts integration', () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
it ( 'Open a scene, and 2 levels deep child', async () => {
|
|
11
|
-
const calls = [];
|
|
12
|
-
|
|
13
|
-
const scenes = [
|
|
14
|
-
{ name: 'top', scene: { show: ({task}) => { calls.push('show top'); task.done() }, hide: ({task}) => { calls.push('hide top'); task.done() } } },
|
|
15
|
-
{ name: 'mid', scene: { show: ({task}) => { calls.push('show mid'); task.done() }, hide: ({task}) => { calls.push('hide mid'); task.done() }, parents: ['top'] } },
|
|
16
|
-
{ name: 'deep', scene: { show: ({task}) => { calls.push('show deep'); task.done() }, hide: ({task}) => { calls.push('hide deep'); task.done() }, parents: ['top', 'mid'] } }
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
const script = cuts()
|
|
20
|
-
script.setScenes ( scenes )
|
|
21
|
-
|
|
22
|
-
await script.show ({ scene: 'top' })
|
|
23
|
-
expect ( calls ).toEqual ([ 'show top' ])
|
|
24
|
-
|
|
25
|
-
await script.show ({ scene: 'deep' })
|
|
26
|
-
expect ( calls ).toEqual ([
|
|
27
|
-
'show top',
|
|
28
|
-
'show mid',
|
|
29
|
-
'show deep'
|
|
30
|
-
])
|
|
31
|
-
|
|
32
|
-
await script.show ({ scene: 'top' })
|
|
33
|
-
expect ( calls ).toEqual ([
|
|
34
|
-
'show top',
|
|
35
|
-
'show mid',
|
|
36
|
-
'show deep',
|
|
37
|
-
'hide deep',
|
|
38
|
-
'hide mid'
|
|
39
|
-
])
|
|
40
|
-
|
|
41
|
-
await script.show ({ scene: 'deep' })
|
|
42
|
-
expect ( calls ).toEqual ([
|
|
43
|
-
'show top',
|
|
44
|
-
'show mid',
|
|
45
|
-
'show deep',
|
|
46
|
-
'hide deep',
|
|
47
|
-
'hide mid',
|
|
48
|
-
'show mid',
|
|
49
|
-
'show deep'
|
|
50
|
-
])
|
|
51
|
-
}) // it Open a scene, and 2 levels deep child
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}) // describe
|