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

angular-hmr

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-hmr - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

interceptors/animation.js

55

angular-hot-replacement.js

@@ -15,2 +15,6 @@

this.name;
this.bootstrapElement;
this.element = document.querySelector('[ng-app]');
this.originalContent = this.element.innerHTML;
};

@@ -20,27 +24,54 @@

HotAngular.prototype.run = require('./interceptors/run');
HotAngular.prototype.value = require('./interceptors/value');
HotAngular.prototype.module = require('./interceptors/module');
HotAngular.prototype.config = require('./interceptors/config');
HotAngular.prototype.filter = require('./interceptors/filter');
HotAngular.prototype.factory = require('./interceptors/factory');
HotAngular.prototype.service = require('./interceptors/service');
HotAngular.prototype.constant = require('./interceptors/constant');
HotAngular.prototype.provider = require('./interceptors/provider');
HotAngular.prototype.animation = require('./interceptors/animation');
HotAngular.prototype.directive = require('./interceptors/directive');
HotAngular.prototype.controller = require('./interceptors/controller');
HotAngular.prototype.reloadState = function() {
var elm = angular.element(document.querySelector('[ng-app]'));
var elm = this.bootstrapElement;
if (elm) {
if (elm.injector().has('$state')) {
console.log('Reloading State');
var $state = elm.injector().get('$state');
if (elm.injector().has('$state')) {
console.log('Reloading State');
var $state = elm.injector().get('$state');
$state.transitionTo($state.current, $state.params, {
reload: true,
inherit: false,
notify: true
});
} else {
elm.injector().get('$compile')(elm.contents())(elm.scope());
}
$state.transitionTo($state.current, $state.params, {
reload: true,
inherit: false,
notify: true
});
} else {
elm.injector().get('$compile')(elm.contents())(elm.scope());
}
}
};
HotAngular.prototype.recompile = function() {
var elm = this.bootstrapElement;
console.log('Recompile App');
//elm.injector().get('$compile')(this.originalContent)(elm.scope());
window.location.reload();
};
HotAngular.prototype.test = function(webpackModule) {
console.log(webpackModule);
this.webpackModule = webpackModule;
return this;
}
module.exports = new HotAngular();

@@ -7,3 +7,3 @@ var path = require('path'),

