@peter.naydenov/cuts 1.6.0 → 2.0.1
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 +9 -1
- package/Migration.guide.md +93 -0
- package/README.md +52 -8
- 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/cuts.png +0 -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 +15 -15
- package/src/main.js +6 -4
- 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 +14 -10
- package/types/main.d.ts +5 -5
- package/types/main.d.ts.map +1 -1
- package/types/methods/jumpBack.d.ts +1 -1
- package/types/methods/jumpBack.d.ts.map +1 -1
- package/types/methods/setScenes.d.ts +3 -3
- package/types/methods/setScenes.d.ts.map +1 -1
- package/types/methods/show.d.ts +1 -1
- package/types/methods/show.d.ts.map +1 -1
- package/types/src/findInstructions.d.ts +12 -0
- package/types/src/findInstructions.d.ts.map +1 -0
- package/types/src/main.d.ts +31 -0
- package/types/src/main.d.ts.map +1 -0
- package/types/src/methods/hide.d.ts +3 -0
- package/types/src/methods/hide.d.ts.map +1 -0
- package/types/src/methods/jump.d.ts +5 -0
- package/types/src/methods/jump.d.ts.map +1 -0
- package/types/src/methods/jumpBack.d.ts +5 -0
- package/types/src/methods/jumpBack.d.ts.map +1 -0
- package/types/src/methods/jumpsReset.d.ts +3 -0
- package/types/src/methods/jumpsReset.d.ts.map +1 -0
- package/types/src/methods/listShortcuts.d.ts +3 -0
- package/types/src/methods/listShortcuts.d.ts.map +1 -0
- package/types/src/methods/setScenes.d.ts +69 -0
- package/types/src/methods/setScenes.d.ts.map +1 -0
- package/types/src/methods/show.d.ts +8 -0
- package/types/src/methods/show.d.ts.map +1 -0
- package/types/src/setInstruction.d.ts +3 -0
- package/types/src/setInstruction.d.ts.map +1 -0
- package/test-vitest/01-findPosition.test.js +0 -119
- package/test-vitest/02-cuts.test.js +0 -412
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export default main;
|
|
2
|
+
declare function main(cfg?: {
|
|
3
|
+
logLevel: number;
|
|
4
|
+
}): {
|
|
5
|
+
hide: (endSteps?: number | string) => Promise<any>;
|
|
6
|
+
listShortcuts: (sceneName: string) => (Array<string> | null);
|
|
7
|
+
setScenes: (list: import("./methods/setScenes.js").sceneDescription[]) => void;
|
|
8
|
+
show: ({ scene: requestedScene, options }: {
|
|
9
|
+
scene: string;
|
|
10
|
+
options?: {
|
|
11
|
+
ssr: boolean;
|
|
12
|
+
} | undefined;
|
|
13
|
+
}, ...args?: any[]) => Promise<any>;
|
|
14
|
+
jump: ({ scene }: {
|
|
15
|
+
scene: string;
|
|
16
|
+
}, ...args?: any[]) => Promise<any>;
|
|
17
|
+
jumpBack: ({ hops }?: {
|
|
18
|
+
hops?: number | undefined;
|
|
19
|
+
}, ...args?: any[]) => Promise<any> | undefined;
|
|
20
|
+
jumpsReset: () => void;
|
|
21
|
+
loadPlugins(plugins: Array<"Key" | "Click" | "Form" | "Hover" | "Scroll">): Promise<Function[]>;
|
|
22
|
+
setDependencies(deps: any): void;
|
|
23
|
+
getDependencies(): any;
|
|
24
|
+
setNote(note: string): void;
|
|
25
|
+
listScenes(): Array<string>;
|
|
26
|
+
enablePlugin(plugin: Function, options?: any): void;
|
|
27
|
+
disablePlugin(pluginName: string): void;
|
|
28
|
+
getState(): Object;
|
|
29
|
+
emit(event: string, ...args: any[]): void;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;gBAQJ,MAAM;gBAeP,MAAM,WACH,GAAC,EAAA;EAKvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hide.d.ts","sourceRoot":"","sources":["../../../src/methods/hide.js"],"names":[],"mappings":";AAIA,uDAOuB,WAHZ,MAAM,GAAC,MAGe,kBAmC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jump.d.ts","sourceRoot":"","sources":["../../../src/methods/jump.js"],"names":[],"mappings":";AAAA,0DAKO;IAAwB,KAAK,EAArB,MAAM;CACd,mCAQN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jumpBack.d.ts","sourceRoot":"","sources":["../../../src/methods/jumpBack.js"],"names":[],"mappings":";AAAA,8DAKO;IAAyB,IAAI;CAC7B,sBACU,eAAQ,SAAS,CAWjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jumpsReset.d.ts","sourceRoot":"","sources":["../../../src/methods/jumpsReset.js"],"names":[],"mappings":";AAAA,+CAIiB,IAAI,CAKpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listShortcuts.d.ts","sourceRoot":"","sources":["../../../src/methods/listShortcuts.js"],"names":[],"mappings":";AAEA,gEAOgC,WAHrB,MAG8B,KAF5B,CAAC,KAAK,CAAE,MAAM,CAAC,GAAC,IAAI,CAAC,CAOhC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export default setScenes;
|
|
2
|
+
export type AskObject = {
|
|
3
|
+
/**
|
|
4
|
+
* - Mark the task as done
|
|
5
|
+
*/
|
|
6
|
+
done: Function;
|
|
7
|
+
};
|
|
8
|
+
export type SceneObject = {
|
|
9
|
+
/**
|
|
10
|
+
* - load interface and prerequisites for the scene;
|
|
11
|
+
*/
|
|
12
|
+
show: (arg0: {
|
|
13
|
+
task: AskObject;
|
|
14
|
+
dependencies: any;
|
|
15
|
+
}) => void;
|
|
16
|
+
/**
|
|
17
|
+
* - run after scene is loaded. Optional. Returns true to continue loading, false to cancel;
|
|
18
|
+
*/
|
|
19
|
+
afterShow?: (() => boolean) | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* - Reverse the settings from 'show';
|
|
22
|
+
*/
|
|
23
|
+
hide: (arg0: {
|
|
24
|
+
task: AskObject;
|
|
25
|
+
dependencies: any;
|
|
26
|
+
}) => void;
|
|
27
|
+
/**
|
|
28
|
+
* - Run before scene is hidden. Optional;
|
|
29
|
+
*/
|
|
30
|
+
beforeHide?: (() => void) | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* - list of parent scene names.
|
|
33
|
+
*/
|
|
34
|
+
parents?: string[] | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* - shortcut descriptions
|
|
37
|
+
*/
|
|
38
|
+
"": any;
|
|
39
|
+
};
|
|
40
|
+
export type sceneDescription = {
|
|
41
|
+
/**
|
|
42
|
+
* - name of the scene
|
|
43
|
+
*/
|
|
44
|
+
name: string;
|
|
45
|
+
/**
|
|
46
|
+
* - object should contain 'show' and 'hide' + shortcuts and action functions
|
|
47
|
+
*/
|
|
48
|
+
scene: SceneObject;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {Object} AskObject
|
|
52
|
+
* @property {function} done - Mark the task as done
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* @typedef {Object} SceneObject
|
|
56
|
+
* @property {function({task: AskObject, dependencies: *}): void} show - load interface and prerequisites for the scene;
|
|
57
|
+
* @property {function():boolean} [afterShow] - run after scene is loaded. Optional. Returns true to continue loading, false to cancel;
|
|
58
|
+
* @property {function({task: AskObject, dependencies: *}): void} hide - Reverse the settings from 'show';
|
|
59
|
+
* @property {function():void} [beforeHide] - Run before scene is hidden. Optional;
|
|
60
|
+
* @property {Array.<string>} [parents] - list of parent scene names.
|
|
61
|
+
* @property {*} ... - shortcut descriptions
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* @typedef {Object} sceneDescription
|
|
65
|
+
* @property {string} name - name of the scene
|
|
66
|
+
* @property {SceneObject} scene - object should contain 'show' and 'hide' + shortcuts and action functions
|
|
67
|
+
*/
|
|
68
|
+
declare function setScenes(dependencies: any, state: any): (list: sceneDescription[]) => void;
|
|
69
|
+
//# sourceMappingURL=setScenes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;;;;uBACvC,OAAO;;;;UAClB,CAAS,IAAkC,EAAlC;QAAC,IAAI,EAAE,SAAS,CAAC;QAAC,YAAY,EAAE,GAAC,CAAA;KAAC,KAAG,IAAI;;;;wBACvC,IAAI;;;;;;;;QAEf,GAAC;;;;;;UAOD,MAAM;;;;WACN,WAAW;;AAnBzB;;;GAGG;AACH;;;;;;;;GAQG;AAIH;;;;GAIG;AAKH,4DAOgC,MAJhB,gBAAgB,EAII,UAkClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/methods/show.js"],"names":[],"mappings":";AAIA,2FAKG;IAAwB,KAAK,EAArB,MAAM;IACW,OAAO;aACxB,OAAO;;CACf,mCA4GF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setInstruction.d.ts","sourceRoot":"","sources":["../../src/setInstruction.js"],"names":[],"mappings":";AAEA,qDAQiC,YAAE,EAAE,GAAG,MAHtB,GAAC,EAGyB,cAO1C"}
|
|
@@ -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
|