@staffbase/plugins-client-sdk 1.2.3 → 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.2
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,13 +347,13 @@ 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 = {
464
359
  af: {
@@ -895,29 +790,28 @@ var locales = {
895
790
  *
896
791
  * @return {string} the first part of the locale
897
792
  */
898
- var normalize = function normalize(locale) {
793
+ const normalize = locale => {
899
794
  locale = locale && locale.split(/-|_/)[0] || locale; // use only first part
900
795
 
901
796
  if (['nb', 'nn'].indexOf(locale) !== -1) {
902
797
  // fix Norwegian language code to conform with our non-standard stuff
903
798
  locale = 'no';
904
799
  }
905
-
906
800
  if (locale === 'iw') {
907
801
  // fix legacy Hebrew language code from our backend to conform with our frontend
908
802
  locale = 'he';
909
803
  }
910
-
911
804
  return locale;
912
805
  };
913
806
 
914
807
  /**
915
808
  * Fallbacks for all sdk commands
916
809
  */
917
- var userAgent = navigator.userAgent || navigator.vendor || window.opera || '';
918
- var currentLanguage = normalize(window && window.navigator.language); // initialize Staffbase/platform namespace for ios frontend js code injection
919
- // 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);
920
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
921
815
  if (typeof window !== 'undefined') {
922
816
  window.Staffbase = window.Staffbase || {};
923
817
  window.Staffbase.platform = window.Staffbase.platform || {
@@ -926,81 +820,80 @@ if (typeof window !== 'undefined') {
926
820
  native: false
927
821
  };
928
822
  }
823
+
929
824
  /**
930
825
  * Get the current Staffbase app version
931
826
  *
932
827
  * @return {String} version
933
828
  */
934
-
935
-
936
- var getVersion$1 = function getVersion() {
829
+ const getVersion$1 = () => {
937
830
  return window.Staffbase.platform.version;
938
831
  };
832
+
939
833
  /**
940
834
  * Are we running in a native app
941
835
  *
942
836
  * works only for ios or old initial native data
943
837
  * @return {Boolean}
944
838
  */
945
-
946
- var isNative$1 = function isNative() {
947
- var safari = /safari/i.test(userAgent);
839
+ const isNative$1 = () => {
840
+ const safari = /safari/i.test(userAgent);
948
841
  return window.Staffbase.platform.native === 'android' || window.Staffbase.platform.native === 'ios' || !safari && isIos$1();
949
842
  };
843
+
950
844
  /**
951
845
  * Are we running on a mobile device
952
846
  *
953
847
  * @return {Boolean}
954
848
  */
955
-
956
- var isMobile$1 = function isMobile() {
849
+ const isMobile$1 = () => {
957
850
  return window.Staffbase.platform.mobile;
958
851
  };
852
+
959
853
  /**
960
854
  * Are we running on android
961
855
  *
962
856
  * @return {Boolean}
963
857
  */
964
-
965
- var isAndroid$1 = function isAndroid() {
858
+ const isAndroid$1 = () => {
966
859
  return window.Staffbase.platform.native === 'android' || /Android/i.test(userAgent);
967
860
  };
861
+
968
862
  /**
969
863
  * Are we running on ios
970
864
  *
971
865
  * @return {Boolean}
972
866
  */
973
-
974
- var isIos$1 = function isIos() {
867
+ const isIos$1 = () => {
975
868
  return window.Staffbase.platform.native === 'ios' || /iPhone|iPad|iPod/i.test(userAgent);
976
869
  };
870
+
977
871
  /**
978
872
  * Open an external link
979
873
  *
980
874
  * @param {String} url address
981
875
  */
982
-
983
- var openLink$2 = function openLink(url) {
876
+ const openLink$2 = url => {
984
877
  window.open(url, '_blank');
985
878
  };
879
+
986
880
  /**
987
881
  * Handler for unpossible functions
988
882
  *
989
883
  * @param {String} cmd command name
990
884
  */
991
-
992
- var unSupported = function unSupported(cmd) {
885
+ const unSupported = cmd => {
993
886
  // nothing we can do here
994
887
  return;
995
888
  };
889
+
996
890
  /**
997
891
  * Get extensive locale information.
998
892
  *
999
893
  * @return {Object} containing various language informations
1000
894
  */
1001
-
1002
- var langInfos = function langInfos() {
1003
- var branchDefaultLanguage = getBranchDefaultLanguage$2();
895
+ const langInfos = () => {
896
+ const branchDefaultLanguage = getBranchDefaultLanguage$2();
1004
897
  return {
1005
898
  contentLanguage: branchDefaultLanguage,
1006
899
  branchLanguages: locales,
@@ -1009,15 +902,16 @@ var langInfos = function langInfos() {
1009
902
  contentLanguages: locales
1010
903
  };
1011
904
  };
905
+
1012
906
  /**
1013
907
  * Get the default language object
1014
908
  *
1015
909
  * @return {Object} the language object
1016
910
  */
1017
-
1018
- var getBranchDefaultLanguage$2 = function getBranchDefaultLanguage() {
911
+ const getBranchDefaultLanguage$2 = () => {
1019
912
  return locales[currentLanguage] || locales.en;
1020
913
  };
914
+
1021
915
  /**
1022
916
  * Gets the chosen language from a given content object
1023
917
  *
@@ -1025,28 +919,24 @@ var getBranchDefaultLanguage$2 = function getBranchDefaultLanguage() {
1025
919
  *
1026
920
  * @return {string}
1027
921
  */
1028
-
1029
- var getPreferredContentLocale$2 = function getPreferredContentLocale(content) {
1030
- var locale = getBranchDefaultLanguage$2().locale;
1031
-
922
+ const getPreferredContentLocale$2 = content => {
923
+ const locale = getBranchDefaultLanguage$2().locale;
1032
924
  if (!content) {
1033
925
  return locale;
1034
926
  }
1035
-
1036
927
  if (Array.isArray(content)) {
1037
- var index = content.indexOf(locale);
928
+ const index = content.indexOf(locale);
1038
929
  return content[index] || content[0];
1039
930
  } else {
1040
- var keys = Object.keys(content);
1041
-
1042
- var _index = keys.indexOf(locale);
1043
-
1044
- return keys[_index] || keys[0];
931
+ const keys = Object.keys(content);
932
+ const index = keys.indexOf(locale);
933
+ return keys[index] || keys[0];
1045
934
  }
1046
935
  };
1047
936
 
1048
- var connection$2 = null;
1049
- var fallbackKickIn = 500;
937
+ let connection$2 = null;
938
+ const fallbackKickIn = 500;
939
+
1050
940
  /**
1051
941
  * Fake connection to the Staffbase App after a period of time.
1052
942
  *
@@ -1054,19 +944,18 @@ var fallbackKickIn = 500;
1054
944
  * after the time specified in fallbackKickIn runs out.
1055
945
  * @return {Promise<function>} An appropriate send function
1056
946
  */
1057
-
1058
- var fallback = (function () {
947
+ var fallback = (() => {
1059
948
  if (connection$2) {
1060
949
  return connection$2;
1061
950
  }
1062
-
1063
- connection$2 = new Promise(function (resolve) {
951
+ connection$2 = new Promise(resolve => {
1064
952
  setTimeout(function () {
1065
953
  resolve(sendMessage$3);
1066
954
  }, fallbackKickIn);
1067
955
  });
1068
956
  return connection$2;
1069
957
  });
958
+
1070
959
  /**
1071
960
  * Send a SDK command to the Staffbase App.
1072
961
  *
@@ -1076,56 +965,38 @@ var fallback = (function () {
1076
965
  * @return {Promise<any>} which awaits the response of the Staffbase App
1077
966
  * @throws {Error} on commands not supported by protocol
1078
967
  */
1079
-
1080
- var sendMessage$3 = function sendMessage(cmd) {
1081
- var $args = arguments;
1082
- return new Promise(function ($return, $error) {
1083
- for (var _len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1084
- payload[_key - 1] = $args[_key];
1085
- }
1086
-
1087
- switch (cmd) {
1088
- case commands.version:
1089
- return $return(getVersion$1());
1090
-
1091
- case commands.native:
1092
- return $return(isNative$1());
1093
-
1094
- case commands.mobile:
1095
- return $return(isMobile$1());
1096
-
1097
- case commands.ios:
1098
- return $return(isIos$1());
1099
-
1100
- case commands.android:
1101
- return $return(isAndroid$1());
1102
-
1103
- case commands.openLink:
1104
- return $return(openLink$2.apply(null, payload));
1105
-
1106
- case commands.langInfos:
1107
- return $return(langInfos());
1108
-
1109
- case commands.branchDefaultLang:
1110
- return $return(getBranchDefaultLanguage$2());
1111
-
1112
- case commands.prefContentLang:
1113
- return $return(getPreferredContentLocale$2.apply(null, payload));
1114
-
1115
- case commands.nativeUpload:
1116
- case commands.nativeShare:
1117
- return $return(unSupported());
1118
-
1119
- default:
1120
- // should actually never ever happen
1121
- return $error(new Error('Command ' + cmd + ' not supported by driver'));
1122
- }
1123
-
1124
- return $return();
1125
- });
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
+ }
1126
998
  };
1127
999
 
1128
- var _invocationMapping;
1129
1000
  /**
1130
1001
  * Postmessage protocol (3.6)
1131
1002
  */
@@ -1138,33 +1009,39 @@ var protocol = {
1138
1009
  INVOCATION: 'INVOCATION',
1139
1010
  // send this to call a function in the frontend
1140
1011
  ERROR: 'ERROR' // receive this when something goes wrong
1012
+ };
1141
1013
 
1014
+ const invocationMapping = {
1015
+ [commands.openLink]: 'openLink',
1016
+ [commands.nativeUpload]: 'nativeFileUpload',
1017
+ [commands.nativeShare]: 'nativeShareDialog',
1018
+ [commands.langInfos]: 'getPluginLanguageInfo',
1019
+ [commands.prefContentLang]: 'getPreferredContentLocale'
1142
1020
  };
1143
- 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);
1144
1021
 
1145
1022
  /**
1146
1023
  * Generates an unique id of 4 alpha numerical chars
1147
1024
  *
1148
1025
  * @return {string} unique id
1149
1026
  */
1150
- var genID = function genID() {
1027
+ const genID = () => {
1151
1028
  return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
1152
1029
  };
1153
1030
 
1154
1031
  /**
1155
1032
  * @type {Object.<string, {resolve: function, reject: function, promise: Promise}>}
1156
1033
  */
1034
+ let promiseMap = {};
1157
1035
 
1158
- var promiseMap = {};
1159
1036
  /**
1160
1037
  * Create an info object for a new promise in the map.
1161
1038
  *
1162
1039
  * @return {string} id of the promise
1163
1040
  */
1164
-
1165
1041
  function createPromiseObject() {
1166
- var id = genID(); // When the id is already used, it invokes the function again
1042
+ const id = genID();
1167
1043
 
1044
+ // When the id is already used, it invokes the function again
1168
1045
  if (id in promiseMap) return createPromiseObject();
1169
1046
  promiseMap[id] = {
1170
1047
  resolve: null,
@@ -1173,6 +1050,7 @@ function createPromiseObject() {
1173
1050
  };
1174
1051
  return id;
1175
1052
  }
1053
+
1176
1054
  /**
1177
1055
  * Create a promise and return it's id.
1178
1056
  *
@@ -1180,17 +1058,16 @@ function createPromiseObject() {
1180
1058
  *
1181
1059
  * @return {string} id of the promise
1182
1060
  */
1183
-
1184
-
1185
- var create = function create() {
1186
- var id = createPromiseObject();
1187
- var p = new Promise(function (resolve, reject) {
1061
+ const create = () => {
1062
+ const id = createPromiseObject();
1063
+ const p = new Promise(function (resolve, reject) {
1188
1064
  promiseMap[id].resolve = resolve;
1189
1065
  promiseMap[id].reject = reject;
1190
1066
  });
1191
1067
  promiseMap[id].promise = p;
1192
1068
  return id;
1193
1069
  };
1070
+
1194
1071
  /**
1195
1072
  * Resolve a promise by id.
1196
1073
  *
@@ -1199,12 +1076,12 @@ var create = function create() {
1199
1076
  *
1200
1077
  * @throws {Error} on unknown id
1201
1078
  */
1202
-
1203
- var resolve = function resolve(id, msg) {
1079
+ const resolve = (id, msg) => {
1204
1080
  if (!(id in promiseMap)) throw new Error('Tried to resolve an unknown [' + id + '] promise.');
1205
1081
  promiseMap[id].resolve(msg);
1206
1082
  delete promiseMap[id];
1207
1083
  };
1084
+
1208
1085
  /**
1209
1086
  * Reject a promise by id.
1210
1087
  *
@@ -1212,12 +1089,12 @@ var resolve = function resolve(id, msg) {
1212
1089
  * @param {any} err the error which will will be passed to reject
1213
1090
  * @throws {Error} on unknown id
1214
1091
  */
1215
-
1216
- var reject = function reject(id, err) {
1092
+ const reject = (id, err) => {
1217
1093
  if (!(id in promiseMap)) throw new Error('Tried to reject an unknown [' + id + '] promise.');
1218
1094
  promiseMap[id].reject(err);
1219
1095
  delete promiseMap[id];
1220
1096
  };
1097
+
1221
1098
  /**
1222
1099
  * Get a promise by id.
1223
1100
  *
@@ -1225,8 +1102,7 @@ var reject = function reject(id, err) {
1225
1102
  * @return {Promise} the promise identified by id
1226
1103
  * @throws {Error} on unknown id
1227
1104
  */
1228
-
1229
- var get = function get(id) {
1105
+ const get = id => {
1230
1106
  if (!(id in promiseMap)) throw new Error('Tried to get an unknown [' + id + '] promise.');
1231
1107
  return promiseMap[id].promise;
1232
1108
  };
@@ -1249,10 +1125,11 @@ var get = function get(id) {
1249
1125
  * @static
1250
1126
  * @return {StaticValueStore}
1251
1127
  */
1252
-
1253
- var dataStore$1 = function dataStore(_ref) {
1254
- var platform = _ref.platform,
1255
- language = _ref.language;
1128
+ const dataStore$1 = _ref => {
1129
+ let {
1130
+ platform,
1131
+ language
1132
+ } = _ref;
1256
1133
  return {
1257
1134
  mobile: platform.mobile,
1258
1135
  version: platform.version,
@@ -1263,22 +1140,20 @@ var dataStore$1 = function dataStore(_ref) {
1263
1140
  branchDefaultLanguage: language.branchDefaultLanguage
1264
1141
  };
1265
1142
  };
1143
+ let connection$1 = null;
1144
+ const targetOrigin = '*';
1266
1145
 
1267
- var connection$1 = null;
1268
- var targetOrigin = '*';
1269
1146
  /**
1270
1147
  * Connect to the Staffbase App.
1271
1148
  *
1272
1149
  * Create a connection to a Staffbase app 3.6
1273
1150
  * @return {Promise<function>} An appropriate send function
1274
1151
  */
1275
-
1276
- var connect$2 = function connect() {
1152
+ const connect$2 = () => {
1277
1153
  if (connection$1) {
1278
1154
  return connection$1;
1279
1155
  }
1280
-
1281
- var connectId = create();
1156
+ const connectId = create();
1282
1157
  connection$1 = get(connectId).then(function (payload) {
1283
1158
  return sendMessage$2(dataStore$1(payload));
1284
1159
  });
@@ -1286,53 +1161,46 @@ var connect$2 = function connect() {
1286
1161
  window.parent.postMessage([protocol.HELLO, connectId, []], targetOrigin);
1287
1162
  return connection$1;
1288
1163
  };
1164
+
1289
1165
  /**
1290
1166
  * Handler that receives a message from the Staffbase app
1291
1167
  *
1292
1168
  * Can be attached to window.onPostMessage
1293
1169
  * @param {MessageEvent} evt onPostMessage event result
1294
1170
  */
1171
+ const receiveMessage = async evt => {
1172
+ let type;
1173
+ let id;
1174
+ let payload;
1295
1175
 
1296
- var receiveMessage = function receiveMessage(evt) {
1297
- return new Promise(function ($return, $error) {
1298
- var type;
1299
- var id;
1300
- var payload; // safe destructure
1301
-
1302
- try {
1303
- var _evt$data = _slicedToArray(evt.data, 3);
1304
-
1305
- type = _evt$data[0];
1306
- id = _evt$data[1];
1307
- payload = _evt$data[2];
1308
- } 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:
1309
1196
  // even thought catch-ignore is a bad style
1310
1197
  // there may be other participants listening
1311
1198
  // to messages in a different format so we
1312
1199
  // silently ignore here
1313
- return $return();
1314
- }
1315
-
1316
- switch (type) {
1317
- case protocol.SUCCESS:
1318
- resolve(id, payload);
1319
- break;
1320
-
1321
- case protocol.ERROR:
1322
- reject(id, payload);
1323
- break;
1324
-
1325
- default:
1326
- // even thought catch-ignore is a bad style
1327
- // there may be other participants listening
1328
- // to messages in a different format so we
1329
- // silently ignore here
1330
- return $return();
1331
- }
1332
-
1333
- return $return();
1334
- });
1200
+ return;
1201
+ }
1335
1202
  };
1203
+
1336
1204
  /**
1337
1205
  * Send a SDK command to the Staffbase App.
1338
1206
  *
@@ -1343,40 +1211,29 @@ var receiveMessage = function receiveMessage(evt) {
1343
1211
  * @return {Promise<any>} which awaits the response of the Staffbase App
1344
1212
  * @throws {Error} on commands not supported by protocol
1345
1213
  */
1346
-
1347
-
1348
- var sendMessage$2 = function sendMessage(store) {
1349
- return function (cmd) {
1350
- var $args = arguments;
1351
- return new Promise(function ($return, $error) {
1352
- switch (cmd) {
1353
- case commands.version:
1354
- case commands.native:
1355
- case commands.mobile:
1356
- case commands.ios:
1357
- case commands.android:
1358
- case commands.branchDefaultLang:
1359
- return $return(store[reversedCommands[cmd]]);
1360
-
1361
- case commands.langInfos:
1362
- case commands.openLink:
1363
- case commands.nativeUpload:
1364
- case commands.nativeShare:
1365
- case commands.prefContentLang:
1366
- for (var _len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1367
- payload[_key - 1] = $args[_key];
1368
- }
1369
-
1370
- return $return(sendInvocationCall$1(create())(invocationMapping[cmd], payload));
1371
-
1372
- default:
1373
- 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];
1374
1230
  }
1375
-
1376
- return $return();
1377
- });
1378
- };
1231
+ return sendInvocationCall$1(create())(invocationMapping[cmd], payload);
1232
+ default:
1233
+ throw new Error('Command ' + cmd + ' not supported by driver');
1234
+ }
1379
1235
  };
1236
+
1380
1237
  /**
1381
1238
  * Create a promise and send an invocation call to the frontend
1382
1239
  *
@@ -1386,17 +1243,14 @@ var sendMessage$2 = function sendMessage(store) {
1386
1243
  *
1387
1244
  * @return {Promise}
1388
1245
  */
1389
-
1390
-
1391
- var sendInvocationCall$1 = function sendInvocationCall(promiseID) {
1392
- return function (process, args) {
1393
- window.parent.postMessage([protocol.INVOCATION, promiseID, process, args], targetOrigin);
1394
- return get(promiseID);
1395
- };
1246
+ const sendInvocationCall$1 = promiseID => (process, args) => {
1247
+ window.parent.postMessage([protocol.INVOCATION, promiseID, process, args], targetOrigin);
1248
+ return get(promiseID);
1396
1249
  };
1397
1250
 
1398
- var connection = null;
1399
- var outMsgQueue = [];
1251
+ let connection = null;
1252
+ let outMsgQueue = [];
1253
+
1400
1254
  /**
1401
1255
  * Simple store solution to make the initial data available
1402
1256
  * as static values
@@ -1405,10 +1259,11 @@ var outMsgQueue = [];
1405
1259
  * @static
1406
1260
  * @return {StaticValueStore}
1407
1261
  */
1408
-
1409
- var dataStore = function dataStore(_ref) {
1410
- var platform = _ref.platform,
1411
- language = _ref.language;
1262
+ const dataStore = _ref => {
1263
+ let {
1264
+ platform,
1265
+ language
1266
+ } = _ref;
1412
1267
  return {
1413
1268
  mobile: platform.mobile,
1414
1269
  version: platform.version,
@@ -1419,31 +1274,30 @@ var dataStore = function dataStore(_ref) {
1419
1274
  branchDefaultLang: language.branchDefaultLanguage
1420
1275
  };
1421
1276
  };
1422
-
1423
1277
  window.Staffbase = window.Staffbase || {};
1424
1278
  window.Staffbase.plugins = {
1425
1279
  getMessages: multiMessageProvider,
1426
1280
  putMessage: singleMessageReceiver
1427
1281
  };
1282
+
1428
1283
  /**
1429
1284
  * Connect to the Staffbase App.
1430
1285
  *
1431
1286
  * Create a connection to a Staffbase app 3.6 from a native tab
1432
1287
  * @return {Promise<function>} An appropriate send function
1433
1288
  */
1434
-
1435
- var connect$1 = function connect() {
1289
+ const connect$1 = () => {
1436
1290
  if (connection) {
1437
1291
  return connection;
1438
1292
  }
1439
-
1440
- var connectId = create();
1293
+ const connectId = create();
1441
1294
  connection = get(connectId).then(function (payload) {
1442
1295
  return sendMessage$1(dataStore(payload));
1443
1296
  });
1444
1297
  outMsgQueue.push([protocol.HELLO, connectId, []]);
1445
1298
  return connection;
1446
1299
  };
1300
+
1447
1301
  /**
1448
1302
  * A function which returns an array of messages
1449
1303
  *
@@ -1452,44 +1306,34 @@ var connect$1 = function connect() {
1452
1306
  *
1453
1307
  * @return {Array} ordered list of messages
1454
1308
  */
1455
-
1456
1309
  function multiMessageProvider() {
1457
- var queueRef = outMsgQueue;
1458
-
1310
+ const queueRef = outMsgQueue;
1459
1311
  if (queueRef.length) ;
1460
-
1461
1312
  outMsgQueue = [];
1462
1313
  return queueRef;
1463
1314
  }
1315
+
1464
1316
  /**
1465
1317
  * A function which can receive a single message.
1466
1318
  *
1467
1319
  * Can be attached to window.onPostMessage
1468
1320
  * @param {Array} msg Staffbase 3.6 message
1469
1321
  */
1470
-
1471
-
1472
1322
  function singleMessageReceiver(msg) {
1473
- var type;
1474
- var id;
1475
- var payload; // safe destructure
1323
+ let type;
1324
+ let id;
1325
+ let payload;
1476
1326
 
1327
+ // safe destructure
1477
1328
  try {
1478
- var _msg = _slicedToArray(msg, 3);
1479
-
1480
- type = _msg[0];
1481
- id = _msg[1];
1482
- payload = _msg[2];
1483
-
1329
+ [type, id, payload] = msg;
1484
1330
  switch (type) {
1485
1331
  case protocol.SUCCESS:
1486
1332
  resolve(id, payload);
1487
1333
  break;
1488
-
1489
1334
  case protocol.ERROR:
1490
1335
  reject(id, payload);
1491
1336
  break;
1492
-
1493
1337
  default:
1494
1338
  // even thought catch-ignore is a bad style
1495
1339
  // there may be other participants listening
@@ -1505,6 +1349,7 @@ function singleMessageReceiver(msg) {
1505
1349
  return;
1506
1350
  }
1507
1351
  }
1352
+
1508
1353
  /**
1509
1354
  * Send a SDK command to the Staffbase App.
1510
1355
  *
@@ -1515,37 +1360,27 @@ function singleMessageReceiver(msg) {
1515
1360
  * @return {Promise<any>} which awaits the response of the Staffbase App
1516
1361
  * @throws {Error} on commands not supported by protocol
1517
1362
  */
1518
-
1519
- var sendMessage$1 = function sendMessage(store) {
1520
- return function (cmd) {
1521
- var $args = arguments;
1522
- return new Promise(function ($return, $error) {
1523
- switch (cmd) {
1524
- case commands.version:
1525
- case commands.native:
1526
- case commands.mobile:
1527
- case commands.ios:
1528
- case commands.android:
1529
- case commands.langInfos:
1530
- case commands.branchDefaultLang:
1531
- return $return(store[reversedCommands[cmd]]);
1532
-
1533
- case commands.openLink:
1534
- case commands.prefContentLang:
1535
- for (var _len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1536
- payload[_key - 1] = $args[_key];
1537
- }
1538
-
1539
- return $return(sendInvocationCall(invocationMapping[cmd], payload));
1540
-
1541
- default:
1542
- 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];
1543
1377
  }
1544
-
1545
- return $return();
1546
- });
1547
- };
1378
+ return sendInvocationCall(invocationMapping[cmd], payload);
1379
+ default:
1380
+ throw new Error('Command ' + cmd + ' not supported by driver');
1381
+ }
1548
1382
  };
1383
+
1549
1384
  /**
1550
1385
  * Create a promise and send an invocation call to the frontend
1551
1386
  *
@@ -1554,31 +1389,27 @@ var sendMessage$1 = function sendMessage(store) {
1554
1389
  *
1555
1390
  * @return {Promise}
1556
1391
  */
1557
-
1558
-
1559
- var sendInvocationCall = function sendInvocationCall(process, args) {
1560
- var promiseID = create();
1392
+ const sendInvocationCall = (process, args) => {
1393
+ const promiseID = create();
1561
1394
  outMsgQueue.push([protocol.INVOCATION, promiseID, process, args]);
1562
1395
  return get(promiseID);
1563
1396
  };
1564
1397
 
1565
- var connector;
1566
-
1567
- var connect = function connect() {
1568
- return new Promise(function ($return, $error) {
1569
- var putMessageConnection, postMessageConnection, fallbackConnection, realConnectionBucket, fallbackConnectionBucket;
1570
- putMessageConnection = connect$1();
1571
- postMessageConnection = connect$2();
1572
- fallbackConnection = fallback();
1573
- realConnectionBucket = [putMessageConnection, postMessageConnection];
1574
- fallbackConnectionBucket = realConnectionBucket.concat(fallbackConnection);
1575
- // Wait on the real communication and replace the connector with
1576
- Promise.race(realConnectionBucket).then(function (newConnector) {
1577
- connector = newConnector;
1578
- });
1579
- 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;
1580
1409
  });
1410
+ return await Promise.race(fallbackConnectionBucket);
1581
1411
  };
1412
+
1582
1413
  /**
1583
1414
  * Send a message to the App
1584
1415
  *
@@ -1589,30 +1420,15 @@ var connect = function connect() {
1589
1420
  * @param {any} payload that will be attached to the message
1590
1421
  * @return {Promise<any>} result of the request
1591
1422
  */
1592
-
1593
- var sendMessage = function sendMessage(msg) {
1594
- var $args = arguments;
1595
- return new Promise(function ($return, $error) {
1596
- var sendFn, _len, payload, _key;
1597
-
1598
- if (!connector) {
1599
- connector = connect();
1600
- }
1601
-
1602
- return Promise.resolve(connector).then(function ($await_2) {
1603
- try {
1604
- sendFn = $await_2;
1605
-
1606
- for (_len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1607
- payload[_key - 1] = $args[_key];
1608
- }
1609
-
1610
- return $return(sendFn.apply(void 0, [msg].concat(payload)));
1611
- } catch ($boundEx) {
1612
- return $error($boundEx);
1613
- }
1614
- }, $error);
1615
- });
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);
1616
1432
  };
1617
1433
 
1618
1434
  /**
@@ -1620,34 +1436,28 @@ var sendMessage = function sendMessage(msg) {
1620
1436
  *
1621
1437
  * @return {Promise<string>}
1622
1438
  */
1623
-
1624
- var getVersion = function getVersion() {
1625
- return new Promise(function ($return, $error) {
1626
- return $return(sendMessage(commands.version));
1627
- });
1439
+ const getVersion = async () => {
1440
+ return sendMessage(commands.version);
1628
1441
  };
1442
+
1629
1443
  /**
1630
1444
  * Check if app is native.
1631
1445
  *
1632
1446
  * @return {Promise<boolean>}
1633
1447
  */
1634
-
1635
- var isNative = function isNative() {
1636
- return new Promise(function ($return, $error) {
1637
- return $return(sendMessage(commands.native));
1638
- });
1448
+ const isNative = async () => {
1449
+ return sendMessage(commands.native);
1639
1450
  };
1451
+
1640
1452
  /**
1641
1453
  * Check if app is mobile.
1642
1454
  *
1643
1455
  * @return {Promise<boolean>}
1644
1456
  */
1645
-
1646
- var isMobile = function isMobile() {
1647
- return new Promise(function ($return, $error) {
1648
- return $return(sendMessage(commands.mobile));
1649
- });
1457
+ const isMobile = async () => {
1458
+ return sendMessage(commands.mobile);
1650
1459
  };
1460
+
1651
1461
  /**
1652
1462
  * Open a link through the app.
1653
1463
  *
@@ -1658,12 +1468,10 @@ var isMobile = function isMobile() {
1658
1468
  *
1659
1469
  * @return {Promise<any>}
1660
1470
  */
1661
-
1662
- var openLink$1 = function openLink(url) {
1663
- return new Promise(function ($return, $error) {
1664
- return $return(sendMessage(commands.openLink, url));
1665
- });
1471
+ const openLink$1 = async url => {
1472
+ return sendMessage(commands.openLink, url);
1666
1473
  };
1474
+
1667
1475
  /**
1668
1476
  * Open a link explicitly in the external browser.
1669
1477
  *
@@ -1671,14 +1479,12 @@ var openLink$1 = function openLink(url) {
1671
1479
  *
1672
1480
  * @return {Promise<any>}
1673
1481
  */
1674
-
1675
- var openLinkExternal$1 = function openLinkExternal(url) {
1676
- return new Promise(function ($return, $error) {
1677
- return $return(sendMessage(commands.openLink, url, {
1678
- inAppBrowser: false
1679
- }));
1482
+ const openLinkExternal$1 = async url => {
1483
+ return sendMessage(commands.openLink, url, {
1484
+ inAppBrowser: false
1680
1485
  });
1681
1486
  };
1487
+
1682
1488
  /**
1683
1489
  * Open a link explicitly in the internal browser.
1684
1490
  *
@@ -1686,14 +1492,12 @@ var openLinkExternal$1 = function openLinkExternal(url) {
1686
1492
  *
1687
1493
  * @return {Promise<any>}
1688
1494
  */
1689
-
1690
- var openLinkInternal$1 = function openLinkInternal(url) {
1691
- return new Promise(function ($return, $error) {
1692
- return $return(sendMessage(commands.openLink, url, {
1693
- inAppBrowser: true
1694
- }));
1495
+ const openLinkInternal$1 = async url => {
1496
+ return sendMessage(commands.openLink, url, {
1497
+ inAppBrowser: true
1695
1498
  });
1696
1499
  };
1500
+
1697
1501
  /**
1698
1502
  * Open a native file upload dialog on device which do not support it by default.
1699
1503
  *
@@ -1701,12 +1505,10 @@ var openLinkInternal$1 = function openLinkInternal(url) {
1701
1505
  *
1702
1506
  * @return {Promise<any>}
1703
1507
  */
1704
-
1705
- var openNativeFileDialog = function openNativeFileDialog() {
1706
- return new Promise(function ($return, $error) {
1707
- return $return(sendMessage(commands.nativeUpload));
1708
- });
1508
+ const openNativeFileDialog = async () => {
1509
+ return sendMessage(commands.nativeUpload);
1709
1510
  };
1511
+
1710
1512
  /**
1711
1513
  * Open a share dialog on native devices
1712
1514
  *
@@ -1722,51 +1524,37 @@ var openNativeFileDialog = function openNativeFileDialog() {
1722
1524
  *
1723
1525
  * @return {Promise<string>}
1724
1526
  */
1725
-
1726
- var openNativeShareDialog$1 = function openNativeShareDialog(content) {
1727
- return new Promise(function ($return, $error) {
1728
- return $return(sendMessage(commands.nativeShare, content));
1729
- });
1527
+ const openNativeShareDialog$1 = async content => {
1528
+ return sendMessage(commands.nativeShare, content);
1730
1529
  };
1530
+
1731
1531
  /**
1732
1532
  * Get the content languages configured for the branch.
1733
1533
  *
1734
1534
  * @return {Promise<Object>}
1735
1535
  */
1736
-
1737
- var getBranchLanguages$1 = function getBranchLanguages() {
1738
- return new Promise(function ($return, $error) {
1739
- return $return(sendMessage(commands.langInfos).then(function (res) {
1740
- return res.branchLanguages;
1741
- }));
1742
- });
1536
+ const getBranchLanguages$1 = async () => {
1537
+ return sendMessage(commands.langInfos).then(res => res.branchLanguages);
1743
1538
  };
1539
+
1744
1540
  /**
1745
1541
  * Get the default content language configured for the branch.
1746
1542
  *
1747
1543
  * @return {Promise<Object>}
1748
1544
  */
1749
-
1750
- var getBranchDefaultLanguage$1 = function getBranchDefaultLanguage() {
1751
- return new Promise(function ($return, $error) {
1752
- return $return(sendMessage(commands.langInfos).then(function (res) {
1753
- return res.branchDefaultLanguage;
1754
- }));
1755
- });
1545
+ const getBranchDefaultLanguage$1 = async () => {
1546
+ return sendMessage(commands.langInfos).then(res => res.branchDefaultLanguage);
1756
1547
  };
1548
+
1757
1549
  /**
1758
1550
  * Get all content languages supported by the Staffbase app.
1759
1551
  *
1760
1552
  * @return {Promise<Object>}
1761
1553
  */
1762
-
1763
- var getContentLanguages$1 = function getContentLanguages() {
1764
- return new Promise(function ($return, $error) {
1765
- return $return(sendMessage(commands.langInfos).then(function (res) {
1766
- return res.contentLanguages;
1767
- }));
1768
- });
1554
+ const getContentLanguages$1 = async () => {
1555
+ return sendMessage(commands.langInfos).then(res => res.contentLanguages);
1769
1556
  };
1557
+
1770
1558
  /**
1771
1559
  * Gets the chosen language from a given content object
1772
1560
  *
@@ -1778,89 +1566,53 @@ var getContentLanguages$1 = function getContentLanguages() {
1778
1566
  *
1779
1567
  * @return {Promise<string>}
1780
1568
  */
1781
-
1782
- var getPreferredContentLocale$1 = function getPreferredContentLocale(content) {
1783
- return new Promise(function ($return, $error) {
1784
- return $return(sendMessage(commands.prefContentLang, content));
1785
- });
1569
+ const getPreferredContentLocale$1 = async content => {
1570
+ return sendMessage(commands.prefContentLang, content);
1786
1571
  };
1787
1572
 
1788
- 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) => {
1789
1581
  // validate input and split into segments
1790
1582
  const n1 = validateAndParse(v1);
1791
- const n2 = validateAndParse(v2); // pop off the patch
1792
-
1583
+ const n2 = validateAndParse(v2);
1584
+ // pop off the patch
1793
1585
  const p1 = n1.pop();
1794
- const p2 = n2.pop(); // validate numbers
1795
-
1586
+ const p2 = n2.pop();
1587
+ // validate numbers
1796
1588
  const r = compareSegments(n1, n2);
1797
- if (r !== 0) return r; // validate pre-release
1798
-
1589
+ if (r !== 0) return r;
1590
+ // validate pre-release
1799
1591
  if (p1 && p2) {
1800
1592
  return compareSegments(p1.split('.'), p2.split('.'));
1801
1593
  } else if (p1 || p2) {
1802
1594
  return p1 ? -1 : 1;
1803
1595
  }
1804
-
1805
1596
  return 0;
1806
- }
1807
- const validate = v => typeof v === 'string' && /^[v\d]/.test(v) && semver.test(v);
1808
- const compare = (v1, v2, operator) => {
1809
- // validate input operator
1810
- assertValidOperator(operator); // since result of compareVersions can only be -1 or 0 or 1
1811
- // a simple map can be used to replace switch
1812
-
1813
- const res = compareVersions(v1, v2);
1814
- return operatorResMap[operator].includes(res);
1815
1597
  };
1816
- const satisfies = (v, r) => {
1817
- // if no range operator then "="
1818
- const m = r.match(/^([<>=~^]+)/);
1819
- const op = m ? m[1] : '='; // if gt/lt/eq then operator compare
1820
-
1821
- if (op !== '^' && op !== '~') return compare(v, r, op); // else range of either "~" or "^" is assumed
1822
-
1823
- const [v1, v2, v3] = validateAndParse(v);
1824
- const [r1, r2, r3] = validateAndParse(r);
1825
- if (compareStrings(v1, r1) !== 0) return false;
1826
-
1827
- if (op === '^') {
1828
- return compareSegments([v2, v3], [r2, r3]) >= 0;
1829
- }
1830
-
1831
- if (compareStrings(v2, r2) !== 0) return false;
1832
- return compareStrings(v3, r3) >= 0;
1833
- }; // export CJS style for parity
1834
-
1835
- compareVersions.validate = validate;
1836
- compareVersions.compare = compare;
1837
- compareVersions.sastisfies = satisfies;
1838
1598
  const semver = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
1839
-
1840
- const validateAndParse = v => {
1841
- if (typeof v !== 'string') {
1599
+ const validateAndParse = version => {
1600
+ if (typeof version !== 'string') {
1842
1601
  throw new TypeError('Invalid argument expected string');
1843
1602
  }
1844
-
1845
- const match = v.match(semver);
1846
-
1603
+ const match = version.match(semver);
1847
1604
  if (!match) {
1848
- throw new Error(`Invalid argument not valid semver ('${v}' received)`);
1605
+ throw new Error(`Invalid argument not valid semver ('${version}' received)`);
1849
1606
  }
1850
-
1851
1607
  match.shift();
1852
1608
  return match;
1853
1609
  };
1854
-
1855
1610
  const isWildcard = s => s === '*' || s === 'x' || s === 'X';
1856
-
1857
1611
  const tryParse = v => {
1858
1612
  const n = parseInt(v, 10);
1859
1613
  return isNaN(n) ? v : n;
1860
1614
  };
1861
-
1862
1615
  const forceType = (a, b) => typeof a !== typeof b ? [String(a), String(b)] : [a, b];
1863
-
1864
1616
  const compareStrings = (a, b) => {
1865
1617
  if (isWildcard(a) || isWildcard(b)) return 0;
1866
1618
  const [ap, bp] = forceType(tryParse(a), tryParse(b));
@@ -1868,152 +1620,97 @@ const compareStrings = (a, b) => {
1868
1620
  if (ap < bp) return -1;
1869
1621
  return 0;
1870
1622
  };
1871
-
1872
1623
  const compareSegments = (a, b) => {
1873
1624
  for (let i = 0; i < Math.max(a.length, b.length); i++) {
1874
- const r = compareStrings(a[i] || 0, b[i] || 0);
1625
+ const r = compareStrings(a[i] || '0', b[i] || '0');
1875
1626
  if (r !== 0) return r;
1876
1627
  }
1877
-
1878
1628
  return 0;
1879
1629
  };
1880
1630
 
1881
- const operatorResMap = {
1882
- '>': [1],
1883
- '>=': [0, 1],
1884
- '=': [0],
1885
- '<=': [-1, 0],
1886
- '<': [-1]
1887
- };
1888
- const allowedOperators = Object.keys(operatorResMap);
1889
-
1890
- const assertValidOperator = op => {
1891
- if (typeof op !== 'string') {
1892
- throw new TypeError(`Invalid operator type, expected string but got ${typeof op}`);
1893
- }
1894
-
1895
- if (allowedOperators.indexOf(op) === -1) {
1896
- throw new Error(`Invalid operator, expected one of ${allowedOperators.join('|')}`);
1897
- }
1898
- };
1899
-
1631
+ /* eslint-disable no-unused-vars */
1900
1632
  /**
1901
1633
  * Check if device is using ios.
1902
1634
  *
1903
1635
  * @return {Promise<boolean>}
1904
1636
  */
1905
-
1906
- var isIos = function isIos() {
1907
- return new Promise(function ($return, $error) {
1908
- return $return(sendMessage(commands.ios));
1909
- });
1637
+ const isIos = async () => {
1638
+ return sendMessage(commands.ios);
1910
1639
  };
1640
+
1911
1641
  /**
1912
1642
  * Check if device is using android.
1913
1643
  *
1914
1644
  * @return {Promise<boolean>}
1915
1645
  */
1916
-
1917
- var isAndroid = function isAndroid() {
1918
- return new Promise(function ($return, $error) {
1919
- return $return(sendMessage(commands.android));
1920
- });
1646
+ const isAndroid = async () => {
1647
+ return sendMessage(commands.android);
1921
1648
  };
1649
+
1922
1650
  /**
1923
1651
  * Check if device is able to perform a download.
1924
1652
  *
1925
1653
  * @return {Promise<boolean>}
1926
1654
  */
1655
+ const canDownload = async () => {
1656
+ let [native, version, ios] = await Promise.all([isNative(), getVersion(), isIos()]);
1927
1657
 
1928
- var canDownload = function canDownload() {
1929
- return new Promise(function ($return, $error) {
1930
- var _await$Promise$all, _await$Promise$all2, native, version, ios, dashIndex;
1931
-
1932
- return Promise.resolve(Promise.all([isNative(), getVersion(), isIos()])).then(function ($await_1) {
1933
- try {
1934
- _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];
1935
- dashIndex = version.indexOf('-');
1936
- version = version.substring(0, dashIndex != -1 ? dashIndex : version.length); // mobile ios devices can not download with an app version less than 3.5
1937
- // but apps below 3.5 don't have the platform information from the frontend available
1938
- // 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);
1939
1661
 
1940
- return $return(!(compareVersions(version, '3.5') < 0 && native && ios));
1941
- } catch ($boundEx) {
1942
- return $error($boundEx);
1943
- }
1944
- }, $error);
1945
- });
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);
1946
1666
  };
1947
1667
 
1948
1668
  /**
1949
1669
  * Interface exports
1950
1670
  */
1671
+
1951
1672
  /**
1952
1673
  * Check if device is able to perform a download.
1953
1674
  * @function
1954
1675
  * @return {Promise<boolean>}
1955
1676
  */
1677
+ const deviceCanDownload = async () => canDownload();
1956
1678
 
1957
- var deviceCanDownload = function deviceCanDownload() {
1958
- return new Promise(function ($return, $error) {
1959
- return $return(canDownload());
1960
- });
1961
- };
1962
1679
  /**
1963
1680
  * Check if device is using ios.
1964
1681
  * @function
1965
1682
  * @return {Promise<boolean>}
1966
1683
  */
1684
+ const isIosDevice = async () => isIos();
1967
1685
 
1968
- var isIosDevice = function isIosDevice() {
1969
- return new Promise(function ($return, $error) {
1970
- return $return(isIos());
1971
- });
1972
- };
1973
1686
  /**
1974
1687
  * Check if device is using android.
1975
1688
  * @function
1976
1689
  * @return {Promise<boolean>}
1977
1690
  */
1691
+ const isAndroidDevice = async () => isAndroid();
1978
1692
 
1979
- var isAndroidDevice = function isAndroidDevice() {
1980
- return new Promise(function ($return, $error) {
1981
- return $return(isAndroid());
1982
- });
1983
- };
1984
1693
  /**
1985
1694
  * Get the version of the Staffbase App.
1986
1695
  * @function
1987
1696
  * @return {Promise<string>}
1988
1697
  */
1698
+ const getAppVersion = async () => getVersion();
1989
1699
 
1990
- var getAppVersion = function getAppVersion() {
1991
- return new Promise(function ($return, $error) {
1992
- return $return(getVersion());
1993
- });
1994
- };
1995
1700
  /**
1996
1701
  * Check if app is native.
1997
1702
  * @function
1998
1703
  * @return {Promise<boolean>}
1999
1704
  */
1705
+ const isNativeApp = async () => isNative();
2000
1706
 
2001
- var isNativeApp = function isNativeApp() {
2002
- return new Promise(function ($return, $error) {
2003
- return $return(isNative());
2004
- });
2005
- };
2006
1707
  /**
2007
1708
  * Check if app is mobile.
2008
1709
  * @function
2009
1710
  * @return {Promise<boolean>}
2010
1711
  */
1712
+ const isMobileApp = async () => isMobile();
2011
1713
 
2012
- var isMobileApp = function isMobileApp() {
2013
- return new Promise(function ($return, $error) {
2014
- return $return(isMobile());
2015
- });
2016
- };
2017
1714
  /**
2018
1715
  * Open a link through the app.
2019
1716
  *
@@ -2024,12 +1721,8 @@ var isMobileApp = function isMobileApp() {
2024
1721
  * @function
2025
1722
  * @return {Promise<any>}
2026
1723
  */
1724
+ const openLink = async url => openLink$1(url);
2027
1725
 
2028
- var openLink = function openLink(url) {
2029
- return new Promise(function ($return, $error) {
2030
- return $return(openLink$1(url));
2031
- });
2032
- };
2033
1726
  /**
2034
1727
  * Open a link explicitly in the external browser.
2035
1728
  *
@@ -2037,12 +1730,8 @@ var openLink = function openLink(url) {
2037
1730
  * @function
2038
1731
  * @return {Promise<any>}
2039
1732
  */
1733
+ const openLinkExternal = async url => openLinkExternal$1(url);
2040
1734
 
2041
- var openLinkExternal = function openLinkExternal(url) {
2042
- return new Promise(function ($return, $error) {
2043
- return $return(openLinkExternal$1(url));
2044
- });
2045
- };
2046
1735
  /**
2047
1736
  * Open a link explicitly in the internal browser.
2048
1737
  *
@@ -2050,45 +1739,29 @@ var openLinkExternal = function openLinkExternal(url) {
2050
1739
  * @function
2051
1740
  * @return {Promise<any>}
2052
1741
  */
1742
+ const openLinkInternal = async url => openLinkInternal$1(url);
2053
1743
 
2054
- var openLinkInternal = function openLinkInternal(url) {
2055
- return new Promise(function ($return, $error) {
2056
- return $return(openLinkInternal$1(url));
2057
- });
2058
- };
2059
1744
  /**
2060
1745
  * Get all enabled content languages configured in the app.
2061
1746
  * @function
2062
1747
  * @return {Promise<any>}
2063
1748
  */
1749
+ const getBranchLanguages = async () => getBranchLanguages$1();
2064
1750
 
2065
- var getBranchLanguages = function getBranchLanguages() {
2066
- return new Promise(function ($return, $error) {
2067
- return $return(getBranchLanguages$1());
2068
- });
2069
- };
2070
1751
  /**
2071
1752
  * Get the default content language configured in the app.
2072
1753
  * @function
2073
1754
  * @return {Promise<any>}
2074
1755
  */
1756
+ const getBranchDefaultLanguage = async () => getBranchDefaultLanguage$1();
2075
1757
 
2076
- var getBranchDefaultLanguage = function getBranchDefaultLanguage() {
2077
- return new Promise(function ($return, $error) {
2078
- return $return(getBranchDefaultLanguage$1());
2079
- });
2080
- };
2081
1758
  /**
2082
1759
  * Get all content languages supported by the app.
2083
1760
  * @function
2084
1761
  * @return {Promise<any>}
2085
1762
  */
1763
+ const getContentLanguages = async () => getContentLanguages$1();
2086
1764
 
2087
- var getContentLanguages = function getContentLanguages() {
2088
- return new Promise(function ($return, $error) {
2089
- return $return(getContentLanguages$1());
2090
- });
2091
- };
2092
1765
  /**
2093
1766
  * Gets the chosen language from a given content object
2094
1767
  *
@@ -2100,12 +1773,8 @@ var getContentLanguages = function getContentLanguages() {
2100
1773
  * @function
2101
1774
  * @return {Promise<string>}
2102
1775
  */
1776
+ const getPreferredContentLocale = async content => getPreferredContentLocale$1(content);
2103
1777
 
2104
- var getPreferredContentLocale = function getPreferredContentLocale(content) {
2105
- return new Promise(function ($return, $error) {
2106
- return $return(getPreferredContentLocale$1(content));
2107
- });
2108
- };
2109
1778
  /**
2110
1779
  * Open a share dialog on native devices
2111
1780
  *
@@ -2121,13 +1790,8 @@ var getPreferredContentLocale = function getPreferredContentLocale(content) {
2121
1790
  *
2122
1791
  * @return {Promise<string>}
2123
1792
  */
2124
-
2125
- var openNativeShareDialog = function openNativeShareDialog(content) {
2126
- return new Promise(function ($return, $error) {
2127
- return $return(openNativeShareDialog$1(content));
2128
- });
2129
- };
2130
- /* experimental */
1793
+ const openNativeShareDialog = async content => openNativeShareDialog$1(content);
1794
+ /* experimental */
2131
1795
 
2132
1796
  exports.deviceCanDownload = deviceCanDownload;
2133
1797
  exports.getAppVersion = getAppVersion;