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