Network WIP

This commit is contained in:
Sebastien L
2022-01-20 13:43:23 -05:00
parent 052600a45a
commit 15c0e47ae3
72 changed files with 1676 additions and 2212 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 634 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +0,0 @@
!function(e){function r(r){for(var n,l,f=r[0],i=r[1],a=r[2],c=0,s=[];c<f.length;c++)l=f[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,f=1;f<t.length;f++){var i=t[f];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={2:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="";var f=window.webpackJsonp=window.webpackJsonp||[],i=f.push.bind(f);f.push=r,f=f.slice();for(var a=0;a<f.length;a++)r(f[a]);var p=i;t()}([]);

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg"><defs><symbol viewBox="0 0 24 24" id="battery-line"><path fill="none" d="M0 0h24v24H0z"/><path d="M4 7v10h14V7H4zM3 5h16a1 1 0 011 1v12a1 1 0 01-1 1H3a1 1 0 01-1-1V6a1 1 0 011-1zm18 4h2v6h-2V9z"/></symbol><symbol viewBox="0 0 24 24" id="lock-unlock-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M7 10h13a1 1 0 011 1v10a1 1 0 01-1 1H4a1 1 0 01-1-1V11a1 1 0 011-1h1V9a7 7 0 0113.262-3.131l-1.789.894A5 5 0 007 9v1zm3 5v2h4v-2h-4z"/></symbol><symbol viewBox="0 0 24 24" id="battery-low-line"><path fill="none" d="M0 0h24v24H0z"/><path d="M4 7v10h14V7H4zM3 5h16a1 1 0 011 1v12a1 1 0 01-1 1H3a1 1 0 01-1-1V6a1 1 0 011-1zm2 3h4v8H5V8zm16 1h2v6h-2V9z"/></symbol><symbol viewBox="0 0 24 24" id="bluetooth-connect-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M14.341 12.03l4.343 4.343-5.656 5.656h-2v-6.686l-4.364 4.364-1.415-1.414 5.779-5.778v-.97l-5.779-5.78 1.415-1.414 4.364 4.364V2.029h2l5.656 5.657-4.343 4.343zm-1.313 1.514v5.657l2.828-2.828-2.828-2.829zm0-3.03l2.828-2.828-2.828-2.828v5.657zM19.5 13.5a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm-13 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3z"/></symbol><symbol viewBox="0 0 24 24" id="bluetooth-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M14.341 12.03l4.343 4.343-5.656 5.656h-2v-6.686l-4.364 4.364-1.415-1.414 5.779-5.778v-.97l-5.779-5.78 1.415-1.414 4.364 4.364V2.029h2l5.656 5.657-4.343 4.343zm-1.313 1.514v5.657l2.828-2.828-2.828-2.829zm0-3.03l2.828-2.828-2.828-2.828v5.657z"/></symbol><symbol viewBox="0 0 24 24" id="device-recover-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M19 2a1 1 0 011 1v18a1 1 0 01-1 1H5a1 1 0 01-1-1V3a1 1 0 011-1h14zm-7 5a5 5 0 10.955 9.909L12 15a3 3 0 010-6c1.598 0 3 1.34 3 3h-2.5l2.128 4.254A5 5 0 0012 7z"/></symbol><symbol viewBox="0 0 24 24" id="headphone-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M4 12h3a2 2 0 012 2v5a2 2 0 01-2 2H4a2 2 0 01-2-2v-7C2 6.477 6.477 2 12 2s10 4.477 10 10v7a2 2 0 01-2 2h-3a2 2 0 01-2-2v-5a2 2 0 012-2h3a8 8 0 10-16 0z"/></symbol><symbol viewBox="0 0 24 24" id="lock-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M19 10h1a1 1 0 011 1v10a1 1 0 01-1 1H4a1 1 0 01-1-1V11a1 1 0 011-1h1V9a7 7 0 1114 0v1zm-2 0V9A5 5 0 007 9v1h10zm-6 4v4h2v-4h-2z"/></symbol><symbol viewBox="0 0 24 24" id="battery-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 5h16a1 1 0 011 1v12a1 1 0 01-1 1H3a1 1 0 01-1-1V6a1 1 0 011-1zm18 4h2v6h-2V9z"/></symbol><symbol viewBox="0 0 24 24" id="pause-circle-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zM9 9v6h2V9H9zm4 0v6h2V9h-2z"/></symbol><symbol viewBox="0 0 24 24" id="play-circle-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zM10.622 8.415a.4.4 0 00-.622.332v6.506a.4.4 0 00.622.332l4.879-3.252a.4.4 0 000-.666l-4.88-3.252z"/></symbol><symbol viewBox="0 0 24 24" id="signal-wifi-1-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 3c4.284 0 8.22 1.497 11.31 3.996L12 21 .69 6.997A17.917 17.917 0 0112 3zm0 2c-3.028 0-5.923.842-8.42 2.392l5.108 6.324A7.965 7.965 0 0112 13c1.181 0 2.303.256 3.312.716L20.42 7.39A15.928 15.928 0 0012 5z"/></symbol><symbol viewBox="0 0 24 24" id="signal-wifi-2-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 3c4.284 0 8.22 1.497 11.31 3.996L12 21 .69 6.997A17.917 17.917 0 0112 3zm0 2c-3.028 0-5.923.842-8.42 2.392l3.178 3.935A10.953 10.953 0 0112 10c1.898 0 3.683.48 5.241 1.327L20.42 7.39A15.928 15.928 0 0012 5z"/></symbol><symbol viewBox="0 0 24 24" id="signal-wifi-3-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 3c4.284 0 8.22 1.497 11.31 3.996L12 21 .69 6.997A17.917 17.917 0 0112 3zm0 2c-3.028 0-5.923.842-8.42 2.392l1.904 2.357C7.4 8.637 9.625 8 12 8s4.6.637 6.516 1.749L20.42 7.39A15.928 15.928 0 0012 5z"/></symbol><symbol viewBox="0 0 24 24" id="signal-wifi-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 3c4.284 0 8.22 1.497 11.31 3.996L12 21 .69 6.997A17.917 17.917 0 0112 3z"/></symbol><symbol viewBox="0 0 24 24" id="signal-wifi-line"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 3c4.284 0 8.22 1.497 11.31 3.996L12 21 .69 6.997A17.917 17.917 0 0112 3zm0 2c-3.028 0-5.923.842-8.42 2.392L12 17.817 20.42 7.39A15.928 15.928 0 0012 5z"/></symbol><symbol viewBox="0 0 24 24" id="stop-circle-fill"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zM9 9v6h6V9H9z"/></symbol></defs></svg>

Before

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -1,251 +0,0 @@
/* eslint-disable */
// Common Config is used in Development and Production Mode.
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const StylelintPlugin = require('stylelint-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
// Linting
const TSLintPlugin = require('tslint-webpack-plugin');
const ImageminPlugin = require('imagemin-webpack-plugin').default;
const imageminMozjpeg = require('imagemin-mozjpeg');
module.exports = {
entry: {
index: './src/index.ts'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: './js/[name].[hash:6].bundle.js'
},
module: {
rules: [
// Raw Loader
{
test: /\.txt$/,
use: 'raw-loader'
},
// HTML Loader
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
options: {minimize: true}
}
]
},
// CSS/SCSS Loader & Minimizer
{
test: /\.(sa|sc|c)ss$/,
use: [
"style-loader",
"css-loader",
{
loader: 'postcss-loader',
options: {
postcssOptions: {
parser: "sugarss",
},
},
},
{
loader: 'resolve-url-loader',
options: {}
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
sourceMapContents: false
}
}
],
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-sprite-loader',
options: {
extract: true,
} },
'svg-transform-loader',
{
loader: 'svgo-loader',
options: {
plugins: [
{removeTitle: true},
{convertColors: {shorthex: false}},
{convertPathData: false},
{convertPathData:true}
]
}
}
]
},
// Image Loader
{
test: /\.(png|jpeg|jpg|webp|gif|ico)/i,
use: [
{
loader: 'url-loader',
options: {
// publicPath: '../',
//name: './assets/images/' + '[name].[ext]',
limit: 10000,
//limit:false,
//publicPath: '../'
}
},
]
},
// Babel Loader
{
test: /\.ts(x?)$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-class-properties'
]
}
},
},
// XML Loader
{
test: /\.xml$/,
use: [
'xml-loader'
]
},
{
test: require.resolve("bootstrap"),
loader: "expose-loader",
options: {
exposes: ["bootstrap"],
},
},
{
test: require.resolve("jquery"),
loader: "expose-loader",
options: {
exposes: ["$", "jQuery"],
},
},
{
test: require.resolve("underscore"),
loader: "expose-loader",
options: {
exposes: [
"_.map|map",
{
globalName: "_.reduce",
moduleLocalName: "reduce",
},
{
globalName: ["_", "filter"],
moduleLocalName: "filter",
},
],
},
},
]
},
resolve: {
extensions: ['.js', '.jsx', '.tsx', '.ts', '.json'],
alias: {
riSvg: 'remixicon/icons/'
}
},
plugins: [
new CleanWebpackPlugin(),
new ImageminPlugin({
test: /\.(jpe?g|png|gif|svg)$/i,
// lossLess gif compressor
gifsicle: {
optimizationLevel: 9
},
// lossy png compressor, remove for default lossLess
pngquant: ({
quality: '75'
}),
// lossy jpg compressor
plugins: [imageminMozjpeg({
quality: '75'
})],
destination: './webpack',
}),
new ESLintPlugin({
cache: true,
ignore: true,
useEslintrc: true,
}),
new HtmlWebPackPlugin({
title: 'SqueezeESP32',
template: './src/index.ejs',
filename: 'index.html',
inject: 'body',
minify: {
html5 : true,
collapseWhitespace : true,
minifyCSS : true,
minifyJS : true,
minifyURLs : false,
removeAttributeQuotes : true,
removeComments : true, // false for Vue SSR to find app placeholder
removeEmptyAttributes : true,
removeOptionalTags : true,
removeRedundantAttributes : true,
removeScriptTypeAttributes : true,
removeStyleLinkTypeAttributese : true,
useShortDoctype : true
},
favicon: "./src/assets/images/favicon-32x32.png",
excludeChunks: ['test'],
}),
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'defer'
}),
// // Load Lodash Features Separately https://www.npmjs.com/package/lodash-webpack-plugin
new LodashModuleReplacementPlugin({
'collections': true,
'paths': true,
}),
new TSLintPlugin({
files: ['./src/ts/*.ts']
}),
new StylelintPlugin( {
files: ['./src/sass/*.s?(a|c)ss'],
configFile: './config/.stylelintrc',
emitError: true,
emitWarning: true,
failOnError: false,
fix: true
}),
new SpriteLoaderPlugin({plainSprite: true})
],
};

