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

electron-redux

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-redux - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.eslintrc

32

dist/index.js

@@ -1,5 +0,29 @@

import forwardToMain from './middleware/forwardToMain';
import forwardToRenderer from './middleware/forwardToRenderer';
import triggerAlias, { createAliasedAction } from './middleware/triggerAlias';
'use strict';
export { forwardToMain, forwardToRenderer, triggerAlias, createAliasedAction };
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createAliasedAction = exports.triggerAlias = exports.forwardToRenderer = exports.forwardToMain = undefined;
var _forwardToMain = require('./middleware/forwardToMain');
var _forwardToMain2 = _interopRequireDefault(_forwardToMain);
var _forwardToRenderer = require('./middleware/forwardToRenderer');
var _forwardToRenderer2 = _interopRequireDefault(_forwardToRenderer);
var _triggerAlias = require('./middleware/triggerAlias');
var _triggerAlias2 = _interopRequireDefault(_triggerAlias);
var _createAliasedAction = require('./helpers/createAliasedAction');
var _createAliasedAction2 = _interopRequireDefault(_createAliasedAction);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.forwardToMain = _forwardToMain2.default;
exports.forwardToRenderer = _forwardToRenderer2.default;
exports.triggerAlias = _triggerAlias2.default;
exports.createAliasedAction = _createAliasedAction2.default;

30

dist/middleware/forwardToMain.js

@@ -1,15 +0,25 @@

import { ipcRenderer } from 'electron';
'use strict';
const forwardToMain = store => next => action => {
// eslint-disable-line no-unused-vars
if (action.type.substr(0, 2) !== '@@' && action.type.substr(0, 10) !== 'redux-form' && (!action.meta || !action.meta.scope || action.meta.scope !== 'local')) {
ipcRenderer.send('redux-action', action);
Object.defineProperty(exports, "__esModule", {
value: true
});
// stop action in-flight
return;
}
var _electron = require('electron');
return next(action); // eslint-disable-line consistent-return
var forwardToMain = function forwardToMain(store) {
return function (next) {
return function (action) {
// eslint-disable-line no-unused-vars
if (action.type.substr(0, 2) !== '@@' && action.type.substr(0, 10) !== 'redux-form' && (!action.meta || !action.meta.scope || action.meta.scope !== 'local')) {
_electron.ipcRenderer.send('redux-action', action);
// stop action in-flight
return;
}
return next(action); // eslint-disable-line consistent-return
};
};
};
export default forwardToMain;
exports.default = forwardToMain;

@@ -0,21 +1,33 @@

'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; };
import { BrowserWindow } from 'electron';
var _electron = require('electron');
const forwardToRenderer = store => next => action => {
// change scope to avoid endless-loop
const rendererAction = _extends({}, action, {
meta: _extends({}, action.meta, {
scope: 'local'
})
});
var forwardToRenderer = function forwardToRenderer() {
return function (next) {
return function (action) {
// change scope to avoid endless-loop
var rendererAction = _extends({}, action, {
meta: _extends({}, action.meta, {
scope: 'local'
})
});
const openWindows = BrowserWindow.getAllWindows();
openWindows.forEach(({ webContents }) => {
webContents.send('redux-action', rendererAction);
});
var openWindows = _electron.BrowserWindow.getAllWindows();
openWindows.forEach(function (_ref) {
var webContents = _ref.webContents;
return next(action);
webContents.send('redux-action', rendererAction);
});
return next(action);
};
};
};
export default forwardToRenderer;
exports.default = forwardToRenderer;

@@ -1,37 +0,42 @@

/* eslint-disable no-param-reassign */
/* eslint-disable no-unused-vars */
import assert from 'assert';
import { ALIASED } from '../actions';
'use strict';
// TODO: move to alias registry
const aliases = {};
Object.defineProperty(exports, "__esModule", {
value: true
});
export function createAliasedAction(name, actionCreator) {
// register
aliases[name] = actionCreator;
var _assert = require('assert');
// factory
return (...args) => ({
type: ALIASED,
payload: args,
meta: {
trigger: name
}
});
}
var _assert2 = _interopRequireDefault(_assert);
const triggerAlias = store => next => action => {
// TODO: store.dispatch() instead to not skip any middleware
if (action.type === ALIASED) {
assert(action.meta && action.meta.trigger, 'No trigger defined');
assert(aliases[action.meta.trigger], `Trigger alias ${ action.meta.trigger } not found`);
const args = action.payload || [];
var _alias = require('../actions/alias');
// trigger alias
action = aliases[action.meta.trigger](...args);
}
var _alias2 = require('../registry/alias');
return next(action);
var _alias3 = _interopRequireDefault(_alias2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } /* eslint-disable no-param-reassign */
/* eslint-disable no-unused-vars */
var triggerAlias = function triggerAlias(store) {
return function (next) {
return function (action) {
// TODO: store.dispatch() instead to not skip any middleware
if (action.type === _alias.ALIASED) {
(0, _assert2.default)(action.meta && action.meta.trigger, 'No trigger defined');
var alias = _alias3.default.get(action.meta.trigger);
(0, _assert2.default)(alias, 'Trigger alias ' + action.meta.trigger + ' not found');
var args = action.payload || [];
// trigger alias
action = alias.apply(undefined, _toConsumableArray(args));
}
return next(action);
};
};
};
export default triggerAlias;
exports.default = triggerAlias;
{
"name": "electron-redux",
"version": "1.0.0",
"version": "1.1.0",
"description": "Use redux in the main and browser process in electron",

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

"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint src",
"build": "babel src --out-dir dist"

@@ -13,3 +14,5 @@ },

"electron",
"redux"
"redux",
"react",
"desktop"
],

@@ -19,5 +22,7 @@ "author": "Burkhard Reffeling <burkhard.reffeling@gmail.com>",

"dependencies": {
"electron": "^1.4.3",
"redux": "^3.4.0"
},
"peerDependencies": {
"electron": "^1.4.3",
"redux": "^3.4.0"

@@ -27,5 +32,12 @@ },

"babel-cli": "^6.16.0",
"babel-eslint": "^7.0.0",
"babel-plugin-transform-object-rest-spread": "^6.16.0",
"babel-preset-es2017": "^6.16.0"
"babel-preset-es2015": "^6.16.0",
"babel-preset-es2016": "^6.16.0",
"babel-preset-es2017": "^6.16.0",
"eslint": "^3.7.1",
"eslint-config-airbnb-base": "^8.0.0",
"eslint-plugin-import": "^1.16.0",
"jest": "^16.0.1"
}
}

@@ -42,3 +42,3 @@ # electron-redux

...otherMiddleware,
forwardToMain, // IMPORTANT! This goes last
forwardToRenderer, // IMPORTANT! This goes last
)

@@ -45,0 +45,0 @@ )

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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