electron-redux
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -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; |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136769
14
131
4
10
+ Addedelectron@^1.4.3
+ Added@types/node@8.10.66(transitive)
+ Addedajv@6.12.6(transitive)
+ Addedansi-regex@2.1.1(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconcat-stream@1.6.2(transitive)
+ Addedcore-util-is@1.0.21.0.3(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedelectron@1.8.8(transitive)
+ Addedelectron-download@3.3.0(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextract-zip@1.7.0(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfd-slicer@1.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedfs-extra@0.30.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhome-path@1.0.7(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedini@1.3.8(transitive)
+ Addedis-fullwidth-code-point@1.0.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisarray@0.0.11.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsonfile@2.4.0(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedklaw@1.3.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.0.0(transitive)
+ Addednugget@2.2.0(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedobject-keys@0.4.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-exists@2.1.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpend@1.2.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedpretty-bytes@4.0.2(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedprogress-stream@1.2.0(transitive)
+ Addedpsl@1.15.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedreadable-stream@1.1.142.3.8(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedsingle-line-log@1.1.2(transitive)
+ Addedspeedometer@0.1.4(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedstring-width@1.0.2(transitive)
+ Addedstring_decoder@0.10.311.1.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedsumchecker@1.3.1(transitive)
+ Addedthrottleit@0.0.2(transitive)
+ Addedthrough2@0.2.3(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedxtend@2.1.2(transitive)
+ Addedyauzl@2.10.0(transitive)