sanity-plugin-transifex 2.0.0 → 2.0.3
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/dist/index.d.ts +2 -2
- package/dist/sanity-plugin-transifex.cjs.development.js +463 -796
- package/dist/sanity-plugin-transifex.cjs.development.js.map +1 -1
- package/dist/sanity-plugin-transifex.cjs.production.min.js +1 -1
- package/dist/sanity-plugin-transifex.cjs.production.min.js.map +1 -1
- package/dist/sanity-plugin-transifex.esm.js +452 -797
- package/dist/sanity-plugin-transifex.esm.js.map +1 -1
- package/dist/transifexAdapter/createTask.d.ts +6 -0
- package/dist/transifexAdapter/getLocales.d.ts +2 -0
- package/dist/transifexAdapter/getTranslation.d.ts +2 -0
- package/dist/transifexAdapter/getTranslationTask.d.ts +6 -0
- package/dist/transifexAdapter/helpers.d.ts +7 -0
- package/dist/{transifexAdapter.d.ts → transifexAdapter/index.d.ts} +0 -0
- package/package.json +2 -3
- package/src/index.ts +4 -0
- package/src/transifexAdapter/createTask.ts +87 -0
- package/src/transifexAdapter/getLocales.ts +21 -0
- package/src/transifexAdapter/getTranslation.ts +102 -0
- package/src/transifexAdapter/getTranslationTask.ts +58 -0
- package/src/transifexAdapter/helpers.ts +11 -0
- package/src/transifexAdapter/index.ts +13 -0
- package/src/transifexAdapter.ts +0 -231
|
@@ -1,836 +1,422 @@
|
|
|
1
1
|
import { baseFieldLevelConfig, baseDocumentLevelConfig } from 'sanity-translations-tab';
|
|
2
|
-
export { BaseDocumentDeserializer, BaseDocumentMerger, BaseDocumentSerializer, TranslationsTab, customSerializers, defaultStopTypes, findLatestDraft } from 'sanity-translations-tab';
|
|
2
|
+
export { BaseDocumentDeserializer, BaseDocumentMerger, BaseDocumentSerializer, TranslationsTab, customSerializers, defaultStopTypes, documentLevelPatch, fieldLevelPatch, findLatestDraft } from 'sanity-translations-tab';
|
|
3
3
|
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
var info = gen[key](arg);
|
|
7
|
-
var value = info.value;
|
|
8
|
-
} catch (error) {
|
|
9
|
-
reject(error);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (info.done) {
|
|
14
|
-
resolve(value);
|
|
15
|
-
} else {
|
|
16
|
-
Promise.resolve(value).then(_next, _throw);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _asyncToGenerator(fn) {
|
|
21
|
-
return function () {
|
|
22
|
-
var self = this,
|
|
23
|
-
args = arguments;
|
|
24
|
-
return new Promise(function (resolve, reject) {
|
|
25
|
-
var gen = fn.apply(self, args);
|
|
26
|
-
|
|
27
|
-
function _next(value) {
|
|
28
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function _throw(err) {
|
|
32
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
-
}
|
|
4
|
+
function _regeneratorRuntime() {
|
|
5
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
34
6
|
|
|
35
|
-
|
|
36
|
-
|
|
7
|
+
_regeneratorRuntime = function () {
|
|
8
|
+
return exports;
|
|
37
9
|
};
|
|
38
|
-
}
|
|
39
10
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
target[key] = source[key];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return target;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return _extends.apply(this, arguments);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function createCommonjsModule(fn, module) {
|
|
59
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
var runtime_1 = createCommonjsModule(function (module) {
|
|
63
|
-
/**
|
|
64
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
65
|
-
*
|
|
66
|
-
* This source code is licensed under the MIT license found in the
|
|
67
|
-
* LICENSE file in the root directory of this source tree.
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
var runtime = (function (exports) {
|
|
71
|
-
|
|
72
|
-
var Op = Object.prototype;
|
|
73
|
-
var hasOwn = Op.hasOwnProperty;
|
|
74
|
-
var undefined$1; // More compressible than void 0.
|
|
75
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
76
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
77
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
78
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
11
|
+
var exports = {},
|
|
12
|
+
Op = Object.prototype,
|
|
13
|
+
hasOwn = Op.hasOwnProperty,
|
|
14
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
15
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
16
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
17
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
79
18
|
|
|
80
19
|
function define(obj, key, value) {
|
|
81
|
-
Object.defineProperty(obj, key, {
|
|
20
|
+
return Object.defineProperty(obj, key, {
|
|
82
21
|
value: value,
|
|
83
|
-
enumerable:
|
|
84
|
-
configurable:
|
|
85
|
-
writable:
|
|
86
|
-
});
|
|
87
|
-
return obj[key];
|
|
22
|
+
enumerable: !0,
|
|
23
|
+
configurable: !0,
|
|
24
|
+
writable: !0
|
|
25
|
+
}), obj[key];
|
|
88
26
|
}
|
|
27
|
+
|
|
89
28
|
try {
|
|
90
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
91
29
|
define({}, "");
|
|
92
30
|
} catch (err) {
|
|
93
|
-
define = function(obj, key, value) {
|
|
31
|
+
define = function (obj, key, value) {
|
|
94
32
|
return obj[key] = value;
|
|
95
33
|
};
|
|
96
34
|
}
|
|
97
35
|
|
|
98
36
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
37
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
38
|
+
generator = Object.create(protoGenerator.prototype),
|
|
39
|
+
context = new Context(tryLocsList || []);
|
|
40
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
41
|
+
var state = "suspendedStart";
|
|
42
|
+
return function (method, arg) {
|
|
43
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
44
|
+
|
|
45
|
+
if ("completed" === state) {
|
|
46
|
+
if ("throw" === method) throw arg;
|
|
47
|
+
return doneResult();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
for (context.method = method, context.arg = arg;;) {
|
|
51
|
+
var delegate = context.delegate;
|
|
103
52
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
53
|
+
if (delegate) {
|
|
54
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
107
55
|
|
|
108
|
-
|
|
56
|
+
if (delegateResult) {
|
|
57
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
58
|
+
return delegateResult;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
63
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
64
|
+
context.dispatchException(context.arg);
|
|
65
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
66
|
+
state = "executing";
|
|
67
|
+
var record = tryCatch(innerFn, self, context);
|
|
68
|
+
|
|
69
|
+
if ("normal" === record.type) {
|
|
70
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
71
|
+
return {
|
|
72
|
+
value: record.arg,
|
|
73
|
+
done: context.done
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}(innerFn, self, context), generator;
|
|
109
81
|
}
|
|
110
|
-
exports.wrap = wrap;
|
|
111
82
|
|
|
112
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
113
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
114
|
-
// have been (and was previously) designed to take a closure to be
|
|
115
|
-
// invoked without arguments, but in all the cases we care about we
|
|
116
|
-
// already have an existing method we want to call, so there's no need
|
|
117
|
-
// to create a new function object. We can even get away with assuming
|
|
118
|
-
// the method takes exactly one argument, since that happens to be true
|
|
119
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
120
|
-
// only additional allocation required is the completion record, which
|
|
121
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
122
83
|
function tryCatch(fn, obj, arg) {
|
|
123
84
|
try {
|
|
124
|
-
return {
|
|
85
|
+
return {
|
|
86
|
+
type: "normal",
|
|
87
|
+
arg: fn.call(obj, arg)
|
|
88
|
+
};
|
|
125
89
|
} catch (err) {
|
|
126
|
-
return {
|
|
90
|
+
return {
|
|
91
|
+
type: "throw",
|
|
92
|
+
arg: err
|
|
93
|
+
};
|
|
127
94
|
}
|
|
128
95
|
}
|
|
129
96
|
|
|
130
|
-
|
|
131
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
132
|
-
var GenStateExecuting = "executing";
|
|
133
|
-
var GenStateCompleted = "completed";
|
|
134
|
-
|
|
135
|
-
// Returning this object from the innerFn has the same effect as
|
|
136
|
-
// breaking out of the dispatch switch statement.
|
|
97
|
+
exports.wrap = wrap;
|
|
137
98
|
var ContinueSentinel = {};
|
|
138
99
|
|
|
139
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
140
|
-
// .constructor.prototype properties for functions that return Generator
|
|
141
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
142
|
-
// minifier not to mangle the names of these two functions.
|
|
143
100
|
function Generator() {}
|
|
101
|
+
|
|
144
102
|
function GeneratorFunction() {}
|
|
103
|
+
|
|
145
104
|
function GeneratorFunctionPrototype() {}
|
|
146
105
|
|
|
147
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
148
|
-
// don't natively support it.
|
|
149
106
|
var IteratorPrototype = {};
|
|
150
107
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
151
108
|
return this;
|
|
152
109
|
});
|
|
110
|
+
var getProto = Object.getPrototypeOf,
|
|
111
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
112
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
113
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
153
114
|
|
|
154
|
-
var getProto = Object.getPrototypeOf;
|
|
155
|
-
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
156
|
-
if (NativeIteratorPrototype &&
|
|
157
|
-
NativeIteratorPrototype !== Op &&
|
|
158
|
-
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
159
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
160
|
-
// of the polyfill.
|
|
161
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
var Gp = GeneratorFunctionPrototype.prototype =
|
|
165
|
-
Generator.prototype = Object.create(IteratorPrototype);
|
|
166
|
-
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
167
|
-
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
168
|
-
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
169
|
-
GeneratorFunction.displayName = define(
|
|
170
|
-
GeneratorFunctionPrototype,
|
|
171
|
-
toStringTagSymbol,
|
|
172
|
-
"GeneratorFunction"
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
176
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
177
115
|
function defineIteratorMethods(prototype) {
|
|
178
|
-
["next", "throw", "return"].forEach(function(method) {
|
|
179
|
-
define(prototype, method, function(arg) {
|
|
116
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
117
|
+
define(prototype, method, function (arg) {
|
|
180
118
|
return this._invoke(method, arg);
|
|
181
119
|
});
|
|
182
120
|
});
|
|
183
121
|
}
|
|
184
122
|
|
|
185
|
-
exports.isGeneratorFunction = function(genFun) {
|
|
186
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
187
|
-
return ctor
|
|
188
|
-
? ctor === GeneratorFunction ||
|
|
189
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
190
|
-
// do is to check its .name property.
|
|
191
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
192
|
-
: false;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
exports.mark = function(genFun) {
|
|
196
|
-
if (Object.setPrototypeOf) {
|
|
197
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
198
|
-
} else {
|
|
199
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
200
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
201
|
-
}
|
|
202
|
-
genFun.prototype = Object.create(Gp);
|
|
203
|
-
return genFun;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
// Within the body of any async function, `await x` is transformed to
|
|
207
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
208
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
209
|
-
// meant to be awaited.
|
|
210
|
-
exports.awrap = function(arg) {
|
|
211
|
-
return { __await: arg };
|
|
212
|
-
};
|
|
213
|
-
|
|
214
123
|
function AsyncIterator(generator, PromiseImpl) {
|
|
215
124
|
function invoke(method, arg, resolve, reject) {
|
|
216
125
|
var record = tryCatch(generator[method], generator, arg);
|
|
217
|
-
if (record.type === "throw") {
|
|
218
|
-
reject(record.arg);
|
|
219
|
-
} else {
|
|
220
|
-
var result = record.arg;
|
|
221
|
-
var value = result.value;
|
|
222
|
-
if (value &&
|
|
223
|
-
typeof value === "object" &&
|
|
224
|
-
hasOwn.call(value, "__await")) {
|
|
225
|
-
return PromiseImpl.resolve(value.__await).then(function(value) {
|
|
226
|
-
invoke("next", value, resolve, reject);
|
|
227
|
-
}, function(err) {
|
|
228
|
-
invoke("throw", err, resolve, reject);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
126
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
127
|
+
if ("throw" !== record.type) {
|
|
128
|
+
var result = record.arg,
|
|
129
|
+
value = result.value;
|
|
130
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
131
|
+
invoke("next", value, resolve, reject);
|
|
132
|
+
}, function (err) {
|
|
133
|
+
invoke("throw", err, resolve, reject);
|
|
134
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
135
|
+
result.value = unwrapped, resolve(result);
|
|
136
|
+
}, function (error) {
|
|
241
137
|
return invoke("throw", error, resolve, reject);
|
|
242
138
|
});
|
|
243
139
|
}
|
|
140
|
+
|
|
141
|
+
reject(record.arg);
|
|
244
142
|
}
|
|
245
143
|
|
|
246
144
|
var previousPromise;
|
|
247
145
|
|
|
248
|
-
function
|
|
146
|
+
this._invoke = function (method, arg) {
|
|
249
147
|
function callInvokeWithMethodAndArg() {
|
|
250
|
-
return new PromiseImpl(function(resolve, reject) {
|
|
148
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
251
149
|
invoke(method, arg, resolve, reject);
|
|
252
150
|
});
|
|
253
151
|
}
|
|
254
152
|
|
|
255
|
-
return previousPromise =
|
|
256
|
-
// If enqueue has been called before, then we want to wait until
|
|
257
|
-
// all previous Promises have been resolved before calling invoke,
|
|
258
|
-
// so that results are always delivered in the correct order. If
|
|
259
|
-
// enqueue has not been called before, then it is important to
|
|
260
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
261
|
-
// so that the async generator function has the opportunity to do
|
|
262
|
-
// any necessary setup in a predictable way. This predictability
|
|
263
|
-
// is why the Promise constructor synchronously invokes its
|
|
264
|
-
// executor callback, and why async functions synchronously
|
|
265
|
-
// execute code before the first await. Since we implement simple
|
|
266
|
-
// async functions in terms of async generators, it is especially
|
|
267
|
-
// important to get this right, even though it requires care.
|
|
268
|
-
previousPromise ? previousPromise.then(
|
|
269
|
-
callInvokeWithMethodAndArg,
|
|
270
|
-
// Avoid propagating failures to Promises returned by later
|
|
271
|
-
// invocations of the iterator.
|
|
272
|
-
callInvokeWithMethodAndArg
|
|
273
|
-
) : callInvokeWithMethodAndArg();
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// Define the unified helper method that is used to implement .next,
|
|
277
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
278
|
-
this._invoke = enqueue;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
282
|
-
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
283
|
-
return this;
|
|
284
|
-
});
|
|
285
|
-
exports.AsyncIterator = AsyncIterator;
|
|
286
|
-
|
|
287
|
-
// Note that simple async functions are implemented on top of
|
|
288
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
289
|
-
// the final result produced by the iterator.
|
|
290
|
-
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
291
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
292
|
-
|
|
293
|
-
var iter = new AsyncIterator(
|
|
294
|
-
wrap(innerFn, outerFn, self, tryLocsList),
|
|
295
|
-
PromiseImpl
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
return exports.isGeneratorFunction(outerFn)
|
|
299
|
-
? iter // If outerFn is a generator, return the full iterator.
|
|
300
|
-
: iter.next().then(function(result) {
|
|
301
|
-
return result.done ? result.value : iter.next();
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
306
|
-
var state = GenStateSuspendedStart;
|
|
307
|
-
|
|
308
|
-
return function invoke(method, arg) {
|
|
309
|
-
if (state === GenStateExecuting) {
|
|
310
|
-
throw new Error("Generator is already running");
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (state === GenStateCompleted) {
|
|
314
|
-
if (method === "throw") {
|
|
315
|
-
throw arg;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
319
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
320
|
-
return doneResult();
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
context.method = method;
|
|
324
|
-
context.arg = arg;
|
|
325
|
-
|
|
326
|
-
while (true) {
|
|
327
|
-
var delegate = context.delegate;
|
|
328
|
-
if (delegate) {
|
|
329
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
330
|
-
if (delegateResult) {
|
|
331
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
332
|
-
return delegateResult;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (context.method === "next") {
|
|
337
|
-
// Setting context._sent for legacy support of Babel's
|
|
338
|
-
// function.sent implementation.
|
|
339
|
-
context.sent = context._sent = context.arg;
|
|
340
|
-
|
|
341
|
-
} else if (context.method === "throw") {
|
|
342
|
-
if (state === GenStateSuspendedStart) {
|
|
343
|
-
state = GenStateCompleted;
|
|
344
|
-
throw context.arg;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
context.dispatchException(context.arg);
|
|
348
|
-
|
|
349
|
-
} else if (context.method === "return") {
|
|
350
|
-
context.abrupt("return", context.arg);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
state = GenStateExecuting;
|
|
354
|
-
|
|
355
|
-
var record = tryCatch(innerFn, self, context);
|
|
356
|
-
if (record.type === "normal") {
|
|
357
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
358
|
-
// GenStateExecuting and loop back for another invocation.
|
|
359
|
-
state = context.done
|
|
360
|
-
? GenStateCompleted
|
|
361
|
-
: GenStateSuspendedYield;
|
|
362
|
-
|
|
363
|
-
if (record.arg === ContinueSentinel) {
|
|
364
|
-
continue;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return {
|
|
368
|
-
value: record.arg,
|
|
369
|
-
done: context.done
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
} else if (record.type === "throw") {
|
|
373
|
-
state = GenStateCompleted;
|
|
374
|
-
// Dispatch the exception by looping back around to the
|
|
375
|
-
// context.dispatchException(context.arg) call above.
|
|
376
|
-
context.method = "throw";
|
|
377
|
-
context.arg = record.arg;
|
|
378
|
-
}
|
|
379
|
-
}
|
|
153
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
380
154
|
};
|
|
381
155
|
}
|
|
382
156
|
|
|
383
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
384
|
-
// result, either by returning a { value, done } result from the
|
|
385
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
386
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
387
157
|
function maybeInvokeDelegate(delegate, context) {
|
|
388
158
|
var method = delegate.iterator[context.method];
|
|
389
|
-
if (method === undefined$1) {
|
|
390
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
391
|
-
// method always terminates the yield* loop.
|
|
392
|
-
context.delegate = null;
|
|
393
|
-
|
|
394
|
-
if (context.method === "throw") {
|
|
395
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
396
|
-
if (delegate.iterator["return"]) {
|
|
397
|
-
// If the delegate iterator has a return method, give it a
|
|
398
|
-
// chance to clean up.
|
|
399
|
-
context.method = "return";
|
|
400
|
-
context.arg = undefined$1;
|
|
401
|
-
maybeInvokeDelegate(delegate, context);
|
|
402
|
-
|
|
403
|
-
if (context.method === "throw") {
|
|
404
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
405
|
-
// "return" to "throw", let that override the TypeError below.
|
|
406
|
-
return ContinueSentinel;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
159
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
160
|
+
if (undefined === method) {
|
|
161
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
162
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
163
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
413
164
|
}
|
|
414
165
|
|
|
415
166
|
return ContinueSentinel;
|
|
416
167
|
}
|
|
417
168
|
|
|
418
169
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
419
|
-
|
|
420
|
-
if (record.type === "throw") {
|
|
421
|
-
context.method = "throw";
|
|
422
|
-
context.arg = record.arg;
|
|
423
|
-
context.delegate = null;
|
|
424
|
-
return ContinueSentinel;
|
|
425
|
-
}
|
|
426
|
-
|
|
170
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
427
171
|
var info = record.arg;
|
|
428
|
-
|
|
429
|
-
if (! info) {
|
|
430
|
-
context.method = "throw";
|
|
431
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
432
|
-
context.delegate = null;
|
|
433
|
-
return ContinueSentinel;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
if (info.done) {
|
|
437
|
-
// Assign the result of the finished delegate to the temporary
|
|
438
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
439
|
-
context[delegate.resultName] = info.value;
|
|
440
|
-
|
|
441
|
-
// Resume execution at the desired location (see delegateYield).
|
|
442
|
-
context.next = delegate.nextLoc;
|
|
443
|
-
|
|
444
|
-
// If context.method was "throw" but the delegate handled the
|
|
445
|
-
// exception, let the outer generator proceed normally. If
|
|
446
|
-
// context.method was "next", forget context.arg since it has been
|
|
447
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
448
|
-
// "return", allow the original .return call to continue in the
|
|
449
|
-
// outer generator.
|
|
450
|
-
if (context.method !== "return") {
|
|
451
|
-
context.method = "next";
|
|
452
|
-
context.arg = undefined$1;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
} else {
|
|
456
|
-
// Re-yield the result returned by the delegate method.
|
|
457
|
-
return info;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
461
|
-
// the outer generator.
|
|
462
|
-
context.delegate = null;
|
|
463
|
-
return ContinueSentinel;
|
|
172
|
+
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);
|
|
464
173
|
}
|
|
465
174
|
|
|
466
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
467
|
-
// unified ._invoke helper method.
|
|
468
|
-
defineIteratorMethods(Gp);
|
|
469
|
-
|
|
470
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
471
|
-
|
|
472
|
-
// A Generator should always return itself as the iterator object when the
|
|
473
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
474
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
475
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
476
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
477
|
-
define(Gp, iteratorSymbol, function() {
|
|
478
|
-
return this;
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
define(Gp, "toString", function() {
|
|
482
|
-
return "[object Generator]";
|
|
483
|
-
});
|
|
484
|
-
|
|
485
175
|
function pushTryEntry(locs) {
|
|
486
|
-
var entry = {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
if (2 in locs) {
|
|
493
|
-
entry.finallyLoc = locs[2];
|
|
494
|
-
entry.afterLoc = locs[3];
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
this.tryEntries.push(entry);
|
|
176
|
+
var entry = {
|
|
177
|
+
tryLoc: locs[0]
|
|
178
|
+
};
|
|
179
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
498
180
|
}
|
|
499
181
|
|
|
500
182
|
function resetTryEntry(entry) {
|
|
501
183
|
var record = entry.completion || {};
|
|
502
|
-
record.type = "normal";
|
|
503
|
-
delete record.arg;
|
|
504
|
-
entry.completion = record;
|
|
184
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
505
185
|
}
|
|
506
186
|
|
|
507
187
|
function Context(tryLocsList) {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
this.tryEntries = [{ tryLoc: "root" }];
|
|
512
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
513
|
-
this.reset(true);
|
|
188
|
+
this.tryEntries = [{
|
|
189
|
+
tryLoc: "root"
|
|
190
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
514
191
|
}
|
|
515
192
|
|
|
516
|
-
exports.keys = function(object) {
|
|
517
|
-
var keys = [];
|
|
518
|
-
for (var key in object) {
|
|
519
|
-
keys.push(key);
|
|
520
|
-
}
|
|
521
|
-
keys.reverse();
|
|
522
|
-
|
|
523
|
-
// Rather than returning an object with a next method, we keep
|
|
524
|
-
// things simple and return the next function itself.
|
|
525
|
-
return function next() {
|
|
526
|
-
while (keys.length) {
|
|
527
|
-
var key = keys.pop();
|
|
528
|
-
if (key in object) {
|
|
529
|
-
next.value = key;
|
|
530
|
-
next.done = false;
|
|
531
|
-
return next;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
// To avoid creating an additional object, we just hang the .value
|
|
536
|
-
// and .done properties off the next function object itself. This
|
|
537
|
-
// also ensures that the minifier will not anonymize the function.
|
|
538
|
-
next.done = true;
|
|
539
|
-
return next;
|
|
540
|
-
};
|
|
541
|
-
};
|
|
542
|
-
|
|
543
193
|
function values(iterable) {
|
|
544
194
|
if (iterable) {
|
|
545
195
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
546
|
-
if (iteratorMethod)
|
|
547
|
-
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
if (typeof iterable.next === "function") {
|
|
551
|
-
return iterable;
|
|
552
|
-
}
|
|
196
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
197
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
553
198
|
|
|
554
199
|
if (!isNaN(iterable.length)) {
|
|
555
|
-
var i = -1,
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
next.value = iterable[i];
|
|
559
|
-
next.done = false;
|
|
560
|
-
return next;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
next.value = undefined$1;
|
|
565
|
-
next.done = true;
|
|
200
|
+
var i = -1,
|
|
201
|
+
next = function next() {
|
|
202
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
566
203
|
|
|
567
|
-
return next;
|
|
204
|
+
return next.value = undefined, next.done = !0, next;
|
|
568
205
|
};
|
|
569
206
|
|
|
570
207
|
return next.next = next;
|
|
571
208
|
}
|
|
572
209
|
}
|
|
573
210
|
|
|
574
|
-
|
|
575
|
-
|
|
211
|
+
return {
|
|
212
|
+
next: doneResult
|
|
213
|
+
};
|
|
576
214
|
}
|
|
577
|
-
exports.values = values;
|
|
578
215
|
|
|
579
216
|
function doneResult() {
|
|
580
|
-
return {
|
|
217
|
+
return {
|
|
218
|
+
value: undefined,
|
|
219
|
+
done: !0
|
|
220
|
+
};
|
|
581
221
|
}
|
|
582
222
|
|
|
583
|
-
|
|
584
|
-
constructor
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
this[name] = undefined$1;
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
},
|
|
223
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
224
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
225
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
226
|
+
}, exports.mark = function (genFun) {
|
|
227
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
228
|
+
}, exports.awrap = function (arg) {
|
|
229
|
+
return {
|
|
230
|
+
__await: arg
|
|
231
|
+
};
|
|
232
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
233
|
+
return this;
|
|
234
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
235
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
236
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
237
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
238
|
+
return result.done ? result.value : iter.next();
|
|
239
|
+
});
|
|
240
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
241
|
+
return this;
|
|
242
|
+
}), define(Gp, "toString", function () {
|
|
243
|
+
return "[object Generator]";
|
|
244
|
+
}), exports.keys = function (object) {
|
|
245
|
+
var keys = [];
|
|
611
246
|
|
|
612
|
-
|
|
613
|
-
this.done = true;
|
|
247
|
+
for (var key in object) keys.push(key);
|
|
614
248
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
249
|
+
return keys.reverse(), function next() {
|
|
250
|
+
for (; keys.length;) {
|
|
251
|
+
var key = keys.pop();
|
|
252
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
619
253
|
}
|
|
620
254
|
|
|
255
|
+
return next.done = !0, next;
|
|
256
|
+
};
|
|
257
|
+
}, exports.values = values, Context.prototype = {
|
|
258
|
+
constructor: Context,
|
|
259
|
+
reset: function (skipTempReset) {
|
|
260
|
+
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);
|
|
261
|
+
},
|
|
262
|
+
stop: function () {
|
|
263
|
+
this.done = !0;
|
|
264
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
265
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
621
266
|
return this.rval;
|
|
622
267
|
},
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
if (this.done) {
|
|
626
|
-
throw exception;
|
|
627
|
-
}
|
|
628
|
-
|
|
268
|
+
dispatchException: function (exception) {
|
|
269
|
+
if (this.done) throw exception;
|
|
629
270
|
var context = this;
|
|
630
|
-
function handle(loc, caught) {
|
|
631
|
-
record.type = "throw";
|
|
632
|
-
record.arg = exception;
|
|
633
|
-
context.next = loc;
|
|
634
|
-
|
|
635
|
-
if (caught) {
|
|
636
|
-
// If the dispatched exception was caught by a catch block,
|
|
637
|
-
// then let that catch block handle the exception normally.
|
|
638
|
-
context.method = "next";
|
|
639
|
-
context.arg = undefined$1;
|
|
640
|
-
}
|
|
641
271
|
|
|
642
|
-
|
|
272
|
+
function handle(loc, caught) {
|
|
273
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
643
274
|
}
|
|
644
275
|
|
|
645
276
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
646
|
-
var entry = this.tryEntries[i]
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
if (entry.tryLoc === "root") {
|
|
650
|
-
// Exception thrown outside of any try block that could handle
|
|
651
|
-
// it, so set the completion value of the entire function to
|
|
652
|
-
// throw the exception.
|
|
653
|
-
return handle("end");
|
|
654
|
-
}
|
|
277
|
+
var entry = this.tryEntries[i],
|
|
278
|
+
record = entry.completion;
|
|
279
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
655
280
|
|
|
656
281
|
if (entry.tryLoc <= this.prev) {
|
|
657
|
-
var hasCatch = hasOwn.call(entry, "catchLoc")
|
|
658
|
-
|
|
282
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
283
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
659
284
|
|
|
660
285
|
if (hasCatch && hasFinally) {
|
|
661
|
-
if (this.prev < entry.catchLoc)
|
|
662
|
-
|
|
663
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
664
|
-
return handle(entry.finallyLoc);
|
|
665
|
-
}
|
|
666
|
-
|
|
286
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
287
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
667
288
|
} else if (hasCatch) {
|
|
668
|
-
if (this.prev < entry.catchLoc)
|
|
669
|
-
return handle(entry.catchLoc, true);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
} else if (hasFinally) {
|
|
673
|
-
if (this.prev < entry.finallyLoc) {
|
|
674
|
-
return handle(entry.finallyLoc);
|
|
675
|
-
}
|
|
676
|
-
|
|
289
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
677
290
|
} else {
|
|
678
|
-
throw new Error("try statement without catch or finally");
|
|
291
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
292
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
679
293
|
}
|
|
680
294
|
}
|
|
681
295
|
}
|
|
682
296
|
},
|
|
683
|
-
|
|
684
|
-
abrupt: function(type, arg) {
|
|
297
|
+
abrupt: function (type, arg) {
|
|
685
298
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
686
299
|
var entry = this.tryEntries[i];
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
this.prev < entry.finallyLoc) {
|
|
300
|
+
|
|
301
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
690
302
|
var finallyEntry = entry;
|
|
691
303
|
break;
|
|
692
304
|
}
|
|
693
305
|
}
|
|
694
306
|
|
|
695
|
-
|
|
696
|
-
(type === "break" ||
|
|
697
|
-
type === "continue") &&
|
|
698
|
-
finallyEntry.tryLoc <= arg &&
|
|
699
|
-
arg <= finallyEntry.finallyLoc) {
|
|
700
|
-
// Ignore the finally entry if control is not jumping to a
|
|
701
|
-
// location outside the try/catch block.
|
|
702
|
-
finallyEntry = null;
|
|
703
|
-
}
|
|
704
|
-
|
|
307
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
705
308
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
706
|
-
record.type = type;
|
|
707
|
-
record.arg = arg;
|
|
708
|
-
|
|
709
|
-
if (finallyEntry) {
|
|
710
|
-
this.method = "next";
|
|
711
|
-
this.next = finallyEntry.finallyLoc;
|
|
712
|
-
return ContinueSentinel;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
return this.complete(record);
|
|
309
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
716
310
|
},
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
throw record.arg;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
if (record.type === "break" ||
|
|
724
|
-
record.type === "continue") {
|
|
725
|
-
this.next = record.arg;
|
|
726
|
-
} else if (record.type === "return") {
|
|
727
|
-
this.rval = this.arg = record.arg;
|
|
728
|
-
this.method = "return";
|
|
729
|
-
this.next = "end";
|
|
730
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
731
|
-
this.next = afterLoc;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
return ContinueSentinel;
|
|
311
|
+
complete: function (record, afterLoc) {
|
|
312
|
+
if ("throw" === record.type) throw record.arg;
|
|
313
|
+
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;
|
|
735
314
|
},
|
|
736
|
-
|
|
737
|
-
finish: function(finallyLoc) {
|
|
315
|
+
finish: function (finallyLoc) {
|
|
738
316
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
739
317
|
var entry = this.tryEntries[i];
|
|
740
|
-
if (entry.finallyLoc === finallyLoc)
|
|
741
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
742
|
-
resetTryEntry(entry);
|
|
743
|
-
return ContinueSentinel;
|
|
744
|
-
}
|
|
318
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
745
319
|
}
|
|
746
320
|
},
|
|
747
|
-
|
|
748
|
-
"catch": function(tryLoc) {
|
|
321
|
+
catch: function (tryLoc) {
|
|
749
322
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
750
323
|
var entry = this.tryEntries[i];
|
|
324
|
+
|
|
751
325
|
if (entry.tryLoc === tryLoc) {
|
|
752
326
|
var record = entry.completion;
|
|
753
|
-
|
|
327
|
+
|
|
328
|
+
if ("throw" === record.type) {
|
|
754
329
|
var thrown = record.arg;
|
|
755
330
|
resetTryEntry(entry);
|
|
756
331
|
}
|
|
332
|
+
|
|
757
333
|
return thrown;
|
|
758
334
|
}
|
|
759
335
|
}
|
|
760
336
|
|
|
761
|
-
// The context.catch method must only be called with a location
|
|
762
|
-
// argument that corresponds to a known catch block.
|
|
763
337
|
throw new Error("illegal catch attempt");
|
|
764
338
|
},
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
this.delegate = {
|
|
339
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
340
|
+
return this.delegate = {
|
|
768
341
|
iterator: values(iterable),
|
|
769
342
|
resultName: resultName,
|
|
770
343
|
nextLoc: nextLoc
|
|
771
|
-
};
|
|
344
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
345
|
+
}
|
|
346
|
+
}, exports;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
350
|
+
try {
|
|
351
|
+
var info = gen[key](arg);
|
|
352
|
+
var value = info.value;
|
|
353
|
+
} catch (error) {
|
|
354
|
+
reject(error);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (info.done) {
|
|
359
|
+
resolve(value);
|
|
360
|
+
} else {
|
|
361
|
+
Promise.resolve(value).then(_next, _throw);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
772
364
|
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
365
|
+
function _asyncToGenerator(fn) {
|
|
366
|
+
return function () {
|
|
367
|
+
var self = this,
|
|
368
|
+
args = arguments;
|
|
369
|
+
return new Promise(function (resolve, reject) {
|
|
370
|
+
var gen = fn.apply(self, args);
|
|
371
|
+
|
|
372
|
+
function _next(value) {
|
|
373
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
777
374
|
}
|
|
778
375
|
|
|
779
|
-
|
|
780
|
-
|
|
376
|
+
function _throw(err) {
|
|
377
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
_next(undefined);
|
|
381
|
+
});
|
|
781
382
|
};
|
|
383
|
+
}
|
|
782
384
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
regeneratorRuntime = runtime;
|
|
799
|
-
} catch (accidentalStrictMode) {
|
|
800
|
-
// This module should not be running in strict mode, so the above
|
|
801
|
-
// assignment should always work unless something is misconfigured. Just
|
|
802
|
-
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
803
|
-
// we can explicitly access globalThis. In older engines we can escape
|
|
804
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
805
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
806
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
807
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
808
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
809
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
810
|
-
if (typeof globalThis === "object") {
|
|
811
|
-
globalThis.regeneratorRuntime = runtime;
|
|
812
|
-
} else {
|
|
813
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
814
|
-
}
|
|
385
|
+
function _extends() {
|
|
386
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
387
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
388
|
+
var source = arguments[i];
|
|
389
|
+
|
|
390
|
+
for (var key in source) {
|
|
391
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
392
|
+
target[key] = source[key];
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return target;
|
|
398
|
+
};
|
|
399
|
+
return _extends.apply(this, arguments);
|
|
815
400
|
}
|
|
816
|
-
});
|
|
817
401
|
|
|
818
402
|
var baseTransifexUrl = 'https://rest.api.transifex.com';
|
|
819
|
-
|
|
820
403
|
var getHeaders = function getHeaders(secrets) {
|
|
821
404
|
return {
|
|
822
405
|
Authorization: "Bearer " + (secrets == null ? void 0 : secrets.token),
|
|
823
406
|
'Content-Type': 'application/vnd.api+json'
|
|
824
407
|
};
|
|
825
408
|
};
|
|
826
|
-
|
|
827
409
|
var projOrgSlug = function projOrgSlug(secrets) {
|
|
828
410
|
return "o:" + (secrets == null ? void 0 : secrets.organization) + ":p:" + (secrets == null ? void 0 : secrets.project);
|
|
829
411
|
};
|
|
830
412
|
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
413
|
+
function getLocales(_x) {
|
|
414
|
+
return _getLocales.apply(this, arguments);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function _getLocales() {
|
|
418
|
+
_getLocales = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(secrets) {
|
|
419
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
834
420
|
while (1) {
|
|
835
421
|
switch (_context.prev = _context.next) {
|
|
836
422
|
case 0:
|
|
@@ -863,25 +449,26 @@ var getLocales = /*#__PURE__*/function () {
|
|
|
863
449
|
}
|
|
864
450
|
}, _callee);
|
|
865
451
|
}));
|
|
452
|
+
return _getLocales.apply(this, arguments);
|
|
453
|
+
}
|
|
866
454
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
}();
|
|
455
|
+
function getTranslationTask(_x, _x2) {
|
|
456
|
+
return _getTranslationTask.apply(this, arguments);
|
|
457
|
+
}
|
|
871
458
|
|
|
872
|
-
|
|
873
|
-
|
|
459
|
+
function _getTranslationTask() {
|
|
460
|
+
_getTranslationTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(documentId, secrets) {
|
|
874
461
|
var projectFilter, resourceFilter, task, locales, localeIds, validLocales;
|
|
875
|
-
return
|
|
462
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
876
463
|
while (1) {
|
|
877
|
-
switch (
|
|
464
|
+
switch (_context.prev = _context.next) {
|
|
878
465
|
case 0:
|
|
879
466
|
if (!(!documentId || !secrets)) {
|
|
880
|
-
|
|
467
|
+
_context.next = 2;
|
|
881
468
|
break;
|
|
882
469
|
}
|
|
883
470
|
|
|
884
|
-
return
|
|
471
|
+
return _context.abrupt("return", {
|
|
885
472
|
taskId: documentId,
|
|
886
473
|
documentId: documentId,
|
|
887
474
|
locales: []
|
|
@@ -890,7 +477,7 @@ var getTranslationTask = /*#__PURE__*/function () {
|
|
|
890
477
|
case 2:
|
|
891
478
|
projectFilter = "filter[project]=" + projOrgSlug(secrets);
|
|
892
479
|
resourceFilter = "filter[resource]=" + projOrgSlug(secrets) + ":r:" + documentId;
|
|
893
|
-
|
|
480
|
+
_context.next = 6;
|
|
894
481
|
return fetch(baseTransifexUrl + "/resource_language_stats?" + projectFilter + "&" + resourceFilter, {
|
|
895
482
|
headers: getHeaders(secrets)
|
|
896
483
|
}).then(function (res) {
|
|
@@ -918,12 +505,12 @@ var getTranslationTask = /*#__PURE__*/function () {
|
|
|
918
505
|
});
|
|
919
506
|
|
|
920
507
|
case 6:
|
|
921
|
-
task =
|
|
922
|
-
|
|
508
|
+
task = _context.sent;
|
|
509
|
+
_context.next = 9;
|
|
923
510
|
return getLocales(secrets);
|
|
924
511
|
|
|
925
512
|
case 9:
|
|
926
|
-
locales =
|
|
513
|
+
locales = _context.sent;
|
|
927
514
|
localeIds = locales.map(function (l) {
|
|
928
515
|
return l.localeId;
|
|
929
516
|
});
|
|
@@ -933,9 +520,170 @@ var getTranslationTask = /*#__PURE__*/function () {
|
|
|
933
520
|
});
|
|
934
521
|
});
|
|
935
522
|
task.locales = validLocales;
|
|
936
|
-
return
|
|
523
|
+
return _context.abrupt("return", task);
|
|
937
524
|
|
|
938
525
|
case 14:
|
|
526
|
+
case "end":
|
|
527
|
+
return _context.stop();
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}, _callee);
|
|
531
|
+
}));
|
|
532
|
+
return _getTranslationTask.apply(this, arguments);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function getTranslation(_x, _x2, _x3) {
|
|
536
|
+
return _getTranslation.apply(this, arguments);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function _getTranslation() {
|
|
540
|
+
_getTranslation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(taskId, localeId, secrets) {
|
|
541
|
+
var resourceDownloadBody, resourceDownloadUrl, translationDownloadId, headers, location;
|
|
542
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
543
|
+
while (1) {
|
|
544
|
+
switch (_context3.prev = _context3.next) {
|
|
545
|
+
case 0:
|
|
546
|
+
resourceDownloadBody = {
|
|
547
|
+
data: {
|
|
548
|
+
attributes: {
|
|
549
|
+
content_encoding: 'text'
|
|
550
|
+
},
|
|
551
|
+
relationships: {
|
|
552
|
+
language: {
|
|
553
|
+
data: {
|
|
554
|
+
id: "l:" + localeId,
|
|
555
|
+
type: 'languages'
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
resource: {
|
|
559
|
+
data: {
|
|
560
|
+
id: taskId,
|
|
561
|
+
type: 'resources'
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
type: 'resource_translations_async_downloads'
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
resourceDownloadUrl = baseTransifexUrl + "/resource_translations_async_downloads";
|
|
569
|
+
_context3.next = 4;
|
|
570
|
+
return fetch(resourceDownloadUrl, {
|
|
571
|
+
headers: getHeaders(secrets),
|
|
572
|
+
method: 'POST',
|
|
573
|
+
body: JSON.stringify(resourceDownloadBody)
|
|
574
|
+
}).then(function (res) {
|
|
575
|
+
return res.json();
|
|
576
|
+
}).then(function (res) {
|
|
577
|
+
return res.data.id;
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
case 4:
|
|
581
|
+
translationDownloadId = _context3.sent;
|
|
582
|
+
headers = getHeaders(secrets);
|
|
583
|
+
_context3.next = 8;
|
|
584
|
+
return pollForFileDownloadLocation(resourceDownloadUrl, translationDownloadId, headers);
|
|
585
|
+
|
|
586
|
+
case 8:
|
|
587
|
+
location = _context3.sent;
|
|
588
|
+
return _context3.abrupt("return", handleFileDownload(location));
|
|
589
|
+
|
|
590
|
+
case 10:
|
|
591
|
+
case "end":
|
|
592
|
+
return _context3.stop();
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}, _callee3);
|
|
596
|
+
}));
|
|
597
|
+
return _getTranslation.apply(this, arguments);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
var pollForFileDownloadLocation = /*#__PURE__*/function () {
|
|
601
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resourceDownloadUrl, translationDownloadId, headers) {
|
|
602
|
+
var response;
|
|
603
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
604
|
+
while (1) {
|
|
605
|
+
switch (_context.prev = _context.next) {
|
|
606
|
+
case 0:
|
|
607
|
+
_context.next = 2;
|
|
608
|
+
return fetch(resourceDownloadUrl + "/" + translationDownloadId, {
|
|
609
|
+
headers: headers
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
case 2:
|
|
613
|
+
response = _context.sent;
|
|
614
|
+
|
|
615
|
+
if (!(response.status === 500)) {
|
|
616
|
+
_context.next = 10;
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
console.info("Transifex plugin message: Received 500 for translation download ID " + translationDownloadId + ". Trying to reconnect...");
|
|
621
|
+
_context.next = 7;
|
|
622
|
+
return new Promise(function (resolve) {
|
|
623
|
+
return setTimeout(resolve, 3000);
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
case 7:
|
|
627
|
+
return _context.abrupt("return", pollForFileDownloadLocation(resourceDownloadUrl, translationDownloadId, headers));
|
|
628
|
+
|
|
629
|
+
case 10:
|
|
630
|
+
if (!response.redirected) {
|
|
631
|
+
_context.next = 15;
|
|
632
|
+
break;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
console.info("Transifex plugin message: Received redirect for translation download ID " + translationDownloadId + ". Following redirect now for file download.");
|
|
636
|
+
return _context.abrupt("return", response.url);
|
|
637
|
+
|
|
638
|
+
case 15:
|
|
639
|
+
if (!(response.status === 200)) {
|
|
640
|
+
_context.next = 22;
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
console.info("Transifex plugin message: Requested download location for translation download ID " + translationDownloadId + ". Location is still pending, trying again.");
|
|
645
|
+
_context.next = 19;
|
|
646
|
+
return new Promise(function (resolve) {
|
|
647
|
+
return setTimeout(resolve, 3000);
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
case 19:
|
|
651
|
+
return _context.abrupt("return", pollForFileDownloadLocation(resourceDownloadUrl, translationDownloadId, headers));
|
|
652
|
+
|
|
653
|
+
case 22:
|
|
654
|
+
console.info("Transifex plugin message: Requested download location for translation download ID " + translationDownloadId + " but received error code " + response.status + ". Waiting and trying again.");
|
|
655
|
+
_context.next = 25;
|
|
656
|
+
return new Promise(function (resolve) {
|
|
657
|
+
return setTimeout(resolve, 3000);
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
case 25:
|
|
661
|
+
return _context.abrupt("return", pollForFileDownloadLocation(resourceDownloadUrl, translationDownloadId, headers));
|
|
662
|
+
|
|
663
|
+
case 26:
|
|
664
|
+
case "end":
|
|
665
|
+
return _context.stop();
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}, _callee);
|
|
669
|
+
}));
|
|
670
|
+
|
|
671
|
+
return function pollForFileDownloadLocation(_x4, _x5, _x6) {
|
|
672
|
+
return _ref.apply(this, arguments);
|
|
673
|
+
};
|
|
674
|
+
}();
|
|
675
|
+
|
|
676
|
+
var handleFileDownload = /*#__PURE__*/function () {
|
|
677
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(url) {
|
|
678
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
679
|
+
while (1) {
|
|
680
|
+
switch (_context2.prev = _context2.next) {
|
|
681
|
+
case 0:
|
|
682
|
+
return _context2.abrupt("return", fetch(url).then(function (res) {
|
|
683
|
+
return res.text();
|
|
684
|
+
}));
|
|
685
|
+
|
|
686
|
+
case 1:
|
|
939
687
|
case "end":
|
|
940
688
|
return _context2.stop();
|
|
941
689
|
}
|
|
@@ -943,17 +691,17 @@ var getTranslationTask = /*#__PURE__*/function () {
|
|
|
943
691
|
}, _callee2);
|
|
944
692
|
}));
|
|
945
693
|
|
|
946
|
-
return function
|
|
694
|
+
return function handleFileDownload(_x7) {
|
|
947
695
|
return _ref2.apply(this, arguments);
|
|
948
696
|
};
|
|
949
697
|
}();
|
|
950
698
|
|
|
951
699
|
var createResource = /*#__PURE__*/function () {
|
|
952
|
-
var
|
|
700
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(doc, documentId, secrets) {
|
|
953
701
|
var resourceCreateBody;
|
|
954
|
-
return
|
|
702
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
955
703
|
while (1) {
|
|
956
|
-
switch (
|
|
704
|
+
switch (_context.prev = _context.next) {
|
|
957
705
|
case 0:
|
|
958
706
|
resourceCreateBody = {
|
|
959
707
|
data: {
|
|
@@ -979,7 +727,7 @@ var createResource = /*#__PURE__*/function () {
|
|
|
979
727
|
type: 'resources'
|
|
980
728
|
}
|
|
981
729
|
};
|
|
982
|
-
return
|
|
730
|
+
return _context.abrupt("return", fetch(baseTransifexUrl + "/resources", {
|
|
983
731
|
headers: getHeaders(secrets),
|
|
984
732
|
method: 'POST',
|
|
985
733
|
body: JSON.stringify(resourceCreateBody)
|
|
@@ -991,27 +739,31 @@ var createResource = /*#__PURE__*/function () {
|
|
|
991
739
|
|
|
992
740
|
case 2:
|
|
993
741
|
case "end":
|
|
994
|
-
return
|
|
742
|
+
return _context.stop();
|
|
995
743
|
}
|
|
996
744
|
}
|
|
997
|
-
},
|
|
745
|
+
}, _callee);
|
|
998
746
|
}));
|
|
999
747
|
|
|
1000
|
-
return function createResource(
|
|
1001
|
-
return
|
|
748
|
+
return function createResource(_x, _x2, _x3) {
|
|
749
|
+
return _ref.apply(this, arguments);
|
|
1002
750
|
};
|
|
1003
751
|
}();
|
|
1004
752
|
|
|
1005
|
-
|
|
1006
|
-
|
|
753
|
+
function createTask(_x4, _x5, _x6, _x7) {
|
|
754
|
+
return _createTask.apply(this, arguments);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
function _createTask() {
|
|
758
|
+
_createTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(documentId, document, //unfortunately Transifex doesn't let you specify locales on creating a task
|
|
1007
759
|
//@ts-ignore
|
|
1008
760
|
localeIds, secrets) {
|
|
1009
761
|
var resourceId, resourceUploadUrl, resourceUploadBody;
|
|
1010
|
-
return
|
|
762
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1011
763
|
while (1) {
|
|
1012
|
-
switch (
|
|
764
|
+
switch (_context2.prev = _context2.next) {
|
|
1013
765
|
case 0:
|
|
1014
|
-
|
|
766
|
+
_context2.next = 2;
|
|
1015
767
|
return fetch(baseTransifexUrl + "/resources/" + projOrgSlug(secrets) + ":r:" + documentId, {
|
|
1016
768
|
headers: getHeaders(secrets)
|
|
1017
769
|
}).then(function (res) {
|
|
@@ -1021,18 +773,18 @@ var createTask = /*#__PURE__*/function () {
|
|
|
1021
773
|
});
|
|
1022
774
|
|
|
1023
775
|
case 2:
|
|
1024
|
-
resourceId =
|
|
776
|
+
resourceId = _context2.sent;
|
|
1025
777
|
|
|
1026
778
|
if (resourceId) {
|
|
1027
|
-
|
|
779
|
+
_context2.next = 7;
|
|
1028
780
|
break;
|
|
1029
781
|
}
|
|
1030
782
|
|
|
1031
|
-
|
|
783
|
+
_context2.next = 6;
|
|
1032
784
|
return createResource(document, documentId, secrets);
|
|
1033
785
|
|
|
1034
786
|
case 6:
|
|
1035
|
-
resourceId =
|
|
787
|
+
resourceId = _context2.sent;
|
|
1036
788
|
|
|
1037
789
|
case 7:
|
|
1038
790
|
resourceUploadUrl = baseTransifexUrl + "/resource_strings_async_uploads";
|
|
@@ -1053,7 +805,7 @@ var createTask = /*#__PURE__*/function () {
|
|
|
1053
805
|
type: 'resource_strings_async_uploads'
|
|
1054
806
|
}
|
|
1055
807
|
};
|
|
1056
|
-
return
|
|
808
|
+
return _context2.abrupt("return", fetch(resourceUploadUrl, {
|
|
1057
809
|
method: 'POST',
|
|
1058
810
|
body: JSON.stringify(resourceUploadBody),
|
|
1059
811
|
headers: getHeaders(secrets)
|
|
@@ -1063,110 +815,13 @@ var createTask = /*#__PURE__*/function () {
|
|
|
1063
815
|
|
|
1064
816
|
case 10:
|
|
1065
817
|
case "end":
|
|
1066
|
-
return
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
}, _callee4);
|
|
1070
|
-
}));
|
|
1071
|
-
|
|
1072
|
-
return function createTask(_x7, _x8, _x9, _x10) {
|
|
1073
|
-
return _ref4.apply(this, arguments);
|
|
1074
|
-
};
|
|
1075
|
-
}();
|
|
1076
|
-
|
|
1077
|
-
var getTranslation = /*#__PURE__*/function () {
|
|
1078
|
-
var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(taskId, localeId, secrets) {
|
|
1079
|
-
var resourceDownloadBody, resourceDownloadUrl, translationDownloadId;
|
|
1080
|
-
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1081
|
-
while (1) {
|
|
1082
|
-
switch (_context5.prev = _context5.next) {
|
|
1083
|
-
case 0:
|
|
1084
|
-
resourceDownloadBody = {
|
|
1085
|
-
data: {
|
|
1086
|
-
attributes: {
|
|
1087
|
-
content_encoding: 'text'
|
|
1088
|
-
},
|
|
1089
|
-
relationships: {
|
|
1090
|
-
language: {
|
|
1091
|
-
data: {
|
|
1092
|
-
id: "l:" + localeId,
|
|
1093
|
-
type: 'languages'
|
|
1094
|
-
}
|
|
1095
|
-
},
|
|
1096
|
-
resource: {
|
|
1097
|
-
data: {
|
|
1098
|
-
id: taskId,
|
|
1099
|
-
type: 'resources'
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
},
|
|
1103
|
-
type: 'resource_translations_async_downloads'
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
resourceDownloadUrl = baseTransifexUrl + "/resource_translations_async_downloads";
|
|
1107
|
-
_context5.next = 4;
|
|
1108
|
-
return fetch(resourceDownloadUrl, {
|
|
1109
|
-
headers: getHeaders(secrets),
|
|
1110
|
-
method: 'POST',
|
|
1111
|
-
body: JSON.stringify(resourceDownloadBody)
|
|
1112
|
-
}).then(function (res) {
|
|
1113
|
-
return res.json();
|
|
1114
|
-
}).then(function (res) {
|
|
1115
|
-
return res.data.id;
|
|
1116
|
-
});
|
|
1117
|
-
|
|
1118
|
-
case 4:
|
|
1119
|
-
translationDownloadId = _context5.sent;
|
|
1120
|
-
return _context5.abrupt("return", new Promise(function (resolve) {
|
|
1121
|
-
setTimeout(function () {
|
|
1122
|
-
fetch(resourceDownloadUrl + "/" + translationDownloadId, {
|
|
1123
|
-
headers: getHeaders(secrets)
|
|
1124
|
-
}).then(function (res) {
|
|
1125
|
-
if (res.redirected) {
|
|
1126
|
-
return resolve(handleFileDownload(res.url));
|
|
1127
|
-
} else {
|
|
1128
|
-
console.log('no redirected, try again');
|
|
1129
|
-
return res.json();
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
|
-
}, 3000);
|
|
1133
|
-
}));
|
|
1134
|
-
|
|
1135
|
-
case 6:
|
|
1136
|
-
case "end":
|
|
1137
|
-
return _context5.stop();
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
}, _callee5);
|
|
1141
|
-
}));
|
|
1142
|
-
|
|
1143
|
-
return function getTranslation(_x11, _x12, _x13) {
|
|
1144
|
-
return _ref5.apply(this, arguments);
|
|
1145
|
-
};
|
|
1146
|
-
}();
|
|
1147
|
-
|
|
1148
|
-
var handleFileDownload = /*#__PURE__*/function () {
|
|
1149
|
-
var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(url) {
|
|
1150
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1151
|
-
while (1) {
|
|
1152
|
-
switch (_context6.prev = _context6.next) {
|
|
1153
|
-
case 0:
|
|
1154
|
-
return _context6.abrupt("return", fetch(url).then(function (res) {
|
|
1155
|
-
return res.text();
|
|
1156
|
-
}));
|
|
1157
|
-
|
|
1158
|
-
case 1:
|
|
1159
|
-
case "end":
|
|
1160
|
-
return _context6.stop();
|
|
818
|
+
return _context2.stop();
|
|
1161
819
|
}
|
|
1162
820
|
}
|
|
1163
|
-
},
|
|
821
|
+
}, _callee2);
|
|
1164
822
|
}));
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
return _ref6.apply(this, arguments);
|
|
1168
|
-
};
|
|
1169
|
-
}();
|
|
823
|
+
return _createTask.apply(this, arguments);
|
|
824
|
+
}
|
|
1170
825
|
|
|
1171
826
|
var TransifexAdapter = {
|
|
1172
827
|
getLocales: getLocales,
|