update build

This commit is contained in:
Kieran 2019-05-15 16:39:41 +08:00
parent 87b59d3428
commit c60f346120
10 changed files with 57 additions and 19 deletions

View File

@ -1,2 +0,0 @@
@echo off
google-closure-compiler src/js/Const.js src/js/Util.js src/js/FileDownloader.js src/js/VBF.js src/js/autodownloader.js --js_output_file dist/void_auto_loader.js --language_out ECMASCRIPT_NEXT

View File

@ -1,2 +0,0 @@
@echo off
google-closure-compiler src/js/Const.js src/js/Util.js src/js/FileDownloader.js src/js/VBF.js --js_output_file dist/void_lib.js --language_out ECMASCRIPT_NEXT

View File

@ -5,7 +5,7 @@
<title>void.cat</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="dist/style.css" />
<link rel="stylesheet" href="dist/bundle.css" />
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
@ -160,7 +160,7 @@
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<script type="text/javascript" src="./dist/bundle.js"></script>
<script type="text/javascript" src="dist/bundle.js"></script>
</body>
</html>

View File

@ -7,9 +7,9 @@
"url": "git+https://github.com/v0l/void.cat.git"
},
"scripts": {
"build": "sass src/css/style.scss dist/style.css && webpack-cli --entry ./src/js/index.js --mode production --output ./dist/bundle.js && webpack-cli --entry ./src/js/Worker.js --mode production --output ./sw.js",
"build": "webpack",
"debug": "webpack-cli --entry ./src/js/index.js --mode development --watch --output ./dist/bundle.js",
"debug-worker": "webpack-cli --entry ./src/js/Worker.js --mode development --watch --output ./sw.js"
"debug:worker": "webpack-cli --entry ./src/js/Worker.js --mode development --watch --output ./sw.js"
},
"keywords": [
"upload",
@ -25,10 +25,11 @@
"homepage": "https://github.com/v0l/void.cat#readme",
"dependencies": {
"asmcrypto.js": "^2.3.2",
"css-loader": "^2.1.1",
"mini-css-extract-plugin": "^0.6.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"sass-loader": "^7.1.0",
"webpack": "^4.31.0"
},
"devDependencies": {
"saas": "^1.0.0",
"webpack-cli": "^3.3.2"
}
}

View File

@ -26,8 +26,9 @@ const VoidFetch = function (event) {
}
};
let resp = await fd.StreamResponse();
resp.headers.set("Content-Type", fd.fileHeader.mime != "" ? fd.fileHeader.mime : "application/octet-stream");
resp.headers.set("Content-Disposition", `inline; filename="${fd.fileHeader.name}"`);
let head = await fd.waitForHeader;
resp.headers.set("Content-Type", head.mime != "" ? head.mime : "application/octet-stream");
resp.headers.set("Content-Disposition", `inline; filename="${head.name}"`);
return resp;
} else {
return Response.error();

View File

@ -1,4 +1,5 @@
import * as App from './modules/App.js';
import '../scss/style.scss';
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').then(function (registration) {

View File

@ -1,7 +1,7 @@
import * as Const from './Const.js';
import { VBF } from './VBF.js';
import { XHR, Utils, Log } from './Util.js';
import { bytes_to_base64, HmacSha256, AES_CBC } from 'asmcrypto.js';
import { HmacSha256, AES_CBC } from 'asmcrypto.js';
/**
* File download and decryption class
@ -80,8 +80,14 @@ function FileDownloader(fileinfo, key, iv) {
mode: 'cors'
});
//hack
var completeHeader;
this.waitForHeader = new Promise((resolve, reject) => {
completeHeader = resolve;
});
let void_download = {
SetFileHeader: function (fh) { this.fileHeader = fh; }.bind(this),
SetFileHeader: function (fh) { completeHeader(fh); }.bind({ completeHeader }),
HandleProgress: this.HandleProgress.bind(this),
downloadStats: this.downloadStats,
isStart: true,

View File

@ -21,6 +21,7 @@
self::$Instance = new Redis();
$con = self::$Instance->pconnect(REDIS_CONFIG);
if($con){
self::$Instance->select(REDIS_DB);
$rep = self::$Instance->info();
if($rep["role"] == "slave"){
self::$IsConnectedToSlave = true;
@ -29,9 +30,6 @@
return $con && $mcon;
}
}
if(REDIS_DB !== 0 && $con){
self::$Instance->select(REDIS_DB);
}
return $con;
}
}

35
webpack.config.js Normal file
View File

@ -0,0 +1,35 @@
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = {
entry: {
bundle: './src/js/index.js',
sw: './src/js/Worker.js'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"]
}
]
},
mode: 'production',
optimization: {
usedExports: true,
minimizer: [new TerserJSPlugin(), new OptimizeCSSAssetsPlugin()]
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
path: path.resolve(__dirname, 'dist')
})
]
};