View File

@@ -1,12 +1,8 @@
/* eslint-disable */
var path = require('path');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const bodyParser = require('body-parser')
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { config } = require('process');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
const { Command } = require('commander');
let cmdLines= { };
var { parseArgsStringToArgv } = require('string-argv');
@@ -90,6 +86,7 @@ for(const cmdIdx in data.commands.commands){
(arg.longopts?'--'+arg.longopts:'') +
(arg.hasvalue?`${(arg.shortopts || arg.longopts?' ':'')}<${arg.datatype.replace(/[<>]/gm,'')}>`:''));
//console.log(` Option: ${optstr}, Glossary: ${arg.glossary}`);
if(arg.remark) continue;
if(arg.mincount>0){
cmdLines[cmd.name].cmd.requiredOption( optstr,arg.glossary);
}
@@ -105,15 +102,16 @@ const connectReturnCode = {
UPDATE_LOST_CONNECTION : 3,
UPDATE_FAILED_ATTEMPT_AND_RESTORE : 4
}
module.exports = merge(common, {
mode: 'development',
devtool: 'inline-source-map',
module.exports ={
entry: {
test: './src/test.ts'
},
test: './src/test.ts',
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
contentBase: path.resolve(__dirname, './dist'),
publicPath: '/',
open: true,
compress: true,
port: 9100,
host: '127.0.0.1',//your ip address
disableHostCheck: true,
@@ -230,25 +228,25 @@ module.exports = merge(common, {
app.post('/config.json', function(req, res) {
var fwurl='';
console.log(`Processing config.json with request body: ${req.body}`);
console.log(data.config);
console.log(data.config.config);
for (const property in req.body.config) {
console.log(`${property}: ${req.body.config[property].value}`);
if(property=='fwurl'){
fwurl=req.body.config[property].value;
}
else {
if(data.config[property]=== undefined){
if(data.config.config[property]=== undefined){
console.log(`Added config value ${property} [${req.body.config[property].value}]`);
data.config[property] = {value: req.body.config[property].value};
data.config.config[property] = {value: req.body.config[property].value};
}
else if (data.config[property].value!=req.body.config[property].value){
console.log(`Updated config value ${property}\nFrom: ${data.config[property].value}\nTo: ${req.body.config[property].value}]`);
data.config[property].value=req.body.config[property].value;
else if (data.config.config[property].value!=req.body.config[property].value){
console.log(`Updated config value ${property}\n From: ${data.config.config[property].value}\n To: ${req.body.config[property].value}]`);
data.config.config[property].value=req.body.config[property].value;
}
}
}
res.json( {} );
res.json( {"result" : "OK" });
if(fwurl!=='' ){
const ota_msg_list= ((data.status.mock_fail_fw_update ?? '')!=='')?data.messages_ota_fail:data.messages_ota;
if(data.status.recovery!=1) {
@@ -288,7 +286,7 @@ module.exports = merge(common, {
data.status[property]=req.body.status[property];
}
}
res.json( {} );
res.json( {"result" : "OK" } );
});
app.post('/connect.json', function(req, res) {
setTimeout(function(r){
@@ -306,15 +304,15 @@ module.exports = merge(common, {
data.status.urc=connectReturnCode.UPDATE_CONNECTION_OK;
}
}, 1000, req);
res.json( {} );
res.json( {"result" : "OK" } );
});
app.post('/reboot_ota.json', function(req, res) {
data.status.recovery=0;
requeueMessages();
res.json( {} );
res.json( {"result" : "OK" } );
});
app.post('/reboot.json', function(req, res) {
res.json( {} );
res.json( {"result" : "OK" } );
requeueMessages();
});
app.post('/recovery.json', function(req, res) {
@@ -324,7 +322,7 @@ module.exports = merge(common, {
else {
data.status.recovery=1;
requeueMessages();
res.json( { } );
res.json( {"result" : "OK" } );
}
});
app.post('/flash.json', function(req, res) {
@@ -342,7 +340,7 @@ module.exports = merge(common, {
requeueMessages();
}
res.json({});
res.json({"result" : "OK" });
}
}
@@ -352,22 +350,20 @@ module.exports = merge(common, {
});
app.delete('/connect.json', function(req, res) {
data.status.ssid='';
res.json( {} ); });
app.get('/reboot', function(req, res) { res.json( {} ); });
res.json({"result" : "OK" }); });
app.get('/reboot', function(req, res) { res.json({"result" : "OK" }); });
},
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/[id].css' ,
}),
new HtmlWebPackPlugin({
title: 'SqueezeESP32-test',
template: './src/test.ejs',
filename: 'test',
minify: false,
excludeChunks: ['index'],
inject: 'body',
excludeChunks: ['index','main'],
})
],
});
}

View File

@@ -1,188 +0,0 @@
/* eslint-disable */
// Merges webpack.common config with this production config
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
// Optimisations and Compression
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const fs = require('fs');
const glob = require('glob');
var WebpackOnBuildPlugin = require('on-build-webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const PurgecssPlugin = require('purgecss-webpack-plugin')
// Optional
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const PATHS = {
src: path.join(__dirname, 'src')
}
module.exports = merge(common, {
mode: 'production',
stats: 'errors-only',
optimization: {
minimizer: [
new TerserPlugin({
test: /\.js(\?.*)?$/i,
exclude: /node_modules/,
cache: true,
parallel: 4,
sourceMap: true,
}),
new OptimizeCSSAssetsPlugin({})
],
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
// maxInitialRequests: Infinity,
// minSize: 0,
cacheGroups: {
vendor: {
test: /node_modules/, // you may add "vendor.js" here if you want to
name: "node-modules",
chunks: "initial",
enforce: true
},
}
},
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].[hash:6].css',
chunkFilename: 'css/[name].[contenthash].css',
}),
new ExtractTextPlugin('[name].css?[hash]'),
new PurgecssPlugin({
paths: glob.sync(`${PATHS.src}/*`),
whitelist: ['whitelisted']
}),
new CleanWebpackPlugin(),
new CompressionPlugin({
test: /\.(js|css|html|svg)$/,
filename: '[path].br[query]',
algorithm: 'brotliCompress',
compressionOptions: { level: 11 },
threshold: 100,
minRatio: 0.8,
deleteOriginalAssets: false
}),
new CompressionPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
threshold: 100,
minRatio: 0.8,
}),
// new FaviconsWebpackPlugin({
// // Your source logo
// logo: './src/assets/images/200px-ControllerAppIcon.png',
// // // The prefix for all image files (might be a folder or a name)
// //prefix: 'assets/icons_[hash:6]/',
// prefix: 'icons_[hash:6]/',
// // // Emit all stats of the generated icons
// //emitStats: false,
// // // The name of the json containing all favicon information
// // statsFilename: 'iconstats-[hash].json',
// // // Generate a cache file with control hashes and
// // // don't rebuild the favicons until those hashes change
// persistentCache: true,
// // // Inject the html into the html-webpack-plugin
// inject: true,
// // // favicon background color (see https://github.com/haydenbleasel/favicons#usage)
// background: '#fff',
// // // which icons should be generated (see https://github.com/haydenbleasel/favicons#usage)
// icons: {
// // android: false,
// // appleIcon: false,
// favicons: true
// // firefox: true,
// // windows: false
// }
// }),
new WebpackOnBuildPlugin(function(stats) {
var getDirectories = function (src, callback) {
glob(`${src}/**/*(*.gz|favicon-32x32.png)`, callback);
};
console.log('Cleaning up previous builds');
glob(`../../../build/*.S`, function (err, list) {
if (err) {
console.error('Error', err);
} else {
list.forEach(fileName=>{
try {
console.log(`Purging old binary file ${fileName} from C project.`);
fs.unlinkSync(fileName)
//file removed
} catch(ferr) {
console.error(ferr)
}
});
}
}
);
console.log('Generating C include files from webpack build output');
getDirectories('./webpack/dist', function (err, list) {
if (err) {
console.log('Error', err);
} else {
const regex = /^(.*\/)([^\/]*)$/
const relativeRegex = /((\w+(?<!dist)\/){0,1}[^\/]*)$/
const makePathRegex = /([^\.].*)$/
let exportDefHead=
'/***********************************\n'+
'webpack_headers\n'+
stats+'\n'+
'***********************************/\n'+
'#pragma once\n'+
'#include <inttypes.h>\n'+
'extern const char * resource_lookups[];\n'+
'extern const uint8_t * resource_map_start[];\n'+
'extern const uint8_t * resource_map_end[];\n';
let exportDef= '// Automatically generated. Do not edit manually!.\n'+
'#include <inttypes.h>\n';
let lookupDef='const char * resource_lookups[] = {\n';
let lookupMapStart='const uint8_t * resource_map_start[] = {\n';
let lookupMapEnd='const uint8_t * resource_map_end[] = {\n';
let cMake='';
list.forEach(fileName=>{
let exportName=fileName.match(regex)[2].replace(/[\. \-]/gm,'_');
let relativeName=fileName.match(relativeRegex)[1];
exportDef+= 'extern const uint8_t _'+exportName+'_start[] asm("_binary_'+exportName+'_start");\n'+
'extern const uint8_t _'+exportName+'_end[] asm("_binary_'+exportName+'_end");\n';
lookupDef+='\t"/'+relativeName+'",\n';
lookupMapStart+='\t_'+ exportName+'_start,\n';
lookupMapEnd+= '\t_'+ exportName+'_end,\n';
cMake+='target_add_binary_data( __idf_wifi-manager ./webapp'+fileName.match(makePathRegex)[1]+' BINARY)\n';
});
lookupDef+='""\n};\n';
lookupMapStart=lookupMapStart.substring(0,lookupMapStart.length-2)+'\n};\n';
lookupMapEnd=lookupMapEnd.substring(0,lookupMapEnd.length-2)+'\n};\n';
try {
fs.writeFileSync('webapp.cmake', cMake);
fs.writeFileSync('webpack.c', exportDef+lookupDef+lookupMapStart+lookupMapEnd);
fs.writeFileSync('webpack.h', exportDefHead);
//file written successfully
} catch (e) {
console.error(e);
}
}
});
console.log('Post build completed.');
})
//, new BundleAnalyzerPlugin()
]
});