mp-front-cli 0.0.54 → 0.0.55
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/core/utils/api-request/fetch-service-be.d.ts +5 -3
- package/dist/core/utils/api-request/fetch-service-be.d.ts.map +1 -1
- package/dist/core/utils/custom-adapter.d.ts +16 -0
- package/dist/core/utils/custom-adapter.d.ts.map +1 -0
- package/dist/{custom-encoder-05d6a9f1.js → custom-encoder-70a77460.js} +969 -947
- package/dist/{custom-encrypter-1573699a.js → custom-encrypter-e3901c44.js} +3945 -4158
- package/dist/{custom-header-eeb04e28.js → custom-header-db08aa72.js} +1 -1
- package/dist/mp-front-cli-adapter.es.js +149 -0
- package/dist/mp-front-cli-all.es.js +14 -13
- package/dist/mp-front-cli-cache.es.js +5 -4
- package/dist/mp-front-cli-core.es.js +626 -599
- package/dist/mp-front-cli-encoder.es.js +1 -1
- package/dist/mp-front-cli-encrypter.es.js +4 -3
- package/dist/mp-front-cli-header.es.js +5 -4
- package/dist/v4-8464ab21.js +46 -0
- package/package.json +8 -2
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
var ve = Object.defineProperty;
|
|
2
|
-
var we = (i,
|
|
3
|
-
var $ = (i,
|
|
4
|
-
import { C as
|
|
5
|
-
import { S as
|
|
6
|
-
import { MessageHandler as
|
|
7
|
-
import { RxSubjectManager as
|
|
8
|
-
import { t as
|
|
2
|
+
var we = (i, t, e) => t in i ? ve(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var $ = (i, t, e) => (we(i, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import { C as Ne, f as q } from "./custom-header-db08aa72.js";
|
|
5
|
+
import { S as dt } from "./custom-header-db08aa72.js";
|
|
6
|
+
import { MessageHandler as ie, LoadingHandler as M } from "./mp-front-cli-utils-rxjs.es.js";
|
|
7
|
+
import { RxSubjectManager as mt } from "./mp-front-cli-utils-rxjs.es.js";
|
|
8
|
+
import { t as Re } from "./index-df4e0539.js";
|
|
9
9
|
import { CustomLogger as Pe } from "./mp-front-cli-logger.es.js";
|
|
10
|
-
import { of as
|
|
11
|
-
import { C as $e,
|
|
12
|
-
import { C as
|
|
10
|
+
import { of as N, switchMap as R, forkJoin as re, catchError as me, EMPTY as ye, filter as xe } from "rxjs";
|
|
11
|
+
import { C as $e, v as ae } from "./custom-encrypter-e3901c44.js";
|
|
12
|
+
import { C as Ee } from "./custom-encoder-70a77460.js";
|
|
13
13
|
import "crypto";
|
|
14
|
-
|
|
14
|
+
import "./v4-8464ab21.js";
|
|
15
|
+
const Ce = {
|
|
15
16
|
type: "logger",
|
|
16
17
|
log(i) {
|
|
17
18
|
this.output("log", i);
|
|
@@ -22,50 +23,50 @@ const Ee = {
|
|
|
22
23
|
error(i) {
|
|
23
24
|
this.output("error", i);
|
|
24
25
|
},
|
|
25
|
-
output(i,
|
|
26
|
-
console && console[i] && console[i].apply(console,
|
|
26
|
+
output(i, t) {
|
|
27
|
+
console && console[i] && console[i].apply(console, t);
|
|
27
28
|
}
|
|
28
29
|
};
|
|
29
30
|
class z {
|
|
30
|
-
constructor(
|
|
31
|
-
let
|
|
32
|
-
this.init(
|
|
31
|
+
constructor(t) {
|
|
32
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
33
|
+
this.init(t, e);
|
|
33
34
|
}
|
|
34
|
-
init(
|
|
35
|
-
let
|
|
36
|
-
this.prefix =
|
|
35
|
+
init(t) {
|
|
36
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
37
|
+
this.prefix = e.prefix || "i18next:", this.logger = t || Ce, this.options = e, this.debug = e.debug;
|
|
37
38
|
}
|
|
38
39
|
log() {
|
|
39
|
-
for (var
|
|
40
|
-
|
|
41
|
-
return this.forward(
|
|
40
|
+
for (var t = arguments.length, e = new Array(t), s = 0; s < t; s++)
|
|
41
|
+
e[s] = arguments[s];
|
|
42
|
+
return this.forward(e, "log", "", !0);
|
|
42
43
|
}
|
|
43
44
|
warn() {
|
|
44
|
-
for (var
|
|
45
|
-
|
|
46
|
-
return this.forward(
|
|
45
|
+
for (var t = arguments.length, e = new Array(t), s = 0; s < t; s++)
|
|
46
|
+
e[s] = arguments[s];
|
|
47
|
+
return this.forward(e, "warn", "", !0);
|
|
47
48
|
}
|
|
48
49
|
error() {
|
|
49
|
-
for (var
|
|
50
|
-
|
|
51
|
-
return this.forward(
|
|
50
|
+
for (var t = arguments.length, e = new Array(t), s = 0; s < t; s++)
|
|
51
|
+
e[s] = arguments[s];
|
|
52
|
+
return this.forward(e, "error", "");
|
|
52
53
|
}
|
|
53
54
|
deprecate() {
|
|
54
|
-
for (var
|
|
55
|
-
|
|
56
|
-
return this.forward(
|
|
55
|
+
for (var t = arguments.length, e = new Array(t), s = 0; s < t; s++)
|
|
56
|
+
e[s] = arguments[s];
|
|
57
|
+
return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
|
|
57
58
|
}
|
|
58
|
-
forward(
|
|
59
|
-
return n && !this.debug ? null : (typeof
|
|
59
|
+
forward(t, e, s, n) {
|
|
60
|
+
return n && !this.debug ? null : (typeof t[0] == "string" && (t[0] = `${s}${this.prefix} ${t[0]}`), this.logger[e](t));
|
|
60
61
|
}
|
|
61
|
-
create(
|
|
62
|
+
create(t) {
|
|
62
63
|
return new z(this.logger, {
|
|
63
|
-
prefix: `${this.prefix}:${
|
|
64
|
+
prefix: `${this.prefix}:${t}:`,
|
|
64
65
|
...this.options
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
|
-
clone(
|
|
68
|
-
return
|
|
68
|
+
clone(t) {
|
|
69
|
+
return t = t || this.options, t.prefix = t.prefix || this.prefix, new z(this.logger, t);
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
var P = new z();
|
|
@@ -73,99 +74,99 @@ class Q {
|
|
|
73
74
|
constructor() {
|
|
74
75
|
this.observers = {};
|
|
75
76
|
}
|
|
76
|
-
on(
|
|
77
|
-
return
|
|
78
|
-
this.observers[s] = this.observers[s] || [], this.observers[s].push(
|
|
77
|
+
on(t, e) {
|
|
78
|
+
return t.split(" ").forEach((s) => {
|
|
79
|
+
this.observers[s] = this.observers[s] || [], this.observers[s].push(e);
|
|
79
80
|
}), this;
|
|
80
81
|
}
|
|
81
|
-
off(
|
|
82
|
-
if (this.observers[
|
|
83
|
-
if (!
|
|
84
|
-
delete this.observers[
|
|
82
|
+
off(t, e) {
|
|
83
|
+
if (this.observers[t]) {
|
|
84
|
+
if (!e) {
|
|
85
|
+
delete this.observers[t];
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
|
-
this.observers[
|
|
88
|
+
this.observers[t] = this.observers[t].filter((s) => s !== e);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
emit(
|
|
91
|
-
for (var
|
|
91
|
+
emit(t) {
|
|
92
|
+
for (var e = arguments.length, s = new Array(e > 1 ? e - 1 : 0), n = 1; n < e; n++)
|
|
92
93
|
s[n - 1] = arguments[n];
|
|
93
|
-
this.observers[
|
|
94
|
+
this.observers[t] && [].concat(this.observers[t]).forEach((a) => {
|
|
94
95
|
a(...s);
|
|
95
96
|
}), this.observers["*"] && [].concat(this.observers["*"]).forEach((a) => {
|
|
96
|
-
a.apply(a, [
|
|
97
|
+
a.apply(a, [t, ...s]);
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
function U() {
|
|
101
|
-
let i,
|
|
102
|
-
const
|
|
103
|
-
i = s,
|
|
102
|
+
let i, t;
|
|
103
|
+
const e = new Promise((s, n) => {
|
|
104
|
+
i = s, t = n;
|
|
104
105
|
});
|
|
105
|
-
return
|
|
106
|
+
return e.resolve = i, e.reject = t, e;
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
+
function oe(i) {
|
|
108
109
|
return i == null ? "" : "" + i;
|
|
109
110
|
}
|
|
110
|
-
function je(i,
|
|
111
|
+
function je(i, t, e) {
|
|
111
112
|
i.forEach((s) => {
|
|
112
|
-
|
|
113
|
+
t[s] && (e[s] = t[s]);
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
|
-
function
|
|
116
|
+
function _(i, t, e) {
|
|
116
117
|
function s(a) {
|
|
117
118
|
return a && a.indexOf("###") > -1 ? a.replace(/###/g, ".") : a;
|
|
118
119
|
}
|
|
119
120
|
function n() {
|
|
120
121
|
return !i || typeof i == "string";
|
|
121
122
|
}
|
|
122
|
-
const r = typeof
|
|
123
|
+
const r = typeof t != "string" ? [].concat(t) : t.split(".");
|
|
123
124
|
for (; r.length > 1; ) {
|
|
124
125
|
if (n())
|
|
125
126
|
return {};
|
|
126
127
|
const a = s(r.shift());
|
|
127
|
-
!i[a] &&
|
|
128
|
+
!i[a] && e && (i[a] = new e()), Object.prototype.hasOwnProperty.call(i, a) ? i = i[a] : i = {};
|
|
128
129
|
}
|
|
129
130
|
return n() ? {} : {
|
|
130
131
|
obj: i,
|
|
131
132
|
k: s(r.shift())
|
|
132
133
|
};
|
|
133
134
|
}
|
|
134
|
-
function
|
|
135
|
+
function le(i, t, e) {
|
|
135
136
|
const {
|
|
136
137
|
obj: s,
|
|
137
138
|
k: n
|
|
138
|
-
} =
|
|
139
|
-
s[n] =
|
|
139
|
+
} = _(i, t, Object);
|
|
140
|
+
s[n] = e;
|
|
140
141
|
}
|
|
141
|
-
function ke(i,
|
|
142
|
+
function ke(i, t, e, s) {
|
|
142
143
|
const {
|
|
143
144
|
obj: n,
|
|
144
145
|
k: r
|
|
145
|
-
} =
|
|
146
|
-
n[r] = n[r] || [], s && (n[r] = n[r].concat(
|
|
146
|
+
} = _(i, t, Object);
|
|
147
|
+
n[r] = n[r] || [], s && (n[r] = n[r].concat(e)), s || n[r].push(e);
|
|
147
148
|
}
|
|
148
|
-
function W(i,
|
|
149
|
+
function W(i, t) {
|
|
149
150
|
const {
|
|
150
|
-
obj:
|
|
151
|
+
obj: e,
|
|
151
152
|
k: s
|
|
152
|
-
} =
|
|
153
|
-
if (
|
|
154
|
-
return
|
|
153
|
+
} = _(i, t);
|
|
154
|
+
if (e)
|
|
155
|
+
return e[s];
|
|
155
156
|
}
|
|
156
|
-
function
|
|
157
|
-
const s = W(i,
|
|
158
|
-
return s !== void 0 ? s : W(
|
|
157
|
+
function De(i, t, e) {
|
|
158
|
+
const s = W(i, e);
|
|
159
|
+
return s !== void 0 ? s : W(t, e);
|
|
159
160
|
}
|
|
160
|
-
function
|
|
161
|
-
for (const s in
|
|
162
|
-
s !== "__proto__" && s !== "constructor" && (s in i ? typeof i[s] == "string" || i[s] instanceof String || typeof
|
|
161
|
+
function be(i, t, e) {
|
|
162
|
+
for (const s in t)
|
|
163
|
+
s !== "__proto__" && s !== "constructor" && (s in i ? typeof i[s] == "string" || i[s] instanceof String || typeof t[s] == "string" || t[s] instanceof String ? e && (i[s] = t[s]) : be(i[s], t[s], e) : i[s] = t[s]);
|
|
163
164
|
return i;
|
|
164
165
|
}
|
|
165
166
|
function j(i) {
|
|
166
167
|
return i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
167
168
|
}
|
|
168
|
-
var
|
|
169
|
+
var Fe = {
|
|
169
170
|
"&": "&",
|
|
170
171
|
"<": "<",
|
|
171
172
|
">": ">",
|
|
@@ -173,50 +174,50 @@ var Ae = {
|
|
|
173
174
|
"'": "'",
|
|
174
175
|
"/": "/"
|
|
175
176
|
};
|
|
176
|
-
function
|
|
177
|
-
return typeof i == "string" ? i.replace(/[&<>"'\/]/g, (
|
|
177
|
+
function Ae(i) {
|
|
178
|
+
return typeof i == "string" ? i.replace(/[&<>"'\/]/g, (t) => Fe[t]) : i;
|
|
178
179
|
}
|
|
179
180
|
const Ie = [" ", ",", "?", "!", ";"];
|
|
180
|
-
function Ue(i,
|
|
181
|
-
|
|
182
|
-
const s = Ie.filter((a) =>
|
|
181
|
+
function Ue(i, t, e) {
|
|
182
|
+
t = t || "", e = e || "";
|
|
183
|
+
const s = Ie.filter((a) => t.indexOf(a) < 0 && e.indexOf(a) < 0);
|
|
183
184
|
if (s.length === 0)
|
|
184
185
|
return !0;
|
|
185
186
|
const n = new RegExp(`(${s.map((a) => a === "?" ? "\\?" : a).join("|")})`);
|
|
186
187
|
let r = !n.test(i);
|
|
187
188
|
if (!r) {
|
|
188
|
-
const a = i.indexOf(
|
|
189
|
+
const a = i.indexOf(e);
|
|
189
190
|
a > 0 && !n.test(i.substring(0, a)) && (r = !0);
|
|
190
191
|
}
|
|
191
192
|
return r;
|
|
192
193
|
}
|
|
193
|
-
function Y(i,
|
|
194
|
-
let
|
|
194
|
+
function Y(i, t) {
|
|
195
|
+
let e = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
|
|
195
196
|
if (!i)
|
|
196
197
|
return;
|
|
197
|
-
if (i[
|
|
198
|
-
return i[
|
|
199
|
-
const s =
|
|
198
|
+
if (i[t])
|
|
199
|
+
return i[t];
|
|
200
|
+
const s = t.split(e);
|
|
200
201
|
let n = i;
|
|
201
202
|
for (let r = 0; r < s.length; ++r) {
|
|
202
203
|
if (!n || typeof n[s[r]] == "string" && r + 1 < s.length)
|
|
203
204
|
return;
|
|
204
205
|
if (n[s[r]] === void 0) {
|
|
205
|
-
let a = 2, l = s.slice(r, r + a).join(
|
|
206
|
+
let a = 2, l = s.slice(r, r + a).join(e), o = n[l];
|
|
206
207
|
for (; o === void 0 && s.length > r + a; )
|
|
207
|
-
a++, l = s.slice(r, r + a).join(
|
|
208
|
+
a++, l = s.slice(r, r + a).join(e), o = n[l];
|
|
208
209
|
if (o === void 0)
|
|
209
210
|
return;
|
|
210
211
|
if (o === null)
|
|
211
212
|
return null;
|
|
212
|
-
if (
|
|
213
|
+
if (t.endsWith(l)) {
|
|
213
214
|
if (typeof o == "string")
|
|
214
215
|
return o;
|
|
215
216
|
if (l && typeof o[l] == "string")
|
|
216
217
|
return o[l];
|
|
217
218
|
}
|
|
218
|
-
const f = s.slice(r + a).join(
|
|
219
|
-
return f ? Y(o, f,
|
|
219
|
+
const f = s.slice(r + a).join(e);
|
|
220
|
+
return f ? Y(o, f, e) : void 0;
|
|
220
221
|
}
|
|
221
222
|
n = n[s[r]];
|
|
222
223
|
}
|
|
@@ -225,75 +226,75 @@ function Y(i, e) {
|
|
|
225
226
|
function G(i) {
|
|
226
227
|
return i && i.indexOf("_") > 0 ? i.replace("_", "-") : i;
|
|
227
228
|
}
|
|
228
|
-
class
|
|
229
|
-
constructor(
|
|
230
|
-
let
|
|
229
|
+
class ue extends Q {
|
|
230
|
+
constructor(t) {
|
|
231
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
231
232
|
ns: ["translation"],
|
|
232
233
|
defaultNS: "translation"
|
|
233
234
|
};
|
|
234
|
-
super(), this.data =
|
|
235
|
+
super(), this.data = t || {}, this.options = e, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
|
|
235
236
|
}
|
|
236
|
-
addNamespaces(
|
|
237
|
-
this.options.ns.indexOf(
|
|
237
|
+
addNamespaces(t) {
|
|
238
|
+
this.options.ns.indexOf(t) < 0 && this.options.ns.push(t);
|
|
238
239
|
}
|
|
239
|
-
removeNamespaces(
|
|
240
|
-
const
|
|
241
|
-
|
|
240
|
+
removeNamespaces(t) {
|
|
241
|
+
const e = this.options.ns.indexOf(t);
|
|
242
|
+
e > -1 && this.options.ns.splice(e, 1);
|
|
242
243
|
}
|
|
243
|
-
getResource(
|
|
244
|
+
getResource(t, e, s) {
|
|
244
245
|
let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
245
246
|
const r = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator, a = n.ignoreJSONStructure !== void 0 ? n.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
246
|
-
let l = [
|
|
247
|
-
s && typeof s != "string" && (l = l.concat(s)), s && typeof s == "string" && (l = l.concat(r ? s.split(r) : s)),
|
|
247
|
+
let l = [t, e];
|
|
248
|
+
s && typeof s != "string" && (l = l.concat(s)), s && typeof s == "string" && (l = l.concat(r ? s.split(r) : s)), t.indexOf(".") > -1 && (l = t.split("."));
|
|
248
249
|
const o = W(this.data, l);
|
|
249
|
-
return o || !a || typeof s != "string" ? o : Y(this.data && this.data[
|
|
250
|
+
return o || !a || typeof s != "string" ? o : Y(this.data && this.data[t] && this.data[t][e], s, r);
|
|
250
251
|
}
|
|
251
|
-
addResource(
|
|
252
|
+
addResource(t, e, s, n) {
|
|
252
253
|
let r = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
|
|
253
254
|
silent: !1
|
|
254
255
|
};
|
|
255
256
|
const a = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator;
|
|
256
|
-
let l = [
|
|
257
|
-
s && (l = l.concat(a ? s.split(a) : s)),
|
|
257
|
+
let l = [t, e];
|
|
258
|
+
s && (l = l.concat(a ? s.split(a) : s)), t.indexOf(".") > -1 && (l = t.split("."), n = e, e = l[1]), this.addNamespaces(e), le(this.data, l, n), r.silent || this.emit("added", t, e, s, n);
|
|
258
259
|
}
|
|
259
|
-
addResources(
|
|
260
|
+
addResources(t, e, s) {
|
|
260
261
|
let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
|
|
261
262
|
silent: !1
|
|
262
263
|
};
|
|
263
264
|
for (const r in s)
|
|
264
|
-
(typeof s[r] == "string" || Object.prototype.toString.apply(s[r]) === "[object Array]") && this.addResource(
|
|
265
|
+
(typeof s[r] == "string" || Object.prototype.toString.apply(s[r]) === "[object Array]") && this.addResource(t, e, r, s[r], {
|
|
265
266
|
silent: !0
|
|
266
267
|
});
|
|
267
|
-
n.silent || this.emit("added",
|
|
268
|
+
n.silent || this.emit("added", t, e, s);
|
|
268
269
|
}
|
|
269
|
-
addResourceBundle(
|
|
270
|
+
addResourceBundle(t, e, s, n, r) {
|
|
270
271
|
let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
|
|
271
272
|
silent: !1
|
|
272
|
-
}, l = [
|
|
273
|
-
|
|
273
|
+
}, l = [t, e];
|
|
274
|
+
t.indexOf(".") > -1 && (l = t.split("."), n = s, s = e, e = l[1]), this.addNamespaces(e);
|
|
274
275
|
let o = W(this.data, l) || {};
|
|
275
|
-
n ?
|
|
276
|
+
n ? be(o, s, r) : o = {
|
|
276
277
|
...o,
|
|
277
278
|
...s
|
|
278
|
-
},
|
|
279
|
+
}, le(this.data, l, o), a.silent || this.emit("added", t, e, s);
|
|
279
280
|
}
|
|
280
|
-
removeResourceBundle(
|
|
281
|
-
this.hasResourceBundle(
|
|
281
|
+
removeResourceBundle(t, e) {
|
|
282
|
+
this.hasResourceBundle(t, e) && delete this.data[t][e], this.removeNamespaces(e), this.emit("removed", t, e);
|
|
282
283
|
}
|
|
283
|
-
hasResourceBundle(
|
|
284
|
-
return this.getResource(
|
|
284
|
+
hasResourceBundle(t, e) {
|
|
285
|
+
return this.getResource(t, e) !== void 0;
|
|
285
286
|
}
|
|
286
|
-
getResourceBundle(
|
|
287
|
-
return
|
|
288
|
-
...this.getResource(
|
|
289
|
-
} : this.getResource(
|
|
287
|
+
getResourceBundle(t, e) {
|
|
288
|
+
return e || (e = this.options.defaultNS), this.options.compatibilityAPI === "v1" ? {
|
|
289
|
+
...this.getResource(t, e)
|
|
290
|
+
} : this.getResource(t, e);
|
|
290
291
|
}
|
|
291
|
-
getDataByLanguage(
|
|
292
|
-
return this.data[
|
|
292
|
+
getDataByLanguage(t) {
|
|
293
|
+
return this.data[t];
|
|
293
294
|
}
|
|
294
|
-
hasLanguageSomeTranslations(
|
|
295
|
-
const
|
|
296
|
-
return !!(
|
|
295
|
+
hasLanguageSomeTranslations(t) {
|
|
296
|
+
const e = this.getDataByLanguage(t);
|
|
297
|
+
return !!(e && Object.keys(e) || []).find((n) => e[n] && Object.keys(e[n]).length > 0);
|
|
297
298
|
}
|
|
298
299
|
toJSON() {
|
|
299
300
|
return this.data;
|
|
@@ -304,71 +305,71 @@ var Se = {
|
|
|
304
305
|
addPostProcessor(i) {
|
|
305
306
|
this.processors[i.name] = i;
|
|
306
307
|
},
|
|
307
|
-
handle(i,
|
|
308
|
+
handle(i, t, e, s, n) {
|
|
308
309
|
return i.forEach((r) => {
|
|
309
|
-
this.processors[r] && (
|
|
310
|
-
}),
|
|
310
|
+
this.processors[r] && (t = this.processors[r].process(t, e, s, n));
|
|
311
|
+
}), t;
|
|
311
312
|
}
|
|
312
313
|
};
|
|
313
|
-
const
|
|
314
|
+
const fe = {};
|
|
314
315
|
class Z extends Q {
|
|
315
|
-
constructor(
|
|
316
|
-
let
|
|
317
|
-
super(), je(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"],
|
|
316
|
+
constructor(t) {
|
|
317
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
318
|
+
super(), je(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], t, this), this.options = e, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = P.create("translator");
|
|
318
319
|
}
|
|
319
|
-
changeLanguage(
|
|
320
|
-
|
|
320
|
+
changeLanguage(t) {
|
|
321
|
+
t && (this.language = t);
|
|
321
322
|
}
|
|
322
|
-
exists(
|
|
323
|
-
let
|
|
323
|
+
exists(t) {
|
|
324
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
324
325
|
interpolation: {}
|
|
325
326
|
};
|
|
326
|
-
if (
|
|
327
|
+
if (t == null)
|
|
327
328
|
return !1;
|
|
328
|
-
const s = this.resolve(
|
|
329
|
+
const s = this.resolve(t, e);
|
|
329
330
|
return s && s.res !== void 0;
|
|
330
331
|
}
|
|
331
|
-
extractFromKey(
|
|
332
|
-
let s =
|
|
332
|
+
extractFromKey(t, e) {
|
|
333
|
+
let s = e.nsSeparator !== void 0 ? e.nsSeparator : this.options.nsSeparator;
|
|
333
334
|
s === void 0 && (s = ":");
|
|
334
|
-
const n =
|
|
335
|
-
let r =
|
|
336
|
-
const a = s &&
|
|
335
|
+
const n = e.keySeparator !== void 0 ? e.keySeparator : this.options.keySeparator;
|
|
336
|
+
let r = e.ns || this.options.defaultNS || [];
|
|
337
|
+
const a = s && t.indexOf(s) > -1, l = !this.options.userDefinedKeySeparator && !e.keySeparator && !this.options.userDefinedNsSeparator && !e.nsSeparator && !Ue(t, s, n);
|
|
337
338
|
if (a && !l) {
|
|
338
|
-
const o =
|
|
339
|
+
const o = t.match(this.interpolator.nestingRegexp);
|
|
339
340
|
if (o && o.length > 0)
|
|
340
341
|
return {
|
|
341
|
-
key:
|
|
342
|
+
key: t,
|
|
342
343
|
namespaces: r
|
|
343
344
|
};
|
|
344
|
-
const f =
|
|
345
|
-
(s !== n || s === n && this.options.ns.indexOf(f[0]) > -1) && (r = f.shift()),
|
|
345
|
+
const f = t.split(s);
|
|
346
|
+
(s !== n || s === n && this.options.ns.indexOf(f[0]) > -1) && (r = f.shift()), t = f.join(n);
|
|
346
347
|
}
|
|
347
348
|
return typeof r == "string" && (r = [r]), {
|
|
348
|
-
key:
|
|
349
|
+
key: t,
|
|
349
350
|
namespaces: r
|
|
350
351
|
};
|
|
351
352
|
}
|
|
352
|
-
translate(
|
|
353
|
-
if (typeof
|
|
354
|
-
...
|
|
355
|
-
}),
|
|
353
|
+
translate(t, e, s) {
|
|
354
|
+
if (typeof e != "object" && this.options.overloadTranslationOptionHandler && (e = this.options.overloadTranslationOptionHandler(arguments)), typeof e == "object" && (e = {
|
|
355
|
+
...e
|
|
356
|
+
}), e || (e = {}), t == null)
|
|
356
357
|
return "";
|
|
357
|
-
Array.isArray(
|
|
358
|
-
const n =
|
|
358
|
+
Array.isArray(t) || (t = [String(t)]);
|
|
359
|
+
const n = e.returnDetails !== void 0 ? e.returnDetails : this.options.returnDetails, r = e.keySeparator !== void 0 ? e.keySeparator : this.options.keySeparator, {
|
|
359
360
|
key: a,
|
|
360
361
|
namespaces: l
|
|
361
|
-
} = this.extractFromKey(
|
|
362
|
+
} = this.extractFromKey(t[t.length - 1], e), o = l[l.length - 1], f = e.lng || this.language, g = e.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
362
363
|
if (f && f.toLowerCase() === "cimode") {
|
|
363
364
|
if (g) {
|
|
364
|
-
const y =
|
|
365
|
+
const y = e.nsSeparator || this.options.nsSeparator;
|
|
365
366
|
return n ? {
|
|
366
367
|
res: `${o}${y}${a}`,
|
|
367
368
|
usedKey: a,
|
|
368
369
|
exactUsedKey: a,
|
|
369
370
|
usedLng: f,
|
|
370
371
|
usedNS: o,
|
|
371
|
-
usedParams: this.getUsedParamsDetails(
|
|
372
|
+
usedParams: this.getUsedParamsDetails(e)
|
|
372
373
|
} : `${o}${y}${a}`;
|
|
373
374
|
}
|
|
374
375
|
return n ? {
|
|
@@ -377,77 +378,77 @@ class Z extends Q {
|
|
|
377
378
|
exactUsedKey: a,
|
|
378
379
|
usedLng: f,
|
|
379
380
|
usedNS: o,
|
|
380
|
-
usedParams: this.getUsedParamsDetails(
|
|
381
|
+
usedParams: this.getUsedParamsDetails(e)
|
|
381
382
|
} : a;
|
|
382
383
|
}
|
|
383
|
-
const h = this.resolve(
|
|
384
|
+
const h = this.resolve(t, e);
|
|
384
385
|
let u = h && h.res;
|
|
385
|
-
const d = h && h.usedKey || a, c = h && h.exactUsedKey || a, p = Object.prototype.toString.apply(u), m = ["[object Number]", "[object Function]", "[object RegExp]"],
|
|
386
|
-
if (
|
|
387
|
-
if (!
|
|
386
|
+
const d = h && h.usedKey || a, c = h && h.exactUsedKey || a, p = Object.prototype.toString.apply(u), m = ["[object Number]", "[object Function]", "[object RegExp]"], O = e.joinArrays !== void 0 ? e.joinArrays : this.options.joinArrays, b = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
387
|
+
if (b && u && (typeof u != "string" && typeof u != "boolean" && typeof u != "number") && m.indexOf(p) < 0 && !(typeof O == "string" && p === "[object Array]")) {
|
|
388
|
+
if (!e.returnObjects && !this.options.returnObjects) {
|
|
388
389
|
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
389
390
|
const y = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(d, u, {
|
|
390
|
-
...
|
|
391
|
+
...e,
|
|
391
392
|
ns: l
|
|
392
393
|
}) : `key '${a} (${this.language})' returned an object instead of string.`;
|
|
393
|
-
return n ? (h.res = y, h.usedParams = this.getUsedParamsDetails(
|
|
394
|
+
return n ? (h.res = y, h.usedParams = this.getUsedParamsDetails(e), h) : y;
|
|
394
395
|
}
|
|
395
396
|
if (r) {
|
|
396
|
-
const y = p === "[object Array]",
|
|
397
|
+
const y = p === "[object Array]", L = y ? [] : {}, w = y ? c : d;
|
|
397
398
|
for (const S in u)
|
|
398
399
|
if (Object.prototype.hasOwnProperty.call(u, S)) {
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
...
|
|
400
|
+
const V = `${w}${r}${S}`;
|
|
401
|
+
L[S] = this.translate(V, {
|
|
402
|
+
...e,
|
|
402
403
|
joinArrays: !1,
|
|
403
404
|
ns: l
|
|
404
|
-
}),
|
|
405
|
+
}), L[S] === V && (L[S] = u[S]);
|
|
405
406
|
}
|
|
406
|
-
u =
|
|
407
|
+
u = L;
|
|
407
408
|
}
|
|
408
|
-
} else if (
|
|
409
|
-
u = u.join(
|
|
409
|
+
} else if (b && typeof O == "string" && p === "[object Array]")
|
|
410
|
+
u = u.join(O), u && (u = this.extendTranslation(u, t, e, s));
|
|
410
411
|
else {
|
|
411
|
-
let y = !1,
|
|
412
|
-
const
|
|
412
|
+
let y = !1, L = !1;
|
|
413
|
+
const w = e.count !== void 0 && typeof e.count != "string", S = Z.hasDefaultValue(e), V = w ? this.pluralResolver.getSuffix(f, e.count, e) : "", Oe = e.ordinal && w ? this.pluralResolver.getSuffix(f, e.count, {
|
|
413
414
|
ordinal: !1
|
|
414
|
-
}) : "",
|
|
415
|
-
!this.isValidLookup(u) && S && (y = !0, u =
|
|
416
|
-
const
|
|
417
|
-
if (
|
|
418
|
-
if (this.logger.log(
|
|
415
|
+
}) : "", te = w && !e.ordinal && e.count === 0 && this.pluralResolver.shouldUseIntlApi(), D = te && e[`defaultValue${this.options.pluralSeparator}zero`] || e[`defaultValue${V}`] || e[`defaultValue${Oe}`] || e.defaultValue;
|
|
416
|
+
!this.isValidLookup(u) && S && (y = !0, u = D), this.isValidLookup(u) || (L = !0, u = a);
|
|
417
|
+
const Le = (e.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && L ? void 0 : u, F = S && D !== u && this.options.updateMissing;
|
|
418
|
+
if (L || y || F) {
|
|
419
|
+
if (this.logger.log(F ? "updateKey" : "missingKey", f, o, a, F ? D : u), r) {
|
|
419
420
|
const v = this.resolve(a, {
|
|
420
|
-
...
|
|
421
|
+
...e,
|
|
421
422
|
keySeparator: !1
|
|
422
423
|
});
|
|
423
424
|
v && v.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
|
|
424
425
|
}
|
|
425
|
-
let
|
|
426
|
-
const
|
|
427
|
-
if (this.options.saveMissingTo === "fallback" &&
|
|
428
|
-
for (let v = 0; v <
|
|
429
|
-
|
|
426
|
+
let A = [];
|
|
427
|
+
const K = this.languageUtils.getFallbackCodes(this.options.fallbackLng, e.lng || this.language);
|
|
428
|
+
if (this.options.saveMissingTo === "fallback" && K && K[0])
|
|
429
|
+
for (let v = 0; v < K.length; v++)
|
|
430
|
+
A.push(K[v]);
|
|
430
431
|
else
|
|
431
|
-
this.options.saveMissingTo === "all" ?
|
|
432
|
-
const
|
|
433
|
-
const
|
|
434
|
-
this.options.missingKeyHandler ? this.options.missingKeyHandler(v, o,
|
|
432
|
+
this.options.saveMissingTo === "all" ? A = this.languageUtils.toResolveHierarchy(e.lng || this.language) : A.push(e.lng || this.language);
|
|
433
|
+
const se = (v, C, I) => {
|
|
434
|
+
const ne = S && I !== u ? I : Le;
|
|
435
|
+
this.options.missingKeyHandler ? this.options.missingKeyHandler(v, o, C, ne, F, e) : this.backendConnector && this.backendConnector.saveMissing && this.backendConnector.saveMissing(v, o, C, ne, F, e), this.emit("missingKey", v, o, C, u);
|
|
435
436
|
};
|
|
436
|
-
this.options.saveMissing && (this.options.saveMissingPlurals &&
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
437
|
+
this.options.saveMissing && (this.options.saveMissingPlurals && w ? A.forEach((v) => {
|
|
438
|
+
const C = this.pluralResolver.getSuffixes(v, e);
|
|
439
|
+
te && e[`defaultValue${this.options.pluralSeparator}zero`] && C.indexOf(`${this.options.pluralSeparator}zero`) < 0 && C.push(`${this.options.pluralSeparator}zero`), C.forEach((I) => {
|
|
440
|
+
se([v], a + I, e[`defaultValue${I}`] || D);
|
|
440
441
|
});
|
|
441
|
-
}) :
|
|
442
|
+
}) : se(A, a, D));
|
|
442
443
|
}
|
|
443
|
-
u = this.extendTranslation(u,
|
|
444
|
+
u = this.extendTranslation(u, t, e, h, s), L && u === a && this.options.appendNamespaceToMissingKey && (u = `${o}:${a}`), (L || y) && this.options.parseMissingKeyHandler && (this.options.compatibilityAPI !== "v1" ? u = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${o}:${a}` : a, y ? u : void 0) : u = this.options.parseMissingKeyHandler(u));
|
|
444
445
|
}
|
|
445
|
-
return n ? (h.res = u, h.usedParams = this.getUsedParamsDetails(
|
|
446
|
+
return n ? (h.res = u, h.usedParams = this.getUsedParamsDetails(e), h) : u;
|
|
446
447
|
}
|
|
447
|
-
extendTranslation(
|
|
448
|
+
extendTranslation(t, e, s, n, r) {
|
|
448
449
|
var a = this;
|
|
449
450
|
if (this.i18nFormat && this.i18nFormat.parse)
|
|
450
|
-
|
|
451
|
+
t = this.i18nFormat.parse(t, {
|
|
451
452
|
...this.options.interpolation.defaultVariables,
|
|
452
453
|
...s
|
|
453
454
|
}, s.lng || this.language || n.usedLng, n.usedNS, n.usedKey, {
|
|
@@ -461,65 +462,65 @@ class Z extends Q {
|
|
|
461
462
|
...s.interpolation
|
|
462
463
|
}
|
|
463
464
|
});
|
|
464
|
-
const f = typeof
|
|
465
|
+
const f = typeof t == "string" && (s && s.interpolation && s.interpolation.skipOnVariables !== void 0 ? s.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
465
466
|
let g;
|
|
466
467
|
if (f) {
|
|
467
|
-
const u =
|
|
468
|
+
const u = t.match(this.interpolator.nestingRegexp);
|
|
468
469
|
g = u && u.length;
|
|
469
470
|
}
|
|
470
471
|
let h = s.replace && typeof s.replace != "string" ? s.replace : s;
|
|
471
472
|
if (this.options.interpolation.defaultVariables && (h = {
|
|
472
473
|
...this.options.interpolation.defaultVariables,
|
|
473
474
|
...h
|
|
474
|
-
}),
|
|
475
|
-
const u =
|
|
475
|
+
}), t = this.interpolator.interpolate(t, h, s.lng || this.language, s), f) {
|
|
476
|
+
const u = t.match(this.interpolator.nestingRegexp), d = u && u.length;
|
|
476
477
|
g < d && (s.nest = !1);
|
|
477
478
|
}
|
|
478
|
-
!s.lng && this.options.compatibilityAPI !== "v1" && n && n.res && (s.lng = n.usedLng), s.nest !== !1 && (
|
|
479
|
+
!s.lng && this.options.compatibilityAPI !== "v1" && n && n.res && (s.lng = n.usedLng), s.nest !== !1 && (t = this.interpolator.nest(t, function() {
|
|
479
480
|
for (var u = arguments.length, d = new Array(u), c = 0; c < u; c++)
|
|
480
481
|
d[c] = arguments[c];
|
|
481
|
-
return r && r[0] === d[0] && !s.context ? (a.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${
|
|
482
|
+
return r && r[0] === d[0] && !s.context ? (a.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${e[0]}`), null) : a.translate(...d, e);
|
|
482
483
|
}, s)), s.interpolation && this.interpolator.reset();
|
|
483
484
|
}
|
|
484
485
|
const l = s.postProcess || this.options.postProcess, o = typeof l == "string" ? [l] : l;
|
|
485
|
-
return
|
|
486
|
+
return t != null && o && o.length && s.applyPostProcessor !== !1 && (t = Se.handle(o, t, e, this.options && this.options.postProcessPassResolved ? {
|
|
486
487
|
i18nResolved: {
|
|
487
488
|
...n,
|
|
488
489
|
usedParams: this.getUsedParamsDetails(s)
|
|
489
490
|
},
|
|
490
491
|
...s
|
|
491
|
-
} : s, this)),
|
|
492
|
+
} : s, this)), t;
|
|
492
493
|
}
|
|
493
|
-
resolve(
|
|
494
|
-
let
|
|
495
|
-
return typeof
|
|
494
|
+
resolve(t) {
|
|
495
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s, n, r, a, l;
|
|
496
|
+
return typeof t == "string" && (t = [t]), t.forEach((o) => {
|
|
496
497
|
if (this.isValidLookup(s))
|
|
497
498
|
return;
|
|
498
|
-
const f = this.extractFromKey(o,
|
|
499
|
+
const f = this.extractFromKey(o, e), g = f.key;
|
|
499
500
|
n = g;
|
|
500
501
|
let h = f.namespaces;
|
|
501
502
|
this.options.fallbackNS && (h = h.concat(this.options.fallbackNS));
|
|
502
|
-
const u =
|
|
503
|
+
const u = e.count !== void 0 && typeof e.count != "string", d = u && !e.ordinal && e.count === 0 && this.pluralResolver.shouldUseIntlApi(), c = e.context !== void 0 && (typeof e.context == "string" || typeof e.context == "number") && e.context !== "", p = e.lngs ? e.lngs : this.languageUtils.toResolveHierarchy(e.lng || this.language, e.fallbackLng);
|
|
503
504
|
h.forEach((m) => {
|
|
504
|
-
this.isValidLookup(s) || (l = m, !
|
|
505
|
+
this.isValidLookup(s) || (l = m, !fe[`${p[0]}-${m}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(l) && (fe[`${p[0]}-${m}`] = !0, this.logger.warn(`key "${n}" for languages "${p.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), p.forEach((O) => {
|
|
505
506
|
if (this.isValidLookup(s))
|
|
506
507
|
return;
|
|
507
|
-
a =
|
|
508
|
-
const
|
|
508
|
+
a = O;
|
|
509
|
+
const b = [g];
|
|
509
510
|
if (this.i18nFormat && this.i18nFormat.addLookupKeys)
|
|
510
|
-
this.i18nFormat.addLookupKeys(
|
|
511
|
+
this.i18nFormat.addLookupKeys(b, g, O, m, e);
|
|
511
512
|
else {
|
|
512
513
|
let y;
|
|
513
|
-
u && (y = this.pluralResolver.getSuffix(
|
|
514
|
-
const
|
|
515
|
-
if (u && (
|
|
516
|
-
const S = `${g}${this.options.contextSeparator}${
|
|
517
|
-
|
|
514
|
+
u && (y = this.pluralResolver.getSuffix(O, e.count, e));
|
|
515
|
+
const L = `${this.options.pluralSeparator}zero`, w = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
516
|
+
if (u && (b.push(g + y), e.ordinal && y.indexOf(w) === 0 && b.push(g + y.replace(w, this.options.pluralSeparator)), d && b.push(g + L)), c) {
|
|
517
|
+
const S = `${g}${this.options.contextSeparator}${e.context}`;
|
|
518
|
+
b.push(S), u && (b.push(S + y), e.ordinal && y.indexOf(w) === 0 && b.push(S + y.replace(w, this.options.pluralSeparator)), d && b.push(S + L));
|
|
518
519
|
}
|
|
519
520
|
}
|
|
520
|
-
let
|
|
521
|
-
for (;
|
|
522
|
-
this.isValidLookup(s) || (r =
|
|
521
|
+
let B;
|
|
522
|
+
for (; B = b.pop(); )
|
|
523
|
+
this.isValidLookup(s) || (r = B, s = this.getResource(O, m, B, e));
|
|
523
524
|
}));
|
|
524
525
|
});
|
|
525
526
|
}), {
|
|
@@ -530,33 +531,33 @@ class Z extends Q {
|
|
|
530
531
|
usedNS: l
|
|
531
532
|
};
|
|
532
533
|
}
|
|
533
|
-
isValidLookup(
|
|
534
|
-
return
|
|
534
|
+
isValidLookup(t) {
|
|
535
|
+
return t !== void 0 && !(!this.options.returnNull && t === null) && !(!this.options.returnEmptyString && t === "");
|
|
535
536
|
}
|
|
536
|
-
getResource(
|
|
537
|
+
getResource(t, e, s) {
|
|
537
538
|
let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
538
|
-
return this.i18nFormat && this.i18nFormat.getResource ? this.i18nFormat.getResource(
|
|
539
|
+
return this.i18nFormat && this.i18nFormat.getResource ? this.i18nFormat.getResource(t, e, s, n) : this.resourceStore.getResource(t, e, s, n);
|
|
539
540
|
}
|
|
540
541
|
getUsedParamsDetails() {
|
|
541
|
-
let
|
|
542
|
-
const
|
|
543
|
-
let n = s ?
|
|
544
|
-
if (s && typeof
|
|
542
|
+
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
543
|
+
const e = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], s = t.replace && typeof t.replace != "string";
|
|
544
|
+
let n = s ? t.replace : t;
|
|
545
|
+
if (s && typeof t.count < "u" && (n.count = t.count), this.options.interpolation.defaultVariables && (n = {
|
|
545
546
|
...this.options.interpolation.defaultVariables,
|
|
546
547
|
...n
|
|
547
548
|
}), !s) {
|
|
548
549
|
n = {
|
|
549
550
|
...n
|
|
550
551
|
};
|
|
551
|
-
for (const r of
|
|
552
|
+
for (const r of e)
|
|
552
553
|
delete n[r];
|
|
553
554
|
}
|
|
554
555
|
return n;
|
|
555
556
|
}
|
|
556
|
-
static hasDefaultValue(
|
|
557
|
-
const
|
|
558
|
-
for (const s in
|
|
559
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
557
|
+
static hasDefaultValue(t) {
|
|
558
|
+
const e = "defaultValue";
|
|
559
|
+
for (const s in t)
|
|
560
|
+
if (Object.prototype.hasOwnProperty.call(t, s) && e === s.substring(0, e.length) && t[s] !== void 0)
|
|
560
561
|
return !0;
|
|
561
562
|
return !1;
|
|
562
563
|
}
|
|
@@ -564,71 +565,71 @@ class Z extends Q {
|
|
|
564
565
|
function X(i) {
|
|
565
566
|
return i.charAt(0).toUpperCase() + i.slice(1);
|
|
566
567
|
}
|
|
567
|
-
class
|
|
568
|
-
constructor(
|
|
569
|
-
this.options =
|
|
568
|
+
class ge {
|
|
569
|
+
constructor(t) {
|
|
570
|
+
this.options = t, this.supportedLngs = this.options.supportedLngs || !1, this.logger = P.create("languageUtils");
|
|
570
571
|
}
|
|
571
|
-
getScriptPartFromCode(
|
|
572
|
-
if (
|
|
572
|
+
getScriptPartFromCode(t) {
|
|
573
|
+
if (t = G(t), !t || t.indexOf("-") < 0)
|
|
573
574
|
return null;
|
|
574
|
-
const
|
|
575
|
-
return
|
|
575
|
+
const e = t.split("-");
|
|
576
|
+
return e.length === 2 || (e.pop(), e[e.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(e.join("-"));
|
|
576
577
|
}
|
|
577
|
-
getLanguagePartFromCode(
|
|
578
|
-
if (
|
|
579
|
-
return
|
|
580
|
-
const
|
|
581
|
-
return this.formatLanguageCode(
|
|
582
|
-
}
|
|
583
|
-
formatLanguageCode(
|
|
584
|
-
if (typeof
|
|
585
|
-
const
|
|
586
|
-
let s =
|
|
587
|
-
return this.options.lowerCaseLng ? s = s.map((n) => n.toLowerCase()) : s.length === 2 ? (s[0] = s[0].toLowerCase(), s[1] = s[1].toUpperCase(),
|
|
578
|
+
getLanguagePartFromCode(t) {
|
|
579
|
+
if (t = G(t), !t || t.indexOf("-") < 0)
|
|
580
|
+
return t;
|
|
581
|
+
const e = t.split("-");
|
|
582
|
+
return this.formatLanguageCode(e[0]);
|
|
583
|
+
}
|
|
584
|
+
formatLanguageCode(t) {
|
|
585
|
+
if (typeof t == "string" && t.indexOf("-") > -1) {
|
|
586
|
+
const e = ["hans", "hant", "latn", "cyrl", "cans", "mong", "arab"];
|
|
587
|
+
let s = t.split("-");
|
|
588
|
+
return this.options.lowerCaseLng ? s = s.map((n) => n.toLowerCase()) : s.length === 2 ? (s[0] = s[0].toLowerCase(), s[1] = s[1].toUpperCase(), e.indexOf(s[1].toLowerCase()) > -1 && (s[1] = X(s[1].toLowerCase()))) : s.length === 3 && (s[0] = s[0].toLowerCase(), s[1].length === 2 && (s[1] = s[1].toUpperCase()), s[0] !== "sgn" && s[2].length === 2 && (s[2] = s[2].toUpperCase()), e.indexOf(s[1].toLowerCase()) > -1 && (s[1] = X(s[1].toLowerCase())), e.indexOf(s[2].toLowerCase()) > -1 && (s[2] = X(s[2].toLowerCase()))), s.join("-");
|
|
588
589
|
}
|
|
589
|
-
return this.options.cleanCode || this.options.lowerCaseLng ?
|
|
590
|
+
return this.options.cleanCode || this.options.lowerCaseLng ? t.toLowerCase() : t;
|
|
590
591
|
}
|
|
591
|
-
isSupportedCode(
|
|
592
|
-
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (
|
|
592
|
+
isSupportedCode(t) {
|
|
593
|
+
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (t = this.getLanguagePartFromCode(t)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(t) > -1;
|
|
593
594
|
}
|
|
594
|
-
getBestMatchFromCodes(
|
|
595
|
-
if (!
|
|
595
|
+
getBestMatchFromCodes(t) {
|
|
596
|
+
if (!t)
|
|
596
597
|
return null;
|
|
597
|
-
let
|
|
598
|
-
return
|
|
599
|
-
if (
|
|
598
|
+
let e;
|
|
599
|
+
return t.forEach((s) => {
|
|
600
|
+
if (e)
|
|
600
601
|
return;
|
|
601
602
|
const n = this.formatLanguageCode(s);
|
|
602
|
-
(!this.options.supportedLngs || this.isSupportedCode(n)) && (
|
|
603
|
-
}), !
|
|
604
|
-
if (
|
|
603
|
+
(!this.options.supportedLngs || this.isSupportedCode(n)) && (e = n);
|
|
604
|
+
}), !e && this.options.supportedLngs && t.forEach((s) => {
|
|
605
|
+
if (e)
|
|
605
606
|
return;
|
|
606
607
|
const n = this.getLanguagePartFromCode(s);
|
|
607
608
|
if (this.isSupportedCode(n))
|
|
608
|
-
return
|
|
609
|
-
|
|
609
|
+
return e = n;
|
|
610
|
+
e = this.options.supportedLngs.find((r) => {
|
|
610
611
|
if (r === n)
|
|
611
612
|
return r;
|
|
612
613
|
if (!(r.indexOf("-") < 0 && n.indexOf("-") < 0) && r.indexOf(n) === 0)
|
|
613
614
|
return r;
|
|
614
615
|
});
|
|
615
|
-
}),
|
|
616
|
+
}), e || (e = this.getFallbackCodes(this.options.fallbackLng)[0]), e;
|
|
616
617
|
}
|
|
617
|
-
getFallbackCodes(
|
|
618
|
-
if (!e)
|
|
619
|
-
return [];
|
|
620
|
-
if (typeof e == "function" && (e = e(t)), typeof e == "string" && (e = [e]), Object.prototype.toString.apply(e) === "[object Array]")
|
|
621
|
-
return e;
|
|
618
|
+
getFallbackCodes(t, e) {
|
|
622
619
|
if (!t)
|
|
623
|
-
return
|
|
624
|
-
|
|
625
|
-
|
|
620
|
+
return [];
|
|
621
|
+
if (typeof t == "function" && (t = t(e)), typeof t == "string" && (t = [t]), Object.prototype.toString.apply(t) === "[object Array]")
|
|
622
|
+
return t;
|
|
623
|
+
if (!e)
|
|
624
|
+
return t.default || [];
|
|
625
|
+
let s = t[e];
|
|
626
|
+
return s || (s = t[this.getScriptPartFromCode(e)]), s || (s = t[this.formatLanguageCode(e)]), s || (s = t[this.getLanguagePartFromCode(e)]), s || (s = t.default), s || [];
|
|
626
627
|
}
|
|
627
|
-
toResolveHierarchy(
|
|
628
|
-
const s = this.getFallbackCodes(
|
|
628
|
+
toResolveHierarchy(t, e) {
|
|
629
|
+
const s = this.getFallbackCodes(e || this.options.fallbackLng || [], t), n = [], r = (a) => {
|
|
629
630
|
a && (this.isSupportedCode(a) ? n.push(a) : this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`));
|
|
630
631
|
};
|
|
631
|
-
return typeof
|
|
632
|
+
return typeof t == "string" && (t.indexOf("-") > -1 || t.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && r(this.formatLanguageCode(t)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && r(this.getScriptPartFromCode(t)), this.options.load !== "currentOnly" && r(this.getLanguagePartFromCode(t))) : typeof t == "string" && r(this.formatLanguageCode(t)), s.forEach((a) => {
|
|
632
633
|
n.indexOf(a) < 0 && r(this.formatLanguageCode(a));
|
|
633
634
|
}), n;
|
|
634
635
|
}
|
|
@@ -725,7 +726,7 @@ let Te = [{
|
|
|
725
726
|
lngs: ["he", "iw"],
|
|
726
727
|
nr: [1, 2, 20, 21],
|
|
727
728
|
fc: 22
|
|
728
|
-
}],
|
|
729
|
+
}], Be = {
|
|
729
730
|
1: function(i) {
|
|
730
731
|
return +(i > 1);
|
|
731
732
|
},
|
|
@@ -793,7 +794,7 @@ let Te = [{
|
|
|
793
794
|
return i == 1 ? 0 : i == 2 ? 1 : (i < 0 || i > 10) && i % 10 == 0 ? 2 : 3;
|
|
794
795
|
}
|
|
795
796
|
};
|
|
796
|
-
const
|
|
797
|
+
const Ve = ["v1", "v2", "v3"], Ke = ["v4"], he = {
|
|
797
798
|
zero: 0,
|
|
798
799
|
one: 1,
|
|
799
800
|
two: 2,
|
|
@@ -803,94 +804,94 @@ const Ke = ["v1", "v2", "v3"], Be = ["v4"], ge = {
|
|
|
803
804
|
};
|
|
804
805
|
function Me() {
|
|
805
806
|
const i = {};
|
|
806
|
-
return Te.forEach((
|
|
807
|
-
|
|
808
|
-
i[
|
|
809
|
-
numbers:
|
|
810
|
-
plurals:
|
|
807
|
+
return Te.forEach((t) => {
|
|
808
|
+
t.lngs.forEach((e) => {
|
|
809
|
+
i[e] = {
|
|
810
|
+
numbers: t.nr,
|
|
811
|
+
plurals: Be[t.fc]
|
|
811
812
|
};
|
|
812
813
|
});
|
|
813
814
|
}), i;
|
|
814
815
|
}
|
|
815
816
|
class He {
|
|
816
|
-
constructor(
|
|
817
|
-
let
|
|
818
|
-
this.languageUtils =
|
|
817
|
+
constructor(t) {
|
|
818
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
819
|
+
this.languageUtils = t, this.options = e, this.logger = P.create("pluralResolver"), (!this.options.compatibilityJSON || Ke.includes(this.options.compatibilityJSON)) && (typeof Intl > "u" || !Intl.PluralRules) && (this.options.compatibilityJSON = "v3", this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")), this.rules = Me();
|
|
819
820
|
}
|
|
820
|
-
addRule(
|
|
821
|
-
this.rules[
|
|
821
|
+
addRule(t, e) {
|
|
822
|
+
this.rules[t] = e;
|
|
822
823
|
}
|
|
823
|
-
getRule(
|
|
824
|
-
let
|
|
824
|
+
getRule(t) {
|
|
825
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
825
826
|
if (this.shouldUseIntlApi())
|
|
826
827
|
try {
|
|
827
|
-
return new Intl.PluralRules(G(
|
|
828
|
-
type:
|
|
828
|
+
return new Intl.PluralRules(G(t === "dev" ? "en" : t), {
|
|
829
|
+
type: e.ordinal ? "ordinal" : "cardinal"
|
|
829
830
|
});
|
|
830
831
|
} catch {
|
|
831
832
|
return;
|
|
832
833
|
}
|
|
833
|
-
return this.rules[
|
|
834
|
+
return this.rules[t] || this.rules[this.languageUtils.getLanguagePartFromCode(t)];
|
|
834
835
|
}
|
|
835
|
-
needsPlural(
|
|
836
|
-
let
|
|
837
|
-
const s = this.getRule(
|
|
836
|
+
needsPlural(t) {
|
|
837
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
838
|
+
const s = this.getRule(t, e);
|
|
838
839
|
return this.shouldUseIntlApi() ? s && s.resolvedOptions().pluralCategories.length > 1 : s && s.numbers.length > 1;
|
|
839
840
|
}
|
|
840
|
-
getPluralFormsOfKey(
|
|
841
|
+
getPluralFormsOfKey(t, e) {
|
|
841
842
|
let s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
842
|
-
return this.getSuffixes(
|
|
843
|
+
return this.getSuffixes(t, s).map((n) => `${e}${n}`);
|
|
843
844
|
}
|
|
844
|
-
getSuffixes(
|
|
845
|
-
let
|
|
846
|
-
const s = this.getRule(
|
|
847
|
-
return s ? this.shouldUseIntlApi() ? s.resolvedOptions().pluralCategories.sort((n, r) =>
|
|
845
|
+
getSuffixes(t) {
|
|
846
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
847
|
+
const s = this.getRule(t, e);
|
|
848
|
+
return s ? this.shouldUseIntlApi() ? s.resolvedOptions().pluralCategories.sort((n, r) => he[n] - he[r]).map((n) => `${this.options.prepend}${e.ordinal ? `ordinal${this.options.prepend}` : ""}${n}`) : s.numbers.map((n) => this.getSuffix(t, n, e)) : [];
|
|
848
849
|
}
|
|
849
|
-
getSuffix(
|
|
850
|
+
getSuffix(t, e) {
|
|
850
851
|
let s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
851
|
-
const n = this.getRule(
|
|
852
|
-
return n ? this.shouldUseIntlApi() ? `${this.options.prepend}${s.ordinal ? `ordinal${this.options.prepend}` : ""}${n.select(
|
|
852
|
+
const n = this.getRule(t, s);
|
|
853
|
+
return n ? this.shouldUseIntlApi() ? `${this.options.prepend}${s.ordinal ? `ordinal${this.options.prepend}` : ""}${n.select(e)}` : this.getSuffixRetroCompatible(n, e) : (this.logger.warn(`no plural rule found for: ${t}`), "");
|
|
853
854
|
}
|
|
854
|
-
getSuffixRetroCompatible(
|
|
855
|
-
const s =
|
|
856
|
-
let n =
|
|
857
|
-
this.options.simplifyPluralSuffix &&
|
|
855
|
+
getSuffixRetroCompatible(t, e) {
|
|
856
|
+
const s = t.noAbs ? t.plurals(e) : t.plurals(Math.abs(e));
|
|
857
|
+
let n = t.numbers[s];
|
|
858
|
+
this.options.simplifyPluralSuffix && t.numbers.length === 2 && t.numbers[0] === 1 && (n === 2 ? n = "plural" : n === 1 && (n = ""));
|
|
858
859
|
const r = () => this.options.prepend && n.toString() ? this.options.prepend + n.toString() : n.toString();
|
|
859
|
-
return this.options.compatibilityJSON === "v1" ? n === 1 ? "" : typeof n == "number" ? `_plural_${n.toString()}` : r() : this.options.compatibilityJSON === "v2" || this.options.simplifyPluralSuffix &&
|
|
860
|
+
return this.options.compatibilityJSON === "v1" ? n === 1 ? "" : typeof n == "number" ? `_plural_${n.toString()}` : r() : this.options.compatibilityJSON === "v2" || this.options.simplifyPluralSuffix && t.numbers.length === 2 && t.numbers[0] === 1 ? r() : this.options.prepend && s.toString() ? this.options.prepend + s.toString() : s.toString();
|
|
860
861
|
}
|
|
861
862
|
shouldUseIntlApi() {
|
|
862
|
-
return !
|
|
863
|
+
return !Ve.includes(this.options.compatibilityJSON);
|
|
863
864
|
}
|
|
864
865
|
}
|
|
865
|
-
function
|
|
866
|
-
let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, r =
|
|
867
|
-
return !r && n && typeof
|
|
866
|
+
function ce(i, t, e) {
|
|
867
|
+
let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, r = De(i, t, e);
|
|
868
|
+
return !r && n && typeof e == "string" && (r = Y(i, e, s), r === void 0 && (r = Y(t, e, s))), r;
|
|
868
869
|
}
|
|
869
870
|
class Je {
|
|
870
871
|
constructor() {
|
|
871
|
-
let
|
|
872
|
-
this.logger = P.create("interpolator"), this.options =
|
|
872
|
+
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
873
|
+
this.logger = P.create("interpolator"), this.options = t, this.format = t.interpolation && t.interpolation.format || ((e) => e), this.init(t);
|
|
873
874
|
}
|
|
874
875
|
init() {
|
|
875
|
-
let
|
|
876
|
-
|
|
876
|
+
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
877
|
+
t.interpolation || (t.interpolation = {
|
|
877
878
|
escapeValue: !0
|
|
878
879
|
});
|
|
879
|
-
const
|
|
880
|
-
this.escape =
|
|
880
|
+
const e = t.interpolation;
|
|
881
|
+
this.escape = e.escape !== void 0 ? e.escape : Ae, this.escapeValue = e.escapeValue !== void 0 ? e.escapeValue : !0, this.useRawValueToEscape = e.useRawValueToEscape !== void 0 ? e.useRawValueToEscape : !1, this.prefix = e.prefix ? j(e.prefix) : e.prefixEscaped || "{{", this.suffix = e.suffix ? j(e.suffix) : e.suffixEscaped || "}}", this.formatSeparator = e.formatSeparator ? e.formatSeparator : e.formatSeparator || ",", this.unescapePrefix = e.unescapeSuffix ? "" : e.unescapePrefix || "-", this.unescapeSuffix = this.unescapePrefix ? "" : e.unescapeSuffix || "", this.nestingPrefix = e.nestingPrefix ? j(e.nestingPrefix) : e.nestingPrefixEscaped || j("$t("), this.nestingSuffix = e.nestingSuffix ? j(e.nestingSuffix) : e.nestingSuffixEscaped || j(")"), this.nestingOptionsSeparator = e.nestingOptionsSeparator ? e.nestingOptionsSeparator : e.nestingOptionsSeparator || ",", this.maxReplaces = e.maxReplaces ? e.maxReplaces : 1e3, this.alwaysFormat = e.alwaysFormat !== void 0 ? e.alwaysFormat : !1, this.resetRegExp();
|
|
881
882
|
}
|
|
882
883
|
reset() {
|
|
883
884
|
this.options && this.init(this.options);
|
|
884
885
|
}
|
|
885
886
|
resetRegExp() {
|
|
886
|
-
const
|
|
887
|
-
this.regexp = new RegExp(
|
|
888
|
-
const
|
|
889
|
-
this.regexpUnescape = new RegExp(
|
|
887
|
+
const t = `${this.prefix}(.+?)${this.suffix}`;
|
|
888
|
+
this.regexp = new RegExp(t, "g");
|
|
889
|
+
const e = `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;
|
|
890
|
+
this.regexpUnescape = new RegExp(e, "g");
|
|
890
891
|
const s = `${this.nestingPrefix}(.+?)${this.nestingSuffix}`;
|
|
891
892
|
this.nestingRegexp = new RegExp(s, "g");
|
|
892
893
|
}
|
|
893
|
-
interpolate(
|
|
894
|
+
interpolate(t, e, s, n) {
|
|
894
895
|
let r, a, l;
|
|
895
896
|
const o = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
896
897
|
function f(c) {
|
|
@@ -898,17 +899,17 @@ class Je {
|
|
|
898
899
|
}
|
|
899
900
|
const g = (c) => {
|
|
900
901
|
if (c.indexOf(this.formatSeparator) < 0) {
|
|
901
|
-
const
|
|
902
|
-
return this.alwaysFormat ? this.format(
|
|
902
|
+
const b = ce(e, o, c, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
903
|
+
return this.alwaysFormat ? this.format(b, void 0, s, {
|
|
903
904
|
...n,
|
|
904
|
-
...
|
|
905
|
+
...e,
|
|
905
906
|
interpolationkey: c
|
|
906
|
-
}) :
|
|
907
|
+
}) : b;
|
|
907
908
|
}
|
|
908
|
-
const p = c.split(this.formatSeparator), m = p.shift().trim(),
|
|
909
|
-
return this.format(
|
|
909
|
+
const p = c.split(this.formatSeparator), m = p.shift().trim(), O = p.join(this.formatSeparator).trim();
|
|
910
|
+
return this.format(ce(e, o, m, this.options.keySeparator, this.options.ignoreJSONStructure), O, s, {
|
|
910
911
|
...n,
|
|
911
|
-
...
|
|
912
|
+
...e,
|
|
912
913
|
interpolationkey: m
|
|
913
914
|
});
|
|
914
915
|
};
|
|
@@ -921,28 +922,28 @@ class Je {
|
|
|
921
922
|
regex: this.regexp,
|
|
922
923
|
safeValue: (c) => this.escapeValue ? f(this.escape(c)) : f(c)
|
|
923
924
|
}].forEach((c) => {
|
|
924
|
-
for (l = 0; r = c.regex.exec(
|
|
925
|
+
for (l = 0; r = c.regex.exec(t); ) {
|
|
925
926
|
const p = r[1].trim();
|
|
926
927
|
if (a = g(p), a === void 0)
|
|
927
928
|
if (typeof h == "function") {
|
|
928
|
-
const
|
|
929
|
-
a = typeof
|
|
929
|
+
const O = h(t, r, n);
|
|
930
|
+
a = typeof O == "string" ? O : "";
|
|
930
931
|
} else if (n && Object.prototype.hasOwnProperty.call(n, p))
|
|
931
932
|
a = "";
|
|
932
933
|
else if (u) {
|
|
933
934
|
a = r[0];
|
|
934
935
|
continue;
|
|
935
936
|
} else
|
|
936
|
-
this.logger.warn(`missed to pass in variable ${p} for interpolating ${
|
|
937
|
+
this.logger.warn(`missed to pass in variable ${p} for interpolating ${t}`), a = "";
|
|
937
938
|
else
|
|
938
|
-
typeof a != "string" && !this.useRawValueToEscape && (a =
|
|
939
|
+
typeof a != "string" && !this.useRawValueToEscape && (a = oe(a));
|
|
939
940
|
const m = c.safeValue(a);
|
|
940
|
-
if (
|
|
941
|
+
if (t = t.replace(r[0], m), u ? (c.regex.lastIndex += a.length, c.regex.lastIndex -= r[0].length) : c.regex.lastIndex = 0, l++, l >= this.maxReplaces)
|
|
941
942
|
break;
|
|
942
943
|
}
|
|
943
|
-
}),
|
|
944
|
+
}), t;
|
|
944
945
|
}
|
|
945
|
-
nest(
|
|
946
|
+
nest(t, e) {
|
|
946
947
|
let s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, n, r, a;
|
|
947
948
|
function l(o, f) {
|
|
948
949
|
const g = this.nestingOptionsSeparator;
|
|
@@ -963,7 +964,7 @@ class Je {
|
|
|
963
964
|
}
|
|
964
965
|
return delete a.defaultValue, o;
|
|
965
966
|
}
|
|
966
|
-
for (; n = this.nestingRegexp.exec(
|
|
967
|
+
for (; n = this.nestingRegexp.exec(t); ) {
|
|
967
968
|
let o = [];
|
|
968
969
|
a = {
|
|
969
970
|
...s
|
|
@@ -973,95 +974,95 @@ class Je {
|
|
|
973
974
|
const g = n[1].split(this.formatSeparator).map((h) => h.trim());
|
|
974
975
|
n[1] = g.shift(), o = g, f = !0;
|
|
975
976
|
}
|
|
976
|
-
if (r =
|
|
977
|
+
if (r = e(l.call(this, n[1].trim(), a), a), r && n[0] === t && typeof r != "string")
|
|
977
978
|
return r;
|
|
978
|
-
typeof r != "string" && (r =
|
|
979
|
+
typeof r != "string" && (r = oe(r)), r || (this.logger.warn(`missed to resolve ${n[1]} for nesting ${t}`), r = ""), f && (r = o.reduce((g, h) => this.format(g, h, s.lng, {
|
|
979
980
|
...s,
|
|
980
981
|
interpolationkey: n[1].trim()
|
|
981
|
-
}), r.trim())),
|
|
982
|
+
}), r.trim())), t = t.replace(n[0], r), this.regexp.lastIndex = 0;
|
|
982
983
|
}
|
|
983
|
-
return
|
|
984
|
+
return t;
|
|
984
985
|
}
|
|
985
986
|
}
|
|
986
987
|
function ze(i) {
|
|
987
|
-
let
|
|
988
|
-
const
|
|
988
|
+
let t = i.toLowerCase().trim();
|
|
989
|
+
const e = {};
|
|
989
990
|
if (i.indexOf("(") > -1) {
|
|
990
991
|
const s = i.split("(");
|
|
991
|
-
|
|
992
|
+
t = s[0].toLowerCase().trim();
|
|
992
993
|
const n = s[1].substring(0, s[1].length - 1);
|
|
993
|
-
|
|
994
|
+
t === "currency" && n.indexOf(":") < 0 ? e.currency || (e.currency = n.trim()) : t === "relativetime" && n.indexOf(":") < 0 ? e.range || (e.range = n.trim()) : n.split(";").forEach((a) => {
|
|
994
995
|
if (!a)
|
|
995
996
|
return;
|
|
996
997
|
const [l, ...o] = a.split(":"), f = o.join(":").trim().replace(/^'+|'+$/g, "");
|
|
997
|
-
|
|
998
|
+
e[l.trim()] || (e[l.trim()] = f), f === "false" && (e[l.trim()] = !1), f === "true" && (e[l.trim()] = !0), isNaN(f) || (e[l.trim()] = parseInt(f, 10));
|
|
998
999
|
});
|
|
999
1000
|
}
|
|
1000
1001
|
return {
|
|
1001
|
-
formatName:
|
|
1002
|
-
formatOptions:
|
|
1002
|
+
formatName: t,
|
|
1003
|
+
formatOptions: e
|
|
1003
1004
|
};
|
|
1004
1005
|
}
|
|
1005
1006
|
function k(i) {
|
|
1006
|
-
const
|
|
1007
|
+
const t = {};
|
|
1007
1008
|
return function(s, n, r) {
|
|
1008
1009
|
const a = n + JSON.stringify(r);
|
|
1009
|
-
let l =
|
|
1010
|
-
return l || (l = i(G(n), r),
|
|
1010
|
+
let l = t[a];
|
|
1011
|
+
return l || (l = i(G(n), r), t[a] = l), l(s);
|
|
1011
1012
|
};
|
|
1012
1013
|
}
|
|
1013
1014
|
class We {
|
|
1014
1015
|
constructor() {
|
|
1015
|
-
let
|
|
1016
|
-
this.logger = P.create("formatter"), this.options =
|
|
1017
|
-
number: k((
|
|
1018
|
-
const n = new Intl.NumberFormat(
|
|
1016
|
+
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1017
|
+
this.logger = P.create("formatter"), this.options = t, this.formats = {
|
|
1018
|
+
number: k((e, s) => {
|
|
1019
|
+
const n = new Intl.NumberFormat(e, {
|
|
1019
1020
|
...s
|
|
1020
1021
|
});
|
|
1021
1022
|
return (r) => n.format(r);
|
|
1022
1023
|
}),
|
|
1023
|
-
currency: k((
|
|
1024
|
-
const n = new Intl.NumberFormat(
|
|
1024
|
+
currency: k((e, s) => {
|
|
1025
|
+
const n = new Intl.NumberFormat(e, {
|
|
1025
1026
|
...s,
|
|
1026
1027
|
style: "currency"
|
|
1027
1028
|
});
|
|
1028
1029
|
return (r) => n.format(r);
|
|
1029
1030
|
}),
|
|
1030
|
-
datetime: k((
|
|
1031
|
-
const n = new Intl.DateTimeFormat(
|
|
1031
|
+
datetime: k((e, s) => {
|
|
1032
|
+
const n = new Intl.DateTimeFormat(e, {
|
|
1032
1033
|
...s
|
|
1033
1034
|
});
|
|
1034
1035
|
return (r) => n.format(r);
|
|
1035
1036
|
}),
|
|
1036
|
-
relativetime: k((
|
|
1037
|
-
const n = new Intl.RelativeTimeFormat(
|
|
1037
|
+
relativetime: k((e, s) => {
|
|
1038
|
+
const n = new Intl.RelativeTimeFormat(e, {
|
|
1038
1039
|
...s
|
|
1039
1040
|
});
|
|
1040
1041
|
return (r) => n.format(r, s.range || "day");
|
|
1041
1042
|
}),
|
|
1042
|
-
list: k((
|
|
1043
|
-
const n = new Intl.ListFormat(
|
|
1043
|
+
list: k((e, s) => {
|
|
1044
|
+
const n = new Intl.ListFormat(e, {
|
|
1044
1045
|
...s
|
|
1045
1046
|
});
|
|
1046
1047
|
return (r) => n.format(r);
|
|
1047
1048
|
})
|
|
1048
|
-
}, this.init(
|
|
1049
|
+
}, this.init(t);
|
|
1049
1050
|
}
|
|
1050
|
-
init(
|
|
1051
|
+
init(t) {
|
|
1051
1052
|
const s = (arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
1052
1053
|
interpolation: {}
|
|
1053
1054
|
}).interpolation;
|
|
1054
1055
|
this.formatSeparator = s.formatSeparator ? s.formatSeparator : s.formatSeparator || ",";
|
|
1055
1056
|
}
|
|
1056
|
-
add(
|
|
1057
|
-
this.formats[
|
|
1057
|
+
add(t, e) {
|
|
1058
|
+
this.formats[t.toLowerCase().trim()] = e;
|
|
1058
1059
|
}
|
|
1059
|
-
addCached(
|
|
1060
|
-
this.formats[
|
|
1060
|
+
addCached(t, e) {
|
|
1061
|
+
this.formats[t.toLowerCase().trim()] = k(e);
|
|
1061
1062
|
}
|
|
1062
|
-
format(
|
|
1063
|
+
format(t, e, s) {
|
|
1063
1064
|
let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
1064
|
-
return
|
|
1065
|
+
return e.split(this.formatSeparator).reduce((l, o) => {
|
|
1065
1066
|
const {
|
|
1066
1067
|
formatName: f,
|
|
1067
1068
|
formatOptions: g
|
|
@@ -1082,22 +1083,22 @@ class We {
|
|
|
1082
1083
|
} else
|
|
1083
1084
|
this.logger.warn(`there was no format function for ${f}`);
|
|
1084
1085
|
return l;
|
|
1085
|
-
},
|
|
1086
|
+
}, t);
|
|
1086
1087
|
}
|
|
1087
1088
|
}
|
|
1088
|
-
function Ye(i,
|
|
1089
|
-
i.pending[
|
|
1089
|
+
function Ye(i, t) {
|
|
1090
|
+
i.pending[t] !== void 0 && (delete i.pending[t], i.pendingCount--);
|
|
1090
1091
|
}
|
|
1091
1092
|
class Ge extends Q {
|
|
1092
|
-
constructor(
|
|
1093
|
+
constructor(t, e, s) {
|
|
1093
1094
|
let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
1094
|
-
super(), this.backend =
|
|
1095
|
+
super(), this.backend = t, this.store = e, this.services = s, this.languageUtils = s.languageUtils, this.options = n, this.logger = P.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = n.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = n.maxRetries >= 0 ? n.maxRetries : 5, this.retryTimeout = n.retryTimeout >= 1 ? n.retryTimeout : 350, this.state = {}, this.queue = [], this.backend && this.backend.init && this.backend.init(s, n.backend, n);
|
|
1095
1096
|
}
|
|
1096
|
-
queueLoad(
|
|
1097
|
+
queueLoad(t, e, s, n) {
|
|
1097
1098
|
const r = {}, a = {}, l = {}, o = {};
|
|
1098
|
-
return
|
|
1099
|
+
return t.forEach((f) => {
|
|
1099
1100
|
let g = !0;
|
|
1100
|
-
|
|
1101
|
+
e.forEach((h) => {
|
|
1101
1102
|
const u = `${f}|${h}`;
|
|
1102
1103
|
!s.reload && this.store.hasResourceBundle(f, h) ? this.state[u] = 2 : this.state[u] < 0 || (this.state[u] === 1 ? a[u] === void 0 && (a[u] = !0) : (this.state[u] = 1, g = !1, a[u] === void 0 && (a[u] = !0), r[u] === void 0 && (r[u] = !0), o[h] === void 0 && (o[h] = !0)));
|
|
1103
1104
|
}), g || (l[f] = !0);
|
|
@@ -1114,12 +1115,12 @@ class Ge extends Q {
|
|
|
1114
1115
|
toLoadNamespaces: Object.keys(o)
|
|
1115
1116
|
};
|
|
1116
1117
|
}
|
|
1117
|
-
loaded(
|
|
1118
|
-
const n =
|
|
1119
|
-
|
|
1118
|
+
loaded(t, e, s) {
|
|
1119
|
+
const n = t.split("|"), r = n[0], a = n[1];
|
|
1120
|
+
e && this.emit("failedLoading", r, a, e), s && this.store.addResourceBundle(r, a, s), this.state[t] = e ? -1 : 2;
|
|
1120
1121
|
const l = {};
|
|
1121
1122
|
this.queue.forEach((o) => {
|
|
1122
|
-
ke(o.loaded, [r], a), Ye(o,
|
|
1123
|
+
ke(o.loaded, [r], a), Ye(o, t), e && o.errors.push(e), o.pendingCount === 0 && !o.done && (Object.keys(o.loaded).forEach((f) => {
|
|
1123
1124
|
l[f] || (l[f] = {});
|
|
1124
1125
|
const g = o.loaded[f];
|
|
1125
1126
|
g.length && g.forEach((h) => {
|
|
@@ -1128,14 +1129,14 @@ class Ge extends Q {
|
|
|
1128
1129
|
}), o.done = !0, o.errors.length ? o.callback(o.errors) : o.callback());
|
|
1129
1130
|
}), this.emit("loaded", l), this.queue = this.queue.filter((o) => !o.done);
|
|
1130
1131
|
}
|
|
1131
|
-
read(
|
|
1132
|
+
read(t, e, s) {
|
|
1132
1133
|
let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0, r = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout, a = arguments.length > 5 ? arguments[5] : void 0;
|
|
1133
|
-
if (!
|
|
1134
|
+
if (!t.length)
|
|
1134
1135
|
return a(null, {});
|
|
1135
1136
|
if (this.readingCalls >= this.maxParallelReads) {
|
|
1136
1137
|
this.waitingReads.push({
|
|
1137
|
-
lng:
|
|
1138
|
-
ns:
|
|
1138
|
+
lng: t,
|
|
1139
|
+
ns: e,
|
|
1139
1140
|
fcName: s,
|
|
1140
1141
|
tried: n,
|
|
1141
1142
|
wait: r,
|
|
@@ -1151,7 +1152,7 @@ class Ge extends Q {
|
|
|
1151
1152
|
}
|
|
1152
1153
|
if (f && g && n < this.maxRetries) {
|
|
1153
1154
|
setTimeout(() => {
|
|
1154
|
-
this.read.call(this,
|
|
1155
|
+
this.read.call(this, t, e, s, n + 1, r * 2, a);
|
|
1155
1156
|
}, r);
|
|
1156
1157
|
return;
|
|
1157
1158
|
}
|
|
@@ -1159,47 +1160,47 @@ class Ge extends Q {
|
|
|
1159
1160
|
}, o = this.backend[s].bind(this.backend);
|
|
1160
1161
|
if (o.length === 2) {
|
|
1161
1162
|
try {
|
|
1162
|
-
const f = o(
|
|
1163
|
+
const f = o(t, e);
|
|
1163
1164
|
f && typeof f.then == "function" ? f.then((g) => l(null, g)).catch(l) : l(null, f);
|
|
1164
1165
|
} catch (f) {
|
|
1165
1166
|
l(f);
|
|
1166
1167
|
}
|
|
1167
1168
|
return;
|
|
1168
1169
|
}
|
|
1169
|
-
return o(
|
|
1170
|
+
return o(t, e, l);
|
|
1170
1171
|
}
|
|
1171
|
-
prepareLoading(
|
|
1172
|
+
prepareLoading(t, e) {
|
|
1172
1173
|
let s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, n = arguments.length > 3 ? arguments[3] : void 0;
|
|
1173
1174
|
if (!this.backend)
|
|
1174
1175
|
return this.logger.warn("No backend was added via i18next.use. Will not load resources."), n && n();
|
|
1175
|
-
typeof
|
|
1176
|
-
const r = this.queueLoad(
|
|
1176
|
+
typeof t == "string" && (t = this.languageUtils.toResolveHierarchy(t)), typeof e == "string" && (e = [e]);
|
|
1177
|
+
const r = this.queueLoad(t, e, s, n);
|
|
1177
1178
|
if (!r.toLoad.length)
|
|
1178
1179
|
return r.pending.length || n(), null;
|
|
1179
1180
|
r.toLoad.forEach((a) => {
|
|
1180
1181
|
this.loadOne(a);
|
|
1181
1182
|
});
|
|
1182
1183
|
}
|
|
1183
|
-
load(
|
|
1184
|
-
this.prepareLoading(
|
|
1184
|
+
load(t, e, s) {
|
|
1185
|
+
this.prepareLoading(t, e, {}, s);
|
|
1185
1186
|
}
|
|
1186
|
-
reload(
|
|
1187
|
-
this.prepareLoading(
|
|
1187
|
+
reload(t, e, s) {
|
|
1188
|
+
this.prepareLoading(t, e, {
|
|
1188
1189
|
reload: !0
|
|
1189
1190
|
}, s);
|
|
1190
1191
|
}
|
|
1191
|
-
loadOne(
|
|
1192
|
-
let
|
|
1193
|
-
const s =
|
|
1192
|
+
loadOne(t) {
|
|
1193
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
1194
|
+
const s = t.split("|"), n = s[0], r = s[1];
|
|
1194
1195
|
this.read(n, r, "read", void 0, void 0, (a, l) => {
|
|
1195
|
-
a && this.logger.warn(`${
|
|
1196
|
+
a && this.logger.warn(`${e}loading namespace ${r} for language ${n} failed`, a), !a && l && this.logger.log(`${e}loaded namespace ${r} for language ${n}`, l), this.loaded(t, a, l);
|
|
1196
1197
|
});
|
|
1197
1198
|
}
|
|
1198
|
-
saveMissing(
|
|
1199
|
+
saveMissing(t, e, s, n, r) {
|
|
1199
1200
|
let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {}, l = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
|
|
1200
1201
|
};
|
|
1201
|
-
if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(
|
|
1202
|
-
this.logger.warn(`did not save key "${s}" as the namespace "${
|
|
1202
|
+
if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(e)) {
|
|
1203
|
+
this.logger.warn(`did not save key "${s}" as the namespace "${e}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
|
|
1203
1204
|
return;
|
|
1204
1205
|
}
|
|
1205
1206
|
if (!(s == null || s === "")) {
|
|
@@ -1211,18 +1212,18 @@ class Ge extends Q {
|
|
|
1211
1212
|
if (f.length < 6)
|
|
1212
1213
|
try {
|
|
1213
1214
|
let g;
|
|
1214
|
-
f.length === 5 ? g = f(
|
|
1215
|
+
f.length === 5 ? g = f(t, e, s, n, o) : g = f(t, e, s, n), g && typeof g.then == "function" ? g.then((h) => l(null, h)).catch(l) : l(null, g);
|
|
1215
1216
|
} catch (g) {
|
|
1216
1217
|
l(g);
|
|
1217
1218
|
}
|
|
1218
1219
|
else
|
|
1219
|
-
f(
|
|
1220
|
+
f(t, e, s, n, l, o);
|
|
1220
1221
|
}
|
|
1221
|
-
!
|
|
1222
|
+
!t || !t[0] || this.store.addResource(t[0], e, s, n);
|
|
1222
1223
|
}
|
|
1223
1224
|
}
|
|
1224
1225
|
}
|
|
1225
|
-
function
|
|
1226
|
+
function de() {
|
|
1226
1227
|
return {
|
|
1227
1228
|
debug: !1,
|
|
1228
1229
|
initImmediate: !0,
|
|
@@ -1256,15 +1257,15 @@ function ce() {
|
|
|
1256
1257
|
parseMissingKeyHandler: !1,
|
|
1257
1258
|
appendNamespaceToMissingKey: !1,
|
|
1258
1259
|
appendNamespaceToCIMode: !1,
|
|
1259
|
-
overloadTranslationOptionHandler: function(
|
|
1260
|
-
let
|
|
1261
|
-
if (typeof
|
|
1262
|
-
const s =
|
|
1260
|
+
overloadTranslationOptionHandler: function(t) {
|
|
1261
|
+
let e = {};
|
|
1262
|
+
if (typeof t[1] == "object" && (e = t[1]), typeof t[1] == "string" && (e.defaultValue = t[1]), typeof t[2] == "string" && (e.tDescription = t[2]), typeof t[2] == "object" || typeof t[3] == "object") {
|
|
1263
|
+
const s = t[3] || t[2];
|
|
1263
1264
|
Object.keys(s).forEach((n) => {
|
|
1264
|
-
|
|
1265
|
+
e[n] = s[n];
|
|
1265
1266
|
});
|
|
1266
1267
|
}
|
|
1267
|
-
return
|
|
1268
|
+
return e;
|
|
1268
1269
|
},
|
|
1269
1270
|
interpolation: {
|
|
1270
1271
|
escapeValue: !0,
|
|
@@ -1281,42 +1282,42 @@ function ce() {
|
|
|
1281
1282
|
}
|
|
1282
1283
|
};
|
|
1283
1284
|
}
|
|
1284
|
-
function
|
|
1285
|
+
function pe(i) {
|
|
1285
1286
|
return typeof i.ns == "string" && (i.ns = [i.ns]), typeof i.fallbackLng == "string" && (i.fallbackLng = [i.fallbackLng]), typeof i.fallbackNS == "string" && (i.fallbackNS = [i.fallbackNS]), i.supportedLngs && i.supportedLngs.indexOf("cimode") < 0 && (i.supportedLngs = i.supportedLngs.concat(["cimode"])), i;
|
|
1286
1287
|
}
|
|
1287
1288
|
function H() {
|
|
1288
1289
|
}
|
|
1289
1290
|
function Ze(i) {
|
|
1290
|
-
Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((
|
|
1291
|
-
typeof i[
|
|
1291
|
+
Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((e) => {
|
|
1292
|
+
typeof i[e] == "function" && (i[e] = i[e].bind(i));
|
|
1292
1293
|
});
|
|
1293
1294
|
}
|
|
1294
1295
|
class T extends Q {
|
|
1295
1296
|
constructor() {
|
|
1296
|
-
let
|
|
1297
|
-
if (super(), this.options =
|
|
1297
|
+
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, e = arguments.length > 1 ? arguments[1] : void 0;
|
|
1298
|
+
if (super(), this.options = pe(t), this.services = {}, this.logger = P, this.modules = {
|
|
1298
1299
|
external: []
|
|
1299
|
-
}, Ze(this),
|
|
1300
|
+
}, Ze(this), e && !this.isInitialized && !t.isClone) {
|
|
1300
1301
|
if (!this.options.initImmediate)
|
|
1301
|
-
return this.init(
|
|
1302
|
+
return this.init(t, e), this;
|
|
1302
1303
|
setTimeout(() => {
|
|
1303
|
-
this.init(
|
|
1304
|
+
this.init(t, e);
|
|
1304
1305
|
}, 0);
|
|
1305
1306
|
}
|
|
1306
1307
|
}
|
|
1307
1308
|
init() {
|
|
1308
|
-
var
|
|
1309
|
-
let
|
|
1310
|
-
typeof
|
|
1311
|
-
const n =
|
|
1309
|
+
var t = this;
|
|
1310
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, s = arguments.length > 1 ? arguments[1] : void 0;
|
|
1311
|
+
typeof e == "function" && (s = e, e = {}), !e.defaultNS && e.defaultNS !== !1 && e.ns && (typeof e.ns == "string" ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
|
|
1312
|
+
const n = de();
|
|
1312
1313
|
this.options = {
|
|
1313
1314
|
...n,
|
|
1314
1315
|
...this.options,
|
|
1315
|
-
...
|
|
1316
|
+
...pe(e)
|
|
1316
1317
|
}, this.options.compatibilityAPI !== "v1" && (this.options.interpolation = {
|
|
1317
1318
|
...n.interpolation,
|
|
1318
1319
|
...this.options.interpolation
|
|
1319
|
-
}),
|
|
1320
|
+
}), e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator);
|
|
1320
1321
|
function r(g) {
|
|
1321
1322
|
return g ? typeof g == "function" ? new g() : g : null;
|
|
1322
1323
|
}
|
|
@@ -1324,8 +1325,8 @@ class T extends Q {
|
|
|
1324
1325
|
this.modules.logger ? P.init(r(this.modules.logger), this.options) : P.init(null, this.options);
|
|
1325
1326
|
let g;
|
|
1326
1327
|
this.modules.formatter ? g = this.modules.formatter : typeof Intl < "u" && (g = We);
|
|
1327
|
-
const h = new
|
|
1328
|
-
this.store = new
|
|
1328
|
+
const h = new ge(this.options);
|
|
1329
|
+
this.store = new ue(this.options.resources, this.options);
|
|
1329
1330
|
const u = this.services;
|
|
1330
1331
|
u.logger = P, u.resourceStore = this.store, u.languageUtils = h, u.pluralResolver = new He(h, {
|
|
1331
1332
|
prepend: this.options.pluralSeparator,
|
|
@@ -1336,11 +1337,11 @@ class T extends Q {
|
|
|
1336
1337
|
}, u.backendConnector = new Ge(r(this.modules.backend), u.resourceStore, u, this.options), u.backendConnector.on("*", function(d) {
|
|
1337
1338
|
for (var c = arguments.length, p = new Array(c > 1 ? c - 1 : 0), m = 1; m < c; m++)
|
|
1338
1339
|
p[m - 1] = arguments[m];
|
|
1339
|
-
|
|
1340
|
+
t.emit(d, ...p);
|
|
1340
1341
|
}), this.modules.languageDetector && (u.languageDetector = r(this.modules.languageDetector), u.languageDetector.init && u.languageDetector.init(u, this.options.detection, this.options)), this.modules.i18nFormat && (u.i18nFormat = r(this.modules.i18nFormat), u.i18nFormat.init && u.i18nFormat.init(this)), this.translator = new Z(this.services, this.options), this.translator.on("*", function(d) {
|
|
1341
1342
|
for (var c = arguments.length, p = new Array(c > 1 ? c - 1 : 0), m = 1; m < c; m++)
|
|
1342
1343
|
p[m - 1] = arguments[m];
|
|
1343
|
-
|
|
1344
|
+
t.emit(d, ...p);
|
|
1344
1345
|
}), this.modules.external.forEach((d) => {
|
|
1345
1346
|
d.init && d.init(this);
|
|
1346
1347
|
});
|
|
@@ -1351,11 +1352,11 @@ class T extends Q {
|
|
|
1351
1352
|
}
|
|
1352
1353
|
!this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((g) => {
|
|
1353
1354
|
this[g] = function() {
|
|
1354
|
-
return
|
|
1355
|
+
return t.store[g](...arguments);
|
|
1355
1356
|
};
|
|
1356
1357
|
}), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((g) => {
|
|
1357
1358
|
this[g] = function() {
|
|
1358
|
-
return
|
|
1359
|
+
return t.store[g](...arguments), t;
|
|
1359
1360
|
};
|
|
1360
1361
|
});
|
|
1361
1362
|
const o = U(), f = () => {
|
|
@@ -1368,10 +1369,10 @@ class T extends Q {
|
|
|
1368
1369
|
};
|
|
1369
1370
|
return this.options.resources || !this.options.initImmediate ? f() : setTimeout(f, 0), o;
|
|
1370
1371
|
}
|
|
1371
|
-
loadResources(
|
|
1372
|
+
loadResources(t) {
|
|
1372
1373
|
let s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : H;
|
|
1373
|
-
const n = typeof
|
|
1374
|
-
if (typeof
|
|
1374
|
+
const n = typeof t == "string" ? t : this.language;
|
|
1375
|
+
if (typeof t == "function" && (s = t), !this.options.resources || this.options.partialBundledLanguages) {
|
|
1375
1376
|
if (n && n.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0))
|
|
1376
1377
|
return s();
|
|
1377
1378
|
const r = [], a = (l) => {
|
|
@@ -1387,52 +1388,52 @@ class T extends Q {
|
|
|
1387
1388
|
} else
|
|
1388
1389
|
s(null);
|
|
1389
1390
|
}
|
|
1390
|
-
reloadResources(
|
|
1391
|
+
reloadResources(t, e, s) {
|
|
1391
1392
|
const n = U();
|
|
1392
|
-
return
|
|
1393
|
+
return t || (t = this.languages), e || (e = this.options.ns), s || (s = H), this.services.backendConnector.reload(t, e, (r) => {
|
|
1393
1394
|
n.resolve(), s(r);
|
|
1394
1395
|
}), n;
|
|
1395
1396
|
}
|
|
1396
|
-
use(
|
|
1397
|
-
if (!
|
|
1397
|
+
use(t) {
|
|
1398
|
+
if (!t)
|
|
1398
1399
|
throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
1399
|
-
if (!
|
|
1400
|
+
if (!t.type)
|
|
1400
1401
|
throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
1401
|
-
return
|
|
1402
|
+
return t.type === "backend" && (this.modules.backend = t), (t.type === "logger" || t.log && t.warn && t.error) && (this.modules.logger = t), t.type === "languageDetector" && (this.modules.languageDetector = t), t.type === "i18nFormat" && (this.modules.i18nFormat = t), t.type === "postProcessor" && Se.addPostProcessor(t), t.type === "formatter" && (this.modules.formatter = t), t.type === "3rdParty" && this.modules.external.push(t), this;
|
|
1402
1403
|
}
|
|
1403
|
-
setResolvedLanguage(
|
|
1404
|
-
if (!(!
|
|
1405
|
-
for (let
|
|
1406
|
-
const s = this.languages[
|
|
1404
|
+
setResolvedLanguage(t) {
|
|
1405
|
+
if (!(!t || !this.languages) && !(["cimode", "dev"].indexOf(t) > -1))
|
|
1406
|
+
for (let e = 0; e < this.languages.length; e++) {
|
|
1407
|
+
const s = this.languages[e];
|
|
1407
1408
|
if (!(["cimode", "dev"].indexOf(s) > -1) && this.store.hasLanguageSomeTranslations(s)) {
|
|
1408
1409
|
this.resolvedLanguage = s;
|
|
1409
1410
|
break;
|
|
1410
1411
|
}
|
|
1411
1412
|
}
|
|
1412
1413
|
}
|
|
1413
|
-
changeLanguage(
|
|
1414
|
+
changeLanguage(t, e) {
|
|
1414
1415
|
var s = this;
|
|
1415
|
-
this.isLanguageChangingTo =
|
|
1416
|
+
this.isLanguageChangingTo = t;
|
|
1416
1417
|
const n = U();
|
|
1417
|
-
this.emit("languageChanging",
|
|
1418
|
+
this.emit("languageChanging", t);
|
|
1418
1419
|
const r = (o) => {
|
|
1419
1420
|
this.language = o, this.languages = this.services.languageUtils.toResolveHierarchy(o), this.resolvedLanguage = void 0, this.setResolvedLanguage(o);
|
|
1420
1421
|
}, a = (o, f) => {
|
|
1421
1422
|
f ? (r(f), this.translator.changeLanguage(f), this.isLanguageChangingTo = void 0, this.emit("languageChanged", f), this.logger.log("languageChanged", f)) : this.isLanguageChangingTo = void 0, n.resolve(function() {
|
|
1422
1423
|
return s.t(...arguments);
|
|
1423
|
-
}),
|
|
1424
|
+
}), e && e(o, function() {
|
|
1424
1425
|
return s.t(...arguments);
|
|
1425
1426
|
});
|
|
1426
1427
|
}, l = (o) => {
|
|
1427
|
-
!
|
|
1428
|
+
!t && !o && this.services.languageDetector && (o = []);
|
|
1428
1429
|
const f = typeof o == "string" ? o : this.services.languageUtils.getBestMatchFromCodes(o);
|
|
1429
1430
|
f && (this.language || r(f), this.translator.language || this.translator.changeLanguage(f), this.services.languageDetector && this.services.languageDetector.cacheUserLanguage && this.services.languageDetector.cacheUserLanguage(f)), this.loadResources(f, (g) => {
|
|
1430
1431
|
a(g, f);
|
|
1431
1432
|
});
|
|
1432
1433
|
};
|
|
1433
|
-
return !
|
|
1434
|
+
return !t && this.services.languageDetector && !this.services.languageDetector.async ? l(this.services.languageDetector.detect()) : !t && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(l) : this.services.languageDetector.detect(l) : l(t), n;
|
|
1434
1435
|
}
|
|
1435
|
-
getFixedT(
|
|
1436
|
+
getFixedT(t, e, s) {
|
|
1436
1437
|
var n = this;
|
|
1437
1438
|
const r = function(a, l) {
|
|
1438
1439
|
let o;
|
|
@@ -1449,7 +1450,7 @@ class T extends Q {
|
|
|
1449
1450
|
let d;
|
|
1450
1451
|
return o.keyPrefix && Array.isArray(a) ? d = a.map((c) => `${o.keyPrefix}${u}${c}`) : d = o.keyPrefix ? `${o.keyPrefix}${u}${a}` : a, n.t(d, o);
|
|
1451
1452
|
};
|
|
1452
|
-
return typeof
|
|
1453
|
+
return typeof t == "string" ? r.lng = t : r.lngs = t, r.ns = e, r.keyPrefix = s, r;
|
|
1453
1454
|
}
|
|
1454
1455
|
t() {
|
|
1455
1456
|
return this.translator && this.translator.translate(...arguments);
|
|
@@ -1457,75 +1458,75 @@ class T extends Q {
|
|
|
1457
1458
|
exists() {
|
|
1458
1459
|
return this.translator && this.translator.exists(...arguments);
|
|
1459
1460
|
}
|
|
1460
|
-
setDefaultNamespace(
|
|
1461
|
-
this.options.defaultNS =
|
|
1461
|
+
setDefaultNamespace(t) {
|
|
1462
|
+
this.options.defaultNS = t;
|
|
1462
1463
|
}
|
|
1463
|
-
hasLoadedNamespace(
|
|
1464
|
-
let
|
|
1464
|
+
hasLoadedNamespace(t) {
|
|
1465
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1465
1466
|
if (!this.isInitialized)
|
|
1466
1467
|
return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
|
|
1467
1468
|
if (!this.languages || !this.languages.length)
|
|
1468
1469
|
return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
|
|
1469
|
-
const s =
|
|
1470
|
+
const s = e.lng || this.resolvedLanguage || this.languages[0], n = this.options ? this.options.fallbackLng : !1, r = this.languages[this.languages.length - 1];
|
|
1470
1471
|
if (s.toLowerCase() === "cimode")
|
|
1471
1472
|
return !0;
|
|
1472
1473
|
const a = (l, o) => {
|
|
1473
1474
|
const f = this.services.backendConnector.state[`${l}|${o}`];
|
|
1474
1475
|
return f === -1 || f === 2;
|
|
1475
1476
|
};
|
|
1476
|
-
if (
|
|
1477
|
-
const l =
|
|
1477
|
+
if (e.precheck) {
|
|
1478
|
+
const l = e.precheck(this, a);
|
|
1478
1479
|
if (l !== void 0)
|
|
1479
1480
|
return l;
|
|
1480
1481
|
}
|
|
1481
|
-
return !!(this.hasResourceBundle(s,
|
|
1482
|
+
return !!(this.hasResourceBundle(s, t) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(s, t) && (!n || a(r, t)));
|
|
1482
1483
|
}
|
|
1483
|
-
loadNamespaces(
|
|
1484
|
+
loadNamespaces(t, e) {
|
|
1484
1485
|
const s = U();
|
|
1485
|
-
return this.options.ns ? (typeof
|
|
1486
|
+
return this.options.ns ? (typeof t == "string" && (t = [t]), t.forEach((n) => {
|
|
1486
1487
|
this.options.ns.indexOf(n) < 0 && this.options.ns.push(n);
|
|
1487
1488
|
}), this.loadResources((n) => {
|
|
1488
|
-
s.resolve(),
|
|
1489
|
-
}), s) : (
|
|
1489
|
+
s.resolve(), e && e(n);
|
|
1490
|
+
}), s) : (e && e(), Promise.resolve());
|
|
1490
1491
|
}
|
|
1491
|
-
loadLanguages(
|
|
1492
|
+
loadLanguages(t, e) {
|
|
1492
1493
|
const s = U();
|
|
1493
|
-
typeof
|
|
1494
|
-
const n = this.options.preload || [], r =
|
|
1494
|
+
typeof t == "string" && (t = [t]);
|
|
1495
|
+
const n = this.options.preload || [], r = t.filter((a) => n.indexOf(a) < 0);
|
|
1495
1496
|
return r.length ? (this.options.preload = n.concat(r), this.loadResources((a) => {
|
|
1496
|
-
s.resolve(),
|
|
1497
|
-
}), s) : (
|
|
1497
|
+
s.resolve(), e && e(a);
|
|
1498
|
+
}), s) : (e && e(), Promise.resolve());
|
|
1498
1499
|
}
|
|
1499
|
-
dir(
|
|
1500
|
-
if (
|
|
1500
|
+
dir(t) {
|
|
1501
|
+
if (t || (t = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language)), !t)
|
|
1501
1502
|
return "rtl";
|
|
1502
|
-
const
|
|
1503
|
-
return
|
|
1503
|
+
const e = ["ar", "shu", "sqr", "ssh", "xaa", "yhd", "yud", "aao", "abh", "abv", "acm", "acq", "acw", "acx", "acy", "adf", "ads", "aeb", "aec", "afb", "ajp", "apc", "apd", "arb", "arq", "ars", "ary", "arz", "auz", "avl", "ayh", "ayl", "ayn", "ayp", "bbz", "pga", "he", "iw", "ps", "pbt", "pbu", "pst", "prp", "prd", "ug", "ur", "ydd", "yds", "yih", "ji", "yi", "hbo", "men", "xmn", "fa", "jpr", "peo", "pes", "prs", "dv", "sam", "ckb"], s = this.services && this.services.languageUtils || new ge(de());
|
|
1504
|
+
return e.indexOf(s.getLanguagePartFromCode(t)) > -1 || t.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
1504
1505
|
}
|
|
1505
1506
|
static createInstance() {
|
|
1506
|
-
let
|
|
1507
|
-
return new T(
|
|
1507
|
+
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, e = arguments.length > 1 ? arguments[1] : void 0;
|
|
1508
|
+
return new T(t, e);
|
|
1508
1509
|
}
|
|
1509
1510
|
cloneInstance() {
|
|
1510
|
-
let
|
|
1511
|
-
const s =
|
|
1512
|
-
s && delete
|
|
1511
|
+
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : H;
|
|
1512
|
+
const s = t.forkResourceStore;
|
|
1513
|
+
s && delete t.forkResourceStore;
|
|
1513
1514
|
const n = {
|
|
1514
1515
|
...this.options,
|
|
1515
|
-
...
|
|
1516
|
+
...t,
|
|
1516
1517
|
isClone: !0
|
|
1517
1518
|
}, r = new T(n);
|
|
1518
|
-
return (
|
|
1519
|
+
return (t.debug !== void 0 || t.prefix !== void 0) && (r.logger = r.logger.clone(t)), ["store", "services", "language"].forEach((l) => {
|
|
1519
1520
|
r[l] = this[l];
|
|
1520
1521
|
}), r.services = {
|
|
1521
1522
|
...this.services
|
|
1522
1523
|
}, r.services.utils = {
|
|
1523
1524
|
hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
|
|
1524
|
-
}, s && (r.store = new
|
|
1525
|
+
}, s && (r.store = new ue(this.store.data, n), r.services.resourceStore = r.store), r.translator = new Z(r.services, n), r.translator.on("*", function(l) {
|
|
1525
1526
|
for (var o = arguments.length, f = new Array(o > 1 ? o - 1 : 0), g = 1; g < o; g++)
|
|
1526
1527
|
f[g - 1] = arguments[g];
|
|
1527
1528
|
r.emit(l, ...f);
|
|
1528
|
-
}), r.init(n,
|
|
1529
|
+
}), r.init(n, e), r.translator.options = n, r.translator.backendConnector.services.utils = {
|
|
1529
1530
|
hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
|
|
1530
1531
|
}, r;
|
|
1531
1532
|
}
|
|
@@ -1539,30 +1540,30 @@ class T extends Q {
|
|
|
1539
1540
|
};
|
|
1540
1541
|
}
|
|
1541
1542
|
}
|
|
1542
|
-
const
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
const J =
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1543
|
+
const x = T.createInstance();
|
|
1544
|
+
x.createInstance = T.createInstance;
|
|
1545
|
+
x.createInstance;
|
|
1546
|
+
x.dir;
|
|
1547
|
+
x.init;
|
|
1548
|
+
x.loadResources;
|
|
1549
|
+
x.reloadResources;
|
|
1550
|
+
x.use;
|
|
1551
|
+
x.changeLanguage;
|
|
1552
|
+
x.getFixedT;
|
|
1553
|
+
const J = x.t;
|
|
1554
|
+
x.exists;
|
|
1555
|
+
x.setDefaultNamespace;
|
|
1556
|
+
x.hasLoadedNamespace;
|
|
1557
|
+
x.loadNamespaces;
|
|
1558
|
+
x.loadLanguages;
|
|
1558
1559
|
const Qe = {
|
|
1559
1560
|
es: {
|
|
1560
1561
|
translation: {
|
|
1561
|
-
...
|
|
1562
|
+
...Re
|
|
1562
1563
|
}
|
|
1563
1564
|
}
|
|
1564
1565
|
};
|
|
1565
|
-
|
|
1566
|
+
x.init({
|
|
1566
1567
|
resources: Qe,
|
|
1567
1568
|
lng: "es",
|
|
1568
1569
|
// language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources
|
|
@@ -1575,7 +1576,7 @@ b.init({
|
|
|
1575
1576
|
},
|
|
1576
1577
|
debug: !1
|
|
1577
1578
|
});
|
|
1578
|
-
const
|
|
1579
|
+
const E = {
|
|
1579
1580
|
// EXAMPLE ERROR
|
|
1580
1581
|
"MP-001": {
|
|
1581
1582
|
code: 400,
|
|
@@ -1613,70 +1614,70 @@ const C = {
|
|
|
1613
1614
|
level: "warning"
|
|
1614
1615
|
}
|
|
1615
1616
|
};
|
|
1616
|
-
class
|
|
1617
|
-
get(
|
|
1617
|
+
class ee extends Pe {
|
|
1618
|
+
get(t = "default", e) {
|
|
1618
1619
|
var r, a;
|
|
1619
|
-
if (
|
|
1620
|
-
return this.logError(
|
|
1621
|
-
...
|
|
1622
|
-
title: J(
|
|
1623
|
-
message: J(
|
|
1624
|
-
uuid:
|
|
1620
|
+
if (t instanceof Error)
|
|
1621
|
+
return this.logError(t.message), {
|
|
1622
|
+
...E.internalError,
|
|
1623
|
+
title: J(E.internalError.title),
|
|
1624
|
+
message: J(E.internalError.message),
|
|
1625
|
+
uuid: e
|
|
1625
1626
|
};
|
|
1626
|
-
const s = typeof
|
|
1627
|
+
const s = typeof t == "string" ? t : t.code ?? t.errorType, n = typeof t == "string" ? {} : { ...t };
|
|
1627
1628
|
return {
|
|
1628
|
-
...
|
|
1629
|
+
...E[s] ?? E.default,
|
|
1629
1630
|
title: J(
|
|
1630
|
-
((r =
|
|
1631
|
+
((r = E[s]) == null ? void 0 : r.title) ?? E.default.title,
|
|
1631
1632
|
n
|
|
1632
1633
|
),
|
|
1633
1634
|
message: J(
|
|
1634
|
-
((a =
|
|
1635
|
+
((a = E[s]) == null ? void 0 : a.message) ?? E.default.message,
|
|
1635
1636
|
n
|
|
1636
1637
|
),
|
|
1637
|
-
uuid:
|
|
1638
|
+
uuid: e
|
|
1638
1639
|
};
|
|
1639
1640
|
}
|
|
1640
1641
|
}
|
|
1641
|
-
class
|
|
1642
|
+
class ut extends $e {
|
|
1642
1643
|
constructor() {
|
|
1643
1644
|
super(...arguments);
|
|
1644
1645
|
$(this, "uuid", "");
|
|
1645
1646
|
$(this, "session", null);
|
|
1646
1647
|
}
|
|
1647
|
-
setSession(
|
|
1648
|
-
this.session =
|
|
1648
|
+
setSession(e) {
|
|
1649
|
+
this.session = e;
|
|
1649
1650
|
}
|
|
1650
1651
|
getSession() {
|
|
1651
1652
|
return this.session;
|
|
1652
1653
|
}
|
|
1653
|
-
returnData(
|
|
1654
|
+
returnData(e, s, n) {
|
|
1654
1655
|
const r = this.encode(s, n);
|
|
1655
|
-
|
|
1656
|
+
e.status(200).json(r);
|
|
1656
1657
|
}
|
|
1657
|
-
returnError(
|
|
1658
|
-
return s != null && s.uuid ?
|
|
1658
|
+
returnError(e, s) {
|
|
1659
|
+
return s != null && s.uuid ? e.status(520).json(s) : e.status(520).json(new ee().get(s, this.uuid));
|
|
1659
1660
|
}
|
|
1660
|
-
get(
|
|
1661
|
+
get(e) {
|
|
1661
1662
|
return this.logDebug("get ApiMiddleware"), (s, n) => {
|
|
1662
1663
|
var r;
|
|
1663
|
-
this.logDebug("return ApiMiddleware"), this.uuid = (r = s == null ? void 0 : s.body) == null ? void 0 : r.uuid,
|
|
1664
|
-
|
|
1665
|
-
(a) =>
|
|
1666
|
-
params:
|
|
1667
|
-
headers:
|
|
1664
|
+
this.logDebug("return ApiMiddleware"), this.uuid = (r = s == null ? void 0 : s.body) == null ? void 0 : r.uuid, N(s).pipe(
|
|
1665
|
+
R(
|
|
1666
|
+
(a) => re({
|
|
1667
|
+
params: N(this.decode(a.body)),
|
|
1668
|
+
headers: N(a.headers)
|
|
1668
1669
|
})
|
|
1669
1670
|
),
|
|
1670
|
-
|
|
1671
|
-
({ params: a, headers: l }) =>
|
|
1672
|
-
response:
|
|
1673
|
-
headers:
|
|
1674
|
-
params:
|
|
1671
|
+
R(
|
|
1672
|
+
({ params: a, headers: l }) => re({
|
|
1673
|
+
response: e(a, this.uuid, l),
|
|
1674
|
+
headers: N(l),
|
|
1675
|
+
params: N(a)
|
|
1675
1676
|
})
|
|
1676
1677
|
),
|
|
1677
|
-
|
|
1678
|
+
R(({ params: a, response: l, headers: o }) => (this.logDebug(
|
|
1678
1679
|
`ApiMiddleware \x1B[37m <URL>: \x1B[33m ${s.url} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(o)} \x1B[37m <UUID> \x1B[33m ${s.body.uuid} \x1B[37m <PARAMS> \x1B[33m ${JSON.stringify(a)} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(l)}`
|
|
1679
|
-
),
|
|
1680
|
+
), N(l))),
|
|
1680
1681
|
me((a) => {
|
|
1681
1682
|
var l;
|
|
1682
1683
|
return this.logError(
|
|
@@ -1691,90 +1692,116 @@ class ot extends $e {
|
|
|
1691
1692
|
};
|
|
1692
1693
|
}
|
|
1693
1694
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1695
|
+
const Xe = process.env.ID_FRONT ?? "NOT_AVAILABLE";
|
|
1696
|
+
class ft extends Ne {
|
|
1697
|
+
constructor(e, s) {
|
|
1696
1698
|
super();
|
|
1697
1699
|
$(this, "apiUrl");
|
|
1698
1700
|
$(this, "method");
|
|
1699
|
-
this.apiUrl =
|
|
1700
|
-
}
|
|
1701
|
-
errorHandler(
|
|
1702
|
-
if (
|
|
1703
|
-
throw new
|
|
1704
|
-
return !(
|
|
1701
|
+
this.apiUrl = e, this.method = s ?? "POST";
|
|
1702
|
+
}
|
|
1703
|
+
errorHandler(e, s) {
|
|
1704
|
+
if (e != null && e.errors)
|
|
1705
|
+
throw new ee().get(e.errors[0], s);
|
|
1706
|
+
return !(e != null && e.errors);
|
|
1707
|
+
}
|
|
1708
|
+
formatParams(e) {
|
|
1709
|
+
return JSON.stringify({
|
|
1710
|
+
data: {
|
|
1711
|
+
type: Xe,
|
|
1712
|
+
attributes: e
|
|
1713
|
+
}
|
|
1714
|
+
});
|
|
1705
1715
|
}
|
|
1706
|
-
fetchData(
|
|
1707
|
-
return
|
|
1708
|
-
|
|
1709
|
-
(n) => this.
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
headers: r,
|
|
1715
|
-
body: this.method === "GET" ? null : JSON.stringify(n),
|
|
1716
|
-
selector: (a) => a.json()
|
|
1716
|
+
fetchData(e = {}, s) {
|
|
1717
|
+
return this.getHeaders().pipe(
|
|
1718
|
+
R(
|
|
1719
|
+
(n) => q(this.apiUrl, {
|
|
1720
|
+
method: "POST",
|
|
1721
|
+
headers: n,
|
|
1722
|
+
body: this.formatParams(e),
|
|
1723
|
+
selector: (r) => r.json()
|
|
1717
1724
|
}).pipe(
|
|
1718
|
-
|
|
1725
|
+
R((r) => (this.logDebug(
|
|
1719
1726
|
`FetchServiceBE \x1B[37m <URL>: \x1B[33m ${this.apiUrl} \x1B[37m <UUID>: \x1B[33m ${s} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(
|
|
1720
|
-
r
|
|
1721
|
-
)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(
|
|
1722
1727
|
n
|
|
1723
|
-
)} \x1B[37m <
|
|
1724
|
-
|
|
1728
|
+
)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(
|
|
1729
|
+
e
|
|
1730
|
+
)} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(r)} \x1B[33m`
|
|
1731
|
+
), N(r)))
|
|
1725
1732
|
)
|
|
1726
1733
|
),
|
|
1727
|
-
|
|
1734
|
+
xe((n) => this.errorHandler(n, s))
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
fetchCustomData(e = {}, s) {
|
|
1738
|
+
return this.getHeaders().pipe(
|
|
1739
|
+
R(
|
|
1740
|
+
(n) => q(this.apiUrl, {
|
|
1741
|
+
method: this.method,
|
|
1742
|
+
headers: n,
|
|
1743
|
+
body: this.method === "GET" ? null : JSON.stringify(e),
|
|
1744
|
+
selector: (r) => r.json()
|
|
1745
|
+
}).pipe(
|
|
1746
|
+
R((r) => (this.logDebug(
|
|
1747
|
+
`FetchServiceBE \x1B[37m <URL>: \x1B[33m ${this.apiUrl} \x1B[37m \x1B[37m <METHOD>: \x1B[33m ${this.method} <UUID>: \x1B[33m ${s} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(
|
|
1748
|
+
n
|
|
1749
|
+
)} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(
|
|
1750
|
+
e
|
|
1751
|
+
)} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(r)} \x1B[33m`
|
|
1752
|
+
), N(r)))
|
|
1753
|
+
)
|
|
1754
|
+
)
|
|
1728
1755
|
);
|
|
1729
1756
|
}
|
|
1730
1757
|
}
|
|
1731
|
-
class
|
|
1732
|
-
constructor(
|
|
1758
|
+
class gt extends Ee {
|
|
1759
|
+
constructor(e, s = "POST", n = {}) {
|
|
1733
1760
|
super();
|
|
1734
1761
|
$(this, "apiUrl");
|
|
1735
1762
|
$(this, "method");
|
|
1736
1763
|
$(this, "headers");
|
|
1737
1764
|
$(this, "isLoadingEnabled", !0);
|
|
1738
|
-
this.apiUrl =
|
|
1765
|
+
this.apiUrl = e, this.method = s, this.headers = {
|
|
1739
1766
|
"Content-Type": "application/json",
|
|
1740
1767
|
...n
|
|
1741
1768
|
};
|
|
1742
1769
|
}
|
|
1743
|
-
setIsLoadingEnabled(
|
|
1744
|
-
this.isLoadingEnabled =
|
|
1770
|
+
setIsLoadingEnabled(e) {
|
|
1771
|
+
this.isLoadingEnabled = e;
|
|
1745
1772
|
}
|
|
1746
|
-
errorHandler(
|
|
1747
|
-
return
|
|
1773
|
+
errorHandler(e) {
|
|
1774
|
+
return e.code && (ie.getInstance().setSubject(e), M.getInstance().setSubject(!1)), !e.code;
|
|
1748
1775
|
}
|
|
1749
|
-
fetchData(
|
|
1750
|
-
const s = (/* @__PURE__ */ new Date()).toISOString(), n =
|
|
1776
|
+
fetchData(e = {}) {
|
|
1777
|
+
const s = (/* @__PURE__ */ new Date()).toISOString(), n = ae(s, ae.URL), r = this.encode({ ...e }, n);
|
|
1751
1778
|
M.getInstance().setSubject(this.isLoadingEnabled);
|
|
1752
1779
|
const l = new URLSearchParams(window.location.search).get("flow") ?? "N/A";
|
|
1753
|
-
return
|
|
1780
|
+
return q(this.apiUrl, {
|
|
1754
1781
|
method: this.method,
|
|
1755
1782
|
headers: { ...this.headers, flow: l },
|
|
1756
1783
|
body: r,
|
|
1757
1784
|
selector: (o) => o.json()
|
|
1758
1785
|
}).pipe(
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
`FetchServiceFE <URL>: ${this.apiUrl} <HEADERS>: ${JSON.stringify(this.headers)} <PARAMS> ${JSON.stringify(
|
|
1762
|
-
),
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
me((o) => (M.getInstance().setSubject(!1),
|
|
1766
|
-
new
|
|
1786
|
+
R((o) => N(this.decode(o))),
|
|
1787
|
+
R((o) => (this.logDebug(
|
|
1788
|
+
`FetchServiceFE <URL>: ${this.apiUrl} <HEADERS>: ${JSON.stringify(this.headers)} <PARAMS> ${JSON.stringify(e)} <BODY> ${r} <RESPONSE>: ${JSON.stringify(o)}`
|
|
1789
|
+
), N(o))),
|
|
1790
|
+
xe(this.errorHandler),
|
|
1791
|
+
R((o) => (M.getInstance().setSubject(!1), N(o))),
|
|
1792
|
+
me((o) => (M.getInstance().setSubject(!1), ie.getInstance().setSubject(
|
|
1793
|
+
new ee().get(o, n)
|
|
1767
1794
|
), ye))
|
|
1768
1795
|
);
|
|
1769
1796
|
}
|
|
1770
1797
|
}
|
|
1771
1798
|
export {
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1799
|
+
ut as ApiMiddleware,
|
|
1800
|
+
ee as ErrorCatalog,
|
|
1801
|
+
ft as FetchServiceBE,
|
|
1802
|
+
gt as FetchServiceFE,
|
|
1776
1803
|
M as LoadingHandler,
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1804
|
+
ie as MessageHandler,
|
|
1805
|
+
mt as RxSubjectManager,
|
|
1806
|
+
dt as ServiceToken
|
|
1780
1807
|
};
|