eligius 1.0.12 → 1.0.14

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 (32) hide show
  1. package/dist/action/action.d.ts +2 -2
  2. package/dist/action/timeline-action.d.ts +2 -2
  3. package/dist/action/types.d.ts +2 -2
  4. package/dist/eligius-engine.d.ts +9 -1
  5. package/dist/eligius.cjs.development.js +358 -212
  6. package/dist/eligius.cjs.development.js.map +1 -1
  7. package/dist/eligius.cjs.production.min.js +1 -1
  8. package/dist/eligius.cjs.production.min.js.map +1 -1
  9. package/dist/eligius.esm.js +358 -212
  10. package/dist/eligius.esm.js.map +1 -1
  11. package/dist/operation/end-action.d.ts +4 -0
  12. package/dist/operation/get-controller-instance.d.ts +2 -2
  13. package/dist/operation/helper/get-property-chain-value.d.ts +24 -0
  14. package/dist/operation/helper/resolve-operation-or-global-data-property-chain.d.ts +13 -0
  15. package/dist/operation/helper/resolve-property-chain.d.ts +23 -0
  16. package/dist/operation/helper/resolve-property-values.d.ts +1 -1
  17. package/dist/operation/log.d.ts +2 -2
  18. package/dist/operation/math.d.ts +1 -1
  19. package/dist/operation/set-style.d.ts +2 -3
  20. package/dist/operation/types.d.ts +1 -1
  21. package/dist/timelineproviders/jwplayer-timeline-provider.d.ts +2 -2
  22. package/dist/timelineproviders/request-animation-frame-timeline-provider.d.ts +2 -1
  23. package/dist/timelineproviders/types.d.ts +1 -1
  24. package/dist/util/guards/is-function.d.ts +1 -0
  25. package/dist/util/guards/is-object.d.ts +1 -0
  26. package/dist/util/guards/is-promise.d.ts +1 -0
  27. package/dist/util/guards/is-string.d.ts +1 -0
  28. package/package.json +5 -5
  29. package/dist/action/is-promise.d.ts +0 -1
  30. package/dist/operation/helper/extract-operation-data-argument-values.d.ts +0 -1
  31. package/dist/operation/helper/get-nested-property-value.d.ts +0 -1
  32. package/dist/operation/helper/get-nested-value.d.ts +0 -1
@@ -419,12 +419,20 @@ function _setPrototypeOf(o, p) {
419
419
  return _setPrototypeOf(o, p);
420
420
  }
421
421
 
