@media-quest/engine 0.0.14 → 0.0.15

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 (60) hide show
  1. package/package.json +1 -2
  2. package/src/Delement/DElement.dto.ts +5 -0
  3. package/src/Delement/DElement.ts +78 -253
  4. package/src/Delement/DImg.ts +31 -70
  5. package/src/Delement/DStyle.ts +156 -156
  6. package/src/Delement/DText.ts +9 -25
  7. package/src/Delement/Ddiv.ts +10 -23
  8. package/src/Delement/button-click-action.ts +11 -0
  9. package/src/Delement/element-factory.ts +40 -0
  10. package/src/engine/DCommand.ts +21 -0
  11. package/src/engine/SchemaDto.ts +24 -0
  12. package/src/engine/SchemaEngine.ts +48 -120
  13. package/src/{player → engine}/dplayer.spec.ts +20 -17
  14. package/src/{player → engine}/dplayer.ts +29 -16
  15. package/src/engine/history-que.spec.ts +59 -0
  16. package/src/engine/history-que.ts +39 -0
  17. package/src/{player → engine}/next-que.spec.ts +19 -8
  18. package/src/engine/next-que.ts +93 -0
  19. package/src/page/Page.ts +160 -0
  20. package/src/page/media-player.ts +117 -0
  21. package/src/page/page-component.ts +113 -0
  22. package/src/page/page-result.ts +11 -0
  23. package/src/page/task-manager.ts +203 -0
  24. package/src/page/task-state.ts +55 -0
  25. package/src/page/task.ts +87 -0
  26. package/src/public-api.ts +17 -13
  27. package/src/rules/__test__/rule-engine.spec.ts +1 -1
  28. package/src/utils/DUtil.ts +110 -103
  29. package/tsconfig.tsbuildinfo +1 -0
  30. package/dist/public-api.js +0 -2245
  31. package/dist/public-api.mjs +0 -2205
  32. package/src/Delement/AudioContainer.ts +0 -169
  33. package/src/Delement/DAuto-play.ts +0 -36
  34. package/src/Delement/VideoContainer.ts +0 -199
  35. package/src/commands/DCommand.ts +0 -63
  36. package/src/commands/DCommandBus.ts +0 -60
  37. package/src/dto/AnimationDto.ts +0 -4
  38. package/src/dto/DElement.dto.ts +0 -46
  39. package/src/dto/SchemaDto.ts +0 -65
  40. package/src/engine/DPage.ts +0 -60
  41. package/src/engine/element-factory.ts +0 -52
  42. package/src/event-handlers/DEventHandler.ts +0 -29
  43. package/src/events/DEvents.ts +0 -94
  44. package/src/events/event-bus.spec.ts +0 -21
  45. package/src/events/event-bus.ts +0 -81
  46. package/src/kladd/context-menu-manager.ts +0 -56
  47. package/src/player/history-que.spec.ts +0 -46
  48. package/src/player/history-que.ts +0 -38
  49. package/src/player/next-que.ts +0 -93
  50. package/src/services/DMedia-manager.spec.ts +0 -27
  51. package/src/services/DMedia-manager.ts +0 -179
  52. package/src/services/resource-provider.ts +0 -33
  53. package/src/services/sequence-manager.spec.ts +0 -168
  54. package/src/services/sequence-manager.ts +0 -133
  55. package/src/state/Dstate.spec.ts +0 -7
  56. package/src/state/Dstate.ts +0 -105
  57. package/src/state/boolean-property.ts +0 -69
  58. package/src/state/state-service.spec.ts +0 -307
  59. package/src/state/state-service.ts +0 -251
  60. package/src/state/state-testing-helpers.ts +0 -59
