New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@jsreport/jsreport-localization

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsreport/jsreport-localization - npm Package Compare versions

Comparing version 3.2.2 to 4.0.0

37

lib/worker.js

@@ -7,2 +7,6 @@ const fs = require('fs').promises

reporter.localization = {
cacheRequestsMap: new Map()
}
reporter.initializeListeners.add('assets', async () => {

@@ -22,2 +26,10 @@ helpers = (await fs.readFile(path.join(__dirname, '../static/helpers.js'))).toString()

reporter.afterRenderListeners.add(definition.name, (req) => {
reporter.localization.cacheRequestsMap.delete(req.context.rootId)
})
reporter.renderErrorListeners.add(definition.name, (req) => {
reporter.localization.cacheRequestsMap.delete(req.context.rootId)
})
reporter.extendProxy((proxy, req) => {

@@ -53,12 +65,27 @@ proxy.localization = {

if (!reporter.localization.cacheRequestsMap.has(req.context.rootId)) {
reporter.localization.cacheRequestsMap.set(req.context.rootId, {})
}
const cache = reporter.localization.cacheRequestsMap.get(req.context.rootId)
const localizationDataPath = path.posix.join(folder, `${language || 'en'}.json`)
const resolvedCurrentDirectoryPath = await proxy.currentDirectoryPath()
const resolvedValue = await proxy.folders.resolveEntityFromPath(localizationDataPath, 'assets', { currentPath: resolvedCurrentDirectoryPath })
if (!resolvedValue) {
throw new Error('localize helper couldn\'t find asset with data at ' + localizationDataPath)
const localizationCacheKey = path.posix.join(resolvedCurrentDirectoryPath || '/', localizationDataPath)
if (cache[localizationCacheKey] == null) {
cache[localizationCacheKey] = (async () => {
const resolvedValue = await proxy.folders.resolveEntityFromPath(localizationDataPath, 'assets', { currentPath: resolvedCurrentDirectoryPath })
if (!resolvedValue) {
throw new Error('localize helper couldn\'t find asset with data at ' + localizationDataPath)
}
return JSON.parse(resolvedValue.entity.content.toString())
})()
}
const localizedData = JSON.parse(resolvedValue.entity.content.toString())
return localizedData[key]
const localizationData = await cache[localizationCacheKey]
return localizationData[key]
}

@@ -65,0 +92,0 @@ }

14

package.json
{
"name": "@jsreport/jsreport-localization",
"version": "3.2.2",
"version": "4.0.0",
"description": "jsreport extension adding localize helper",

@@ -36,7 +36,7 @@ "keywords": [

"handlebars": "4.7.7",
"@jsreport/jsreport-assets": "3.6.0",
"@jsreport/jsreport-core": "3.11.0",
"@jsreport/jsreport-components": "3.3.0",
"@jsreport/jsreport-child-templates": "3.1.0",
"@jsreport/jsreport-handlebars": "3.2.1",
"@jsreport/jsreport-assets": "4.0.0",
"@jsreport/jsreport-core": "4.0.0",
"@jsreport/jsreport-components": "4.0.0",
"@jsreport/jsreport-child-templates": "4.0.0",
"@jsreport/jsreport-handlebars": "4.0.0",
"@jsreport/studio-dev": "3.2.1",

@@ -48,3 +48,3 @@ "mocha": "8.3.2",

"engines": {
"node": ">=16.11"
"node": ">=18.15"
},

@@ -51,0 +51,0 @@ "standard": {

@@ -10,2 +10,8 @@ # jsreport-localization

### 4.0.0
- cache localization calls to improve performance
- minimum node.js version is now `18.15.0`
- update studio build against new webpack and babel
### 3.2.2

@@ -12,0 +18,0 @@

@@ -1,206 +0,146 @@

/******/ (function(modules) { // webpackBootstrap
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ([
/* 0 */,
/* 1 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ LocalizationProperties)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
class LocalizationProperties extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
static title(entity, entities) {
if (!entity.localization) {
return 'localization';
}
return `localization: ${entity.localization.language || ''}`;
}
render() {
const {
entity,
onChange
} = this.props;
const localization = (entity.localization || {}).language;
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
className: "properties-section"
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
className: "form-group"
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", null, "Template language ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
href: "http://jsreport.net/learn/localization",
target: "_blank",
rel: "noreferrer"
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("i", {
className: "fa fa-question"
}), " ")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
type: "text",
placeholder: "en",
value: localization || '',
onChange: v => onChange({
_id: entity._id,
localization: {
language: v.target.value
}
})
})));
}
}
/***/ }),
/* 2 */
/***/ ((module) => {
module.exports = Studio.libraries['react'];
/***/ }),
/* 3 */
/***/ ((module) => {
module.exports = Studio;
/***/ })
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/******/
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _LocalizationProperties_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
/* harmony import */ var jsreport_studio__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
/* harmony import */ var jsreport_studio__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(jsreport_studio__WEBPACK_IMPORTED_MODULE_1__);
"use strict";
jsreport_studio__WEBPACK_IMPORTED_MODULE_1___default().addPropertiesComponent(_LocalizationProperties_js__WEBPACK_IMPORTED_MODULE_0__["default"].title, _LocalizationProperties_js__WEBPACK_IMPORTED_MODULE_0__["default"], entity => entity.__entitySet === 'templates');
})();
var _LocalizationProperties = __webpack_require__(1);
var _LocalizationProperties2 = _interopRequireDefault(_LocalizationProperties);
var _jsreportStudio = __webpack_require__(3);
var _jsreportStudio2 = _interopRequireDefault(_jsreportStudio);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_jsreportStudio2.default.addPropertiesComponent(_LocalizationProperties2.default.title, _LocalizationProperties2.default, function (entity) {
return entity.__entitySet === 'templates';
});
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var LocalizationProperties = function (_Component) {
_inherits(LocalizationProperties, _Component);
function LocalizationProperties() {
_classCallCheck(this, LocalizationProperties);
return _possibleConstructorReturn(this, (LocalizationProperties.__proto__ || Object.getPrototypeOf(LocalizationProperties)).apply(this, arguments));
}
_createClass(LocalizationProperties, [{
key: 'render',
value: function render() {
var _props = this.props,
entity = _props.entity,
_onChange = _props.onChange;
var localization = (entity.localization || {}).language;
return _react2.default.createElement(
'div',
{ className: 'properties-section' },
_react2.default.createElement(
'div',
{ className: 'form-group' },
_react2.default.createElement(
'label',
null,
'Template language ',
_react2.default.createElement(
'a',
{ href: 'http://jsreport.net/learn/localization', target: '_blank', rel: 'noreferrer' },
_react2.default.createElement('i', { className: 'fa fa-question' }),
' '
)
),
_react2.default.createElement('input', {
type: 'text', placeholder: 'en', value: localization || '',
onChange: function onChange(v) {
return _onChange({ _id: entity._id, localization: { language: v.target.value } });
}
})
)
);
}
}], [{
key: 'title',
value: function title(entity, entities) {
if (!entity.localization) {
return 'localization';
}
return 'localization: ' + (entity.localization.language || '');
}
}]);
return LocalizationProperties;
}(_react.Component);
exports.default = LocalizationProperties;
/***/ }),
/* 2 */
/***/ (function(module, exports) {
module.exports = Studio.libraries['react'];
/***/ }),
/* 3 */
/***/ (function(module, exports) {
module.exports = Studio;
/***/ })
/******/ ]);
/******/ })()
;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc