update dev server

pull/70/head
Vladimir Mandic 2021-02-13 08:42:10 -05:00
parent 6b1734088d
commit 96a2b0a1b0
8 changed files with 33960 additions and 25 deletions

File diff suppressed because one or more lines are too long

View File

@ -417,7 +417,7 @@
"imports": []
},
"package.json": {
"bytes": 2403,
"bytes": 2459,
"imports": []
},
"src/human.ts": {

4216
dist/tfjs.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

29733
dist/tfjs.esm.json vendored

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,7 @@
"scripts": {
"start": "node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation src/node.js",
"lint": "eslint src/*.js demo/*.js",
"dev": "npm install && node server/dev.js",
"dev": "npm install && node server/serve.js",
"build": "rimraf dist/* && rimraf types/* && node server/build.js && node server/changelog.js",
"update": "npm update --depth 20 --force && npm dedupe && npm prune && npm audit"
},

View File

@ -173,7 +173,7 @@ async function getStats(metafile) {
// rebuild typings
function compile(fileNames, options) {
log.info('Compile:', fileNames);
log.info('Compile typings:', fileNames);
const program = ts.createProgram(fileNames, options);
const emit = program.emit();
const diag = ts

View File

@ -9,7 +9,6 @@
- passthrough data compression
*/
const process = require('process');
const fs = require('fs');
const zlib = require('zlib');
const http = require('http');
@ -31,15 +30,17 @@ const options = {
default: 'demo/index.html',
httpPort: 10030,
httpsPort: 10031,
insecureHTTPParser: false,
minElapsed: 2,
monitor: ['package.json', 'config.js', 'demo', 'src'],
};
// just some predefined mime types
const mime = {
'.html': 'text/html',
'.js': 'text/javascript',
'.css': 'text/css',
'.json': 'application/json',
'.html': 'text/html; charset=utf-8',
'.js': 'text/javascript; charset=utf-8',
'.css': 'text/css; charset=utf-8',
'.json': 'application/json; charset=utf-8',
'.png': 'image/png',
'.jpg': 'image/jpg',
'.gif': 'image/gif',
@ -47,15 +48,16 @@ const mime = {
'.svg': 'image/svg+xml',
'.wav': 'audio/wav',
'.mp4': 'video/mp4',
'.woff': 'application/font-woff',
'.ttf': 'application/font-ttf',
'.woff': 'font/woff',
'.woff2': 'font/woff2',
'.ttf': 'font/ttf',
'.wasm': 'application/wasm',
};
let last = Date.now();
async function buildAll(evt, msg) {
const now = Date.now();
if ((now - last) > 2) build.build(evt, msg);
if ((now - last) > options.minElapsed) build.build(evt, msg);
else log.state('Build: merge event file', msg, evt);
last = now;
}
@ -114,7 +116,7 @@ async function httpRequest(req, res) {
const accept = req.headers['accept-encoding'] ? req.headers['accept-encoding'].includes('br') : false; // does target accept brotli compressed data
res.writeHead(200, {
// 'Content-Length': result.stat.size, // not using as it's misleading for compressed streams
'Content-Language': 'en', 'Content-Type': contentType, 'Content-Encoding': accept ? 'br' : '', 'Last-Modified': result.stat.mtime, 'Cache-Control': 'no-cache', 'X-Powered-By': `NodeJS/${process.version}`,
'Content-Language': 'en', 'Content-Type': contentType, 'Content-Encoding': accept ? 'br' : '', 'Last-Modified': result.stat.mtime, 'Cache-Control': 'no-cache', 'X-Content-Type-Options': 'nosniff',
});
const compress = zlib.createBrotliCompress({ params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 5 } }); // instance of brotli compression with level 5
const stream = fs.createReadStream(result.file);