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