422
+ function isFunction(value) {
423
+ return typeof value === 'function';
424
+ }
425
+
426
+ function isObject(value) {
427
+ return value !== null && typeof value === 'object';
428
+ }
429
+
422
430
  function prepareValueForSerialization(value) {
423
431
  if (Array.isArray(value)) {
424
432
  return value.map(prepareValueForSerialization);
425
433
  } else if (value instanceof $) {
426
434
  return 'jQuery object';
427
- } else if (value !== null && typeof value === 'object') {
435
+ } else if (isObject(value)) {
428
436
  if (value.constructor.toString().substring(0, 5) === 'class' || !value.constructor.toString().startsWith('function Object()')) {
429
437
  var funcString = value.constructor.toString();
430
438
  return funcString.substring(0, funcString.indexOf('{') + 1);
@@ -435,7 +443,7 @@ function prepareValueForSerialization(value) {
435
443
  propValue = _ref[1];
436
444
  return [propName, prepareValueForSerialization(propValue)];
437
445
  }));
438
- } else if (typeof value === 'function') {
446
+ } else if (isFunction(value)) {
439
447
  var _funcString = value.toString();
440
448
 
441
449
  var paranIndex = _funcString.indexOf('{');
@@ -583,7 +591,7 @@ var Action = /*#__PURE__*/function () {
583
591
 
584
592
  if (isPromise(operationResult)) {
585
593
  operationResult.then(function (promisedOperationResult) {
586
- _this2.executeOperation(operations, ++idx, resolve, reject, promisedOperationResult, context);
594
+ return _this2.executeOperation(operations, ++idx, resolve, reject, promisedOperationResult, context);
587
595
  })["catch"](function (error) {
588
596
  reject(error);
589
597
  });
@@ -664,9 +672,7 @@ var TimelineAction = /*#__PURE__*/function (_EndableAction) {
664
672
  return _EndableAction.prototype.start.call(this, initOperationData);
665
673
  }
666
674
 
667
- return new Promise(function (resolve) {
668
- resolve();
669
- });
675
+ return Promise.resolve(undefined);
670
676
  };
671
677
 
672
678
  _proto.end = function end(initOperationData) {
@@ -846,7 +852,11 @@ function _gatherControllerImportPaths(operationConfigs) {
846
852
 
847
853
  return false;
848
854
  }).map(function (operationConfig) {
849
- var systemName = operationConfig.operationData.systemName;
855
+ var _operationConfig$oper2;
856
+
857
+ var _ref = (_operationConfig$oper2 = operationConfig.operationData) != null ? _operationConfig$oper2 : {},
858
+ systemName = _ref.systemName;
859
+
850
860
  return {
851
861
  systemName: systemName
852
862
  };
@@ -878,19 +888,34 @@ function dedupe(importPaths) {
878
888
  });
879
889
  }
880
890
 
881
- function getNestedValue(properties, sourceObject) {
882
- if (!properties) {
883
- throw Error('properties arg cannot be null');
884
- }
885
-
886
- if (!sourceObject) {
887
- throw Error('sourceObject arg cannot be null');
888
- }
889
-
891
+ /**
892
+ /**
893
+ * Gets the value for the given property chain. A property chain is defined by a string array.
894
+ *
895
+ * For example, this property chain: `[mySource, subSource, element, value]` should be extracted from an object of this shape:
896
+ * ```ts
897
+ * const foo = {
898
+ * mySource: {
899
+ * subSource: {
900
+ * element: {
901
+ * value: 'bar'
902
+ * }
903
+ * }
904
+ * }
905
+ * }
906
+ * ```
907
+ *
908
+ * The result of the invocation `getPropertyChainValue([mySource, subSource, element, value], foo)` would then yield the value `bar`.
909
+ *
910
+ * @param propertyChain
911
+ * @param sourceObject
912
+ * @returns
913
+ */
914
+ function getPropertyChainValue(propertyChain, sourceObject) {
890
915
  var currentInstance = sourceObject;
891
916
  var suffix = null;
892
- properties.forEach(function (prop, index) {
893
- if (index === properties.length - 1) {
917
+ propertyChain.forEach(function (prop, index) {
918
+ if (index === propertyChain.length - 1) {
894
919
  var parts = prop.split('+');
895
920
 
896
921
  if (parts.length > 1) {
@@ -901,12 +926,39 @@ function getNestedValue(properties, sourceObject) {
901
926
 
902
927
  currentInstance = currentInstance[prop];
903
928
  });
904
- return suffix ? currentInstance + suffix : currentInstance;
929
+ return suffix ? "" + currentInstance + suffix : currentInstance;
905
930
  }
906
931
 
907
- function getNestedPropertyValue(propertyChain, sourceObject) {
932
+ /**
933
+ * Gets the value for the given property chain. A property chain is defined by a period delimited string.
934
+ *
935
+ * For example, this property chain: `mySource.subSource.element.value` should be extracted from an object of this shape:
936
+ * ```ts
937
+ * const foo = {
938
+ * mySource: {
939
+ * subSource: {
940
+ * element: {
941
+ * value: 'bar'
942
+ * }
943
+ * }
944
+ * }
945
+ * }
946
+ * ```
947
+ *
948
+ * The result of the invocation `resolvePropertyChain('mySource.subSource.element.value', foo)` would then yield the value `bar`.
949
+ *
950
+ * @param propertyChain the specified property chain
951
+ * @param sourceObject the given source object
952
+ * @returns
953
+ */
954
+
955
+ function resolvePropertyChain(propertyChain, sourceObject) {
908
956
  var properties = propertyChain.split('.');
909
- return getNestedValue(properties, sourceObject);
957
+ return getPropertyChainValue(properties, sourceObject);
958
+ }
959
+
960
+ function isString(value) {
961
+ return typeof value === 'string';
910
962
  }
911
963
 
912
964
  var ConfigurationResolver = /*#__PURE__*/function () {
@@ -981,10 +1033,12 @@ function resolveTimelines(timelines, importer, eventbus) {
981
1033
  }
982
1034
 
983
1035
  function resolveOperation(importer, operationConfig) {
1036
+ var _deepCopy;
1037
+
984
1038
  return {
985
1039
  id: operationConfig.id,
986
1040
  systemName: operationConfig.systemName,
987
- operationData: deepCopy(operationConfig.operationData),
1041
+ operationData: (_deepCopy = deepCopy(operationConfig.operationData)) != null ? _deepCopy : {},
988
1042
  instance: importer["import"](operationConfig.systemName)[operationConfig.systemName]
989
1043
  };
990
1044
  }
@@ -1056,10 +1110,10 @@ function resolvePlaceholders(configFragment, rootConfig, importer) {
1056
1110
  function resolvePlaceholder(key, configFragment, rootConfig, importer) {
1057
1111
  var configValue = configFragment[key];
1058
1112
 
1059
- if (typeof configValue === 'string') {
1113
+ if (isString(configValue)) {
1060
1114
  if (configValue.startsWith('config:')) {
1061
1115
  var configProperty = configValue.substring(7, configValue.length);
1062
- configFragment[key] = getNestedPropertyValue(configProperty, rootConfig);
1116
+ configFragment[key] = resolvePropertyChain(configProperty, rootConfig);
1063
1117
  } else if (configValue.startsWith('template:')) {
1064
1118
  var templateKey = configValue.substring(9, configValue.length);
1065
1119
  var template = importer["import"](templateKey)[templateKey];
@@ -1069,7 +1123,7 @@ function resolvePlaceholder(key, configFragment, rootConfig, importer) {
1069
1123
  var json = importer["import"](jsonKey)[jsonKey];
1070
1124
  configFragment[key] = json;
1071
1125
  }
1072
- } else if (typeof configValue === 'object') {
1126
+ } else if (isObject(configValue)) {
1073
1127
  resolvePlaceholders(configValue, rootConfig, importer);
1074
1128
  }
1075
1129
  }
@@ -2135,63 +2189,69 @@ var EligiusEngine = /*#__PURE__*/function () {
2135
2189
  }
2136
2190
  };
2137
2191
 
2138
- _proto._initializeTimelineProvider = function _initializeTimelineProvider() {
2139
- var _this$configuration$t,
2140
- _this$_activeTimeline,
2141
- _this = this;
2192
+ _proto._initializeTimelineProvider = /*#__PURE__*/function () {
2193
+ var _initializeTimelineProvider2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
2194
+ var _this$configuration$t, _this$_activeTimeline;
2142
2195
 
2143
- if (!((_this$configuration$t = this.configuration.timelines) != null && _this$configuration$t.length)) {
2144
- throw new Error('No timelines present');
2145
- }
2196
+ var firstTimeline, providerSettings;
2197
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
2198
+ while (1) {
2199
+ switch (_context.prev = _context.next) {
2200
+ case 0:
2201
+ if ((_this$configuration$t = this.configuration.timelines) != null && _this$configuration$t.length) {
2202
+ _context.next = 2;
2203
+ break;
2204
+ }
2146
2205
 
2147
- var firstTimeline = this.configuration.timelines[0];
2148
- var providerSettings = this.timelineProviders[firstTimeline.type];
2206
+ throw new Error('No timelines present');
2149
2207
 
2150
- if (!providerSettings) {
2151
- throw new Error("No timeline provider configured for type " + firstTimeline.type);
2152
- }
2208
+ case 2:
2209
+ firstTimeline = this.configuration.timelines[0];
2210
+ providerSettings = this.timelineProviders[firstTimeline.type];
2153
2211
 
2154
- (_this$_activeTimeline = this._activeTimelineProvider) == null ? void 0 : _this$_activeTimeline.destroy();
2155
- this._activeTimelineProvider = providerSettings.provider;
2156
- return new Promise( /*#__PURE__*/function () {
2157
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
2158
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2159
- while (1) {
2160
- switch (_context.prev = _context.next) {
2161
- case 0:
2162
- if (!_this._activeTimelineProvider) {
2163
- _context.next = 8;
2164
- break;
2165
- }
2212
+ if (providerSettings) {
2213
+ _context.next = 6;
2214
+ break;
2215
+ }
2166
2216
 
2167
- _context.next = 3;
2168
- return _this._activeTimelineProvider.init();
2217
+ throw new Error("No timeline provider configured for type " + firstTimeline.type);
2169
2218
 
2170
- case 3:
2171
- _context.next = 5;
2172
- return _this._executeActions(_this.configuration.initActions, 'start');
2219
+ case 6:
2220
+ (_this$_activeTimeline = this._activeTimelineProvider) == null ? void 0 : _this$_activeTimeline.destroy();
2221
+ this._activeTimelineProvider = providerSettings.provider;
2173
2222
 
2174
- case 5:
2175
- resolve(_this._activeTimelineProvider);
2176
- _context.next = 9;
2223
+ if (this._activeTimelineProvider) {
2224
+ _context.next = 10;
2177
2225
  break;
2226
+ }
2178
2227
 
2179
- case 8:
2180
- throw new Error('NO ACTIVE TIMELINE PROVIDER');
2228
+ throw new Error('NO ACTIVE TIMELINE PROVIDER');
2181
2229
 
2182
- case 9:
2183
- case "end":
2184
- return _context.stop();
2185
- }
2230
+ case 10:
2231
+ _context.next = 12;
2232
+ return this._activeTimelineProvider.init();
2233
+
2234
+ case 12:
2235
+ _context.next = 14;
2236
+ return this._executeActions(this.configuration.initActions, 'start');
2237
+
2238
+ case 14:
2239
+ return _context.abrupt("return", this._activeTimelineProvider);
2240
+
2241
+ case 15:
2242
+ case "end":
2243
+ return _context.stop();
2186
2244
  }
2187
- }, _callee);
2188
- }));
2245
+ }
2246
+ }, _callee, this);
2247
+ }));
2189
2248
 
2190
- return function (_x) {
2191
- return _ref.apply(this, arguments);
2192
- };
2193
- }());
2194
- };
2249
+ function _initializeTimelineProvider() {
2250
+ return _initializeTimelineProvider2.apply(this, arguments);
2251
+ }
2252
+
2253
+ return _initializeTimelineProvider;
2254
+ }();
2195
2255
 
2196
2256
  _proto._cleanUp = /*#__PURE__*/function () {
2197
2257
  var _cleanUp2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
@@ -2204,7 +2264,7 @@ var EligiusEngine = /*#__PURE__*/function () {
2204
2264
 
2205
2265
  case 2:
2206
2266
  _context2.next = 4;
2207
- return this._executeActions(this.configuration.initActions, 'end');
2267
+ return this._executeActions([].concat(this.configuration.initActions).reverse(), 'end');
2208
2268
 
2209
2269
  case 4:
2210
2270
  case "end":
@@ -2300,18 +2360,25 @@ var EligiusEngine = /*#__PURE__*/function () {
2300
2360
  };
2301
2361
 
2302
2362
  _proto._createTimelineLookup = function _createTimelineLookup() {
2303
- var _this2 = this;
2363
+ var _this = this;
2304
2364
 
2305
2365
  if (!this.configuration.timelines) {
2306
2366
  return;
2307
2367
  }
2308
2368
 
2309
2369
  this.configuration.timelines.forEach(function (timelineInfo) {
2310
- timelineInfo.timelineActions.forEach(_this2._addTimelineAction.bind(_this2, timelineInfo.uri));
2370
+ timelineInfo.timelineActions.forEach(_this._addTimelineActionStart.bind(_this, timelineInfo.uri));
2371
+ });
2372
+ this.configuration.timelines.forEach(function (timelineInfo) {
2373
+ // actions ends need to be in reversed order, otherwise, for example,
2374
+ // elements that were created before dependent actions will already have been
2375
+ // removed in the end phase.
2376
+ var reversed = [].concat(timelineInfo.timelineActions).reverse();
2377
+ reversed.forEach(_this._addTimelineActionEnd.bind(_this, timelineInfo.uri));
2311
2378
  });
2312
2379
  };
2313
2380
 
2314
- _proto._addTimelineAction = function _addTimelineAction(uri, timeLineAction) {
2381
+ _proto._addTimelineActionStart = function _addTimelineActionStart(uri, timeLineAction) {
2315
2382
  var _timeLineAction$id;
2316
2383
 
2317
2384
  var startPosition = timeLineAction.duration.start;
@@ -2326,6 +2393,9 @@ var EligiusEngine = /*#__PURE__*/function () {
2326
2393
  }
2327
2394
 
2328
2395
  timelineStartPositions.push(startMethod);
2396
+ };
2397
+
2398
+ _proto._addTimelineActionEnd = function _addTimelineActionEnd(uri, timeLineAction) {
2329
2399
  var end = timeLineAction.duration.end;
2330
2400
 
2331
2401
  if (end < 0) {
@@ -2385,9 +2455,7 @@ var EligiusEngine = /*#__PURE__*/function () {
2385
2455
  return _context4.abrupt("return", this._executeActions(actions, methodName, ++idx));
2386
2456
 
2387
2457
  case 6:
2388
- return _context4.abrupt("return", new Promise(function (resolve) {
2389
- resolve();
2390
- }));
2458
+ return _context4.abrupt("return", Promise.resolve());
2391
2459
 
2392
2460
  case 7:
2393
2461
  case "end":
@@ -2397,7 +2465,7 @@ var EligiusEngine = /*#__PURE__*/function () {
2397
2465
  }, _callee4, this);
2398
2466
  }));
2399
2467
 
2400
- function _executeActions(_x2, _x3, _x4) {
2468
+ function _executeActions(_x, _x2, _x3) {
2401
2469
  return _executeActions2.apply(this, arguments);
2402
2470
  }
2403
2471
 
@@ -2409,27 +2477,29 @@ var EligiusEngine = /*#__PURE__*/function () {
2409
2477
  };
2410
2478
 
2411
2479
  _proto._handleRequestTimelineUri = /*#__PURE__*/function () {
2412
- var _handleRequestTimelineUri2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(uri, position, previousVideoPosition) {
2413
- var _position,
2414
- _this3 = this;
2480
+ var _handleRequestTimelineUri2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(uri, position) {
2481
+ var _this2 = this;
2415
2482
 
2416
2483
  var timelineConfig, newProviderSettings;
2417
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
2484
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
2418
2485
  while (1) {
2419
- switch (_context5.prev = _context5.next) {
2486
+ switch (_context6.prev = _context6.next) {
2420
2487
  case 0:
2488
+ if (position === void 0) {
2489
+ position = 0;
2490
+ }
2491
+
2421
2492
  if (this._activeTimelineProvider) {
2422
- _context5.next = 2;
2493
+ _context6.next = 3;
2423
2494
  break;
2424
2495
  }
2425
2496
 
2426
- return _context5.abrupt("return");
2427
-
2428
- case 2:
2497
+ return _context6.abrupt("return");
2429
2498
 
2499
+ case 3:
2430
2500
  this._activeTimelineProvider.stop();
2431
2501
 
2432
- _context5.next = 6;
2502
+ _context6.next = 6;
2433
2503
  return this._cleanUpTimeline();
2434
2504
 
2435
2505
  case 6:
@@ -2438,11 +2508,11 @@ var EligiusEngine = /*#__PURE__*/function () {
2438
2508
  });
2439
2509
 
2440
2510
  if (!(!timelineConfig || !this._activeTimelineProvider || this._currentTimelineUri === timelineConfig.uri)) {
2441
- _context5.next = 9;
2511
+ _context6.next = 9;
2442
2512
  break;
2443
2513
  }
2444
2514
 
2445
- return _context5.abrupt("return");
2515
+ return _context6.abrupt("return");
2446
2516
 
2447
2517
  case 9:
2448
2518
  this._currentTimelineUri = timelineConfig.uri;
@@ -2456,42 +2526,55 @@ var EligiusEngine = /*#__PURE__*/function () {
2456
2526
  }
2457
2527
 
2458
2528
  this._activeTimelineProvider.loop = timelineConfig.loop;
2459
- position = (_position = position) != null ? _position : 0;
2460
2529
 
2461
2530
  if (!this._activeTimelineProvider.loop && position > 0) {
2462
- this.eventbus.once(TimelineEventNames.FIRST_FRAME, function () {
2463
- if (!_this3._activeTimelineProvider) {
2464
- return;
2465
- }
2466
-
2467
- _this3._activeTimelineProvider.pause();
2468
-
2469
- _this3.eventbus.broadcast(TimelineEventNames.DURATION, [_this3._activeTimelineProvider.getDuration()]);
2470
-
2471
- _this3._executeStartActions().then(function () {
2472
- var _position2, _this3$_activeTimelin;
2473
-
2474
- position = (_position2 = position) != null ? _position2 : 0;
2475
- (_this3$_activeTimelin = _this3._activeTimelineProvider) == null ? void 0 : _this3$_activeTimelin.seek(position);
2476
-
2477
- _this3._onSeekHandler(Math.floor, {
2478
- offset: position
2479
- });
2480
- });
2481
- });
2531
+ this.eventbus.once(TimelineEventNames.FIRST_FRAME, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
2532
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
2533
+ while (1) {
2534
+ switch (_context5.prev = _context5.next) {
2535
+ case 0:
2536
+ if (_this2._activeTimelineProvider) {
2537
+ _context5.next = 2;
2538
+ break;
2539
+ }
2540
+
2541
+ return _context5.abrupt("return");
2542
+
2543
+ case 2:
2544
+ _this2._activeTimelineProvider.pause();
2545
+
2546
+ _this2.eventbus.broadcast(TimelineEventNames.DURATION, [_this2._activeTimelineProvider.getDuration()]);
2547
+
2548
+ _context5.next = 6;
2549
+ return _this2._executeStartActions();
2550
+
2551
+ case 6:
2552
+ _this2._activeTimelineProvider.seek(position);
2553
+
2554
+ _this2._onSeekHandler(Math.floor, {
2555
+ offset: position
2556
+ });
2557
+
2558
+ case 8:
2559
+ case "end":
2560
+ return _context5.stop();
2561
+ }
2562
+ }
2563
+ }, _callee5);
2564
+ })));
2482
2565
  }
2483
2566
 
2484
2567
  this._activeTimelineProvider.playlistItem(uri);
2485
2568
 
2486
- case 17:
2569
+ case 16:
2487
2570
  case "end":
2488
- return _context5.stop();
2571
+ return _context6.stop();
2489
2572
  }
2490
2573
  }
2491
- }, _callee5, this);
2574
+ }, _callee6, this);
2492
2575
  }));