@@ -1,60 +0,0 @@
1
- import { DElement } from "../Delement/DElement";
2
- import { PageDto } from "../dto/SchemaDto";
3
- import { createDElement } from "./element-factory";
4
- import { EventBus } from "../events/event-bus";
5
- import { DCommandBus } from "../commands/DCommandBus";
6
- import { DTimestamp } from "../common/DTimestamp";
7
- import { ScaleService } from "./scale";
8
-
9
- export class DPage {
10
- private readonly TAG = "[ DPage ]: ";
11
- private elements: DElement<HTMLElement>[] = [];
12
- private readonly eventBus;
13
- private readonly commandBus;
14
- private readonly scale: ScaleService;
15
- // Todo GLOBAL EVENT_BUSS AND PAGE EVENTS:
16
-
17
- constructor(
18
- private readonly dto: PageDto,
19
- eventBus: EventBus,
20
- commandBus: DCommandBus,
21
- scale: ScaleService,
22
- ) {
23
- this.eventBus = eventBus;
24
- this.commandBus = commandBus;
25
- this.scale = scale;
26
- this.elements = dto.elements.map((dto) => createDElement(dto, this.commandBus, this.eventBus, this.scale));
27
- }
28
-
29
- appendYourself(parent: HTMLElement) {
30
- // console.log(this.TAG + " APPENDING TO PARENT");
31
- this.elements.forEach((el) => {
32
- el.appendYourself(parent);
33
- // parent.appendChild(el.el);
34
- });
35
-
36
- // if (!preloadMode) {
37
- this.eventBus.emit({
38
- kind: "PAGE_ENTER_EVENT",
39
- timestamp: DTimestamp.now(),
40
- producer: "DPage",
41
- producerId: this.id,
42
- data: { pageId: this.id },
43
- });
44
- // }
45
- }
46
-
47
- destroy() {
48
- this.elements.forEach((el) => {
49
- el.destroy();
50
- });
51
- }
52
-
53
- log(): void {
54
- // console.log(this.TAG + 'scale - ' + this.scale);
55
- }
56
-
57
- get id() {
58
- return this.dto.id;
59
- }
60
- }
@@ -1,52 +0,0 @@
1
- import { DElement } from "../Delement/DElement";
2
- import { DDiv } from "../Delement/Ddiv";
3
- import { DImg } from "../Delement/DImg";
4
- import { DText } from "../Delement/DText";
5
- import { DDivDto, DElementDto } from "../dto/DElement.dto";
6
- import { DCommandBus } from "../commands/DCommandBus";
7
- import { EventBus } from "../events/event-bus";
8
- import { ScaleService } from "./scale";
9
-
10
- export const createDElement = (
11
- dto: DElementDto,
12
- actionBus: DCommandBus,
13
- eventBus: EventBus,
14
- scale: ScaleService
15
- ): DElement<any> => {
16
- switch (dto._tag) {
17
- case "div":
18
- const childEls = createChildrenForDiv(dto, actionBus, eventBus, scale);
19
- const newDiv = new DDiv(dto, eventBus, actionBus, scale, childEls);
20
- return newDiv;
21
- case "img":
22
- return new DImg(dto, actionBus, eventBus, scale);
23
- case "p":
24
- return new DText(dto, eventBus, actionBus, scale);
25
- default:
26
- const check: never = dto;
27
- throw new Error("Unknown dto given to the createDElement function.");
28
- // TODO LOGGING or create any HTML-ELEMENT??
29
- }
30
- };
31
-
32
- const createChildrenForDiv = (
33
- dto: DDivDto,
34
- actionSubject: DCommandBus,
35
- eventBus: EventBus,
36
- scale: ScaleService
37
- ): DDiv["children"] => {
38
- const childDto = dto.children;
39
- const childEls: Array<DImg | DText> = [];
40
- // console.log(childElements);
41
- childDto.forEach((dto) => {
42
- if (dto._tag === "p") {
43
- const newText = new DText(dto, eventBus, actionSubject, scale);
44
- childEls.push(newText);
45
- }
46
- if (dto._tag === "img") {
47
- const newImage = new DImg(dto, actionSubject, eventBus, scale);
48
- childEls.push(newImage);
49
- }
50
- });
51
- return childEls;
52
- };
@@ -1,29 +0,0 @@
1
- import { DCommand, ElementCommand, StateCommand } from "../commands/DCommand";
2
- import { DEvent } from "../events/DEvents";
3
- import { Condition } from "../rules/condition";
4
-
5
- export interface DEventHandler<E extends DEvent = DEvent> {
6
- readonly onEvent: E["kind"];
7
- readonly when?: { producerId?: string; condition?: Condition };
8
- readonly thenExecute: ReadonlyArray<DCommand>;
9
- }
10
-
11
- export interface QueryChangedHandler {
12
- readonly queryName: string;
13
- readonly whenTrue: ReadonlyArray<ElementCommand>;
14
- readonly whenFalse: ReadonlyArray<ElementCommand>;
15
- }
16
-
17
- export namespace DEventHandler {
18
- export type LookUp = Map<DEventHandler["onEvent"], Array<DEventHandler>>;
19
- export const createLookUp = (handlers?: ReadonlyArray<DEventHandler>): LookUp => {
20
- const map = new Map<DEventHandler["onEvent"], Array<DEventHandler>>();
21
- handlers?.forEach((h) => {
22
- const kind = h.onEvent;
23
- const current = map.get(kind);
24
- const actions = current ? [...current, h] : [h];
25
- map.set(kind, actions);
26
- });
27
- return map;
28
- };
29
- }
@@ -1,94 +0,0 @@
1
- import { DTimestamp } from "../common/DTimestamp";
2
- import { AnsweredQuestion } from "../player/history-que";
3
- import { DState } from "../state/Dstate";
4
-
5
- type EventProducer =
6
- | "DVideo"
7
- | "DUser"
8
- | "DAudio"
9
- | "DImage"
10
- | "MediaManager"
11
- | "DPage"
12
- | "Window"
13
- | "HOST"
14
- | "RuleEngine"
15
- | "Engine"
16
- | "STATE-SERVICE";
17
-
18
- interface Ev<K extends EventKind, P extends EventProducer, T> {
19
- readonly kind: K;
20
- readonly timestamp: DTimestamp;
21
- readonly producer: P;
22
- readonly producerId: string;
23
- readonly data: T;
24
- }
25
-
26
- type EventKind = `${Uppercase<string>}_EVENT`;
27
-
28
- export type QueryChangedEvent = Ev<"STATE_QUERY_RESULT_CHANGED_EVENT", "STATE-SERVICE", DState.StateQueryResult>;
29
-
30
- export type AudioPlayEvent = Ev<"AUDIO_PLAY_EVENT", "DAudio", {}>;
31
- // export type AudioWillPlayEvent = Ev<"AUDIO_WILL_PLAY_EVENT", "DAudio", {}>;
32
-
33
- export type DAudioEvent =
34
- | AudioPlayEvent
35
- // | AudioWillPlayEvent
36
- | Ev<"AUDIO_PAUSED_EVENT", "DAudio", {}>
37
- | Ev<"AUDIO_ENDED_EVENT", "DAudio", { url: string }>
38
- | Ev<"AUDIO_ERROR_EVENT", "DAudio", { error: unknown }>
39
- | Ev<"AUDIO_METADATA_LOADED_EVENT", "DAudio", {}>
40
- | Ev<"AUDIO_LOAD_EVENT", "DAudio", {}>
41
- | Ev<"AUDIO_CAN_PLAY_THROUGH_EVENT", "DAudio", {}>
42
- | Ev<"AUDIO_DURATION_CHANGE_EVENT", "DAudio", { duration: number; isInfinity: boolean }>
43
- | Ev<"AUDIO_PROGRESS_EVENT", "DAudio", {}>;
44
-
45
- export type DVideoEvent =
46
- | Ev<"VIDEO_PLAY_EVENT", "DVideo", {}>
47
- | Ev<"VIDEO_PAUSED_EVENT", "DVideo", {}>
48
- | Ev<"VIDEO_ERROR_EVENT", "DVideo", { error: unknown }>
49
- | Ev<"VIDEO_EVENT", "DVideo", { error: unknown }>
50
- | Ev<"VIDEO_LOADED_METADATA_EVENT", "DVideo", { duration: number; isInfinity: boolean }>
51
- | Ev<"VIDEO_DURATION_CHANGE_EVENT", "DVideo", { duration: number; isInfinity: boolean }>
52
- | Ev<"VIDEO_PROGRESS_EVENT", "DVideo", { duration: number; progress: number }>
53
- | Ev<"VIDEO_ENDED_EVENT", "DVideo", {}>;
54
-
55
- // export type MediaManagerEvent =
56
- // | Ev<"MEDIA_B
57
- //
58
- //
59
- // LOCKING_START_EVENT", "MediaManager", {}>
60
- // | Ev<"MEDIA_BLOCKING_END_EVENT", "MediaManager", {}>
61
- // | Ev<"INPUT_BLOCKING_MEDIA_START_EVENT", "MediaManager", {}>
62
- // | Ev<"INPUT_BLOCKING_MEDIA_END_EVENT", "MediaManager", {}>;
63
-
64
- export type DImageEvent =
65
- | Ev<
66
- "IMAGE_LOADED_EVENT",
67
- "DImage",
68
- { naturalHeight: number; naturalWidth: number; loadTime: DTimestamp.Diff; height: number; width: number }
69
- >
70
- | Ev<"IMAGE_ERROR_EVENT", "DImage", { error: unknown }>;
71
- export type DPageEvents =
72
- | Ev<"PAGE_ENTER_EVENT", "DPage", { pageId: string }>
73
- | Ev<"PAGE_COMPLETED_EVENT", "DPage", { pageId: string; answers: AnsweredQuestion[] }>;
74
-
75
- export type DWindowEvents =
76
- | Ev<"WINDOW_VISIBILITY_CHANGE_EVENT", "Window", {}>
77
- | Ev<"WINDOW_ONLINE_STATUS_CHANGE_EVENT", "Window", {}>;
78
-
79
- export type DEvent =
80
- | DImageEvent
81
- | DAudioEvent
82
- | DVideoEvent
83
- | DPageEvents
84
- // | MediaManagerEvent
85
- | DWindowEvents
86
- | QueryChangedEvent
87
- | Ev<"USER_CLICKED_EVENT", "DUser", { elementId: string }>
88
- | Ev<"RULE_MATCH_EVENT", "Window", { ruleId: string }>
89
- | Ev<
90
- "ENGINE_SCHEMA_LOADED_EVENT",
91
- "Engine",
92
- { pageCount: number; hostHeight: number; hostWidth: number; scale: number }
93
- >
94
- | Ev<"HOST_SCALE_CHANGED_EVENT", "HOST", { scale: number }>;
@@ -1,21 +0,0 @@
1
- import { EventBus } from "./event-bus";
2
- import { DTimestamp } from "../common/DTimestamp";
3
- describe("Event-bus-works", () => {
4
- test("Can create event-bus", (done) => {
5
- const bus = new EventBus();
6
-
7
- bus.consoleLogEvents = false;
8
- bus.subscribe((ev) => {
9
- expect(ev.kind === "AUDIO_PLAY_EVENT").toBe(true);
10
- done();
11
- }, "TEST. CAN CREATE EVENTBUS");
12
-
13
- bus.emit({
14
- kind: "AUDIO_PLAY_EVENT",
15
- timestamp: DTimestamp.now(),
16
- data: {},
17
- producerId: "",
18
- producer: "DAudio",
19
- });
20
- });
21
- });
@@ -1,81 +0,0 @@
1
- import { DEvent } from "./DEvents";
2
-
3
- interface SubscriberData {
4
- readonly subscriberId: string;
5
- readonly cb: (event: DEvent) => void;
6
- }
7
-
8
- export interface DEventStore {
9
- subscribe(cb: (event: DEvent) => void, subscriberId: string): void;
10
- }
11
-
12
- export interface DEventDispatcher {
13
- emit(event: DEvent): void;
14
- }
15
- export class EventBus implements DEventStore, DEventDispatcher {
16
- private readonly TAG = "[ EVENT_BUS ] :";
17
- // private readonly subscribers = new Set<(event: DEvent) => void>();
18
- private readonly subscribers = new Set<SubscriberData>();
19
-
20
- /**
21
- * Emit on module end.
22
- * @private
23
- */
24
- private readonly eventLog: DEvent[] = [];
25
- consoleLogEvents = false;
26
- // readonly sub
27
-
28
- subscribe(cb: (event: DEvent) => void, subscriberId: string) {
29
- // this.subscribers.add(cb);
30
- const subscriberData: SubscriberData = {
31
- subscriberId,
32
- cb,
33
- };
34
- this.subscribers.add(subscriberData);
35
- if (this.consoleLogEvents) {
36
- console.log(this.TAG + "subscription added: " + subscriberId);
37
- console.log(this.TAG + "subscription count: " + this.subscribers.size);
38
- }
39
- return () => {
40
- if (this.consoleLogEvents) {
41
- console.log(this.TAG + "subscription removed: " + subscriberId);
42
- console.log(this.TAG + "subscription count : " + this.subscribers.size);
43
- }
44
- // this.subscribers.delete(cb);
45
- this.subscribers.delete(subscriberData);
46
- };
47
- }
48
-
49
- getStats() {
50
- return {
51
- subscribersCount: this.subscribers.size,
52
- eventLog: [...this.eventLog],
53
- subscribers: [...this.subscribers],
54
- };
55
- }
56
-
57
- emit(event: DEvent) {
58
- if (this.consoleLogEvents) {
59
- this.logEvent(event);
60
- }
61
- this.eventLog.push(event);
62
- this.subscribers.forEach((data) => {
63
- // console.log('CALLING EMIT');
64
- data.cb(event);
65
- });
66
- // this.logEvents();
67
- }
68
-
69
- private logEvent(event: DEvent) {
70
- console.groupCollapsed(this.TAG + " " + event.kind);
71
- console.log("ProducerId: " + event.producerId);
72
- console.log(event.data);
73
- console.groupEnd();
74
- }
75
-
76
- private logEvents() {
77
- console.group(this.TAG + "LOGG");
78
- console.table(this.eventLog);
79
- console.groupEnd();
80
- }
81
- }
@@ -1,56 +0,0 @@
1
- // @ts-ignore
2
- class ContextMenuManager {
3
- private static ROOT = document.createElement("div");
4
- public static hasMenu = false;
5
- private hasMenu = false;
6
-
7
- createMenu() {
8
- const root = document.createElement("div");
9
- const menu = document.createElement("div");
10
- const backDrop = document.createElement("div");
11
- backDrop.style.position = "fixed";
12
- backDrop.style.height = "100vh";
13
- backDrop.style.width = "100vw";
14
- backDrop.style.backgroundColor = "rgba(255, 0, 0, 0.25)";
15
- backDrop.style.top = "0";
16
- backDrop.style.right = "0";
17
- backDrop.style.zIndex = "1000";
18
- // backDrop.style.opacity = '0.5';
19
-
20
- menu.style.height = "50%";
21
- menu.style.width = "50%";
22
- menu.style.top = "10%";
23
- menu.style.right = "25%";
24
- menu.style.backgroundColor = "green";
25
- menu.style.position = "absolute";
26
- menu.style.zIndex = "1001";
27
- menu.contentEditable = "false";
28
- const createOption = (text: string) => {
29
- const p = document.createElement("p");
30
- p.textContent = text;
31
- return p;
32
- };
33
-
34
- const options = ["Select On-Click Actions", "Select On-Hover Actions"].map(
35
- createOption
36
- );
37
- options.forEach((op) => {
38
- menu.appendChild(op);
39
- });
40
- root.appendChild(backDrop);
41
- root.appendChild(menu);
42
- document.body.appendChild(root);
43
- this.hasMenu = true;
44
- backDrop.onclick = (ev: MouseEvent) => {
45
- console.log("BACKDROP CLICKED");
46
- console.log(ev.type);
47
- root.removeChild(backDrop);
48
- root.removeChild(menu);
49
- this.hasMenu = false;
50
- };
51
-
52
- menu.onclick = (_: MouseEvent) => {
53
- console.log("NODE CLICKED");
54
- };
55
- }
56
- }
@@ -1,46 +0,0 @@
1
- import { AnsweredQuestion, HistoryQue, PageHistory } from "./history-que";
2
- import { DTimestamp } from "../common/DTimestamp";
3
- import { PageDto } from "../dto/SchemaDto";
4
- import { PageID } from "../utils/ID";
5
-
6
- const p = (id: number): PageDto => {
7
- return { id: PageID.create(), elements: [] };
8
- };
9
-
10
- const answer = (id: number, value: number): AnsweredQuestion => ({
11
- timestamp: DTimestamp.now(),
12
- fact: {
13
- referenceId: "" + id,
14
- referenceLabel: "label-for-" + id,
15
- value,
16
- label: "value-label " + value,
17
- kind: "numeric-fact",
18
- },
19
- });
20
- const h = (page: PageDto, answeredQuestions: AnsweredQuestion[]): PageHistory => ({
21
- pageId: page.id,
22
- answeredQuestions,
23
- });
24
- const p1 = p(1);
25
- const p2 = p(2);
26
- const p3 = p(3);
27
- const p4 = p(4);
28
- const p5 = p(5);
29
- const p6 = p(6);
30
- const all = [p1, p2, p3, p4, p5, p6];
31
-
32
- let history = new HistoryQue();
33
- beforeEach(() => {
34
- history = new HistoryQue();
35
- });
36
-
37
- describe("HistoryQue", () => {
38
- it("should create an instance", () => {
39
- expect(history).toBeTruthy();
40
- });
41
-
42
- it("Can add history, and get facts back", () => {
43
- history.addToHistory(h(p1, [answer(1, 2)]));
44
- expect(history.getFacts().length).toBe(1);
45
- });
46
- });
@@ -1,38 +0,0 @@
1
- import { Fact } from "../rules/fact";
2
- import { DTimestamp } from "../common/DTimestamp";
3
-
4
- export interface AnsweredQuestion {
5
- readonly timestamp: DTimestamp;
6
- readonly fact: Fact;
7
- }
8
-
9
- export namespace AnsweredQuestion {
10
- export const eq = (a: AnsweredQuestion, b: AnsweredQuestion): boolean => {
11
- return a.fact === b.fact;
12
- };
13
- }
14
-
15
- export interface PageHistory {
16
- readonly pageId: string;
17
- readonly answeredQuestions: AnsweredQuestion[];
18
- }
19
-
20
- export class HistoryQue {
21
- private history: PageHistory[] = [];
22
-
23
- getFacts(): Array<Fact> {
24
- const answers = this.history.map((h) => h.answeredQuestions).flat(1);
25
- const facts = answers.map((a) => a.fact);
26
- // TODO FIND LATEST FACT (answer) if have multiple.
27
- return facts;
28
- }
29
-
30
- getAnswers(): Array<AnsweredQuestion> {
31
- const answers = this.history.map((h) => h.answeredQuestions).flat(1);
32
- return answers;
33
- }
34
-
35
- addToHistory(page: PageHistory) {
36
- this.history.push(page);
37
- }
38
- }
@@ -1,93 +0,0 @@
1
- import { PageDto } from "../dto/SchemaDto";
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
- get size(): number {
88
- return this.remaining.length;
89
- }
90
- get pageCount(): number {
91
- return this.originalOrder.length;
92
- }
93
- }
@@ -1,27 +0,0 @@
1
- import { DMediaManager } from "./DMedia-manager";
2
- import { EventBus } from "../events/event-bus";
3
- import { ScaleService } from "../engine/scale";
4
- import { DCommandBus } from "../commands/DCommandBus";
5
- import { ResourceProvider } from "./resource-provider";
6
-
7
- describe("Media-manager to work", () => {
8
- test("Can be instanciated", () => {
9
- const host = document.createElement("div");
10
- const eventBus = new EventBus();
11
- const commandBus = new DCommandBus();
12
- const scale = new ScaleService({
13
- baseHeight: 1300,
14
- baseWidth: 1024,
15
- containerHeight: 650,
16
- containerWidth: 600,
17
- });
18
-
19
- const resourceProvider = new ResourceProvider({
20
- videos: [],
21
- audio: [],
22
- });
23
- const mm = new DMediaManager(host, commandBus, eventBus, resourceProvider, scale);
24
- // const pageDto: PageDto = {id}
25
- expect(host.children.length).toBe(1);
26
- });
27
- });