@staffbase/plugins-client-sdk 1.2.2 → 2.0.0-beta.1

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.
@@ -2,22 +2,24 @@
2
2
  * Bundle of @staffbase/plugins-client-sdk
3
3
  * @file Staffbase plugins client SDK for JavaScript
4
4
  * @see https://github.com/Staffbase/plugins-client-sdk#readme
5
- * @version 1.2.1
5
+ * @version 1.2.3
6
6
  *
7
7
  * @author Stefan Staude <stefan.staude@staffbase.com>
8
8
  * @author Daniel Große <daniel.grosse@staffbase.com>
9
9
  *
10
- * @copyright 2022
10
+ * @copyright 2023
11
11
  * @license Apache-2.0
12
12
  */
13
13
 
14
14
  'use strict';
15
15
 
16
- Object.defineProperty(exports, '__esModule', { value: true });
17
-
18
16
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
19
17
 
20
- var loglevel = {exports: {}};
18
+ var loglevelExports = {};
19
+ var loglevel = {
20
+ get exports(){ return loglevelExports; },
21
+ set exports(v){ loglevelExports = v; },
22
+ };
21
23
 
22
24
  /*
23
25
  * loglevel - https://github.com/pimterry/loglevel
@@ -25,7 +27,6 @@ var loglevel = {exports: {}};
25
27
  * Copyright (c) 2013 Tim Perry
26
28
  * Licensed under the MIT license.
27
29
  */
28
-
29
30
  (function (module) {
30
31
  (function (root, definition) {
31
32
 
@@ -36,15 +37,15 @@ var loglevel = {exports: {}};
36
37
  }
37
38
  })(commonjsGlobal, function () {
38
39
 
40
+ // Slightly dubious tricks to cut down minimized file size
39
41
  var noop = function () {};
40
-
41
42
  var undefinedType = "undefined";
42
43
  var isIE = typeof window !== undefinedType && typeof window.navigator !== undefinedType && /Trident\/|MSIE /.test(window.navigator.userAgent);
43
- var logMethods = ["trace", "debug", "info", "warn", "error"]; // Cross-browser bind equivalent that works at least back to IE6
44
+ var logMethods = ["trace", "debug", "info", "warn", "error"];
44
45
 
46
+ // Cross-browser bind equivalent that works at least back to IE6
45
47
  function bindMethod(obj, methodName) {
46
48
  var method = obj[methodName];
47
-
48
49
  if (typeof method.bind === 'function') {
49
50
  return method.bind(obj);
50
51
  } else {
@@ -57,9 +58,9 @@ var loglevel = {exports: {}};
57
58
  };
58
59
  }
59
60
  }
60
- } // Trace() doesn't print the message in IE, so for that case we need to wrap it
61
-
61
+ }
62
62
 
63
+ // Trace() doesn't print the message in IE, so for that case we need to wrap it
63
64
  function traceForIE() {
64
65
  if (console.log) {
65
66
  if (console.log.apply) {
@@ -69,17 +70,15 @@ var loglevel = {exports: {}};
69
70
  Function.prototype.apply.apply(console.log, [console, arguments]);
70
71
  }
71
72
  }
72
-
73
73
  if (console.trace) console.trace();
74
- } // Build the best logging method possible for this env
75
- // Wherever possible we want to bind, not wrap, to preserve stack traces
76
-
74
+ }
77
75
 
76
+ // Build the best logging method possible for this env
77
+ // Wherever possible we want to bind, not wrap, to preserve stack traces
78
78
  function realMethod(methodName) {
79
79
  if (methodName === 'debug') {
80
80
  methodName = 'log';
81
81
  }
82
-
83
82
  if (typeof console === undefinedType) {
84
83
  return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
85
84
  } else if (methodName === 'trace' && isIE) {
@@ -91,22 +90,23 @@ var loglevel = {exports: {}};
91
90
  } else {
92
91
  return noop;
93
92
  }
94
- } // These private functions always need `this` to be set properly
93
+ }
95
94
 
95
+ // These private functions always need `this` to be set properly
96
96
 
97
97
  function replaceLoggingMethods(level, loggerName) {
98
98
  /*jshint validthis:true */
99
99
  for (var i = 0; i < logMethods.length; i++) {
100
100
  var methodName = logMethods[i];
101
101
  this[methodName] = i < level ? noop : this.methodFactory(methodName, level, loggerName);
102
- } // Define log.log as an alias for log.debug
103
-
102
+ }
104
103
 
104
+ // Define log.log as an alias for log.debug
105
105
  this.log = this.debug;
106
- } // In old IE versions, the console isn't present until you first open it.
107
- // We build realMethod() replacements here that regenerate logging methods
108
-
106
+ }
109
107
 
108
+ // In old IE versions, the console isn't present until you first open it.
109
+ // We build realMethod() replacements here that regenerate logging methods
110
110
  function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
111
111
  return function () {
112
112
  if (typeof console !== undefinedType) {
@@ -114,90 +114,84 @@ var loglevel = {exports: {}};
114
114
  this[methodName].apply(this, arguments);
115
115
  }
116
116
  };
117
- } // By default, we use closely bound real methods wherever possible, and
118
- // otherwise we wait for a console to appear, and then try again.
119
-
117
+ }
120
118
 
119
+ // By default, we use closely bound real methods wherever possible, and
120
+ // otherwise we wait for a console to appear, and then try again.
121
121
  function defaultMethodFactory(methodName, level, loggerName) {
122
122
  /*jshint validthis:true */
123
123
  return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
124
124
  }
125
-
126
125
  function Logger(name, defaultLevel, factory) {
127
126
  var self = this;
128
127
  var currentLevel;
129
128
  defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
130
129
  var storageKey = "loglevel";
131
-
132
130
  if (typeof name === "string") {
133
131
  storageKey += ":" + name;
134
132
  } else if (typeof name === "symbol") {
135
133
  storageKey = undefined;
136
134
  }
137
-
138
135
  function persistLevelIfPossible(levelNum) {
139
136
  var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
140
- if (typeof window === undefinedType || !storageKey) return; // Use localStorage if available
137
+ if (typeof window === undefinedType || !storageKey) return;
141
138
 
139
+ // Use localStorage if available
142
140
  try {
143
141
  window.localStorage[storageKey] = levelName;
144
142
  return;
145
- } catch (ignore) {} // Use session cookie as fallback
146
-
143
+ } catch (ignore) {}
147
144
 
145
+ // Use session cookie as fallback
148
146
  try {
149
147
  window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
150
148
  } catch (ignore) {}
151
149
  }
152
-
153
150
  function getPersistedLevel() {
154
151
  var storedLevel;
155
152
  if (typeof window === undefinedType || !storageKey) return;
156
-
157
153
  try {
158
154
  storedLevel = window.localStorage[storageKey];
159
- } catch (ignore) {} // Fallback to cookies if local storage gives us nothing
160
-
155
+ } catch (ignore) {}
161
156
 
157
+ // Fallback to cookies if local storage gives us nothing
162
158
  if (typeof storedLevel === undefinedType) {
163
159
  try {
164
160
  var cookie = window.document.cookie;
165
161
  var location = cookie.indexOf(encodeURIComponent(storageKey) + "=");
166
-
167
162
  if (location !== -1) {
168
163
  storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];
169
164
  }
170
165
  } catch (ignore) {}
171
- } // If the stored level is not valid, treat it as if nothing was stored.
172
-
166
+ }
173
167
 
168
+ // If the stored level is not valid, treat it as if nothing was stored.
174
169
  if (self.levels[storedLevel] === undefined) {
175
170
  storedLevel = undefined;
176
171
  }
177
-
178
172
  return storedLevel;
179
173
  }
180
-
181
174
  function clearPersistedLevel() {
182
- if (typeof window === undefinedType || !storageKey) return; // Use localStorage if available
175
+ if (typeof window === undefinedType || !storageKey) return;
183
176
 
177
+ // Use localStorage if available
184
178
  try {
185
179
  window.localStorage.removeItem(storageKey);
186
180
  return;
187
- } catch (ignore) {} // Use session cookie as fallback
188
-
181
+ } catch (ignore) {}
189
182
 
183
+ // Use session cookie as fallback
190
184
  try {
191
185
  window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
192
186
  } catch (ignore) {}
193
187
  }
188
+
194
189
  /*
195
190
  *
196
191
  * Public logger API - see https://github.com/pimterry/loglevel for details
197
192
  *
198
193
  */
199
194
 
200
-
201
195
  self.name = name;
202
196
  self.levels = {
203
197
  "TRACE": 0,
@@ -208,26 +202,20 @@ var loglevel = {exports: {}};
208
202
  "SILENT": 5
209
203
  };
210
204
  self.methodFactory = factory || defaultMethodFactory;
211
-
212
205
  self.getLevel = function () {
213
206
  return currentLevel;
214
207
  };
215
-
216
208
  self.setLevel = function (level, persist) {
217
209
  if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
218
210
  level = self.levels[level.toUpperCase()];
219
211
  }
220
-
221
212
  if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
222
213
  currentLevel = level;
223
-
224
214
  if (persist !== false) {
225
215
  // defaults to true
226
216
  persistLevelIfPossible(level);
227
217
  }
228
-
229
218
  replaceLoggingMethods.call(self, level, name);
230
-
231
219
  if (typeof console === undefinedType && level < self.levels.SILENT) {
232
220
  return "No console available for logging";
233
221
  }
@@ -235,179 +223,93 @@ var loglevel = {exports: {}};
235
223
  throw "log.setLevel() called with invalid level: " + level;
236
224
  }
237
225
  };
238
-
239
226
  self.setDefaultLevel = function (level) {
240
227
  defaultLevel = level;
241
-
242
228
  if (!getPersistedLevel()) {
243
229
  self.setLevel(level, false);
244
230
  }
245
231
  };
246
-
247
232
  self.resetLevel = function () {
248
233
  self.setLevel(defaultLevel, false);
249
234
  clearPersistedLevel();
250
235
  };
251
-
252
236
  self.disableAll = function (persist) {
253
237
  self.setLevel(self.levels.SILENT, persist);
254
- }; // Initialize with the right level
255
-
238
+ };
256
239
 
240
+ // Initialize with the right level
257
241
  var initialLevel = getPersistedLevel();
258
-
259
242
  if (initialLevel == null) {
260
243
  initialLevel = defaultLevel;
261
244
  }
262
-
263
245
  self.setLevel(initialLevel, false);
264
246
  }
247
+
265
248
  /*
266
249
  *
267
250
  * Top-level API
268
251
  *
269
252
  */
270
253
 
271
-
272
254
  var defaultLogger = new Logger();
273
255
  var _loggersByName = {};
274
-
275
256
  defaultLogger.getLogger = function getLogger(name) {
276
257
  if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
277
258
  throw new TypeError("You must supply a name when creating a logger.");
278
259
  }
279
-
280
260
  var logger = _loggersByName[name];
