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

coffee-react

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coffee-react - npm Package Compare versions

Comparing version 0.5.2 to 1.0.1

15

lib/coffee-react-script.js
// Generated by CoffeeScript 1.7.1
var CoffeeScript, csCompile, fs, helpers, transform;
var CoffeeScript, fs, helpers, transform;

@@ -12,3 +12,3 @@ fs = require('fs');

CoffeeScript.FILE_EXTENSIONS.push('.csx', '.cjsx');
CoffeeScript.FILE_EXTENSIONS.push('.cjsx');

@@ -19,12 +19,12 @@ CoffeeScript.register = function() {

csCompile = CoffeeScript.compile;
CoffeeScript._csCompile = CoffeeScript.compile;
CoffeeScript.compile = function(code, options) {
var input;
input = helpers.hasCJSXPragma && transform(code) || code;
return csCompile(input, options);
input = transform(code);
return CoffeeScript._csCompile(input, options);
};
CoffeeScript._compileFile = function(filename, sourceMap) {
var answer, err, input, raw, stripped;
var answer, err, raw, stripped;
if (sourceMap == null) {

@@ -35,5 +35,4 @@ sourceMap = false;

stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw;
input = helpers.hasCJSXExtension(filename) && transform(stripped) || stripped;
try {
answer = CoffeeScript.compile(input, {
answer = CoffeeScript.compile(stripped, {
filename: filename,

@@ -40,0 +39,0 @@ sourceMap: sourceMap,

@@ -7,13 +7,13 @@ // Generated by CoffeeScript 1.7.1

helpers.isCoffee = function(filepath) {
return /\.((lit)?coffee|coffee\.md|cjsx|csx)$/.test(filepath);
return /\.((lit)?coffee|coffee\.md|cjsx)$/.test(filepath);
};
helpers.hasCJSXExtension = function(filepath) {
return /\.(cjsx|csx)$/.test(filepath);
return /\.(cjsx)$/.test(filepath);
};
helpers.hasCJSXPragma = function(src) {
return /^\s*#\s*@(cjsx|csx)/.test(src);
return /^\s*#\s*@(cjsx)/.test(src);
};
module.exports = helpers;

@@ -12,3 +12,3 @@ {

"author": "James Friend",
"version": "0.5.2",
"version": "1.0.1",
"licenses": [

@@ -43,3 +43,3 @@ {

"coffee-script": "^1.7.1",
"coffee-react-transform": "^0.5.2"
"coffee-react-transform": "^1.0.1"
},

@@ -49,4 +49,5 @@ "devDependencies": {

"tap": "^0.4.9",
"object.assign": "^0.5.0"
"object.assign": "^0.5.0",
"react": "^0.11.2"
}
}

@@ -10,5 +10,2 @@ # Coffee-React

### Try it out
The [try coffee-react](http://jsdf.github.io/coffee-react-transform/) tool is available to test out some CJSX code and see the CoffeeScript it transforms into.
### Example

@@ -22,8 +19,6 @@

render: ->
{showTitle, neat} = @props
<div className="neat-component">
{<h1>A Component is I</h1> if showTitle}
Coffeescript really saves a lot of typing...
{<p>is this component neat?<br />{neat}x{times}</p> for times in [1..10]}
{<h1>A Component is I</h1> if @props.showTitle}
<hr />
{<p>This line has been printed {n} times</p> for n in [1..10]}
</div>

@@ -44,11 +39,10 @@ ```

render: function() {
var neat, showTitle, times, _ref;
_ref = this.props, showTitle = _ref.showTitle, neat = _ref.neat;
return React.DOM.div({
var n;
return React.createElement(React.DOM.div, {
"className": "neat-component"
}, (showTitle ? React.DOM.h1(null, "A Component is I") : void 0), "Coffeescript really saves a lot of typing...", (function() {
}, (this.props.showTitle ? React.createElement(React.DOM.h1, null, "A Component is I") : void 0), React.createElement(React.DOM.hr, null), (function() {
var _i, _results;
_results = [];
for (times = _i = 1; _i <= 10; times = ++_i) {
_results.push(React.DOM.p(null, "is this component neat?", React.DOM.br(null), neat, "x", times));
for (n = _i = 1; _i <= 10; n = ++_i) {
_results.push(React.createElement(React.DOM.p, null, "This line has been printed ", n, " times"));
}

@@ -116,3 +110,3 @@ return _results;

extraProps = color: 'red', speed: 'fast'
React.DOM.div(Object.assign({"color": "blue"}, extraProps)
React.createElement(React.DOM.div, Object.assign({"color": "blue"}, extraProps)
```

@@ -122,2 +116,12 @@ If you use this syntax in your code, be sure to include a shim for `Object.assign` for browsers/environments which don't yet support it (basically all of them).

### Breaking Changes in 1.0
React 0.12 will introduce changes to the way component descriptors are constructed, where the return value of `React.createClass` is not a descriptor factory but simply the component class itself, and descriptors must be created manually using `React.createElement` or by wrapping the component class with `React.createDescriptor`.
In preparation for this, coffee-react-transform (and as a result, coffee-react) now outputs calls to `React.createElement` to construct element descriptors from component classes for you, so you won't need to [wrap your classes using `React.createFactory`](https://gist.github.com/sebmarkbage/ae327f2eda03bf165261). However, for this to work you will need to be using at least React 0.11.2, which adds `React.createElement`.
If you want the older style JSX output (which just desugars into function calls) then you need to use the 0.x branch, eg. 0.5.1.
Additionally, as of 1.0.0, all input files will be CJSX transformed, even if they don't have a `.cjsx` extension or `# @cjsx` pragma.
### Related projects

@@ -124,0 +128,0 @@ - [coffee-react-transform](https://github.com/jsdf/coffee-react-transform), the underlying parser/transformer package.

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