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

@lingui/react

Package Overview
Dependencies
Maintainers
1
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lingui/react - npm Package Compare versions

Comparing version 3.0.0-13 to 3.0.0-16

4

cjs/I18nProvider.d.ts

@@ -8,3 +8,5 @@ import { FunctionComponent } from "react";

};
export declare type I18nProviderProps = I18nContext;
export declare type I18nProviderProps = I18nContext & {
forceRenderOnLocaleChange?: boolean;
};
export declare function useLingui(): I18nContext;

@@ -11,0 +13,0 @@ export declare const I18nProvider: FunctionComponent<I18nProviderProps>;

@@ -5,11 +5,15 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var React = require('react');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _slicedToArray = _interopDefault(require('@babel/runtime/helpers/slicedToArray'));
var React = _interopDefault(require('react'));
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var LinguiContext = React.createContext(null);
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var LinguiContext = /*#__PURE__*/React__default['default'].createContext(null);
function useLingui() {
var context = React.useContext(LinguiContext);
var context = React__default['default'].useContext(LinguiContext);

@@ -25,6 +29,10 @@ {

var I18nProvider = function I18nProvider(props) {
var _React$useState = React.useState(makeContext()),
_React$useState2 = _slicedToArray(_React$useState, 2),
var _props$forceRenderOnL;
var _React$useState = React__default['default'].useState(makeContext()),
_React$useState2 = _slicedToArray__default['default'](_React$useState, 2),
context = _React$useState2[0],
setContext = _React$useState2[1];
var forceRenderOnLocaleChange = (_props$forceRenderOnL = props.forceRenderOnLocaleChange) !== null && _props$forceRenderOnL !== void 0 ? _props$forceRenderOnL : true;
/**

@@ -38,4 +46,3 @@ * Subscribe for locale/message changes

React.useEffect(function () {
React__default['default'].useEffect(function () {
var unsubscribe = props.i18n.on("change", function () {

@@ -67,3 +74,11 @@ return setContext(makeContext());

return React.createElement(LinguiContext.Provider, {
if (forceRenderOnLocaleChange) {
if (!context.i18n.locale) return null;
return /*#__PURE__*/React__default['default'].createElement(LinguiContext.Provider, {
value: context,
key: context.i18n.locale
}, props.children);
}
return /*#__PURE__*/React__default['default'].createElement(LinguiContext.Provider, {
value: context

@@ -73,3 +88,3 @@ }, props.children);

function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }

@@ -104,3 +119,3 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _step$value = _slicedToArray(_step.value, 3),
var _step$value = _slicedToArray__default['default'](_step.value, 3),
index = _step$value[0],

@@ -111,3 +126,3 @@ children = _step$value[1],

var element = elements[index];
tree.push(React.cloneElement(element, {
tree.push( /*#__PURE__*/React__default['default'].cloneElement(element, {
key: index

@@ -147,3 +162,3 @@ }, // format children for pair tags

var _parts$slice = parts.slice(0, 4),
_parts$slice2 = _slicedToArray(_parts$slice, 4),
_parts$slice2 = _slicedToArray__default['default'](_parts$slice, 4),
paired = _parts$slice2[0],

@@ -159,3 +174,3 @@ children = _parts$slice2[1],

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function Trans(props) {

@@ -188,3 +203,3 @@ var _useLingui = useLingui(),

var value = values[key];
if (!React.isValidElement(value)) return;
if (! /*#__PURE__*/React__default['default'].isValidElement(value)) return;
var index = Object.keys(components).length;

@@ -208,10 +223,10 @@ components[index] = value;

// Built-in element: h1, p
return React.createElement(render, {}, translation);
} else if (React.isValidElement(render)) {
return /*#__PURE__*/React__default['default'].createElement(render, {}, translation);
} else if ( /*#__PURE__*/React__default['default'].isValidElement(render)) {
// Element: <p className="lear' />
return React.cloneElement(render, {}, translation);
return /*#__PURE__*/React__default['default'].cloneElement(render, {}, translation);
} // Component: (props) => <a title={props.translation}>x</a>
return React.createElement(render, {
return /*#__PURE__*/React__default['default'].createElement(render, {
id: id,

@@ -218,0 +233,0 @@ translation: translation,

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("@babel/runtime/helpers/slicedToArray")),t=e(require("react")),n=e(require("@babel/runtime/helpers/defineProperty")),o=t.createContext(null);function i(){var e=t.useContext(o);return e}function u(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,r){if(!e)return;if("string"==typeof e)return a(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return a(e,r)}(e))){var r=0,t=function(){};return{s:t,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,o,i=!0,u=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return i=e.done,e},e:function(e){u=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(u)throw o}}}}function a(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var c=/<(\d+)>(.*?)<\/\1>|<(\d+)\/>/,l=/(?:\r\n|\r|\n)/g;function f(e){if(!e.length)return[];var t=e.slice(0,4),n=r(t,4),o=n[0],i=n[1],u=n[2],a=n[3];return[[parseInt(o||u),i||"",a]].concat(f(e.slice(4,e.length)))}function s(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?s(Object(t),!0).forEach((function(r){n(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function d(e){var n=i(),o=n.i18n,a=n.defaultRender,s=e.render,d=void 0===s?a:s,y=e.id,v=e.message,b=e.formats,m=p({},e.values),h=p({},e.components);m&&Object.keys(m).forEach((function(e){var r=m[e];if(t.isValidElement(r)){var n=Object.keys(h).length;h[n]=r,m[e]="<".concat(n,"/>")}}));var g=o&&"function"==typeof o._?o._(y,m,{message:v,formats:b}):y,O=g?function e(n){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.replace(l,"").split(c);if(1===i.length)return n;var a=[],s=i.shift();s&&a.push(s);var p,d=u(f(i));try{for(d.s();!(p=d.n()).done;){var y=r(p.value,3),v=y[0],b=y[1],m=y[2],h=o[v];a.push(t.cloneElement(h,{key:v},b?e(b,o):h.props.children)),m&&a.push(m)}}catch(e){d.e(e)}finally{d.f()}return a}(g,h):null;return null==d?O:"string"==typeof d?t.createElement(d,{},O):t.isValidElement(d)?t.cloneElement(d,{},O):t.createElement(d,{id:y,translation:O,message:v})}d.defaultProps={values:{},components:{}},exports.I18nProvider=function(e){var n=t.useState(c()),i=r(n,2),u=i[0],a=i[1];function c(){return{i18n:e.i18n,defaultRender:e.defaultRender}}return t.useEffect((function(){var r=e.i18n.on("change",(function(){return a(c())}));return function(){return r()}}),[]),t.createElement(o.Provider,{value:u},e.children)},exports.Trans=d,exports.useLingui=i;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),r=require("@babel/runtime/helpers/defineProperty");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(e),u=n(t),a=n(r),l=u.default.createContext(null);function i(){var e=u.default.useContext(l);return e}function f(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,a=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,u=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw u}}}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var s=/<(\d+)>(.*?)<\/\1>|<(\d+)\/>/,d=/(?:\r\n|\r|\n)/g;function p(e){if(!e.length)return[];var t=e.slice(0,4),r=o.default(t,4),n=r[0],u=r[1],a=r[2],l=r[3];return[[parseInt(n||a),u||"",l]].concat(p(e.slice(4,e.length)))}function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach((function(t){a.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e){var t=i(),r=t.i18n,n=t.defaultRender,a=e.render,l=void 0===a?n:a,c=e.id,v=e.message,b=e.formats,m=y({},e.values),h=y({},e.components);m&&Object.keys(m).forEach((function(e){var t=m[e];if(u.default.isValidElement(t)){var r=Object.keys(h).length;h[r]=t,m[e]="<".concat(r,"/>")}}));var g=r&&"function"==typeof r._?r._(c,m,{message:v,formats:b}):c,O=g?function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.replace(d,"").split(s);if(1===n.length)return t;var a=[],l=n.shift();l&&a.push(l);var i,c=f(p(n));try{for(c.s();!(i=c.n()).done;){var v=o.default(i.value,3),y=v[0],b=v[1],m=v[2],h=r[y];a.push(u.default.cloneElement(h,{key:y},b?e(b,r):h.props.children)),m&&a.push(m)}}catch(e){c.e(e)}finally{c.f()}return a}(g,h):null;return null==l?O:"string"==typeof l?u.default.createElement(l,{},O):u.default.isValidElement(l)?u.default.cloneElement(l,{},O):u.default.createElement(l,{id:c,translation:O,message:v})}b.defaultProps={values:{},components:{}},exports.I18nProvider=function(e){var t,r=u.default.useState(c()),n=o.default(r,2),a=n[0],i=n[1],f=null===(t=e.forceRenderOnLocaleChange)||void 0===t||t;function c(){return{i18n:e.i18n,defaultRender:e.defaultRender}}return u.default.useEffect((function(){var t=e.i18n.on("change",(function(){return i(c())}));return function(){return t()}}),[]),f?a.i18n.locale?u.default.createElement(l.Provider,{value:a,key:a.i18n.locale},e.children):null:u.default.createElement(l.Provider,{value:a},e.children)},exports.Trans=b,exports.useLingui=i;
//# sourceMappingURL=react.production.min.js.map
{
"name": "@lingui/react",
"version": "3.0.0-13",
"version": "3.0.0-16",
"description": "React components for translations",

@@ -42,4 +42,4 @@ "main": "index.js",

"dependencies": {
"@babel/runtime": "^7.9.6",
"@lingui/core": "3.0.0-13"
"@babel/runtime": "^7.11.2",
"@lingui/core": "3.0.0-16"
},

@@ -46,0 +46,0 @@ "devDependencies": {

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