@media-quest/engine 0.0.22 → 0.0.23

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.
Files changed (51) hide show
  1. package/package.json +1 -1
  2. package/src/Delement/DElement.dto.ts +5 -5
  3. package/src/Delement/DElement.ts +88 -88
  4. package/src/Delement/DImg.ts +39 -39
  5. package/src/Delement/DStyle-utils.ts +616 -616
  6. package/src/Delement/DStyle.ts +165 -165
  7. package/src/Delement/DText.ts +13 -13
  8. package/src/Delement/Ddiv.ts +25 -25
  9. package/src/Delement/button-click-action.ts +35 -35
  10. package/src/Delement/css.spec.ts +36 -36
  11. package/src/Delement/css.ts +46 -46
  12. package/src/Delement/element-factory.ts +40 -40
  13. package/src/common/DMaybe.ts +46 -46
  14. package/src/common/DTimestamp.ts +20 -20
  15. package/src/common/DTmestamp.spec.ts +11 -11
  16. package/src/common/result.ts +41 -41
  17. package/src/engine/SchemaDto.ts +24 -24
  18. package/src/engine/SchemaEngine.ts +150 -150
  19. package/src/engine/SchemaResult.ts +10 -10
  20. package/src/engine/dplayer.spec.ts +91 -91
  21. package/src/engine/dplayer.ts +104 -104
  22. package/src/engine/history-que.spec.ts +67 -67
  23. package/src/engine/history-que.ts +17 -17
  24. package/src/engine/next-que.spec.ts +121 -121
  25. package/src/engine/next-que.ts +101 -101
  26. package/src/engine/page-que-ruleengine-action.ts +6 -6
  27. package/src/engine/scale.spec.ts +38 -38
  28. package/src/engine/scale.ts +70 -70
  29. package/src/events/mq-events.ts +63 -63
  30. package/src/page/Page.ts +182 -182
  31. package/src/page/media-player.ts +117 -117
  32. package/src/page/page-component.ts +113 -113
  33. package/src/page/page-result.ts +11 -11
  34. package/src/page/task-manager.ts +240 -240
  35. package/src/page/task-state.ts +55 -55
  36. package/src/page/task.ts +90 -90
  37. package/src/public-api.ts +26 -26
  38. package/src/rules/__test__/complex-condition.spec.ts +15 -15
  39. package/src/rules/__test__/conditon.spec.ts +124 -124
  40. package/src/rules/__test__/numeric-condition.spec.ts +84 -84
  41. package/src/rules/__test__/rule-engine.spec.ts +348 -348
  42. package/src/rules/__test__/rule-evaluation.spec.ts +140 -140
  43. package/src/rules/__test__/string-condition.spec.ts +41 -41
  44. package/src/rules/condition.ts +191 -191
  45. package/src/rules/fact.ts +18 -18
  46. package/src/rules/rule-engine.ts +45 -45
  47. package/src/rules/rule.ts +40 -40
  48. package/src/utils/DUtil.ts +116 -116
  49. package/src/utils/ID.spec.ts +39 -39
  50. package/src/utils/ID.ts +73 -73
  51. package/tsconfig.json +19 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@media-quest/engine",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "Rendering engine for media-quest schemas.",
5
5
  "main": "src/public-api.ts",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
