@media-quest/engine 0.0.39 → 0.0.40
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/dist/public-api.d.ts +3 -21
- package/dist/public-api.js +16 -29
- package/dist/public-api.js.map +1 -1
- package/package.json +26 -26
- package/src/Delement/DButton.ts +25 -25
- package/src/Delement/DElement.dto.ts +6 -6
- package/src/Delement/DElement.ts +190 -190
- package/src/Delement/DImg.ts +48 -48
- package/src/Delement/DStyle.ts +376 -391
- package/src/Delement/DText.ts +23 -23
- package/src/Delement/Ddiv.ts +44 -44
- package/src/Delement/button-click-action.ts +42 -42
- package/src/Delement/css.spec.ts +40 -40
- package/src/Delement/css.ts +56 -56
- package/src/Delement/element-factory.ts +49 -49
- package/src/engine/SchemaEngine.ts +155 -160
- package/src/engine/SchemaResult.ts +10 -12
- package/src/engine/dplayer.spec.ts +91 -92
- package/src/engine/dplayer.ts +104 -106
- package/src/engine/history-que.spec.ts +67 -69
- package/src/engine/history-que.ts +17 -21
- package/src/engine/next-que.spec.ts +121 -122
- package/src/engine/next-que.ts +101 -101
- package/src/events/mq-events.ts +63 -76
- package/src/page/Page.ts +190 -180
- package/src/page/page-result.ts +11 -12
- package/src/page/task-manager.ts +263 -263
- package/src/page/task-state.ts +65 -65
- package/src/public-api.ts +25 -26
- package/tsconfig.json +19 -19
package/src/engine/next-que.ts
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
import { PageDto } from "../page/Page";
|
|
2
|
-
|
|
3
|
-
export class NextQue {
|
|
4
|
-
private originalOrder: ReadonlyArray<string> = [];
|
|
5
|
-
private allPages: PageDto[] = [];
|
|
6
|
-
private excludedTags = new Set<string>();
|
|
7
|
-
private excludedByPageId = new Set<string>();
|
|
8
|
-
private remaining: PageDto[] = [];
|
|
9
|
-
constructor(pages: PageDto[] = []) {
|
|
10
|
-
this.resetQue(pages);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Will reset que with the new pages.
|
|
15
|
-
* @param pages
|
|
16
|
-
*/
|
|
17
|
-
resetQue(pages: PageDto[]) {
|
|
18
|
-
this.allPages = [...pages];
|
|
19
|
-
this.remaining = [...pages];
|
|
20
|
-
this.excludedTags = new Set();
|
|
21
|
-
this.excludedByPageId = new Set();
|
|
22
|
-
this.originalOrder = this.allPages.map((p) => p.id);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
pop(): PageDto | false {
|
|
26
|
-
const next = this.remaining.shift();
|
|
27
|
-
// TODO CLONE??
|
|
28
|
-
return next ?? false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
peek(): PageDto | false {
|
|
32
|
-
const next = this.remaining[0];
|
|
33
|
-
return next ?? false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
jumpToPageById(pageId: string): boolean {
|
|
37
|
-
const index = this.remaining.findIndex((p) => p.id === pageId);
|
|
38
|
-
if (index < 0) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
this.remaining = this.remaining.slice(index);
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
removeByTag(tag: string | string[]) {
|
|
46
|
-
if (Array.isArray(tag)) {
|
|
47
|
-
tag.forEach((tag) => {
|
|
48
|
-
this.excludedTags.add(tag);
|
|
49
|
-
});
|
|
50
|
-
} else {
|
|
51
|
-
this.excludedTags.add(tag);
|
|
52
|
-
}
|
|
53
|
-
this.filterRemaining();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Will not be included
|
|
58
|
-
* @param pages
|
|
59
|
-
*/
|
|
60
|
-
insertAsNextByForce(pages: PageDto[]) {
|
|
61
|
-
this.remaining.unshift(...pages);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
removeByPageId(pageId: string | string[]) {
|
|
65
|
-
if (Array.isArray(pageId)) {
|
|
66
|
-
pageId.forEach((id) => {
|
|
67
|
-
this.excludedByPageId.add(id);
|
|
68
|
-
});
|
|
69
|
-
} else {
|
|
70
|
-
this.excludedByPageId.add(pageId);
|
|
71
|
-
}
|
|
72
|
-
this.filterRemaining();
|
|
73
|
-
// this.excludedByPageId.add(pageId);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private filterRemaining() {
|
|
77
|
-
this.remaining = this.remaining.filter((p) => {
|
|
78
|
-
const tags = p.tags ?? [];
|
|
79
|
-
const isIncluededByTag = !tags.some((tag) => this.excludedTags.has(tag));
|
|
80
|
-
const isIncludedByPageId = !this.excludedByPageId.has(p.id);
|
|
81
|
-
return isIncludedByPageId && isIncluededByTag;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
get isEmpty(): boolean {
|
|
85
|
-
return this.remaining.length === 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Total number of pages left in que
|
|
90
|
-
*/
|
|
91
|
-
get size(): number {
|
|
92
|
-
return this.remaining.length;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Total number of pages in test
|
|
97
|
-
*/
|
|
98
|
-
get pageCount(): number {
|
|
99
|
-
return this.originalOrder.length;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
1
|
+
import { PageDto } from "../page/Page";
|
|
2
|
+
|
|
3
|
+
export class NextQue {
|
|
4
|
+
private originalOrder: ReadonlyArray<string> = [];
|
|
5
|
+
private allPages: PageDto[] = [];
|
|
6
|
+
private excludedTags = new Set<string>();
|
|
7
|
+
private excludedByPageId = new Set<string>();
|
|
8
|
+
private remaining: PageDto[] = [];
|
|
9
|
+
constructor(pages: PageDto[] = []) {
|
|
10
|
+
this.resetQue(pages);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Will reset que with the new pages.
|
|
15
|
+
* @param pages
|
|
16
|
+
*/
|
|
17
|
+
resetQue(pages: PageDto[]) {
|
|
18
|
+
this.allPages = [...pages];
|
|
19
|
+
this.remaining = [...pages];
|
|
20
|
+
this.excludedTags = new Set();
|
|
21
|
+
this.excludedByPageId = new Set();
|
|
22
|
+
this.originalOrder = this.allPages.map((p) => p.id);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
pop(): PageDto | false {
|
|
26
|
+
const next = this.remaining.shift();
|
|
27
|
+
// TODO CLONE??
|
|
28
|
+
return next ?? false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
peek(): PageDto | false {
|
|
32
|
+
const next = this.remaining[0];
|
|
33
|
+
return next ?? false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
jumpToPageById(pageId: string): boolean {
|
|
37
|
+
const index = this.remaining.findIndex((p) => p.id === pageId);
|
|
38
|
+
if (index < 0) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
this.remaining = this.remaining.slice(index);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
removeByTag(tag: string | string[]) {
|
|
46
|
+
if (Array.isArray(tag)) {
|
|
47
|
+
tag.forEach((tag) => {
|
|
48
|
+
this.excludedTags.add(tag);
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
this.excludedTags.add(tag);
|
|
52
|
+
}
|
|
53
|
+
this.filterRemaining();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Will not be included
|
|
58
|
+
* @param pages
|
|
59
|
+
*/
|
|
60
|
+
insertAsNextByForce(pages: PageDto[]) {
|
|
61
|
+
this.remaining.unshift(...pages);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
removeByPageId(pageId: string | string[]) {
|
|
65
|
+
if (Array.isArray(pageId)) {
|
|
66
|
+
pageId.forEach((id) => {
|
|
67
|
+
this.excludedByPageId.add(id);
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
this.excludedByPageId.add(pageId);
|
|
71
|
+
}
|
|
72
|
+
this.filterRemaining();
|
|
73
|
+
// this.excludedByPageId.add(pageId);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private filterRemaining() {
|
|
77
|
+
this.remaining = this.remaining.filter((p) => {
|
|
78
|
+
const tags = p.tags ?? [];
|
|
79
|
+
const isIncluededByTag = !tags.some((tag) => this.excludedTags.has(tag));
|
|
80
|
+
const isIncludedByPageId = !this.excludedByPageId.has(p.id);
|
|
81
|
+
return isIncludedByPageId && isIncluededByTag;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
get isEmpty(): boolean {
|
|
85
|
+
return this.remaining.length === 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Total number of pages left in que
|
|
90
|
+
*/
|
|
91
|
+
get size(): number {
|
|
92
|
+
return this.remaining.length;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Total number of pages in test
|
|
97
|
+
*/
|
|
98
|
+
get pageCount(): number {
|
|
99
|
+
return this.originalOrder.length;
|
|
100
|
+
}
|
|
101
|
+
}
|
package/src/events/mq-events.ts
CHANGED
|
@@ -1,76 +1,63 @@
|
|
|
1
|
-
import { DTimestamp } from "../common/DTimestamp";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
readonly
|
|
5
|
-
readonly
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
readonly
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
> {}
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
pagePrefix: string;
|
|
65
|
-
pageNumber: number;
|
|
66
|
-
action: string;
|
|
67
|
-
descriptions: string;
|
|
68
|
-
}): MqEventUserClicked {
|
|
69
|
-
const { pageId, pageNumber, pagePrefix, action, descriptions } = data;
|
|
70
|
-
return {
|
|
71
|
-
kind: "user-clicked",
|
|
72
|
-
timestamp: DTimestamp.now(),
|
|
73
|
-
payload: { pageId, pagePrefix, action, descriptions, pageNumber },
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
} as const;
|
|
1
|
+
import { DTimestamp } from "../common/DTimestamp";
|
|
2
|
+
|
|
3
|
+
interface _MqEvent<K extends string, P extends object> {
|
|
4
|
+
readonly kind: K;
|
|
5
|
+
readonly timestamp: DTimestamp;
|
|
6
|
+
readonly payload: P;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type MqEventEngineStart = _MqEvent<
|
|
10
|
+
"engine-start",
|
|
11
|
+
{
|
|
12
|
+
readonly schemaId: string;
|
|
13
|
+
readonly schemaPrefix: string;
|
|
14
|
+
}
|
|
15
|
+
>;
|
|
16
|
+
export interface MqEventPageEnter
|
|
17
|
+
extends _MqEvent<"page-enter", { readonly pageId: string; readonly pagePrefix: string }> {}
|
|
18
|
+
export interface MqEventPageLeave
|
|
19
|
+
extends _MqEvent<"page-leave", { readonly pageId: string; readonly pagePrefix: string }> {}
|
|
20
|
+
|
|
21
|
+
export type MqEventUserClicked = _MqEvent<
|
|
22
|
+
"user-clicked",
|
|
23
|
+
{ readonly pageId: string; pagePrefix: string; action: string; descriptions: string }
|
|
24
|
+
>;
|
|
25
|
+
|
|
26
|
+
export type MqEvent = MqEventPageEnter | MqEventPageLeave | MqEventEngineStart | MqEventUserClicked;
|
|
27
|
+
|
|
28
|
+
export const MqEvent = {
|
|
29
|
+
engineStart(schemaId: string, schemaPrefix: string): MqEventEngineStart {
|
|
30
|
+
return {
|
|
31
|
+
kind: "engine-start",
|
|
32
|
+
timestamp: DTimestamp.now(),
|
|
33
|
+
payload: { schemaId, schemaPrefix },
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
pageEnter(pageId: string, pagePrefix: string): MqEventPageEnter {
|
|
37
|
+
return {
|
|
38
|
+
kind: "page-enter",
|
|
39
|
+
timestamp: DTimestamp.now(),
|
|
40
|
+
payload: { pageId, pagePrefix },
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
pageLeave(pageId: string, pagePrefix: string): MqEventPageLeave {
|
|
44
|
+
return {
|
|
45
|
+
kind: "page-leave",
|
|
46
|
+
timestamp: DTimestamp.now(),
|
|
47
|
+
payload: { pageId, pagePrefix },
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
userClicked(data: {
|
|
51
|
+
pageId: string;
|
|
52
|
+
pagePrefix: string;
|
|
53
|
+
action: string;
|
|
54
|
+
descriptions: string;
|
|
55
|
+
}): MqEventUserClicked {
|
|
56
|
+
const { pageId, pagePrefix, action, descriptions } = data;
|
|
57
|
+
return {
|
|
58
|
+
kind: "user-clicked",
|
|
59
|
+
timestamp: DTimestamp.now(),
|
|
60
|
+
payload: { pageId, pagePrefix, action, descriptions },
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
} as const;
|