eligius 1.0.1 → 1.0.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/action/endable-action.d.ts +1 -1
  3. package/dist/configuration/types.d.ts +1 -1
  4. package/dist/controllers/metadata/{EventListenerController.d.ts → event-listener-controller.d.ts} +1 -1
  5. package/dist/controllers/metadata/index.d.ts +7 -0
  6. package/dist/controllers/metadata/{LabelController.d.ts → label-controller.d.ts} +1 -1
  7. package/dist/controllers/metadata/{LottieController.d.ts → lottie-controller.d.ts} +1 -1
  8. package/dist/controllers/metadata/{NavigationController.d.ts → navigation-controller.d.ts} +1 -1
  9. package/dist/controllers/metadata/{ProgressbarController.d.ts → progressbar-controller.d.ts} +1 -1
  10. package/dist/controllers/metadata/{RoutingController.d.ts → routing-controller.d.ts} +1 -1
  11. package/dist/controllers/metadata/{SubtitlesController.d.ts → subtitles-controller.d.ts} +1 -1
  12. package/dist/eligius.cjs.development.js +1231 -1087
  13. package/dist/eligius.cjs.development.js.map +1 -1
  14. package/dist/eligius.cjs.production.min.js +1 -1
  15. package/dist/eligius.cjs.production.min.js.map +1 -1
  16. package/dist/eligius.esm.js +1212 -1071
  17. package/dist/eligius.esm.js.map +1 -1
  18. package/dist/operation/add-class.d.ts +6 -0
  19. package/dist/operation/add-controller-to-element.d.ts +6 -1
  20. package/dist/operation/add-globals-to-operation.d.ts +7 -0
  21. package/dist/operation/animate-with-class.d.ts +8 -0
  22. package/dist/operation/animate.d.ts +7 -0
  23. package/dist/operation/broadcast-event.d.ts +7 -0
  24. package/dist/operation/clear-element.d.ts +3 -0
  25. package/dist/operation/clear-operation-data.d.ts +4 -0
  26. package/dist/operation/create-element.d.ts +8 -0
  27. package/dist/operation/custom-function.d.ts +7 -0
  28. package/dist/operation/end-action.d.ts +6 -0
  29. package/dist/operation/end-loop.d.ts +8 -1
  30. package/dist/operation/extend-controller.d.ts +3 -0
  31. package/dist/operation/get-controller-from-element.d.ts +6 -0
  32. package/dist/operation/get-controller-instance.d.ts +8 -0
  33. package/dist/operation/get-element-dimensions.d.ts +19 -1
  34. package/dist/operation/get-import.d.ts +8 -1
  35. package/dist/operation/helper/merge-operation-data.d.ts +1 -1
  36. package/dist/operation/helper/modify-dimensions.d.ts +15 -0
  37. package/dist/operation/load-json.d.ts +10 -0
  38. package/dist/operation/log.d.ts +6 -0
  39. package/dist/operation/remove-class.d.ts +6 -0
  40. package/dist/operation/remove-controller-from-element.d.ts +6 -0
  41. package/dist/operation/remove-element.d.ts +6 -0
  42. package/dist/operation/remove-properties-from-operation-data.d.ts +6 -0
  43. package/dist/operation/reparent-element.d.ts +7 -0
  44. package/dist/operation/request-action.d.ts +7 -0
  45. package/dist/operation/resize-action.d.ts +6 -0
  46. package/dist/operation/select-element.d.ts +10 -0
  47. package/dist/operation/set-element-attributes.d.ts +7 -1
  48. package/dist/operation/set-element-content.d.ts +13 -1
  49. package/dist/operation/set-operation-data.d.ts +7 -0
  50. package/dist/operation/set-style.d.ts +9 -2
  51. package/dist/operation/start-action.d.ts +10 -0
  52. package/dist/operation/start-loop.d.ts +10 -0
  53. package/dist/operation/toggle-class.d.ts +6 -0
  54. package/dist/operation/toggle-element.d.ts +6 -0
  55. package/dist/operation/types.d.ts +1 -1
  56. package/dist/operation/wait.d.ts +6 -0
  57. package/dist/timelineproviders/index.d.ts +0 -1
  58. package/package.json +47 -46
@@ -2,14 +2,17 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
5
  var tsIsPresent = require('ts-is-present');
8
- var lottie = _interopDefault(require('lottie-web'));
9
- var $ = _interopDefault(require('jquery'));
10
- var Mousetrap = _interopDefault(require('mousetrap'));
6
+ var lottie = require('lottie-web');
7
+ var $ = require('jquery');
8
+ var Mousetrap = require('mousetrap');
11
9
  var uuid = require('uuid');
12
- require('mediaelement');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ var lottie__default = /*#__PURE__*/_interopDefaultLegacy(lottie);
14
+ var $__default = /*#__PURE__*/_interopDefaultLegacy($);
15
+ var Mousetrap__default = /*#__PURE__*/_interopDefaultLegacy(Mousetrap);
13
16
 
