diff --git a/.eslintrc-hound.json b/.eslintrc-hound.json index b6762294d0..f381b50114 100644 --- a/.eslintrc-hound.json +++ b/.eslintrc-hound.json @@ -18,10 +18,9 @@ }, "globals": { "__DEV__": false, - "__DEMO__": false, "__BUILD__": false, "__VERSION__": false, - "__PUBLIC_PATH__": false, + "__STATIC_PATH__": false, "Polymer": true, "webkitSpeechRecognition": false, "ResizeObserver": false diff --git a/hassio/.gitignore b/hassio/.gitignore deleted file mode 100644 index e996d33877..0000000000 --- a/hassio/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build-es5/* -hassio-icons.html diff --git a/hassio/config.js b/hassio/config.js index 957a3f3c6e..4b2432c081 100644 --- a/hassio/config.js +++ b/hassio/config.js @@ -2,9 +2,7 @@ const path = require('path'); module.exports = { // Target directory for the build. - buildDirLegacy: path.resolve(__dirname, 'build-es5'), buildDir: path.resolve(__dirname, 'build'), // Path where the Hass.io frontend will be publicly available. publicPath: '/api/hassio/app', - publicPathLegacy: '/api/hassio/app-es5', -} \ No newline at end of file +} diff --git a/hassio/index.html b/hassio/index.html deleted file mode 100644 index f560d39d45..0000000000 --- a/hassio/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Hass.io - - - - - - - - - - - diff --git a/hassio/script/build_hassio b/hassio/script/build_hassio index 45afee21ff..f0c76e0f64 100755 --- a/hassio/script/build_hassio +++ b/hassio/script/build_hassio @@ -7,22 +7,8 @@ set -e cd "$(dirname "$0")/.." OUTPUT_DIR=build -OUTPUT_DIR_ES5=build-es5 -rm -rf $OUTPUT_DIR $OUTPUT_DIR_ES5 +rm -rf $OUTPUT_DIR + node script/gen-icons.js - -# LEGACY BUILD -NODE_ENV=production ../node_modules/.bin/webpack -p --config webpack.legacy.config.js -node script/gen-index-html.js - -# Temporarily re-create old HTML import -echo "" >> $OUTPUT_DIR_ES5/hassio-app.html -rm $OUTPUT_DIR_ES5/app.js* -rm $OUTPUT_DIR_ES5/chunk.* - -# NEW BUILD NODE_ENV=production ../node_modules/.bin/webpack -p --config webpack.config.js diff --git a/hassio/script/gen-index-html.js b/hassio/script/gen-index-html.js deleted file mode 100755 index 047f7ad6cd..0000000000 --- a/hassio/script/gen-index-html.js +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env node -const fs = require('fs'); -const config = require('../config.js'); - -let index = fs.readFileSync('index.html', 'utf-8'); - -const toReplace = [ - [ - '', - "" - ], -]; - -for (item of toReplace) { - index = index.replace(item[0], item[1]); -} - -fs.writeFileSync(`${config.buildDirLegacy}/index.html`, index); diff --git a/hassio/webpack.config.js b/hassio/webpack.config.js index ca8b62c14c..59f8dc8f4d 100644 --- a/hassio/webpack.config.js +++ b/hassio/webpack.config.js @@ -1,51 +1,14 @@ -const fs = require('fs'); -const path = require('path'); -const webpack = require('webpack'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const CompressionPlugin = require("compression-webpack-plugin"); const config = require('./config.js'); -const version = fs.readFileSync('../setup.py', 'utf8').match(/\d{8}[^']*/); -if (!version) { - throw Error('Version not found'); -} -const VERSION = version[0]; const isProdBuild = process.env.NODE_ENV === 'production' const chunkFilename = isProdBuild ? 'chunk.[chunkhash].js' : '[name].chunk.js'; -const plugins = [ - new webpack.DefinePlugin({ - __DEV__: JSON.stringify(!isProdBuild), - __VERSION__: JSON.stringify(VERSION), - }) -]; - -if (isProdBuild) { - plugins.push(new UglifyJsPlugin({ - extractComments: true, - sourceMap: true, - uglifyOptions: { - // Disabling because it broke output - mangle: false, - } - })); - plugins.push(new CompressionPlugin({ - cache: true, - exclude: [ - /\.js\.map$/, - /\.LICENSE$/, - /\.py$/, - /\.txt$/, - ] - })); -} - module.exports = { mode: isProdBuild ? 'production' : 'development', - // Disabled in prod while we make Home Assistant able to serve the right files. - // Was source-map - devtool: isProdBuild ? 'none' : 'inline-source-map', + devtool: isProdBuild ? 'source-map' : 'inline-source-map', entry: { entrypoint: './src/entrypoint.js', }, @@ -78,10 +41,28 @@ module.exports = { ] }, - plugins, + plugins: [ + isProdBuild && new UglifyJsPlugin({ + extractComments: true, + sourceMap: true, + uglifyOptions: { + // Disabling because it broke output + mangle: false, + } + }), + isProdBuild && new CompressionPlugin({ + cache: true, + exclude: [ + /\.js\.map$/, + /\.LICENSE$/, + /\.py$/, + /\.txt$/, + ] + }), + ].filter(Boolean), output: { filename: '[name].js', - chunkFilename: chunkFilename, + chunkFilename, path: config.buildDir, publicPath: `${config.publicPath}/`, } diff --git a/hassio/webpack.legacy.config.js b/hassio/webpack.legacy.config.js deleted file mode 100644 index 092865e52a..0000000000 --- a/hassio/webpack.legacy.config.js +++ /dev/null @@ -1,78 +0,0 @@ -const fs = require('fs'); -const path = require('path'); -const webpack = require('webpack'); -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); -const config = require('./config.js'); - -const version = fs.readFileSync('../setup.py', 'utf8').match(/\d{8}[^']*/); -if (!version) { - throw Error('Version not found'); -} -const VERSION = version[0]; -const isProdBuild = process.env.NODE_ENV === 'production' -const chunkFilename = isProdBuild ? - 'chunk.[chunkhash].js' : '[name].chunk.js'; - -const plugins = [ - new webpack.DefinePlugin({ - __DEV__: JSON.stringify(!isProdBuild), - __VERSION__: JSON.stringify(VERSION), - }) -]; - -if (isProdBuild) { - plugins.push(new UglifyJsPlugin({ - extractComments: true, - sourceMap: true, - uglifyOptions: { - // Disabling because it broke output - mangle: false, - } - })); -} - -module.exports = { - mode: isProdBuild ? 'production' : 'development', - // Disabled in prod while we make Home Assistant able to serve the right files. - // Was source-map - devtool: isProdBuild ? 'none' : 'inline-source-map', - entry: { - app: './src/hassio-app.js', - }, - module: { - rules: [ - { - test: /\.js$/, - use: { - loader: 'babel-loader', - options: { - presets: [ - [require('babel-preset-env').default, { modules: false }] - ], - plugins: [ - // Only support the syntax, Webpack will handle it. - "syntax-dynamic-import", - ], - }, - }, - }, - { - test: /\.(html)$/, - use: { - loader: 'html-loader', - options: { - exportAsEs6Default: true, - } - } - } - - ] - }, - plugins, - output: { - filename: '[name].js', - chunkFilename: chunkFilename, - path: config.buildDirLegacy, - publicPath: `${config.publicPathLegacy}/`, - } -}; diff --git a/public/markdown-js.html b/public/markdown-js.html deleted file mode 100644 index ca0a2a2555..0000000000 --- a/public/markdown-js.html +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/public/webcomponents-lite.js b/public/webcomponents-lite.js deleted file mode 100644 index f5d2d000a7..0000000000 --- a/public/webcomponents-lite.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -@license @nocompile -Copyright (c) 2018 The Polymer Project Authors. All rights reserved. -This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt -The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt -The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt -Code distributed by Google as part of the polymer project is also -subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt -*/ -(function(){/* - - Copyright (c) 2016 The Polymer Project Authors. All rights reserved. - This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt - The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt - The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt - Code distributed by Google as part of the polymer project is also - subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt -*/ -'use strict';var p,q="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};function da(){da=function(){};q.Symbol||(q.Symbol=ea)}var ea=function(){var a=0;return function(b){return"jscomp_symbol_"+(b||"")+a++}}(); -function fa(){da();var a=q.Symbol.iterator;a||(a=q.Symbol.iterator=q.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&aa(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return ha(this)}});fa=function(){}}function ha(a){var b=0;return ia(function(){return b"+this.innerHTML+""},set:function(a){if(this.parentNode){P.body.innerHTML=a;for(a=this.ownerDocument.createDocumentFragment();P.body.firstChild;)l.call(a,P.body.firstChild);m.call(this.parentNode,a,this)}else throw Error("Failed to set the 'outerHTML' property on 'Element': This element has no parent node."); -},configurable:!0})};va(a.prototype);ja(a.prototype);a.M=function(c){c=b(c,"template");for(var d=0,e=c.length,f;d]/g,ka=function(a){switch(a){case "&":return"&";case "<":return"<";case ">":return">";case '"':return""";case "\u00a0":return" "}}; -ba=function(a){for(var b={},c=0;c";break a;case Node.TEXT_NODE:g=g.data;g=k&&xa[k.localName]?g:g.replace(ca,ka);break a;case Node.COMMENT_NODE:g="\x3c!--"+g.data+"--\x3e";break a;default:throw window.console.error(g),Error("not implemented");}}c+=g}return c}}if(c||Z){a.ga=function(a,b){var c=f.call(a,!1);this.H&&this.H(c);b&&(l.call(c.content,f.call(a.content,!0)),ya(c.content,a.content));return c};var ya=function(c,d){if(d.querySelectorAll&& -(d=b(d,"template"),0!==d.length)){c=b(c,"template");for(var e=0,f=c.length,h,g;e]*)(rel=['|"]?stylesheet['|"]?[^>]*>)/g,C={Oa:function(a,b){a.href&&a.setAttribute("href",C.aa(a.getAttribute("href"),b));a.src&&a.setAttribute("src",C.aa(a.getAttribute("src"),b));if("style"===a.localName){var c=C.xa(a.textContent,b,Ka);a.textContent=C.xa(c,b,ba)}},xa:function(a,b,c){return a.replace(c, -function(a,c,d,e){a=d.replace(/["']/g,"");b&&(a=C.aa(a,b));return c+"'"+a+"'"+e})},aa:function(a,b){if(void 0===C.fa){C.fa=!1;try{var c=new URL("b","http://a");c.pathname="c%20d";C.fa="http://a/c%20d"===c.href}catch(nb){}}if(C.fa)return(new URL(a,b)).href;c=C.Ea;c||(c=document.implementation.createHTMLDocument("temp"),C.Ea=c,c.oa=c.createElement("base"),c.head.appendChild(c.oa),c.na=c.createElement("a"));c.oa.href=b;c.na.href=a;return c.na.href||a}},va={async:!0,load:function(a,b,c){if(a)if(a.match(/^data:/)){a= -a.split(",");var d=a[1];d=-1e.status?b(d,a):c(d)};e.send()}else c("error: href must be specified")}},ja=/Trident/.test(navigator.userAgent)||/Edge\/\d./i.test(navigator.userAgent); -k.prototype.loadImports=function(a){var b=this;a=m(a,"link[rel=import]");n(a,function(a){return b.s(a)})};k.prototype.s=function(a){var b=this,c=a.href;if(void 0!==this.a[c]){var d=this.a[c];d&&d.__loaded&&(a.__import=d,this.i(a))}else this.b++,this.a[c]="pending",va.load(c,function(a,d){a=b.Va(a,d||c);b.a[c]=a;b.b--;b.loadImports(a);b.N()},function(){b.a[c]=null;b.b--;b.N()})};k.prototype.Va=function(a,b){if(!a)return document.createDocumentFragment();ja&&(a=a.replace(La,function(a,b,c){return-1=== -a.indexOf("type=")?b+" type=import-disable "+c:a}));var c=document.createElement("template");c.innerHTML=a;if(c.content)a=c.content,l(a);else for(a=document.createDocumentFragment();c.firstChild;)a.appendChild(c.firstChild);if(c=a.querySelector("base"))b=C.aa(c.getAttribute("href"),b),c.removeAttribute("href");c=m(a,'link[rel=import],link[rel=stylesheet][href][type=import-disable],style:not([type]),link[rel=stylesheet][href]:not([type]),script:not([type]),script[type="application/javascript"],script[type="text/javascript"]'); -var d=0;n(c,function(a){h(a);C.Oa(a,b);a.setAttribute("import-dependency","");"script"===a.localName&&!a.src&&a.textContent&&(a.setAttribute("src","data:text/javascript;charset=utf-8,"+encodeURIComponent(a.textContent+("\n//# sourceURL="+b+(d?"-"+d:"")+".js\n"))),a.textContent="",d++)});return a};k.prototype.N=function(){var a=this;if(!this.b){this.c.disconnect();this.flatten(document);var b=!1,c=!1,d=function(){c&&b&&(a.loadImports(document),a.b||(a.c.observe(document.head,{childList:!0,subtree:!0}), -a.Sa()))};this.Xa(function(){c=!0;d()});this.Wa(function(){b=!0;d()})}};k.prototype.flatten=function(a){var b=this;a=m(a,"link[rel=import]");n(a,function(a){var c=b.a[a.href];(a.__import=c)&&c.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&(b.a[a.href]=a,a.readyState="loading",a.__import=a,b.flatten(c),a.appendChild(c))})};k.prototype.Wa=function(a){function b(e){if(e]/g;function rc(a){switch(a){case "&":return"&";case "<":return"<";case ">":return">";case '"':return""";case "\u00a0":return" "}}function sc(a){for(var b={},c=0;c";break a;case Node.TEXT_NODE:g=g.data;g=k&&uc[k.localName]?g:g.replace(qc,rc);break a;case Node.COMMENT_NODE:g="\x3c!--"+g.data+"--\x3e";break a;default:throw window.console.error(g), -Error("not implemented");}}c+=g}return c};var E={},F=document.createTreeWalker(document,NodeFilter.SHOW_ALL,null,!1),G=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT,null,!1);function wc(a){var b=[];F.currentNode=a;for(a=F.firstChild();a;)b.push(a),a=F.nextSibling();return b}E.parentNode=function(a){F.currentNode=a;return F.parentNode()};E.firstChild=function(a){F.currentNode=a;return F.firstChild()};E.lastChild=function(a){F.currentNode=a;return F.lastChild()};E.previousSibling=function(a){F.currentNode=a;return F.previousSibling()}; -E.nextSibling=function(a){F.currentNode=a;return F.nextSibling()};E.childNodes=wc;E.parentElement=function(a){G.currentNode=a;return G.parentNode()};E.firstElementChild=function(a){G.currentNode=a;return G.firstChild()};E.lastElementChild=function(a){G.currentNode=a;return G.lastChild()};E.previousElementSibling=function(a){G.currentNode=a;return G.previousSibling()};E.nextElementSibling=function(a){G.currentNode=a;return G.nextSibling()}; -E.children=function(a){var b=[];G.currentNode=a;for(a=G.firstChild();a;)b.push(a),a=G.nextSibling();return b};E.innerHTML=function(a){return vc(a,function(a){return wc(a)})};E.textContent=function(a){switch(a.nodeType){case Node.ELEMENT_NODE:case Node.DOCUMENT_FRAGMENT_NODE:a=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null,!1);for(var b="",c;c=a.nextNode();)b+=c.nodeValue;return b;default:return a.nodeValue}};var H={},xc=z.w,yc=[Node.prototype,Element.prototype,HTMLElement.prototype];function I(a){var b;a:{for(b=0;bd.assignedNodes.length&&(d.Y=!0)}d.Y&&(d.Y=!1,Od(this,b))}a=this.g;b=[];for(d=0;db.indexOf(c))||b.push(c);for(a=0;a "+b}))}a=a.replace(jg,function(a,b,c){return'[dir="'+c+'"] '+b+", "+b+'[dir="'+c+'"]'});return{value:a,Na:b,stop:f}}function hg(a,b){a=a.split(kg);a[0]+=b;return a.join(kg)} -function gg(a,b){var c=a.match(lg);return(c=c&&c[2].trim()||"")?c[0].match(mg)?a.replace(lg,function(a,c,f){return b+f}):c.split(mg)[0]===b?c:ng:a.replace(cg,b)}function og(a){a.selector===pg&&(a.selector="html")}Pf.prototype.c=function(a){return a.match(fg)?this.b(a,qg):hg(a.trim(),qg)};q.Object.defineProperties(Pf.prototype,{a:{configurable:!0,enumerable:!0,get:function(){return"style-scope"}}}); -var ag=/:(nth[-\w]+)\(([^)]+)\)/,qg=":not(.style-scope)",Zf=",",dg=/(^|[\s>+~]+)((?:\[.+?\]|[^\s>+~=[])+)/g,mg=/[[.:#*]/,cg=":host",pg=":root",fg="::slotted",bg=new RegExp("^("+fg+")"),lg=/(:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/,ig=/(?:::slotted)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/,jg=/(.*):dir\((?:(ltr|rtl))\)/,Xf=".",kg=":",Tf="class",ng="should_not_match",V=new Pf;function rg(a,b,c,d){this.B=a||null;this.b=b||null;this.ma=c||[];this.K=null;this.R=d||"";this.a=this.u=this.F=null}function W(a){return a?a.__styleInfo:null}function sg(a,b){return a.__styleInfo=b}rg.prototype.c=function(){return this.B};rg.prototype._getStyleRules=rg.prototype.c;function tg(a){var b=this.matches||this.matchesSelector||this.mozMatchesSelector||this.msMatchesSelector||this.oMatchesSelector||this.webkitMatchesSelector;return b&&b.call(this,a)}var ug=navigator.userAgent.match("Trident");function vg(){}function wg(a){var b={},c=[],d=0;Gf(a,function(a){xg(a);a.index=d++;a=a.l.cssText;for(var c;c=Af.exec(a);){var e=c[1];":"!==c[2]&&(b[e]=!0)}},function(a){c.push(a)});a.b=c;a=[];for(var e in b)a.push(e);return a} -function xg(a){if(!a.l){var b={},c={};yg(a,c)&&(b.A=c,a.rules=null);b.cssText=a.parsedCssText.replace(Df,"").replace(yf,"");a.l=b}}function yg(a,b){var c=a.l;if(c){if(c.A)return Object.assign(b,c.A),!0}else{c=a.parsedCssText;for(var d;a=yf.exec(c);){d=(a[2]||a[3]).trim();if("inherit"!==d||"unset"!==d)b[a[1].trim()]=d;d=!0}return d}} -function zg(a,b,c){b&&(b=0<=b.indexOf(";")?Ag(a,b,c):Mf(b,function(b,e,f,h){if(!e)return b+h;(e=zg(a,c[e],c))&&"initial"!==e?"apply-shim-inherit"===e&&(e="inherit"):e=zg(a,c[f]||f,c)||f;return b+(e||"")+h}));return b&&b.trim()||""} -function Ag(a,b,c){b=b.split(";");for(var d=0,e,f;d *"===f||"html"===f,g=0===f.indexOf(":host")&&!h;"shady"===c&&(h=f===e+" > *."+e||-1!==f.indexOf("html"),g=!h&&0===f.indexOf(e));"shadow"===c&&(h=":host > *"===f||"html"===f,g=g&&!h);if(h||g)c=e,g&&(b.o||(b.o=Yf(V,b,V.b,a?Xf+a:"",e)),c=b.o||e),d({Za:c,Ta:g,rb:h})}} -function Dg(a,b){var c={},d={},e=b&&b.__cssBuild;Gf(b,function(b){Cg(a,b,e,function(e){tg.call(a.b||a,e.Za)&&(e.Ta?yg(b,c):yg(b,d))})},null,!0);return{Ya:d,Ra:c}} -function Eg(a,b,c,d){var e=Of(b),f=Wf(e.is,e.R),h=new RegExp("(?:^|[^.#[:])"+(b.extends?"\\"+f.slice(0,-1)+"\\]":f)+"($|[.:[\\s>+~])");e=W(b).B;var g=Fg(e,d);return Uf(b,e,function(b){var e="";b.l||xg(b);b.l.cssText&&(e=Ag(a,b.l.cssText,c));b.cssText=e;if(!T&&!If(b)&&b.cssText){var k=e=b.cssText;null==b.ta&&(b.ta=Bf.test(e));if(b.ta)if(null==b.Z){b.Z=[];for(var n in g)k=g[n],k=k(e),e!==k&&(e=k,b.Z.push(n))}else{for(n=0;n=l._useCount&&l.parentNode&&l.parentNode.removeChild(l));T?f.a?(f.a.textContent=e,d=f.a):e&&(d=Jf(e,g,a.shadowRoot,f.b)):d?d.parentNode|| -(ug&&-1> $OUTPUT_DIR/__init__.py echo "CREATED_AT = `date +%s`" >> $OUTPUT_DIR/__init__.py diff --git a/script/update_mdi.py b/script/update_mdi.py deleted file mode 100755 index ae9225773a..0000000000 --- a/script/update_mdi.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python3 -"""Download the latest Polymer v1 iconset for materialdesignicons.com.""" -import os -import re -import sys -import urllib.request - -GETTING_STARTED_URL = ('https://raw.githubusercontent.com/Templarian/' - 'MaterialDesign/master/site/getting-started.savvy') -DOWNLOAD_LINK = re.compile(r'(/api/download/polymer/v1/([A-Z0-9-]{36}))') -START_ICONSET = ' { if (!es5Loaded) { es5Loaded = Promise.all([ - loadJS(`${__PUBLIC_PATH__}custom-elements-es5-adapter.js`).catch(), + loadJS(`${__STATIC_PATH__}custom-elements-es5-adapter.js`).catch(), import(/* webpackChunkName: "compat" */ './compatibility.js'), ]); } diff --git a/webpack.config.js b/webpack.config.js index daeb7f0e33..475b3e0a02 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -96,12 +96,11 @@ function createConfig(isProdBuild, latestBuild) { __DEV__: JSON.stringify(!isProdBuild), __BUILD__: JSON.stringify(latestBuild ? 'latest' : 'es5'), __VERSION__: JSON.stringify(VERSION), - __PUBLIC_PATH__: JSON.stringify(publicPath), + __STATIC_PATH__: '/static/', 'process.env.NODE_ENV': JSON.stringify(isProdBuild ? 'production' : 'development'), }), new CopyWebpackPlugin([ - // Leave here until Hass.io no longer references the ES5 build. - 'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js', + latestBuild && 'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js', latestBuild && { from: 'public', to: '.' }, latestBuild && { from: 'build-translations/output', to: `translations` }, latestBuild && { from: 'node_modules/@polymer/font-roboto-local/fonts', to: 'fonts' },