2493
2576
 
2494
- function _handleRequestTimelineUri(_x5, _x6, _x7) {
2577
+ function _handleRequestTimelineUri(_x4, _x5) {
2495
2578
  return _handleRequestTimelineUri2.apply(this, arguments);
2496
2579
  }
2497
2580
 
@@ -2504,10 +2587,18 @@ var EligiusEngine = /*#__PURE__*/function () {
2504
2587
 
2505
2588
  _proto._executeStartActions = function _executeStartActions() {
2506
2589
  return this._executeRelevantActions(this._getActionsForPosition.bind(this, 0), 'start');
2507
- };
2590
+ }
2591
+ /**
2592
+ * Gets all of the inactive actions whose duration falls within the given timeline position.
2593
+ *
2594
+ * @param position the given position
2595
+ * @param actions all of the relevant actions
2596
+ * @returns
2597
+ */
2598
+ ;
2508
2599
 
2509
- _proto._getActionsForPosition = function _getActionsForPosition(position, allActions) {
2510
- return allActions.filter(function (action) {
2600
+ _proto._getActionsForPosition = function _getActionsForPosition(position, actions) {
2601
+ return actions.filter(function (action) {
2511
2602
  return !action.active && action.duration.start <= position && action.duration.end >= position;
2512
2603
  });
2513
2604
  };
@@ -2516,15 +2607,7 @@ var EligiusEngine = /*#__PURE__*/function () {
2516
2607
  var actions = allActions.filter(function (action) {
2517
2608
  return action.active;
2518
2609
  });
2519
- return actions.sort(function (a, b) {
2520
- if (b.duration.start < a.duration.start) {
2521
- return -1;
2522
- } else if (b.duration.start > a.duration.start) {
2523
- return 1;
2524
- } else {
2525
- return 0;
2526
- }
2527
- });
2610
+ return actions.sort(sortActions);
2528
2611
  };
2529
2612
 
2530
2613
  _proto._executeRelevantActions = function _executeRelevantActions(filter, executionType) {
@@ -2599,21 +2682,44 @@ var EligiusEngine = /*#__PURE__*/function () {
2599
2682
  }
2600
2683
  };
2601
2684
 
2602
- _proto._onSeekHandler = function _onSeekHandler(floor, event) {
2603
- var _this4 = this;
2685
+ _proto._onSeekHandler = /*#__PURE__*/function () {
2686
+ var _onSeekHandler2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(floor, event) {
2687
+ var _this$_activeTimeline5;
2604
2688
 
2605
- if (isNaN(event.offset)) {
2606
- return;
2607
- }
2689
+ var pos;
2690
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
2691
+ while (1) {
2692
+ switch (_context7.prev = _context7.next) {
2693
+ case 0:
2694
+ if (!isNaN(event.offset)) {
2695
+ _context7.next = 2;
2696
+ break;
2697
+ }
2608
2698
 
2609
- var pos = floor(event.offset);
2699
+ return _context7.abrupt("return");
2610
2700
 
2611
- this._executeSeekActions(pos).then(function () {
2612
- var _this4$_activeTimelin;
2701
+ case 2:
2702
+ pos = floor(event.offset);
2703
+ _context7.next = 5;
2704
+ return this._executeSeekActions(pos);
2613
2705
 
2614
- (_this4$_activeTimelin = _this4._activeTimelineProvider) == null ? void 0 : _this4$_activeTimelin.start();
2615
- });
2616
- };
2706
+ case 5:
2707
+ (_this$_activeTimeline5 = this._activeTimelineProvider) == null ? void 0 : _this$_activeTimeline5.start();
2708
+
2709
+ case 6:
2710
+ case "end":
2711
+ return _context7.stop();
2712
+ }
2713
+ }
2714
+ }, _callee7, this);
2715
+ }));
2716
+
2717
+ function _onSeekHandler(_x6, _x7) {
2718
+ return _onSeekHandler2.apply(this, arguments);
2719
+ }
2720
+
2721
+ return _onSeekHandler;
2722
+ }();
2617
2723
 
