Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@visma/react-intl-helpers

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visma/react-intl-helpers - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3-patch

cjs/getLocale.js

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 0.1.3
* Fix: Ensure same hash value for each messages object.
# 0.1.2

@@ -2,0 +6,0 @@

7

cjs/get-messages-file-list-loader.js

@@ -18,3 +18,3 @@ "use strict";

var _loader = require("./loader");
var _messages = require("./messages");

@@ -25,6 +25,7 @@ var _stringify2 = _interopRequireDefault(require("./stringify"));

this.cacheable(false);
return "export default ".concat((0, _stringify.default)((0, _lodash.mapValues)(_loader.messages, function (countries, language) {
var messages = (0, _messages.getCurrent)();
return "export default ".concat((0, _stringify.default)((0, _lodash.mapValues)(messages, function (countries, language) {
return (0, _lodash.mapValues)(countries, function (messagesByCountry, country) {
return (0, _getFilenameFromLocaleData.default)({
source: (0, _stringify2.default)((0, _objectSpread2.default)({}, _loader.messages.default.default, countries.default, messagesByCountry)),
source: (0, _stringify2.default)((0, _objectSpread2.default)({}, messages.default.default, countries.default, messagesByCountry)),
locale: [language, country].filter(function (x) {

@@ -31,0 +32,0 @@ return x !== 'default';

@@ -16,6 +16,6 @@ "use strict";

var _ = require(".");
var _messages = require("../messages");
var _default = function _default(compilation, callback) {
(0, _getLocalesAndMessagesList.default)(_.messages).map(function (_ref) {
(0, _getLocalesAndMessagesList.default)((0, _messages.get)()).map(function (_ref) {
var locale = _ref.locale,

@@ -22,0 +22,0 @@ source = _ref.source;

@@ -9,3 +9,2 @@ "use strict";

exports.default = loader;
exports.messages = void 0;

@@ -16,4 +15,2 @@ var _getIterator2 = _interopRequireDefault(require("@babel/runtime/core-js/get-iterator"));

var _assign = _interopRequireDefault(require("@babel/runtime/core-js/object/assign"));
var _promise = _interopRequireDefault(require("@babel/runtime/core-js/promise"));

@@ -35,8 +32,5 @@

var _getLocale2 = _interopRequireDefault(require("./getLocale"));
var _tapToEmitEvent = _interopRequireDefault(require("./tapToEmitEvent"));
var messages = {};
exports.messages = messages;
var _messages = require("../messages");

@@ -46,3 +40,4 @@ function loader(source) {

var _compiler = this._compiler,
var compilation = this._compilation,
compiler = this._compiler,
resourcePath = this.resourcePath;

@@ -53,3 +48,3 @@ var projectRoot = (0, _path.join)(__dirname, '../../..');

var absolutePathToMessages = (0, _path.resolve)(process.cwd(), projectRoot, messagesPath);
(0, _tapToEmitEvent.default)(_compiler);
(0, _tapToEmitEvent.default)(compiler);

@@ -103,11 +98,8 @@ var addNamespace = function addNamespace(key) {

var _getLocale = (0, _getLocale2.default)(file),
language = _getLocale.language,
country = _getLocale.country;
var languageMessages = messages[language] || (messages[language] = {});
var localeMessages = languageMessages[country] || (languageMessages[country] = {});
(0, _assign.default)(localeMessages, (0, _lodash.mapValues)((0, _lodash.mapKeys)((0, _properties.parse)(data), function (value, key) {
return addNamespace(key);
}), String));
(0, _messages.add)({
addNamespace: addNamespace,
compilation: compilation,
file: file,
data: data
});
resolve();

@@ -182,3 +174,5 @@ });

return "export const ".concat((0, _lodash.camelCase)(key), " = '").concat(addNamespace(key), "';");
}).join('\n'), "\nexport default {").concat(keys.map(_lodash.camelCase).join(', '), "};\n").concat(process.env.NODE_ENV === 'production' ? '' : // If only message values change, content of returned data does
}).join('\n'), "\nexport default {").concat(keys.map(_lodash.camelCase).map(function (key) {
return "".concat(key, ": ").concat(key);
}).join(', '), "};\n").concat(process.env.NODE_ENV === 'production' ? '' : // If only message values change, content of returned data does
// not change. Add timestamp to notify Webpack for changes.

@@ -185,0 +179,0 @@ "/* ".concat(Date.now(), " */")));

@@ -8,8 +8,6 @@ "use strict";

});
exports.default = exports.messages = void 0;
exports.default = void 0;
var _addMessageFileAssets = _interopRequireDefault(require("./addMessageFileAssets"));
var messages = {};
exports.messages = messages;
var isTapped;

@@ -16,0 +14,0 @@

@@ -5,6 +5,7 @@ import _objectSpread from "@babel/runtime/helpers/objectSpread";

import getFilenameFromLocaleData from './getFilenameFromLocaleData';
import { messages } from './loader';
import { getCurrent } from './messages';
import stringify from './stringify';
export default function () {
this.cacheable(false);
var messages = getCurrent();
return "export default ".concat(_JSON$stringify(mapValues(messages, function (countries, language) {

@@ -11,0 +12,0 @@ return mapValues(countries, function (messagesByCountry, country) {

import addFileAsset from './addFileAsset';
import getLocalesAndMessagesList from './getLocalesAndMessagesList';
import getFilenameFromLocaleData from '../getFilenameFromLocaleData';
import { messages } from '.';
import { get } from '../messages';
export default (function (compilation, callback) {
getLocalesAndMessagesList(messages).map(function (_ref) {
getLocalesAndMessagesList(get()).map(function (_ref) {
var locale = _ref.locale,

@@ -8,0 +8,0 @@ source = _ref.source;

import _getIterator from "@babel/runtime/core-js/get-iterator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _Object$assign from "@babel/runtime/core-js/object/assign";
import _Promise from "@babel/runtime/core-js/promise";

@@ -8,13 +7,13 @@ import _Object$keys from "@babel/runtime/core-js/object/keys";

import { readdir, readFile } from 'fs';
import { mapKeys, mapValues, camelCase } from 'lodash';
import { camelCase } from 'lodash';
import { dirname, join, relative, resolve } from 'path';
import { parse } from 'properties';
import normalize from 'normalize-path';
import getLocale from './getLocale';
import tapToEmitEvent from './tapToEmitEvent';
export var messages = {};
import { add } from '../messages';
export default function loader(source) {
var _this = this;
var _compiler = this._compiler,
var compilation = this._compilation,
compiler = this._compiler,
resourcePath = this.resourcePath;

@@ -25,3 +24,3 @@ var projectRoot = join(__dirname, '../../..');

var absolutePathToMessages = resolve(process.cwd(), projectRoot, messagesPath);
tapToEmitEvent(_compiler);
tapToEmitEvent(compiler);

@@ -75,13 +74,8 @@ var addNamespace = function addNamespace(key) {

var _getLocale = getLocale(file),
language = _getLocale.language,
country = _getLocale.country;
var languageMessages = messages[language] || (messages[language] = {});
var localeMessages = languageMessages[country] || (languageMessages[country] = {});
_Object$assign(localeMessages, mapValues(mapKeys(parse(data), function (value, key) {
return addNamespace(key);
}), String));
add({
addNamespace: addNamespace,
compilation: compilation,
file: file,
data: data
});
resolve();

@@ -156,3 +150,5 @@ });

return "export const ".concat(camelCase(key), " = '").concat(addNamespace(key), "';");
}).join('\n'), "\nexport default {").concat(keys.map(camelCase).join(', '), "};\n").concat(process.env.NODE_ENV === 'production' ? '' : // If only message values change, content of returned data does
}).join('\n'), "\nexport default {").concat(keys.map(camelCase).map(function (key) {
return "".concat(key, ": ").concat(key);
}).join(', '), "};\n").concat(process.env.NODE_ENV === 'production' ? '' : // If only message values change, content of returned data does
// not change. Add timestamp to notify Webpack for changes.

@@ -159,0 +155,0 @@ "/* ".concat(Date.now(), " */")));

import addMessageFileAssets from './addMessageFileAssets';
export var messages = {};
var isTapped;

@@ -4,0 +3,0 @@ export default (function (compiler) {

{
"name": "@visma/react-intl-helpers",
"version": "0.1.2",
"version": "0.1.3-patch",
"description": "Modular messages.properties, loaded dynamically.",

@@ -5,0 +5,0 @@ "main": "cjs",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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