eligius 1.1.0 → 1.1.2

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.
@@ -726,7 +726,7 @@ var TimelineAction = /*#__PURE__*/function (_EndableAction) {
726
726
 
727
727
  _this = _EndableAction.call(this, name, startOperations, endOperations, eventBus) || this;
728
728
  _this.duration = void 0;
729
- _this.active = false;
729
+ _this._active = false;
730
730
  _this.duration = duration;
731
731
  return _this;
732
732
  }
@@ -735,7 +735,7 @@ var TimelineAction = /*#__PURE__*/function (_EndableAction) {
735
735
 
736
736
  _proto.start = function start(initOperationData) {
737
737
  if (!this.active || this.duration.end < 0) {
738
- this.active = this.duration.end > -1;
738
+ this._active = this.endOperations.length > 0;
739
739
  return _EndableAction.prototype.start.call(this, initOperationData);
740
740
  }
741
741
 
@@ -743,10 +743,17 @@ var TimelineAction = /*#__PURE__*/function (_EndableAction) {
743
743
  };
744
744
 
745
745
  _proto.end = function end(initOperationData) {
746
- this.active = false;
746
+ this._active = false;
747
747
  return _EndableAction.prototype.end.call(this, initOperationData);
748
748
  };
749
749
 
750
+ _createClass(TimelineAction, [{
751
+ key: "active",
752
+ get: function get() {
753
+ return this._active;
754
+ }
755
+ }]);
756
+
750
757
  return TimelineAction;
751
758
  }(EndableAction);
752
759
 
@@ -1124,6 +1131,10 @@ function getPropertyChainValue(propertyChain, sourceObject) {
1124
1131
  var currentInstance = sourceObject;
1125
1132
  var suffix = null;
1126
1133
  propertyChain.forEach(function (prop, index) {
1134
+ if (!currentInstance) {
1135
+ throw new Error("Property chain '" + propertyChain.join('.') + "' cannot be resolved.");
1136
+ }
1137
+
1127
1138
  if (index === propertyChain.length - 1) {
1128
1139
  var parts = prop.split('+');
1129
1140
 
@@ -1405,8 +1416,6 @@ TimelineEventNames.BEFORE_REQUEST_TIMELINE_URI = 'before-request-timeline-uri';
1405
1416
  TimelineEventNames.REQUEST_ENGINE_ROOT = 'request-engine-root';
1406
1417
  TimelineEventNames.REQUEST_CURRENT_TIMELINE_POSITION = 'request-current-timeline-position';
1407
1418
  TimelineEventNames.REQUEST_TIMELINE_CLEANUP = 'request-timeline-cleanup';
1408
- TimelineEventNames.EXECUTE_TIMELINEACTION = 'execute-timelineaction';
1409
- TimelineEventNames.RESIZE_TIMELINEACTION = 'resize-timelineaction';
1410
1419
  TimelineEventNames.REQUEST_LABEL_COLLECTION = 'request-label-collection';
1411
1420
  TimelineEventNames.REQUEST_LABEL_COLLECTIONS = 'request-label-collections';
1412
1421
  TimelineEventNames.REQUEST_CURRENT_LANGUAGE = 'request-current-language';
@@ -1502,6 +1511,24 @@ var extendController$1 = function extendController(operationData) {
1502
1511
  return operationData;
1503
1512
  };
1504
1513
 
1514
+ /**
1515
+ * This operation retrieves the values for the specified attribute names from the given selected element.
1516
+ */
1517
+ var getAttributesFromElement$1 = function getAttributesFromElement(operationData) {
1518
+ var selectedElement = operationData.selectedElement,
1519
+ attributeNames = operationData.attributeNames;
1520
+ operationData.attributeValues = attributeNames.reduce(function (acc, attrName) {
1521
+ if (attrName !== 'value') {
1522
+ acc[attrName] = selectedElement == null ? void 0 : selectedElement.attr(attrName);
1523
+ } else {
1524
+ acc[attrName] = selectedElement == null ? void 0 : selectedElement.val();
1525
+ }
1526
+
1527
+ return acc;
1528
+ }, {});
1529
+ return operationData;
1530
+ };
1531
+
1505
1532
  /**
1506
1533
  * This operation retrieves the controller instance with the specified name that is assigned to the given selected element.
1507
1534
  *
@@ -1879,20 +1906,18 @@ var loadJSON$1 = /*#__PURE__*/function () {
1879
1906
  }();
1880
1907
 
1881
1908
  /**
1882
- * This operation logs the current operation data and context to the console.
1909
+ * This operation logs the current operation data, global data and context to the console.
1883
1910
  *
1884
1911
  * @param operationData
1885
1912
  * @returns
1886
1913
  */
1887
1914
 
1888
1915
  var log$1 = function log(operationData) {
1916
+ var globalData = getGlobals();
1889
1917
  console.group('Operation info');
1890
- console.dir({
1891
- context: deepCopy(this)
1892
- });
1893
- console.dir({
1894
- operationData: deepCopy(operationData)
1895
- });
1918
+ console.log('context', this);
1919
+ console.log('operationData', operationData);
1920
+ console.log('globalData', globalData);
1896
1921
  console.groupEnd();
1897
1922
  return operationData;
1898
1923
  };
@@ -2144,6 +2169,7 @@ function findElementBySelector(root, selector) {
2144
2169
 
2145
2170
 
2146
2171
  var selectElement$1 = function selectElement(operationData) {
2172
+ operationData.selector = resolveExternalPropertyChain(operationData, this, operationData.selector);
2147
2173
  var selector = operationData.selector,
2148
2174
  _operationData$useSel = operationData.useSelectedElementAsRoot,
2149
2175
  useSelectedElementAsRoot = _operationData$useSel === void 0 ? false : _operationData$useSel;
@@ -2166,6 +2192,59 @@ var selectElement$1 = function selectElement(operationData) {
2166
2192
  return operationData;
2167
2193
  };
2168
2194
 
2195
+ /**
2196
+ * This operation assigns the specified properties to the specified data targets.
2197
+ *
2198
+ * @example The various ways of assigning data
2199
+ * ```ts
2200
+ * setData({
2201
+ * 'operationdata.foo': 'context.currentItem', // context.currentItem will be assigned to operationdata.foo
2202
+ * 'globaldata.foo': 'context.currentItem', // context.currentItem will be assigned to globaldata.foo
2203
+ * 'context.newIndex': 100, // The constant 100 will be assigned to context.newIndex
2204
+ * })
2205
+ * ```
2206
+ *
2207
+ * @param operationData
2208
+ * @returns
2209
+ */
2210
+
2211
+ var setData$1 = function setData(operationData) {
2212
+ var properties = operationData.properties;
2213
+ delete operationData.properties;
2214
+ resolveTargets(properties, operationData, this);
2215
+ return operationData;
2216
+ };
2217
+
2218
+ function resolveTargets(data, operationData, context) {
2219
+ var propertyChains = Object.keys(data);
2220
+ return propertyChains.forEach(function (item) {
2221
+ var _path$shift$toLowerCa, _path$shift, _path$pop;
2222
+
2223
+ var path = item.split('.');
2224
+ var rootTarget = (_path$shift$toLowerCa = (_path$shift = path.shift()) == null ? void 0 : _path$shift.toLowerCase()) != null ? _path$shift$toLowerCa : '';
2225
+
2226
+ if (!isDataTarget(rootTarget)) {
2227
+ throw new Error("Unrecognized target: " + rootTarget + ", known targets are: " + knownTargets.join(', '));
2228
+ }
2229
+
2230
+ var property = (_path$pop = path.pop()) != null ? _path$pop : '';
2231
+ var propertyValue = resolveExternalPropertyChain(operationData, context, data[item]);
2232
+ var targets = {
2233
+ context: context,
2234
+ operationdata: operationData,
2235
+ globaldata: getGlobals()
2236
+ };
2237
+ var propertyTarget = getPropertyChainValue(path, targets[rootTarget]);
2238
+ propertyTarget[property] = propertyValue;
2239
+ });
2240
+ }
2241
+
2242
+ var knownTargets = ['context', 'operationdata', 'globaldata'];
2243
+
2244
+ function isDataTarget(value) {
2245
+ return knownTargets.includes(value);
2246
+ }
2247
+
2169
2248
  /**
2170
2249
  * This operation sets the specified set of attributes on the given selected element.
2171
2250
  *
@@ -2494,6 +2573,7 @@ var ops = {
2494
2573
  endLoop: endLoop$1,
2495
2574
  endWhen: endWhen$1,
2496
2575
  extendController: extendController$1,
2576
+ getAttributesFromElement: getAttributesFromElement$1,
2497
2577
  getControllerFromElement: getControllerFromElement$1,
2498
2578
  getControllerInstance: getControllerInstance$1,
2499
2579
  getElementDimensions: getElementDimensions$1,
@@ -2512,6 +2592,7 @@ var ops = {
2512
2592
  requestAction: requestAction$1,
2513
2593
  resizeAction: resizeAction$1,
2514
2594
  selectElement: selectElement$1,
2595
+ setData: setData$1,
2515
2596
  setElementAttributes: setElementAttributes$1,
2516
2597
  setElementContent: setElementContent$1,
2517
2598
  setGlobalData: setGlobalData$1,
@@ -3039,6 +3120,53 @@ var OperationEditor = /*#__PURE__*/function () {
3039
3120
  return OperationEditor;
3040
3121
  }();
3041
3122
 
3123
+ var LabelEditor = /*#__PURE__*/function () {
3124
+ function LabelEditor(factory, languageLabel) {
3125
+ this.factory = void 0;
3126
+ this.languageLabel = void 0;
3127
+ this.factory = factory;
3128
+ this.languageLabel = languageLabel;
3129
+ }
3130
+
3131
+ var _proto = LabelEditor.prototype;
3132
+
3133
+ _proto._internalGetLabel = function _internalGetLabel(languageCode) {
3134
+ return this.languageLabel.labels.find(function (x) {
3135
+ return x.languageCode === languageCode;
3136
+ });
3137
+ };
3138
+
3139
+ _proto.setLabel = function setLabel(languageCode, translation) {
3140
+ var label = this._internalGetLabel(languageCode);
3141
+
3142
+ if (label) ; else {
3143
+ throw new Error("No label found for language code '" + languageCode + "'");
3144
+ }
3145
+
3146
+ return this;
3147
+ };
3148
+
3149
+ _proto.removeLabel = function removeLabel(languageCode) {
3150
+ var idx = this.languageLabel.labels.findIndex(function (x) {
3151
+ return x.languageCode === languageCode;
3152
+ });
3153
+
3154
+ if (idx > -1) {
3155
+ this.languageLabel.labels.splice(idx, 1);
3156
+ } else {
3157
+ throw new Error("No label found for language code '" + languageCode + "'");
3158
+ }
3159
+
3160
+ return this;
3161
+ };
3162
+
3163
+ _proto.end = function end() {
3164
+ return this.factory;
3165
+ };
3166
+
3167
+ return LabelEditor;
3168
+ }();
3169
+
3042
3170
  // https://gist.github.com/jakearchibald/cb03f15670817001b1157e62a076fe95
3043
3171
  function animationInterval(ms, signal, callback) {
3044
3172
  var _document$timeline$cu, _document, _document$timeline;
@@ -3358,7 +3486,7 @@ var TimelineProviderSettingsEditor = /*#__PURE__*/function () {
3358
3486
  }();
3359
3487
 
3360
3488
  /**
3361
- * This class offers a fluent and strongly typed DSL for creating Eligius configurations.
3489
+ * This class offers a fluent, extensible and strongly typed DSL for creating Eligius configurations.
3362
3490
  *
3363
3491
  * @example Building a configuration using the factory
3364
3492
  * To initialize a basic configuration to start off of:
@@ -3511,10 +3639,7 @@ var ConfigurationFactory = /*#__PURE__*/function () {
3511
3639
 
3512
3640
  if (callBack) {
3513
3641
  var newConfig = callBack.call(this, copy);
3514
-
3515
- if (newConfig) {
3516
- this.configuration = newConfig;
3517
- }
3642
+ this.configuration = deepCopy(newConfig);
3518
3643
  }
3519
3644
 
3520
3645
  return copy;
@@ -3668,6 +3793,20 @@ var ConfigurationFactory = /*#__PURE__*/function () {
3668
3793
  return translation;
3669
3794
  };
3670
3795
 
3796
+ _proto.editLabel = function editLabel(id) {
3797
+ var _this$configuration$l;
3798
+
3799
+ var label = (_this$configuration$l = this.configuration.labels) == null ? void 0 : _this$configuration$l.find(function (x) {
3800
+ return x.id === id;
3801
+ });
3802
+
3803
+ if (label) {
3804
+ return new LabelEditor(this, label);
3805
+ } else {
3806
+ throw new Error("Language label with id '" + id + "' not found");
3807
+ }
3808
+ };
3809
+
3671
3810
  _proto.addLabel = function addLabel(id, code, translation) {
3672
3811
  var labels = this._initializeCollection(this.configuration, 'labels');
3673
3812
 
@@ -3679,6 +3818,17 @@ var ConfigurationFactory = /*#__PURE__*/function () {
3679
3818
  return this;
3680
3819
  };
3681
3820
 
3821
+ _proto.addLabels = function addLabels(id, translations) {
3822
+ var _this = this;
3823
+
3824
+ Object.entries(translations).forEach(function (_ref2) {
3825
+ var code = _ref2[0],
3826
+ translation = _ref2[1];
3827
+ return _this.addLabel(id, code, translation);
3828
+ });
3829
+ return this;
3830
+ };
3831
+
3682
3832
  _proto.removeLabel = function removeLabel(id) {
3683
3833
  var idx = this.configuration.labels.findIndex(function (x) {
3684
3834
  return x.id === id;
@@ -3833,7 +3983,7 @@ var EventListenerController = /*#__PURE__*/function () {
3833
3983
  var actionOperationData = this.operationData.actionOperationData ? deepCopy(this.operationData.actionOperationData) : {};
3834
3984
 
3835
3985
  if (event.target) {
3836
- actionOperationData.targetValue = event.target.value;
3986
+ actionOperationData.eventTarget = event.target;
3837
3987
  }
3838
3988
 
3839
3989
  this._executeAction(this.actionInstanceInfos, actionOperationData, 0);
@@ -3939,7 +4089,11 @@ var LabelController = /*#__PURE__*/function () {
3939
4089
  var _this2 = this;
3940
4090
 
3941
4091
  eventbus.broadcast(TimelineEventNames.REQUEST_LABEL_COLLECTION, [labelId, function (labelCollection) {
3942
- _this2._createTextDataLookup(labelCollection);
4092
+ if (labelCollection) {
4093
+ _this2._createTextDataLookup(labelCollection);
4094
+ } else {
4095
+ throw new Error("Label id '" + labelId + "' does not exist!");
4096
+ }
3943
4097
  }]);
3944
4098
  };
3945
4099
 
@@ -3947,7 +4101,17 @@ var LabelController = /*#__PURE__*/function () {
3947
4101
  if (this.currentLanguage) {
3948
4102
  var _this$operationData;
3949
4103
 
3950
- (_this$operationData = this.operationData) == null ? void 0 : _this$operationData.selectedElement.html(this.labelData[this.currentLanguage]);
4104
+ var text = this.labelData[this.currentLanguage];
4105
+
4106
+ if (!((_this$operationData = this.operationData) != null && _this$operationData.attributeName)) {
4107
+ var _this$operationData2;
4108
+
4109
+ (_this$operationData2 = this.operationData) == null ? void 0 : _this$operationData2.selectedElement.html(text);
4110
+ } else {
4111
+ var _this$operationData3, _this$operationData4;
4112
+
4113
+ (_this$operationData3 = this.operationData) == null ? void 0 : _this$operationData3.selectedElement.attr((_this$operationData4 = this.operationData) == null ? void 0 : _this$operationData4.attributeName, text);
4114
+ }
3951
4115
  }
3952
4116
  };
3953
4117
 
@@ -4721,7 +4885,7 @@ var SubtitlesController = /*#__PURE__*/function () {
4721
4885
 
4722
4886
  for (var j = 0, jj = subtitleData.length; j < jj; j++) {
4723
4887
  var subs = subtitleData[j];
4724
- titleLanguageLookup[subs.lang] = subs.titles[i].text;
4888
+ titleLanguageLookup[subs.languageCode] = subs.titles[i].text;
4725
4889
  }
4726
4890
 
4727
4891
  subtitleTimeLookup[titles[i].duration.start] = this.setTitle.bind(this, container, titleLanguageLookup);
@@ -4935,6 +5099,23 @@ function extendController() {
4935
5099
  };
4936
5100
  }
4937
5101
 
5102
+ function getAttributesFromElement() {
5103
+ return {
5104
+ description: 'Retrieves the values for the specified attribute names from the given selected element.',
5105
+ dependentProperties: ['selectedElement'],
5106
+ properties: {
5107
+ attributeNames: {
5108
+ type: 'ParameterType:array',
5109
+ itemType: 'ParameterType:string',
5110
+ required: true
5111
+ }
5112
+ },
5113
+ outputProperties: {
5114
+ attributeValues: 'ParameterType:object'
5115
+ }
5116
+ };
5117
+ }
5118
+
4938
5119
  function getControllerFromElement() {
4939
5120
  return {
4940
5121
  description: 'Retrieves the specified controller from the current element',
@@ -5171,6 +5352,18 @@ function selectElement() {
5171
5352
  };
5172
5353
  }
5173
5354
 
5355
+ function setData() {
5356
+ return {
5357
+ description: 'Copies the specified values to the specified targets',
5358
+ properties: {
5359
+ properties: {
5360
+ type: 'ParameterType:object',
5361
+ required: true
5362
+ }
5363
+ }
5364
+ };
5365
+ }
5366
+
5174
5367
  function setElementAttributes() {
5175
5368
  return {
5176
5369
  description: 'Sets the given attributes on the selected element',
@@ -5324,6 +5517,7 @@ var operationMetadata = {
5324
5517
  endLoop: endLoop,
5325
5518
  endWhen: endWhen,
5326
5519
  extendController: extendController,
5520
+ getAttributesFromElement: getAttributesFromElement,
5327
5521
  getControllerFromElement: getControllerFromElement,
5328
5522
  getControllerInstance: getControllerInstance,
5329
5523
  getElementDimensions: getElementDimensions,
@@ -5342,6 +5536,7 @@ var operationMetadata = {
5342
5536
  requestAction: requestAction,
5343
5537
  resizeAction: resizeAction,
5344
5538
  selectElement: selectElement,
5539
+ setData: setData,
5345
5540
  setElementAttributes: setElementAttributes,
5346
5541
  setElementContent: setElementContent,
5347
5542
  setGlobalData: setGlobalData,
@@ -5406,6 +5601,187 @@ var TimeLineEventNamesProvider = /*#__PURE__*/function () {
5406
5601
  return TimeLineEventNamesProvider;
5407
5602
  }();
5408
5603
 
5604
+ /**
5605
+ * This class converts an AVID subtitle file to an `ISubtitle` array.
5606
+ */
5607
+ var SubtitleImporter = /*#__PURE__*/function () {
5608
+ function SubtitleImporter() {}
5609
+
5610
+ var _proto = SubtitleImporter.prototype;
5611
+
5612
+ _proto.importSubtitles = function importSubtitles(rawLines) {
5613
+ var _this = this;
5614
+
5615
+ var result = [];
5616
+ var lines = [];
5617
+
5618
+ for (var i = 0, l = rawLines.length; i < l; i++) {
5619
+ var rawLine = this.stripNewlineChars(rawLines[i].toString());
5620
+
5621
+ if (this.isValidLine(rawLine)) {
5622
+ lines.push(rawLine);
5623
+ }
5624
+ }
5625
+
5626
+ if (lines[0] === '') {
5627
+ lines.splice(0, 1);
5628
+ }
5629
+
5630
+ while (lines[lines.length - 1] === '') {
5631
+ lines.pop();
5632
+ }
5633
+
5634
+ var caption = null;
5635
+ lines.forEach(function (line) {
5636
+ if (line.length === 0 || !caption) {
5637
+ caption = {
5638
+ text: ''
5639
+ };
5640
+
5641
+ if (line.length) {
5642
+ //this happens for first caption only
5643
+ caption.duration = _this.convertDuration(line);
5644
+ }
5645
+
5646
+ result.push(caption);
5647
+ } else {
5648
+ if (!caption.hasOwnProperty('duration')) {
5649
+ caption.duration = _this.convertDuration(line);
5650
+ } else {
5651
+ caption.text += line;
5652
+ }
5653
+ }
5654
+ });
5655
+ return result;
5656
+ };
5657
+
5658
+ _proto.stripNewlineChars = function stripNewlineChars(str) {
5659
+ var res = '';
5660
+
5661
+ for (var i = 0, l = str.length; i < l; i++) {
5662
+ if (str.charCodeAt(i) !== 13 && str.charCodeAt(i) !== 0) {
5663
+ res += str.charAt(i);
5664
+ }
5665
+ }
5666
+
5667
+ return res;
5668
+ };
5669
+
5670
+ _proto.isValidLine = function isValidLine(line) {
5671
+ return !line.startsWith('@') && !line.startsWith('<begin subtitles>') && !line.startsWith('<end subtitles>');
5672
+ };
5673
+
5674
+ _proto.convertDuration = function convertDuration(time) {
5675
+ var times = time.split(' ');
5676
+ return {
5677
+ start: this.convertTimeToSeconds(times[0]),
5678
+ end: this.convertTimeToSeconds(times[1])
5679
+ };
5680
+ };
5681
+
5682
+ _proto.convertTimeToSeconds = function convertTimeToSeconds(time) {
5683
+ var parts = time.split(':');
5684
+ return parseInt(parts[0], 10) * 3600 + parseInt(parts[1], 10) * 60 + parseInt(parts[2], 10);
5685
+ };
5686
+
5687
+ return SubtitleImporter;
5688
+ }();
5689
+
5690
+ /**
5691
+ * Used to edit and add to an {@link ISubtitleCollection}.
5692
+ */
5693
+
5694
+ var SubtitleEditor = /*#__PURE__*/function () {
5695
+ function SubtitleEditor(collection) {
5696
+ if (collection === void 0) {
5697
+ collection = [];
5698
+ }
5699
+
5700
+ this.collection = void 0;
5701
+ this.collection = collection;
5702
+ }
5703
+
5704
+ var _proto = SubtitleEditor.prototype;
5705
+
5706
+ _proto._getLanguage = function _getLanguage(languageCode) {
5707
+ return this.collection.find(function (x) {
5708
+ return x.languageCode === languageCode;
5709
+ });
5710
+ };
5711
+
5712
+ _proto.addLanguage = function addLanguage(languageCode) {
5713
+ var language = this._getLanguage(languageCode);
5714
+
5715
+ if (language) {
5716
+ throw new Error("Language " + languageCode + " already exists.");
5717
+ }
5718
+
5719
+ var newLanguage = this.collection.length ? _extends({}, this.collection[0], {
5720
+ titles: this.collection[0].titles.map(function (x) {
5721
+ return {
5722
+ id: v4(),
5723
+ duration: _extends({}, x.duration),
5724
+ text: ''
5725
+ };
5726
+ })
5727
+ }) : {
5728
+ languageCode: languageCode,
5729
+ titles: []
5730
+ };
5731
+ this.collection.push(newLanguage);
5732
+ return this;
5733
+ };
5734
+
5735
+ _proto.addSubtitle = function addSubtitle(languageCode, subtitle) {
5736
+ var language = this._getLanguage(languageCode);
5737
+
5738
+ if (!language) {
5739
+ throw new Error("Language " + languageCode + " does not exist.");
5740
+ }
5741
+
5742
+ language.titles.push(subtitle);
5743
+ return this;
5744
+ };
5745
+
5746
+ _proto.addSubtitles = function addSubtitles(subtitles) {
5747
+ var _this = this;
5748
+
5749
+ Object.entries(subtitles).forEach(function (_ref) {
5750
+ var languageCode = _ref[0],
5751
+ subtitle = _ref[1];
5752
+ return _this.addSubtitle(languageCode, subtitle);
5753
+ });
5754
+ return this;
5755
+ };
5756
+
5757
+ _proto.setSubtitle = function setSubtitle(languageCode, subtitle) {
5758
+ var language = this._getLanguage(languageCode);
5759
+
5760
+ if (!language) {
5761
+ throw new Error("Language " + languageCode + " does not exist.");
5762
+ }
5763
+
5764
+ var titleIdx = language.titles.findIndex(function (x) {
5765
+ return x.id === subtitle.id;
5766
+ });
5767
+
5768
+ if (titleIdx < 0) {
5769
+ throw new Error("Subtitle with id '" + subtitle.id + "' was not found in language with code " + languageCode + ".");
5770
+ }
5771
+
5772
+ language.titles[titleIdx] = _extends({}, subtitle, {
5773
+ duration: _extends({}, subtitle.duration)
5774
+ });
5775
+ return this;
5776
+ };
5777
+
5778
+ _proto["export"] = function _export() {
5779
+ return this.collection;
5780
+ };
5781
+
5782
+ return SubtitleEditor;
5783
+ }();
5784
+
5409
5785
  /**
5410
5786
  * Gets the value for the given property chain. A property chain is defined by a period delimited string.
5411
5787
  *
@@ -5854,10 +6230,6 @@ var EligiusEngine = /*#__PURE__*/function () {
5854
6230
 
5855
6231
  this._addEventListener(TimelineEventNames.REQUEST_TIMELINE_CLEANUP, this._handleTimelineComplete.bind(this));
5856
6232
 
5857
- this._addEventListener(TimelineEventNames.EXECUTE_TIMELINEACTION, this._handleExecuteTimelineAction.bind(this));
5858
-
5859
- this._addEventListener(TimelineEventNames.RESIZE_TIMELINEACTION, this._resizeTimelineAction.bind(this));
5860
-
5861
6233
  this._addEventListener(TimelineEventNames.REQUEST_CURRENT_TIMELINE, this._requestCurrentTimeline.bind(this));
5862
6234
 
5863
6235
  this._addEventListener(TimelineEventNames.PLAY_TOGGLE_REQUEST, this._toggleplay.bind(this));
@@ -6004,11 +6376,35 @@ var EligiusEngine = /*#__PURE__*/function () {
6004
6376
  // actions ends need to be in reversed order, otherwise, for example,
6005
6377
  // elements that were created before dependent actions will already have been
6006
6378
  // removed in the end phase.
6007
- var reversed = [].concat(timelineInfo.timelineActions).reverse();
6008
- reversed.forEach(_this._addTimelineActionEnd.bind(_this, timelineInfo.uri));
6379
+ timelineInfo.timelineActions.forEach(_this._addTimelineActionEnd.bind(_this, timelineInfo.uri));
6380
+ });
6381
+ EligiusEngine.sortTimelines(Object.values(this._timeLineActionsLookup));
6382
+ };
6383
+
6384
+ EligiusEngine.sortTimelines = function sortTimelines(timelines) {
6385
+ timelines.forEach(function (timelineActions) {
6386
+ Object.keys(timelineActions).forEach(function (key) {
6387
+ return timelineActions[key] = EligiusEngine.sortActionsPerPosition(timelineActions[key]);
6388
+ });
6009
6389
  });
6010
6390
  };
6011
6391
 
6392
+ EligiusEngine.sortActionsPerPosition = function sortActionsPerPosition(actions) {
6393
+ var _actions$reduce = actions.reduce(function (acc, item) {
6394
+ if (item.isStart) {
6395
+ acc[0].push(item);
6396
+ } else {
6397
+ acc[1].push(item);
6398
+ }
6399
+
6400
+ return acc;
6401
+ }, [[], []]),
6402
+ startMethods = _actions$reduce[0],
6403
+ endMethods = _actions$reduce[1];
6404
+
6405
+ return [].concat(endMethods.sort(sortActionMethodsHighestStartPositionFirst), startMethods);
6406
+ };
6407
+
6012
6408
  _proto._addTimelineActionStart = function _addTimelineActionStart(uri, timeLineAction) {
6013
6409
  var _timeLineAction$id;
6014
6410
 
@@ -6020,9 +6416,9 @@ var EligiusEngine = /*#__PURE__*/function () {
6020
6416
 
6021
6417
  if ((_timeLineAction$id = timeLineAction.id) != null && _timeLineAction$id.length) {
6022
6418
  startMethod.id = timeLineAction.id;
6023
- startMethod.isStart = true;
6024
6419
  }
6025
6420
 
6421
+ startMethod.isStart = true;
6026
6422
  timelineStartPositions.push(startMethod);
6027
6423
  };
6028
6424
 
@@ -6034,14 +6430,18 @@ var EligiusEngine = /*#__PURE__*/function () {
6034
6430
  }
6035
6431
 
6036
6432
  if (isFinite(end)) {
6433
+ var _timeLineAction$id2;
6434
+
6037
6435
  var timelineEndPositions = this._initializeTimelinePosition(this._timeLineActionsLookup[uri], end);
6038
6436
 
6039
6437
  var endMethod = timeLineAction.end.bind(timeLineAction);
6040
6438
 
6041
- if (!timeLineAction.id) {
6439
+ if ((_timeLineAction$id2 = timeLineAction.id) != null && _timeLineAction$id2.length) {
6042
6440
  endMethod.id = timeLineAction.id;
6441
+ endMethod.startPosition = timeLineAction.duration.start;
6043
6442
  }
6044
6443
 
6444
+ endMethod.isStart = false;
6045
6445
  timelineEndPositions.push(endMethod);
6046
6446
  }
6047
6447
  };
@@ -6241,11 +6641,11 @@ var EligiusEngine = /*#__PURE__*/function () {
6241
6641
  var actions = allActions.filter(function (action) {
6242
6642
  return action.active;
6243
6643
  });
6244
- return actions.sort(sortActions);
6644
+ return actions.sort(sortActionsHighestStartPositionFirst);
6245
6645
  };
6246
6646
 
6247
6647
  _proto._executeRelevantActions = function _executeRelevantActions(filter, executionType) {
6248
- var timelineActions = this._getRelevantTimelineActions();
6648
+ var timelineActions = this._getTimelineActionsForCurrentTimeline();
6249
6649
 
6250
6650
  var currentActions = filter.apply(this, [timelineActions]);
6251
6651
  return this._executeActions(currentActions, executionType, 0);
@@ -6261,27 +6661,7 @@ var EligiusEngine = /*#__PURE__*/function () {
6261
6661
  this._cleanUpTimeline();
6262
6662
  };
6263
6663
 
6264
- _proto._handleExecuteTimelineAction = function _handleExecuteTimelineAction(uri, index, start) {
6265
- var actions = this._getTimelineActionsForUri(uri);
6266
-
6267
- var action = actions == null ? void 0 : actions[index];
6268
-
6269
- if (action) {
6270
- if (start) {
6271
- action.start();
6272
- } else {
6273
- action.end();
6274
- }
6275
- }
6276
- };
6277
-
6278
- _proto._resizeTimelineAction = function
6279
- /*uri: string, index: number*/
6280
- _resizeTimelineAction() {
6281
- console.error('no resizing implemented');
6282
- };
6283
-
6284
- _proto._getRelevantTimelineActions = function _getRelevantTimelineActions() {
6664
+ _proto._getTimelineActionsForCurrentTimeline = function _getTimelineActionsForCurrentTimeline() {
6285
6665
  return this._getTimelineActionsForUri(this._currentTimelineUri);
6286
6666
  };
6287
6667
 
@@ -6317,19 +6697,19 @@ var EligiusEngine = /*#__PURE__*/function () {
6317
6697
  if (actions) {
6318
6698
  var executions = actions[position];
6319
6699
  executions == null ? void 0 : executions.forEach(function (exec) {
6320
- exec();
6700
+ return exec();
6321
6701
  });
6322
6702
  }
6323
6703
  };
6324
6704
 
6325
6705
  _proto._executeSeekActions = /*#__PURE__*/function () {
6326
- var _executeSeekActions2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(pos) {
6706
+ var _executeSeekActions2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(position) {
6327
6707
  var timelineActions, currentActions, newActions, currentActionsEnd;
6328
6708
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
6329
6709
  while (1) {
6330
6710
  switch (_context8.prev = _context8.next) {
6331
6711
  case 0:
6332
- timelineActions = this._getRelevantTimelineActions();
6712
+ timelineActions = this._getTimelineActionsForCurrentTimeline();
6333
6713
 
6334
6714
  if (timelineActions) {
6335
6715
  _context8.next = 3;
@@ -6339,8 +6719,10 @@ var EligiusEngine = /*#__PURE__*/function () {
6339
6719
  return _context8.abrupt("return", Promise.resolve());
6340
6720
 
6341
6721
  case 3:
6342
- currentActions = this._getActiveActions(timelineActions);
6343
- newActions = this._getActionsForPosition(pos, timelineActions);
6722
+ currentActions = this._getActiveActions(timelineActions).filter(function (action) {
6723
+ return !(action.duration.start <= position && action.duration.end >= position);
6724
+ });
6725
+ newActions = this._getActionsForPosition(position, timelineActions);
6344
6726
  currentActionsEnd = this._executeActions(currentActions, 'end', 0);
6345
6727
  _context8.next = 8;
6346
6728
  return currentActionsEnd;
@@ -6366,7 +6748,7 @@ var EligiusEngine = /*#__PURE__*/function () {
6366
6748
  return EligiusEngine;
6367
6749
  }();
6368
6750
 
6369
- var sortActions = function sortActions(a, b) {
6751
+ var sortActionsHighestStartPositionFirst = function sortActionsHighestStartPositionFirst(a, b) {
6370
6752
  if (b.duration.start < a.duration.start) {
6371
6753
  return -1;
6372
6754
  } else if (b.duration.start > a.duration.start) {
@@ -6376,6 +6758,20 @@ var sortActions = function sortActions(a, b) {
6376
6758
  }
6377
6759
  };
6378
6760
 
6761
+ var sortActionMethodsHighestStartPositionFirst = function sortActionMethodsHighestStartPositionFirst(a, b) {
6762
+ if (b.startPosition === undefined || a.startPosition === undefined) {
6763
+ return 0;
6764
+ }
6765
+
6766
+ if (b.startPosition < a.startPosition) {
6767
+ return -1;
6768
+ } else if (b.startPosition > a.startPosition) {
6769
+ return 1;
6770
+ } else {
6771
+ return 0;
6772
+ }
6773
+ };
6774
+
6379
6775
  /**
6380
6776
  * The `IEventbusListener` first registers a number of actions that are then
6381
6777
  * executed when the specified event is broadcast.
@@ -6964,5 +7360,5 @@ var EligiusResourceImporter = /*#__PURE__*/function () {
6964
7360
  return EligiusResourceImporter;
6965
7361
  }();
6966
7362
 
6967
- export { Action, ActionCreator, ActionCreatorFactory, ActionEditor, ActionRegistryEventbusListener, ConfigurationFactory, ConfigurationResolver, ControllerNamesProvider, DEV_TOOLS_KEY, DevToolEventListener, Diagnostics, EligiusEngine, EligiusResourceImporter, EndableAction, EndableActionCreator, EndableActionEditor, EngineFactory, EventListenerController, Eventbus, LabelController, LanguageManager, LottieController, NavigationController, OperationEditor, OperationMetadataProvider, OperationNamesProvider, ProgressbarController, RequestAnimationFrameTimelineProvider, RequestVideoUriInterceptor, RoutingController, SubtitlesController, TimeLineEventNamesProvider, TimelineAction, TimelineActionCreator, TimelineActionEditor, TimelineEventNames, TimelineProviderSettingsEditor, TimelineProvidersSettingsEditor, addClass$1 as addClass, addControllerToElement$1 as addControllerToElement, animate$1 as animate, animateWithClass$1 as animateWithClass, broadcastEvent$1 as broadcastEvent, calc$1 as calc, clearElement$1 as clearElement, clearOperationData$1 as clearOperationData, createElement$1 as createElement, customFunction$1 as customFunction, endAction$1 as endAction, endLoop$1 as endLoop, endWhen$1 as endWhen, extendController$1 as extendController, generateImporterSourceCode, getControllerFromElement$1 as getControllerFromElement, getControllerInstance$1 as getControllerInstance, getElementDimensions$1 as getElementDimensions, getImport$1 as getImport, getQueryParams$1 as getQueryParams, invokeObjectMethod$1 as invokeObjectMethod, loadJSON$1 as loadJSON, log$1 as log, math$1 as math, operationMetadata as metadata, otherwise$1 as otherwise, removeClass$1 as removeClass, removeControllerFromElement$1 as removeControllerFromElement, removeElement$1 as removeElement, removePropertiesFromOperationData$1 as removePropertiesFromOperationData, reparentElement$1 as reparentElement, requestAction$1 as requestAction, resizeAction$1 as resizeAction, selectElement$1 as selectElement, setElementAttributes$1 as setElementAttributes, setElementContent$1 as setElementContent, setGlobalData$1 as setGlobalData, setOperationData$1 as setOperationData, setStyle$1 as setStyle, startAction$1 as startAction, startLoop$1 as startLoop, toggleClass$1 as toggleClass, toggleElement$1 as toggleElement, wait$2 as wait, when };
7363
+ export { Action, ActionCreator, ActionCreatorFactory, ActionEditor, ActionRegistryEventbusListener, ConfigurationFactory, ConfigurationResolver, ControllerNamesProvider, DEV_TOOLS_KEY, DevToolEventListener, Diagnostics, EligiusEngine, EligiusResourceImporter, EndableAction, EndableActionCreator, EndableActionEditor, EngineFactory, EventListenerController, Eventbus, LabelController, LanguageManager, LottieController, NavigationController, OperationEditor, OperationMetadataProvider, OperationNamesProvider, ProgressbarController, RequestAnimationFrameTimelineProvider, RequestVideoUriInterceptor, RoutingController, SubtitleEditor, SubtitleImporter, SubtitlesController, TimeLineEventNamesProvider, TimelineAction, TimelineActionCreator, TimelineActionEditor, TimelineEventNames, TimelineProviderSettingsEditor, TimelineProvidersSettingsEditor, addClass$1 as addClass, addControllerToElement$1 as addControllerToElement, animate$1 as animate, animateWithClass$1 as animateWithClass, broadcastEvent$1 as broadcastEvent, calc$1 as calc, clearElement$1 as clearElement, clearOperationData$1 as clearOperationData, createElement$1 as createElement, customFunction$1 as customFunction, endAction$1 as endAction, endLoop$1 as endLoop, endWhen$1 as endWhen, extendController$1 as extendController, generateImporterSourceCode, getAttributesFromElement$1 as getAttributesFromElement, getControllerFromElement$1 as getControllerFromElement, getControllerInstance$1 as getControllerInstance, getElementDimensions$1 as getElementDimensions, getImport$1 as getImport, getQueryParams$1 as getQueryParams, invokeObjectMethod$1 as invokeObjectMethod, loadJSON$1 as loadJSON, log$1 as log, math$1 as math, operationMetadata as metadata, otherwise$1 as otherwise, removeClass$1 as removeClass, removeControllerFromElement$1 as removeControllerFromElement, removeElement$1 as removeElement, removePropertiesFromOperationData$1 as removePropertiesFromOperationData, reparentElement$1 as reparentElement, requestAction$1 as requestAction, resizeAction$1 as resizeAction, selectElement$1 as selectElement, setData$1 as setData, setElementAttributes$1 as setElementAttributes, setElementContent$1 as setElementContent, setGlobalData$1 as setGlobalData, setOperationData$1 as setOperationData, setStyle$1 as setStyle, startAction$1 as startAction, startLoop$1 as startLoop, toggleClass$1 as toggleClass, toggleElement$1 as toggleElement, wait$2 as wait, when };
6968
7364
  //# sourceMappingURL=eligius.esm.js.map