@media-quest/engine 0.0.30 → 0.0.32

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/src/public-api.ts CHANGED
@@ -1,26 +1,25 @@
1
- export * from "./engine/SchemaResult";
2
- export * from "./engine/SchemaEngine";
3
- export * from "./engine/SchemaDto";
4
- export * from "./engine/page-que-ruleengine-action";
5
- export * from "./rules/rule";
6
- export * from "./rules/fact";
7
- export * from "./rules/rule-engine";
8
- export * from "./rules/condition";
9
- export * from "./utils/DUtil";
10
- // export * from "./utils/ID";
11
-
12
- export * from "./events/mq-events";
13
-
14
- export * from "./page/page-component";
15
-
16
- // ELEMENTS
17
- export * from "./Delement/css";
18
- export * from "./Delement/DStyle";
19
- export * from "./Delement/DImg";
20
- export * from "./Delement/DText";
21
- export * from "./Delement/Ddiv";
22
- export * from "./Delement/button-click-action";
23
- export * from "./Delement/DElement";
24
- export * from "./Delement/DElement.dto";
25
- export { PageDto } from "./page/Page";
26
- export * from "./page/task";
1
+ export * from "./engine/SchemaResult";
2
+ export * from "./engine/SchemaEngine";
3
+ export * from "./engine/SchemaDto";
4
+ export * from "./engine/page-que-ruleengine-action";
5
+ export * from "./rules/rule";
6
+ export * from "./rules/fact";
7
+ export * from "./rules/rule-engine";
8
+ export * from "./rules/condition";
9
+ export * from "./utils/DUtil";
10
+ // export * from "./utils/ID";
11
+
12
+ export * from "./events/mq-events";
13
+
14
+ // ELEMENTS
15
+ export * from "./Delement/css";
16
+ export * from "./Delement/DStyle";
17
+ export * from "./Delement/DImg";
18
+ export * from "./Delement/DText";
19
+ export * from "./Delement/DButton";
20
+ export * from "./Delement/Ddiv";
21
+ export * from "./Delement/button-click-action";
22
+ export * from "./Delement/DElement";
23
+ export * from "./Delement/DElement.dto";
24
+ export { PageDto } from "./page/Page";
25
+ export * from "./page/task";
package/src/VERSION.ts DELETED
@@ -1 +0,0 @@
1
- export const VERSION = "0.0.27"
@@ -1,113 +0,0 @@
1
- import { PStyle } from "../Delement/DStyle";
2
- import { ScaleService } from "../engine/scale";
3
- import { DElement } from "../Delement/DElement";
4
- import { createDElement } from "../Delement/element-factory";
5
- import { ButtonClickAction } from "../Delement/button-click-action";
6
- import { DElementDto } from "../Delement/DElement.dto";
7
- import { TaskState, TaskStateDiff } from "./task-state";
8
-
9
- export interface PageComponentDto {
10
- readonly onClick?: ButtonClickAction;
11
- readonly el: DElementDto;
12
- readonly whenVideoPlay?: PStyle;
13
- readonly whenVideoPaused?: PStyle;
14
- readonly whenAudioPlaying?: PStyle;
15
- readonly whenAudioPaused?: PStyle;
16
- readonly whenAudioBlocked?: PStyle;
17
- readonly whenVideoBlocked?: PStyle;
18
- readonly whenAudioUnblocked?: PStyle;
19
- readonly whenVideoUnblocked?: PStyle;
20
- readonly whenResponseBlocked?: PStyle;
21
- readonly whenResponseUnblocked?: PStyle;
22
- readonly whenFormInputBlocked?: PStyle;
23
- readonly whenFormInputUnblocked?: PStyle;
24
- }
25
-
26
- const isFalse = (bool?: boolean): bool is false => bool === false;
27
- const isTrue = (bool?: boolean): bool is true => bool === true;
28
-
29
- export class PageComponent {
30
- private readonly TAG = "[ PageComponent ]: ";
31
- private el: DElement<HTMLElement>;
32
- private prevState: TaskState | false = false;
33
-
34
- constructor(
35
- readonly dto: PageComponentDto,
36
- readonly scale: ScaleService,
37
- ) {
38
- this.el = createDElement(dto.el, scale);
39
- this.el.onclick = () => {
40
- if (dto.onClick) {
41
- this.onClick(dto.onClick);
42
- } else {
43
- console.warn(this.TAG + "onClick not implemented");
44
- }
45
- };
46
- }
47
-
48
- onClick(action: ButtonClickAction) {
49
- console.warn(this.TAG + "onclick not implemented");
50
- }
51
-
52
- updateState(state: TaskStateDiff) {
53
- this.handleStateChanges(state);
54
- }
55
-
56
- setState(state: TaskState) {
57
- const prev = this.prevState;
58
- const diff = TaskState.getDiff(state, prev);
59
- this.prevState = state;
60
- if (Object.keys(diff).length > 0) {
61
- this.handleStateChanges(diff);
62
- }
63
- }
64
-
65
- private handleStateChanges(diff: TaskStateDiff) {
66
- const {
67
- videoIsPlaying,
68
- audioIsPlaying,
69
- blockAudio,
70
- blockVideo,
71
- blockResponseButton,
72
- blockFormInput,
73
- isGifMode,
74
- } = diff;
75
- const {
76
- whenAudioPaused,
77
- whenVideoPaused,
78
- whenAudioPlaying,
79
- whenFormInputBlocked,
80
- whenResponseBlocked,
81
- whenVideoPlay,
82
- whenAudioBlocked,
83
- whenVideoBlocked,
84
- whenAudioUnblocked,
85
- whenVideoUnblocked,
86
- whenResponseUnblocked,
87
- whenFormInputUnblocked,
88
- } = this.dto;
89
- if (isTrue(audioIsPlaying) && whenAudioPlaying) {
90
- this.el.setStyle(whenAudioPlaying);
91
- }
92
- if (isFalse(audioIsPlaying) && whenAudioPaused) {
93
- this.el.setStyle(whenAudioPaused);
94
- }
95
- if (isTrue(videoIsPlaying) && whenVideoPlay) {
96
- this.el.setStyle(whenVideoPlay);
97
- }
98
- if (isFalse(videoIsPlaying) && whenVideoPaused) {
99
- this.el.setStyle(whenVideoPaused);
100
- }
101
- // if (isTrue(blockAudio) && whenAudioBlocked) {
102
- // this.el.setStyle(whenAudioBlocked);
103
- // }
104
- // if (isTrue(blockVideo) && whenVideoBlocked) {
105
- // this.el.setStyle(whenVideoBlocked);
106
- // }
107
- }
108
-
109
- appendToParent(parent: { append: (el: HTMLElement) => void }) {
110
- // parent.appendChild(this.el.);
111
- this.el.appendYourself(parent);
112
- }
113
- }