281
-
282
261
  if (!logger) {
283
262
  logger = _loggersByName[name] = new Logger(name, defaultLogger.getLevel(), defaultLogger.methodFactory);
284
263
  }
285
-
286
264
  return logger;
287
- }; // Grab the current global log variable in case of overwrite
288
-
265
+ };
289
266
 
267
+ // Grab the current global log variable in case of overwrite
290
268
  var _log = typeof window !== undefinedType ? window.log : undefined;
291
-
292
269
  defaultLogger.noConflict = function () {
293
270
  if (typeof window !== undefinedType && window.log === defaultLogger) {
294
271
  window.log = _log;
295
272
  }
296
-
297
273
  return defaultLogger;
298
274
  };
299
-
300
275
  defaultLogger.getLoggers = function getLoggers() {
301
276
  return _loggersByName;
302
- }; // ES6 default export, for compatibility
303
-
277
+ };
304
278
 
279
+ // ES6 default export, for compatibility
305
280
  defaultLogger['default'] = defaultLogger;
306
281
  return defaultLogger;
307
282
  });
308
283
  })(loglevel);
309
284
 
310
- function _defineProperty(obj, key, value) {
311
- if (key in obj) {
312
- Object.defineProperty(obj, key, {
313
- value: value,
314
- enumerable: true,
315
- configurable: true,
316
- writable: true
317
- });
318
- } else {
319
- obj[key] = value;
320
- }
321
-
322
- return obj;
323
- }
324
-
325
- function _slicedToArray(arr, i) {
326
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
327
- }
328
-
329
- function _arrayWithHoles(arr) {
330
- if (Array.isArray(arr)) return arr;
331
- }
332
-
333
- function _iterableToArrayLimit(arr, i) {
334
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
335
-
336
- if (_i == null) return;
337
- var _arr = [];
338
- var _n = true;
339
- var _d = false;
340
-
341
- var _s, _e;
342
-
343
- try {
344
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
345
- _arr.push(_s.value);
346
-
347
- if (i && _arr.length === i) break;
348
- }
349
- } catch (err) {
350
- _d = true;
351
- _e = err;
352
- } finally {
353
- try {
354
- if (!_n && _i["return"] != null) _i["return"]();
355
- } finally {
356
- if (_d) throw _e;
285
+ var entries_1;
286
+ var hasRequiredEntries;
287
+ function requireEntries() {
288
+ if (hasRequiredEntries) return entries_1;
289
+ hasRequiredEntries = 1;
290
+ var has = function (obj, prop) {
291
+ return Object.prototype.hasOwnProperty.call(obj, prop);
292
+ };
293
+ var isEnumerable = function (obj, prop) {
294
+ return Object.prototype.propertyIsEnumerable.call(obj, prop);
295
+ };
296
+ function entries(obj) {
297
+ if (obj == null) {
298
+ throw new TypeError('Cannot convert undefined or null to object');
357
299
  }
358
- }
359
-
360
- return _arr;
361
- }
362
-
363
- function _unsupportedIterableToArray(o, minLen) {
364
- if (!o) return;
365
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
366
- var n = Object.prototype.toString.call(o).slice(8, -1);
367
- if (n === "Object" && o.constructor) n = o.constructor.name;
368
- if (n === "Map" || n === "Set") return Array.from(o);
369
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
370
- }
371
-
372
- function _arrayLikeToArray(arr, len) {
373
- if (len == null || len > arr.length) len = arr.length;
374
-
375
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
376
-
377
- return arr2;
378
- }
379
-
380
- function _nonIterableRest() {
381
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
382
- }
383
-
384
- var has = function (obj, prop) {
385
- return Object.prototype.hasOwnProperty.call(obj, prop);
386
- };
387
-
388
- var isEnumerable = function (obj, prop) {
389
- return Object.prototype.propertyIsEnumerable.call(obj, prop);
390
- };
391
-
392
- function entries(obj) {
393
- if (obj == null) {
394
- throw new TypeError('Cannot convert undefined or null to object');
395
- }
396
-
397
- var pairs = [];
398
-
399
- for (var key in obj) {
400
- if (has(obj, key) && isEnumerable(obj, key)) {
401
- pairs.push([key, obj[key]]);
300
+ var pairs = [];
301
+ for (var key in obj) {
302
+ if (has(obj, key) && isEnumerable(obj, key)) {
303
+ pairs.push([key, obj[key]]);
304
+ }
402
305
  }
306
+ return pairs;
403
307
  }
404
-
405
- return pairs;
308
+ entries_1 = entries;
309
+ return entries_1;
406
310
  }
407
311
 
408
- var entries_1 = entries;
409
-
410
- var object_entriesPonyfill = typeof Object.entries === 'function' ? Object.entries : entries_1;
312
+ var object_entriesPonyfill = typeof Object.entries === 'function' ? Object.entries : requireEntries();
411
313
 
412
314
  /**
413
315
  * Reverses the keys and properties of the given object
@@ -415,17 +317,11 @@ var object_entriesPonyfill = typeof Object.entries === 'function' ? Object.entri
415
317
  * @param {object} obj the object to reverse
416
318
  * @return {object}
417
319
  */
418
-
419
- var reverse = function reverse(obj) {
420
- return object_entriesPonyfill(obj).reduce(function (acc, _ref) {
421
- var _ref2 = _slicedToArray(_ref, 2),
422
- k = _ref2[0],
423
- p = _ref2[1];
424
-
425
- acc[p] = k;
426
- return acc;
427
- }, {});
428
- };
320
+ const reverse = obj => object_entriesPonyfill(obj).reduce((acc, _ref) => {
321
+ let [k, p] = _ref;
322
+ acc[p] = k;
323
+ return acc;
324
+ }, {});
429
325
 
430
326
  /**
431
327
  * @typedef { Object.<string, string> } PlatformCommands
@@ -438,8 +334,7 @@ var reverse = function reverse(obj) {
438
334
  *
439
335
  * @type {PlatformCommands}
440
336
  */
441
-
442
- var commands = {
337
+ const commands = {
443
338
  ios: 'dev-ios',
444
339
  android: 'dev-android',
445
340
  version: 'app-version',
@@ -452,209 +347,439 @@ var commands = {
452
347
  branchDefaultLang: 'getBranchDefaultLanguage',
453
348
  prefContentLang: 'getPreferredContentLocale'
454
349
  };
350
+
455
351
  /**
456
352
  * All supported commands with reversed keys and properties
457
353
  *
458
354
  * @type {ReversedPlatformCommands>}
459
355
  */
460
-
461
- var reversedCommands = reverse(commands);
356
+ const reversedCommands = reverse(commands);
462
357
 
463
358
  var locales = {
359
+ af: {
360
+ key: 'af',
361
+ locale: 'af_ZA',
362
+ name: 'Afrikaans',
363
+ localizedName: 'Afrikaans'
364
+ },
365
+ am: {
366
+ key: 'am',
367
+ locale: 'am_ET',
368
+ name: 'አማርኛ',
369
+ localizedName: 'Amharic'
370
+ },
464
371
  ar: {
465
372
  key: 'ar',
373
+ locale: 'ar_SA',
374
+ name: 'العربية (المملكة العربية السعودية)',
375
+ direction: 'rtl',
376
+ localizedName: 'Arabic (Saudi Arabia)'
377
+ },
378
+ arAE: {
379
+ key: 'arAE',
466
380
  locale: 'ar_AE',
467
- name: 'العربية'
381
+ name: 'العربية (الإمارات العربية المتحدة)',
382
+ direction: 'rtl',
383
+ localizedName: 'Arabic (United Arab Emirates)'
384
+ },
385
+ arEG: {
386
+ key: 'arEG',
387
+ locale: 'ar_EG',
388
+ name: 'العربية (مصر)',
389
+ direction: 'rtl',
390
+ localizedName: 'Arabic (Egypt)'
468
391
  },
469
392
  bg: {
470
393
  key: 'bg',
471
394
  locale: 'bg_BG',
472
- name: 'български'
395
+ name: 'български',
396
+ localizedName: 'Bulgarian'
473
397
  },
474
398
  bn: {
475
399
  key: 'bn',
476
400
  locale: 'bn_BD',
477
- name: 'বাংলা'
401
+ name: 'বাংলা',
402
+ localizedName: 'Bengali'
403
+ },
404
+ bs: {
405
+ key: 'bs',
406
+ locale: 'bs_BA',
407
+ name: 'Bosanski',
408
+ localizedName: 'Bosnian'
478
409
  },
479
410
  cs: {
480
411
  key: 'cs',
481
412
  locale: 'cs_CZ',
482
- name: 'Čeština'
413
+ name: 'Čeština',
414
+ localizedName: 'Czech'
415
+ },
416
+ cy: {
417
+ key: 'cy',
418
+ locale: 'cy_GB',
419
+ name: 'Cymraeg',
420
+ localizedName: 'Welsh'
483
421
  },
484
422
  da: {
485
423
  key: 'da',
486
424
  locale: 'da_DK',
487
- name: 'Dansk'
425
+ name: 'Dansk',
426
+ localizedName: 'Danish'
488
427
  },
489
428
  de: {
490
429
  key: 'de',
491
430
  locale: 'de_DE',
492
- name: 'Deutsch'
431
+ name: 'Deutsch',
432
+ localizedName: 'German'
493
433
  },
494
434
  el: {
495
435
  key: 'el',
496
436
  locale: 'el_GR',
497
- name: 'Ελληνικά'
437
+ name: 'Ελληνικά',
438
+ localizedName: 'Greek'
498
439
  },
499
440
  en: {
500
441
  key: 'en',
501
442
  locale: 'en_US',
502
- name: 'English'
443
+ name: 'English',
444
+ localizedName: 'English'
503
445
  },
504
446
  es: {
505
447
  key: 'es',
506
448
  locale: 'es_ES',
507
- name: 'Español'
449
+ name: 'Español (España)',
450
+ localizedName: 'Spanish (Spain)'
451
+ },
452
+ esMX: {
453
+ key: 'esMX',
454
+ locale: 'es_MX',
455
+ name: 'Español (México)',
456
+ localizedName: 'Spanish (Mexico)'
508
457
  },
509
458
  et: {
510
459
  key: 'et',
511
460
  locale: 'et_EE',
512
- name: 'Eesti keel'
461
+ name: 'Eesti keel',
462
+ localizedName: 'Estonian'
513
463
  },
514
464
  fi: {
515
465
  key: 'fi',
516
466
  locale: 'fi_FI',
517
- name: 'Suomi'
467
+ name: 'Suomi',
468
+ localizedName: 'Finnish'
518
469
  },
519
470
  fr: {
520
471
  key: 'fr',
521
472
  locale: 'fr_FR',
522
- name: 'Français'
473
+ name: 'Français (France)',
474
+ localizedName: 'French (France)'
475
+ },
476
+ frCA: {
477
+ key: 'frCA',
478
+ locale: 'fr_CA',
479
+ name: 'Français (Canada)',
480
+ localizedName: 'French (Canada)'
523
481
  },
524
482
  he: {
525
483
  key: 'he',
526
484
  locale: 'he_IL',
527
- name: 'עִבְרִית'
485
+ name: 'עִבְרִית',
486
+ direction: 'rtl',
487
+ localizedName: 'Hebrew'
528
488
  },
529
489
  hi: {
530
490
  key: 'hi',
531
491
  locale: 'hi_IN',
532
- name: 'िन्दी'
492
+ name: 'िन्दी',
493
+ localizedName: 'Hindi'
494
+ },
495
+ hk: {
496
+ key: 'hk',
497
+ locale: 'zh_HK',
498
+ name: '繁體中文',
499
+ localizedName: 'Chinese traditional'
500
+ },
501
+ ht: {
502
+ key: 'ht',
503
+ locale: 'ht_HT',
504
+ name: 'kreyòl ayisyen',
505
+ localizedName: 'Haitian Creole'
533
506
  },
534
507
  hr: {
535
508
  key: 'hr',
536
509
  locale: 'hr_HR',
537
- name: 'Hrvatski'
510
+ name: 'Hrvatski',
511
+ localizedName: 'Croatian'
538
512
  },
539
513
  hu: {
540
514
  key: 'hu',
541
515
  locale: 'hu_HU',
542
- name: 'Magyar'
516
+ name: 'Magyar',
517
+ localizedName: 'Hungarian'
518
+ },
519
+ in: {
520
+ key: 'in',
521
+ locale: 'in_ID',
522
+ name: 'Bahasa Indonesia',
523
+ localizedName: 'Indonesian'
543
524
  },
544
525
  is: {
545
526
  key: 'is',
546
527
  locale: 'is_IS',
547
- name: 'Íslenska'
528
+ name: 'Íslenska',
529
+ localizedName: 'Icelandic'
548
530
  },
549
531
  it: {
550
532
  key: 'it',
551
533
  locale: 'it_IT',
552
- name: 'Italiano'
534
+ name: 'Italiano',
535
+ localizedName: 'Italian'
553
536
  },
554
537
  ja: {
555
538
  key: 'ja',
556
539
  locale: 'ja_JP',
557
- name: '日本語'
540
+ name: '日本語',
541
+ localizedName: 'Japanese'
542
+ },
543
+ kl: {
544
+ key: 'kl',
545
+ locale: 'kl_GL',
546
+ name: 'Kalaallisut',
547
+ localizedName: 'Greenlandic'
548
+ },
549
+ km: {
550
+ key: 'km',
551
+ locale: 'km_KH',
552
+ name: 'ខ្មែរ',
553
+ localizedName: 'Khmer'
558
554
  },
559
555
  ko: {
560
556
  key: 'ko',
561
557
  locale: 'ko_KR',
562
- name: '한국어'
558
+ name: '한국어',
559
+ localizedName: 'Korean'
560
+ },
561
+ lo: {
562
+ key: 'lo',
563
+ locale: 'lo_LA',
564
+ name: 'ລາວ',
565
+ localizedName: 'Lao'
563
566
  },
564
567
  lt: {
565
568
  key: 'lt',
566
569
  locale: 'lt_LT',
567
- name: 'Lietuvių'
570
+ name: 'Lietuvių',
571
+ localizedName: 'Lithuanian'
568
572
  },
569
573
  lv: {
570
574
  key: 'lv',
571
575
  locale: 'lv_LV',
572
- name: 'Latviešu'
576
+ name: 'Latviešu',
577
+ localizedName: 'Latvian'
578
+ },
579
+ mg: {
580
+ key: 'mg',
581
+ locale: 'mg_MG',
582
+ name: 'Malagasy',
583
+ localizedName: 'Malagasy'
573
584
  },
574
585
  mk: {
575
586
  key: 'mk',
576
587
  locale: 'mk_MK',
577
- name: 'Македонски'
588
+ name: 'Македонски',
589
+ localizedName: 'Macedonian'
590
+ },
591
+ mh: {
592
+ key: 'mh',
593
+ locale: 'mh_MH',
594
+ name: 'Kajin M̧ajeļ',
595
+ localizedName: 'Marshallese'
596
+ },
597
+ mi: {
598
+ key: 'mi',
599
+ locale: 'mi_NZ',
600
+ name: 'Māori',
601
+ localizedName: 'Māori'
602
+ },
603
+ mn: {
604
+ key: 'mn',
605
+ locale: 'mn_MN',
606
+ name: 'монгол',
607
+ localizedName: 'Mongolian'
608
+ },
609
+ mr: {
610
+ key: 'mr',
611
+ locale: 'mr_IN',
612
+ name: 'मराठी',
613
+ localizedName: 'Marathi'
578
614
  },
579
615
  ms: {
580
616
  key: 'ms',
581
617
  locale: 'ms_MY',
582
- name: 'Bahasa Melayu'
618
+ name: 'Bahasa Melayu',
619
+ localizedName: 'Malay'
620
+ },
621
+ my: {
622
+ key: 'my',
623
+ locale: 'my_MM',
624
+ name: 'Burmese',
625
+ localizedName: 'Burmese'
626
+ },
627
+ ne: {
628
+ key: 'ne',
629
+ locale: 'ne_NP',
630
+ name: 'नेपाली',
631
+ localizedName: 'Nepali'
583
632
  },
584
633
  nl: {
585
634
  key: 'nl',
586
635
  locale: 'nl_NL',
587
- name: 'Nederlands'
636
+ name: 'Nederlands',
637
+ localizedName: 'Dutch'
638
+ },
639
+ nlBE: {
640
+ key: 'nlBE',
641
+ locale: 'nl_BE',
642
+ name: 'Vlaemsch',
643
+ localizedName: 'Flemish'
588
644
  },
589
645
  no: {
590
646
  key: 'no',
591
647
  locale: 'no_NO',
592
- name: 'Norsk'
648
+ name: 'Norsk',
649
+ localizedName: 'Norwegian'
593
650
  },
594
651
  pl: {
595
652
  key: 'pl',
596
653
  locale: 'pl_PL',
597
- name: 'Polski'
654
+ name: 'Polski',
655
+ localizedName: 'Polish'
598
656
  },
599
657
  pt: {
600
658
  key: 'pt',
659
+ locale: 'pt_PT',
660
+ name: 'Português (Portugal)',
661
+ localizedName: 'Portuguese (Portugal)'
662
+ },
663
+ ptBR: {
664
+ key: 'ptBR',
601
665
  locale: 'pt_BR',
602
- name: 'Português'
666
+ name: 'Português (Brasil)',
667
+ localizedName: 'Portuguese (Brazil)'
603
668
  },
604
669
  ro: {
605
670
  key: 'ro',
606
671
  locale: 'ro_RO',
607
- name: 'Română'
672
+ name: 'Română',
673
+ localizedName: 'Romanian'
608
674
  },
609
675
  ru: {
610
676
  key: 'ru',
611
677
  locale: 'ru_RU',
612
- name: 'Русский'
678
+ name: 'Русский',
679
+ localizedName: 'Russian'
680
+ },
681
+ si: {
682
+ key: 'si',
683
+ locale: 'si_LK',
684
+ name: 'සිංහල',
685
+ localizedName: 'Sinhala'
613
686
  },
614
687
  sk: {
615
688
  key: 'sk',
616
689
  locale: 'sk_SK',
617
- name: 'Slovenský'
690
+ name: 'Slovenský',
691
+ localizedName: 'Slovak'
618
692
  },
619
693
  sl: {
620
694
  key: 'sl',
621
695
  locale: 'sl_SI',
622
- name: 'Slovenščina'
696
+ name: 'Slovenščina',
697
+ localizedName: 'Slovenian'
698
+ },
699
+ sq: {
700
+ key: 'sq',
701
+ locale: 'sq_AL',
702
+ name: 'Shqip',
703
+ localizedName: 'Albanian'
623
704
  },
624
705
  sr: {
625
706
  key: 'sr',
626
707
  locale: 'sr_RS',
627
- name: 'Српски'
708
+ name: 'Српски',
709
+ localizedName: 'Serbian'
710
+ },
711
+ so: {
712
+ key: 'so',
713
+ locale: 'so_SO',
714
+ name: 'Af-Soomaali',
715
+ localizedName: 'Somali'
628
716
  },
629
717
  sv: {
630
718
  key: 'sv',
631
719
  locale: 'sv_SE',
632
- name: 'Svenska'
720
+ name: 'Svenska',
721
+ localizedName: 'Swedish'
722
+ },
723
+ sw: {
724
+ key: 'sw',
725
+ locale: 'sw_TZ',
726
+ name: 'Swahili',
727
+ localizedName: 'Swahili'
728
+ },
729
+ ta: {
730
+ key: 'ta',
731
+ locale: 'ta_IN',
732
+ name: 'தமிழ்',
733
+ localizedName: 'Tamil'
734
+ },
735
+ tl: {
736
+ key: 'tl',
737
+ locale: 'tl_PH',
738
+ name: 'Filipino',
739
+ localizedName: 'Filipino'
633
740
  },
634
741
  th: {
635
742
  key: 'th',
636
743
  locale: 'th_TH',
637
- name: 'ภาษาไทย'
744
+ name: 'ภาษาไทย',
745
+ localizedName: 'Thai'
638
746
  },
639
747
  tr: {
640
748
  key: 'tr',
641
749
  locale: 'tr_TR',
642
- name: 'Türkçe'
750
+ name: 'Türkçe',
751
+ localizedName: 'Turkish'
643
752
  },
644
753
  uk: {
645
754
  key: 'uk',
646
755
  locale: 'uk_UA',
647
- name: 'Українська'
756
+ name: 'Українська',
757
+ localizedName: 'Ukrainian'
758
+ },
759
+ ur: {
760
+ key: 'ur',
761
+ locale: 'ur_PK',
762
+ name: 'اُردُو',
763
+ direction: 'rtl',
764
+ localizedName: 'Urdu'
648
765
  },
649
766
  vi: {
650
767
  key: 'vi',
651
768
  locale: 'vi_VN',
652
- name: 'Tiếng Việt'
769
+ name: 'Tiếng Việt',
770
+ localizedName: 'Vietnamese'
653
771
  },
654
772
  zh: {
655
773
  key: 'zh',
656
774
  locale: 'zh_CN',
657
- name: '简体中文'
775
+ name: '简体中文',
776
+ localizedName: 'Chinese'
777
+ },
778
+ zu: {
779
+ key: 'zu',
780
+ locale: 'zu_ZA',
781
+ name: 'isiZulu',
782
+ localizedName: 'Zulu'
658
783
  }
659
784
  };
660
785
 
@@ -665,29 +790,28 @@ var locales = {
665
790
  *
666
791
  * @return {string} the first part of the locale
667
792
  */
668
- var normalize = function normalize(locale) {
793
+ const normalize = locale => {
669
794
  locale = locale && locale.split(/-|_/)[0] || locale; // use only first part
670
795
 
671
796
  if (['nb', 'nn'].indexOf(locale) !== -1) {
672
797
  // fix Norwegian language code to conform with our non-standard stuff
673
798
  locale = 'no';
674
799
  }
675
-
676
800
  if (locale === 'iw') {
677
801
  // fix legacy Hebrew language code from our backend to conform with our frontend
678
802
  locale = 'he';
679
803
  }
680
-
681
804
  return locale;
682
805
  };
683
806
 
684
807
  /**
685
808
  * Fallbacks for all sdk commands
686
809
  */
687
- var userAgent = navigator.userAgent || navigator.vendor || window.opera || '';
688
- var currentLanguage = normalize(window && window.navigator.language); // initialize Staffbase/platform namespace for ios frontend js code injection
689
- // in case of executeJs of app version 3.5 this object gets overwritten
810
+ const userAgent = navigator.userAgent || navigator.vendor || window.opera || '';
811
+ const currentLanguage = normalize(window && window.navigator.language);
690
812
 
813
+ // initialize Staffbase/platform namespace for ios frontend js code injection
814
+ // in case of executeJs of app version 3.5 this object gets overwritten
691
815
  if (typeof window !== 'undefined') {
692
816
  window.Staffbase = window.Staffbase || {};
693
817
  window.Staffbase.platform = window.Staffbase.platform || {
@@ -696,81 +820,80 @@ if (typeof window !== 'undefined') {
696
820
  native: false
697
821
  };
698
822
  }
823
+
699
824
  /**
700
825
  * Get the current Staffbase app version
701
826
  *
702
827
  * @return {String} version
703
828
  */
704
-
705
-
706
- var getVersion$1 = function getVersion() {
829
+ const getVersion$1 = () => {
707
830
  return window.Staffbase.platform.version;
708
831
  };
832
+
709
833
  /**
710
834
  * Are we running in a native app
711
835
  *
712
836
  * works only for ios or old initial native data
713
837
  * @return {Boolean}
714
838
  */
715
-
716
- var isNative$1 = function isNative() {
717
- var safari = /safari/i.test(userAgent);
839
+ const isNative$1 = () => {
840
+ const safari = /safari/i.test(userAgent);
718
841
  return window.Staffbase.platform.native === 'android' || window.Staffbase.platform.native === 'ios' || !safari && isIos$1();
719
842
  };
843
+
720
844
  /**
721
845
  * Are we running on a mobile device
722
846
  *
723
847
  * @return {Boolean}
724
848
  */
725
-
726
- var isMobile$1 = function isMobile() {
849
+ const isMobile$1 = () => {
727
850
  return window.Staffbase.platform.mobile;
728
851
  };
852
+
729
853
  /**
730
854
  * Are we running on android
731
855
  *
732
856
  * @return {Boolean}
733
857
  */
734
-
735
- var isAndroid$1 = function isAndroid() {
858
+ const isAndroid$1 = () => {
736
859
  return window.Staffbase.platform.native === 'android' || /Android/i.test(userAgent);
737
860
  };
861
+
738
862
  /**
739
863
  * Are we running on ios
740
864
  *
741
865
  * @return {Boolean}
742
866
  */
743
-
744
- var isIos$1 = function isIos() {
867
+ const isIos$1 = () => {
745
868
  return window.Staffbase.platform.native === 'ios' || /iPhone|iPad|iPod/i.test(userAgent);
746
869
  };
870
+
747
871
  /**
748
872
  * Open an external link
749
873
  *
750
874
  * @param {String} url address
751
875
  */
752
-
753
- var openLink$2 = function openLink(url) {
876
+ const openLink$2 = url => {
754
877
  window.open(url, '_blank');
755
878
  };
879
+
756
880
  /**
757
881
  * Handler for unpossible functions
758
882
  *
759
883
  * @param {String} cmd command name
760
884
  */
761
-
762
- var unSupported = function unSupported(cmd) {
885
+ const unSupported = cmd => {
763
886
  // nothing we can do here
764
887
  return;
765
888
  };
889
+
766
890
  /**
767
891
  * Get extensive locale information.
768
892
  *
769
893
  * @return {Object} containing various language informations
770
894
  */
771
-
772
- var langInfos = function langInfos() {
773
- var branchDefaultLanguage = getBranchDefaultLanguage$2();
895
+ const langInfos = () => {
896
+ const branchDefaultLanguage = getBranchDefaultLanguage$2();
774
897
  return {
775
898
  contentLanguage: branchDefaultLanguage,
776
899
  branchLanguages: locales,
@@ -779,15 +902,16 @@ var langInfos = function langInfos() {
779
902
  contentLanguages: locales
780
903
  };
781
904
  };
905
+
782
906
  /**
783
907
  * Get the default language object
784
908
  *
785
909
  * @return {Object} the language object
786
910
  */
787
-
788
- var getBranchDefaultLanguage$2 = function getBranchDefaultLanguage() {
911
+ const getBranchDefaultLanguage$2 = () => {
789
912
  return locales[currentLanguage] || locales.en;
790
913
  };
914
+
791
915
  /**
792
916
  * Gets the chosen language from a given content object
793
917
  *
@@ -795,28 +919,24 @@ var getBranchDefaultLanguage$2 = function getBranchDefaultLanguage() {
795
919
  *
796
920
  * @return {string}
797
921
  */
798
-
799
- var getPreferredContentLocale$2 = function getPreferredContentLocale(content) {
800
- var locale = getBranchDefaultLanguage$2().locale;
801
-
922
+ const getPreferredContentLocale$2 = content => {
923
+ const locale = getBranchDefaultLanguage$2().locale;
802
924
  if (!content) {
803
925
  return locale;
804
926
  }
805
-
806
927
  if (Array.isArray(content)) {
807
- var index = content.indexOf(locale);
928
+ const index = content.indexOf(locale);
808
929
  return content[index] || content[0];
809
930
  } else {
810
- var keys = Object.keys(content);
811
-
812
- var _index = keys.indexOf(locale);
813
-
814
- return keys[_index] || keys[0];
931
+ const keys = Object.keys(content);
932
+ const index = keys.indexOf(locale);
933
+ return keys[index] || keys[0];
815
934
  }
816
935
  };
817
936
 
818
- var connection$2 = null;
819
- var fallbackKickIn = 500;
937
+ let connection$2 = null;
938
+ const fallbackKickIn = 500;
939
+
820
940
  /**
821
941
  * Fake connection to the Staffbase App after a period of time.
822
942
  *
@@ -824,19 +944,18 @@ var fallbackKickIn = 500;
824
944
  * after the time specified in fallbackKickIn runs out.
825
945
  * @return {Promise<function>} An appropriate send function
826
946
  */
827
-
828
- var fallback = (function () {
947
+ var fallback = (() => {
829
948
  if (connection$2) {
830
949
  return connection$2;
831
950
  }
832
-
833
- connection$2 = new Promise(function (resolve) {
951
+ connection$2 = new Promise(resolve => {
834
952
  setTimeout(function () {
835
953
  resolve(sendMessage$3);
836
954
  }, fallbackKickIn);
837
955
  });
838
956
  return connection$2;
839
957
  });
958
+
840
959
  /**
841
960
  * Send a SDK command to the Staffbase App.
842
961
  *
@@ -846,56 +965,38 @@ var fallback = (function () {
846
965
  * @return {Promise<any>} which awaits the response of the Staffbase App
847
966
  * @throws {Error} on commands not supported by protocol
848
967
  */
849
-
850
- var sendMessage$3 = function sendMessage(cmd) {
851
- var $args = arguments;
852
- return new Promise(function ($return, $error) {
853
- for (var _len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
854
- payload[_key - 1] = $args[_key];
855
- }
856
-
857
- switch (cmd) {
858
- case commands.version:
859
- return $return(getVersion$1());
860
-
861
- case commands.native:
862
- return $return(isNative$1());
863
-
864
- case commands.mobile:
865
- return $return(isMobile$1());
866
-
867
- case commands.ios:
868
- return $return(isIos$1());
869
-
870
- case commands.android:
871
- return $return(isAndroid$1());
872
-
873
- case commands.openLink:
874
- return $return(openLink$2.apply(null, payload));
875
-
876
- case commands.langInfos:
877
- return $return(langInfos());
878
-
879
- case commands.branchDefaultLang:
880
- return $return(getBranchDefaultLanguage$2());
881
-
882
- case commands.prefContentLang:
883
- return $return(getPreferredContentLocale$2.apply(null, payload));
884
-
885
- case commands.nativeUpload:
886
- case commands.nativeShare:
887
- return $return(unSupported());
888
-
889
- default:
890
- // should actually never ever happen
891
- return $error(new Error('Command ' + cmd + ' not supported by driver'));
892
- }
893
-
894
- return $return();
895
- });
968
+ const sendMessage$3 = async function (cmd) {
969
+ for (var _len = arguments.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
970
+ payload[_key - 1] = arguments[_key];
971
+ }
972
+ switch (cmd) {
973
+ case commands.version:
974
+ return getVersion$1();
975
+ case commands.native:
976
+ return isNative$1();
977
+ case commands.mobile:
978
+ return isMobile$1();
979
+ case commands.ios:
980
+ return isIos$1();
981
+ case commands.android:
982
+ return isAndroid$1();
983
+ case commands.openLink:
984
+ return openLink$2.apply(null, payload);
985
+ case commands.langInfos:
986
+ return langInfos();
987
+ case commands.branchDefaultLang:
988
+ return getBranchDefaultLanguage$2();
989
+ case commands.prefContentLang:
990
+ return getPreferredContentLocale$2.apply(null, payload);
991
+ case commands.nativeUpload:
992
+ case commands.nativeShare:
993
+ return unSupported();
994
+ default:
995
+ // should actually never ever happen
996
+ throw new Error('Command ' + cmd + ' not supported by driver');
997
+ }
896
998
  };
897
999
 
898
- var _invocationMapping;
899
1000
  /**
900
1001
  * Postmessage protocol (3.6)
901
1002
  */
@@ -908,33 +1009,39 @@ var protocol = {
908
1009
  INVOCATION: 'INVOCATION',
909
1010
  // send this to call a function in the frontend
910
1011
  ERROR: 'ERROR' // receive this when something goes wrong
1012
+ };
911
1013
 
1014
+ const invocationMapping = {
1015
+ [commands.openLink]: 'openLink',
1016
+ [commands.nativeUpload]: 'nativeFileUpload',
1017
+ [commands.nativeShare]: 'nativeShareDialog',
1018
+ [commands.langInfos]: 'getPluginLanguageInfo',
1019
+ [commands.prefContentLang]: 'getPreferredContentLocale'
912
1020
  };
913
- var invocationMapping = (_invocationMapping = {}, _defineProperty(_invocationMapping, commands.openLink, 'openLink'), _defineProperty(_invocationMapping, commands.nativeUpload, 'nativeFileUpload'), _defineProperty(_invocationMapping, commands.nativeShare, 'nativeShareDialog'), _defineProperty(_invocationMapping, commands.langInfos, 'getPluginLanguageInfo'), _defineProperty(_invocationMapping, commands.prefContentLang, 'getPreferredContentLocale'), _invocationMapping);
914
1021
 
915
1022
  /**
916
1023
  * Generates an unique id of 4 alpha numerical chars
917
1024
  *
918
1025
  * @return {string} unique id
919
1026
  */
920
- var genID = function genID() {
1027
+ const genID = () => {
921
1028
  return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
922
1029
  };
923
1030
 
924
1031
  /**
925
1032
  * @type {Object.<string, {resolve: function, reject: function, promise: Promise}>}
926
1033
  */
1034
+ let promiseMap = {};
927
1035
 
928
- var promiseMap = {};
929
1036
  /**
930
1037
  * Create an info object for a new promise in the map.
931
1038
  *
932
1039
  * @return {string} id of the promise
933
1040
  */
934
-
935
1041
  function createPromiseObject() {
936
- var id = genID(); // When the id is already used, it invokes the function again
1042
+ const id = genID();
937
1043
 
1044
+ // When the id is already used, it invokes the function again
938
1045
  if (id in promiseMap) return createPromiseObject();
939
1046
  promiseMap[id] = {
940
1047
  resolve: null,
@@ -943,6 +1050,7 @@ function createPromiseObject() {
943
1050
  };
944
1051
  return id;
945
1052
  }
1053
+
946
1054
  /**
947
1055
  * Create a promise and return it's id.
948
1056
  *
@@ -950,17 +1058,16 @@ function createPromiseObject() {
950
1058
  *
951
1059
  * @return {string} id of the promise
952
1060
  */
953
-
954
-
955
- var create = function create() {
956
- var id = createPromiseObject();
957
- var p = new Promise(function (resolve, reject) {
1061
+ const create = () => {
1062
+ const id = createPromiseObject();
1063
+ const p = new Promise(function (resolve, reject) {
958
1064
  promiseMap[id].resolve = resolve;
959
1065
  promiseMap[id].reject = reject;
960
1066
  });
961
1067
  promiseMap[id].promise = p;
962
1068
  return id;
963
1069
  };
1070
+
964
1071
  /**
965
1072
  * Resolve a promise by id.
966
1073
  *
@@ -969,12 +1076,12 @@ var create = function create() {
969
1076
  *
970
1077
  * @throws {Error} on unknown id
971
1078
  */
972
-
973
- var resolve = function resolve(id, msg) {
1079
+ const resolve = (id, msg) => {
974
1080
  if (!(id in promiseMap)) throw new Error('Tried to resolve an unknown [' + id + '] promise.');
975
1081
  promiseMap[id].resolve(msg);
976
1082
  delete promiseMap[id];
977
1083
  };
1084
+
978
1085
  /**
979
1086
  * Reject a promise by id.
980
1087
  *
@@ -982,12 +1089,12 @@ var resolve = function resolve(id, msg) {
982
1089
  * @param {any} err the error which will will be passed to reject
983
1090
  * @throws {Error} on unknown id
984
1091
  */
985
-
986
- var reject = function reject(id, err) {
1092
+ const reject = (id, err) => {
987
1093
  if (!(id in promiseMap)) throw new Error('Tried to reject an unknown [' + id + '] promise.');
988
1094
  promiseMap[id].reject(err);
989
1095
  delete promiseMap[id];
990
1096
  };
1097
+
991
1098
  /**
992
1099
  * Get a promise by id.
993
1100
  *
@@ -995,8 +1102,7 @@ var reject = function reject(id, err) {
995
1102
  * @return {Promise} the promise identified by id
996
1103
  * @throws {Error} on unknown id
997
1104
  */
998
-
999
- var get = function get(id) {
1105
+ const get = id => {
1000
1106
  if (!(id in promiseMap)) throw new Error('Tried to get an unknown [' + id + '] promise.');
1001
1107
  return promiseMap[id].promise;
1002
1108
  };
@@ -1019,10 +1125,11 @@ var get = function get(id) {
1019
1125
  * @static
1020
1126
  * @return {StaticValueStore}
1021
1127
  */
1022
-
1023
- var dataStore$1 = function dataStore(_ref) {
1024
- var platform = _ref.platform,
1025
- language = _ref.language;
1128
+ const dataStore$1 = _ref => {
1129
+ let {
1130
+ platform,
1131
+ language
1132
+ } = _ref;
1026
1133
  return {
1027
1134
  mobile: platform.mobile,
1028
1135
  version: platform.version,
@@ -1033,22 +1140,20 @@ var dataStore$1 = function dataStore(_ref) {
1033
1140
  branchDefaultLanguage: language.branchDefaultLanguage
1034
1141
  };
1035
1142
  };
1143
+ let connection$1 = null;
1144
+ const targetOrigin = '*';
1036
1145
 
1037
- var connection$1 = null;
1038
- var targetOrigin = '*';
1039
1146
  /**
1040
1147
  * Connect to the Staffbase App.
1041
1148
  *
1042
1149
  * Create a connection to a Staffbase app 3.6
1043
1150
  * @return {Promise<function>} An appropriate send function
1044
1151
  */
1045
-
1046
- var connect$2 = function connect() {
1152
+ const connect$2 = () => {
1047
1153
  if (connection$1) {
1048
1154
  return connection$1;
1049
1155
  }
1050
-
1051
- var connectId = create();
1156
+ const connectId = create();
1052
1157
  connection$1 = get(connectId).then(function (payload) {
1053
1158
  return sendMessage$2(dataStore$1(payload));
1054
1159
  });
@@ -1056,53 +1161,46 @@ var connect$2 = function connect() {
1056
1161
  window.parent.postMessage([protocol.HELLO, connectId, []], targetOrigin);
1057
1162
  return connection$1;
1058
1163
  };
1164
+
1059
1165
  /**
1060
1166
  * Handler that receives a message from the Staffbase app
1061
1167
  *
1062
1168
  * Can be attached to window.onPostMessage
1063
1169
  * @param {MessageEvent} evt onPostMessage event result
1064
1170
  */
1171
+ const receiveMessage = async evt => {
1172
+ let type;
1173
+ let id;
1174
+ let payload;
1065
1175
 
1066
- var receiveMessage = function receiveMessage(evt) {
1067
- return new Promise(function ($return, $error) {
1068
- var type;
1069
- var id;
1070
- var payload; // safe destructure
1071
-
1072
- try {
1073
- var _evt$data = _slicedToArray(evt.data, 3);
1074
-
1075
- type = _evt$data[0];
1076
- id = _evt$data[1];
1077
- payload = _evt$data[2];
1078
- } catch (e) {
1176
+ // safe destructure
1177
+ try {
1178
+ ({
1179
+ data: [type, id, payload]
1180
+ } = evt);
1181
+ } catch (e) {
1182
+ // even thought catch-ignore is a bad style
1183
+ // there may be other participants listening
1184
+ // to messages in a different format so we
1185
+ // silently ignore here
1186
+ return;
1187
+ }
1188
+ switch (type) {
1189
+ case protocol.SUCCESS:
1190
+ resolve(id, payload);
1191
+ break;
1192
+ case protocol.ERROR:
1193
+ reject(id, payload);
1194
+ break;
1195
+ default:
1079
1196
  // even thought catch-ignore is a bad style
1080
1197
  // there may be other participants listening
1081
1198
  // to messages in a different format so we
1082
1199
  // silently ignore here
1083
- return $return();
1084
- }
1085
-
1086
- switch (type) {
1087
- case protocol.SUCCESS:
1088
- resolve(id, payload);
1089
- break;
1090
-
1091
- case protocol.ERROR:
1092
- reject(id, payload);
1093
- break;
1094
-
1095
- default:
1096
- // even thought catch-ignore is a bad style
1097
- // there may be other participants listening
1098
- // to messages in a different format so we
1099
- // silently ignore here
1100
- return $return();
1101
- }
1102
-
1103
- return $return();
1104
- });
1200
+ return;
1201
+ }
1105
1202
  };
1203
+
1106
1204
  /**
1107
1205
  * Send a SDK command to the Staffbase App.
1108
1206
  *
@@ -1113,40 +1211,29 @@ var receiveMessage = function receiveMessage(evt) {
1113
1211
  * @return {Promise<any>} which awaits the response of the Staffbase App
1114
1212
  * @throws {Error} on commands not supported by protocol
1115
1213
  */
1116
-
1117
-
1118
- var sendMessage$2 = function sendMessage(store) {
1119
- return function (cmd) {
1120
- var $args = arguments;
1121
- return new Promise(function ($return, $error) {
1122
- switch (cmd) {
1123
- case commands.version:
1124
- case commands.native:
1125
- case commands.mobile:
1126
- case commands.ios:
1127
- case commands.android:
1128
- case commands.branchDefaultLang:
1129
- return $return(store[reversedCommands[cmd]]);
1130
-
1131
- case commands.langInfos:
1132
- case commands.openLink:
1133
- case commands.nativeUpload:
1134
- case commands.nativeShare:
1135
- case commands.prefContentLang:
1136
- for (var _len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1137
- payload[_key - 1] = $args[_key];
1138
- }
1139
-
1140
- return $return(sendInvocationCall$1(create())(invocationMapping[cmd], payload));
1141
-
1142
- default:
1143
- return $error(new Error('Command ' + cmd + ' not supported by driver'));
1214
+ const sendMessage$2 = store => async function (cmd) {
1215
+ switch (cmd) {
1216
+ case commands.version:
1217
+ case commands.native:
1218
+ case commands.mobile:
1219
+ case commands.ios:
1220
+ case commands.android:
1221
+ case commands.branchDefaultLang:
1222
+ return store[reversedCommands[cmd]];
1223
+ case commands.langInfos:
1224
+ case commands.openLink:
1225
+ case commands.nativeUpload:
1226
+ case commands.nativeShare:
1227
+ case commands.prefContentLang:
1228
+ for (var _len = arguments.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1229
+ payload[_key - 1] = arguments[_key];
1144
1230
  }
1145
-
1146
- return $return();
1147
- });
1148
- };
1231
+ return sendInvocationCall$1(create())(invocationMapping[cmd], payload);
1232
+ default:
1233
+ throw new Error('Command ' + cmd + ' not supported by driver');
1234
+ }
1149
1235
  };
1236
+
1150
1237
  /**
1151
1238
  * Create a promise and send an invocation call to the frontend
1152
1239
  *
@@ -1156,17 +1243,14 @@ var sendMessage$2 = function sendMessage(store) {
1156
1243
  *
1157
1244
  * @return {Promise}
1158
1245
  */
1159
-
1160
-
1161
- var sendInvocationCall$1 = function sendInvocationCall(promiseID) {
1162
- return function (process, args) {
1163
- window.parent.postMessage([protocol.INVOCATION, promiseID, process, args], targetOrigin);
1164
- return get(promiseID);
1165
- };
1246
+ const sendInvocationCall$1 = promiseID => (process, args) => {
1247
+ window.parent.postMessage([protocol.INVOCATION, promiseID, process, args], targetOrigin);
1248
+ return get(promiseID);
1166
1249
  };
1167
1250
 
1168
- var connection = null;
1169
- var outMsgQueue = [];
1251
+ let connection = null;
1252
+ let outMsgQueue = [];
1253
+
1170
1254
  /**
1171
1255
  * Simple store solution to make the initial data available
1172
1256
  * as static values
@@ -1175,10 +1259,11 @@ var outMsgQueue = [];
1175
1259
  * @static
1176
1260
  * @return {StaticValueStore}
1177
1261
  */
1178
-
1179
- var dataStore = function dataStore(_ref) {
1180
- var platform = _ref.platform,
1181
- language = _ref.language;
1262
+ const dataStore = _ref => {
1263
+ let {
1264
+ platform,
1265
+ language
1266
+ } = _ref;
1182
1267
  return {
1183
1268
  mobile: platform.mobile,
1184
1269
  version: platform.version,
@@ -1189,31 +1274,30 @@ var dataStore = function dataStore(_ref) {
1189
1274
  branchDefaultLang: language.branchDefaultLanguage
1190
1275
  };
1191
1276
  };
1192
-
1193
1277
  window.Staffbase = window.Staffbase || {};
1194
1278
  window.Staffbase.plugins = {
1195
1279
  getMessages: multiMessageProvider,
1196
1280
  putMessage: singleMessageReceiver
1197
1281
  };
1282
+
1198
1283
  /**
1199
1284
  * Connect to the Staffbase App.
1200
1285
  *
1201
1286
  * Create a connection to a Staffbase app 3.6 from a native tab
1202
1287
  * @return {Promise<function>} An appropriate send function
1203
1288
  */
1204
-
1205
- var connect$1 = function connect() {
1289
+ const connect$1 = () => {
1206
1290
  if (connection) {
1207
1291
  return connection;
1208
1292
  }
1209
-
1210
- var connectId = create();
1293
+ const connectId = create();
1211
1294
  connection = get(connectId).then(function (payload) {
1212
1295
  return sendMessage$1(dataStore(payload));
1213
1296
  });
1214
1297
  outMsgQueue.push([protocol.HELLO, connectId, []]);
1215
1298
  return connection;
1216
1299
  };
1300
+
1217
1301
  /**
1218
1302
  * A function which returns an array of messages
1219
1303
  *
@@ -1222,44 +1306,34 @@ var connect$1 = function connect() {
1222
1306
  *
1223
1307
  * @return {Array} ordered list of messages
1224
1308
  */
1225
-
1226
1309
  function multiMessageProvider() {
1227
- var queueRef = outMsgQueue;
1228
-
1310
+ const queueRef = outMsgQueue;
1229
1311
  if (queueRef.length) ;
1230
-
1231
1312
  outMsgQueue = [];
1232
1313
  return queueRef;
1233
1314
  }
1315
+
1234
1316
  /**
1235
1317
  * A function which can receive a single message.
1236
1318
  *
1237
1319
  * Can be attached to window.onPostMessage
1238
1320
  * @param {Array} msg Staffbase 3.6 message
1239
1321
  */
1240
-
1241
-
1242
1322
  function singleMessageReceiver(msg) {
1243
- var type;
1244
- var id;
1245
- var payload; // safe destructure
1323
+ let type;
1324
+ let id;
1325
+ let payload;
1246
1326
 
1327
+ // safe destructure
1247
1328
  try {
1248
- var _msg = _slicedToArray(msg, 3);
1249
-
1250
- type = _msg[0];
1251
- id = _msg[1];
1252
- payload = _msg[2];
1253
-
1329
+ [type, id, payload] = msg;
1254
1330
  switch (type) {
1255
1331
  case protocol.SUCCESS:
1256
1332
  resolve(id, payload);
1257
1333
  break;
1258
-
1259
1334
  case protocol.ERROR:
1260
1335
  reject(id, payload);
1261
1336
  break;
1262
-
1263
1337
  default:
1264
1338
  // even thought catch-ignore is a bad style
1265
1339
  // there may be other participants listening
@@ -1275,6 +1349,7 @@ function singleMessageReceiver(msg) {
1275
1349
  return;
1276
1350
  }
1277
1351
  }
1352
+
1278
1353
  /**
1279
1354
  * Send a SDK command to the Staffbase App.
1280
1355
  *
@@ -1285,37 +1360,27 @@ function singleMessageReceiver(msg) {
1285
1360
  * @return {Promise<any>} which awaits the response of the Staffbase App
1286
1361
  * @throws {Error} on commands not supported by protocol
1287
1362
  */
1288
-
1289
- var sendMessage$1 = function sendMessage(store) {
1290
- return function (cmd) {
1291
- var $args = arguments;
1292
- return new Promise(function ($return, $error) {
1293
- switch (cmd) {
1294
- case commands.version:
1295
- case commands.native:
1296
- case commands.mobile:
1297
- case commands.ios:
1298
- case commands.android:
1299
- case commands.langInfos:
1300
- case commands.branchDefaultLang:
1301
- return $return(store[reversedCommands[cmd]]);
1302
-
1303
- case commands.openLink:
1304
- case commands.prefContentLang:
1305
- for (var _len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1306
- payload[_key - 1] = $args[_key];
1307
- }
1308
-
1309
- return $return(sendInvocationCall(invocationMapping[cmd], payload));
1310
-
1311
- default:
1312
- return $error(new Error('Command ' + cmd + ' not supported by driver'));
1363
+ const sendMessage$1 = store => async function (cmd) {
1364
+ switch (cmd) {
1365
+ case commands.version:
1366
+ case commands.native:
1367
+ case commands.mobile:
1368
+ case commands.ios:
1369
+ case commands.android:
1370
+ case commands.langInfos:
1371
+ case commands.branchDefaultLang:
1372
+ return store[reversedCommands[cmd]];
1373
+ case commands.openLink:
1374
+ case commands.prefContentLang:
1375
+ for (var _len = arguments.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1376
+ payload[_key - 1] = arguments[_key];
1313
1377
  }
1314
-
1315
- return $return();
1316
- });
1317
- };
1378
+ return sendInvocationCall(invocationMapping[cmd], payload);
1379
+ default:
1380
+ throw new Error('Command ' + cmd + ' not supported by driver');
1381
+ }
1318
1382
  };
1383
+
1319
1384
  /**
1320
1385
  * Create a promise and send an invocation call to the frontend
1321
1386
  *
@@ -1324,31 +1389,27 @@ var sendMessage$1 = function sendMessage(store) {
1324
1389
  *
1325
1390
  * @return {Promise}
1326
1391
  */
1327
-
1328
-
1329
- var sendInvocationCall = function sendInvocationCall(process, args) {
1330
- var promiseID = create();
1392
+ const sendInvocationCall = (process, args) => {
1393
+ const promiseID = create();
1331
1394
  outMsgQueue.push([protocol.INVOCATION, promiseID, process, args]);
1332
1395
  return get(promiseID);
1333
1396
  };
1334
1397
 
1335
- var connector;
1336
-
1337
- var connect = function connect() {
1338
- return new Promise(function ($return, $error) {
1339
- var putMessageConnection, postMessageConnection, fallbackConnection, realConnectionBucket, fallbackConnectionBucket;
1340
- putMessageConnection = connect$1();
1341
- postMessageConnection = connect$2();
1342
- fallbackConnection = fallback();
1343
- realConnectionBucket = [putMessageConnection, postMessageConnection];
1344
- fallbackConnectionBucket = realConnectionBucket.concat(fallbackConnection);
1345
- // Wait on the real communication and replace the connector with
1346
- Promise.race(realConnectionBucket).then(function (newConnector) {
1347
- connector = newConnector;
1348
- });
1349
- return Promise.resolve(Promise.race(fallbackConnectionBucket)).then($return, $error);
1398
+ let connector;
1399
+ const connect = async () => {
1400
+ const putMessageConnection = connect$1();
1401
+ const postMessageConnection = connect$2();
1402
+ const fallbackConnection = fallback();
1403
+ const realConnectionBucket = [putMessageConnection, postMessageConnection];
1404
+ const fallbackConnectionBucket = realConnectionBucket.concat(fallbackConnection);
1405
+
1406
+ // Wait on the real communication and replace the connector with
1407
+ Promise.race(realConnectionBucket).then(newConnector => {
1408
+ connector = newConnector;
1350
1409
  });
1410
+ return await Promise.race(fallbackConnectionBucket);
1351
1411
  };
1412
+
1352
1413
  /**
1353
1414
  * Send a message to the App
1354
1415
  *
@@ -1359,30 +1420,15 @@ var connect = function connect() {
1359
1420
  * @param {any} payload that will be attached to the message
1360
1421
  * @return {Promise<any>} result of the request
1361
1422
  */
1362
-
1363
- var sendMessage = function sendMessage(msg) {
1364
- var $args = arguments;
1365
- return new Promise(function ($return, $error) {
1366
- var sendFn, _len, payload, _key;
1367
-
1368
- if (!connector) {
1369
- connector = connect();
1370
- }
1371
-
1372
- return Promise.resolve(connector).then(function ($await_2) {
1373
- try {
1374
- sendFn = $await_2;
1375
-
1376
- for (_len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1377
- payload[_key - 1] = $args[_key];
1378
- }
1379
-
1380
- return $return(sendFn.apply(void 0, [msg].concat(payload)));
1381
- } catch ($boundEx) {
1382
- return $error($boundEx);
1383
- }
1384
- }, $error);
1385
- });
1423
+ const sendMessage = async function (msg) {
1424
+ if (!connector) {
1425
+ connector = connect();
1426
+ }
1427
+ const sendFn = await connector;
1428
+ for (var _len = arguments.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1429
+ payload[_key - 1] = arguments[_key];
1430
+ }
1431
+ return sendFn(msg, ...payload);
1386
1432
  };
1387
1433
 
1388
1434
  /**
@@ -1390,34 +1436,28 @@ var sendMessage = function sendMessage(msg) {
1390
1436
  *
1391
1437
  * @return {Promise<string>}
1392
1438
  */
1393
-
1394
- var getVersion = function getVersion() {
1395
- return new Promise(function ($return, $error) {
1396
- return $return(sendMessage(commands.version));
1397
- });
1439
+ const getVersion = async () => {
1440
+ return sendMessage(commands.version);
1398
1441
  };
1442
+
1399
1443
  /**
1400
1444
  * Check if app is native.
1401
1445
  *
1402
1446
  * @return {Promise<boolean>}
1403
1447
  */
1404
-
1405
- var isNative = function isNative() {
1406
- return new Promise(function ($return, $error) {
1407
- return $return(sendMessage(commands.native));
1408
- });
1448
+ const isNative = async () => {
1449
+ return sendMessage(commands.native);
1409
1450
  };
1451
+
1410
1452
  /**
1411
1453
  * Check if app is mobile.
1412
1454
  *
1413
1455
  * @return {Promise<boolean>}
1414
1456
  */
1415
-
1416
- var isMobile = function isMobile() {
1417
- return new Promise(function ($return, $error) {
1418
- return $return(sendMessage(commands.mobile));
1419
- });
1457
+ const isMobile = async () => {
1458
+ return sendMessage(commands.mobile);
1420
1459
  };
1460
+
1421
1461
  /**
1422
1462
  * Open a link through the app.
1423
1463
  *
@@ -1428,12 +1468,10 @@ var isMobile = function isMobile() {
1428
1468
  *
1429
1469
  * @return {Promise<any>}
1430
1470
  */
1431
-
1432
- var openLink$1 = function openLink(url) {
1433
- return new Promise(function ($return, $error) {
1434
- return $return(sendMessage(commands.openLink, url));
1435
- });
1471
+ const openLink$1 = async url => {
1472
+ return sendMessage(commands.openLink, url);
1436
1473
  };
1474
+
1437
1475
  /**
1438
1476
  * Open a link explicitly in the external browser.
1439
1477
  *
@@ -1441,14 +1479,12 @@ var openLink$1 = function openLink(url) {
1441
1479
  *
1442
1480
  * @return {Promise<any>}
1443
1481
  */
1444
-
1445
- var openLinkExternal$1 = function openLinkExternal(url) {
1446
- return new Promise(function ($return, $error) {
1447
- return $return(sendMessage(commands.openLink, url, {
1448
- inAppBrowser: false
1449
- }));
1482
+ const openLinkExternal$1 = async url => {
1483
+ return sendMessage(commands.openLink, url, {
1484
+ inAppBrowser: false
1450
1485
  });
1451
1486
  };
1487
+
1452
1488
  /**
1453
1489
  * Open a link explicitly in the internal browser.
1454
1490
  *
@@ -1456,14 +1492,12 @@ var openLinkExternal$1 = function openLinkExternal(url) {
1456
1492
  *
1457
1493
  * @return {Promise<any>}
1458
1494
  */
1459
-
1460
- var openLinkInternal$1 = function openLinkInternal(url) {
1461
- return new Promise(function ($return, $error) {
1462
- return $return(sendMessage(commands.openLink, url, {
1463
- inAppBrowser: true
1464
- }));
1495
+ const openLinkInternal$1 = async url => {
1496
+ return sendMessage(commands.openLink, url, {
1497
+ inAppBrowser: true
1465
1498
  });
1466
1499
  };
1500
+
1467
1501
  /**
1468
1502
  * Open a native file upload dialog on device which do not support it by default.
1469
1503
  *
@@ -1471,12 +1505,10 @@ var openLinkInternal$1 = function openLinkInternal(url) {
1471
1505
  *
1472
1506
  * @return {Promise<any>}
1473
1507
  */
1474
-
1475
- var openNativeFileDialog = function openNativeFileDialog() {
1476
- return new Promise(function ($return, $error) {
1477
- return $return(sendMessage(commands.nativeUpload));
1478
- });
1508
+ const openNativeFileDialog = async () => {
1509
+ return sendMessage(commands.nativeUpload);
1479
1510
  };
1511
+
1480
1512
  /**
1481
1513
  * Open a share dialog on native devices
1482
1514
  *
@@ -1492,51 +1524,37 @@ var openNativeFileDialog = function openNativeFileDialog() {
1492
1524
  *
1493
1525
  * @return {Promise<string>}
1494
1526
  */
1495
-
1496
- var openNativeShareDialog$1 = function openNativeShareDialog(content) {
1497
- return new Promise(function ($return, $error) {
1498
- return $return(sendMessage(commands.nativeShare, content));
1499
- });
1527
+ const openNativeShareDialog$1 = async content => {
1528
+ return sendMessage(commands.nativeShare, content);
1500
1529
  };
1530
+
1501
1531
  /**
1502
1532
  * Get the content languages configured for the branch.
1503
1533
  *
1504
1534
  * @return {Promise<Object>}
1505
1535
  */
1506
-
1507
- var getBranchLanguages$1 = function getBranchLanguages() {
1508
- return new Promise(function ($return, $error) {
1509
- return $return(sendMessage(commands.langInfos).then(function (res) {
1510
- return res.branchLanguages;
1511
- }));
1512
- });
1536
+ const getBranchLanguages$1 = async () => {
1537
+ return sendMessage(commands.langInfos).then(res => res.branchLanguages);
1513
1538
  };
1539
+
1514
1540
  /**
1515
1541
  * Get the default content language configured for the branch.
1516
1542
  *
1517
1543
  * @return {Promise<Object>}
1518
1544
  */
1519
-
1520
- var getBranchDefaultLanguage$1 = function getBranchDefaultLanguage() {
1521
- return new Promise(function ($return, $error) {
1522
- return $return(sendMessage(commands.langInfos).then(function (res) {
1523
- return res.branchDefaultLanguage;
1524
- }));
1525
- });
1545
+ const getBranchDefaultLanguage$1 = async () => {
1546
+ return sendMessage(commands.langInfos).then(res => res.branchDefaultLanguage);
1526
1547
  };
1548
+
1527
1549
  /**
1528
1550
  * Get all content languages supported by the Staffbase app.
1529
1551
  *
1530
1552
  * @return {Promise<Object>}
1531
1553
  */
1532
-
1533
- var getContentLanguages$1 = function getContentLanguages() {
1534
- return new Promise(function ($return, $error) {
1535
- return $return(sendMessage(commands.langInfos).then(function (res) {
1536
- return res.contentLanguages;
1537
- }));
1538
- });
1554
+ const getContentLanguages$1 = async () => {
1555
+ return sendMessage(commands.langInfos).then(res => res.contentLanguages);
1539
1556
  };
1557
+
1540
1558
  /**
1541
1559
  * Gets the chosen language from a given content object
1542
1560
  *
@@ -1548,89 +1566,53 @@ var getContentLanguages$1 = function getContentLanguages() {
1548
1566
  *
1549
1567
  * @return {Promise<string>}
1550
1568
  */
1551
-
1552
- var getPreferredContentLocale$1 = function getPreferredContentLocale(content) {
1553
- return new Promise(function ($return, $error) {
1554
- return $return(sendMessage(commands.prefContentLang, content));
1555
- });
1569
+ const getPreferredContentLocale$1 = async content => {
1570
+ return sendMessage(commands.prefContentLang, content);
1556
1571
  };
1557
1572
 
1558
- function compareVersions(v1, v2) {
1573
+ /**
1574
+ * Compare [semver](https://semver.org/) version strings to find greater, equal or lesser.
1575
+ * This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
1576
+ * @param v1 - First version to compare
1577
+ * @param v2 - Second version to compare
1578
+ * @returns Numeric value compatible with the [Array.sort(fn) interface](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters).
1579
+ */
1580
+ const compareVersions = (v1, v2) => {
1559
1581
  // validate input and split into segments
1560
1582
  const n1 = validateAndParse(v1);
1561
- const n2 = validateAndParse(v2); // pop off the patch
1562
-
1583
+ const n2 = validateAndParse(v2);
1584
+ // pop off the patch
1563
1585
  const p1 = n1.pop();
1564
- const p2 = n2.pop(); // validate numbers
1565
-
1586
+ const p2 = n2.pop();
1587
+ // validate numbers
1566
1588
  const r = compareSegments(n1, n2);
1567
- if (r !== 0) return r; // validate pre-release
1568
-
1589
+ if (r !== 0) return r;
1590
+ // validate pre-release
1569
1591
  if (p1 && p2) {
1570
1592
  return compareSegments(p1.split('.'), p2.split('.'));
1571
1593
  } else if (p1 || p2) {
1572
1594
  return p1 ? -1 : 1;
1573
1595
  }
1574
-
1575
1596
  return 0;
1576
- }
1577
- const validate = v => typeof v === 'string' && /^[v\d]/.test(v) && semver.test(v);
1578
- const compare = (v1, v2, operator) => {
1579
- // validate input operator
1580
- assertValidOperator(operator); // since result of compareVersions can only be -1 or 0 or 1
1581
- // a simple map can be used to replace switch
1582
-
1583
- const res = compareVersions(v1, v2);
1584
- return operatorResMap[operator].includes(res);
1585
1597
  };
1586
- const satisfies = (v, r) => {
1587
- // if no range operator then "="
1588
- const m = r.match(/^([<>=~^]+)/);
1589
- const op = m ? m[1] : '='; // if gt/lt/eq then operator compare
1590
-
1591
- if (op !== '^' && op !== '~') return compare(v, r, op); // else range of either "~" or "^" is assumed
1592
-
1593
- const [v1, v2, v3] = validateAndParse(v);
1594
- const [r1, r2, r3] = validateAndParse(r);
1595
- if (compareStrings(v1, r1) !== 0) return false;
1596
-
1597
- if (op === '^') {
1598
- return compareSegments([v2, v3], [r2, r3]) >= 0;
1599
- }
1600
-
1601
- if (compareStrings(v2, r2) !== 0) return false;
1602
- return compareStrings(v3, r3) >= 0;
1603
- }; // export CJS style for parity
1604
-
1605
- compareVersions.validate = validate;
1606
- compareVersions.compare = compare;
1607
- compareVersions.sastisfies = satisfies;
1608
1598
  const semver = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
1609
-
1610
- const validateAndParse = v => {
1611
- if (typeof v !== 'string') {
1599
+ const validateAndParse = version => {
1600
+ if (typeof version !== 'string') {
1612
1601
  throw new TypeError('Invalid argument expected string');
1613
1602
  }
1614
-
1615
- const match = v.match(semver);
1616
-
1603
+ const match = version.match(semver);
1617
1604
  if (!match) {
1618
- throw new Error(`Invalid argument not valid semver ('${v}' received)`);
1605
+ throw new Error(`Invalid argument not valid semver ('${version}' received)`);
1619
1606
  }
1620
-
1621
1607
  match.shift();
1622
1608
  return match;
1623
1609
  };
1624
-
1625
1610
  const isWildcard = s => s === '*' || s === 'x' || s === 'X';
1626
-
1627
1611
  const tryParse = v => {
1628
1612
  const n = parseInt(v, 10);
1629
1613
  return isNaN(n) ? v : n;
1630
1614
  };
1631
-
1632
1615
  const forceType = (a, b) => typeof a !== typeof b ? [String(a), String(b)] : [a, b];
1633
-
1634
1616
  const compareStrings = (a, b) => {
1635
1617
  if (isWildcard(a) || isWildcard(b)) return 0;
1636
1618
  const [ap, bp] = forceType(tryParse(a), tryParse(b));
@@ -1638,152 +1620,97 @@ const compareStrings = (a, b) => {
1638
1620
  if (ap < bp) return -1;
1639
1621
  return 0;
1640
1622
  };
1641
-
1642
1623
  const compareSegments = (a, b) => {
1643
1624
  for (let i = 0; i < Math.max(a.length, b.length); i++) {
1644
- const r = compareStrings(a[i] || 0, b[i] || 0);
1625
+ const r = compareStrings(a[i] || '0', b[i] || '0');
1645
1626
  if (r !== 0) return r;
1646
1627
  }
1647
-
1648
1628
  return 0;
1649
1629
  };
1650
1630
 
1651
- const operatorResMap = {
1652
- '>': [1],
1653
- '>=': [0, 1],
1654
- '=': [0],
1655
- '<=': [-1, 0],
1656
- '<': [-1]
1657
- };
1658
- const allowedOperators = Object.keys(operatorResMap);
1659
-
1660
- const assertValidOperator = op => {
1661
- if (typeof op !== 'string') {
1662
- throw new TypeError(`Invalid operator type, expected string but got ${typeof op}`);
1663
- }
1664
-
1665
- if (allowedOperators.indexOf(op) === -1) {
1666
- throw new Error(`Invalid operator, expected one of ${allowedOperators.join('|')}`);
1667
- }
1668
- };
1669
-
1631
+ /* eslint-disable no-unused-vars */
1670
1632
  /**
1671
1633
  * Check if device is using ios.
1672
1634
  *
1673
1635
  * @return {Promise<boolean>}
1674
1636
  */
1675
-
1676
- var isIos = function isIos() {
1677
- return new Promise(function ($return, $error) {
1678
- return $return(sendMessage(commands.ios));
1679
- });
1637
+ const isIos = async () => {
1638
+ return sendMessage(commands.ios);
1680
1639
  };
1640
+
1681
1641
  /**
1682
1642
  * Check if device is using android.
1683
1643
  *
1684
1644
  * @return {Promise<boolean>}
1685
1645
  */
1686
-
1687
- var isAndroid = function isAndroid() {
1688
- return new Promise(function ($return, $error) {
1689
- return $return(sendMessage(commands.android));
1690
- });
1646
+ const isAndroid = async () => {
1647
+ return sendMessage(commands.android);
1691
1648
  };
1649
+
1692
1650
  /**
1693
1651
  * Check if device is able to perform a download.
1694
1652
  *
1695
1653
  * @return {Promise<boolean>}
1696
1654
  */
1655
+ const canDownload = async () => {
1656
+ let [native, version, ios] = await Promise.all([isNative(), getVersion(), isIos()]);
1697
1657
 
1698
- var canDownload = function canDownload() {
1699
- return new Promise(function ($return, $error) {
1700
- var _await$Promise$all, _await$Promise$all2, native, version, ios, dashIndex;
1701
-
1702
- return Promise.resolve(Promise.all([isNative(), getVersion(), isIos()])).then(function ($await_1) {
1703
- try {
1704
- _await$Promise$all = $await_1, _await$Promise$all2 = _slicedToArray(_await$Promise$all, 3), native = _await$Promise$all2[0], version = _await$Promise$all2[1], ios = _await$Promise$all2[2];
1705
- dashIndex = version.indexOf('-');
1706
- version = version.substring(0, dashIndex != -1 ? dashIndex : version.length); // mobile ios devices can not download with an app version less than 3.5
1707
- // but apps below 3.5 don't have the platform information from the frontend available
1708
- // so we disable download for all native ios devices under these conditions
1658
+ // support any development versions like X.Y-dev for compare versions
1659
+ const dashIndex = version.indexOf('-');
1660
+ version = version.substring(0, dashIndex != -1 ? dashIndex : version.length);
1709
1661
 
1710
- return $return(!(compareVersions(version, '3.5') < 0 && native && ios));
1711
- } catch ($boundEx) {
1712
- return $error($boundEx);
1713
- }
1714
- }, $error);
1715
- });
1662
+ // mobile ios devices can not download with an app version less than 3.5
1663
+ // but apps below 3.5 don't have the platform information from the frontend available
1664
+ // so we disable download for all native ios devices under these conditions
1665
+ return !(compareVersions(version, '3.5') < 0 && native && ios);
1716
1666
  };
1717
1667
 
1718
1668
  /**
1719
1669
  * Interface exports
1720
1670
  */
1671
+
1721
1672
  /**
1722
1673
  * Check if device is able to perform a download.
1723
1674
  * @function
1724
1675
  * @return {Promise<boolean>}
1725
1676
  */
1677
+ const deviceCanDownload = async () => canDownload();
1726
1678
 
1727
- var deviceCanDownload = function deviceCanDownload() {
1728
- return new Promise(function ($return, $error) {
1729
- return $return(canDownload());
1730
- });
1731
- };
1732
1679
  /**
1733
1680
  * Check if device is using ios.
1734
1681
  * @function
1735
1682
  * @return {Promise<boolean>}
1736
1683
  */
1684
+ const isIosDevice = async () => isIos();
1737
1685
 
1738
- var isIosDevice = function isIosDevice() {
1739
- return new Promise(function ($return, $error) {
1740
- return $return(isIos());
1741
- });
1742
- };
1743
1686
  /**
1744
1687
  * Check if device is using android.
1745
1688
  * @function
1746
1689
  * @return {Promise<boolean>}
1747
1690
  */
1691
+ const isAndroidDevice = async () => isAndroid();
1748
1692
 
1749
- var isAndroidDevice = function isAndroidDevice() {
1750
- return new Promise(function ($return, $error) {
1751
- return $return(isAndroid());
1752
- });
1753
- };
1754
1693
  /**
1755
1694
  * Get the version of the Staffbase App.
1756
1695
  * @function
1757
1696
  * @return {Promise<string>}
1758
1697
  */
1698
+ const getAppVersion = async () => getVersion();
1759
1699
 
1760
- var getAppVersion = function getAppVersion() {
1761
- return new Promise(function ($return, $error) {
1762
- return $return(getVersion());
1763
- });
1764
- };
1765
1700
  /**
1766
1701
  * Check if app is native.
1767
1702
  * @function
1768
1703
  * @return {Promise<boolean>}
1769
1704
  */
1705
+ const isNativeApp = async () => isNative();
1770
1706
 
1771
- var isNativeApp = function isNativeApp() {
1772
- return new Promise(function ($return, $error) {
1773
- return $return(isNative());
1774
- });
1775
- };
1776
1707
  /**
1777
1708
  * Check if app is mobile.
1778
1709
  * @function
1779
1710
  * @return {Promise<boolean>}
1780
1711
  */
1712
+ const isMobileApp = async () => isMobile();
1781
1713
 
1782
- var isMobileApp = function isMobileApp() {
1783
- return new Promise(function ($return, $error) {
1784
- return $return(isMobile());
1785
- });
1786
- };
1787
1714
  /**
1788
1715
  * Open a link through the app.
1789
1716
  *
@@ -1794,12 +1721,8 @@ var isMobileApp = function isMobileApp() {
1794
1721
  * @function
1795
1722
  * @return {Promise<any>}
1796
1723
  */
1724
+ const openLink = async url => openLink$1(url);
1797
1725
 
1798
- var openLink = function openLink(url) {
1799
- return new Promise(function ($return, $error) {
1800
- return $return(openLink$1(url));
1801
- });
1802
- };
1803
1726
  /**
1804
1727
  * Open a link explicitly in the external browser.
1805
1728
  *
@@ -1807,12 +1730,8 @@ var openLink = function openLink(url) {
1807
1730
  * @function
1808
1731
  * @return {Promise<any>}
1809
1732
  */
1733
+ const openLinkExternal = async url => openLinkExternal$1(url);
1810
1734
 
1811
- var openLinkExternal = function openLinkExternal(url) {
1812
- return new Promise(function ($return, $error) {
1813
- return $return(openLinkExternal$1(url));
1814
- });
1815
- };
1816
1735
  /**
1817
1736
  * Open a link explicitly in the internal browser.
1818
1737
  *
@@ -1820,45 +1739,29 @@ var openLinkExternal = function openLinkExternal(url) {
1820
1739
  * @function
1821
1740
  * @return {Promise<any>}
1822
1741
  */
1742
+ const openLinkInternal = async url => openLinkInternal$1(url);
1823
1743
 
1824
- var openLinkInternal = function openLinkInternal(url) {
1825
- return new Promise(function ($return, $error) {
1826
- return $return(openLinkInternal$1(url));
1827
- });
1828
- };
1829
1744
  /**
1830
1745
  * Get all enabled content languages configured in the app.
1831
1746
  * @function
1832
1747
  * @return {Promise<any>}
1833
1748
  */
1749
+ const getBranchLanguages = async () => getBranchLanguages$1();
1834
1750
 
1835
- var getBranchLanguages = function getBranchLanguages() {
1836
- return new Promise(function ($return, $error) {
1837
- return $return(getBranchLanguages$1());
1838
- });
1839
- };
1840
1751
  /**
1841
1752
  * Get the default content language configured in the app.
1842
1753
  * @function
1843
1754
  * @return {Promise<any>}
1844
1755
  */
1756
+ const getBranchDefaultLanguage = async () => getBranchDefaultLanguage$1();
1845
1757
 
1846
- var getBranchDefaultLanguage = function getBranchDefaultLanguage() {
1847
- return new Promise(function ($return, $error) {
1848
- return $return(getBranchDefaultLanguage$1());
1849
- });
1850
- };
1851
1758
  /**
1852
1759
  * Get all content languages supported by the app.
1853
1760
  * @function
1854
1761
  * @return {Promise<any>}
1855
1762
  */
1763
+ const getContentLanguages = async () => getContentLanguages$1();
1856
1764
 
1857
- var getContentLanguages = function getContentLanguages() {
1858
- return new Promise(function ($return, $error) {
1859
- return $return(getContentLanguages$1());
1860
- });
1861
- };
1862
1765
  /**
1863
1766
  * Gets the chosen language from a given content object
1864
1767
  *
@@ -1870,12 +1773,8 @@ var getContentLanguages = function getContentLanguages() {
1870
1773
  * @function
1871
1774
  * @return {Promise<string>}
1872
1775
  */
1776
+ const getPreferredContentLocale = async content => getPreferredContentLocale$1(content);
1873
1777
 
1874
- var getPreferredContentLocale = function getPreferredContentLocale(content) {
1875
- return new Promise(function ($return, $error) {
1876
- return $return(getPreferredContentLocale$1(content));
1877
- });
1878
- };
1879
1778
  /**
1880
1779
  * Open a share dialog on native devices
1881
1780
  *
@@ -1891,13 +1790,8 @@ var getPreferredContentLocale = function getPreferredContentLocale(content) {
1891
1790
  *
1892
1791
  * @return {Promise<string>}
1893
1792
  */
1894
-
1895
- var openNativeShareDialog = function openNativeShareDialog(content) {
1896
- return new Promise(function ($return, $error) {
1897
- return $return(openNativeShareDialog$1(content));
1898
- });
1899
- };
1900
- /* experimental */
1793
+ const openNativeShareDialog = async content => openNativeShareDialog$1(content);
1794
+ /* experimental */
1901
1795
 
1902
1796
  exports.deviceCanDownload = deviceCanDownload;
1903
1797
  exports.getAppVersion = getAppVersion;