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.
@@ -1121,12 +1121,12 @@ function resolveOperationOrGlobalDataPropertyChain(sourceObject, propertyChainOr
1121
1121
  var propNames = propertyChainOrRegularObject.split('.');
1122
1122
  var prefix = (_propNames$shift = propNames.shift()) == null ? void 0 : _propNames$shift.toLowerCase();
1123
1123
 
1124
- if (prefix == 'operationdata') {
1125
- return getPropertyChainValue(propNames, sourceObject);
1126
- }
1124
+ switch (prefix) {
1125
+ case 'operationdata':
1126
+ return getPropertyChainValue(propNames, sourceObject);
1127
1127
 
1128
- if (prefix == 'globaldata') {
1129
- return getPropertyChainValue(propNames, getGlobals());
1128
+ case 'globaldata':
1129
+ return getPropertyChainValue(propNames, getGlobals());
1130
1130
  }
1131
1131
  }
1132
1132
 
@@ -1419,6 +1419,11 @@ var endLoop$1 = function endLoop(operationData) {
1419
1419
  return operationData;
1420
1420
  };
1421
1421
 
1422
+ var endWhen$1 = function endWhen(operationData) {
1423
+ delete this.skipNextOperation;
1424
+ return operationData;
1425
+ };
1426
+
1422
1427
  var extendController$1 = function extendController(operationData) {
1423
1428
  var controllerInstance = operationData.controllerInstance,
1424
1429
  controllerExtension = operationData.controllerExtension;
@@ -1840,6 +1845,14 @@ function isMathProperty(value) {
1840
1845
  return isString(value) && value in Math && !isFunction(Math[value]);
1841
1846
  }
1842
1847
 
1848
+ var otherwise$1 = function otherwise(operationData) {
1849
+ if (this.skipNextOperation === false) {
1850
+ this.skipNextOperation = true;
1851
+ }
1852
+
1853
+ return operationData;
1854
+ };
1855
+
1843
1856
  /**
1844
1857
  * This operation removes the spcified class name from the specified selected element.
1845
1858
  *
@@ -2209,7 +2222,7 @@ var toggleElement$1 = function toggleElement(operationData) {
2209
2222
  * @returns
2210
2223
  */
2211
2224
 
2212
- var wait$1 = function wait(operationData) {
2225
+ var wait$2 = function wait(operationData) {
2213
2226
  var milliseconds = operationData.milliseconds;
2214
2227
  return new Promise(function (resolve) {
2215
2228
  setTimeout(function () {
@@ -2218,6 +2231,59 @@ var wait$1 = function wait(operationData) {
2218
2231
  });
2219
2232
  };
2220
2233
 
2234
+ /**
2235
+ * When the given expression evaluates to false, subsequent operations will be skipped
2236
+ * until an `endWhen` operation is encountered.
2237
+ * Practically, this mean an `if` statement control flow implementation in a list of operations.
2238
+ *
2239
+ * @param operationData
2240
+ * @returns
2241
+ */
2242
+
2243
+ var when = function when(operationData) {
2244
+ var _parseExpression = parseExpression(operationData.expression, operationData),
2245
+ left = _parseExpression[0],
2246
+ operator = _parseExpression[1],
2247
+ right = _parseExpression[2];
2248
+
2249
+ var evaluationResult = evaluations[operator](left, right);
2250
+ this.skipNextOperation = !evaluationResult;
2251
+ delete operationData.expression;
2252
+ return operationData;
2253
+ };
2254
+
2255
+ function parseExpression(expression, operationData) {
2256
+ var _expression$split = expression.split(/!=|==|>=|<=|>|</),
2257
+ left = _expression$split[0],
2258
+ right = _expression$split[1];
2259
+
2260
+ var operator = expression.substring(left.length, expression.length - right.length);
2261
+ var leftNr = +left;
2262
+ var rightNr = +right;
2263
+ return [isNaN(leftNr) ? resolveOperationOrGlobalDataPropertyChain(operationData, left) : leftNr, operator, isNaN(rightNr) ? resolveOperationOrGlobalDataPropertyChain(operationData, right) : rightNr];
2264
+ }
2265
+
2266
+ var evaluations = {
2267
+ '==': function _(left, right) {
2268
+ return left === right;
2269
+ },
2270
+ '!=': function _(left, right) {
2271
+ return left !== right;
2272
+ },
2273
+ '>=': function _(left, right) {
2274
+ return left >= right;
2275
+ },
2276
+ '<=': function _(left, right) {
2277
+ return left <= right;
2278
+ },
2279
+ '>': function _(left, right) {
2280
+ return left > right;
2281
+ },
2282
+ '<': function _(left, right) {
2283
+ return left < right;
2284
+ }
2285
+ };
2286
+
2221
2287
  var ops = {
2222
2288
  __proto__: null,
2223
2289
  addClass: addClass$1,
@@ -2232,6 +2298,7 @@ var ops = {
2232
2298
  customFunction: customFunction$1,
2233
2299
  endAction: endAction$1,
2234
2300
  endLoop: endLoop$1,
2301
+ endWhen: endWhen$1,
2235
2302
  extendController: extendController$1,
2236
2303
  getControllerFromElement: getControllerFromElement$1,
2237
2304
  getControllerInstance: getControllerInstance$1,
@@ -2242,6 +2309,7 @@ var ops = {
2242
2309
  loadJSON: loadJSON$1,
2243
2310
  log: log$1,
2244
2311
  math: math$1,
2312
+ otherwise: otherwise$1,
2245
2313
  removeClass: removeClass$1,
2246
2314
  removeControllerFromElement: removeControllerFromElement$1,
2247
2315
  removeElement: removeElement$1,
@@ -2259,7 +2327,8 @@ var ops = {
2259
2327
  startLoop: startLoop$1,
2260
2328
  toggleClass: toggleClass$1,
2261
2329
  toggleElement: toggleElement$1,
2262
- wait: wait$1
2330
+ wait: wait$2,
2331
+ when: when
2263
2332
  };
2264
2333
 
2265
2334
  var ActionCreatorFactory = /*#__PURE__*/function () {
@@ -4820,6 +4889,12 @@ function endLoop() {
4820
4889
  };
4821
4890
  }
4822
4891
 
4892
+ function endWhen() {
4893
+ return {
4894
+ description: 'Ends the current when block'
4895
+ };
4896
+ }
4897
+
4823
4898
  function extendController() {
4824
4899
  return {
4825
4900
  description: 'Extends the current controller',
@@ -4964,6 +5039,12 @@ function createMathFunctionNames() {
4964
5039
  });
4965
5040
  }
4966
5041
 
5042
+ function otherwise() {
5043
+ return {
5044
+ description: 'Inverts the control flow for `when` logic'
5045
+ };
5046
+ }
5047
+
4967
5048
  function removeClass() {
4968
5049
  return {
4969
5050
  description: 'Removes the specified class from the selected element',
@@ -5174,7 +5255,7 @@ function toggleElement() {
5174
5255
  };
5175
5256
  }
5176
5257
 
5177
- function wait() {
5258
+ function wait$1() {
5178
5259
  return {
5179
5260
  description: 'Waits the given amount of milliseconds before the action continues',
5180
5261
  properties: {
@@ -5186,6 +5267,18 @@ function wait() {
5186
5267
  };
5187
5268
  }
5188
5269
 
5270
+ function wait() {
5271
+ return {
5272
+ description: 'Evaluates the given expression, when it evaluates to false context.skipNextOperation will be set to true',
5273
+ properties: {
5274
+ expression: {
5275
+ type: 'ParameterType:expression',
5276
+ required: true
5277
+ }
5278
+ }
5279
+ };
5280
+ }
5281
+
5189
5282
  var operationMetadata = {
5190
5283
  __proto__: null,
5191
5284
  addClass: addClass,
@@ -5200,6 +5293,7 @@ var operationMetadata = {
5200
5293
  customFunction: customFunction,
5201
5294
  endAction: endAction,
5202
5295
  endLoop: endLoop,
5296
+ endWhen: endWhen,
5203
5297
  extendController: extendController,
5204
5298
  getControllerFromElement: getControllerFromElement,
5205
5299
  getControllerInstance: getControllerInstance,
@@ -5210,6 +5304,7 @@ var operationMetadata = {
5210
5304
  loadJSON: loadJSON,
5211
5305
  log: log,
5212
5306
  math: math,
5307
+ otherwise: otherwise,
5213
5308
  removeClass: removeClass,
5214
5309
  removeControllerFromElement: removeControllerFromElement,
5215
5310
  removeElement: removeElement,
@@ -5227,7 +5322,8 @@ var operationMetadata = {
5227
5322
  startLoop: startLoop,
5228
5323
  toggleClass: toggleClass,
5229
5324
  toggleElement: toggleElement,
5230
- wait: wait
5325
+ wait: wait$1,
5326
+ when: wait
5231
5327
  };
5232
5328
 
5233
5329
  var OperationNamesProvider = /*#__PURE__*/function () {
@@ -6344,6 +6440,11 @@ var evtb = {
6344
6440
  RequestVideoUriInterceptor: RequestVideoUriInterceptor
6345
6441
  };
6346
6442
 
6443
+ function setGlobal(name, value) {
6444
+ var cache = getGlobals();
6445
+ cache[name] = value;
6446
+ }
6447
+
6347
6448
  var LanguageManager = /*#__PURE__*/function () {
6348
6449
  function LanguageManager(_currentLanguage, labels, _eventbus) {
6349
6450
  this._currentLanguage = void 0;
@@ -6357,6 +6458,8 @@ var LanguageManager = /*#__PURE__*/function () {
6357
6458
  throw new Error('language ctor arg cannot have zero length');
6358
6459
  }
6359
6460
 
6461
+ setGlobal('defaultLanguage', _currentLanguage);
6462
+
6360
6463
  this._setRootElementLang(_currentLanguage);
6361
6464
 
6362
6465
  this._labelLookup = this._createLabelLookup(labels);
@@ -6738,6 +6841,7 @@ exports.createElement = createElement$1;
6738
6841
  exports.customFunction = customFunction$1;
6739
6842
  exports.endAction = endAction$1;
6740
6843
  exports.endLoop = endLoop$1;
6844
+ exports.endWhen = endWhen$1;
6741
6845
  exports.extendController = extendController$1;
6742
6846
  exports.generateImporterSourceCode = generateImporterSourceCode;
6743
6847
  exports.getControllerFromElement = getControllerFromElement$1;
@@ -6750,6 +6854,7 @@ exports.loadJSON = loadJSON$1;
6750
6854
  exports.log = log$1;
6751
6855
  exports.math = math$1;
6752
6856
  exports.metadata = operationMetadata;
6857
+ exports.otherwise = otherwise$1;
6753
6858
  exports.removeClass = removeClass$1;
6754
6859
  exports.removeControllerFromElement = removeControllerFromElement$1;
6755
6860
  exports.removeElement = removeElement$1;
@@ -6767,5 +6872,6 @@ exports.startAction = startAction$1;
6767
6872
  exports.startLoop = startLoop$1;
6768
6873
  exports.toggleClass = toggleClass$1;
6769
6874
  exports.toggleElement = toggleElement$1;
6770
- exports.wait = wait$1;
6875
+ exports.wait = wait$2;
6876
+ exports.when = when;
6771
6877
  //# sourceMappingURL=eligius.cjs.development.js.map