i18next 21.7.0 → 21.8.1
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/cjs/i18next.js +50 -27
- package/dist/esm/i18next.bundled.js +50 -27
- package/dist/esm/i18next.js +50 -27
- package/dist/esm/package.json +1 -1
- package/dist/umd/i18next.js +50 -27
- package/dist/umd/i18next.min.js +1 -1
- package/i18next.js +50 -27
- package/i18next.min.js +1 -1
- package/index.d.ts +18 -4
- package/package.json +1 -1
package/dist/cjs/i18next.js
CHANGED
|
@@ -1848,13 +1848,9 @@ function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeRefl
|
|
|
1848
1848
|
|
|
1849
1849
|
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1850
1850
|
|
|
1851
|
-
function
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
while (found !== -1) {
|
|
1855
|
-
arr.splice(found, 1);
|
|
1856
|
-
found = arr.indexOf(what);
|
|
1857
|
-
}
|
|
1851
|
+
function removePending(q, name) {
|
|
1852
|
+
delete q.pending[name];
|
|
1853
|
+
q.pendingCount--;
|
|
1858
1854
|
}
|
|
1859
1855
|
|
|
1860
1856
|
var Connector = function (_EventEmitter) {
|
|
@@ -1881,6 +1877,9 @@ var Connector = function (_EventEmitter) {
|
|
|
1881
1877
|
_this.languageUtils = services.languageUtils;
|
|
1882
1878
|
_this.options = options;
|
|
1883
1879
|
_this.logger = baseLogger.create('backendConnector');
|
|
1880
|
+
_this.waitingReads = [];
|
|
1881
|
+
_this.maxParallelReads = options.maxParallelReads || 10;
|
|
1882
|
+
_this.readingCalls = 0;
|
|
1884
1883
|
_this.state = {};
|
|
1885
1884
|
_this.queue = [];
|
|
1886
1885
|
|
|
@@ -1896,10 +1895,10 @@ var Connector = function (_EventEmitter) {
|
|
|
1896
1895
|
value: function queueLoad(languages, namespaces, options, callback) {
|
|
1897
1896
|
var _this2 = this;
|
|
1898
1897
|
|
|
1899
|
-
var toLoad =
|
|
1900
|
-
var pending =
|
|
1901
|
-
var toLoadLanguages =
|
|
1902
|
-
var toLoadNamespaces =
|
|
1898
|
+
var toLoad = {};
|
|
1899
|
+
var pending = {};
|
|
1900
|
+
var toLoadLanguages = {};
|
|
1901
|
+
var toLoadNamespaces = {};
|
|
1903
1902
|
languages.forEach(function (lng) {
|
|
1904
1903
|
var hasAllNamespaces = true;
|
|
1905
1904
|
namespaces.forEach(function (ns) {
|
|
@@ -1908,21 +1907,22 @@ var Connector = function (_EventEmitter) {
|
|
|
1908
1907
|
if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
|
|
1909
1908
|
_this2.state[name] = 2;
|
|
1910
1909
|
} else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
|
|
1911
|
-
if (pending
|
|
1910
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
1912
1911
|
} else {
|
|
1913
1912
|
_this2.state[name] = 1;
|
|
1914
1913
|
hasAllNamespaces = false;
|
|
1915
|
-
if (pending
|
|
1916
|
-
if (toLoad
|
|
1917
|
-
if (toLoadNamespaces
|
|
1914
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
1915
|
+
if (toLoad[name] === undefined) toLoad[name] = true;
|
|
1916
|
+
if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
|
|
1918
1917
|
}
|
|
1919
1918
|
});
|
|
1920
|
-
if (!hasAllNamespaces) toLoadLanguages
|
|
1919
|
+
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
1921
1920
|
});
|
|
1922
1921
|
|
|
1923
|
-
if (toLoad.length || pending.length) {
|
|
1922
|
+
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
|
1924
1923
|
this.queue.push({
|
|
1925
1924
|
pending: pending,
|
|
1925
|
+
pendingCount: Object.keys(pending).length,
|
|
1926
1926
|
loaded: {},
|
|
1927
1927
|
errors: [],
|
|
1928
1928
|
callback: callback
|
|
@@ -1930,10 +1930,10 @@ var Connector = function (_EventEmitter) {
|
|
|
1930
1930
|
}
|
|
1931
1931
|
|
|
1932
1932
|
return {
|
|
1933
|
-
toLoad: toLoad,
|
|
1934
|
-
pending: pending,
|
|
1935
|
-
toLoadLanguages: toLoadLanguages,
|
|
1936
|
-
toLoadNamespaces: toLoadNamespaces
|
|
1933
|
+
toLoad: Object.keys(toLoad),
|
|
1934
|
+
pending: Object.keys(pending),
|
|
1935
|
+
toLoadLanguages: Object.keys(toLoadLanguages),
|
|
1936
|
+
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
|
1937
1937
|
};
|
|
1938
1938
|
}
|
|
1939
1939
|
}, {
|
|
@@ -1952,16 +1952,17 @@ var Connector = function (_EventEmitter) {
|
|
|
1952
1952
|
var loaded = {};
|
|
1953
1953
|
this.queue.forEach(function (q) {
|
|
1954
1954
|
pushPath(q.loaded, [lng], ns);
|
|
1955
|
-
|
|
1955
|
+
removePending(q, name);
|
|
1956
1956
|
if (err) q.errors.push(err);
|
|
1957
1957
|
|
|
1958
|
-
if (q.
|
|
1958
|
+
if (q.pendingCount === 0 && !q.done) {
|
|
1959
1959
|
Object.keys(q.loaded).forEach(function (l) {
|
|
1960
|
-
if (!loaded[l]) loaded[l] =
|
|
1960
|
+
if (!loaded[l]) loaded[l] = {};
|
|
1961
|
+
var loadedKeys = Object.keys(loaded[l]);
|
|
1961
1962
|
|
|
1962
|
-
if (
|
|
1963
|
-
|
|
1964
|
-
if (
|
|
1963
|
+
if (loadedKeys.length) {
|
|
1964
|
+
loadedKeys.forEach(function (ns) {
|
|
1965
|
+
if (loadedKeys[ns] !== undefined) loaded[l][ns] = true;
|
|
1965
1966
|
});
|
|
1966
1967
|
}
|
|
1967
1968
|
});
|
|
@@ -1988,6 +1989,20 @@ var Connector = function (_EventEmitter) {
|
|
|
1988
1989
|
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 350;
|
|
1989
1990
|
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
1990
1991
|
if (!lng.length) return callback(null, {});
|
|
1992
|
+
|
|
1993
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
1994
|
+
this.waitingReads.push({
|
|
1995
|
+
lng: lng,
|
|
1996
|
+
ns: ns,
|
|
1997
|
+
fcName: fcName,
|
|
1998
|
+
tried: tried,
|
|
1999
|
+
wait: wait,
|
|
2000
|
+
callback: callback
|
|
2001
|
+
});
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
this.readingCalls++;
|
|
1991
2006
|
return this.backend[fcName](lng, ns, function (err, data) {
|
|
1992
2007
|
if (err && data && tried < 5) {
|
|
1993
2008
|
setTimeout(function () {
|
|
@@ -1996,6 +2011,14 @@ var Connector = function (_EventEmitter) {
|
|
|
1996
2011
|
return;
|
|
1997
2012
|
}
|
|
1998
2013
|
|
|
2014
|
+
_this3.readingCalls--;
|
|
2015
|
+
|
|
2016
|
+
if (_this3.waitingReads.length > 0) {
|
|
2017
|
+
var next = _this3.waitingReads.shift();
|
|
2018
|
+
|
|
2019
|
+
_this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
2020
|
+
}
|
|
2021
|
+
|
|
1999
2022
|
callback(err, data);
|
|
2000
2023
|
});
|
|
2001
2024
|
}
|
|
@@ -1994,13 +1994,9 @@ var Formatter = function () {
|
|
|
1994
1994
|
return Formatter;
|
|
1995
1995
|
}();
|
|
1996
1996
|
|
|
1997
|
-
function
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
while (found !== -1) {
|
|
2001
|
-
arr.splice(found, 1);
|
|
2002
|
-
found = arr.indexOf(what);
|
|
2003
|
-
}
|
|
1997
|
+
function removePending(q, name) {
|
|
1998
|
+
delete q.pending[name];
|
|
1999
|
+
q.pendingCount--;
|
|
2004
2000
|
}
|
|
2005
2001
|
|
|
2006
2002
|
var Connector = function (_EventEmitter) {
|
|
@@ -2027,6 +2023,9 @@ var Connector = function (_EventEmitter) {
|
|
|
2027
2023
|
_this.languageUtils = services.languageUtils;
|
|
2028
2024
|
_this.options = options;
|
|
2029
2025
|
_this.logger = baseLogger.create('backendConnector');
|
|
2026
|
+
_this.waitingReads = [];
|
|
2027
|
+
_this.maxParallelReads = options.maxParallelReads || 10;
|
|
2028
|
+
_this.readingCalls = 0;
|
|
2030
2029
|
_this.state = {};
|
|
2031
2030
|
_this.queue = [];
|
|
2032
2031
|
|
|
@@ -2042,10 +2041,10 @@ var Connector = function (_EventEmitter) {
|
|
|
2042
2041
|
value: function queueLoad(languages, namespaces, options, callback) {
|
|
2043
2042
|
var _this2 = this;
|
|
2044
2043
|
|
|
2045
|
-
var toLoad =
|
|
2046
|
-
var pending =
|
|
2047
|
-
var toLoadLanguages =
|
|
2048
|
-
var toLoadNamespaces =
|
|
2044
|
+
var toLoad = {};
|
|
2045
|
+
var pending = {};
|
|
2046
|
+
var toLoadLanguages = {};
|
|
2047
|
+
var toLoadNamespaces = {};
|
|
2049
2048
|
languages.forEach(function (lng) {
|
|
2050
2049
|
var hasAllNamespaces = true;
|
|
2051
2050
|
namespaces.forEach(function (ns) {
|
|
@@ -2054,21 +2053,22 @@ var Connector = function (_EventEmitter) {
|
|
|
2054
2053
|
if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
|
|
2055
2054
|
_this2.state[name] = 2;
|
|
2056
2055
|
} else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
|
|
2057
|
-
if (pending
|
|
2056
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
2058
2057
|
} else {
|
|
2059
2058
|
_this2.state[name] = 1;
|
|
2060
2059
|
hasAllNamespaces = false;
|
|
2061
|
-
if (pending
|
|
2062
|
-
if (toLoad
|
|
2063
|
-
if (toLoadNamespaces
|
|
2060
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
2061
|
+
if (toLoad[name] === undefined) toLoad[name] = true;
|
|
2062
|
+
if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
|
|
2064
2063
|
}
|
|
2065
2064
|
});
|
|
2066
|
-
if (!hasAllNamespaces) toLoadLanguages
|
|
2065
|
+
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
2067
2066
|
});
|
|
2068
2067
|
|
|
2069
|
-
if (toLoad.length || pending.length) {
|
|
2068
|
+
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
|
2070
2069
|
this.queue.push({
|
|
2071
2070
|
pending: pending,
|
|
2071
|
+
pendingCount: Object.keys(pending).length,
|
|
2072
2072
|
loaded: {},
|
|
2073
2073
|
errors: [],
|
|
2074
2074
|
callback: callback
|
|
@@ -2076,10 +2076,10 @@ var Connector = function (_EventEmitter) {
|
|
|
2076
2076
|
}
|
|
2077
2077
|
|
|
2078
2078
|
return {
|
|
2079
|
-
toLoad: toLoad,
|
|
2080
|
-
pending: pending,
|
|
2081
|
-
toLoadLanguages: toLoadLanguages,
|
|
2082
|
-
toLoadNamespaces: toLoadNamespaces
|
|
2079
|
+
toLoad: Object.keys(toLoad),
|
|
2080
|
+
pending: Object.keys(pending),
|
|
2081
|
+
toLoadLanguages: Object.keys(toLoadLanguages),
|
|
2082
|
+
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
|
2083
2083
|
};
|
|
2084
2084
|
}
|
|
2085
2085
|
}, {
|
|
@@ -2098,16 +2098,17 @@ var Connector = function (_EventEmitter) {
|
|
|
2098
2098
|
var loaded = {};
|
|
2099
2099
|
this.queue.forEach(function (q) {
|
|
2100
2100
|
pushPath(q.loaded, [lng], ns);
|
|
2101
|
-
|
|
2101
|
+
removePending(q, name);
|
|
2102
2102
|
if (err) q.errors.push(err);
|
|
2103
2103
|
|
|
2104
|
-
if (q.
|
|
2104
|
+
if (q.pendingCount === 0 && !q.done) {
|
|
2105
2105
|
Object.keys(q.loaded).forEach(function (l) {
|
|
2106
|
-
if (!loaded[l]) loaded[l] =
|
|
2106
|
+
if (!loaded[l]) loaded[l] = {};
|
|
2107
|
+
var loadedKeys = Object.keys(loaded[l]);
|
|
2107
2108
|
|
|
2108
|
-
if (
|
|
2109
|
-
|
|
2110
|
-
if (
|
|
2109
|
+
if (loadedKeys.length) {
|
|
2110
|
+
loadedKeys.forEach(function (ns) {
|
|
2111
|
+
if (loadedKeys[ns] !== undefined) loaded[l][ns] = true;
|
|
2111
2112
|
});
|
|
2112
2113
|
}
|
|
2113
2114
|
});
|
|
@@ -2134,6 +2135,20 @@ var Connector = function (_EventEmitter) {
|
|
|
2134
2135
|
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 350;
|
|
2135
2136
|
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
2136
2137
|
if (!lng.length) return callback(null, {});
|
|
2138
|
+
|
|
2139
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
2140
|
+
this.waitingReads.push({
|
|
2141
|
+
lng: lng,
|
|
2142
|
+
ns: ns,
|
|
2143
|
+
fcName: fcName,
|
|
2144
|
+
tried: tried,
|
|
2145
|
+
wait: wait,
|
|
2146
|
+
callback: callback
|
|
2147
|
+
});
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
this.readingCalls++;
|
|
2137
2152
|
return this.backend[fcName](lng, ns, function (err, data) {
|
|
2138
2153
|
if (err && data && tried < 5) {
|
|
2139
2154
|
setTimeout(function () {
|
|
@@ -2142,6 +2157,14 @@ var Connector = function (_EventEmitter) {
|
|
|
2142
2157
|
return;
|
|
2143
2158
|
}
|
|
2144
2159
|
|
|
2160
|
+
_this3.readingCalls--;
|
|
2161
|
+
|
|
2162
|
+
if (_this3.waitingReads.length > 0) {
|
|
2163
|
+
var next = _this3.waitingReads.shift();
|
|
2164
|
+
|
|
2165
|
+
_this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2145
2168
|
callback(err, data);
|
|
2146
2169
|
});
|
|
2147
2170
|
}
|
package/dist/esm/i18next.js
CHANGED
|
@@ -1834,13 +1834,9 @@ function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeRefl
|
|
|
1834
1834
|
|
|
1835
1835
|
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1836
1836
|
|
|
1837
|
-
function
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
while (found !== -1) {
|
|
1841
|
-
arr.splice(found, 1);
|
|
1842
|
-
found = arr.indexOf(what);
|
|
1843
|
-
}
|
|
1837
|
+
function removePending(q, name) {
|
|
1838
|
+
delete q.pending[name];
|
|
1839
|
+
q.pendingCount--;
|
|
1844
1840
|
}
|
|
1845
1841
|
|
|
1846
1842
|
var Connector = function (_EventEmitter) {
|
|
@@ -1867,6 +1863,9 @@ var Connector = function (_EventEmitter) {
|
|
|
1867
1863
|
_this.languageUtils = services.languageUtils;
|
|
1868
1864
|
_this.options = options;
|
|
1869
1865
|
_this.logger = baseLogger.create('backendConnector');
|
|
1866
|
+
_this.waitingReads = [];
|
|
1867
|
+
_this.maxParallelReads = options.maxParallelReads || 10;
|
|
1868
|
+
_this.readingCalls = 0;
|
|
1870
1869
|
_this.state = {};
|
|
1871
1870
|
_this.queue = [];
|
|
1872
1871
|
|
|
@@ -1882,10 +1881,10 @@ var Connector = function (_EventEmitter) {
|
|
|
1882
1881
|
value: function queueLoad(languages, namespaces, options, callback) {
|
|
1883
1882
|
var _this2 = this;
|
|
1884
1883
|
|
|
1885
|
-
var toLoad =
|
|
1886
|
-
var pending =
|
|
1887
|
-
var toLoadLanguages =
|
|
1888
|
-
var toLoadNamespaces =
|
|
1884
|
+
var toLoad = {};
|
|
1885
|
+
var pending = {};
|
|
1886
|
+
var toLoadLanguages = {};
|
|
1887
|
+
var toLoadNamespaces = {};
|
|
1889
1888
|
languages.forEach(function (lng) {
|
|
1890
1889
|
var hasAllNamespaces = true;
|
|
1891
1890
|
namespaces.forEach(function (ns) {
|
|
@@ -1894,21 +1893,22 @@ var Connector = function (_EventEmitter) {
|
|
|
1894
1893
|
if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
|
|
1895
1894
|
_this2.state[name] = 2;
|
|
1896
1895
|
} else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
|
|
1897
|
-
if (pending
|
|
1896
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
1898
1897
|
} else {
|
|
1899
1898
|
_this2.state[name] = 1;
|
|
1900
1899
|
hasAllNamespaces = false;
|
|
1901
|
-
if (pending
|
|
1902
|
-
if (toLoad
|
|
1903
|
-
if (toLoadNamespaces
|
|
1900
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
1901
|
+
if (toLoad[name] === undefined) toLoad[name] = true;
|
|
1902
|
+
if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
|
|
1904
1903
|
}
|
|
1905
1904
|
});
|
|
1906
|
-
if (!hasAllNamespaces) toLoadLanguages
|
|
1905
|
+
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
1907
1906
|
});
|
|
1908
1907
|
|
|
1909
|
-
if (toLoad.length || pending.length) {
|
|
1908
|
+
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
|
1910
1909
|
this.queue.push({
|
|
1911
1910
|
pending: pending,
|
|
1911
|
+
pendingCount: Object.keys(pending).length,
|
|
1912
1912
|
loaded: {},
|
|
1913
1913
|
errors: [],
|
|
1914
1914
|
callback: callback
|
|
@@ -1916,10 +1916,10 @@ var Connector = function (_EventEmitter) {
|
|
|
1916
1916
|
}
|
|
1917
1917
|
|
|
1918
1918
|
return {
|
|
1919
|
-
toLoad: toLoad,
|
|
1920
|
-
pending: pending,
|
|
1921
|
-
toLoadLanguages: toLoadLanguages,
|
|
1922
|
-
toLoadNamespaces: toLoadNamespaces
|
|
1919
|
+
toLoad: Object.keys(toLoad),
|
|
1920
|
+
pending: Object.keys(pending),
|
|
1921
|
+
toLoadLanguages: Object.keys(toLoadLanguages),
|
|
1922
|
+
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
|
1923
1923
|
};
|
|
1924
1924
|
}
|
|
1925
1925
|
}, {
|
|
@@ -1938,16 +1938,17 @@ var Connector = function (_EventEmitter) {
|
|
|
1938
1938
|
var loaded = {};
|
|
1939
1939
|
this.queue.forEach(function (q) {
|
|
1940
1940
|
pushPath(q.loaded, [lng], ns);
|
|
1941
|
-
|
|
1941
|
+
removePending(q, name);
|
|
1942
1942
|
if (err) q.errors.push(err);
|
|
1943
1943
|
|
|
1944
|
-
if (q.
|
|
1944
|
+
if (q.pendingCount === 0 && !q.done) {
|
|
1945
1945
|
Object.keys(q.loaded).forEach(function (l) {
|
|
1946
|
-
if (!loaded[l]) loaded[l] =
|
|
1946
|
+
if (!loaded[l]) loaded[l] = {};
|
|
1947
|
+
var loadedKeys = Object.keys(loaded[l]);
|
|
1947
1948
|
|
|
1948
|
-
if (
|
|
1949
|
-
|
|
1950
|
-
if (
|
|
1949
|
+
if (loadedKeys.length) {
|
|
1950
|
+
loadedKeys.forEach(function (ns) {
|
|
1951
|
+
if (loadedKeys[ns] !== undefined) loaded[l][ns] = true;
|
|
1951
1952
|
});
|
|
1952
1953
|
}
|
|
1953
1954
|
});
|
|
@@ -1974,6 +1975,20 @@ var Connector = function (_EventEmitter) {
|
|
|
1974
1975
|
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 350;
|
|
1975
1976
|
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
1976
1977
|
if (!lng.length) return callback(null, {});
|
|
1978
|
+
|
|
1979
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
1980
|
+
this.waitingReads.push({
|
|
1981
|
+
lng: lng,
|
|
1982
|
+
ns: ns,
|
|
1983
|
+
fcName: fcName,
|
|
1984
|
+
tried: tried,
|
|
1985
|
+
wait: wait,
|
|
1986
|
+
callback: callback
|
|
1987
|
+
});
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
this.readingCalls++;
|
|
1977
1992
|
return this.backend[fcName](lng, ns, function (err, data) {
|
|
1978
1993
|
if (err && data && tried < 5) {
|
|
1979
1994
|
setTimeout(function () {
|
|
@@ -1982,6 +1997,14 @@ var Connector = function (_EventEmitter) {
|
|
|
1982
1997
|
return;
|
|
1983
1998
|
}
|
|
1984
1999
|
|
|
2000
|
+
_this3.readingCalls--;
|
|
2001
|
+
|
|
2002
|
+
if (_this3.waitingReads.length > 0) {
|
|
2003
|
+
var next = _this3.waitingReads.shift();
|
|
2004
|
+
|
|
2005
|
+
_this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
2006
|
+
}
|
|
2007
|
+
|
|
1985
2008
|
callback(err, data);
|
|
1986
2009
|
});
|
|
1987
2010
|
}
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"21.
|
|
1
|
+
{"type":"module","version":"21.8.1"}
|
package/dist/umd/i18next.js
CHANGED
|
@@ -1967,13 +1967,9 @@
|
|
|
1967
1967
|
|
|
1968
1968
|
function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1969
1969
|
|
|
1970
|
-
function
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
while (found !== -1) {
|
|
1974
|
-
arr.splice(found, 1);
|
|
1975
|
-
found = arr.indexOf(what);
|
|
1976
|
-
}
|
|
1970
|
+
function removePending(q, name) {
|
|
1971
|
+
delete q.pending[name];
|
|
1972
|
+
q.pendingCount--;
|
|
1977
1973
|
}
|
|
1978
1974
|
|
|
1979
1975
|
var Connector = function (_EventEmitter) {
|
|
@@ -2000,6 +1996,9 @@
|
|
|
2000
1996
|
_this.languageUtils = services.languageUtils;
|
|
2001
1997
|
_this.options = options;
|
|
2002
1998
|
_this.logger = baseLogger.create('backendConnector');
|
|
1999
|
+
_this.waitingReads = [];
|
|
2000
|
+
_this.maxParallelReads = options.maxParallelReads || 10;
|
|
2001
|
+
_this.readingCalls = 0;
|
|
2003
2002
|
_this.state = {};
|
|
2004
2003
|
_this.queue = [];
|
|
2005
2004
|
|
|
@@ -2015,10 +2014,10 @@
|
|
|
2015
2014
|
value: function queueLoad(languages, namespaces, options, callback) {
|
|
2016
2015
|
var _this2 = this;
|
|
2017
2016
|
|
|
2018
|
-
var toLoad =
|
|
2019
|
-
var pending =
|
|
2020
|
-
var toLoadLanguages =
|
|
2021
|
-
var toLoadNamespaces =
|
|
2017
|
+
var toLoad = {};
|
|
2018
|
+
var pending = {};
|
|
2019
|
+
var toLoadLanguages = {};
|
|
2020
|
+
var toLoadNamespaces = {};
|
|
2022
2021
|
languages.forEach(function (lng) {
|
|
2023
2022
|
var hasAllNamespaces = true;
|
|
2024
2023
|
namespaces.forEach(function (ns) {
|
|
@@ -2027,21 +2026,22 @@
|
|
|
2027
2026
|
if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
|
|
2028
2027
|
_this2.state[name] = 2;
|
|
2029
2028
|
} else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
|
|
2030
|
-
if (pending
|
|
2029
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
2031
2030
|
} else {
|
|
2032
2031
|
_this2.state[name] = 1;
|
|
2033
2032
|
hasAllNamespaces = false;
|
|
2034
|
-
if (pending
|
|
2035
|
-
if (toLoad
|
|
2036
|
-
if (toLoadNamespaces
|
|
2033
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
2034
|
+
if (toLoad[name] === undefined) toLoad[name] = true;
|
|
2035
|
+
if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
|
|
2037
2036
|
}
|
|
2038
2037
|
});
|
|
2039
|
-
if (!hasAllNamespaces) toLoadLanguages
|
|
2038
|
+
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
2040
2039
|
});
|
|
2041
2040
|
|
|
2042
|
-
if (toLoad.length || pending.length) {
|
|
2041
|
+
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
|
2043
2042
|
this.queue.push({
|
|
2044
2043
|
pending: pending,
|
|
2044
|
+
pendingCount: Object.keys(pending).length,
|
|
2045
2045
|
loaded: {},
|
|
2046
2046
|
errors: [],
|
|
2047
2047
|
callback: callback
|
|
@@ -2049,10 +2049,10 @@
|
|
|
2049
2049
|
}
|
|
2050
2050
|
|
|
2051
2051
|
return {
|
|
2052
|
-
toLoad: toLoad,
|
|
2053
|
-
pending: pending,
|
|
2054
|
-
toLoadLanguages: toLoadLanguages,
|
|
2055
|
-
toLoadNamespaces: toLoadNamespaces
|
|
2052
|
+
toLoad: Object.keys(toLoad),
|
|
2053
|
+
pending: Object.keys(pending),
|
|
2054
|
+
toLoadLanguages: Object.keys(toLoadLanguages),
|
|
2055
|
+
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
|
2056
2056
|
};
|
|
2057
2057
|
}
|
|
2058
2058
|
}, {
|
|
@@ -2071,16 +2071,17 @@
|
|
|
2071
2071
|
var loaded = {};
|
|
2072
2072
|
this.queue.forEach(function (q) {
|
|
2073
2073
|
pushPath(q.loaded, [lng], ns);
|
|
2074
|
-
|
|
2074
|
+
removePending(q, name);
|
|
2075
2075
|
if (err) q.errors.push(err);
|
|
2076
2076
|
|
|
2077
|
-
if (q.
|
|
2077
|
+
if (q.pendingCount === 0 && !q.done) {
|
|
2078
2078
|
Object.keys(q.loaded).forEach(function (l) {
|
|
2079
|
-
if (!loaded[l]) loaded[l] =
|
|
2079
|
+
if (!loaded[l]) loaded[l] = {};
|
|
2080
|
+
var loadedKeys = Object.keys(loaded[l]);
|
|
2080
2081
|
|
|
2081
|
-
if (
|
|
2082
|
-
|
|
2083
|
-
if (
|
|
2082
|
+
if (loadedKeys.length) {
|
|
2083
|
+
loadedKeys.forEach(function (ns) {
|
|
2084
|
+
if (loadedKeys[ns] !== undefined) loaded[l][ns] = true;
|
|
2084
2085
|
});
|
|
2085
2086
|
}
|
|
2086
2087
|
});
|
|
@@ -2107,6 +2108,20 @@
|
|
|
2107
2108
|
var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 350;
|
|
2108
2109
|
var callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
2109
2110
|
if (!lng.length) return callback(null, {});
|
|
2111
|
+
|
|
2112
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
2113
|
+
this.waitingReads.push({
|
|
2114
|
+
lng: lng,
|
|
2115
|
+
ns: ns,
|
|
2116
|
+
fcName: fcName,
|
|
2117
|
+
tried: tried,
|
|
2118
|
+
wait: wait,
|
|
2119
|
+
callback: callback
|
|
2120
|
+
});
|
|
2121
|
+
return;
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
this.readingCalls++;
|
|
2110
2125
|
return this.backend[fcName](lng, ns, function (err, data) {
|
|
2111
2126
|
if (err && data && tried < 5) {
|
|
2112
2127
|
setTimeout(function () {
|
|
@@ -2115,6 +2130,14 @@
|
|
|
2115
2130
|
return;
|
|
2116
2131
|
}
|
|
2117
2132
|
|
|
2133
|
+
_this3.readingCalls--;
|
|
2134
|
+
|
|
2135
|
+
if (_this3.waitingReads.length > 0) {
|
|
2136
|
+
var next = _this3.waitingReads.shift();
|
|
2137
|
+
|
|
2138
|
+
_this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2118
2141
|
callback(err, data);
|
|
2119
2142
|
});
|
|
2120
2143
|
}
|