eligius 1.5.2 → 2.0.0
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/README.md +107 -25
- package/dist/index.d.mts +1882 -396
- package/dist/index.mjs +2618 -1442
- package/dist/index.mjs.map +1 -1
- package/jsonschema/operation-templates/animate-with-class.json +1 -3
- package/jsonschema/operation-templates/clear-operation-data.json +1 -3
- package/jsonschema/operation-templates/clear-storage.json +1 -3
- package/jsonschema/operation-templates/concatenate-strings.json +1 -3
- package/jsonschema/operation-templates/create-element.json +1 -3
- package/jsonschema/operation-templates/filter-array.json +2 -6
- package/jsonschema/operation-templates/find-in-array.json +2 -6
- package/jsonschema/operation-templates/get-query-params.json +1 -3
- package/jsonschema/operation-templates/http-delete.json +1 -3
- package/jsonschema/operation-templates/http-post.json +1 -3
- package/jsonschema/operation-templates/http-put.json +1 -3
- package/jsonschema/operation-templates/invoke-object-method.json +1 -3
- package/jsonschema/operation-templates/load-json.json +1 -3
- package/jsonschema/operation-templates/log.json +1 -3
- package/jsonschema/operation-templates/select-element.json +1 -3
- package/jsonschema/operation-templates/set-operation-data.json +1 -3
- package/jsonschema/operation-templates/sort-array.json +2 -6
- package/jsonschema/operation-templates/split-string.json +1 -3
- package/jsonschema/operation-templates/substring-text.json +1 -3
- package/jsonschema/operation-templates/validate-form.json +1 -3
- package/jsonschema/operations/animate-with-class.json +1 -3
- package/jsonschema/operations/clear-operation-data.json +1 -3
- package/jsonschema/operations/clear-storage.json +1 -3
- package/jsonschema/operations/concatenate-strings.json +1 -3
- package/jsonschema/operations/create-element.json +1 -3
- package/jsonschema/operations/filter-array.json +2 -6
- package/jsonschema/operations/find-in-array.json +2 -6
- package/jsonschema/operations/get-query-params.json +1 -3
- package/jsonschema/operations/http-delete.json +1 -3
- package/jsonschema/operations/http-post.json +1 -3
- package/jsonschema/operations/http-put.json +1 -3
- package/jsonschema/operations/invoke-object-method.json +1 -3
- package/jsonschema/operations/load-json.json +1 -3
- package/jsonschema/operations/log.json +1 -3
- package/jsonschema/operations/select-element.json +1 -3
- package/jsonschema/operations/set-operation-data.json +1 -3
- package/jsonschema/operations/sort-array.json +2 -6
- package/jsonschema/operations/split-string.json +1 -3
- package/jsonschema/operations/substring-text.json +1 -3
- package/jsonschema/operations/validate-form.json +1 -3
- package/package.json +8 -7
package/dist/index.mjs
CHANGED
|
@@ -1,90 +1,11 @@
|
|
|
1
1
|
import { t as __export } from "./chunk-C6wwvPpM.mjs";
|
|
2
|
-
import $ from "jquery";
|
|
3
2
|
import { isDefined } from "ts-is-present";
|
|
3
|
+
import hk from "hotkeys-js";
|
|
4
|
+
import $ from "jquery";
|
|
4
5
|
import { v4 } from "uuid";
|
|
5
|
-
import vjs from "video.js";
|
|
6
6
|
import lt from "lottie-web";
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
//#region src/util/guards/is-function.ts
|
|
10
|
-
function isFunction(value) {
|
|
11
|
-
return typeof value === "function";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/util/guards/is-object.ts
|
|
16
|
-
function isObject(value) {
|
|
17
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/util/prepare-value-for-serialization.ts
|
|
22
|
-
function prepareValueForSerialization(value) {
|
|
23
|
-
if (Array.isArray(value)) return value.map(prepareValueForSerialization);
|
|
24
|
-
else if (value instanceof $) return "[jQuery object]";
|
|
25
|
-
else if (isObject(value)) {
|
|
26
|
-
if (value.constructor.toString().substring(0, 5) === "class" || !value.constructor.toString().startsWith("function Object()")) {
|
|
27
|
-
const funcString = value.constructor.toString();
|
|
28
|
-
return funcString.substring(0, funcString.indexOf("{") + 1);
|
|
29
|
-
}
|
|
30
|
-
return Object.fromEntries(Object.entries(value).map(([propName, propValue]) => [propName, prepareValueForSerialization(propValue)]));
|
|
31
|
-
} else if (isFunction(value)) {
|
|
32
|
-
const funcString = value.toString();
|
|
33
|
-
if (funcString.indexOf("{") > -1) return funcString.substring(0, funcString.indexOf("{") + 1);
|
|
34
|
-
return funcString;
|
|
35
|
-
}
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/diagnostics/devtool-event-listener.ts
|
|
41
|
-
var DevToolEventListener = class {
|
|
42
|
-
constructor(agent) {
|
|
43
|
-
this.agent = agent;
|
|
44
|
-
}
|
|
45
|
-
handleEvent(eventName, eventTopic, args) {
|
|
46
|
-
const message = {
|
|
47
|
-
eventName,
|
|
48
|
-
eventTopic,
|
|
49
|
-
args: prepareValueForSerialization(args)
|
|
50
|
-
};
|
|
51
|
-
try {
|
|
52
|
-
this.agent.postMessage("eligius-diagnostics-event", message);
|
|
53
|
-
} catch (e) {
|
|
54
|
-
console.error("postmessage failed");
|
|
55
|
-
console.error(e);
|
|
56
|
-
console.info("message", message);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/diagnostics/diagnostics.ts
|
|
63
|
-
let active;
|
|
64
|
-
function send(_name, _data) {
|
|
65
|
-
console.log(_name, _data);
|
|
66
|
-
}
|
|
67
|
-
function setActive(value) {
|
|
68
|
-
active = value;
|
|
69
|
-
}
|
|
70
|
-
function isActive() {
|
|
71
|
-
return active;
|
|
72
|
-
}
|
|
73
|
-
const Diagnostics = {
|
|
74
|
-
send,
|
|
75
|
-
get active() {
|
|
76
|
-
return active;
|
|
77
|
-
},
|
|
78
|
-
set active(value) {
|
|
79
|
-
active = value;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region src/diagnostics/types.ts
|
|
85
|
-
const DEV_TOOLS_KEY = "__ELIGIUS_DEV_TOOLS__";
|
|
7
|
+
import vjs from "video.js";
|
|
86
8
|
|
|
87
|
-
//#endregion
|
|
88
9
|
//#region src/operation/helper/find-matching-operation-index.ts
|
|
89
10
|
/**
|
|
90
11
|
* This function can be used to find the index of a matching closing operation within a list of operations.
|
|
@@ -392,23 +313,14 @@ var Action = class {
|
|
|
392
313
|
this.eventbus = eventbus$1;
|
|
393
314
|
}
|
|
394
315
|
start(initOperationData) {
|
|
395
|
-
Diagnostics.active && Diagnostics.send("eligius-diagnostics-action", `${this.name ?? "Action"} begins executing start operations`);
|
|
396
316
|
this._initializeScopeStack();
|
|
397
|
-
|
|
317
|
+
return new Promise((resolve, reject) => {
|
|
398
318
|
this.executeOperation(this.startOperations, 0, resolve, reject, initOperationData);
|
|
399
319
|
}).catch((e) => {
|
|
400
|
-
Diagnostics.active && Diagnostics.send("eligius-diagnostics-action-error", {
|
|
401
|
-
name: this.name,
|
|
402
|
-
error: e
|
|
403
|
-
});
|
|
404
320
|
console.error(`Error in action start '${this.name}'`);
|
|
405
321
|
console.error(e);
|
|
406
322
|
throw e;
|
|
407
323
|
});
|
|
408
|
-
return !Diagnostics.active ? result : result.then((operationsResult) => {
|
|
409
|
-
Diagnostics.send("eligius-diagnostics-action", `${this.name ?? "Action"} finished executing start operations`);
|
|
410
|
-
return operationsResult;
|
|
411
|
-
});
|
|
412
324
|
}
|
|
413
325
|
_initializeScopeStack() {
|
|
414
326
|
this._scopeStack = [{
|
|
@@ -455,14 +367,6 @@ var Action = class {
|
|
|
455
367
|
scope = this._pushScope(scope);
|
|
456
368
|
scope.owner = operationInfo;
|
|
457
369
|
}
|
|
458
|
-
Diagnostics.active && Diagnostics.send("eligius-diagnostics-operation", {
|
|
459
|
-
systemName: operationInfo.systemName,
|
|
460
|
-
operationData: mergedOperationData,
|
|
461
|
-
scope: {
|
|
462
|
-
...scope,
|
|
463
|
-
eventbus: void 0
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
370
|
const operationResult = operationInfo.instance.call(scope, mergedOperationData);
|
|
467
371
|
if (operationInfo.systemName === endWhenSystemName || operationInfo.systemName === endForEachSystemName && scope.newIndex === void 0) this._popScope();
|
|
468
372
|
if (isPromise(operationResult)) operationResult.then((promisedOperationResult) => this.executeOperation(operations$1, ++operationIndex, resolve, reject, promisedOperationResult)).catch((error) => {
|
|
@@ -481,23 +385,14 @@ var EndableAction = class extends Action {
|
|
|
481
385
|
this.endOperations = endOperations;
|
|
482
386
|
}
|
|
483
387
|
end(initOperationData) {
|
|
484
|
-
Diagnostics.active && Diagnostics.send("eligius-diagnostics-action", `${this.name ?? "Action"} begins executing end operations`);
|
|
485
388
|
if (!this.endOperations.length) return Promise.resolve(initOperationData ?? {});
|
|
486
389
|
this._initializeScopeStack();
|
|
487
|
-
|
|
390
|
+
return new Promise((resolve, reject) => {
|
|
488
391
|
this.executeOperation(this.endOperations, 0, resolve, reject, initOperationData);
|
|
489
392
|
}).catch((e) => {
|
|
490
|
-
Diagnostics.active && Diagnostics.send("eligius-diagnostics-action-error", {
|
|
491
|
-
name: this.name,
|
|
492
|
-
error: e
|
|
493
|
-
});
|
|
494
393
|
console.error(`Error in action end '${this.name}'`);
|
|
495
394
|
throw e;
|
|
496
395
|
});
|
|
497
|
-
return !Diagnostics.active ? result : result.then((operationsResult) => {
|
|
498
|
-
Diagnostics.send("eligius-diagnostics-action", `${this.name ?? "Action"} finished executing start operations`);
|
|
499
|
-
return operationsResult;
|
|
500
|
-
});
|
|
501
396
|
}
|
|
502
397
|
};
|
|
503
398
|
|
|
@@ -527,6 +422,273 @@ var TimelineAction = class extends EndableAction {
|
|
|
527
422
|
}
|
|
528
423
|
};
|
|
529
424
|
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/adapters/engine-eventbus-adapter.ts
|
|
427
|
+
/**
|
|
428
|
+
* Bridges EligiusEngine to/from the eventbus.
|
|
429
|
+
*
|
|
430
|
+
* This adapter:
|
|
431
|
+
* - Forwards engine events to eventbus broadcasts
|
|
432
|
+
* - Forwards eventbus commands to engine methods
|
|
433
|
+
* - Handles eventbus state queries by reading engine properties
|
|
434
|
+
*/
|
|
435
|
+
var EngineEventbusAdapter = class {
|
|
436
|
+
_engineEventRemovers = [];
|
|
437
|
+
_eventbusRemovers = [];
|
|
438
|
+
constructor(_engine, _eventbus) {
|
|
439
|
+
this._engine = _engine;
|
|
440
|
+
this._eventbus = _eventbus;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Connect adapter - start listening and forwarding
|
|
444
|
+
*/
|
|
445
|
+
connect() {
|
|
446
|
+
this._subscribeToEngineEvents();
|
|
447
|
+
this._subscribeToEventbusEvents();
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Disconnect adapter - stop all listeners
|
|
451
|
+
*/
|
|
452
|
+
disconnect() {
|
|
453
|
+
this._engineEventRemovers.forEach((remove) => remove());
|
|
454
|
+
this._engineEventRemovers = [];
|
|
455
|
+
this._eventbusRemovers.forEach((remove) => remove());
|
|
456
|
+
this._eventbusRemovers = [];
|
|
457
|
+
}
|
|
458
|
+
_subscribeToEngineEvents() {
|
|
459
|
+
this._onEngineEvent("start", () => {
|
|
460
|
+
this._eventbus.broadcast("timeline-play", []);
|
|
461
|
+
});
|
|
462
|
+
this._onEngineEvent("pause", () => {
|
|
463
|
+
this._eventbus.broadcast("timeline-pause", []);
|
|
464
|
+
});
|
|
465
|
+
this._onEngineEvent("stop", () => {
|
|
466
|
+
this._eventbus.broadcast("timeline-stop", []);
|
|
467
|
+
});
|
|
468
|
+
this._onEngineEvent("time", (position) => {
|
|
469
|
+
this._eventbus.broadcast("timeline-time", [position]);
|
|
470
|
+
});
|
|
471
|
+
this._onEngineEvent("duration", (duration) => {
|
|
472
|
+
this._eventbus.broadcast("timeline-duration", [() => duration]);
|
|
473
|
+
});
|
|
474
|
+
this._onEngineEvent("seekStart", (target, current, duration) => {
|
|
475
|
+
this._eventbus.broadcast("timeline-seek", [
|
|
476
|
+
target,
|
|
477
|
+
current,
|
|
478
|
+
duration
|
|
479
|
+
]);
|
|
480
|
+
});
|
|
481
|
+
this._onEngineEvent("seekComplete", (position, duration) => {
|
|
482
|
+
this._eventbus.broadcast("timeline-seeked", [position, duration]);
|
|
483
|
+
});
|
|
484
|
+
this._onEngineEvent("timelineChange", (uri) => {
|
|
485
|
+
this._eventbus.broadcast("timeline-current-timeline-change", [uri]);
|
|
486
|
+
});
|
|
487
|
+
this._onEngineEvent("timelineComplete", () => {
|
|
488
|
+
this._eventbus.broadcast("timeline-complete", []);
|
|
489
|
+
});
|
|
490
|
+
this._onEngineEvent("timelineFirstFrame", () => {
|
|
491
|
+
this._eventbus.broadcast("timeline-firstframe", []);
|
|
492
|
+
});
|
|
493
|
+
this._onEngineEvent("timelineRestart", () => {
|
|
494
|
+
this._eventbus.broadcast("timeline-restart", []);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
_onEngineEvent(event, handler) {
|
|
498
|
+
const remover = this._engine.on(event, handler);
|
|
499
|
+
this._engineEventRemovers.push(remover);
|
|
500
|
+
}
|
|
501
|
+
_subscribeToEventbusEvents() {
|
|
502
|
+
this._onEventbusEvent("timeline-play-request", () => {
|
|
503
|
+
this._engine.start();
|
|
504
|
+
});
|
|
505
|
+
this._onEventbusEvent("timeline-pause-request", () => {
|
|
506
|
+
this._engine.pause();
|
|
507
|
+
});
|
|
508
|
+
this._onEventbusEvent("timeline-stop-request", () => {
|
|
509
|
+
this._engine.stop();
|
|
510
|
+
});
|
|
511
|
+
this._onEventbusEvent("timeline-seek-request", (position) => {
|
|
512
|
+
this._engine.seek(position);
|
|
513
|
+
});
|
|
514
|
+
this._onEventbusEvent("timeline-play-toggle-request", () => {
|
|
515
|
+
if (this._engine.playState === "playing") this._engine.pause();
|
|
516
|
+
else this._engine.start();
|
|
517
|
+
});
|
|
518
|
+
this._onEventbusEvent("request-timeline-uri", (uri, position = 0) => {
|
|
519
|
+
this._engine.switchTimeline(uri, position);
|
|
520
|
+
});
|
|
521
|
+
this._registerRequest("request-current-timeline-position", () => {
|
|
522
|
+
return this._engine.position;
|
|
523
|
+
});
|
|
524
|
+
this._registerRequest("timeline-duration-request", () => {
|
|
525
|
+
return this._engine.duration;
|
|
526
|
+
});
|
|
527
|
+
this._registerRequest("timeline-container-request", () => {
|
|
528
|
+
return this._engine.container;
|
|
529
|
+
});
|
|
530
|
+
this._registerRequest("request-engine-root", () => {
|
|
531
|
+
return this._engine.engineRoot;
|
|
532
|
+
});
|
|
533
|
+
this._registerRequest("timeline-request-current-timeline", () => {
|
|
534
|
+
return this._engine.currentTimelineUri;
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
_onEventbusEvent(eventName, handler) {
|
|
538
|
+
const remover = this._eventbus.on(eventName, handler);
|
|
539
|
+
this._eventbusRemovers.push(remover);
|
|
540
|
+
}
|
|
541
|
+
_registerRequest(eventName, responder) {
|
|
542
|
+
const remover = this._eventbus.onRequest(eventName, responder);
|
|
543
|
+
this._eventbusRemovers.push(remover);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region src/adapters/engine-input-adapter.ts
|
|
549
|
+
const hotkeys = hk.default || hk;
|
|
550
|
+
/**
|
|
551
|
+
* Handles external input sources (hotkeys, resize).
|
|
552
|
+
*
|
|
553
|
+
* This adapter:
|
|
554
|
+
* - Registers keyboard hotkeys (space for play/pause toggle)
|
|
555
|
+
* - Handles window resize events with debouncing
|
|
556
|
+
*/
|
|
557
|
+
var EngineInputAdapter = class {
|
|
558
|
+
_removers = [];
|
|
559
|
+
_resizeTimeout;
|
|
560
|
+
_resizeHandler;
|
|
561
|
+
constructor(_engine, _eventbus, _windowRef) {
|
|
562
|
+
this._engine = _engine;
|
|
563
|
+
this._eventbus = _eventbus;
|
|
564
|
+
this._windowRef = _windowRef;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Connect adapter - start listening to inputs
|
|
568
|
+
*/
|
|
569
|
+
connect() {
|
|
570
|
+
this._registerHotkeys();
|
|
571
|
+
this._registerResizeHandler();
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Disconnect adapter - stop all listeners
|
|
575
|
+
*/
|
|
576
|
+
disconnect() {
|
|
577
|
+
if (this._resizeTimeout) {
|
|
578
|
+
clearTimeout(this._resizeTimeout);
|
|
579
|
+
this._resizeTimeout = void 0;
|
|
580
|
+
}
|
|
581
|
+
this._removers.forEach((remove) => remove());
|
|
582
|
+
this._removers = [];
|
|
583
|
+
}
|
|
584
|
+
_registerHotkeys() {
|
|
585
|
+
const handleSpaceBound = this._handleSpacePress.bind(this);
|
|
586
|
+
hotkeys("space", handleSpaceBound);
|
|
587
|
+
this._removers.push(() => hotkeys.unbind("space", handleSpaceBound));
|
|
588
|
+
}
|
|
589
|
+
_handleSpacePress(keyboardEvent, _hotkeysEvent) {
|
|
590
|
+
keyboardEvent.preventDefault();
|
|
591
|
+
if (this._engine.playState === "playing") this._engine.pause();
|
|
592
|
+
else this._engine.start();
|
|
593
|
+
return false;
|
|
594
|
+
}
|
|
595
|
+
_registerResizeHandler() {
|
|
596
|
+
this._resizeHandler = this._handleResize.bind(this);
|
|
597
|
+
this._windowRef.addEventListener("resize", this._resizeHandler);
|
|
598
|
+
this._removers.push(() => {
|
|
599
|
+
if (this._resizeHandler) this._windowRef.removeEventListener("resize", this._resizeHandler);
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
_handleResize() {
|
|
603
|
+
if (this._resizeTimeout) {
|
|
604
|
+
clearTimeout(this._resizeTimeout);
|
|
605
|
+
this._resizeTimeout = void 0;
|
|
606
|
+
}
|
|
607
|
+
this._resizeTimeout = setTimeout(() => {
|
|
608
|
+
this._eventbus.broadcast("timeline-resize", []);
|
|
609
|
+
}, 200);
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
//#endregion
|
|
614
|
+
//#region src/adapters/language-eventbus-adapter.ts
|
|
615
|
+
/**
|
|
616
|
+
* Bridges LanguageManager to/from the eventbus.
|
|
617
|
+
*
|
|
618
|
+
* This adapter:
|
|
619
|
+
* - Forwards language manager events to eventbus broadcasts
|
|
620
|
+
* - Forwards eventbus language commands to language manager methods
|
|
621
|
+
* - Handles eventbus state queries by reading language manager properties
|
|
622
|
+
* - Updates DOM lang attribute when language changes
|
|
623
|
+
*
|
|
624
|
+
* Note: Requires engine reference to update DOM lang attribute on language change
|
|
625
|
+
*/
|
|
626
|
+
var LanguageEventbusAdapter = class {
|
|
627
|
+
_languageEventRemovers = [];
|
|
628
|
+
_eventbusRemovers = [];
|
|
629
|
+
constructor(_languageManager, _eventbus, _engine) {
|
|
630
|
+
this._languageManager = _languageManager;
|
|
631
|
+
this._eventbus = _eventbus;
|
|
632
|
+
this._engine = _engine;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Connect adapter - start listening and forwarding
|
|
636
|
+
*/
|
|
637
|
+
connect() {
|
|
638
|
+
this._subscribeToLanguageManagerEvents();
|
|
639
|
+
this._subscribeToEventbusEvents();
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Disconnect adapter - stop all listeners
|
|
643
|
+
*/
|
|
644
|
+
disconnect() {
|
|
645
|
+
this._languageEventRemovers.forEach((remove) => remove());
|
|
646
|
+
this._languageEventRemovers = [];
|
|
647
|
+
this._eventbusRemovers.forEach((remove) => remove());
|
|
648
|
+
this._eventbusRemovers = [];
|
|
649
|
+
}
|
|
650
|
+
_subscribeToLanguageManagerEvents() {
|
|
651
|
+
this._onLanguageEvent("change", (language, _previousLanguage) => {
|
|
652
|
+
this._setRootElementLang(language);
|
|
653
|
+
this._eventbus.broadcast("language-change", [language]);
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
_onLanguageEvent(event, handler) {
|
|
657
|
+
const remover = this._languageManager.on(event, handler);
|
|
658
|
+
this._languageEventRemovers.push(remover);
|
|
659
|
+
}
|
|
660
|
+
_subscribeToEventbusEvents() {
|
|
661
|
+
this._onEventbusEvent("language-change", (language) => {
|
|
662
|
+
this._languageManager.setLanguage(language);
|
|
663
|
+
this._setRootElementLang(language);
|
|
664
|
+
});
|
|
665
|
+
this._registerRequest("request-current-language", () => {
|
|
666
|
+
return this._languageManager.language;
|
|
667
|
+
});
|
|
668
|
+
this._registerRequest("request-label-collection", (labelId) => {
|
|
669
|
+
return this._languageManager.getLabelCollection(labelId);
|
|
670
|
+
});
|
|
671
|
+
this._registerRequest("request-label-collections", (labelIds) => {
|
|
672
|
+
return this._languageManager.getLabelCollections(labelIds);
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
_onEventbusEvent(eventName, handler) {
|
|
676
|
+
const remover = this._eventbus.on(eventName, handler);
|
|
677
|
+
this._eventbusRemovers.push(remover);
|
|
678
|
+
}
|
|
679
|
+
_registerRequest(eventName, responder) {
|
|
680
|
+
const remover = this._eventbus.onRequest(eventName, responder);
|
|
681
|
+
this._eventbusRemovers.push(remover);
|
|
682
|
+
}
|
|
683
|
+
_setRootElementLang(language) {
|
|
684
|
+
const lang = this._extractPrimaryLanguage(language);
|
|
685
|
+
this._engine.engineRoot.attr("lang", lang);
|
|
686
|
+
}
|
|
687
|
+
_extractPrimaryLanguage(culture) {
|
|
688
|
+
return culture.split("-").shift();
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
|
|
530
692
|
//#endregion
|
|
531
693
|
//#region src/operation/add-class.ts
|
|
532
694
|
/**
|
|
@@ -738,6 +900,12 @@ const broadcastEvent = function(operationData) {
|
|
|
738
900
|
return operationData;
|
|
739
901
|
};
|
|
740
902
|
|
|
903
|
+
//#endregion
|
|
904
|
+
//#region src/util/guards/is-object.ts
|
|
905
|
+
function isObject(value) {
|
|
906
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
907
|
+
}
|
|
908
|
+
|
|
741
909
|
//#endregion
|
|
742
910
|
//#region src/operation/helper/resolve-property-values.ts
|
|
743
911
|
const cache = [];
|
|
@@ -948,7 +1116,8 @@ const createElement = function(operationData) {
|
|
|
948
1116
|
const { elementName, attributes, text } = operationData;
|
|
949
1117
|
removeProperties(operationData, "elementName", "attributes", "text");
|
|
950
1118
|
const serializedAttrs = attributes ? ` ${Object.entries(attributes).filter(([_, value]) => Boolean(value)).map(([key, value]) => `${key}="${value}"`).join(" ")}` : "";
|
|
951
|
-
|
|
1119
|
+
const template = text ? $(`<${elementName}${serializedAttrs}>${text}</${elementName}>`) : $(`<${elementName}${serializedAttrs}/>`);
|
|
1120
|
+
operationData.template = template;
|
|
952
1121
|
return operationData;
|
|
953
1122
|
};
|
|
954
1123
|
|
|
@@ -965,16 +1134,15 @@ const createElement = function(operationData) {
|
|
|
965
1134
|
const customFunction = function(operationData) {
|
|
966
1135
|
const { systemName } = operationData;
|
|
967
1136
|
removeProperties(operationData, "systemName");
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
},
|
|
974
|
-
|
|
975
|
-
};
|
|
976
|
-
this.eventbus.broadcast("request-function", [systemName, resultCallback]);
|
|
1137
|
+
const func = this.eventbus.request("request-function", systemName);
|
|
1138
|
+
if (!func) return operationData;
|
|
1139
|
+
const promise = func.apply(this, [operationData]);
|
|
1140
|
+
if (promise) return new Promise((resolve, reject) => {
|
|
1141
|
+
promise.then(() => {
|
|
1142
|
+
internalResolve(resolve, {}, operationData);
|
|
1143
|
+
}, reject);
|
|
977
1144
|
});
|
|
1145
|
+
return operationData;
|
|
978
1146
|
};
|
|
979
1147
|
|
|
980
1148
|
//#endregion
|
|
@@ -1297,11 +1465,7 @@ const getControllerFromElement = (operationData) => {
|
|
|
1297
1465
|
const getControllerInstance = function(operationData) {
|
|
1298
1466
|
const { systemName } = operationData;
|
|
1299
1467
|
removeProperties(operationData, "systemName");
|
|
1300
|
-
operationData.controllerInstance =
|
|
1301
|
-
const resultCallback = (instance) => {
|
|
1302
|
-
operationData.controllerInstance = instance;
|
|
1303
|
-
};
|
|
1304
|
-
this.eventbus.broadcast("request-instance", [systemName, resultCallback]);
|
|
1468
|
+
operationData.controllerInstance = this.eventbus.request("request-instance", systemName);
|
|
1305
1469
|
return operationData;
|
|
1306
1470
|
};
|
|
1307
1471
|
|
|
@@ -1529,11 +1693,7 @@ const getFormData = (operationData) => {
|
|
|
1529
1693
|
const getImport = function(operationData) {
|
|
1530
1694
|
const { systemName } = operationData;
|
|
1531
1695
|
delete operationData.systemName;
|
|
1532
|
-
|
|
1533
|
-
operationData.importedInstance = instance;
|
|
1534
|
-
};
|
|
1535
|
-
this.eventbus.broadcast("request-function", [systemName, callBack]);
|
|
1536
|
-
delete operationData.systemName;
|
|
1696
|
+
operationData.importedInstance = this.eventbus.request("request-function", systemName);
|
|
1537
1697
|
return operationData;
|
|
1538
1698
|
};
|
|
1539
1699
|
|
|
@@ -1928,6 +2088,12 @@ const mapArray = (operationData) => {
|
|
|
1928
2088
|
return operationData;
|
|
1929
2089
|
};
|
|
1930
2090
|
|
|
2091
|
+
//#endregion
|
|
2092
|
+
//#region src/util/guards/is-function.ts
|
|
2093
|
+
function isFunction(value) {
|
|
2094
|
+
return typeof value === "function";
|
|
2095
|
+
}
|
|
2096
|
+
|
|
1931
2097
|
//#endregion
|
|
1932
2098
|
//#region src/util/guards/is-string.ts
|
|
1933
2099
|
function isString(value) {
|
|
@@ -2159,10 +2325,7 @@ const replaceText = (operationData) => {
|
|
|
2159
2325
|
const requestAction = function(operationData) {
|
|
2160
2326
|
const { systemName } = operationData;
|
|
2161
2327
|
removeProperties(operationData, "systemName");
|
|
2162
|
-
|
|
2163
|
-
operationData.actionInstance = action;
|
|
2164
|
-
};
|
|
2165
|
-
this.eventbus.broadcast("request-action", [systemName, resultCallback]);
|
|
2328
|
+
operationData.actionInstance = this.eventbus.request("request-action", systemName);
|
|
2166
2329
|
return operationData;
|
|
2167
2330
|
};
|
|
2168
2331
|
|
|
@@ -2318,10 +2481,8 @@ const selectElement = function(operationData) {
|
|
|
2318
2481
|
operationData.selectedElement = findElementBySelector(currentRoot, selector);
|
|
2319
2482
|
return operationData;
|
|
2320
2483
|
}
|
|
2321
|
-
const
|
|
2322
|
-
|
|
2323
|
-
};
|
|
2324
|
-
this.eventbus.broadcast("request-engine-root", [rootCallback]);
|
|
2484
|
+
const root = this.eventbus.request("request-engine-root");
|
|
2485
|
+
if (root) operationData.selectedElement = findElementBySelector(root, selector);
|
|
2325
2486
|
return operationData;
|
|
2326
2487
|
};
|
|
2327
2488
|
|
|
@@ -3533,25 +3694,6 @@ var OperationEditor = class {
|
|
|
3533
3694
|
}
|
|
3534
3695
|
};
|
|
3535
3696
|
|
|
3536
|
-
//#endregion
|
|
3537
|
-
//#region src/util/merge-if-missing.ts
|
|
3538
|
-
/**
|
|
3539
|
-
*
|
|
3540
|
-
* Merges the properties of the target object into the source object, only the properties that do not exist yet on the source.
|
|
3541
|
-
*
|
|
3542
|
-
* This function is pure, so it returns a new instance that reflects the merging of the two objects.
|
|
3543
|
-
*
|
|
3544
|
-
* The merge is shallow.
|
|
3545
|
-
*
|
|
3546
|
-
* @param target
|
|
3547
|
-
* @param source
|
|
3548
|
-
* @returns
|
|
3549
|
-
*/
|
|
3550
|
-
const mergeIfMissing = (target, source) => Object.entries(source).reduce((acc, [key, value]) => key in acc ? acc : {
|
|
3551
|
-
...acc,
|
|
3552
|
-
[key]: value
|
|
3553
|
-
}, target);
|
|
3554
|
-
|
|
3555
3697
|
//#endregion
|
|
3556
3698
|
//#region src/configuration/api/label-editor.ts
|
|
3557
3699
|
/**
|
|
@@ -3604,323 +3746,154 @@ var LabelEditor = class {
|
|
|
3604
3746
|
};
|
|
3605
3747
|
|
|
3606
3748
|
//#endregion
|
|
3607
|
-
//#region src/
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
_updateBound = this._update.bind(this);
|
|
3629
|
-
_firstFramePending = true;
|
|
3630
|
-
_currentPlaylistItem;
|
|
3631
|
-
_tickInterval = 1e3;
|
|
3632
|
-
_playlist;
|
|
3633
|
-
_containerElement;
|
|
3634
|
-
_abortController;
|
|
3635
|
-
_onTime;
|
|
3636
|
-
_onComplete;
|
|
3637
|
-
_onRestart;
|
|
3638
|
-
_onFirstFrame;
|
|
3639
|
-
loop = false;
|
|
3640
|
-
_playState = "stopped";
|
|
3641
|
-
get playState() {
|
|
3642
|
-
return this._playState;
|
|
3749
|
+
//#region src/configuration/api/timeline-provider-settings-editor.ts
|
|
3750
|
+
/**
|
|
3751
|
+
* Default position source system names for convenience methods.
|
|
3752
|
+
*/
|
|
3753
|
+
const DEFAULT_POSITION_SOURCES = {
|
|
3754
|
+
raf: "RafPositionSource",
|
|
3755
|
+
scroll: "ScrollPositionSource",
|
|
3756
|
+
video: "VideoPositionSource"
|
|
3757
|
+
};
|
|
3758
|
+
/**
|
|
3759
|
+
* Default container provider system name.
|
|
3760
|
+
*/
|
|
3761
|
+
const DEFAULT_CONTAINER_PROVIDER = "DomContainerProvider";
|
|
3762
|
+
/**
|
|
3763
|
+
* Default playlist system name.
|
|
3764
|
+
*/
|
|
3765
|
+
const DEFAULT_PLAYLIST = "SimplePlaylist";
|
|
3766
|
+
var TimelineProvidersSettingsEditor = class {
|
|
3767
|
+
constructor(providersSettings, configurationFactory) {
|
|
3768
|
+
this.providersSettings = providersSettings;
|
|
3769
|
+
this.configurationFactory = configurationFactory;
|
|
3643
3770
|
}
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3771
|
+
/**
|
|
3772
|
+
* Adds a new provider for the specified timeline type.
|
|
3773
|
+
*
|
|
3774
|
+
* @param timelineType - The timeline type (e.g., 'animation', 'mediaplayer')
|
|
3775
|
+
* @param positionSourceSystemName - System name of the position source class (default: 'RafPositionSource')
|
|
3776
|
+
* @returns A TimelineProviderSettingsEditor for further configuration
|
|
3777
|
+
*/
|
|
3778
|
+
addProvider(timelineType, positionSourceSystemName = "RafPositionSource") {
|
|
3779
|
+
if (this.providersSettings[timelineType]) throw new Error(`Settings for a '${timelineType}' provider already exist`);
|
|
3780
|
+
const settings = { positionSource: { systemName: positionSourceSystemName } };
|
|
3781
|
+
this.providersSettings[timelineType] = settings;
|
|
3782
|
+
return new TimelineProviderSettingsEditor(settings, this, this.configurationFactory);
|
|
3647
3783
|
}
|
|
3648
|
-
|
|
3649
|
-
|
|
3784
|
+
editProvider(timelineType) {
|
|
3785
|
+
if (!this.providersSettings[timelineType]) throw new Error(`No settings for a '${timelineType}' provider exist yet`);
|
|
3786
|
+
return new TimelineProviderSettingsEditor(this.providersSettings[timelineType], this, this.configurationFactory);
|
|
3650
3787
|
}
|
|
3651
|
-
|
|
3652
|
-
this.
|
|
3788
|
+
next() {
|
|
3789
|
+
return this.configurationFactory;
|
|
3653
3790
|
}
|
|
3654
|
-
|
|
3655
|
-
|
|
3791
|
+
};
|
|
3792
|
+
var TimelineProviderSettingsEditor = class {
|
|
3793
|
+
constructor(providerSettings, providersSettingsEditor, configurationFactory) {
|
|
3794
|
+
this.providerSettings = providerSettings;
|
|
3795
|
+
this.providersSettingsEditor = providersSettingsEditor;
|
|
3796
|
+
this.configurationFactory = configurationFactory;
|
|
3656
3797
|
}
|
|
3657
|
-
|
|
3658
|
-
|
|
3798
|
+
/**
|
|
3799
|
+
* Sets the position source configuration with full config object.
|
|
3800
|
+
* @param config - Position source configuration with systemName and options
|
|
3801
|
+
*/
|
|
3802
|
+
setPositionSource(config) {
|
|
3803
|
+
this.providerSettings.positionSource = config;
|
|
3804
|
+
return this;
|
|
3659
3805
|
}
|
|
3660
|
-
|
|
3661
|
-
|
|
3806
|
+
/**
|
|
3807
|
+
* Sets the position source by system name with optional configuration.
|
|
3808
|
+
* @param systemName - The position source class name (e.g., 'RafPositionSource')
|
|
3809
|
+
* @param options - Additional options passed to the position source constructor
|
|
3810
|
+
*/
|
|
3811
|
+
setPositionSourceByName(systemName, options) {
|
|
3812
|
+
this.providerSettings.positionSource = {
|
|
3813
|
+
systemName,
|
|
3814
|
+
...options
|
|
3815
|
+
};
|
|
3816
|
+
return this;
|
|
3662
3817
|
}
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
this._resetToStartPosition();
|
|
3676
|
-
this._onRestart?.();
|
|
3677
|
-
this._callbackPosition();
|
|
3678
|
-
} else {
|
|
3679
|
-
this.stop();
|
|
3680
|
-
this._onComplete?.();
|
|
3681
|
-
return;
|
|
3682
|
-
}
|
|
3683
|
-
this._callbackPosition();
|
|
3684
|
-
}
|
|
3685
|
-
_callbackPosition() {
|
|
3686
|
-
this._onTime?.(this._currentPosition);
|
|
3687
|
-
}
|
|
3688
|
-
start() {
|
|
3689
|
-
if (this.playState === "running") {
|
|
3690
|
-
if (this._currentPosition === 0) this._callbackPosition();
|
|
3691
|
-
return;
|
|
3692
|
-
}
|
|
3693
|
-
this._playState = "running";
|
|
3694
|
-
this._abortController?.abort();
|
|
3695
|
-
this._abortController = new AbortController();
|
|
3696
|
-
if (this._firstFramePending) {
|
|
3697
|
-
this._firstFramePending = false;
|
|
3698
|
-
this._onFirstFrame?.();
|
|
3699
|
-
}
|
|
3700
|
-
if (this._currentPosition === 0) this._callbackPosition();
|
|
3701
|
-
animationInterval(this._tickInterval, this._abortController.signal, this._updateBound);
|
|
3702
|
-
}
|
|
3703
|
-
_resetToStartPosition() {
|
|
3704
|
-
this._currentPosition = 0;
|
|
3705
|
-
}
|
|
3706
|
-
getContainer() {
|
|
3707
|
-
return this._containerElement;
|
|
3708
|
-
}
|
|
3709
|
-
_stopAnimationInterval(resetPosition = true) {
|
|
3710
|
-
this._abortController?.abort();
|
|
3711
|
-
this._abortController = void 0;
|
|
3712
|
-
if (resetPosition) this._resetToStartPosition();
|
|
3713
|
-
}
|
|
3714
|
-
init() {
|
|
3715
|
-
this._currentPlaylistItem = this._playlist[0];
|
|
3716
|
-
this._containerElement = $(this._currentPlaylistItem.selector);
|
|
3717
|
-
if (!this._containerElement.length) throw new Error(`timeline selector '${this._currentPlaylistItem.selector}' not found`);
|
|
3718
|
-
return Promise.resolve();
|
|
3719
|
-
}
|
|
3720
|
-
destroy() {
|
|
3721
|
-
this.stop();
|
|
3722
|
-
this._containerElement = void 0;
|
|
3723
|
-
}
|
|
3724
|
-
stop() {
|
|
3725
|
-
this._stopAnimationInterval();
|
|
3726
|
-
this._playState = "stopped";
|
|
3727
|
-
}
|
|
3728
|
-
pause() {
|
|
3729
|
-
this._stopAnimationInterval(false);
|
|
3730
|
-
this._playState = "stopped";
|
|
3731
|
-
}
|
|
3732
|
-
seek(position) {
|
|
3733
|
-
if (position < 0 || position > this._currentPlaylistItem.duration) return Promise.resolve(this._currentPosition);
|
|
3734
|
-
this._currentPosition = position;
|
|
3735
|
-
return Promise.resolve(position);
|
|
3736
|
-
}
|
|
3737
|
-
getPosition() {
|
|
3738
|
-
return this._currentPosition;
|
|
3739
|
-
}
|
|
3740
|
-
getDuration() {
|
|
3741
|
-
return this._currentPlaylistItem.duration;
|
|
3742
|
-
}
|
|
3743
|
-
};
|
|
3744
|
-
|
|
3745
|
-
//#endregion
|
|
3746
|
-
//#region src/timelineproviders/video-js-timeline-provider.ts
|
|
3747
|
-
const videojs = vjs.default ?? vjs;
|
|
3748
|
-
var VideoJsTimelineProvider = class {
|
|
3749
|
-
_videoElementId = v4();
|
|
3750
|
-
_eventHandlers = [];
|
|
3751
|
-
_playState = "stopped";
|
|
3752
|
-
get playState() {
|
|
3753
|
-
return this._playState;
|
|
3754
|
-
}
|
|
3755
|
-
loop = false;
|
|
3756
|
-
_urls = [];
|
|
3757
|
-
_onTime;
|
|
3758
|
-
_onComplete;
|
|
3759
|
-
_onRestart;
|
|
3760
|
-
_onFirstFrame;
|
|
3761
|
-
_player;
|
|
3762
|
-
constructor(config) {
|
|
3763
|
-
this.config = config;
|
|
3764
|
-
}
|
|
3765
|
-
init() {
|
|
3766
|
-
videojs.log.level("all");
|
|
3767
|
-
const selector = this.config.timelineProviderSettings.mediaplayer?.selector ?? "";
|
|
3768
|
-
this._urls = this._extractUrls(this.config);
|
|
3769
|
-
this._addVideoElements(selector, this._urls);
|
|
3770
|
-
const self = this;
|
|
3771
|
-
return new Promise((resolve) => {
|
|
3772
|
-
setTimeout(() => {
|
|
3773
|
-
this._player = videojs(this._videoElementId, {
|
|
3774
|
-
controls: false,
|
|
3775
|
-
controlBar: false,
|
|
3776
|
-
liveui: false,
|
|
3777
|
-
autoplay: false,
|
|
3778
|
-
preload: "auto",
|
|
3779
|
-
loop: this.loop,
|
|
3780
|
-
src: this._urls[0]
|
|
3781
|
-
}, function onPlayerReady() {
|
|
3782
|
-
this.one("firstplay", () => self._onFirstFrame?.());
|
|
3783
|
-
this.one("canplay", () => resolve());
|
|
3784
|
-
self._addPlayerListener(this, "ended", self._handleEnded.bind(self));
|
|
3785
|
-
self._addPlayerListener(this, "timeupdate", self._handleTimeUpdate.bind(self));
|
|
3786
|
-
this.load();
|
|
3787
|
-
});
|
|
3788
|
-
}, 0);
|
|
3789
|
-
});
|
|
3790
|
-
}
|
|
3791
|
-
_addPlayerListener(instance, type, eventHandler) {
|
|
3792
|
-
instance.on(type, eventHandler);
|
|
3793
|
-
this._eventHandlers.push(() => instance.off(type, eventHandler));
|
|
3794
|
-
}
|
|
3795
|
-
_handleEnded() {
|
|
3796
|
-
if (!this._player?.loop) this._onComplete?.();
|
|
3797
|
-
else this._onRestart?.();
|
|
3798
|
-
}
|
|
3799
|
-
_handleTimeUpdate() {
|
|
3800
|
-
if (this._player) {
|
|
3801
|
-
const time = this._player.currentTime();
|
|
3802
|
-
if (time !== void 0) this._onTime?.(time);
|
|
3803
|
-
}
|
|
3804
|
-
}
|
|
3805
|
-
start() {
|
|
3806
|
-
this._player?.play();
|
|
3807
|
-
this._playState = "running";
|
|
3808
|
-
}
|
|
3809
|
-
stop() {
|
|
3810
|
-
this._player?.pause();
|
|
3811
|
-
this._player?.currentTime(0);
|
|
3812
|
-
this._playState = "stopped";
|
|
3813
|
-
}
|
|
3814
|
-
pause() {
|
|
3815
|
-
this._player?.pause();
|
|
3816
|
-
this._playState = "stopped";
|
|
3817
|
-
}
|
|
3818
|
-
seek(position) {
|
|
3819
|
-
return new Promise((resolve) => {
|
|
3820
|
-
this._player.one("seeked", () => {
|
|
3821
|
-
resolve(this._player?.currentTime() ?? 0);
|
|
3822
|
-
});
|
|
3823
|
-
this._player?.currentTime(position);
|
|
3824
|
-
});
|
|
3825
|
-
}
|
|
3826
|
-
playlistItem(uri) {
|
|
3827
|
-
if (uri === null || !uri.length || this._urls.length === 0) return;
|
|
3828
|
-
if (!this._urls.includes(uri)) throw new Error(`Unknown playlist uri: ${uri}`);
|
|
3829
|
-
this._player?.selectSource([uri]);
|
|
3830
|
-
}
|
|
3831
|
-
getPosition() {
|
|
3832
|
-
return this._player?.currentTime() ?? 0;
|
|
3833
|
-
}
|
|
3834
|
-
getDuration() {
|
|
3835
|
-
return this._player?.duration() ?? 0;
|
|
3836
|
-
}
|
|
3837
|
-
getContainer() {
|
|
3838
|
-
return $(this.config.timelineProviderSettings.mediaplayer?.selector ?? "");
|
|
3839
|
-
}
|
|
3840
|
-
destroy() {
|
|
3841
|
-
this._eventHandlers.forEach((remover) => remover());
|
|
3842
|
-
this._eventHandlers.length = 0;
|
|
3843
|
-
}
|
|
3844
|
-
onTime(callback) {
|
|
3845
|
-
this._onTime = callback;
|
|
3846
|
-
}
|
|
3847
|
-
onComplete(callback) {
|
|
3848
|
-
this._onComplete = callback;
|
|
3849
|
-
}
|
|
3850
|
-
onRestart(callback) {
|
|
3851
|
-
this._onRestart = callback;
|
|
3852
|
-
}
|
|
3853
|
-
onFirstFrame(callback) {
|
|
3854
|
-
this._onFirstFrame = callback;
|
|
3855
|
-
}
|
|
3856
|
-
_extractUrls(configuration) {
|
|
3857
|
-
return configuration.timelines.filter((timeline) => timeline.type === "mediaplayer").map((timeline) => timeline.uri);
|
|
3858
|
-
}
|
|
3859
|
-
_addVideoElements(selector, urls) {
|
|
3860
|
-
const videoElm = [`<video id=${this._videoElementId}>`];
|
|
3861
|
-
urls.forEach((url) => {
|
|
3862
|
-
videoElm.push(`<source src='${url}' type='${this._extractFileType(url)}'/>`);
|
|
3863
|
-
});
|
|
3864
|
-
videoElm.push("</video>");
|
|
3865
|
-
$(selector).append(videoElm.join(""));
|
|
3866
|
-
}
|
|
3867
|
-
_extractFileType(url) {
|
|
3868
|
-
const lastIdx = url.lastIndexOf(".");
|
|
3869
|
-
return `video/${url.substring(lastIdx + 1)}`;
|
|
3870
|
-
}
|
|
3871
|
-
};
|
|
3872
|
-
|
|
3873
|
-
//#endregion
|
|
3874
|
-
//#region src/timelineproviders/index.ts
|
|
3875
|
-
var timelineproviders_exports = /* @__PURE__ */ __export({
|
|
3876
|
-
RequestAnimationFrameTimelineProvider: () => RequestAnimationFrameTimelineProvider,
|
|
3877
|
-
VideoJsTimelineProvider: () => VideoJsTimelineProvider
|
|
3878
|
-
});
|
|
3879
|
-
|
|
3880
|
-
//#endregion
|
|
3881
|
-
//#region src/configuration/api/timeline-provider-settings-editor.ts
|
|
3882
|
-
var TimelineProvidersSettingsEditor = class {
|
|
3883
|
-
constructor(providersSettings, configurationFactory) {
|
|
3884
|
-
this.providersSettings = providersSettings;
|
|
3885
|
-
this.configurationFactory = configurationFactory;
|
|
3886
|
-
}
|
|
3887
|
-
addProvider(timelineType) {
|
|
3888
|
-
if (this.providersSettings[timelineType]) throw new Error(`Settings for a '${timelineType}' provider already exist`);
|
|
3889
|
-
const settings = {
|
|
3890
|
-
id: v4(),
|
|
3891
|
-
poster: void 0,
|
|
3892
|
-
selector: void 0,
|
|
3893
|
-
systemName: "",
|
|
3894
|
-
vendor: ""
|
|
3818
|
+
/**
|
|
3819
|
+
* Convenience method to set position source using shorthand type names.
|
|
3820
|
+
* @param type - Shorthand type ('raf', 'scroll', 'video')
|
|
3821
|
+
* @param options - Type-specific options
|
|
3822
|
+
* @deprecated Use setPositionSourceByName for explicit control
|
|
3823
|
+
*/
|
|
3824
|
+
setPositionSourceType(type, options) {
|
|
3825
|
+
const systemName = DEFAULT_POSITION_SOURCES[type];
|
|
3826
|
+
if (!systemName) throw new Error(`Unknown position source type: ${type}`);
|
|
3827
|
+
this.providerSettings.positionSource = {
|
|
3828
|
+
systemName,
|
|
3829
|
+
...options
|
|
3895
3830
|
};
|
|
3896
|
-
this
|
|
3897
|
-
return new TimelineProviderSettingsEditor(settings, this, this.configurationFactory);
|
|
3831
|
+
return this;
|
|
3898
3832
|
}
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3833
|
+
/**
|
|
3834
|
+
* Sets the container provider configuration by selector.
|
|
3835
|
+
* Uses DomContainerProvider by default.
|
|
3836
|
+
* @param selector - CSS selector for the container element
|
|
3837
|
+
*/
|
|
3838
|
+
setContainer(selector) {
|
|
3839
|
+
this.providerSettings.container = {
|
|
3840
|
+
systemName: DEFAULT_CONTAINER_PROVIDER,
|
|
3841
|
+
selector
|
|
3842
|
+
};
|
|
3843
|
+
return this;
|
|
3902
3844
|
}
|
|
3903
|
-
|
|
3904
|
-
|
|
3845
|
+
/**
|
|
3846
|
+
* Sets the container provider configuration with full config object.
|
|
3847
|
+
* @param config - Container provider configuration with systemName
|
|
3848
|
+
*/
|
|
3849
|
+
setContainerConfig(config) {
|
|
3850
|
+
this.providerSettings.container = config;
|
|
3851
|
+
return this;
|
|
3905
3852
|
}
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3853
|
+
/**
|
|
3854
|
+
* Sets the container provider by system name with options.
|
|
3855
|
+
* @param systemName - The container provider class name
|
|
3856
|
+
* @param options - Additional options passed to the container provider constructor
|
|
3857
|
+
*/
|
|
3858
|
+
setContainerByName(systemName, options) {
|
|
3859
|
+
this.providerSettings.container = {
|
|
3860
|
+
systemName,
|
|
3861
|
+
...options
|
|
3862
|
+
};
|
|
3863
|
+
return this;
|
|
3912
3864
|
}
|
|
3913
|
-
|
|
3914
|
-
|
|
3865
|
+
/**
|
|
3866
|
+
* Sets the playlist configuration.
|
|
3867
|
+
* Uses SimplePlaylist by default.
|
|
3868
|
+
* @param items - Array of playlist items
|
|
3869
|
+
* @param identifierKey - Key used to identify items (default: 'uri')
|
|
3870
|
+
*/
|
|
3871
|
+
setPlaylist(items, identifierKey = "uri") {
|
|
3872
|
+
this.providerSettings.playlist = {
|
|
3873
|
+
systemName: DEFAULT_PLAYLIST,
|
|
3874
|
+
items,
|
|
3875
|
+
identifierKey
|
|
3876
|
+
};
|
|
3915
3877
|
return this;
|
|
3916
3878
|
}
|
|
3917
|
-
|
|
3918
|
-
|
|
3879
|
+
/**
|
|
3880
|
+
* Sets the playlist configuration with full config object.
|
|
3881
|
+
* @param config - Playlist configuration with systemName
|
|
3882
|
+
*/
|
|
3883
|
+
setPlaylistConfig(config) {
|
|
3884
|
+
this.providerSettings.playlist = config;
|
|
3919
3885
|
return this;
|
|
3920
3886
|
}
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3887
|
+
/**
|
|
3888
|
+
* Sets the playlist by system name with options.
|
|
3889
|
+
* @param systemName - The playlist class name
|
|
3890
|
+
* @param options - Additional options including items and identifierKey
|
|
3891
|
+
*/
|
|
3892
|
+
setPlaylistByName(systemName, options) {
|
|
3893
|
+
this.providerSettings.playlist = {
|
|
3894
|
+
systemName,
|
|
3895
|
+
...options
|
|
3896
|
+
};
|
|
3924
3897
|
return this;
|
|
3925
3898
|
}
|
|
3926
3899
|
next() {
|
|
@@ -3931,6 +3904,25 @@ var TimelineProviderSettingsEditor = class {
|
|
|
3931
3904
|
}
|
|
3932
3905
|
};
|
|
3933
3906
|
|
|
3907
|
+
//#endregion
|
|
3908
|
+
//#region src/util/merge-if-missing.ts
|
|
3909
|
+
/**
|
|
3910
|
+
*
|
|
3911
|
+
* Merges the properties of the target object into the source object, only the properties that do not exist yet on the source.
|
|
3912
|
+
*
|
|
3913
|
+
* This function is pure, so it returns a new instance that reflects the merging of the two objects.
|
|
3914
|
+
*
|
|
3915
|
+
* The merge is shallow.
|
|
3916
|
+
*
|
|
3917
|
+
* @param target
|
|
3918
|
+
* @param source
|
|
3919
|
+
* @returns
|
|
3920
|
+
*/
|
|
3921
|
+
const mergeIfMissing = (target, source) => Object.entries(source).reduce((acc, [key, value]) => key in acc ? acc : {
|
|
3922
|
+
...acc,
|
|
3923
|
+
[key]: value
|
|
3924
|
+
}, target);
|
|
3925
|
+
|
|
3934
3926
|
//#endregion
|
|
3935
3927
|
//#region src/configuration/api/configuration-factory.ts
|
|
3936
3928
|
/**
|
|
@@ -4459,15 +4451,13 @@ var DOMEventListenerController = class {
|
|
|
4459
4451
|
const { selectedElement, actions, eventName } = this.operationData;
|
|
4460
4452
|
if (!this.actionInstanceInfos) {
|
|
4461
4453
|
this.actionInstanceInfos = [];
|
|
4462
|
-
|
|
4463
|
-
this.
|
|
4454
|
+
actions.forEach((actionName) => {
|
|
4455
|
+
const [isStart, name] = this._isStartAction(actionName);
|
|
4456
|
+
const actionInstance = eventbus$1.request("request-action", name);
|
|
4457
|
+
if (actionInstance) this.actionInstanceInfos?.push({
|
|
4464
4458
|
start: isStart,
|
|
4465
4459
|
action: actionInstance
|
|
4466
4460
|
});
|
|
4467
|
-
};
|
|
4468
|
-
actions.forEach((actionName) => {
|
|
4469
|
-
const [isStart, name] = this._isStartAction(actionName);
|
|
4470
|
-
eventbus$1.broadcast("request-action", [name, resultCallback(isStart)]);
|
|
4471
4461
|
});
|
|
4472
4462
|
selectedElement.on(eventName, this._eventHandler.bind(this));
|
|
4473
4463
|
}
|
|
@@ -4588,19 +4578,16 @@ var LabelController = class extends BaseController {
|
|
|
4588
4578
|
}
|
|
4589
4579
|
attach(eventbus$1) {
|
|
4590
4580
|
if (!this.operationData) return;
|
|
4591
|
-
eventbus$1.
|
|
4592
|
-
this.currentLanguage = language;
|
|
4593
|
-
}]);
|
|
4581
|
+
this.currentLanguage = eventbus$1.request("request-current-language") ?? null;
|
|
4594
4582
|
this.requestLabelDataBound = this._requestLabelData.bind(this, eventbus$1);
|
|
4595
4583
|
this.requestLabelDataBound(this.operationData.labelId);
|
|
4596
4584
|
this._setLabel();
|
|
4597
4585
|
this.addListener(eventbus$1, "language-change", this._handleLanguageChange);
|
|
4598
4586
|
}
|
|
4599
4587
|
_requestLabelData(eventbus$1, labelId) {
|
|
4600
|
-
eventbus$1.
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
}]);
|
|
4588
|
+
const labelCollection = eventbus$1.request("request-label-collection", labelId);
|
|
4589
|
+
if (labelCollection) this._createTextDataLookup(labelCollection);
|
|
4590
|
+
else throw new Error(`Label id '${labelId}' does not exist!`);
|
|
4604
4591
|
}
|
|
4605
4592
|
_setLabel() {
|
|
4606
4593
|
if (this.currentLanguage) {
|
|
@@ -4661,16 +4648,9 @@ var LottieController = class extends BaseController {
|
|
|
4661
4648
|
if (!this.operationData) return;
|
|
4662
4649
|
const { labelIds } = this.operationData;
|
|
4663
4650
|
if (labelIds?.length) {
|
|
4664
|
-
|
|
4665
|
-
let labelCollections = [];
|
|
4666
|
-
eventbus$1.broadcast("request-current-language", [(language) => {
|
|
4667
|
-
currentLanguage = language;
|
|
4668
|
-
}]);
|
|
4669
|
-
this.currentLanguage = currentLanguage;
|
|
4651
|
+
this.currentLanguage = eventbus$1.request("request-current-language") ?? "en-US";
|
|
4670
4652
|
this.addListener(eventbus$1, "language-change", this._handleLanguageChange);
|
|
4671
|
-
eventbus$1.
|
|
4672
|
-
labelCollections = collections;
|
|
4673
|
-
}]);
|
|
4653
|
+
const labelCollections = eventbus$1.request("request-label-collections", this.operationData.labelIds) ?? [];
|
|
4674
4654
|
this._createTextDataLookup(labelCollections);
|
|
4675
4655
|
}
|
|
4676
4656
|
this._createAnimation();
|
|
@@ -4963,13 +4943,13 @@ var NavigationController = class extends BaseController {
|
|
|
4963
4943
|
selectedElement: parentElm,
|
|
4964
4944
|
labelId
|
|
4965
4945
|
};
|
|
4966
|
-
const
|
|
4946
|
+
const instance = this.eventbus?.request("request-instance", "LabelController");
|
|
4947
|
+
if (instance) {
|
|
4967
4948
|
instance.init(data);
|
|
4968
4949
|
instance.attach(this.eventbus);
|
|
4969
4950
|
this.labelControllers.push(instance);
|
|
4970
4951
|
this.ctrlLookup[labelId] = instance;
|
|
4971
|
-
}
|
|
4972
|
-
this.eventbus?.broadcast("request-instance", ["LabelController", resultCallback]);
|
|
4952
|
+
}
|
|
4973
4953
|
}
|
|
4974
4954
|
_buildNavigationData(data) {
|
|
4975
4955
|
const result = [];
|
|
@@ -5013,7 +4993,7 @@ var ProgressbarController = class extends BaseController {
|
|
|
5013
4993
|
}
|
|
5014
4994
|
attach(eventbus$1) {
|
|
5015
4995
|
this.addListener(eventbus$1, "timeline-time", this._positionUpdateHandler);
|
|
5016
|
-
eventbus$1.
|
|
4996
|
+
this.duration = eventbus$1.request("timeline-duration-request") ?? 0;
|
|
5017
4997
|
this.selectedElement?.css({ "pointer-events": "none" });
|
|
5018
4998
|
const container = this.selectedElement?.parent();
|
|
5019
4999
|
if (container) {
|
|
@@ -5288,7 +5268,11 @@ before it resolves.`,
|
|
|
5288
5268
|
type: "ParameterType:className",
|
|
5289
5269
|
required: true
|
|
5290
5270
|
},
|
|
5291
|
-
removeClass: { type:
|
|
5271
|
+
removeClass: { type: [
|
|
5272
|
+
{ value: "undefined" },
|
|
5273
|
+
{ value: "false" },
|
|
5274
|
+
{ value: "true" }
|
|
5275
|
+
] }
|
|
5292
5276
|
}
|
|
5293
5277
|
};
|
|
5294
5278
|
}
|
|
@@ -5333,7 +5317,11 @@ function announceToScreenReader$1() {
|
|
|
5333
5317
|
erased: true
|
|
5334
5318
|
},
|
|
5335
5319
|
priority: {
|
|
5336
|
-
type: [
|
|
5320
|
+
type: [
|
|
5321
|
+
{ value: "undefined" },
|
|
5322
|
+
{ value: "polite" },
|
|
5323
|
+
{ value: "assertive" }
|
|
5324
|
+
],
|
|
5337
5325
|
erased: true
|
|
5338
5326
|
}
|
|
5339
5327
|
}
|
|
@@ -5406,7 +5394,7 @@ function calc$1() {
|
|
|
5406
5394
|
erased: true
|
|
5407
5395
|
}
|
|
5408
5396
|
},
|
|
5409
|
-
outputProperties: { calculationResult: { type: "
|
|
5397
|
+
outputProperties: { calculationResult: { type: [{ value: "undefined" }, { value: "number" }] } }
|
|
5410
5398
|
};
|
|
5411
5399
|
}
|
|
5412
5400
|
|
|
@@ -5428,8 +5416,7 @@ function clearOperationData$1() {
|
|
|
5428
5416
|
Or, if the \`properties\` property is set only removes the properties defined by that list.`,
|
|
5429
5417
|
category: `Data`,
|
|
5430
5418
|
properties: { properties: {
|
|
5431
|
-
type: "
|
|
5432
|
-
itemType: "ParameterType:string",
|
|
5419
|
+
type: [{ value: "undefined" }, { value: "string[]" }],
|
|
5433
5420
|
erased: true
|
|
5434
5421
|
} }
|
|
5435
5422
|
};
|
|
@@ -5445,7 +5432,7 @@ If \`key\` is provided, removes only that key. If \`key\` is omitted, clears all
|
|
|
5445
5432
|
category: `Data`,
|
|
5446
5433
|
properties: {
|
|
5447
5434
|
key: {
|
|
5448
|
-
type: "
|
|
5435
|
+
type: [{ value: "undefined" }, { value: "string" }],
|
|
5449
5436
|
erased: true
|
|
5450
5437
|
},
|
|
5451
5438
|
storageType: {
|
|
@@ -5507,7 +5494,7 @@ function concatenateStrings$1() {
|
|
|
5507
5494
|
erased: true
|
|
5508
5495
|
},
|
|
5509
5496
|
separator: {
|
|
5510
|
-
type: "
|
|
5497
|
+
type: [{ value: "undefined" }, { value: "string" }],
|
|
5511
5498
|
erased: true
|
|
5512
5499
|
}
|
|
5513
5500
|
},
|
|
@@ -5540,7 +5527,7 @@ the instance to the \`template\` property on the current operation data.`,
|
|
|
5540
5527
|
erased: true
|
|
5541
5528
|
},
|
|
5542
5529
|
text: {
|
|
5543
|
-
type: "
|
|
5530
|
+
type: [{ value: "undefined" }, { value: "string" }],
|
|
5544
5531
|
erased: true
|
|
5545
5532
|
},
|
|
5546
5533
|
attributes: {
|
|
@@ -5633,7 +5620,7 @@ Supports two filtering modes:
|
|
|
5633
5620
|
dependentProperties: ["arrayData"],
|
|
5634
5621
|
properties: {
|
|
5635
5622
|
filterProperty: {
|
|
5636
|
-
type: "
|
|
5623
|
+
type: [{ value: "undefined" }, { value: "string" }],
|
|
5637
5624
|
erased: true
|
|
5638
5625
|
},
|
|
5639
5626
|
filterValue: {
|
|
@@ -5641,7 +5628,7 @@ Supports two filtering modes:
|
|
|
5641
5628
|
erased: true
|
|
5642
5629
|
},
|
|
5643
5630
|
filterPredicate: {
|
|
5644
|
-
type: "
|
|
5631
|
+
type: [{ value: "undefined" }, { value: "(item: any, index?: number | undefined) => boolean" }],
|
|
5645
5632
|
erased: true
|
|
5646
5633
|
}
|
|
5647
5634
|
},
|
|
@@ -5665,7 +5652,7 @@ Returns \`undefined\` for \`foundItem\` and \`-1\` for \`foundIndex\` if no matc
|
|
|
5665
5652
|
dependentProperties: ["arrayData"],
|
|
5666
5653
|
properties: {
|
|
5667
5654
|
findProperty: {
|
|
5668
|
-
type: "
|
|
5655
|
+
type: [{ value: "undefined" }, { value: "string" }],
|
|
5669
5656
|
erased: true
|
|
5670
5657
|
},
|
|
5671
5658
|
findValue: {
|
|
@@ -5673,7 +5660,7 @@ Returns \`undefined\` for \`foundItem\` and \`-1\` for \`foundIndex\` if no matc
|
|
|
5673
5660
|
erased: true
|
|
5674
5661
|
},
|
|
5675
5662
|
findPredicate: {
|
|
5676
|
-
type: "
|
|
5663
|
+
type: [{ value: "undefined" }, { value: "(item: any, index?: number | undefined) => boolean" }],
|
|
5677
5664
|
erased: true
|
|
5678
5665
|
}
|
|
5679
5666
|
},
|
|
@@ -5766,7 +5753,7 @@ function getAttributesFromElement$1() {
|
|
|
5766
5753
|
required: true,
|
|
5767
5754
|
erased: true
|
|
5768
5755
|
} },
|
|
5769
|
-
outputProperties: { attributeValues: { type: "
|
|
5756
|
+
outputProperties: { attributeValues: { type: [{ value: "undefined" }, { value: "Record<string, unknown>" }] } }
|
|
5770
5757
|
};
|
|
5771
5758
|
}
|
|
5772
5759
|
|
|
@@ -5900,10 +5887,10 @@ function getQueryParams$1() {
|
|
|
5900
5887
|
them on the returned operation data.`,
|
|
5901
5888
|
category: `Utility`,
|
|
5902
5889
|
properties: { defaultValues: {
|
|
5903
|
-
type: "
|
|
5890
|
+
type: [{ value: "undefined" }, { value: "Record<string, string>" }],
|
|
5904
5891
|
erased: true
|
|
5905
5892
|
} },
|
|
5906
|
-
outputProperties: { queryParams: { type: "
|
|
5893
|
+
outputProperties: { queryParams: { type: [{ value: "undefined" }, { value: "Record<string, string>" }] } }
|
|
5907
5894
|
};
|
|
5908
5895
|
}
|
|
5909
5896
|
|
|
@@ -5933,7 +5920,7 @@ Uses jQuery's \`.text()\` method which is XSS-safe and returns only the text con
|
|
|
5933
5920
|
without any HTML tags. Preserves whitespace and text from nested elements.`,
|
|
5934
5921
|
category: `Text`,
|
|
5935
5922
|
dependentProperties: ["selectedElement"],
|
|
5936
|
-
outputProperties: { textContent: { type: "
|
|
5923
|
+
outputProperties: { textContent: { type: [{ value: "undefined" }, { value: "string" }] } }
|
|
5937
5924
|
};
|
|
5938
5925
|
}
|
|
5939
5926
|
|
|
@@ -5950,7 +5937,7 @@ function httpDelete$1() {
|
|
|
5950
5937
|
erased: true
|
|
5951
5938
|
},
|
|
5952
5939
|
headers: {
|
|
5953
|
-
type: "
|
|
5940
|
+
type: [{ value: "undefined" }, { value: "Record<string, string>" }],
|
|
5954
5941
|
erased: true
|
|
5955
5942
|
}
|
|
5956
5943
|
},
|
|
@@ -5978,7 +5965,7 @@ function httpPost$1() {
|
|
|
5978
5965
|
erased: true
|
|
5979
5966
|
},
|
|
5980
5967
|
headers: {
|
|
5981
|
-
type: "
|
|
5968
|
+
type: [{ value: "undefined" }, { value: "Record<string, string>" }],
|
|
5982
5969
|
erased: true
|
|
5983
5970
|
}
|
|
5984
5971
|
},
|
|
@@ -6006,7 +5993,7 @@ function httpPut$1() {
|
|
|
6006
5993
|
erased: true
|
|
6007
5994
|
},
|
|
6008
5995
|
headers: {
|
|
6009
|
-
type: "
|
|
5996
|
+
type: [{ value: "undefined" }, { value: "Record<string, string>" }],
|
|
6010
5997
|
erased: true
|
|
6011
5998
|
}
|
|
6012
5999
|
},
|
|
@@ -6032,7 +6019,7 @@ and assigns the result to the \`methodResult\` operationdata property.`,
|
|
|
6032
6019
|
erased: true
|
|
6033
6020
|
},
|
|
6034
6021
|
methodArguments: {
|
|
6035
|
-
type: "
|
|
6022
|
+
type: [{ value: "undefined" }, { value: "unknown[]" }],
|
|
6036
6023
|
erased: true
|
|
6037
6024
|
}
|
|
6038
6025
|
},
|
|
@@ -6094,7 +6081,11 @@ instead of re-retrieving it from the url.`,
|
|
|
6094
6081
|
erased: true
|
|
6095
6082
|
},
|
|
6096
6083
|
cache: {
|
|
6097
|
-
type:
|
|
6084
|
+
type: [
|
|
6085
|
+
{ value: "undefined" },
|
|
6086
|
+
{ value: "false" },
|
|
6087
|
+
{ value: "true" }
|
|
6088
|
+
],
|
|
6098
6089
|
erased: true
|
|
6099
6090
|
}
|
|
6100
6091
|
},
|
|
@@ -6115,7 +6106,7 @@ it will log the current operation data, global data and scope to the console`,
|
|
|
6115
6106
|
erased: true
|
|
6116
6107
|
},
|
|
6117
6108
|
logName: {
|
|
6118
|
-
type: "
|
|
6109
|
+
type: [{ value: "undefined" }, { value: "string" }],
|
|
6119
6110
|
erased: true
|
|
6120
6111
|
}
|
|
6121
6112
|
}
|
|
@@ -6137,7 +6128,7 @@ The mapFunction receives each item and optionally its index.`,
|
|
|
6137
6128
|
required: true,
|
|
6138
6129
|
erased: true
|
|
6139
6130
|
} },
|
|
6140
|
-
outputProperties: { mappedArray: { type: "
|
|
6131
|
+
outputProperties: { mappedArray: { type: [{ value: "undefined" }, { value: "any[]" }] } }
|
|
6141
6132
|
};
|
|
6142
6133
|
}
|
|
6143
6134
|
|
|
@@ -6159,7 +6150,7 @@ function math$1() {
|
|
|
6159
6150
|
erased: true
|
|
6160
6151
|
}
|
|
6161
6152
|
},
|
|
6162
|
-
outputProperties: { mathResult: { type: "
|
|
6153
|
+
outputProperties: { mathResult: { type: [{ value: "undefined" }, { value: "number" }] } }
|
|
6163
6154
|
};
|
|
6164
6155
|
}
|
|
6165
6156
|
|
|
@@ -6350,11 +6341,16 @@ Uses the browser's \`scrollIntoView\` API with configurable behavior.`,
|
|
|
6350
6341
|
dependentProperties: ["selectedElement"],
|
|
6351
6342
|
properties: {
|
|
6352
6343
|
behavior: {
|
|
6353
|
-
type: [
|
|
6344
|
+
type: [
|
|
6345
|
+
{ value: "undefined" },
|
|
6346
|
+
{ value: "auto" },
|
|
6347
|
+
{ value: "smooth" }
|
|
6348
|
+
],
|
|
6354
6349
|
erased: true
|
|
6355
6350
|
},
|
|
6356
6351
|
block: {
|
|
6357
6352
|
type: [
|
|
6353
|
+
{ value: "undefined" },
|
|
6358
6354
|
{ value: "start" },
|
|
6359
6355
|
{ value: "center" },
|
|
6360
6356
|
{ value: "end" },
|
|
@@ -6364,6 +6360,7 @@ Uses the browser's \`scrollIntoView\` API with configurable behavior.`,
|
|
|
6364
6360
|
},
|
|
6365
6361
|
inline: {
|
|
6366
6362
|
type: [
|
|
6363
|
+
{ value: "undefined" },
|
|
6367
6364
|
{ value: "start" },
|
|
6368
6365
|
{ value: "center" },
|
|
6369
6366
|
{ value: "end" },
|
|
@@ -6395,7 +6392,11 @@ Uses the browser's \`window.scrollTo\` API with configurable behavior.`,
|
|
|
6395
6392
|
erased: true
|
|
6396
6393
|
},
|
|
6397
6394
|
behavior: {
|
|
6398
|
-
type: [
|
|
6395
|
+
type: [
|
|
6396
|
+
{ value: "undefined" },
|
|
6397
|
+
{ value: "auto" },
|
|
6398
|
+
{ value: "smooth" }
|
|
6399
|
+
],
|
|
6399
6400
|
erased: true
|
|
6400
6401
|
}
|
|
6401
6402
|
}
|
|
@@ -6419,7 +6420,11 @@ then the element will be looked for only in the descendant elements of this DOM
|
|
|
6419
6420
|
erased: true
|
|
6420
6421
|
},
|
|
6421
6422
|
useSelectedElementAsRoot: {
|
|
6422
|
-
type:
|
|
6423
|
+
type: [
|
|
6424
|
+
{ value: "undefined" },
|
|
6425
|
+
{ value: "false" },
|
|
6426
|
+
{ value: "true" }
|
|
6427
|
+
],
|
|
6423
6428
|
erased: true
|
|
6424
6429
|
}
|
|
6425
6430
|
},
|
|
@@ -6553,7 +6558,11 @@ When override is set to true the properties replace the current operation data e
|
|
|
6553
6558
|
category: `Data`,
|
|
6554
6559
|
properties: {
|
|
6555
6560
|
override: {
|
|
6556
|
-
type:
|
|
6561
|
+
type: [
|
|
6562
|
+
{ value: "undefined" },
|
|
6563
|
+
{ value: "false" },
|
|
6564
|
+
{ value: "true" }
|
|
6565
|
+
],
|
|
6557
6566
|
erased: true
|
|
6558
6567
|
},
|
|
6559
6568
|
properties: {
|
|
@@ -6617,15 +6626,19 @@ Supports three sorting modes:
|
|
|
6617
6626
|
dependentProperties: ["arrayData"],
|
|
6618
6627
|
properties: {
|
|
6619
6628
|
sortProperty: {
|
|
6620
|
-
type: "
|
|
6629
|
+
type: [{ value: "undefined" }, { value: "string" }],
|
|
6621
6630
|
erased: true
|
|
6622
6631
|
},
|
|
6623
6632
|
sortOrder: {
|
|
6624
|
-
type: [
|
|
6633
|
+
type: [
|
|
6634
|
+
{ value: "undefined" },
|
|
6635
|
+
{ value: "asc" },
|
|
6636
|
+
{ value: "desc" }
|
|
6637
|
+
],
|
|
6625
6638
|
erased: true
|
|
6626
6639
|
},
|
|
6627
6640
|
sortComparator: {
|
|
6628
|
-
type: "
|
|
6641
|
+
type: [{ value: "undefined" }, { value: "(a: any, b: any) => number" }],
|
|
6629
6642
|
erased: true
|
|
6630
6643
|
}
|
|
6631
6644
|
},
|
|
@@ -6647,7 +6660,7 @@ function splitString$1() {
|
|
|
6647
6660
|
erased: true
|
|
6648
6661
|
},
|
|
6649
6662
|
limit: {
|
|
6650
|
-
type: "
|
|
6663
|
+
type: [{ value: "undefined" }, { value: "number" }],
|
|
6651
6664
|
erased: true
|
|
6652
6665
|
}
|
|
6653
6666
|
},
|
|
@@ -6690,7 +6703,7 @@ function substringText$1() {
|
|
|
6690
6703
|
erased: true
|
|
6691
6704
|
},
|
|
6692
6705
|
end: {
|
|
6693
|
-
type: "
|
|
6706
|
+
type: [{ value: "undefined" }, { value: "number" }],
|
|
6694
6707
|
erased: true
|
|
6695
6708
|
}
|
|
6696
6709
|
},
|
|
@@ -6758,12 +6771,16 @@ custom validation rules for: required, minLength, maxLength, pattern (regex), an
|
|
|
6758
6771
|
category: `Form`,
|
|
6759
6772
|
dependentProperties: ["selectedElement"],
|
|
6760
6773
|
properties: { validationRules: {
|
|
6761
|
-
type: "
|
|
6774
|
+
type: [{ value: "undefined" }, { value: "Record<string, import(\"/home/runner/work/eligius/eligius/src/operation/validate-form\").IValidationRules>" }],
|
|
6762
6775
|
erased: true
|
|
6763
6776
|
} },
|
|
6764
6777
|
outputProperties: {
|
|
6765
6778
|
validationErrors: { type: "ParameterType:object" },
|
|
6766
|
-
isValid: { type:
|
|
6779
|
+
isValid: { type: [
|
|
6780
|
+
{ value: "undefined" },
|
|
6781
|
+
{ value: "false" },
|
|
6782
|
+
{ value: "true" }
|
|
6783
|
+
] }
|
|
6767
6784
|
}
|
|
6768
6785
|
};
|
|
6769
6786
|
}
|
|
@@ -7279,7 +7296,7 @@ The controller also listen for the \`LANGUAGE_CHANGE\` event and re-renders the
|
|
|
7279
7296
|
type: "ParameterType:labelId",
|
|
7280
7297
|
required: true
|
|
7281
7298
|
},
|
|
7282
|
-
attributeName: { type: "
|
|
7299
|
+
attributeName: { type: [{ value: "undefined" }, { value: "string" }] }
|
|
7283
7300
|
}
|
|
7284
7301
|
};
|
|
7285
7302
|
}
|
|
@@ -7314,16 +7331,37 @@ The controller follows the standard Eligius lifecycle:
|
|
|
7314
7331
|
- detach(): Disconnect the observer and clean up resources`,
|
|
7315
7332
|
dependentProperties: ["selectedElement"],
|
|
7316
7333
|
properties: {
|
|
7317
|
-
observeAttributes: { type:
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
}
|
|
7334
|
+
observeAttributes: { type: [
|
|
7335
|
+
{ value: "undefined" },
|
|
7336
|
+
{ value: "false" },
|
|
7337
|
+
{ value: "true" }
|
|
7338
|
+
] },
|
|
7339
|
+
observeChildList: { type: [
|
|
7340
|
+
{ value: "undefined" },
|
|
7341
|
+
{ value: "false" },
|
|
7342
|
+
{ value: "true" }
|
|
7343
|
+
] },
|
|
7344
|
+
observeCharacterData: { type: [
|
|
7345
|
+
{ value: "undefined" },
|
|
7346
|
+
{ value: "false" },
|
|
7347
|
+
{ value: "true" }
|
|
7348
|
+
] },
|
|
7349
|
+
observeSubtree: { type: [
|
|
7350
|
+
{ value: "undefined" },
|
|
7351
|
+
{ value: "false" },
|
|
7352
|
+
{ value: "true" }
|
|
7353
|
+
] },
|
|
7354
|
+
attributeOldValue: { type: [
|
|
7355
|
+
{ value: "undefined" },
|
|
7356
|
+
{ value: "false" },
|
|
7357
|
+
{ value: "true" }
|
|
7358
|
+
] },
|
|
7359
|
+
characterDataOldValue: { type: [
|
|
7360
|
+
{ value: "undefined" },
|
|
7361
|
+
{ value: "false" },
|
|
7362
|
+
{ value: "true" }
|
|
7363
|
+
] },
|
|
7364
|
+
attributeFilter: { type: [{ value: "undefined" }, { value: "string[]" }] }
|
|
7327
7365
|
}
|
|
7328
7366
|
};
|
|
7329
7367
|
}
|
|
@@ -7371,7 +7409,7 @@ function SubtitlesController$1() {
|
|
|
7371
7409
|
description: ``,
|
|
7372
7410
|
dependentProperties: ["selectedElement"],
|
|
7373
7411
|
properties: {
|
|
7374
|
-
language: { type: "ParameterType
|
|
7412
|
+
language: { type: "ParameterType:languagecode" },
|
|
7375
7413
|
subtitleData: { type: "ParameterType:array" }
|
|
7376
7414
|
}
|
|
7377
7415
|
};
|
|
@@ -7390,656 +7428,6 @@ var metadata_exports = /* @__PURE__ */ __export({
|
|
|
7390
7428
|
SubtitlesController: () => SubtitlesController$1
|
|
7391
7429
|
});
|
|
7392
7430
|
|
|
7393
|
-
//#endregion
|
|
7394
|
-
//#region src/eligius-engine.ts
|
|
7395
|
-
/**
|
|
7396
|
-
* This is where the magic happens. The engine is responsible for starting and stopping
|
|
7397
|
-
* the given timeline provider and triggering the actions associated with the positions along the timeline.
|
|
7398
|
-
*/
|
|
7399
|
-
var EligiusEngine = class EligiusEngine {
|
|
7400
|
-
_timeLineActionsLookup = {};
|
|
7401
|
-
_timelineLookupCache = /* @__PURE__ */ new Map();
|
|
7402
|
-
_eventbusRemovers = [];
|
|
7403
|
-
_currentTimelineUri = "";
|
|
7404
|
-
_activeTimelineProvider = void 0;
|
|
7405
|
-
_lastPosition = -1;
|
|
7406
|
-
constructor(configuration, eventbus$1, timelineProviders, languageManager) {
|
|
7407
|
-
this.configuration = configuration;
|
|
7408
|
-
this.eventbus = eventbus$1;
|
|
7409
|
-
this.timelineProviders = timelineProviders;
|
|
7410
|
-
this.languageManager = languageManager;
|
|
7411
|
-
}
|
|
7412
|
-
/**
|
|
7413
|
-
* Initializes the engine by creating the HTML layout and the first time line
|
|
7414
|
-
* by executing its initActions.
|
|
7415
|
-
*/
|
|
7416
|
-
init() {
|
|
7417
|
-
this._createLayoutTemplate();
|
|
7418
|
-
this._addEventbusListeners();
|
|
7419
|
-
const { timelines } = this.configuration;
|
|
7420
|
-
this._currentTimelineUri = timelines?.[0].uri ?? "";
|
|
7421
|
-
this._createTimelineLookup();
|
|
7422
|
-
return this._initializeTimelineProvider();
|
|
7423
|
-
}
|
|
7424
|
-
_createLayoutTemplate() {
|
|
7425
|
-
const { containerSelector } = this.configuration;
|
|
7426
|
-
const container = $(containerSelector);
|
|
7427
|
-
if (!container || !container.length) throw new Error(`Container selector not found: ${containerSelector}`);
|
|
7428
|
-
const { layoutTemplate } = this.configuration;
|
|
7429
|
-
if (layoutTemplate?.length) container.html(layoutTemplate);
|
|
7430
|
-
else console.warn("layoutTemplate is empty, unable to create layout");
|
|
7431
|
-
}
|
|
7432
|
-
async _initializeTimelineProvider() {
|
|
7433
|
-
if (!this.configuration.timelines?.length) throw new Error("No timelines present");
|
|
7434
|
-
const firstTimeline = this.configuration.timelines[0];
|
|
7435
|
-
const providerSettings = this.timelineProviders[firstTimeline.type];
|
|
7436
|
-
if (!providerSettings) throw new Error(`No timeline provider configured for type ${firstTimeline.type}`);
|
|
7437
|
-
this._activeTimelineProvider?.destroy();
|
|
7438
|
-
this._activeTimelineProvider = providerSettings.provider;
|
|
7439
|
-
if (!this._activeTimelineProvider) throw new Error("NO ACTIVE TIMELINE PROVIDER");
|
|
7440
|
-
this._activeTimelineProvider.onTime(this._onTimeHandler.bind(this, Math.floor));
|
|
7441
|
-
this._activeTimelineProvider.onComplete(this._onCompleteCallback.bind(this));
|
|
7442
|
-
this._activeTimelineProvider.onFirstFrame(this._onFirstFrameCallback.bind(this));
|
|
7443
|
-
this._activeTimelineProvider.onRestart(this._onRestartCallback.bind(this));
|
|
7444
|
-
await this._activeTimelineProvider.init();
|
|
7445
|
-
await this._executeActions(this.configuration.initActions, "start");
|
|
7446
|
-
return this._activeTimelineProvider;
|
|
7447
|
-
}
|
|
7448
|
-
_onCompleteCallback() {
|
|
7449
|
-
this.eventbus.broadcast("timeline-complete", []);
|
|
7450
|
-
}
|
|
7451
|
-
_onFirstFrameCallback() {
|
|
7452
|
-
this.eventbus.broadcast("timeline-firstframe", []);
|
|
7453
|
-
this.eventbus.broadcast("timeline-duration", [this._activeTimelineProvider?.getDuration]);
|
|
7454
|
-
}
|
|
7455
|
-
_onRestartCallback() {
|
|
7456
|
-
this.eventbus.broadcast("timeline-restart", []);
|
|
7457
|
-
}
|
|
7458
|
-
async _cleanUp() {
|
|
7459
|
-
await this._cleanUpTimeline();
|
|
7460
|
-
await this._executeActions([...this.configuration.initActions].reverse(), "end");
|
|
7461
|
-
}
|
|
7462
|
-
/**
|
|
7463
|
-
* Cleans up all the necessary parts that the engine initialized.
|
|
7464
|
-
* - It ends the currently active operations and the init actions.
|
|
7465
|
-
* - It removes all its eventbus listeners, handlers and interceptors.
|
|
7466
|
-
* - It destroys all of its timeline providers
|
|
7467
|
-
* - It empties the HTML element indicated by the containerSelector configuration property.
|
|
7468
|
-
*
|
|
7469
|
-
*/
|
|
7470
|
-
async destroy() {
|
|
7471
|
-
await this._cleanUp();
|
|
7472
|
-
this.languageManager.destroy();
|
|
7473
|
-
this._activeTimelineProvider = void 0;
|
|
7474
|
-
this._eventbusRemovers.forEach((remover) => remover());
|
|
7475
|
-
if (this.timelineProviders) Object.values(this.timelineProviders).forEach((providerInfo) => providerInfo.provider.destroy());
|
|
7476
|
-
const { containerSelector } = this.configuration;
|
|
7477
|
-
$(containerSelector).empty();
|
|
7478
|
-
}
|
|
7479
|
-
_addEventListener(eventName, eventHandler, eventTopic) {
|
|
7480
|
-
this._eventbusRemovers.push(this.eventbus.on(eventName, eventHandler, eventTopic));
|
|
7481
|
-
}
|
|
7482
|
-
_addEventbusListeners() {
|
|
7483
|
-
this._addEventListener("request-engine-root", this._handleRequestEngineRoot.bind(this, this.configuration.containerSelector));
|
|
7484
|
-
this._addEventListener("request-timeline-uri", this._handleRequestTimelineUri.bind(this));
|
|
7485
|
-
this._addEventListener("request-current-timeline-position", this._handleRequestTimelinePosition.bind(this, Math.floor));
|
|
7486
|
-
this._addEventListener("request-timeline-cleanup", this._handleTimelineComplete.bind(this));
|
|
7487
|
-
this._addEventListener("timeline-request-current-timeline", this._requestCurrentTimeline.bind(this));
|
|
7488
|
-
this._addEventListener("timeline-play-toggle-request", this._toggleplay.bind(this));
|
|
7489
|
-
this._addEventListener("timeline-play-request", this._playRequest.bind(this));
|
|
7490
|
-
this._addEventListener("timeline-stop-request", this._stopRequest.bind(this));
|
|
7491
|
-
this._addEventListener("timeline-pause-request", this._pauseRequest.bind(this));
|
|
7492
|
-
this._addEventListener("timeline-container-request", this.containerRequest.bind(this));
|
|
7493
|
-
this._addEventListener("timeline-duration-request", this.durationRequest.bind(this));
|
|
7494
|
-
this._addEventListener("timeline-seek-request", this.seekRequest.bind(this));
|
|
7495
|
-
}
|
|
7496
|
-
async seekRequest(position) {
|
|
7497
|
-
if (!this._activeTimelineProvider) return;
|
|
7498
|
-
const seekPosition = Math.floor(position);
|
|
7499
|
-
const duration = this._activeTimelineProvider.getDuration();
|
|
7500
|
-
const currentPosition = this._activeTimelineProvider.getPosition();
|
|
7501
|
-
if (seekPosition < 0 || seekPosition > duration) return;
|
|
7502
|
-
this.eventbus.broadcast("timeline-seek", [
|
|
7503
|
-
seekPosition,
|
|
7504
|
-
currentPosition,
|
|
7505
|
-
duration
|
|
7506
|
-
]);
|
|
7507
|
-
await this._activeTimelineProvider.seek(seekPosition);
|
|
7508
|
-
await this._executeSeekActions(seekPosition);
|
|
7509
|
-
this.eventbus.broadcast("timeline-seeked", [this._activeTimelineProvider.getPosition(), duration]);
|
|
7510
|
-
this.eventbus.broadcast("timeline-time", [this._activeTimelineProvider.getPosition()]);
|
|
7511
|
-
if (this._activeTimelineProvider?.playState === "running") this._activeTimelineProvider?.start();
|
|
7512
|
-
}
|
|
7513
|
-
durationRequest(callBack) {
|
|
7514
|
-
callBack(this._activeTimelineProvider?.getDuration());
|
|
7515
|
-
}
|
|
7516
|
-
containerRequest(callBack) {
|
|
7517
|
-
callBack(this._activeTimelineProvider?.getContainer());
|
|
7518
|
-
}
|
|
7519
|
-
_pauseRequest() {
|
|
7520
|
-
if (!this._activeTimelineProvider) return;
|
|
7521
|
-
this._activeTimelineProvider.pause();
|
|
7522
|
-
this.eventbus.broadcast("timeline-pause", []);
|
|
7523
|
-
}
|
|
7524
|
-
_stopRequest() {
|
|
7525
|
-
if (!this._activeTimelineProvider) return;
|
|
7526
|
-
this._activeTimelineProvider.stop();
|
|
7527
|
-
this.eventbus.broadcast("timeline-stop", []);
|
|
7528
|
-
}
|
|
7529
|
-
_playRequest() {
|
|
7530
|
-
if (!this._activeTimelineProvider) return;
|
|
7531
|
-
this._activeTimelineProvider.start();
|
|
7532
|
-
this.eventbus.broadcast("timeline-play", []);
|
|
7533
|
-
}
|
|
7534
|
-
_toggleplay() {
|
|
7535
|
-
if (!this._activeTimelineProvider) return;
|
|
7536
|
-
if (this._activeTimelineProvider.playState === "running") this._activeTimelineProvider.pause();
|
|
7537
|
-
else this._activeTimelineProvider.start();
|
|
7538
|
-
}
|
|
7539
|
-
_createTimelineLookup() {
|
|
7540
|
-
if (!this.configuration.timelines) return;
|
|
7541
|
-
this.configuration.timelines.forEach((timelineInfo) => {
|
|
7542
|
-
this._timelineLookupCache.set(timelineInfo.uri, timelineInfo);
|
|
7543
|
-
timelineInfo.timelineActions.forEach((timelineAction) => {
|
|
7544
|
-
this._addTimelineActionStart(timelineInfo.uri, timelineAction);
|
|
7545
|
-
this._addTimelineActionEnd(timelineInfo.uri, timelineAction);
|
|
7546
|
-
});
|
|
7547
|
-
});
|
|
7548
|
-
EligiusEngine.sortTimelines(Object.values(this._timeLineActionsLookup));
|
|
7549
|
-
}
|
|
7550
|
-
static sortTimelines(timelines) {
|
|
7551
|
-
timelines.forEach((timelineActions) => {
|
|
7552
|
-
Object.keys(timelineActions).forEach((key) => {
|
|
7553
|
-
const numericKey = Number(key);
|
|
7554
|
-
timelineActions[numericKey] = EligiusEngine.sortActionsPerPosition(timelineActions[numericKey]);
|
|
7555
|
-
});
|
|
7556
|
-
});
|
|
7557
|
-
}
|
|
7558
|
-
static sortActionsPerPosition(actions) {
|
|
7559
|
-
const [startMethods, endMethods] = actions.reduce((acc, item) => {
|
|
7560
|
-
if (item.isStart) acc[0].push(item);
|
|
7561
|
-
else acc[1].push(item);
|
|
7562
|
-
return acc;
|
|
7563
|
-
}, [[], []]);
|
|
7564
|
-
return [...endMethods.sort(sortActionMethodsHighestStartPositionFirst), ...startMethods];
|
|
7565
|
-
}
|
|
7566
|
-
_addTimelineActionStart(uri, timeLineAction) {
|
|
7567
|
-
const startPosition = timeLineAction.duration.start;
|
|
7568
|
-
const timelineStartPositions = this._initializeTimelinePosition(this._initializeUriLookup(this._timeLineActionsLookup, uri), startPosition);
|
|
7569
|
-
const startMethod = timeLineAction.start.bind(timeLineAction);
|
|
7570
|
-
if (timeLineAction.id?.length) startMethod.id = timeLineAction.id;
|
|
7571
|
-
startMethod.isStart = true;
|
|
7572
|
-
timelineStartPositions.push(startMethod);
|
|
7573
|
-
}
|
|
7574
|
-
_addTimelineActionEnd(uri, timeLineAction) {
|
|
7575
|
-
let end = timeLineAction.duration.end;
|
|
7576
|
-
if (end < 0) end = timeLineAction.duration.end = Infinity;
|
|
7577
|
-
if (Number.isFinite(end)) {
|
|
7578
|
-
const timelineEndPositions = this._initializeTimelinePosition(this._timeLineActionsLookup[uri], end);
|
|
7579
|
-
const endMethod = timeLineAction.end.bind(timeLineAction);
|
|
7580
|
-
if (timeLineAction.id?.length) {
|
|
7581
|
-
endMethod.id = timeLineAction.id;
|
|
7582
|
-
endMethod.startPosition = timeLineAction.duration.start;
|
|
7583
|
-
}
|
|
7584
|
-
endMethod.isStart = false;
|
|
7585
|
-
timelineEndPositions.push(endMethod);
|
|
7586
|
-
}
|
|
7587
|
-
}
|
|
7588
|
-
_initializeUriLookup(lookup, uri) {
|
|
7589
|
-
if (!lookup[uri]) lookup[uri] = {};
|
|
7590
|
-
return lookup[uri];
|
|
7591
|
-
}
|
|
7592
|
-
_initializeTimelinePosition(lookup, position) {
|
|
7593
|
-
if (!lookup[position]) lookup[position] = [];
|
|
7594
|
-
return lookup[position];
|
|
7595
|
-
}
|
|
7596
|
-
async _executeActions(actions, methodName) {
|
|
7597
|
-
if (actions.length === 0) return;
|
|
7598
|
-
for (const action of actions) await action[methodName]();
|
|
7599
|
-
}
|
|
7600
|
-
_handleRequestEngineRoot(engineRootSelector, resultCallback) {
|
|
7601
|
-
resultCallback($(engineRootSelector));
|
|
7602
|
-
}
|
|
7603
|
-
async _handleRequestTimelineUri(uri, position = 0) {
|
|
7604
|
-
if (!this._activeTimelineProvider) return;
|
|
7605
|
-
this._activeTimelineProvider.stop();
|
|
7606
|
-
await this._cleanUpTimeline();
|
|
7607
|
-
const timelineConfig = this._timelineLookupCache.get(uri);
|
|
7608
|
-
if (!timelineConfig || !this._activeTimelineProvider || this._currentTimelineUri === timelineConfig.uri) return;
|
|
7609
|
-
this._currentTimelineUri = timelineConfig.uri;
|
|
7610
|
-
this.eventbus.broadcast("timeline-current-timeline-change", [this._currentTimelineUri]);
|
|
7611
|
-
const newProviderSettings = this.timelineProviders[timelineConfig.type];
|
|
7612
|
-
if (this._activeTimelineProvider !== newProviderSettings.provider) {
|
|
7613
|
-
this._activeTimelineProvider.destroy();
|
|
7614
|
-
this._activeTimelineProvider = newProviderSettings.provider;
|
|
7615
|
-
}
|
|
7616
|
-
this._activeTimelineProvider.loop = timelineConfig.loop;
|
|
7617
|
-
if (!this._activeTimelineProvider.loop && position > 0) this.eventbus.once("timeline-firstframe", async () => {
|
|
7618
|
-
if (!this._activeTimelineProvider) return;
|
|
7619
|
-
this._activeTimelineProvider.pause();
|
|
7620
|
-
this.eventbus.broadcast("timeline-duration", [this._activeTimelineProvider.getDuration]);
|
|
7621
|
-
await this._executeStartActions();
|
|
7622
|
-
const seekPosition = await this._activeTimelineProvider.seek(position);
|
|
7623
|
-
this.seekRequest(seekPosition);
|
|
7624
|
-
});
|
|
7625
|
-
this._activeTimelineProvider.playlistItem(uri);
|
|
7626
|
-
}
|
|
7627
|
-
_cleanUpTimeline() {
|
|
7628
|
-
return this._executeRelevantActions(this._getActiveActions, "end");
|
|
7629
|
-
}
|
|
7630
|
-
_executeStartActions() {
|
|
7631
|
-
return this._executeRelevantActions(this._getActionsForPosition.bind(this, 0), "start");
|
|
7632
|
-
}
|
|
7633
|
-
/**
|
|
7634
|
-
* Gets all of the inactive actions whose duration falls within the given timeline position.
|
|
7635
|
-
*
|
|
7636
|
-
* @param position the given position
|
|
7637
|
-
* @param actions all of the relevant actions
|
|
7638
|
-
* @returns
|
|
7639
|
-
*/
|
|
7640
|
-
_getActionsForPosition(position, actions) {
|
|
7641
|
-
return actions.filter((action) => !action.active && action.duration.start <= position && action.duration.end >= position);
|
|
7642
|
-
}
|
|
7643
|
-
_getActiveActions(allActions) {
|
|
7644
|
-
return allActions.filter((action) => action.active).sort(sortActionsHighestStartPositionFirst);
|
|
7645
|
-
}
|
|
7646
|
-
_executeRelevantActions(filter, executionType) {
|
|
7647
|
-
const timelineActions = this._getTimelineActionsForCurrentTimeline();
|
|
7648
|
-
const currentActions = filter.apply(this, [timelineActions]);
|
|
7649
|
-
return this._executeActions(currentActions, executionType);
|
|
7650
|
-
}
|
|
7651
|
-
_handleRequestTimelinePosition(floor, resultCallback) {
|
|
7652
|
-
resultCallback(floor(this._activeTimelineProvider?.getPosition() || -1));
|
|
7653
|
-
}
|
|
7654
|
-
_handleTimelineComplete() {
|
|
7655
|
-
this._cleanUpTimeline();
|
|
7656
|
-
}
|
|
7657
|
-
_getTimelineActionsForCurrentTimeline() {
|
|
7658
|
-
return this._getTimelineActionsForUri(this._currentTimelineUri);
|
|
7659
|
-
}
|
|
7660
|
-
_requestCurrentTimeline(resultCallback) {
|
|
7661
|
-
resultCallback(this._currentTimelineUri);
|
|
7662
|
-
}
|
|
7663
|
-
_getTimelineActionsForUri(uri) {
|
|
7664
|
-
return this._timelineLookupCache.get(uri)?.timelineActions ?? [];
|
|
7665
|
-
}
|
|
7666
|
-
_onTimeHandler(floor, position) {
|
|
7667
|
-
if (!Number.isNaN(position)) {
|
|
7668
|
-
const pos = floor(position);
|
|
7669
|
-
if (this._lastPosition !== pos) {
|
|
7670
|
-
this._executeActionsForPosition(pos);
|
|
7671
|
-
this.eventbus.broadcast("timeline-time", [pos]);
|
|
7672
|
-
}
|
|
7673
|
-
}
|
|
7674
|
-
}
|
|
7675
|
-
_executeActionsForPosition(position) {
|
|
7676
|
-
this._lastPosition = position;
|
|
7677
|
-
const actions = this._timeLineActionsLookup[this._currentTimelineUri];
|
|
7678
|
-
if (actions) actions[position]?.forEach((exec) => exec());
|
|
7679
|
-
}
|
|
7680
|
-
async _executeSeekActions(position) {
|
|
7681
|
-
const timelineActions = this._getTimelineActionsForCurrentTimeline();
|
|
7682
|
-
if (!timelineActions) return Promise.resolve();
|
|
7683
|
-
const currentActions = this._getActiveActions(timelineActions).filter((action) => !(action.duration.start <= position && action.duration.end >= position));
|
|
7684
|
-
const newActions = this._getActionsForPosition(position, timelineActions);
|
|
7685
|
-
await this._executeActions(currentActions, "end");
|
|
7686
|
-
return this._executeActions(newActions, "start");
|
|
7687
|
-
}
|
|
7688
|
-
};
|
|
7689
|
-
const sortActionsHighestStartPositionFirst = (a, b) => {
|
|
7690
|
-
if (b.duration.start < a.duration.start) return -1;
|
|
7691
|
-
else if (b.duration.start > a.duration.start) return 1;
|
|
7692
|
-
else return 0;
|
|
7693
|
-
};
|
|
7694
|
-
const sortActionMethodsHighestStartPositionFirst = (a, b) => {
|
|
7695
|
-
if (b.startPosition === void 0 || a.startPosition === void 0) return 0;
|
|
7696
|
-
if (b.startPosition < a.startPosition) return -1;
|
|
7697
|
-
else if (b.startPosition > a.startPosition) return 1;
|
|
7698
|
-
else return 0;
|
|
7699
|
-
};
|
|
7700
|
-
|
|
7701
|
-
//#endregion
|
|
7702
|
-
//#region src/eventbus/actionregistry-eventbus-listener.ts
|
|
7703
|
-
/**
|
|
7704
|
-
* The `IEventbusListener` first registers a number of actions that are then
|
|
7705
|
-
* executed when the specified event is broadcast.
|
|
7706
|
-
*/
|
|
7707
|
-
var ActionRegistryEventbusListener = class {
|
|
7708
|
-
_actionRegistry = /* @__PURE__ */ new Map();
|
|
7709
|
-
registerAction(action, eventName, eventTopic) {
|
|
7710
|
-
if (eventTopic?.length) eventName = `${eventName}:${eventTopic}`;
|
|
7711
|
-
if (!this._actionRegistry.has(eventName)) this._actionRegistry.set(eventName, []);
|
|
7712
|
-
this._actionRegistry.get(eventName)?.push(action);
|
|
7713
|
-
}
|
|
7714
|
-
handleEvent(eventName, eventTopic, args) {
|
|
7715
|
-
if (eventTopic) eventName = `${eventName}:${eventTopic}`;
|
|
7716
|
-
const actions = this._actionRegistry.get(eventName);
|
|
7717
|
-
if (actions) {
|
|
7718
|
-
const operationData = { eventArgs: args };
|
|
7719
|
-
actions.forEach((action) => {
|
|
7720
|
-
action.start(operationData);
|
|
7721
|
-
});
|
|
7722
|
-
}
|
|
7723
|
-
}
|
|
7724
|
-
};
|
|
7725
|
-
|
|
7726
|
-
//#endregion
|
|
7727
|
-
//#region src/eventbus/eventbus.ts
|
|
7728
|
-
var Eventbus = class {
|
|
7729
|
-
eventHandlers = /* @__PURE__ */ new Map();
|
|
7730
|
-
eventInterceptors = /* @__PURE__ */ new Map();
|
|
7731
|
-
eventListeners = [];
|
|
7732
|
-
constructor() {
|
|
7733
|
-
this.clear();
|
|
7734
|
-
}
|
|
7735
|
-
clear() {
|
|
7736
|
-
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
7737
|
-
this.eventListeners = [];
|
|
7738
|
-
this.eventInterceptors = /* @__PURE__ */ new Map();
|
|
7739
|
-
}
|
|
7740
|
-
_getEventInterceptors(eventName, eventTopic) {
|
|
7741
|
-
if (eventTopic) eventName = `${eventName}:${eventTopic}`;
|
|
7742
|
-
if (!this.eventInterceptors.has(eventName)) this.eventInterceptors.set(eventName, []);
|
|
7743
|
-
return this.eventInterceptors.get(eventName);
|
|
7744
|
-
}
|
|
7745
|
-
_getEventHandlers(eventName, eventTopic) {
|
|
7746
|
-
if (eventTopic) eventName = `${eventName}:${eventTopic}`;
|
|
7747
|
-
if (!this.eventHandlers.has(eventName)) this.eventHandlers.set(eventName, []);
|
|
7748
|
-
return this.eventHandlers.get(eventName);
|
|
7749
|
-
}
|
|
7750
|
-
on(eventName, eventHandler, eventTopic) {
|
|
7751
|
-
this._getEventHandlers(eventName, eventTopic).push(eventHandler);
|
|
7752
|
-
return () => {
|
|
7753
|
-
this.off(eventName, eventHandler, eventTopic);
|
|
7754
|
-
};
|
|
7755
|
-
}
|
|
7756
|
-
once(eventName, eventHandler, eventTopic) {
|
|
7757
|
-
const eventHandlerDecorator = (...args) => {
|
|
7758
|
-
eventHandler(...args);
|
|
7759
|
-
this.off(eventName, eventHandlerDecorator, eventTopic);
|
|
7760
|
-
};
|
|
7761
|
-
this.on(eventName, eventHandlerDecorator, eventTopic);
|
|
7762
|
-
return () => {
|
|
7763
|
-
this.off(eventName, eventHandlerDecorator, eventTopic);
|
|
7764
|
-
};
|
|
7765
|
-
}
|
|
7766
|
-
off(eventName, eventHandler, eventTopic) {
|
|
7767
|
-
const handlers = this._getEventHandlers(eventName, eventTopic);
|
|
7768
|
-
if (handlers) {
|
|
7769
|
-
const idx = handlers.indexOf(eventHandler);
|
|
7770
|
-
if (idx > -1) handlers.splice(idx, 1);
|
|
7771
|
-
}
|
|
7772
|
-
}
|
|
7773
|
-
broadcast(eventName, args) {
|
|
7774
|
-
this._callHandlers(eventName, void 0, args);
|
|
7775
|
-
}
|
|
7776
|
-
broadcastForTopic(eventName, eventTopic, args) {
|
|
7777
|
-
this._callHandlers(eventName, eventTopic, args);
|
|
7778
|
-
}
|
|
7779
|
-
registerEventlistener(eventbusListener) {
|
|
7780
|
-
this.eventListeners.push(eventbusListener);
|
|
7781
|
-
return () => {
|
|
7782
|
-
const index = this.eventListeners.indexOf(eventbusListener);
|
|
7783
|
-
if (index > -1) this.eventListeners.splice(index, 1);
|
|
7784
|
-
};
|
|
7785
|
-
}
|
|
7786
|
-
registerInterceptor(eventName, interceptor, eventTopic) {
|
|
7787
|
-
const interceptors = this._getEventInterceptors(eventName, eventTopic);
|
|
7788
|
-
interceptors.push(interceptor);
|
|
7789
|
-
return () => {
|
|
7790
|
-
const index = interceptors.indexOf(interceptor);
|
|
7791
|
-
if (index > -1) interceptors.splice(index, 1);
|
|
7792
|
-
};
|
|
7793
|
-
}
|
|
7794
|
-
_callHandlers(eventName, eventTopic, args = []) {
|
|
7795
|
-
const handlers = this._getEventHandlers(eventName, eventTopic);
|
|
7796
|
-
if (handlers) {
|
|
7797
|
-
this._getEventInterceptors(eventName, eventTopic).forEach((interceptor) => {
|
|
7798
|
-
args = interceptor.intercept(args);
|
|
7799
|
-
});
|
|
7800
|
-
this.eventListeners.forEach((listener) => {
|
|
7801
|
-
listener.handleEvent(eventName, eventTopic, args);
|
|
7802
|
-
});
|
|
7803
|
-
if (args?.length) handlers.forEach((handler) => handler(...args));
|
|
7804
|
-
else handlers.forEach((handler) => handler());
|
|
7805
|
-
}
|
|
7806
|
-
}
|
|
7807
|
-
};
|
|
7808
|
-
|
|
7809
|
-
//#endregion
|
|
7810
|
-
//#region src/eventbus/request-video-uri-interceptor.ts
|
|
7811
|
-
var RequestVideoUriInterceptor = class {
|
|
7812
|
-
constructor(eventbus$1) {
|
|
7813
|
-
this.eventbus = eventbus$1;
|
|
7814
|
-
}
|
|
7815
|
-
intercept(args) {
|
|
7816
|
-
this.eventbus.broadcast("before-request-timeline-uri", args.slice());
|
|
7817
|
-
return args;
|
|
7818
|
-
}
|
|
7819
|
-
};
|
|
7820
|
-
|
|
7821
|
-
//#endregion
|
|
7822
|
-
//#region src/eventbus/index.ts
|
|
7823
|
-
var eventbus_exports = /* @__PURE__ */ __export({
|
|
7824
|
-
ActionRegistryEventbusListener: () => ActionRegistryEventbusListener,
|
|
7825
|
-
Eventbus: () => Eventbus,
|
|
7826
|
-
RequestVideoUriInterceptor: () => RequestVideoUriInterceptor
|
|
7827
|
-
});
|
|
7828
|
-
|
|
7829
|
-
//#endregion
|
|
7830
|
-
//#region src/operation/helper/set-global.ts
|
|
7831
|
-
function setGlobal(name, value) {
|
|
7832
|
-
const cache$2 = getGlobals();
|
|
7833
|
-
cache$2[name] = value;
|
|
7834
|
-
}
|
|
7835
|
-
|
|
7836
|
-
//#endregion
|
|
7837
|
-
//#region src/language-manager.ts
|
|
7838
|
-
/**
|
|
7839
|
-
* This class manages the labels for an {@link IEligiusEngine} instance.
|
|
7840
|
-
*
|
|
7841
|
-
* It handles the request-label-collection, request-label-collections, request-current-language and language-change events.
|
|
7842
|
-
*
|
|
7843
|
-
*/
|
|
7844
|
-
var LanguageManager = class {
|
|
7845
|
-
_labelLookup;
|
|
7846
|
-
_eventbusRemovers = [];
|
|
7847
|
-
constructor(_currentLanguage, labels, _eventbus) {
|
|
7848
|
-
this._currentLanguage = _currentLanguage;
|
|
7849
|
-
this._eventbus = _eventbus;
|
|
7850
|
-
if (!_currentLanguage) throw new Error("language ctor arg cannot have zero length");
|
|
7851
|
-
setGlobal("defaultLanguage", _currentLanguage);
|
|
7852
|
-
this._setRootElementLang(_currentLanguage);
|
|
7853
|
-
this._labelLookup = this._createLabelLookup(labels);
|
|
7854
|
-
this._addEventbusListeners(_eventbus);
|
|
7855
|
-
}
|
|
7856
|
-
destroy() {
|
|
7857
|
-
this._eventbusRemovers.forEach((x) => x());
|
|
7858
|
-
}
|
|
7859
|
-
_addEventbusListeners(eventbus$1) {
|
|
7860
|
-
this._eventbusRemovers.push(eventbus$1.on("request-label-collection", this._handleRequestLabelCollection.bind(this)));
|
|
7861
|
-
this._eventbusRemovers.push(eventbus$1.on("request-label-collections", this._handleRequestLabelCollections.bind(this)));
|
|
7862
|
-
this._eventbusRemovers.push(eventbus$1.on("request-current-language", this._handleRequestCurrentLanguage.bind(this)));
|
|
7863
|
-
this._eventbusRemovers.push(eventbus$1.on("language-change", this._handleLanguageChange.bind(this)));
|
|
7864
|
-
}
|
|
7865
|
-
_handleRequestCurrentLanguage(resultCallback) {
|
|
7866
|
-
resultCallback(this._currentLanguage);
|
|
7867
|
-
}
|
|
7868
|
-
_handleRequestLabelCollection(labelId, resultCallback) {
|
|
7869
|
-
resultCallback(this._labelLookup[labelId]);
|
|
7870
|
-
}
|
|
7871
|
-
_handleRequestLabelCollections(labelIds, resultCallback) {
|
|
7872
|
-
resultCallback(labelIds.map((labelId) => {
|
|
7873
|
-
return this._labelLookup[labelId];
|
|
7874
|
-
}));
|
|
7875
|
-
}
|
|
7876
|
-
_handleLanguageChange(language) {
|
|
7877
|
-
this._currentLanguage = language;
|
|
7878
|
-
this._setRootElementLang(this._currentLanguage);
|
|
7879
|
-
}
|
|
7880
|
-
_setRootElementLang(language) {
|
|
7881
|
-
const callBack = (rootSelector) => {
|
|
7882
|
-
const lang = this._extractPrimaryLanguage(language);
|
|
7883
|
-
$(rootSelector).attr("lang", lang);
|
|
7884
|
-
};
|
|
7885
|
-
this._eventbus.broadcast("request-engine-root", [callBack]);
|
|
7886
|
-
}
|
|
7887
|
-
_extractPrimaryLanguage(culture) {
|
|
7888
|
-
return culture.split("-").shift();
|
|
7889
|
-
}
|
|
7890
|
-
_createLabelLookup(labels) {
|
|
7891
|
-
return labels.reduce((acc, label) => {
|
|
7892
|
-
acc[label.id] = label.labels;
|
|
7893
|
-
return acc;
|
|
7894
|
-
}, {});
|
|
7895
|
-
}
|
|
7896
|
-
};
|
|
7897
|
-
|
|
7898
|
-
//#endregion
|
|
7899
|
-
//#region src/engine-factory.ts
|
|
7900
|
-
const hotkeys = hk.default || hk;
|
|
7901
|
-
/**
|
|
7902
|
-
* The EngineFactory is used to create and initialize an {@link IEligiusEngine} instance.
|
|
7903
|
-
*
|
|
7904
|
-
* It prepares a resolved configuration and creates the engine based on the class defined in the configuration.
|
|
7905
|
-
*
|
|
7906
|
-
* @example Loading a configuration and creating an IEligiusEngine instance
|
|
7907
|
-
* ```ts
|
|
7908
|
-
* import { IEngineConfiguration, EngineFactory, WebpackResourceImporter } from 'eligius';
|
|
7909
|
-
* import * as engineConfig from './my-eligius-config.json';
|
|
7910
|
-
*
|
|
7911
|
-
* const factory = new EngineFactory(new WebpackResourceImporter(), window);
|
|
7912
|
-
*
|
|
7913
|
-
* const engine = factory.createEngine((engineConfig as unknown) as IEngineConfiguration);
|
|
7914
|
-
*
|
|
7915
|
-
* engine.init().then(()=> {console.log('Eligius engine ready for business');});
|
|
7916
|
-
* ```
|
|
7917
|
-
*/
|
|
7918
|
-
var EngineFactory = class {
|
|
7919
|
-
_actionsLookup = {};
|
|
7920
|
-
_eventbus;
|
|
7921
|
-
_eventRemovers = [];
|
|
7922
|
-
_importer;
|
|
7923
|
-
_resizeTimeout = -1;
|
|
7924
|
-
constructor(importer, windowRef, options) {
|
|
7925
|
-
this._importer = importer;
|
|
7926
|
-
this._eventbus = options?.eventbus ?? new Eventbus();
|
|
7927
|
-
Diagnostics.active = options?.devtools ?? false;
|
|
7928
|
-
if (Diagnostics.active) this._initializeDevtools(this._eventbus);
|
|
7929
|
-
this._eventRemovers.push(this._eventbus.on("request-instance", this._requestInstanceHandler.bind(this)));
|
|
7930
|
-
this._eventRemovers.push(this._eventbus.on("request-action", this._requestActionHandler.bind(this)));
|
|
7931
|
-
this._eventRemovers.push(this._eventbus.on("request-function", this._requestFunctionHandler.bind(this)));
|
|
7932
|
-
const handleSpaceBound = this._handleSpacePress.bind(this);
|
|
7933
|
-
hotkeys("space", handleSpaceBound);
|
|
7934
|
-
this._eventRemovers.push(() => hotkeys.unbind("space", handleSpaceBound));
|
|
7935
|
-
const resizeBound = this._resizeHandler.bind(this);
|
|
7936
|
-
const jqWin = $(windowRef);
|
|
7937
|
-
jqWin.on("resize", resizeBound);
|
|
7938
|
-
this._eventRemovers.push(() => jqWin.off("resize", resizeBound));
|
|
7939
|
-
}
|
|
7940
|
-
_handleSpacePress(keyboardEvent, _hotkeysEvent) {
|
|
7941
|
-
keyboardEvent.preventDefault();
|
|
7942
|
-
this._eventbus.broadcast("timeline-play-toggle-request", []);
|
|
7943
|
-
return false;
|
|
7944
|
-
}
|
|
7945
|
-
_initializeDevtools(eventbus$1) {
|
|
7946
|
-
const diagnosticInfo = window[DEV_TOOLS_KEY];
|
|
7947
|
-
if (diagnosticInfo) {
|
|
7948
|
-
const { agent } = diagnosticInfo;
|
|
7949
|
-
this._eventRemovers.push(eventbus$1.registerEventlistener(new DevToolEventListener(agent)));
|
|
7950
|
-
this._eventRemovers.push(agent.subscribe((message) => {
|
|
7951
|
-
if (message.type === "playcontrol") switch (message.data.kind) {
|
|
7952
|
-
case "play":
|
|
7953
|
-
this._eventbus.broadcast("timeline-play-request", []);
|
|
7954
|
-
break;
|
|
7955
|
-
case "stop":
|
|
7956
|
-
this._eventbus.broadcast("timeline-stop-request", []);
|
|
7957
|
-
break;
|
|
7958
|
-
case "pause":
|
|
7959
|
-
this._eventbus.broadcast("timeline-pause-request", []);
|
|
7960
|
-
break;
|
|
7961
|
-
case "seek":
|
|
7962
|
-
this._eventbus.broadcast("timeline-seek-request", [message.data.args ?? 0]);
|
|
7963
|
-
break;
|
|
7964
|
-
}
|
|
7965
|
-
}));
|
|
7966
|
-
Diagnostics.send = (name, messageData) => {
|
|
7967
|
-
const message = prepareValueForSerialization(messageData);
|
|
7968
|
-
try {
|
|
7969
|
-
agent.postMessage(name, message);
|
|
7970
|
-
} catch (e) {
|
|
7971
|
-
console.error("postmessage failed");
|
|
7972
|
-
console.error(e);
|
|
7973
|
-
console.log("message", message);
|
|
7974
|
-
}
|
|
7975
|
-
};
|
|
7976
|
-
Diagnostics.send("eligius-diagnostics-factory", "Diagnostics initialized");
|
|
7977
|
-
} else console.warn(`${DEV_TOOLS_KEY} property not found on window, please install the Eligius Devtools extension.`);
|
|
7978
|
-
}
|
|
7979
|
-
destroy() {
|
|
7980
|
-
this._eventRemovers.forEach((x) => x());
|
|
7981
|
-
}
|
|
7982
|
-
_resizeHandler() {
|
|
7983
|
-
if (this._resizeTimeout) {
|
|
7984
|
-
clearTimeout(this._resizeTimeout);
|
|
7985
|
-
this._resizeTimeout = -1;
|
|
7986
|
-
}
|
|
7987
|
-
this._resizeTimeout = setTimeout(() => {
|
|
7988
|
-
this._eventbus.broadcast("timeline-resize", []);
|
|
7989
|
-
}, 200);
|
|
7990
|
-
}
|
|
7991
|
-
_importSystemEntryWithEventbusDependency(systemName) {
|
|
7992
|
-
return new (this._importSystemEntry(systemName))(this._eventbus);
|
|
7993
|
-
}
|
|
7994
|
-
_importSystemEntry(systemName) {
|
|
7995
|
-
return this._importer.import(systemName)[systemName];
|
|
7996
|
-
}
|
|
7997
|
-
_requestInstanceHandler(systemName, resultCallback) {
|
|
7998
|
-
resultCallback(this._importSystemEntryWithEventbusDependency(systemName));
|
|
7999
|
-
}
|
|
8000
|
-
_requestFunctionHandler(systemName, resultCallback) {
|
|
8001
|
-
resultCallback(this._importSystemEntry(systemName));
|
|
8002
|
-
}
|
|
8003
|
-
_requestActionHandler(systemName, resultCallback) {
|
|
8004
|
-
const action = this._actionsLookup[systemName];
|
|
8005
|
-
if (action) resultCallback(action);
|
|
8006
|
-
else {
|
|
8007
|
-
console.error(`Unknown action: ${systemName}`);
|
|
8008
|
-
resultCallback(null);
|
|
8009
|
-
}
|
|
8010
|
-
}
|
|
8011
|
-
createEngine(configuration, resolver) {
|
|
8012
|
-
const { systemName } = configuration.engine;
|
|
8013
|
-
const EngineClass = this._importSystemEntry(systemName);
|
|
8014
|
-
let actionRegistryListener;
|
|
8015
|
-
if (configuration.eventActions?.length) {
|
|
8016
|
-
actionRegistryListener = new ActionRegistryEventbusListener();
|
|
8017
|
-
this._eventRemovers.push(this._eventbus.registerEventlistener(actionRegistryListener));
|
|
8018
|
-
}
|
|
8019
|
-
this._eventRemovers.push(this._eventbus.registerInterceptor("request-timeline-uri", new RequestVideoUriInterceptor(this._eventbus)));
|
|
8020
|
-
resolver = resolver || new ConfigurationResolver(this._importer, this._eventbus);
|
|
8021
|
-
const [actionLookup, resolvedConfiguration] = resolver.process(configuration, actionRegistryListener);
|
|
8022
|
-
this._actionsLookup = actionLookup;
|
|
8023
|
-
const timelineProviders = this._createTimelineProviders(resolvedConfiguration);
|
|
8024
|
-
const { language, labels } = configuration;
|
|
8025
|
-
const languageManager = new LanguageManager(language, labels, this._eventbus);
|
|
8026
|
-
return new EngineClass(resolvedConfiguration, this._eventbus, timelineProviders, languageManager);
|
|
8027
|
-
}
|
|
8028
|
-
_createTimelineProviders(configuration) {
|
|
8029
|
-
const { timelineProviderSettings } = configuration;
|
|
8030
|
-
return Object.entries(timelineProviderSettings).reduce((acc, [timelineType, settings]) => {
|
|
8031
|
-
if (!settings) return acc;
|
|
8032
|
-
const TimelineProviderClass = this._importSystemEntry(settings.systemName);
|
|
8033
|
-
acc[timelineType] = {
|
|
8034
|
-
id: settings.id,
|
|
8035
|
-
vendor: settings.vendor,
|
|
8036
|
-
provider: new TimelineProviderClass(configuration)
|
|
8037
|
-
};
|
|
8038
|
-
return acc;
|
|
8039
|
-
}, {});
|
|
8040
|
-
}
|
|
8041
|
-
};
|
|
8042
|
-
|
|
8043
7431
|
//#endregion
|
|
8044
7432
|
//#region src/eventbus/events/metadata/before-request-timeline-uri.ts
|
|
8045
7433
|
function beforeRequestTimelineUri() {
|
|
@@ -8189,7 +7577,10 @@ function requestCurrentTimelinePosition() {
|
|
|
8189
7577
|
return {
|
|
8190
7578
|
description: `Event: request-current-timeline-position`,
|
|
8191
7579
|
category: `Engine Request`,
|
|
8192
|
-
args: [
|
|
7580
|
+
args: [{
|
|
7581
|
+
name: "callback",
|
|
7582
|
+
type: "TResultCallback<number>"
|
|
7583
|
+
}]
|
|
8193
7584
|
};
|
|
8194
7585
|
}
|
|
8195
7586
|
|
|
@@ -8278,371 +7669,1861 @@ function requestLabelCollections() {
|
|
|
8278
7669
|
type: "string[]"
|
|
8279
7670
|
}, {
|
|
8280
7671
|
name: "callback",
|
|
8281
|
-
type: "(collections: any) => void"
|
|
7672
|
+
type: "(collections: any) => void"
|
|
7673
|
+
}]
|
|
7674
|
+
};
|
|
7675
|
+
}
|
|
7676
|
+
|
|
7677
|
+
//#endregion
|
|
7678
|
+
//#region src/eventbus/events/metadata/request-timeline-cleanup.ts
|
|
7679
|
+
function requestTimelineCleanup() {
|
|
7680
|
+
return {
|
|
7681
|
+
description: `Event: request-timeline-cleanup`,
|
|
7682
|
+
category: `Engine Request`,
|
|
7683
|
+
args: []
|
|
7684
|
+
};
|
|
7685
|
+
}
|
|
7686
|
+
|
|
7687
|
+
//#endregion
|
|
7688
|
+
//#region src/eventbus/events/metadata/request-timeline-uri.ts
|
|
7689
|
+
function requestTimelineUri() {
|
|
7690
|
+
return {
|
|
7691
|
+
description: `Event: request-timeline-uri`,
|
|
7692
|
+
category: `Engine Request`,
|
|
7693
|
+
args: [{
|
|
7694
|
+
name: "uri",
|
|
7695
|
+
type: "string"
|
|
7696
|
+
}, {
|
|
7697
|
+
name: "position",
|
|
7698
|
+
type: "number"
|
|
7699
|
+
}]
|
|
7700
|
+
};
|
|
7701
|
+
}
|
|
7702
|
+
|
|
7703
|
+
//#endregion
|
|
7704
|
+
//#region src/eventbus/events/metadata/request-video-cleanup.ts
|
|
7705
|
+
function requestVideoCleanup() {
|
|
7706
|
+
return {
|
|
7707
|
+
description: `Event: request-video-cleanup`,
|
|
7708
|
+
category: `Navigation`,
|
|
7709
|
+
args: []
|
|
7710
|
+
};
|
|
7711
|
+
}
|
|
7712
|
+
|
|
7713
|
+
//#endregion
|
|
7714
|
+
//#region src/eventbus/events/metadata/request-video-url.ts
|
|
7715
|
+
function requestVideoUrl() {
|
|
7716
|
+
return {
|
|
7717
|
+
description: `Event: request-video-url`,
|
|
7718
|
+
category: `Navigation`,
|
|
7719
|
+
args: [
|
|
7720
|
+
{
|
|
7721
|
+
name: "videoUrlIndex",
|
|
7722
|
+
type: "number"
|
|
7723
|
+
},
|
|
7724
|
+
{
|
|
7725
|
+
name: "requestedVideoPosition",
|
|
7726
|
+
type: "number"
|
|
7727
|
+
},
|
|
7728
|
+
{
|
|
7729
|
+
name: "fromRouting",
|
|
7730
|
+
type: "boolean"
|
|
7731
|
+
}
|
|
7732
|
+
]
|
|
7733
|
+
};
|
|
7734
|
+
}
|
|
7735
|
+
|
|
7736
|
+
//#endregion
|
|
7737
|
+
//#region src/eventbus/events/metadata/timeline-complete.ts
|
|
7738
|
+
function timelineComplete() {
|
|
7739
|
+
return {
|
|
7740
|
+
description: `Event: timeline-complete`,
|
|
7741
|
+
category: `Timeline`,
|
|
7742
|
+
args: []
|
|
7743
|
+
};
|
|
7744
|
+
}
|
|
7745
|
+
|
|
7746
|
+
//#endregion
|
|
7747
|
+
//#region src/eventbus/events/metadata/timeline-container-request.ts
|
|
7748
|
+
function timelineContainerRequest() {
|
|
7749
|
+
return {
|
|
7750
|
+
description: `Event: timeline-container-request`,
|
|
7751
|
+
category: `Timeline`,
|
|
7752
|
+
args: [{
|
|
7753
|
+
name: "callback",
|
|
7754
|
+
type: "(element: HTMLElement) => void"
|
|
7755
|
+
}]
|
|
7756
|
+
};
|
|
7757
|
+
}
|
|
7758
|
+
|
|
7759
|
+
//#endregion
|
|
7760
|
+
//#region src/eventbus/events/metadata/timeline-current-timeline-change.ts
|
|
7761
|
+
function timelineCurrentTimelineChange() {
|
|
7762
|
+
return {
|
|
7763
|
+
description: `Event: timeline-current-timeline-change`,
|
|
7764
|
+
category: `Timeline`,
|
|
7765
|
+
args: [{
|
|
7766
|
+
name: "timelineUri",
|
|
7767
|
+
type: "string"
|
|
7768
|
+
}]
|
|
7769
|
+
};
|
|
7770
|
+
}
|
|
7771
|
+
|
|
7772
|
+
//#endregion
|
|
7773
|
+
//#region src/eventbus/events/metadata/timeline-duration-request.ts
|
|
7774
|
+
function timelineDurationRequest() {
|
|
7775
|
+
return {
|
|
7776
|
+
description: `Event: timeline-duration-request`,
|
|
7777
|
+
category: `Timeline`,
|
|
7778
|
+
args: [{
|
|
7779
|
+
name: "callback",
|
|
7780
|
+
type: "(duration: number) => void"
|
|
7781
|
+
}]
|
|
7782
|
+
};
|
|
7783
|
+
}
|
|
7784
|
+
|
|
7785
|
+
//#endregion
|
|
7786
|
+
//#region src/eventbus/events/metadata/timeline-duration.ts
|
|
7787
|
+
function timelineDuration() {
|
|
7788
|
+
return {
|
|
7789
|
+
description: `Event: timeline-duration`,
|
|
7790
|
+
category: `Timeline`,
|
|
7791
|
+
args: [{
|
|
7792
|
+
name: "getDuration",
|
|
7793
|
+
type: "(() => number) | undefined"
|
|
7794
|
+
}]
|
|
7795
|
+
};
|
|
7796
|
+
}
|
|
7797
|
+
|
|
7798
|
+
//#endregion
|
|
7799
|
+
//#region src/eventbus/events/metadata/timeline-firstframe.ts
|
|
7800
|
+
function timelineFirstframe() {
|
|
7801
|
+
return {
|
|
7802
|
+
description: `Event: timeline-firstframe`,
|
|
7803
|
+
category: `Timeline`,
|
|
7804
|
+
args: []
|
|
7805
|
+
};
|
|
7806
|
+
}
|
|
7807
|
+
|
|
7808
|
+
//#endregion
|
|
7809
|
+
//#region src/eventbus/events/metadata/timeline-pause-request.ts
|
|
7810
|
+
function timelinePauseRequest() {
|
|
7811
|
+
return {
|
|
7812
|
+
description: `Event: timeline-pause-request`,
|
|
7813
|
+
category: `Timeline`,
|
|
7814
|
+
args: []
|
|
7815
|
+
};
|
|
7816
|
+
}
|
|
7817
|
+
|
|
7818
|
+
//#endregion
|
|
7819
|
+
//#region src/eventbus/events/metadata/timeline-pause.ts
|
|
7820
|
+
function timelinePause() {
|
|
7821
|
+
return {
|
|
7822
|
+
description: `Event: timeline-pause`,
|
|
7823
|
+
category: `Timeline`,
|
|
7824
|
+
args: []
|
|
7825
|
+
};
|
|
7826
|
+
}
|
|
7827
|
+
|
|
7828
|
+
//#endregion
|
|
7829
|
+
//#region src/eventbus/events/metadata/timeline-play-request.ts
|
|
7830
|
+
function timelinePlayRequest() {
|
|
7831
|
+
return {
|
|
7832
|
+
description: `Event: timeline-play-request`,
|
|
7833
|
+
category: `Timeline`,
|
|
7834
|
+
args: []
|
|
7835
|
+
};
|
|
7836
|
+
}
|
|
7837
|
+
|
|
7838
|
+
//#endregion
|
|
7839
|
+
//#region src/eventbus/events/metadata/timeline-play-toggle-request.ts
|
|
7840
|
+
function timelinePlayToggleRequest() {
|
|
7841
|
+
return {
|
|
7842
|
+
description: `Event: timeline-play-toggle-request`,
|
|
7843
|
+
category: `Timeline`,
|
|
7844
|
+
args: []
|
|
7845
|
+
};
|
|
7846
|
+
}
|
|
7847
|
+
|
|
7848
|
+
//#endregion
|
|
7849
|
+
//#region src/eventbus/events/metadata/timeline-play.ts
|
|
7850
|
+
function timelinePlay() {
|
|
7851
|
+
return {
|
|
7852
|
+
description: `Event: timeline-play`,
|
|
7853
|
+
category: `Timeline`,
|
|
7854
|
+
args: []
|
|
7855
|
+
};
|
|
7856
|
+
}
|
|
7857
|
+
|
|
7858
|
+
//#endregion
|
|
7859
|
+
//#region src/eventbus/events/metadata/timeline-request-current-timeline.ts
|
|
7860
|
+
function timelineRequestCurrentTimeline() {
|
|
7861
|
+
return {
|
|
7862
|
+
description: `Event: timeline-request-current-timeline`,
|
|
7863
|
+
category: `Engine Request`,
|
|
7864
|
+
args: [{
|
|
7865
|
+
name: "callback",
|
|
7866
|
+
type: "TResultCallback<string>"
|
|
8282
7867
|
}]
|
|
8283
7868
|
};
|
|
8284
7869
|
}
|
|
8285
7870
|
|
|
8286
7871
|
//#endregion
|
|
8287
|
-
//#region src/eventbus/events/metadata/
|
|
8288
|
-
function
|
|
7872
|
+
//#region src/eventbus/events/metadata/timeline-resize-request.ts
|
|
7873
|
+
function timelineResizeRequest() {
|
|
8289
7874
|
return {
|
|
8290
|
-
description: `Event:
|
|
8291
|
-
category: `
|
|
7875
|
+
description: `Event: timeline-resize-request`,
|
|
7876
|
+
category: `Timeline`,
|
|
8292
7877
|
args: []
|
|
8293
7878
|
};
|
|
8294
7879
|
}
|
|
8295
7880
|
|
|
8296
7881
|
//#endregion
|
|
8297
|
-
//#region src/eventbus/events/metadata/
|
|
8298
|
-
function
|
|
7882
|
+
//#region src/eventbus/events/metadata/timeline-resize.ts
|
|
7883
|
+
function timelineResize() {
|
|
8299
7884
|
return {
|
|
8300
|
-
description: `Event:
|
|
8301
|
-
category: `
|
|
7885
|
+
description: `Event: timeline-resize`,
|
|
7886
|
+
category: `Timeline`,
|
|
8302
7887
|
args: []
|
|
8303
7888
|
};
|
|
8304
7889
|
}
|
|
8305
7890
|
|
|
8306
7891
|
//#endregion
|
|
8307
|
-
//#region src/eventbus/events/metadata/
|
|
8308
|
-
function
|
|
7892
|
+
//#region src/eventbus/events/metadata/timeline-restart.ts
|
|
7893
|
+
function timelineRestart() {
|
|
8309
7894
|
return {
|
|
8310
|
-
description: `Event:
|
|
8311
|
-
category: `
|
|
7895
|
+
description: `Event: timeline-restart`,
|
|
7896
|
+
category: `Timeline`,
|
|
8312
7897
|
args: []
|
|
8313
7898
|
};
|
|
8314
7899
|
}
|
|
8315
7900
|
|
|
8316
7901
|
//#endregion
|
|
8317
|
-
//#region src/eventbus/events/metadata/
|
|
8318
|
-
function
|
|
7902
|
+
//#region src/eventbus/events/metadata/timeline-seek-request.ts
|
|
7903
|
+
function timelineSeekRequest() {
|
|
8319
7904
|
return {
|
|
8320
|
-
description: `Event:
|
|
8321
|
-
category: `
|
|
7905
|
+
description: `Event: timeline-seek-request`,
|
|
7906
|
+
category: `Timeline`,
|
|
7907
|
+
args: [{
|
|
7908
|
+
name: "position",
|
|
7909
|
+
type: "number"
|
|
7910
|
+
}]
|
|
7911
|
+
};
|
|
7912
|
+
}
|
|
7913
|
+
|
|
7914
|
+
//#endregion
|
|
7915
|
+
//#region src/eventbus/events/metadata/timeline-seek.ts
|
|
7916
|
+
function timelineSeek() {
|
|
7917
|
+
return {
|
|
7918
|
+
description: `Event: timeline-seek`,
|
|
7919
|
+
category: `Timeline`,
|
|
8322
7920
|
args: [
|
|
8323
7921
|
{
|
|
8324
|
-
name: "
|
|
7922
|
+
name: "seekPosition",
|
|
8325
7923
|
type: "number"
|
|
8326
7924
|
},
|
|
8327
7925
|
{
|
|
8328
|
-
name: "
|
|
7926
|
+
name: "currentPosition",
|
|
8329
7927
|
type: "number"
|
|
8330
7928
|
},
|
|
8331
7929
|
{
|
|
8332
|
-
name: "
|
|
8333
|
-
type: "
|
|
7930
|
+
name: "duration",
|
|
7931
|
+
type: "number"
|
|
8334
7932
|
}
|
|
8335
7933
|
]
|
|
8336
7934
|
};
|
|
8337
7935
|
}
|
|
8338
7936
|
|
|
8339
7937
|
//#endregion
|
|
8340
|
-
//#region src/eventbus/events/metadata/timeline-
|
|
8341
|
-
function
|
|
8342
|
-
return {
|
|
8343
|
-
description: `Event: timeline-complete`,
|
|
8344
|
-
category: `Timeline`,
|
|
8345
|
-
args: []
|
|
8346
|
-
};
|
|
8347
|
-
}
|
|
8348
|
-
|
|
8349
|
-
//#endregion
|
|
8350
|
-
//#region src/eventbus/events/metadata/timeline-container-request.ts
|
|
8351
|
-
function timelineContainerRequest() {
|
|
7938
|
+
//#region src/eventbus/events/metadata/timeline-seeked.ts
|
|
7939
|
+
function timelineSeeked() {
|
|
8352
7940
|
return {
|
|
8353
|
-
description: `Event: timeline-
|
|
7941
|
+
description: `Event: timeline-seeked`,
|
|
8354
7942
|
category: `Timeline`,
|
|
8355
7943
|
args: [{
|
|
8356
|
-
name: "
|
|
8357
|
-
type: "
|
|
7944
|
+
name: "position",
|
|
7945
|
+
type: "number"
|
|
7946
|
+
}, {
|
|
7947
|
+
name: "duration",
|
|
7948
|
+
type: "number"
|
|
8358
7949
|
}]
|
|
8359
7950
|
};
|
|
8360
7951
|
}
|
|
8361
7952
|
|
|
8362
7953
|
//#endregion
|
|
8363
|
-
//#region src/eventbus/events/metadata/timeline-
|
|
8364
|
-
function
|
|
7954
|
+
//#region src/eventbus/events/metadata/timeline-stop-request.ts
|
|
7955
|
+
function timelineStopRequest() {
|
|
8365
7956
|
return {
|
|
8366
|
-
description: `Event: timeline-
|
|
7957
|
+
description: `Event: timeline-stop-request`,
|
|
8367
7958
|
category: `Timeline`,
|
|
8368
|
-
args: [
|
|
8369
|
-
name: "timelineUri",
|
|
8370
|
-
type: "string"
|
|
8371
|
-
}]
|
|
7959
|
+
args: []
|
|
8372
7960
|
};
|
|
8373
7961
|
}
|
|
8374
7962
|
|
|
8375
7963
|
//#endregion
|
|
8376
|
-
//#region src/eventbus/events/metadata/timeline-
|
|
8377
|
-
function
|
|
7964
|
+
//#region src/eventbus/events/metadata/timeline-stop.ts
|
|
7965
|
+
function timelineStop() {
|
|
8378
7966
|
return {
|
|
8379
|
-
description: `Event: timeline-
|
|
7967
|
+
description: `Event: timeline-stop`,
|
|
8380
7968
|
category: `Timeline`,
|
|
8381
|
-
args: [
|
|
8382
|
-
name: "callback",
|
|
8383
|
-
type: "(duration: number) => void"
|
|
8384
|
-
}]
|
|
7969
|
+
args: []
|
|
8385
7970
|
};
|
|
8386
7971
|
}
|
|
8387
7972
|
|
|
8388
7973
|
//#endregion
|
|
8389
|
-
//#region src/eventbus/events/metadata/timeline-
|
|
8390
|
-
function
|
|
7974
|
+
//#region src/eventbus/events/metadata/timeline-time.ts
|
|
7975
|
+
function timelineTime() {
|
|
8391
7976
|
return {
|
|
8392
|
-
description: `Event: timeline-
|
|
7977
|
+
description: `Event: timeline-time`,
|
|
8393
7978
|
category: `Timeline`,
|
|
8394
7979
|
args: [{
|
|
8395
|
-
name: "
|
|
8396
|
-
type: "
|
|
7980
|
+
name: "position",
|
|
7981
|
+
type: "number"
|
|
8397
7982
|
}]
|
|
8398
7983
|
};
|
|
8399
7984
|
}
|
|
8400
7985
|
|
|
8401
7986
|
//#endregion
|
|
8402
|
-
//#region src/eventbus/events/metadata/
|
|
8403
|
-
function
|
|
7987
|
+
//#region src/eventbus/events/metadata/video-complete.ts
|
|
7988
|
+
function videoComplete() {
|
|
8404
7989
|
return {
|
|
8405
|
-
description: `Event:
|
|
8406
|
-
category: `
|
|
8407
|
-
args: [
|
|
7990
|
+
description: `Event: video-complete`,
|
|
7991
|
+
category: `Navigation`,
|
|
7992
|
+
args: [{
|
|
7993
|
+
name: "index",
|
|
7994
|
+
type: "number"
|
|
7995
|
+
}]
|
|
8408
7996
|
};
|
|
8409
7997
|
}
|
|
8410
7998
|
|
|
8411
7999
|
//#endregion
|
|
8412
|
-
//#region src/eventbus/events/metadata/
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8000
|
+
//#region src/eventbus/events/metadata/index.ts
|
|
8001
|
+
var metadata_exports$1 = /* @__PURE__ */ __export({
|
|
8002
|
+
beforeRequestTimelineUri: () => beforeRequestTimelineUri,
|
|
8003
|
+
beforeRequestVideoUrl: () => beforeRequestVideoUrl,
|
|
8004
|
+
domMutation: () => domMutation,
|
|
8005
|
+
highlightNavigation: () => highlightNavigation,
|
|
8006
|
+
languageChange: () => languageChange,
|
|
8007
|
+
navigateToVideoUrl: () => navigateToVideoUrl,
|
|
8008
|
+
pushHistoryState: () => pushHistoryState,
|
|
8009
|
+
requestAction: () => requestAction$1,
|
|
8010
|
+
requestCurrentLanguage: () => requestCurrentLanguage,
|
|
8011
|
+
requestCurrentNavigation: () => requestCurrentNavigation,
|
|
8012
|
+
requestCurrentTimelinePosition: () => requestCurrentTimelinePosition,
|
|
8013
|
+
requestCurrentVideoPosition: () => requestCurrentVideoPosition,
|
|
8014
|
+
requestEngineRoot: () => requestEngineRoot,
|
|
8015
|
+
requestFunction: () => requestFunction,
|
|
8016
|
+
requestInstance: () => requestInstance,
|
|
8017
|
+
requestLabelCollection: () => requestLabelCollection,
|
|
8018
|
+
requestLabelCollections: () => requestLabelCollections,
|
|
8019
|
+
requestTimelineCleanup: () => requestTimelineCleanup,
|
|
8020
|
+
requestTimelineUri: () => requestTimelineUri,
|
|
8021
|
+
requestVideoCleanup: () => requestVideoCleanup,
|
|
8022
|
+
requestVideoUrl: () => requestVideoUrl,
|
|
8023
|
+
timelineComplete: () => timelineComplete,
|
|
8024
|
+
timelineContainerRequest: () => timelineContainerRequest,
|
|
8025
|
+
timelineCurrentTimelineChange: () => timelineCurrentTimelineChange,
|
|
8026
|
+
timelineDuration: () => timelineDuration,
|
|
8027
|
+
timelineDurationRequest: () => timelineDurationRequest,
|
|
8028
|
+
timelineFirstframe: () => timelineFirstframe,
|
|
8029
|
+
timelinePause: () => timelinePause,
|
|
8030
|
+
timelinePauseRequest: () => timelinePauseRequest,
|
|
8031
|
+
timelinePlay: () => timelinePlay,
|
|
8032
|
+
timelinePlayRequest: () => timelinePlayRequest,
|
|
8033
|
+
timelinePlayToggleRequest: () => timelinePlayToggleRequest,
|
|
8034
|
+
timelineRequestCurrentTimeline: () => timelineRequestCurrentTimeline,
|
|
8035
|
+
timelineResize: () => timelineResize,
|
|
8036
|
+
timelineResizeRequest: () => timelineResizeRequest,
|
|
8037
|
+
timelineRestart: () => timelineRestart,
|
|
8038
|
+
timelineSeek: () => timelineSeek,
|
|
8039
|
+
timelineSeekRequest: () => timelineSeekRequest,
|
|
8040
|
+
timelineSeeked: () => timelineSeeked,
|
|
8041
|
+
timelineStop: () => timelineStop,
|
|
8042
|
+
timelineStopRequest: () => timelineStopRequest,
|
|
8043
|
+
timelineTime: () => timelineTime,
|
|
8044
|
+
videoComplete: () => videoComplete
|
|
8045
|
+
});
|
|
8420
8046
|
|
|
8421
8047
|
//#endregion
|
|
8422
|
-
//#region src/eventbus/
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8048
|
+
//#region src/eventbus/actionregistry-eventbus-listener.ts
|
|
8049
|
+
/**
|
|
8050
|
+
* The `IEventbusListener` first registers a number of actions that are then
|
|
8051
|
+
* executed when the specified event is broadcast.
|
|
8052
|
+
*/
|
|
8053
|
+
var ActionRegistryEventbusListener = class {
|
|
8054
|
+
_actionRegistry = /* @__PURE__ */ new Map();
|
|
8055
|
+
registerAction(action, eventName, eventTopic) {
|
|
8056
|
+
if (eventTopic?.length) eventName = `${eventName}:${eventTopic}`;
|
|
8057
|
+
if (!this._actionRegistry.has(eventName)) this._actionRegistry.set(eventName, []);
|
|
8058
|
+
this._actionRegistry.get(eventName)?.push(action);
|
|
8059
|
+
}
|
|
8060
|
+
handleEvent(eventName, eventTopic, args) {
|
|
8061
|
+
if (eventTopic) eventName = `${eventName}:${eventTopic}`;
|
|
8062
|
+
const actions = this._actionRegistry.get(eventName);
|
|
8063
|
+
if (actions) {
|
|
8064
|
+
const operationData = { eventArgs: args };
|
|
8065
|
+
actions.forEach((action) => {
|
|
8066
|
+
action.start(operationData);
|
|
8067
|
+
});
|
|
8068
|
+
}
|
|
8069
|
+
}
|
|
8070
|
+
};
|
|
8430
8071
|
|
|
8431
8072
|
//#endregion
|
|
8432
|
-
//#region src/eventbus/
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8073
|
+
//#region src/eventbus/eventbus.ts
|
|
8074
|
+
/**
|
|
8075
|
+
* Central event bus for pub/sub communication and synchronous request/response queries.
|
|
8076
|
+
*
|
|
8077
|
+
* The eventbus supports:
|
|
8078
|
+
* - **Pub/Sub**: `on()`, `once()`, `off()`, `broadcast()`, `broadcastForTopic()`
|
|
8079
|
+
* - **Request/Response**: `onRequest()`, `request()`, `requestForTopic()` for synchronous queries
|
|
8080
|
+
* - **Interceptors**: Transform event arguments before handlers receive them
|
|
8081
|
+
* - **Listeners**: Global event observers for logging/debugging
|
|
8082
|
+
*
|
|
8083
|
+
* @example Pub/Sub pattern
|
|
8084
|
+
* ```ts
|
|
8085
|
+
* const remover = eventbus.on('timeline-play', () => console.log('Playing'));
|
|
8086
|
+
* eventbus.broadcast('timeline-play', []);
|
|
8087
|
+
* remover(); // Unsubscribe
|
|
8088
|
+
* ```
|
|
8089
|
+
*
|
|
8090
|
+
* @example Request/Response pattern
|
|
8091
|
+
* ```ts
|
|
8092
|
+
* eventbus.onRequest('request-instance', (name) => new MyClass(name));
|
|
8093
|
+
* const instance = eventbus.request<MyClass>('request-instance', 'test');
|
|
8094
|
+
* ```
|
|
8095
|
+
*/
|
|
8096
|
+
var Eventbus = class {
|
|
8097
|
+
eventHandlers = /* @__PURE__ */ new Map();
|
|
8098
|
+
eventInterceptors = /* @__PURE__ */ new Map();
|
|
8099
|
+
eventListeners = [];
|
|
8100
|
+
requestResponders = /* @__PURE__ */ new Map();
|
|
8101
|
+
constructor() {
|
|
8102
|
+
this.clear();
|
|
8103
|
+
}
|
|
8104
|
+
/**
|
|
8105
|
+
* Clears all handlers, listeners, interceptors, and request responders.
|
|
8106
|
+
*/
|
|
8107
|
+
clear() {
|
|
8108
|
+
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
8109
|
+
this.eventListeners = [];
|
|
8110
|
+
this.eventInterceptors = /* @__PURE__ */ new Map();
|
|
8111
|
+
this.requestResponders = /* @__PURE__ */ new Map();
|
|
8112
|
+
}
|
|
8113
|
+
_getEventInterceptors(eventName, eventTopic) {
|
|
8114
|
+
if (eventTopic) eventName = `${eventName}:${eventTopic}`;
|
|
8115
|
+
if (!this.eventInterceptors.has(eventName)) this.eventInterceptors.set(eventName, []);
|
|
8116
|
+
return this.eventInterceptors.get(eventName);
|
|
8117
|
+
}
|
|
8118
|
+
_getEventHandlers(eventName, eventTopic) {
|
|
8119
|
+
if (eventTopic) eventName = `${eventName}:${eventTopic}`;
|
|
8120
|
+
if (!this.eventHandlers.has(eventName)) this.eventHandlers.set(eventName, []);
|
|
8121
|
+
return this.eventHandlers.get(eventName);
|
|
8122
|
+
}
|
|
8123
|
+
on(eventName, eventHandler, eventTopic) {
|
|
8124
|
+
this._getEventHandlers(eventName, eventTopic).push(eventHandler);
|
|
8125
|
+
return () => {
|
|
8126
|
+
this.off(eventName, eventHandler, eventTopic);
|
|
8127
|
+
};
|
|
8128
|
+
}
|
|
8129
|
+
once(eventName, eventHandler, eventTopic) {
|
|
8130
|
+
const eventHandlerDecorator = (...args) => {
|
|
8131
|
+
eventHandler(...args);
|
|
8132
|
+
this.off(eventName, eventHandlerDecorator, eventTopic);
|
|
8133
|
+
};
|
|
8134
|
+
this.on(eventName, eventHandlerDecorator, eventTopic);
|
|
8135
|
+
return () => {
|
|
8136
|
+
this.off(eventName, eventHandlerDecorator, eventTopic);
|
|
8137
|
+
};
|
|
8138
|
+
}
|
|
8139
|
+
off(eventName, eventHandler, eventTopic) {
|
|
8140
|
+
const handlers = this._getEventHandlers(eventName, eventTopic);
|
|
8141
|
+
if (handlers) {
|
|
8142
|
+
const idx = handlers.indexOf(eventHandler);
|
|
8143
|
+
if (idx > -1) handlers.splice(idx, 1);
|
|
8144
|
+
}
|
|
8145
|
+
}
|
|
8146
|
+
broadcast(eventName, args) {
|
|
8147
|
+
this._callHandlers(eventName, void 0, args);
|
|
8148
|
+
}
|
|
8149
|
+
broadcastForTopic(eventName, eventTopic, args) {
|
|
8150
|
+
this._callHandlers(eventName, eventTopic, args);
|
|
8151
|
+
}
|
|
8152
|
+
registerEventlistener(eventbusListener) {
|
|
8153
|
+
this.eventListeners.push(eventbusListener);
|
|
8154
|
+
return () => {
|
|
8155
|
+
const index = this.eventListeners.indexOf(eventbusListener);
|
|
8156
|
+
if (index > -1) this.eventListeners.splice(index, 1);
|
|
8157
|
+
};
|
|
8158
|
+
}
|
|
8159
|
+
registerInterceptor(eventName, interceptor, eventTopic) {
|
|
8160
|
+
const interceptors = this._getEventInterceptors(eventName, eventTopic);
|
|
8161
|
+
interceptors.push(interceptor);
|
|
8162
|
+
return () => {
|
|
8163
|
+
const index = interceptors.indexOf(interceptor);
|
|
8164
|
+
if (index > -1) interceptors.splice(index, 1);
|
|
8165
|
+
};
|
|
8166
|
+
}
|
|
8167
|
+
onRequest(eventName, responder, eventTopic) {
|
|
8168
|
+
const responders = this._getRequestResponders(eventName, eventTopic);
|
|
8169
|
+
responders.push(responder);
|
|
8170
|
+
return () => {
|
|
8171
|
+
const index = responders.indexOf(responder);
|
|
8172
|
+
if (index > -1) responders.splice(index, 1);
|
|
8173
|
+
};
|
|
8174
|
+
}
|
|
8175
|
+
request(eventName, ...args) {
|
|
8176
|
+
return this._callResponder(eventName, void 0, args);
|
|
8177
|
+
}
|
|
8178
|
+
requestForTopic(eventName, eventTopic, ...args) {
|
|
8179
|
+
return this._callResponder(eventName, eventTopic, args);
|
|
8180
|
+
}
|
|
8181
|
+
_getRequestResponders(eventName, eventTopic) {
|
|
8182
|
+
if (eventTopic) eventName = `${eventName}:${eventTopic}`;
|
|
8183
|
+
if (!this.requestResponders.has(eventName)) this.requestResponders.set(eventName, []);
|
|
8184
|
+
return this.requestResponders.get(eventName);
|
|
8185
|
+
}
|
|
8186
|
+
_callResponder(eventName, eventTopic, args) {
|
|
8187
|
+
const responders = this._getRequestResponders(eventName, eventTopic);
|
|
8188
|
+
if (responders.length === 0) return;
|
|
8189
|
+
return responders[0](...args);
|
|
8190
|
+
}
|
|
8191
|
+
_callHandlers(eventName, eventTopic, args = []) {
|
|
8192
|
+
const handlers = this._getEventHandlers(eventName, eventTopic);
|
|
8193
|
+
if (handlers) {
|
|
8194
|
+
this._getEventInterceptors(eventName, eventTopic).forEach((interceptor) => {
|
|
8195
|
+
args = interceptor.intercept(args);
|
|
8196
|
+
});
|
|
8197
|
+
this.eventListeners.forEach((listener) => {
|
|
8198
|
+
listener.handleEvent(eventName, eventTopic, args);
|
|
8199
|
+
});
|
|
8200
|
+
if (args?.length) handlers.forEach((handler) => handler(...args));
|
|
8201
|
+
else handlers.forEach((handler) => handler());
|
|
8202
|
+
}
|
|
8203
|
+
}
|
|
8204
|
+
};
|
|
8440
8205
|
|
|
8441
8206
|
//#endregion
|
|
8442
|
-
//#region src/eventbus/
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8207
|
+
//#region src/eventbus/request-video-uri-interceptor.ts
|
|
8208
|
+
var RequestVideoUriInterceptor = class {
|
|
8209
|
+
constructor(eventbus$1) {
|
|
8210
|
+
this.eventbus = eventbus$1;
|
|
8211
|
+
}
|
|
8212
|
+
intercept(args) {
|
|
8213
|
+
this.eventbus.broadcast("before-request-timeline-uri", args.slice());
|
|
8214
|
+
return args;
|
|
8215
|
+
}
|
|
8216
|
+
};
|
|
8450
8217
|
|
|
8451
8218
|
//#endregion
|
|
8452
|
-
//#region src/eventbus/
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
};
|
|
8459
|
-
}
|
|
8219
|
+
//#region src/eventbus/index.ts
|
|
8220
|
+
var eventbus_exports = /* @__PURE__ */ __export({
|
|
8221
|
+
ActionRegistryEventbusListener: () => ActionRegistryEventbusListener,
|
|
8222
|
+
Eventbus: () => Eventbus,
|
|
8223
|
+
RequestVideoUriInterceptor: () => RequestVideoUriInterceptor
|
|
8224
|
+
});
|
|
8460
8225
|
|
|
8461
8226
|
//#endregion
|
|
8462
|
-
//#region src/
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8227
|
+
//#region src/timelineproviders/types.ts
|
|
8228
|
+
/**
|
|
8229
|
+
* Type guard to check if a position source is seekable.
|
|
8230
|
+
*
|
|
8231
|
+
* @param source - Position source to check
|
|
8232
|
+
* @returns `true` if source implements ISeekable
|
|
8233
|
+
*/
|
|
8234
|
+
function isSeekable(source) {
|
|
8235
|
+
return "seek" in source && typeof source.seek === "function";
|
|
8469
8236
|
}
|
|
8470
8237
|
|
|
8471
8238
|
//#endregion
|
|
8472
|
-
//#region src/
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8239
|
+
//#region src/timelineproviders/position-sources/base-position-source.ts
|
|
8240
|
+
/**
|
|
8241
|
+
* Abstract base class for position sources.
|
|
8242
|
+
*
|
|
8243
|
+
* Provides shared state management, lifecycle handling, and callback
|
|
8244
|
+
* registration for concrete position source implementations.
|
|
8245
|
+
*
|
|
8246
|
+
* Subclasses must implement:
|
|
8247
|
+
* - `doInit()` - Source-specific initialization
|
|
8248
|
+
* - `doDestroy()` - Source-specific cleanup
|
|
8249
|
+
* - `startTicking()` - Start emitting position updates
|
|
8250
|
+
* - `stopTicking()` - Stop emitting position updates
|
|
8251
|
+
*
|
|
8252
|
+
* @example
|
|
8253
|
+
* ```typescript
|
|
8254
|
+
* class MyPositionSource extends BasePositionSource {
|
|
8255
|
+
* protected doInit(): Promise<void> {
|
|
8256
|
+
* // Initialize resources
|
|
8257
|
+
* return Promise.resolve();
|
|
8258
|
+
* }
|
|
8259
|
+
*
|
|
8260
|
+
* protected doDestroy(): void {
|
|
8261
|
+
* // Clean up resources
|
|
8262
|
+
* }
|
|
8263
|
+
*
|
|
8264
|
+
* protected startTicking(): void {
|
|
8265
|
+
* // Start position updates
|
|
8266
|
+
* }
|
|
8267
|
+
*
|
|
8268
|
+
* protected stopTicking(): void {
|
|
8269
|
+
* // Stop position updates
|
|
8270
|
+
* }
|
|
8271
|
+
* }
|
|
8272
|
+
* ```
|
|
8273
|
+
*/
|
|
8274
|
+
var BasePositionSource = class {
|
|
8275
|
+
_state = "inactive";
|
|
8276
|
+
_position = 0;
|
|
8277
|
+
_duration;
|
|
8278
|
+
_loop = false;
|
|
8279
|
+
_positionCallbacks = [];
|
|
8280
|
+
_boundaryCallbacks = [];
|
|
8281
|
+
_activatedCallbacks = [];
|
|
8282
|
+
/**
|
|
8283
|
+
* Create a new position source.
|
|
8284
|
+
*
|
|
8285
|
+
* @param duration - Total duration in seconds (or `Infinity` for unbounded)
|
|
8286
|
+
*/
|
|
8287
|
+
constructor(duration) {
|
|
8288
|
+
this._duration = duration;
|
|
8289
|
+
}
|
|
8290
|
+
get state() {
|
|
8291
|
+
return this._state;
|
|
8292
|
+
}
|
|
8293
|
+
get loop() {
|
|
8294
|
+
return this._loop;
|
|
8295
|
+
}
|
|
8296
|
+
set loop(value) {
|
|
8297
|
+
this._loop = value;
|
|
8298
|
+
}
|
|
8299
|
+
async init() {
|
|
8300
|
+
await this.doInit();
|
|
8301
|
+
}
|
|
8302
|
+
destroy() {
|
|
8303
|
+
if (this._state === "active") this.stopTicking();
|
|
8304
|
+
this._state = "inactive";
|
|
8305
|
+
this._position = 0;
|
|
8306
|
+
this.doDestroy();
|
|
8307
|
+
}
|
|
8308
|
+
async activate() {
|
|
8309
|
+
if (this._state === "active") return;
|
|
8310
|
+
this._state = "active";
|
|
8311
|
+
this.startTicking();
|
|
8312
|
+
for (const callback of this._activatedCallbacks) callback();
|
|
8313
|
+
}
|
|
8314
|
+
suspend() {
|
|
8315
|
+
if (this._state !== "active") return;
|
|
8316
|
+
this._state = "suspended";
|
|
8317
|
+
this.stopTicking();
|
|
8318
|
+
}
|
|
8319
|
+
deactivate() {
|
|
8320
|
+
if (this._state === "inactive") return;
|
|
8321
|
+
if (this._state === "active") this.stopTicking();
|
|
8322
|
+
this._state = "inactive";
|
|
8323
|
+
this._position = 0;
|
|
8324
|
+
}
|
|
8325
|
+
getPosition() {
|
|
8326
|
+
return this._position;
|
|
8327
|
+
}
|
|
8328
|
+
getDuration() {
|
|
8329
|
+
return this._duration;
|
|
8330
|
+
}
|
|
8331
|
+
onPosition(callback) {
|
|
8332
|
+
this._positionCallbacks.push(callback);
|
|
8333
|
+
}
|
|
8334
|
+
onBoundaryReached(callback) {
|
|
8335
|
+
this._boundaryCallbacks.push(callback);
|
|
8336
|
+
}
|
|
8337
|
+
onActivated(callback) {
|
|
8338
|
+
this._activatedCallbacks.push(callback);
|
|
8339
|
+
}
|
|
8340
|
+
/**
|
|
8341
|
+
* Set the current position and emit to callbacks.
|
|
8342
|
+
*
|
|
8343
|
+
* Only emits if the source is active.
|
|
8344
|
+
*
|
|
8345
|
+
* @param position - New position value
|
|
8346
|
+
*/
|
|
8347
|
+
setPosition(position) {
|
|
8348
|
+
this._position = position;
|
|
8349
|
+
if (this._state === "active") for (const callback of this._positionCallbacks) callback(position);
|
|
8350
|
+
}
|
|
8351
|
+
/**
|
|
8352
|
+
* Emit a boundary event to all registered callbacks.
|
|
8353
|
+
*
|
|
8354
|
+
* @param boundary - The boundary type ('start' or 'end')
|
|
8355
|
+
*/
|
|
8356
|
+
emitBoundary(boundary) {
|
|
8357
|
+
for (const callback of this._boundaryCallbacks) callback(boundary);
|
|
8358
|
+
}
|
|
8359
|
+
};
|
|
8480
8360
|
|
|
8481
8361
|
//#endregion
|
|
8482
|
-
//#region src/
|
|
8483
|
-
function
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8362
|
+
//#region src/util/animation-interval.ts
|
|
8363
|
+
function animationInterval(ms, signal, callback) {
|
|
8364
|
+
const currentTime = document?.timeline?.currentTime;
|
|
8365
|
+
const start = currentTime ? Number(currentTime) : performance.now();
|
|
8366
|
+
const frame = (time) => {
|
|
8367
|
+
if (signal.aborted) return;
|
|
8368
|
+
callback(time);
|
|
8369
|
+
scheduleFrame(time);
|
|
8488
8370
|
};
|
|
8489
|
-
}
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
function timelineRestart() {
|
|
8494
|
-
return {
|
|
8495
|
-
description: `Event: timeline-restart`,
|
|
8496
|
-
category: `Timeline`,
|
|
8497
|
-
args: []
|
|
8371
|
+
const { round } = Math;
|
|
8372
|
+
const scheduleFrame = (time) => {
|
|
8373
|
+
const delay = start + round((time - start) / ms) * ms + ms - performance.now();
|
|
8374
|
+
setTimeout(() => requestAnimationFrame(frame), delay);
|
|
8498
8375
|
};
|
|
8376
|
+
scheduleFrame(start);
|
|
8499
8377
|
}
|
|
8500
8378
|
|
|
8501
8379
|
//#endregion
|
|
8502
|
-
//#region src/
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8380
|
+
//#region src/timelineproviders/position-sources/raf-position-source.ts
|
|
8381
|
+
/**
|
|
8382
|
+
* RequestAnimationFrame-based position source.
|
|
8383
|
+
*
|
|
8384
|
+
* Uses the `animationInterval` utility to emit position updates at a regular
|
|
8385
|
+
* interval (default: 1 second). Position increments by 1 per second, making
|
|
8386
|
+
* position values equivalent to elapsed seconds.
|
|
8387
|
+
*
|
|
8388
|
+
* Implements both `IPositionSource` (via `BasePositionSource`) and `ISeekable`.
|
|
8389
|
+
*
|
|
8390
|
+
* @example
|
|
8391
|
+
* ```typescript
|
|
8392
|
+
* const source = new RafPositionSource({ duration: 60 });
|
|
8393
|
+
* await source.init();
|
|
8394
|
+
*
|
|
8395
|
+
* source.onPosition((position) => {
|
|
8396
|
+
* console.log(`Position: ${position}s`);
|
|
8397
|
+
* });
|
|
8398
|
+
*
|
|
8399
|
+
* source.onBoundaryReached((boundary) => {
|
|
8400
|
+
* if (boundary === 'end') {
|
|
8401
|
+
* console.log('Timeline complete');
|
|
8402
|
+
* }
|
|
8403
|
+
* });
|
|
8404
|
+
*
|
|
8405
|
+
* await source.activate();
|
|
8406
|
+
*
|
|
8407
|
+
* // Seek to 30 seconds
|
|
8408
|
+
* await source.seek(30);
|
|
8409
|
+
* ```
|
|
8410
|
+
*/
|
|
8411
|
+
var RafPositionSource = class extends BasePositionSource {
|
|
8412
|
+
_tickInterval;
|
|
8413
|
+
_abortController = null;
|
|
8414
|
+
_startTimeOffset = 0;
|
|
8415
|
+
/**
|
|
8416
|
+
* Create a new RAF-based position source.
|
|
8417
|
+
*
|
|
8418
|
+
* @param config - Configuration options
|
|
8419
|
+
*/
|
|
8420
|
+
constructor(config) {
|
|
8421
|
+
super(config.duration);
|
|
8422
|
+
this._tickInterval = config.tickInterval ?? 1e3;
|
|
8423
|
+
}
|
|
8424
|
+
doInit() {
|
|
8425
|
+
return Promise.resolve();
|
|
8426
|
+
}
|
|
8427
|
+
doDestroy() {
|
|
8428
|
+
this._abortTicking();
|
|
8429
|
+
}
|
|
8430
|
+
startTicking() {
|
|
8431
|
+
this.setPosition(this.getPosition());
|
|
8432
|
+
this._abortController = new AbortController();
|
|
8433
|
+
animationInterval(this._tickInterval, this._abortController.signal, this._onTick.bind(this));
|
|
8434
|
+
}
|
|
8435
|
+
stopTicking() {
|
|
8436
|
+
this._abortTicking();
|
|
8437
|
+
}
|
|
8438
|
+
/**
|
|
8439
|
+
* Seek to a specific position.
|
|
8440
|
+
*
|
|
8441
|
+
* Position is clamped to the valid range [0, duration].
|
|
8442
|
+
*
|
|
8443
|
+
* @param position - Target position in seconds
|
|
8444
|
+
* @returns Actual position after seek (may be clamped)
|
|
8445
|
+
*/
|
|
8446
|
+
async seek(position) {
|
|
8447
|
+
const clampedPosition = Math.max(0, Math.min(position, this.getDuration()));
|
|
8448
|
+
this.setPosition(clampedPosition);
|
|
8449
|
+
return clampedPosition;
|
|
8450
|
+
}
|
|
8451
|
+
/**
|
|
8452
|
+
* Handle a tick from animationInterval.
|
|
8453
|
+
*
|
|
8454
|
+
* The time parameter represents elapsed milliseconds since the animation
|
|
8455
|
+
* interval started. Position is calculated in seconds, rounded to the
|
|
8456
|
+
* precision determined by tickInterval.
|
|
8457
|
+
*
|
|
8458
|
+
* @param time - Elapsed time in milliseconds from animationInterval
|
|
8459
|
+
*/
|
|
8460
|
+
_onTick(time) {
|
|
8461
|
+
if (this.state !== "active") return;
|
|
8462
|
+
const elapsedSinceStart = time - this._startTimeOffset;
|
|
8463
|
+
const newPosition = Math.floor(elapsedSinceStart / this._tickInterval) * this._tickInterval / 1e3;
|
|
8464
|
+
const duration = this.getDuration();
|
|
8465
|
+
if (newPosition >= duration) {
|
|
8466
|
+
this.emitBoundary("end");
|
|
8467
|
+
if (this.loop) {
|
|
8468
|
+
this._startTimeOffset = time;
|
|
8469
|
+
this.setPosition(0);
|
|
8470
|
+
this.emitBoundary("start");
|
|
8471
|
+
} else {
|
|
8472
|
+
this.setPosition(duration);
|
|
8473
|
+
this.deactivate();
|
|
8474
|
+
}
|
|
8475
|
+
} else this.setPosition(newPosition);
|
|
8476
|
+
}
|
|
8477
|
+
/**
|
|
8478
|
+
* Abort the current ticking session.
|
|
8479
|
+
*/
|
|
8480
|
+
_abortTicking() {
|
|
8481
|
+
if (this._abortController) {
|
|
8482
|
+
this._abortController.abort();
|
|
8483
|
+
this._abortController = null;
|
|
8484
|
+
}
|
|
8485
|
+
}
|
|
8486
|
+
};
|
|
8513
8487
|
|
|
8514
8488
|
//#endregion
|
|
8515
|
-
//#region src/
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8489
|
+
//#region src/timelineproviders/position-sources/scroll-position-source.ts
|
|
8490
|
+
/**
|
|
8491
|
+
* Scroll-based position source.
|
|
8492
|
+
*
|
|
8493
|
+
* Maps scroll position to a timeline position. The position is calculated
|
|
8494
|
+
* as a percentage of the scroll progress multiplied by the configured duration.
|
|
8495
|
+
*
|
|
8496
|
+
* Implements `IPositionSource` and `ISeekable`.
|
|
8497
|
+
*
|
|
8498
|
+
* @example
|
|
8499
|
+
* ```typescript
|
|
8500
|
+
* const source = new ScrollPositionSource({
|
|
8501
|
+
* selector: '#scroll-container',
|
|
8502
|
+
* duration: 100, // 100 seconds timeline
|
|
8503
|
+
* });
|
|
8504
|
+
*
|
|
8505
|
+
* await source.init();
|
|
8506
|
+
*
|
|
8507
|
+
* source.onPosition((position) => {
|
|
8508
|
+
* console.log(`Scroll at ${position}s of 100s`);
|
|
8509
|
+
* });
|
|
8510
|
+
*
|
|
8511
|
+
* source.onBoundaryReached((boundary) => {
|
|
8512
|
+
* if (boundary === 'end') {
|
|
8513
|
+
* console.log('Scrolled to bottom');
|
|
8514
|
+
* }
|
|
8515
|
+
* });
|
|
8516
|
+
*
|
|
8517
|
+
* await source.activate();
|
|
8518
|
+
* ```
|
|
8519
|
+
*/
|
|
8520
|
+
var ScrollPositionSource = class extends BasePositionSource {
|
|
8521
|
+
_config;
|
|
8522
|
+
_element = null;
|
|
8523
|
+
_boundScrollHandler = null;
|
|
8524
|
+
_lastPosition = 0;
|
|
8525
|
+
_wasAtStart = true;
|
|
8526
|
+
/**
|
|
8527
|
+
* Create a new scroll-based position source.
|
|
8528
|
+
*
|
|
8529
|
+
* @param config - Configuration options
|
|
8530
|
+
*/
|
|
8531
|
+
constructor(config) {
|
|
8532
|
+
super(config.duration);
|
|
8533
|
+
this._config = config;
|
|
8534
|
+
}
|
|
8535
|
+
doInit() {
|
|
8536
|
+
return new Promise((resolve, reject) => {
|
|
8537
|
+
const $element = $(this._config.selector);
|
|
8538
|
+
if ($element.length === 0) {
|
|
8539
|
+
reject(/* @__PURE__ */ new Error(`Element not found: ${this._config.selector}`));
|
|
8540
|
+
return;
|
|
8532
8541
|
}
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
}
|
|
8542
|
+
this._element = $element.get(0);
|
|
8543
|
+
resolve();
|
|
8544
|
+
});
|
|
8545
|
+
}
|
|
8546
|
+
doDestroy() {
|
|
8547
|
+
if (this._element && this._boundScrollHandler) {
|
|
8548
|
+
this._element.removeEventListener("scroll", this._boundScrollHandler, { passive: true });
|
|
8549
|
+
this._boundScrollHandler = null;
|
|
8550
|
+
}
|
|
8551
|
+
this._element = null;
|
|
8552
|
+
}
|
|
8553
|
+
startTicking() {
|
|
8554
|
+
if (!this._element) return;
|
|
8555
|
+
this._boundScrollHandler = this._handleScroll.bind(this);
|
|
8556
|
+
this._element.addEventListener("scroll", this._boundScrollHandler, { passive: true });
|
|
8557
|
+
}
|
|
8558
|
+
stopTicking() {
|
|
8559
|
+
if (this._element && this._boundScrollHandler) {
|
|
8560
|
+
this._element.removeEventListener("scroll", this._boundScrollHandler, { passive: true });
|
|
8561
|
+
this._boundScrollHandler = null;
|
|
8562
|
+
}
|
|
8563
|
+
}
|
|
8564
|
+
/**
|
|
8565
|
+
* Seek to a specific position by programmatically scrolling.
|
|
8566
|
+
*
|
|
8567
|
+
* @param position - Target position in seconds (0 to duration)
|
|
8568
|
+
* @returns Actual position after scroll
|
|
8569
|
+
*/
|
|
8570
|
+
async seek(position) {
|
|
8571
|
+
if (!this._element || this.state === "inactive") return this.getPosition();
|
|
8572
|
+
const scrollableHeight = this._getScrollableHeight();
|
|
8573
|
+
const targetScrollTop = position / this._config.duration * scrollableHeight;
|
|
8574
|
+
this._element.scrollTo({
|
|
8575
|
+
top: targetScrollTop,
|
|
8576
|
+
behavior: "smooth"
|
|
8577
|
+
});
|
|
8578
|
+
return position;
|
|
8579
|
+
}
|
|
8580
|
+
/**
|
|
8581
|
+
* Handle scroll events and update position.
|
|
8582
|
+
*/
|
|
8583
|
+
_handleScroll(_event) {
|
|
8584
|
+
if (this.state !== "active" || !this._element) return;
|
|
8585
|
+
const position = this._calculatePosition();
|
|
8586
|
+
const duration = this._config.duration;
|
|
8587
|
+
const previousPosition = this._lastPosition;
|
|
8588
|
+
this._lastPosition = position;
|
|
8589
|
+
this.setPosition(position);
|
|
8590
|
+
if (position >= duration && previousPosition < duration) {
|
|
8591
|
+
this.emitBoundary("end");
|
|
8592
|
+
if (this.loop) this._element.scrollTo({
|
|
8593
|
+
top: 0,
|
|
8594
|
+
behavior: "smooth"
|
|
8595
|
+
});
|
|
8596
|
+
}
|
|
8597
|
+
if (position === 0 && previousPosition > 0 && !this._wasAtStart) this.emitBoundary("start");
|
|
8598
|
+
this._wasAtStart = position === 0;
|
|
8599
|
+
}
|
|
8600
|
+
/**
|
|
8601
|
+
* Calculate position from scroll percentage.
|
|
8602
|
+
*/
|
|
8603
|
+
_calculatePosition() {
|
|
8604
|
+
if (!this._element) return 0;
|
|
8605
|
+
const scrollTop = this._element.scrollTop;
|
|
8606
|
+
const scrollableHeight = this._getScrollableHeight();
|
|
8607
|
+
if (scrollableHeight <= 0) return 0;
|
|
8608
|
+
return scrollTop / scrollableHeight * this._config.duration;
|
|
8609
|
+
}
|
|
8610
|
+
/**
|
|
8611
|
+
* Get the scrollable height (total scroll distance).
|
|
8612
|
+
*/
|
|
8613
|
+
_getScrollableHeight() {
|
|
8614
|
+
if (!this._element) return 0;
|
|
8615
|
+
return this._element.scrollHeight - this._element.clientHeight;
|
|
8616
|
+
}
|
|
8617
|
+
};
|
|
8536
8618
|
|
|
8537
8619
|
//#endregion
|
|
8538
|
-
//#region src/
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
}
|
|
8620
|
+
//#region src/timelineproviders/position-sources/video-position-source.ts
|
|
8621
|
+
const videojs = vjs.default ?? vjs;
|
|
8622
|
+
/**
|
|
8623
|
+
* Video.js-based position source.
|
|
8624
|
+
*
|
|
8625
|
+
* Wraps a video.js player to provide position updates based on video playback.
|
|
8626
|
+
* Implements `IPositionSource`, `ISeekable`, and `IContainerProvider`.
|
|
8627
|
+
*
|
|
8628
|
+
* @example
|
|
8629
|
+
* ```typescript
|
|
8630
|
+
* const source = new VideoPositionSource({
|
|
8631
|
+
* selector: '#video-container',
|
|
8632
|
+
* sources: [
|
|
8633
|
+
* { src: 'video.mp4', type: 'video/mp4' },
|
|
8634
|
+
* { src: 'video.webm', type: 'video/webm' },
|
|
8635
|
+
* ],
|
|
8636
|
+
* });
|
|
8637
|
+
*
|
|
8638
|
+
* await source.init();
|
|
8639
|
+
*
|
|
8640
|
+
* source.onPosition((position) => {
|
|
8641
|
+
* console.log(`Video at ${position}s`);
|
|
8642
|
+
* });
|
|
8643
|
+
*
|
|
8644
|
+
* source.onContainerReady(() => {
|
|
8645
|
+
* console.log('Video ready for display');
|
|
8646
|
+
* });
|
|
8647
|
+
*
|
|
8648
|
+
* await source.activate();
|
|
8649
|
+
* ```
|
|
8650
|
+
*/
|
|
8651
|
+
var VideoPositionSource = class extends BasePositionSource {
|
|
8652
|
+
_config;
|
|
8653
|
+
_player = null;
|
|
8654
|
+
_videoElementId;
|
|
8655
|
+
_containerReadyCallbacks = [];
|
|
8656
|
+
_eventHandlers = [];
|
|
8657
|
+
/**
|
|
8658
|
+
* Create a new video.js-based position source.
|
|
8659
|
+
*
|
|
8660
|
+
* @param config - Configuration options
|
|
8661
|
+
*/
|
|
8662
|
+
constructor(config) {
|
|
8663
|
+
super(0);
|
|
8664
|
+
this._config = config;
|
|
8665
|
+
this._videoElementId = `video-${crypto.randomUUID?.() ?? Math.random().toString(36).slice(2)}`;
|
|
8666
|
+
}
|
|
8667
|
+
doInit() {
|
|
8668
|
+
return new Promise((resolve) => {
|
|
8669
|
+
this._createVideoElement();
|
|
8670
|
+
setTimeout(() => {
|
|
8671
|
+
this._player = videojs(this._videoElementId, {
|
|
8672
|
+
controls: false,
|
|
8673
|
+
controlBar: false,
|
|
8674
|
+
liveui: false,
|
|
8675
|
+
autoplay: false,
|
|
8676
|
+
preload: "auto",
|
|
8677
|
+
loop: this.loop,
|
|
8678
|
+
sources: this._config.sources,
|
|
8679
|
+
...this._config.options
|
|
8680
|
+
}, () => {
|
|
8681
|
+
if (this._player) {
|
|
8682
|
+
this._addPlayerListener("timeupdate", this._handleTimeUpdate.bind(this));
|
|
8683
|
+
this._addPlayerListener("ended", this._handleEnded.bind(this));
|
|
8684
|
+
this._player.one("firstplay", () => {
|
|
8685
|
+
this._notifyContainerReady();
|
|
8686
|
+
});
|
|
8687
|
+
this._player.one("canplay", () => {
|
|
8688
|
+
resolve();
|
|
8689
|
+
});
|
|
8690
|
+
this._player.load();
|
|
8691
|
+
}
|
|
8692
|
+
});
|
|
8693
|
+
}, 0);
|
|
8694
|
+
});
|
|
8695
|
+
}
|
|
8696
|
+
doDestroy() {
|
|
8697
|
+
for (const removeHandler of this._eventHandlers) removeHandler();
|
|
8698
|
+
this._eventHandlers.length = 0;
|
|
8699
|
+
if (this._player) {
|
|
8700
|
+
this._player.dispose?.();
|
|
8701
|
+
this._player = null;
|
|
8702
|
+
}
|
|
8703
|
+
$(`#${this._videoElementId}`).remove();
|
|
8704
|
+
}
|
|
8705
|
+
startTicking() {
|
|
8706
|
+
this._player?.play();
|
|
8707
|
+
}
|
|
8708
|
+
stopTicking() {
|
|
8709
|
+
this._player?.pause();
|
|
8710
|
+
}
|
|
8711
|
+
/**
|
|
8712
|
+
* Seek to a specific position in the video.
|
|
8713
|
+
*
|
|
8714
|
+
* @param position - Target position in seconds
|
|
8715
|
+
* @returns Actual position after seek
|
|
8716
|
+
*/
|
|
8717
|
+
async seek(position) {
|
|
8718
|
+
if (!this._player) return this.getPosition();
|
|
8719
|
+
return new Promise((resolve) => {
|
|
8720
|
+
this._player.one("seeked", () => {
|
|
8721
|
+
const actualPosition = this._player?.currentTime() ?? 0;
|
|
8722
|
+
this.setPosition(actualPosition);
|
|
8723
|
+
resolve(actualPosition);
|
|
8724
|
+
});
|
|
8725
|
+
this._player.currentTime(position);
|
|
8726
|
+
});
|
|
8727
|
+
}
|
|
8728
|
+
/**
|
|
8729
|
+
* Get the container element.
|
|
8730
|
+
*
|
|
8731
|
+
* @returns jQuery-wrapped container element
|
|
8732
|
+
*/
|
|
8733
|
+
getContainer() {
|
|
8734
|
+
return $(this._config.selector);
|
|
8735
|
+
}
|
|
8736
|
+
/**
|
|
8737
|
+
* Register a callback for when the container is ready.
|
|
8738
|
+
*
|
|
8739
|
+
* @param callback - Function called when container is ready
|
|
8740
|
+
*/
|
|
8741
|
+
onContainerReady(callback) {
|
|
8742
|
+
this._containerReadyCallbacks.push(callback);
|
|
8743
|
+
}
|
|
8744
|
+
/**
|
|
8745
|
+
* Get the video duration.
|
|
8746
|
+
*
|
|
8747
|
+
* @returns Duration in seconds from video.js player
|
|
8748
|
+
*/
|
|
8749
|
+
getDuration() {
|
|
8750
|
+
return this._player?.duration() ?? 0;
|
|
8751
|
+
}
|
|
8752
|
+
/**
|
|
8753
|
+
* Deactivate the source and reset position.
|
|
8754
|
+
*
|
|
8755
|
+
* Overrides base to also reset video currentTime.
|
|
8756
|
+
*/
|
|
8757
|
+
deactivate() {
|
|
8758
|
+
if (this.state === "inactive") return;
|
|
8759
|
+
if (this.state === "active") this.stopTicking();
|
|
8760
|
+
this._player?.currentTime(0);
|
|
8761
|
+
super.deactivate();
|
|
8762
|
+
}
|
|
8763
|
+
/**
|
|
8764
|
+
* Create the video element in the container.
|
|
8765
|
+
*/
|
|
8766
|
+
_createVideoElement() {
|
|
8767
|
+
const $container = $(this._config.selector);
|
|
8768
|
+
const videoHtml = `<video id="${this._videoElementId}" class="video-js"></video>`;
|
|
8769
|
+
$container.append(videoHtml);
|
|
8770
|
+
}
|
|
8771
|
+
/**
|
|
8772
|
+
* Add an event listener to the player and track for cleanup.
|
|
8773
|
+
*
|
|
8774
|
+
* @param event - Event name
|
|
8775
|
+
* @param handler - Event handler
|
|
8776
|
+
*/
|
|
8777
|
+
_addPlayerListener(event, handler) {
|
|
8778
|
+
if (this._player) {
|
|
8779
|
+
this._player.on(event, handler);
|
|
8780
|
+
this._eventHandlers.push(() => {
|
|
8781
|
+
this._player?.off(event, handler);
|
|
8782
|
+
});
|
|
8783
|
+
}
|
|
8784
|
+
}
|
|
8785
|
+
/**
|
|
8786
|
+
* Handle timeupdate event from video.js.
|
|
8787
|
+
*/
|
|
8788
|
+
_handleTimeUpdate() {
|
|
8789
|
+
if (this.state !== "active" || !this._player) return;
|
|
8790
|
+
const currentTime = this._player.currentTime();
|
|
8791
|
+
if (currentTime !== void 0) this.setPosition(currentTime);
|
|
8792
|
+
}
|
|
8793
|
+
/**
|
|
8794
|
+
* Handle ended event from video.js.
|
|
8795
|
+
*/
|
|
8796
|
+
_handleEnded() {
|
|
8797
|
+
if (this.state !== "active") return;
|
|
8798
|
+
this.emitBoundary("end");
|
|
8799
|
+
if (this.loop) {
|
|
8800
|
+
this._player?.currentTime(0);
|
|
8801
|
+
this.setPosition(0);
|
|
8802
|
+
this.emitBoundary("start");
|
|
8803
|
+
this._player?.play();
|
|
8804
|
+
} else this.deactivate();
|
|
8805
|
+
}
|
|
8806
|
+
/**
|
|
8807
|
+
* Notify all container ready callbacks.
|
|
8808
|
+
*/
|
|
8809
|
+
_notifyContainerReady() {
|
|
8810
|
+
for (const callback of this._containerReadyCallbacks) callback();
|
|
8811
|
+
}
|
|
8812
|
+
};
|
|
8552
8813
|
|
|
8553
8814
|
//#endregion
|
|
8554
|
-
//#region src/
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8815
|
+
//#region src/timelineproviders/container-providers/dom-container-provider.ts
|
|
8816
|
+
/**
|
|
8817
|
+
* DOM selector-based container provider.
|
|
8818
|
+
*
|
|
8819
|
+
* Provides access to a DOM container element via a CSS selector.
|
|
8820
|
+
* Implements `IContainerProvider` for use with position sources that
|
|
8821
|
+
* don't have an intrinsic container (e.g., RAF-based sources, WebSocket sources).
|
|
8822
|
+
*
|
|
8823
|
+
* @example
|
|
8824
|
+
* ```typescript
|
|
8825
|
+
* const containerProvider = new DomContainerProvider({
|
|
8826
|
+
* selector: '#timeline-container',
|
|
8827
|
+
* });
|
|
8828
|
+
*
|
|
8829
|
+
* containerProvider.onContainerReady(() => {
|
|
8830
|
+
* const $container = containerProvider.getContainer();
|
|
8831
|
+
* $container?.append('<div class="content">Ready!</div>');
|
|
8832
|
+
* });
|
|
8833
|
+
*
|
|
8834
|
+
* await containerProvider.init();
|
|
8835
|
+
* ```
|
|
8836
|
+
*/
|
|
8837
|
+
var DomContainerProvider = class {
|
|
8838
|
+
_config;
|
|
8839
|
+
_container;
|
|
8840
|
+
_isReady = false;
|
|
8841
|
+
_isDestroyed = false;
|
|
8842
|
+
_readyCallbacks = [];
|
|
8843
|
+
/**
|
|
8844
|
+
* Create a new DOM container provider.
|
|
8845
|
+
*
|
|
8846
|
+
* @param config - Configuration options
|
|
8847
|
+
*/
|
|
8848
|
+
constructor(config) {
|
|
8849
|
+
this._config = config;
|
|
8850
|
+
}
|
|
8851
|
+
/**
|
|
8852
|
+
* Initialize the container provider.
|
|
8853
|
+
*
|
|
8854
|
+
* Looks up the container element using the configured selector.
|
|
8855
|
+
*
|
|
8856
|
+
* @throws Error if the element is not found
|
|
8857
|
+
*/
|
|
8858
|
+
async init() {
|
|
8859
|
+
if (this._isReady) return;
|
|
8860
|
+
const $element = $(this._config.selector);
|
|
8861
|
+
if ($element.length === 0) throw new Error(`Container element not found: ${this._config.selector}`);
|
|
8862
|
+
this._container = $element;
|
|
8863
|
+
this._isReady = true;
|
|
8864
|
+
this._notifyReady();
|
|
8865
|
+
}
|
|
8866
|
+
/**
|
|
8867
|
+
* Destroy the container provider and release resources.
|
|
8868
|
+
*/
|
|
8869
|
+
destroy() {
|
|
8870
|
+
this._container = void 0;
|
|
8871
|
+
this._isReady = false;
|
|
8872
|
+
this._isDestroyed = true;
|
|
8873
|
+
this._readyCallbacks.length = 0;
|
|
8874
|
+
}
|
|
8875
|
+
/**
|
|
8876
|
+
* Get the container element.
|
|
8877
|
+
*
|
|
8878
|
+
* @returns jQuery-wrapped container element, or `undefined` if not initialized
|
|
8879
|
+
*/
|
|
8880
|
+
getContainer() {
|
|
8881
|
+
return this._container;
|
|
8882
|
+
}
|
|
8883
|
+
/**
|
|
8884
|
+
* Register a callback for when the container is ready.
|
|
8885
|
+
*
|
|
8886
|
+
* If the container is already ready, the callback is invoked immediately.
|
|
8887
|
+
*
|
|
8888
|
+
* @param callback - Function called when container is ready
|
|
8889
|
+
*/
|
|
8890
|
+
onContainerReady(callback) {
|
|
8891
|
+
if (this._isDestroyed) return;
|
|
8892
|
+
if (this._isReady) callback();
|
|
8893
|
+
else this._readyCallbacks.push(callback);
|
|
8894
|
+
}
|
|
8895
|
+
/**
|
|
8896
|
+
* Notify all registered ready callbacks.
|
|
8897
|
+
*/
|
|
8898
|
+
_notifyReady() {
|
|
8899
|
+
for (const callback of this._readyCallbacks) callback();
|
|
8900
|
+
}
|
|
8901
|
+
};
|
|
8562
8902
|
|
|
8563
8903
|
//#endregion
|
|
8564
|
-
//#region src/
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8904
|
+
//#region src/timelineproviders/playlist/simple-playlist.ts
|
|
8905
|
+
/**
|
|
8906
|
+
* Simple playlist implementation.
|
|
8907
|
+
*
|
|
8908
|
+
* Manages a collection of timeline items and allows switching between them.
|
|
8909
|
+
* Implements `IPlaylist<TItem>` for use with timeline providers that
|
|
8910
|
+
* support multiple content sources.
|
|
8911
|
+
*
|
|
8912
|
+
* @typeParam TItem - Type of playlist items
|
|
8913
|
+
*
|
|
8914
|
+
* @example
|
|
8915
|
+
* ```typescript
|
|
8916
|
+
* interface VideoItem {
|
|
8917
|
+
* id: string;
|
|
8918
|
+
* uri: string;
|
|
8919
|
+
* title: string;
|
|
8920
|
+
* }
|
|
8921
|
+
*
|
|
8922
|
+
* const playlist = new SimplePlaylist<VideoItem>({
|
|
8923
|
+
* items: [
|
|
8924
|
+
* { id: 'intro', uri: '/videos/intro.mp4', title: 'Introduction' },
|
|
8925
|
+
* { id: 'ch1', uri: '/videos/chapter-1.mp4', title: 'Chapter 1' },
|
|
8926
|
+
* ],
|
|
8927
|
+
* identifierKey: 'id',
|
|
8928
|
+
* });
|
|
8929
|
+
*
|
|
8930
|
+
* playlist.onItemChange((item) => {
|
|
8931
|
+
* console.log(`Now playing: ${item.title}`);
|
|
8932
|
+
* });
|
|
8933
|
+
*
|
|
8934
|
+
* playlist.selectItem('ch1');
|
|
8935
|
+
* ```
|
|
8936
|
+
*/
|
|
8937
|
+
var SimplePlaylist = class {
|
|
8938
|
+
_items;
|
|
8939
|
+
_identifierKey;
|
|
8940
|
+
_currentIndex = 0;
|
|
8941
|
+
_changeCallbacks = [];
|
|
8942
|
+
/**
|
|
8943
|
+
* Create a new simple playlist.
|
|
8944
|
+
*
|
|
8945
|
+
* @param config - Configuration options
|
|
8946
|
+
* @throws Error if items array is empty
|
|
8947
|
+
*/
|
|
8948
|
+
constructor(config) {
|
|
8949
|
+
if (!config.items || config.items.length === 0) throw new Error("Playlist must have at least one item");
|
|
8950
|
+
this._items = Object.freeze([...config.items]);
|
|
8951
|
+
this._identifierKey = config.identifierKey;
|
|
8952
|
+
}
|
|
8953
|
+
/**
|
|
8954
|
+
* Get the currently active item.
|
|
8955
|
+
*/
|
|
8956
|
+
get currentItem() {
|
|
8957
|
+
return this._items[this._currentIndex];
|
|
8958
|
+
}
|
|
8959
|
+
/**
|
|
8960
|
+
* Get all items in the playlist.
|
|
8961
|
+
*
|
|
8962
|
+
* Returns a readonly array to prevent external modification.
|
|
8963
|
+
*/
|
|
8964
|
+
get items() {
|
|
8965
|
+
return this._items;
|
|
8966
|
+
}
|
|
8967
|
+
/**
|
|
8968
|
+
* Select an item by identifier.
|
|
8969
|
+
*
|
|
8970
|
+
* Looks up the item using the configured identifier key and switches
|
|
8971
|
+
* to it if found. Triggers item change callbacks if the selection changes.
|
|
8972
|
+
*
|
|
8973
|
+
* @param identifier - Unique identifier for the item
|
|
8974
|
+
* @throws Error if no item matches the identifier
|
|
8975
|
+
*/
|
|
8976
|
+
selectItem(identifier) {
|
|
8977
|
+
const index = this._items.findIndex((item) => String(item[this._identifierKey]) === identifier);
|
|
8978
|
+
if (index === -1) throw new Error(`Playlist item not found: ${identifier}`);
|
|
8979
|
+
if (index !== this._currentIndex) {
|
|
8980
|
+
this._currentIndex = index;
|
|
8981
|
+
this._notifyChange();
|
|
8982
|
+
}
|
|
8983
|
+
}
|
|
8984
|
+
/**
|
|
8985
|
+
* Register a callback for item changes.
|
|
8986
|
+
*
|
|
8987
|
+
* Called whenever the current item changes via `selectItem()`.
|
|
8988
|
+
*
|
|
8989
|
+
* @param callback - Function receiving the new current item
|
|
8990
|
+
*/
|
|
8991
|
+
onItemChange(callback) {
|
|
8992
|
+
this._changeCallbacks.push(callback);
|
|
8993
|
+
}
|
|
8994
|
+
/**
|
|
8995
|
+
* Notify all registered change callbacks.
|
|
8996
|
+
*/
|
|
8997
|
+
_notifyChange() {
|
|
8998
|
+
const currentItem = this.currentItem;
|
|
8999
|
+
for (const callback of this._changeCallbacks) callback(currentItem);
|
|
9000
|
+
}
|
|
9001
|
+
};
|
|
8572
9002
|
|
|
8573
9003
|
//#endregion
|
|
8574
|
-
//#region src/
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
}
|
|
9004
|
+
//#region src/timelineproviders/index.ts
|
|
9005
|
+
var timelineproviders_exports = /* @__PURE__ */ __export({
|
|
9006
|
+
BasePositionSource: () => BasePositionSource,
|
|
9007
|
+
DomContainerProvider: () => DomContainerProvider,
|
|
9008
|
+
RafPositionSource: () => RafPositionSource,
|
|
9009
|
+
ScrollPositionSource: () => ScrollPositionSource,
|
|
9010
|
+
SimplePlaylist: () => SimplePlaylist,
|
|
9011
|
+
VideoPositionSource: () => VideoPositionSource,
|
|
9012
|
+
isSeekable: () => isSeekable
|
|
9013
|
+
});
|
|
8585
9014
|
|
|
8586
9015
|
//#endregion
|
|
8587
|
-
//#region src/
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
9016
|
+
//#region src/util/typed-event-emitter.ts
|
|
9017
|
+
/**
|
|
9018
|
+
* Type-safe event emitter implementation
|
|
9019
|
+
*
|
|
9020
|
+
* Features:
|
|
9021
|
+
* - Generic type parameter for event map
|
|
9022
|
+
* - Handler execution order preserved (registration order)
|
|
9023
|
+
* - Errors in handlers caught and logged (don't break other handlers)
|
|
9024
|
+
* - Copy handlers array during emit (safe removal during iteration)
|
|
9025
|
+
*
|
|
9026
|
+
* @example
|
|
9027
|
+
* ```typescript
|
|
9028
|
+
* interface MyEvents {
|
|
9029
|
+
* start: [];
|
|
9030
|
+
* data: [value: string];
|
|
9031
|
+
* progress: [current: number, total: number];
|
|
9032
|
+
* }
|
|
9033
|
+
*
|
|
9034
|
+
* const emitter = new TypedEventEmitter<MyEvents>();
|
|
9035
|
+
*
|
|
9036
|
+
* const unsubscribe = emitter.on('data', (value) => {
|
|
9037
|
+
* console.log('Received:', value);
|
|
9038
|
+
* });
|
|
9039
|
+
*
|
|
9040
|
+
* emitter.emit('data', 'hello');
|
|
9041
|
+
* unsubscribe();
|
|
9042
|
+
* ```
|
|
9043
|
+
*/
|
|
9044
|
+
var TypedEventEmitter = class {
|
|
9045
|
+
handlers = /* @__PURE__ */ new Map();
|
|
9046
|
+
/**
|
|
9047
|
+
* Subscribe to an event
|
|
9048
|
+
* @param event - Event name
|
|
9049
|
+
* @param handler - Event handler
|
|
9050
|
+
* @returns Unsubscribe function
|
|
9051
|
+
*/
|
|
9052
|
+
on(event, handler) {
|
|
9053
|
+
if (!this.handlers.has(event)) this.handlers.set(event, []);
|
|
9054
|
+
this.handlers.get(event).push(handler);
|
|
9055
|
+
return () => this.off(event, handler);
|
|
9056
|
+
}
|
|
9057
|
+
/**
|
|
9058
|
+
* Subscribe to an event for one-time execution
|
|
9059
|
+
* @param event - Event name
|
|
9060
|
+
* @param handler - Event handler
|
|
9061
|
+
* @returns Unsubscribe function
|
|
9062
|
+
*/
|
|
9063
|
+
once(event, handler) {
|
|
9064
|
+
const onceHandler = (...args) => {
|
|
9065
|
+
this.off(event, onceHandler);
|
|
9066
|
+
handler(...args);
|
|
9067
|
+
};
|
|
9068
|
+
return this.on(event, onceHandler);
|
|
9069
|
+
}
|
|
9070
|
+
/**
|
|
9071
|
+
* Unsubscribe from an event
|
|
9072
|
+
* @param event - Event name
|
|
9073
|
+
* @param handler - Event handler to remove
|
|
9074
|
+
*/
|
|
9075
|
+
off(event, handler) {
|
|
9076
|
+
const eventHandlers = this.handlers.get(event);
|
|
9077
|
+
if (!eventHandlers) return;
|
|
9078
|
+
const index = eventHandlers.indexOf(handler);
|
|
9079
|
+
if (index !== -1) eventHandlers.splice(index, 1);
|
|
9080
|
+
}
|
|
9081
|
+
/**
|
|
9082
|
+
* Emit an event to all subscribers
|
|
9083
|
+
*
|
|
9084
|
+
* Features:
|
|
9085
|
+
* - Copies handlers array to allow safe removal during iteration
|
|
9086
|
+
* - Isolates errors - one failing handler doesn't break others
|
|
9087
|
+
* - Logs errors to console for debugging
|
|
9088
|
+
*
|
|
9089
|
+
* @param event - Event name
|
|
9090
|
+
* @param args - Event arguments
|
|
9091
|
+
*/
|
|
9092
|
+
emit(event, ...args) {
|
|
9093
|
+
const eventHandlers = this.handlers.get(event);
|
|
9094
|
+
if (!eventHandlers || eventHandlers.length === 0) return;
|
|
9095
|
+
const handlersCopy = [...eventHandlers];
|
|
9096
|
+
for (const handler of handlersCopy) try {
|
|
9097
|
+
handler(...args);
|
|
9098
|
+
} catch (error) {
|
|
9099
|
+
console.error(`Error in event handler for "${String(event)}":`, error);
|
|
9100
|
+
}
|
|
9101
|
+
}
|
|
9102
|
+
/**
|
|
9103
|
+
* Remove all listeners for a specific event or all events
|
|
9104
|
+
* @param event - Optional event name. If not provided, removes all listeners.
|
|
9105
|
+
*/
|
|
9106
|
+
removeAllListeners(event) {
|
|
9107
|
+
if (event !== void 0) this.handlers.delete(event);
|
|
9108
|
+
else this.handlers.clear();
|
|
9109
|
+
}
|
|
9110
|
+
};
|
|
8598
9111
|
|
|
8599
9112
|
//#endregion
|
|
8600
|
-
//#region src/
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
}
|
|
9113
|
+
//#region src/eligius-engine.ts
|
|
9114
|
+
/**
|
|
9115
|
+
* Type guard to check if a position source supports seeking.
|
|
9116
|
+
*/
|
|
9117
|
+
function isSeekable$1(source) {
|
|
9118
|
+
return "seek" in source && typeof source.seek === "function";
|
|
9119
|
+
}
|
|
9120
|
+
/**
|
|
9121
|
+
* Maps position source state to engine play state.
|
|
9122
|
+
*/
|
|
9123
|
+
function mapSourceStateToPlayState(sourceState) {
|
|
9124
|
+
switch (sourceState) {
|
|
9125
|
+
case "active": return "playing";
|
|
9126
|
+
case "suspended": return "paused";
|
|
9127
|
+
case "inactive": return "stopped";
|
|
9128
|
+
}
|
|
9129
|
+
}
|
|
9130
|
+
/**
|
|
9131
|
+
* The Eligius timeline engine with explicit, testable API.
|
|
9132
|
+
*
|
|
9133
|
+
* This engine is responsible for starting and stopping the given timeline provider
|
|
9134
|
+
* and triggering the actions associated with positions along the timeline.
|
|
9135
|
+
*/
|
|
9136
|
+
var EligiusEngine = class EligiusEngine {
|
|
9137
|
+
_timeLineActionsLookup = {};
|
|
9138
|
+
_timelineLookupCache = /* @__PURE__ */ new Map();
|
|
9139
|
+
_eventbusRemovers = [];
|
|
9140
|
+
_currentTimelineUri = "";
|
|
9141
|
+
_activePositionSource = void 0;
|
|
9142
|
+
_activeContainerProvider = void 0;
|
|
9143
|
+
_activePlaylist = void 0;
|
|
9144
|
+
_lastPosition = -1;
|
|
9145
|
+
_emitter = new TypedEventEmitter();
|
|
9146
|
+
/** Current timeline position in seconds (supports fractional values) */
|
|
9147
|
+
get position() {
|
|
9148
|
+
return this._activePositionSource?.getPosition() ?? 0;
|
|
9149
|
+
}
|
|
9150
|
+
/** Timeline duration in seconds, undefined if not yet available */
|
|
9151
|
+
get duration() {
|
|
9152
|
+
return this._activePositionSource?.getDuration();
|
|
9153
|
+
}
|
|
9154
|
+
/** Current playback state (derived from position source state) */
|
|
9155
|
+
get playState() {
|
|
9156
|
+
if (!this._activePositionSource) return "stopped";
|
|
9157
|
+
return mapSourceStateToPlayState(this._activePositionSource.state);
|
|
9158
|
+
}
|
|
9159
|
+
/** URI of the currently active timeline */
|
|
9160
|
+
get currentTimelineUri() {
|
|
9161
|
+
return this._currentTimelineUri;
|
|
9162
|
+
}
|
|
9163
|
+
/** Container element for the active timeline provider */
|
|
9164
|
+
get container() {
|
|
9165
|
+
return this._activeContainerProvider?.getContainer();
|
|
9166
|
+
}
|
|
9167
|
+
/** Root element of the engine (container selector) */
|
|
9168
|
+
get engineRoot() {
|
|
9169
|
+
return $(this.configuration.containerSelector);
|
|
9170
|
+
}
|
|
9171
|
+
constructor(configuration, eventbus$1, timelineProviders, languageManager) {
|
|
9172
|
+
this.configuration = configuration;
|
|
9173
|
+
this.eventbus = eventbus$1;
|
|
9174
|
+
this.timelineProviders = timelineProviders;
|
|
9175
|
+
this.languageManager = languageManager;
|
|
9176
|
+
}
|
|
9177
|
+
/**
|
|
9178
|
+
* Subscribe to engine events
|
|
9179
|
+
* @param event - Event name
|
|
9180
|
+
* @param handler - Event handler
|
|
9181
|
+
* @returns Unsubscribe function
|
|
9182
|
+
*/
|
|
9183
|
+
on(event, handler) {
|
|
9184
|
+
return this._emitter.on(event, handler);
|
|
9185
|
+
}
|
|
9186
|
+
/**
|
|
9187
|
+
* Start playback
|
|
9188
|
+
* @throws If autoplay is blocked (video provider)
|
|
9189
|
+
*/
|
|
9190
|
+
async start() {
|
|
9191
|
+
if (!this._activePositionSource) return;
|
|
9192
|
+
await this._activePositionSource.activate();
|
|
9193
|
+
this._emitter.emit("start");
|
|
9194
|
+
this.eventbus.broadcast("timeline-play", []);
|
|
9195
|
+
}
|
|
9196
|
+
/**
|
|
9197
|
+
* Pause playback
|
|
9198
|
+
*/
|
|
9199
|
+
pause() {
|
|
9200
|
+
if (!this._activePositionSource) return;
|
|
9201
|
+
this._activePositionSource.suspend();
|
|
9202
|
+
this._emitter.emit("pause");
|
|
9203
|
+
this.eventbus.broadcast("timeline-pause", []);
|
|
9204
|
+
}
|
|
9205
|
+
/**
|
|
9206
|
+
* Stop playback and reset to beginning
|
|
9207
|
+
*/
|
|
9208
|
+
stop() {
|
|
9209
|
+
if (!this._activePositionSource) return;
|
|
9210
|
+
this._activePositionSource.deactivate();
|
|
9211
|
+
this._emitter.emit("stop");
|
|
9212
|
+
this.eventbus.broadcast("timeline-stop", []);
|
|
9213
|
+
}
|
|
9214
|
+
/**
|
|
9215
|
+
* Seek to a specific position
|
|
9216
|
+
* @param position - Target position in seconds
|
|
9217
|
+
* @returns Actual position after seek
|
|
9218
|
+
*/
|
|
9219
|
+
async seek(position) {
|
|
9220
|
+
if (!this._activePositionSource) return 0;
|
|
9221
|
+
const seekPosition = position;
|
|
9222
|
+
const duration = this._activePositionSource.getDuration();
|
|
9223
|
+
const currentPosition = this._activePositionSource.getPosition();
|
|
9224
|
+
if (seekPosition < 0 || seekPosition > duration) return currentPosition;
|
|
9225
|
+
this._emitter.emit("seekStart", seekPosition, currentPosition, duration);
|
|
9226
|
+
this.eventbus.broadcast("timeline-seek", [
|
|
9227
|
+
seekPosition,
|
|
9228
|
+
currentPosition,
|
|
9229
|
+
duration
|
|
9230
|
+
]);
|
|
9231
|
+
if (isSeekable$1(this._activePositionSource)) await this._activePositionSource.seek(seekPosition);
|
|
9232
|
+
await this._executeSeekActions(seekPosition);
|
|
9233
|
+
const finalPosition = this._activePositionSource.getPosition();
|
|
9234
|
+
this._emitter.emit("seekComplete", finalPosition, duration);
|
|
9235
|
+
this.eventbus.broadcast("timeline-seeked", [finalPosition, duration]);
|
|
9236
|
+
this._emitter.emit("time", finalPosition);
|
|
9237
|
+
this.eventbus.broadcast("timeline-time", [finalPosition]);
|
|
9238
|
+
if (this._activePositionSource.state === "active") await this._activePositionSource.activate();
|
|
9239
|
+
return finalPosition;
|
|
9240
|
+
}
|
|
9241
|
+
/**
|
|
9242
|
+
* Switch to a different timeline
|
|
9243
|
+
* @param uri - Timeline URI to switch to
|
|
9244
|
+
* @param position - Optional starting position
|
|
9245
|
+
*/
|
|
9246
|
+
async switchTimeline(uri, position = 0) {
|
|
9247
|
+
if (!this._activePositionSource) return;
|
|
9248
|
+
const timelineConfig = this._timelineLookupCache.get(uri);
|
|
9249
|
+
if (!timelineConfig || this._currentTimelineUri === timelineConfig.uri) return;
|
|
9250
|
+
this._activePositionSource.deactivate();
|
|
9251
|
+
await this._cleanUpTimeline();
|
|
9252
|
+
this._currentTimelineUri = timelineConfig.uri;
|
|
9253
|
+
this._emitter.emit("timelineChange", this._currentTimelineUri);
|
|
9254
|
+
this.eventbus.broadcast("timeline-current-timeline-change", [this._currentTimelineUri]);
|
|
9255
|
+
const newProviderSettings = this.timelineProviders[timelineConfig.type];
|
|
9256
|
+
if (this._activePositionSource !== newProviderSettings.positionSource) {
|
|
9257
|
+
this._activePositionSource.destroy();
|
|
9258
|
+
this._activePositionSource = newProviderSettings.positionSource;
|
|
9259
|
+
this._activeContainerProvider = newProviderSettings.containerProvider;
|
|
9260
|
+
this._activePlaylist = newProviderSettings.playlist;
|
|
9261
|
+
}
|
|
9262
|
+
this._activePositionSource.loop = timelineConfig.loop;
|
|
9263
|
+
if (!this._activePositionSource.loop && position > 0) this.eventbus.once("timeline-firstframe", async () => {
|
|
9264
|
+
if (!this._activePositionSource) return;
|
|
9265
|
+
this._activePositionSource.suspend();
|
|
9266
|
+
this.eventbus.broadcast("timeline-duration", [this._activePositionSource.getDuration]);
|
|
9267
|
+
await this._executeStartActions();
|
|
9268
|
+
if (isSeekable$1(this._activePositionSource)) await this._activePositionSource.seek(position);
|
|
9269
|
+
await this._executeSeekActions(position);
|
|
9270
|
+
});
|
|
9271
|
+
if (this._activePlaylist) this._activePlaylist.selectItem(uri);
|
|
9272
|
+
}
|
|
9273
|
+
/**
|
|
9274
|
+
* Initializes the engine by creating the HTML layout and the first time line
|
|
9275
|
+
* by executing its initActions.
|
|
9276
|
+
*/
|
|
9277
|
+
init() {
|
|
9278
|
+
this._createLayoutTemplate();
|
|
9279
|
+
this._addEventbusListeners();
|
|
9280
|
+
const { timelines } = this.configuration;
|
|
9281
|
+
this._currentTimelineUri = timelines?.[0].uri ?? "";
|
|
9282
|
+
this._createTimelineLookup();
|
|
9283
|
+
return this._initializeTimelineProvider();
|
|
9284
|
+
}
|
|
9285
|
+
_createLayoutTemplate() {
|
|
9286
|
+
const { containerSelector } = this.configuration;
|
|
9287
|
+
const container = $(containerSelector);
|
|
9288
|
+
if (!container || !container.length) throw new Error(`Container selector not found: ${containerSelector}`);
|
|
9289
|
+
const { layoutTemplate } = this.configuration;
|
|
9290
|
+
if (layoutTemplate?.length) container.html(layoutTemplate);
|
|
9291
|
+
else console.warn("layoutTemplate is empty, unable to create layout");
|
|
9292
|
+
}
|
|
9293
|
+
async _initializeTimelineProvider() {
|
|
9294
|
+
if (!this.configuration.timelines?.length) throw new Error("No timelines present");
|
|
9295
|
+
const firstTimeline = this.configuration.timelines[0];
|
|
9296
|
+
const providerSettings = this.timelineProviders[firstTimeline.type];
|
|
9297
|
+
if (!providerSettings) throw new Error(`No timeline provider configured for type ${firstTimeline.type}`);
|
|
9298
|
+
this._activePositionSource?.destroy();
|
|
9299
|
+
this._activePositionSource = providerSettings.positionSource;
|
|
9300
|
+
this._activeContainerProvider = providerSettings.containerProvider;
|
|
9301
|
+
this._activePlaylist = providerSettings.playlist;
|
|
9302
|
+
if (!this._activePositionSource) throw new Error("NO ACTIVE POSITION SOURCE");
|
|
9303
|
+
this._activePositionSource.onPosition(this._onTimeHandler.bind(this, (x) => x));
|
|
9304
|
+
this._activePositionSource.onBoundaryReached((boundary) => {
|
|
9305
|
+
if (boundary === "end") this._onCompleteCallback();
|
|
9306
|
+
else if (boundary === "start") this._onRestartCallback();
|
|
9307
|
+
});
|
|
9308
|
+
this._activePositionSource.onActivated(this._onFirstFrameCallback.bind(this));
|
|
9309
|
+
await this._activePositionSource.init();
|
|
9310
|
+
await this._executeActions(this.configuration.initActions, "start");
|
|
9311
|
+
this._emitter.emit("initialized");
|
|
9312
|
+
return this._activePositionSource;
|
|
9313
|
+
}
|
|
9314
|
+
_onCompleteCallback() {
|
|
9315
|
+
this._emitter.emit("timelineComplete");
|
|
9316
|
+
this.eventbus.broadcast("timeline-complete", []);
|
|
9317
|
+
}
|
|
9318
|
+
_onFirstFrameCallback() {
|
|
9319
|
+
this._emitter.emit("timelineFirstFrame");
|
|
9320
|
+
this.eventbus.broadcast("timeline-firstframe", []);
|
|
9321
|
+
const duration = this._activePositionSource?.getDuration();
|
|
9322
|
+
if (duration !== void 0) this._emitter.emit("duration", duration);
|
|
9323
|
+
this.eventbus.broadcast("timeline-duration", [this._activePositionSource?.getDuration]);
|
|
9324
|
+
}
|
|
9325
|
+
_onRestartCallback() {
|
|
9326
|
+
this._emitter.emit("timelineRestart");
|
|
9327
|
+
this.eventbus.broadcast("timeline-restart", []);
|
|
9328
|
+
}
|
|
9329
|
+
async _cleanUp() {
|
|
9330
|
+
await this._cleanUpTimeline();
|
|
9331
|
+
await this._executeActions([...this.configuration.initActions].reverse(), "end");
|
|
9332
|
+
}
|
|
9333
|
+
/**
|
|
9334
|
+
* Cleans up all the necessary parts that the engine initialized.
|
|
9335
|
+
* - It ends the currently active operations and the init actions.
|
|
9336
|
+
* - It removes all its eventbus listeners, handlers and interceptors.
|
|
9337
|
+
* - It destroys all of its timeline providers
|
|
9338
|
+
* - It empties the HTML element indicated by the containerSelector configuration property.
|
|
9339
|
+
*
|
|
9340
|
+
*/
|
|
9341
|
+
async destroy() {
|
|
9342
|
+
await this._cleanUp();
|
|
9343
|
+
this.languageManager.destroy();
|
|
9344
|
+
this._activePositionSource = void 0;
|
|
9345
|
+
this._activeContainerProvider = void 0;
|
|
9346
|
+
this._activePlaylist = void 0;
|
|
9347
|
+
this._eventbusRemovers.forEach((remover) => remover());
|
|
9348
|
+
if (this.timelineProviders) Object.values(this.timelineProviders).forEach((providerInfo) => providerInfo.positionSource.destroy());
|
|
9349
|
+
const { containerSelector } = this.configuration;
|
|
9350
|
+
$(containerSelector).empty();
|
|
9351
|
+
this._emitter.emit("destroyed");
|
|
9352
|
+
this._emitter.removeAllListeners();
|
|
9353
|
+
}
|
|
9354
|
+
_addEventListener(eventName, eventHandler, eventTopic) {
|
|
9355
|
+
this._eventbusRemovers.push(this.eventbus.on(eventName, eventHandler, eventTopic));
|
|
9356
|
+
}
|
|
9357
|
+
_addEventbusListeners() {
|
|
9358
|
+
this._addEventListener("request-engine-root", this._handleRequestEngineRoot.bind(this, this.configuration.containerSelector));
|
|
9359
|
+
this._addEventListener("request-timeline-uri", this._handleRequestTimelineUri.bind(this));
|
|
9360
|
+
this._addEventListener("request-current-timeline-position", this._handleRequestTimelinePosition.bind(this, (x) => x));
|
|
9361
|
+
this._addEventListener("request-timeline-cleanup", this._handleTimelineComplete.bind(this));
|
|
9362
|
+
this._addEventListener("timeline-request-current-timeline", this._requestCurrentTimeline.bind(this));
|
|
9363
|
+
this._addEventListener("timeline-play-toggle-request", this._toggleplay.bind(this));
|
|
9364
|
+
this._addEventListener("timeline-play-request", this._playRequest.bind(this));
|
|
9365
|
+
this._addEventListener("timeline-stop-request", this._stopRequest.bind(this));
|
|
9366
|
+
this._addEventListener("timeline-pause-request", this._pauseRequest.bind(this));
|
|
9367
|
+
this._addEventListener("timeline-container-request", this._containerRequest.bind(this));
|
|
9368
|
+
this._addEventListener("timeline-duration-request", this._durationRequest.bind(this));
|
|
9369
|
+
this._addEventListener("timeline-seek-request", this._seekRequest.bind(this));
|
|
9370
|
+
}
|
|
9371
|
+
async _seekRequest(position) {
|
|
9372
|
+
await this.seek(position);
|
|
9373
|
+
}
|
|
9374
|
+
_durationRequest(callBack) {
|
|
9375
|
+
callBack(this.duration);
|
|
9376
|
+
}
|
|
9377
|
+
_containerRequest(callBack) {
|
|
9378
|
+
callBack(this.container);
|
|
9379
|
+
}
|
|
9380
|
+
_pauseRequest() {
|
|
9381
|
+
this.pause();
|
|
9382
|
+
}
|
|
9383
|
+
_stopRequest() {
|
|
9384
|
+
this.stop();
|
|
9385
|
+
}
|
|
9386
|
+
async _playRequest() {
|
|
9387
|
+
await this.start();
|
|
9388
|
+
}
|
|
9389
|
+
async _toggleplay() {
|
|
9390
|
+
if (this._activePositionSource?.state === "active") this.pause();
|
|
9391
|
+
else await this.start();
|
|
9392
|
+
}
|
|
9393
|
+
_createTimelineLookup() {
|
|
9394
|
+
if (!this.configuration.timelines) return;
|
|
9395
|
+
this.configuration.timelines.forEach((timelineInfo) => {
|
|
9396
|
+
this._timelineLookupCache.set(timelineInfo.uri, timelineInfo);
|
|
9397
|
+
timelineInfo.timelineActions.forEach((timelineAction) => {
|
|
9398
|
+
this._addTimelineActionStart(timelineInfo.uri, timelineAction);
|
|
9399
|
+
this._addTimelineActionEnd(timelineInfo.uri, timelineAction);
|
|
9400
|
+
});
|
|
9401
|
+
});
|
|
9402
|
+
EligiusEngine.sortTimelines(Object.values(this._timeLineActionsLookup));
|
|
9403
|
+
}
|
|
9404
|
+
static sortTimelines(timelines) {
|
|
9405
|
+
timelines.forEach((timelineActions) => {
|
|
9406
|
+
Object.keys(timelineActions).forEach((key) => {
|
|
9407
|
+
const numericKey = Number(key);
|
|
9408
|
+
timelineActions[numericKey] = EligiusEngine.sortActionsPerPosition(timelineActions[numericKey]);
|
|
9409
|
+
});
|
|
9410
|
+
});
|
|
9411
|
+
}
|
|
9412
|
+
static sortActionsPerPosition(actions) {
|
|
9413
|
+
const [startMethods, endMethods] = actions.reduce((acc, item) => {
|
|
9414
|
+
if (item.isStart) acc[0].push(item);
|
|
9415
|
+
else acc[1].push(item);
|
|
9416
|
+
return acc;
|
|
9417
|
+
}, [[], []]);
|
|
9418
|
+
return [...endMethods.sort(sortActionMethodsHighestStartPositionFirst), ...startMethods];
|
|
9419
|
+
}
|
|
9420
|
+
_addTimelineActionStart(uri, timeLineAction) {
|
|
9421
|
+
const startPosition = timeLineAction.duration.start;
|
|
9422
|
+
const timelineStartPositions = this._initializeTimelinePosition(this._initializeUriLookup(this._timeLineActionsLookup, uri), startPosition);
|
|
9423
|
+
const startMethod = timeLineAction.start.bind(timeLineAction);
|
|
9424
|
+
if (timeLineAction.id?.length) startMethod.id = timeLineAction.id;
|
|
9425
|
+
startMethod.isStart = true;
|
|
9426
|
+
timelineStartPositions.push(startMethod);
|
|
9427
|
+
}
|
|
9428
|
+
_addTimelineActionEnd(uri, timeLineAction) {
|
|
9429
|
+
let end = timeLineAction.duration.end;
|
|
9430
|
+
if (end < 0) end = timeLineAction.duration.end = Infinity;
|
|
9431
|
+
if (Number.isFinite(end)) {
|
|
9432
|
+
const timelineEndPositions = this._initializeTimelinePosition(this._timeLineActionsLookup[uri], end);
|
|
9433
|
+
const endMethod = timeLineAction.end.bind(timeLineAction);
|
|
9434
|
+
if (timeLineAction.id?.length) {
|
|
9435
|
+
endMethod.id = timeLineAction.id;
|
|
9436
|
+
endMethod.startPosition = timeLineAction.duration.start;
|
|
9437
|
+
}
|
|
9438
|
+
endMethod.isStart = false;
|
|
9439
|
+
timelineEndPositions.push(endMethod);
|
|
9440
|
+
}
|
|
9441
|
+
}
|
|
9442
|
+
_initializeUriLookup(lookup, uri) {
|
|
9443
|
+
if (!lookup[uri]) lookup[uri] = {};
|
|
9444
|
+
return lookup[uri];
|
|
9445
|
+
}
|
|
9446
|
+
_initializeTimelinePosition(lookup, position) {
|
|
9447
|
+
if (!lookup[position]) lookup[position] = [];
|
|
9448
|
+
return lookup[position];
|
|
9449
|
+
}
|
|
9450
|
+
async _executeActions(actions, methodName) {
|
|
9451
|
+
if (actions.length === 0) return;
|
|
9452
|
+
for (const action of actions) await action[methodName]();
|
|
9453
|
+
}
|
|
9454
|
+
_handleRequestEngineRoot(engineRootSelector, resultCallback) {
|
|
9455
|
+
resultCallback($(engineRootSelector));
|
|
9456
|
+
}
|
|
9457
|
+
async _handleRequestTimelineUri(uri, position = 0) {
|
|
9458
|
+
await this.switchTimeline(uri, position);
|
|
9459
|
+
}
|
|
9460
|
+
_cleanUpTimeline() {
|
|
9461
|
+
return this._executeRelevantActions(this._getActiveActions, "end");
|
|
9462
|
+
}
|
|
9463
|
+
_executeStartActions() {
|
|
9464
|
+
return this._executeRelevantActions(this._getActionsForPosition.bind(this, 0), "start");
|
|
9465
|
+
}
|
|
9466
|
+
/**
|
|
9467
|
+
* Gets all of the inactive actions whose duration falls within the given timeline position.
|
|
9468
|
+
*
|
|
9469
|
+
* @param position the given position
|
|
9470
|
+
* @param actions all of the relevant actions
|
|
9471
|
+
* @returns
|
|
9472
|
+
*/
|
|
9473
|
+
_getActionsForPosition(position, actions) {
|
|
9474
|
+
return actions.filter((action) => !action.active && action.duration.start <= position && action.duration.end >= position);
|
|
9475
|
+
}
|
|
9476
|
+
_getActiveActions(allActions) {
|
|
9477
|
+
return allActions.filter((action) => action.active).sort(sortActionsHighestStartPositionFirst);
|
|
9478
|
+
}
|
|
9479
|
+
_executeRelevantActions(filter, executionType) {
|
|
9480
|
+
const timelineActions = this._getTimelineActionsForCurrentTimeline();
|
|
9481
|
+
const currentActions = filter.apply(this, [timelineActions]);
|
|
9482
|
+
return this._executeActions(currentActions, executionType);
|
|
9483
|
+
}
|
|
9484
|
+
_handleRequestTimelinePosition(floor, resultCallback) {
|
|
9485
|
+
resultCallback(floor(this._activePositionSource?.getPosition() || -1));
|
|
9486
|
+
}
|
|
9487
|
+
_handleTimelineComplete() {
|
|
9488
|
+
this._cleanUpTimeline();
|
|
9489
|
+
}
|
|
9490
|
+
_getTimelineActionsForCurrentTimeline() {
|
|
9491
|
+
return this._getTimelineActionsForUri(this._currentTimelineUri);
|
|
9492
|
+
}
|
|
9493
|
+
_requestCurrentTimeline(resultCallback) {
|
|
9494
|
+
resultCallback(this._currentTimelineUri);
|
|
9495
|
+
}
|
|
9496
|
+
_getTimelineActionsForUri(uri) {
|
|
9497
|
+
return this._timelineLookupCache.get(uri)?.timelineActions ?? [];
|
|
9498
|
+
}
|
|
9499
|
+
_onTimeHandler(floor, position) {
|
|
9500
|
+
if (!Number.isNaN(position)) {
|
|
9501
|
+
const pos = floor(position);
|
|
9502
|
+
if (this._lastPosition !== pos) {
|
|
9503
|
+
this._executeActionsForPosition(pos);
|
|
9504
|
+
this._emitter.emit("time", pos);
|
|
9505
|
+
this.eventbus.broadcast("timeline-time", [pos]);
|
|
9506
|
+
}
|
|
9507
|
+
}
|
|
9508
|
+
}
|
|
9509
|
+
_executeActionsForPosition(position) {
|
|
9510
|
+
this._lastPosition = position;
|
|
9511
|
+
const actions = this._timeLineActionsLookup[this._currentTimelineUri];
|
|
9512
|
+
if (actions) actions[position]?.forEach((exec) => exec());
|
|
9513
|
+
}
|
|
9514
|
+
async _executeSeekActions(position) {
|
|
9515
|
+
const timelineActions = this._getTimelineActionsForCurrentTimeline();
|
|
9516
|
+
const currentActions = this._getActiveActions(timelineActions).filter((action) => !(action.duration.start <= position && action.duration.end >= position));
|
|
9517
|
+
const newActions = this._getActionsForPosition(position, timelineActions);
|
|
9518
|
+
await this._executeActions(currentActions, "end");
|
|
9519
|
+
await this._executeActions(newActions, "start");
|
|
9520
|
+
}
|
|
9521
|
+
};
|
|
9522
|
+
const sortActionsHighestStartPositionFirst = (a, b) => b.duration.start - a.duration.start;
|
|
9523
|
+
const sortActionMethodsHighestStartPositionFirst = (a, b) => {
|
|
9524
|
+
if (a.startPosition === void 0 || b.startPosition === void 0) return 0;
|
|
9525
|
+
return b.startPosition - a.startPosition;
|
|
9526
|
+
};
|
|
8646
9527
|
|
|
8647
9528
|
//#endregion
|
|
8648
9529
|
//#region src/importer/eligius-resource-importer.ts
|
|
@@ -8671,5 +9552,300 @@ var EligiusResourceImporter = class {
|
|
|
8671
9552
|
};
|
|
8672
9553
|
|
|
8673
9554
|
//#endregion
|
|
8674
|
-
|
|
9555
|
+
//#region src/operation/helper/set-global.ts
|
|
9556
|
+
function setGlobal(name, value) {
|
|
9557
|
+
const cache$2 = getGlobals();
|
|
9558
|
+
cache$2[name] = value;
|
|
9559
|
+
}
|
|
9560
|
+
|
|
9561
|
+
//#endregion
|
|
9562
|
+
//#region src/language-manager.ts
|
|
9563
|
+
/**
|
|
9564
|
+
* Manages multi-language labels with explicit, testable API.
|
|
9565
|
+
*
|
|
9566
|
+
* This class manages the labels for an {@link IEligiusEngine} instance.
|
|
9567
|
+
* It provides a pure API for language management and emits events for language changes.
|
|
9568
|
+
*
|
|
9569
|
+
* Eventbus integration is handled by LanguageEventbusAdapter.
|
|
9570
|
+
*/
|
|
9571
|
+
var LanguageManager = class {
|
|
9572
|
+
_labelLookup;
|
|
9573
|
+
_emitter = new TypedEventEmitter();
|
|
9574
|
+
_availableLanguages = [];
|
|
9575
|
+
/** Current language code (e.g., 'en-US', 'nl-NL') */
|
|
9576
|
+
get language() {
|
|
9577
|
+
return this._currentLanguage;
|
|
9578
|
+
}
|
|
9579
|
+
/** List of available language codes, derived from unique languages in label collections */
|
|
9580
|
+
get availableLanguages() {
|
|
9581
|
+
return this._availableLanguages;
|
|
9582
|
+
}
|
|
9583
|
+
constructor(_currentLanguage, labels) {
|
|
9584
|
+
this._currentLanguage = _currentLanguage;
|
|
9585
|
+
if (!_currentLanguage) throw new Error("language ctor arg cannot have zero length");
|
|
9586
|
+
setGlobal("defaultLanguage", _currentLanguage);
|
|
9587
|
+
this._labelLookup = this._createLabelLookup(labels);
|
|
9588
|
+
this._availableLanguages = this._extractAvailableLanguages(labels);
|
|
9589
|
+
}
|
|
9590
|
+
/**
|
|
9591
|
+
* Subscribe to language manager events
|
|
9592
|
+
* @param event - Event name
|
|
9593
|
+
* @param handler - Event handler
|
|
9594
|
+
* @returns Unsubscribe function
|
|
9595
|
+
*/
|
|
9596
|
+
on(event, handler) {
|
|
9597
|
+
return this._emitter.on(event, handler);
|
|
9598
|
+
}
|
|
9599
|
+
/**
|
|
9600
|
+
* Change the current language
|
|
9601
|
+
* @param language - New language code
|
|
9602
|
+
* @throws If language code is empty or null
|
|
9603
|
+
*/
|
|
9604
|
+
setLanguage(language) {
|
|
9605
|
+
if (!language || language.length === 0) throw new Error("Language cannot be empty");
|
|
9606
|
+
const previousLanguage = this._currentLanguage;
|
|
9607
|
+
this._currentLanguage = language;
|
|
9608
|
+
this._emitter.emit("change", language, previousLanguage);
|
|
9609
|
+
}
|
|
9610
|
+
/**
|
|
9611
|
+
* Get a label collection by ID
|
|
9612
|
+
* @param collectionId - Label collection ID
|
|
9613
|
+
* @returns Label array or undefined if not found
|
|
9614
|
+
*/
|
|
9615
|
+
getLabelCollection(collectionId) {
|
|
9616
|
+
return this._labelLookup[collectionId];
|
|
9617
|
+
}
|
|
9618
|
+
/**
|
|
9619
|
+
* Get multiple label collections by IDs
|
|
9620
|
+
* @param collectionIds - Array of label collection IDs
|
|
9621
|
+
* @returns Array of label arrays (undefined for not found collections)
|
|
9622
|
+
*/
|
|
9623
|
+
getLabelCollections(collectionIds) {
|
|
9624
|
+
return collectionIds.map((id) => this._labelLookup[id]);
|
|
9625
|
+
}
|
|
9626
|
+
/**
|
|
9627
|
+
* Clean up resources
|
|
9628
|
+
*/
|
|
9629
|
+
destroy() {
|
|
9630
|
+
this._emitter.removeAllListeners();
|
|
9631
|
+
}
|
|
9632
|
+
_createLabelLookup(labels) {
|
|
9633
|
+
return labels.reduce((acc, label) => {
|
|
9634
|
+
acc[label.id] = label.labels;
|
|
9635
|
+
return acc;
|
|
9636
|
+
}, {});
|
|
9637
|
+
}
|
|
9638
|
+
_extractAvailableLanguages(labels) {
|
|
9639
|
+
const languages = /* @__PURE__ */ new Set();
|
|
9640
|
+
for (const labelCollection of labels) for (const label of labelCollection.labels) languages.add(label.languageCode);
|
|
9641
|
+
return Array.from(languages);
|
|
9642
|
+
}
|
|
9643
|
+
};
|
|
9644
|
+
|
|
9645
|
+
//#endregion
|
|
9646
|
+
//#region src/engine-factory.ts
|
|
9647
|
+
/**
|
|
9648
|
+
* The EngineFactory is used to create and initialize an {@link IEligiusEngine} instance.
|
|
9649
|
+
*
|
|
9650
|
+
* It prepares a resolved configuration and creates the engine based on the class defined in the configuration.
|
|
9651
|
+
*
|
|
9652
|
+
* @example Loading a configuration and creating an IEligiusEngine instance
|
|
9653
|
+
* ```ts
|
|
9654
|
+
* import { IEngineConfiguration, EngineFactory, EligiusResourceImporter } from 'eligius';
|
|
9655
|
+
* import * as engineConfig from './my-eligius-config.json';
|
|
9656
|
+
*
|
|
9657
|
+
* const factory = new EngineFactory(new EligiusResourceImporter(), window);
|
|
9658
|
+
*
|
|
9659
|
+
* const { engine } = factory.createEngine((engineConfig as unknown) as IEngineConfiguration);
|
|
9660
|
+
*
|
|
9661
|
+
* engine.init().then(()=> {console.log('Eligius engine ready for business');});
|
|
9662
|
+
* ```
|
|
9663
|
+
*/
|
|
9664
|
+
var EngineFactory = class {
|
|
9665
|
+
_actionsLookup = {};
|
|
9666
|
+
_eventbus;
|
|
9667
|
+
_eventRemovers = [];
|
|
9668
|
+
_importer;
|
|
9669
|
+
_windowRef;
|
|
9670
|
+
constructor(importer, windowRef, options) {
|
|
9671
|
+
this._importer = importer;
|
|
9672
|
+
this._windowRef = windowRef;
|
|
9673
|
+
this._eventbus = options?.eventbus ?? new Eventbus();
|
|
9674
|
+
this._eventRemovers.push(this._eventbus.onRequest("request-instance", this._requestInstanceHandler.bind(this)));
|
|
9675
|
+
this._eventRemovers.push(this._eventbus.onRequest("request-action", this._requestActionHandler.bind(this)));
|
|
9676
|
+
this._eventRemovers.push(this._eventbus.onRequest("request-function", this._requestFunctionHandler.bind(this)));
|
|
9677
|
+
}
|
|
9678
|
+
/**
|
|
9679
|
+
* Destroys the factory and cleans up all registered request handlers.
|
|
9680
|
+
*/
|
|
9681
|
+
destroy() {
|
|
9682
|
+
this._eventRemovers.forEach((x) => x());
|
|
9683
|
+
this._eventRemovers = [];
|
|
9684
|
+
this._actionsLookup = {};
|
|
9685
|
+
}
|
|
9686
|
+
_importSystemEntryWithEventbusDependency(systemName) {
|
|
9687
|
+
return new (this._importSystemEntry(systemName))(this._eventbus);
|
|
9688
|
+
}
|
|
9689
|
+
_importSystemEntry(systemName) {
|
|
9690
|
+
const entry = this._importer.import(systemName)?.[systemName];
|
|
9691
|
+
if (!entry) throw new Error(`Failed to import '${systemName}': module does not export '${systemName}'`);
|
|
9692
|
+
return entry;
|
|
9693
|
+
}
|
|
9694
|
+
_requestInstanceHandler(systemName) {
|
|
9695
|
+
return this._importSystemEntryWithEventbusDependency(systemName);
|
|
9696
|
+
}
|
|
9697
|
+
_requestFunctionHandler(systemName) {
|
|
9698
|
+
return this._importSystemEntry(systemName);
|
|
9699
|
+
}
|
|
9700
|
+
_requestActionHandler(systemName) {
|
|
9701
|
+
const action = this._actionsLookup[systemName];
|
|
9702
|
+
if (action) return action;
|
|
9703
|
+
else {
|
|
9704
|
+
console.error(`Unknown action: ${systemName}`);
|
|
9705
|
+
return null;
|
|
9706
|
+
}
|
|
9707
|
+
}
|
|
9708
|
+
/**
|
|
9709
|
+
* Creates a fully wired engine with adapters and event handlers.
|
|
9710
|
+
*
|
|
9711
|
+
* This method:
|
|
9712
|
+
* - Resolves the configuration
|
|
9713
|
+
* - Creates timeline providers
|
|
9714
|
+
* - Instantiates the engine and language manager
|
|
9715
|
+
* - Creates and connects adapters for eventbus integration
|
|
9716
|
+
*
|
|
9717
|
+
* @param configuration - The engine configuration
|
|
9718
|
+
* @param resolver - Optional custom configuration resolver
|
|
9719
|
+
* @returns Engine result with engine, language manager, eventbus, and destroy function
|
|
9720
|
+
*/
|
|
9721
|
+
createEngine(configuration, resolver) {
|
|
9722
|
+
const { systemName } = configuration.engine;
|
|
9723
|
+
const EngineClass = this._importSystemEntry(systemName);
|
|
9724
|
+
let actionRegistryListener;
|
|
9725
|
+
if (configuration.eventActions?.length) {
|
|
9726
|
+
actionRegistryListener = new ActionRegistryEventbusListener();
|
|
9727
|
+
this._eventRemovers.push(this._eventbus.registerEventlistener(actionRegistryListener));
|
|
9728
|
+
}
|
|
9729
|
+
this._eventRemovers.push(this._eventbus.registerInterceptor("request-timeline-uri", new RequestVideoUriInterceptor(this._eventbus)));
|
|
9730
|
+
resolver = resolver || new ConfigurationResolver(this._importer, this._eventbus);
|
|
9731
|
+
const [actionLookup, resolvedConfiguration] = resolver.process(configuration, actionRegistryListener);
|
|
9732
|
+
this._actionsLookup = actionLookup;
|
|
9733
|
+
const timelineProviders = this._createTimelineProviders(resolvedConfiguration);
|
|
9734
|
+
const { language, labels } = configuration;
|
|
9735
|
+
const languageManager = new LanguageManager(language, labels);
|
|
9736
|
+
const engineInstance = new EngineClass(resolvedConfiguration, this._eventbus, timelineProviders, languageManager);
|
|
9737
|
+
const engineEventbusAdapter = new EngineEventbusAdapter(engineInstance, this._eventbus);
|
|
9738
|
+
const languageEventbusAdapter = new LanguageEventbusAdapter(languageManager, this._eventbus, engineInstance);
|
|
9739
|
+
const engineInputAdapter = new EngineInputAdapter(engineInstance, this._eventbus, this._windowRef);
|
|
9740
|
+
engineEventbusAdapter.connect();
|
|
9741
|
+
languageEventbusAdapter.connect();
|
|
9742
|
+
engineInputAdapter.connect();
|
|
9743
|
+
return {
|
|
9744
|
+
engine: engineInstance,
|
|
9745
|
+
languageManager,
|
|
9746
|
+
eventbus: this._eventbus,
|
|
9747
|
+
destroy: async () => {
|
|
9748
|
+
engineInputAdapter.disconnect();
|
|
9749
|
+
languageEventbusAdapter.disconnect();
|
|
9750
|
+
engineEventbusAdapter.disconnect();
|
|
9751
|
+
await engineInstance.destroy();
|
|
9752
|
+
}
|
|
9753
|
+
};
|
|
9754
|
+
}
|
|
9755
|
+
_createTimelineProviders(configuration) {
|
|
9756
|
+
return this.createTimelineProvidersForConfig(configuration);
|
|
9757
|
+
}
|
|
9758
|
+
/**
|
|
9759
|
+
* Creates a position source for a specific timeline based on configuration.
|
|
9760
|
+
*
|
|
9761
|
+
* The position source class is resolved dynamically via the resource importer
|
|
9762
|
+
* using the `systemName` property from the configuration.
|
|
9763
|
+
*
|
|
9764
|
+
* @param timeline - The resolved timeline configuration
|
|
9765
|
+
* @param settings - The timeline provider settings containing position source config
|
|
9766
|
+
* @returns A configured position source
|
|
9767
|
+
* @throws Error if the position source class cannot be resolved
|
|
9768
|
+
*/
|
|
9769
|
+
createPositionSourceForTimeline(timeline, settings) {
|
|
9770
|
+
const { systemName, ...options } = settings.positionSource;
|
|
9771
|
+
return new (this._importSystemEntry(systemName))({
|
|
9772
|
+
...options,
|
|
9773
|
+
duration: timeline.duration
|
|
9774
|
+
});
|
|
9775
|
+
}
|
|
9776
|
+
/**
|
|
9777
|
+
* Creates a container provider based on timeline provider settings.
|
|
9778
|
+
*
|
|
9779
|
+
* The container provider class is resolved dynamically via the resource importer
|
|
9780
|
+
* using the `systemName` property from the configuration.
|
|
9781
|
+
*
|
|
9782
|
+
* @param settings - The timeline provider settings
|
|
9783
|
+
* @returns A container provider, or undefined if not configured
|
|
9784
|
+
* @throws Error if the container provider class cannot be resolved
|
|
9785
|
+
*/
|
|
9786
|
+
createContainerProviderForTimeline(settings) {
|
|
9787
|
+
if (!settings.container) return;
|
|
9788
|
+
const { systemName, ...options } = settings.container;
|
|
9789
|
+
return new (this._importSystemEntry(systemName))(options);
|
|
9790
|
+
}
|
|
9791
|
+
/**
|
|
9792
|
+
* Creates a playlist based on timeline provider settings.
|
|
9793
|
+
*
|
|
9794
|
+
* The playlist class is resolved dynamically via the resource importer
|
|
9795
|
+
* using the `systemName` property from the configuration.
|
|
9796
|
+
*
|
|
9797
|
+
* @param settings - The timeline provider settings
|
|
9798
|
+
* @returns A playlist, or undefined if not configured
|
|
9799
|
+
* @throws Error if the playlist class cannot be resolved
|
|
9800
|
+
*/
|
|
9801
|
+
createPlaylistForTimeline(settings) {
|
|
9802
|
+
if (!settings.playlist) return;
|
|
9803
|
+
const { systemName, ...options } = settings.playlist;
|
|
9804
|
+
return new (this._importSystemEntry(systemName))(options);
|
|
9805
|
+
}
|
|
9806
|
+
/**
|
|
9807
|
+
* Assembles a complete ITimelineProviderInfo from timeline and settings.
|
|
9808
|
+
*
|
|
9809
|
+
* This is the main entry point for creating provider info with the new
|
|
9810
|
+
* configuration-driven architecture.
|
|
9811
|
+
*
|
|
9812
|
+
* @param timeline - The resolved timeline configuration
|
|
9813
|
+
* @param settings - The timeline provider settings
|
|
9814
|
+
* @returns A complete timeline provider info with all components
|
|
9815
|
+
*/
|
|
9816
|
+
createTimelineProviderInfo(timeline, settings) {
|
|
9817
|
+
return {
|
|
9818
|
+
positionSource: this.createPositionSourceForTimeline(timeline, settings),
|
|
9819
|
+
containerProvider: this.createContainerProviderForTimeline(settings),
|
|
9820
|
+
playlist: this.createPlaylistForTimeline(settings)
|
|
9821
|
+
};
|
|
9822
|
+
}
|
|
9823
|
+
/**
|
|
9824
|
+
* Creates timeline providers for all configured timeline types using the new
|
|
9825
|
+
* configuration-driven architecture.
|
|
9826
|
+
*
|
|
9827
|
+
* This method iterates over timelineProviderSettings and creates a
|
|
9828
|
+
* ITimelineProviderInfo for each configured timeline type by:
|
|
9829
|
+
* 1. Finding the first timeline that matches the type
|
|
9830
|
+
* 2. Using the timeline's duration for the position source
|
|
9831
|
+
* 3. Assembling components from the settings
|
|
9832
|
+
*
|
|
9833
|
+
* @param configuration - The resolved engine configuration
|
|
9834
|
+
* @returns A record of timeline types to their provider info
|
|
9835
|
+
* @throws Error if a provider setting has no matching timeline in config
|
|
9836
|
+
*/
|
|
9837
|
+
createTimelineProvidersForConfig(configuration) {
|
|
9838
|
+
const { timelineProviderSettings, timelines } = configuration;
|
|
9839
|
+
return Object.entries(timelineProviderSettings).reduce((acc, [timelineType, settings]) => {
|
|
9840
|
+
if (!settings) return acc;
|
|
9841
|
+
const matchingTimeline = timelines.find((t) => t.type === timelineType);
|
|
9842
|
+
if (!matchingTimeline) throw new Error(`Timeline provider settings for '${timelineType}' has no matching timeline in configuration`);
|
|
9843
|
+
acc[timelineType] = this.createTimelineProviderInfo(matchingTimeline, settings);
|
|
9844
|
+
return acc;
|
|
9845
|
+
}, {});
|
|
9846
|
+
}
|
|
9847
|
+
};
|
|
9848
|
+
|
|
9849
|
+
//#endregion
|
|
9850
|
+
export { Action, ActionCreator, ActionCreatorFactory, ActionEditor, ActionRegistryEventbusListener, BasePositionSource, ConfigurationFactory, ConfigurationResolver, ControllerNamesProvider, DOMEventListenerController, DomContainerProvider, EligiusEngine, EligiusResourceImporter, EndableAction, EndableActionCreator, EndableActionEditor, EngineEventbusAdapter, EngineFactory, EngineInputAdapter, Eventbus, LabelController, LanguageEventbusAdapter, LanguageManager, LottieController, MutationObserverController, NavigationController, OperationEditor, OperationMetadataProvider, OperationNamesProvider, ProgressbarController, RafPositionSource, RequestVideoUriInterceptor, RoutingController, ScrollPositionSource, SimplePlaylist, SubtitleEditor, SubtitleImporter, SubtitlesController, TimeLineEventNamesProvider, TimelineAction, TimelineActionCreator, TimelineActionEditor, TimelineProviderSettingsEditor, TimelineProvidersSettingsEditor, TypedEventEmitter, VideoPositionSource, addClass, addControllerToElement, addGlobalsToOperation, animate, animateWithClass, announceToScreenReader, breakForEach, broadcastEvent, calc, clearElement, clearOperationData, clearStorage, compareDate, concatenateStrings, continueForEach, createElement, metadata_exports as ctrlmetadata, customFunction, endAction, endForEach, endWhen, metadata_exports$1 as eventmetadata, extendController, filterArray, findInArray, forEach, formatDate, formatText, getAttributesFromElement, getControllerFromElement, getControllerInstance, getCurrentTime, getElementDimensions, getFocusedElement, getFormData, getImport, getQueryParams, getScrollPosition, getTextContent, httpDelete, httpPost, httpPut, invokeObjectMethod, isElementInViewport, isSeekable, loadFromStorage, loadJson, log, mapArray, math, metadata_exports$2 as metadata, otherwise, removeClass, removeControllerFromElement, removeElement, removePropertiesFromOperationData, reparentElement, replaceString, replaceText, requestAction, saveToStorage, scrollToElement, scrollToPosition, selectElement, setData, setElementAttributes, setElementContent, setFocus, setFormValue, setGlobalData, setOperationData, setStyle, setVariable, sortArray, splitString, startAction, substringText, toggleClass, toggleElement, toggleFormElement, validateForm, wait, when };
|
|
8675
9851
|
//# sourceMappingURL=index.mjs.map
|