@lingui/macro
Advanced tools
Comparing version 3.0.0-7 to 3.0.0-8
10
icu.js
@@ -12,4 +12,6 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
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) { (0, _defineProperty2.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; } | ||
var metaOptions = ["id", "comment", "props"]; | ||
@@ -26,6 +28,6 @@ var escapedMetaOptionsRe = new RegExp("^_(".concat(metaOptions.join("|"), ")$")); | ||
}).reduce(function (props, message) { | ||
return (0, _objectSpread2.default)({}, message, { | ||
return _objectSpread({}, message, { | ||
message: props.message + message.message, | ||
values: (0, _objectSpread2.default)({}, props.values, {}, message.values), | ||
jsxElements: (0, _objectSpread2.default)({}, props.jsxElements, {}, message.jsxElements) | ||
values: _objectSpread({}, props.values, {}, message.values), | ||
jsxElements: _objectSpread({}, props.jsxElements, {}, message.jsxElements) | ||
}); | ||
@@ -32,0 +34,0 @@ }, { |
@@ -5,45 +5,38 @@ import { ComponentType, ReactNode } from "react" | ||
declare namespace LinguiMacro { | ||
export function t( | ||
literals: TemplateStringsArray, | ||
...placeholders: any[] | ||
): string | ||
export function plural(arg: number | string, options: Object): string | ||
export function selectOrdinal(arg: number | string, options: Object): string | ||
export function select( | ||
arg: string, | ||
choices: { [key: string]: string } | ||
): string | ||
export function defineMessages< | ||
M extends { [key: string]: MessageDescriptor } | ||
>(messages: M): M | ||
export function defineMessage( | ||
descriptor: MessageDescriptor | ||
): MessageDescriptor | ||
export function t( | ||
literals: TemplateStringsArray, | ||
...placeholders: any[] | ||
): string | ||
export function plural(arg: number | string, options: Object): string | ||
export function selectOrdinal(arg: number | string, options: Object): string | ||
export function select(arg: string, choices: { [key: string]: string }): string | ||
export function defineMessages<M extends { [key: string]: MessageDescriptor }>( | ||
messages: M | ||
): M | ||
export function defineMessage(descriptor: MessageDescriptor): MessageDescriptor | ||
export interface TransProps { | ||
id?: string | ||
comment?: string | ||
render?: TransRenderType | ||
} | ||
export interface TransProps { | ||
id?: string | ||
comment?: string | ||
render?: TransRenderType | ||
} | ||
export interface ChoiceProps extends TransProps { | ||
value?: string | number | ||
offset?: number | ||
zero: ReactNode | ||
one: ReactNode | ||
few: ReactNode | ||
many: ReactNode | ||
other: ReactNode | ||
} | ||
export interface ChoiceProps extends TransProps { | ||
value?: string | number | ||
offset?: number | ||
zero?: ReactNode | ||
one?: ReactNode | ||
few?: ReactNode | ||
many?: ReactNode | ||
other?: ReactNode | ||
} | ||
export interface SelectProps extends TransProps { | ||
value?: string | ||
other?: ReactNode | ||
} | ||
export interface SelectProps extends TransProps { | ||
value?: string | ||
other?: ReactNode | ||
} | ||
export const Trans: ComponentType<TransProps> | ||
export const Plural: ComponentType<ChoiceProps> | ||
export const Select: ComponentType<SelectProps> | ||
export const SelectOrdinal: ComponentType<ChoiceProps> | ||
} | ||
export const Trans: ComponentType<TransProps> | ||
export const Plural: ComponentType<ChoiceProps> | ||
export const Select: ComponentType<SelectProps> | ||
export const SelectOrdinal: ComponentType<ChoiceProps> |
@@ -12,4 +12,2 @@ "use strict"; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
@@ -27,2 +25,12 @@ | ||
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 _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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
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) { (0, _defineProperty2.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; } | ||
var keepSpaceRe = /(?:\\(?:\r\n|\r|\n))+\s+/g; | ||
@@ -86,4 +94,5 @@ var keepNewLineRe = /(?:\r\n|\r|\n)+\s+/g; | ||
_this.addExtractMark(path); | ||
_this.addExtractMark(path); // @ts-ignore | ||
path.replaceWith(newNode); | ||
@@ -196,3 +205,4 @@ }); | ||
return (0, _utils.zip)(exp.quasis, exp.expressions); | ||
}, R.flatten, R.filter(Boolean)); | ||
}, // @ts-ignore | ||
R.flatten, R.filter(Boolean)); | ||
return tokenize(_this.types.isTaggedTemplateExpression(node) ? node.quasi : node); | ||
@@ -202,3 +212,4 @@ }); | ||
var format = node.callee.name.toLowerCase(); | ||
var token = (0, _objectSpread2.default)({}, _this.tokenizeExpression(node.arguments[0]), { | ||
var token = _objectSpread({}, _this.tokenizeExpression(node.arguments[0]), { | ||
format: format, | ||
@@ -209,9 +220,10 @@ options: { | ||
}); | ||
var props = node.arguments[1].properties; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
var _iterator = _createForOfIteratorHelper(props), | ||
_step; | ||
try { | ||
for (var _iterator = props[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var attr = _step.value; | ||
@@ -242,14 +254,5 @@ var key = attr.key; // name is either: | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
_iterator.e(err); | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
_iterator.f(); | ||
} | ||
@@ -256,0 +259,0 @@ |
@@ -26,2 +26,8 @@ "use strict"; | ||
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 _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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
var pluralRuleRe = /(_[\d\w]+|zero|one|two|few|many|other)/; | ||
@@ -40,3 +46,3 @@ | ||
return text.replace(stripAroundTagsRe, "$1").replace(keepSpaceRe, " ") // keep escaped newlines | ||
.replace(/\\n/, "\n").replace(/\\s/, " ").trim(); | ||
.replace(/\\n/g, "\n").replace(/\\s/g, " ").trim(); | ||
} | ||
@@ -117,3 +123,4 @@ | ||
newNode.loc = path.node.loc; | ||
newNode.loc = path.node.loc; // @ts-ignore | ||
path.replaceWith(newNode); | ||
@@ -195,3 +202,4 @@ }); | ||
return (0, _utils.zip)(exp.quasis, exp.expressions); | ||
}, R.flatten, R.filter(Boolean)); | ||
}, // @ts-ignore | ||
R.flatten, R.filter(Boolean)); | ||
return tokenize(exp); | ||
@@ -229,8 +237,8 @@ } else if (_this.types.isJSXElement(exp)) { | ||
}; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
var _iterator = _createForOfIteratorHelper(props), | ||
_step; | ||
try { | ||
for (var _iterator = props[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var attr = _step.value; | ||
@@ -259,14 +267,5 @@ var name = attr.name.name; | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
_iterator.e(err); | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
_iterator.f(); | ||
} | ||
@@ -273,0 +272,0 @@ |
{ | ||
"name": "@lingui/macro", | ||
"version": "3.0.0-7", | ||
"version": "3.0.0-8", | ||
"description": "Macro for generating messages in ICU MessageFormat syntax", | ||
@@ -22,3 +22,3 @@ "main": "index.ts", | ||
"engines": { | ||
"node": ">=8.0.0" | ||
"node": ">=10.0.0" | ||
}, | ||
@@ -32,4 +32,4 @@ "files": [ | ||
"dependencies": { | ||
"@babel/runtime": "^7.4.5", | ||
"ramda": "^0.26.1" | ||
"@babel/runtime": "^7.9.2", | ||
"ramda": "^0.27.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39500
810
+ Addedramda@0.27.2(transitive)
- Removedramda@0.26.1(transitive)
Updated@babel/runtime@^7.9.2
Updatedramda@^0.27.0