@freelog/tools-lib 0.1.89 → 0.1.93
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/LICENSE +20 -20
- package/README.md +103 -103
- package/dist/service-API/activities.d.ts +12 -0
- package/dist/service-API/informalNodes.d.ts +15 -45
- package/dist/service-API/policies.d.ts +2 -6
- package/dist/tools-lib.cjs.development.js +536 -926
- package/dist/tools-lib.cjs.development.js.map +1 -1
- package/dist/tools-lib.cjs.production.min.js +1 -1
- package/dist/tools-lib.cjs.production.min.js.map +1 -1
- package/dist/tools-lib.esm.js +536 -926
- package/dist/tools-lib.esm.js.map +1 -1
- package/dist/utils/axios.d.ts +1 -4
- package/package.json +1 -1
- package/src/index.ts +7 -7
- package/src/service-API/activities.ts +32 -0
- package/src/service-API/captcha.ts +30 -30
- package/src/service-API/collections.ts +81 -81
- package/src/service-API/contracts.ts +84 -84
- package/src/service-API/events.ts +18 -18
- package/src/service-API/index.ts +29 -29
- package/src/service-API/informalNodes.ts +238 -238
- package/src/service-API/nodes.ts +65 -65
- package/src/service-API/policies.ts +39 -39
- package/src/service-API/presentables.ts +282 -282
- package/src/service-API/resources.ts +496 -496
- package/src/service-API/storages.ts +345 -345
- package/src/service-API/tools/index.ts +10 -10
- package/src/service-API/transactions.ts +109 -109
- package/src/service-API/user.ts +188 -188
- package/src/utils/axios.ts +8 -3
- package/src/utils/format.ts +89 -89
- package/src/utils/index.ts +18 -18
- package/src/utils/linkTo.ts +332 -332
- package/src/utils/predefined.ts +37 -37
- package/src/utils/regexp.ts +52 -52
- package/src/utils/tools.ts +72 -72
package/dist/tools-lib.esm.js
CHANGED
|
@@ -6,832 +6,422 @@ import NProgress from 'nprogress';
|
|
|
6
6
|
import 'nprogress/nprogress.css';
|
|
7
7
|
import { lib, SHA1 } from 'crypto-js';
|
|
8
8
|
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
var info = gen[key](arg);
|
|
12
|
-
var value = info.value;
|
|
13
|
-
} catch (error) {
|
|
14
|
-
reject(error);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (info.done) {
|
|
19
|
-
resolve(value);
|
|
20
|
-
} else {
|
|
21
|
-
Promise.resolve(value).then(_next, _throw);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function _asyncToGenerator(fn) {
|
|
26
|
-
return function () {
|
|
27
|
-
var self = this,
|
|
28
|
-
args = arguments;
|
|
29
|
-
return new Promise(function (resolve, reject) {
|
|
30
|
-
var gen = fn.apply(self, args);
|
|
31
|
-
|
|
32
|
-
function _next(value) {
|
|
33
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
34
|
-
}
|
|
9
|
+
function _regeneratorRuntime() {
|
|
10
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
35
11
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
_next(undefined);
|
|
41
|
-
});
|
|
12
|
+
_regeneratorRuntime = function () {
|
|
13
|
+
return exports;
|
|
42
14
|
};
|
|
43
|
-
}
|
|
44
15
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
target[key] = source[key];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return target;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return _extends.apply(this, arguments);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _objectDestructuringEmpty(obj) {
|
|
64
|
-
if (obj == null) throw new TypeError("Cannot destructure undefined");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
68
|
-
if (source == null) return {};
|
|
69
|
-
var target = {};
|
|
70
|
-
var sourceKeys = Object.keys(source);
|
|
71
|
-
var key, i;
|
|
72
|
-
|
|
73
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
74
|
-
key = sourceKeys[i];
|
|
75
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
76
|
-
target[key] = source[key];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return target;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function createCommonjsModule(fn, module) {
|
|
83
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
var runtime_1 = createCommonjsModule(function (module) {
|
|
87
|
-
/**
|
|
88
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
89
|
-
*
|
|
90
|
-
* This source code is licensed under the MIT license found in the
|
|
91
|
-
* LICENSE file in the root directory of this source tree.
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
var runtime = (function (exports) {
|
|
95
|
-
|
|
96
|
-
var Op = Object.prototype;
|
|
97
|
-
var hasOwn = Op.hasOwnProperty;
|
|
98
|
-
var undefined$1; // More compressible than void 0.
|
|
99
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
100
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
101
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
102
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
16
|
+
var exports = {},
|
|
17
|
+
Op = Object.prototype,
|
|
18
|
+
hasOwn = Op.hasOwnProperty,
|
|
19
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
20
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
21
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
22
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
103
23
|
|
|
104
24
|
function define(obj, key, value) {
|
|
105
|
-
Object.defineProperty(obj, key, {
|
|
25
|
+
return Object.defineProperty(obj, key, {
|
|
106
26
|
value: value,
|
|
107
|
-
enumerable:
|
|
108
|
-
configurable:
|
|
109
|
-
writable:
|
|
110
|
-
});
|
|
111
|
-
return obj[key];
|
|
27
|
+
enumerable: !0,
|
|
28
|
+
configurable: !0,
|
|
29
|
+
writable: !0
|
|
30
|
+
}), obj[key];
|
|
112
31
|
}
|
|
32
|
+
|
|
113
33
|
try {
|
|
114
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
115
34
|
define({}, "");
|
|
116
35
|
} catch (err) {
|
|
117
|
-
define = function(obj, key, value) {
|
|
36
|
+
define = function (obj, key, value) {
|
|
118
37
|
return obj[key] = value;
|
|
119
38
|
};
|
|
120
39
|
}
|
|
121
40
|
|
|
122
41
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
42
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
43
|
+
generator = Object.create(protoGenerator.prototype),
|
|
44
|
+
context = new Context(tryLocsList || []);
|
|
45
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
46
|
+
var state = "suspendedStart";
|
|
47
|
+
return function (method, arg) {
|
|
48
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
49
|
+
|
|
50
|
+
if ("completed" === state) {
|
|
51
|
+
if ("throw" === method) throw arg;
|
|
52
|
+
return doneResult();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
for (context.method = method, context.arg = arg;;) {
|
|
56
|
+
var delegate = context.delegate;
|
|
57
|
+
|
|
58
|
+
if (delegate) {
|
|
59
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
60
|
+
|
|
61
|
+
if (delegateResult) {
|
|
62
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
63
|
+
return delegateResult;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
127
66
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
67
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
68
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
69
|
+
context.dispatchException(context.arg);
|
|
70
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
71
|
+
state = "executing";
|
|
72
|
+
var record = tryCatch(innerFn, self, context);
|
|
73
|
+
|
|
74
|
+
if ("normal" === record.type) {
|
|
75
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
76
|
+
return {
|
|
77
|
+
value: record.arg,
|
|
78
|
+
done: context.done
|
|
79
|
+
};
|
|
80
|
+
}
|
|
131
81
|
|
|
132
|
-
|
|
82
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}(innerFn, self, context), generator;
|
|
133
86
|
}
|
|
134
|
-
exports.wrap = wrap;
|
|
135
87
|
|
|
136
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
137
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
138
|
-
// have been (and was previously) designed to take a closure to be
|
|
139
|
-
// invoked without arguments, but in all the cases we care about we
|
|
140
|
-
// already have an existing method we want to call, so there's no need
|
|
141
|
-
// to create a new function object. We can even get away with assuming
|
|
142
|
-
// the method takes exactly one argument, since that happens to be true
|
|
143
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
144
|
-
// only additional allocation required is the completion record, which
|
|
145
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
146
88
|
function tryCatch(fn, obj, arg) {
|
|
147
89
|
try {
|
|
148
|
-
return {
|
|
90
|
+
return {
|
|
91
|
+
type: "normal",
|
|
92
|
+
arg: fn.call(obj, arg)
|
|
93
|
+
};
|
|
149
94
|
} catch (err) {
|
|
150
|
-
return {
|
|
95
|
+
return {
|
|
96
|
+
type: "throw",
|
|
97
|
+
arg: err
|
|
98
|
+
};
|
|
151
99
|
}
|
|
152
100
|
}
|
|
153
101
|
|
|
154
|
-
|
|
155
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
156
|
-
var GenStateExecuting = "executing";
|
|
157
|
-
var GenStateCompleted = "completed";
|
|
158
|
-
|
|
159
|
-
// Returning this object from the innerFn has the same effect as
|
|
160
|
-
// breaking out of the dispatch switch statement.
|
|
102
|
+
exports.wrap = wrap;
|
|
161
103
|
var ContinueSentinel = {};
|
|
162
104
|
|
|
163
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
164
|
-
// .constructor.prototype properties for functions that return Generator
|
|
165
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
166
|
-
// minifier not to mangle the names of these two functions.
|
|
167
105
|
function Generator() {}
|
|
106
|
+
|
|
168
107
|
function GeneratorFunction() {}
|
|
108
|
+
|
|
169
109
|
function GeneratorFunctionPrototype() {}
|
|
170
110
|
|
|
171
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
172
|
-
// don't natively support it.
|
|
173
111
|
var IteratorPrototype = {};
|
|
174
|
-
IteratorPrototype
|
|
112
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
175
113
|
return this;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
NativeIteratorPrototype !== Op &&
|
|
182
|
-
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
183
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
184
|
-
// of the polyfill.
|
|
185
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
186
|
-
}
|
|
114
|
+
});
|
|
115
|
+
var getProto = Object.getPrototypeOf,
|
|
116
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
117
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
118
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
187
119
|
|
|
188
|
-
var Gp = GeneratorFunctionPrototype.prototype =
|
|
189
|
-
Generator.prototype = Object.create(IteratorPrototype);
|
|
190
|
-
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
191
|
-
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
192
|
-
GeneratorFunction.displayName = define(
|
|
193
|
-
GeneratorFunctionPrototype,
|
|
194
|
-
toStringTagSymbol,
|
|
195
|
-
"GeneratorFunction"
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
199
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
200
120
|
function defineIteratorMethods(prototype) {
|
|
201
|
-
["next", "throw", "return"].forEach(function(method) {
|
|
202
|
-
define(prototype, method, function(arg) {
|
|
121
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
122
|
+
define(prototype, method, function (arg) {
|
|
203
123
|
return this._invoke(method, arg);
|
|
204
124
|
});
|
|
205
125
|
});
|
|
206
126
|
}
|
|
207
127
|
|
|
208
|
-
exports.isGeneratorFunction = function(genFun) {
|
|
209
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
210
|
-
return ctor
|
|
211
|
-
? ctor === GeneratorFunction ||
|
|
212
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
213
|
-
// do is to check its .name property.
|
|
214
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
215
|
-
: false;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
exports.mark = function(genFun) {
|
|
219
|
-
if (Object.setPrototypeOf) {
|
|
220
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
221
|
-
} else {
|
|
222
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
223
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
224
|
-
}
|
|
225
|
-
genFun.prototype = Object.create(Gp);
|
|
226
|
-
return genFun;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
// Within the body of any async function, `await x` is transformed to
|
|
230
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
231
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
232
|
-
// meant to be awaited.
|
|
233
|
-
exports.awrap = function(arg) {
|
|
234
|
-
return { __await: arg };
|
|
235
|
-
};
|
|
236
|
-
|
|
237
128
|
function AsyncIterator(generator, PromiseImpl) {
|
|
238
129
|
function invoke(method, arg, resolve, reject) {
|
|
239
130
|
var record = tryCatch(generator[method], generator, arg);
|
|
240
|
-
if (record.type === "throw") {
|
|
241
|
-
reject(record.arg);
|
|
242
|
-
} else {
|
|
243
|
-
var result = record.arg;
|
|
244
|
-
var value = result.value;
|
|
245
|
-
if (value &&
|
|
246
|
-
typeof value === "object" &&
|
|
247
|
-
hasOwn.call(value, "__await")) {
|
|
248
|
-
return PromiseImpl.resolve(value.__await).then(function(value) {
|
|
249
|
-
invoke("next", value, resolve, reject);
|
|
250
|
-
}, function(err) {
|
|
251
|
-
invoke("throw", err, resolve, reject);
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
131
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
132
|
+
if ("throw" !== record.type) {
|
|
133
|
+
var result = record.arg,
|
|
134
|
+
value = result.value;
|
|
135
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
136
|
+
invoke("next", value, resolve, reject);
|
|
137
|
+
}, function (err) {
|
|
138
|
+
invoke("throw", err, resolve, reject);
|
|
139
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
140
|
+
result.value = unwrapped, resolve(result);
|
|
141
|
+
}, function (error) {
|
|
264
142
|
return invoke("throw", error, resolve, reject);
|
|
265
143
|
});
|
|
266
144
|
}
|
|
145
|
+
|
|
146
|
+
reject(record.arg);
|
|
267
147
|
}
|
|
268
148
|
|
|
269
149
|
var previousPromise;
|
|
270
150
|
|
|
271
|
-
function
|
|
151
|
+
this._invoke = function (method, arg) {
|
|
272
152
|
function callInvokeWithMethodAndArg() {
|
|
273
|
-
return new PromiseImpl(function(resolve, reject) {
|
|
153
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
274
154
|
invoke(method, arg, resolve, reject);
|
|
275
155
|
});
|
|
276
156
|
}
|
|
277
157
|
|
|
278
|
-
return previousPromise =
|
|
279
|
-
// If enqueue has been called before, then we want to wait until
|
|
280
|
-
// all previous Promises have been resolved before calling invoke,
|
|
281
|
-
// so that results are always delivered in the correct order. If
|
|
282
|
-
// enqueue has not been called before, then it is important to
|
|
283
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
284
|
-
// so that the async generator function has the opportunity to do
|
|
285
|
-
// any necessary setup in a predictable way. This predictability
|
|
286
|
-
// is why the Promise constructor synchronously invokes its
|
|
287
|
-
// executor callback, and why async functions synchronously
|
|
288
|
-
// execute code before the first await. Since we implement simple
|
|
289
|
-
// async functions in terms of async generators, it is especially
|
|
290
|
-
// important to get this right, even though it requires care.
|
|
291
|
-
previousPromise ? previousPromise.then(
|
|
292
|
-
callInvokeWithMethodAndArg,
|
|
293
|
-
// Avoid propagating failures to Promises returned by later
|
|
294
|
-
// invocations of the iterator.
|
|
295
|
-
callInvokeWithMethodAndArg
|
|
296
|
-
) : callInvokeWithMethodAndArg();
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Define the unified helper method that is used to implement .next,
|
|
300
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
301
|
-
this._invoke = enqueue;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
305
|
-
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
306
|
-
return this;
|
|
307
|
-
};
|
|
308
|
-
exports.AsyncIterator = AsyncIterator;
|
|
309
|
-
|
|
310
|
-
// Note that simple async functions are implemented on top of
|
|
311
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
312
|
-
// the final result produced by the iterator.
|
|
313
|
-
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
314
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
315
|
-
|
|
316
|
-
var iter = new AsyncIterator(
|
|
317
|
-
wrap(innerFn, outerFn, self, tryLocsList),
|
|
318
|
-
PromiseImpl
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
return exports.isGeneratorFunction(outerFn)
|
|
322
|
-
? iter // If outerFn is a generator, return the full iterator.
|
|
323
|
-
: iter.next().then(function(result) {
|
|
324
|
-
return result.done ? result.value : iter.next();
|
|
325
|
-
});
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
329
|
-
var state = GenStateSuspendedStart;
|
|
330
|
-
|
|
331
|
-
return function invoke(method, arg) {
|
|
332
|
-
if (state === GenStateExecuting) {
|
|
333
|
-
throw new Error("Generator is already running");
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (state === GenStateCompleted) {
|
|
337
|
-
if (method === "throw") {
|
|
338
|
-
throw arg;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
342
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
343
|
-
return doneResult();
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
context.method = method;
|
|
347
|
-
context.arg = arg;
|
|
348
|
-
|
|
349
|
-
while (true) {
|
|
350
|
-
var delegate = context.delegate;
|
|
351
|
-
if (delegate) {
|
|
352
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
353
|
-
if (delegateResult) {
|
|
354
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
355
|
-
return delegateResult;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (context.method === "next") {
|
|
360
|
-
// Setting context._sent for legacy support of Babel's
|
|
361
|
-
// function.sent implementation.
|
|
362
|
-
context.sent = context._sent = context.arg;
|
|
363
|
-
|
|
364
|
-
} else if (context.method === "throw") {
|
|
365
|
-
if (state === GenStateSuspendedStart) {
|
|
366
|
-
state = GenStateCompleted;
|
|
367
|
-
throw context.arg;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
context.dispatchException(context.arg);
|
|
371
|
-
|
|
372
|
-
} else if (context.method === "return") {
|
|
373
|
-
context.abrupt("return", context.arg);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
state = GenStateExecuting;
|
|
377
|
-
|
|
378
|
-
var record = tryCatch(innerFn, self, context);
|
|
379
|
-
if (record.type === "normal") {
|
|
380
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
381
|
-
// GenStateExecuting and loop back for another invocation.
|
|
382
|
-
state = context.done
|
|
383
|
-
? GenStateCompleted
|
|
384
|
-
: GenStateSuspendedYield;
|
|
385
|
-
|
|
386
|
-
if (record.arg === ContinueSentinel) {
|
|
387
|
-
continue;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
return {
|
|
391
|
-
value: record.arg,
|
|
392
|
-
done: context.done
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
} else if (record.type === "throw") {
|
|
396
|
-
state = GenStateCompleted;
|
|
397
|
-
// Dispatch the exception by looping back around to the
|
|
398
|
-
// context.dispatchException(context.arg) call above.
|
|
399
|
-
context.method = "throw";
|
|
400
|
-
context.arg = record.arg;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
158
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
403
159
|
};
|
|
404
160
|
}
|
|
405
161
|
|
|
406
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
407
|
-
// result, either by returning a { value, done } result from the
|
|
408
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
409
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
410
162
|
function maybeInvokeDelegate(delegate, context) {
|
|
411
163
|
var method = delegate.iterator[context.method];
|
|
412
|
-
if (method === undefined$1) {
|
|
413
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
414
|
-
// method always terminates the yield* loop.
|
|
415
|
-
context.delegate = null;
|
|
416
|
-
|
|
417
|
-
if (context.method === "throw") {
|
|
418
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
419
|
-
if (delegate.iterator["return"]) {
|
|
420
|
-
// If the delegate iterator has a return method, give it a
|
|
421
|
-
// chance to clean up.
|
|
422
|
-
context.method = "return";
|
|
423
|
-
context.arg = undefined$1;
|
|
424
|
-
maybeInvokeDelegate(delegate, context);
|
|
425
|
-
|
|
426
|
-
if (context.method === "throw") {
|
|
427
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
428
|
-
// "return" to "throw", let that override the TypeError below.
|
|
429
|
-
return ContinueSentinel;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
164
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
165
|
+
if (undefined === method) {
|
|
166
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
167
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
168
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
436
169
|
}
|
|
437
170
|
|
|
438
171
|
return ContinueSentinel;
|
|
439
172
|
}
|
|
440
173
|
|
|
441
174
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
442
|
-
|
|
443
|
-
if (record.type === "throw") {
|
|
444
|
-
context.method = "throw";
|
|
445
|
-
context.arg = record.arg;
|
|
446
|
-
context.delegate = null;
|
|
447
|
-
return ContinueSentinel;
|
|
448
|
-
}
|
|
449
|
-
|
|
175
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
450
176
|
var info = record.arg;
|
|
451
|
-
|
|
452
|
-
if (! info) {
|
|
453
|
-
context.method = "throw";
|
|
454
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
455
|
-
context.delegate = null;
|
|
456
|
-
return ContinueSentinel;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
if (info.done) {
|
|
460
|
-
// Assign the result of the finished delegate to the temporary
|
|
461
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
462
|
-
context[delegate.resultName] = info.value;
|
|
463
|
-
|
|
464
|
-
// Resume execution at the desired location (see delegateYield).
|
|
465
|
-
context.next = delegate.nextLoc;
|
|
466
|
-
|
|
467
|
-
// If context.method was "throw" but the delegate handled the
|
|
468
|
-
// exception, let the outer generator proceed normally. If
|
|
469
|
-
// context.method was "next", forget context.arg since it has been
|
|
470
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
471
|
-
// "return", allow the original .return call to continue in the
|
|
472
|
-
// outer generator.
|
|
473
|
-
if (context.method !== "return") {
|
|
474
|
-
context.method = "next";
|
|
475
|
-
context.arg = undefined$1;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
} else {
|
|
479
|
-
// Re-yield the result returned by the delegate method.
|
|
480
|
-
return info;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
484
|
-
// the outer generator.
|
|
485
|
-
context.delegate = null;
|
|
486
|
-
return ContinueSentinel;
|
|
177
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
487
178
|
}
|
|
488
179
|
|
|
489
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
490
|
-
// unified ._invoke helper method.
|
|
491
|
-
defineIteratorMethods(Gp);
|
|
492
|
-
|
|
493
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
494
|
-
|
|
495
|
-
// A Generator should always return itself as the iterator object when the
|
|
496
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
497
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
498
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
499
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
500
|
-
Gp[iteratorSymbol] = function() {
|
|
501
|
-
return this;
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
Gp.toString = function() {
|
|
505
|
-
return "[object Generator]";
|
|
506
|
-
};
|
|
507
|
-
|
|
508
180
|
function pushTryEntry(locs) {
|
|
509
|
-
var entry = {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
if (2 in locs) {
|
|
516
|
-
entry.finallyLoc = locs[2];
|
|
517
|
-
entry.afterLoc = locs[3];
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
this.tryEntries.push(entry);
|
|
181
|
+
var entry = {
|
|
182
|
+
tryLoc: locs[0]
|
|
183
|
+
};
|
|
184
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
521
185
|
}
|
|
522
186
|
|
|
523
187
|
function resetTryEntry(entry) {
|
|
524
188
|
var record = entry.completion || {};
|
|
525
|
-
record.type = "normal";
|
|
526
|
-
delete record.arg;
|
|
527
|
-
entry.completion = record;
|
|
189
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
528
190
|
}
|
|
529
191
|
|
|
530
192
|
function Context(tryLocsList) {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
this.tryEntries = [{ tryLoc: "root" }];
|
|
535
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
536
|
-
this.reset(true);
|
|
193
|
+
this.tryEntries = [{
|
|
194
|
+
tryLoc: "root"
|
|
195
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
537
196
|
}
|
|
538
197
|
|
|
539
|
-
exports.keys = function(object) {
|
|
540
|
-
var keys = [];
|
|
541
|
-
for (var key in object) {
|
|
542
|
-
keys.push(key);
|
|
543
|
-
}
|
|
544
|
-
keys.reverse();
|
|
545
|
-
|
|
546
|
-
// Rather than returning an object with a next method, we keep
|
|
547
|
-
// things simple and return the next function itself.
|
|
548
|
-
return function next() {
|
|
549
|
-
while (keys.length) {
|
|
550
|
-
var key = keys.pop();
|
|
551
|
-
if (key in object) {
|
|
552
|
-
next.value = key;
|
|
553
|
-
next.done = false;
|
|
554
|
-
return next;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// To avoid creating an additional object, we just hang the .value
|
|
559
|
-
// and .done properties off the next function object itself. This
|
|
560
|
-
// also ensures that the minifier will not anonymize the function.
|
|
561
|
-
next.done = true;
|
|
562
|
-
return next;
|
|
563
|
-
};
|
|
564
|
-
};
|
|
565
|
-
|
|
566
198
|
function values(iterable) {
|
|
567
199
|
if (iterable) {
|
|
568
200
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
569
|
-
if (iteratorMethod)
|
|
570
|
-
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
if (typeof iterable.next === "function") {
|
|
574
|
-
return iterable;
|
|
575
|
-
}
|
|
201
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
202
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
576
203
|
|
|
577
204
|
if (!isNaN(iterable.length)) {
|
|
578
|
-
var i = -1,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
next.value = iterable[i];
|
|
582
|
-
next.done = false;
|
|
583
|
-
return next;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
next.value = undefined$1;
|
|
588
|
-
next.done = true;
|
|
205
|
+
var i = -1,
|
|
206
|
+
next = function next() {
|
|
207
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
589
208
|
|
|
590
|
-
return next;
|
|
209
|
+
return next.value = undefined, next.done = !0, next;
|
|
591
210
|
};
|
|
592
211
|
|
|
593
212
|
return next.next = next;
|
|
594
213
|
}
|
|
595
214
|
}
|
|
596
215
|
|
|
597
|
-
|
|
598
|
-
|
|
216
|
+
return {
|
|
217
|
+
next: doneResult
|
|
218
|
+
};
|
|
599
219
|
}
|
|
600
|
-
exports.values = values;
|
|
601
220
|
|
|
602
221
|
function doneResult() {
|
|
603
|
-
return {
|
|
222
|
+
return {
|
|
223
|
+
value: undefined,
|
|
224
|
+
done: !0
|
|
225
|
+
};
|
|
604
226
|
}
|
|
605
227
|
|
|
606
|
-
|
|
607
|
-
constructor
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
this[name] = undefined$1;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
},
|
|
228
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
229
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
230
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
231
|
+
}, exports.mark = function (genFun) {
|
|
232
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
233
|
+
}, exports.awrap = function (arg) {
|
|
234
|
+
return {
|
|
235
|
+
__await: arg
|
|
236
|
+
};
|
|
237
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
238
|
+
return this;
|
|
239
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
240
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
241
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
242
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
243
|
+
return result.done ? result.value : iter.next();
|
|
244
|
+
});
|
|
245
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
246
|
+
return this;
|
|
247
|
+
}), define(Gp, "toString", function () {
|
|
248
|
+
return "[object Generator]";
|
|
249
|
+
}), exports.keys = function (object) {
|
|
250
|
+
var keys = [];
|
|
634
251
|
|
|
635
|
-
|
|
636
|
-
this.done = true;
|
|
252
|
+
for (var key in object) keys.push(key);
|
|
637
253
|
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
254
|
+
return keys.reverse(), function next() {
|
|
255
|
+
for (; keys.length;) {
|
|
256
|
+
var key = keys.pop();
|
|
257
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
642
258
|
}
|
|
643
259
|
|
|
260
|
+
return next.done = !0, next;
|
|
261
|
+
};
|
|
262
|
+
}, exports.values = values, Context.prototype = {
|
|
263
|
+
constructor: Context,
|
|
264
|
+
reset: function (skipTempReset) {
|
|
265
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
266
|
+
},
|
|
267
|
+
stop: function () {
|
|
268
|
+
this.done = !0;
|
|
269
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
270
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
644
271
|
return this.rval;
|
|
645
272
|
},
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
if (this.done) {
|
|
649
|
-
throw exception;
|
|
650
|
-
}
|
|
651
|
-
|
|
273
|
+
dispatchException: function (exception) {
|
|
274
|
+
if (this.done) throw exception;
|
|
652
275
|
var context = this;
|
|
653
|
-
function handle(loc, caught) {
|
|
654
|
-
record.type = "throw";
|
|
655
|
-
record.arg = exception;
|
|
656
|
-
context.next = loc;
|
|
657
|
-
|
|
658
|
-
if (caught) {
|
|
659
|
-
// If the dispatched exception was caught by a catch block,
|
|
660
|
-
// then let that catch block handle the exception normally.
|
|
661
|
-
context.method = "next";
|
|
662
|
-
context.arg = undefined$1;
|
|
663
|
-
}
|
|
664
276
|
|
|
665
|
-
|
|
277
|
+
function handle(loc, caught) {
|
|
278
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
666
279
|
}
|
|
667
280
|
|
|
668
281
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
669
|
-
var entry = this.tryEntries[i]
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
if (entry.tryLoc === "root") {
|
|
673
|
-
// Exception thrown outside of any try block that could handle
|
|
674
|
-
// it, so set the completion value of the entire function to
|
|
675
|
-
// throw the exception.
|
|
676
|
-
return handle("end");
|
|
677
|
-
}
|
|
282
|
+
var entry = this.tryEntries[i],
|
|
283
|
+
record = entry.completion;
|
|
284
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
678
285
|
|
|
679
286
|
if (entry.tryLoc <= this.prev) {
|
|
680
|
-
var hasCatch = hasOwn.call(entry, "catchLoc")
|
|
681
|
-
|
|
287
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
288
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
682
289
|
|
|
683
290
|
if (hasCatch && hasFinally) {
|
|
684
|
-
if (this.prev < entry.catchLoc)
|
|
685
|
-
|
|
686
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
687
|
-
return handle(entry.finallyLoc);
|
|
688
|
-
}
|
|
689
|
-
|
|
291
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
292
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
690
293
|
} else if (hasCatch) {
|
|
691
|
-
if (this.prev < entry.catchLoc)
|
|
692
|
-
return handle(entry.catchLoc, true);
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
} else if (hasFinally) {
|
|
696
|
-
if (this.prev < entry.finallyLoc) {
|
|
697
|
-
return handle(entry.finallyLoc);
|
|
698
|
-
}
|
|
699
|
-
|
|
294
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
700
295
|
} else {
|
|
701
|
-
throw new Error("try statement without catch or finally");
|
|
296
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
297
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
702
298
|
}
|
|
703
299
|
}
|
|
704
300
|
}
|
|
705
301
|
},
|
|
706
|
-
|
|
707
|
-
abrupt: function(type, arg) {
|
|
302
|
+
abrupt: function (type, arg) {
|
|
708
303
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
709
304
|
var entry = this.tryEntries[i];
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
this.prev < entry.finallyLoc) {
|
|
305
|
+
|
|
306
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
713
307
|
var finallyEntry = entry;
|
|
714
308
|
break;
|
|
715
309
|
}
|
|
716
310
|
}
|
|
717
311
|
|
|
718
|
-
|
|
719
|
-
(type === "break" ||
|
|
720
|
-
type === "continue") &&
|
|
721
|
-
finallyEntry.tryLoc <= arg &&
|
|
722
|
-
arg <= finallyEntry.finallyLoc) {
|
|
723
|
-
// Ignore the finally entry if control is not jumping to a
|
|
724
|
-
// location outside the try/catch block.
|
|
725
|
-
finallyEntry = null;
|
|
726
|
-
}
|
|
727
|
-
|
|
312
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
728
313
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
729
|
-
record.type = type;
|
|
730
|
-
record.arg = arg;
|
|
731
|
-
|
|
732
|
-
if (finallyEntry) {
|
|
733
|
-
this.method = "next";
|
|
734
|
-
this.next = finallyEntry.finallyLoc;
|
|
735
|
-
return ContinueSentinel;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
return this.complete(record);
|
|
314
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
739
315
|
},
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
throw record.arg;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
if (record.type === "break" ||
|
|
747
|
-
record.type === "continue") {
|
|
748
|
-
this.next = record.arg;
|
|
749
|
-
} else if (record.type === "return") {
|
|
750
|
-
this.rval = this.arg = record.arg;
|
|
751
|
-
this.method = "return";
|
|
752
|
-
this.next = "end";
|
|
753
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
754
|
-
this.next = afterLoc;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
return ContinueSentinel;
|
|
316
|
+
complete: function (record, afterLoc) {
|
|
317
|
+
if ("throw" === record.type) throw record.arg;
|
|
318
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
758
319
|
},
|
|
759
|
-
|
|
760
|
-
finish: function(finallyLoc) {
|
|
320
|
+
finish: function (finallyLoc) {
|
|
761
321
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
762
322
|
var entry = this.tryEntries[i];
|
|
763
|
-
if (entry.finallyLoc === finallyLoc)
|
|
764
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
765
|
-
resetTryEntry(entry);
|
|
766
|
-
return ContinueSentinel;
|
|
767
|
-
}
|
|
323
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
768
324
|
}
|
|
769
325
|
},
|
|
770
|
-
|
|
771
|
-
"catch": function(tryLoc) {
|
|
326
|
+
catch: function (tryLoc) {
|
|
772
327
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
773
328
|
var entry = this.tryEntries[i];
|
|
329
|
+
|
|
774
330
|
if (entry.tryLoc === tryLoc) {
|
|
775
331
|
var record = entry.completion;
|
|
776
|
-
|
|
332
|
+
|
|
333
|
+
if ("throw" === record.type) {
|
|
777
334
|
var thrown = record.arg;
|
|
778
335
|
resetTryEntry(entry);
|
|
779
336
|
}
|
|
337
|
+
|
|
780
338
|
return thrown;
|
|
781
339
|
}
|
|
782
340
|
}
|
|
783
341
|
|
|
784
|
-
// The context.catch method must only be called with a location
|
|
785
|
-
// argument that corresponds to a known catch block.
|
|
786
342
|
throw new Error("illegal catch attempt");
|
|
787
343
|
},
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
this.delegate = {
|
|
344
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
345
|
+
return this.delegate = {
|
|
791
346
|
iterator: values(iterable),
|
|
792
347
|
resultName: resultName,
|
|
793
348
|
nextLoc: nextLoc
|
|
794
|
-
};
|
|
349
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
350
|
+
}
|
|
351
|
+
}, exports;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
355
|
+
try {
|
|
356
|
+
var info = gen[key](arg);
|
|
357
|
+
var value = info.value;
|
|
358
|
+
} catch (error) {
|
|
359
|
+
reject(error);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (info.done) {
|
|
364
|
+
resolve(value);
|
|
365
|
+
} else {
|
|
366
|
+
Promise.resolve(value).then(_next, _throw);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function _asyncToGenerator(fn) {
|
|
371
|
+
return function () {
|
|
372
|
+
var self = this,
|
|
373
|
+
args = arguments;
|
|
374
|
+
return new Promise(function (resolve, reject) {
|
|
375
|
+
var gen = fn.apply(self, args);
|
|
376
|
+
|
|
377
|
+
function _next(value) {
|
|
378
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
379
|
+
}
|
|
795
380
|
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
// accidentally pass it on to the delegate.
|
|
799
|
-
this.arg = undefined$1;
|
|
381
|
+
function _throw(err) {
|
|
382
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
800
383
|
}
|
|
801
384
|
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
};
|
|
385
|
+
_next(undefined);
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function _extends() {
|
|
391
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
392
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
393
|
+
var source = arguments[i];
|
|
394
|
+
|
|
395
|
+
for (var key in source) {
|
|
396
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
397
|
+
target[key] = source[key];
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return target;
|
|
403
|
+
};
|
|
404
|
+
return _extends.apply(this, arguments);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function _objectDestructuringEmpty(obj) {
|
|
408
|
+
if (obj == null) throw new TypeError("Cannot destructure undefined");
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
412
|
+
if (source == null) return {};
|
|
413
|
+
var target = {};
|
|
414
|
+
var sourceKeys = Object.keys(source);
|
|
415
|
+
var key, i;
|
|
416
|
+
|
|
417
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
418
|
+
key = sourceKeys[i];
|
|
419
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
420
|
+
target[key] = source[key];
|
|
421
|
+
}
|
|
805
422
|
|
|
806
|
-
|
|
807
|
-
// or not, return the runtime object so that we can declare the variable
|
|
808
|
-
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
809
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
810
|
-
return exports;
|
|
811
|
-
|
|
812
|
-
}(
|
|
813
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
814
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
815
|
-
// object. Either way, the resulting object will be used to initialize
|
|
816
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
817
|
-
module.exports
|
|
818
|
-
));
|
|
819
|
-
|
|
820
|
-
try {
|
|
821
|
-
regeneratorRuntime = runtime;
|
|
822
|
-
} catch (accidentalStrictMode) {
|
|
823
|
-
// This module should not be running in strict mode, so the above
|
|
824
|
-
// assignment should always work unless something is misconfigured. Just
|
|
825
|
-
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
826
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
827
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
828
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
829
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
830
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
831
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
832
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
423
|
+
return target;
|
|
833
424
|
}
|
|
834
|
-
});
|
|
835
425
|
|
|
836
426
|
var _require = /*#__PURE__*/require('@freelog/resource-policy-lang'),
|
|
837
427
|
compile = _require.compile;
|
|
@@ -890,9 +480,9 @@ function policyCodeTranslationToText(_x, _x2) {
|
|
|
890
480
|
}
|
|
891
481
|
|
|
892
482
|
function _policyCodeTranslationToText() {
|
|
893
|
-
_policyCodeTranslationToText = _asyncToGenerator( /*#__PURE__*/
|
|
483
|
+
_policyCodeTranslationToText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(code, targetType) {
|
|
894
484
|
var result, contract, rrr;
|
|
895
|
-
return
|
|
485
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
896
486
|
while (1) {
|
|
897
487
|
switch (_context.prev = _context.next) {
|
|
898
488
|
case 0:
|
|
@@ -1312,257 +902,11 @@ var Predefined = {
|
|
|
1312
902
|
__proto__: null,
|
|
1313
903
|
resourceTypes: resourceTypes,
|
|
1314
904
|
pageSize: pageSize,
|
|
1315
|
-
momentDateFormat: momentDateFormat,
|
|
1316
|
-
momentDateTimeFormat: momentDateTimeFormat,
|
|
1317
|
-
get EnumContractPartyIdentityType () { return EnumContractPartyIdentityType; },
|
|
1318
|
-
get EnumSubjectType () { return EnumSubjectType; },
|
|
1319
|
-
get EnumContractStatus () { return EnumContractStatus; }
|
|
1320
|
-
};
|
|
1321
|
-
|
|
1322
|
-
var codeMessage = {
|
|
1323
|
-
200: '服务器成功返回请求的数据。',
|
|
1324
|
-
201: '新建或修改数据成功。',
|
|
1325
|
-
202: '一个请求已经进入后台排队(异步任务)。',
|
|
1326
|
-
204: '删除数据成功。',
|
|
1327
|
-
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
|
|
1328
|
-
401: '用户没有权限(令牌、用户名、密码错误)。',
|
|
1329
|
-
403: '用户得到授权,但是访问是被禁止的。',
|
|
1330
|
-
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
|
|
1331
|
-
406: '请求的格式不可得。',
|
|
1332
|
-
410: '请求的资源被永久删除,且不会再得到的。',
|
|
1333
|
-
422: '当创建一个对象时,发生一个验证错误。',
|
|
1334
|
-
500: '服务器发生错误,请检查服务器。',
|
|
1335
|
-
502: '网关错误。',
|
|
1336
|
-
503: '服务不可用,服务器暂时过载或维护。',
|
|
1337
|
-
504: '网关超时。'
|
|
1338
|
-
}; // export let apiHost: string = '';
|
|
1339
|
-
|
|
1340
|
-
if (window.location.hostname.includes('.com')) {
|
|
1341
|
-
// apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
|
|
1342
|
-
// apiHost = window.location.origin.replace('console', 'qi');
|
|
1343
|
-
axios.defaults.withCredentials = true;
|
|
1344
|
-
axios.defaults.baseURL = /*#__PURE__*/completeUrlByDomain('qi');
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* 异常处理程序
|
|
1348
|
-
*/
|
|
1349
|
-
// const errorHandler = (error: { response: Response }): Response => {
|
|
1350
|
-
// const {response} = error;
|
|
1351
|
-
// if (response && response.status) {
|
|
1352
|
-
// const errorText = codeMessage[response.status] || response.statusText;
|
|
1353
|
-
// const {status, url} = response;
|
|
1354
|
-
//
|
|
1355
|
-
// // notification.error({
|
|
1356
|
-
// // message: `请求错误 ${status}: ${url}`,
|
|
1357
|
-
// // description: errorText,
|
|
1358
|
-
// // });
|
|
1359
|
-
// } else if (!response) {
|
|
1360
|
-
// // notification.error({
|
|
1361
|
-
// // description: '您的网络发生异常,无法连接服务器',
|
|
1362
|
-
// // message: '网络异常',
|
|
1363
|
-
// // });
|
|
1364
|
-
// }
|
|
1365
|
-
// return response;
|
|
1366
|
-
// };
|
|
1367
|
-
//
|
|
1368
|
-
// // Add a request interceptor
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
axios.interceptors.request.use(function (config) {
|
|
1372
|
-
// Do something before request is sent
|
|
1373
|
-
NProgress.start();
|
|
1374
|
-
return config;
|
|
1375
|
-
}, function (error) {
|
|
1376
|
-
// Do something with request error
|
|
1377
|
-
NProgress.done();
|
|
1378
|
-
return Promise.reject(error);
|
|
1379
|
-
});
|
|
1380
|
-
/**
|
|
1381
|
-
* 配置request请求时的默认参数
|
|
1382
|
-
*/
|
|
1383
|
-
|
|
1384
|
-
axios.interceptors.response.use(function (response) {
|
|
1385
|
-
var _headers$contentDisp;
|
|
1386
|
-
|
|
1387
|
-
// Do something with response data
|
|
1388
|
-
// console.log(response, 'response!!!!!!');
|
|
1389
|
-
NProgress.done();
|
|
1390
|
-
|
|
1391
|
-
if (response.status !== 200) {
|
|
1392
|
-
var error = {
|
|
1393
|
-
description: codeMessage[response.status],
|
|
1394
|
-
message: response.status
|
|
1395
|
-
}; // notification.error(error);
|
|
1396
|
-
|
|
1397
|
-
throw new Error(JSON.stringify(error));
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
var data = response.data,
|
|
1401
|
-
headers = response.headers;
|
|
1402
|
-
|
|
1403
|
-
if ((_headers$contentDisp = headers['content-disposition']) != null && _headers$contentDisp.includes('attachment;')) {
|
|
1404
|
-
// downloadFile(response);
|
|
1405
|
-
return;
|
|
1406
|
-
} // console.log(data, 'data2390jasdflkf');
|
|
1407
|
-
// if ((data.errcode === undefined
|
|
1408
|
-
// ? (data.errCode !== 0 && data.errCode !== 2)
|
|
1409
|
-
// : (data.errcode !== 0 && data.errcode !== 2))
|
|
1410
|
-
// || data.ret !== 0) {
|
|
1411
|
-
//
|
|
1412
|
-
// // notification.error({
|
|
1413
|
-
// // message: data.msg,
|
|
1414
|
-
// // });
|
|
1415
|
-
// throw new Error(JSON.stringify(data));
|
|
1416
|
-
// }
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
return data;
|
|
1420
|
-
}, function (error) {
|
|
1421
|
-
// Do something with response error
|
|
1422
|
-
NProgress.done();
|
|
1423
|
-
return Promise.reject(error);
|
|
1424
|
-
});
|
|
1425
|
-
function request(_x, _x2) {
|
|
1426
|
-
return _request.apply(this, arguments);
|
|
1427
|
-
} // export function downloadFile(res: AxiosResponse) {
|
|
1428
|
-
// const {data, headers} = res;
|
|
1429
|
-
// // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
1430
|
-
// const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
1431
|
-
// const blob = new Blob([data], {});
|
|
1432
|
-
// FileSaver.saveAs(blob, fileName);
|
|
1433
|
-
// }
|
|
1434
|
-
|
|
1435
|
-
function _request() {
|
|
1436
|
-
_request = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(config, _temp) {
|
|
1437
|
-
var _ref, _ref$noRedirect, noRedirect, _ref$noErrorAlert, noErrorAlert, result;
|
|
1438
|
-
|
|
1439
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1440
|
-
while (1) {
|
|
1441
|
-
switch (_context.prev = _context.next) {
|
|
1442
|
-
case 0:
|
|
1443
|
-
_ref = _temp === void 0 ? {} : _temp, _ref$noRedirect = _ref.noRedirect, noRedirect = _ref$noRedirect === void 0 ? false : _ref$noRedirect, _ref$noErrorAlert = _ref.noErrorAlert, noErrorAlert = _ref$noErrorAlert === void 0 ? false : _ref$noErrorAlert;
|
|
1444
|
-
_context.next = 3;
|
|
1445
|
-
return axios.request(config);
|
|
1446
|
-
|
|
1447
|
-
case 3:
|
|
1448
|
-
result = _context.sent;
|
|
1449
|
-
|
|
1450
|
-
if (!((result.errCode === 30 || result.errCode === 30) && !noRedirect)) {
|
|
1451
|
-
_context.next = 6;
|
|
1452
|
-
break;
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
return _context.abrupt("return", window.location.replace("" + completeUrlByDomain('user') + login({
|
|
1456
|
-
goTo: window.location.href
|
|
1457
|
-
})));
|
|
1458
|
-
|
|
1459
|
-
case 6:
|
|
1460
|
-
|
|
1461
|
-
return _context.abrupt("return", result);
|
|
1462
|
-
|
|
1463
|
-
case 8:
|
|
1464
|
-
case "end":
|
|
1465
|
-
return _context.stop();
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
}, _callee);
|
|
1469
|
-
}));
|
|
1470
|
-
return _request.apply(this, arguments);
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
/**
|
|
1474
|
-
* 根据 File 获取 SHA1 Hash 字符串
|
|
1475
|
-
* @param file
|
|
1476
|
-
* @return {Promise<string>}
|
|
1477
|
-
*/
|
|
1478
|
-
|
|
1479
|
-
function getSHA1Hash(file) {
|
|
1480
|
-
return new Promise(function (resolve) {
|
|
1481
|
-
var reader = new FileReader();
|
|
1482
|
-
|
|
1483
|
-
reader.onload = function () {
|
|
1484
|
-
var wordArray = lib.WordArray.create(reader.result);
|
|
1485
|
-
var hash = SHA1(wordArray).toString();
|
|
1486
|
-
resolve(hash);
|
|
1487
|
-
};
|
|
1488
|
-
|
|
1489
|
-
reader.readAsArrayBuffer(file);
|
|
1490
|
-
});
|
|
1491
|
-
}
|
|
1492
|
-
/**
|
|
1493
|
-
* 生成随机码
|
|
1494
|
-
*/
|
|
1495
|
-
|
|
1496
|
-
function generateRandomCode(strLen) {
|
|
1497
|
-
if (strLen === void 0) {
|
|
1498
|
-
strLen = 5;
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
var allStr = 'ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
|
|
1502
|
-
var newStrArr = [];
|
|
1503
|
-
|
|
1504
|
-
for (var i = 0; i < strLen; i++) {
|
|
1505
|
-
newStrArr.push(allStr[Math.floor(Math.random() * 61)]);
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
return newStrArr.join('');
|
|
1509
|
-
}
|
|
1510
|
-
/**
|
|
1511
|
-
* 通过读取 cookies 获取用户 ID
|
|
1512
|
-
*/
|
|
1513
|
-
|
|
1514
|
-
function getUserIDByCookies() {
|
|
1515
|
-
var uid = document.cookie.split('; ').find(function (co) {
|
|
1516
|
-
return co.startsWith('uid=');
|
|
1517
|
-
});
|
|
1518
|
-
|
|
1519
|
-
if (!uid) {
|
|
1520
|
-
return -1;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
return Number(uid.replace('uid=', ''));
|
|
1524
|
-
}
|
|
1525
|
-
function transformServerAPIContractState(_ref) {
|
|
1526
|
-
var status = _ref.status,
|
|
1527
|
-
authStatus = _ref.authStatus;
|
|
1528
|
-
|
|
1529
|
-
if (status === 0) {
|
|
1530
|
-
if (authStatus === 1 || authStatus === 3) {
|
|
1531
|
-
return 'active';
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
if (authStatus === 2) {
|
|
1535
|
-
return 'testActive';
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
if (authStatus === 128) {
|
|
1539
|
-
return 'inactive';
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
if (status === 1) {
|
|
1544
|
-
return 'terminal';
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
return 'exception';
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
var Tool = {
|
|
1551
|
-
__proto__: null,
|
|
1552
|
-
getSHA1Hash: getSHA1Hash,
|
|
1553
|
-
generateRandomCode: generateRandomCode,
|
|
1554
|
-
getUserIDByCookies: getUserIDByCookies,
|
|
1555
|
-
transformServerAPIContractState: transformServerAPIContractState
|
|
1556
|
-
};
|
|
1557
|
-
|
|
1558
|
-
var FUtil = {
|
|
1559
|
-
Format: Format,
|
|
1560
|
-
Regexp: Regexp,
|
|
1561
|
-
LinkTo: LinkTo,
|
|
1562
|
-
Predefined: Predefined,
|
|
1563
|
-
Axios: axios,
|
|
1564
|
-
Request: request,
|
|
1565
|
-
Tool: Tool
|
|
905
|
+
momentDateFormat: momentDateFormat,
|
|
906
|
+
momentDateTimeFormat: momentDateTimeFormat,
|
|
907
|
+
get EnumContractPartyIdentityType () { return EnumContractPartyIdentityType; },
|
|
908
|
+
get EnumSubjectType () { return EnumSubjectType; },
|
|
909
|
+
get EnumContractStatus () { return EnumContractStatus; }
|
|
1566
910
|
};
|
|
1567
911
|
|
|
1568
912
|
function create(params) {
|
|
@@ -2837,11 +2181,27 @@ function find4Client(params) {
|
|
|
2837
2181
|
params: params
|
|
2838
2182
|
});
|
|
2839
2183
|
}
|
|
2184
|
+
function adsList(params) {
|
|
2185
|
+
return FUtil.Request({
|
|
2186
|
+
method: 'GET',
|
|
2187
|
+
url: "/v2/activities/ads/list4Client",
|
|
2188
|
+
params: params
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
function adsDetails(params) {
|
|
2192
|
+
return FUtil.Request({
|
|
2193
|
+
method: 'GET',
|
|
2194
|
+
url: "/v2/activities/ads/find4Client",
|
|
2195
|
+
params: params
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2840
2198
|
|
|
2841
2199
|
var Activity = {
|
|
2842
2200
|
__proto__: null,
|
|
2843
2201
|
list4Client: list4Client,
|
|
2844
|
-
find4Client: find4Client
|
|
2202
|
+
find4Client: find4Client,
|
|
2203
|
+
adsList: adsList,
|
|
2204
|
+
adsDetails: adsDetails
|
|
2845
2205
|
};
|
|
2846
2206
|
|
|
2847
2207
|
var FServiceAPI = {
|
|
@@ -2859,5 +2219,255 @@ var FServiceAPI = {
|
|
|
2859
2219
|
Activity: Activity
|
|
2860
2220
|
};
|
|
2861
2221
|
|
|
2222
|
+
var codeMessage = {
|
|
2223
|
+
200: '服务器成功返回请求的数据。',
|
|
2224
|
+
201: '新建或修改数据成功。',
|
|
2225
|
+
202: '一个请求已经进入后台排队(异步任务)。',
|
|
2226
|
+
204: '删除数据成功。',
|
|
2227
|
+
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
|
|
2228
|
+
401: '用户没有权限(令牌、用户名、密码错误)。',
|
|
2229
|
+
403: '用户得到授权,但是访问是被禁止的。',
|
|
2230
|
+
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
|
|
2231
|
+
406: '请求的格式不可得。',
|
|
2232
|
+
410: '请求的资源被永久删除,且不会再得到的。',
|
|
2233
|
+
422: '当创建一个对象时,发生一个验证错误。',
|
|
2234
|
+
500: '服务器发生错误,请检查服务器。',
|
|
2235
|
+
502: '网关错误。',
|
|
2236
|
+
503: '服务不可用,服务器暂时过载或维护。',
|
|
2237
|
+
504: '网关超时。'
|
|
2238
|
+
}; // export let apiHost: string = '';
|
|
2239
|
+
|
|
2240
|
+
if (window.location.hostname.includes('.com')) {
|
|
2241
|
+
// apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
|
|
2242
|
+
// apiHost = window.location.origin.replace('console', 'qi');
|
|
2243
|
+
axios.defaults.withCredentials = true;
|
|
2244
|
+
axios.defaults.baseURL = /*#__PURE__*/completeUrlByDomain('qi');
|
|
2245
|
+
}
|
|
2246
|
+
/**
|
|
2247
|
+
* 异常处理程序
|
|
2248
|
+
*/
|
|
2249
|
+
// const errorHandler = (error: { response: Response }): Response => {
|
|
2250
|
+
// const {response} = error;
|
|
2251
|
+
// if (response && response.status) {
|
|
2252
|
+
// const errorText = codeMessage[response.status] || response.statusText;
|
|
2253
|
+
// const {status, url} = response;
|
|
2254
|
+
//
|
|
2255
|
+
// // notification.error({
|
|
2256
|
+
// // message: `请求错误 ${status}: ${url}`,
|
|
2257
|
+
// // description: errorText,
|
|
2258
|
+
// // });
|
|
2259
|
+
// } else if (!response) {
|
|
2260
|
+
// // notification.error({
|
|
2261
|
+
// // description: '您的网络发生异常,无法连接服务器',
|
|
2262
|
+
// // message: '网络异常',
|
|
2263
|
+
// // });
|
|
2264
|
+
// }
|
|
2265
|
+
// return response;
|
|
2266
|
+
// };
|
|
2267
|
+
//
|
|
2268
|
+
// // Add a request interceptor
|
|
2269
|
+
|
|
2270
|
+
|
|
2271
|
+
axios.interceptors.request.use(function (config) {
|
|
2272
|
+
// Do something before request is sent
|
|
2273
|
+
NProgress.start();
|
|
2274
|
+
return config;
|
|
2275
|
+
}, function (error) {
|
|
2276
|
+
// Do something with request error
|
|
2277
|
+
NProgress.done();
|
|
2278
|
+
return Promise.reject(error);
|
|
2279
|
+
});
|
|
2280
|
+
/**
|
|
2281
|
+
* 配置request请求时的默认参数
|
|
2282
|
+
*/
|
|
2283
|
+
|
|
2284
|
+
axios.interceptors.response.use(function (response) {
|
|
2285
|
+
var _headers$contentDisp;
|
|
2286
|
+
|
|
2287
|
+
// Do something with response data
|
|
2288
|
+
// console.log(response, 'response!!!!!!');
|
|
2289
|
+
NProgress.done();
|
|
2290
|
+
|
|
2291
|
+
if (response.status !== 200) {
|
|
2292
|
+
var error = {
|
|
2293
|
+
description: codeMessage[response.status],
|
|
2294
|
+
message: response.status
|
|
2295
|
+
}; // notification.error(error);
|
|
2296
|
+
|
|
2297
|
+
throw new Error(JSON.stringify(error));
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
var data = response.data,
|
|
2301
|
+
headers = response.headers;
|
|
2302
|
+
|
|
2303
|
+
if ((_headers$contentDisp = headers['content-disposition']) != null && _headers$contentDisp.includes('attachment;')) {
|
|
2304
|
+
// downloadFile(response);
|
|
2305
|
+
return;
|
|
2306
|
+
} // console.log(data, 'data2390jasdflkf');
|
|
2307
|
+
// if ((data.errcode === undefined
|
|
2308
|
+
// ? (data.errCode !== 0 && data.errCode !== 2)
|
|
2309
|
+
// : (data.errcode !== 0 && data.errcode !== 2))
|
|
2310
|
+
// || data.ret !== 0) {
|
|
2311
|
+
//
|
|
2312
|
+
// // notification.error({
|
|
2313
|
+
// // message: data.msg,
|
|
2314
|
+
// // });
|
|
2315
|
+
// throw new Error(JSON.stringify(data));
|
|
2316
|
+
// }
|
|
2317
|
+
|
|
2318
|
+
|
|
2319
|
+
return data;
|
|
2320
|
+
}, function (error) {
|
|
2321
|
+
// Do something with response error
|
|
2322
|
+
NProgress.done();
|
|
2323
|
+
return Promise.reject(error);
|
|
2324
|
+
});
|
|
2325
|
+
function request(_x, _x2) {
|
|
2326
|
+
return _request.apply(this, arguments);
|
|
2327
|
+
} // export function downloadFile(res: AxiosResponse) {
|
|
2328
|
+
// const {data, headers} = res;
|
|
2329
|
+
// // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
2330
|
+
// const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
2331
|
+
// const blob = new Blob([data], {});
|
|
2332
|
+
// FileSaver.saveAs(blob, fileName);
|
|
2333
|
+
// }
|
|
2334
|
+
|
|
2335
|
+
function _request() {
|
|
2336
|
+
_request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, _temp) {
|
|
2337
|
+
var _ref, _ref$noRedirect, noRedirect, _ref$noErrorAlert, noErrorAlert, result;
|
|
2338
|
+
|
|
2339
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2340
|
+
while (1) {
|
|
2341
|
+
switch (_context.prev = _context.next) {
|
|
2342
|
+
case 0:
|
|
2343
|
+
_ref = _temp === void 0 ? {} : _temp, _ref$noRedirect = _ref.noRedirect, noRedirect = _ref$noRedirect === void 0 ? false : _ref$noRedirect, _ref$noErrorAlert = _ref.noErrorAlert, noErrorAlert = _ref$noErrorAlert === void 0 ? false : _ref$noErrorAlert;
|
|
2344
|
+
_context.next = 3;
|
|
2345
|
+
return axios.request(config);
|
|
2346
|
+
|
|
2347
|
+
case 3:
|
|
2348
|
+
result = _context.sent;
|
|
2349
|
+
|
|
2350
|
+
if (!((result.errCode === 30 || result.errCode === 30) && !noRedirect)) {
|
|
2351
|
+
_context.next = 8;
|
|
2352
|
+
break;
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
_context.next = 7;
|
|
2356
|
+
return FServiceAPI.User.logout();
|
|
2357
|
+
|
|
2358
|
+
case 7:
|
|
2359
|
+
window.location.replace("" + completeUrlByDomain('user') + login({
|
|
2360
|
+
goTo: window.location.href
|
|
2361
|
+
}));
|
|
2362
|
+
|
|
2363
|
+
case 8:
|
|
2364
|
+
|
|
2365
|
+
return _context.abrupt("return", result);
|
|
2366
|
+
|
|
2367
|
+
case 10:
|
|
2368
|
+
case "end":
|
|
2369
|
+
return _context.stop();
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
}, _callee);
|
|
2373
|
+
}));
|
|
2374
|
+
return _request.apply(this, arguments);
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
/**
|
|
2378
|
+
* 根据 File 获取 SHA1 Hash 字符串
|
|
2379
|
+
* @param file
|
|
2380
|
+
* @return {Promise<string>}
|
|
2381
|
+
*/
|
|
2382
|
+
|
|
2383
|
+
function getSHA1Hash(file) {
|
|
2384
|
+
return new Promise(function (resolve) {
|
|
2385
|
+
var reader = new FileReader();
|
|
2386
|
+
|
|
2387
|
+
reader.onload = function () {
|
|
2388
|
+
var wordArray = lib.WordArray.create(reader.result);
|
|
2389
|
+
var hash = SHA1(wordArray).toString();
|
|
2390
|
+
resolve(hash);
|
|
2391
|
+
};
|
|
2392
|
+
|
|
2393
|
+
reader.readAsArrayBuffer(file);
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
/**
|
|
2397
|
+
* 生成随机码
|
|
2398
|
+
*/
|
|
2399
|
+
|
|
2400
|
+
function generateRandomCode(strLen) {
|
|
2401
|
+
if (strLen === void 0) {
|
|
2402
|
+
strLen = 5;
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
var allStr = 'ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
|
|
2406
|
+
var newStrArr = [];
|
|
2407
|
+
|
|
2408
|
+
for (var i = 0; i < strLen; i++) {
|
|
2409
|
+
newStrArr.push(allStr[Math.floor(Math.random() * 61)]);
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
return newStrArr.join('');
|
|
2413
|
+
}
|
|
2414
|
+
/**
|
|
2415
|
+
* 通过读取 cookies 获取用户 ID
|
|
2416
|
+
*/
|
|
2417
|
+
|
|
2418
|
+
function getUserIDByCookies() {
|
|
2419
|
+
var uid = document.cookie.split('; ').find(function (co) {
|
|
2420
|
+
return co.startsWith('uid=');
|
|
2421
|
+
});
|
|
2422
|
+
|
|
2423
|
+
if (!uid) {
|
|
2424
|
+
return -1;
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
return Number(uid.replace('uid=', ''));
|
|
2428
|
+
}
|
|
2429
|
+
function transformServerAPIContractState(_ref) {
|
|
2430
|
+
var status = _ref.status,
|
|
2431
|
+
authStatus = _ref.authStatus;
|
|
2432
|
+
|
|
2433
|
+
if (status === 0) {
|
|
2434
|
+
if (authStatus === 1 || authStatus === 3) {
|
|
2435
|
+
return 'active';
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
if (authStatus === 2) {
|
|
2439
|
+
return 'testActive';
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
if (authStatus === 128) {
|
|
2443
|
+
return 'inactive';
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
if (status === 1) {
|
|
2448
|
+
return 'terminal';
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
return 'exception';
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
var Tool = {
|
|
2455
|
+
__proto__: null,
|
|
2456
|
+
getSHA1Hash: getSHA1Hash,
|
|
2457
|
+
generateRandomCode: generateRandomCode,
|
|
2458
|
+
getUserIDByCookies: getUserIDByCookies,
|
|
2459
|
+
transformServerAPIContractState: transformServerAPIContractState
|
|
2460
|
+
};
|
|
2461
|
+
|
|
2462
|
+
var FUtil = {
|
|
2463
|
+
Format: Format,
|
|
2464
|
+
Regexp: Regexp,
|
|
2465
|
+
LinkTo: LinkTo,
|
|
2466
|
+
Predefined: Predefined,
|
|
2467
|
+
Axios: axios,
|
|
2468
|
+
Request: request,
|
|
2469
|
+
Tool: Tool
|
|
2470
|
+
};
|
|
2471
|
+
|
|
2862
2472
|
export { FServiceAPI, FUtil };
|
|
2863
2473
|
//# sourceMappingURL=tools-lib.esm.js.map
|