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

react-on-rails

Package Overview
Dependencies
Maintainers
1
Versions
204
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-on-rails - npm Package Compare versions

Comparing version 2.0.0-beta.1 to 2.0.0-beta.2

node_package/lib/context.js

36

node_package/lib/buildConsoleReplay.js

@@ -6,2 +6,3 @@ 'use strict';

});
exports.consoleReplay = consoleReplay;
exports.default = buildConsoleReplay;

@@ -19,21 +20,26 @@

function buildConsoleReplay() {
var consoleReplay = '';
function consoleReplay() {
// console.history is a global polyfill used in server rendering.
var history = console.history;
if (!history || history.length === 0) {
return '';
}
if (history && history.length > 0) {
history.forEach(function (msg) {
var stringifiedList = msg.arguments.map(function (arg) {
try {
return typeof arg === 'string' || arg instanceof String ? arg : (0, _stringify2.default)(arg);
} catch (e) {
return e.message + ': ' + arg;
}
});
consoleReplay += '\nconsole.' + msg.level + '.apply(console, ' + (0, _stringify2.default)(stringifiedList) + ');';
var lines = history.map(function (msg) {
var stringifiedList = msg.arguments.map(function (arg) {
try {
return typeof arg === 'string' || arg instanceof String ? arg : (0, _stringify2.default)(arg);
} catch (e) {
return e.message + ': ' + arg;
}
});
}
return _RenderUtils2.default.wrapInScriptTags(consoleReplay);
return 'console.' + msg.level + '.apply(console, ' + (0, _stringify2.default)(stringifiedList) + ');';
});
return lines.join('\n');
}
function buildConsoleReplay() {
return _RenderUtils2.default.wrapInScriptTags(consoleReplay());
}

@@ -45,3 +45,3 @@ 'use strict';

function render(el) {
var componentName = el.getAttribute('data-component-name');
var name = el.getAttribute('data-component-name');
var domNodeId = el.getAttribute('data-dom-id');

@@ -60,3 +60,3 @@ var props = JSON.parse(el.getAttribute('data-props'));

var reactElementOrRouterResult = (0, _createReactElement2.default)({
componentName: componentName,
name: name,
props: props,

@@ -76,3 +76,3 @@ domNodeId: domNodeId,

e: e,
componentName: componentName,
name: name,
serverSide: false

@@ -79,0 +79,0 @@ });

@@ -19,7 +19,13 @@ 'use strict';

var _context = require('./context');
var _context2 = _interopRequireDefault(_context);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _components = new _map2.default(); // key = name used by react_on_rails
// key = name used by react_on_rails
// value = { name, component, generatorFunction: boolean }
var _components = new _map2.default();
exports.default = {

@@ -52,2 +58,3 @@ /**

getComponent: function getComponent(name) {
var ctx = (0, _context2.default)();
if (_components.has(name)) {

@@ -58,3 +65,3 @@ return _components.get(name);

// Backwards compatability. Remove for v3.0.
if (!context[name]) {
if (!ctx[name]) {
throw new Error('Could not find component registered with name ' + name);

@@ -64,4 +71,12 @@ }

console.warn('WARNING: Global components are deprecated support will be removed from a future version. ' + 'Use ReactOnRails.register');
return { name: name, component: context[name] };
return { name: name, component: ctx[name] };
},
/**
* Get an Object containing all registered components. Useful for debugging.
* @returns {*}
*/
components: function components() {
return _components;
}
};

@@ -22,3 +22,3 @@ 'use strict';

* @param options
* @param options.componentName
* @param options.name
* @param options.props

@@ -31,3 +31,3 @@ * @param options.domNodeId

function createReactElement(_ref) {
var componentName = _ref.componentName;
var name = _ref.name;
var props = _ref.props;

@@ -39,6 +39,6 @@ var domNodeId = _ref.domNodeId;

if (trace) {
console.log('RENDERED ' + componentName + ' to dom node with id: ' + domNodeId);
console.log('RENDERED ' + name + ' to dom node with id: ' + domNodeId);
}
var componentObj = _ReactOnRails2.default.getComponent(componentName);
var componentObj = _ReactOnRails2.default.getComponent(name);

@@ -45,0 +45,0 @@ // CONSIDER NOT RELEASING THE OPTION version

@@ -19,10 +19,10 @@ 'use strict';

var e = options.e;
var componentName = options.componentName;
var name = options.name;
var msg = '';
if (componentName) {
if (name) {
var lastLine = 'A generator function takes a single arg of props (and the location for react-router) ' + 'and returns a ReactElement.';
var shouldBeGeneratorError = 'ERROR: ReactOnRails is incorrectly detecting generator function to be false. The React\ncomponent \'' + componentName + '\' seems to be a generator function.\n' + lastLine;
var shouldBeGeneratorError = 'ERROR: ReactOnRails is incorrectly detecting generator function to be false. The React\ncomponent \'' + name + '\' seems to be a generator function.\n' + lastLine;
var reMatchShouldBeGeneratorError = /Can't add property context, object is not extensible/;

@@ -34,3 +34,3 @@ if (reMatchShouldBeGeneratorError.test(e.message)) {

shouldBeGeneratorError = 'ERROR: ReactOnRails is incorrectly detecting generatorFunction to be true, but the React\ncomponent \'' + componentName + '\' is not a generator function.\n' + lastLine;
shouldBeGeneratorError = 'ERROR: ReactOnRails is incorrectly detecting generatorFunction to be true, but the React\ncomponent \'' + name + '\' is not a generator function.\n' + lastLine;

@@ -37,0 +37,0 @@ var reMatchShouldNotBeGeneratorError = /Cannot call a class as a function/;

@@ -35,7 +35,11 @@ 'use strict';

var _context = require('./context');
var _context2 = _interopRequireDefault(_context);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var context = typeof window !== 'undefined' && window || typeof global !== 'undefined' && global || undefined;
var ctx = (0, _context2.default)();
context.ReactOnRails = {
ctx.ReactOnRails = {
/**

@@ -96,7 +100,15 @@ * Main entry point to using the react-on-rails npm package. This is how Rails will be able to

return (0, _buildConsoleReplay3.default)();
},
/**
* Get an Object containing all registered components. Useful for debugging.
* @returns {*}
*/
registeredComponents: function registeredComponents() {
return _ComponentStore2.default.components();
}
};
(0, _clientStartup2.default)(context);
(0, _clientStartup2.default)(ctx);
exports.default = context.ReactOnRails;
exports.default = ctx.ReactOnRails;

@@ -12,4 +12,4 @@ 'use strict';

return '\n<script>' + scriptBody + '\n</script>';
return '\n<script>\n' + scriptBody + '\n</script>';
}
};

@@ -35,3 +35,3 @@ 'use strict';

function serverRenderReactComponent(options) {
var componentName = options.componentName;
var name = options.name;
var domNodeId = options.domNodeId;

@@ -56,3 +56,3 @@ var trace = options.trace;

var redirectPath = redirectLocation.pathname + redirectLocation.search;
console.log('ROUTER REDIRECT: ' + componentName + ' to dom node with id: ' + domNodeId + ', redirect to ' + redirectPath);
console.log('ROUTER REDIRECT: ' + name + ' to dom node with id: ' + domNodeId + ', redirect to ' + redirectPath);
}

@@ -67,3 +67,3 @@ }

e: e,
componentName: componentName,
name: name,
serverSide: true

@@ -70,0 +70,0 @@ });

{
"name": "react-on-rails",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"description": "react-on-rails JavaScript for react_on_rails Ruby gem",

@@ -48,2 +48,3 @@ "main": "node_package/lib/ReactOnRails.js",

"lint": "node_package/scripts/lint && cd spec/dummy/client && npm run lint",
"lint:fix": "node_package/scripts/lint-fix",
"check": "npm run lint && npm run test",

@@ -54,3 +55,4 @@ "prerelease": "npm run check && npm run clean && npm run build",

"release:major": "node_package/scripts/release major",
"dummy:install": "cd spec/dummy && npm i",
"dummy:install": "rake dummy_apps",
"dummy:spec": "rake run_rspec:dummy",
"local": "echo 'Be sure to run npm run dummy:install' && npm run build && cd spec/dummy && foreman start"

@@ -57,0 +59,0 @@ },

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