Socket
Socket
Sign inDemoInstall

@angularclass/hmr

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angularclass/hmr - npm Package Compare versions

Comparing version 1.2.2 to 2.0.0

dist/experimental.d.ts

4

dist/helpers.d.ts

@@ -1,6 +0,6 @@

export declare function bootloader(main: any): void;
export declare function bootloader(main: any, before?: any, after?: any): void;
export declare function createNewHosts(cmps: any): () => void;
export declare function removeNgStyles(): void;
export declare function getInputValues(): any;
export declare function setInputValues($inputs: any): void;
export declare function setInputValues(_inputs: any): void;
export declare function createInputTransfer(): () => void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// Hot Module Replacement
function bootloader(main) {
if (document.readyState === 'complete') {
main();
function identity(val) {
return val;
}
function bootloader(main, before, after) {
before = before || identity;
after = after || identity;
var readyState = document.readyState;
function __domReadyHandler() {
document.removeEventListener('DOMContentLoaded', __domReadyHandler);
after(main(before(readyState)));
}
else {
document.addEventListener('DOMContentLoaded', main);
switch (readyState) {
case 'loading':
document.addEventListener('DOMContentLoaded', __domReadyHandler);
break;
case 'interactive':
case 'complete':
default:
after(main(before(readyState)));
}
}
exports.bootloader = bootloader;
// create new elements
// create new host elements and remove the old elements
function createNewHosts(cmps) {
var components = cmps.map(function (componentNode) {
var components = Array.prototype.map.call(cmps, function (componentNode) {
var newNode = document.createElement(componentNode.tagName);
// display none
var parentNode = componentNode.parentNode;
var currentDisplay = newNode.style.display;
newNode.style.display = 'none';
var parentNode = componentNode.parentNode;
parentNode.insertBefore(newNode, componentNode);
return { currentDisplay: currentDisplay, newNode: newNode };
function removeOldHost() {
newNode.style.display = currentDisplay;
try {
parentNode.removeChild(componentNode);
}
catch (e) { }
}
return removeOldHost;
});
return function () {
components.forEach(function (cmp) {
cmp.newNode.style.display = cmp.currentDisplay;
cmp.newNode = null;
cmp.currentDisplay = null;
});
return function removeOldHosts() {
components.forEach(function (removeOldHost) { return removeOldHost(); });
};

@@ -34,5 +50,8 @@ }

function removeNgStyles() {
Array.prototype.slice.call(document.head.querySelectorAll('style'), 0)
var docHead = document.head;
var _styles = docHead.querySelectorAll('style');
var styles = Array.prototype.slice.call(_styles);
styles
.filter(function (style) { return style.innerText.indexOf('_ng') !== -1; })
.map(function (el) { return el.remove(); });
.map(function (el) { return docHead.removeChild(el); });
}

@@ -42,11 +61,12 @@ exports.removeNgStyles = removeNgStyles;

function getInputValues() {
var inputs = document.querySelectorAll('input');
return Array.prototype.slice.call(inputs).map(function (input) { return input.value; });
var _inputs = document.querySelectorAll('input');
var inputs = Array.prototype.slice.call(_inputs);
return inputs.map(function (input) { return input.value; });
}
exports.getInputValues = getInputValues;
// set input values
function setInputValues($inputs) {
function setInputValues(_inputs) {
var inputs = document.querySelectorAll('input');
if ($inputs && inputs.length === $inputs.length) {
$inputs.forEach(function (value, i) {
if (_inputs && inputs.length === _inputs.length) {
_inputs.forEach(function (value, i) {
var el = inputs[i];

@@ -56,2 +76,4 @@ el.value = value;

});
// clear array
_inputs.length = 0;
}

@@ -62,5 +84,5 @@ }

function createInputTransfer() {
var $inputs = getInputValues();
var _inputs = getInputValues();
return function restoreInputValues() {
setInputValues($inputs);
return setInputValues(_inputs);
};

@@ -67,0 +89,0 @@ }

export * from './helpers';
export * from './experimental';
export * from './hmr';

@@ -5,4 +5,7 @@ "use strict";

}
Object.defineProperty(exports, "__esModule", { value: true });
// Hot Module Replacement
__export(require('./helpers'));
__export(require("./helpers"));
__export(require("./experimental"));
__export(require("./hmr"));
//# sourceMappingURL=index.js.map
{
"name": "@angularclass/hmr",
"version": "1.2.2",
"description": "angular2-hmr: Hot Module Replacement for Webpack and Angular 2",
"version": "2.0.0",
"description": "angular-hmr: Hot Module Replacement for Webpack and Angular by @AngularClass",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
"dist",
"src"
"dist"
],

@@ -14,23 +12,23 @@ "scripts": {

"build": "tsc || true",
"typings": "typings",
"test": "echo \"Error: no test specified\" && exit 1",
"prepublish": "npm run typings -- install && npm run build"
"prepublish": "npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/angularclass/angular2-hmr.git"
"url": "git+https://github.com/angularclass/angular-hmr.git"
},
"author": "PatrickJS <github@gdi2290.com>",
"author": "PatrickJS <patrick@angularclass.io>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/angularclass/angular2-hmr/issues"
"url": "https://github.com/angularclass/angular-hmr/issues"
},
"homepage": "https://github.com/angularclass/angular2-hmr#readme",
"homepage": "https://github.com/angularclass/angular-hmr#readme",
"devDependencies": {
"@angular/core": "2.1.2",
"rxjs": "5.0.0-rc.1",
"zone.js": "0.6.26",
"typescript": "2.0.3",
"webpack": "^1.13.0",
"typings": "^0.7.9"
"@angular/core": "~4.2.4",
"reflect-metadata": "^0.1.3",
"rxjs": "^5.0.1",
"tslib": "^1.7.1",
"typescript": "^2.3.2",
"zone.js": "^0.8.12",
"webpack": "3"
},

@@ -37,0 +35,0 @@ "dependencies": {

@@ -9,10 +9,17 @@ <p align="center">

<p align="center">
<a href="http://angularclass.com" target="_blank">
<img src="https://cloud.githubusercontent.com/assets/1016365/26220655/77e69902-3be1-11e7-8305-87471affe598.png" alt="Angular HMR" width="500" height="320"/>
</a>
</p>
# Angular 2 Hot Module Replacement
> Angular2-HMR
# Angular Hot Module Replacement
> Angular-HMR
Hot Module Reloading for Webpack 2 and Angular 4. All versions of Angular will work with this module
`npm install @angularclass/hmr @angularclass/hmr-loader`
Please see repository [AngularClass/angular2-seed](https://github.com/AngularClass/angular2-seed) for a working example.
Also download [AngularClass/angular2-hmr-loader](https://github.com/AngularClass/angular2-hmr-loader)
Please see repository [AngularClass/angular-seed](https://github.com/AngularClass/angular-seed) for a working example.
Also download [AngularClass/angular-hmr-loader](https://github.com/AngularClass/angular-hmr-loader)

@@ -106,3 +113,3 @@ ![hmr-state-dom](https://cloud.githubusercontent.com/assets/1016365/18380378/e573320e-762b-11e6-99e0-cc110ffacc6a.gif)

```
You would bootstrap your app the normal way, in production, afer dom is ready. Also, in production, you should remove the loader:
You would bootstrap your app the normal way, in production, after dom is ready. Also, in production, you should remove the loader:
```es6

@@ -109,0 +116,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