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