- import { DImgDto } from "../Delement/DImg";
2
- import { DTextDto } from "../Delement/DText";
3
- import { DDivDto } from "../Delement/Ddiv";
4
-
5
- export type DElementDto = DTextDto | DImgDto | DDivDto;
1
+ import { DImgDto } from "../Delement/DImg";
2
+ import { DTextDto } from "../Delement/DText";
3
+ import { DDivDto } from "../Delement/Ddiv";
4
+
5
+ export type DElementDto = DTextDto | DImgDto | DDivDto;
@@ -1,88 +1,88 @@
1
- import { DStyle, PStyle } from "./DStyle";
2
- import { ScaleService } from "../engine/scale";
3
-
4
- export interface DElementBaseDto {
5
- readonly style: PStyle;
6
- readonly onMouseEnter?: PStyle;
7
- readonly onMouseLeave?: PStyle;
8
- readonly onMouseDown?: PStyle;
9
- readonly onMouseUp?: PStyle;
10
- readonly innerText?: string;
11
- }
12
-
13
- export abstract class DElement<T extends HTMLElement> {
14
- protected currStyle: Partial<DStyle> = {
15
- fontSize: { _unit: "px", value: 100 },
16
- fontWeight: 500,
17
- textColor: "black",
18
- opacity: 1,
19
- };
20
-
21
- protected constructor(
22
- protected readonly el: T,
23
- protected readonly dto: DElementBaseDto,
24
- protected readonly scale: ScaleService,
25
- ) {
26
- if (dto.innerText) {
27
- this.el.innerText = dto.innerText;
28
- }
29
- this.setStyle = this.setStyle.bind(this);
30
- this.normalize = this.normalize.bind(this);
31
- this.appendYourself = this.appendYourself.bind(this);
32
- this.updateStyles = this.updateStyles.bind(this);
33
- const { onMouseEnter, onMouseLeave } = dto;
34
-
35
- if (onMouseEnter) {
36
- this.el.onmouseenter = () => {
37
- this.setStyle(onMouseEnter);
38
- };
39
- }
40
- if (onMouseLeave) {
41
- this.el.onmouseleave = () => {
42
- this.setStyle(onMouseLeave);
43
- };
44
- }
45
-
46
- this.el.onclick = () => {
47
- // if (onClick2) {
48
- this.onclick();
49
- // }
50
- };
51
- this.normalize();
52
-
53
- if (dto) {
54
- this.updateStyles(dto?.style);
55
- }
56
- }
57
-
58
- /**
59
- * This method is called when the element is clicked.
60
- * This method shall be overridden by the pageClass.
61
- * @param actions
62
- */
63
- onclick() {
64
- // console.warn("onclick not implemented");
65
- }
66
-
67
- setStyle(style: PStyle) {
68
- this.updateStyles(style);
69
- }
70
-
71
- appendYourself(parent: { append: (el: HTMLElement) => void }) {
72
- parent.append(this.el);
73
- // console.log(parent);
74
- }
75
-
76
- private normalize() {
77
- this.el.style.padding = "0";
78
- this.el.style.margin = "0";
79
- this.el.style.position = "absolute";
80
- this.el.style.boxSizing = "border-box";
81
- }
82
-
83
- protected updateStyles(style: Partial<DStyle>) {
84
- this.currStyle = Object.assign(this.currStyle, style);
85
- DStyle.applyStyles(this.el, this.currStyle, this.scale.scale);
86
- window.getComputedStyle(this.el);
87
- }
88
- }
1
+ import { DStyle, PStyle } from "./DStyle";
2
+ import { ScaleService } from "../engine/scale";
3
+
4
+ export interface DElementBaseDto {
5
+ readonly style: PStyle;
6
+ readonly onMouseEnter?: PStyle;
7
+ readonly onMouseLeave?: PStyle;
8
+ readonly onMouseDown?: PStyle;
9
+ readonly onMouseUp?: PStyle;
10
+ readonly innerText?: string;
11
+ }
12
+
13
+ export abstract class DElement<T extends HTMLElement> {
14
+ protected currStyle: Partial<DStyle> = {
15
+ fontSize: { _unit: "px", value: 100 },
16
+ fontWeight: 500,
17
+ textColor: "black",
18
+ opacity: 1,
19
+ };
20
+
21
+ protected constructor(
22
+ protected readonly el: T,
23
+ protected readonly dto: DElementBaseDto,
24
+ protected readonly scale: ScaleService,
25
+ ) {
26
+ if (dto.innerText) {
27
+ this.el.innerText = dto.innerText;
28
+ }
29
+ this.setStyle = this.setStyle.bind(this);
30
+ this.normalize = this.normalize.bind(this);
31
+ this.appendYourself = this.appendYourself.bind(this);
32
+ this.updateStyles = this.updateStyles.bind(this);
33
+ const { onMouseEnter, onMouseLeave } = dto;
34
+
35
+ if (onMouseEnter) {
36
+ this.el.onmouseenter = () => {
37
+ this.setStyle(onMouseEnter);
38
+ };
39
+ }
40
+ if (onMouseLeave) {
41
+ this.el.onmouseleave = () => {
42
+ this.setStyle(onMouseLeave);
43
+ };
44
+ }
45
+
46
+ this.el.onclick = () => {
47
+ // if (onClick2) {
48
+ this.onclick();
49
+ // }
50
+ };
51
+ this.normalize();
52
+
53
+ if (dto) {
54
+ this.updateStyles(dto?.style);
55
+ }
56
+ }
57
+
58
+ /**
59
+ * This method is called when the element is clicked.
60
+ * This method shall be overridden by the pageClass.
61
+ * @param actions
62
+ */
63
+ onclick() {
64
+ // console.warn("onclick not implemented");
65
+ }
66
+
67
+ setStyle(style: PStyle) {
68
+ this.updateStyles(style);
69
+ }
70
+
71
+ appendYourself(parent: { append: (el: HTMLElement) => void }) {
72
+ parent.append(this.el);
73
+ // console.log(parent);
74
+ }
75
+
76
+ private normalize() {
77
+ this.el.style.padding = "0";
78
+ this.el.style.margin = "0";
79
+ this.el.style.position = "absolute";
80
+ this.el.style.boxSizing = "border-box";
81
+ }
82
+
83
+ protected updateStyles(style: Partial<DStyle>) {
84
+ this.currStyle = Object.assign(this.currStyle, style);
85
+ DStyle.applyStyles(this.el, this.currStyle, this.scale.scale);
86
+ window.getComputedStyle(this.el);
87
+ }
88
+ }
@@ -1,39 +1,39 @@
1
- import { DElement, DElementBaseDto } from "./DElement";
2
- import { ScaleService } from "../engine/scale";
3
- import { DTimestamp } from "../common/DTimestamp";
4
-
5
- export interface DImgDto extends DElementBaseDto {
6
- readonly _tag: "img";
7
- // readonly id: string;
8
- readonly url: string;
9
- }
10
-
11
- export class DImg extends DElement<HTMLImageElement> {
12
- private static IMAGE_COUNT = 0;
13
- private readonly imageCount: number;
14
- readonly TAG: string;
15
- readonly TIMING_TAG: string;
16
- private readonly loadStart: DTimestamp;
17
-
18
- constructor(
19
- protected readonly dto: DImgDto,
20
- readonly scaleService: ScaleService,
21
- ) {
22
- super(document.createElement("img"), dto, scaleService);
23
- DImg.IMAGE_COUNT += 1;
24
- this.imageCount = DImg.IMAGE_COUNT;
25
- this.TAG = "[D_IMG " + DImg.IMAGE_COUNT + " ]: ";
26
- this.TIMING_TAG = "load-time (" + DImg.IMAGE_COUNT + ") ";
27
- this.el.loading = "eager";
28
- this.el.style.position = "absolute";
29
- this.setStyle(dto.style);
30
-
31
- this.loadStart = DTimestamp.now();
32
- this.el.onload = () => {};
33
- this.el.onerror = () => {};
34
- this.el.src = dto.url;
35
- console.time(this.TIMING_TAG);
36
- }
37
-
38
- log(): void {}
39
- }
1
+ import { DElement, DElementBaseDto } from "./DElement";
2
+ import { ScaleService } from "../engine/scale";
3
+ import { DTimestamp } from "../common/DTimestamp";
4
+
5
+ export interface DImgDto extends DElementBaseDto {
6
+ readonly _tag: "img";
7
+ // readonly id: string;
8
+ readonly url: string;
9
+ }
10
+
11
+ export class DImg extends DElement<HTMLImageElement> {
12
+ private static IMAGE_COUNT = 0;
13
+ private readonly imageCount: number;
14
+ readonly TAG: string;
15
+ readonly TIMING_TAG: string;
16
+ private readonly loadStart: DTimestamp;
17
+
18
+ constructor(
19
+ protected readonly dto: DImgDto,
20
+ readonly scaleService: ScaleService,
21
+ ) {
22
+ super(document.createElement("img"), dto, scaleService);
23
+ DImg.IMAGE_COUNT += 1;
24
+ this.imageCount = DImg.IMAGE_COUNT;
25
+ this.TAG = "[D_IMG " + DImg.IMAGE_COUNT + " ]: ";
26
+ this.TIMING_TAG = "load-time (" + DImg.IMAGE_COUNT + ") ";
27
+ this.el.loading = "eager";
28
+ this.el.style.position = "absolute";
29
+ this.setStyle(dto.style);
30
+
31
+ this.loadStart = DTimestamp.now();
32
+ this.el.onload = () => {};
33
+ this.el.onerror = () => {};
34
+ this.el.src = dto.url;
35
+ console.time(this.TIMING_TAG);
36
+ }
37
+
38
+ log(): void {}
39
+ }