2618
2724
  _proto._executeActionsForPosition = function _executeActionsForPosition(position) {
2619
2725
  this._lastPosition = position;
@@ -2627,33 +2733,60 @@ var EligiusEngine = /*#__PURE__*/function () {
2627
2733
  }
2628
2734
  };
2629
2735
 
2630
- _proto._executeSeekActions = function _executeSeekActions(pos) {
2631
- var _this5 = this;
2736
+ _proto._executeSeekActions = /*#__PURE__*/function () {
2737
+ var _executeSeekActions2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(pos) {
2738
+ var timelineActions, currentActions, newActions, currentActionsEnd;
2739
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
2740
+ while (1) {
2741
+ switch (_context8.prev = _context8.next) {
2742
+ case 0:
2743
+ timelineActions = this._getRelevantTimelineActions();
2744
+
2745
+ if (timelineActions) {
2746
+ _context8.next = 3;
2747
+ break;
2748
+ }
2632
2749
 
2633
- var timelineActions = this._getRelevantTimelineActions();
2750
+ return _context8.abrupt("return", Promise.resolve());
2634
2751
 
2635
- if (!timelineActions) {
2636
- return Promise.resolve();
2637
- }
2752
+ case 3:
2753
+ currentActions = this._getActiveActions(timelineActions).reverse();
2754
+ newActions = this._getActionsForPosition(pos, timelineActions);
2755
+ currentActionsEnd = this._executeActions(currentActions, 'end', 0);
2756
+ _context8.next = 8;
2757
+ return currentActionsEnd;
2638
2758
 
2639
- var currentActions = this._getActiveActions(timelineActions);
2759
+ case 8:
2760
+ return _context8.abrupt("return", this._executeActions(newActions, 'start', 0));
2640
2761
 
2641
- var newActions = this._getActionsForPosition(pos, timelineActions);
2762
+ case 9:
2763
+ case "end":
2764
+ return _context8.stop();
2765
+ }
2766
+ }
2767
+ }, _callee8, this);
2768
+ }));
2642
2769
 
