@staffbase/plugins-client-sdk 1.1.0 → 1.2.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.
@@ -1,778 +1,311 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
-
7
- function createCommonjsModule(fn, module) {
8
- return module = { exports: {} }, fn(module, module.exports), module.exports;
9
- }
10
-
11
- var runtime_1 = createCommonjsModule(function (module) {
12
1
  /**
13
- * Copyright (c) 2014-present, Facebook, Inc.
2
+ * Bundle of @staffbase/plugins-client-sdk
3
+ * @file Staffbase plugins client SDK for JavaScript
4
+ * @see https://github.com/Staffbase/plugins-client-sdk#readme
5
+ * @version 1.2.0
14
6
  *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
7
+ * @author Stefan Staude <stefan.staude@staffbase.com>
8
+ * @author Daniel Große <daniel.grosse@staffbase.com>
9
+ *
10
+ * @copyright 2022
11
+ * @license Apache-2.0
17
12
  */
18
13
 
19
- var runtime = (function (exports) {
20
-
21
- var Op = Object.prototype;
22
- var hasOwn = Op.hasOwnProperty;
23
- var undefined$1; // More compressible than void 0.
24
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
25
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
26
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
27
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
28
-
29
- function wrap(innerFn, outerFn, self, tryLocsList) {
30
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
31
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
32
- var generator = Object.create(protoGenerator.prototype);
33
- var context = new Context(tryLocsList || []);
34
-
35
- // The ._invoke method unifies the implementations of the .next,
36
- // .throw, and .return methods.
37
- generator._invoke = makeInvokeMethod(innerFn, self, context);
14
+ 'use strict';
38
15
 
39
- return generator;
40
- }
41
- exports.wrap = wrap;
42
-
43
- // Try/catch helper to minimize deoptimizations. Returns a completion
44
- // record like context.tryEntries[i].completion. This interface could
45
- // have been (and was previously) designed to take a closure to be
46
- // invoked without arguments, but in all the cases we care about we
47
- // already have an existing method we want to call, so there's no need
48
- // to create a new function object. We can even get away with assuming
49
- // the method takes exactly one argument, since that happens to be true
50
- // in every case, so we don't have to touch the arguments object. The
51
- // only additional allocation required is the completion record, which
52
- // has a stable shape and so hopefully should be cheap to allocate.
53
- function tryCatch(fn, obj, arg) {
54
- try {
55
- return { type: "normal", arg: fn.call(obj, arg) };
56
- } catch (err) {
57
- return { type: "throw", arg: err };
58
- }
59
- }
16
+ Object.defineProperty(exports, '__esModule', { value: true });
60
17
 
61
- var GenStateSuspendedStart = "suspendedStart";
62
- var GenStateSuspendedYield = "suspendedYield";
63
- var GenStateExecuting = "executing";
64
- var GenStateCompleted = "completed";
65
-
66
- // Returning this object from the innerFn has the same effect as
67
- // breaking out of the dispatch switch statement.
68
- var ContinueSentinel = {};
69
-
70
- // Dummy constructor functions that we use as the .constructor and
71
- // .constructor.prototype properties for functions that return Generator
72
- // objects. For full spec compliance, you may wish to configure your
73
- // minifier not to mangle the names of these two functions.
74
- function Generator() {}
75
- function GeneratorFunction() {}
76
- function GeneratorFunctionPrototype() {}
77
-
78
- // This is a polyfill for %IteratorPrototype% for environments that
79
- // don't natively support it.
80
- var IteratorPrototype = {};
81
- IteratorPrototype[iteratorSymbol] = function () {
82
- return this;
83
- };
18
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
84
19
 
85
- var getProto = Object.getPrototypeOf;
86
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
87
- if (NativeIteratorPrototype &&
88
- NativeIteratorPrototype !== Op &&
89
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
90
- // This environment has a native %IteratorPrototype%; use it instead
91
- // of the polyfill.
92
- IteratorPrototype = NativeIteratorPrototype;
93
- }
20
+ var loglevel = {exports: {}};
94
21
 
95
- var Gp = GeneratorFunctionPrototype.prototype =
96
- Generator.prototype = Object.create(IteratorPrototype);
97
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
98
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
99
- GeneratorFunctionPrototype[toStringTagSymbol] =
100
- GeneratorFunction.displayName = "GeneratorFunction";
101
-
102
- // Helper for defining the .next, .throw, and .return methods of the
103
- // Iterator interface in terms of a single ._invoke method.
104
- function defineIteratorMethods(prototype) {
105
- ["next", "throw", "return"].forEach(function(method) {
106
- prototype[method] = function(arg) {
107
- return this._invoke(method, arg);
108
- };
109
- });
110
- }
22
+ /*
23
+ * loglevel - https://github.com/pimterry/loglevel
24
+ *
25
+ * Copyright (c) 2013 Tim Perry
26
+ * Licensed under the MIT license.
27
+ */
111
28
 
112
- exports.isGeneratorFunction = function(genFun) {
113
- var ctor = typeof genFun === "function" && genFun.constructor;
114
- return ctor
115
- ? ctor === GeneratorFunction ||
116
- // For the native GeneratorFunction constructor, the best we can
117
- // do is to check its .name property.
118
- (ctor.displayName || ctor.name) === "GeneratorFunction"
119
- : false;
120
- };
29
+ (function (module) {
30
+ (function (root, definition) {
121
31
 
122
- exports.mark = function(genFun) {
123
- if (Object.setPrototypeOf) {
124
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
32
+ if (module.exports) {
33
+ module.exports = definition();
125
34
  } else {
126
- genFun.__proto__ = GeneratorFunctionPrototype;
127
- if (!(toStringTagSymbol in genFun)) {
128
- genFun[toStringTagSymbol] = "GeneratorFunction";
129
- }
35
+ root.log = definition();
130
36
  }
131
- genFun.prototype = Object.create(Gp);
132
- return genFun;
133
- };
37
+ })(commonjsGlobal, function () {
134
38
 
135
- // Within the body of any async function, `await x` is transformed to
136
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
137
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
138
- // meant to be awaited.
139
- exports.awrap = function(arg) {
140
- return { __await: arg };
141
- };
39
+ var noop = function () {};
40
+
41
+ var undefinedType = "undefined";
42
+ 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
142
44
 
143
- function AsyncIterator(generator) {
144
- function invoke(method, arg, resolve, reject) {
145
- var record = tryCatch(generator[method], generator, arg);
146
- if (record.type === "throw") {
147
- reject(record.arg);
45
+ function bindMethod(obj, methodName) {
46
+ var method = obj[methodName];
47
+
48
+ if (typeof method.bind === 'function') {
49
+ return method.bind(obj);
148
50
  } else {
149
- var result = record.arg;
150
- var value = result.value;
151
- if (value &&
152
- typeof value === "object" &&
153
- hasOwn.call(value, "__await")) {
154
- return Promise.resolve(value.__await).then(function(value) {
155
- invoke("next", value, resolve, reject);
156
- }, function(err) {
157
- invoke("throw", err, resolve, reject);
158
- });
51
+ try {
52
+ return Function.prototype.bind.call(method, obj);
53
+ } catch (e) {
54
+ // Missing bind shim or IE8 + Modernizr, fallback to wrapping
55
+ return function () {
56
+ return Function.prototype.apply.apply(method, [obj, arguments]);
57
+ };
159
58
  }
160
-
161
- return Promise.resolve(value).then(function(unwrapped) {
162
- // When a yielded Promise is resolved, its final value becomes
163
- // the .value of the Promise<{value,done}> result for the
164
- // current iteration.
165
- result.value = unwrapped;
166
- resolve(result);
167
- }, function(error) {
168
- // If a rejected Promise was yielded, throw the rejection back
169
- // into the async generator function so it can be handled there.
170
- return invoke("throw", error, resolve, reject);
171
- });
172
59
  }
173
- }
60
+ } // Trace() doesn't print the message in IE, so for that case we need to wrap it
174
61
 
175
- var previousPromise;
176
62
 
177
- function enqueue(method, arg) {
178
- function callInvokeWithMethodAndArg() {
179
- return new Promise(function(resolve, reject) {
180
- invoke(method, arg, resolve, reject);
181
- });
63
+ function traceForIE() {
64
+ if (console.log) {
65
+ if (console.log.apply) {
66
+ console.log.apply(console, arguments);
67
+ } else {
68
+ // In old IE, native console methods themselves don't have apply().
69
+ Function.prototype.apply.apply(console.log, [console, arguments]);
70
+ }
182
71
  }
183
72
 
184
- return previousPromise =
185
- // If enqueue has been called before, then we want to wait until
186
- // all previous Promises have been resolved before calling invoke,
187
- // so that results are always delivered in the correct order. If
188
- // enqueue has not been called before, then it is important to
189
- // call invoke immediately, without waiting on a callback to fire,
190
- // so that the async generator function has the opportunity to do
191
- // any necessary setup in a predictable way. This predictability
192
- // is why the Promise constructor synchronously invokes its
193
- // executor callback, and why async functions synchronously
194
- // execute code before the first await. Since we implement simple
195
- // async functions in terms of async generators, it is especially
196
- // important to get this right, even though it requires care.
197
- previousPromise ? previousPromise.then(
198
- callInvokeWithMethodAndArg,
199
- // Avoid propagating failures to Promises returned by later
200
- // invocations of the iterator.
201
- callInvokeWithMethodAndArg
202
- ) : callInvokeWithMethodAndArg();
203
- }
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
204
76
 
205
- // Define the unified helper method that is used to implement .next,
206
- // .throw, and .return (see defineIteratorMethods).
207
- this._invoke = enqueue;
208
- }
209
77
 
210
- defineIteratorMethods(AsyncIterator.prototype);
211
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
212
- return this;
213
- };
214
- exports.AsyncIterator = AsyncIterator;
215
-
216
- // Note that simple async functions are implemented on top of
217
- // AsyncIterator objects; they just return a Promise for the value of
218
- // the final result produced by the iterator.
219
- exports.async = function(innerFn, outerFn, self, tryLocsList) {
220
- var iter = new AsyncIterator(
221
- wrap(innerFn, outerFn, self, tryLocsList)
222
- );
223
-
224
- return exports.isGeneratorFunction(outerFn)
225
- ? iter // If outerFn is a generator, return the full iterator.
226
- : iter.next().then(function(result) {
227
- return result.done ? result.value : iter.next();
228
- });
229
- };
230
-
231
- function makeInvokeMethod(innerFn, self, context) {
232
- var state = GenStateSuspendedStart;
233
-
234
- return function invoke(method, arg) {
235
- if (state === GenStateExecuting) {
236
- throw new Error("Generator is already running");
78
+ function realMethod(methodName) {
79
+ if (methodName === 'debug') {
80
+ methodName = 'log';
237
81
  }
238
82
 
239
- if (state === GenStateCompleted) {
240
- if (method === "throw") {
241
- throw arg;
242
- }
243
-
244
- // Be forgiving, per 25.3.3.3.3 of the spec:
245
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
246
- return doneResult();
83
+ if (typeof console === undefinedType) {
84
+ return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
85
+ } else if (methodName === 'trace' && isIE) {
86
+ return traceForIE;
87
+ } else if (console[methodName] !== undefined) {
88
+ return bindMethod(console, methodName);
89
+ } else if (console.log !== undefined) {
90
+ return bindMethod(console, 'log');
91
+ } else {
92
+ return noop;
247
93
  }
94
+ } // These private functions always need `this` to be set properly
248
95
 
249
- context.method = method;
250
- context.arg = arg;
251
96
 
252
- while (true) {
253
- var delegate = context.delegate;
254
- if (delegate) {
255
- var delegateResult = maybeInvokeDelegate(delegate, context);
256
- if (delegateResult) {
257
- if (delegateResult === ContinueSentinel) continue;
258
- return delegateResult;
259
- }
260
- }
261
-
262
- if (context.method === "next") {
263
- // Setting context._sent for legacy support of Babel's
264
- // function.sent implementation.
265
- context.sent = context._sent = context.arg;
266
-
267
- } else if (context.method === "throw") {
268
- if (state === GenStateSuspendedStart) {
269
- state = GenStateCompleted;
270
- throw context.arg;
271
- }
272
-
273
- context.dispatchException(context.arg);
274
-
275
- } else if (context.method === "return") {
276
- context.abrupt("return", context.arg);
277
- }
97
+ function replaceLoggingMethods(level, loggerName) {
98
+ /*jshint validthis:true */
99
+ for (var i = 0; i < logMethods.length; i++) {
100
+ var methodName = logMethods[i];
101
+ this[methodName] = i < level ? noop : this.methodFactory(methodName, level, loggerName);
102
+ } // Define log.log as an alias for log.debug
278
103
 
279
- state = GenStateExecuting;
280
104
 
281
- var record = tryCatch(innerFn, self, context);
282
- if (record.type === "normal") {
283
- // If an exception is thrown from innerFn, we leave state ===
284
- // GenStateExecuting and loop back for another invocation.
285
- state = context.done
286
- ? GenStateCompleted
287
- : GenStateSuspendedYield;
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
288
108
 
289
- if (record.arg === ContinueSentinel) {
290
- continue;
291
- }
292
-
293
- return {
294
- value: record.arg,
295
- done: context.done
296
- };
297
-
298
- } else if (record.type === "throw") {
299
- state = GenStateCompleted;
300
- // Dispatch the exception by looping back around to the
301
- // context.dispatchException(context.arg) call above.
302
- context.method = "throw";
303
- context.arg = record.arg;
304
- }
305
- }
306
- };
307
- }
308
109
 
309
- // Call delegate.iterator[context.method](context.arg) and handle the
310
- // result, either by returning a { value, done } result from the
311
- // delegate iterator, or by modifying context.method and context.arg,
312
- // setting context.delegate to null, and returning the ContinueSentinel.
313
- function maybeInvokeDelegate(delegate, context) {
314
- var method = delegate.iterator[context.method];
315
- if (method === undefined$1) {
316
- // A .throw or .return when the delegate iterator has no .throw
317
- // method always terminates the yield* loop.
318
- context.delegate = null;
319
-
320
- if (context.method === "throw") {
321
- // Note: ["return"] must be used for ES3 parsing compatibility.
322
- if (delegate.iterator["return"]) {
323
- // If the delegate iterator has a return method, give it a
324
- // chance to clean up.
325
- context.method = "return";
326
- context.arg = undefined$1;
327
- maybeInvokeDelegate(delegate, context);
328
-
329
- if (context.method === "throw") {
330
- // If maybeInvokeDelegate(context) changed context.method from
331
- // "return" to "throw", let that override the TypeError below.
332
- return ContinueSentinel;
333
- }
110
+ function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
111
+ return function () {
112
+ if (typeof console !== undefinedType) {
113
+ replaceLoggingMethods.call(this, level, loggerName);
114
+ this[methodName].apply(this, arguments);
334
115
  }
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.
335
119
 
336
- context.method = "throw";
337
- context.arg = new TypeError(
338
- "The iterator does not provide a 'throw' method");
339
- }
340
-
341
- return ContinueSentinel;
342
- }
343
-
344
- var record = tryCatch(method, delegate.iterator, context.arg);
345
120
 
346
- if (record.type === "throw") {
347
- context.method = "throw";
348
- context.arg = record.arg;
349
- context.delegate = null;
350
- return ContinueSentinel;
121
+ function defaultMethodFactory(methodName, level, loggerName) {
122
+ /*jshint validthis:true */
123
+ return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
351
124
  }
352
125
 
353
- var info = record.arg;
126
+ function Logger(name, defaultLevel, factory) {
127
+ var self = this;
128
+ var currentLevel;
129
+ defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
130
+ var storageKey = "loglevel";
354
131
 
355
- if (! info) {
356
- context.method = "throw";
357
- context.arg = new TypeError("iterator result is not an object");
358
- context.delegate = null;
359
- return ContinueSentinel;
360
- }
361
-
362
- if (info.done) {
363
- // Assign the result of the finished delegate to the temporary
364
- // variable specified by delegate.resultName (see delegateYield).
365
- context[delegate.resultName] = info.value;
366
-
367
- // Resume execution at the desired location (see delegateYield).
368
- context.next = delegate.nextLoc;
369
-
370
- // If context.method was "throw" but the delegate handled the
371
- // exception, let the outer generator proceed normally. If
372
- // context.method was "next", forget context.arg since it has been
373
- // "consumed" by the delegate iterator. If context.method was
374
- // "return", allow the original .return call to continue in the
375
- // outer generator.
376
- if (context.method !== "return") {
377
- context.method = "next";
378
- context.arg = undefined$1;
132
+ if (typeof name === "string") {
133
+ storageKey += ":" + name;
134
+ } else if (typeof name === "symbol") {
135
+ storageKey = undefined;
379
136
  }
380
137
 
381
- } else {
382
- // Re-yield the result returned by the delegate method.
383
- return info;
384
- }
138
+ function persistLevelIfPossible(levelNum) {
139
+ var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
140
+ if (typeof window === undefinedType || !storageKey) return; // Use localStorage if available
385
141
 
386
- // The delegate iterator is finished, so forget it and continue with
387
- // the outer generator.
388
- context.delegate = null;
389
- return ContinueSentinel;
390
- }
142
+ try {
143
+ window.localStorage[storageKey] = levelName;
144
+ return;
145
+ } catch (ignore) {} // Use session cookie as fallback
391
146
 
392
- // Define Generator.prototype.{next,throw,return} in terms of the
393
- // unified ._invoke helper method.
394
- defineIteratorMethods(Gp);
395
-
396
- Gp[toStringTagSymbol] = "Generator";
397
-
398
- // A Generator should always return itself as the iterator object when the
399
- // @@iterator function is called on it. Some browsers' implementations of the
400
- // iterator prototype chain incorrectly implement this, causing the Generator
401
- // object to not be returned from this call. This ensures that doesn't happen.
402
- // See https://github.com/facebook/regenerator/issues/274 for more details.
403
- Gp[iteratorSymbol] = function() {
404
- return this;
405
- };
406
147
 
407
- Gp.toString = function() {
408
- return "[object Generator]";
409
- };
148
+ try {
149
+ window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
150
+ } catch (ignore) {}
151
+ }
410
152
 
411
- function pushTryEntry(locs) {
412
- var entry = { tryLoc: locs[0] };
153
+ function getPersistedLevel() {
154
+ var storedLevel;
155
+ if (typeof window === undefinedType || !storageKey) return;
413
156
 
414
- if (1 in locs) {
415
- entry.catchLoc = locs[1];
416
- }
157
+ try {
158
+ storedLevel = window.localStorage[storageKey];
159
+ } catch (ignore) {} // Fallback to cookies if local storage gives us nothing
417
160
 
418
- if (2 in locs) {
419
- entry.finallyLoc = locs[2];
420
- entry.afterLoc = locs[3];
421
- }
422
161
 
423
- this.tryEntries.push(entry);
424
- }
162
+ if (typeof storedLevel === undefinedType) {
163
+ try {
164
+ var cookie = window.document.cookie;
165
+ var location = cookie.indexOf(encodeURIComponent(storageKey) + "=");
425
166
 
426
- function resetTryEntry(entry) {
427
- var record = entry.completion || {};
428
- record.type = "normal";
429
- delete record.arg;
430
- entry.completion = record;
431
- }
167
+ if (location !== -1) {
168
+ storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];
169
+ }
170
+ } catch (ignore) {}
171
+ } // If the stored level is not valid, treat it as if nothing was stored.
432
172
 
433
- function Context(tryLocsList) {
434
- // The root entry object (effectively a try statement without a catch
435
- // or a finally block) gives us a place to store values thrown from
436
- // locations where there is no enclosing try statement.
437
- this.tryEntries = [{ tryLoc: "root" }];
438
- tryLocsList.forEach(pushTryEntry, this);
439
- this.reset(true);
440
- }
441
173
 
442
- exports.keys = function(object) {
443
- var keys = [];
444
- for (var key in object) {
445
- keys.push(key);
446
- }
447
- keys.reverse();
448
-
449
- // Rather than returning an object with a next method, we keep
450
- // things simple and return the next function itself.
451
- return function next() {
452
- while (keys.length) {
453
- var key = keys.pop();
454
- if (key in object) {
455
- next.value = key;
456
- next.done = false;
457
- return next;
174
+ if (self.levels[storedLevel] === undefined) {
175
+ storedLevel = undefined;
458
176
  }
459
- }
460
-
461
- // To avoid creating an additional object, we just hang the .value
462
- // and .done properties off the next function object itself. This
463
- // also ensures that the minifier will not anonymize the function.
464
- next.done = true;
465
- return next;
466
- };
467
- };
468
-
469
- function values(iterable) {
470
- if (iterable) {
471
- var iteratorMethod = iterable[iteratorSymbol];
472
- if (iteratorMethod) {
473
- return iteratorMethod.call(iterable);
474
- }
475
177
 
476
- if (typeof iterable.next === "function") {
477
- return iterable;
178
+ return storedLevel;
478
179
  }
479
180
 
480
- if (!isNaN(iterable.length)) {
481
- var i = -1, next = function next() {
482
- while (++i < iterable.length) {
483
- if (hasOwn.call(iterable, i)) {
484
- next.value = iterable[i];
485
- next.done = false;
486
- return next;
487
- }
488
- }
181
+ function clearPersistedLevel() {
182
+ if (typeof window === undefinedType || !storageKey) return; // Use localStorage if available
489
183
 
490
- next.value = undefined$1;
491
- next.done = true;
184
+ try {
185
+ window.localStorage.removeItem(storageKey);
186
+ return;
187
+ } catch (ignore) {} // Use session cookie as fallback
492
188
 
493
- return next;
494
- };
495
189
 
496
- return next.next = next;
190
+ try {
191
+ window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
192
+ } catch (ignore) {}
497
193
  }
498
- }
499
-
500
- // Return an iterator with no values.
501
- return { next: doneResult };
502
- }
503
- exports.values = values;
194
+ /*
195
+ *
196
+ * Public logger API - see https://github.com/pimterry/loglevel for details
197
+ *
198
+ */
199
+
200
+
201
+ self.name = name;
202
+ self.levels = {
203
+ "TRACE": 0,
204
+ "DEBUG": 1,
205
+ "INFO": 2,
206
+ "WARN": 3,
207
+ "ERROR": 4,
208
+ "SILENT": 5
209
+ };
210
+ self.methodFactory = factory || defaultMethodFactory;
504
211
 
505
- function doneResult() {
506
- return { value: undefined$1, done: true };
507
- }
212
+ self.getLevel = function () {
213
+ return currentLevel;
214
+ };
508
215
 
509
- Context.prototype = {
510
- constructor: Context,
511
-
512
- reset: function(skipTempReset) {
513
- this.prev = 0;
514
- this.next = 0;
515
- // Resetting context._sent for legacy support of Babel's
516
- // function.sent implementation.
517
- this.sent = this._sent = undefined$1;
518
- this.done = false;
519
- this.delegate = null;
520
-
521
- this.method = "next";
522
- this.arg = undefined$1;
523
-
524
- this.tryEntries.forEach(resetTryEntry);
525
-
526
- if (!skipTempReset) {
527
- for (var name in this) {
528
- // Not sure about the optimal order of these conditions:
529
- if (name.charAt(0) === "t" &&
530
- hasOwn.call(this, name) &&
531
- !isNaN(+name.slice(1))) {
532
- this[name] = undefined$1;
533
- }
216
+ self.setLevel = function (level, persist) {
217
+ if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
218
+ level = self.levels[level.toUpperCase()];
534
219
  }
535
- }
536
- },
537
220
 
538
- stop: function() {
539
- this.done = true;
221
+ if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
222
+ currentLevel = level;
540
223
 
541
- var rootEntry = this.tryEntries[0];
542
- var rootRecord = rootEntry.completion;
543
- if (rootRecord.type === "throw") {
544
- throw rootRecord.arg;
545
- }
546
-
547
- return this.rval;
548
- },
224
+ if (persist !== false) {
225
+ // defaults to true
226
+ persistLevelIfPossible(level);
227
+ }
549
228
 
550
- dispatchException: function(exception) {
551
- if (this.done) {
552
- throw exception;
553
- }
229
+ replaceLoggingMethods.call(self, level, name);
554
230
 
555
- var context = this;
556
- function handle(loc, caught) {
557
- record.type = "throw";
558
- record.arg = exception;
559
- context.next = loc;
560
-
561
- if (caught) {
562
- // If the dispatched exception was caught by a catch block,
563
- // then let that catch block handle the exception normally.
564
- context.method = "next";
565
- context.arg = undefined$1;
231
+ if (typeof console === undefinedType && level < self.levels.SILENT) {
232
+ return "No console available for logging";
233
+ }
234
+ } else {
235
+ throw "log.setLevel() called with invalid level: " + level;
566
236
  }
237
+ };
567
238
 
568
- return !! caught;
569
- }
570
-
571
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
572
- var entry = this.tryEntries[i];
573
- var record = entry.completion;
239
+ self.setDefaultLevel = function (level) {
240
+ defaultLevel = level;
574
241
 
575
- if (entry.tryLoc === "root") {
576
- // Exception thrown outside of any try block that could handle
577
- // it, so set the completion value of the entire function to
578
- // throw the exception.
579
- return handle("end");
242
+ if (!getPersistedLevel()) {
243
+ self.setLevel(level, false);
580
244
  }
245
+ };
581
246
 
582
- if (entry.tryLoc <= this.prev) {
583
- var hasCatch = hasOwn.call(entry, "catchLoc");
584
- var hasFinally = hasOwn.call(entry, "finallyLoc");
247
+ self.resetLevel = function () {
248
+ self.setLevel(defaultLevel, false);
249
+ clearPersistedLevel();
250
+ };
585
251
 
586
- if (hasCatch && hasFinally) {
587
- if (this.prev < entry.catchLoc) {
588
- return handle(entry.catchLoc, true);
589
- } else if (this.prev < entry.finallyLoc) {
590
- return handle(entry.finallyLoc);
591
- }
252
+ self.disableAll = function (persist) {
253
+ self.setLevel(self.levels.SILENT, persist);
254
+ }; // Initialize with the right level
592
255
 
593
- } else if (hasCatch) {
594
- if (this.prev < entry.catchLoc) {
595
- return handle(entry.catchLoc, true);
596
- }
597
256
 
598
- } else if (hasFinally) {
599
- if (this.prev < entry.finallyLoc) {
600
- return handle(entry.finallyLoc);
601
- }
257
+ var initialLevel = getPersistedLevel();
602
258
 
603
- } else {
604
- throw new Error("try statement without catch or finally");
605
- }
606
- }
607
- }
608
- },
609
-
610
- abrupt: function(type, arg) {
611
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
612
- var entry = this.tryEntries[i];
613
- if (entry.tryLoc <= this.prev &&
614
- hasOwn.call(entry, "finallyLoc") &&
615
- this.prev < entry.finallyLoc) {
616
- var finallyEntry = entry;
617
- break;
618
- }
259
+ if (initialLevel == null) {
260
+ initialLevel = defaultLevel;
619
261
  }
620
262
 
621
- if (finallyEntry &&
622
- (type === "break" ||
623
- type === "continue") &&
624
- finallyEntry.tryLoc <= arg &&
625
- arg <= finallyEntry.finallyLoc) {
626
- // Ignore the finally entry if control is not jumping to a
627
- // location outside the try/catch block.
628
- finallyEntry = null;
629
- }
630
-
631
- var record = finallyEntry ? finallyEntry.completion : {};
632
- record.type = type;
633
- record.arg = arg;
634
-
635
- if (finallyEntry) {
636
- this.method = "next";
637
- this.next = finallyEntry.finallyLoc;
638
- return ContinueSentinel;
639
- }
263
+ self.setLevel(initialLevel, false);
264
+ }
265
+ /*
266
+ *
267
+ * Top-level API
268
+ *
269
+ */
640
270
 
641
- return this.complete(record);
642
- },
643
271
 
644
- complete: function(record, afterLoc) {
645
- if (record.type === "throw") {
646
- throw record.arg;
647
- }
272
+ var defaultLogger = new Logger();
273
+ var _loggersByName = {};
648
274
 
649
- if (record.type === "break" ||
650
- record.type === "continue") {
651
- this.next = record.arg;
652
- } else if (record.type === "return") {
653
- this.rval = this.arg = record.arg;
654
- this.method = "return";
655
- this.next = "end";
656
- } else if (record.type === "normal" && afterLoc) {
657
- this.next = afterLoc;
275
+ defaultLogger.getLogger = function getLogger(name) {
276
+ if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
277
+ throw new TypeError("You must supply a name when creating a logger.");
658
278
  }
659
279
 
660
- return ContinueSentinel;
661
- },
280
+ var logger = _loggersByName[name];
662
281
 
663
- finish: function(finallyLoc) {
664
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
665
- var entry = this.tryEntries[i];
666
- if (entry.finallyLoc === finallyLoc) {
667
- this.complete(entry.completion, entry.afterLoc);
668
- resetTryEntry(entry);
669
- return ContinueSentinel;
670
- }
671
- }
672
- },
673
-
674
- "catch": function(tryLoc) {
675
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
676
- var entry = this.tryEntries[i];
677
- if (entry.tryLoc === tryLoc) {
678
- var record = entry.completion;
679
- if (record.type === "throw") {
680
- var thrown = record.arg;
681
- resetTryEntry(entry);
682
- }
683
- return thrown;
684
- }
282
+ if (!logger) {
283
+ logger = _loggersByName[name] = new Logger(name, defaultLogger.getLevel(), defaultLogger.methodFactory);
685
284
  }
686
285
 
687
- // The context.catch method must only be called with a location
688
- // argument that corresponds to a known catch block.
689
- throw new Error("illegal catch attempt");
690
- },
286
+ return logger;
287
+ }; // Grab the current global log variable in case of overwrite
691
288
 
692
- delegateYield: function(iterable, resultName, nextLoc) {
693
- this.delegate = {
694
- iterator: values(iterable),
695
- resultName: resultName,
696
- nextLoc: nextLoc
697
- };
698
289
 
699
- if (this.method === "next") {
700
- // Deliberately forget the last sent value so that we don't
701
- // accidentally pass it on to the delegate.
702
- this.arg = undefined$1;
703
- }
290
+ var _log = typeof window !== undefinedType ? window.log : undefined;
704
291
 
705
- return ContinueSentinel;
706
- }
707
- };
708
-
709
- // Regardless of whether this script is executing as a CommonJS module
710
- // or not, return the runtime object so that we can declare the variable
711
- // regeneratorRuntime in the outer scope, which allows this module to be
712
- // injected easily by `bin/regenerator --include-runtime script.js`.
713
- return exports;
714
-
715
- }(
716
- // If this script is executing as a CommonJS module, use module.exports
717
- // as the regeneratorRuntime namespace. Otherwise create a new empty
718
- // object. Either way, the resulting object will be used to initialize
719
- // the regeneratorRuntime variable at the top of this file.
720
- module.exports
721
- ));
722
-
723
- try {
724
- regeneratorRuntime = runtime;
725
- } catch (accidentalStrictMode) {
726
- // This module should not be running in strict mode, so the above
727
- // assignment should always work unless something is misconfigured. Just
728
- // in case runtime.js accidentally runs in strict mode, we can escape
729
- // strict mode using a global Function call. This could conceivably fail
730
- // if a Content Security Policy forbids using Function, but in that case
731
- // the proper solution is to fix the accidental strict mode problem. If
732
- // you've misconfigured your bundler to force strict mode and applied a
733
- // CSP to forbid Function, and you're not willing to fix either of those
734
- // problems, please detail your unique predicament in a GitHub issue.
735
- Function("r", "regeneratorRuntime = r")(runtime);
736
- }
737
- });
738
-
739
- var regenerator = runtime_1;
740
-
741
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
742
- try {
743
- var info = gen[key](arg);
744
- var value = info.value;
745
- } catch (error) {
746
- reject(error);
747
- return;
748
- }
749
-
750
- if (info.done) {
751
- resolve(value);
752
- } else {
753
- Promise.resolve(value).then(_next, _throw);
754
- }
755
- }
292
+ defaultLogger.noConflict = function () {
293
+ if (typeof window !== undefinedType && window.log === defaultLogger) {
294
+ window.log = _log;
295
+ }
756
296
 
757
- function _asyncToGenerator(fn) {
758
- return function () {
759
- var self = this,
760
- args = arguments;
761
- return new Promise(function (resolve, reject) {
762
- var gen = fn.apply(self, args);
297
+ return defaultLogger;
298
+ };
763
299
 
764
- function _next(value) {
765
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
766
- }
300
+ defaultLogger.getLoggers = function getLoggers() {
301
+ return _loggersByName;
302
+ }; // ES6 default export, for compatibility
767
303
 
768
- function _throw(err) {
769
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
770
- }
771
304
 
772
- _next(undefined);
773
- });
774
- };
775
- }
305
+ defaultLogger['default'] = defaultLogger;
306
+ return defaultLogger;
307
+ });
308
+ })(loglevel);
776
309
 
777
310
  function _defineProperty(obj, key, value) {
778
311
  if (key in obj) {
@@ -790,7 +323,7 @@ function _defineProperty(obj, key, value) {
790
323
  }
791
324
 
792
325
  function _slicedToArray(arr, i) {
793
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
326
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
794
327
  }
795
328
 
796
329
  function _arrayWithHoles(arr) {
@@ -798,13 +331,17 @@ function _arrayWithHoles(arr) {
798
331
  }
799
332
 
800
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;
801
337
  var _arr = [];
802
338
  var _n = true;
803
339
  var _d = false;
804
- var _e = undefined;
340
+
341
+ var _s, _e;
805
342
 
806
343
  try {
807
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
344
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
808
345
  _arr.push(_s.value);
809
346
 
810
347
  if (i && _arr.length === i) break;
@@ -823,26 +360,49 @@ function _iterableToArrayLimit(arr, i) {
823
360
  return _arr;
824
361
  }
825
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
+
826
380
  function _nonIterableRest() {
827
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
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.");
828
382
  }
829
383
 
830
- var has = function (obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop) };
384
+ var has = function (obj, prop) {
385
+ return Object.prototype.hasOwnProperty.call(obj, prop);
386
+ };
387
+
831
388
  var isEnumerable = function (obj, prop) {
832
- return Object.prototype.propertyIsEnumerable.call(obj, prop)
389
+ return Object.prototype.propertyIsEnumerable.call(obj, prop);
833
390
  };
834
391
 
835
- function entries (obj) {
392
+ function entries(obj) {
836
393
  if (obj == null) {
837
- throw new TypeError('Cannot convert undefined or null to object')
394
+ throw new TypeError('Cannot convert undefined or null to object');
838
395
  }
396
+
839
397
  var pairs = [];
398
+
840
399
  for (var key in obj) {
841
400
  if (has(obj, key) && isEnumerable(obj, key)) {
842
401
  pairs.push([key, obj[key]]);
843
402
  }
844
403
  }
845
- return pairs
404
+
405
+ return pairs;
846
406
  }
847
407
 
848
408
  var entries_1 = entries;
@@ -900,111 +460,6 @@ var commands = {
900
460
 
901
461
  var reversedCommands = reverse(commands);
902
462
 
903
- /**
904
- * Postmessage legacy protocol (3.5)
905
- */
906
-
907
- var protocol = {
908
- init: 'pluginLoaded',
909
- // send this if ready to communicate
910
- platformInfo: 'platformInfo',
911
- // receive this after pluginLoaded was sent
912
- startUpload: 'startImageUploadForPlugin',
913
- // start a file upload process
914
- finishUpload: 'finishedImageUploadForPlugin' // return the file data uploaded
915
-
916
- };
917
- var invocationMapping = _defineProperty({}, commands.nativeUpload, 'nativeFileUpload');
918
-
919
- /**
920
- * Generates an unique id of 4 alpha numerical chars
921
- *
922
- * @return {string} unique id
923
- */
924
- var genID = function genID() {
925
- return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
926
- };
927
-
928
- /**
929
- * @type {Object.<string, {resolve: function, reject: function, promise: Promise}>}
930
- */
931
-
932
- var promiseMap = {};
933
- /**
934
- * Create an info object for a new promise in the map.
935
- *
936
- * @return {string} id of the promise
937
- */
938
-
939
- function createPromiseObject() {
940
- var id = genID(); // When the id is already used, it invokes the function again
941
-
942
- if (id in promiseMap) return createPromiseObject();
943
- promiseMap[id] = {
944
- resolve: null,
945
- reject: null,
946
- promise: null
947
- };
948
- return id;
949
- }
950
- /**
951
- * Create a promise and return it's id.
952
- *
953
- * The id can be used to operate on the promise using other interface functions.
954
- *
955
- * @return {string} id of the promise
956
- */
957
-
958
-
959
- var create = function create() {
960
- var id = createPromiseObject();
961
- var p = new Promise(function (resolve, reject) {
962
- promiseMap[id].resolve = resolve;
963
- promiseMap[id].reject = reject;
964
- });
965
- promiseMap[id].promise = p;
966
- return id;
967
- };
968
- /**
969
- * Resolve a promise by id.
970
- *
971
- * @param {string} id of the promise
972
- * @param {any} msg the message which will will be passed to resolve
973
- *
974
- * @throws {Error} on unknown id
975
- */
976
-
977
- var resolve = function resolve(id, msg) {
978
- if (!(id in promiseMap)) throw new Error('Tried to resolve an unknown [' + id + '] promise.');
979
- promiseMap[id].resolve(msg);
980
- delete promiseMap[id];
981
- };
982
- /**
983
- * Reject a promise by id.
984
- *
985
- * @param {string} id of the promise
986
- * @param {any} err the error which will will be passed to reject
987
- * @throws {Error} on unknown id
988
- */
989
-
990
- var reject = function reject(id, err) {
991
- if (!(id in promiseMap)) throw new Error('Tried to reject an unknown [' + id + '] promise.');
992
- promiseMap[id].reject(err);
993
- delete promiseMap[id];
994
- };
995
- /**
996
- * Get a promise by id.
997
- *
998
- * @param {string} id of the promise
999
- * @return {Promise} the promise identified by id
1000
- * @throws {Error} on unknown id
1001
- */
1002
-
1003
- var get = function get(id) {
1004
- if (!(id in promiseMap)) throw new Error('Tried to get an unknown [' + id + '] promise.');
1005
- return promiseMap[id].promise;
1006
- };
1007
-
1008
463
  var locales = {
1009
464
  ar: {
1010
465
  key: 'ar',
@@ -1248,7 +703,7 @@ if (typeof window !== 'undefined') {
1248
703
  */
1249
704
 
1250
705
 
1251
- var getVersion = function getVersion() {
706
+ var getVersion$1 = function getVersion() {
1252
707
  return window.Staffbase.platform.version;
1253
708
  };
1254
709
  /**
@@ -1258,9 +713,9 @@ var getVersion = function getVersion() {
1258
713
  * @return {Boolean}
1259
714
  */
1260
715
 
1261
- var isNative = function isNative() {
716
+ var isNative$1 = function isNative() {
1262
717
  var safari = /safari/i.test(userAgent);
1263
- return window.Staffbase.platform.native === 'android' || window.Staffbase.platform.native === 'ios' || !safari && isIos();
718
+ return window.Staffbase.platform.native === 'android' || window.Staffbase.platform.native === 'ios' || !safari && isIos$1();
1264
719
  };
1265
720
  /**
1266
721
  * Are we running on a mobile device
@@ -1268,7 +723,7 @@ var isNative = function isNative() {
1268
723
  * @return {Boolean}
1269
724
  */
1270
725
 
1271
- var isMobile = function isMobile() {
726
+ var isMobile$1 = function isMobile() {
1272
727
  return window.Staffbase.platform.mobile;
1273
728
  };
1274
729
  /**
@@ -1277,7 +732,7 @@ var isMobile = function isMobile() {
1277
732
  * @return {Boolean}
1278
733
  */
1279
734
 
1280
- var isAndroid = function isAndroid() {
735
+ var isAndroid$1 = function isAndroid() {
1281
736
  return window.Staffbase.platform.native === 'android' || /Android/i.test(userAgent);
1282
737
  };
1283
738
  /**
@@ -1286,7 +741,7 @@ var isAndroid = function isAndroid() {
1286
741
  * @return {Boolean}
1287
742
  */
1288
743
 
1289
- var isIos = function isIos() {
744
+ var isIos$1 = function isIos() {
1290
745
  return window.Staffbase.platform.native === 'ios' || /iPhone|iPad|iPod/i.test(userAgent);
1291
746
  };
1292
747
  /**
@@ -1295,7 +750,7 @@ var isIos = function isIos() {
1295
750
  * @param {String} url address
1296
751
  */
1297
752
 
1298
- var openLink = function openLink(url) {
753
+ var openLink$2 = function openLink(url) {
1299
754
  window.open(url, '_blank');
1300
755
  };
1301
756
  /**
@@ -1315,7 +770,7 @@ var unSupported = function unSupported(cmd) {
1315
770
  */
1316
771
 
1317
772
  var langInfos = function langInfos() {
1318
- var branchDefaultLanguage = getBranchDefaultLanguage();
773
+ var branchDefaultLanguage = getBranchDefaultLanguage$2();
1319
774
  return {
1320
775
  contentLanguage: branchDefaultLanguage,
1321
776
  branchLanguages: locales,
@@ -1330,7 +785,7 @@ var langInfos = function langInfos() {
1330
785
  * @return {Object} the language object
1331
786
  */
1332
787
 
1333
- var getBranchDefaultLanguage = function getBranchDefaultLanguage() {
788
+ var getBranchDefaultLanguage$2 = function getBranchDefaultLanguage() {
1334
789
  return locales[currentLanguage] || locales.en;
1335
790
  };
1336
791
  /**
@@ -1341,8 +796,8 @@ var getBranchDefaultLanguage = function getBranchDefaultLanguage() {
1341
796
  * @return {string}
1342
797
  */
1343
798
 
1344
- var getPreferredContentLocale = function getPreferredContentLocale(content) {
1345
- var locale = getBranchDefaultLanguage().locale;
799
+ var getPreferredContentLocale$2 = function getPreferredContentLocale(content) {
800
+ var locale = getBranchDefaultLanguage$2().locale;
1346
801
 
1347
802
  if (!content) {
1348
803
  return locale;
@@ -1360,7 +815,7 @@ var getPreferredContentLocale = function getPreferredContentLocale(content) {
1360
815
  }
1361
816
  };
1362
817
 
1363
- var connection = null;
818
+ var connection$2 = null;
1364
819
  var fallbackKickIn = 500;
1365
820
  /**
1366
821
  * Fake connection to the Staffbase App after a period of time.
@@ -1371,16 +826,16 @@ var fallbackKickIn = 500;
1371
826
  */
1372
827
 
1373
828
  var fallback = (function () {
1374
- if (connection) {
1375
- return connection;
829
+ if (connection$2) {
830
+ return connection$2;
1376
831
  }
1377
832
 
1378
- connection = new Promise(function (resolve, reject) {
833
+ connection$2 = new Promise(function (resolve) {
1379
834
  setTimeout(function () {
1380
- resolve(sendMessage);
835
+ resolve(sendMessage$3);
1381
836
  }, fallbackKickIn);
1382
837
  });
1383
- return connection;
838
+ return connection$2;
1384
839
  });
1385
840
  /**
1386
841
  * Send a SDK command to the Staffbase App.
@@ -1392,260 +847,159 @@ var fallback = (function () {
1392
847
  * @throws {Error} on commands not supported by protocol
1393
848
  */
1394
849
 
1395
- var sendMessage =
1396
- /*#__PURE__*/
1397
- function () {
1398
- var _ref = _asyncToGenerator(
1399
- /*#__PURE__*/
1400
- regenerator.mark(function _callee(cmd) {
1401
- var _len,
1402
- payload,
1403
- _key,
1404
- _args = arguments;
1405
-
1406
- return regenerator.wrap(function _callee$(_context) {
1407
- while (1) {
1408
- switch (_context.prev = _context.next) {
1409
- case 0:
1410
- for (_len = _args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1411
- payload[_key - 1] = _args[_key];
1412
- }
850
+ var sendMessage$3 = function sendMessage(cmd) {
851
+ var $args = arguments;
852
+ return new Promise(function ($return, $error) {
853
+ for (var _len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
854
+ payload[_key - 1] = $args[_key];
855
+ }
1413
856
 
1414
- _context.t0 = cmd;
1415
- _context.next = _context.t0 === commands.version ? 4 : _context.t0 === commands.native ? 5 : _context.t0 === commands.mobile ? 6 : _context.t0 === commands.ios ? 7 : _context.t0 === commands.android ? 8 : _context.t0 === commands.openLink ? 9 : _context.t0 === commands.langInfos ? 10 : _context.t0 === commands.branchDefaultLang ? 11 : _context.t0 === commands.prefContentLang ? 12 : _context.t0 === commands.nativeUpload ? 13 : _context.t0 === commands.nativeShare ? 13 : 14;
1416
- break;
857
+ switch (cmd) {
858
+ case commands.version:
859
+ return $return(getVersion$1());
1417
860
 
1418
- case 4:
1419
- return _context.abrupt("return", getVersion());
861
+ case commands.native:
862
+ return $return(isNative$1());
1420
863
 
1421
- case 5:
1422
- return _context.abrupt("return", isNative());
864
+ case commands.mobile:
865
+ return $return(isMobile$1());
1423
866
 
1424
- case 6:
1425
- return _context.abrupt("return", isMobile());
867
+ case commands.ios:
868
+ return $return(isIos$1());
1426
869
 
1427
- case 7:
1428
- return _context.abrupt("return", isIos());
870
+ case commands.android:
871
+ return $return(isAndroid$1());
1429
872
 
1430
- case 8:
1431
- return _context.abrupt("return", isAndroid());
873
+ case commands.openLink:
874
+ return $return(openLink$2.apply(null, payload));
1432
875
 
1433
- case 9:
1434
- return _context.abrupt("return", openLink.apply(null, payload));
876
+ case commands.langInfos:
877
+ return $return(langInfos());
1435
878
 
1436
- case 10:
1437
- return _context.abrupt("return", langInfos());
879
+ case commands.branchDefaultLang:
880
+ return $return(getBranchDefaultLanguage$2());
1438
881
 
1439
- case 11:
1440
- return _context.abrupt("return", getBranchDefaultLanguage());
882
+ case commands.prefContentLang:
883
+ return $return(getPreferredContentLocale$2.apply(null, payload));
1441
884
 
1442
- case 12:
1443
- return _context.abrupt("return", getPreferredContentLocale.apply(null, payload));
885
+ case commands.nativeUpload:
886
+ case commands.nativeShare:
887
+ return $return(unSupported());
1444
888
 
1445
- case 13:
1446
- return _context.abrupt("return", unSupported());
889
+ default:
890
+ // should actually never ever happen
891
+ return $error(new Error('Command ' + cmd + ' not supported by driver'));
892
+ }
1447
893
 
1448
- case 14:
1449
- throw new Error('Command ' + cmd + ' not supported by driver');
894
+ return $return();
895
+ });
896
+ };
1450
897
 
1451
- case 15:
1452
- case "end":
1453
- return _context.stop();
1454
- }
1455
- }
1456
- }, _callee);
1457
- }));
898
+ var _invocationMapping;
899
+ /**
900
+ * Postmessage protocol (3.6)
901
+ */
1458
902
 
1459
- return function sendMessage(_x) {
1460
- return _ref.apply(this, arguments);
1461
- };
1462
- }();
903
+ var protocol = {
904
+ HELLO: 'HELLO',
905
+ // send this if ready to communicate
906
+ SUCCESS: 'SUCCESS',
907
+ // receive this after pluginLoaded was sent
908
+ INVOCATION: 'INVOCATION',
909
+ // send this to call a function in the frontend
910
+ ERROR: 'ERROR' // receive this when something goes wrong
911
+
912
+ };
913
+ var invocationMapping = (_invocationMapping = {}, _defineProperty(_invocationMapping, commands.openLink, 'openLink'), _defineProperty(_invocationMapping, commands.nativeUpload, 'nativeFileUpload'), _defineProperty(_invocationMapping, commands.nativeShare, 'nativeShareDialog'), _defineProperty(_invocationMapping, commands.langInfos, 'getPluginLanguageInfo'), _defineProperty(_invocationMapping, commands.prefContentLang, 'getPreferredContentLocale'), _invocationMapping);
1463
914
 
1464
- var connection$1 = null;
1465
- var connectId = null;
1466
- var targetOrigin = '*';
1467
915
  /**
1468
- * @typedef {{ mobile: boolean, version: string|number, native: string }} PlatformInfos
1469
- * @typedef {{ mobile: boolean, version: string|number, native: string, ios: boolean, android: boolean }} StaticValueStore
916
+ * Generates an unique id of 4 alpha numerical chars
917
+ *
918
+ * @return {string} unique id
1470
919
  */
920
+ var genID = function genID() {
921
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
922
+ };
1471
923
 
1472
924
  /**
1473
- * Simple store solution to make the initial data available
1474
- * as static values
925
+ * @type {Object.<string, {resolve: function, reject: function, promise: Promise}>}
926
+ */
927
+
928
+ var promiseMap = {};
929
+ /**
930
+ * Create an info object for a new promise in the map.
1475
931
  *
1476
- * @param {PlatformInfos} initial the initial data from the frontend
1477
- * @static
1478
- * @return {StaticValueStore}
932
+ * @return {string} id of the promise
1479
933
  */
1480
934
 
1481
- var dataStore = function dataStore(initial) {
1482
- return {
1483
- mobile: initial.mobile,
1484
- version: initial.version,
1485
- native: !!initial.native,
1486
- ios: initial.native === 'ios',
1487
- android: initial.native === 'android'
935
+ function createPromiseObject() {
936
+ var id = genID(); // When the id is already used, it invokes the function again
937
+
938
+ if (id in promiseMap) return createPromiseObject();
939
+ promiseMap[id] = {
940
+ resolve: null,
941
+ reject: null,
942
+ promise: null
1488
943
  };
1489
- };
944
+ return id;
945
+ }
1490
946
  /**
1491
- * Connect to the Staffbase App.
947
+ * Create a promise and return it's id.
1492
948
  *
1493
- * Create a connection to a Staffbase app 3.5
1494
- * @return {Promise<function>} An appropriate send function
949
+ * The id can be used to operate on the promise using other interface functions.
950
+ *
951
+ * @return {string} id of the promise
1495
952
  */
1496
953
 
1497
954
 
1498
- var connect = function connect() {
1499
- if (connection$1) {
1500
- return connection$1;
1501
- }
1502
-
1503
- connectId = create();
1504
- connection$1 = get(connectId).then(function (payload) {
1505
- return sendMessage$1(dataStore(payload));
955
+ var create = function create() {
956
+ var id = createPromiseObject();
957
+ var p = new Promise(function (resolve, reject) {
958
+ promiseMap[id].resolve = resolve;
959
+ promiseMap[id].reject = reject;
1506
960
  });
1507
- window.addEventListener('message', receiveMessage);
1508
- window.parent.postMessage(protocol.init, targetOrigin);
1509
- return connection$1;
961
+ promiseMap[id].promise = p;
962
+ return id;
1510
963
  };
1511
964
  /**
1512
- * Handler that receives a message from the Staffbase app
965
+ * Resolve a promise by id.
1513
966
  *
1514
- * Can be attached to window.onPostMessage
1515
- * @param {Object} an onPostMessage event result
1516
- */
1517
-
1518
- var receiveMessage =
1519
- /*#__PURE__*/
1520
- function () {
1521
- var _ref2 = _asyncToGenerator(
1522
- /*#__PURE__*/
1523
- regenerator.mark(function _callee(_ref) {
1524
- var _ref$data, data;
1525
-
1526
- return regenerator.wrap(function _callee$(_context) {
1527
- while (1) {
1528
- switch (_context.prev = _context.next) {
1529
- case 0:
1530
- _ref$data = _ref.data, data = _ref$data === void 0 ? {} : _ref$data;
1531
- _context.t0 = data.state;
1532
- _context.next = _context.t0 === protocol.platformInfo ? 4 : _context.t0 === protocol.finishUpload ? 6 : 8;
1533
- break;
1534
-
1535
- case 4:
1536
- resolve(connectId, data.info);
1537
- return _context.abrupt("break", 9);
1538
-
1539
- case 6:
1540
- resolve(connectId, data.file);
1541
- return _context.abrupt("break", 9);
1542
-
1543
- case 8:
1544
- return _context.abrupt("return");
1545
-
1546
- case 9:
1547
- case "end":
1548
- return _context.stop();
1549
- }
1550
- }
1551
- }, _callee);
1552
- }));
1553
-
1554
- return function receiveMessage(_x) {
1555
- return _ref2.apply(this, arguments);
1556
- };
1557
- }();
1558
- /**
1559
- * Send a SDK command to the Staffbase App.
967
+ * @param {string} id of the promise
968
+ * @param {any} msg the message which will will be passed to resolve
1560
969
  *
1561
- * Translates SDK commands into protocol native commands.
1562
- * @param {StaticValueStore} store the store object
1563
- * @param {String} cmd an SDK command
1564
- * @param {array} payload for the command
1565
- * @return {Promise<any>} which awaits the response of the Staffbase App
1566
- * @throws {Error} on commands not supported by protocol
970
+ * @throws {Error} on unknown id
1567
971
  */
1568
972
 
1569
-
1570
- var sendMessage$1 = function sendMessage$1(store) {
1571
- return (
1572
- /*#__PURE__*/
1573
- function () {
1574
- var _ref3 = _asyncToGenerator(
1575
- /*#__PURE__*/
1576
- regenerator.mark(function _callee2(cmd) {
1577
- var _len,
1578
- payload,
1579
- _key,
1580
- _args2 = arguments;
1581
-
1582
- return regenerator.wrap(function _callee2$(_context2) {
1583
- while (1) {
1584
- switch (_context2.prev = _context2.next) {
1585
- case 0:
1586
- for (_len = _args2.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1587
- payload[_key - 1] = _args2[_key];
1588
- }
1589
-
1590
- _context2.t0 = cmd;
1591
- _context2.next = _context2.t0 === commands.version ? 4 : _context2.t0 === commands.native ? 4 : _context2.t0 === commands.mobile ? 4 : _context2.t0 === commands.ios ? 4 : _context2.t0 === commands.android ? 4 : _context2.t0 === commands.nativeUpload ? 5 : 6;
1592
- break;
1593
-
1594
- case 4:
1595
- return _context2.abrupt("return", store[reversedCommands[cmd]]);
1596
-
1597
- case 5:
1598
- return _context2.abrupt("return", sendInvocationCall(invocationMapping[cmd]));
1599
-
1600
- case 6:
1601
- return _context2.abrupt("return", sendMessage.apply(null, [cmd].concat(payload)));
1602
-
1603
- case 7:
1604
- case "end":
1605
- return _context2.stop();
1606
- }
1607
- }
1608
- }, _callee2);
1609
- }));
1610
-
1611
- return function (_x2) {
1612
- return _ref3.apply(this, arguments);
1613
- };
1614
- }()
1615
- );
973
+ var resolve = function resolve(id, msg) {
974
+ if (!(id in promiseMap)) throw new Error('Tried to resolve an unknown [' + id + '] promise.');
975
+ promiseMap[id].resolve(msg);
976
+ delete promiseMap[id];
1616
977
  };
1617
978
  /**
1618
- * Create a promise and send an invocation call to the frontend
1619
- *
1620
- * @param {string} process the name of the process to call
1621
- * @param {array} args an array of arguments
979
+ * Reject a promise by id.
1622
980
  *
1623
- * @return {Promise}
981
+ * @param {string} id of the promise
982
+ * @param {any} err the error which will will be passed to reject
983
+ * @throws {Error} on unknown id
1624
984
  */
1625
985
 
1626
-
1627
- var sendInvocationCall = function sendInvocationCall(process, args) {
1628
- connectId = create();
1629
- window.parent.postMessage(protocol.startUpload, targetOrigin);
1630
- return get(connectId);
986
+ var reject = function reject(id, err) {
987
+ if (!(id in promiseMap)) throw new Error('Tried to reject an unknown [' + id + '] promise.');
988
+ promiseMap[id].reject(err);
989
+ delete promiseMap[id];
1631
990
  };
1632
-
1633
- var _invocationMapping;
1634
991
  /**
1635
- * Postmessage protocol (3.6)
992
+ * Get a promise by id.
993
+ *
994
+ * @param {string} id of the promise
995
+ * @return {Promise} the promise identified by id
996
+ * @throws {Error} on unknown id
1636
997
  */
1637
998
 
1638
- var protocol$1 = {
1639
- HELLO: 'HELLO',
1640
- // send this if ready to communicate
1641
- SUCCESS: 'SUCCESS',
1642
- // receive this after pluginLoaded was sent
1643
- INVOCATION: 'INVOCATION',
1644
- // send this to call a function in the frontend
1645
- ERROR: 'ERROR' // receive this when something goes wrong
1646
-
999
+ var get = function get(id) {
1000
+ if (!(id in promiseMap)) throw new Error('Tried to get an unknown [' + id + '] promise.');
1001
+ return promiseMap[id].promise;
1647
1002
  };
1648
- var invocationMapping$1 = (_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);
1649
1003
 
1650
1004
  /**
1651
1005
  * @typedef {{ mobile: boolean, version: string|number, native: string }} PlatformInfos
@@ -1680,8 +1034,8 @@ var dataStore$1 = function dataStore(_ref) {
1680
1034
  };
1681
1035
  };
1682
1036
 
1683
- var connection$2 = null;
1684
- var targetOrigin$1 = '*';
1037
+ var connection$1 = null;
1038
+ var targetOrigin = '*';
1685
1039
  /**
1686
1040
  * Connect to the Staffbase App.
1687
1041
  *
@@ -1689,18 +1043,18 @@ var targetOrigin$1 = '*';
1689
1043
  * @return {Promise<function>} An appropriate send function
1690
1044
  */
1691
1045
 
1692
- var connect$1 = function connect() {
1693
- if (connection$2) {
1694
- return connection$2;
1046
+ var connect$2 = function connect() {
1047
+ if (connection$1) {
1048
+ return connection$1;
1695
1049
  }
1696
1050
 
1697
1051
  var connectId = create();
1698
- connection$2 = get(connectId).then(function (payload) {
1052
+ connection$1 = get(connectId).then(function (payload) {
1699
1053
  return sendMessage$2(dataStore$1(payload));
1700
1054
  });
1701
- window.addEventListener('message', receiveMessage$1);
1702
- window.parent.postMessage([protocol$1.HELLO, connectId, []], targetOrigin$1);
1703
- return connection$2;
1055
+ window.addEventListener('message', receiveMessage);
1056
+ window.parent.postMessage([protocol.HELLO, connectId, []], targetOrigin);
1057
+ return connection$1;
1704
1058
  };
1705
1059
  /**
1706
1060
  * Handler that receives a message from the Staffbase app
@@ -1709,59 +1063,46 @@ var connect$1 = function connect() {
1709
1063
  * @param {MessageEvent} evt onPostMessage event result
1710
1064
  */
1711
1065
 
1712
- var receiveMessage$1 =
1713
- /*#__PURE__*/
1714
- function () {
1715
- var _ref2 = _asyncToGenerator(
1716
- /*#__PURE__*/
1717
- regenerator.mark(function _callee(evt) {
1718
- var type, id, payload, _evt$data;
1719
-
1720
- return regenerator.wrap(function _callee$(_context) {
1721
- while (1) {
1722
- switch (_context.prev = _context.next) {
1723
- case 0:
1724
- _context.prev = 0;
1725
- _evt$data = _slicedToArray(evt.data, 3);
1726
- type = _evt$data[0];
1727
- id = _evt$data[1];
1728
- payload = _evt$data[2];
1729
- _context.next = 10;
1730
- break;
1731
-
1732
- case 7:
1733
- _context.prev = 7;
1734
- _context.t0 = _context["catch"](0);
1735
- return _context.abrupt("return");
1736
-
1737
- case 10:
1738
- _context.t1 = type;
1739
- _context.next = _context.t1 === protocol$1.SUCCESS ? 13 : _context.t1 === protocol$1.ERROR ? 15 : 17;
1740
- break;
1741
-
1742
- case 13:
1743
- resolve(id, payload);
1744
- return _context.abrupt("break", 18);
1745
-
1746
- case 15:
1747
- reject(id, payload);
1748
- return _context.abrupt("break", 18);
1749
-
1750
- case 17:
1751
- return _context.abrupt("return");
1752
-
1753
- case 18:
1754
- case "end":
1755
- return _context.stop();
1756
- }
1757
- }
1758
- }, _callee, null, [[0, 7]]);
1759
- }));
1066
+ var receiveMessage = function receiveMessage(evt) {
1067
+ return new Promise(function ($return, $error) {
1068
+ var type;
1069
+ var id;
1070
+ var payload; // safe destructure
1760
1071
 
1761
- return function receiveMessage(_x) {
1762
- return _ref2.apply(this, arguments);
1763
- };
1764
- }();
1072
+ try {
1073
+ var _evt$data = _slicedToArray(evt.data, 3);
1074
+
1075
+ type = _evt$data[0];
1076
+ id = _evt$data[1];
1077
+ payload = _evt$data[2];
1078
+ } catch (e) {
1079
+ // even thought catch-ignore is a bad style
1080
+ // there may be other participants listening
1081
+ // to messages in a different format so we
1082
+ // silently ignore here
1083
+ return $return();
1084
+ }
1085
+
1086
+ switch (type) {
1087
+ case protocol.SUCCESS:
1088
+ resolve(id, payload);
1089
+ break;
1090
+
1091
+ case protocol.ERROR:
1092
+ reject(id, payload);
1093
+ break;
1094
+
1095
+ default:
1096
+ // even thought catch-ignore is a bad style
1097
+ // there may be other participants listening
1098
+ // to messages in a different format so we
1099
+ // silently ignore here
1100
+ return $return();
1101
+ }
1102
+
1103
+ return $return();
1104
+ });
1105
+ };
1765
1106
  /**
1766
1107
  * Send a SDK command to the Staffbase App.
1767
1108
  *
@@ -1775,51 +1116,36 @@ function () {
1775
1116
 
1776
1117
 
1777
1118
  var sendMessage$2 = function sendMessage(store) {
1778
- return (
1779
- /*#__PURE__*/
1780
- function () {
1781
- var _ref3 = _asyncToGenerator(
1782
- /*#__PURE__*/
1783
- regenerator.mark(function _callee2(cmd) {
1784
- var _len,
1785
- payload,
1786
- _key,
1787
- _args2 = arguments;
1788
-
1789
- return regenerator.wrap(function _callee2$(_context2) {
1790
- while (1) {
1791
- switch (_context2.prev = _context2.next) {
1792
- case 0:
1793
- _context2.t0 = cmd;
1794
- _context2.next = _context2.t0 === commands.version ? 3 : _context2.t0 === commands.native ? 3 : _context2.t0 === commands.mobile ? 3 : _context2.t0 === commands.ios ? 3 : _context2.t0 === commands.android ? 3 : _context2.t0 === commands.branchDefaultLang ? 3 : _context2.t0 === commands.langInfos ? 4 : _context2.t0 === commands.openLink ? 4 : _context2.t0 === commands.nativeUpload ? 4 : _context2.t0 === commands.nativeShare ? 4 : _context2.t0 === commands.prefContentLang ? 4 : 6;
1795
- break;
1796
-
1797
- case 3:
1798
- return _context2.abrupt("return", store[reversedCommands[cmd]]);
1799
-
1800
- case 4:
1801
- for (_len = _args2.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1802
- payload[_key - 1] = _args2[_key];
1803
- }
1804
-
1805
- return _context2.abrupt("return", sendInvocationCall$1(create())(invocationMapping$1[cmd], payload));
1806
-
1807
- case 6:
1808
- throw new Error('Command ' + cmd + ' not supported by driver');
1809
-
1810
- case 7:
1811
- case "end":
1812
- return _context2.stop();
1813
- }
1119
+ return function (cmd) {
1120
+ var $args = arguments;
1121
+ return new Promise(function ($return, $error) {
1122
+ switch (cmd) {
1123
+ case commands.version:
1124
+ case commands.native:
1125
+ case commands.mobile:
1126
+ case commands.ios:
1127
+ case commands.android:
1128
+ case commands.branchDefaultLang:
1129
+ return $return(store[reversedCommands[cmd]]);
1130
+
1131
+ case commands.langInfos:
1132
+ case commands.openLink:
1133
+ case commands.nativeUpload:
1134
+ case commands.nativeShare:
1135
+ case commands.prefContentLang:
1136
+ for (var _len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1137
+ payload[_key - 1] = $args[_key];
1814
1138
  }
1815
- }, _callee2);
1816
- }));
1817
1139
 
1818
- return function (_x2) {
1819
- return _ref3.apply(this, arguments);
1820
- };
1821
- }()
1822
- );
1140
+ return $return(sendInvocationCall$1(create())(invocationMapping[cmd], payload));
1141
+
1142
+ default:
1143
+ return $error(new Error('Command ' + cmd + ' not supported by driver'));
1144
+ }
1145
+
1146
+ return $return();
1147
+ });
1148
+ };
1823
1149
  };
1824
1150
  /**
1825
1151
  * Create a promise and send an invocation call to the frontend
@@ -1834,12 +1160,12 @@ var sendMessage$2 = function sendMessage(store) {
1834
1160
 
1835
1161
  var sendInvocationCall$1 = function sendInvocationCall(promiseID) {
1836
1162
  return function (process, args) {
1837
- window.parent.postMessage([protocol$1.INVOCATION, promiseID, process, args], targetOrigin$1);
1163
+ window.parent.postMessage([protocol.INVOCATION, promiseID, process, args], targetOrigin);
1838
1164
  return get(promiseID);
1839
1165
  };
1840
1166
  };
1841
1167
 
1842
- var connection$3 = null;
1168
+ var connection = null;
1843
1169
  var outMsgQueue = [];
1844
1170
  /**
1845
1171
  * Simple store solution to make the initial data available
@@ -1850,7 +1176,7 @@ var outMsgQueue = [];
1850
1176
  * @return {StaticValueStore}
1851
1177
  */
1852
1178
 
1853
- var dataStore$2 = function dataStore(_ref) {
1179
+ var dataStore = function dataStore(_ref) {
1854
1180
  var platform = _ref.platform,
1855
1181
  language = _ref.language;
1856
1182
  return {
@@ -1863,6 +1189,12 @@ var dataStore$2 = function dataStore(_ref) {
1863
1189
  branchDefaultLang: language.branchDefaultLanguage
1864
1190
  };
1865
1191
  };
1192
+
1193
+ window.Staffbase = window.Staffbase || {};
1194
+ window.Staffbase.plugins = {
1195
+ getMessages: multiMessageProvider,
1196
+ putMessage: singleMessageReceiver
1197
+ };
1866
1198
  /**
1867
1199
  * Connect to the Staffbase App.
1868
1200
  *
@@ -1870,23 +1202,17 @@ var dataStore$2 = function dataStore(_ref) {
1870
1202
  * @return {Promise<function>} An appropriate send function
1871
1203
  */
1872
1204
 
1873
-
1874
- var connect$2 = function connect() {
1875
- if (connection$3) {
1876
- return connection$3;
1205
+ var connect$1 = function connect() {
1206
+ if (connection) {
1207
+ return connection;
1877
1208
  }
1878
1209
 
1879
1210
  var connectId = create();
1880
- connection$3 = get(connectId).then(function (payload) {
1881
- return sendMessage$3(dataStore$2(payload));
1211
+ connection = get(connectId).then(function (payload) {
1212
+ return sendMessage$1(dataStore(payload));
1882
1213
  });
1883
- window.Staffbase = window.Staffbase || {};
1884
- window.Staffbase.plugins = {
1885
- getMessages: multiMessageProvider,
1886
- putMessage: singleMessageReceiver
1887
- };
1888
- outMsgQueue.push([protocol$1.HELLO, connectId, []]);
1889
- return connection$3;
1214
+ outMsgQueue.push([protocol.HELLO, connectId, []]);
1215
+ return connection;
1890
1216
  };
1891
1217
  /**
1892
1218
  * A function which returns an array of messages
@@ -1899,6 +1225,9 @@ var connect$2 = function connect() {
1899
1225
 
1900
1226
  function multiMessageProvider() {
1901
1227
  var queueRef = outMsgQueue;
1228
+
1229
+ if (queueRef.length) ;
1230
+
1902
1231
  outMsgQueue = [];
1903
1232
  return queueRef;
1904
1233
  }
@@ -1923,11 +1252,11 @@ function singleMessageReceiver(msg) {
1923
1252
  payload = _msg[2];
1924
1253
 
1925
1254
  switch (type) {
1926
- case protocol$1.SUCCESS:
1255
+ case protocol.SUCCESS:
1927
1256
  resolve(id, payload);
1928
1257
  break;
1929
1258
 
1930
- case protocol$1.ERROR:
1259
+ case protocol.ERROR:
1931
1260
  reject(id, payload);
1932
1261
  break;
1933
1262
 
@@ -1957,52 +1286,35 @@ function singleMessageReceiver(msg) {
1957
1286
  * @throws {Error} on commands not supported by protocol
1958
1287
  */
1959
1288
 
1960
- var sendMessage$3 = function sendMessage(store) {
1961
- return (
1962
- /*#__PURE__*/
1963
- function () {
1964
- var _ref2 = _asyncToGenerator(
1965
- /*#__PURE__*/
1966
- regenerator.mark(function _callee(cmd) {
1967
- var _len,
1968
- payload,
1969
- _key,
1970
- _args = arguments;
1971
-
1972
- return regenerator.wrap(function _callee$(_context) {
1973
- while (1) {
1974
- switch (_context.prev = _context.next) {
1975
- case 0:
1976
- _context.t0 = cmd;
1977
- _context.next = _context.t0 === commands.version ? 3 : _context.t0 === commands.native ? 3 : _context.t0 === commands.mobile ? 3 : _context.t0 === commands.ios ? 3 : _context.t0 === commands.android ? 3 : _context.t0 === commands.langInfos ? 3 : _context.t0 === commands.branchDefaultLang ? 3 : _context.t0 === commands.openLink ? 4 : _context.t0 === commands.prefContentLang ? 4 : 6;
1978
- break;
1979
-
1980
- case 3:
1981
- return _context.abrupt("return", store[reversedCommands[cmd]]);
1982
-
1983
- case 4:
1984
- for (_len = _args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1985
- payload[_key - 1] = _args[_key];
1986
- }
1987
-
1988
- return _context.abrupt("return", sendInvocationCall$2(invocationMapping$1[cmd], payload));
1989
-
1990
- case 6:
1991
- throw new Error('Command ' + cmd + ' not supported by driver');
1992
-
1993
- case 7:
1994
- case "end":
1995
- return _context.stop();
1996
- }
1289
+ var sendMessage$1 = function sendMessage(store) {
1290
+ return function (cmd) {
1291
+ var $args = arguments;
1292
+ return new Promise(function ($return, $error) {
1293
+ switch (cmd) {
1294
+ case commands.version:
1295
+ case commands.native:
1296
+ case commands.mobile:
1297
+ case commands.ios:
1298
+ case commands.android:
1299
+ case commands.langInfos:
1300
+ case commands.branchDefaultLang:
1301
+ return $return(store[reversedCommands[cmd]]);
1302
+
1303
+ case commands.openLink:
1304
+ case commands.prefContentLang:
1305
+ for (var _len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1306
+ payload[_key - 1] = $args[_key];
1997
1307
  }
1998
- }, _callee);
1999
- }));
2000
1308
 
2001
- return function (_x) {
2002
- return _ref2.apply(this, arguments);
2003
- };
2004
- }()
2005
- );
1309
+ return $return(sendInvocationCall(invocationMapping[cmd], payload));
1310
+
1311
+ default:
1312
+ return $error(new Error('Command ' + cmd + ' not supported by driver'));
1313
+ }
1314
+
1315
+ return $return();
1316
+ });
1317
+ };
2006
1318
  };
2007
1319
  /**
2008
1320
  * Create a promise and send an invocation call to the frontend
@@ -2014,53 +1326,29 @@ var sendMessage$3 = function sendMessage(store) {
2014
1326
  */
2015
1327
 
2016
1328
 
2017
- var sendInvocationCall$2 = function sendInvocationCall(process, args) {
1329
+ var sendInvocationCall = function sendInvocationCall(process, args) {
2018
1330
  var promiseID = create();
2019
- outMsgQueue.push([protocol$1.INVOCATION, promiseID, process, args]);
1331
+ outMsgQueue.push([protocol.INVOCATION, promiseID, process, args]);
2020
1332
  return get(promiseID);
2021
1333
  };
2022
1334
 
2023
1335
  var connector;
2024
1336
 
2025
- var connect$3 =
2026
- /*#__PURE__*/
2027
- function () {
2028
- var _ref = _asyncToGenerator(
2029
- /*#__PURE__*/
2030
- regenerator.mark(function _callee() {
2031
- var putMessageConnection, postMessageConnection, postMessagLegacyConnection, fallbackConnection, realConnectionBucket, fallbackConnectionBucket;
2032
- return regenerator.wrap(function _callee$(_context) {
2033
- while (1) {
2034
- switch (_context.prev = _context.next) {
2035
- case 0:
2036
- putMessageConnection = connect$2();
2037
- postMessageConnection = connect$1();
2038
- postMessagLegacyConnection = connect();
2039
- fallbackConnection = fallback();
2040
- realConnectionBucket = [putMessageConnection, postMessageConnection, postMessagLegacyConnection];
2041
- fallbackConnectionBucket = realConnectionBucket.concat(fallbackConnection); // Wait on the real communication and replace the connector with
2042
-
2043
- Promise.race(realConnectionBucket).then(function (newConnector) {
2044
- connector = newConnector;
2045
- });
2046
- _context.next = 9;
2047
- return Promise.race(fallbackConnectionBucket);
2048
-
2049
- case 9:
2050
- return _context.abrupt("return", _context.sent);
2051
-
2052
- case 10:
2053
- case "end":
2054
- return _context.stop();
2055
- }
2056
- }
2057
- }, _callee);
2058
- }));
2059
-
2060
- return function connect() {
2061
- return _ref.apply(this, arguments);
2062
- };
2063
- }();
1337
+ var connect = function connect() {
1338
+ return new Promise(function ($return, $error) {
1339
+ var putMessageConnection, postMessageConnection, fallbackConnection, realConnectionBucket, fallbackConnectionBucket;
1340
+ putMessageConnection = connect$1();
1341
+ postMessageConnection = connect$2();
1342
+ fallbackConnection = fallback();
1343
+ realConnectionBucket = [putMessageConnection, postMessageConnection];
1344
+ fallbackConnectionBucket = realConnectionBucket.concat(fallbackConnection);
1345
+ // Wait on the real communication and replace the connector with
1346
+ Promise.race(realConnectionBucket).then(function (newConnector) {
1347
+ connector = newConnector;
1348
+ });
1349
+ return Promise.resolve(Promise.race(fallbackConnectionBucket)).then($return, $error);
1350
+ });
1351
+ };
2064
1352
  /**
2065
1353
  * Send a message to the App
2066
1354
  *
@@ -2072,50 +1360,30 @@ function () {
2072
1360
  * @return {Promise<any>} result of the request
2073
1361
  */
2074
1362
 
2075
- var sendMessage$4 =
2076
- /*#__PURE__*/
2077
- function () {
2078
- var _ref2 = _asyncToGenerator(
2079
- /*#__PURE__*/
2080
- regenerator.mark(function _callee2(msg) {
2081
- var sendFn,
2082
- _len,
2083
- payload,
2084
- _key,
2085
- _args2 = arguments;
2086
-
2087
- return regenerator.wrap(function _callee2$(_context2) {
2088
- while (1) {
2089
- switch (_context2.prev = _context2.next) {
2090
- case 0:
2091
- if (!connector) {
2092
- connector = connect$3();
2093
- }
2094
-
2095
- _context2.next = 3;
2096
- return connector;
2097
-
2098
- case 3:
2099
- sendFn = _context2.sent;
1363
+ var sendMessage = function sendMessage(msg) {
1364
+ var $args = arguments;
1365
+ return new Promise(function ($return, $error) {
1366
+ var sendFn, _len, payload, _key;
2100
1367
 
2101
- for (_len = _args2.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2102
- payload[_key - 1] = _args2[_key];
2103
- }
1368
+ if (!connector) {
1369
+ connector = connect();
1370
+ }
2104
1371
 
2105
- return _context2.abrupt("return", sendFn.apply(void 0, [msg].concat(payload)));
1372
+ return Promise.resolve(connector).then(function ($await_2) {
1373
+ try {
1374
+ sendFn = $await_2;
2106
1375
 
2107
- case 6:
2108
- case "end":
2109
- return _context2.stop();
1376
+ for (_len = $args.length, payload = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1377
+ payload[_key - 1] = $args[_key];
2110
1378
  }
2111
- }
2112
- }, _callee2);
2113
- }));
2114
1379
 
2115
- return function sendMessage(_x) {
2116
- return _ref2.apply(this, arguments);
2117
- };
2118
- }();
1380
+ return $return(sendFn.apply(void 0, [msg].concat(payload)));
1381
+ } catch ($boundEx) {
1382
+ return $error($boundEx);
1383
+ }
1384
+ }, $error);
1385
+ });
1386
+ };
2119
1387
 
2120
1388
  /**
2121
1389
  * Get the version of the Staffbase App.
@@ -2123,90 +1391,33 @@ function () {
2123
1391
  * @return {Promise<string>}
2124
1392
  */
2125
1393
 
2126
- var getVersion$1 =
2127
- /*#__PURE__*/
2128
- function () {
2129
- var _ref = _asyncToGenerator(
2130
- /*#__PURE__*/
2131
- regenerator.mark(function _callee() {
2132
- return regenerator.wrap(function _callee$(_context) {
2133
- while (1) {
2134
- switch (_context.prev = _context.next) {
2135
- case 0:
2136
- return _context.abrupt("return", sendMessage$4(commands.version));
2137
-
2138
- case 1:
2139
- case "end":
2140
- return _context.stop();
2141
- }
2142
- }
2143
- }, _callee);
2144
- }));
2145
-
2146
- return function getVersion() {
2147
- return _ref.apply(this, arguments);
2148
- };
2149
- }();
1394
+ var getVersion = function getVersion() {
1395
+ return new Promise(function ($return, $error) {
1396
+ return $return(sendMessage(commands.version));
1397
+ });
1398
+ };
2150
1399
  /**
2151
1400
  * Check if app is native.
2152
1401
  *
2153
1402
  * @return {Promise<boolean>}
2154
1403
  */
2155
1404
 
2156
- var isNative$1 =
2157
- /*#__PURE__*/
2158
- function () {
2159
- var _ref2 = _asyncToGenerator(
2160
- /*#__PURE__*/
2161
- regenerator.mark(function _callee2() {
2162
- return regenerator.wrap(function _callee2$(_context2) {
2163
- while (1) {
2164
- switch (_context2.prev = _context2.next) {
2165
- case 0:
2166
- return _context2.abrupt("return", sendMessage$4(commands.native));
2167
-
2168
- case 1:
2169
- case "end":
2170
- return _context2.stop();
2171
- }
2172
- }
2173
- }, _callee2);
2174
- }));
2175
-
2176
- return function isNative() {
2177
- return _ref2.apply(this, arguments);
2178
- };
2179
- }();
1405
+ var isNative = function isNative() {
1406
+ return new Promise(function ($return, $error) {
1407
+ return $return(sendMessage(commands.native));
1408
+ });
1409
+ };
2180
1410
  /**
2181
1411
  * Check if app is mobile.
2182
1412
  *
2183
1413
  * @return {Promise<boolean>}
2184
1414
  */
2185
1415
 
2186
- var isMobile$1 =
2187
- /*#__PURE__*/
2188
- function () {
2189
- var _ref3 = _asyncToGenerator(
2190
- /*#__PURE__*/
2191
- regenerator.mark(function _callee3() {
2192
- return regenerator.wrap(function _callee3$(_context3) {
2193
- while (1) {
2194
- switch (_context3.prev = _context3.next) {
2195
- case 0:
2196
- return _context3.abrupt("return", sendMessage$4(commands.mobile));
2197
-
2198
- case 1:
2199
- case "end":
2200
- return _context3.stop();
2201
- }
2202
- }
2203
- }, _callee3);
2204
- }));
2205
-
2206
- return function isMobile() {
2207
- return _ref3.apply(this, arguments);
2208
- };
2209
- }();
1416
+ var isMobile = function isMobile() {
1417
+ return new Promise(function ($return, $error) {
1418
+ return $return(sendMessage(commands.mobile));
1419
+ });
1420
+ };
2210
1421
  /**
2211
1422
  * Open a link through the app.
2212
1423
  *
@@ -2218,30 +1429,11 @@ function () {
2218
1429
  * @return {Promise<any>}
2219
1430
  */
2220
1431
 
2221
- var openLink$1 =
2222
- /*#__PURE__*/
2223
- function () {
2224
- var _ref4 = _asyncToGenerator(
2225
- /*#__PURE__*/
2226
- regenerator.mark(function _callee4(url) {
2227
- return regenerator.wrap(function _callee4$(_context4) {
2228
- while (1) {
2229
- switch (_context4.prev = _context4.next) {
2230
- case 0:
2231
- return _context4.abrupt("return", sendMessage$4(commands.openLink, url));
2232
-
2233
- case 1:
2234
- case "end":
2235
- return _context4.stop();
2236
- }
2237
- }
2238
- }, _callee4);
2239
- }));
2240
-
2241
- return function openLink(_x) {
2242
- return _ref4.apply(this, arguments);
2243
- };
2244
- }();
1432
+ var openLink$1 = function openLink(url) {
1433
+ return new Promise(function ($return, $error) {
1434
+ return $return(sendMessage(commands.openLink, url));
1435
+ });
1436
+ };
2245
1437
  /**
2246
1438
  * Open a link explicitly in the external browser.
2247
1439
  *
@@ -2250,32 +1442,13 @@ function () {
2250
1442
  * @return {Promise<any>}
2251
1443
  */
2252
1444
 
2253
- var openLinkExternal =
2254
- /*#__PURE__*/
2255
- function () {
2256
- var _ref5 = _asyncToGenerator(
2257
- /*#__PURE__*/
2258
- regenerator.mark(function _callee5(url) {
2259
- return regenerator.wrap(function _callee5$(_context5) {
2260
- while (1) {
2261
- switch (_context5.prev = _context5.next) {
2262
- case 0:
2263
- return _context5.abrupt("return", sendMessage$4(commands.openLink, url, {
2264
- inAppBrowser: false
2265
- }));
2266
-
2267
- case 1:
2268
- case "end":
2269
- return _context5.stop();
2270
- }
2271
- }
2272
- }, _callee5);
2273
- }));
2274
-
2275
- return function openLinkExternal(_x2) {
2276
- return _ref5.apply(this, arguments);
2277
- };
2278
- }();
1445
+ var openLinkExternal$1 = function openLinkExternal(url) {
1446
+ return new Promise(function ($return, $error) {
1447
+ return $return(sendMessage(commands.openLink, url, {
1448
+ inAppBrowser: false
1449
+ }));
1450
+ });
1451
+ };
2279
1452
  /**
2280
1453
  * Open a link explicitly in the internal browser.
2281
1454
  *
@@ -2284,32 +1457,13 @@ function () {
2284
1457
  * @return {Promise<any>}
2285
1458
  */
2286
1459
 
2287
- var openLinkInternal =
2288
- /*#__PURE__*/
2289
- function () {
2290
- var _ref6 = _asyncToGenerator(
2291
- /*#__PURE__*/
2292
- regenerator.mark(function _callee6(url) {
2293
- return regenerator.wrap(function _callee6$(_context6) {
2294
- while (1) {
2295
- switch (_context6.prev = _context6.next) {
2296
- case 0:
2297
- return _context6.abrupt("return", sendMessage$4(commands.openLink, url, {
2298
- inAppBrowser: true
2299
- }));
2300
-
2301
- case 1:
2302
- case "end":
2303
- return _context6.stop();
2304
- }
2305
- }
2306
- }, _callee6);
2307
- }));
2308
-
2309
- return function openLinkInternal(_x3) {
2310
- return _ref6.apply(this, arguments);
2311
- };
2312
- }();
1460
+ var openLinkInternal$1 = function openLinkInternal(url) {
1461
+ return new Promise(function ($return, $error) {
1462
+ return $return(sendMessage(commands.openLink, url, {
1463
+ inAppBrowser: true
1464
+ }));
1465
+ });
1466
+ };
2313
1467
  /**
2314
1468
  * Open a native file upload dialog on device which do not support it by default.
2315
1469
  *
@@ -2318,30 +1472,11 @@ function () {
2318
1472
  * @return {Promise<any>}
2319
1473
  */
2320
1474
 
2321
- var openNativeFileDialog =
2322
- /*#__PURE__*/
2323
- function () {
2324
- var _ref7 = _asyncToGenerator(
2325
- /*#__PURE__*/
2326
- regenerator.mark(function _callee7() {
2327
- return regenerator.wrap(function _callee7$(_context7) {
2328
- while (1) {
2329
- switch (_context7.prev = _context7.next) {
2330
- case 0:
2331
- return _context7.abrupt("return", sendMessage$4(commands.nativeUpload));
2332
-
2333
- case 1:
2334
- case "end":
2335
- return _context7.stop();
2336
- }
2337
- }
2338
- }, _callee7);
2339
- }));
2340
-
2341
- return function openNativeFileDialog() {
2342
- return _ref7.apply(this, arguments);
2343
- };
2344
- }();
1475
+ var openNativeFileDialog = function openNativeFileDialog() {
1476
+ return new Promise(function ($return, $error) {
1477
+ return $return(sendMessage(commands.nativeUpload));
1478
+ });
1479
+ };
2345
1480
  /**
2346
1481
  * Open a share dialog on native devices
2347
1482
  *
@@ -2358,126 +1493,50 @@ function () {
2358
1493
  * @return {Promise<string>}
2359
1494
  */
2360
1495
 
2361
- var openNativeShareDialog =
2362
- /*#__PURE__*/
2363
- function () {
2364
- var _ref8 = _asyncToGenerator(
2365
- /*#__PURE__*/
2366
- regenerator.mark(function _callee8(content) {
2367
- return regenerator.wrap(function _callee8$(_context8) {
2368
- while (1) {
2369
- switch (_context8.prev = _context8.next) {
2370
- case 0:
2371
- return _context8.abrupt("return", sendMessage$4(commands.nativeShare, content));
2372
-
2373
- case 1:
2374
- case "end":
2375
- return _context8.stop();
2376
- }
2377
- }
2378
- }, _callee8);
2379
- }));
2380
-
2381
- return function openNativeShareDialog(_x4) {
2382
- return _ref8.apply(this, arguments);
2383
- };
2384
- }();
1496
+ var openNativeShareDialog$1 = function openNativeShareDialog(content) {
1497
+ return new Promise(function ($return, $error) {
1498
+ return $return(sendMessage(commands.nativeShare, content));
1499
+ });
1500
+ };
2385
1501
  /**
2386
1502
  * Get the content languages configured for the branch.
2387
1503
  *
2388
1504
  * @return {Promise<Object>}
2389
1505
  */
2390
1506
 
2391
- var getBranchLanguages =
2392
- /*#__PURE__*/
2393
- function () {
2394
- var _ref9 = _asyncToGenerator(
2395
- /*#__PURE__*/
2396
- regenerator.mark(function _callee9() {
2397
- return regenerator.wrap(function _callee9$(_context9) {
2398
- while (1) {
2399
- switch (_context9.prev = _context9.next) {
2400
- case 0:
2401
- return _context9.abrupt("return", sendMessage$4(commands.langInfos).then(function (res) {
2402
- return res.branchLanguages;
2403
- }));
2404
-
2405
- case 1:
2406
- case "end":
2407
- return _context9.stop();
2408
- }
2409
- }
2410
- }, _callee9);
2411
- }));
2412
-
2413
- return function getBranchLanguages() {
2414
- return _ref9.apply(this, arguments);
2415
- };
2416
- }();
1507
+ var getBranchLanguages$1 = function getBranchLanguages() {
1508
+ return new Promise(function ($return, $error) {
1509
+ return $return(sendMessage(commands.langInfos).then(function (res) {
1510
+ return res.branchLanguages;
1511
+ }));
1512
+ });
1513
+ };
2417
1514
  /**
2418
1515
  * Get the default content language configured for the branch.
2419
1516
  *
2420
1517
  * @return {Promise<Object>}
2421
1518
  */
2422
1519
 
2423
- var getBranchDefaultLanguage$1 =
2424
- /*#__PURE__*/
2425
- function () {
2426
- var _ref10 = _asyncToGenerator(
2427
- /*#__PURE__*/
2428
- regenerator.mark(function _callee10() {
2429
- return regenerator.wrap(function _callee10$(_context10) {
2430
- while (1) {
2431
- switch (_context10.prev = _context10.next) {
2432
- case 0:
2433
- return _context10.abrupt("return", sendMessage$4(commands.langInfos).then(function (res) {
2434
- return res.branchDefaultLanguage;
2435
- }));
2436
-
2437
- case 1:
2438
- case "end":
2439
- return _context10.stop();
2440
- }
2441
- }
2442
- }, _callee10);
2443
- }));
2444
-
2445
- return function getBranchDefaultLanguage() {
2446
- return _ref10.apply(this, arguments);
2447
- };
2448
- }();
1520
+ var getBranchDefaultLanguage$1 = function getBranchDefaultLanguage() {
1521
+ return new Promise(function ($return, $error) {
1522
+ return $return(sendMessage(commands.langInfos).then(function (res) {
1523
+ return res.branchDefaultLanguage;
1524
+ }));
1525
+ });
1526
+ };
2449
1527
  /**
2450
1528
  * Get all content languages supported by the Staffbase app.
2451
1529
  *
2452
1530
  * @return {Promise<Object>}
2453
1531
  */
2454
1532
 
2455
- var getContentLanguages =
2456
- /*#__PURE__*/
2457
- function () {
2458
- var _ref11 = _asyncToGenerator(
2459
- /*#__PURE__*/
2460
- regenerator.mark(function _callee11() {
2461
- return regenerator.wrap(function _callee11$(_context11) {
2462
- while (1) {
2463
- switch (_context11.prev = _context11.next) {
2464
- case 0:
2465
- return _context11.abrupt("return", sendMessage$4(commands.langInfos).then(function (res) {
2466
- return res.contentLanguages;
2467
- }));
2468
-
2469
- case 1:
2470
- case "end":
2471
- return _context11.stop();
2472
- }
2473
- }
2474
- }, _callee11);
2475
- }));
2476
-
2477
- return function getContentLanguages() {
2478
- return _ref11.apply(this, arguments);
2479
- };
2480
- }();
1533
+ var getContentLanguages$1 = function getContentLanguages() {
1534
+ return new Promise(function ($return, $error) {
1535
+ return $return(sendMessage(commands.langInfos).then(function (res) {
1536
+ return res.contentLanguages;
1537
+ }));
1538
+ });
1539
+ };
2481
1540
  /**
2482
1541
  * Gets the chosen language from a given content object
2483
1542
  *
@@ -2490,141 +1549,123 @@ function () {
2490
1549
  * @return {Promise<string>}
2491
1550
  */
2492
1551
 
2493
- var getPreferredContentLocale$1 =
2494
- /*#__PURE__*/
2495
- function () {
2496
- var _ref12 = _asyncToGenerator(
2497
- /*#__PURE__*/
2498
- regenerator.mark(function _callee12(content) {
2499
- return regenerator.wrap(function _callee12$(_context12) {
2500
- while (1) {
2501
- switch (_context12.prev = _context12.next) {
2502
- case 0:
2503
- return _context12.abrupt("return", sendMessage$4(commands.prefContentLang, content));
2504
-
2505
- case 1:
2506
- case "end":
2507
- return _context12.stop();
2508
- }
2509
- }
2510
- }, _callee12);
2511
- }));
1552
+ var getPreferredContentLocale$1 = function getPreferredContentLocale(content) {
1553
+ return new Promise(function ($return, $error) {
1554
+ return $return(sendMessage(commands.prefContentLang, content));
1555
+ });
1556
+ };
2512
1557
 
2513
- return function getPreferredContentLocale(_x5) {
2514
- return _ref12.apply(this, arguments);
2515
- };
2516
- }();
2517
-
2518
- var compareVersions = createCommonjsModule(function (module, exports) {
2519
- /* global define */
2520
- (function (root, factory) {
2521
- /* istanbul ignore next */
2522
- {
2523
- module.exports = factory();
2524
- }
2525
- }(commonjsGlobal, function () {
1558
+ function compareVersions(v1, v2) {
1559
+ // validate input and split into segments
1560
+ const n1 = validateAndParse(v1);
1561
+ const n2 = validateAndParse(v2); // pop off the patch
2526
1562
 
2527
- var semver = /^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
1563
+ const p1 = n1.pop();
1564
+ const p2 = n2.pop(); // validate numbers
2528
1565
 
2529
- function indexOrEnd(str, q) {
2530
- return str.indexOf(q) === -1 ? str.length : str.indexOf(q);
1566
+ const r = compareSegments(n1, n2);
1567
+ if (r !== 0) return r; // validate pre-release
1568
+
1569
+ if (p1 && p2) {
1570
+ return compareSegments(p1.split('.'), p2.split('.'));
1571
+ } else if (p1 || p2) {
1572
+ return p1 ? -1 : 1;
2531
1573
  }
2532
1574
 
2533
- function split(v) {
2534
- var c = v.replace(/^v/, '').replace(/\+.*$/, '');
2535
- var patchIndex = indexOrEnd(c, '-');
2536
- var arr = c.substring(0, patchIndex).split('.');
2537
- arr.push(c.substring(patchIndex + 1));
2538
- return arr;
1575
+ return 0;
1576
+ }
1577
+ const validate = v => typeof v === 'string' && /^[v\d]/.test(v) && semver.test(v);
1578
+ const compare = (v1, v2, operator) => {
1579
+ // validate input operator
1580
+ assertValidOperator(operator); // since result of compareVersions can only be -1 or 0 or 1
1581
+ // a simple map can be used to replace switch
1582
+
1583
+ const res = compareVersions(v1, v2);
1584
+ return operatorResMap[operator].includes(res);
1585
+ };
1586
+ const satisfies = (v, r) => {
1587
+ // if no range operator then "="
1588
+ const m = r.match(/^([<>=~^]+)/);
1589
+ const op = m ? m[1] : '='; // if gt/lt/eq then operator compare
1590
+
1591
+ if (op !== '^' && op !== '~') return compare(v, r, op); // else range of either "~" or "^" is assumed
1592
+
1593
+ const [v1, v2, v3] = validateAndParse(v);
1594
+ const [r1, r2, r3] = validateAndParse(r);
1595
+ if (compareStrings(v1, r1) !== 0) return false;
1596
+
1597
+ if (op === '^') {
1598
+ return compareSegments([v2, v3], [r2, r3]) >= 0;
2539
1599
  }
2540
1600
 
2541
- function tryParse(v) {
2542
- return isNaN(Number(v)) ? v : Number(v);
1601
+ if (compareStrings(v2, r2) !== 0) return false;
1602
+ return compareStrings(v3, r3) >= 0;
1603
+ }; // export CJS style for parity
1604
+
1605
+ compareVersions.validate = validate;
1606
+ compareVersions.compare = compare;
1607
+ compareVersions.sastisfies = satisfies;
1608
+ const semver = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
1609
+
1610
+ const validateAndParse = v => {
1611
+ if (typeof v !== 'string') {
1612
+ throw new TypeError('Invalid argument expected string');
2543
1613
  }
2544
1614
 
2545
- function validate(version) {
2546
- if (typeof version !== 'string') {
2547
- throw new TypeError('Invalid argument expected string');
2548
- }
2549
- if (!semver.test(version)) {
2550
- throw new Error('Invalid argument not valid semver (\''+version+'\' received)');
2551
- }
1615
+ const match = v.match(semver);
1616
+
1617
+ if (!match) {
1618
+ throw new Error(`Invalid argument not valid semver ('${v}' received)`);
2552
1619
  }
2553
1620
 
2554
- function compareVersions(v1, v2) {
2555
- [v1, v2].forEach(validate);
1621
+ match.shift();
1622
+ return match;
1623
+ };
2556
1624
 
2557
- var s1 = split(v1);
2558
- var s2 = split(v2);
1625
+ const isWildcard = s => s === '*' || s === 'x' || s === 'X';
2559
1626
 
2560
- for (var i = 0; i < Math.max(s1.length - 1, s2.length - 1); i++) {
2561
- var n1 = parseInt(s1[i] || 0, 10);
2562
- var n2 = parseInt(s2[i] || 0, 10);
1627
+ const tryParse = v => {
1628
+ const n = parseInt(v, 10);
1629
+ return isNaN(n) ? v : n;
1630
+ };
2563
1631
 
2564
- if (n1 > n2) return 1;
2565
- if (n2 > n1) return -1;
2566
- }
1632
+ const forceType = (a, b) => typeof a !== typeof b ? [String(a), String(b)] : [a, b];
2567
1633
 
2568
- var sp1 = s1[s1.length - 1];
2569
- var sp2 = s2[s2.length - 1];
1634
+ const compareStrings = (a, b) => {
1635
+ if (isWildcard(a) || isWildcard(b)) return 0;
1636
+ const [ap, bp] = forceType(tryParse(a), tryParse(b));
1637
+ if (ap > bp) return 1;
1638
+ if (ap < bp) return -1;
1639
+ return 0;
1640
+ };
2570
1641
 
2571
- if (sp1 && sp2) {
2572
- var p1 = sp1.split('.').map(tryParse);
2573
- var p2 = sp2.split('.').map(tryParse);
1642
+ const compareSegments = (a, b) => {
1643
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
1644
+ const r = compareStrings(a[i] || 0, b[i] || 0);
1645
+ if (r !== 0) return r;
1646
+ }
2574
1647
 
2575
- for (i = 0; i < Math.max(p1.length, p2.length); i++) {
2576
- if (p1[i] === undefined || typeof p2[i] === 'string' && typeof p1[i] === 'number') return -1;
2577
- if (p2[i] === undefined || typeof p1[i] === 'string' && typeof p2[i] === 'number') return 1;
1648
+ return 0;
1649
+ };
2578
1650
 
2579
- if (p1[i] > p2[i]) return 1;
2580
- if (p2[i] > p1[i]) return -1;
2581
- }
2582
- } else if (sp1 || sp2) {
2583
- return sp1 ? -1 : 1;
2584
- }
1651
+ const operatorResMap = {
1652
+ '>': [1],
1653
+ '>=': [0, 1],
1654
+ '=': [0],
1655
+ '<=': [-1, 0],
1656
+ '<': [-1]
1657
+ };
1658
+ const allowedOperators = Object.keys(operatorResMap);
2585
1659
 
2586
- return 0;
1660
+ const assertValidOperator = op => {
1661
+ if (typeof op !== 'string') {
1662
+ throw new TypeError(`Invalid operator type, expected string but got ${typeof op}`);
2587
1663
  }
2588
- var allowedOperators = [
2589
- '>',
2590
- '>=',
2591
- '=',
2592
- '<',
2593
- '<='
2594
- ];
2595
-
2596
- function validateOperator(op) {
2597
- if (typeof op !== 'string') {
2598
- throw new TypeError('Invalid operator type, expected string but got ' + typeof op);
2599
- }
2600
- if (allowedOperators.indexOf(op) === -1) {
2601
- throw new TypeError('Invalid operator, expected one of ' + allowedOperators.join('|'));
2602
- }
2603
- }
2604
-
2605
- compareVersions.compare = function (v1, v2, operator) {
2606
- // Validate operator
2607
- validateOperator(operator);
2608
-
2609
- // TODO: there might be a better way instead of doing this
2610
- switch(operator) {
2611
- case '>':
2612
- return compareVersions(v1, v2) > 0;
2613
- case '>=':
2614
- return compareVersions(v1, v2) >= 0;
2615
- case '<':
2616
- return compareVersions(v1, v2) < 0;
2617
- case '<=':
2618
- return compareVersions(v1, v2) <= 0;
2619
- default:
2620
- // Since validateOperator already checks the operator, this case in the switch checks for the '=' operator
2621
- return compareVersions(v1, v2) === 0;
2622
- }
2623
- };
2624
1664
 
2625
- return compareVersions;
2626
- }));
2627
- });
1665
+ if (allowedOperators.indexOf(op) === -1) {
1666
+ throw new Error(`Invalid operator, expected one of ${allowedOperators.join('|')}`);
1667
+ }
1668
+ };
2628
1669
 
2629
1670
  /**
2630
1671
  * Check if device is using ios.
@@ -2632,288 +1673,117 @@ var compareVersions = createCommonjsModule(function (module, exports) {
2632
1673
  * @return {Promise<boolean>}
2633
1674
  */
2634
1675
 
2635
- var isIos$1 =
2636
- /*#__PURE__*/
2637
- function () {
2638
- var _ref = _asyncToGenerator(
2639
- /*#__PURE__*/
2640
- regenerator.mark(function _callee() {
2641
- return regenerator.wrap(function _callee$(_context) {
2642
- while (1) {
2643
- switch (_context.prev = _context.next) {
2644
- case 0:
2645
- return _context.abrupt("return", sendMessage$4(commands.ios));
2646
-
2647
- case 1:
2648
- case "end":
2649
- return _context.stop();
2650
- }
2651
- }
2652
- }, _callee);
2653
- }));
2654
-
2655
- return function isIos() {
2656
- return _ref.apply(this, arguments);
2657
- };
2658
- }();
1676
+ var isIos = function isIos() {
1677
+ return new Promise(function ($return, $error) {
1678
+ return $return(sendMessage(commands.ios));
1679
+ });
1680
+ };
2659
1681
  /**
2660
1682
  * Check if device is using android.
2661
1683
  *
2662
1684
  * @return {Promise<boolean>}
2663
1685
  */
2664
1686
 
2665
- var isAndroid$1 =
2666
- /*#__PURE__*/
2667
- function () {
2668
- var _ref2 = _asyncToGenerator(
2669
- /*#__PURE__*/
2670
- regenerator.mark(function _callee2() {
2671
- return regenerator.wrap(function _callee2$(_context2) {
2672
- while (1) {
2673
- switch (_context2.prev = _context2.next) {
2674
- case 0:
2675
- return _context2.abrupt("return", sendMessage$4(commands.android));
2676
-
2677
- case 1:
2678
- case "end":
2679
- return _context2.stop();
2680
- }
2681
- }
2682
- }, _callee2);
2683
- }));
2684
-
2685
- return function isAndroid() {
2686
- return _ref2.apply(this, arguments);
2687
- };
2688
- }();
1687
+ var isAndroid = function isAndroid() {
1688
+ return new Promise(function ($return, $error) {
1689
+ return $return(sendMessage(commands.android));
1690
+ });
1691
+ };
2689
1692
  /**
2690
1693
  * Check if device is able to perform a download.
2691
1694
  *
2692
1695
  * @return {Promise<boolean>}
2693
1696
  */
2694
1697
 
2695
- var canDownload =
2696
- /*#__PURE__*/
2697
- function () {
2698
- var _ref3 = _asyncToGenerator(
2699
- /*#__PURE__*/
2700
- regenerator.mark(function _callee3() {
2701
- var _ref4, _ref5, native, version, ios, dashIndex;
2702
-
2703
- return regenerator.wrap(function _callee3$(_context3) {
2704
- while (1) {
2705
- switch (_context3.prev = _context3.next) {
2706
- case 0:
2707
- _context3.next = 2;
2708
- return Promise.all([isNative$1(), getVersion$1(), isIos$1()]);
2709
-
2710
- case 2:
2711
- _ref4 = _context3.sent;
2712
- _ref5 = _slicedToArray(_ref4, 3);
2713
- native = _ref5[0];
2714
- version = _ref5[1];
2715
- ios = _ref5[2];
2716
- // support any development versions like X.Y-dev for compare versions
2717
- dashIndex = version.indexOf('-');
2718
- version = version.substring(0, dashIndex != -1 ? dashIndex : version.length); // mobile ios devices can not download with an app version less than 3.5
2719
- // but apps below 3.5 don't have the platform information from the frontend available
2720
- // so we disable download for all native ios devices under these conditions
2721
-
2722
- return _context3.abrupt("return", !(compareVersions(version, '3.5') < 0 && native && ios));
2723
-
2724
- case 10:
2725
- case "end":
2726
- return _context3.stop();
2727
- }
2728
- }
2729
- }, _callee3);
2730
- }));
1698
+ var canDownload = function canDownload() {
1699
+ return new Promise(function ($return, $error) {
1700
+ var _await$Promise$all, _await$Promise$all2, native, version, ios, dashIndex;
2731
1701
 
2732
- return function canDownload() {
2733
- return _ref3.apply(this, arguments);
2734
- };
2735
- }();
1702
+ return Promise.resolve(Promise.all([isNative(), getVersion(), isIos()])).then(function ($await_1) {
1703
+ try {
1704
+ _await$Promise$all = $await_1, _await$Promise$all2 = _slicedToArray(_await$Promise$all, 3), native = _await$Promise$all2[0], version = _await$Promise$all2[1], ios = _await$Promise$all2[2];
1705
+ dashIndex = version.indexOf('-');
1706
+ version = version.substring(0, dashIndex != -1 ? dashIndex : version.length); // mobile ios devices can not download with an app version less than 3.5
1707
+ // but apps below 3.5 don't have the platform information from the frontend available
1708
+ // so we disable download for all native ios devices under these conditions
1709
+
1710
+ return $return(!(compareVersions(version, '3.5') < 0 && native && ios));
1711
+ } catch ($boundEx) {
1712
+ return $error($boundEx);
1713
+ }
1714
+ }, $error);
1715
+ });
1716
+ };
2736
1717
 
1718
+ /**
1719
+ * Interface exports
1720
+ */
2737
1721
  /**
2738
1722
  * Check if device is able to perform a download.
2739
1723
  * @function
2740
1724
  * @return {Promise<boolean>}
2741
1725
  */
2742
1726
 
2743
- var deviceCanDownload =
2744
- /*#__PURE__*/
2745
- function () {
2746
- var _ref = _asyncToGenerator(
2747
- /*#__PURE__*/
2748
- regenerator.mark(function _callee() {
2749
- return regenerator.wrap(function _callee$(_context) {
2750
- while (1) {
2751
- switch (_context.prev = _context.next) {
2752
- case 0:
2753
- return _context.abrupt("return", canDownload());
2754
-
2755
- case 1:
2756
- case "end":
2757
- return _context.stop();
2758
- }
2759
- }
2760
- }, _callee);
2761
- }));
2762
-
2763
- return function deviceCanDownload() {
2764
- return _ref.apply(this, arguments);
2765
- };
2766
- }();
1727
+ var deviceCanDownload = function deviceCanDownload() {
1728
+ return new Promise(function ($return, $error) {
1729
+ return $return(canDownload());
1730
+ });
1731
+ };
2767
1732
  /**
2768
1733
  * Check if device is using ios.
2769
1734
  * @function
2770
1735
  * @return {Promise<boolean>}
2771
1736
  */
2772
1737
 
2773
- var isIosDevice =
2774
- /*#__PURE__*/
2775
- function () {
2776
- var _ref2 = _asyncToGenerator(
2777
- /*#__PURE__*/
2778
- regenerator.mark(function _callee2() {
2779
- return regenerator.wrap(function _callee2$(_context2) {
2780
- while (1) {
2781
- switch (_context2.prev = _context2.next) {
2782
- case 0:
2783
- return _context2.abrupt("return", isIos$1());
2784
-
2785
- case 1:
2786
- case "end":
2787
- return _context2.stop();
2788
- }
2789
- }
2790
- }, _callee2);
2791
- }));
2792
-
2793
- return function isIosDevice() {
2794
- return _ref2.apply(this, arguments);
2795
- };
2796
- }();
1738
+ var isIosDevice = function isIosDevice() {
1739
+ return new Promise(function ($return, $error) {
1740
+ return $return(isIos());
1741
+ });
1742
+ };
2797
1743
  /**
2798
1744
  * Check if device is using android.
2799
1745
  * @function
2800
1746
  * @return {Promise<boolean>}
2801
1747
  */
2802
1748
 
2803
- var isAndroidDevice =
2804
- /*#__PURE__*/
2805
- function () {
2806
- var _ref3 = _asyncToGenerator(
2807
- /*#__PURE__*/
2808
- regenerator.mark(function _callee3() {
2809
- return regenerator.wrap(function _callee3$(_context3) {
2810
- while (1) {
2811
- switch (_context3.prev = _context3.next) {
2812
- case 0:
2813
- return _context3.abrupt("return", isAndroid$1());
2814
-
2815
- case 1:
2816
- case "end":
2817
- return _context3.stop();
2818
- }
2819
- }
2820
- }, _callee3);
2821
- }));
2822
-
2823
- return function isAndroidDevice() {
2824
- return _ref3.apply(this, arguments);
2825
- };
2826
- }();
1749
+ var isAndroidDevice = function isAndroidDevice() {
1750
+ return new Promise(function ($return, $error) {
1751
+ return $return(isAndroid());
1752
+ });
1753
+ };
2827
1754
  /**
2828
1755
  * Get the version of the Staffbase App.
2829
1756
  * @function
2830
1757
  * @return {Promise<string>}
2831
1758
  */
2832
1759
 
2833
- var getAppVersion =
2834
- /*#__PURE__*/
2835
- function () {
2836
- var _ref4 = _asyncToGenerator(
2837
- /*#__PURE__*/
2838
- regenerator.mark(function _callee4() {
2839
- return regenerator.wrap(function _callee4$(_context4) {
2840
- while (1) {
2841
- switch (_context4.prev = _context4.next) {
2842
- case 0:
2843
- return _context4.abrupt("return", getVersion$1());
2844
-
2845
- case 1:
2846
- case "end":
2847
- return _context4.stop();
2848
- }
2849
- }
2850
- }, _callee4);
2851
- }));
2852
-
2853
- return function getAppVersion() {
2854
- return _ref4.apply(this, arguments);
2855
- };
2856
- }();
1760
+ var getAppVersion = function getAppVersion() {
1761
+ return new Promise(function ($return, $error) {
1762
+ return $return(getVersion());
1763
+ });
1764
+ };
2857
1765
  /**
2858
1766
  * Check if app is native.
2859
1767
  * @function
2860
1768
  * @return {Promise<boolean>}
2861
1769
  */
2862
1770
 
2863
- var isNativeApp =
2864
- /*#__PURE__*/
2865
- function () {
2866
- var _ref5 = _asyncToGenerator(
2867
- /*#__PURE__*/
2868
- regenerator.mark(function _callee5() {
2869
- return regenerator.wrap(function _callee5$(_context5) {
2870
- while (1) {
2871
- switch (_context5.prev = _context5.next) {
2872
- case 0:
2873
- return _context5.abrupt("return", isNative$1());
2874
-
2875
- case 1:
2876
- case "end":
2877
- return _context5.stop();
2878
- }
2879
- }
2880
- }, _callee5);
2881
- }));
2882
-
2883
- return function isNativeApp() {
2884
- return _ref5.apply(this, arguments);
2885
- };
2886
- }();
1771
+ var isNativeApp = function isNativeApp() {
1772
+ return new Promise(function ($return, $error) {
1773
+ return $return(isNative());
1774
+ });
1775
+ };
2887
1776
  /**
2888
1777
  * Check if app is mobile.
2889
1778
  * @function
2890
1779
  * @return {Promise<boolean>}
2891
1780
  */
2892
1781
 
2893
- var isMobileApp =
2894
- /*#__PURE__*/
2895
- function () {
2896
- var _ref6 = _asyncToGenerator(
2897
- /*#__PURE__*/
2898
- regenerator.mark(function _callee6() {
2899
- return regenerator.wrap(function _callee6$(_context6) {
2900
- while (1) {
2901
- switch (_context6.prev = _context6.next) {
2902
- case 0:
2903
- return _context6.abrupt("return", isMobile$1());
2904
-
2905
- case 1:
2906
- case "end":
2907
- return _context6.stop();
2908
- }
2909
- }
2910
- }, _callee6);
2911
- }));
2912
-
2913
- return function isMobileApp() {
2914
- return _ref6.apply(this, arguments);
2915
- };
2916
- }();
1782
+ var isMobileApp = function isMobileApp() {
1783
+ return new Promise(function ($return, $error) {
1784
+ return $return(isMobile());
1785
+ });
1786
+ };
2917
1787
  /**
2918
1788
  * Open a link through the app.
2919
1789
  *
@@ -2925,30 +1795,11 @@ function () {
2925
1795
  * @return {Promise<any>}
2926
1796
  */
2927
1797
 
2928
- var openLink$2 =
2929
- /*#__PURE__*/
2930
- function () {
2931
- var _ref7 = _asyncToGenerator(
2932
- /*#__PURE__*/
2933
- regenerator.mark(function _callee7(url) {
2934
- return regenerator.wrap(function _callee7$(_context7) {
2935
- while (1) {
2936
- switch (_context7.prev = _context7.next) {
2937
- case 0:
2938
- return _context7.abrupt("return", openLink$1(url));
2939
-
2940
- case 1:
2941
- case "end":
2942
- return _context7.stop();
2943
- }
2944
- }
2945
- }, _callee7);
2946
- }));
2947
-
2948
- return function openLink(_x) {
2949
- return _ref7.apply(this, arguments);
2950
- };
2951
- }();
1798
+ var openLink = function openLink(url) {
1799
+ return new Promise(function ($return, $error) {
1800
+ return $return(openLink$1(url));
1801
+ });
1802
+ };
2952
1803
  /**
2953
1804
  * Open a link explicitly in the external browser.
2954
1805
  *
@@ -2957,30 +1808,11 @@ function () {
2957
1808
  * @return {Promise<any>}
2958
1809
  */
2959
1810
 
2960
- var openLinkExternal$1 =
2961
- /*#__PURE__*/
2962
- function () {
2963
- var _ref8 = _asyncToGenerator(
2964
- /*#__PURE__*/
2965
- regenerator.mark(function _callee8(url) {
2966
- return regenerator.wrap(function _callee8$(_context8) {
2967
- while (1) {
2968
- switch (_context8.prev = _context8.next) {
2969
- case 0:
2970
- return _context8.abrupt("return", openLinkExternal(url));
2971
-
2972
- case 1:
2973
- case "end":
2974
- return _context8.stop();
2975
- }
2976
- }
2977
- }, _callee8);
2978
- }));
2979
-
2980
- return function openLinkExternal(_x2) {
2981
- return _ref8.apply(this, arguments);
2982
- };
2983
- }();
1811
+ var openLinkExternal = function openLinkExternal(url) {
1812
+ return new Promise(function ($return, $error) {
1813
+ return $return(openLinkExternal$1(url));
1814
+ });
1815
+ };
2984
1816
  /**
2985
1817
  * Open a link explicitly in the internal browser.
2986
1818
  *
@@ -2989,120 +1821,44 @@ function () {
2989
1821
  * @return {Promise<any>}
2990
1822
  */
2991
1823
 
2992
- var openLinkInternal$1 =
2993
- /*#__PURE__*/
2994
- function () {
2995
- var _ref9 = _asyncToGenerator(
2996
- /*#__PURE__*/
2997
- regenerator.mark(function _callee9(url) {
2998
- return regenerator.wrap(function _callee9$(_context9) {
2999
- while (1) {
3000
- switch (_context9.prev = _context9.next) {
3001
- case 0:
3002
- return _context9.abrupt("return", openLinkInternal(url));
3003
-
3004
- case 1:
3005
- case "end":
3006
- return _context9.stop();
3007
- }
3008
- }
3009
- }, _callee9);
3010
- }));
3011
-
3012
- return function openLinkInternal(_x3) {
3013
- return _ref9.apply(this, arguments);
3014
- };
3015
- }();
1824
+ var openLinkInternal = function openLinkInternal(url) {
1825
+ return new Promise(function ($return, $error) {
1826
+ return $return(openLinkInternal$1(url));
1827
+ });
1828
+ };
3016
1829
  /**
3017
1830
  * Get all enabled content languages configured in the app.
3018
1831
  * @function
3019
1832
  * @return {Promise<any>}
3020
1833
  */
3021
1834
 
3022
- var getBranchLanguages$1 =
3023
- /*#__PURE__*/
3024
- function () {
3025
- var _ref10 = _asyncToGenerator(
3026
- /*#__PURE__*/
3027
- regenerator.mark(function _callee10() {
3028
- return regenerator.wrap(function _callee10$(_context10) {
3029
- while (1) {
3030
- switch (_context10.prev = _context10.next) {
3031
- case 0:
3032
- return _context10.abrupt("return", getBranchLanguages());
3033
-
3034
- case 1:
3035
- case "end":
3036
- return _context10.stop();
3037
- }
3038
- }
3039
- }, _callee10);
3040
- }));
3041
-
3042
- return function getBranchLanguages() {
3043
- return _ref10.apply(this, arguments);
3044
- };
3045
- }();
1835
+ var getBranchLanguages = function getBranchLanguages() {
1836
+ return new Promise(function ($return, $error) {
1837
+ return $return(getBranchLanguages$1());
1838
+ });
1839
+ };
3046
1840
  /**
3047
1841
  * Get the default content language configured in the app.
3048
1842
  * @function
3049
1843
  * @return {Promise<any>}
3050
1844
  */
3051
1845
 
3052
- var getBranchDefaultLanguage$2 =
3053
- /*#__PURE__*/
3054
- function () {
3055
- var _ref11 = _asyncToGenerator(
3056
- /*#__PURE__*/
3057
- regenerator.mark(function _callee11() {
3058
- return regenerator.wrap(function _callee11$(_context11) {
3059
- while (1) {
3060
- switch (_context11.prev = _context11.next) {
3061
- case 0:
3062
- return _context11.abrupt("return", getBranchDefaultLanguage$1());
3063
-
3064
- case 1:
3065
- case "end":
3066
- return _context11.stop();
3067
- }
3068
- }
3069
- }, _callee11);
3070
- }));
3071
-
3072
- return function getBranchDefaultLanguage() {
3073
- return _ref11.apply(this, arguments);
3074
- };
3075
- }();
1846
+ var getBranchDefaultLanguage = function getBranchDefaultLanguage() {
1847
+ return new Promise(function ($return, $error) {
1848
+ return $return(getBranchDefaultLanguage$1());
1849
+ });
1850
+ };
3076
1851
  /**
3077
1852
  * Get all content languages supported by the app.
3078
1853
  * @function
3079
1854
  * @return {Promise<any>}
3080
1855
  */
3081
1856
 
3082
- var getContentLanguages$1 =
3083
- /*#__PURE__*/
3084
- function () {
3085
- var _ref12 = _asyncToGenerator(
3086
- /*#__PURE__*/
3087
- regenerator.mark(function _callee12() {
3088
- return regenerator.wrap(function _callee12$(_context12) {
3089
- while (1) {
3090
- switch (_context12.prev = _context12.next) {
3091
- case 0:
3092
- return _context12.abrupt("return", getContentLanguages());
3093
-
3094
- case 1:
3095
- case "end":
3096
- return _context12.stop();
3097
- }
3098
- }
3099
- }, _callee12);
3100
- }));
3101
-
3102
- return function getContentLanguages() {
3103
- return _ref12.apply(this, arguments);
3104
- };
3105
- }();
1857
+ var getContentLanguages = function getContentLanguages() {
1858
+ return new Promise(function ($return, $error) {
1859
+ return $return(getContentLanguages$1());
1860
+ });
1861
+ };
3106
1862
  /**
3107
1863
  * Gets the chosen language from a given content object
3108
1864
  *
@@ -3115,30 +1871,11 @@ function () {
3115
1871
  * @return {Promise<string>}
3116
1872
  */
3117
1873
 
3118
- var getPreferredContentLocale$2 =
3119
- /*#__PURE__*/
3120
- function () {
3121
- var _ref13 = _asyncToGenerator(
3122
- /*#__PURE__*/
3123
- regenerator.mark(function _callee13(content) {
3124
- return regenerator.wrap(function _callee13$(_context13) {
3125
- while (1) {
3126
- switch (_context13.prev = _context13.next) {
3127
- case 0:
3128
- return _context13.abrupt("return", getPreferredContentLocale$1(content));
3129
-
3130
- case 1:
3131
- case "end":
3132
- return _context13.stop();
3133
- }
3134
- }
3135
- }, _callee13);
3136
- }));
3137
-
3138
- return function getPreferredContentLocale(_x4) {
3139
- return _ref13.apply(this, arguments);
3140
- };
3141
- }();
1874
+ var getPreferredContentLocale = function getPreferredContentLocale(content) {
1875
+ return new Promise(function ($return, $error) {
1876
+ return $return(getPreferredContentLocale$1(content));
1877
+ });
1878
+ };
3142
1879
  /**
3143
1880
  * Open a share dialog on native devices
3144
1881
  *
@@ -3155,45 +1892,26 @@ function () {
3155
1892
  * @return {Promise<string>}
3156
1893
  */
3157
1894
 
3158
- var openNativeShareDialog$1 =
3159
- /*#__PURE__*/
3160
- function () {
3161
- var _ref14 = _asyncToGenerator(
3162
- /*#__PURE__*/
3163
- regenerator.mark(function _callee14(content) {
3164
- return regenerator.wrap(function _callee14$(_context14) {
3165
- while (1) {
3166
- switch (_context14.prev = _context14.next) {
3167
- case 0:
3168
- return _context14.abrupt("return", openNativeShareDialog(content));
3169
-
3170
- case 1:
3171
- case "end":
3172
- return _context14.stop();
3173
- }
3174
- }
3175
- }, _callee14);
3176
- }));
3177
-
3178
- return function openNativeShareDialog(_x5) {
3179
- return _ref14.apply(this, arguments);
3180
- };
3181
- }();
1895
+ var openNativeShareDialog = function openNativeShareDialog(content) {
1896
+ return new Promise(function ($return, $error) {
1897
+ return $return(openNativeShareDialog$1(content));
1898
+ });
1899
+ };
3182
1900
  /* experimental */
3183
1901
 
3184
1902
  exports.deviceCanDownload = deviceCanDownload;
3185
1903
  exports.getAppVersion = getAppVersion;
3186
- exports.getBranchDefaultLanguage = getBranchDefaultLanguage$2;
3187
- exports.getBranchLanguages = getBranchLanguages$1;
3188
- exports.getContentLanguages = getContentLanguages$1;
3189
- exports.getPreferredContentLocale = getPreferredContentLocale$2;
1904
+ exports.getBranchDefaultLanguage = getBranchDefaultLanguage;
1905
+ exports.getBranchLanguages = getBranchLanguages;
1906
+ exports.getContentLanguages = getContentLanguages;
1907
+ exports.getPreferredContentLocale = getPreferredContentLocale;
3190
1908
  exports.isAndroidDevice = isAndroidDevice;
3191
1909
  exports.isIosDevice = isIosDevice;
3192
1910
  exports.isMobileApp = isMobileApp;
3193
1911
  exports.isNativeApp = isNativeApp;
3194
- exports.openLink = openLink$2;
3195
- exports.openLinkExternal = openLinkExternal$1;
3196
- exports.openLinkInternal = openLinkInternal$1;
1912
+ exports.openLink = openLink;
1913
+ exports.openLinkExternal = openLinkExternal;
1914
+ exports.openLinkInternal = openLinkInternal;
3197
1915
  exports.openNativeFileDialog = openNativeFileDialog;
3198
- exports.openNativeShareDialog = openNativeShareDialog$1;
1916
+ exports.openNativeShareDialog = openNativeShareDialog;
3199
1917
  //# sourceMappingURL=plugins-client-sdk.js.map