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