2643
- var promise = this._executeActions(currentActions, 'end', 0);
2770
+ function _executeSeekActions(_x8) {
2771
+ return _executeSeekActions2.apply(this, arguments);
2772
+ }
2644
2773
 
2645
- return new Promise(function (resolve) {
2646
- promise.then(function () {
2647
- _this5._executeActions(newActions, 'start', 0).then(function () {
2648
- resolve();
2649
- });
2650
- });
2651
- });
2652
- };
2774
+ return _executeSeekActions;
2775
+ }();
2653
2776
 
2654
2777
  return EligiusEngine;
2655
2778
  }();
2656
2779
 
2780
+ var sortActions = function sortActions(a, b) {
2781
+ if (b.duration.start < a.duration.start) {
2782
+ return -1;
2783
+ } else if (b.duration.start > a.duration.start) {
2784
+ return 1;
2785
+ } else {
2786
+ return 0;
2787
+ }
2788
+ };
2789
+
2657
2790
  var ActionRegistryEventbusListener = /*#__PURE__*/function () {
2658
2791
  function ActionRegistryEventbusListener() {
2659
2792
  this._actionRegistry = new Map();
@@ -3323,28 +3456,41 @@ function _setGlobals(cache, newValues) {
3323
3456
  value = _ref[1];
3324
3457
  return cache[name] = value;
3325
3458
  });
3326
- console.log('cache', cache);
3327
3459
  }
