sanity-plugin-transifex 1.1.2 → 2.0.2
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 +10 -15
- package/dist/sanity-plugin-transifex.cjs.development.js +492 -1063
- 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 +466 -1053
- 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 -2
- package/src/index.ts +25 -30
- 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/dist/helpers.d.ts +0 -5
- package/src/helpers.ts +0 -114
- package/src/transifexAdapter.ts +0 -230
|
@@ -2,818 +2,424 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
5
|
var sanityTranslationsTab = require('sanity-translations-tab');
|
|
8
|
-
var sanityNaiveHtmlSerializer = require('sanity-naive-html-serializer');
|
|
9
|
-
var sanityClient = _interopDefault(require('part:@sanity/base/client'));
|
|
10
|
-
|
|
11
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
12
|
-
try {
|
|
13
|
-
var info = gen[key](arg);
|
|
14
|
-
var value = info.value;
|
|
15
|
-
} catch (error) {
|
|
16
|
-
reject(error);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (info.done) {
|
|
21
|
-
resolve(value);
|
|
22
|
-
} else {
|
|
23
|
-
Promise.resolve(value).then(_next, _throw);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function _asyncToGenerator(fn) {
|
|
28
|
-
return function () {
|
|
29
|
-
var self = this,
|
|
30
|
-
args = arguments;
|
|
31
|
-
return new Promise(function (resolve, reject) {
|
|
32
|
-
var gen = fn.apply(self, args);
|
|
33
6
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function _throw(err) {
|
|
39
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
|
-
}
|
|
7
|
+
function _regeneratorRuntime() {
|
|
8
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
41
9
|
|
|
42
|
-
|
|
43
|
-
|
|
10
|
+
_regeneratorRuntime = function () {
|
|
11
|
+
return exports;
|
|
44
12
|
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function createCommonjsModule(fn, module) {
|
|
48
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
49
|
-
}
|
|
50
13
|
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var runtime = (function (exports) {
|
|
60
|
-
|
|
61
|
-
var Op = Object.prototype;
|
|
62
|
-
var hasOwn = Op.hasOwnProperty;
|
|
63
|
-
var undefined$1; // More compressible than void 0.
|
|
64
|
-
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
65
|
-
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
66
|
-
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
67
|
-
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
14
|
+
var exports = {},
|
|
15
|
+
Op = Object.prototype,
|
|
16
|
+
hasOwn = Op.hasOwnProperty,
|
|
17
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
18
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
19
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
20
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
68
21
|
|
|
69
22
|
function define(obj, key, value) {
|
|
70
|
-
Object.defineProperty(obj, key, {
|
|
23
|
+
return Object.defineProperty(obj, key, {
|
|
71
24
|
value: value,
|
|
72
|
-
enumerable:
|
|
73
|
-
configurable:
|
|
74
|
-
writable:
|
|
75
|
-
});
|
|
76
|
-
return obj[key];
|
|
25
|
+
enumerable: !0,
|
|
26
|
+
configurable: !0,
|
|
27
|
+
writable: !0
|
|
28
|
+
}), obj[key];
|
|
77
29
|
}
|
|
30
|
+
|
|
78
31
|
try {
|
|
79
|
-
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
80
32
|
define({}, "");
|
|
81
33
|
} catch (err) {
|
|
82
|
-
define = function(obj, key, value) {
|
|
34
|
+
define = function (obj, key, value) {
|
|
83
35
|
return obj[key] = value;
|
|
84
36
|
};
|
|
85
37
|
}
|
|
86
38
|
|
|
87
39
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
40
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
41
|
+
generator = Object.create(protoGenerator.prototype),
|
|
42
|
+
context = new Context(tryLocsList || []);
|
|
43
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
44
|
+
var state = "suspendedStart";
|
|
45
|
+
return function (method, arg) {
|
|
46
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
47
|
+
|
|
48
|
+
if ("completed" === state) {
|
|
49
|
+
if ("throw" === method) throw arg;
|
|
50
|
+
return doneResult();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
for (context.method = method, context.arg = arg;;) {
|
|
54
|
+
var delegate = context.delegate;
|
|
55
|
+
|
|
56
|
+
if (delegate) {
|
|
57
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
58
|
+
|
|
59
|
+
if (delegateResult) {
|
|
60
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
61
|
+
return delegateResult;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
92
64
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
65
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
66
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
67
|
+
context.dispatchException(context.arg);
|
|
68
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
69
|
+
state = "executing";
|
|
70
|
+
var record = tryCatch(innerFn, self, context);
|
|
71
|
+
|
|
72
|
+
if ("normal" === record.type) {
|
|
73
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
74
|
+
return {
|
|
75
|
+
value: record.arg,
|
|
76
|
+
done: context.done
|
|
77
|
+
};
|
|
78
|
+
}
|
|
96
79
|
|
|
97
|
-
|
|
80
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}(innerFn, self, context), generator;
|
|
98
84
|
}
|
|
99
|
-
exports.wrap = wrap;
|
|
100
85
|
|
|
101
|
-
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
102
|
-
// record like context.tryEntries[i].completion. This interface could
|
|
103
|
-
// have been (and was previously) designed to take a closure to be
|
|
104
|
-
// invoked without arguments, but in all the cases we care about we
|
|
105
|
-
// already have an existing method we want to call, so there's no need
|
|
106
|
-
// to create a new function object. We can even get away with assuming
|
|
107
|
-
// the method takes exactly one argument, since that happens to be true
|
|
108
|
-
// in every case, so we don't have to touch the arguments object. The
|
|
109
|
-
// only additional allocation required is the completion record, which
|
|
110
|
-
// has a stable shape and so hopefully should be cheap to allocate.
|
|
111
86
|
function tryCatch(fn, obj, arg) {
|
|
112
87
|
try {
|
|
113
|
-
return {
|
|
88
|
+
return {
|
|
89
|
+
type: "normal",
|
|
90
|
+
arg: fn.call(obj, arg)
|
|
91
|
+
};
|
|
114
92
|
} catch (err) {
|
|
115
|
-
return {
|
|
93
|
+
return {
|
|
94
|
+
type: "throw",
|
|
95
|
+
arg: err
|
|
96
|
+
};
|
|
116
97
|
}
|
|
117
98
|
}
|
|
118
99
|
|
|
119
|
-
|
|
120
|
-
var GenStateSuspendedYield = "suspendedYield";
|
|
121
|
-
var GenStateExecuting = "executing";
|
|
122
|
-
var GenStateCompleted = "completed";
|
|
123
|
-
|
|
124
|
-
// Returning this object from the innerFn has the same effect as
|
|
125
|
-
// breaking out of the dispatch switch statement.
|
|
100
|
+
exports.wrap = wrap;
|
|
126
101
|
var ContinueSentinel = {};
|
|
127
102
|
|
|
128
|
-
// Dummy constructor functions that we use as the .constructor and
|
|
129
|
-
// .constructor.prototype properties for functions that return Generator
|
|
130
|
-
// objects. For full spec compliance, you may wish to configure your
|
|
131
|
-
// minifier not to mangle the names of these two functions.
|
|
132
103
|
function Generator() {}
|
|
104
|
+
|
|
133
105
|
function GeneratorFunction() {}
|
|
106
|
+
|
|
134
107
|
function GeneratorFunctionPrototype() {}
|
|
135
108
|
|
|
136
|
-
// This is a polyfill for %IteratorPrototype% for environments that
|
|
137
|
-
// don't natively support it.
|
|
138
109
|
var IteratorPrototype = {};
|
|
139
|
-
IteratorPrototype
|
|
110
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
140
111
|
return this;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
NativeIteratorPrototype !== Op &&
|
|
147
|
-
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
148
|
-
// This environment has a native %IteratorPrototype%; use it instead
|
|
149
|
-
// of the polyfill.
|
|
150
|
-
IteratorPrototype = NativeIteratorPrototype;
|
|
151
|
-
}
|
|
112
|
+
});
|
|
113
|
+
var getProto = Object.getPrototypeOf,
|
|
114
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
115
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
116
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
152
117
|
|
|
153
|
-
var Gp = GeneratorFunctionPrototype.prototype =
|
|
154
|
-
Generator.prototype = Object.create(IteratorPrototype);
|
|
155
|
-
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
156
|
-
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
157
|
-
GeneratorFunction.displayName = define(
|
|
158
|
-
GeneratorFunctionPrototype,
|
|
159
|
-
toStringTagSymbol,
|
|
160
|
-
"GeneratorFunction"
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
// Helper for defining the .next, .throw, and .return methods of the
|
|
164
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
165
118
|
function defineIteratorMethods(prototype) {
|
|
166
|
-
["next", "throw", "return"].forEach(function(method) {
|
|
167
|
-
define(prototype, method, function(arg) {
|
|
119
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
120
|
+
define(prototype, method, function (arg) {
|
|
168
121
|
return this._invoke(method, arg);
|
|
169
122
|
});
|
|
170
123
|
});
|
|
171
124
|
}
|
|
172
125
|
|
|
173
|
-
exports.isGeneratorFunction = function(genFun) {
|
|
174
|
-
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
175
|
-
return ctor
|
|
176
|
-
? ctor === GeneratorFunction ||
|
|
177
|
-
// For the native GeneratorFunction constructor, the best we can
|
|
178
|
-
// do is to check its .name property.
|
|
179
|
-
(ctor.displayName || ctor.name) === "GeneratorFunction"
|
|
180
|
-
: false;
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
exports.mark = function(genFun) {
|
|
184
|
-
if (Object.setPrototypeOf) {
|
|
185
|
-
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
186
|
-
} else {
|
|
187
|
-
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
188
|
-
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
189
|
-
}
|
|
190
|
-
genFun.prototype = Object.create(Gp);
|
|
191
|
-
return genFun;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
// Within the body of any async function, `await x` is transformed to
|
|
195
|
-
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
196
|
-
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
197
|
-
// meant to be awaited.
|
|
198
|
-
exports.awrap = function(arg) {
|
|
199
|
-
return { __await: arg };
|
|
200
|
-
};
|
|
201
|
-
|
|
202
126
|
function AsyncIterator(generator, PromiseImpl) {
|
|
203
127
|
function invoke(method, arg, resolve, reject) {
|
|
204
128
|
var record = tryCatch(generator[method], generator, arg);
|
|
205
|
-
if (record.type === "throw") {
|
|
206
|
-
reject(record.arg);
|
|
207
|
-
} else {
|
|
208
|
-
var result = record.arg;
|
|
209
|
-
var value = result.value;
|
|
210
|
-
if (value &&
|
|
211
|
-
typeof value === "object" &&
|
|
212
|
-
hasOwn.call(value, "__await")) {
|
|
213
|
-
return PromiseImpl.resolve(value.__await).then(function(value) {
|
|
214
|
-
invoke("next", value, resolve, reject);
|
|
215
|
-
}, function(err) {
|
|
216
|
-
invoke("throw", err, resolve, reject);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
129
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
130
|
+
if ("throw" !== record.type) {
|
|
131
|
+
var result = record.arg,
|
|
132
|
+
value = result.value;
|
|
133
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
134
|
+
invoke("next", value, resolve, reject);
|
|
135
|
+
}, function (err) {
|
|
136
|
+
invoke("throw", err, resolve, reject);
|
|
137
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
138
|
+
result.value = unwrapped, resolve(result);
|
|
139
|
+
}, function (error) {
|
|
229
140
|
return invoke("throw", error, resolve, reject);
|
|
230
141
|
});
|
|
231
142
|
}
|
|
143
|
+
|
|
144
|
+
reject(record.arg);
|
|
232
145
|
}
|
|
233
146
|
|
|
234
147
|
var previousPromise;
|
|
235
148
|
|
|
236
|
-
function
|
|
149
|
+
this._invoke = function (method, arg) {
|
|
237
150
|
function callInvokeWithMethodAndArg() {
|
|
238
|
-
return new PromiseImpl(function(resolve, reject) {
|
|
151
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
239
152
|
invoke(method, arg, resolve, reject);
|
|
240
153
|
});
|
|
241
154
|
}
|
|
242
155
|
|
|
243
|
-
return previousPromise =
|
|
244
|
-
// If enqueue has been called before, then we want to wait until
|
|
245
|
-
// all previous Promises have been resolved before calling invoke,
|
|
246
|
-
// so that results are always delivered in the correct order. If
|
|
247
|
-
// enqueue has not been called before, then it is important to
|
|
248
|
-
// call invoke immediately, without waiting on a callback to fire,
|
|
249
|
-
// so that the async generator function has the opportunity to do
|
|
250
|
-
// any necessary setup in a predictable way. This predictability
|
|
251
|
-
// is why the Promise constructor synchronously invokes its
|
|
252
|
-
// executor callback, and why async functions synchronously
|
|
253
|
-
// execute code before the first await. Since we implement simple
|
|
254
|
-
// async functions in terms of async generators, it is especially
|
|
255
|
-
// important to get this right, even though it requires care.
|
|
256
|
-
previousPromise ? previousPromise.then(
|
|
257
|
-
callInvokeWithMethodAndArg,
|
|
258
|
-
// Avoid propagating failures to Promises returned by later
|
|
259
|
-
// invocations of the iterator.
|
|
260
|
-
callInvokeWithMethodAndArg
|
|
261
|
-
) : callInvokeWithMethodAndArg();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Define the unified helper method that is used to implement .next,
|
|
265
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
266
|
-
this._invoke = enqueue;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
defineIteratorMethods(AsyncIterator.prototype);
|
|
270
|
-
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
271
|
-
return this;
|
|
272
|
-
};
|
|
273
|
-
exports.AsyncIterator = AsyncIterator;
|
|
274
|
-
|
|
275
|
-
// Note that simple async functions are implemented on top of
|
|
276
|
-
// AsyncIterator objects; they just return a Promise for the value of
|
|
277
|
-
// the final result produced by the iterator.
|
|
278
|
-
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
279
|
-
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
280
|
-
|
|
281
|
-
var iter = new AsyncIterator(
|
|
282
|
-
wrap(innerFn, outerFn, self, tryLocsList),
|
|
283
|
-
PromiseImpl
|
|
284
|
-
);
|
|
285
|
-
|
|
286
|
-
return exports.isGeneratorFunction(outerFn)
|
|
287
|
-
? iter // If outerFn is a generator, return the full iterator.
|
|
288
|
-
: iter.next().then(function(result) {
|
|
289
|
-
return result.done ? result.value : iter.next();
|
|
290
|
-
});
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
294
|
-
var state = GenStateSuspendedStart;
|
|
295
|
-
|
|
296
|
-
return function invoke(method, arg) {
|
|
297
|
-
if (state === GenStateExecuting) {
|
|
298
|
-
throw new Error("Generator is already running");
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (state === GenStateCompleted) {
|
|
302
|
-
if (method === "throw") {
|
|
303
|
-
throw arg;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
307
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
308
|
-
return doneResult();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
context.method = method;
|
|
312
|
-
context.arg = arg;
|
|
313
|
-
|
|
314
|
-
while (true) {
|
|
315
|
-
var delegate = context.delegate;
|
|
316
|
-
if (delegate) {
|
|
317
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
318
|
-
if (delegateResult) {
|
|
319
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
320
|
-
return delegateResult;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (context.method === "next") {
|
|
325
|
-
// Setting context._sent for legacy support of Babel's
|
|
326
|
-
// function.sent implementation.
|
|
327
|
-
context.sent = context._sent = context.arg;
|
|
328
|
-
|
|
329
|
-
} else if (context.method === "throw") {
|
|
330
|
-
if (state === GenStateSuspendedStart) {
|
|
331
|
-
state = GenStateCompleted;
|
|
332
|
-
throw context.arg;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
context.dispatchException(context.arg);
|
|
336
|
-
|
|
337
|
-
} else if (context.method === "return") {
|
|
338
|
-
context.abrupt("return", context.arg);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
state = GenStateExecuting;
|
|
342
|
-
|
|
343
|
-
var record = tryCatch(innerFn, self, context);
|
|
344
|
-
if (record.type === "normal") {
|
|
345
|
-
// If an exception is thrown from innerFn, we leave state ===
|
|
346
|
-
// GenStateExecuting and loop back for another invocation.
|
|
347
|
-
state = context.done
|
|
348
|
-
? GenStateCompleted
|
|
349
|
-
: GenStateSuspendedYield;
|
|
350
|
-
|
|
351
|
-
if (record.arg === ContinueSentinel) {
|
|
352
|
-
continue;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return {
|
|
356
|
-
value: record.arg,
|
|
357
|
-
done: context.done
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
} else if (record.type === "throw") {
|
|
361
|
-
state = GenStateCompleted;
|
|
362
|
-
// Dispatch the exception by looping back around to the
|
|
363
|
-
// context.dispatchException(context.arg) call above.
|
|
364
|
-
context.method = "throw";
|
|
365
|
-
context.arg = record.arg;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
156
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
368
157
|
};
|
|
369
158
|
}
|
|
370
159
|
|
|
371
|
-
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
372
|
-
// result, either by returning a { value, done } result from the
|
|
373
|
-
// delegate iterator, or by modifying context.method and context.arg,
|
|
374
|
-
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
375
160
|
function maybeInvokeDelegate(delegate, context) {
|
|
376
161
|
var method = delegate.iterator[context.method];
|
|
377
|
-
if (method === undefined$1) {
|
|
378
|
-
// A .throw or .return when the delegate iterator has no .throw
|
|
379
|
-
// method always terminates the yield* loop.
|
|
380
|
-
context.delegate = null;
|
|
381
|
-
|
|
382
|
-
if (context.method === "throw") {
|
|
383
|
-
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
384
|
-
if (delegate.iterator["return"]) {
|
|
385
|
-
// If the delegate iterator has a return method, give it a
|
|
386
|
-
// chance to clean up.
|
|
387
|
-
context.method = "return";
|
|
388
|
-
context.arg = undefined$1;
|
|
389
|
-
maybeInvokeDelegate(delegate, context);
|
|
390
|
-
|
|
391
|
-
if (context.method === "throw") {
|
|
392
|
-
// If maybeInvokeDelegate(context) changed context.method from
|
|
393
|
-
// "return" to "throw", let that override the TypeError below.
|
|
394
|
-
return ContinueSentinel;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
162
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
163
|
+
if (undefined === method) {
|
|
164
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
165
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
166
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
401
167
|
}
|
|
402
168
|
|
|
403
169
|
return ContinueSentinel;
|
|
404
170
|
}
|
|
405
171
|
|
|
406
172
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
407
|
-
|
|
408
|
-
if (record.type === "throw") {
|
|
409
|
-
context.method = "throw";
|
|
410
|
-
context.arg = record.arg;
|
|
411
|
-
context.delegate = null;
|
|
412
|
-
return ContinueSentinel;
|
|
413
|
-
}
|
|
414
|
-
|
|
173
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
415
174
|
var info = record.arg;
|
|
416
|
-
|
|
417
|
-
if (! info) {
|
|
418
|
-
context.method = "throw";
|
|
419
|
-
context.arg = new TypeError("iterator result is not an object");
|
|
420
|
-
context.delegate = null;
|
|
421
|
-
return ContinueSentinel;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
if (info.done) {
|
|
425
|
-
// Assign the result of the finished delegate to the temporary
|
|
426
|
-
// variable specified by delegate.resultName (see delegateYield).
|
|
427
|
-
context[delegate.resultName] = info.value;
|
|
428
|
-
|
|
429
|
-
// Resume execution at the desired location (see delegateYield).
|
|
430
|
-
context.next = delegate.nextLoc;
|
|
431
|
-
|
|
432
|
-
// If context.method was "throw" but the delegate handled the
|
|
433
|
-
// exception, let the outer generator proceed normally. If
|
|
434
|
-
// context.method was "next", forget context.arg since it has been
|
|
435
|
-
// "consumed" by the delegate iterator. If context.method was
|
|
436
|
-
// "return", allow the original .return call to continue in the
|
|
437
|
-
// outer generator.
|
|
438
|
-
if (context.method !== "return") {
|
|
439
|
-
context.method = "next";
|
|
440
|
-
context.arg = undefined$1;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
} else {
|
|
444
|
-
// Re-yield the result returned by the delegate method.
|
|
445
|
-
return info;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
// The delegate iterator is finished, so forget it and continue with
|
|
449
|
-
// the outer generator.
|
|
450
|
-
context.delegate = null;
|
|
451
|
-
return ContinueSentinel;
|
|
175
|
+
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);
|
|
452
176
|
}
|
|
453
177
|
|
|
454
|
-
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
455
|
-
// unified ._invoke helper method.
|
|
456
|
-
defineIteratorMethods(Gp);
|
|
457
|
-
|
|
458
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
459
|
-
|
|
460
|
-
// A Generator should always return itself as the iterator object when the
|
|
461
|
-
// @@iterator function is called on it. Some browsers' implementations of the
|
|
462
|
-
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
463
|
-
// object to not be returned from this call. This ensures that doesn't happen.
|
|
464
|
-
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
465
|
-
Gp[iteratorSymbol] = function() {
|
|
466
|
-
return this;
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
Gp.toString = function() {
|
|
470
|
-
return "[object Generator]";
|
|
471
|
-
};
|
|
472
|
-
|
|
473
178
|
function pushTryEntry(locs) {
|
|
474
|
-
var entry = {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
if (2 in locs) {
|
|
481
|
-
entry.finallyLoc = locs[2];
|
|
482
|
-
entry.afterLoc = locs[3];
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
this.tryEntries.push(entry);
|
|
179
|
+
var entry = {
|
|
180
|
+
tryLoc: locs[0]
|
|
181
|
+
};
|
|
182
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
486
183
|
}
|
|
487
184
|
|
|
488
185
|
function resetTryEntry(entry) {
|
|
489
186
|
var record = entry.completion || {};
|
|
490
|
-
record.type = "normal";
|
|
491
|
-
delete record.arg;
|
|
492
|
-
entry.completion = record;
|
|
187
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
493
188
|
}
|
|
494
189
|
|
|
495
190
|
function Context(tryLocsList) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
this.tryEntries = [{ tryLoc: "root" }];
|
|
500
|
-
tryLocsList.forEach(pushTryEntry, this);
|
|
501
|
-
this.reset(true);
|
|
191
|
+
this.tryEntries = [{
|
|
192
|
+
tryLoc: "root"
|
|
193
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
502
194
|
}
|
|
503
195
|
|
|
504
|
-
exports.keys = function(object) {
|
|
505
|
-
var keys = [];
|
|
506
|
-
for (var key in object) {
|
|
507
|
-
keys.push(key);
|
|
508
|
-
}
|
|
509
|
-
keys.reverse();
|
|
510
|
-
|
|
511
|
-
// Rather than returning an object with a next method, we keep
|
|
512
|
-
// things simple and return the next function itself.
|
|
513
|
-
return function next() {
|
|
514
|
-
while (keys.length) {
|
|
515
|
-
var key = keys.pop();
|
|
516
|
-
if (key in object) {
|
|
517
|
-
next.value = key;
|
|
518
|
-
next.done = false;
|
|
519
|
-
return next;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
// To avoid creating an additional object, we just hang the .value
|
|
524
|
-
// and .done properties off the next function object itself. This
|
|
525
|
-
// also ensures that the minifier will not anonymize the function.
|
|
526
|
-
next.done = true;
|
|
527
|
-
return next;
|
|
528
|
-
};
|
|
529
|
-
};
|
|
530
|
-
|
|
531
196
|
function values(iterable) {
|
|
532
197
|
if (iterable) {
|
|
533
198
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
534
|
-
if (iteratorMethod)
|
|
535
|
-
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
if (typeof iterable.next === "function") {
|
|
539
|
-
return iterable;
|
|
540
|
-
}
|
|
199
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
200
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
541
201
|
|
|
542
202
|
if (!isNaN(iterable.length)) {
|
|
543
|
-
var i = -1,
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
next.value = iterable[i];
|
|
547
|
-
next.done = false;
|
|
548
|
-
return next;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
next.value = undefined$1;
|
|
553
|
-
next.done = true;
|
|
203
|
+
var i = -1,
|
|
204
|
+
next = function next() {
|
|
205
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
554
206
|
|
|
555
|
-
return next;
|
|
207
|
+
return next.value = undefined, next.done = !0, next;
|
|
556
208
|
};
|
|
557
209
|
|
|
558
210
|
return next.next = next;
|
|
559
211
|
}
|
|
560
212
|
}
|
|
561
213
|
|
|
562
|
-
|
|
563
|
-
|
|
214
|
+
return {
|
|
215
|
+
next: doneResult
|
|
216
|
+
};
|
|
564
217
|
}
|
|
565
|
-
exports.values = values;
|
|
566
218
|
|
|
567
219
|
function doneResult() {
|
|
568
|
-
return {
|
|
220
|
+
return {
|
|
221
|
+
value: undefined,
|
|
222
|
+
done: !0
|
|
223
|
+
};
|
|
569
224
|
}
|
|
570
225
|
|
|
571
|
-
|
|
572
|
-
constructor
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
this[name] = undefined$1;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
},
|
|
226
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
227
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
228
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
229
|
+
}, exports.mark = function (genFun) {
|
|
230
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
231
|
+
}, exports.awrap = function (arg) {
|
|
232
|
+
return {
|
|
233
|
+
__await: arg
|
|
234
|
+
};
|
|
235
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
236
|
+
return this;
|
|
237
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
238
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
239
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
240
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
241
|
+
return result.done ? result.value : iter.next();
|
|
242
|
+
});
|
|
243
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
244
|
+
return this;
|
|
245
|
+
}), define(Gp, "toString", function () {
|
|
246
|
+
return "[object Generator]";
|
|
247
|
+
}), exports.keys = function (object) {
|
|
248
|
+
var keys = [];
|
|
599
249
|
|
|
600
|
-
|
|
601
|
-
this.done = true;
|
|
250
|
+
for (var key in object) keys.push(key);
|
|
602
251
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
252
|
+
return keys.reverse(), function next() {
|
|
253
|
+
for (; keys.length;) {
|
|
254
|
+
var key = keys.pop();
|
|
255
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
607
256
|
}
|
|
608
257
|
|
|
258
|
+
return next.done = !0, next;
|
|
259
|
+
};
|
|
260
|
+
}, exports.values = values, Context.prototype = {
|
|
261
|
+
constructor: Context,
|
|
262
|
+
reset: function (skipTempReset) {
|
|
263
|
+
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);
|
|
264
|
+
},
|
|
265
|
+
stop: function () {
|
|
266
|
+
this.done = !0;
|
|
267
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
268
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
609
269
|
return this.rval;
|
|
610
270
|
},
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
if (this.done) {
|
|
614
|
-
throw exception;
|
|
615
|
-
}
|
|
616
|
-
|
|
271
|
+
dispatchException: function (exception) {
|
|
272
|
+
if (this.done) throw exception;
|
|
617
273
|
var context = this;
|
|
618
|
-
function handle(loc, caught) {
|
|
619
|
-
record.type = "throw";
|
|
620
|
-
record.arg = exception;
|
|
621
|
-
context.next = loc;
|
|
622
|
-
|
|
623
|
-
if (caught) {
|
|
624
|
-
// If the dispatched exception was caught by a catch block,
|
|
625
|
-
// then let that catch block handle the exception normally.
|
|
626
|
-
context.method = "next";
|
|
627
|
-
context.arg = undefined$1;
|
|
628
|
-
}
|
|
629
274
|
|
|
630
|
-
|
|
275
|
+
function handle(loc, caught) {
|
|
276
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
631
277
|
}
|
|
632
278
|
|
|
633
279
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
634
|
-
var entry = this.tryEntries[i]
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
if (entry.tryLoc === "root") {
|
|
638
|
-
// Exception thrown outside of any try block that could handle
|
|
639
|
-
// it, so set the completion value of the entire function to
|
|
640
|
-
// throw the exception.
|
|
641
|
-
return handle("end");
|
|
642
|
-
}
|
|
280
|
+
var entry = this.tryEntries[i],
|
|
281
|
+
record = entry.completion;
|
|
282
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
643
283
|
|
|
644
284
|
if (entry.tryLoc <= this.prev) {
|
|
645
|
-
var hasCatch = hasOwn.call(entry, "catchLoc")
|
|
646
|
-
|
|
285
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
286
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
647
287
|
|
|
648
288
|
if (hasCatch && hasFinally) {
|
|
649
|
-
if (this.prev < entry.catchLoc)
|
|
650
|
-
|
|
651
|
-
} else if (this.prev < entry.finallyLoc) {
|
|
652
|
-
return handle(entry.finallyLoc);
|
|
653
|
-
}
|
|
654
|
-
|
|
289
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
290
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
655
291
|
} else if (hasCatch) {
|
|
656
|
-
if (this.prev < entry.catchLoc)
|
|
657
|
-
return handle(entry.catchLoc, true);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
} else if (hasFinally) {
|
|
661
|
-
if (this.prev < entry.finallyLoc) {
|
|
662
|
-
return handle(entry.finallyLoc);
|
|
663
|
-
}
|
|
664
|
-
|
|
292
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
665
293
|
} else {
|
|
666
|
-
throw new Error("try statement without catch or finally");
|
|
294
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
295
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
667
296
|
}
|
|
668
297
|
}
|
|
669
298
|
}
|
|
670
299
|
},
|
|
671
|
-
|
|
672
|
-
abrupt: function(type, arg) {
|
|
300
|
+
abrupt: function (type, arg) {
|
|
673
301
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
674
302
|
var entry = this.tryEntries[i];
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
this.prev < entry.finallyLoc) {
|
|
303
|
+
|
|
304
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
678
305
|
var finallyEntry = entry;
|
|
679
306
|
break;
|
|
680
307
|
}
|
|
681
308
|
}
|
|
682
309
|
|
|
683
|
-
|
|
684
|
-
(type === "break" ||
|
|
685
|
-
type === "continue") &&
|
|
686
|
-
finallyEntry.tryLoc <= arg &&
|
|
687
|
-
arg <= finallyEntry.finallyLoc) {
|
|
688
|
-
// Ignore the finally entry if control is not jumping to a
|
|
689
|
-
// location outside the try/catch block.
|
|
690
|
-
finallyEntry = null;
|
|
691
|
-
}
|
|
692
|
-
|
|
310
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
693
311
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
694
|
-
record.type = type;
|
|
695
|
-
record.arg = arg;
|
|
696
|
-
|
|
697
|
-
if (finallyEntry) {
|
|
698
|
-
this.method = "next";
|
|
699
|
-
this.next = finallyEntry.finallyLoc;
|
|
700
|
-
return ContinueSentinel;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
return this.complete(record);
|
|
312
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
704
313
|
},
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
throw record.arg;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
if (record.type === "break" ||
|
|
712
|
-
record.type === "continue") {
|
|
713
|
-
this.next = record.arg;
|
|
714
|
-
} else if (record.type === "return") {
|
|
715
|
-
this.rval = this.arg = record.arg;
|
|
716
|
-
this.method = "return";
|
|
717
|
-
this.next = "end";
|
|
718
|
-
} else if (record.type === "normal" && afterLoc) {
|
|
719
|
-
this.next = afterLoc;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
return ContinueSentinel;
|
|
314
|
+
complete: function (record, afterLoc) {
|
|
315
|
+
if ("throw" === record.type) throw record.arg;
|
|
316
|
+
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;
|
|
723
317
|
},
|
|
724
|
-
|
|
725
|
-
finish: function(finallyLoc) {
|
|
318
|
+
finish: function (finallyLoc) {
|
|
726
319
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
727
320
|
var entry = this.tryEntries[i];
|
|
728
|
-
if (entry.finallyLoc === finallyLoc)
|
|
729
|
-
this.complete(entry.completion, entry.afterLoc);
|
|
730
|
-
resetTryEntry(entry);
|
|
731
|
-
return ContinueSentinel;
|
|
732
|
-
}
|
|
321
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
733
322
|
}
|
|
734
323
|
},
|
|
735
|
-
|
|
736
|
-
"catch": function(tryLoc) {
|
|
324
|
+
catch: function (tryLoc) {
|
|
737
325
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
738
326
|
var entry = this.tryEntries[i];
|
|
327
|
+
|
|
739
328
|
if (entry.tryLoc === tryLoc) {
|
|
740
329
|
var record = entry.completion;
|
|
741
|
-
|
|
330
|
+
|
|
331
|
+
if ("throw" === record.type) {
|
|
742
332
|
var thrown = record.arg;
|
|
743
333
|
resetTryEntry(entry);
|
|
744
334
|
}
|
|
335
|
+
|
|
745
336
|
return thrown;
|
|
746
337
|
}
|
|
747
338
|
}
|
|
748
339
|
|
|
749
|
-
// The context.catch method must only be called with a location
|
|
750
|
-
// argument that corresponds to a known catch block.
|
|
751
340
|
throw new Error("illegal catch attempt");
|
|
752
341
|
},
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
this.delegate = {
|
|
342
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
|
343
|
+
return this.delegate = {
|
|
756
344
|
iterator: values(iterable),
|
|
757
345
|
resultName: resultName,
|
|
758
346
|
nextLoc: nextLoc
|
|
759
|
-
};
|
|
347
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
348
|
+
}
|
|
349
|
+
}, exports;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
353
|
+
try {
|
|
354
|
+
var info = gen[key](arg);
|
|
355
|
+
var value = info.value;
|
|
356
|
+
} catch (error) {
|
|
357
|
+
reject(error);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (info.done) {
|
|
362
|
+
resolve(value);
|
|
363
|
+
} else {
|
|
364
|
+
Promise.resolve(value).then(_next, _throw);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function _asyncToGenerator(fn) {
|
|
369
|
+
return function () {
|
|
370
|
+
var self = this,
|
|
371
|
+
args = arguments;
|
|
372
|
+
return new Promise(function (resolve, reject) {
|
|
373
|
+
var gen = fn.apply(self, args);
|
|
760
374
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
// accidentally pass it on to the delegate.
|
|
764
|
-
this.arg = undefined$1;
|
|
375
|
+
function _next(value) {
|
|
376
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
765
377
|
}
|
|
766
378
|
|
|
767
|
-
|
|
768
|
-
|
|
379
|
+
function _throw(err) {
|
|
380
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
_next(undefined);
|
|
384
|
+
});
|
|
769
385
|
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function _extends() {
|
|
389
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
390
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
391
|
+
var source = arguments[i];
|
|
392
|
+
|
|
393
|
+
for (var key in source) {
|
|
394
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
395
|
+
target[key] = source[key];
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
770
399
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
775
|
-
return exports;
|
|
776
|
-
|
|
777
|
-
}(
|
|
778
|
-
// If this script is executing as a CommonJS module, use module.exports
|
|
779
|
-
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
780
|
-
// object. Either way, the resulting object will be used to initialize
|
|
781
|
-
// the regeneratorRuntime variable at the top of this file.
|
|
782
|
-
module.exports
|
|
783
|
-
));
|
|
784
|
-
|
|
785
|
-
try {
|
|
786
|
-
regeneratorRuntime = runtime;
|
|
787
|
-
} catch (accidentalStrictMode) {
|
|
788
|
-
// This module should not be running in strict mode, so the above
|
|
789
|
-
// assignment should always work unless something is misconfigured. Just
|
|
790
|
-
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
791
|
-
// strict mode using a global Function call. This could conceivably fail
|
|
792
|
-
// if a Content Security Policy forbids using Function, but in that case
|
|
793
|
-
// the proper solution is to fix the accidental strict mode problem. If
|
|
794
|
-
// you've misconfigured your bundler to force strict mode and applied a
|
|
795
|
-
// CSP to forbid Function, and you're not willing to fix either of those
|
|
796
|
-
// problems, please detail your unique predicament in a GitHub issue.
|
|
797
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
400
|
+
return target;
|
|
401
|
+
};
|
|
402
|
+
return _extends.apply(this, arguments);
|
|
798
403
|
}
|
|
799
|
-
});
|
|
800
404
|
|
|
801
405
|
var baseTransifexUrl = 'https://rest.api.transifex.com';
|
|
802
|
-
|
|
803
406
|
var getHeaders = function getHeaders(secrets) {
|
|
804
407
|
return {
|
|
805
408
|
Authorization: "Bearer " + (secrets == null ? void 0 : secrets.token),
|
|
806
409
|
'Content-Type': 'application/vnd.api+json'
|
|
807
410
|
};
|
|
808
411
|
};
|
|
809
|
-
|
|
810
412
|
var projOrgSlug = function projOrgSlug(secrets) {
|
|
811
413
|
return "o:" + (secrets == null ? void 0 : secrets.organization) + ":p:" + (secrets == null ? void 0 : secrets.project);
|
|
812
414
|
};
|
|
813
415
|
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
416
|
+
function getLocales(_x) {
|
|
417
|
+
return _getLocales.apply(this, arguments);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function _getLocales() {
|
|
421
|
+
_getLocales = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(secrets) {
|
|
422
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
817
423
|
while (1) {
|
|
818
424
|
switch (_context.prev = _context.next) {
|
|
819
425
|
case 0:
|
|
@@ -846,25 +452,26 @@ var getLocales = /*#__PURE__*/function () {
|
|
|
846
452
|
}
|
|
847
453
|
}, _callee);
|
|
848
454
|
}));
|
|
455
|
+
return _getLocales.apply(this, arguments);
|
|
456
|
+
}
|
|
849
457
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
}();
|
|
458
|
+
function getTranslationTask(_x, _x2) {
|
|
459
|
+
return _getTranslationTask.apply(this, arguments);
|
|
460
|
+
}
|
|
854
461
|
|
|
855
|
-
|
|
856
|
-
|
|
462
|
+
function _getTranslationTask() {
|
|
463
|
+
_getTranslationTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(documentId, secrets) {
|
|
857
464
|
var projectFilter, resourceFilter, task, locales, localeIds, validLocales;
|
|
858
|
-
return
|
|
465
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
859
466
|
while (1) {
|
|
860
|
-
switch (
|
|
467
|
+
switch (_context.prev = _context.next) {
|
|
861
468
|
case 0:
|
|
862
469
|
if (!(!documentId || !secrets)) {
|
|
863
|
-
|
|
470
|
+
_context.next = 2;
|
|
864
471
|
break;
|
|
865
472
|
}
|
|
866
473
|
|
|
867
|
-
return
|
|
474
|
+
return _context.abrupt("return", {
|
|
868
475
|
taskId: documentId,
|
|
869
476
|
documentId: documentId,
|
|
870
477
|
locales: []
|
|
@@ -873,21 +480,20 @@ var getTranslationTask = /*#__PURE__*/function () {
|
|
|
873
480
|
case 2:
|
|
874
481
|
projectFilter = "filter[project]=" + projOrgSlug(secrets);
|
|
875
482
|
resourceFilter = "filter[resource]=" + projOrgSlug(secrets) + ":r:" + documentId;
|
|
876
|
-
|
|
483
|
+
_context.next = 6;
|
|
877
484
|
return fetch(baseTransifexUrl + "/resource_language_stats?" + projectFilter + "&" + resourceFilter, {
|
|
878
485
|
headers: getHeaders(secrets)
|
|
879
486
|
}).then(function (res) {
|
|
880
487
|
if (res.ok) {
|
|
881
488
|
return res.json();
|
|
882
489
|
} //normal -- just means that this task doesn't exist yet.
|
|
883
|
-
else
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
}
|
|
490
|
+
else if (res.status === 404) {
|
|
491
|
+
return {
|
|
492
|
+
data: []
|
|
493
|
+
};
|
|
494
|
+
} else {
|
|
495
|
+
throw Error("Failed to retrieve tasks from Transifex. Status: " + res.status);
|
|
496
|
+
}
|
|
891
497
|
}).then(function (res) {
|
|
892
498
|
return {
|
|
893
499
|
taskId: projOrgSlug(secrets) + ":r:" + documentId,
|
|
@@ -902,12 +508,12 @@ var getTranslationTask = /*#__PURE__*/function () {
|
|
|
902
508
|
});
|
|
903
509
|
|
|
904
510
|
case 6:
|
|
905
|
-
task =
|
|
906
|
-
|
|
511
|
+
task = _context.sent;
|
|
512
|
+
_context.next = 9;
|
|
907
513
|
return getLocales(secrets);
|
|
908
514
|
|
|
909
515
|
case 9:
|
|
910
|
-
locales =
|
|
516
|
+
locales = _context.sent;
|
|
911
517
|
localeIds = locales.map(function (l) {
|
|
912
518
|
return l.localeId;
|
|
913
519
|
});
|
|
@@ -917,9 +523,170 @@ var getTranslationTask = /*#__PURE__*/function () {
|
|
|
917
523
|
});
|
|
918
524
|
});
|
|
919
525
|
task.locales = validLocales;
|
|
920
|
-
return
|
|
526
|
+
return _context.abrupt("return", task);
|
|
921
527
|
|
|
922
528
|
case 14:
|
|
529
|
+
case "end":
|
|
530
|
+
return _context.stop();
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}, _callee);
|
|
534
|
+
}));
|
|
535
|
+
return _getTranslationTask.apply(this, arguments);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function getTranslation(_x, _x2, _x3) {
|
|
539
|
+
return _getTranslation.apply(this, arguments);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function _getTranslation() {
|
|
543
|
+
_getTranslation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(taskId, localeId, secrets) {
|
|
544
|
+
var resourceDownloadBody, resourceDownloadUrl, translationDownloadId, headers, location;
|
|
545
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
546
|
+
while (1) {
|
|
547
|
+
switch (_context3.prev = _context3.next) {
|
|
548
|
+
case 0:
|
|
549
|
+
resourceDownloadBody = {
|
|
550
|
+
data: {
|
|
551
|
+
attributes: {
|
|
552
|
+
content_encoding: 'text'
|
|
553
|
+
},
|
|
554
|
+
relationships: {
|
|
555
|
+
language: {
|
|
556
|
+
data: {
|
|
557
|
+
id: "l:" + localeId,
|
|
558
|
+
type: 'languages'
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
resource: {
|
|
562
|
+
data: {
|
|
563
|
+
id: taskId,
|
|
564
|
+
type: 'resources'
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
type: 'resource_translations_async_downloads'
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
resourceDownloadUrl = baseTransifexUrl + "/resource_translations_async_downloads";
|
|
572
|
+
_context3.next = 4;
|
|
573
|
+
return fetch(resourceDownloadUrl, {
|
|
574
|
+
headers: getHeaders(secrets),
|
|
575
|
+
method: 'POST',
|
|
576
|
+
body: JSON.stringify(resourceDownloadBody)
|
|
577
|
+
}).then(function (res) {
|
|
578
|
+
return res.json();
|
|
579
|
+
}).then(function (res) {
|
|
580
|
+
return res.data.id;
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
case 4:
|
|
584
|
+
translationDownloadId = _context3.sent;
|
|
585
|
+
headers = getHeaders(secrets);
|
|
586
|
+
_context3.next = 8;
|
|
587
|
+
return pollForFileDownloadLocation(resourceDownloadUrl, translationDownloadId, headers);
|
|
588
|
+
|
|
589
|
+
case 8:
|
|
590
|
+
location = _context3.sent;
|
|
591
|
+
return _context3.abrupt("return", handleFileDownload(location));
|
|
592
|
+
|
|
593
|
+
case 10:
|
|
594
|
+
case "end":
|
|
595
|
+
return _context3.stop();
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}, _callee3);
|
|
599
|
+
}));
|
|
600
|
+
return _getTranslation.apply(this, arguments);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
var pollForFileDownloadLocation = /*#__PURE__*/function () {
|
|
604
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resourceDownloadUrl, translationDownloadId, headers) {
|
|
605
|
+
var response;
|
|
606
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
607
|
+
while (1) {
|
|
608
|
+
switch (_context.prev = _context.next) {
|
|
609
|
+
case 0:
|
|
610
|
+
_context.next = 2;
|
|
611
|
+
return fetch(resourceDownloadUrl + "/" + translationDownloadId, {
|
|
612
|
+
headers: headers
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
case 2:
|
|
616
|
+
response = _context.sent;
|
|
617
|
+
|
|
618
|
+
if (!(response.status === 500)) {
|
|
619
|
+
_context.next = 10;
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
console.info("Transifex plugin message: Received 500 for translation download ID " + translationDownloadId + ". Trying to reconnect...");
|
|
624
|
+
_context.next = 7;
|
|
625
|
+
return new Promise(function (resolve) {
|
|
626
|
+
return setTimeout(resolve, 3000);
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
case 7:
|
|
630
|
+
return _context.abrupt("return", pollForFileDownloadLocation(resourceDownloadUrl, translationDownloadId, headers));
|
|
631
|
+
|
|
632
|
+
case 10:
|
|
633
|
+
if (!response.redirected) {
|
|
634
|
+
_context.next = 15;
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
console.info("Transifex plugin message: Received redirect for translation download ID " + translationDownloadId + ". Following redirect now for file download.");
|
|
639
|
+
return _context.abrupt("return", response.url);
|
|
640
|
+
|
|
641
|
+
case 15:
|
|
642
|
+
if (!(response.status === 200)) {
|
|
643
|
+
_context.next = 22;
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
console.info("Transifex plugin message: Requested download location for translation download ID " + translationDownloadId + ". Location is still pending, trying again.");
|
|
648
|
+
_context.next = 19;
|
|
649
|
+
return new Promise(function (resolve) {
|
|
650
|
+
return setTimeout(resolve, 3000);
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
case 19:
|
|
654
|
+
return _context.abrupt("return", pollForFileDownloadLocation(resourceDownloadUrl, translationDownloadId, headers));
|
|
655
|
+
|
|
656
|
+
case 22:
|
|
657
|
+
console.info("Transifex plugin message: Requested download location for translation download ID " + translationDownloadId + " but received error code " + response.status + ". Waiting and trying again.");
|
|
658
|
+
_context.next = 25;
|
|
659
|
+
return new Promise(function (resolve) {
|
|
660
|
+
return setTimeout(resolve, 3000);
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
case 25:
|
|
664
|
+
return _context.abrupt("return", pollForFileDownloadLocation(resourceDownloadUrl, translationDownloadId, headers));
|
|
665
|
+
|
|
666
|
+
case 26:
|
|
667
|
+
case "end":
|
|
668
|
+
return _context.stop();
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}, _callee);
|
|
672
|
+
}));
|
|
673
|
+
|
|
674
|
+
return function pollForFileDownloadLocation(_x4, _x5, _x6) {
|
|
675
|
+
return _ref.apply(this, arguments);
|
|
676
|
+
};
|
|
677
|
+
}();
|
|
678
|
+
|
|
679
|
+
var handleFileDownload = /*#__PURE__*/function () {
|
|
680
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(url) {
|
|
681
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
682
|
+
while (1) {
|
|
683
|
+
switch (_context2.prev = _context2.next) {
|
|
684
|
+
case 0:
|
|
685
|
+
return _context2.abrupt("return", fetch(url).then(function (res) {
|
|
686
|
+
return res.text();
|
|
687
|
+
}));
|
|
688
|
+
|
|
689
|
+
case 1:
|
|
923
690
|
case "end":
|
|
924
691
|
return _context2.stop();
|
|
925
692
|
}
|
|
@@ -927,17 +694,17 @@ var getTranslationTask = /*#__PURE__*/function () {
|
|
|
927
694
|
}, _callee2);
|
|
928
695
|
}));
|
|
929
696
|
|
|
930
|
-
return function
|
|
697
|
+
return function handleFileDownload(_x7) {
|
|
931
698
|
return _ref2.apply(this, arguments);
|
|
932
699
|
};
|
|
933
700
|
}();
|
|
934
701
|
|
|
935
702
|
var createResource = /*#__PURE__*/function () {
|
|
936
|
-
var
|
|
703
|
+
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(doc, documentId, secrets) {
|
|
937
704
|
var resourceCreateBody;
|
|
938
|
-
return
|
|
705
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
939
706
|
while (1) {
|
|
940
|
-
switch (
|
|
707
|
+
switch (_context.prev = _context.next) {
|
|
941
708
|
case 0:
|
|
942
709
|
resourceCreateBody = {
|
|
943
710
|
data: {
|
|
@@ -963,7 +730,7 @@ var createResource = /*#__PURE__*/function () {
|
|
|
963
730
|
type: 'resources'
|
|
964
731
|
}
|
|
965
732
|
};
|
|
966
|
-
return
|
|
733
|
+
return _context.abrupt("return", fetch(baseTransifexUrl + "/resources", {
|
|
967
734
|
headers: getHeaders(secrets),
|
|
968
735
|
method: 'POST',
|
|
969
736
|
body: JSON.stringify(resourceCreateBody)
|
|
@@ -975,27 +742,31 @@ var createResource = /*#__PURE__*/function () {
|
|
|
975
742
|
|
|
976
743
|
case 2:
|
|
977
744
|
case "end":
|
|
978
|
-
return
|
|
745
|
+
return _context.stop();
|
|
979
746
|
}
|
|
980
747
|
}
|
|
981
|
-
},
|
|
748
|
+
}, _callee);
|
|
982
749
|
}));
|
|
983
750
|
|
|
984
|
-
return function createResource(
|
|
985
|
-
return
|
|
751
|
+
return function createResource(_x, _x2, _x3) {
|
|
752
|
+
return _ref.apply(this, arguments);
|
|
986
753
|
};
|
|
987
754
|
}();
|
|
988
755
|
|
|
989
|
-
|
|
990
|
-
|
|
756
|
+
function createTask(_x4, _x5, _x6, _x7) {
|
|
757
|
+
return _createTask.apply(this, arguments);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
function _createTask() {
|
|
761
|
+
_createTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(documentId, document, //unfortunately Transifex doesn't let you specify locales on creating a task
|
|
991
762
|
//@ts-ignore
|
|
992
763
|
localeIds, secrets) {
|
|
993
764
|
var resourceId, resourceUploadUrl, resourceUploadBody;
|
|
994
|
-
return
|
|
765
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
995
766
|
while (1) {
|
|
996
|
-
switch (
|
|
767
|
+
switch (_context2.prev = _context2.next) {
|
|
997
768
|
case 0:
|
|
998
|
-
|
|
769
|
+
_context2.next = 2;
|
|
999
770
|
return fetch(baseTransifexUrl + "/resources/" + projOrgSlug(secrets) + ":r:" + documentId, {
|
|
1000
771
|
headers: getHeaders(secrets)
|
|
1001
772
|
}).then(function (res) {
|
|
@@ -1005,18 +776,18 @@ var createTask = /*#__PURE__*/function () {
|
|
|
1005
776
|
});
|
|
1006
777
|
|
|
1007
778
|
case 2:
|
|
1008
|
-
resourceId =
|
|
779
|
+
resourceId = _context2.sent;
|
|
1009
780
|
|
|
1010
781
|
if (resourceId) {
|
|
1011
|
-
|
|
782
|
+
_context2.next = 7;
|
|
1012
783
|
break;
|
|
1013
784
|
}
|
|
1014
785
|
|
|
1015
|
-
|
|
786
|
+
_context2.next = 6;
|
|
1016
787
|
return createResource(document, documentId, secrets);
|
|
1017
788
|
|
|
1018
789
|
case 6:
|
|
1019
|
-
resourceId =
|
|
790
|
+
resourceId = _context2.sent;
|
|
1020
791
|
|
|
1021
792
|
case 7:
|
|
1022
793
|
resourceUploadUrl = baseTransifexUrl + "/resource_strings_async_uploads";
|
|
@@ -1037,7 +808,7 @@ var createTask = /*#__PURE__*/function () {
|
|
|
1037
808
|
type: 'resource_strings_async_uploads'
|
|
1038
809
|
}
|
|
1039
810
|
};
|
|
1040
|
-
return
|
|
811
|
+
return _context2.abrupt("return", fetch(resourceUploadUrl, {
|
|
1041
812
|
method: 'POST',
|
|
1042
813
|
body: JSON.stringify(resourceUploadBody),
|
|
1043
814
|
headers: getHeaders(secrets)
|
|
@@ -1047,109 +818,13 @@ var createTask = /*#__PURE__*/function () {
|
|
|
1047
818
|
|
|
1048
819
|
case 10:
|
|
1049
820
|
case "end":
|
|
1050
|
-
return
|
|
1051
|
-
}
|
|
1052
|
-
}
|
|
1053
|
-
}, _callee4);
|
|
1054
|
-
}));
|
|
1055
|
-
|
|
1056
|
-
return function createTask(_x7, _x8, _x9, _x10) {
|
|
1057
|
-
return _ref4.apply(this, arguments);
|
|
1058
|
-
};
|
|
1059
|
-
}();
|
|
1060
|
-
|
|
1061
|
-
var getTranslation = /*#__PURE__*/function () {
|
|
1062
|
-
var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(taskId, localeId, secrets) {
|
|
1063
|
-
var resourceDownloadBody, resourceDownloadUrl, translationDownloadId;
|
|
1064
|
-
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1065
|
-
while (1) {
|
|
1066
|
-
switch (_context5.prev = _context5.next) {
|
|
1067
|
-
case 0:
|
|
1068
|
-
resourceDownloadBody = {
|
|
1069
|
-
data: {
|
|
1070
|
-
attributes: {
|
|
1071
|
-
content_encoding: 'text'
|
|
1072
|
-
},
|
|
1073
|
-
relationships: {
|
|
1074
|
-
language: {
|
|
1075
|
-
data: {
|
|
1076
|
-
id: "l:" + localeId,
|
|
1077
|
-
type: 'languages'
|
|
1078
|
-
}
|
|
1079
|
-
},
|
|
1080
|
-
resource: {
|
|
1081
|
-
data: {
|
|
1082
|
-
id: taskId,
|
|
1083
|
-
type: 'resources'
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
},
|
|
1087
|
-
type: 'resource_translations_async_downloads'
|
|
1088
|
-
}
|
|
1089
|
-
};
|
|
1090
|
-
resourceDownloadUrl = baseTransifexUrl + "/resource_translations_async_downloads";
|
|
1091
|
-
_context5.next = 4;
|
|
1092
|
-
return fetch(resourceDownloadUrl, {
|
|
1093
|
-
headers: getHeaders(secrets),
|
|
1094
|
-
method: 'POST',
|
|
1095
|
-
body: JSON.stringify(resourceDownloadBody)
|
|
1096
|
-
}).then(function (res) {
|
|
1097
|
-
return res.json();
|
|
1098
|
-
}).then(function (res) {
|
|
1099
|
-
return res.data.id;
|
|
1100
|
-
});
|
|
1101
|
-
|
|
1102
|
-
case 4:
|
|
1103
|
-
translationDownloadId = _context5.sent;
|
|
1104
|
-
return _context5.abrupt("return", new Promise(function (resolve) {
|
|
1105
|
-
setTimeout(function () {
|
|
1106
|
-
fetch(resourceDownloadUrl + "/" + translationDownloadId, {
|
|
1107
|
-
headers: getHeaders(secrets)
|
|
1108
|
-
}).then(function (res) {
|
|
1109
|
-
if (res.redirected) {
|
|
1110
|
-
return resolve(handleFileDownload(res.url));
|
|
1111
|
-
} else {
|
|
1112
|
-
return res.json();
|
|
1113
|
-
}
|
|
1114
|
-
});
|
|
1115
|
-
}, 3000);
|
|
1116
|
-
}));
|
|
1117
|
-
|
|
1118
|
-
case 6:
|
|
1119
|
-
case "end":
|
|
1120
|
-
return _context5.stop();
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
}, _callee5);
|
|
1124
|
-
}));
|
|
1125
|
-
|
|
1126
|
-
return function getTranslation(_x11, _x12, _x13) {
|
|
1127
|
-
return _ref5.apply(this, arguments);
|
|
1128
|
-
};
|
|
1129
|
-
}();
|
|
1130
|
-
|
|
1131
|
-
var handleFileDownload = /*#__PURE__*/function () {
|
|
1132
|
-
var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(url) {
|
|
1133
|
-
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1134
|
-
while (1) {
|
|
1135
|
-
switch (_context6.prev = _context6.next) {
|
|
1136
|
-
case 0:
|
|
1137
|
-
return _context6.abrupt("return", fetch(url).then(function (res) {
|
|
1138
|
-
return res.text();
|
|
1139
|
-
}));
|
|
1140
|
-
|
|
1141
|
-
case 1:
|
|
1142
|
-
case "end":
|
|
1143
|
-
return _context6.stop();
|
|
821
|
+
return _context2.stop();
|
|
1144
822
|
}
|
|
1145
823
|
}
|
|
1146
|
-
},
|
|
824
|
+
}, _callee2);
|
|
1147
825
|
}));
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
return _ref6.apply(this, arguments);
|
|
1151
|
-
};
|
|
1152
|
-
}();
|
|
826
|
+
return _createTask.apply(this, arguments);
|
|
827
|
+
}
|
|
1153
828
|
|
|
1154
829
|
var TransifexAdapter = {
|
|
1155
830
|
getLocales: getLocales,
|
|
@@ -1158,314 +833,68 @@ var TransifexAdapter = {
|
|
|
1158
833
|
getTranslation: getTranslation
|
|
1159
834
|
};
|
|
1160
835
|
|
|
1161
|
-
var
|
|
1162
|
-
apiVersion: '2021-03-25'
|
|
1163
|
-
}); //document fetch
|
|
1164
|
-
|
|
1165
|
-
var findLatestDraft = function findLatestDraft(documentId) {
|
|
1166
|
-
//eliminates i18n versions
|
|
1167
|
-
var query = "*[_id == $id || _id == $draftId]";
|
|
1168
|
-
var params = {
|
|
1169
|
-
id: "" + documentId,
|
|
1170
|
-
draftId: "drafts." + documentId
|
|
1171
|
-
};
|
|
1172
|
-
return client.fetch(query, params).then(function (docs) {
|
|
1173
|
-
var _docs$find;
|
|
1174
|
-
|
|
1175
|
-
return (_docs$find = docs.find(function (doc) {
|
|
1176
|
-
return doc._id.includes('draft');
|
|
1177
|
-
})) != null ? _docs$find : docs[0];
|
|
1178
|
-
});
|
|
1179
|
-
}; //revision fetch
|
|
1180
|
-
|
|
1181
|
-
var findDocumentAtRevision = /*#__PURE__*/function () {
|
|
1182
|
-
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(documentId, rev) {
|
|
1183
|
-
var dataset, baseUrl, url, revisionDoc;
|
|
1184
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1185
|
-
while (1) {
|
|
1186
|
-
switch (_context.prev = _context.next) {
|
|
1187
|
-
case 0:
|
|
1188
|
-
dataset = client.config().dataset;
|
|
1189
|
-
baseUrl = "/data/history/" + dataset + "/documents/" + documentId + "?revision=" + rev;
|
|
1190
|
-
url = client.getUrl(baseUrl);
|
|
1191
|
-
_context.next = 5;
|
|
1192
|
-
return fetch(url, {
|
|
1193
|
-
credentials: 'include'
|
|
1194
|
-
}).then(function (req) {
|
|
1195
|
-
return req.json();
|
|
1196
|
-
}).then(function (req) {
|
|
1197
|
-
return req.documents[0];
|
|
1198
|
-
});
|
|
1199
|
-
|
|
1200
|
-
case 5:
|
|
1201
|
-
revisionDoc = _context.sent;
|
|
1202
|
-
|
|
1203
|
-
if (!(!revisionDoc || revisionDoc._rev !== rev)) {
|
|
1204
|
-
_context.next = 12;
|
|
1205
|
-
break;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
baseUrl = "/data/history/" + dataset + "/documents/drafts." + documentId + "?revision=" + rev;
|
|
1209
|
-
url = client.getUrl(baseUrl);
|
|
1210
|
-
_context.next = 11;
|
|
1211
|
-
return fetch(url, {
|
|
1212
|
-
credentials: 'include'
|
|
1213
|
-
}).then(function (req) {
|
|
1214
|
-
return req.json();
|
|
1215
|
-
}).then(function (req) {
|
|
1216
|
-
return req.documents[0];
|
|
1217
|
-
});
|
|
1218
|
-
|
|
1219
|
-
case 11:
|
|
1220
|
-
revisionDoc = _context.sent;
|
|
1221
|
-
|
|
1222
|
-
case 12:
|
|
1223
|
-
return _context.abrupt("return", revisionDoc);
|
|
1224
|
-
|
|
1225
|
-
case 13:
|
|
1226
|
-
case "end":
|
|
1227
|
-
return _context.stop();
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
}, _callee);
|
|
1231
|
-
}));
|
|
1232
|
-
|
|
1233
|
-
return function findDocumentAtRevision(_x, _x2) {
|
|
1234
|
-
return _ref.apply(this, arguments);
|
|
1235
|
-
};
|
|
1236
|
-
}(); //document-level patch
|
|
1237
|
-
|
|
1238
|
-
var documentLevelPatch = /*#__PURE__*/function () {
|
|
1239
|
-
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(documentId, translatedFields, localeId) {
|
|
1240
|
-
var baseDoc, merged, targetId, i18nDoc, cleanedMerge;
|
|
1241
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1242
|
-
while (1) {
|
|
1243
|
-
switch (_context2.prev = _context2.next) {
|
|
1244
|
-
case 0:
|
|
1245
|
-
if (!translatedFields._rev) {
|
|
1246
|
-
_context2.next = 6;
|
|
1247
|
-
break;
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
_context2.next = 3;
|
|
1251
|
-
return findDocumentAtRevision(documentId, translatedFields._rev);
|
|
1252
|
-
|
|
1253
|
-
case 3:
|
|
1254
|
-
baseDoc = _context2.sent;
|
|
1255
|
-
_context2.next = 9;
|
|
1256
|
-
break;
|
|
1257
|
-
|
|
1258
|
-
case 6:
|
|
1259
|
-
_context2.next = 8;
|
|
1260
|
-
return findLatestDraft(documentId);
|
|
1261
|
-
|
|
1262
|
-
case 8:
|
|
1263
|
-
baseDoc = _context2.sent;
|
|
1264
|
-
|
|
1265
|
-
case 9:
|
|
1266
|
-
merged = sanityNaiveHtmlSerializer.BaseDocumentMerger.documentLevelMerge(translatedFields, baseDoc);
|
|
1267
|
-
targetId = "i18n." + documentId + "." + localeId;
|
|
1268
|
-
_context2.next = 13;
|
|
1269
|
-
return findLatestDraft(targetId);
|
|
1270
|
-
|
|
1271
|
-
case 13:
|
|
1272
|
-
i18nDoc = _context2.sent;
|
|
1273
|
-
|
|
1274
|
-
if (i18nDoc) {
|
|
1275
|
-
cleanedMerge = {}; //don't overwrite any existing values on the i18n doc
|
|
1276
|
-
|
|
1277
|
-
Object.entries(merged).forEach(function (_ref3) {
|
|
1278
|
-
var key = _ref3[0],
|
|
1279
|
-
value = _ref3[1];
|
|
1280
|
-
|
|
1281
|
-
if (Object.keys(translatedFields).includes(key) && !['_id', '_rev', '_updatedAt'].includes(key)) {
|
|
1282
|
-
cleanedMerge[key] = value;
|
|
1283
|
-
}
|
|
1284
|
-
});
|
|
1285
|
-
client.transaction() //@ts-ignore
|
|
1286
|
-
.patch(i18nDoc._id, function (p) {
|
|
1287
|
-
return p.set(cleanedMerge);
|
|
1288
|
-
}).commit();
|
|
1289
|
-
} else {
|
|
1290
|
-
merged._id = "drafts." + targetId; //account for legacy implementations of i18n plugin lang
|
|
1291
|
-
|
|
1292
|
-
if (baseDoc._lang) {
|
|
1293
|
-
merged._lang = localeId;
|
|
1294
|
-
} else if (baseDoc.__i18n_lang) {
|
|
1295
|
-
merged.__i18n_lang = localeId;
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
client.create(merged);
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
case 15:
|
|
1302
|
-
case "end":
|
|
1303
|
-
return _context2.stop();
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
}, _callee2);
|
|
1307
|
-
}));
|
|
1308
|
-
|
|
1309
|
-
return function documentLevelPatch(_x3, _x4, _x5) {
|
|
1310
|
-
return _ref2.apply(this, arguments);
|
|
1311
|
-
};
|
|
1312
|
-
}(); //field level patch
|
|
1313
|
-
|
|
1314
|
-
var fieldLevelPatch = /*#__PURE__*/function () {
|
|
1315
|
-
var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(documentId, translatedFields, localeId) {
|
|
1316
|
-
var baseDoc, merged;
|
|
1317
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1318
|
-
while (1) {
|
|
1319
|
-
switch (_context3.prev = _context3.next) {
|
|
1320
|
-
case 0:
|
|
1321
|
-
if (!translatedFields._rev) {
|
|
1322
|
-
_context3.next = 6;
|
|
1323
|
-
break;
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
_context3.next = 3;
|
|
1327
|
-
return findDocumentAtRevision(documentId, translatedFields._rev);
|
|
1328
|
-
|
|
1329
|
-
case 3:
|
|
1330
|
-
baseDoc = _context3.sent;
|
|
1331
|
-
_context3.next = 9;
|
|
1332
|
-
break;
|
|
1333
|
-
|
|
1334
|
-
case 6:
|
|
1335
|
-
_context3.next = 8;
|
|
1336
|
-
return findLatestDraft(documentId);
|
|
1337
|
-
|
|
1338
|
-
case 8:
|
|
1339
|
-
baseDoc = _context3.sent;
|
|
1340
|
-
|
|
1341
|
-
case 9:
|
|
1342
|
-
merged = sanityNaiveHtmlSerializer.BaseDocumentMerger.fieldLevelMerge(translatedFields, baseDoc, localeId, 'en');
|
|
1343
|
-
client.patch(baseDoc._id).set(merged).commit();
|
|
1344
|
-
|
|
1345
|
-
case 11:
|
|
1346
|
-
case "end":
|
|
1347
|
-
return _context3.stop();
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
}, _callee3);
|
|
1351
|
-
}));
|
|
1352
|
-
|
|
1353
|
-
return function fieldLevelPatch(_x6, _x7, _x8) {
|
|
1354
|
-
return _ref4.apply(this, arguments);
|
|
1355
|
-
};
|
|
1356
|
-
}();
|
|
1357
|
-
|
|
1358
|
-
var defaultDocumentLevelConfig = {
|
|
1359
|
-
exportForTranslation: /*#__PURE__*/function () {
|
|
1360
|
-
var _exportForTranslation = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(id) {
|
|
1361
|
-
var doc, serialized;
|
|
1362
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1363
|
-
while (1) {
|
|
1364
|
-
switch (_context.prev = _context.next) {
|
|
1365
|
-
case 0:
|
|
1366
|
-
_context.next = 2;
|
|
1367
|
-
return findLatestDraft(id);
|
|
1368
|
-
|
|
1369
|
-
case 2:
|
|
1370
|
-
doc = _context.sent;
|
|
1371
|
-
serialized = sanityNaiveHtmlSerializer.BaseDocumentSerializer.serializeDocument(doc, 'document');
|
|
1372
|
-
serialized.name = id;
|
|
1373
|
-
return _context.abrupt("return", serialized);
|
|
1374
|
-
|
|
1375
|
-
case 6:
|
|
1376
|
-
case "end":
|
|
1377
|
-
return _context.stop();
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
}, _callee);
|
|
1381
|
-
}));
|
|
1382
|
-
|
|
1383
|
-
function exportForTranslation(_x) {
|
|
1384
|
-
return _exportForTranslation.apply(this, arguments);
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
return exportForTranslation;
|
|
1388
|
-
}(),
|
|
1389
|
-
importTranslation: function importTranslation(id, localeId, document) {
|
|
1390
|
-
var deserialized = sanityNaiveHtmlSerializer.BaseDocumentDeserializer.deserializeDocument(document);
|
|
1391
|
-
documentLevelPatch(id, deserialized, localeId);
|
|
1392
|
-
},
|
|
836
|
+
var defaultDocumentLevelConfig = /*#__PURE__*/_extends({}, sanityTranslationsTab.baseDocumentLevelConfig, {
|
|
1393
837
|
adapter: TransifexAdapter,
|
|
1394
838
|
secretsNamespace: 'transifex'
|
|
1395
|
-
};
|
|
1396
|
-
var defaultFieldLevelConfig = {
|
|
1397
|
-
exportForTranslation: /*#__PURE__*/function () {
|
|
1398
|
-
var _exportForTranslation2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(id) {
|
|
1399
|
-
var doc, serialized;
|
|
1400
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1401
|
-
while (1) {
|
|
1402
|
-
switch (_context2.prev = _context2.next) {
|
|
1403
|
-
case 0:
|
|
1404
|
-
_context2.next = 2;
|
|
1405
|
-
return findLatestDraft(id);
|
|
1406
|
-
|
|
1407
|
-
case 2:
|
|
1408
|
-
doc = _context2.sent;
|
|
1409
|
-
serialized = sanityNaiveHtmlSerializer.BaseDocumentSerializer.serializeDocument(doc, 'field');
|
|
1410
|
-
serialized.name = id;
|
|
1411
|
-
return _context2.abrupt("return", serialized);
|
|
1412
|
-
|
|
1413
|
-
case 6:
|
|
1414
|
-
case "end":
|
|
1415
|
-
return _context2.stop();
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
}, _callee2);
|
|
1419
|
-
}));
|
|
1420
|
-
|
|
1421
|
-
function exportForTranslation(_x2) {
|
|
1422
|
-
return _exportForTranslation2.apply(this, arguments);
|
|
1423
|
-
}
|
|
839
|
+
});
|
|
1424
840
|
|
|
1425
|
-
|
|
1426
|
-
}(),
|
|
1427
|
-
importTranslation: function importTranslation(id, localeId, document) {
|
|
1428
|
-
var deserialized = sanityNaiveHtmlSerializer.BaseDocumentDeserializer.deserializeDocument(document);
|
|
1429
|
-
fieldLevelPatch(id, deserialized, localeId);
|
|
1430
|
-
},
|
|
841
|
+
var defaultFieldLevelConfig = /*#__PURE__*/_extends({}, sanityTranslationsTab.baseFieldLevelConfig, {
|
|
1431
842
|
adapter: TransifexAdapter,
|
|
1432
843
|
secretsNamespace: 'transifex'
|
|
1433
|
-
};
|
|
844
|
+
});
|
|
1434
845
|
|
|
1435
|
-
Object.defineProperty(exports, '
|
|
846
|
+
Object.defineProperty(exports, 'BaseDocumentDeserializer', {
|
|
1436
847
|
enumerable: true,
|
|
1437
848
|
get: function () {
|
|
1438
|
-
return sanityTranslationsTab.
|
|
849
|
+
return sanityTranslationsTab.BaseDocumentDeserializer;
|
|
1439
850
|
}
|
|
1440
851
|
});
|
|
1441
|
-
Object.defineProperty(exports, '
|
|
852
|
+
Object.defineProperty(exports, 'BaseDocumentMerger', {
|
|
1442
853
|
enumerable: true,
|
|
1443
854
|
get: function () {
|
|
1444
|
-
return
|
|
855
|
+
return sanityTranslationsTab.BaseDocumentMerger;
|
|
1445
856
|
}
|
|
1446
857
|
});
|
|
1447
|
-
Object.defineProperty(exports, '
|
|
858
|
+
Object.defineProperty(exports, 'BaseDocumentSerializer', {
|
|
1448
859
|
enumerable: true,
|
|
1449
860
|
get: function () {
|
|
1450
|
-
return
|
|
861
|
+
return sanityTranslationsTab.BaseDocumentSerializer;
|
|
1451
862
|
}
|
|
1452
863
|
});
|
|
1453
|
-
Object.defineProperty(exports, '
|
|
864
|
+
Object.defineProperty(exports, 'TranslationsTab', {
|
|
1454
865
|
enumerable: true,
|
|
1455
866
|
get: function () {
|
|
1456
|
-
return
|
|
867
|
+
return sanityTranslationsTab.TranslationsTab;
|
|
1457
868
|
}
|
|
1458
869
|
});
|
|
1459
870
|
Object.defineProperty(exports, 'customSerializers', {
|
|
1460
871
|
enumerable: true,
|
|
1461
872
|
get: function () {
|
|
1462
|
-
return
|
|
873
|
+
return sanityTranslationsTab.customSerializers;
|
|
1463
874
|
}
|
|
1464
875
|
});
|
|
1465
876
|
Object.defineProperty(exports, 'defaultStopTypes', {
|
|
1466
877
|
enumerable: true,
|
|
1467
878
|
get: function () {
|
|
1468
|
-
return
|
|
879
|
+
return sanityTranslationsTab.defaultStopTypes;
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
Object.defineProperty(exports, 'documentLevelPatch', {
|
|
883
|
+
enumerable: true,
|
|
884
|
+
get: function () {
|
|
885
|
+
return sanityTranslationsTab.documentLevelPatch;
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
Object.defineProperty(exports, 'fieldLevelPatch', {
|
|
889
|
+
enumerable: true,
|
|
890
|
+
get: function () {
|
|
891
|
+
return sanityTranslationsTab.fieldLevelPatch;
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
Object.defineProperty(exports, 'findLatestDraft', {
|
|
895
|
+
enumerable: true,
|
|
896
|
+
get: function () {
|
|
897
|
+
return sanityTranslationsTab.findLatestDraft;
|
|
1469
898
|
}
|
|
1470
899
|
});
|
|
1471
900
|
exports.TransifexAdapter = TransifexAdapter;
|