diff --git a/lib/index.js b/lib/index.js index ff36fe3..d0e6e0b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.writeFileResponse=exports.writeFileRequest=exports.readFileResponse=exports.readFileRequest=exports.preloadBindings=exports.mainBindings=exports["default"]=exports.clearMainBindings=exports.changeLanguageRequest=void 0;var _lodash=require("lodash"),_utils=require("./utils");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c"),this.rendererLog="".concat("[i18next-electron-fs-backend:","renderer]=>"),"undefined"==typeof this.backendOptions.i18nextElectronBackend?void console.error("".concat(this.rendererLog," i18nextElectronBackend is undefined, please ensure you are exposing i18nextElectronBackend via the contextBridge in your preload file.")):void this.setupIpcBindings()}},{key:"setupIpcBindings",value:function setupIpcBindings(){var a=this,b=this.backendOptions.i18nextElectronBackend;b.onReceive(readFileResponse,function(b){if("undefined"!=typeof a.readCallbacks[b.key]){var c;if(b.error)c=a.readCallbacks[b.key].callback,delete a.readCallbacks[b.key],null!==c&&"function"==typeof c&&c(null,{});else{var d;b.data=b.data.replace(/^\uFEFF/,"");try{d=JSON.parse(b.data)}catch(d){return d.message="Error parsing '".concat(b.filename,"'. Message: '").concat(d,"'."),c=a.readCallbacks[b.key].callback,delete a.readCallbacks[b.key],void(null!==c&&"function"==typeof c&&c(d))}c=a.readCallbacks[b.key].callback,delete a.readCallbacks[b.key],null!==c&&"function"==typeof c&&c(null,d)}}}),b.onReceive(writeFileResponse,function(b){for(var c,d=b.keys,e=0;e"),this.rendererLog="".concat("[i18next-electron-fs-backend:","renderer]=>"),"undefined"==typeof this.backendOptions.i18nextElectronBackend||this.setupIpcBindings()}},{key:"setupIpcBindings",value:function setupIpcBindings(){var a=this,b=this.backendOptions.i18nextElectronBackend;b.onReceive(readFileResponse,function(b){if("undefined"!=typeof a.readCallbacks[b.key]){var c;if(b.error)c=a.readCallbacks[b.key].callback,delete a.readCallbacks[b.key],null!==c&&"function"==typeof c&&c(null,{});else{var d;b.data=b.data.replace(/^\uFEFF/,"");try{d=JSON.parse(b.data)}catch(d){return d.message="Error parsing '".concat(b.filename,"'. Message: '").concat(d,"'."),c=a.readCallbacks[b.key].callback,delete a.readCallbacks[b.key],void(null!==c&&"function"==typeof c&&c(d))}c=a.readCallbacks[b.key].callback,delete a.readCallbacks[b.key],null!==c&&"function"==typeof c&&c(null,d)}}}),b.onReceive(writeFileResponse,function(b){for(var c,d=b.keys,e=0;e`; if (typeof this.backendOptions.i18nextElectronBackend === "undefined") { - console.error(`${this.rendererLog} i18nextElectronBackend is undefined, please ensure you are exposing i18nextElectronBackend via the contextBridge in your preload file.`); + // Since this is run twice if you use .init we can't be sure + // console.error(`${this.rendererLog} i18nextElectronBackend is undefined, please ensure you are exposing i18nextElectronBackend via the contextBridge in your preload file.`); return; }