eligius 1.0.15 → 1.0.17

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.
@@ -1109,12 +1109,12 @@ function resolveOperationOrGlobalDataPropertyChain(sourceObject, propertyChainOr
1109
1109
  var propNames = propertyChainOrRegularObject.split('.');
1110
1110
  var prefix = (_propNames$shift = propNames.shift()) == null ? void 0 : _propNames$shift.toLowerCase();
1111
1111
 
1112
- if (prefix == 'operationdata') {
1113
- return getPropertyChainValue(propNames, sourceObject);
1114
- }
1112
+ switch (prefix) {
1113
+ case 'operationdata':
1114
+ return getPropertyChainValue(propNames, sourceObject);
1115
1115
 
1116
- if (prefix == 'globaldata') {
1117
- return getPropertyChainValue(propNames, getGlobals());
1116
+ case 'globaldata':
1117
+ return getPropertyChainValue(propNames, getGlobals());
1118
1118
  }
1119
1119
  }
1120
1120
 
@@ -1407,6 +1407,11 @@ var endLoop$1 = function endLoop(operationData) {
1407
1407
  return operationData;
1408
1408
  };
1409
1409
 
1410
+ var endWhen$1 = function endWhen(operationData) {
1411
+ delete this.skipNextOperation;
1412
+ return operationData;
1413
+ };
1414
+
1410
1415
  var extendController$1 = function extendController(operationData) {
1411
1416
  var controllerInstance = operationData.controllerInstance,
1412
1417
  controllerExtension = operationData.controllerExtension;
@@ -1828,6 +1833,14 @@ function isMathProperty(value) {
1828
1833
  return isString(value) && value in Math && !isFunction(Math[value]);
1829
1834
  }
1830
1835
 
1836
+ var otherwise$1 = function otherwise(operationData) {
1837
+ if (this.skipNextOperation === false) {
1838
+ this.skipNextOperation = true;
1839
+ }
1840
+
1841
+ return operationData;
1842
+ };
1843
+
1831
1844
  /**
1832
1845
  * This operation removes the spcified class name from the specified selected element.
1833
1846
  *
@@ -2197,7 +2210,7 @@ var toggleElement$1 = function toggleElement(operationData) {
2197
2210
  * @returns
2198
2211
  */
2199
2212
 
2200
- var wait$1 = function wait(operationData) {
2213
+ var wait$2 = function wait(operationData) {
2201
2214
  var milliseconds = operationData.milliseconds;
2202
2215
  return new Promise(function (resolve) {
2203
2216
  setTimeout(function () {
@@ -2206,6 +2219,59 @@ var wait$1 = function wait(operationData) {
2206
2219
  });
2207
2220
  };
2208
2221
 
2222
+ /**
2223
+ * When the given expression evaluates to false, subsequent operations will be skipped
2224
+ * until an `endWhen` operation is encountered.
2225
+ * Practically, this mean an `if` statement control flow implementation in a list of operations.
2226
+ *
2227
+ * @param operationData
2228
+ * @returns
2229
+ */
2230
+
2231
+ var when = function when(operationData) {
2232
+ var _parseExpression = parseExpression(operationData.expression, operationData),
2233
+ left = _parseExpression[0],
2234
+ operator = _parseExpression[1],
2235
+ right = _parseExpression[2];
2236
+
2237
+ var evaluationResult = evaluations[operator](left, right);
2238
+ this.skipNextOperation = !evaluationResult;
2239
+ delete operationData.expression;
2240
+ return operationData;
2241
+ };
2242
+
2243
+ function parseExpression(expression, operationData) {
2244
+ var _expression$split = expression.split(/!=|==|>=|<=|>|</),
2245
+ left = _expression$split[0],
2246
+ right = _expression$split[1];
2247
+
2248
+ var operator = expression.substring(left.length, expression.length - right.length);
2249
+ var leftNr = +left;
2250
+ var rightNr = +right;
2251
+ return [isNaN(leftNr) ? resolveOperationOrGlobalDataPropertyChain(operationData, left) : leftNr, operator, isNaN(rightNr) ? resolveOperationOrGlobalDataPropertyChain(operationData, right) : rightNr];
2252
+ }
2253
+
2254
+ var evaluations = {
2255
+ '==': function _(left, right) {
2256
+ return left === right;
2257
+ },
2258
+ '!=': function _(left, right) {
2259
+ return left !== right;
2260
+ },
2261
+ '>=': function _(left, right) {
2262
+ return left >= right;
2263
+ },
2264
+ '<=': function _(left, right) {
2265
+ return left <= right;
2266
+ },
2267
+ '>': function _(left, right) {
2268
+ return left > right;
2269
+ },
2270
+ '<': function _(left, right) {
2271
+ return left < right;
2272
+ }
2273
+ };
2274
+
2209
2275
  var ops = {
2210
2276
  __proto__: null,
2211
2277
  addClass: addClass$1,
@@ -2220,6 +2286,7 @@ var ops = {
2220
2286
  customFunction: customFunction$1,
2221
2287
  endAction: endAction$1,
2222
2288
  endLoop: endLoop$1,
2289
+ endWhen: endWhen$1,
2223
2290
  extendController: extendController$1,
2224
2291
  getControllerFromElement: getControllerFromElement$1,
2225
2292
  getControllerInstance: getControllerInstance$1,
@@ -2230,6 +2297,7 @@ var ops = {
2230
2297
  loadJSON: loadJSON$1,
2231
2298
  log: log$1,
2232
2299
  math: math$1,
2300
+ otherwise: otherwise$1,
2233
2301
  removeClass: removeClass$1,
2234
2302
  removeControllerFromElement: removeControllerFromElement$1,
2235
2303
  removeElement: removeElement$1,
@@ -2247,7 +2315,8 @@ var ops = {
2247
2315
  startLoop: startLoop$1,
2248
2316
  toggleClass: toggleClass$1,
2249
2317
  toggleElement: toggleElement$1,
2250
- wait: wait$1
2318
+ wait: wait$2,
2319
+ when: when
2251
2320
  };
2252
2321
 
2253
2322
  var ActionCreatorFactory = /*#__PURE__*/function () {
@@ -3323,9 +3392,9 @@ var TimelineProvidersSettingsEditor = /*#__PURE__*/function () {
3323
3392
  }
3324
3393
 
3325
3394
  var settings = {
3326
- id: '',
3327
- poster: '',
3328
- selector: '',
3395
+ id: v4(),
3396
+ poster: undefined,
3397
+ selector: undefined,
3329
3398
  systemName: '',
3330
3399
  vendor: ''
3331
3400
  };
@@ -3397,6 +3466,20 @@ var ConfigurationFactory = /*#__PURE__*/function () {
3397
3466
  this.actionCreatorFactory = new ActionCreatorFactory(this);
3398
3467
  }
3399
3468
 
3469
+ ConfigurationFactory.extend = function extend(factory, extensionMethodName, extensionMethod) {
3470
+ factory[extensionMethodName] = extensionMethod.bind(factory);
3471
+ return factory;
3472
+ };
3473
+
3474
+ ConfigurationFactory.extendMultiple = function extendMultiple(factory, extensions) {
3475
+ Object.entries(extensions).forEach(function (_ref) {
3476
+ var name = _ref[0],
3477
+ method = _ref[1];
3478
+ return ConfigurationFactory.extend(factory, name, method);
3479
+ });
3480
+ return factory;
3481
+ };
3482
+
3400
3483
  var _proto = ConfigurationFactory.prototype;
3401
3484
 
3402
3485
  _proto.init = function init(defaultLanguage) {
@@ -3613,7 +3696,7 @@ var ConfigurationFactory = /*#__PURE__*/function () {
3613
3696
  });
3614
3697
 
3615
3698
  if (actionConfig) {
3616
- return new ActionEditor(actionConfig, this);
3699
+ return new EndableActionEditor(actionConfig, this);
3617
3700
  }
3618
3701
 
3619
3702
  throw new Error("Action not found for id " + id);
@@ -4794,6 +4877,12 @@ function endLoop() {
4794
4877
  };
4795
4878
  }
4796
4879
 
4880
+ function endWhen() {
4881
+ return {
4882
+ description: 'Ends the current when block'
4883
+ };
4884
+ }
4885
+
4797
4886
  function extendController() {
4798
4887
  return {
4799
4888
  description: 'Extends the current controller',
@@ -4938,6 +5027,12 @@ function createMathFunctionNames() {
4938
5027
  });
4939
5028
  }
4940
5029
 
5030
+ function otherwise() {
5031
+ return {
5032
+ description: 'Inverts the control flow for `when` logic'
5033
+ };
5034
+ }
5035
+
4941
5036
  function removeClass() {
4942
5037
  return {
4943
5038
  description: 'Removes the specified class from the selected element',
@@ -5148,7 +5243,7 @@ function toggleElement() {
5148
5243
  };
5149
5244
  }
5150
5245
 
5151
- function wait() {
5246
+ function wait$1() {
5152
5247
  return {
5153
5248
  description: 'Waits the given amount of milliseconds before the action continues',
5154
5249
  properties: {
@@ -5160,6 +5255,18 @@ function wait() {
5160
5255
  };
5161
5256
  }
5162
5257
 
5258
+ function wait() {
5259
+ return {
5260
+ description: 'Evaluates the given expression, when it evaluates to false context.skipNextOperation will be set to true',
5261
+ properties: {
5262
+ expression: {
5263
+ type: 'ParameterType:expression',
5264
+ required: true
5265
+ }
5266
+ }
5267
+ };
5268
+ }
5269
+
5163
5270
  var operationMetadata = {
5164
5271
  __proto__: null,
5165
5272
  addClass: addClass,
@@ -5174,6 +5281,7 @@ var operationMetadata = {
5174
5281
  customFunction: customFunction,
5175
5282
  endAction: endAction,
5176
5283
  endLoop: endLoop,
5284
+ endWhen: endWhen,
5177
5285
  extendController: extendController,
5178
5286
  getControllerFromElement: getControllerFromElement,
5179
5287
  getControllerInstance: getControllerInstance,
@@ -5184,6 +5292,7 @@ var operationMetadata = {
5184
5292
  loadJSON: loadJSON,
5185
5293
  log: log,
5186
5294
  math: math,
5295
+ otherwise: otherwise,
5187
5296
  removeClass: removeClass,
5188
5297
  removeControllerFromElement: removeControllerFromElement,
5189
5298
  removeElement: removeElement,
@@ -5201,7 +5310,8 @@ var operationMetadata = {
5201
5310
  startLoop: startLoop,
5202
5311
  toggleClass: toggleClass,
5203
5312
  toggleElement: toggleElement,
5204
- wait: wait
5313
+ wait: wait$1,
5314
+ when: wait
5205
5315
  };
5206
5316
 
5207
5317
  var OperationNamesProvider = /*#__PURE__*/function () {
@@ -6318,6 +6428,11 @@ var evtb = {
6318
6428
  RequestVideoUriInterceptor: RequestVideoUriInterceptor
6319
6429
  };
6320
6430
 
6431
+ function setGlobal(name, value) {
6432
+ var cache = getGlobals();
6433
+ cache[name] = value;
6434
+ }
6435
+
6321
6436
  var LanguageManager = /*#__PURE__*/function () {
6322
6437
  function LanguageManager(_currentLanguage, labels, _eventbus) {
6323
6438
  this._currentLanguage = void 0;
@@ -6331,6 +6446,8 @@ var LanguageManager = /*#__PURE__*/function () {
6331
6446
  throw new Error('language ctor arg cannot have zero length');
6332
6447
  }
6333
6448
 
6449
+ setGlobal('defaultLanguage', _currentLanguage);
6450
+
6334
6451
  this._setRootElementLang(_currentLanguage);
6335
6452
 
6336
6453
  this._labelLookup = this._createLabelLookup(labels);
@@ -6661,5 +6778,5 @@ var EligiusResourceImporter = /*#__PURE__*/function () {
6661
6778
  return EligiusResourceImporter;
6662
6779
  }();
6663
6780
 
6664
- export { Action, ActionCreator, ActionCreatorFactory, ActionEditor, ActionRegistryEventbusListener, ConfigurationFactory, ConfigurationResolver, ControllerNamesProvider, DEV_TOOLS_KEY, DevToolEventListener, Diagnostics, EligiusEngine, EligiusResourceImporter, EndableAction, EndableActionCreator, EndableActionEditor, EngineFactory, EventListenerController, Eventbus, JwPlayerTimelineProvider, LabelController, LanguageManager, LottieController, NavigationController, OperationEditor, OperationMetadataProvider, OperationNamesProvider, ProgressbarController, RequestAnimationFrameTimelineProvider, RequestVideoUriInterceptor, RoutingController, SubtitlesController, TimeLineEventNamesProvider, TimelineAction, TimelineActionCreator, TimelineActionEditor, TimelineEventNames, TimelineProviderSettingsEditor, TimelineProvidersSettingsEditor, addClass$1 as addClass, addControllerToElement$1 as addControllerToElement, animate$1 as animate, animateWithClass$1 as animateWithClass, broadcastEvent$1 as broadcastEvent, calc$1 as calc, clearElement$1 as clearElement, clearOperationData$1 as clearOperationData, createElement$1 as createElement, customFunction$1 as customFunction, endAction$1 as endAction, endLoop$1 as endLoop, extendController$1 as extendController, generateImporterSourceCode, getControllerFromElement$1 as getControllerFromElement, getControllerInstance$1 as getControllerInstance, getElementDimensions$1 as getElementDimensions, getImport$1 as getImport, getQueryParams$1 as getQueryParams, invokeObjectMethod$1 as invokeObjectMethod, loadJSON$1 as loadJSON, log$1 as log, math$1 as math, operationMetadata as metadata, removeClass$1 as removeClass, removeControllerFromElement$1 as removeControllerFromElement, removeElement$1 as removeElement, removePropertiesFromOperationData$1 as removePropertiesFromOperationData, reparentElement$1 as reparentElement, requestAction$1 as requestAction, resizeAction$1 as resizeAction, selectElement$1 as selectElement, setElementAttributes$1 as setElementAttributes, setElementContent$1 as setElementContent, setGlobalData$1 as setGlobalData, setOperationData$1 as setOperationData, setStyle$1 as setStyle, startAction$1 as startAction, startLoop$1 as startLoop, toggleClass$1 as toggleClass, toggleElement$1 as toggleElement, wait$1 as wait };
6781
+ export { Action, ActionCreator, ActionCreatorFactory, ActionEditor, ActionRegistryEventbusListener, ConfigurationFactory, ConfigurationResolver, ControllerNamesProvider, DEV_TOOLS_KEY, DevToolEventListener, Diagnostics, EligiusEngine, EligiusResourceImporter, EndableAction, EndableActionCreator, EndableActionEditor, EngineFactory, EventListenerController, Eventbus, JwPlayerTimelineProvider, LabelController, LanguageManager, LottieController, NavigationController, OperationEditor, OperationMetadataProvider, OperationNamesProvider, ProgressbarController, RequestAnimationFrameTimelineProvider, RequestVideoUriInterceptor, RoutingController, SubtitlesController, TimeLineEventNamesProvider, TimelineAction, TimelineActionCreator, TimelineActionEditor, TimelineEventNames, TimelineProviderSettingsEditor, TimelineProvidersSettingsEditor, addClass$1 as addClass, addControllerToElement$1 as addControllerToElement, animate$1 as animate, animateWithClass$1 as animateWithClass, broadcastEvent$1 as broadcastEvent, calc$1 as calc, clearElement$1 as clearElement, clearOperationData$1 as clearOperationData, createElement$1 as createElement, customFunction$1 as customFunction, endAction$1 as endAction, endLoop$1 as endLoop, endWhen$1 as endWhen, extendController$1 as extendController, generateImporterSourceCode, getControllerFromElement$1 as getControllerFromElement, getControllerInstance$1 as getControllerInstance, getElementDimensions$1 as getElementDimensions, getImport$1 as getImport, getQueryParams$1 as getQueryParams, invokeObjectMethod$1 as invokeObjectMethod, loadJSON$1 as loadJSON, log$1 as log, math$1 as math, operationMetadata as metadata, otherwise$1 as otherwise, removeClass$1 as removeClass, removeControllerFromElement$1 as removeControllerFromElement, removeElement$1 as removeElement, removePropertiesFromOperationData$1 as removePropertiesFromOperationData, reparentElement$1 as reparentElement, requestAction$1 as requestAction, resizeAction$1 as resizeAction, selectElement$1 as selectElement, setElementAttributes$1 as setElementAttributes, setElementContent$1 as setElementContent, setGlobalData$1 as setGlobalData, setOperationData$1 as setOperationData, setStyle$1 as setStyle, startAction$1 as startAction, startLoop$1 as startLoop, toggleClass$1 as toggleClass, toggleElement$1 as toggleElement, wait$2 as wait, when };
6665
6782
  //# sourceMappingURL=eligius.esm.js.map