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

i18next-parser

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-parser - npm Package Compare versions

Comparing version 1.0.0-beta29 to 1.0.0-beta30

44

dist/lexers/javascript-lexer.js

@@ -1,6 +0,4 @@

"use strict";Object.defineProperty(exports, "__esModule", { value: true });var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};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 _acorn = require("acorn");var acorn = _interopRequireWildcard(_acorn);
var _inject = require("acorn-stage3/inject");var _inject2 = _interopRequireDefault(_inject);
var _acornEs = require("acorn-es7");var _acornEs2 = _interopRequireDefault(_acornEs);
var _walk = require("acorn/dist/walk");var walk = _interopRequireWildcard(_walk);
var _baseLexer = require("./base-lexer");var _baseLexer2 = _interopRequireDefault(_baseLexer);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _interopRequireWildcard(obj) {if (obj && obj.__esModule) {return obj;} else {var newObj = {};if (obj != null) {for (var key in obj) {if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];}}newObj.default = obj;return newObj;}}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;}
'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};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 _acorn = require('acorn');var acorn = _interopRequireWildcard(_acorn);
var _walk = require('acorn/dist/walk');var walk = _interopRequireWildcard(_walk);
var _baseLexer = require('./base-lexer');var _baseLexer2 = _interopRequireDefault(_baseLexer);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _interopRequireWildcard(obj) {if (obj && obj.__esModule) {return obj;} else {var newObj = {};if (obj != null) {for (var key in obj) {if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];}}newObj.default = obj;return newObj;}}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;}

@@ -19,11 +17,8 @@ var WalkerBase = Object.assign({}, walk.base, {

sourceType: 'module',
ecmaVersion: 9 },
options.acorn, {
plugins: _extends({
stage3: true,
es7: true },
options.acorn ? options.acorn.plugins : {}) });
ecmaVersion: 9,
injectors: [],
plugins: {} },
options.acorn);
_this.functions = options.functions || ['t'];

@@ -35,12 +30,9 @@ _this.attr = options.attr || 'i18nKey';

if (_this.acornOptions.plugins) {
if (_this.acornOptions.plugins.stage3) {
_this.acorn = (0, _inject2.default)(_this.acorn);
}
if (_this.acornOptions.plugins.es7) {
(0, _acornEs2.default)(_this.acorn);
}
}return _this;
}_createClass(JavascriptLexer, [{ key: "extract", value: function extract(
// Apply all injectors to the acorn instance
_this.acornOptions.injectors.reduce(
function (acornInstance, injector) {return injector(acornInstance);},
_this.acorn);return _this;
}_createClass(JavascriptLexer, [{ key: 'extract', value: function extract(
content) {

@@ -60,3 +52,3 @@ var that = this;

return this.keys;
} }, { key: "expressionExtractor", value: function expressionExtractor(
} }, { key: 'expressionExtractor', value: function expressionExtractor(

@@ -80,3 +72,3 @@ node) {

if (!concatenatedString) {
this.emit('warning', "Key is not a string literal: " + keyArgument.name);
this.emit('warning', 'Key is not a string literal: ' + keyArgument.name);
return;

@@ -88,3 +80,3 @@ }

if (keyArgument.type === 'Identifier') {
this.emit('warning', "Key is not a string literal: " + keyArgument.name);
this.emit('warning', 'Key is not a string literal: ' + keyArgument.name);
}

@@ -109,3 +101,3 @@

}
} }, { key: "concatenateString", value: function concatenateString(
} }, { key: 'concatenateString', value: function concatenateString(

@@ -138,2 +130,2 @@ binaryExpression) {var string = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

return string;
} }]);return JavascriptLexer;}(_baseLexer2.default);exports.default = JavascriptLexer;module.exports = exports["default"];
} }]);return JavascriptLexer;}(_baseLexer2.default);exports.default = JavascriptLexer;module.exports = exports['default'];
'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};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 _javascriptLexer = require('./javascript-lexer');var _javascriptLexer2 = _interopRequireDefault(_javascriptLexer);
var _walk = require('acorn/dist/walk');var walk = _interopRequireWildcard(_walk);
var _inject = require('acorn-jsx/inject');var _inject2 = _interopRequireDefault(_inject);function _interopRequireWildcard(obj) {if (obj && obj.__esModule) {return obj;} else {var newObj = {};if (obj != null) {for (var key in obj) {if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];}}newObj.default = obj;return newObj;}}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 _walk = require('acorn/dist/walk');var walk = _interopRequireWildcard(_walk);function _interopRequireWildcard(obj) {if (obj && obj.__esModule) {return obj;} else {var newObj = {};if (obj != null) {for (var key in obj) {if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];}}newObj.default = obj;return newObj;}}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;}

@@ -39,3 +38,11 @@ var JSXParserExtension = {

_this.acorn = (0, _inject2.default)(_this.acorn);return _this;
try {
var injectAcornJsx = require('acorn-jsx/inject');
_this.acorn = injectAcornJsx(_this.acorn);
} catch (e) {
throw new Error(
'You must install acorn-jsx to parse jsx files. ' +
'Try running "yarn add acorn-jsx" or "npm install acorn-jsx"');
}return _this;
}_createClass(JsxLexer, [{ key: 'extract', value: function extract(

@@ -42,0 +49,0 @@

'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};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 _get = function get(object, property, receiver) {if (object === null) object = Function.prototype;var desc = Object.getOwnPropertyDescriptor(object, property);if (desc === undefined) {var parent = Object.getPrototypeOf(object);if (parent === null) {return undefined;} else {return get(parent, property, receiver);}} else if ("value" in desc) {return desc.value;} else {var getter = desc.get;if (getter === undefined) {return undefined;}return getter.call(receiver);}};var _jsxLexer = require('./jsx-lexer');var _jsxLexer2 = _interopRequireDefault(_jsxLexer);
var _fs = require('fs');
var _path = require('path');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 _path = require('path');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
var loadedTs = null;
function loadTypeScript() {
if (loadedTs) {
return loadedTs;
}
try {
loadedTs = require('typescript');
} catch (e) {
throw new ParsingError('You must install typescript to parse TypeScript files. ' + 'Try running "yarn add typescript" or "npm install typescript"');
}
return loadedTs;
}var
TypescriptLexer = function (_JsxLexer) {_inherits(TypescriptLexer, _JsxLexer);
function TypescriptLexer() {var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};_classCallCheck(this, TypescriptLexer);var _this = _possibleConstructorReturn(this, (TypescriptLexer.__proto__ || Object.getPrototypeOf(TypescriptLexer)).call(this,
options));
_this.tsOptions = options.tsOptions;return _this;
_this.tsOptions = options.tsOptions;
try {
_this.typescript = require('typescript');
} catch (e) {
throw new Error(
'You must install typescript to parse TypeScript files. ' +
'Try running "yarn add typescript" or "npm install typescript"');
}return _this;
}_createClass(TypescriptLexer, [{ key: 'extract', value: function extract(
content, extension) {
var transpiled = loadTypeScript().transpileModule(content, {
var transpiled = this.typescript.transpileModule(content, {
compilerOptions: _extends({},

@@ -30,0 +22,0 @@ this.tsOptions, {

@@ -5,3 +5,3 @@ {

"name": "i18next-parser",
"version": "1.0.0-beta29",
"version": "1.0.0-beta30",
"license": "MIT",

@@ -8,0 +8,0 @@ "main": "dist/index.js",

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