i18next-http-backend
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
@@ -13,3 +13,3 @@ var _utils = require("./utils.js"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -36,3 +36,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
}, | ||
request: _request["default"], | ||
request: _request.default, | ||
reloadInterval: false, | ||
@@ -42,9 +42,5 @@ customHeaders: {}, | ||
crossDomain: false, | ||
// used for XmlHttpRequest | ||
withCredentials: false, | ||
// used for XmlHttpRequest | ||
overrideMimeType: false, | ||
// used for XmlHttpRequest | ||
requestOptions: { | ||
// used for fetch | ||
mode: 'cors', | ||
@@ -57,3 +53,3 @@ credentials: 'same-origin', | ||
var Backend = /*#__PURE__*/function () { | ||
var Backend = function () { | ||
function Backend(services) { | ||
@@ -125,8 +121,4 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
this.options.request(this.options, url, undefined, function (err, res) { | ||
if (res && res.status >= 500 && res.status < 600) return callback('failed loading ' + url, true | ||
/* retry */ | ||
); | ||
if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + url, false | ||
/* no retry */ | ||
); | ||
if (res && res.status >= 500 && res.status < 600) return callback('failed loading ' + url, true); | ||
if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + url, false); | ||
if (err) return callback(err, false); | ||
@@ -150,3 +142,2 @@ var ret, parseErr; | ||
// If there is a falsey addPath, then abort -- this has been disabled. | ||
if (!this.options.addPath) return; | ||
@@ -161,4 +152,3 @@ if (typeof languages === 'string') languages = [languages]; | ||
_this3.options.request(_this3.options, url, payload, function (data, res) {// TODO: if res.status === 4xx do log | ||
}); | ||
_this3.options.request(_this3.options, url, payload, function (data, res) {}); | ||
}); | ||
@@ -176,4 +166,3 @@ } | ||
var currentLanguage = backendConnector.language; | ||
if (currentLanguage && currentLanguage.toLowerCase() === 'cimode') return; // avoid loading resources for cimode | ||
if (currentLanguage && currentLanguage.toLowerCase() === 'cimode') return; | ||
var toLoad = []; | ||
@@ -209,3 +198,3 @@ | ||
var _default = Backend; | ||
exports["default"] = _default; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
@@ -15,3 +15,3 @@ var _utils = require("./utils.js"); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
@@ -50,4 +50,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
if (!fetchApi && fetchNode && !XmlHttpRequestApi && !ActiveXObjectApi) fetchApi = fetchNode["default"] || fetchNode; // because of strange export | ||
if (!fetchApi && fetchNode && !XmlHttpRequestApi && !ActiveXObjectApi) fetchApi = fetchNode.default || fetchNode; | ||
if (typeof fetchApi !== 'function') fetchApi = undefined; | ||
@@ -57,3 +56,3 @@ | ||
if (params && _typeof(params) === 'object') { | ||
var queryString = ''; // Must encode data | ||
var queryString = ''; | ||
@@ -69,5 +68,4 @@ for (var paramName in params) { | ||
return url; | ||
}; // fetch api stuff | ||
}; | ||
var requestWithFetch = function requestWithFetch(options, url, payload, callback) { | ||
@@ -93,11 +91,8 @@ if (options.queryStringParams) { | ||
}); | ||
})["catch"](callback); | ||
})["catch"](callback); | ||
}; // xml http request stuff | ||
}).catch(callback); | ||
}).catch(callback); | ||
}; | ||
var requestWithXmlHttpRequest = function requestWithXmlHttpRequest(options, url, payload, callback) { | ||
if (payload && _typeof(payload) === 'object') { | ||
// if (!cache) payload._t = Date.now() | ||
// URL encoded form payload must be in querystring format | ||
payload = addQueryString('', payload).slice(1); | ||
@@ -166,3 +161,2 @@ } | ||
if (fetchApi) { | ||
// use fetch api | ||
return requestWithFetch(options, url, payload, callback); | ||
@@ -172,3 +166,2 @@ } | ||
if (typeof XMLHttpRequest === 'function' || typeof ActiveXObject === 'function') { | ||
// use xml http request | ||
return requestWithXmlHttpRequest(options, url, payload, callback); | ||
@@ -179,3 +172,3 @@ } | ||
var _default = request; | ||
exports["default"] = _default; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -26,3 +26,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.i18nextHttpBackend = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
@@ -33,3 +33,3 @@ var _utils = require("./utils.js"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -56,3 +56,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
}, | ||
request: _request["default"], | ||
request: _request.default, | ||
reloadInterval: false, | ||
@@ -62,9 +62,5 @@ customHeaders: {}, | ||
crossDomain: false, | ||
// used for XmlHttpRequest | ||
withCredentials: false, | ||
// used for XmlHttpRequest | ||
overrideMimeType: false, | ||
// used for XmlHttpRequest | ||
requestOptions: { | ||
// used for fetch | ||
mode: 'cors', | ||
@@ -77,3 +73,3 @@ credentials: 'same-origin', | ||
var Backend = /*#__PURE__*/function () { | ||
var Backend = function () { | ||
function Backend(services) { | ||
@@ -145,8 +141,4 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
this.options.request(this.options, url, undefined, function (err, res) { | ||
if (res && res.status >= 500 && res.status < 600) return callback('failed loading ' + url, true | ||
/* retry */ | ||
); | ||
if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + url, false | ||
/* no retry */ | ||
); | ||
if (res && res.status >= 500 && res.status < 600) return callback('failed loading ' + url, true); | ||
if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + url, false); | ||
if (err) return callback(err, false); | ||
@@ -170,3 +162,2 @@ var ret, parseErr; | ||
// If there is a falsey addPath, then abort -- this has been disabled. | ||
if (!this.options.addPath) return; | ||
@@ -181,4 +172,3 @@ if (typeof languages === 'string') languages = [languages]; | ||
_this3.options.request(_this3.options, url, payload, function (data, res) {// TODO: if res.status === 4xx do log | ||
}); | ||
_this3.options.request(_this3.options, url, payload, function (data, res) {}); | ||
}); | ||
@@ -196,4 +186,3 @@ } | ||
var currentLanguage = backendConnector.language; | ||
if (currentLanguage && currentLanguage.toLowerCase() === 'cimode') return; // avoid loading resources for cimode | ||
if (currentLanguage && currentLanguage.toLowerCase() === 'cimode') return; | ||
var toLoad = []; | ||
@@ -229,3 +218,3 @@ | ||
var _default = Backend; | ||
exports["default"] = _default; | ||
exports.default = _default; | ||
module.exports = exports.default; | ||
@@ -239,3 +228,3 @@ },{"./request.js":3,"./utils.js":4}],3:[function(require,module,exports){ | ||
}); | ||
exports["default"] = void 0; | ||
exports.default = void 0; | ||
@@ -248,3 +237,3 @@ var _utils = require("./utils.js"); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
@@ -283,4 +272,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
if (!fetchApi && fetchNode && !XmlHttpRequestApi && !ActiveXObjectApi) fetchApi = fetchNode["default"] || fetchNode; // because of strange export | ||
if (!fetchApi && fetchNode && !XmlHttpRequestApi && !ActiveXObjectApi) fetchApi = fetchNode.default || fetchNode; | ||
if (typeof fetchApi !== 'function') fetchApi = undefined; | ||
@@ -290,3 +278,3 @@ | ||
if (params && _typeof(params) === 'object') { | ||
var queryString = ''; // Must encode data | ||
var queryString = ''; | ||
@@ -302,5 +290,4 @@ for (var paramName in params) { | ||
return url; | ||
}; // fetch api stuff | ||
}; | ||
var requestWithFetch = function requestWithFetch(options, url, payload, callback) { | ||
@@ -326,11 +313,8 @@ if (options.queryStringParams) { | ||
}); | ||
})["catch"](callback); | ||
})["catch"](callback); | ||
}; // xml http request stuff | ||
}).catch(callback); | ||
}).catch(callback); | ||
}; | ||
var requestWithXmlHttpRequest = function requestWithXmlHttpRequest(options, url, payload, callback) { | ||
if (payload && _typeof(payload) === 'object') { | ||
// if (!cache) payload._t = Date.now() | ||
// URL encoded form payload must be in querystring format | ||
payload = addQueryString('', payload).slice(1); | ||
@@ -399,3 +383,2 @@ } | ||
if (fetchApi) { | ||
// use fetch api | ||
return requestWithFetch(options, url, payload, callback); | ||
@@ -405,3 +388,2 @@ } | ||
if (typeof XMLHttpRequest === 'function' || typeof ActiveXObject === 'function') { | ||
// use xml http request | ||
return requestWithXmlHttpRequest(options, url, payload, callback); | ||
@@ -412,3 +394,3 @@ } | ||
var _default = request; | ||
exports["default"] = _default; | ||
exports.default = _default; | ||
module.exports = exports.default; | ||
@@ -415,0 +397,0 @@ }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
@@ -1,1 +0,1 @@ | ||
!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).i18nextHttpBackend=e()}(function(){return function r(a,s,u){function f(t,e){if(!s[t]){if(!a[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(l)return l(t,!0);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}var i=s[t]={exports:{}};a[t][0].call(i.exports,function(e){return f(a[t][1][e]||e)},i,i.exports,r,a,s,u)}return s[t].exports}for(var l="function"==typeof require&&require,e=0;e<u.length;e++)f(u[e]);return f}({1:[function(o,i,r){(function(e){var t,n;"function"==typeof fetch&&(void 0!==e&&e.fetch?t=e.fetch:"undefined"!=typeof window&&window.fetch&&(t=window.fetch)),void 0===o||"undefined"!=typeof window&&void 0!==window.document||((n=t||o("node-fetch")).default&&(n=n.default),r.default=n,i.exports=r.default)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"node-fetch":5}],2:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o,a=e("./utils.js"),i=(o=e("./request.js"))&&o.__esModule?o:{default:o};function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function s(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",allowMultiLoading:!1,parse:function(e){return JSON.parse(e)},stringify:JSON.stringify,parsePayload:function(e,t,n){return r=n||"",(i=t)in(o={})?Object.defineProperty(o,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):o[i]=r,o;var o,i,r},request:i.default,reloadInterval:!1,customHeaders:{},queryStringParams:{},crossDomain:!1,withCredentials:!1,overrideMimeType:!1,requestOptions:{mode:"cors",credentials:"same-origin",cache:"default"}}}var u=function(){function o(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),this.services=e,this.options=t,this.allOptions=n,this.type="backend",this.init(e,t,n)}var e,t,n;return e=o,(t=[{key:"init",value:function(e,t,n){var o=this,i=1<arguments.length&&void 0!==t?t:{},r=2<arguments.length&&void 0!==n?n:{};this.services=e,this.options=(0,a.defaults)(i,this.options||{},s()),this.allOptions=r,this.options.reloadInterval&&setInterval(function(){return o.reload()},this.options.reloadInterval)}},{key:"readMulti",value:function(e,t,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath(e,t));var i=this.services.interpolator.interpolate(o,{lng:e.join("+"),ns:t.join("+")});this.loadUrl(i,n,e,t)}},{key:"read",value:function(e,t,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath([e],[t]));var i=this.services.interpolator.interpolate(o,{lng:e,ns:t});this.loadUrl(i,n,e,t)}},{key:"loadUrl",value:function(i,r,a,s){var u=this;this.options.request(this.options,i,void 0,function(e,t){if(t&&500<=t.status&&t.status<600)return r("failed loading "+i,!0);if(t&&400<=t.status&&t.status<500)return r("failed loading "+i,!1);if(e)return r(e,!1);var n,o;try{n=u.options.parse(t.data,a,s)}catch(e){o="failed parsing "+i+" to json"}if(o)return r(o,!1);r(null,n)})}},{key:"create",value:function(e,n,t,o){var i,r=this;this.options.addPath&&("string"==typeof e&&(e=[e]),i=this.options.parsePayload(n,t,o),e.forEach(function(e){var t=r.services.interpolator.interpolate(r.options.addPath,{lng:e,ns:n});r.options.request(r.options,t,i,function(e,t){})}))}},{key:"reload",value:function(){var t,e,n=this,o=this.services,i=o.backendConnector,r=o.languageUtils,a=o.logger,s=i.language;s&&"cimode"===s.toLowerCase()||(t=[],(e=function(e){r.toResolveHierarchy(e).forEach(function(e){t.indexOf(e)<0&&t.push(e)})})(s),this.allOptions.preload&&this.allOptions.preload.forEach(e),t.forEach(function(o){n.allOptions.ns.forEach(function(n){i.read(o,n,"read",null,null,function(e,t){e&&a.warn("loading namespace ".concat(n," for language ").concat(o," failed"),e),!e&&t&&a.log("loaded namespace ".concat(n," for language ").concat(o),t),i.loaded("".concat(o,"|").concat(n),e,t)})})}))}}])&&r(e.prototype,t),n&&r(e,n),o}();u.type="backend",n.default=u,t.exports=n.default},{"./request.js":3,"./utils.js":4}],3:[function(o,i,d){(function(e){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.default=void 0;var r,s,u,a=o("./utils.js"),t=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==l(e)&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e){var r;Object.prototype.hasOwnProperty.call(e,i)&&((r=o?Object.getOwnPropertyDescriptor(e,i):null)&&(r.get||r.set)?Object.defineProperty(n,i,r):n[i]=e[i])}n.default=e,t&&t.set(e,n);return n}(o("./getFetch.js"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}"function"==typeof fetch&&(void 0!==e&&e.fetch?r=e.fetch:"undefined"!=typeof window&&window.fetch&&(r=window.fetch)),"function"==typeof XMLHttpRequest&&(void 0!==e&&e.XMLHttpRequest?s=e.XMLHttpRequest:"undefined"!=typeof window&&window.XMLHttpRequest&&(s=window.XMLHttpRequest)),"function"==typeof ActiveXObject&&(void 0!==e&&e.ActiveXObject?u=e.ActiveXObject:"undefined"!=typeof window&&window.ActiveXObject&&(u=window.ActiveXObject)),r||!t||s||u||(r=t.default||t),"function"!=typeof r&&(r=void 0);function c(e,t){if(t&&"object"===l(t)){var n="";for(var o in t)n+="&"+encodeURIComponent(o)+"="+encodeURIComponent(t[o]);if(!n)return e;e=e+(-1!==e.indexOf("?")?"&":"?")+n.slice(1)}return e}function n(e,t,n,o){return"function"==typeof n&&(o=n,n=void 0),o=o||function(){},r?function(e,t,n,o){e.queryStringParams&&(t=c(t,e.queryStringParams));var i=(0,a.defaults)({},e.customHeaders);n&&(i["Content-Type"]="application/json"),r(t,(0,a.defaults)({method:n?"POST":"GET",body:n?e.stringify(n):void 0,headers:i},"function"==typeof e.requestOptions?e.requestOptions(n):e.requestOptions)).then(function(t){if(!t.ok)return o(t.statusText||"Error",{status:t.status});t.text().then(function(e){o(null,{status:t.status,data:e})}).catch(o)}).catch(o)}(e,t,n,o):"function"==typeof XMLHttpRequest||"function"==typeof ActiveXObject?function(e,t,n,o){n&&"object"===l(n)&&(n=c("",n).slice(1)),e.queryStringParams&&(t=c(t,e.queryStringParams));try{var i=s?new s:new u("MSXML2.XMLHTTP.3.0");i.open(n?"POST":"GET",t,1),e.crossDomain||i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.withCredentials=!!e.withCredentials,n&&i.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),i.overrideMimeType&&i.overrideMimeType("application/json");var r=e.customHeaders;if(r="function"==typeof r?r():r)for(var a in r)i.setRequestHeader(a,r[a]);i.onreadystatechange=function(){3<i.readyState&&o(400<=i.status?i.statusText:null,{status:i.status,data:i.responseText})},i.send(n)}catch(e){console&&console.log(e)}}(e,t,n,o):void 0}d.default=n,i.exports=d.default}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./getFetch.js":1,"./utils.js":4}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.defaults=function(n){return i.call(r.call(arguments,1),function(e){if(e)for(var t in e)void 0===n[t]&&(n[t]=e[t])}),n};var o=[],i=o.forEach,r=o.slice},{}],5:[function(e,t,n){},{}]},{},[2])(2)}); | ||
!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).i18nextHttpBackend=e()}(function(){return function r(a,s,u){function f(t,e){if(!s[t]){if(!a[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(l)return l(t,!0);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}var i=s[t]={exports:{}};a[t][0].call(i.exports,function(e){return f(a[t][1][e]||e)},i,i.exports,r,a,s,u)}return s[t].exports}for(var l="function"==typeof require&&require,e=0;e<u.length;e++)f(u[e]);return f}({1:[function(o,i,r){(function(e){var t,n;"function"==typeof fetch&&(void 0!==e&&e.fetch?t=e.fetch:"undefined"!=typeof window&&window.fetch&&(t=window.fetch)),void 0===o||"undefined"!=typeof window&&void 0!==window.document||((n=t||o("node-fetch")).default&&(n=n.default),r.default=n,i.exports=r.default)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"node-fetch":5}],2:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o,a=e("./utils.js"),i=(o=e("./request.js"))&&o.__esModule?o:{default:o};function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function s(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",allowMultiLoading:!1,parse:function(e){return JSON.parse(e)},stringify:JSON.stringify,parsePayload:function(e,t,n){return r=n||"",(i=t)in(o={})?Object.defineProperty(o,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):o[i]=r,o;var o,i,r},request:i.default,reloadInterval:!1,customHeaders:{},queryStringParams:{},crossDomain:!1,withCredentials:!1,overrideMimeType:!1,requestOptions:{mode:"cors",credentials:"same-origin",cache:"default"}}}var u,f,l=(r((u=c).prototype,[{key:"init",value:function(e,t,n){var o=this,i=1<arguments.length&&void 0!==t?t:{},r=2<arguments.length&&void 0!==n?n:{};this.services=e,this.options=(0,a.defaults)(i,this.options||{},s()),this.allOptions=r,this.options.reloadInterval&&setInterval(function(){return o.reload()},this.options.reloadInterval)}},{key:"readMulti",value:function(e,t,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath(e,t));var i=this.services.interpolator.interpolate(o,{lng:e.join("+"),ns:t.join("+")});this.loadUrl(i,n,e,t)}},{key:"read",value:function(e,t,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath([e],[t]));var i=this.services.interpolator.interpolate(o,{lng:e,ns:t});this.loadUrl(i,n,e,t)}},{key:"loadUrl",value:function(i,r,a,s){var u=this;this.options.request(this.options,i,void 0,function(e,t){if(t&&500<=t.status&&t.status<600)return r("failed loading "+i,!0);if(t&&400<=t.status&&t.status<500)return r("failed loading "+i,!1);if(e)return r(e,!1);var n,o;try{n=u.options.parse(t.data,a,s)}catch(e){o="failed parsing "+i+" to json"}if(o)return r(o,!1);r(null,n)})}},{key:"create",value:function(e,n,t,o){var i,r=this;this.options.addPath&&("string"==typeof e&&(e=[e]),i=this.options.parsePayload(n,t,o),e.forEach(function(e){var t=r.services.interpolator.interpolate(r.options.addPath,{lng:e,ns:n});r.options.request(r.options,t,i,function(e,t){})}))}},{key:"reload",value:function(){var t,e,n=this,o=this.services,i=o.backendConnector,r=o.languageUtils,a=o.logger,s=i.language;s&&"cimode"===s.toLowerCase()||(t=[],(e=function(e){r.toResolveHierarchy(e).forEach(function(e){t.indexOf(e)<0&&t.push(e)})})(s),this.allOptions.preload&&this.allOptions.preload.forEach(e),t.forEach(function(o){n.allOptions.ns.forEach(function(n){i.read(o,n,"read",null,null,function(e,t){e&&a.warn("loading namespace ".concat(n," for language ").concat(o," failed"),e),!e&&t&&a.log("loaded namespace ".concat(n," for language ").concat(o),t),i.loaded("".concat(o,"|").concat(n),e,t)})})}))}}]),f&&r(u,f),c);function c(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),this.services=e,this.options=t,this.allOptions=n,this.type="backend",this.init(e,t,n)}l.type="backend",n.default=l,t.exports=n.default},{"./request.js":3,"./utils.js":4}],3:[function(o,i,d){(function(e){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.default=void 0;var r,s,u,a=o("./utils.js"),t=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==l(e)&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e){var r;Object.prototype.hasOwnProperty.call(e,i)&&((r=o?Object.getOwnPropertyDescriptor(e,i):null)&&(r.get||r.set)?Object.defineProperty(n,i,r):n[i]=e[i])}n.default=e,t&&t.set(e,n);return n}(o("./getFetch.js"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}"function"==typeof fetch&&(void 0!==e&&e.fetch?r=e.fetch:"undefined"!=typeof window&&window.fetch&&(r=window.fetch)),"function"==typeof XMLHttpRequest&&(void 0!==e&&e.XMLHttpRequest?s=e.XMLHttpRequest:"undefined"!=typeof window&&window.XMLHttpRequest&&(s=window.XMLHttpRequest)),"function"==typeof ActiveXObject&&(void 0!==e&&e.ActiveXObject?u=e.ActiveXObject:"undefined"!=typeof window&&window.ActiveXObject&&(u=window.ActiveXObject)),r||!t||s||u||(r=t.default||t),"function"!=typeof r&&(r=void 0);function c(e,t){if(t&&"object"===l(t)){var n="";for(var o in t)n+="&"+encodeURIComponent(o)+"="+encodeURIComponent(t[o]);if(!n)return e;e=e+(-1!==e.indexOf("?")?"&":"?")+n.slice(1)}return e}function n(e,t,n,o){return"function"==typeof n&&(o=n,n=void 0),o=o||function(){},r?function(e,t,n,o){e.queryStringParams&&(t=c(t,e.queryStringParams));var i=(0,a.defaults)({},e.customHeaders);n&&(i["Content-Type"]="application/json"),r(t,(0,a.defaults)({method:n?"POST":"GET",body:n?e.stringify(n):void 0,headers:i},"function"==typeof e.requestOptions?e.requestOptions(n):e.requestOptions)).then(function(t){return t.ok?void t.text().then(function(e){o(null,{status:t.status,data:e})}).catch(o):o(t.statusText||"Error",{status:t.status})}).catch(o)}(e,t,n,o):"function"==typeof XMLHttpRequest||"function"==typeof ActiveXObject?function(e,t,n,o){n&&"object"===l(n)&&(n=c("",n).slice(1)),e.queryStringParams&&(t=c(t,e.queryStringParams));try{var i=s?new s:new u("MSXML2.XMLHTTP.3.0");i.open(n?"POST":"GET",t,1),e.crossDomain||i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.withCredentials=!!e.withCredentials,n&&i.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),i.overrideMimeType&&i.overrideMimeType("application/json");var r=e.customHeaders;if(r="function"==typeof r?r():r)for(var a in r)i.setRequestHeader(a,r[a]);i.onreadystatechange=function(){3<i.readyState&&o(400<=i.status?i.statusText:null,{status:i.status,data:i.responseText})},i.send(n)}catch(e){console&&console.log(e)}}(e,t,n,o):void 0}d.default=n,i.exports=d.default}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./getFetch.js":1,"./utils.js":4}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.defaults=function(n){return i.call(r.call(arguments,1),function(e){if(e)for(var t in e)void 0===n[t]&&(n[t]=e[t])}),n};var o=[],i=o.forEach,r=o.slice},{}],5:[function(e,t,n){},{}]},{},[2])(2)}); |
{ | ||
"name": "i18next-http-backend", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"private": false, | ||
@@ -11,9 +11,12 @@ "type": "module", | ||
"require": "./cjs/index.js", | ||
"default": "./lib/index.js" | ||
"default": "./esm/index.js" | ||
}, | ||
"./cjs": { | ||
"default": "./cjs/index.js" | ||
}, | ||
"./esm": { | ||
"default": "./esm/index.js" | ||
} | ||
}, | ||
"module": "./lib/index.js", | ||
"module": "./esm/index.js", | ||
"dependencies": { | ||
@@ -24,10 +27,10 @@ "node-fetch": "2.6.0" | ||
"devDependencies": { | ||
"@babel/cli": "7.8.4", | ||
"@babel/core": "7.9.6", | ||
"@babel/preset-env": "7.9.6", | ||
"@babel/cli": "7.10.4", | ||
"@babel/core": "7.10.4", | ||
"@babel/preset-env": "7.10.4", | ||
"babel-plugin-add-module-exports": "1.0.2", | ||
"browserify": "16.5.1", | ||
"eslint": "7.0.0", | ||
"eslint": "7.3.1", | ||
"eslint-config-standard": "14.1.1", | ||
"eslint-plugin-import": "2.20.2", | ||
"eslint-plugin-import": "2.22.0", | ||
"eslint-plugin-node": "11.1.0", | ||
@@ -38,7 +41,7 @@ "eslint-plugin-promise": "4.2.1", | ||
"expect.js": "0.3.1", | ||
"i18next": "19.4.4", | ||
"i18next": "19.5.2", | ||
"json-server": "0.16.1", | ||
"json5": "2.1.3", | ||
"mocha": "7.1.2", | ||
"uglify-js": "3.9.2", | ||
"mocha": "8.0.1", | ||
"uglify-js": "3.10.0", | ||
"xmlhttprequest": "1.8.0" | ||
@@ -68,3 +71,5 @@ }, | ||
"lint": "eslint .", | ||
"compile": "rm -rf cjs && mkdir cjs && babel lib -d cjs --presets=@babel/preset-env --plugins=add-module-exports && echo '{\"type\":\"commonjs\"}' > cjs/package.json && cp lib/getFetch.cjs cjs/getFetch.js && node -e \"fs.writeFileSync('cjs/request.js', fs.readFileSync('cjs/request.js').toString().replace('getFetch.cjs', 'getFetch.js'))\"", | ||
"compile:esm": "rm -rf esm && mkdir esm && BABEL_ENV=esm babel lib -d esm && cp lib/getFetch.cjs esm/getFetch.cjs", | ||
"compile:cjs": "rm -rf cjs && mkdir cjs && BABEL_ENV=cjs babel lib -d cjs && echo '{\"type\":\"commonjs\"}' > cjs/package.json && cp lib/getFetch.cjs cjs/getFetch.js && node -e \"fs.writeFileSync('cjs/request.js', fs.readFileSync('cjs/request.js').toString().replace('getFetch.cjs', 'getFetch.js'))\"", | ||
"compile": "npm run compile:esm && npm run compile:cjs", | ||
"browser": "browserify --ignore node-fetch --standalone i18nextHttpBackend cjs/index.js -o i18nextHttpBackend.js && uglifyjs i18nextHttpBackend.js --compress --mangle -o i18nextHttpBackend.min.js", | ||
@@ -71,0 +76,0 @@ "build": "npm run compile && npm run browser", |
@@ -100,9 +100,9 @@ # Introduction | ||
// | ||
// 'options' will be this entire options object | ||
// 'url' will be passed the value of 'loadPath' | ||
// 'options' will be this entire options object | ||
// 'callback' is a function that takes two parameters, 'data' and 'HttpApi'. | ||
// 'data' should be the key:value translation pairs for the | ||
// 'payload' will be a key:value object used when saving missing translations | ||
// 'callback' is a function that takes two parameters, 'err' and 'res'. | ||
// 'err' should be an error | ||
// 'res' should be an object with a 'status' property and a 'data' property the key:value translation pairs for the | ||
// requested language and namespace, or null in case of an error. | ||
// 'HttpApi' should be a status object, e.g. { status: 200 } | ||
// 'payload' will be a key:value object used when saving missing translations | ||
request: function (options, url, payload, callback) {}, | ||
@@ -154,1 +154,13 @@ | ||
</p> | ||
--- | ||
**localization as a service - locize.com** | ||
Needing a translation management? Want to edit your translations with an InContext Editor? Use the orginal provided to you by the maintainers of i18next! | ||
![locize](https://locize.com/img/ads/github_locize.png) | ||
With using [locize](http://locize.com/?utm_source=react_i18next_readme&utm_medium=github) you directly support the future of i18next and react-i18next. | ||
--- |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69184
20
1284
164
10