Comparing version 0.0.0 to 0.0.1
@@ -1,1 +0,1 @@ | ||
exports.visitorList = require('./transforms/react').visitorList; | ||
module.exports = require('./transforms/react'); |
{ | ||
"name": "jsx-i18n", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"esprima-fb": "~6001.1001.0-dev-harmony-fb", | ||
"jstransform": "~6.3.2" | ||
"jstransform": "~6.3.2", | ||
"react-tools": "^0.12.0" | ||
}, | ||
"main": "index.js" | ||
"main": "index.js", | ||
"description": "Simple [jstransform](https://github.com/facebook/jstransform) pass for use with the JSX transformer in React 0.12+ to convert JSX `<$_>...</$_>` tags (only) to `$_(...)` calls, to simulate how React 0.11 behaved.", | ||
"devDependencies": {}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Khan/jsx-i18n.git" | ||
}, | ||
"author": "Ben Alpert", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Khan/jsx-i18n/issues" | ||
}, | ||
"homepage": "https://github.com/Khan/jsx-i18n" | ||
} |
@@ -24,3 +24,5 @@ # jsx-i18n | ||
process.stdin.on("end", function() { | ||
var visitorList = jsxI18n.visitorList.concat(visitors.getAllVisitors()); | ||
var visitorList = jsxI18n.getVisitorList([ | ||
"$_" | ||
]).concat(visitors.getAllVisitors()); | ||
js = jstransform.transform(visitorList, js).code; | ||
@@ -36,6 +38,6 @@ | ||
// in | ||
var x = <div><$_ name={WORLD}>hello %(name)s</$_></div>; | ||
var x = <div><$_ name={world}>hello %(name)s</$_></div>; | ||
// out | ||
var x = React.createElement("div", null, $_({name: "WORLD"}, "hello %(name)s")); | ||
var x = React.createElement("div", null, $_({name: world}, "hello %(name)s")); | ||
``` |
@@ -71,3 +71,3 @@ /** | ||
if (hasAtLeastOneSpreadProperty) { | ||
utils.append('Object.assign({', state); | ||
utils.append('React.__spread({', state); | ||
} else if (hasAttributes) { | ||
@@ -227,12 +227,40 @@ utils.append('{', state); | ||
visitReactTag.test = function(object, path, state) { | ||
if (object.type === Syntax.XJSElement) { | ||
var openingElement = object.openingElement; | ||
var nameObject = openingElement.name; | ||
return nameObject.type === Syntax.XJSIdentifier && nameObject.name === "$_"; | ||
var getVisitorList = function(i18nFuncList) { | ||
var i18nTestHash = {}; | ||
for (var i = 0; i < i18nFuncList.length; i++) { | ||
i18nTestHash["__i18n__" + i18nFuncList[i]] = true; | ||
} | ||
var visitor = function(traverse, object, path, state) { | ||
return visitReactTag(traverse, object, path, state); | ||
}; | ||
visitor.test = function(object, path, state) { | ||
if (object.type === Syntax.XJSElement) { | ||
var openingElement = object.openingElement; | ||
var nameObject = openingElement.name; | ||
return nameObject.type === Syntax.XJSIdentifier && | ||
i18nTestHash["__i18n__" + nameObject.name]; | ||
} | ||
}; | ||
return [visitor]; | ||
}; | ||
exports.visitorList = [ | ||
visitReactTag | ||
]; | ||
/** | ||
* Takes an array of i18n function names as strings, | ||
* and returns an array of visitors. | ||
* | ||
* getVisitorList(["$_", "$i18nDoNotTranslate"]) | ||
* => [<visitor>] | ||
*/ | ||
exports.getVisitorList = getVisitorList; | ||
/** | ||
* deprecated: visitorList | ||
* | ||
* For backwards compatibility, this returns the list with just | ||
* the i18n function `$_` | ||
*/ | ||
exports.visitorList = getVisitorList(["$_"]); | ||
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
13348
7
327
1
1
42
0
3
1
1
+ Addedreact-tools@^0.12.0
+ Addedacorn@5.7.4(transitive)
+ Addedast-types@0.9.6(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcommoner@0.10.8(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addeddefined@1.0.1(transitive)
+ Addeddetective@4.7.1(transitive)
+ Addedesprima@3.1.3(transitive)
+ Addedesprima-fb@8001.1001.0-dev-harmony-fb(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjstransform@8.2.0(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprivate@0.1.8(transitive)
+ Addedq@1.5.1(transitive)
+ Addedreact-tools@0.12.2(transitive)
+ Addedrecast@0.11.23(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedwrappy@1.0.2(transitive)