3328
3460
 
3329
3461
  var getGlobals = /*#__PURE__*/_getGlobals.bind(null, cache$1);
3330
3462
  var setGlobals = /*#__PURE__*/_setGlobals.bind(null, cache$1);
3331
3463
 
3332
- function extractOperationDataArgumentValues(sourceObject, argumentValue) {
3333
- if (typeof argumentValue === 'string' && argumentValue.toLowerCase().startsWith('operationdata.')) {
3334
- var propNames = argumentValue.split('.');
3335
- propNames.shift();
3336
- return getNestedValue(propNames, sourceObject);
3337
- }
3464
+ /**
3465
+ * Resolves operation and global data property chains.
3466
+ *
3467
+ * An operation data property chain is designated by a `operationdata.` suffix, followed by an arbitrary property chain.
3468
+ * For global data the suffix should be `globaldata.`
3469
+ *
3470
+ * If the propertyChainOrRegularObject is not a property chain, this value is returned instead.
3471
+ *
3472
+ * @param sourceObject The object that represents the operation data
3473
+ * @param propertyChainOrRegularObject A period delimited string, or just a regular object
3474
+ * @returns
3475
+ */
3338
3476
 
3339
- if (typeof argumentValue === 'string' && argumentValue.toLowerCase().startsWith('globaldata.')) {
3340
- var _propNames = argumentValue.split('.');
3477
+ function resolveOperationOrGlobalDataPropertyChain(sourceObject, propertyChainOrRegularObject) {
3478
+ if (isString(propertyChainOrRegularObject)) {
3479
+ var _propNames$shift;
3341
3480
 
3342
- _propNames.shift();
3481
+ var propNames = propertyChainOrRegularObject.split('.');
3482
+ var prefix = (_propNames$shift = propNames.shift()) == null ? void 0 : _propNames$shift.toLowerCase();
3343
3483
 
3344
- return getNestedValue(_propNames, getGlobals());
3484
+ if (prefix == 'operationdata') {
3485
+ return getPropertyChainValue(propNames, sourceObject);
3486
+ }
3487
+
3488
+ if (prefix == 'globaldata') {
3489
+ return getPropertyChainValue(propNames, getGlobals());
3490
+ }
3345
3491
  }
3346
3492
 
3347
- return argumentValue;
3493
+ return propertyChainOrRegularObject;
3348
3494
  }
3349
3495
 
3350
3496
  function resolveEventArguments(operationData, eventArgs) {
@@ -3352,7 +3498,7 @@ function resolveEventArguments(operationData, eventArgs) {
3352
3498
  return;
3353
3499
  }
3354
3500
 
3355
- var extract = extractOperationDataArgumentValues.bind(null, operationData);
3501
+ var extract = resolveOperationOrGlobalDataPropertyChain.bind(null, operationData);
3356
3502
  return eventArgs.map(extract);
3357
3503
  }
3358
3504
 
@@ -3382,12 +3528,13 @@ var broadcastEvent$1 = function broadcastEvent(operationData) {
3382
3528
  var cache = [];
3383
3529
  function resolvePropertyValues(operationData, properties) {
3384
3530
  var copy = properties !== operationData ? deepCopy(properties) : properties;
3385
- var extract = extractOperationDataArgumentValues.bind(null, operationData);
3386
- resolveProperties(properties, copy, extract);
3531
+ var resolvePropertyChain = resolveOperationOrGlobalDataPropertyChain.bind(null, operationData);
3532
+ resolveProperties(properties, copy, resolvePropertyChain);
3387
3533
  return copy;
3388
3534
  }
3389
3535
 
3390
- function resolveProperties(properties, copy, extract) {
3536
+ function resolveProperties(properties, copy, resolvePropertyChain) {
3537
+ // Prevent recursive looping
3391
3538
  if (cache.indexOf(properties) > -1) {
3392
3539
  return;
3393
3540
  }
@@ -3403,18 +3550,18 @@ function resolveProperties(properties, copy, extract) {
3403
3550
  return;
3404
3551
  }
3405
3552
 
3406
- if (typeof value === 'string') {
3407
- copy[key] = extract(value);
3553
+ if (isString(value)) {
3554
+ copy[key] = resolvePropertyChain(value);
3408
3555
  } else if (Array.isArray(value)) {
3409
3556
  value.forEach(function (item, index, arr) {
3410
- if (typeof item === 'string') {
3411
- arr[index] = extract(item);
3557
+ if (isString(item)) {
3558
+ arr[index] = resolvePropertyChain(item);
3412
3559
  } else {
3413
- resolveProperties(item, item, extract);
3560
+ resolveProperties(item, item, resolvePropertyChain);
3414
3561
  }
3415
3562
  });
3416
- } else if (typeof value === 'object') {
3417
- resolveProperties(value, value, extract);
3563
+ } else if (isObject(value)) {
3564
+ resolveProperties(value, value, resolvePropertyChain);
3418
3565
  }
3419
3566
  });
3420
3567
  } finally {
@@ -3501,7 +3648,7 @@ var createElement$1 = function createElement(operationData) {
3501
3648
  elementName = _operationData.elementName,
3502
3649
  attributes = _operationData.attributes,
3503
3650
  text = _operationData.text;
3504
- var serializedAttrs = attributes ? ' ' + Object.entries(attributes).map(function (_ref) {
3651
+ var serializedAttrs = attributes ? " " + Object.entries(attributes).map(function (_ref) {
3505
3652
  var key = _ref[0],
3506
3653
  value = _ref[1];
3507
3654
  return key + "=\"" + value + "\"";
@@ -3525,7 +3672,7 @@ var customFunction$1 = function customFunction(operationData) {
3525
3672
  var systemName = operationData.systemName;
3526
3673
  return new Promise(function (resolve, reject) {
3527
3674
  var resultCallback = function resultCallback(func) {
3528
- var promise = func(operationData, _this.eventbus);
3675
+ var promise = func.apply(_this, [operationData]);
3529
3676
 
3530
3677
  if (promise) {
3531
3678
  promise.then(function () {
@@ -3543,6 +3690,10 @@ var customFunction$1 = function customFunction(operationData) {
3543
3690
  /**
3544
3691
  * This operation invokes the end() method on the specified action instance.
3545
3692
  *
3693
+ * The action operation data is first merged with the current operation data before it is
3694
+ * passed on to the action. After the action has completed the action operation data properties
3695
+ * are removed from the current operation data.
3696
+ *
3546
3697
  * @param operationData
3547
3698
  * @returns
3548
3699
  */
@@ -3885,22 +4036,10 @@ var getImport$1 = function getImport(operationData) {
3885
4036
  var getQueryParams$1 = function getQueryParams(operationData) {
3886
4037
  var searchParams = new URLSearchParams(window.location.search);
3887
4038
  var queryParams = Object.fromEntries(searchParams.entries());
3888
- var defaultValues = operationData.defaultValues;
3889
-
3890
- if (defaultValues) {
3891
- var defaultEntries = Object.entries(defaultValues).filter(function (_ref) {
3892
- var name = _ref[0];
3893
- return !(name in queryParams);
3894
- });
3895
- defaultEntries.forEach(function (_ref2) {
3896
- var name = _ref2[0],
3897
- value = _ref2[1];
3898
- return queryParams[name] = value;
3899
- });
3900
- delete operationData.defaultValues;
3901
- }
3902
-
3903
- operationData.queryParams = queryParams;
4039
+ var _operationData$defaul = operationData.defaultValues,
4040
+ defaultValues = _operationData$defaul === void 0 ? {} : _operationData$defaul;
4041
+ delete operationData.defaultValues;
4042
+ operationData.queryParams = _extends({}, defaultValues, queryParams);
3904
4043
  return operationData;
3905
4044
  };
3906
4045
 
@@ -3993,7 +4132,7 @@ var log$1 = function log(operationData) {
3993
4132
  };
3994
4133
 
3995
4134
  /**
3996
- * This operation performs the given math function of the specified arguments.
4135
+ * This operation performs the given math function with the specified arguments.
3997
4136
  *
3998
4137
  * @param operationData
3999
4138
  */
@@ -4019,7 +4158,7 @@ function resolveMathConstants(args) {
4019
4158
  }
4020
4159
 
4021
4160
  function isMathProperty(value) {
4022
- return typeof value === 'string' && value in Math && typeof Math[value] !== 'function';
4161
+ return isString(value) && value in Math && !isFunction(Math[value]);
4023
4162
  }
4024
4163
 
4025
4164
  /**
@@ -4287,8 +4426,7 @@ var setOperationData$1 = function setOperationData(operationData) {
4287
4426
 
4288
4427
  /**
4289
4428
  * This operation assigns the specified CSS style properties to the
4290
- * specified selected element. The selected element is assigned to
4291
- * the `selectedElement` property.
4429
+ * specified selected element.
4292
4430
  *
4293
4431
  * @param operationData
4294
4432
  * @returns
@@ -4550,7 +4688,7 @@ var JwPlayerTimelineProvider = /*#__PURE__*/function () {
4550
4688
 
4551
4689
  _this2.eventbus.broadcast(TimelineEventNames.DURATION, [_this2.getDuration()]);
4552
4690
 
4553
- resolve(_this2);
4691
+ resolve();
4554
4692
  });
4555
4693
 
4556
4694
  this._player.on(TimelineEventNames.TIME, this._loopHandler.bind(this, Math.floor));
@@ -4820,11 +4958,6 @@ var RequestAnimationFrameTimelineProvider = /*#__PURE__*/function () {
4820
4958
  return;
4821
4959
  }
4822
4960
 
4823
- if (this._firstFrame) {
4824
- this._firstFrame = false;
4825
- this.eventbus.broadcast(TimelineEventNames.FIRST_FRAME);
4826
- }
4827
-
4828
4961
  this._currentPosition++;
4829
4962
 
4830
4963
  if (this._currentPosition > this._currentPlaylistItem.duration) {
@@ -4832,6 +4965,8 @@ var RequestAnimationFrameTimelineProvider = /*#__PURE__*/function () {
4832
4965
  this._resetToStartPosition();
4833
4966
 
4834
4967
  this.eventbus.broadcast(TimelineEventNames.RESTART);
4968
+
4969
+ this._broadCastPosition();
4835
4970
  } else {
4836
4971
  this.stop();
4837
4972
  this.eventbus.broadcast(TimelineEventNames.COMPLETE);
@@ -4839,6 +4974,10 @@ var RequestAnimationFrameTimelineProvider = /*#__PURE__*/function () {
4839
4974
  }
4840
4975
  }
4841
4976
 
4977
+ this._broadCastPosition();
4978
+ };
4979
+
4980
+ _proto._broadCastPosition = function _broadCastPosition() {
4842
4981
  this.eventbus.broadcast(TimelineEventNames.TIME, [{
4843
4982
  position: this._currentPosition
4844
4983
  }]);
@@ -4858,6 +4997,16 @@ var RequestAnimationFrameTimelineProvider = /*#__PURE__*/function () {
4858
4997
  this.playState = 'running';
4859
4998
  (_this$_abortControlle = this._abortController) == null ? void 0 : _this$_abortControlle.abort();
4860
4999
  this._abortController = new AbortController();
5000
+
5001
+ if (this._firstFrame) {
5002
+ this._firstFrame = false;
5003
+ this.eventbus.broadcast(TimelineEventNames.FIRST_FRAME);
5004
+ }
5005
+
5006
+ if (this._currentPosition == 0) {
5007
+ this._broadCastPosition();
5008
+ }
5009
+
4861
5010
  animationInterval(this._tickInterval, this._abortController.signal, this._updateBound);
4862
5011
  };
4863
5012
 
@@ -4866,7 +5015,7 @@ var RequestAnimationFrameTimelineProvider = /*#__PURE__*/function () {
4866
5015
  };
4867
5016
 
4868
5017
  _proto._resize = function _resize() {
4869
- console.error('Not implemented yet');
5018
+ console.error('Not implemented yet, not even sure this needs to be implemented...');
4870
5019
  };
4871
5020
 
4872
5021
  _proto._container = function _container(callBack) {
@@ -4898,10 +5047,7 @@ var RequestAnimationFrameTimelineProvider = /*#__PURE__*/function () {
4898
5047
  throw new Error("timeline selector '" + this._currentPlaylistItem.selector + "' not found");
4899
5048
  }
4900
5049
 
4901
- var promise = new Promise(function (resolve) {
4902
- resolve();
4903
- });
4904
- return promise;
5050
+ return Promise.resolve();
4905
5051
  };
4906
5052
 
4907
5053
  _proto.destroy = function destroy() {
@@ -5317,7 +5463,7 @@ function math() {
5317
5463
 
5318
5464
  function createMathFunctionNames() {
5319
5465
  return Object.getOwnPropertyNames(Math).filter(function (x) {
5320
- return typeof Math[x] === 'function';
5466
+ return isFunction(Math[x]);
5321
5467
  }).map(function (functionName) {
5322
5468
  return {
5323
5469
  value: functionName