eligius 1.0.16 → 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 () {
@@ -4808,6 +4877,12 @@ function endLoop() {
4808
4877
  };
4809
4878
  }
4810
4879
 
4880
+ function endWhen() {
4881
+ return {
4882
+ description: 'Ends the current when block'
4883
+ };
4884
+ }
4885
+
4811
4886
  function extendController() {
4812
4887
  return {
4813
4888
  description: 'Extends the current controller',
@@ -4952,6 +5027,12 @@ function createMathFunctionNames() {
4952
5027
  });
4953
5028
  }
4954
5029
 
5030
+ function otherwise() {
5031
+ return {
5032
+ description: 'Inverts the control flow for `when` logic'
5033
+ };
5034
+ }
5035
+
4955
5036
  function removeClass() {
4956
5037
  return {
4957
5038
  description: 'Removes the specified class from the selected element',
@@ -5162,7 +5243,7 @@ function toggleElement() {
5162
5243
  };
5163
5244
  }
5164
5245
 
5165
- function wait() {
5246
+ function wait$1() {
5166
5247
  return {
5167
5248
  description: 'Waits the given amount of milliseconds before the action continues',
5168
5249
  properties: {
@@ -5174,6 +5255,18 @@ function wait() {
5174
5255
  };
5175
5256
  }
5176
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
+
5177
5270
  var operationMetadata = {
5178
5271
  __proto__: null,
5179
5272
  addClass: addClass,
@@ -5188,6 +5281,7 @@ var operationMetadata = {
5188
5281
  customFunction: customFunction,
5189
5282
  endAction: endAction,
5190
5283
  endLoop: endLoop,
5284
+ endWhen: endWhen,
5191
5285
  extendController: extendController,
5192
5286
  getControllerFromElement: getControllerFromElement,
5193
5287
  getControllerInstance: getControllerInstance,
@@ -5198,6 +5292,7 @@ var operationMetadata = {
5198
5292
  loadJSON: loadJSON,
5199
5293
  log: log,
5200
5294
  math: math,
5295
+ otherwise: otherwise,
5201
5296
  removeClass: removeClass,
5202
5297
  removeControllerFromElement: removeControllerFromElement,
5203
5298
  removeElement: removeElement,
@@ -5215,7 +5310,8 @@ var operationMetadata = {
5215
5310
  startLoop: startLoop,
5216
5311
  toggleClass: toggleClass,
5217
5312
  toggleElement: toggleElement,
5218
- wait: wait
5313
+ wait: wait$1,
5314
+ when: wait
5219
5315
  };
5220
5316
 
5221
5317
  var OperationNamesProvider = /*#__PURE__*/function () {
@@ -6332,6 +6428,11 @@ var evtb = {
6332
6428
  RequestVideoUriInterceptor: RequestVideoUriInterceptor
6333
6429
  };
6334
6430
 
6431
+ function setGlobal(name, value) {
6432
+ var cache = getGlobals();
6433
+ cache[name] = value;
6434
+ }
6435
+
6335
6436
  var LanguageManager = /*#__PURE__*/function () {
6336
6437
  function LanguageManager(_currentLanguage, labels, _eventbus) {
6337
6438
  this._currentLanguage = void 0;
@@ -6345,6 +6446,8 @@ var LanguageManager = /*#__PURE__*/function () {
6345
6446
  throw new Error('language ctor arg cannot have zero length');
6346
6447
  }
6347
6448
 
6449
+ setGlobal('defaultLanguage', _currentLanguage);
6450
+
6348
6451
  this._setRootElementLang(_currentLanguage);
6349
6452
 
6350
6453
  this._labelLookup = this._createLabelLookup(labels);
@@ -6675,5 +6778,5 @@ var EligiusResourceImporter = /*#__PURE__*/function () {
6675
6778
  return EligiusResourceImporter;
6676
6779
  }();
6677
6780
 
6678
- 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 };
6679
6782
  //# sourceMappingURL=eligius.esm.js.map