Optimize loading core
This commit is contained in:
parent
c1cbd33d41
commit
439545b4f8
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "Home Assistant",
|
"name": "home-assistant",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Paulus Schoutsen <Paulus@PaulusSchoutsen.nl>"
|
"Paulus Schoutsen <Paulus@PaulusSchoutsen.nl>"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
|
"author": "Paulus Schoutsen <Paulus@PaulusSchoutsen.nl> (http://paulusschoutsen.nl)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"home-assistant-js": "git+https://github.com/home-assistant/home-assistant-js.git#ff2bd7efd23bb731d1bcc88996154c5d573395ed",
|
"home-assistant-js": "git+https://github.com/home-assistant/home-assistant-js.git#9e1399526ae3542259a596f462cfac7c5f559ecd",
|
||||||
"moment": "^2.13.0"
|
"moment": "^2.13.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -21,7 +21,7 @@ function md5(filename) {
|
||||||
|
|
||||||
var appPaths = ['/', '/states', '/logbook', '/history', '/map',
|
var appPaths = ['/', '/states', '/logbook', '/history', '/map',
|
||||||
'/devService', '/devState', '/devEvent', '/devInfo', '/devTemplate'];
|
'/devService', '/devState', '/devEvent', '/devInfo', '/devTemplate'];
|
||||||
var fingerprinted = ['frontend', 'mdi'];
|
var fingerprinted = ['frontend.html', 'mdi.html', 'core.js'];
|
||||||
|
|
||||||
var dynamicUrlToDependencies = {};
|
var dynamicUrlToDependencies = {};
|
||||||
|
|
||||||
|
@ -30,9 +30,11 @@ appPaths.forEach(ap => {
|
||||||
});
|
});
|
||||||
|
|
||||||
fingerprinted.forEach(fn => {
|
fingerprinted.forEach(fn => {
|
||||||
var hash = md5(rootDir + '/' + fn + '.html');
|
var parts = path.parse(fn);
|
||||||
var url = '/static/' + fn + '-' + hash + '.html';
|
|
||||||
var fpath = rootDir + '/' + fn + '.html';
|
var hash = md5(rootDir + '/' + parts.name + parts.ext);
|
||||||
|
var url = '/static/' + parts.name + '-' + hash + parts.ext;
|
||||||
|
var fpath = rootDir + '/' + parts.name + parts.ext;
|
||||||
dynamicUrlToDependencies[url] = [fpath];
|
dynamicUrlToDependencies[url] = [fpath];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
import moment from 'moment';
|
|
||||||
|
|
||||||
import HomeAssistant from 'home-assistant-js';
|
import HomeAssistant from 'home-assistant-js';
|
||||||
|
|
||||||
window.moment = moment;
|
|
||||||
|
|
||||||
// While we figure out how ha-entity-marker can keep it's references
|
// While we figure out how ha-entity-marker can keep it's references
|
||||||
window.hass = new HomeAssistant();
|
const hass = new HomeAssistant();
|
||||||
|
|
||||||
window.validateAuth = function validateAuth(hass, authToken, rememberAuth) {
|
window.validateAuth = function validateAuth(authToken, rememberAuth) {
|
||||||
hass.authActions.validate(authToken, {
|
hass.authActions.validate(authToken, {
|
||||||
rememberAuth,
|
rememberAuth,
|
||||||
useStreaming: hass.localStoragePreferences.useStreaming,
|
useStreaming: hass.localStoragePreferences.useStreaming,
|
||||||
|
@ -21,3 +17,19 @@ window.removeInitMsg = function removeInitMessage() {
|
||||||
initMsg.parentElement.removeChild(initMsg);
|
initMsg.parentElement.removeChild(initMsg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hass.reactor.batch(function () {
|
||||||
|
hass.navigationActions.showSidebar(
|
||||||
|
hass.localStoragePreferences.showSidebar);
|
||||||
|
|
||||||
|
// if auth was given, tell the backend
|
||||||
|
if (window.noAuth) {
|
||||||
|
window.validateAuth('', false);
|
||||||
|
} else if (hass.localStoragePreferences.authToken) {
|
||||||
|
window.validateAuth(hass.localStoragePreferences.authToken, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(hass.startLocalStoragePreferencesSync, 5000);
|
||||||
|
|
||||||
|
window.hass = hass;
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
<link rel='import' href='../bower_components/polymer/polymer.html'>
|
<link rel='import' href='../bower_components/polymer/polymer.html'>
|
||||||
<link rel='import' href='../bower_components/paper-spinner/paper-spinner.html'>
|
<link rel='import' href='../bower_components/paper-spinner/paper-spinner.html'>
|
||||||
|
|
||||||
<script src='../build/_app_core_compiled.js'></script>
|
|
||||||
|
|
||||||
<link rel='import' href='../bower_components/iron-flex-layout/iron-flex-layout-classes.html'>
|
|
||||||
<link rel='import' href='./util/roboto.html'>
|
<link rel='import' href='./util/roboto.html'>
|
||||||
<link rel='import' href='../bower_components/paper-styles/typography.html'>
|
<link rel='import' href='../bower_components/paper-styles/typography.html'>
|
||||||
|
<link rel='import' href='../bower_components/iron-flex-layout/iron-flex-layout-classes.html'>
|
||||||
<link rel="import" href="../bower_components/iron-iconset-svg/iron-iconset-svg.html">
|
<link rel="import" href="../bower_components/iron-iconset-svg/iron-iconset-svg.html">
|
||||||
|
|
||||||
<link rel='import' href='./util/hass-behavior.html'>
|
<link rel='import' href='./util/hass-behavior.html'>
|
||||||
|
@ -104,22 +101,9 @@ Polymer({
|
||||||
},
|
},
|
||||||
|
|
||||||
ready: function () {
|
ready: function () {
|
||||||
var hass = this.hass;
|
|
||||||
hass.reactor.batch(function () {
|
|
||||||
// if auth was given, tell the backend
|
|
||||||
if (this.auth) {
|
|
||||||
window.validateAuth(this.hass, this.auth, false);
|
|
||||||
} else if (hass.localStoragePreferences.authToken) {
|
|
||||||
window.validateAuth(this.hass, hass.localStoragePreferences.authToken, true);
|
|
||||||
}
|
|
||||||
hass.navigationActions.showSidebar(hass.localStoragePreferences.showSidebar);
|
|
||||||
});
|
|
||||||
|
|
||||||
hass.startLocalStoragePreferencesSync();
|
|
||||||
|
|
||||||
this.loadIcons();
|
this.loadIcons();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src='../build/_app_compiled.js'></script>
|
<script src='../build/_ui_compiled.js'></script>
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
require('./layouts/home-assistant-main');
|
require('./layouts/home-assistant-main');
|
||||||
|
|
||||||
|
window.moment = moment;
|
||||||
|
|
|
@ -152,7 +152,7 @@ Polymer({
|
||||||
validatePassword: function () {
|
validatePassword: function () {
|
||||||
this.$.hideKeyboardOnFocus.focus();
|
this.$.hideKeyboardOnFocus.focus();
|
||||||
|
|
||||||
window.validateAuth(this.hass, this.$.passwordInput.value,
|
window.validateAuth(this.$.passwordInput.value,
|
||||||
this.$.rememberLogin.checked);
|
this.$.rememberLogin.checked);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,8 +8,8 @@ var definePlugin = new webpack.DefinePlugin({
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: {
|
entry: {
|
||||||
_app_compiled: './src/home-assistant.js',
|
_ui_compiled: './src/home-assistant.js',
|
||||||
_app_core_compiled: './src/app-core.js',
|
_core_compiled: './src/app-core.js',
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: 'build',
|
path: 'build',
|
||||||
|
|
Loading…
Reference in New Issue