eligius 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +309 -311
  3. package/dist/chunk-C6wwvPpM.mjs +18 -0
  4. package/dist/index.d.mts +168 -181
  5. package/dist/index.mjs +896 -955
  6. package/dist/index.mjs.map +1 -1
  7. package/jsonschema/eligius-configuration.json +122 -122
  8. package/jsonschema/engine-config.json +21 -21
  9. package/jsonschema/mediaplayer-timeline-provider-settings.json +40 -40
  10. package/jsonschema/operation-templates/animate-with-class.json +1 -3
  11. package/jsonschema/operation-templates/break-for-each.json +1 -1
  12. package/jsonschema/operation-templates/clear-operation-data.json +1 -3
  13. package/jsonschema/operation-templates/clear-storage.json +1 -3
  14. package/jsonschema/operation-templates/concatenate-strings.json +1 -3
  15. package/jsonschema/operation-templates/continue-for-each.json +1 -1
  16. package/jsonschema/operation-templates/create-element.json +1 -3
  17. package/jsonschema/operation-templates/filter-array.json +2 -6
  18. package/jsonschema/operation-templates/find-in-array.json +2 -6
  19. package/jsonschema/operation-templates/get-query-params.json +1 -3
  20. package/jsonschema/operation-templates/http-delete.json +1 -3
  21. package/jsonschema/operation-templates/http-post.json +1 -3
  22. package/jsonschema/operation-templates/http-put.json +1 -3
  23. package/jsonschema/operation-templates/invoke-object-method.json +1 -3
  24. package/jsonschema/operation-templates/load-json.json +1 -3
  25. package/jsonschema/operation-templates/log.json +1 -3
  26. package/jsonschema/operation-templates/select-element.json +1 -3
  27. package/jsonschema/operation-templates/set-operation-data.json +1 -3
  28. package/jsonschema/operation-templates/sort-array.json +2 -6
  29. package/jsonschema/operation-templates/split-string.json +1 -3
  30. package/jsonschema/operation-templates/substring-text.json +1 -3
  31. package/jsonschema/operation-templates/validate-form.json +1 -3
  32. package/jsonschema/operations/animate-with-class.json +1 -3
  33. package/jsonschema/operations/break-for-each.json +1 -1
  34. package/jsonschema/operations/clear-operation-data.json +1 -3
  35. package/jsonschema/operations/clear-storage.json +1 -3
  36. package/jsonschema/operations/concatenate-strings.json +1 -3
  37. package/jsonschema/operations/continue-for-each.json +1 -1
  38. package/jsonschema/operations/create-element.json +1 -3
  39. package/jsonschema/operations/filter-array.json +2 -6
  40. package/jsonschema/operations/find-in-array.json +2 -6
  41. package/jsonschema/operations/get-query-params.json +1 -3
  42. package/jsonschema/operations/http-delete.json +1 -3
  43. package/jsonschema/operations/http-post.json +1 -3
  44. package/jsonschema/operations/http-put.json +1 -3
  45. package/jsonschema/operations/invoke-object-method.json +1 -3
  46. package/jsonschema/operations/load-json.json +1 -3
  47. package/jsonschema/operations/log.json +1 -3
  48. package/jsonschema/operations/select-element.json +1 -3
  49. package/jsonschema/operations/set-operation-data.json +1 -3
  50. package/jsonschema/operations/sort-array.json +2 -6
  51. package/jsonschema/operations/split-string.json +1 -3
  52. package/jsonschema/operations/substring-text.json +1 -3
  53. package/jsonschema/operations/validate-form.json +1 -3
  54. package/jsonschema/raf-timeline-provider-settings.json +29 -29
  55. package/jsonschema/timeline-provider-settings.json +16 -16
  56. package/jsonschema/timeline.json +52 -52
  57. package/package.json +13 -16
  58. package/dist/chunk-z5eko27R.mjs +0 -13
package/dist/index.mjs CHANGED
@@ -1,8 +1,6 @@
1
- import { t as __export } from "./chunk-z5eko27R.mjs";
1
+ import { t as __export } from "./chunk-C6wwvPpM.mjs";
2
2
  import $ from "jquery";
3
3
  import { isDefined } from "ts-is-present";
4
- import fs from "node:fs";
5
- import path from "node:path";
6
4
  import { v4 } from "uuid";
7
5
  import vjs from "video.js";
8
6
  import lt from "lottie-web";
@@ -529,124 +527,6 @@ var TimelineAction = class extends EndableAction {
529
527
  }
530
528
  };
531
529
 
532
- //#endregion
533
- //#region src/util/dash-to-camel-case.ts
534
- function dashToCamelCase(input) {
535
- return input.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
536
- }
537
-
538
- //#endregion
539
- //#region src/build/generate-importer-source-code.ts
540
- /**
541
- * This function takes an Eligius engine configuration, a root path for the configuration file and an arbitrary list of asset info.
542
- * The asset info determines a number of subdirectories in the root path that contain the different assets used by the presentation.
543
- * I.e. html, json, etc.
544
- *
545
- * @param config
546
- * @param configPath
547
- * @param assetInfo
548
- */
549
- function generateImporterSourceCode(config, configPath, assetInfo) {
550
- return _generateSourceCode(_gatherImportPaths(config, configPath, assetInfo));
551
- }
552
- function _generateSourceCode(importPaths) {
553
- const result = importPaths.filter((x) => x.defaultImport).map((imp) => `import ${imp.systemName} from '${imp.path}';`).concat(importPaths.filter((x) => !x.defaultImport).map((imp) => `import {${imp.systemName}} from '${imp.path ?? "eligius"}';`));
554
- result.push(`import { ISimpleResourceImporter } from 'eligius';`);
555
- result.push("");
556
- result.push("const imports: Record<string, any> = {");
557
- result.push(...importPaths.map((imp) => `${imp.systemName}: { '${imp.systemName}': ${imp.systemName} },`));
558
- result.push("};");
559
- result.push("");
560
- result.push("class EligiusResourceImporter implements ISimpleResourceImporter {");
561
- result.push("import(name: string): Record<string, any> {");
562
- result.push("if (imports.hasOwnProperty(name)) { return imports[name]; }");
563
- result.push("throw Error(\"Unknown systemName: \" + name);");
564
- result.push("}}");
565
- result.push("");
566
- result.push("export default EligiusResourceImporter;");
567
- return result.join("\n");
568
- }
569
- function _gatherImportPaths(config, configPath, assetInfo) {
570
- return [
571
- ..._gatherOperations(config),
572
- ...assetInfo.flatMap((info) => _gatherAssets(configPath, info.path, info.extension)),
573
- ..._gatherControllers(config),
574
- ..._gatherProviders(config),
575
- ..._gatherEngines(config)
576
- ];
577
- }
578
- function _gatherAssets(assetPath, subdir, extension) {
579
- return fs.readdirSync(path.join(assetPath, subdir)).map((file) => {
580
- return {
581
- systemName: `${dashToCamelCase(path.basename(file, extension))}`,
582
- path: `./${subdir}/${file}`,
583
- defaultImport: true
584
- };
585
- });
586
- }
587
- function _gatherControllers(config) {
588
- let importPaths = [];
589
- importPaths.push(..._gatherControllerImportPathsFromActions(config.initActions));
590
- importPaths.push(..._gatherControllerImportPathsFromActions(config.actions));
591
- importPaths.push(..._gatherControllerImportPathsFromActions(config.timelines.flatMap((x) => x.timelineActions)));
592
- importPaths.push(..._gatherControllerImportPathsFromActions(config.eventActions));
593
- importPaths = _deduplicate(importPaths);
594
- return importPaths;
595
- }
596
- function _gatherProviders(config) {
597
- if (config.timelineProviderSettings) return Object.values(config.timelineProviderSettings).map((settings) => {
598
- return { systemName: settings.systemName };
599
- });
600
- return [];
601
- }
602
- function _gatherEngines(config) {
603
- if (config.engine) {
604
- const { systemName } = config.engine;
605
- return [{ systemName }];
606
- }
607
- return [];
608
- }
609
- function _gatherOperations(config) {
610
- let importPaths = _gatherOperationImportPathsFromActions(config.initActions.concat(config.actions).concat(config.eventActions ?? []));
611
- if (config.timelines) {
612
- const timelineActions = config.timelines.flatMap((x) => x.timelineActions);
613
- importPaths = importPaths.concat(_gatherOperationImportPathsFromActions(timelineActions));
614
- }
615
- return _deduplicate(importPaths);
616
- }
617
- function _gatherControllerImportPathsFromActions(actionsConfig) {
618
- if (!actionsConfig) return [];
619
- return _gatherControllerImportPaths(actionsConfig.flatMap((x) => [...x.startOperations, ...x.endOperations ?? []]));
620
- }
621
- function _gatherOperationImportPathsFromActions(actionsConfig) {
622
- if (!actionsConfig) return [];
623
- return _gatherOperationImportPaths(actionsConfig.flatMap((x) => [...x.startOperations, ...x.endOperations ?? []]));
624
- }
625
- function _gatherControllerImportPaths(operationConfigs) {
626
- if (!operationConfigs) return [];
627
- return operationConfigs.filter((operationConfig) => {
628
- if (Object.hasOwn(operationConfig.operationData ?? {}, "systemName")) return operationConfig.operationData.systemName.endsWith("Controller");
629
- return false;
630
- }).map((operationConfig) => {
631
- const { systemName } = operationConfig.operationData ?? {};
632
- return { systemName };
633
- });
634
- }
635
- function _gatherOperationImportPaths(operationConfigs) {
636
- if (!operationConfigs) return [];
637
- return operationConfigs.map((operationConfig) => {
638
- const { systemName } = operationConfig;
639
- return { systemName };
640
- });
641
- }
642
- function _deduplicate(importPaths) {
643
- const lookup = {};
644
- return importPaths.filter((imp) => {
645
- if (lookup[imp.systemName]) return false;
646
- return lookup[imp.systemName] = true;
647
- });
648
- }
649
-
650
530
  //#endregion
651
531
  //#region src/operation/add-class.ts
652
532
  /**
@@ -1109,7 +989,7 @@ const customFunction = function(operationData) {
1109
989
  * @category Action
1110
990
  */