14
17
  function deepCopy(original) {
15
18
  if (tsIsPresent.isDefined(original)) {
@@ -25,10 +28,13 @@ function isPromise(obj) {
25
28
 
26
29
  var Action = /*#__PURE__*/function () {
27
30
  function Action(name, startOperations, eventbus) {
31
+ this.name = void 0;
32
+ this.startOperations = void 0;
33
+ this.eventbus = void 0;
34
+ this.id = '';
28
35
  this.name = name;
29
36
  this.startOperations = startOperations;
30
37
  this.eventbus = eventbus;
31
- this.id = '';
32
38
  }
33
39
 
34
40
  var _proto = Action.prototype;
@@ -172,6 +178,7 @@ var EndableAction = /*#__PURE__*/function (_Action) {
172
178
  var _this;
173
179
 
174
180
  _this = _Action.call(this, name, startOperations, eventBus) || this;
181
+ _this.endOperations = void 0;
175
182
  _this.endOperations = endOperations;
176
183
  return _this;
177
184
  }
@@ -210,8 +217,9 @@ var TimelineAction = /*#__PURE__*/function (_EndableAction) {
210
217
  var _this;
211
218
 
212
219
  _this = _EndableAction.call(this, name, startOperations, endOperations, eventBus) || this;
213
- _this.duration = duration;
220
+ _this.duration = void 0;
214
221
  _this.active = false;
222
+ _this.duration = duration;
215
223
  return _this;
216
224
  }
217
225
 
@@ -269,6 +277,8 @@ function getNestedPropertyValue(propertyChain, sourceObject) {
269
277
 
270
278
  var ConfigurationResolver = /*#__PURE__*/function () {
271
279
  function ConfigurationResolver(importer, eventbus) {
280
+ this.importer = void 0;
281
+ this.eventbus = void 0;
272
282
  this.importer = importer;
273
283
  this.eventbus = eventbus;
274
284
  }
@@ -429,11 +439,8 @@ function resolvePlaceholder(key, config, rootConfig, importer) {
429
439
  }
430
440
  }
431
441
 
432
- function createCommonjsModule(fn, module) {
433
- return module = { exports: {} }, fn(module, module.exports), module.exports;
434
- }
442
+ var runtime = {exports: {}};
435
443
 
436
- var runtime_1 = createCommonjsModule(function (module) {
437
444
  /**
438
445
  * Copyright (c) 2014-present, Facebook, Inc.
439
446
  *
@@ -441,6 +448,7 @@ var runtime_1 = createCommonjsModule(function (module) {
441
448
  * LICENSE file in the root directory of this source tree.
442
449
  */
443
450
 
451
+ (function (module) {
444
452
  var runtime = (function (exports) {
445
453
 
446
454
  var Op = Object.prototype;
@@ -521,9 +529,9 @@ var runtime = (function (exports) {
521
529
  // This is a polyfill for %IteratorPrototype% for environments that
522
530
  // don't natively support it.
523
531
  var IteratorPrototype = {};
524
- IteratorPrototype[iteratorSymbol] = function () {
532
+ define(IteratorPrototype, iteratorSymbol, function () {
525
533
  return this;
526
- };
534
+ });
527
535
 
528
536
  var getProto = Object.getPrototypeOf;
529
537
  var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
@@ -537,8 +545,9 @@ var runtime = (function (exports) {
537
545
 
538
546
  var Gp = GeneratorFunctionPrototype.prototype =
539
547
  Generator.prototype = Object.create(IteratorPrototype);
540
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
541
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
548
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
549
+ define(Gp, "constructor", GeneratorFunctionPrototype);
550
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
542
551
  GeneratorFunction.displayName = define(
543
552
  GeneratorFunctionPrototype,
544
553
  toStringTagSymbol,
@@ -652,9 +661,9 @@ var runtime = (function (exports) {
652
661
  }
653
662
 
654
663
  defineIteratorMethods(AsyncIterator.prototype);
655
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
664
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
656
665
  return this;
657
- };
666
+ });
658
667
  exports.AsyncIterator = AsyncIterator;
659
668
 
660
669
  // Note that simple async functions are implemented on top of
@@ -847,13 +856,13 @@ var runtime = (function (exports) {
847
856
  // iterator prototype chain incorrectly implement this, causing the Generator
848
857
  // object to not be returned from this call. This ensures that doesn't happen.
849
858
  // See https://github.com/facebook/regenerator/issues/274 for more details.
850
- Gp[iteratorSymbol] = function() {
859
+ define(Gp, iteratorSymbol, function() {
851
860
  return this;
852
- };
861
+ });
853
862
 
854
- Gp.toString = function() {
863
+ define(Gp, "toString", function() {
855
864
  return "[object Generator]";
856
- };
865
+ });
857
866
 
858
867
  function pushTryEntry(locs) {
859
868
  var entry = { tryLoc: locs[0] };
@@ -1164,7 +1173,7 @@ var runtime = (function (exports) {
1164
1173
  // as the regeneratorRuntime namespace. Otherwise create a new empty
1165
1174
  // object. Either way, the resulting object will be used to initialize
1166
1175
  // the regeneratorRuntime variable at the top of this file.
1167
- module.exports
1176
+ module.exports
1168
1177
  ));
1169
1178
 
1170
1179
  try {
@@ -1172,19 +1181,25 @@ try {
1172
1181
  } catch (accidentalStrictMode) {
1173
1182
  // This module should not be running in strict mode, so the above
1174
1183
  // assignment should always work unless something is misconfigured. Just
1175
- // in case runtime.js accidentally runs in strict mode, we can escape
1184
+ // in case runtime.js accidentally runs in strict mode, in modern engines
1185
+ // we can explicitly access globalThis. In older engines we can escape
1176
1186
  // strict mode using a global Function call. This could conceivably fail
1177
1187
  // if a Content Security Policy forbids using Function, but in that case
1178
1188
  // the proper solution is to fix the accidental strict mode problem. If
1179
1189
  // you've misconfigured your bundler to force strict mode and applied a
1180
1190
  // CSP to forbid Function, and you're not willing to fix either of those
1181
1191
  // problems, please detail your unique predicament in a GitHub issue.
1182
- Function("r", "regeneratorRuntime = r")(runtime);
1192
+ if (typeof globalThis === "object") {
1193
+ globalThis.regeneratorRuntime = runtime;
1194
+ } else {
1195
+ Function("r", "regeneratorRuntime = r")(runtime);
1196
+ }
1183
1197
  }
1184
- });
1198
+ }(runtime));
1185
1199
 
1186
- var TimelineEventNames = function TimelineEventNames() {}; // timeline requests
1200
+ var _regeneratorRuntime = runtime.exports;
1187
1201
 
1202
+ var TimelineEventNames = function TimelineEventNames() {};
1188
1203
  TimelineEventNames.PLAY_TOGGLE_REQUEST = 'timeline-play-toggle-request';
1189
1204
  TimelineEventNames.PLAY_REQUEST = 'timeline-play-request';
1190
1205
  TimelineEventNames.STOP_REQUEST = 'timeline-stop-request';
@@ -1193,8 +1208,7 @@ TimelineEventNames.SEEK_REQUEST = 'timeline-seek-request';
1193
1208
  TimelineEventNames.RESIZE_REQUEST = 'timeline-resize-request';
1194
1209
  TimelineEventNames.CONTAINER_REQUEST = 'timeline-container-request';
1195
1210
  TimelineEventNames.DURATION_REQUEST = 'timeline-duration-request';
1196
- TimelineEventNames.REQUEST_CURRENT_TIMELINE = 'timeline-request-current-timeline'; // timeline announcements
1197
-
1211
+ TimelineEventNames.REQUEST_CURRENT_TIMELINE = 'timeline-request-current-timeline';
1198
1212
  TimelineEventNames.DURATION = 'timeline-duration';
1199
1213
  TimelineEventNames.TIME = 'timeline-time';
1200
1214
  TimelineEventNames.SEEKED = 'timeline-seeked';
@@ -1207,8 +1221,7 @@ TimelineEventNames.RESIZE = 'timeline-resize';
1207
1221
  TimelineEventNames.POSITION_UPDATE = 'timeline-position-update';
1208
1222
  TimelineEventNames.TIME_UPDATE = 'timeline-time-update';
1209
1223
  TimelineEventNames.CURRENT_TIMELINE_CHANGE = 'timeline-current-timeline-change';
1210
- TimelineEventNames.FIRST_FRAME = 'timeline-firstframe'; // factory and engine events
1211
-
1224
+ TimelineEventNames.FIRST_FRAME = 'timeline-firstframe';
1212
1225
  TimelineEventNames.REQUEST_INSTANCE = 'request-instance';
1213
1226
  TimelineEventNames.REQUEST_ACTION = 'request-action';
1214
1227
  TimelineEventNames.REQUEST_FUNCTION = 'request-function';
@@ -1218,8 +1231,7 @@ TimelineEventNames.REQUEST_ENGINE_ROOT = 'request-engine-root';
1218
1231
  TimelineEventNames.REQUEST_CURRENT_TIMELINE_POSITION = 'request-current-timeline-position';
1219
1232
  TimelineEventNames.REQUEST_TIMELINE_CLEANUP = 'request-timeline-cleanup';
1220
1233
  TimelineEventNames.EXECUTE_TIMELINEACTION = 'execute-timelineaction';
1221
- TimelineEventNames.RESIZE_TIMELINEACTION = 'resize-timelineaction'; //language manager events
1222
-
1234
+ TimelineEventNames.RESIZE_TIMELINEACTION = 'resize-timelineaction';
1223
1235
  TimelineEventNames.REQUEST_LABEL_COLLECTION = 'request-label-collection';
1224
1236
  TimelineEventNames.REQUEST_LABEL_COLLECTIONS = 'request-label-collections';
1225
1237
  TimelineEventNames.REQUEST_CURRENT_LANGUAGE = 'request-current-language';
@@ -1227,6 +1239,8 @@ TimelineEventNames.LANGUAGE_CHANGE = 'language-change';
1227
1239
 
1228
1240
  var EventListenerController = /*#__PURE__*/function () {
1229
1241
  function EventListenerController() {
1242
+ this.operationData = void 0;
1243
+ this.actionInstanceInfos = void 0;
1230
1244
  this.name = 'EventListenerController';
1231
1245
  }
1232
1246
 
@@ -1303,9 +1317,9 @@ var EventListenerController = /*#__PURE__*/function () {
1303
1317
  };
1304
1318
 
1305
1319
  _proto._executeAction = /*#__PURE__*/function () {
1306
- var _executeAction2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(actions, operationData, idx) {
1320
+ var _executeAction2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(actions, operationData, idx) {
1307
1321
  var actionInfo, action, method, resultOperationData;
1308
- return runtime_1.wrap(function _callee$(_context) {
1322
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1309
1323
  while (1) {
1310
1324
  switch (_context.prev = _context.next) {
1311
1325
  case 0:
@@ -1536,7 +1550,7 @@ var LottieController = /*#__PURE__*/function () {
1536
1550
  rendererSettings: this.operationData.renderer,
1537
1551
  animationData: animationData
1538
1552
  };
1539
- this.animationItem = lottie.loadAnimation(animationSettings);
1553
+ this.animationItem = lottie__default["default"].loadAnimation(animationSettings);
1540
1554
 
1541
1555
  if (this.endPosition < 0) {
1542
1556
  this.endPosition = this.animationItem.timeCompleted;
@@ -1569,7 +1583,7 @@ var LottieController = /*#__PURE__*/function () {
1569
1583
  };
1570
1584
 
1571
1585
  _proto.isIE = function isIE() {
1572
- var isIE = !!window.document['documentMode']; // Edge 20+
1586
+ var isIE = !!window.document['documentMode']; // Edge 20+
1573
1587
 
1574
1588
  var isEdge = !isIE && !!window['StyleMedia'];
1575
1589
  return isEdge || isIE;
@@ -1698,21 +1712,21 @@ var NavigationController = /*#__PURE__*/function () {
1698
1712
  };
1699
1713
 
1700
1714
  _proto.buildHtml = function buildHtml(parentElm, data) {
1701
- var ul = $('<ul/>');
1715
+ var ul = $__default["default"]('<ul/>');
1702
1716
  data.forEach(this.addNavElement.bind(this, ul));
1703
1717
  parentElm.append(ul);
1704
1718
  };
1705
1719
 
1706
1720
  _proto.addNavElement = function addNavElement(parentElm, data) {
1707
1721
  if (data.visible) {
1708
- var li = $('<li/>');
1709
- var a = $("<a href='javascript:;' id='nav_" + data.videoUrlIndex + "'/>");
1722
+ var li = $__default["default"]('<li/>');
1723
+ var a = $__default["default"]("<a href='javascript:;' id='nav_" + data.videoUrlIndex + "'/>");
1710
1724
  li.append(a);
1711
1725
  this.addLabel(a, data.labelId);
1712
1726
  this.addClickHandler(a, data.videoUrlIndex);
1713
1727
 
1714
1728
  if (data.children) {
1715
- var ul = $('<ul/>');
1729
+ var ul = $__default["default"]('<ul/>');
1716
1730
  data.children.forEach(this.addNavElement.bind(this, ul));
1717
1731
  li.append(ul);
1718
1732
  }
@@ -1750,10 +1764,10 @@ var NavigationController = /*#__PURE__*/function () {
1750
1764
  };
1751
1765
 
1752
1766
  _proto.highlightMenu = function highlightMenu(index) {
1753
- var navElm = $("#nav_" + index);
1767
+ var navElm = $__default["default"]("#nav_" + index);
1754
1768
 
1755
1769
  if (navElm.length) {
1756
- $('.current-menu-item').removeClass('current-menu-item');
1770
+ $__default["default"]('.current-menu-item').removeClass('current-menu-item');
1757
1771
  navElm.addClass('current-menu-item');
1758
1772
  }
1759
1773
  };
@@ -2146,8 +2160,6 @@ var SubtitlesController = /*#__PURE__*/function () {
2146
2160
  return SubtitlesController;
2147
2161
  }();
2148
2162
 
2149
-
2150
-
2151
2163
  var ctrls = {
2152
2164
  __proto__: null,
2153
2165
  EventListenerController: EventListenerController,
@@ -2167,15 +2179,19 @@ var ctrls = {
2167
2179
 
2168
2180
  var EligiusEngine = /*#__PURE__*/function () {
2169
2181
  function EligiusEngine(configuration, eventbus, timelineProviders, _languageManager) {
2170
- this.configuration = configuration;
2171
- this.eventbus = eventbus;
2172
- this.timelineProviders = timelineProviders;
2173
- this._languageManager = _languageManager;
2182
+ this.configuration = void 0;
2183
+ this.eventbus = void 0;
2184
+ this.timelineProviders = void 0;
2185
+ this._languageManager = void 0;
2174
2186
  this._timeLineActionsLookup = {};
2175
2187
  this._eventbusListeners = [];
2176
2188
  this._currentTimelineUri = '';
2177
2189
  this._activeTimelineProvider = undefined;
2178
2190
  this._lastPosition = -1;
2191
+ this.configuration = configuration;
2192
+ this.eventbus = eventbus;
2193
+ this.timelineProviders = timelineProviders;
2194
+ this._languageManager = _languageManager;
2179
2195
  }
2180
2196
 
2181
2197
  var _proto = EligiusEngine.prototype;
@@ -2199,7 +2215,7 @@ var EligiusEngine = /*#__PURE__*/function () {
2199
2215
 
2200
2216
  _proto._createLayoutTemplate = function _createLayoutTemplate() {
2201
2217
  var containerSelector = this.configuration.containerSelector;
2202
- var container = $(containerSelector);
2218
+ var container = $__default["default"](containerSelector);
2203
2219
 
2204
2220
  if (!container || !container.length) {
2205
2221
  throw new Error("Container selector not found: " + containerSelector);
@@ -2235,8 +2251,8 @@ var EligiusEngine = /*#__PURE__*/function () {
2235
2251
 
2236
2252
  this._activeTimelineProvider = providerSettings.provider;
2237
2253
  return new Promise( /*#__PURE__*/function () {
2238
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(resolve) {
2239
- return runtime_1.wrap(function _callee$(_context) {
2254
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve) {
2255
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
2240
2256
  while (1) {
2241
2257
  switch (_context.prev = _context.next) {
2242
2258
  case 0:
@@ -2275,8 +2291,8 @@ var EligiusEngine = /*#__PURE__*/function () {
2275
2291
  };
2276
2292
 
2277
2293
  _proto._cleanUp = /*#__PURE__*/function () {
2278
- var _cleanUp2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
2279
- return runtime_1.wrap(function _callee2$(_context2) {
2294
+ var _cleanUp2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
2295
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
2280
2296
  while (1) {
2281
2297
  switch (_context2.prev = _context2.next) {
2282
2298
  case 0:
@@ -2303,8 +2319,8 @@ var EligiusEngine = /*#__PURE__*/function () {
2303
2319
  }();
2304
2320
 
2305
2321
  _proto.destroy = /*#__PURE__*/function () {
2306
- var _destroy = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
2307
- return runtime_1.wrap(function _callee3$(_context3) {
2322
+ var _destroy = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
2323
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
2308
2324
  while (1) {
2309
2325
  switch (_context3.prev = _context3.next) {
2310
2326
  case 0:
@@ -2420,9 +2436,9 @@ var EligiusEngine = /*#__PURE__*/function () {
2420
2436
  };
2421
2437
 
2422
2438
  _proto._executeActions = /*#__PURE__*/function () {
2423
- var _executeActions2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(actions, methodName, idx) {
2439
+ var _executeActions2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(actions, methodName, idx) {
2424
2440
  var action;
2425
- return runtime_1.wrap(function _callee4$(_context4) {
2441
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
2426
2442
  while (1) {
2427
2443
  switch (_context4.prev = _context4.next) {
2428
2444
  case 0:
@@ -2463,16 +2479,16 @@ var EligiusEngine = /*#__PURE__*/function () {
2463
2479
  }();
2464
2480
 
2465
2481
  _proto._handleRequestEngineRoot = function _handleRequestEngineRoot(engineRootSelector, resultCallback) {
2466
- resultCallback($(engineRootSelector));
2482
+ resultCallback($__default["default"](engineRootSelector));
2467
2483
  };
2468
2484
 
2469
2485
  _proto._handleRequestTimelineUri = /*#__PURE__*/function () {
2470
- var _handleRequestTimelineUri2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(uri, position, previousVideoPosition) {
2486
+ var _handleRequestTimelineUri2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(uri, position, previousVideoPosition) {
2471
2487
  var _position,
2472
2488
  _this3 = this;
2473
2489
 
2474
2490
  var timelineConfig, newProviderSettings;
2475
- return runtime_1.wrap(function _callee5$(_context5) {
2491
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
2476
2492
  while (1) {
2477
2493
  switch (_context5.prev = _context5.next) {
2478
2494
  case 0:
@@ -2616,9 +2632,9 @@ var EligiusEngine = /*#__PURE__*/function () {
2616
2632
  }
2617
2633
  };
2618
2634
 
2619
- _proto._resizeTimelineAction = function _resizeTimelineAction()
2620
- /*uri: string, index: number*/
2621
- {
2635
+ _proto._resizeTimelineAction = function
2636
+ /*uri: string, index: number*/
2637
+ _resizeTimelineAction() {
2622
2638
  console.error('no resizing implemented');
2623
2639
  };
2624
2640
 
@@ -2879,6 +2895,7 @@ var Eventbus = /*#__PURE__*/function () {
2879
2895
 
2880
2896
  var RequestVideoUriInterceptor = /*#__PURE__*/function () {
2881
2897
  function RequestVideoUriInterceptor(eventbus) {
2898
+ this.eventbus = void 0;
2882
2899
  this.eventbus = eventbus;
2883
2900
  }
2884
2901
 
@@ -2892,8 +2909,6 @@ var RequestVideoUriInterceptor = /*#__PURE__*/function () {
2892
2909
  return RequestVideoUriInterceptor;
2893
2910
  }();
2894
2911
 
2895
-
2896
-
2897
2912
  var evtb = {
2898
2913
  __proto__: null,
2899
2914
  ActionRegistryEventbusListener: ActionRegistryEventbusListener,
@@ -2903,10 +2918,12 @@ var evtb = {
2903
2918
 
2904
2919
  var LanguageManager = /*#__PURE__*/function () {
2905
2920
  function LanguageManager(_currentLanguage, labels, _eventbus) {
2906
- this._currentLanguage = _currentLanguage;
2907
- this._eventbus = _eventbus;
2921
+ this._currentLanguage = void 0;
2922
+ this._eventbus = void 0;
2908
2923
  this._labelLookup = {};
2909
2924
  this._eventbusListeners = [];
2925
+ this._currentLanguage = _currentLanguage;
2926
+ this._eventbus = _eventbus;
2910
2927
 
2911
2928
  if (!_currentLanguage || !_currentLanguage.length) {
2912
2929
  throw new Error('language ctor arg cannot be null or have zero length');
@@ -2972,7 +2989,7 @@ var LanguageManager = /*#__PURE__*/function () {
2972
2989
  var callBack = function callBack(rootSelector) {
2973
2990
  var lang = _this2._extractLanguageFromCulture(language);
2974
2991
 
2975
- $(rootSelector).attr('lang', lang);
2992
+ $__default["default"](rootSelector).attr('lang', lang);
2976
2993
  };
2977
2994
 
2978
2995
  this._eventbus.broadcast(TimelineEventNames.REQUEST_ENGINE_ROOT, [callBack]);
@@ -3001,12 +3018,14 @@ var EngineFactory = /*#__PURE__*/function () {
3001
3018
  function EngineFactory(importer, windowRef, eventbus) {
3002
3019
  this.resizeTimeout = -1;
3003
3020
  this.actionsLookup = {};
3021
+ this.importer = void 0;
3022
+ this.eventbus = void 0;
3004
3023
  this.importer = importer;
3005
3024
  this.eventbus = eventbus || new Eventbus();
3006
3025
  this.eventbus.on(TimelineEventNames.REQUEST_INSTANCE, this._requestInstanceHandler.bind(this));
3007
3026
  this.eventbus.on(TimelineEventNames.REQUEST_ACTION, this._requestActionHandler.bind(this));
3008
3027
  this.eventbus.on(TimelineEventNames.REQUEST_FUNCTION, this._requestFunctionHandler.bind(this));
3009
- $(windowRef).resize(this._resizeHandler.bind(this));
3028
+ $__default["default"](windowRef).resize(this._resizeHandler.bind(this));
3010
3029
  }
3011
3030
 
3012
3031
  var _proto = EngineFactory.prototype;
@@ -3086,7 +3105,7 @@ var EngineFactory = /*#__PURE__*/function () {
3086
3105
  labels = configuration.labels;
3087
3106
  var languageManager = new LanguageManager(language, labels, this.eventbus);
3088
3107
  var engineInstance = new EngineClass(resolvedConfiguration, this.eventbus, timelineProviders, languageManager);
3089
- Mousetrap.bind('space', function (event) {
3108
+ Mousetrap__default["default"].bind('space', function (event) {
3090
3109
  event.preventDefault();
3091
3110
 
3092
3111
  _this2.eventbus.broadcast(TimelineEventNames.PLAY_TOGGLE_REQUEST);
@@ -3123,6 +3142,12 @@ var EngineFactory = /*#__PURE__*/function () {
3123
3142
  return EngineFactory;
3124
3143
  }();
3125
3144
 
3145
+ /**
3146
+ * This operation adds the specified class name to the specified selected element.
3147
+ *
3148
+ * @param operationData
3149
+ * @returns
3150
+ */
3126
3151
  var addClass = function addClass(operationData) {
3127
3152
  var selectedElement = operationData.selectedElement,
3128
3153
  className = operationData.className;
@@ -3148,6 +3173,7 @@ function attachControllerToElement(element, controller) {
3148
3173
  }
3149
3174
 
3150
3175
  function mergeOperationData(operationData, newOperationData) {
3176
+ //return { ...(operationData as any), ...newOperationData } as K;
3151
3177
  return Object.assign(operationData, newOperationData);
3152
3178
  }
3153
3179
 
@@ -3159,6 +3185,13 @@ function internalResolve(resolve, operationData, newOperationData) {
3159
3185
  }
3160
3186
  }
3161
3187
 
3188
+ /**
3189
+ * This operation adds the specified controller instance to the specified selected element.
3190
+ *
3191
+ * @param operationData
3192
+ * @returns
3193
+ */
3194
+
3162
3195
  var addControllerToElement = function addControllerToElement(operationData) {
3163
3196
  var selectedElement = operationData.selectedElement,
3164
3197
  controllerInstance = operationData.controllerInstance;
@@ -3177,6 +3210,14 @@ var addControllerToElement = function addControllerToElement(operationData) {
3177
3210
  }
3178
3211
  };
3179
3212
 
3213
+ /**
3214
+ * This operation animates the specified selected element with the given jQuery animation settings.
3215
+ * It resolves after the animation completes.
3216
+ *
3217
+ * @param operationData
3218
+ * @returns
3219
+ */
3220
+
3180
3221
  var animate = function animate(operationData) {
3181
3222
  var animationEasing = operationData.animationEasing,
3182
3223
  selectedElement = operationData.selectedElement,
@@ -3200,6 +3241,15 @@ var animate = function animate(operationData) {
3200
3241
  return promise;
3201
3242
  };
3202
3243
 
3244
+ /**
3245
+ * This operation adds the specified class name to the specified selected element and assumes that this
3246
+ * class triggers and animation on the selected element. It then waits for this animation to complete
3247
+ * until it resolves.
3248
+ *
3249
+ * @param operationData
3250
+ * @returns
3251
+ */
3252
+
3203
3253
  var animateWithClass = function animateWithClass(operationData) {
3204
3254
  var selectedElement = operationData.selectedElement,
3205
3255
  className = operationData.className,
@@ -3247,6 +3297,14 @@ function resolveEventArguments(operationData, eventArgs) {
3247
3297
  return eventArgs.map(extract);
3248
3298
  }
3249
3299
 
3300
+ /**
3301
+ * This operation broadcasts the given event through the eventbus, along with the
3302
+ * event argumetns and optional event topic.
3303
+ *
3304
+ * @param operationData
3305
+ * @returns
3306
+ */
3307
+
3250
3308
  var broadcastEvent = function broadcastEvent(operationData) {
3251
3309
  var eventArgs = operationData.eventArgs,
3252
3310
  eventTopic = operationData.eventTopic,
@@ -3263,12 +3321,19 @@ var broadcastEvent = function broadcastEvent(operationData) {
3263
3321
  return operationData;
3264
3322
  };
3265
3323
 
3324
+ /**
3325
+ * This operation removes all of the children from the specified selected element.
3326
+ */
3266
3327
  var clearElement = function clearElement(operationData) {
3267
3328
  var selectedElement = operationData.selectedElement;
3268
3329
  selectedElement.empty();
3269
3330
  return operationData;
3270
3331
  };
3271
3332
 
3333
+ /**
3334
+ * This operation removes all of the properties on the current operation date.
3335
+ * Or, if the properties property is set only removes the properties defined by that list.
3336
+ */
3272
3337
  var clearOperationData = function clearOperationData(operationData) {
3273
3338
  var properties = operationData.properties;
3274
3339
 
@@ -3303,7 +3368,7 @@ function resolveProperties(properties, copy, extract) {
3303
3368
  var key = _ref[0],
3304
3369
  value = _ref[1];
3305
3370
 
3306
- if (value instanceof $) {
3371
+ if (value instanceof $__default["default"]) {
3307
3372
  return;
3308
3373
  }
3309
3374
 
@@ -3327,6 +3392,15 @@ function resolveProperties(properties, copy, extract) {
3327
3392
  }
3328
3393
  }
3329
3394
 
3395
+ /**
3396
+ * This operation creates the DOM element defined by the given properties and assigns
3397
+ * the instance to the give property name on the current operation data.
3398
+ * The property name defaults to 'template'.
3399
+ *
3400
+ * @param operationData
3401
+ * @returns
3402
+ */
3403
+
3330
3404
  var createElement = function createElement(operationData) {
3331
3405
  operationData = resolvePropertyValues(operationData, operationData);
3332
3406
  var _operationData = operationData,
@@ -3340,1284 +3414,1355 @@ var createElement = function createElement(operationData) {
3340
3414
  value = _ref[1];
3341
3415
  return key + "=\"" + value + "\"";
3342
3416
  }).join(' ') : '';
3343
- var template = text ? $("<" + elementName + serializedAttrs + ">" + text + "</" + elementName + ">") : $("<" + elementName + serializedAttrs + "/>");
3417
+ var template = text ? $__default["default"]("<" + elementName + serializedAttrs + ">" + text + "</" + elementName + ">") : $__default["default"]("<" + elementName + serializedAttrs + "/>");
3344
3418
  operationData[propertyName] = template;
3345
3419
  delete operationData.propertyName;
3346
3420
  return operationData;
3347
3421
  };
3348
3422
 
3349
- var JwPlayerTimelineProvider = /*#__PURE__*/function () {
3350
- function JwPlayerTimelineProvider(eventbus, config) {
3351
- this.eventbus = eventbus;
3352
- this.config = config;
3353
- this._paused = false;
3354
- this._player = null;
3355
- this._currentLoopHandler = null;
3356
- this._eventbusListeners = [];
3357
- this._playlist = [];
3358
- this._videoElementId = uuid.v4();
3359
- this.loop = false;
3360
-
3361
- this._addEventListeners();
3362
- }
3363
-
3364
- var _proto = JwPlayerTimelineProvider.prototype;
3423
+ /**
3424
+ * This operation retrieves a custom function defined by the specified system name
3425
+ * and invokes it with the current operation data and eventbus.
3426
+ *
3427
+ * @param operationData
3428
+ * @returns
3429
+ */
3365
3430
 
3366
- _proto._extractUrls = function _extractUrls(configuration) {
3367
- var urls = configuration.timelines.filter(function (timeline) {
3368
- return timeline.type === 'mediaplayer';
3369
- }).map(function (timeline) {
3370
- return timeline.uri;
3371
- });
3372
- return urls;
3373
- };
3431
+ var customFunction = function customFunction(operationData) {
3432
+ var _this = this;
3374
3433
 
3375
- _proto.init = function init() {
3376
- var _this = this;
3434
+ var systemName = operationData.systemName;
3435
+ return new Promise(function (resolve, reject) {
3436
+ var resultCallback = function resultCallback(func) {
3437
+ var promise = func(operationData, _this.eventbus);
3377
3438
 
3378
- var settings = this.config.timelineProviderSettings['mediaplayer'];
3439
+ if (promise) {
3440
+ promise.then(function () {
3441
+ internalResolve(resolve, {}, operationData);
3442
+ }, reject);
3443
+ } else {
3444
+ internalResolve(resolve, {}, operationData);
3445
+ }
3446
+ };
3379
3447
 
3380
- if (!settings) {
3381
- throw new Error("No settings found for 'mediaplayer' timeline provider");
3382
- }
3448
+ _this.eventbus.broadcast(TimelineEventNames.REQUEST_FUNCTION, [systemName, resultCallback]);
3449
+ });
3450
+ };
3383
3451
 
3384
- var selector = settings.selector;
3452
+ /**
3453
+ * This operation invokes the end() method on the specified action instance.
3454
+ *
3455
+ * @param operationData
3456
+ * @returns
3457
+ */
3385
3458
 
3386
- var urls = this._extractUrls(this.config);
3459
+ var endAction = function endAction(operationData) {
3460
+ var _operationData = operationData,
3461
+ actionInstance = _operationData.actionInstance,
3462
+ actionOperationData = _operationData.actionOperationData;
3463
+ delete operationData.actionOperationData;
3464
+ return new Promise(function (resolve, reject) {
3465
+ operationData = mergeOperationData(operationData, actionOperationData);
3466
+ actionInstance.end(operationData).then(function () {
3467
+ Object.keys(actionOperationData).forEach(function (key) {
3468
+ delete operationData[key];
3469
+ });
3470
+ internalResolve(resolve, operationData);
3471
+ }, reject);
3472
+ });
3473
+ };
3387
3474
 
3388
- var jwp = window.jwplayer;
3389
- var p = $("#" + selector);
3475
+ /**
3476
+ * This operation checks if the current loop should end or start the next iteration.
3477
+ *
3478
+ * @param operationData
3479
+ * @returns
3480
+ */
3481
+ var endLoop = function endLoop(operationData) {
3482
+ var context = this;
3390
3483
 
3391
- if (!p.length) {
3392
- throw new Error("videoplayer selector '" + selector + "' not found");
3484
+ if (!context.skipNextOperation) {
3485
+ if (context.loopIndex !== undefined && context.loopLength !== undefined && context.loopIndex < context.loopLength) {
3486
+ context.loopIndex = context.loopIndex + 1;
3487
+ context.newIndex = context.startIndex;
3488
+ } else {
3489
+ delete context.loopIndex;
3490
+ delete context.loopLength;
3491
+ delete context.startIndex;
3492
+ delete context.newIndex;
3393
3493
  }
3494
+ } else {
3495
+ delete context.skipNextOperation;
3496
+ }
3394
3497
 
3395
- var w = p.innerWidth();
3396
- var h = p.innerHeight();
3498
+ return operationData;
3499
+ };
3397
3500
 
3398
- if (w === 0) {
3399
- w = 100;
3400
- }
3501
+ var extendController = function extendController(operationData) {
3502
+ var controllerInstance = operationData.controllerInstance,
3503
+ controllerExtension = operationData.controllerExtension;
3504
+ operationData.controllerInstance = Object.assign(controllerInstance, controllerExtension);
3505
+ return operationData;
3506
+ };
3401
3507
 
3402
- if (h === 0) {
3403
- h = 300;
3404
- }
3508
+ /**
3509
+ * This operation retrieves the controller instance with the specified name from the specified selected element.
3510
+ *
3511
+ * @param operationData
3512
+ * @returns
3513
+ */
3405
3514
 
3406
- this._player = jwp(selector);
3515
+ var getControllerFromElement = function getControllerFromElement(operationData) {
3516
+ var selectedElement = operationData.selectedElement,
3517
+ controllerName = operationData.controllerName;
3518
+ var controllers = getElementControllers(selectedElement);
3519
+ var controller = controllers.find(function (ctrl) {
3520
+ return ctrl.name === controllerName;
3521
+ });
3407
3522
 
3408
- this._player.setup({
3409
- file: urls[0],
3410
- image: settings.poster,
3411
- height: h,
3412
- width: w,
3413
- controls: true,
3414
- autostart: false,
3415
- displaytitle: false,
3416
- displaydescription: false,
3417
- nextUpDisplay: false,
3418
- abouttext: 'Eligius',
3419
- aboutlink: 'http://www.google.com',
3420
- stretching: 'fill',
3421
- repeat: false
3422
- });
3523
+ if (!controller) {
3524
+ console.warn("controller for name '" + controllerName + "' was not found on the given element");
3525
+ }
3423
3526
 
3424
- this._playlist.length = 0;
3425
- urls.forEach(function (url) {
3426
- var item = {
3427
- file: url,
3428
- title: url,
3429
- image: settings.poster
3430
- };
3527
+ operationData.controllerInstance = controller;
3528
+ return operationData;
3529
+ };
3431
3530
 
3432
- _this._playlist.push(item);
3433
- });
3434
- var promise = new Promise(function (resolve) {
3435
- _this._player.once('ready', function () {
3436
- _this._handlePlayerReady(resolve);
3437
- });
3531
+ /**
3532
+ * This operation retrieves an instance of the given controller name.
3533
+ * It assigns this instance to the property on the current operation data
3534
+ * defined by the propertyName property which defaults to 'controllerInstance'.
3535
+ *
3536
+ * @param operationData
3537
+ * @returns
3538
+ */
3438
3539
 
3439
- _this._player.load(_this._playlist);
3440
- });
3441
- return promise;
3442
- };
3540
+ var getControllerInstance = function getControllerInstance(operationData) {
3541
+ var systemName = operationData.systemName,
3542
+ _operationData$proper = operationData.propertyName,
3543
+ propertyName = _operationData$proper === void 0 ? 'controllerInstance' : _operationData$proper;
3544
+ operationData[propertyName] = null;
3443
3545
 
3444
- _proto._handlePlayerReady = function _handlePlayerReady(resolve) {
3445
- var _this2 = this;
3546
+ var resultCallback = function resultCallback(instance) {
3547
+ operationData[propertyName] = instance;
3548
+ };
3446
3549
 
3447
- this._player.once('firstFrame', function () {
3448
- _this2._player.pause();
3550
+ this.eventbus.broadcast(TimelineEventNames.REQUEST_INSTANCE, [systemName, resultCallback]);
3551
+ delete operationData.propertyName;
3552
+ return operationData;
3553
+ };
3449
3554
 
3450
- _this2.eventbus.broadcast(TimelineEventNames.DURATION, [_this2.getDuration()]);
3555
+ function modifyDimensionsByRatio(ratioModifier, dimensions) {
3556
+ //h[ar=8-1]
3557
+ var prefix = ratioModifier.substring(0, 1);
3558
+ var ratio = ratioModifier.substring(ratioModifier.indexOf('[') + 1, ratioModifier.indexOf(']') - ratioModifier.indexOf('[') - 1);
3559
+ var ratios = ratio.split('=')[1].split('-');
3451
3560
 
3452
- resolve(_this2);
3453
- });
3561
+ if (prefix === 'h') {
3562
+ dimensions.height = dimensions.width / +ratios[0] * +ratios[1];
3563
+ } else if (prefix === 'w') {
3564
+ dimensions.width = dimensions.height / +ratios[1] * +ratios[0];
3565
+ }
3566
+ }
3454
3567
 
3455
- this._player.on(TimelineEventNames.TIME, this._loopHandler.bind(this, Math.floor));
3568
+ function getModifierSuffix(modifier) {
3569
+ var endIdx = 1;
3570
+ var suffix = modifier.substring(modifier.length - 1, 1);
3456
3571
 
3457
- this._player.on(TimelineEventNames.SEEKED, this._seekedHandler.bind(this));
3572
+ if (suffix !== 'h' && suffix !== 'w' && suffix !== '%') {
3573
+ suffix = null;
3574
+ }
3458
3575
 
3459
- this._player.on(TimelineEventNames.COMPLETE, this._handlePlayerComplete.bind(this));
3576
+ var isPercent = suffix === '%';
3460
3577
 
3461
- setTimeout(function () {
3462
- _this2._player.play();
3463
- }, 10);
3464
- };
3578
+ if (isPercent) {
3579
+ endIdx = 2;
3580
+ suffix = modifier.substring(modifier.length - endIdx, 1);
3465
3581
 
3466
- _proto._handlePlayerComplete = function _handlePlayerComplete() {
3467
- if (!this.loop) {
3468
- this.stop();
3469
- this.eventbus.broadcast(TimelineEventNames.COMPLETE, [this._player.getPlaylistIndex()]);
3582
+ if (suffix !== 'h' && suffix !== 'w') {
3583
+ suffix = null;
3584
+ endIdx = 1;
3470
3585
  }
3471
- };
3472
-
3473
- _proto._seekedHandler = function _seekedHandler() {
3474
- this.eventbus.broadcast(TimelineEventNames.SEEKED, [this.getPosition(), this.getDuration()]);
3475
- };
3476
-
3477
- _proto.destroy = function destroy() {
3478
- this._player.remove();
3479
-
3480
- this._eventbusListeners.forEach(function (func) {
3481
- return func();
3482
- });
3483
- };
3484
-
3485
- _proto._loopHandler = function _loopHandler(floor, jwplayerEvent) {
3486
- var pos = floor(jwplayerEvent.position);
3586
+ }
3487
3587
 
3488
- if (this.loop && pos === floor(this._player.getDuration() - 1)) {
3489
- this.seek(0);
3490
- }
3491
- };
3588
+ return [suffix, endIdx, isPercent];
3589
+ }
3492
3590
 
3493
- _proto._timeResetLoopHandler = function _timeResetLoopHandler() {
3494
- if (this.loop) {
3495
- this.seek(0);
3496
- }
3497
- };
3591
+ function _modifyDimensions(dimensions, prefix, suffix, widthModifier, heightModifier) {
3592
+ switch (prefix) {
3593
+ case '+':
3594
+ switch (suffix) {
3595
+ case 'h':
3596
+ dimensions.height += heightModifier;
3597
+ break;
3498
3598
 
3499
- _proto._addEventListeners = function _addEventListeners() {
3500
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PLAY_TOGGLE_REQUEST, this.toggleplay.bind(this)));
3599
+ case 'w':
3600
+ dimensions.width += widthModifier;
3601
+ break;
3501
3602
 
3502
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PLAY_REQUEST, this.start.bind(this)));
3603
+ default:
3604
+ dimensions.height += heightModifier;
3605
+ dimensions.width += widthModifier;
3606
+ }
3503
3607
 
3504
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.STOP_REQUEST, this.stop.bind(this)));
3608
+ break;
3505
3609
 
3506
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PAUSE_REQUEST, this.pause.bind(this)));
3610
+ case '-':
3611
+ switch (suffix) {
3612
+ case 'h':
3613
+ dimensions.height -= heightModifier;
3614
+ break;
3507
3615
 
3508
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.SEEK_REQUEST, this.seek.bind(this)));
3616
+ case 'w':
3617
+ dimensions.width -= widthModifier;
3618
+ break;
3509
3619
 
3510
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.RESIZE_REQUEST, this.resize.bind(this)));
3620
+ default:
3621
+ dimensions.height -= heightModifier;
3622
+ dimensions.width -= widthModifier;
3623
+ }
3511
3624
 
3512
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.CONTAINER_REQUEST, this._container.bind(this)));
3625
+ break;
3513
3626
 
3514
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.DURATION_REQUEST, this.duration.bind(this)));
3515
- };
3627
+ case '/':
3628
+ switch (suffix) {
3629
+ case 'h':
3630
+ dimensions.height /= heightModifier;
3631
+ break;
3516
3632
 
3517
- _proto._container = function _container(resultCallback) {
3518
- var suffix = '';
3633
+ case 'w':
3634
+ dimensions.width /= widthModifier;
3635
+ break;
3519
3636
 
3520
- if (this._player.getProvider().name !== 'html5') {
3521
- suffix = '_wrapper';
3522
- }
3637
+ default:
3638
+ dimensions.height /= heightModifier;
3639
+ dimensions.width /= widthModifier;
3640
+ }
3523
3641
 
3524
- var container = $("#" + this._videoElementId + suffix);
3525
- resultCallback(container);
3526
- };
3642
+ break;
3527
3643
 
3528
- _proto.toggleplay = function toggleplay() {
3529
- if (this._paused) {
3530
- this.start();
3531
- } else {
3532
- this.pause();
3533
- }
3534
- };
3644
+ case '*':
3645
+ switch (suffix) {
3646
+ case 'h':
3647
+ dimensions.height *= heightModifier;
3648
+ break;
3535
3649
 
3536
- _proto.start = function start() {
3537
- this._paused = false;
3650
+ case 'w':
3651
+ dimensions.width *= widthModifier;
3652
+ break;
3538
3653
 
3539
- this._player.play();
3654
+ default:
3655
+ dimensions.height *= heightModifier;
3656
+ dimensions.width *= widthModifier;
3657
+ }
3540
3658
 
3541
- this.eventbus.broadcast(TimelineEventNames.PLAY);
3542
- };
3659
+ break;
3543
3660
 
3544
- _proto.stop = function stop() {
3545
- this._paused = false;
3661
+ default:
3662
+ console.error("Unknown operator found: " + prefix);
3663
+ }
3546
3664
 
3547
- this._player.stop();
3665
+ return dimensions;
3666
+ }
3667
+ /**
3668
+ * Modifies the given dimensions using the given modifier string.
3669
+ * The modifier string is formatted in the following way:
3670
+ *
3671
+ * <operator><amount><optional-side><optional-precentage>|<ratio-definition>
3672
+ *
3673
+ * Where the ratio modifier is formatted in the following way:
3674
+ * <side>[ar=<ratio-left>-<ratio-right>]
3675
+ *
3676
+ * For example, this modifier '+100h|w[ar=8-1]' will modifiy the dimensions like this:
3677
+ * it will add a value of 100 to the height and modify the width by a ration of 8 to 1 relative to the height.
3678
+ *
3679
+ * @param dimensions
3680
+ * @param modifier
3681
+ */
3548
3682
 
3549
- this.eventbus.broadcast(TimelineEventNames.STOP);
3550
- };
3551
3683
 
3552
- _proto.pause = function pause() {
3553
- this._paused = true;
3684
+ function modifyDimensions(dimensions, modifier) {
3685
+ var ratioModifier = null;
3554
3686
 
3555
- this._player.pause();
3687
+ if (modifier.indexOf('|') > -1) {
3688
+ var _modifier$split = modifier.split('|');
3556
3689
 
3557
- this.eventbus.broadcast(TimelineEventNames.PAUSE);
3558
- };
3690
+ modifier = _modifier$split[0];
3691
+ ratioModifier = _modifier$split[1];
3692
+ }
3559
3693
 
3560
- _proto.seek = function seek(position) {
3561
- var currentPosition = this._player.getPosition();
3694
+ var prefix = modifier.substring(0, 1);
3562
3695
 
3563
- this._player.seek(position);
3696
+ var _getModifierSuffix = getModifierSuffix(modifier),
3697
+ suffix = _getModifierSuffix[0],
3698
+ endIdx = _getModifierSuffix[1],
3699
+ isPercent = _getModifierSuffix[2];
3564
3700
 
3565
- this.eventbus.broadcast(TimelineEventNames.SEEK, [position, currentPosition, this._player.getDuration()]);
3566
- };
3701
+ var value = parseInt(suffix !== null ? modifier.substring(1, modifier.length - endIdx - 1) : modifier.substring(1, modifier.length), 10);
3702
+ var widthModifier = value;
3703
+ var heightModifier = value;
3567
3704
 
3568
- _proto.resize = function resize(width, height) {
3569
- this._player.resize(width, height);
3705
+ if (isPercent) {
3706
+ widthModifier = dimensions.width / 100 * value;
3707
+ heightModifier = dimensions.height / 100 * value;
3708
+ }
3570
3709
 
3571
- this.eventbus.broadcast(TimelineEventNames.RESIZE, [width, height]);
3572
- };
3710
+ dimensions = _modifyDimensions(dimensions, prefix, suffix, widthModifier, heightModifier);
3573
3711
 
3574
- _proto.duration = function duration(resultCallback) {
3575
- resultCallback(Math.floor(this.getDuration()));
3576
- };
3712
+ if (ratioModifier) {
3713
+ modifyDimensionsByRatio(ratioModifier, dimensions);
3714
+ }
3715
+ }
3577
3716
 
3578
- _proto.playlistItem = function playlistItem(uri) {
3579
- var index = this._playlist.findIndex(function (item) {
3580
- return item.file === uri;
3581
- });
3717
+ /**
3718
+ * This operation calculates the width and height of the specified selected element.
3719
+ * It assigns this struct to the dimensions property on the current operation data.
3720
+ * Optionally the width and height can be tweaked using the given modifier string.
3721
+ *
3722
+ * The modifier string is formatted in the following way:
3723
+ *
3724
+ * <operator><amount><optional-side><optional-precentage>|<ratio-definition>
3725
+ *
3726
+ * Where the ratio modifier is formatted in the following way:
3727
+ * <side>[ar=<ratio-left>-<ratio-right>]
3728
+ *
3729
+ * For example, this modifier '+100h|w[ar=8-1]' will modifiy the dimensions like this:
3730
+ * it will add a value of 100 to the height and modify the width by a ration of 8 to 1 relative to the height.
3731
+ *
3732
+ * @param operationData
3733
+ * @returns
3734
+ */
3582
3735
 
3583
- if (index > -1) {
3584
- this._player.playlistItem(index);
3585
- }
3586
- };
3736
+ var getElementDimensions = function getElementDimensions(operationData) {
3737
+ var _selectedElement$inne, _selectedElement$inne2;
3587
3738
 
3588
- _proto.getPosition = function getPosition() {
3589
- return this._player.getPosition();
3739
+ var selectedElement = operationData.selectedElement,
3740
+ modifier = operationData.modifier;
3741
+ var dimensions = {
3742
+ width: (_selectedElement$inne = selectedElement.innerWidth()) != null ? _selectedElement$inne : 0,
3743
+ height: (_selectedElement$inne2 = selectedElement.innerHeight()) != null ? _selectedElement$inne2 : 0
3590
3744
  };
3591
3745
 
3592
- _proto.getPlaylistIndex = function getPlaylistIndex() {
3593
- return this._player.getPlaylistIndex();
3594
- };
3746
+ if (dimensions.height === 0) {
3747
+ dimensions.height = dimensions.width;
3748
+ }
3595
3749
 
3596
- _proto.getState = function getState() {
3597
- return this._player.getState();
3598
- };
3750
+ if (modifier) {
3751
+ modifyDimensions(dimensions, modifier);
3752
+ }
3599
3753
 
3600
- _proto.getDuration = function getDuration() {
3601
- return this._player.getDuration();
3602
- };
3754
+ operationData.dimensions = dimensions;
3755
+ return operationData;
3756
+ };
3603
3757
 
3604
- _proto.getMute = function getMute() {
3605
- return this._player.getMute();
3606
- };
3758
+ /**
3759
+ * This operation retrieves the import specified by the given system name and
3760
+ * assigns it to the importedInstance property on the current operaton date.
3761
+ *
3762
+ * @param operationData
3763
+ * @returns
3764
+ */
3607
3765
 
3608
- _proto.getVolume = function getVolume() {
3609
- return this._player.getVolume();
3610
- };
3766
+ var getImport = function getImport(operationData) {
3767
+ var systemName = operationData.systemName;
3611
3768
 
3612
- _proto.setMute = function setMute(state) {
3613
- this._player.setMute(state);
3769
+ var callBack = function callBack(instance) {
3770
+ operationData.importedInstance = instance;
3614
3771
  };
3615
3772
 
3616
- _proto.setVolume = function setVolume(volume) {
3617
- this._player.setVolume(volume);
3618
- };
3773
+ this.eventbus.broadcast(TimelineEventNames.REQUEST_FUNCTION, [systemName, callBack]);
3774
+ delete operationData.systemName;
3775
+ return operationData;
3776
+ };
3619
3777
 
3620
- return JwPlayerTimelineProvider;
3621
- }();
3778
+ var jsonCache = {};
3779
+ var addToCache = function addToCache(key, value) {
3780
+ jsonCache[key] = value;
3781
+ };
3782
+ /**
3783
+ * This operation loads a JSON file from the specified url and assigns it to the specified
3784
+ * property name on the current operation data. The property name defaults to 'json'.
3785
+ *
3786
+ * If the cache property is set to true and a cached value already exists, this is assigned
3787
+ * instead of re-retrieving it from the url.
3788
+ *
3789
+ * @param operationData
3790
+ * @returns
3791
+ */
3622
3792
 
3623
- var _window = window,
3624
- MediaElementPlayer = _window.MediaElementPlayer;
3625
- var MediaElementTimelineProvider = /*#__PURE__*/function () {
3626
- function MediaElementTimelineProvider(eventbus, config) {
3627
- this.eventbus = eventbus;
3628
- this.config = config;
3629
- this._videoElementId = uuid.v4();
3630
- this._eventbusListeners = [];
3631
- this._playlist = [];
3632
- this._length = 0;
3633
- this._urls = [];
3634
- this.loop = false;
3793
+ var loadJSON = function loadJSON(operationData) {
3794
+ var url = operationData.url,
3795
+ cache = operationData.cache,
3796
+ _operationData$proper = operationData.propertyName,
3797
+ propertyName = _operationData$proper === void 0 ? 'json' : _operationData$proper;
3635
3798
 
3636
- this._addEventListeners();
3799
+ if (cache && jsonCache[url]) {
3800
+ operationData[propertyName] = jsonCache[url];
3801
+ delete operationData.propertyName;
3802
+ return operationData;
3637
3803
  }
3638
3804
 
3639
- var _proto = MediaElementTimelineProvider.prototype;
3805
+ return new Promise(function (resolve, reject) {
3806
+ fetch(url).then( /*#__PURE__*/function () {
3807
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response) {
3808
+ var json, cacheValue;
3809
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
3810
+ while (1) {
3811
+ switch (_context.prev = _context.next) {
3812
+ case 0:
3813
+ _context.next = 2;
3814
+ return response.json();
3640
3815
 
3641
- _proto._addEventListeners = function _addEventListeners() {
3642
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PLAY_REQUEST, this.start.bind(this)));
3816
+ case 2:
3817
+ json = _context.sent;
3818
+ cacheValue = operationData[propertyName] = json;
3819
+ delete operationData.propertyName;
3820
+ addToCache(url, cacheValue);
3821
+ resolve(operationData);
3643
3822
 
3644
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.STOP_REQUEST, this.stop.bind(this)));
3823
+ case 7:
3824
+ case "end":
3825
+ return _context.stop();
3826
+ }
3827
+ }
3828
+ }, _callee);
3829
+ }));
3645
3830
 
3646
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PAUSE_REQUEST, this.pause.bind(this)));
3831
+ return function (_x) {
3832
+ return _ref.apply(this, arguments);
3833
+ };
3834
+ }())["catch"](reject);
3835
+ });
3836
+ };
3647
3837
 
3648
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.SEEK_REQUEST, this.seek.bind(this)));
3838
+ /**
3839
+ * This operation logs the current operation data and context.
3840
+ *
3841
+ * @param operationData
3842
+ * @returns
3843
+ */
3844
+ var log = function log(operationData) {
3845
+ console.group('Operation info');
3846
+ console.dir({
3847
+ context: this
3848
+ });
3849
+ console.dir({
3850
+ operationData: operationData
3851
+ });
3852
+ console.groupEnd();
3853
+ return operationData;
3854
+ };
3649
3855
 
3650
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.RESIZE_REQUEST, this.resize.bind(this)));
3856
+ /**
3857
+ * This operation removes the spcified class name from the specified selected element.
3858
+ *
3859
+ * @param operationData
3860
+ * @returns
3861
+ */
3862
+ var removeClass = function removeClass(operationData) {
3863
+ var selectedElement = operationData.selectedElement,
3864
+ className = operationData.className;
3865
+ selectedElement.removeClass(className);
3866
+ return operationData;
3867
+ };
3651
3868
 
3652
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.CONTAINER_REQUEST, this._container.bind(this)));
3869
+ /**
3870
+ * This operation removes the controller with the specified name from the specified selected element.
3871
+ *
3872
+ * @param operationData
3873
+ * @returns
3874
+ */
3653
3875
 
3654
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.DURATION_REQUEST, this.duration.bind(this)));
3655
- };
3876
+ var removeControllerFromElement = function removeControllerFromElement(operationData) {
3877
+ var selectedElement = operationData.selectedElement,
3878
+ controllerName = operationData.controllerName;
3879
+ var controllers = getElementControllers(selectedElement);
3880
+ var controller = controllers == null ? void 0 : controllers.find(function (ctrl) {
3881
+ return ctrl.name === controllerName;
3882
+ });
3656
3883
 
3657
- _proto._extractUrls = function _extractUrls(configuration) {
3658
- var urls = configuration.timelines.filter(function (timeline) {
3659
- return timeline.type === 'mediaplayer';
3660
- }).map(function (timeline) {
3661
- return timeline.uri;
3662
- });
3663
- return urls;
3664
- };
3884
+ if (controller) {
3885
+ var idx = controllers.indexOf(controller);
3886
+ controllers.splice(idx, 1);
3887
+ controller.detach(this.eventbus);
3888
+ }
3665
3889
 
3666
- _proto.init = function init() {
3667
- var _this = this;
3890
+ return operationData;
3891
+ };
3668
3892
 
3669
- var selector = '';
3670
- this._urls = this._extractUrls(this.config);
3893
+ /**
3894
+ * This operation removes the specified selected element from the DOM.
3895
+ *
3896
+ * @param operationData
3897
+ * @returns
3898
+ */
3899
+ var removeElement = function removeElement(operationData) {
3900
+ var selectedElement = operationData.selectedElement;
3901
+ selectedElement.remove();
3902
+ return operationData;
3903
+ };
3671
3904
 
3672
- this._addVideoElements(selector, this._urls);
3905
+ /**
3906
+ * This operation removes the given list of properties from the current operation data.
3907
+ *
3908
+ * @param operationData
3909
+ * @returns
3910
+ */
3911
+ var removePropertiesFromOperationData = function removePropertiesFromOperationData(operationData) {
3912
+ var propertyNames = operationData.propertyNames;
3913
+ propertyNames.forEach(function (name) {
3914
+ delete operationData[name];
3915
+ });
3916
+ delete operationData.propertyNames;
3917
+ return operationData;
3918
+ };
3673
3919
 
3674
- var self = this;
3675
- var promise = new Promise(function (resolve) {
3676
- var videoElement = document.getElementById(_this._videoElementId);
3677
- self.player = new MediaElementPlayer(videoElement, {
3678
- success: function success(mediaElement, _originalNode, instance) {
3679
- mediaElement.addEventListener('timeupdate', _this._timeUpdateHandler.bind(_this));
3680
- instance.loop = _this.loop;
3681
- instance.controlsAreVisible = false;
3682
- instance.controlsEnabled = false;
3683
- resolve();
3684
- }
3685
- });
3686
- });
3687
- return promise;
3688
- };
3920
+ /**
3921
+ * This operation moves the specified selected element to the new parent that is defined
3922
+ * by the specified selector.
3923
+ *
3924
+ * @param operationData
3925
+ * @returns
3926
+ */
3927
+ var reparentElement = function reparentElement(operationData) {
3928
+ var selectedElement = operationData.selectedElement,
3929
+ newParentSelector = operationData.newParentSelector;
3930
+ selectedElement.remove().appendTo(newParentSelector);
3931
+ return operationData;
3932
+ };
3689
3933
 
3690
- _proto._timeUpdateHandler = function _timeUpdateHandler() {
3691
- if (this.player) {
3692
- this.eventbus.broadcast(TimelineEventNames.TIME, [{
3693
- position: this.player.currentTime
3694
- }]);
3695
- this.eventbus.broadcast(TimelineEventNames.POSITION_UPDATE, [{
3696
- position: this.player.currentTime,
3697
- duration: this.player.duration
3698
- }]);
3699
- }
3700
- };
3934
+ /**
3935
+ * This operation requests an action instance with the specified name and assigns it
3936
+ * to the actionInstance property on the current operation data.
3937
+ *
3938
+ * @param operationData
3939
+ * @returns
3940
+ */
3701
3941
 
3702
- _proto._addVideoElements = function _addVideoElements(selector, urls) {
3703
- var _this2 = this;
3942
+ var requestAction = function requestAction(operationData) {
3943
+ var systemName = operationData.systemName;
3704
3944
 
3705
- var videoElm = ["<video class='mejs__player' id=" + this._videoElementId + " data-mejsoptions='{\"preload\": \"true\"}'>"];
3706
- urls.forEach(function (url) {
3707
- videoElm.push("<source src='" + url + "' type='" + _this2._extractFileType(url) + "'/>");
3708
- });
3709
- videoElm.push('</video>');
3710
- $(selector).append(videoElm.join(''));
3945
+ var resultCallback = function resultCallback(action) {
3946
+ operationData.actionInstance = action;
3711
3947
  };
3712
3948
 
3713
- _proto._extractFileType = function _extractFileType(url) {
3714
- var lastIdx = url.lastIndexOf('.');
3715
- return "video/" + url.substr(lastIdx + 1);
3716
- };
3949
+ this.eventbus.broadcast(TimelineEventNames.REQUEST_ACTION, [systemName, resultCallback]);
3950
+ return operationData;
3951
+ };
3717
3952
 
3718
- _proto.playlistItem = function playlistItem(uri) {
3719
- var _this$player;
3953
+ /**
3954
+ * @deprecated
3955
+ *
3956
+ * @param operationData
3957
+ * @returns
3958
+ */
3720
3959
 
3721
- (_this$player = this.player) == null ? void 0 : _this$player.setSrc(uri);
3722
- };
3960
+ var resizeAction = function resizeAction(operationData) {
3961
+ var _operationData = operationData,
3962
+ actionInstance = _operationData.actionInstance,
3963
+ actionOperationData = _operationData.actionOperationData;
3964
+ operationData = mergeOperationData(operationData, actionOperationData);
3723
3965
 
3724
- _proto.start = function start() {
3725
- var _this$player2;
3966
+ if (actionInstance.resize) {
3967
+ return actionInstance.resize(operationData);
3968
+ }
3726
3969
 
3727
- (_this$player2 = this.player) == null ? void 0 : _this$player2.play();
3728
- };
3970
+ return operationData;
3971
+ };
3729
3972
 
3730
- _proto.stop = function stop() {
3731
- var _this$player3;
3973
+ function findElementBySelector(root, selector, operationData, propertyName) {
3974
+ var element = root.find(selector);
3732
3975
 
3733
- (_this$player3 = this.player) == null ? void 0 : _this$player3.stop();
3734
- };
3976
+ if (!element.length) {
3977
+ console.warn("selector '" + selector + "' wasn't found!");
3978
+ }
3735
3979
 
3736
- _proto.destroy = function destroy() {
3737
- var _this$player4, _this$player6;
3980
+ operationData[propertyName] = element;
3738
3981
 
3739
- if (!((_this$player4 = this.player) != null && _this$player4.paused)) {
3740
- var _this$player5;
3982
+ if (operationData.hasOwnProperty('propertyName')) {
3983
+ delete operationData.propertyName;
3984
+ }
3985
+ }
3986
+ /**
3987
+ * This operation selects one or more elements using the specified selector.
3988
+ *
3989
+ * If useSelectedElementAsRoot is set to true and a valid DOM element is assigned
3990
+ * to the current operation data defined by the given property name (defaults to 'selectedElement')
3991
+ * then the element will be looked for only in the child elements of this DOM element.
3992
+ *
3993
+ * @param operationData
3994
+ * @returns
3995
+ */
3741
3996
 
3742
- (_this$player5 = this.player) == null ? void 0 : _this$player5.pause();
3743
- }
3744
3997
 
3745
- (_this$player6 = this.player) == null ? void 0 : _this$player6.remove();
3746
- $("#" + this._videoElementId).remove();
3998
+ var selectElement = function selectElement(operationData) {
3999
+ var selector = operationData.selector,
4000
+ _operationData$proper = operationData.propertyName,
4001
+ propertyName = _operationData$proper === void 0 ? 'selectedElement' : _operationData$proper,
4002
+ _operationData$useSel = operationData.useSelectedElementAsRoot,
4003
+ useSelectedElementAsRoot = _operationData$useSel === void 0 ? false : _operationData$useSel;
3747
4004
 
3748
- this._eventbusListeners.forEach(function (func) {
3749
- return func();
3750
- });
3751
- };
4005
+ if (!selector) {
4006
+ throw new Error('selector is undefined!');
4007
+ }
3752
4008
 
3753
- _proto.pause = function pause() {
3754
- var _this$player7;
4009
+ if (useSelectedElementAsRoot && operationData[propertyName]) {
4010
+ var currentRoot = operationData[propertyName];
4011
+ findElementBySelector(currentRoot, selector, operationData, propertyName);
4012
+ return operationData;
4013
+ }
3755
4014
 
3756
- (_this$player7 = this.player) == null ? void 0 : _this$player7.pause();
4015
+ var rootCallback = function rootCallback(root) {
4016
+ findElementBySelector(root, selector, operationData, propertyName);
3757
4017
  };
3758
4018
 
3759
- _proto.seek = function seek(position) {
3760
- var _this$player8;
3761
-
3762
- (_this$player8 = this.player) == null ? void 0 : _this$player8.setCurrentTime(position);
3763
- };
4019
+ this.eventbus.broadcast(TimelineEventNames.REQUEST_ENGINE_ROOT, [rootCallback]);
4020
+ return operationData;
4021
+ };
3764
4022
 
3765
- _proto.resize = function resize() {};
4023
+ /**
4024
+ * This operation sets the given set of attributes on the specified selected element.
4025
+ *
4026
+ * @param operationData
4027
+ * @returns
4028
+ */
4029
+ var setElementAttributes = function setElementAttributes(operationData) {
4030
+ var attributes = operationData.attributes,
4031
+ selectedElement = operationData.selectedElement;
4032
+ Object.entries(attributes).forEach(function (_ref) {
4033
+ var attrName = _ref[0],
4034
+ attrValue = _ref[1];
4035
+ selectedElement.attr(attrName, attrValue);
4036
+ });
4037
+ return operationData;
4038
+ };
3766
4039
 
3767
- _proto.duration = function duration(resultCallback) {
3768
- resultCallback(this.getDuration());
3769
- };
4040
+ /**
4041
+ * This operation sets the specified content defined by the value assigned to the template property
4042
+ * to the specified selected element.
4043
+ *
4044
+ * When the insertionType is set to 'overwrite' the contents of the selected element are replaced
4045
+ * by the given template.
4046
+ * When set to 'append' the new content will be inserted after the current content.
4047
+ * When set to 'prepend' the new content will be inserted before the current content.
4048
+ *
4049
+ * @param operationData
4050
+ * @returns
4051
+ */
4052
+ var setElementContent = function setElementContent(operationData) {
4053
+ var _operationData$insert = operationData.insertionType,
4054
+ insertionType = _operationData$insert === void 0 ? 'overwrite' : _operationData$insert,
4055
+ selectedElement = operationData.selectedElement,
4056
+ template = operationData.template;
3770
4057
 
3771
- _proto.getDuration = function getDuration() {
3772
- var _this$player9;
4058
+ switch (true) {
4059
+ case insertionType === 'overwrite':
4060
+ selectedElement.html(template);
4061
+ break;
3773
4062
 
3774
- return ((_this$player9 = this.player) == null ? void 0 : _this$player9.duration) || -1;
3775
- };
4063
+ case insertionType === 'append':
4064
+ selectedElement.append(template);
4065
+ break;
3776
4066
 
3777
- _proto.getPosition = function getPosition() {
3778
- var _this$player10;
4067
+ case insertionType === 'prepend':
4068
+ selectedElement.prepend(template);
4069
+ break;
4070
+ }
3779
4071
 
3780
- return ((_this$player10 = this.player) == null ? void 0 : _this$player10.getCurrentTime()) || -1;
3781
- };
4072
+ delete operationData.insertionType;
4073
+ return operationData;
4074
+ };
3782
4075
 
3783
- _proto._container = function _container(resultCallback) {
3784
- resultCallback($("#" + this._videoElementId));
3785
- };
4076
+ /**
4077
+ * This operation assigns the specified properties to the current operation data.
4078
+ * When override is set to true the properties replace the current operation data entirely.
4079
+ *
4080
+ * @param operationData
4081
+ * @returns
4082
+ */
3786
4083
 
3787
- return MediaElementTimelineProvider;
3788
- }();
4084
+ var setOperationData = function setOperationData(operationData) {
4085
+ var _operationData = operationData,
4086
+ _operationData$overri = _operationData.override,
4087
+ override = _operationData$overri === void 0 ? false : _operationData$overri,
4088
+ properties = _operationData.properties;
4089
+ delete operationData.properties;
4090
+ delete operationData.override;
4091
+ var resolvedProperties = resolvePropertyValues(operationData, properties);
3789
4092
 
3790
- var RequestAnimationFrameTimelineProvider = /*#__PURE__*/function () {
3791
- function RequestAnimationFrameTimelineProvider(eventbus, config) {
3792
- this.eventbus = eventbus;
3793
- this.config = config;
3794
- this._requestID = -1;
3795
- this._last = 0;
3796
- this._currentPosition = 0;
3797
- this._updateBound = this._update.bind(this);
3798
- this._eventbusListeners = [];
3799
- this._firstFrame = true;
3800
- this._granularity = 1000;
3801
- this.playState = 'stopped';
3802
- this.loop = false;
3803
- this.eventbus = eventbus;
3804
- this.config = config;
3805
- this._playlist = this._extractPlaylist(config);
3806
- this._currentPlaylistItem = this._playlist[0];
4093
+ if (override) {
4094
+ operationData = resolvedProperties;
4095
+ } else {
4096
+ operationData = Object.assign(operationData, resolvedProperties);
3807
4097
  }
3808
4098
 
3809
- var _proto = RequestAnimationFrameTimelineProvider.prototype;
4099
+ return operationData;
4100
+ };
3810
4101
 
3811
- _proto._extractPlaylist = function _extractPlaylist(configuration) {
3812
- var playlist = configuration.timelines.filter(function (timeline) {
3813
- return timeline.type === 'animation';
3814
- });
3815
- return playlist;
3816
- };
3817
-
3818
- _proto.playlistItem = function playlistItem(uri) {
3819
- if (uri === null || !uri.length || this._playlist.length === 0) {
3820
- return;
3821
- }
4102
+ /**
4103
+ * This operation assigns the specified CSS style properties to the
4104
+ * specified selected element. The selected element is assigned to
4105
+ * the property defined by the propertyName property which defaults
4106
+ * to 'selectedElement'.
4107
+ *
4108
+ * @param operationData
4109
+ * @returns
4110
+ */
3822
4111
 
3823
- var item = this._playlist.find(function (item) {
3824
- return item.uri === uri;
3825
- });
4112
+ var setStyle = function setStyle(operationData) {
4113
+ var _operationData$proper = operationData.propertyName,
4114
+ propertyName = _operationData$proper === void 0 ? 'selectedElement' : _operationData$proper;
4115
+ var properties = resolvePropertyValues(operationData, operationData.properties);
4116
+ operationData[propertyName].css(properties);
4117
+ delete operationData.propertyName;
4118
+ return operationData;
4119
+ };
3826
4120
 
3827
- if (!item) {
3828
- throw new Error("Unknown playlist uri: " + uri);
3829
- }
4121
+ /**
4122
+ * This operation starts the specified action instance using the specified action operation data.
4123
+ *
4124
+ * The action operation data is first merged with the current operation data before it is
4125
+ * passed on to the action. After the action has completed the action operation data properties
4126
+ * are removed from the current operation data.
4127
+ *
4128
+ * @param operationData
4129
+ * @returns
4130
+ */
3830
4131
 
3831
- this._currentPlaylistItem = item;
3832
- this._firstFrame = true;
3833
- };
4132
+ var startAction = function startAction(operationData) {
4133
+ var _operationData = operationData,
4134
+ actionInstance = _operationData.actionInstance,
4135
+ actionOperationData = _operationData.actionOperationData;
4136
+ delete operationData.actionOperationData;
4137
+ return new Promise(function (resolve, reject) {
4138
+ operationData = mergeOperationData(operationData, actionOperationData);
4139
+ actionInstance.start(operationData).then(function () {
4140
+ Object.keys(actionOperationData).forEach(function (key) {
4141
+ delete operationData[key];
4142
+ });
4143
+ internalResolve(resolve, operationData);
4144
+ }, reject);
4145
+ });
4146
+ };
3834
4147
 
3835
- _proto._addEventListeners = function _addEventListeners() {
3836
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PLAY_TOGGLE_REQUEST, this.toggleplay.bind(this)));
4148
+ /**
4149
+ * This operation starts a loop using the given collection.
4150
+ *
4151
+ * Each iteration the current item from the specified collection is
4152
+ * assigned to the property on the current operation data specified
4153
+ * by the propertyName property which defaults to 'currentItem'.
4154
+ *
4155
+ * @param operationData
4156
+ * @returns
4157
+ */
4158
+ var startLoop = function startLoop(operationData) {
4159
+ var context = this;
4160
+ var collection = operationData.collection,
4161
+ _operationData$proper = operationData.propertyName,
4162
+ propertyName = _operationData$proper === void 0 ? 'currentItem' : _operationData$proper;
3837
4163
 
3838
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PLAY_REQUEST, this.start.bind(this)));
4164
+ if (typeof collection === 'string') {
4165
+ throw new Error('Expected collection to be array type, string value was probably not resolved correctly');
4166
+ }
3839
4167
 
3840
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.STOP_REQUEST, this.stop.bind(this)));
4168
+ if (context.loopIndex === undefined) {
4169
+ if (collection != null && collection.length) {
4170
+ context.loopIndex = 0;
4171
+ context.loopLength = collection.length - 1;
4172
+ context.startIndex = context.currentIndex;
4173
+ } else {
4174
+ context.skipNextOperation = true;
4175
+ }
4176
+ }
3841
4177
 
3842
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PAUSE_REQUEST, this.pause.bind(this)));
4178
+ if (collection != null && collection.length && context.loopIndex !== undefined) {
4179
+ operationData[propertyName] = collection[context.loopIndex];
4180
+ }
3843
4181
 
3844
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.SEEK_REQUEST, this.seek.bind(this)));
4182
+ delete operationData.propertyName;
4183
+ return operationData;
4184
+ };
3845
4185
 
3846
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.RESIZE_REQUEST, this._resize.bind(this)));
4186
+ /**
4187
+ * This operation toggles the specfied class name on the specified selected element.
4188
+ *
4189
+ * @param operationData
4190
+ * @returns
4191
+ */
4192
+ var toggleClass = function toggleClass(operationData) {
4193
+ var selectedElement = operationData.selectedElement,
4194
+ className = operationData.className;
4195
+ selectedElement.toggleClass(className);
4196
+ return operationData;
4197
+ };
3847
4198
 
3848
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.CONTAINER_REQUEST, this._container.bind(this)));
4199
+ /**
4200
+ * This operation toggles the visibility of the specified selected element
4201
+ *
4202
+ * @param operationData
4203
+ * @returns
4204
+ */
4205
+ var toggleElement = function toggleElement(operationData) {
4206
+ operationData.selectedElement.toggle();
4207
+ return operationData;
4208
+ };
3849
4209
 
3850
- this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.DURATION_REQUEST, this.requestDurationHandler.bind(this)));
3851
- };
4210
+ /**
4211
+ * This operation waits for the specified amount of milliseconds.
4212
+ *
4213
+ * @param operationData
4214
+ * @returns
4215
+ */
3852
4216
 
3853
- _proto._update = function _update(now) {
3854
- if (this.playState !== 'running') {
3855
- return;
3856
- }
4217
+ var wait = function wait(operationData) {
4218
+ var milliseconds = operationData.milliseconds;
4219
+ return new Promise(function (resolve) {
4220
+ setTimeout(function () {
4221
+ internalResolve(resolve, operationData);
4222
+ }, milliseconds);
4223
+ });
4224
+ };
3857
4225
 
3858
- if (!this._last || now - this._last >= this._granularity) {
3859
- if (!this._last && this._firstFrame) {
3860
- this._firstFrame = false;
3861
- this.eventbus.broadcast(TimelineEventNames.FIRST_FRAME);
3862
- }
4226
+ var ops = {
4227
+ __proto__: null,
4228
+ addClass: addClass,
4229
+ addControllerToElement: addControllerToElement,
4230
+ animate: animate,
4231
+ animateWithClass: animateWithClass,
4232
+ broadcastEvent: broadcastEvent,
4233
+ clearElement: clearElement,
4234
+ clearOperationData: clearOperationData,
4235
+ createElement: createElement,
4236
+ customFunction: customFunction,
4237
+ endAction: endAction,
4238
+ endLoop: endLoop,
4239
+ extendController: extendController,
4240
+ getControllerFromElement: getControllerFromElement,
4241
+ getControllerInstance: getControllerInstance,
4242
+ getElementDimensions: getElementDimensions,
4243
+ getImport: getImport,
4244
+ loadJSON: loadJSON,
4245
+ log: log,
4246
+ removeClass: removeClass,
4247
+ removeControllerFromElement: removeControllerFromElement,
4248
+ removeElement: removeElement,
4249
+ removePropertiesFromOperationData: removePropertiesFromOperationData,
4250
+ reparentElement: reparentElement,
4251
+ requestAction: requestAction,
4252
+ resizeAction: resizeAction,
4253
+ selectElement: selectElement,
4254
+ setElementAttributes: setElementAttributes,
4255
+ setElementContent: setElementContent,
4256
+ setOperationData: setOperationData,
4257
+ setStyle: setStyle,
4258
+ startAction: startAction,
4259
+ startLoop: startLoop,
4260
+ toggleClass: toggleClass,
4261
+ toggleElement: toggleElement,
4262
+ wait: wait
4263
+ };
3863
4264
 
3864
- this._last = now;
3865
- this._currentPosition++;
4265
+ var JwPlayerTimelineProvider = /*#__PURE__*/function () {
4266
+ function JwPlayerTimelineProvider(eventbus, config) {
4267
+ this.eventbus = void 0;
4268
+ this.config = void 0;
4269
+ this._paused = false;
4270
+ this._player = null;
4271
+ this._currentLoopHandler = null;
4272
+ this._eventbusListeners = [];
4273
+ this._playlist = [];
4274
+ this._videoElementId = uuid.v4();
4275
+ this.loop = false;
4276
+ this.eventbus = eventbus;
4277
+ this.config = config;
3866
4278
 
3867
- if (this._currentPosition > this._currentPlaylistItem.duration) {
3868
- if (this.loop) {
3869
- this._reset();
3870
- } else {
3871
- this.stop();
3872
- this.eventbus.broadcast(TimelineEventNames.COMPLETE);
3873
- return;
3874
- }
3875
- }
4279
+ this._addEventListeners();
4280
+ }
3876
4281
 
3877
- this.eventbus.broadcast(TimelineEventNames.TIME, [{
3878
- position: this._currentPosition
3879
- }]);
3880
- this.eventbus.broadcast(TimelineEventNames.POSITION_UPDATE, [{
3881
- position: this._currentPosition,
3882
- duration: this._currentPlaylistItem.duration
3883
- }]);
3884
- }
4282
+ var _proto = JwPlayerTimelineProvider.prototype;
3885
4283
 
3886
- this._requestID = requestAnimationFrame(this._updateBound);
4284
+ _proto._extractUrls = function _extractUrls(configuration) {
4285
+ var urls = configuration.timelines.filter(function (timeline) {
4286
+ return timeline.type === 'mediaplayer';
4287
+ }).map(function (timeline) {
4288
+ return timeline.uri;
4289
+ });
4290
+ return urls;
3887
4291
  };
3888
4292
 
3889
- _proto._start = function _start() {
3890
- if (this._requestID && this.playState === 'running') {
3891
- return;
3892
- }
4293
+ _proto.init = function init() {
4294
+ var _this = this;
3893
4295
 
3894
- this.playState = 'running';
3895
- this._requestID = requestAnimationFrame(this._updateBound);
3896
- };
4296
+ var settings = this.config.timelineProviderSettings['mediaplayer'];
3897
4297
 
3898
- _proto._reset = function _reset() {
3899
- this._cancelAnimationFrame();
4298
+ if (!settings) {
4299
+ throw new Error("No settings found for 'mediaplayer' timeline provider");
4300
+ }
3900
4301
 
3901
- this._last = 0;
3902
- this._currentPosition = 0;
3903
- };
4302
+ var selector = settings.selector;
3904
4303
 
3905
- _proto._resize = function _resize() {
3906
- console.error('Not implemented yet');
3907
- };
4304
+ var urls = this._extractUrls(this.config);
3908
4305
 
3909
- _proto._container = function _container(callBack) {
3910
- callBack(this._containerElement);
3911
- };
4306
+ var jwp = window.jwplayer;
4307
+ var p = $__default["default"]("#" + selector);
3912
4308
 
3913
- _proto._cancelAnimationFrame = function _cancelAnimationFrame() {
3914
- if (this._requestID) {
3915
- cancelAnimationFrame(this._requestID);
3916
- this._requestID = -1;
3917
- this._last = 0;
3918
- this._currentPosition = 0;
4309
+ if (!p.length) {
4310
+ throw new Error("videoplayer selector '" + selector + "' not found");
3919
4311
  }
3920
- };
3921
-
3922
- _proto.init = function init() {
3923
- this._addEventListeners();
3924
4312
 
3925
- this._currentPlaylistItem = this._playlist[0];
3926
- this._containerElement = $(this._currentPlaylistItem.selector);
4313
+ var w = p.innerWidth();
4314
+ var h = p.innerHeight();
3927
4315
 
3928
- if (!this._containerElement.length) {
3929
- throw new Error("timeline selector '" + this._currentPlaylistItem.selector + "' not found");
4316
+ if (w === 0) {
4317
+ w = 100;
3930
4318
  }
3931
4319
 
3932
- var promise = new Promise(function (resolve) {
3933
- resolve();
3934
- });
3935
- return promise;
3936
- };
3937
-
3938
- _proto.destroy = function destroy() {
3939
- this.stop();
3940
-
3941
- this._eventbusListeners.forEach(function (func) {
3942
- return func();
3943
- });
4320
+ if (h === 0) {
4321
+ h = 300;
4322
+ }
3944
4323
 
3945
- this._containerElement = undefined;
3946
- };
4324
+ this._player = jwp(selector);
3947
4325
 
3948
- _proto.toggleplay = function toggleplay() {
3949
- if (this.playState !== 'running') {
3950
- this.start();
3951
- } else {
3952
- this.pause();
3953
- }
3954
- };
4326
+ this._player.setup({
4327
+ file: urls[0],
4328
+ image: settings.poster,
4329
+ height: h,
4330
+ width: w,
4331
+ controls: true,
4332
+ autostart: false,
4333
+ displaytitle: false,
4334
+ displaydescription: false,
4335
+ nextUpDisplay: false,
4336
+ abouttext: 'Eligius',
4337
+ aboutlink: 'http://www.google.com',
4338
+ stretching: 'fill',
4339
+ repeat: false
4340
+ });
3955
4341
 
3956
- _proto.start = function start() {
3957
- this._start();
4342
+ this._playlist.length = 0;
4343
+ urls.forEach(function (url) {
4344
+ var item = {
4345
+ file: url,
4346
+ title: url,
4347
+ image: settings.poster
4348
+ };
3958
4349
 
3959
- this.eventbus.broadcast(TimelineEventNames.PLAY);
4350
+ _this._playlist.push(item);
4351
+ });
4352
+ var promise = new Promise(function (resolve) {
4353
+ _this._player.once('ready', function () {
4354
+ _this._handlePlayerReady(resolve);
4355
+ });
4356
+
4357
+ _this._player.load(_this._playlist);
4358
+ });
4359
+ return promise;
3960
4360
  };
3961
4361
 
3962
- _proto.stop = function stop() {
3963
- this._cancelAnimationFrame();
4362
+ _proto._handlePlayerReady = function _handlePlayerReady(resolve) {
4363
+ var _this2 = this;
3964
4364
 
3965
- this.playState = 'stopped';
3966
- this.eventbus.broadcast(TimelineEventNames.STOP);
3967
- };
4365
+ this._player.once('firstFrame', function () {
4366
+ _this2._player.pause();
3968
4367
 
3969
- _proto.pause = function pause() {
3970
- this.playState = 'paused';
3971
- this.eventbus.broadcast(TimelineEventNames.PAUSE);
4368
+ _this2.eventbus.broadcast(TimelineEventNames.DURATION, [_this2.getDuration()]);
4369
+
4370
+ resolve(_this2);
4371
+ });
4372
+
4373
+ this._player.on(TimelineEventNames.TIME, this._loopHandler.bind(this, Math.floor));
4374
+
4375
+ this._player.on(TimelineEventNames.SEEKED, this._seekedHandler.bind(this));
4376
+
4377
+ this._player.on(TimelineEventNames.COMPLETE, this._handlePlayerComplete.bind(this));
4378
+
4379
+ setTimeout(function () {
4380
+ _this2._player.play();
4381
+ }, 10);
3972
4382
  };
3973
4383
 
3974
- _proto.seek = function seek(position) {
3975
- if (position < 0 || position > this._currentPlaylistItem.duration) {
3976
- return;
4384
+ _proto._handlePlayerComplete = function _handlePlayerComplete() {
4385
+ if (!this.loop) {
4386
+ this.stop();
4387
+ this.eventbus.broadcast(TimelineEventNames.COMPLETE, [this._player.getPlaylistIndex()]);
3977
4388
  }
4389
+ };
3978
4390
 
3979
- this.eventbus.broadcast(TimelineEventNames.SEEK, [position, this._currentPosition, this.getDuration()]);
3980
- this._currentPosition = position;
3981
- this.eventbus.broadcast(TimelineEventNames.SEEKED, [this._currentPosition, this.getDuration()]);
3982
- this.eventbus.broadcast(TimelineEventNames.TIME, [{
3983
- position: this.getPosition()
3984
- }]);
3985
- this.eventbus.broadcast(TimelineEventNames.POSITION_UPDATE, [{
3986
- position: this._currentPosition,
3987
- duration: this._currentPlaylistItem.duration
3988
- }]);
4391
+ _proto._seekedHandler = function _seekedHandler() {
4392
+ this.eventbus.broadcast(TimelineEventNames.SEEKED, [this.getPosition(), this.getDuration()]);
3989
4393
  };
3990
4394
 
3991
- _proto.getPosition = function getPosition() {
3992
- return this._currentPosition;
4395
+ _proto.destroy = function destroy() {
4396
+ this._player.remove();
4397
+
4398
+ this._eventbusListeners.forEach(function (func) {
4399
+ return func();
4400
+ });
3993
4401
  };
3994
4402
 
3995
- _proto.getDuration = function getDuration() {
3996
- return this._currentPlaylistItem.duration;
4403
+ _proto._loopHandler = function _loopHandler(floor, jwplayerEvent) {
4404
+ var pos = floor(jwplayerEvent.position);
4405
+
4406
+ if (this.loop && pos === floor(this._player.getDuration() - 1)) {
4407
+ this.seek(0);
4408
+ }
3997
4409
  };
3998
4410
 
3999
- _proto.requestDurationHandler = function requestDurationHandler(callBack) {
4000
- callBack(this._currentPlaylistItem.duration);
4411
+ _proto._timeResetLoopHandler = function _timeResetLoopHandler() {
4412
+ if (this.loop) {
4413
+ this.seek(0);
4414
+ }
4001
4415
  };
4002
4416
 
4003
- return RequestAnimationFrameTimelineProvider;
4004
- }();
4417
+ _proto._addEventListeners = function _addEventListeners() {
4418
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PLAY_TOGGLE_REQUEST, this.toggleplay.bind(this)));
4005
4419
 
4420
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PLAY_REQUEST, this.start.bind(this)));
4006
4421
 
4422
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.STOP_REQUEST, this.stop.bind(this)));
4007
4423
 
4008
- var prvdrs = {
4009
- __proto__: null,
4010
- JwPlayerTimelineProvider: JwPlayerTimelineProvider,
4011
- MediaElementTimelineProvider: MediaElementTimelineProvider,
4012
- RequestAnimationFrameTimelineProvider: RequestAnimationFrameTimelineProvider
4013
- };
4424
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PAUSE_REQUEST, this.pause.bind(this)));
4014
4425
 
4015
- var customFunction = function customFunction(operationData) {
4016
- var _this = this;
4426
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.SEEK_REQUEST, this.seek.bind(this)));
4017
4427
 
4018
- var systemName = operationData.systemName;
4019
- return new Promise(function (resolve, reject) {
4020
- var resultCallback = function resultCallback(func) {
4021
- var promise = func(operationData, _this.eventbus);
4428
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.RESIZE_REQUEST, this.resize.bind(this)));
4022
4429
 
4023
- if (promise) {
4024
- promise.then(function () {
4025
- internalResolve(resolve, {}, operationData);
4026
- }, reject);
4027
- } else {
4028
- internalResolve(resolve, {}, operationData);
4029
- }
4030
- };
4430
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.CONTAINER_REQUEST, this._container.bind(this)));
4031
4431
 
4032
- _this.eventbus.broadcast(TimelineEventNames.REQUEST_FUNCTION, [systemName, resultCallback]);
4033
- });
4034
- };
4432
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.DURATION_REQUEST, this.duration.bind(this)));
4433
+ };
4035
4434
 
4036
- var endAction = function endAction(operationData) {
4037
- var _operationData = operationData,
4038
- actionInstance = _operationData.actionInstance,
4039
- actionOperationData = _operationData.actionOperationData;
4040
- delete operationData.actionOperationData;
4041
- return new Promise(function (resolve, reject) {
4042
- operationData = mergeOperationData(operationData, actionOperationData);
4043
- actionInstance.end(operationData).then(function () {
4044
- Object.keys(actionOperationData).forEach(function (key) {
4045
- delete operationData[key];
4046
- });
4047
- internalResolve(resolve, operationData);
4048
- }, reject);
4049
- });
4050
- };
4435
+ _proto._container = function _container(resultCallback) {
4436
+ var suffix = '';
4051
4437
 
4052
- var endLoop = function endLoop(operationData) {
4053
- var context = this;
4438
+ if (this._player.getProvider().name !== 'html5') {
4439
+ suffix = '_wrapper';
4440
+ }
4054
4441
 
4055
- if (!context.skipNextOperation) {
4056
- if (context.loopIndex !== undefined && context.loopLength !== undefined && context.loopIndex < context.loopLength) {
4057
- context.loopIndex = context.loopIndex + 1;
4058
- context.newIndex = context.startIndex;
4442
+ var container = $__default["default"]("#" + this._videoElementId + suffix);
4443
+ resultCallback(container);
4444
+ };
4445
+
4446
+ _proto.toggleplay = function toggleplay() {
4447
+ if (this._paused) {
4448
+ this.start();
4059
4449
  } else {
4060
- delete context.loopIndex;
4061
- delete context.loopLength;
4062
- delete context.startIndex;
4063
- delete context.newIndex;
4450
+ this.pause();
4064
4451
  }
4065
- } else {
4066
- delete context.skipNextOperation;
4067
- }
4068
-
4069
- return operationData;
4070
- };
4452
+ };
4071
4453
 
4072
- var extendController = function extendController(operationData) {
4073
- var controllerInstance = operationData.controllerInstance,
4074
- controllerExtension = operationData.controllerExtension;
4075
- operationData.controllerInstance = Object.assign(controllerInstance, controllerExtension);
4076
- return operationData;
4077
- };
4454
+ _proto.start = function start() {
4455
+ this._paused = false;
4078
4456
 
4079
- var getControllerFromElement = function getControllerFromElement(operationData) {
4080
- var selectedElement = operationData.selectedElement,
4081
- controllerName = operationData.controllerName;
4082
- var controllers = getElementControllers(selectedElement);
4083
- var controller = controllers.find(function (ctrl) {
4084
- return ctrl.name === controllerName;
4085
- });
4457
+ this._player.play();
4086
4458
 
4087
- if (!controller) {
4088
- console.warn("controller for name '" + controllerName + "' was not found on the given element");
4089
- }
4459
+ this.eventbus.broadcast(TimelineEventNames.PLAY);
4460
+ };
4090
4461
 
4091
- operationData.controllerInstance = controller;
4092
- return operationData;
4093
- };
4462
+ _proto.stop = function stop() {
4463
+ this._paused = false;
4094
4464
 
4095
- var getControllerInstance = function getControllerInstance(operationData) {
4096
- var systemName = operationData.systemName,
4097
- _operationData$proper = operationData.propertyName,
4098
- propertyName = _operationData$proper === void 0 ? 'controllerInstance' : _operationData$proper;
4099
- operationData[propertyName] = null;
4465
+ this._player.stop();
4100
4466
 
4101
- var resultCallback = function resultCallback(instance) {
4102
- operationData[propertyName] = instance;
4467
+ this.eventbus.broadcast(TimelineEventNames.STOP);
4103
4468
  };
4104
4469
 
4105
- this.eventbus.broadcast(TimelineEventNames.REQUEST_INSTANCE, [systemName, resultCallback]);
4106
- delete operationData.propertyName;
4107
- return operationData;
4108
- };
4470
+ _proto.pause = function pause() {
4471
+ this._paused = true;
4109
4472
 
4110
- function modifyDimensionsByRatio(ratioModifier, dimensions) {
4111
- //h[ar=8-1]
4112
- var prefix = ratioModifier.substr(0, 1);
4113
- var ratio = ratioModifier.substr(ratioModifier.indexOf('[') + 1, ratioModifier.indexOf(']') - ratioModifier.indexOf('[') - 1);
4114
- var ratios = ratio.split('=')[1].split('-');
4473
+ this._player.pause();
4115
4474
 
4116
- if (prefix === 'h') {
4117
- dimensions.height = dimensions.width / +ratios[0] * +ratios[1];
4118
- } else if (prefix === 'w') {
4119
- dimensions.width = dimensions.height / +ratios[1] * +ratios[0];
4120
- }
4121
- }
4475
+ this.eventbus.broadcast(TimelineEventNames.PAUSE);
4476
+ };
4122
4477
 
4123
- function getModifierSuffix(modifier) {
4124
- var endIdx = 1;
4125
- var suffix = modifier.substr(modifier.length - 1, 1);
4478
+ _proto.seek = function seek(position) {
4479
+ var currentPosition = this._player.getPosition();
4126
4480
 
4127
- if (suffix !== 'h' && suffix !== 'w' && suffix !== '%') {
4128
- suffix = null;
4129
- }
4481
+ this._player.seek(position);
4130
4482
 
4131
- var isPercent = suffix === '%';
4483
+ this.eventbus.broadcast(TimelineEventNames.SEEK, [position, currentPosition, this._player.getDuration()]);
4484
+ };
4132
4485
 
4133
- if (isPercent) {
4134
- endIdx = 2;
4135
- suffix = modifier.substr(modifier.length - endIdx, 1);
4486
+ _proto.resize = function resize(width, height) {
4487
+ this._player.resize(width, height);
4136
4488
 
4137
- if (suffix !== 'h' && suffix !== 'w') {
4138
- suffix = null;
4139
- endIdx = 1;
4140
- }
4141
- }
4489
+ this.eventbus.broadcast(TimelineEventNames.RESIZE, [width, height]);
4490
+ };
4142
4491
 
4143
- return [suffix, endIdx, isPercent];
4144
- }
4492
+ _proto.duration = function duration(resultCallback) {
4493
+ resultCallback(Math.floor(this.getDuration()));
4494
+ };
4145
4495
 
4146
- function _modifyDimensions(dimensions, prefix, suffix, widthModifier, heightModifier) {
4147
- switch (prefix) {
4148
- case '+':
4149
- switch (suffix) {
4150
- case 'h':
4151
- dimensions.height += heightModifier;
4152
- break;
4496
+ _proto.playlistItem = function playlistItem(uri) {
4497
+ var index = this._playlist.findIndex(function (item) {
4498
+ return item.file === uri;
4499
+ });
4153
4500
 
4154
- case 'w':
4155
- dimensions.width += widthModifier;
4156
- break;
4501
+ if (index > -1) {
4502
+ this._player.playlistItem(index);
4503
+ }
4504
+ };
4157
4505
 
4158
- default:
4159
- dimensions.height += heightModifier;
4160
- dimensions.width += widthModifier;
4161
- }
4506
+ _proto.getPosition = function getPosition() {
4507
+ return this._player.getPosition();
4508
+ };
4162
4509
 
4163
- break;
4510
+ _proto.getPlaylistIndex = function getPlaylistIndex() {
4511
+ return this._player.getPlaylistIndex();
4512
+ };
4164
4513
 
4165
- case '-':
4166
- switch (suffix) {
4167
- case 'h':
4168
- dimensions.height -= heightModifier;
4169
- break;
4514
+ _proto.getState = function getState() {
4515
+ return this._player.getState();
4516
+ };
4170
4517
 
4171
- case 'w':
4172
- dimensions.width -= widthModifier;
4173
- break;
4518
+ _proto.getDuration = function getDuration() {
4519
+ return this._player.getDuration();
4520
+ };
4174
4521
 
4175
- default:
4176
- dimensions.height -= heightModifier;
4177
- dimensions.width -= widthModifier;
4178
- }
4522
+ _proto.getMute = function getMute() {
4523
+ return this._player.getMute();
4524
+ };
4179
4525
 
4180
- break;
4526
+ _proto.getVolume = function getVolume() {
4527
+ return this._player.getVolume();
4528
+ };
4181
4529
 
4182
- case '/':
4183
- switch (suffix) {
4184
- case 'h':
4185
- dimensions.height /= heightModifier;
4186
- break;
4530
+ _proto.setMute = function setMute(state) {
4531
+ this._player.setMute(state);
4532
+ };
4187
4533
 
4188
- case 'w':
4189
- dimensions.width /= widthModifier;
4190
- break;
4534
+ _proto.setVolume = function setVolume(volume) {
4535
+ this._player.setVolume(volume);
4536
+ };
4191
4537
 
4192
- default:
4193
- dimensions.height /= heightModifier;
4194
- dimensions.width /= widthModifier;
4195
- }
4538
+ return JwPlayerTimelineProvider;
4539
+ }();
4196
4540
 
4197
- break;
4541
+ var RequestAnimationFrameTimelineProvider = /*#__PURE__*/function () {
4542
+ function RequestAnimationFrameTimelineProvider(eventbus, config) {
4543
+ this.eventbus = void 0;
4544
+ this.config = void 0;
4545
+ this._requestID = -1;
4546
+ this._last = 0;
4547
+ this._currentPosition = 0;
4548
+ this._updateBound = this._update.bind(this);
4549
+ this._eventbusListeners = [];
4550
+ this._firstFrame = true;
4551
+ this._currentPlaylistItem = void 0;
4552
+ this._granularity = 1000;
4553
+ this._playlist = void 0;
4554
+ this._containerElement = void 0;
4555
+ this.playState = 'stopped';
4556
+ this.loop = false;
4557
+ this.eventbus = eventbus;
4558
+ this.config = config;
4559
+ this.eventbus = eventbus;
4560
+ this.config = config;
4561
+ this._playlist = this._extractPlaylist(config);
4562
+ this._currentPlaylistItem = this._playlist[0];
4563
+ }
4198
4564
 
4199
- case '*':
4200
- switch (suffix) {
4201
- case 'h':
4202
- dimensions.height *= heightModifier;
4203
- break;
4565
+ var _proto = RequestAnimationFrameTimelineProvider.prototype;
4204
4566
 
4205
- case 'w':
4206
- dimensions.width *= widthModifier;
4207
- break;
4567
+ _proto._extractPlaylist = function _extractPlaylist(configuration) {
4568
+ var playlist = configuration.timelines.filter(function (timeline) {
4569
+ return timeline.type === 'animation';
4570
+ });
4571
+ return playlist;
4572
+ };
4208
4573
 
4209
- default:
4210
- dimensions.height *= heightModifier;
4211
- dimensions.width *= widthModifier;
4212
- }
4574
+ _proto.playlistItem = function playlistItem(uri) {
4575
+ if (uri === null || !uri.length || this._playlist.length === 0) {
4576
+ return;
4577
+ }
4213
4578
 
4214
- break;
4579
+ var item = this._playlist.find(function (item) {
4580
+ return item.uri === uri;
4581
+ });
4215
4582
 
4216
- default:
4217
- console.error("Unknown operator found: " + prefix);
4218
- }
4583
+ if (!item) {
4584
+ throw new Error("Unknown playlist uri: " + uri);
4585
+ }
4219
4586
 
4220
- return dimensions;
4221
- }
4587
+ this._currentPlaylistItem = item;
4588
+ this._firstFrame = true;
4589
+ };
4222
4590
 
4223
- function modifyDimensions(dimensions, modifier) {
4224
- var ratioModifier = null;
4591
+ _proto._addEventListeners = function _addEventListeners() {
4592
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PLAY_TOGGLE_REQUEST, this.toggleplay.bind(this)));
4225
4593
 
4226
- if (modifier.indexOf('|') > -1) {
4227
- var _modifier$split = modifier.split('|');
4594
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PLAY_REQUEST, this.start.bind(this)));
4228
4595
 
4229
- modifier = _modifier$split[0];
4230
- ratioModifier = _modifier$split[1];
4231
- }
4596
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.STOP_REQUEST, this.stop.bind(this)));
4232
4597
 
4233
- var prefix = modifier.substr(0, 1);
4598
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.PAUSE_REQUEST, this.pause.bind(this)));
4234
4599
 
4235
- var _getModifierSuffix = getModifierSuffix(modifier),
4236
- suffix = _getModifierSuffix[0],
4237
- endIdx = _getModifierSuffix[1],
4238
- isPercent = _getModifierSuffix[2];
4600
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.SEEK_REQUEST, this.seek.bind(this)));
4239
4601
 
4240
- var value = parseInt(suffix !== null ? modifier.substr(1, modifier.length - endIdx - 1) : modifier.substr(1, modifier.length), 10);
4241
- var widthModifier = value;
4242
- var heightModifier = value;
4602
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.RESIZE_REQUEST, this._resize.bind(this)));
4243
4603
 
4244
- if (isPercent) {
4245
- widthModifier = dimensions.width / 100 * value;
4246
- heightModifier = dimensions.height / 100 * value;
4247
- }
4604
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.CONTAINER_REQUEST, this._container.bind(this)));
4248
4605
 
4249
- dimensions = _modifyDimensions(dimensions, prefix, suffix, widthModifier, heightModifier);
4606
+ this._eventbusListeners.push(this.eventbus.on(TimelineEventNames.DURATION_REQUEST, this.requestDurationHandler.bind(this)));
4607
+ };
4250
4608
 
4251
- if (ratioModifier) {
4252
- modifyDimensionsByRatio(ratioModifier, dimensions);
4253
- }
4254
- }
4609
+ _proto._update = function _update(now) {
4610
+ if (this.playState !== 'running') {
4611
+ return;
4612
+ }
4255
4613
 
4256
- var getElementDimensions = function getElementDimensions(operationData) {
4257
- var _selectedElement$inne, _selectedElement$inne2;
4614
+ if (!this._last || now - this._last >= this._granularity) {
4615
+ if (!this._last && this._firstFrame) {
4616
+ this._firstFrame = false;
4617
+ this.eventbus.broadcast(TimelineEventNames.FIRST_FRAME);
4618
+ }
4258
4619
 
4259
- var selectedElement = operationData.selectedElement,
4260
- modifier = operationData.modifier;
4261
- var dimensions = {
4262
- width: (_selectedElement$inne = selectedElement.innerWidth()) != null ? _selectedElement$inne : 0,
4263
- height: (_selectedElement$inne2 = selectedElement.innerHeight()) != null ? _selectedElement$inne2 : 0
4264
- };
4620
+ this._last = now;
4621
+ this._currentPosition++;
4265
4622
 
4266
- if (dimensions.height === 0) {
4267
- dimensions.height = dimensions.width;
4268
- }
4623
+ if (this._currentPosition > this._currentPlaylistItem.duration) {
4624
+ if (this.loop) {
4625
+ this._reset();
4626
+ } else {
4627
+ this.stop();
4628
+ this.eventbus.broadcast(TimelineEventNames.COMPLETE);
4629
+ return;
4630
+ }
4631
+ }
4269
4632
 
4270
- if (modifier && modifier.length) {
4271
- modifyDimensions(dimensions, modifier);
4272
- }
4633
+ this.eventbus.broadcast(TimelineEventNames.TIME, [{
4634
+ position: this._currentPosition
4635
+ }]);
4636
+ this.eventbus.broadcast(TimelineEventNames.POSITION_UPDATE, [{
4637
+ position: this._currentPosition,
4638
+ duration: this._currentPlaylistItem.duration
4639
+ }]);
4640
+ }
4273
4641
 
4274
- operationData.dimensions = dimensions;
4275
- return operationData;
4276
- };
4642
+ this._requestID = requestAnimationFrame(this._updateBound);
4643
+ };
4277
4644
 
4278
- var getImport = function getImport(operationData) {
4279
- var systemName = operationData.systemName;
4645
+ _proto._start = function _start() {
4646
+ if (this._requestID && this.playState === 'running') {
4647
+ return;
4648
+ }
4280
4649
 
4281
- var callBack = function callBack(instance) {
4282
- operationData.importedInstance = instance;
4650
+ this.playState = 'running';
4651
+ this._requestID = requestAnimationFrame(this._updateBound);
4283
4652
  };
4284
4653
 
4285
- this.eventbus.broadcast(TimelineEventNames.REQUEST_FUNCTION, [systemName, callBack]);
4286
- delete operationData.systemName;
4287
- return operationData;
4288
- };
4654
+ _proto._reset = function _reset() {
4655
+ this._cancelAnimationFrame();
4289
4656
 
4290
- var jsonCache = {};
4291
- var addToCache = function addToCache(key, value) {
4292
- jsonCache[key] = value;
4293
- };
4294
- var loadJSON = function loadJSON(operationData) {
4295
- var url = operationData.url,
4296
- cache = operationData.cache,
4297
- _operationData$proper = operationData.propertyName,
4298
- propertyName = _operationData$proper === void 0 ? 'json' : _operationData$proper;
4657
+ this._last = 0;
4658
+ this._currentPosition = 0;
4659
+ };
4299
4660
 
4300
- if (cache && jsonCache[url]) {
4301
- operationData[propertyName] = jsonCache[url];
4302
- delete operationData.propertyName;
4303
- return operationData;
4304
- }
4661
+ _proto._resize = function _resize() {
4662
+ console.error('Not implemented yet');
4663
+ };
4305
4664
 
4306
- return new Promise(function (resolve, reject) {
4307
- fetch(url).then( /*#__PURE__*/function () {
4308
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(response) {
4309
- var json, cacheValue;
4310
- return runtime_1.wrap(function _callee$(_context) {
4311
- while (1) {
4312
- switch (_context.prev = _context.next) {
4313
- case 0:
4314
- _context.next = 2;
4315
- return response.json();
4316
-
4317
- case 2:
4318
- json = _context.sent;
4319
- cacheValue = operationData[propertyName] = json;
4320
- delete operationData.propertyName;
4321
- addToCache(url, cacheValue);
4322
- resolve(operationData);
4323
-
4324
- case 7:
4325
- case "end":
4326
- return _context.stop();
4327
- }
4328
- }
4329
- }, _callee);
4330
- }));
4331
-
4332
- return function (_x) {
4333
- return _ref.apply(this, arguments);
4334
- };
4335
- }())["catch"](reject);
4336
- });
4337
- };
4338
-
4339
- var log = function log(operationData) {
4340
- console.group('Operation info');
4341
- console.dir({
4342
- context: this
4343
- });
4344
- console.dir({
4345
- operationData: operationData
4346
- });
4347
- console.groupEnd();
4348
- return operationData;
4349
- };
4350
-
4351
- var removeClass = function removeClass(operationData) {
4352
- var selectedElement = operationData.selectedElement,
4353
- className = operationData.className;
4354
- selectedElement.removeClass(className);
4355
- return operationData;
4356
- };
4357
-
4358
- var removeControllerFromElement = function removeControllerFromElement(operationData) {
4359
- var selectedElement = operationData.selectedElement,
4360
- controllerName = operationData.controllerName;
4361
- var controllers = getElementControllers(selectedElement);
4362
- var controller = controllers == null ? void 0 : controllers.find(function (ctrl) {
4363
- return ctrl.name === controllerName;
4364
- });
4365
-
4366
- if (controller) {
4367
- var idx = controllers.indexOf(controller);
4368
- controllers.splice(idx, 1);
4369
- controller.detach(this.eventbus);
4370
- }
4371
-
4372
- return operationData;
4373
- };
4374
-
4375
- var removeElement = function removeElement(operationData) {
4376
- var selectedElement = operationData.selectedElement;
4377
- selectedElement.remove();
4378
- return operationData;
4379
- };
4380
-
4381
- var removePropertiesFromOperationData = function removePropertiesFromOperationData(operationData) {
4382
- var propertyNames = operationData.propertyNames;
4383
- propertyNames.forEach(function (name) {
4384
- delete operationData[name];
4385
- });
4386
- delete operationData.propertyNames;
4387
- return operationData;
4388
- };
4389
-
4390
- var reparentElement = function reparentElement(operationData) {
4391
- var selectedElement = operationData.selectedElement,
4392
- newParentSelector = operationData.newParentSelector;
4393
- selectedElement.remove().appendTo(newParentSelector);
4394
- return operationData;
4395
- };
4396
-
4397
- var requestAction = function requestAction(operationData) {
4398
- var systemName = operationData.systemName;
4399
-
4400
- var resultCallback = function resultCallback(action) {
4401
- operationData.actionInstance = action;
4665
+ _proto._container = function _container(callBack) {
4666
+ callBack(this._containerElement);
4402
4667
  };
4403
4668
 
4404
- this.eventbus.broadcast(TimelineEventNames.REQUEST_ACTION, [systemName, resultCallback]);
4405
- return operationData;
4406
- };
4407
-
4408
- var resizeAction = function resizeAction(operationData) {
4409
- var _operationData = operationData,
4410
- actionInstance = _operationData.actionInstance,
4411
- actionOperationData = _operationData.actionOperationData;
4412
- operationData = mergeOperationData(operationData, actionOperationData);
4413
-
4414
- if (actionInstance.resize) {
4415
- return actionInstance.resize(operationData);
4416
- }
4417
-
4418
- return operationData;
4419
- };
4420
-
4421
- function findElementBySelector(root, selector, operationData, propertyName) {
4422
- var element = root.find(selector);
4423
-
4424
- if (!element.length) {
4425
- console.warn("selector '" + selector + "' wasn't found!");
4426
- }
4427
-
4428
- operationData[propertyName] = element;
4429
-
4430
- if (operationData.hasOwnProperty('propertyName')) {
4431
- delete operationData.propertyName;
4432
- }
4433
- }
4434
-
4435
- var selectElement = function selectElement(operationData) {
4436
- var selector = operationData.selector,
4437
- _operationData$proper = operationData.propertyName,
4438
- propertyName = _operationData$proper === void 0 ? 'selectedElement' : _operationData$proper,
4439
- _operationData$useSel = operationData.useSelectedElementAsRoot,
4440
- useSelectedElementAsRoot = _operationData$useSel === void 0 ? false : _operationData$useSel;
4441
-
4442
- if (!selector) {
4443
- throw new Error('selector is undefined!');
4444
- }
4445
-
4446
- if (useSelectedElementAsRoot && operationData[propertyName]) {
4447
- var currentRoot = operationData[propertyName];
4448
- findElementBySelector(currentRoot, selector, operationData, propertyName);
4449
- return operationData;
4450
- }
4451
-
4452
- var rootCallback = function rootCallback(root) {
4453
- findElementBySelector(root, selector, operationData, propertyName);
4669
+ _proto._cancelAnimationFrame = function _cancelAnimationFrame() {
4670
+ if (this._requestID) {
4671
+ cancelAnimationFrame(this._requestID);
4672
+ this._requestID = -1;
4673
+ this._last = 0;
4674
+ this._currentPosition = 0;
4675
+ }
4454
4676
  };
4455
4677
 
4456
- this.eventbus.broadcast(TimelineEventNames.REQUEST_ENGINE_ROOT, [rootCallback]);
4457
- return operationData;
4458
- };
4459
-
4460
- var setElementAttributes = function setElementAttributes(operationData) {
4461
- var attributes = operationData.attributes,
4462
- selectedElement = operationData.selectedElement;
4463
- Object.keys(attributes).forEach(function (attrName) {
4464
- selectedElement.attr(attrName, attributes[attrName]);
4465
- });
4466
- return operationData;
4467
- };
4678
+ _proto.init = function init() {
4679
+ this._addEventListeners();
4468
4680
 
4469
- var setElementContent = function setElementContent(operationData) {
4470
- var insertionType = operationData.insertionType,
4471
- selectedElement = operationData.selectedElement,
4472
- template = operationData.template;
4681
+ this._currentPlaylistItem = this._playlist[0];
4682
+ this._containerElement = $__default["default"](this._currentPlaylistItem.selector);
4473
4683
 
4474
- switch (true) {
4475
- case insertionType === undefined:
4476
- selectedElement.html(template);
4477
- break;
4684
+ if (!this._containerElement.length) {
4685
+ throw new Error("timeline selector '" + this._currentPlaylistItem.selector + "' not found");
4686
+ }
4478
4687
 
4479
- case insertionType === 'append':
4480
- selectedElement.append(template);
4481
- break;
4688
+ var promise = new Promise(function (resolve) {
4689
+ resolve();
4690
+ });
4691
+ return promise;
4692
+ };
4482
4693
 
4483
- case insertionType === 'prepend':
4484
- selectedElement.prepend(template);
4485
- break;
4486
- }
4694
+ _proto.destroy = function destroy() {
4695
+ this.stop();
4487
4696
 
4488
- delete operationData.insertionType;
4489
- return operationData;
4490
- };
4697
+ this._eventbusListeners.forEach(function (func) {
4698
+ return func();
4699
+ });
4491
4700
 
4492
- var setOperationData = function setOperationData(operationData) {
4493
- var _operationData = operationData,
4494
- override = _operationData.override,
4495
- properties = _operationData.properties;
4496
- var resolvedProperties = resolvePropertyValues(operationData, properties);
4497
- delete operationData.properties;
4701
+ this._containerElement = undefined;
4702
+ };
4498
4703
 
4499
- if (override) {
4500
- operationData = resolvedProperties;
4501
- } else {
4502
- operationData = Object.assign(operationData, resolvedProperties);
4503
- }
4704
+ _proto.toggleplay = function toggleplay() {
4705
+ if (this.playState !== 'running') {
4706
+ this.start();
4707
+ } else {
4708
+ this.pause();
4709
+ }
4710
+ };
4504
4711
 
4505
- return operationData;
4506
- };
4712
+ _proto.start = function start() {
4713
+ this._start();
4507
4714
 
4508
- var setStyle = function setStyle(operationData) {
4509
- var _operationData$proper = operationData.propertyName,
4510
- propertyName = _operationData$proper === void 0 ? 'selectedElement' : _operationData$proper;
4511
- var properties = resolvePropertyValues(operationData, operationData.properties);
4512
- operationData[propertyName].css(properties);
4513
- delete operationData.propertyName;
4514
- return operationData;
4515
- };
4715
+ this.eventbus.broadcast(TimelineEventNames.PLAY);
4716
+ };
4516
4717
 
4517
- var startAction = function startAction(operationData) {
4518
- var _operationData = operationData,
4519
- actionInstance = _operationData.actionInstance,
4520
- actionOperationData = _operationData.actionOperationData;
4521
- delete operationData.actionOperationData;
4522
- return new Promise(function (resolve, reject) {
4523
- operationData = mergeOperationData(operationData, actionOperationData);
4524
- actionInstance.start(operationData).then(function () {
4525
- Object.keys(actionOperationData).forEach(function (key) {
4526
- delete operationData[key];
4527
- });
4528
- internalResolve(resolve, operationData);
4529
- }, reject);
4530
- });
4531
- };
4718
+ _proto.stop = function stop() {
4719
+ this._cancelAnimationFrame();
4532
4720
 
4533
- var startLoop = function startLoop(operationData) {
4534
- var context = this;
4535
- var collection = operationData.collection,
4536
- _operationData$proper = operationData.propertyName,
4537
- propertyName = _operationData$proper === void 0 ? 'currentItem' : _operationData$proper;
4721
+ this.playState = 'stopped';
4722
+ this.eventbus.broadcast(TimelineEventNames.STOP);
4723
+ };
4538
4724
 
4539
- if (typeof collection === 'string') {
4540
- throw new Error('Expected collection to be array type, string value was probably not resolved correctly');
4541
- }
4725
+ _proto.pause = function pause() {
4726
+ this.playState = 'paused';
4727
+ this.eventbus.broadcast(TimelineEventNames.PAUSE);
4728
+ };
4542
4729
 
4543
- if (context.loopIndex === undefined) {
4544
- if (collection != null && collection.length) {
4545
- context.loopIndex = 0;
4546
- context.loopLength = collection.length - 1;
4547
- context.startIndex = context.currentIndex;
4548
- } else {
4549
- context.skipNextOperation = true;
4730
+ _proto.seek = function seek(position) {
4731
+ if (position < 0 || position > this._currentPlaylistItem.duration) {
4732
+ return;
4550
4733
  }
4551
- }
4552
-
4553
- if (collection != null && collection.length && context.loopIndex !== undefined) {
4554
- operationData[propertyName] = collection[context.loopIndex];
4555
- }
4556
4734
 
4557
- delete operationData.propertyName;
4558
- return operationData;
4559
- };
4560
-
4561
- var toggleClass = function toggleClass(operationData) {
4562
- var selectedElement = operationData.selectedElement,
4563
- className = operationData.className;
4564
- selectedElement.toggleClass(className);
4565
- return operationData;
4566
- };
4735
+ this.eventbus.broadcast(TimelineEventNames.SEEK, [position, this._currentPosition, this.getDuration()]);
4736
+ this._currentPosition = position;
4737
+ this.eventbus.broadcast(TimelineEventNames.SEEKED, [this._currentPosition, this.getDuration()]);
4738
+ this.eventbus.broadcast(TimelineEventNames.TIME, [{
4739
+ position: this.getPosition()
4740
+ }]);
4741
+ this.eventbus.broadcast(TimelineEventNames.POSITION_UPDATE, [{
4742
+ position: this._currentPosition,
4743
+ duration: this._currentPlaylistItem.duration
4744
+ }]);
4745
+ };
4567
4746
 
4568
- var toggleElement = function toggleElement(operationData) {
4569
- operationData.selectedElement.toggle();
4570
- return operationData;
4571
- };
4747
+ _proto.getPosition = function getPosition() {
4748
+ return this._currentPosition;
4749
+ };
4572
4750
 
4573
- var wait = function wait(operationData) {
4574
- var milliseconds = operationData.milliseconds;
4575
- return new Promise(function (resolve) {
4576
- setTimeout(function () {
4577
- internalResolve(resolve, operationData);
4578
- }, milliseconds);
4579
- });
4580
- };
4751
+ _proto.getDuration = function getDuration() {
4752
+ return this._currentPlaylistItem.duration;
4753
+ };
4581
4754
 
4755
+ _proto.requestDurationHandler = function requestDurationHandler(callBack) {
4756
+ callBack(this._currentPlaylistItem.duration);
4757
+ };
4582
4758
 
4759
+ return RequestAnimationFrameTimelineProvider;
4760
+ }();
4583
4761
 
4584
- var ops = {
4762
+ var prvdrs = {
4585
4763
  __proto__: null,
4586
- addClass: addClass,
4587
- addControllerToElement: addControllerToElement,
4588
- animate: animate,
4589
- animateWithClass: animateWithClass,
4590
- broadcastEvent: broadcastEvent,
4591
- clearElement: clearElement,
4592
- clearOperationData: clearOperationData,
4593
- createElement: createElement,
4594
- customFunction: customFunction,
4595
- endAction: endAction,
4596
- endLoop: endLoop,
4597
- extendController: extendController,
4598
- getControllerFromElement: getControllerFromElement,
4599
- getControllerInstance: getControllerInstance,
4600
- getElementDimensions: getElementDimensions,
4601
- getImport: getImport,
4602
- loadJSON: loadJSON,
4603
- log: log,
4604
- removeClass: removeClass,
4605
- removeControllerFromElement: removeControllerFromElement,
4606
- removeElement: removeElement,
4607
- removePropertiesFromOperationData: removePropertiesFromOperationData,
4608
- reparentElement: reparentElement,
4609
- requestAction: requestAction,
4610
- resizeAction: resizeAction,
4611
- selectElement: selectElement,
4612
- setElementAttributes: setElementAttributes,
4613
- setElementContent: setElementContent,
4614
- setOperationData: setOperationData,
4615
- setStyle: setStyle,
4616
- startAction: startAction,
4617
- startLoop: startLoop,
4618
- toggleClass: toggleClass,
4619
- toggleElement: toggleElement,
4620
- wait: wait
4764
+ JwPlayerTimelineProvider: JwPlayerTimelineProvider,
4765
+ RequestAnimationFrameTimelineProvider: RequestAnimationFrameTimelineProvider
4621
4766
  };
4622
4767
 
4623
4768
  var operations = ops;
@@ -4666,7 +4811,6 @@ exports.JwPlayerTimelineProvider = JwPlayerTimelineProvider;
4666
4811
  exports.LabelController = LabelController;
4667
4812
  exports.LanguageManager = LanguageManager;
4668
4813
  exports.LottieController = LottieController;
4669
- exports.MediaElementTimelineProvider = MediaElementTimelineProvider;
4670
4814
  exports.NavigationController = NavigationController;
4671
4815
  exports.ProgressbarController = ProgressbarController;
4672
4816
  exports.RequestAnimationFrameTimelineProvider = RequestAnimationFrameTimelineProvider;