var angularModule= /angular[\.\n ]+module\(([\'\"\w\.\-\,\[\] ]+)\)/g;
var angularModule= /angular[\.\n ]+module\(([\'\"\w\.\/\(\)\n\-\,\[\] ]+)\)/g;

@@ -36,3 +36,3 @@ module.exports = function (source, map) {

processedSource = source.replace(angularModule, 'hotAngular.module($1)');
processedSource = source.replace(angularModule, 'hotAngular.test(module).module($1)');

@@ -39,0 +39,0 @@ if (this.sourceMap === false) {

@@ -1,2 +0,2 @@

module.exports = function(thing) {
module.exports = function(configFunction) {

@@ -6,35 +6,7 @@ var _that = this;

var functionString = thing.toString();
console.log('CONFIG', configFunction);
functionString.replace(/var configName = [\'\"]([\w]+).+?(?=;)/g, function(match, contents) {
name = contents || new Date.getSeconds();
});
this.ANGULAR_MODULE.config(configFunction);
var exists = this.configCache[name];
console.log('CONFIG', thing);
this.configCache[name] = thing;
if (!exists) {
this.ANGULAR_MODULE.config(function($injector) {
console.log('CONFIG Reloading');
//console.log(_that.configCache[name].toString());
return $injector.invoke(_that.configCache[name], this);
});
var configLength = this.ANGULAR_MODULE._configBlocks.length;
this.ANGULAR_MODULE._configBlocks[configLength -1].AngId = name;
}
if (exists) {
this.reloadState();
}
console.log(this.ANGULAR_MODULE._configBlocks);
return this;
};

@@ -1,8 +0,8 @@

module.exports = function(name, thing) {
module.exports = function(name, controllerFunction) {
var _that = this;
var exists = this.MODULE_CACHE[name];
this.controllerCache[name] = thing;
this.controllerCache[name] = controllerFunction;
console.log('CONTROLLER', name, thing);
console.log('CONTROLLER', name, controllerFunction);

@@ -9,0 +9,0 @@ if (!exists) {

module.exports = function(name, d) {
var obj = d();
var obj = null;
if (Array.isArray(d)) {
obj = d[d.length - 1]();
} else if (typeof d === 'function') {
obj = d();
} else {
throw new Error('Malformed directive function');
}
var exists = this.MODULE_CACHE[name];

@@ -7,3 +16,2 @@ var _that = this;

var transform = function(n, obj) {
if (obj.template) {

@@ -10,0 +18,0 @@ obj.template = function() {

@@ -1,26 +0,27 @@

module.exports = function(name, thing) {
module.exports = function(name, factoryFunction) {
var _that = this;
var exists = this.MODULE_CACHE[name];
this.factoryCache[name] = thing;
this.factoryCache[name] = factoryFunction;
console.log('FACTORY', name, thing);
console.log('FACTORY', name, factoryFunction);
if (!exists) {
this.MODULE_CACHE[name] = true;
this.ANGULAR_MODULE.factory(name, function($injector) {
this.ANGULAR_MODULE.factory(name, factoryFunction);
}
console.log('Factory CACHE');
console.log(_that.factoryCache[name], this);
if (exists) {
this.factoryInject = factoryFunction();
return $injector.invoke(_that.factoryCache[name], this, {});
});
}
this.bootstrapElement.injector().invoke([name, function(factory) {
factory.loadSessions = this.factoryInject.loadSessions;
}], this);
if (exists) {
this.reloadState();
}
return this;
};
module.exports = function(moduleName, injectorArray) {
this.ANGULAR_MODULE = angular.module(moduleName, injectorArray);
this.strapped = false;
if (this.strapped) {
return this;
}
if (injectorArray) {
injectorArray.push(require('../module').name);
this.ANGULAR_MODULE = angular.module(moduleName, injectorArray);
} else {
angular.module(moduleName);
}
console.log(this.webpackModule);
this.cache[moduleName] = this.cache[moduleName] || {};

@@ -9,3 +23,8 @@ this.MODULE_CACHE = this.cache[moduleName];

var element = document.querySelector('[ng-app]');
this.bootstrapElement = angular.element(element);
this.strapped = true;
return this;
};

@@ -1,8 +0,8 @@

module.exports = function(thing) {
module.exports = function(runFunction) {
console.log('RUN', thing);
console.log('RUN', runFunction);
this.ANGULAR_MODULE.run(thing);
this.ANGULAR_MODULE.run(runFunction);
return this;
};

@@ -1,16 +0,10 @@

module.exports = function(name, thing) {
module.exports = function(name, serviceFunction) {
var _that = this;
var exists = this.MODULE_CACHE[name];
this.serviceCache[name] = thing;
this.serviceCache[name] = serviceFunction;
console.log('SERVICE', name, thing);
console.log('SERVICE', name, serviceFunction);
var intercept = function($provide) {
$provide.decorator(name, function($delegate) {
$delegate.updateService = function() {
// Lets see if we can pull in the values from the update
};
return $delegate;

@@ -22,3 +16,3 @@ });

this.MODULE_CACHE[name] = true;
this.ANGULAR_MODULE.service(name, thing);
this.ANGULAR_MODULE.service(name, this.serviceCache[name]);
this.ANGULAR_MODULE.config(intercept);

@@ -28,2 +22,8 @@ }

if (exists) {
this.serviceInject = serviceFunction;
this.bootstrapElement.injector().invoke([name, function(service) {
service = this.serviceInject;
}], this);
this.reloadState();

@@ -30,0 +30,0 @@ }

{
"name": "angular-hmr",
"version": "0.1.1",
"version": "0.2.0",
"description": "Angular Hot module replacement",

@@ -13,3 +13,16 @@ "main": "index.js",

"source-map": "^0.4.2"
}
},
"repository": {
"type": "git",
"url": "git+https://yargalot@github.com/yargalot/Angular-HMR.git"
},
"keywords": [
"Angular",
"webpack",
"HMR"
],
"bugs": {
"url": "https://github.com/yargalot/Angular-HMR/issues"
},
"homepage": "https://github.com/yargalot/Angular-HMR#readme"
}
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