From b40bfe59d2e27a24f3039afc710b4dd5e0b8d144 Mon Sep 17 00:00:00 2001 From: Oz Date: Thu, 5 Nov 2015 15:51:53 +0200 Subject: [PATCH] fix jspm add node-process dependency --- README.md | 2 +- angular-electron.js | 11 +++++------ angular-electron.min.js | 2 +- gulpfile.js | 4 ++-- package.json | 2 +- src/process.js | 2 +- src/remote.js | 3 +-- src/rendererModules.js | 2 +- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7c47246..a215620 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ menu, menu-item, power-save-blocker, protocol, web-contents, tray` path, punycode, querystring, readline, stream, string_decoder, tls, dgram, url, util, v8, vm, zlib` -> All of the modules are required upon instantiation. +> All of the modules are lazy required (required only on use). ### remoteProvider diff --git a/angular-electron.js b/angular-electron.js index e05685b..877d185 100644 --- a/angular-electron.js +++ b/angular-electron.js @@ -1,4 +1,4 @@ -(function(angular, require, undefined) {'use strict'; +(function(angular, electronRequire, electronProcess, undefined) {'use strict'; angular.module('angular-electron', []); @@ -15,7 +15,7 @@ angular.module('angular-electron').directive('externalLink', ['shell', function }; }]); -angular.module('angular-electron').constant('process', process); +angular.module('angular-electron').constant('process', electronProcess); var remoteModules = ['app', 'auto-updater', 'browser-window', 'content-tracing', 'dialog', 'global-shortcut', 'menu', 'menu-item', 'power-save-blocker', @@ -25,8 +25,7 @@ var nodeModules = ['buffer', 'child_process', 'cluster', 'crypto', 'dns', 'event 'string_decoder', 'tls', 'dgram', 'url', 'util', 'v8', 'vm', 'zlib']; angular.module('angular-electron').provider('remote', ['$provide', function($provide) { - var _remote = 'remote'; - var remote = require(_remote); + var remote = electronRequire('remote'); function register(name, _require) { _require = _require || name; @@ -60,7 +59,7 @@ var wrapModules = ['ipc', 'web-frame', 'clipboard', 'crash-reporter', 'native-im angular.forEach(wrapModules, function (_module) { angular.module('angular-electron').service(_module.name || _module, [function() { - var __module = require(_module.require || _module); + var __module = electronRequire(_module.require || _module); return __module; }]); @@ -104,4 +103,4 @@ angular.module('angular-electron').service('safeShutdown', ['$q', 'currentWindow }; }]); -})(window.angular, window.require); +})(window.angular, window.require, window.process); diff --git a/angular-electron.min.js b/angular-electron.min.js index 432a7b3..add46fb 100644 --- a/angular-electron.min.js +++ b/angular-electron.min.js @@ -1 +1 @@ -!function(e,r,n){"use strict";e.module("angular-electron",[]),e.module("angular-electron").directive("externalLink",["shell",function(e){return{restrict:"A",link:function(r,n,t){n.on("click",function(r){r.preventDefault(),e.openExternal(t.href||t.externalLink)})}}}]),e.module("angular-electron").constant("process",process);var t=["app","auto-updater","browser-window","content-tracing","dialog","global-shortcut","menu","menu-item","power-save-blocker","protocol","web-contents","tray"],o=["buffer","child_process","cluster","crypto","dns","events","fs","http","https","net","os","path","punycode","querystring","readline","stream","string_decoder","tls","dgram","url","util","v8","vm","zlib"];e.module("angular-electron").provider("remote",["$provide",function(n){function u(e,r){r=r||e,n.service(e,function(){var e=i.require(r);return e})}var c="remote",i=r(c);this.register=u,this.$get=[function(){return i}],n.constant("remoteProcess",i.process),n.constant("currentWindow",i.getCurrentWindow()),e.forEach(t,function(e){u(e.name||e,e.require)}),e.forEach(o,function(e){u(e.name||e,e.require)})}]);var u=["ipc","web-frame","clipboard","crash-reporter","native-image","screen","shell"];e.forEach(u,function(n){e.module("angular-electron").service(n.name||n,[function(){var e=r(n.require||n);return e}])}),e.module("angular-electron").service("safeShutdown",["$q","currentWindow","app",function(r,t,o){function u(e){i.push(e)}function c(){var t=[];return e.forEach(i,function(e){var r=e();r!==n&&r.then!==n&&t.push(r)}),r.all(t)}var i=[];return t.safeReload=function(){c().then(function(){t.reload()})},o.safeQuit=function(){c().then(function(){o.quit()})},{register:u}}])}(window.angular,window.require); \ No newline at end of file +!function(e,r,n,t){"use strict";e.module("angular-electron",[]),e.module("angular-electron").directive("externalLink",["shell",function(e){return{restrict:"A",link:function(r,n,t){n.on("click",function(r){r.preventDefault(),e.openExternal(t.href||t.externalLink)})}}}]),e.module("angular-electron").constant("process",n);var o=["app","auto-updater","browser-window","content-tracing","dialog","global-shortcut","menu","menu-item","power-save-blocker","protocol","web-contents","tray"],u=["buffer","child_process","cluster","crypto","dns","events","fs","http","https","net","os","path","punycode","querystring","readline","stream","string_decoder","tls","dgram","url","util","v8","vm","zlib"];e.module("angular-electron").provider("remote",["$provide",function(n){function t(e,r){r=r||e,n.service(e,function(){var e=i.require(r);return e})}var i=r("remote");this.register=t,this.$get=[function(){return i}],n.constant("remoteProcess",i.process),n.constant("currentWindow",i.getCurrentWindow()),e.forEach(o,function(e){t(e.name||e,e.require)}),e.forEach(u,function(e){t(e.name||e,e.require)})}]);var i=["ipc","web-frame","clipboard","crash-reporter","native-image","screen","shell"];e.forEach(i,function(n){e.module("angular-electron").service(n.name||n,[function(){var e=r(n.require||n);return e}])}),e.module("angular-electron").service("safeShutdown",["$q","currentWindow","app",function(r,n,o){function u(e){c.push(e)}function i(){var n=[];return e.forEach(c,function(e){var r=e();r!==t&&r.then!==t&&n.push(r)}),r.all(n)}var c=[];return n.safeReload=function(){i().then(function(){n.reload()})},o.safeQuit=function(){i().then(function(){o.quit()})},{register:u}}])}(window.angular,window.require,window.process); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 8be8a96..3d939f8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,9 +3,9 @@ var gulp = require('gulp'), insert = require('gulp-insert'), uglify = require('gulp-uglify'); -var HEADER = "(function(angular, require, undefined) {'use strict';\n\n" + +var HEADER = "(function(angular, electronRequire, electronProcess, undefined) {'use strict';\n\n" + "angular.module('angular-electron', []);\n\n"; -var FOOTER = "\n})(window.angular, window.require);\n"; +var FOOTER = "\n})(window.angular, window.require, window.process);\n"; gulp.task('build:dev', function () { return gulp.src('./src/*') diff --git a/package.json b/package.json index c6d5042..0396e34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-electron", - "version": "0.1.10", + "version": "0.1.11", "description": "angularjs helpers for electron apps", "repository": { "type": "git", diff --git a/src/process.js b/src/process.js index e43575a..a95b012 100644 --- a/src/process.js +++ b/src/process.js @@ -1 +1 @@ -angular.module('angular-electron').constant('process', process); +angular.module('angular-electron').constant('process', electronProcess); diff --git a/src/remote.js b/src/remote.js index 864d11e..bf3263f 100644 --- a/src/remote.js +++ b/src/remote.js @@ -6,8 +6,7 @@ var nodeModules = ['buffer', 'child_process', 'cluster', 'crypto', 'dns', 'event 'string_decoder', 'tls', 'dgram', 'url', 'util', 'v8', 'vm', 'zlib']; angular.module('angular-electron').provider('remote', ['$provide', function($provide) { - var _remote = 'remote'; - var remote = require(_remote); + var remote = electronRequire('remote'); function register(name, _require) { _require = _require || name; diff --git a/src/rendererModules.js b/src/rendererModules.js index a31a2a6..fab2858 100644 --- a/src/rendererModules.js +++ b/src/rendererModules.js @@ -2,7 +2,7 @@ var wrapModules = ['ipc', 'web-frame', 'clipboard', 'crash-reporter', 'native-im angular.forEach(wrapModules, function (_module) { angular.module('angular-electron').service(_module.name || _module, [function() { - var __module = require(_module.require || _module); + var __module = electronRequire(_module.require || _module); return __module; }]);