1111
991
  const endAction = (operationData) => {
1112
- let { actionOperationData,...newOperationData } = operationData;
992
+ let { actionOperationData, ...newOperationData } = operationData;
1113
993
  return new Promise((resolve, reject) => {
1114
994
  newOperationData = mergeOperationData(newOperationData, actionOperationData);
1115
995
  newOperationData.actionInstance.end(newOperationData).then(() => {
@@ -1865,7 +1745,7 @@ const httpPut = async (operationData) => {
1865
1745
  * @category Utility
1866
1746
  */
1867
1747
  const invokeObjectMethod = (operationData) => {
1868
- const { methodName, methodArguments,...newOperationData } = operationData;
1748
+ const { methodName, methodArguments, ...newOperationData } = operationData;
1869
1749
  delete operationData.methodName;
1870
1750
  delete operationData.methodArguments;
1871
1751
  const func = operationData.instance[methodName];
@@ -2064,7 +1944,7 @@ function isString(value) {
2064
1944
  const math = function(operationData) {
2065
1945
  operationData = resolvePropertyValues(operationData, this, operationData);
2066
1946
  operationData.args = resolveMathConstants(operationData.args);
2067
- const { args, functionName,...newOperationData } = operationData;
1947
+ const { args, functionName, ...newOperationData } = operationData;
2068
1948
  newOperationData.mathResult = Math[functionName].apply(null, args);
2069
1949
  return newOperationData;
2070
1950
  };
@@ -2469,12 +2349,12 @@ const setData = function(operationData) {
2469
2349
  };
2470
2350
  function resolveTargets(data, operationData, scope) {
2471
2351
  return Object.keys(data).forEach((item) => {
2472
- const path$1 = item.split(".");
2473
- const rootTarget = path$1.shift()?.toLowerCase().substring(1) ?? "";
2352
+ const path = item.split(".");
2353
+ const rootTarget = path.shift()?.toLowerCase().substring(1) ?? "";
2474
2354
  if (!isDataTarget(rootTarget)) throw new Error(`Unrecognized target: ${rootTarget}, known targets are: ${knownTargets.join(", ")}`);
2475
- const property = path$1.pop() ?? "";
2355
+ const property = path.pop() ?? "";
2476
2356
  const propertyValue = resolveExternalPropertyChain(operationData, scope, data[item]);
2477
- const propertyTarget = getPropertyChainValue(path$1, {
2357
+ const propertyTarget = getPropertyChainValue(path, {
2478
2358
  scope,
2479
2359
  operationdata: operationData,
2480
2360
  globaldata: getGlobals()
@@ -2593,7 +2473,7 @@ const setFormValue = (operationData) => {
2593
2473
  * @category Data
2594
2474
  */
2595
2475
  const setGlobalData = (operationData) => {
2596
- const { propertyNames,...newOperationData } = operationData;
2476
+ const { propertyNames, ...newOperationData } = operationData;
2597
2477
  setGlobals(Object.fromEntries(Object.entries(operationData).filter(([name, _value]) => propertyNames.includes(name))));
2598
2478
  return newOperationData;
2599
2479
  };
@@ -2607,7 +2487,7 @@ const setGlobalData = (operationData) => {
2607
2487
  * @category Data
2608
2488
  */
2609
2489
  const setOperationData = function(operationData) {
2610
- const { override = false, properties,...newOperationData } = operationData;
2490
+ const { override = false, properties, ...newOperationData } = operationData;
2611
2491
  const resolvedProperties = resolvePropertyValues(newOperationData, this, properties);
2612
2492
  if (override) return resolvedProperties;
2613
2493
  return {
@@ -2751,7 +2631,7 @@ const splitString = (operationData) => {
2751
2631
  * @category Action
2752
2632
  */
2753
2633
  const startAction = (operationData) => {
2754
- let { actionInstance, actionOperationData,...newOperationData } = operationData;
2634
+ let { actionInstance, actionOperationData, ...newOperationData } = operationData;
2755
2635
  return new Promise((resolve, reject) => {
2756
2636
  newOperationData = mergeOperationData(newOperationData, actionOperationData);
2757
2637
  actionInstance.start(newOperationData).then(() => {
@@ -2946,7 +2826,7 @@ const validateForm = (operationData) => {
2946
2826
  * @category Utility
2947
2827
  */
2948
2828
  const wait = (operationData) => {
2949
- const { milliseconds,...newOperationData } = operationData;
2829
+ const { milliseconds, ...newOperationData } = operationData;
2950
2830
  return new Promise((resolve) => {
2951
2831
  setTimeout(() => {
2952
2832
  internalResolve(resolve, newOperationData);
@@ -3653,25 +3533,6 @@ var OperationEditor = class {
3653
3533
  }
3654
3534
  };
3655
3535
 
3656
- //#endregion
3657
- //#region src/util/merge-if-missing.ts
3658
- /**
3659
- *
3660
- * Merges the properties of the target object into the source object, only the properties that do not exist yet on the source.
3661
- *
3662
- * This function is pure, so it returns a new instance that reflects the merging of the two objects.
3663
- *
3664
- * The merge is shallow.
3665
- *
3666
- * @param target
3667
- * @param source
3668
- * @returns
3669
- */
3670
- const mergeIfMissing = (target, source) => Object.entries(source).reduce((acc, [key, value]) => key in acc ? acc : {
3671
- ...acc,
3672
- [key]: value
3673
- }, target);
3674
-
3675
3536
  //#endregion
3676
3537
  //#region src/configuration/api/label-editor.ts
3677
3538
  /**
@@ -3924,13 +3785,16 @@ var VideoJsTimelineProvider = class {
3924
3785
  }
3925
3786
  start() {
3926
3787
  this._player?.play();
3788
+ this._playState = "running";
3927
3789
  }
3928
3790
  stop() {
3929
3791
  this._player?.pause();
3930
3792
  this._player?.currentTime(0);
3793
+ this._playState = "stopped";
3931
3794
  }
3932
3795
  pause() {
3933
3796
  this._player?.pause();
3797
+ this._playState = "stopped";
3934
3798
  }
3935
3799
  seek(position) {
3936
3800
  return new Promise((resolve) => {
@@ -3941,7 +3805,9 @@ var VideoJsTimelineProvider = class {
3941
3805
  });
3942
3806
  }
3943
3807
  playlistItem(uri) {
3944
- if (this._urls.includes(uri)) this._player?.selectSource([uri]);
3808
+ if (uri === null || !uri.length || this._urls.length === 0) return;
3809
+ if (!this._urls.includes(uri)) throw new Error(`Unknown playlist uri: ${uri}`);
3810
+ this._player?.selectSource([uri]);
3945
3811
  }
3946
3812
  getPosition() {
3947
3813
  return this._player?.currentTime() ?? 0;
@@ -4046,6 +3912,25 @@ var TimelineProviderSettingsEditor = class {
4046
3912
  }
4047
3913
  };
4048
3914
 
3915
+ //#endregion
3916
+ //#region src/util/merge-if-missing.ts
3917
+ /**
3918
+ *
3919
+ * Merges the properties of the target object into the source object, only the properties that do not exist yet on the source.
3920
+ *
3921
+ * This function is pure, so it returns a new instance that reflects the merging of the two objects.
3922
+ *
3923
+ * The merge is shallow.
3924
+ *
3925
+ * @param target
3926
+ * @param source
3927
+ * @returns
3928
+ */
3929
+ const mergeIfMissing = (target, source) => Object.entries(source).reduce((acc, [key, value]) => key in acc ? acc : {
3930
+ ...acc,
3931
+ [key]: value
3932
+ }, target);
3933
+
4049
3934
  //#endregion
4050
3935
  //#region src/configuration/api/configuration-factory.ts
4051
3936
  /**
@@ -5403,7 +5288,11 @@ before it resolves.`,
5403
5288
  type: "ParameterType:className",
5404
5289
  required: true
5405
5290
  },
5406
- removeClass: { type: "ParameterType:boolean" }
5291
+ removeClass: { type: [
5292
+ { value: "undefined" },
5293
+ { value: "false" },
5294
+ { value: "true" }
5295
+ ] }
5407
5296
  }
5408
5297
  };
5409
5298
  }
@@ -5448,7 +5337,11 @@ function announceToScreenReader$1() {
5448
5337
  erased: true
5449
5338
  },
5450
5339
  priority: {
5451
- type: [{ value: "polite" }, { value: "assertive" }],
5340
+ type: [
5341
+ { value: "undefined" },
5342
+ { value: "polite" },
5343
+ { value: "assertive" }
5344
+ ],
5452
5345
  erased: true
5453
5346
  }
5454
5347
  }
@@ -5459,8 +5352,7 @@ function announceToScreenReader$1() {
5459
5352
  //#region src/operation/metadata/break-for-each.ts
5460
5353
  function breakForEach$1() {
5461
5354
  return {
5462
- description: `
5463
- This operation should only be used within a loop, so between a {@link forEach} and {@link endForEach}
5355
+ description: `This operation should only be used within a loop, so between a {@link forEach} and {@link endForEach}
5464
5356
  operation. This operation immediately moves to the loop end index, effectively stopping the loop.`,
5465
5357
  category: `Control Flow`
5466
5358
  };
@@ -5522,7 +5414,7 @@ function calc$1() {
5522
5414
  erased: true
5523
5415
  }
5524
5416
  },
5525
- outputProperties: { calculationResult: { type: "ParameterType:number" } }
5417
+ outputProperties: { calculationResult: { type: [{ value: "undefined" }, { value: "number" }] } }
5526
5418
  };
5527
5419
  }
5528
5420
 
@@ -5544,8 +5436,7 @@ function clearOperationData$1() {
5544
5436
  Or, if the \`properties\` property is set only removes the properties defined by that list.`,
5545
5437
  category: `Data`,
5546
5438
  properties: { properties: {
5547
- type: "ParameterType:array",
5548
- itemType: "ParameterType:string",
5439
+ type: [{ value: "undefined" }, { value: "string[]" }],
5549
5440
  erased: true
5550
5441
  } }
5551
5442
  };
@@ -5561,7 +5452,7 @@ If \`key\` is provided, removes only that key. If \`key\` is omitted, clears all
5561
5452
  category: `Data`,
5562
5453
  properties: {
5563
5454
  key: {
5564
- type: "ParameterType:string",
5455
+ type: [{ value: "undefined" }, { value: "string" }],
5565
5456
  erased: true
5566
5457
  },
5567
5458
  storageType: {
@@ -5623,7 +5514,7 @@ function concatenateStrings$1() {
5623
5514
  erased: true
5624
5515
  },
5625
5516
  separator: {
5626
- type: "ParameterType:string",
5517
+ type: [{ value: "undefined" }, { value: "string" }],
5627
5518
  erased: true
5628
5519
  }
5629
5520
  },
@@ -5635,8 +5526,7 @@ function concatenateStrings$1() {
5635
5526
  //#region src/operation/metadata/continue-for-each.ts
5636
5527
  function continueForEach$1() {
5637
5528
  return {
5638
- description: `
5639
- This operation should only be used within a loop, so between a {@link forEach} and {@link endForEach}
5529
+ description: `This operation should only be used within a loop, so between a {@link forEach} and {@link endForEach}
5640
5530
  operation. This operation immediately moves to the next loop index, effectively canceling the rest
5641
5531
  of the operations in the current iteration.`,
5642
5532
  category: `Control Flow`
@@ -5657,7 +5547,7 @@ the instance to the \`template\` property on the current operation data.`,
5657
5547
  erased: true
5658
5548
  },
5659
5549
  text: {
5660
- type: "ParameterType:string",
5550
+ type: [{ value: "undefined" }, { value: "string" }],
5661
5551
  erased: true
5662
5552
  },
5663
5553
  attributes: {
@@ -5750,7 +5640,7 @@ Supports two filtering modes:
5750
5640
  dependentProperties: ["arrayData"],
5751
5641
  properties: {
5752
5642
  filterProperty: {
5753
- type: "ParameterType:string",
5643
+ type: [{ value: "undefined" }, { value: "string" }],
5754
5644
  erased: true
5755
5645
  },
5756
5646
  filterValue: {
@@ -5758,7 +5648,7 @@ Supports two filtering modes:
5758
5648
  erased: true
5759
5649
  },
5760
5650
  filterPredicate: {
5761
- type: "ParameterType:function",
5651
+ type: [{ value: "undefined" }, { value: "(item: any, index?: number | undefined) => boolean" }],
5762
5652
  erased: true
5763
5653
  }
5764
5654
  },
@@ -5782,7 +5672,7 @@ Returns \`undefined\` for \`foundItem\` and \`-1\` for \`foundIndex\` if no matc
5782
5672
  dependentProperties: ["arrayData"],
5783
5673
  properties: {
5784
5674
  findProperty: {
5785
- type: "ParameterType:string",
5675
+ type: [{ value: "undefined" }, { value: "string" }],
5786
5676
  erased: true
5787
5677
  },
5788
5678
  findValue: {
@@ -5790,7 +5680,7 @@ Returns \`undefined\` for \`foundItem\` and \`-1\` for \`foundIndex\` if no matc
5790
5680
  erased: true
5791
5681
  },
5792
5682
  findPredicate: {
5793
- type: "ParameterType:function",
5683
+ type: [{ value: "undefined" }, { value: "(item: any, index?: number | undefined) => boolean" }],
5794
5684
  erased: true
5795
5685
  }
5796
5686
  },
@@ -5883,7 +5773,7 @@ function getAttributesFromElement$1() {
5883
5773
  required: true,
5884
5774
  erased: true
5885
5775
  } },
5886
- outputProperties: { attributeValues: { type: "ParameterType:object" } }
5776
+ outputProperties: { attributeValues: { type: [{ value: "undefined" }, { value: "Record<string, unknown>" }] } }
5887
5777
  };
5888
5778
  }
5889
5779
 
@@ -6017,10 +5907,10 @@ function getQueryParams$1() {
6017
5907
  them on the returned operation data.`,
6018
5908
  category: `Utility`,
6019
5909
  properties: { defaultValues: {
6020
- type: "ParameterType:object",
5910
+ type: [{ value: "undefined" }, { value: "Record<string, string>" }],
6021
5911
  erased: true
6022
5912
  } },
6023
- outputProperties: { queryParams: { type: "ParameterType:object" } }
5913
+ outputProperties: { queryParams: { type: [{ value: "undefined" }, { value: "Record<string, string>" }] } }
6024
5914
  };
6025
5915
  }
6026
5916
 
@@ -6050,7 +5940,7 @@ Uses jQuery's \`.text()\` method which is XSS-safe and returns only the text con
6050
5940
  without any HTML tags. Preserves whitespace and text from nested elements.`,
6051
5941
  category: `Text`,
6052
5942
  dependentProperties: ["selectedElement"],
6053
- outputProperties: { textContent: { type: "ParameterType:string" } }
5943
+ outputProperties: { textContent: { type: [{ value: "undefined" }, { value: "string" }] } }
6054
5944
  };
6055
5945
  }
6056
5946
 
@@ -6067,7 +5957,7 @@ function httpDelete$1() {
6067
5957
  erased: true
6068
5958
  },
6069
5959
  headers: {
6070
- type: "ParameterType:object",
5960
+ type: [{ value: "undefined" }, { value: "Record<string, string>" }],
6071
5961
  erased: true
6072
5962
  }
6073
5963
  },
@@ -6095,7 +5985,7 @@ function httpPost$1() {
6095
5985
  erased: true
6096
5986
  },
6097
5987
  headers: {
6098
- type: "ParameterType:object",
5988
+ type: [{ value: "undefined" }, { value: "Record<string, string>" }],
6099
5989
  erased: true
6100
5990
  }
6101
5991
  },
@@ -6123,7 +6013,7 @@ function httpPut$1() {
6123
6013
  erased: true
6124
6014
  },
6125
6015
  headers: {
6126
- type: "ParameterType:object",
6016
+ type: [{ value: "undefined" }, { value: "Record<string, string>" }],
6127
6017
  erased: true
6128
6018
  }
6129
6019
  },
@@ -6149,7 +6039,7 @@ and assigns the result to the \`methodResult\` operationdata property.`,
6149
6039
  erased: true
6150
6040
  },
6151
6041
  methodArguments: {
6152
- type: "ParameterType:array",
6042
+ type: [{ value: "undefined" }, { value: "unknown[]" }],
6153
6043
  erased: true
6154
6044
  }
6155
6045
  },
@@ -6211,7 +6101,11 @@ instead of re-retrieving it from the url.`,
6211
6101
  erased: true
6212
6102
  },
6213
6103
  cache: {
6214
- type: "ParameterType:boolean",
6104
+ type: [
6105
+ { value: "undefined" },
6106
+ { value: "false" },
6107
+ { value: "true" }
6108
+ ],
6215
6109
  erased: true
6216
6110
  }
6217
6111
  },
@@ -6232,7 +6126,7 @@ it will log the current operation data, global data and scope to the console`,
6232
6126
  erased: true
6233
6127
  },
6234
6128
  logName: {
6235
- type: "ParameterType:string",
6129
+ type: [{ value: "undefined" }, { value: "string" }],
6236
6130
  erased: true
6237
6131
  }
6238
6132
  }
@@ -6254,7 +6148,7 @@ The mapFunction receives each item and optionally its index.`,
6254
6148
  required: true,
6255
6149
  erased: true
6256
6150
  } },
6257
- outputProperties: { mappedArray: { type: "ParameterType:array" } }
6151
+ outputProperties: { mappedArray: { type: [{ value: "undefined" }, { value: "any[]" }] } }
6258
6152
  };
6259
6153
  }
6260
6154
 
@@ -6276,7 +6170,7 @@ function math$1() {
6276
6170
  erased: true
6277
6171
  }
6278
6172
  },
6279
- outputProperties: { mathResult: { type: "ParameterType:number" } }
6173
+ outputProperties: { mathResult: { type: [{ value: "undefined" }, { value: "number" }] } }
6280
6174
  };
6281
6175
  }
6282
6176
 
@@ -6467,11 +6361,16 @@ Uses the browser's \`scrollIntoView\` API with configurable behavior.`,
6467
6361
  dependentProperties: ["selectedElement"],
6468
6362
  properties: {
6469
6363
  behavior: {
6470
- type: [{ value: "auto" }, { value: "smooth" }],
6364
+ type: [
6365
+ { value: "undefined" },
6366
+ { value: "auto" },
6367
+ { value: "smooth" }
6368
+ ],
6471
6369
  erased: true
6472
6370
  },
6473
6371
  block: {
6474
6372
  type: [
6373
+ { value: "undefined" },
6475
6374
  { value: "start" },
6476
6375
  { value: "center" },
6477
6376
  { value: "end" },
@@ -6481,6 +6380,7 @@ Uses the browser's \`scrollIntoView\` API with configurable behavior.`,
6481
6380
  },
6482
6381
  inline: {
6483
6382
  type: [
6383
+ { value: "undefined" },
6484
6384
  { value: "start" },
6485
6385
  { value: "center" },
6486
6386
  { value: "end" },
@@ -6512,7 +6412,11 @@ Uses the browser's \`window.scrollTo\` API with configurable behavior.`,
6512
6412
  erased: true
6513
6413
  },
6514
6414
  behavior: {
6515
- type: [{ value: "auto" }, { value: "smooth" }],
6415
+ type: [
6416
+ { value: "undefined" },
6417
+ { value: "auto" },
6418
+ { value: "smooth" }
6419
+ ],
6516
6420
  erased: true
6517
6421
  }
6518
6422
  }
@@ -6536,7 +6440,11 @@ then the element will be looked for only in the descendant elements of this DOM
6536
6440
  erased: true
6537
6441
  },
6538
6442
  useSelectedElementAsRoot: {
6539
- type: "ParameterType:boolean",
6443
+ type: [
6444
+ { value: "undefined" },
6445
+ { value: "false" },
6446
+ { value: "true" }
6447
+ ],
6540
6448
  erased: true
6541
6449
  }
6542
6450
  },
@@ -6670,7 +6578,11 @@ When override is set to true the properties replace the current operation data e
6670
6578
  category: `Data`,
6671
6579
  properties: {
6672
6580
  override: {
6673
- type: "ParameterType:boolean",
6581
+ type: [
6582
+ { value: "undefined" },
6583
+ { value: "false" },
6584
+ { value: "true" }
6585
+ ],
6674
6586
  erased: true
6675
6587
  },
6676
6588
  properties: {
@@ -6734,15 +6646,19 @@ Supports three sorting modes:
6734
6646
  dependentProperties: ["arrayData"],
6735
6647
  properties: {
6736
6648
  sortProperty: {
6737
- type: "ParameterType:string",
6649
+ type: [{ value: "undefined" }, { value: "string" }],
6738
6650
  erased: true
6739
6651
  },
6740
6652
  sortOrder: {
6741
- type: [{ value: "asc" }, { value: "desc" }],
6653
+ type: [
6654
+ { value: "undefined" },
6655
+ { value: "asc" },
6656
+ { value: "desc" }
6657
+ ],
6742
6658
  erased: true
6743
6659
  },
6744
6660
  sortComparator: {
6745
- type: "ParameterType:function",
6661
+ type: [{ value: "undefined" }, { value: "(a: any, b: any) => number" }],
6746
6662
  erased: true
6747
6663
  }
6748
6664
  },
@@ -6764,7 +6680,7 @@ function splitString$1() {
6764
6680
  erased: true
6765
6681
  },
6766
6682
  limit: {
6767
- type: "ParameterType:number",
6683
+ type: [{ value: "undefined" }, { value: "number" }],
6768
6684
  erased: true
6769
6685
  }
6770
6686
  },
@@ -6807,7 +6723,7 @@ function substringText$1() {
6807
6723
  erased: true
6808
6724
  },
6809
6725
  end: {
6810
- type: "ParameterType:number",
6726
+ type: [{ value: "undefined" }, { value: "number" }],
6811
6727
  erased: true
6812
6728
  }
6813
6729
  },
@@ -6875,12 +6791,16 @@ custom validation rules for: required, minLength, maxLength, pattern (regex), an
6875
6791
  category: `Form`,
6876
6792
  dependentProperties: ["selectedElement"],
6877
6793
  properties: { validationRules: {
6878
- type: "ParameterType:object",
6794
+ type: [{ value: "undefined" }, { value: "Record<string, import(\"/home/runner/work/eligius/eligius/src/operation/validate-form\").IValidationRules>" }],
6879
6795
  erased: true
6880
6796
  } },
6881
6797
  outputProperties: {
6882
6798
  validationErrors: { type: "ParameterType:object" },
6883
- isValid: { type: "ParameterType:boolean" }
6799
+ isValid: { type: [
6800
+ { value: "undefined" },
6801
+ { value: "false" },
6802
+ { value: "true" }
6803
+ ] }
6884
6804
  }
6885
6805
  };
6886
6806
  }
@@ -7396,7 +7316,7 @@ The controller also listen for the \`LANGUAGE_CHANGE\` event and re-renders the
7396
7316
  type: "ParameterType:labelId",
7397
7317
  required: true
7398
7318
  },
7399
- attributeName: { type: "ParameterType:string" }
7319
+ attributeName: { type: [{ value: "undefined" }, { value: "string" }] }
7400
7320
  }
7401
7321
  };
7402
7322
  }
@@ -7431,16 +7351,37 @@ The controller follows the standard Eligius lifecycle:
7431
7351
  - detach(): Disconnect the observer and clean up resources`,
7432
7352
  dependentProperties: ["selectedElement"],
7433
7353
  properties: {
7434
- observeAttributes: { type: "ParameterType:boolean" },
7435
- observeChildList: { type: "ParameterType:boolean" },
7436
- observeCharacterData: { type: "ParameterType:boolean" },
7437
- observeSubtree: { type: "ParameterType:boolean" },
7438
- attributeOldValue: { type: "ParameterType:boolean" },
7439
- characterDataOldValue: { type: "ParameterType:boolean" },
7440
- attributeFilter: {
7441
- type: "ParameterType:array",
7442
- itemType: "ParameterType:string"
7443
- }
7354
+ observeAttributes: { type: [
7355
+ { value: "undefined" },
7356
+ { value: "false" },
7357
+ { value: "true" }
7358
+ ] },
7359
+ observeChildList: { type: [
7360
+ { value: "undefined" },
7361
+ { value: "false" },
7362
+ { value: "true" }
7363
+ ] },
7364
+ observeCharacterData: { type: [
7365
+ { value: "undefined" },
7366
+ { value: "false" },
7367
+ { value: "true" }
7368
+ ] },
7369
+ observeSubtree: { type: [
7370
+ { value: "undefined" },
7371
+ { value: "false" },
7372
+ { value: "true" }
7373
+ ] },
7374
+ attributeOldValue: { type: [
7375
+ { value: "undefined" },
7376
+ { value: "false" },
7377
+ { value: "true" }
7378
+ ] },
7379
+ characterDataOldValue: { type: [
7380
+ { value: "undefined" },
7381
+ { value: "false" },
7382
+ { value: "true" }
7383
+ ] },
7384
+ attributeFilter: { type: [{ value: "undefined" }, { value: "string[]" }] }
7444
7385
  }
7445
7386
  };
7446
7387
  }
@@ -7488,7 +7429,7 @@ function SubtitlesController$1() {
7488
7429
  description: ``,
7489
7430
  dependentProperties: ["selectedElement"],
7490
7431
  properties: {
7491
- language: { type: "ParameterType:`${Lowercase<string>}-${Uppercase<string>}`" },
7432
+ language: { type: "ParameterType:languagecode" },
7492
7433
  subtitleData: { type: "ParameterType:array" }
7493
7434
  }
7494
7435
  };
@@ -7508,771 +7449,121 @@ var metadata_exports = /* @__PURE__ */ __export({
7508
7449
  });
7509
7450
 
7510
7451
  //#endregion
7511
- //#region src/eligius-engine.ts
7512
- /**
7513
- * This is where the magic happens. The engine is responsible for starting and stopping
7514
- * the given timeline provider and triggering the actions associated with the positions along the timeline.
7515
- */
7516
- var EligiusEngine = class EligiusEngine {
7517
- _timeLineActionsLookup = {};
7518
- _timelineLookupCache = /* @__PURE__ */ new Map();
7519
- _eventbusRemovers = [];
7520
- _currentTimelineUri = "";
7521
- _activeTimelineProvider = void 0;
7522
- _lastPosition = -1;
7523
- constructor(configuration, eventbus$1, timelineProviders, languageManager) {
7524
- this.configuration = configuration;
7525
- this.eventbus = eventbus$1;
7526
- this.timelineProviders = timelineProviders;
7527
- this.languageManager = languageManager;
7528
- }
7529
- /**
7530
- * Initializes the engine by creating the HTML layout and the first time line
7531
- * by executing its initActions.
7532
- */
7533
- init() {
7534
- this._createLayoutTemplate();
7535
- this._addEventbusListeners();
7536
- const { timelines } = this.configuration;
7537
- this._currentTimelineUri = timelines?.[0].uri ?? "";
7538
- this._createTimelineLookup();
7539
- return this._initializeTimelineProvider();
7540
- }
7541
- _createLayoutTemplate() {
7542
- const { containerSelector } = this.configuration;
7543
- const container = $(containerSelector);
7544
- if (!container || !container.length) throw new Error(`Container selector not found: ${containerSelector}`);
7545
- const { layoutTemplate } = this.configuration;
7546
- if (layoutTemplate?.length) container.html(layoutTemplate);
7547
- else console.warn("layoutTemplate is empty, unable to create layout");
7548
- }
7549
- async _initializeTimelineProvider() {
7550
- if (!this.configuration.timelines?.length) throw new Error("No timelines present");
7551
- const firstTimeline = this.configuration.timelines[0];
7552
- const providerSettings = this.timelineProviders[firstTimeline.type];
7553
- if (!providerSettings) throw new Error(`No timeline provider configured for type ${firstTimeline.type}`);
7554
- this._activeTimelineProvider?.destroy();
7555
- this._activeTimelineProvider = providerSettings.provider;
7556
- if (!this._activeTimelineProvider) throw new Error("NO ACTIVE TIMELINE PROVIDER");
7557
- this._activeTimelineProvider.onTime(this._onTimeHandler.bind(this, Math.floor));
7558
- this._activeTimelineProvider.onComplete(this._onCompleteCallback.bind(this));
7559
- this._activeTimelineProvider.onFirstFrame(this._onFirstFrameCallback.bind(this));
7560
- this._activeTimelineProvider.onRestart(this._onRestartCallback.bind(this));
7561
- await this._activeTimelineProvider.init();
7562
- await this._executeActions(this.configuration.initActions, "start");
7563
- return this._activeTimelineProvider;
7564
- }
7565
- _onCompleteCallback() {
7566
- this.eventbus.broadcast("timeline-complete", []);
7567
- }
7568
- _onFirstFrameCallback() {
7569
- this.eventbus.broadcast("timeline-firstframe", []);
7570
- this.eventbus.broadcast("timeline-duration", [this._activeTimelineProvider?.getDuration]);
7571
- }
7572
- _onRestartCallback() {
7573
- this.eventbus.broadcast("timeline-restart", []);
7574
- }
7575
- async _cleanUp() {
7576
- await this._cleanUpTimeline();
7577
- await this._executeActions([...this.configuration.initActions].reverse(), "end");
7578
- }
7579
- /**
7580
- * Cleans up all the necessary parts that the engine initialized.
7581
- * - It ends the currently active operations and the init actions.
7582
- * - It removes all its eventbus listeners, handlers and interceptors.
7583
- * - It destroys all of its timeline providers
7584
- * - It empties the HTML element indicated by the containerSelector configuration property.
7585
- *
7586
- */
7587
- async destroy() {
7588
- await this._cleanUp();
7589
- this.languageManager.destroy();
7590
- this._activeTimelineProvider = void 0;
7591
- this._eventbusRemovers.forEach((remover) => remover());
7592
- if (this.timelineProviders) Object.values(this.timelineProviders).forEach((providerInfo) => providerInfo.provider.destroy());
7593
- const { containerSelector } = this.configuration;
7594
- $(containerSelector).empty();
7595
- }
7596
- _addEventListener(eventName, eventHandler, eventTopic) {
7597
- this._eventbusRemovers.push(this.eventbus.on(eventName, eventHandler, eventTopic));
7598
- }
7599
- _addEventbusListeners() {
7600
- this._addEventListener("request-engine-root", this._handleRequestEngineRoot.bind(this, this.configuration.containerSelector));
7601
- this._addEventListener("request-timeline-uri", this._handleRequestTimelineUri.bind(this));
7602
- this._addEventListener("request-current-timeline-position", this._handleRequestTimelinePosition.bind(this, Math.floor));
7603
- this._addEventListener("request-timeline-cleanup", this._handleTimelineComplete.bind(this));
7604
- this._addEventListener("timeline-request-current-timeline", this._requestCurrentTimeline.bind(this));
7605
- this._addEventListener("timeline-play-toggle-request", this._toggleplay.bind(this));
7606
- this._addEventListener("timeline-play-request", this._playRequest.bind(this));
7607
- this._addEventListener("timeline-stop-request", this._stopRequest.bind(this));
7608
- this._addEventListener("timeline-pause-request", this._pauseRequest.bind(this));
7609
- this._addEventListener("timeline-container-request", this.containerRequest.bind(this));
7610
- this._addEventListener("timeline-duration-request", this.durationRequest.bind(this));
7611
- this._addEventListener("timeline-seek-request", this.seekRequest.bind(this));
7612
- }
7613
- async seekRequest(position) {
7614
- if (!this._activeTimelineProvider) return;
7615
- const seekPosition = Math.floor(position);
7616
- const duration = this._activeTimelineProvider.getDuration();
7617
- const currentPosition = this._activeTimelineProvider.getPosition();
7618
- if (seekPosition < 0 || seekPosition > duration) return;
7619
- this.eventbus.broadcast("timeline-seek", [
7620
- seekPosition,
7621
- currentPosition,
7622
- duration
7623
- ]);
7624
- await this._activeTimelineProvider.seek(seekPosition);
7625
- await this._executeSeekActions(seekPosition);
7626
- this.eventbus.broadcast("timeline-seeked", [this._activeTimelineProvider.getPosition(), duration]);
7627
- this.eventbus.broadcast("timeline-time", [this._activeTimelineProvider.getPosition()]);
7628
- if (this._activeTimelineProvider?.playState === "running") this._activeTimelineProvider?.start();
7629
- }
7630
- durationRequest(callBack) {
7631
- callBack(this._activeTimelineProvider?.getDuration());
7632
- }
7633
- containerRequest(callBack) {
7634
- callBack(this._activeTimelineProvider?.getContainer());
7635
- }
7636
- _pauseRequest() {
7637
- if (!this._activeTimelineProvider) return;
7638
- this._activeTimelineProvider.pause();
7639
- this.eventbus.broadcast("timeline-pause", []);
7640
- }
7641
- _stopRequest() {
7642
- if (!this._activeTimelineProvider) return;
7643
- this._activeTimelineProvider.stop();
7644
- this.eventbus.broadcast("timeline-stop", []);
7645
- }
7646
- _playRequest() {
7647
- if (!this._activeTimelineProvider) return;
7648
- this._activeTimelineProvider.start();
7649
- this.eventbus.broadcast("timeline-play", []);
7650
- }
7651
- _toggleplay() {
7652
- if (!this._activeTimelineProvider) return;
7653
- if (this._activeTimelineProvider.playState === "running") this._activeTimelineProvider.pause();
7654
- else this._activeTimelineProvider.start();
7655
- }
7656
- _createTimelineLookup() {
7657
- if (!this.configuration.timelines) return;
7658
- this.configuration.timelines.forEach((timelineInfo) => {
7659
- this._timelineLookupCache.set(timelineInfo.uri, timelineInfo);
7660
- timelineInfo.timelineActions.forEach((timelineAction) => {
7661
- this._addTimelineActionStart(timelineInfo.uri, timelineAction);
7662
- this._addTimelineActionEnd(timelineInfo.uri, timelineAction);
7663
- });
7664
- });
7665
- EligiusEngine.sortTimelines(Object.values(this._timeLineActionsLookup));
7666
- }
7667
- static sortTimelines(timelines) {
7668
- timelines.forEach((timelineActions) => {
7669
- Object.keys(timelineActions).forEach((key) => {
7670
- const numericKey = Number(key);
7671
- timelineActions[numericKey] = EligiusEngine.sortActionsPerPosition(timelineActions[numericKey]);
7672
- });
7673
- });
7674
- }
7675
- static sortActionsPerPosition(actions) {
7676
- const [startMethods, endMethods] = actions.reduce((acc, item) => {
7677
- if (item.isStart) acc[0].push(item);
7678
- else acc[1].push(item);
7679
- return acc;
7680
- }, [[], []]);
7681
- return [...endMethods.sort(sortActionMethodsHighestStartPositionFirst), ...startMethods];
7682
- }
7683
- _addTimelineActionStart(uri, timeLineAction) {
7684
- const startPosition = timeLineAction.duration.start;
7685
- const timelineStartPositions = this._initializeTimelinePosition(this._initializeUriLookup(this._timeLineActionsLookup, uri), startPosition);
7686
- const startMethod = timeLineAction.start.bind(timeLineAction);
7687
- if (timeLineAction.id?.length) startMethod.id = timeLineAction.id;
7688
- startMethod.isStart = true;
7689
- timelineStartPositions.push(startMethod);
7690
- }
7691
- _addTimelineActionEnd(uri, timeLineAction) {
7692
- let end = timeLineAction.duration.end;
7693
- if (end < 0) end = timeLineAction.duration.end = Infinity;
7694
- if (Number.isFinite(end)) {
7695
- const timelineEndPositions = this._initializeTimelinePosition(this._timeLineActionsLookup[uri], end);
7696
- const endMethod = timeLineAction.end.bind(timeLineAction);
7697
- if (timeLineAction.id?.length) {
7698
- endMethod.id = timeLineAction.id;
7699
- endMethod.startPosition = timeLineAction.duration.start;
7700
- }
7701
- endMethod.isStart = false;
7702
- timelineEndPositions.push(endMethod);
7703
- }
7704
- }
7705
- _initializeUriLookup(lookup, uri) {
7706
- if (!lookup[uri]) lookup[uri] = {};
7707
- return lookup[uri];
7708
- }
7709
- _initializeTimelinePosition(lookup, position) {
7710
- if (!lookup[position]) lookup[position] = [];
7711
- return lookup[position];
7712
- }
7713
- async _executeActions(actions, methodName) {
7714
- if (actions.length === 0) return;
7715
- for (const action of actions) await action[methodName]();
7716
- }
7717
- _handleRequestEngineRoot(engineRootSelector, resultCallback) {
7718
- resultCallback($(engineRootSelector));
7719
- }
7720
- async _handleRequestTimelineUri(uri, position = 0) {
7721
- if (!this._activeTimelineProvider) return;
7722
- this._activeTimelineProvider.stop();
7723
- await this._cleanUpTimeline();
7724
- const timelineConfig = this._timelineLookupCache.get(uri);
7725
- if (!timelineConfig || !this._activeTimelineProvider || this._currentTimelineUri === timelineConfig.uri) return;
7726
- this._currentTimelineUri = timelineConfig.uri;
7727
- this.eventbus.broadcast("timeline-current-timeline-change", [this._currentTimelineUri]);
7728
- const newProviderSettings = this.timelineProviders[timelineConfig.type];
7729
- if (this._activeTimelineProvider !== newProviderSettings.provider) {
7730
- this._activeTimelineProvider.destroy();
7731
- this._activeTimelineProvider = newProviderSettings.provider;
7732
- }
7733
- this._activeTimelineProvider.loop = timelineConfig.loop;
7734
- if (!this._activeTimelineProvider.loop && position > 0) this.eventbus.once("timeline-firstframe", async () => {
7735
- if (!this._activeTimelineProvider) return;
7736
- this._activeTimelineProvider.pause();
7737
- this.eventbus.broadcast("timeline-duration", [this._activeTimelineProvider.getDuration]);
7738
- await this._executeStartActions();
7739
- const seekPosition = await this._activeTimelineProvider.seek(position);
7740
- this.seekRequest(seekPosition);
7741
- });
7742
- this._activeTimelineProvider.playlistItem(uri);
7743
- }
7744
- _cleanUpTimeline() {
7745
- return this._executeRelevantActions(this._getActiveActions, "end");
7746
- }
7747
- _executeStartActions() {
7748
- return this._executeRelevantActions(this._getActionsForPosition.bind(this, 0), "start");
7749
- }
7750
- /**
7751
- * Gets all of the inactive actions whose duration falls within the given timeline position.
7752
- *
7753
- * @param position the given position
7754
- * @param actions all of the relevant actions
7755
- * @returns
7756
- */
7757
- _getActionsForPosition(position, actions) {
7758
- return actions.filter((action) => !action.active && action.duration.start <= position && action.duration.end >= position);
7759
- }
7760
- _getActiveActions(allActions) {
7761
- return allActions.filter((action) => action.active).sort(sortActionsHighestStartPositionFirst);
7762
- }
7763
- _executeRelevantActions(filter, executionType) {
7764
- const timelineActions = this._getTimelineActionsForCurrentTimeline();
7765
- const currentActions = filter.apply(this, [timelineActions]);
7766
- return this._executeActions(currentActions, executionType);
7767
- }
7768
- _handleRequestTimelinePosition(floor, resultCallback) {
7769
- resultCallback(floor(this._activeTimelineProvider?.getPosition() || -1));
7770
- }
7771
- _handleTimelineComplete() {
7772
- this._cleanUpTimeline();
7773
- }
7774
- _getTimelineActionsForCurrentTimeline() {
7775
- return this._getTimelineActionsForUri(this._currentTimelineUri);
7776
- }
7777
- _requestCurrentTimeline(resultCallback) {
7778
- resultCallback(this._currentTimelineUri);
7779
- }
7780
- _getTimelineActionsForUri(uri) {
7781
- return this._timelineLookupCache.get(uri)?.timelineActions ?? [];
7782
- }
7783
- _onTimeHandler(floor, position) {
7784
- if (!Number.isNaN(position)) {
7785
- const pos = floor(position);
7786
- if (this._lastPosition !== pos) {
7787
- this._executeActionsForPosition(pos);
7788
- this.eventbus.broadcast("timeline-time", [pos]);
7452
+ //#region src/eventbus/events/metadata/before-request-timeline-uri.ts
7453
+ function beforeRequestTimelineUri() {
7454
+ return {
7455
+ description: `Event: before-request-timeline-uri`,
7456
+ category: `Timeline`,
7457
+ args: []
7458
+ };
7459
+ }
7460
+
7461
+ //#endregion
7462
+ //#region src/eventbus/events/metadata/before-request-video-url.ts
7463
+ function beforeRequestVideoUrl() {
7464
+ return {
7465
+ description: `Event: before-request-video-url`,
7466
+ category: `Navigation`,
7467
+ args: [
7468
+ {
7469
+ name: "index",
7470
+ type: "number"
7471
+ },
7472
+ {
7473
+ name: "requestedVideoPosition",
7474
+ type: "number"
7475
+ },
7476
+ {
7477
+ name: "isHistoryRequest",
7478
+ type: "boolean"
7789
7479
  }
7790
- }
7791
- }
7792
- _executeActionsForPosition(position) {
7793
- this._lastPosition = position;
7794
- const actions = this._timeLineActionsLookup[this._currentTimelineUri];
7795
- if (actions) actions[position]?.forEach((exec) => exec());
7796
- }
7797
- async _executeSeekActions(position) {
7798
- const timelineActions = this._getTimelineActionsForCurrentTimeline();
7799
- if (!timelineActions) return Promise.resolve();
7800
- const currentActions = this._getActiveActions(timelineActions).filter((action) => !(action.duration.start <= position && action.duration.end >= position));
7801
- const newActions = this._getActionsForPosition(position, timelineActions);
7802
- await this._executeActions(currentActions, "end");
7803
- return this._executeActions(newActions, "start");
7804
- }
7805
- };
7806
- const sortActionsHighestStartPositionFirst = (a, b) => {
7807
- if (b.duration.start < a.duration.start) return -1;
7808
- else if (b.duration.start > a.duration.start) return 1;
7809
- else return 0;
7810
- };
7811
- const sortActionMethodsHighestStartPositionFirst = (a, b) => {
7812
- if (b.startPosition === void 0 || a.startPosition === void 0) return 0;
7813
- if (b.startPosition < a.startPosition) return -1;
7814
- else if (b.startPosition > a.startPosition) return 1;
7815
- else return 0;
7816
- };
7480
+ ]
7481
+ };
7482
+ }
7817
7483
 
7818
7484
  //#endregion
7819
- //#region src/eventbus/actionregistry-eventbus-listener.ts
7820
- /**
7821
- * The `IEventbusListener` first registers a number of actions that are then
7822
- * executed when the specified event is broadcast.
7823
- */
7824
- var ActionRegistryEventbusListener = class {
7825
- _actionRegistry = /* @__PURE__ */ new Map();
7826
- registerAction(action, eventName, eventTopic) {
7827
- if (eventTopic?.length) eventName = `${eventName}:${eventTopic}`;
7828
- if (!this._actionRegistry.has(eventName)) this._actionRegistry.set(eventName, []);
7829
- this._actionRegistry.get(eventName)?.push(action);
7830
- }
7831
- handleEvent(eventName, eventTopic, args) {
7832
- if (eventTopic) eventName = `${eventName}:${eventTopic}`;
7833
- const actions = this._actionRegistry.get(eventName);
7834
- if (actions) {
7835
- const operationData = { eventArgs: args };
7836
- actions.forEach((action) => {
7837
- action.start(operationData);
7838
- });
7839
- }
7840
- }
7841
- };
7485
+ //#region src/eventbus/events/metadata/dom-mutation.ts
7486
+ function domMutation() {
7487
+ return {
7488
+ description: `Event: dom-mutation`,
7489
+ category: `Controller`,
7490
+ args: [{
7491
+ name: "payload",
7492
+ type: "any"
7493
+ }]
7494
+ };
7495
+ }
7842
7496
 
7843
7497
  //#endregion
7844
- //#region src/eventbus/eventbus.ts
7845
- var Eventbus = class {
7846
- eventHandlers = /* @__PURE__ */ new Map();
7847
- eventInterceptors = /* @__PURE__ */ new Map();
7848
- eventListeners = [];
7849
- constructor() {
7850
- this.clear();
7851
- }
7852
- clear() {
7853
- this.eventHandlers = /* @__PURE__ */ new Map();
7854
- this.eventListeners = [];
7855
- this.eventInterceptors = /* @__PURE__ */ new Map();
7856
- }
7857
- _getEventInterceptors(eventName, eventTopic) {
7858
- if (eventTopic) eventName = `${eventName}:${eventTopic}`;
7859
- if (!this.eventInterceptors.has(eventName)) this.eventInterceptors.set(eventName, []);
7860
- return this.eventInterceptors.get(eventName);
7861
- }
7862
- _getEventHandlers(eventName, eventTopic) {
7863
- if (eventTopic) eventName = `${eventName}:${eventTopic}`;
7864
- if (!this.eventHandlers.has(eventName)) this.eventHandlers.set(eventName, []);
7865
- return this.eventHandlers.get(eventName);
7866
- }
7867
- on(eventName, eventHandler, eventTopic) {
7868
- this._getEventHandlers(eventName, eventTopic).push(eventHandler);
7869
- return () => {
7870
- this.off(eventName, eventHandler, eventTopic);
7871
- };
7872
- }
7873
- once(eventName, eventHandler, eventTopic) {
7874
- const eventHandlerDecorator = (...args) => {
7875
- eventHandler(...args);
7876
- this.off(eventName, eventHandlerDecorator, eventTopic);
7877
- };
7878
- this.on(eventName, eventHandlerDecorator, eventTopic);
7879
- return () => {
7880
- this.off(eventName, eventHandlerDecorator, eventTopic);
7881
- };
7882
- }
7883
- off(eventName, eventHandler, eventTopic) {
7884
- const handlers = this._getEventHandlers(eventName, eventTopic);
7885
- if (handlers) {
7886
- const idx = handlers.indexOf(eventHandler);
7887
- if (idx > -1) handlers.splice(idx, 1);
7888
- }
7889
- }
7890
- broadcast(eventName, args) {
7891
- this._callHandlers(eventName, void 0, args);
7892
- }
7893
- broadcastForTopic(eventName, eventTopic, args) {
7894
- this._callHandlers(eventName, eventTopic, args);
7895
- }
7896
- registerEventlistener(eventbusListener) {
7897
- this.eventListeners.push(eventbusListener);
7898
- return () => {
7899
- const index = this.eventListeners.indexOf(eventbusListener);
7900
- if (index > -1) this.eventListeners.splice(index, 1);
7901
- };
7902
- }
7903
- registerInterceptor(eventName, interceptor, eventTopic) {
7904
- const interceptors = this._getEventInterceptors(eventName, eventTopic);
7905
- interceptors.push(interceptor);
7906
- return () => {
7907
- const index = interceptors.indexOf(interceptor);
7908
- if (index > -1) interceptors.splice(index, 1);
7909
- };
7910
- }
7911
- _callHandlers(eventName, eventTopic, args = []) {
7912
- const handlers = this._getEventHandlers(eventName, eventTopic);
7913
- if (handlers) {
7914
- this._getEventInterceptors(eventName, eventTopic).forEach((interceptor) => {
7915
- args = interceptor.intercept(args);
7916
- });
7917
- this.eventListeners.forEach((listener) => {
7918
- listener.handleEvent(eventName, eventTopic, args);
7919
- });
7920
- if (args?.length) handlers.forEach((handler) => handler(...args));
7921
- else handlers.forEach((handler) => handler());
7922
- }
7923
- }
7924
- };
7498
+ //#region src/eventbus/events/metadata/highlight-navigation.ts
7499
+ function highlightNavigation() {
7500
+ return {
7501
+ description: `Event: highlight-navigation`,
7502
+ category: `Navigation`,
7503
+ args: [{
7504
+ name: "videoUrlIndex",
7505
+ type: "number"
7506
+ }]
7507
+ };
7508
+ }
7925
7509
 
7926
7510
  //#endregion
7927
- //#region src/eventbus/request-video-uri-interceptor.ts
7928
- var RequestVideoUriInterceptor = class {
7929
- constructor(eventbus$1) {
7930
- this.eventbus = eventbus$1;
7931
- }
7932
- intercept(args) {
7933
- this.eventbus.broadcast("before-request-timeline-uri", args.slice());
7934
- return args;
7935
- }
7936
- };
7511
+ //#region src/eventbus/events/metadata/language-change.ts
7512
+ function languageChange() {
7513
+ return {
7514
+ description: `Event: language-change`,
7515
+ category: `Language Manager`,
7516
+ args: [{
7517
+ name: "language",
7518
+ type: "TLanguageCode"
7519
+ }]
7520
+ };
7521
+ }
7937
7522
 
7938
7523
  //#endregion
7939
- //#region src/eventbus/index.ts
7940
- var eventbus_exports = /* @__PURE__ */ __export({
7941
- ActionRegistryEventbusListener: () => ActionRegistryEventbusListener,
7942
- Eventbus: () => Eventbus,
7943
- RequestVideoUriInterceptor: () => RequestVideoUriInterceptor
7944
- });
7524
+ //#region src/eventbus/events/metadata/navigate-to-video-url.ts
7525
+ function navigateToVideoUrl() {
7526
+ return {
7527
+ description: `Event: navigate-to-video-url`,
7528
+ category: `Navigation`,
7529
+ args: [{
7530
+ name: "index",
7531
+ type: "number"
7532
+ }, {
7533
+ name: "requestedVideoPosition",
7534
+ type: "number"
7535
+ }]
7536
+ };
7537
+ }
7945
7538
 
7946
7539
  //#endregion
7947
- //#region src/operation/helper/set-global.ts
7948
- function setGlobal(name, value) {
7949
- const cache$2 = getGlobals();
7950
- cache$2[name] = value;
7540
+ //#region src/eventbus/events/metadata/push-history-state.ts
7541
+ function pushHistoryState() {
7542
+ return {
7543
+ description: `Event: push-history-state`,
7544
+ category: `Navigation`,
7545
+ args: [{
7546
+ name: "state",
7547
+ type: "any"
7548
+ }]
7549
+ };
7951
7550
  }
7952
7551
 
7953
7552
  //#endregion
7954
- //#region src/language-manager.ts
7955
- /**
7956
- * This class manages the labels for an {@link IEligiusEngine} instance.
7957
- *
7958
- * It handles the request-label-collection, request-label-collections, request-current-language and language-change events.
7959
- *
7960
- */
7961
- var LanguageManager = class {
7962
- _labelLookup;
7963
- _eventbusRemovers = [];
7964
- constructor(_currentLanguage, labels, _eventbus) {
7965
- this._currentLanguage = _currentLanguage;
7966
- this._eventbus = _eventbus;
7967
- if (!_currentLanguage) throw new Error("language ctor arg cannot have zero length");
7968
- setGlobal("defaultLanguage", _currentLanguage);
7969
- this._setRootElementLang(_currentLanguage);
7970
- this._labelLookup = this._createLabelLookup(labels);
7971
- this._addEventbusListeners(_eventbus);
7972
- }
7973
- destroy() {
7974
- this._eventbusRemovers.forEach((x) => x());
7975
- }
7976
- _addEventbusListeners(eventbus$1) {
7977
- this._eventbusRemovers.push(eventbus$1.on("request-label-collection", this._handleRequestLabelCollection.bind(this)));
7978
- this._eventbusRemovers.push(eventbus$1.on("request-label-collections", this._handleRequestLabelCollections.bind(this)));
7979
- this._eventbusRemovers.push(eventbus$1.on("request-current-language", this._handleRequestCurrentLanguage.bind(this)));
7980
- this._eventbusRemovers.push(eventbus$1.on("language-change", this._handleLanguageChange.bind(this)));
7981
- }
7982
- _handleRequestCurrentLanguage(resultCallback) {
7983
- resultCallback(this._currentLanguage);
7984
- }
7985
- _handleRequestLabelCollection(labelId, resultCallback) {
7986
- resultCallback(this._labelLookup[labelId]);
7987
- }
7988
- _handleRequestLabelCollections(labelIds, resultCallback) {
7989
- resultCallback(labelIds.map((labelId) => {
7990
- return this._labelLookup[labelId];
7991
- }));
7992
- }
7993
- _handleLanguageChange(language) {
7994
- this._currentLanguage = language;
7995
- this._setRootElementLang(this._currentLanguage);
7996
- }
7997
- _setRootElementLang(language) {
7998
- const callBack = (rootSelector) => {
7999
- const lang = this._extractPrimaryLanguage(language);
8000
- $(rootSelector).attr("lang", lang);
8001
- };
8002
- this._eventbus.broadcast("request-engine-root", [callBack]);
8003
- }
8004
- _extractPrimaryLanguage(culture) {
8005
- return culture.split("-").shift();
8006
- }
8007
- _createLabelLookup(labels) {
8008
- return labels.reduce((acc, label) => {
8009
- acc[label.id] = label.labels;
8010
- return acc;
8011
- }, {});
8012
- }
8013
- };
8014
-
8015
- //#endregion
8016
- //#region src/engine-factory.ts
8017
- const hotkeys = hk.default || hk;
8018
- /**
8019
- * The EngineFactory is used to create and initialize an {@link IEligiusEngine} instance.
8020
- *
8021
- * It prepares a resolved configuration and creates the engine based on the class defined in the configuration.
8022
- *
8023
- * @example Loading a configuration and creating an IEligiusEngine instance
8024
- * ```ts
8025
- * import { IEngineConfiguration, EngineFactory, WebpackResourceImporter } from 'eligius';
8026
- * import * as engineConfig from './my-eligius-config.json';
8027
- *
8028
- * const factory = new EngineFactory(new WebpackResourceImporter(), window);
8029
- *
8030
- * const engine = factory.createEngine((engineConfig as unknown) as IEngineConfiguration);
8031
- *
8032
- * engine.init().then(()=> {console.log('Eligius engine ready for business');});
8033
- * ```
8034
- */
8035
- var EngineFactory = class {
8036
- _actionsLookup = {};
8037
- _eventbus;
8038
- _eventRemovers = [];
8039
- _importer;
8040
- _resizeTimeout = -1;
8041
- constructor(importer, windowRef, options) {
8042
- this._importer = importer;
8043
- this._eventbus = options?.eventbus ?? new Eventbus();
8044
- Diagnostics.active = options?.devtools ?? false;
8045
- if (Diagnostics.active) this._initializeDevtools(this._eventbus);
8046
- this._eventRemovers.push(this._eventbus.on("request-instance", this._requestInstanceHandler.bind(this)));
8047
- this._eventRemovers.push(this._eventbus.on("request-action", this._requestActionHandler.bind(this)));
8048
- this._eventRemovers.push(this._eventbus.on("request-function", this._requestFunctionHandler.bind(this)));
8049
- const handleSpaceBound = this._handleSpacePress.bind(this);
8050
- hotkeys("space", handleSpaceBound);
8051
- this._eventRemovers.push(() => hotkeys.unbind("space", handleSpaceBound));
8052
- const resizeBound = this._resizeHandler.bind(this);
8053
- const jqWin = $(windowRef);
8054
- jqWin.on("resize", resizeBound);
8055
- this._eventRemovers.push(() => jqWin.off("resize", resizeBound));
8056
- }
8057
- _handleSpacePress(keyboardEvent, _hotkeysEvent) {
8058
- keyboardEvent.preventDefault();
8059
- this._eventbus.broadcast("timeline-play-toggle-request", []);
8060
- return false;
8061
- }
8062
- _initializeDevtools(eventbus$1) {
8063
- const diagnosticInfo = window[DEV_TOOLS_KEY];
8064
- if (diagnosticInfo) {
8065
- const { agent } = diagnosticInfo;
8066
- this._eventRemovers.push(eventbus$1.registerEventlistener(new DevToolEventListener(agent)));
8067
- this._eventRemovers.push(agent.subscribe((message) => {
8068
- if (message.type === "playcontrol") switch (message.data.kind) {
8069
- case "play":
8070
- this._eventbus.broadcast("timeline-play-request", []);
8071
- break;
8072
- case "stop":
8073
- this._eventbus.broadcast("timeline-stop-request", []);
8074
- break;
8075
- case "pause":
8076
- this._eventbus.broadcast("timeline-pause-request", []);
8077
- break;
8078
- case "seek":
8079
- this._eventbus.broadcast("timeline-seek-request", [message.data.args ?? 0]);
8080
- break;
8081
- }
8082
- }));
8083
- Diagnostics.send = (name, messageData) => {
8084
- const message = prepareValueForSerialization(messageData);
8085
- try {
8086
- agent.postMessage(name, message);
8087
- } catch (e) {
8088
- console.error("postmessage failed");
8089
- console.error(e);
8090
- console.log("message", message);
8091
- }
8092
- };
8093
- Diagnostics.send("eligius-diagnostics-factory", "Diagnostics initialized");
8094
- } else console.warn(`${DEV_TOOLS_KEY} property not found on window, please install the Eligius Devtools extension.`);
8095
- }
8096
- destroy() {
8097
- this._eventRemovers.forEach((x) => x());
8098
- }
8099
- _resizeHandler() {
8100
- if (this._resizeTimeout) {
8101
- clearTimeout(this._resizeTimeout);
8102
- this._resizeTimeout = -1;
8103
- }
8104
- this._resizeTimeout = setTimeout(() => {
8105
- this._eventbus.broadcast("timeline-resize", []);
8106
- }, 200);
8107
- }
8108
- _importSystemEntryWithEventbusDependency(systemName) {
8109
- return new (this._importSystemEntry(systemName))(this._eventbus);
8110
- }
8111
- _importSystemEntry(systemName) {
8112
- return this._importer.import(systemName)[systemName];
8113
- }
8114
- _requestInstanceHandler(systemName, resultCallback) {
8115
- resultCallback(this._importSystemEntryWithEventbusDependency(systemName));
8116
- }
8117
- _requestFunctionHandler(systemName, resultCallback) {
8118
- resultCallback(this._importSystemEntry(systemName));
8119
- }
8120
- _requestActionHandler(systemName, resultCallback) {
8121
- const action = this._actionsLookup[systemName];
8122
- if (action) resultCallback(action);
8123
- else {
8124
- console.error(`Unknown action: ${systemName}`);
8125
- resultCallback(null);
8126
- }
8127
- }
8128
- createEngine(configuration, resolver) {
8129
- const { systemName } = configuration.engine;
8130
- const EngineClass = this._importSystemEntry(systemName);
8131
- let actionRegistryListener;
8132
- if (configuration.eventActions?.length) {
8133
- actionRegistryListener = new ActionRegistryEventbusListener();
8134
- this._eventRemovers.push(this._eventbus.registerEventlistener(actionRegistryListener));
8135
- }
8136
- this._eventRemovers.push(this._eventbus.registerInterceptor("request-timeline-uri", new RequestVideoUriInterceptor(this._eventbus)));
8137
- resolver = resolver || new ConfigurationResolver(this._importer, this._eventbus);
8138
- const [actionLookup, resolvedConfiguration] = resolver.process(configuration, actionRegistryListener);
8139
- this._actionsLookup = actionLookup;
8140
- const timelineProviders = this._createTimelineProviders(resolvedConfiguration);
8141
- const { language, labels } = configuration;
8142
- const languageManager = new LanguageManager(language, labels, this._eventbus);
8143
- return new EngineClass(resolvedConfiguration, this._eventbus, timelineProviders, languageManager);
8144
- }
8145
- _createTimelineProviders(configuration) {
8146
- const { timelineProviderSettings } = configuration;
8147
- return Object.entries(timelineProviderSettings).reduce((acc, [timelineType, settings]) => {
8148
- if (!settings) return acc;
8149
- const TimelineProviderClass = this._importSystemEntry(settings.systemName);
8150
- acc[timelineType] = {
8151
- id: settings.id,
8152
- vendor: settings.vendor,
8153
- provider: new TimelineProviderClass(configuration)
8154
- };
8155
- return acc;
8156
- }, {});
8157
- }
8158
- };
8159
-
8160
- //#endregion
8161
- //#region src/eventbus/events/metadata/before-request-timeline-uri.ts
8162
- function beforeRequestTimelineUri() {
8163
- return {
8164
- description: `Event: before-request-timeline-uri`,
8165
- category: `Timeline`,
8166
- args: []
8167
- };
8168
- }
8169
-
8170
- //#endregion
8171
- //#region src/eventbus/events/metadata/before-request-video-url.ts
8172
- function beforeRequestVideoUrl() {
8173
- return {
8174
- description: `Event: before-request-video-url`,
8175
- category: `Navigation`,
8176
- args: [
8177
- {
8178
- name: "index",
8179
- type: "number"
8180
- },
8181
- {
8182
- name: "requestedVideoPosition",
8183
- type: "number"
8184
- },
8185
- {
8186
- name: "isHistoryRequest",
8187
- type: "boolean"
8188
- }
8189
- ]
8190
- };
8191
- }
8192
-
8193
- //#endregion
8194
- //#region src/eventbus/events/metadata/dom-mutation.ts
8195
- function domMutation() {
8196
- return {
8197
- description: `Event: dom-mutation`,
8198
- category: `Controller`,
8199
- args: [{
8200
- name: "payload",
8201
- type: "any"
8202
- }]
8203
- };
8204
- }
8205
-
8206
- //#endregion
8207
- //#region src/eventbus/events/metadata/highlight-navigation.ts
8208
- function highlightNavigation() {
8209
- return {
8210
- description: `Event: highlight-navigation`,
8211
- category: `Navigation`,
8212
- args: [{
8213
- name: "videoUrlIndex",
8214
- type: "number"
8215
- }]
8216
- };
8217
- }
8218
-
8219
- //#endregion
8220
- //#region src/eventbus/events/metadata/language-change.ts
8221
- function languageChange() {
8222
- return {
8223
- description: `Event: language-change`,
8224
- category: `Language Manager`,
8225
- args: [{
8226
- name: "language",
8227
- type: "TLanguageCode"
8228
- }]
8229
- };
8230
- }
8231
-
8232
- //#endregion
8233
- //#region src/eventbus/events/metadata/navigate-to-video-url.ts
8234
- function navigateToVideoUrl() {
8235
- return {
8236
- description: `Event: navigate-to-video-url`,
8237
- category: `Navigation`,
8238
- args: [{
8239
- name: "index",
8240
- type: "number"
8241
- }, {
8242
- name: "requestedVideoPosition",
8243
- type: "number"
8244
- }]
8245
- };
8246
- }
8247
-
8248
- //#endregion
8249
- //#region src/eventbus/events/metadata/push-history-state.ts
8250
- function pushHistoryState() {
8251
- return {
8252
- description: `Event: push-history-state`,
8253
- category: `Navigation`,
8254
- args: [{
8255
- name: "state",
8256
- type: "any"
8257
- }]
8258
- };
8259
- }
8260
-
8261
- //#endregion
8262
- //#region src/eventbus/events/metadata/request-action.ts
8263
- function requestAction$1() {
8264
- return {
8265
- description: `Event: request-action`,
8266
- category: `Engine Request`,
8267
- args: [{
8268
- name: "actionName",
8269
- type: "string"
8270
- }, {
8271
- name: "callback",
8272
- type: "(actionInstance: any) => void"
8273
- }]
8274
- };
8275
- }
7553
+ //#region src/eventbus/events/metadata/request-action.ts
7554
+ function requestAction$1() {
7555
+ return {
7556
+ description: `Event: request-action`,
7557
+ category: `Engine Request`,
7558
+ args: [{
7559
+ name: "actionName",
7560
+ type: "string"
7561
+ }, {
7562
+ name: "callback",
7563
+ type: "(actionInstance: any) => void"
7564
+ }]
7565
+ };
7566
+ }
8276
7567
 
8277
7568
  //#endregion
8278
7569
  //#region src/eventbus/events/metadata/request-current-language.ts
@@ -8761,6 +8052,442 @@ var metadata_exports$1 = /* @__PURE__ */ __export({
8761
8052
  videoComplete: () => videoComplete
8762
8053
  });
8763
8054
 
8055
+ //#endregion
8056
+ //#region src/eventbus/actionregistry-eventbus-listener.ts
8057
+ /**
8058
+ * The `IEventbusListener` first registers a number of actions that are then
8059
+ * executed when the specified event is broadcast.
8060
+ */
8061
+ var ActionRegistryEventbusListener = class {
8062
+ _actionRegistry = /* @__PURE__ */ new Map();
8063
+ registerAction(action, eventName, eventTopic) {
8064
+ if (eventTopic?.length) eventName = `${eventName}:${eventTopic}`;
8065
+ if (!this._actionRegistry.has(eventName)) this._actionRegistry.set(eventName, []);
8066
+ this._actionRegistry.get(eventName)?.push(action);
8067
+ }
8068
+ handleEvent(eventName, eventTopic, args) {
8069
+ if (eventTopic) eventName = `${eventName}:${eventTopic}`;
8070
+ const actions = this._actionRegistry.get(eventName);
8071
+ if (actions) {
8072
+ const operationData = { eventArgs: args };
8073
+ actions.forEach((action) => {
8074
+ action.start(operationData);
8075
+ });
8076
+ }
8077
+ }
8078
+ };
8079
+
8080
+ //#endregion
8081
+ //#region src/eventbus/eventbus.ts
8082
+ var Eventbus = class {
8083
+ eventHandlers = /* @__PURE__ */ new Map();
8084
+ eventInterceptors = /* @__PURE__ */ new Map();
8085
+ eventListeners = [];
8086
+ constructor() {
8087
+ this.clear();
8088
+ }
8089
+ clear() {
8090
+ this.eventHandlers = /* @__PURE__ */ new Map();
8091
+ this.eventListeners = [];
8092
+ this.eventInterceptors = /* @__PURE__ */ new Map();
8093
+ }
8094
+ _getEventInterceptors(eventName, eventTopic) {
8095
+ if (eventTopic) eventName = `${eventName}:${eventTopic}`;
8096
+ if (!this.eventInterceptors.has(eventName)) this.eventInterceptors.set(eventName, []);
8097
+ return this.eventInterceptors.get(eventName);
8098
+ }
8099
+ _getEventHandlers(eventName, eventTopic) {
8100
+ if (eventTopic) eventName = `${eventName}:${eventTopic}`;
8101
+ if (!this.eventHandlers.has(eventName)) this.eventHandlers.set(eventName, []);
8102
+ return this.eventHandlers.get(eventName);
8103
+ }
8104
+ on(eventName, eventHandler, eventTopic) {
8105
+ this._getEventHandlers(eventName, eventTopic).push(eventHandler);
8106
+ return () => {
8107
+ this.off(eventName, eventHandler, eventTopic);
8108
+ };
8109
+ }
8110
+ once(eventName, eventHandler, eventTopic) {
8111
+ const eventHandlerDecorator = (...args) => {
8112
+ eventHandler(...args);
8113
+ this.off(eventName, eventHandlerDecorator, eventTopic);
8114
+ };
8115
+ this.on(eventName, eventHandlerDecorator, eventTopic);
8116
+ return () => {
8117
+ this.off(eventName, eventHandlerDecorator, eventTopic);
8118
+ };
8119
+ }
8120
+ off(eventName, eventHandler, eventTopic) {
8121
+ const handlers = this._getEventHandlers(eventName, eventTopic);
8122
+ if (handlers) {
8123
+ const idx = handlers.indexOf(eventHandler);
8124
+ if (idx > -1) handlers.splice(idx, 1);
8125
+ }
8126
+ }
8127
+ broadcast(eventName, args) {
8128
+ this._callHandlers(eventName, void 0, args);
8129
+ }
8130
+ broadcastForTopic(eventName, eventTopic, args) {
8131
+ this._callHandlers(eventName, eventTopic, args);
8132
+ }
8133
+ registerEventlistener(eventbusListener) {
8134
+ this.eventListeners.push(eventbusListener);
8135
+ return () => {
8136
+ const index = this.eventListeners.indexOf(eventbusListener);
8137
+ if (index > -1) this.eventListeners.splice(index, 1);
8138
+ };
8139
+ }
8140
+ registerInterceptor(eventName, interceptor, eventTopic) {
8141
+ const interceptors = this._getEventInterceptors(eventName, eventTopic);
8142
+ interceptors.push(interceptor);
8143
+ return () => {
8144
+ const index = interceptors.indexOf(interceptor);
8145
+ if (index > -1) interceptors.splice(index, 1);
8146
+ };
8147
+ }
8148
+ _callHandlers(eventName, eventTopic, args = []) {
8149
+ const handlers = this._getEventHandlers(eventName, eventTopic);
8150
+ if (handlers) {
8151
+ this._getEventInterceptors(eventName, eventTopic).forEach((interceptor) => {
8152
+ args = interceptor.intercept(args);
8153
+ });
8154
+ this.eventListeners.forEach((listener) => {
8155
+ listener.handleEvent(eventName, eventTopic, args);
8156
+ });
8157
+ if (args?.length) handlers.forEach((handler) => handler(...args));
8158
+ else handlers.forEach((handler) => handler());
8159
+ }
8160
+ }
8161
+ };
8162
+
8163
+ //#endregion
8164
+ //#region src/eventbus/request-video-uri-interceptor.ts
8165
+ var RequestVideoUriInterceptor = class {
8166
+ constructor(eventbus$1) {
8167
+ this.eventbus = eventbus$1;
8168
+ }
8169
+ intercept(args) {
8170
+ this.eventbus.broadcast("before-request-timeline-uri", args.slice());
8171
+ return args;
8172
+ }
8173
+ };
8174
+
8175
+ //#endregion
8176
+ //#region src/eventbus/index.ts
8177
+ var eventbus_exports = /* @__PURE__ */ __export({
8178
+ ActionRegistryEventbusListener: () => ActionRegistryEventbusListener,
8179
+ Eventbus: () => Eventbus,
8180
+ RequestVideoUriInterceptor: () => RequestVideoUriInterceptor
8181
+ });
8182
+
8183
+ //#endregion
8184
+ //#region src/eligius-engine.ts
8185
+ /**
8186
+ * This is where the magic happens. The engine is responsible for starting and stopping
8187
+ * the given timeline provider and triggering the actions associated with the positions along the timeline.
8188
+ */
8189
+ var EligiusEngine = class EligiusEngine {
8190
+ _timeLineActionsLookup = {};
8191
+ _timelineLookupCache = /* @__PURE__ */ new Map();
8192
+ _eventbusRemovers = [];
8193
+ _currentTimelineUri = "";
8194
+ _activeTimelineProvider = void 0;
8195
+ _lastPosition = -1;
8196
+ constructor(configuration, eventbus$1, timelineProviders, languageManager) {
8197
+ this.configuration = configuration;
8198
+ this.eventbus = eventbus$1;
8199
+ this.timelineProviders = timelineProviders;
8200
+ this.languageManager = languageManager;
8201
+ }
8202
+ /**
8203
+ * Initializes the engine by creating the HTML layout and the first time line
8204
+ * by executing its initActions.
8205
+ */
8206
+ init() {
8207
+ this._createLayoutTemplate();
8208
+ this._addEventbusListeners();
8209
+ const { timelines } = this.configuration;
8210
+ this._currentTimelineUri = timelines?.[0].uri ?? "";
8211
+ this._createTimelineLookup();
8212
+ return this._initializeTimelineProvider();
8213
+ }
8214
+ _createLayoutTemplate() {
8215
+ const { containerSelector } = this.configuration;
8216
+ const container = $(containerSelector);
8217
+ if (!container || !container.length) throw new Error(`Container selector not found: ${containerSelector}`);
8218
+ const { layoutTemplate } = this.configuration;
8219
+ if (layoutTemplate?.length) container.html(layoutTemplate);
8220
+ else console.warn("layoutTemplate is empty, unable to create layout");
8221
+ }
8222
+ async _initializeTimelineProvider() {
8223
+ if (!this.configuration.timelines?.length) throw new Error("No timelines present");
8224
+ const firstTimeline = this.configuration.timelines[0];
8225
+ const providerSettings = this.timelineProviders[firstTimeline.type];
8226
+ if (!providerSettings) throw new Error(`No timeline provider configured for type ${firstTimeline.type}`);
8227
+ this._activeTimelineProvider?.destroy();
8228
+ this._activeTimelineProvider = providerSettings.provider;
8229
+ if (!this._activeTimelineProvider) throw new Error("NO ACTIVE TIMELINE PROVIDER");
8230
+ this._activeTimelineProvider.onTime(this._onTimeHandler.bind(this, Math.floor));
8231
+ this._activeTimelineProvider.onComplete(this._onCompleteCallback.bind(this));
8232
+ this._activeTimelineProvider.onFirstFrame(this._onFirstFrameCallback.bind(this));
8233
+ this._activeTimelineProvider.onRestart(this._onRestartCallback.bind(this));
8234
+ await this._activeTimelineProvider.init();
8235
+ await this._executeActions(this.configuration.initActions, "start");
8236
+ return this._activeTimelineProvider;
8237
+ }
8238
+ _onCompleteCallback() {
8239
+ this.eventbus.broadcast("timeline-complete", []);
8240
+ }
8241
+ _onFirstFrameCallback() {
8242
+ this.eventbus.broadcast("timeline-firstframe", []);
8243
+ this.eventbus.broadcast("timeline-duration", [this._activeTimelineProvider?.getDuration]);
8244
+ }
8245
+ _onRestartCallback() {
8246
+ this.eventbus.broadcast("timeline-restart", []);
8247
+ }
8248
+ async _cleanUp() {
8249
+ await this._cleanUpTimeline();
8250
+ await this._executeActions([...this.configuration.initActions].reverse(), "end");
8251
+ }
8252
+ /**
8253
+ * Cleans up all the necessary parts that the engine initialized.
8254
+ * - It ends the currently active operations and the init actions.
8255
+ * - It removes all its eventbus listeners, handlers and interceptors.
8256
+ * - It destroys all of its timeline providers
8257
+ * - It empties the HTML element indicated by the containerSelector configuration property.
8258
+ *
8259
+ */
8260
+ async destroy() {
8261
+ await this._cleanUp();
8262
+ this.languageManager.destroy();
8263
+ this._activeTimelineProvider = void 0;
8264
+ this._eventbusRemovers.forEach((remover) => remover());
8265
+ if (this.timelineProviders) Object.values(this.timelineProviders).forEach((providerInfo) => providerInfo.provider.destroy());
8266
+ const { containerSelector } = this.configuration;
8267
+ $(containerSelector).empty();
8268
+ }
8269
+ _addEventListener(eventName, eventHandler, eventTopic) {
8270
+ this._eventbusRemovers.push(this.eventbus.on(eventName, eventHandler, eventTopic));
8271
+ }
8272
+ _addEventbusListeners() {
8273
+ this._addEventListener("request-engine-root", this._handleRequestEngineRoot.bind(this, this.configuration.containerSelector));
8274
+ this._addEventListener("request-timeline-uri", this._handleRequestTimelineUri.bind(this));
8275
+ this._addEventListener("request-current-timeline-position", this._handleRequestTimelinePosition.bind(this, Math.floor));
8276
+ this._addEventListener("request-timeline-cleanup", this._handleTimelineComplete.bind(this));
8277
+ this._addEventListener("timeline-request-current-timeline", this._requestCurrentTimeline.bind(this));
8278
+ this._addEventListener("timeline-play-toggle-request", this._toggleplay.bind(this));
8279
+ this._addEventListener("timeline-play-request", this._playRequest.bind(this));
8280
+ this._addEventListener("timeline-stop-request", this._stopRequest.bind(this));
8281
+ this._addEventListener("timeline-pause-request", this._pauseRequest.bind(this));
8282
+ this._addEventListener("timeline-container-request", this.containerRequest.bind(this));
8283
+ this._addEventListener("timeline-duration-request", this.durationRequest.bind(this));
8284
+ this._addEventListener("timeline-seek-request", this.seekRequest.bind(this));
8285
+ }
8286
+ async seekRequest(position) {
8287
+ if (!this._activeTimelineProvider) return;
8288
+ const seekPosition = Math.floor(position);
8289
+ const duration = this._activeTimelineProvider.getDuration();
8290
+ const currentPosition = this._activeTimelineProvider.getPosition();
8291
+ if (seekPosition < 0 || seekPosition > duration) return;
8292
+ this.eventbus.broadcast("timeline-seek", [
8293
+ seekPosition,
8294
+ currentPosition,
8295
+ duration
8296
+ ]);
8297
+ await this._activeTimelineProvider.seek(seekPosition);
8298
+ await this._executeSeekActions(seekPosition);
8299
+ this.eventbus.broadcast("timeline-seeked", [this._activeTimelineProvider.getPosition(), duration]);
8300
+ this.eventbus.broadcast("timeline-time", [this._activeTimelineProvider.getPosition()]);
8301
+ if (this._activeTimelineProvider?.playState === "running") this._activeTimelineProvider?.start();
8302
+ }
8303
+ durationRequest(callBack) {
8304
+ callBack(this._activeTimelineProvider?.getDuration());
8305
+ }
8306
+ containerRequest(callBack) {
8307
+ callBack(this._activeTimelineProvider?.getContainer());
8308
+ }
8309
+ _pauseRequest() {
8310
+ if (!this._activeTimelineProvider) return;
8311
+ this._activeTimelineProvider.pause();
8312
+ this.eventbus.broadcast("timeline-pause", []);
8313
+ }
8314
+ _stopRequest() {
8315
+ if (!this._activeTimelineProvider) return;
8316
+ this._activeTimelineProvider.stop();
8317
+ this.eventbus.broadcast("timeline-stop", []);
8318
+ }
8319
+ _playRequest() {
8320
+ if (!this._activeTimelineProvider) return;
8321
+ this._activeTimelineProvider.start();
8322
+ this.eventbus.broadcast("timeline-play", []);
8323
+ }
8324
+ _toggleplay() {
8325
+ if (!this._activeTimelineProvider) return;
8326
+ if (this._activeTimelineProvider.playState === "running") this._activeTimelineProvider.pause();
8327
+ else this._activeTimelineProvider.start();
8328
+ }
8329
+ _createTimelineLookup() {
8330
+ if (!this.configuration.timelines) return;
8331
+ this.configuration.timelines.forEach((timelineInfo) => {
8332
+ this._timelineLookupCache.set(timelineInfo.uri, timelineInfo);
8333
+ timelineInfo.timelineActions.forEach((timelineAction) => {
8334
+ this._addTimelineActionStart(timelineInfo.uri, timelineAction);
8335
+ this._addTimelineActionEnd(timelineInfo.uri, timelineAction);
8336
+ });
8337
+ });
8338
+ EligiusEngine.sortTimelines(Object.values(this._timeLineActionsLookup));
8339
+ }
8340
+ static sortTimelines(timelines) {
8341
+ timelines.forEach((timelineActions) => {
8342
+ Object.keys(timelineActions).forEach((key) => {
8343
+ const numericKey = Number(key);
8344
+ timelineActions[numericKey] = EligiusEngine.sortActionsPerPosition(timelineActions[numericKey]);
8345
+ });
8346
+ });
8347
+ }
8348
+ static sortActionsPerPosition(actions) {
8349
+ const [startMethods, endMethods] = actions.reduce((acc, item) => {
8350
+ if (item.isStart) acc[0].push(item);
8351
+ else acc[1].push(item);
8352
+ return acc;
8353
+ }, [[], []]);
8354
+ return [...endMethods.sort(sortActionMethodsHighestStartPositionFirst), ...startMethods];
8355
+ }
8356
+ _addTimelineActionStart(uri, timeLineAction) {
8357
+ const startPosition = timeLineAction.duration.start;
8358
+ const timelineStartPositions = this._initializeTimelinePosition(this._initializeUriLookup(this._timeLineActionsLookup, uri), startPosition);
8359
+ const startMethod = timeLineAction.start.bind(timeLineAction);
8360
+ if (timeLineAction.id?.length) startMethod.id = timeLineAction.id;
8361
+ startMethod.isStart = true;
8362
+ timelineStartPositions.push(startMethod);
8363
+ }
8364
+ _addTimelineActionEnd(uri, timeLineAction) {
8365
+ let end = timeLineAction.duration.end;
8366
+ if (end < 0) end = timeLineAction.duration.end = Infinity;
8367
+ if (Number.isFinite(end)) {
8368
+ const timelineEndPositions = this._initializeTimelinePosition(this._timeLineActionsLookup[uri], end);
8369
+ const endMethod = timeLineAction.end.bind(timeLineAction);
8370
+ if (timeLineAction.id?.length) {
8371
+ endMethod.id = timeLineAction.id;
8372
+ endMethod.startPosition = timeLineAction.duration.start;
8373
+ }
8374
+ endMethod.isStart = false;
8375
+ timelineEndPositions.push(endMethod);
8376
+ }
8377
+ }
8378
+ _initializeUriLookup(lookup, uri) {
8379
+ if (!lookup[uri]) lookup[uri] = {};
8380
+ return lookup[uri];
8381
+ }
8382
+ _initializeTimelinePosition(lookup, position) {
8383
+ if (!lookup[position]) lookup[position] = [];
8384
+ return lookup[position];
8385
+ }
8386
+ async _executeActions(actions, methodName) {
8387
+ if (actions.length === 0) return;
8388
+ for (const action of actions) await action[methodName]();
8389
+ }
8390
+ _handleRequestEngineRoot(engineRootSelector, resultCallback) {
8391
+ resultCallback($(engineRootSelector));
8392
+ }
8393
+ async _handleRequestTimelineUri(uri, position = 0) {
8394
+ if (!this._activeTimelineProvider) return;
8395
+ this._activeTimelineProvider.stop();
8396
+ await this._cleanUpTimeline();
8397
+ const timelineConfig = this._timelineLookupCache.get(uri);
8398
+ if (!timelineConfig || !this._activeTimelineProvider || this._currentTimelineUri === timelineConfig.uri) return;
8399
+ this._currentTimelineUri = timelineConfig.uri;
8400
+ this.eventbus.broadcast("timeline-current-timeline-change", [this._currentTimelineUri]);
8401
+ const newProviderSettings = this.timelineProviders[timelineConfig.type];
8402
+ if (this._activeTimelineProvider !== newProviderSettings.provider) {
8403
+ this._activeTimelineProvider.destroy();
8404
+ this._activeTimelineProvider = newProviderSettings.provider;
8405
+ }
8406
+ this._activeTimelineProvider.loop = timelineConfig.loop;
8407
+ if (!this._activeTimelineProvider.loop && position > 0) this.eventbus.once("timeline-firstframe", async () => {
8408
+ if (!this._activeTimelineProvider) return;
8409
+ this._activeTimelineProvider.pause();
8410
+ this.eventbus.broadcast("timeline-duration", [this._activeTimelineProvider.getDuration]);
8411
+ await this._executeStartActions();
8412
+ const seekPosition = await this._activeTimelineProvider.seek(position);
8413
+ this.seekRequest(seekPosition);
8414
+ });
8415
+ this._activeTimelineProvider.playlistItem(uri);
8416
+ }
8417
+ _cleanUpTimeline() {
8418
+ return this._executeRelevantActions(this._getActiveActions, "end");
8419
+ }
8420
+ _executeStartActions() {
8421
+ return this._executeRelevantActions(this._getActionsForPosition.bind(this, 0), "start");
8422
+ }
8423
+ /**
8424
+ * Gets all of the inactive actions whose duration falls within the given timeline position.
8425
+ *
8426
+ * @param position the given position
8427
+ * @param actions all of the relevant actions
8428
+ * @returns
8429
+ */
8430
+ _getActionsForPosition(position, actions) {
8431
+ return actions.filter((action) => !action.active && action.duration.start <= position && action.duration.end >= position);
8432
+ }
8433
+ _getActiveActions(allActions) {
8434
+ return allActions.filter((action) => action.active).sort(sortActionsHighestStartPositionFirst);
8435
+ }
8436
+ _executeRelevantActions(filter, executionType) {
8437
+ const timelineActions = this._getTimelineActionsForCurrentTimeline();
8438
+ const currentActions = filter.apply(this, [timelineActions]);
8439
+ return this._executeActions(currentActions, executionType);
8440
+ }
8441
+ _handleRequestTimelinePosition(floor, resultCallback) {
8442
+ resultCallback(floor(this._activeTimelineProvider?.getPosition() || -1));
8443
+ }
8444
+ _handleTimelineComplete() {
8445
+ this._cleanUpTimeline();
8446
+ }
8447
+ _getTimelineActionsForCurrentTimeline() {
8448
+ return this._getTimelineActionsForUri(this._currentTimelineUri);
8449
+ }
8450
+ _requestCurrentTimeline(resultCallback) {
8451
+ resultCallback(this._currentTimelineUri);
8452
+ }
8453
+ _getTimelineActionsForUri(uri) {
8454
+ return this._timelineLookupCache.get(uri)?.timelineActions ?? [];
8455
+ }
8456
+ _onTimeHandler(floor, position) {
8457
+ if (!Number.isNaN(position)) {
8458
+ const pos = floor(position);
8459
+ if (this._lastPosition !== pos) {
8460
+ this._executeActionsForPosition(pos);
8461
+ this.eventbus.broadcast("timeline-time", [pos]);
8462
+ }
8463
+ }
8464
+ }
8465
+ _executeActionsForPosition(position) {
8466
+ this._lastPosition = position;
8467
+ const actions = this._timeLineActionsLookup[this._currentTimelineUri];
8468
+ if (actions) actions[position]?.forEach((exec) => exec());
8469
+ }
8470
+ async _executeSeekActions(position) {
8471
+ const timelineActions = this._getTimelineActionsForCurrentTimeline();
8472
+ if (!timelineActions) return Promise.resolve();
8473
+ const currentActions = this._getActiveActions(timelineActions).filter((action) => !(action.duration.start <= position && action.duration.end >= position));
8474
+ const newActions = this._getActionsForPosition(position, timelineActions);
8475
+ await this._executeActions(currentActions, "end");
8476
+ return this._executeActions(newActions, "start");
8477
+ }
8478
+ };
8479
+ const sortActionsHighestStartPositionFirst = (a, b) => {
8480
+ if (b.duration.start < a.duration.start) return -1;
8481
+ else if (b.duration.start > a.duration.start) return 1;
8482
+ else return 0;
8483
+ };
8484
+ const sortActionMethodsHighestStartPositionFirst = (a, b) => {
8485
+ if (b.startPosition === void 0 || a.startPosition === void 0) return 0;
8486
+ if (b.startPosition < a.startPosition) return -1;
8487
+ else if (b.startPosition > a.startPosition) return 1;
8488
+ else return 0;
8489
+ };
8490
+
8764
8491
  //#endregion
8765
8492
  //#region src/importer/eligius-resource-importer.ts
8766
8493
  const operations = operation_exports;
@@ -8788,5 +8515,219 @@ var EligiusResourceImporter = class {
8788
8515
  };
8789
8516
 
8790
8517
  //#endregion
8791
- export { Action, ActionCreator, ActionCreatorFactory, ActionEditor, ActionRegistryEventbusListener, ConfigurationFactory, ConfigurationResolver, ControllerNamesProvider, DEV_TOOLS_KEY, DOMEventListenerController, DevToolEventListener, Diagnostics, EligiusEngine, EligiusResourceImporter, EndableAction, EndableActionCreator, EndableActionEditor, EngineFactory, Eventbus, LabelController, LanguageManager, LottieController, MutationObserverController, NavigationController, OperationEditor, OperationMetadataProvider, OperationNamesProvider, ProgressbarController, RequestAnimationFrameTimelineProvider, RequestVideoUriInterceptor, RoutingController, SubtitleEditor, SubtitleImporter, SubtitlesController, TimeLineEventNamesProvider, TimelineAction, TimelineActionCreator, TimelineActionEditor, TimelineProviderSettingsEditor, TimelineProvidersSettingsEditor, VideoJsTimelineProvider, 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, generateImporterSourceCode, getAttributesFromElement, getControllerFromElement, getControllerInstance, getCurrentTime, getElementDimensions, getFocusedElement, getFormData, getImport, getQueryParams, getScrollPosition, getTextContent, httpDelete, httpPost, httpPut, invokeObjectMethod, isActive, isElementInViewport, loadFromStorage, loadJson, log, mapArray, math, metadata_exports$2 as metadata, otherwise, removeClass, removeControllerFromElement, removeElement, removePropertiesFromOperationData, reparentElement, replaceString, replaceText, requestAction, saveToStorage, scrollToElement, scrollToPosition, selectElement, send, setActive, setData, setElementAttributes, setElementContent, setFocus, setFormValue, setGlobalData, setOperationData, setStyle, setVariable, sortArray, splitString, startAction, substringText, toggleClass, toggleElement, toggleFormElement, validateForm, wait, when };
8518
+ //#region src/operation/helper/set-global.ts
8519
+ function setGlobal(name, value) {
8520
+ const cache$2 = getGlobals();
8521
+ cache$2[name] = value;
8522
+ }
8523
+
8524
+ //#endregion
8525
+ //#region src/language-manager.ts
8526
+ /**
8527
+ * This class manages the labels for an {@link IEligiusEngine} instance.
8528
+ *
8529
+ * It handles the request-label-collection, request-label-collections, request-current-language and language-change events.
8530
+ *
8531
+ */
8532
+ var LanguageManager = class {
8533
+ _labelLookup;
8534
+ _eventbusRemovers = [];
8535
+ constructor(_currentLanguage, labels, _eventbus) {
8536
+ this._currentLanguage = _currentLanguage;
8537
+ this._eventbus = _eventbus;
8538
+ if (!_currentLanguage) throw new Error("language ctor arg cannot have zero length");
8539
+ setGlobal("defaultLanguage", _currentLanguage);
8540
+ this._setRootElementLang(_currentLanguage);
8541
+ this._labelLookup = this._createLabelLookup(labels);
8542
+ this._addEventbusListeners(_eventbus);
8543
+ }
8544
+ destroy() {
8545
+ this._eventbusRemovers.forEach((x) => x());
8546
+ }
8547
+ _addEventbusListeners(eventbus$1) {
8548
+ this._eventbusRemovers.push(eventbus$1.on("request-label-collection", this._handleRequestLabelCollection.bind(this)));
8549
+ this._eventbusRemovers.push(eventbus$1.on("request-label-collections", this._handleRequestLabelCollections.bind(this)));
8550
+ this._eventbusRemovers.push(eventbus$1.on("request-current-language", this._handleRequestCurrentLanguage.bind(this)));
8551
+ this._eventbusRemovers.push(eventbus$1.on("language-change", this._handleLanguageChange.bind(this)));
8552
+ }
8553
+ _handleRequestCurrentLanguage(resultCallback) {
8554
+ resultCallback(this._currentLanguage);
8555
+ }
8556
+ _handleRequestLabelCollection(labelId, resultCallback) {
8557
+ resultCallback(this._labelLookup[labelId]);
8558
+ }
8559
+ _handleRequestLabelCollections(labelIds, resultCallback) {
8560
+ resultCallback(labelIds.map((labelId) => {
8561
+ return this._labelLookup[labelId];
8562
+ }));
8563
+ }
8564
+ _handleLanguageChange(language) {
8565
+ this._currentLanguage = language;
8566
+ this._setRootElementLang(this._currentLanguage);
8567
+ }
8568
+ _setRootElementLang(language) {
8569
+ const callBack = (rootSelector) => {
8570
+ const lang = this._extractPrimaryLanguage(language);
8571
+ $(rootSelector).attr("lang", lang);
8572
+ };
8573
+ this._eventbus.broadcast("request-engine-root", [callBack]);
8574
+ }
8575
+ _extractPrimaryLanguage(culture) {
8576
+ return culture.split("-").shift();
8577
+ }
8578
+ _createLabelLookup(labels) {
8579
+ return labels.reduce((acc, label) => {
8580
+ acc[label.id] = label.labels;
8581
+ return acc;
8582
+ }, {});
8583
+ }
8584
+ };
8585
+
8586
+ //#endregion
8587
+ //#region src/engine-factory.ts
8588
+ const hotkeys = hk.default || hk;
8589
+ /**
8590
+ * The EngineFactory is used to create and initialize an {@link IEligiusEngine} instance.
8591
+ *
8592
+ * It prepares a resolved configuration and creates the engine based on the class defined in the configuration.
8593
+ *
8594
+ * @example Loading a configuration and creating an IEligiusEngine instance
8595
+ * ```ts
8596
+ * import { IEngineConfiguration, EngineFactory, WebpackResourceImporter } from 'eligius';
8597
+ * import * as engineConfig from './my-eligius-config.json';
8598
+ *
8599
+ * const factory = new EngineFactory(new WebpackResourceImporter(), window);
8600
+ *
8601
+ * const engine = factory.createEngine((engineConfig as unknown) as IEngineConfiguration);
8602
+ *
8603
+ * engine.init().then(()=> {console.log('Eligius engine ready for business');});
8604
+ * ```
8605
+ */
8606
+ var EngineFactory = class {
8607
+ _actionsLookup = {};
8608
+ _eventbus;
8609
+ _eventRemovers = [];
8610
+ _importer;
8611
+ _resizeTimeout = -1;
8612
+ constructor(importer, windowRef, options) {
8613
+ this._importer = importer;
8614
+ this._eventbus = options?.eventbus ?? new Eventbus();
8615
+ Diagnostics.active = options?.devtools ?? false;
8616
+ if (Diagnostics.active) this._initializeDevtools(this._eventbus);
8617
+ this._eventRemovers.push(this._eventbus.on("request-instance", this._requestInstanceHandler.bind(this)));
8618
+ this._eventRemovers.push(this._eventbus.on("request-action", this._requestActionHandler.bind(this)));
8619
+ this._eventRemovers.push(this._eventbus.on("request-function", this._requestFunctionHandler.bind(this)));
8620
+ const handleSpaceBound = this._handleSpacePress.bind(this);
8621
+ hotkeys("space", handleSpaceBound);
8622
+ this._eventRemovers.push(() => hotkeys.unbind("space", handleSpaceBound));
8623
+ const resizeBound = this._resizeHandler.bind(this);
8624
+ const jqWin = $(windowRef);
8625
+ jqWin.on("resize", resizeBound);
8626
+ this._eventRemovers.push(() => jqWin.off("resize", resizeBound));
8627
+ }
8628
+ _handleSpacePress(keyboardEvent, _hotkeysEvent) {
8629
+ keyboardEvent.preventDefault();
8630
+ this._eventbus.broadcast("timeline-play-toggle-request", []);
8631
+ return false;
8632
+ }
8633
+ _initializeDevtools(eventbus$1) {
8634
+ const diagnosticInfo = window[DEV_TOOLS_KEY];
8635
+ if (diagnosticInfo) {
8636
+ const { agent } = diagnosticInfo;
8637
+ this._eventRemovers.push(eventbus$1.registerEventlistener(new DevToolEventListener(agent)));
8638
+ this._eventRemovers.push(agent.subscribe((message) => {
8639
+ if (message.type === "playcontrol") switch (message.data.kind) {
8640
+ case "play":
8641
+ this._eventbus.broadcast("timeline-play-request", []);
8642
+ break;
8643
+ case "stop":
8644
+ this._eventbus.broadcast("timeline-stop-request", []);
8645
+ break;
8646
+ case "pause":
8647
+ this._eventbus.broadcast("timeline-pause-request", []);
8648
+ break;
8649
+ case "seek":
8650
+ this._eventbus.broadcast("timeline-seek-request", [message.data.args ?? 0]);
8651
+ break;
8652
+ }
8653
+ }));
8654
+ Diagnostics.send = (name, messageData) => {
8655
+ const message = prepareValueForSerialization(messageData);
8656
+ try {
8657
+ agent.postMessage(name, message);
8658
+ } catch (e) {
8659
+ console.error("postmessage failed");
8660
+ console.error(e);
8661
+ console.log("message", message);
8662
+ }
8663
+ };
8664
+ Diagnostics.send("eligius-diagnostics-factory", "Diagnostics initialized");
8665
+ } else console.warn(`${DEV_TOOLS_KEY} property not found on window, please install the Eligius Devtools extension.`);
8666
+ }
8667
+ destroy() {
8668
+ this._eventRemovers.forEach((x) => x());
8669
+ }
8670
+ _resizeHandler() {
8671
+ if (this._resizeTimeout) {
8672
+ clearTimeout(this._resizeTimeout);
8673
+ this._resizeTimeout = -1;
8674
+ }
8675
+ this._resizeTimeout = setTimeout(() => {
8676
+ this._eventbus.broadcast("timeline-resize", []);
8677
+ }, 200);
8678
+ }
8679
+ _importSystemEntryWithEventbusDependency(systemName) {
8680
+ return new (this._importSystemEntry(systemName))(this._eventbus);
8681
+ }
8682
+ _importSystemEntry(systemName) {
8683
+ return this._importer.import(systemName)[systemName];
8684
+ }
8685
+ _requestInstanceHandler(systemName, resultCallback) {
8686
+ resultCallback(this._importSystemEntryWithEventbusDependency(systemName));
8687
+ }
8688
+ _requestFunctionHandler(systemName, resultCallback) {
8689
+ resultCallback(this._importSystemEntry(systemName));
8690
+ }
8691
+ _requestActionHandler(systemName, resultCallback) {
8692
+ const action = this._actionsLookup[systemName];
8693
+ if (action) resultCallback(action);
8694
+ else {
8695
+ console.error(`Unknown action: ${systemName}`);
8696
+ resultCallback(null);
8697
+ }
8698
+ }
8699
+ createEngine(configuration, resolver) {
8700
+ const { systemName } = configuration.engine;
8701
+ const EngineClass = this._importSystemEntry(systemName);
8702
+ let actionRegistryListener;
8703
+ if (configuration.eventActions?.length) {
8704
+ actionRegistryListener = new ActionRegistryEventbusListener();
8705
+ this._eventRemovers.push(this._eventbus.registerEventlistener(actionRegistryListener));
8706
+ }
8707
+ this._eventRemovers.push(this._eventbus.registerInterceptor("request-timeline-uri", new RequestVideoUriInterceptor(this._eventbus)));
8708
+ resolver = resolver || new ConfigurationResolver(this._importer, this._eventbus);
8709
+ const [actionLookup, resolvedConfiguration] = resolver.process(configuration, actionRegistryListener);
8710
+ this._actionsLookup = actionLookup;
8711
+ const timelineProviders = this._createTimelineProviders(resolvedConfiguration);
8712
+ const { language, labels } = configuration;
8713
+ const languageManager = new LanguageManager(language, labels, this._eventbus);
8714
+ return new EngineClass(resolvedConfiguration, this._eventbus, timelineProviders, languageManager);
8715
+ }
8716
+ _createTimelineProviders(configuration) {
8717
+ const { timelineProviderSettings } = configuration;
8718
+ return Object.entries(timelineProviderSettings).reduce((acc, [timelineType, settings]) => {
8719
+ if (!settings) return acc;
8720
+ const TimelineProviderClass = this._importSystemEntry(settings.systemName);
8721
+ acc[timelineType] = {
8722
+ id: settings.id,
8723
+ vendor: settings.vendor,
8724
+ provider: new TimelineProviderClass(configuration)
8725
+ };
8726
+ return acc;
8727
+ }, {});
8728
+ }
8729
+ };
8730
+
8731
+ //#endregion
8732
+ export { Action, ActionCreator, ActionCreatorFactory, ActionEditor, ActionRegistryEventbusListener, ConfigurationFactory, ConfigurationResolver, ControllerNamesProvider, DEV_TOOLS_KEY, DOMEventListenerController, DevToolEventListener, Diagnostics, EligiusEngine, EligiusResourceImporter, EndableAction, EndableActionCreator, EndableActionEditor, EngineFactory, Eventbus, LabelController, LanguageManager, LottieController, MutationObserverController, NavigationController, OperationEditor, OperationMetadataProvider, OperationNamesProvider, ProgressbarController, RequestAnimationFrameTimelineProvider, RequestVideoUriInterceptor, RoutingController, SubtitleEditor, SubtitleImporter, SubtitlesController, TimeLineEventNamesProvider, TimelineAction, TimelineActionCreator, TimelineActionEditor, TimelineProviderSettingsEditor, TimelineProvidersSettingsEditor, VideoJsTimelineProvider, 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, isActive, isElementInViewport, loadFromStorage, loadJson, log, mapArray, math, metadata_exports$2 as metadata, otherwise, removeClass, removeControllerFromElement, removeElement, removePropertiesFromOperationData, reparentElement, replaceString, replaceText, requestAction, saveToStorage, scrollToElement, scrollToPosition, selectElement, send, setActive, setData, setElementAttributes, setElementContent, setFocus, setFormValue, setGlobalData, setOperationData, setStyle, setVariable, sortArray, splitString, startAction, substringText, toggleClass, toggleElement, toggleFormElement, validateForm, wait, when };
8792
8733
  //# sourceMappingURL=index.mjs.map