diff --git a/CHANGELOG.md b/CHANGELOG.md index dc17ec1..e20b7bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 6.6.0 + +- fix for Deno 2 and removal of unnecessary .cjs file + ### 6.5.2 - improve network error detection across browsers diff --git a/i18nextLocizeBackend.js b/i18nextLocizeBackend.js index ee2b177..f7460c3 100644 --- a/i18nextLocizeBackend.js +++ b/i18nextLocizeBackend.js @@ -1,25 +1,4 @@ (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.i18nextLocizeBackend = 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(e=((e,t)=>{if("object"!=c(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0===o)return("string"===t?String:Number)(e);if("object"!=c(o=o.call(e,t||"default")))return o;throw new TypeError("@@toPrimitive must return a primitive value.")})(e,"string"),"symbol"==c(e)?e:e+""))(n.key),n)}}try{var u="undefined"!=typeof window&&null!==window.localStorage,i="notExistingLocizeProject";window.localStorage.setItem(i,"foo"),window.localStorage.removeItem(i)}catch(e){u=!1}function p(e,t,o){var n={};return t.authorize&&t.apiKey&&(n.Authorization=t.apiKey),(o||t.setContentTypeJSON)&&(n["Content-Type"]="application/json"),{method:o?"POST":"GET",url:e,headers:n,body:o}}function h(e,t,o){if(1===e.request.length)try{var n=e.request(t);n&&"function"==typeof n.then?n.then(function(e){return o(null,e)}).catch(o):o(null,n)}catch(e){o(e)}else e.request(t,o)}e=function e(t){var o=1o&&(window.localStorage.removeItem("notExistingLocizeProject_".concat(e)),1))}):"undefined"!=typeof document&&(a=function(e){var t=new Date,t=(t.setTime(t.getTime()+o),"; expires=".concat(t.toGMTString())),e="notExistingLocizeProject_".concat(e);try{document.cookie="".concat(e,"=").concat(Date.now()).concat(t,";path=/")}catch(e){}},s=function(e){var e="notExistingLocizeProject_".concat(e),t="".concat(e,"=");try{for(var o=document.cookie.split(";"),n=0;n=i.options.translatedPercentageThreshold&&e.push(t),e},[]),e=e.reduce(function(e,t){return-1{if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=l(e)&&"function"!=typeof e)return{default:e};if((t=u(t))&&t.has(e))return t.get(e);var o,n,i={__proto__:null},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(o in e)"default"!==o&&{}.hasOwnProperty.call(e,o)&&((n=r?Object.getOwnPropertyDescriptor(e,o):null)&&(n.get||n.set)?Object.defineProperty(i,o,n):i[o]=e[o]);return i.default=e,t&&t.set(e,i),i})(t("./getFetch.js"));function u(e){var t,o;return"function"!=typeof WeakMap?null:(t=new WeakMap,o=new WeakMap,(u=function(e){return e?o:t})(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&&(s=void 0!==d&&d.fetch?d.fetch:"undefined"!=typeof window&&window.fetch?window.fetch:fetch),"function"!=typeof XMLHttpRequest&&"object"!==("undefined"==typeof XMLHttpRequest?"undefined":l(XMLHttpRequest))||(void 0!==d&&d.XMLHttpRequest?a=d.XMLHttpRequest:"undefined"!=typeof window&&window.XMLHttpRequest&&(a=window.XMLHttpRequest)),"function"==typeof ActiveXObject&&(void 0!==d&&d.ActiveXObject?c=d.ActiveXObject:"undefined"!=typeof window&&window.ActiveXObject&&(c=window.ActiveXObject)),"function"!=typeof(s=s||!e||a||c?s:e.default||e)&&(s=void 0);function f(e,t,o,n){function i(t){var o=t.headers&&"Error from cloudfront"===t.headers.get("x-cache");if(!t.ok)return n(t.statusText||"Error",{status:t.status,resourceNotExisting:o});t.text().then(function(e){n(null,{status:t.status,data:e,resourceNotExisting:o})}).catch(n)}var r={};"undefined"==typeof window&&void 0!==d&&void 0!==d.process&&d.process.versions&&d.process.versions.node&&(r["User-Agent"]="i18next-locize-backend (node/".concat(d.process.version,"; ").concat(d.process.platform," ").concat(d.process.arch,")")),e.authorize&&e.apiKey&&(r.Authorization=e.apiKey),(o||e.setContentTypeJSON)&&(r["Content-Type"]="application/json"),("function"==typeof fetch?fetch:s)(t,{method:o?"POST":"GET",body:o?JSON.stringify(o):void 0,headers:r}).then(i).catch(n)}n.default=function(e,t,o,n){if("function"==typeof o&&(n=o,o=void 0),n=n||function(){},s)return f(e,t,o,n);if("function"==typeof XMLHttpRequest||"object"===("undefined"==typeof XMLHttpRequest?"undefined":l(XMLHttpRequest))||"function"==typeof ActiveXObject){var i=n;try{var r=a?new a:new c("MSXML2.XMLHTTP.3.0");r.open(o?"POST":"GET",t,1),e.crossDomain||r.setRequestHeader("X-Requested-With","XMLHttpRequest"),e.authorize&&e.apiKey&&r.setRequestHeader("Authorization",e.apiKey),(o||e.setContentTypeJSON)&&r.setRequestHeader("Content-Type","application/json"),r.onreadystatechange=function(){var e="Error from cloudfront"===r.getResponseHeader("x-cache");3null==e?"":""+e)(i):i)||"").replace(/\$/g,"$$$$"),e=e.replace(n[0],t[i]||i),s.lastIndex=0;return e},o.isMissingOption=a,o.optionExist=function(e,t){return!a(e,t)},o.pushPath=function(e,t,o,n){e=r(e,t,Object),t=e.obj,e=e.k;t[e]=t[e]||[],n&&(t[e]=t[e].concat(o));n||t[e].push(o)},o.setPath=function(e,t,o){e=r(e,t,Object);e.obj[e.k]=o};var o=[],n=o.forEach,i=o.slice;function r(e,t,o){function n(e){return e&&-1(e=((e,t)=>{if("object"!=c(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0===o)return("string"===t?String:Number)(e);if("object"!=c(o=o.call(e,t||"default")))return o;throw new TypeError("@@toPrimitive must return a primitive value.")})(e,"string"),"symbol"==c(e)?e:e+""))(n.key),n)}}try{var u="undefined"!=typeof window&&null!==window.localStorage,i="notExistingLocizeProject";window.localStorage.setItem(i,"foo"),window.localStorage.removeItem(i)}catch(e){u=!1}function p(e,t,o){var n={};return t.authorize&&t.apiKey&&(n.Authorization=t.apiKey),(o||t.setContentTypeJSON)&&(n["Content-Type"]="application/json"),{method:o?"POST":"GET",url:e,headers:n,body:o}}function h(e,t,o){if(1===e.request.length)try{var n=e.request(t);n&&"function"==typeof n.then?n.then(function(e){return o(null,e)}).catch(o):o(null,n)}catch(e){o(e)}else e.request(t,o)}e=function e(t){var o=1o&&(window.localStorage.removeItem("notExistingLocizeProject_".concat(e)),1))}):"undefined"!=typeof document&&(a=function(e){var t=new Date,t=(t.setTime(t.getTime()+o),"; expires=".concat(t.toGMTString())),e="notExistingLocizeProject_".concat(e);try{document.cookie="".concat(e,"=").concat(Date.now()).concat(t,";path=/")}catch(e){}},r=function(e){var e="notExistingLocizeProject_".concat(e),t="".concat(e,"=");try{for(var o=document.cookie.split(";"),n=0;n=i.options.translatedPercentageThreshold&&e.push(t),e},[]),e=e.reduce(function(e,t){return-1null==e?"":""+e)(i):i)||"").replace(/\$/g,"$$$$"),e=e.replace(n[0],t[i]||i),r.lastIndex=0;return e},o.isMissingOption=a,o.optionExist=function(e,t){return!a(e,t)},o.pushPath=function(e,t,o,n){e=s(e,t,Object),t=e.obj,e=e.k;t[e]=t[e]||[],n&&(t[e]=t[e].concat(o));n||t[e].push(o)},o.setPath=function(e,t,o){e=s(e,t,Object);e.obj[e.k]=o};var o=[],n=o.forEach,i=o.slice;function s(e,t,o){function n(e){return e&&-1 { @@ -66,12 +68,7 @@ const requestWithFetch = (options, url, payload, callback) => { // xml http request stuff const requestWithXmlHttpRequest = (options, url, payload, callback) => { try { - let x - if (XmlHttpRequestApi) { - x = new XmlHttpRequestApi() - } else { - x = new ActiveXObjectApi('MSXML2.XMLHTTP.3.0') - } + const x = XmlHttpRequestApi ? new XmlHttpRequestApi() : new ActiveXObjectApi('MSXML2.XMLHTTP.3.0') x.open(payload ? 'POST' : 'GET', url, 1) if (!options.crossDomain) { x.setRequestHeader('X-Requested-With', 'XMLHttpRequest') diff --git a/package.json b/package.json index 05dbe8d..c799313 100644 --- a/package.json +++ b/package.json @@ -42,33 +42,37 @@ }, "types": "./index.d.mts", "devDependencies": { - "@babel/cli": "7.24.8", - "@babel/core": "7.25.2", - "@babel/preset-env": "7.25.3", + "@babel/cli": "7.25.9", + "@babel/core": "7.26.0", + "@babel/preset-env": "7.26.0", "babel-plugin-add-module-exports": "1.0.4", - "browserify": "17.0.0", + "browserify": "17.0.1", "dtslint": "4.2.1", "eslint": "8.53.0", "eslint-config-standard": "17.1.0", - "eslint-plugin-import": "2.29.1", + "eslint-plugin-import": "2.31.0", "eslint-plugin-n": "16.6.2", "eslint-plugin-promise": "6.1.1", "eslint-plugin-require-path-exists": "1.1.9", "eslint-plugin-standard": "5.0.0", "expect.js": "0.3.1", - "i18next": "23.14.0", + "i18next": "23.16.7", "json-server": "0.17.4", - "mocha": "10.7.3", + "mocha": "10.8.2", "tslint": "5.20.1", - "tsd": "0.31.1", - "typescript": "5.5.4", - "uglify-js": "3.19.2", + "tsd": "0.31.2", + "typescript": "5.6.3", + "uglify-js": "3.19.3", "xmlhttprequest": "1.8.0" }, + "config": { + "fixcjs": "fs.writeFileSync('cjs/request.js', fs.readFileSync('cjs/request.js').toString().replace(`(await Promise.resolve().then(function () {\n return _interopRequireWildcard(require('cross-fetch'));\n })).default`, `require('cross-fetch')`))" + }, "scripts": { "lint": "eslint .", - "compile:esm": "rm -rf esm && mkdir esm && BABEL_ENV=esm babel lib -d esm && cp index.d.ts esm/index.d.ts && cp index.d.mts esm/index.d.mts && cp lib/getFetch.cjs esm/getFetch.cjs && rm -f esm/getFetch.js && node -e \"fs.writeFileSync('esm/getFetch.cjs', fs.readFileSync('esm/getFetch.cjs').toString().replace('/* eslint-disable no-var, no-undef */\\n', ''))\"", - "compile:cjs": "rm -rf cjs && mkdir cjs && BABEL_ENV=cjs babel lib -d cjs && cp index.d.ts cjs/index.d.ts && echo '{\"type\":\"commonjs\"}' > cjs/package.json && cp lib/getFetch.cjs cjs/getFetch.js && node -e \"fs.writeFileSync('cjs/getFetch.js', fs.readFileSync('cjs/getFetch.js').toString().replace('/* eslint-disable no-var, no-undef */\\n', ''))\" && node -e \"fs.writeFileSync('cjs/request.js', fs.readFileSync('cjs/request.js').toString().replace('getFetch.cjs', 'getFetch.js'))\"", + "fixcjs": "node -e \"$npm_package_config_fixcjs\"", + "compile:esm": "rm -rf esm && mkdir esm && BABEL_ENV=esm babel lib -d esm && cp index.d.ts esm/index.d.ts && cp index.d.mts esm/index.d.mts", + "compile:cjs": "rm -rf cjs && mkdir cjs && BABEL_ENV=cjs babel lib -d cjs && cp index.d.ts cjs/index.d.ts && echo '{\"type\":\"commonjs\"}' > cjs/package.json && npm run fixcjs", "compile": "npm run compile:esm && npm run compile:cjs", "browser": "browserify --ignore cross-fetch --standalone i18nextLocizeBackend cjs/index.js -o i18nextLocizeBackend.js && uglifyjs i18nextLocizeBackend.js --compress --mangle -o i18nextLocizeBackend.min.js", "build": "npm run compile && npm run browser",