diff --git a/build_autoloader.bat b/build_autoloader.bat deleted file mode 100644 index 8f91dd7..0000000 --- a/build_autoloader.bat +++ /dev/null @@ -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 \ No newline at end of file diff --git a/build_lib.bat b/build_lib.bat deleted file mode 100644 index 06c6fbd..0000000 --- a/build_lib.bat +++ /dev/null @@ -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 \ No newline at end of file diff --git a/index.html b/index.html index 4a420c8..3749bcc 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ void.cat - + - + \ No newline at end of file diff --git a/package.json b/package.json index 290f5ca..e22559e 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/js/Worker.js b/src/js/Worker.js index 1866d49..38a3a35 100644 --- a/src/js/Worker.js +++ b/src/js/Worker.js @@ -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(); diff --git a/src/js/index.js b/src/js/index.js index 4ed30c9..05736a8 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -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) { diff --git a/src/js/modules/FileDownloader.js b/src/js/modules/FileDownloader.js index 9143c09..6dc6e2e 100644 --- a/src/js/modules/FileDownloader.js +++ b/src/js/modules/FileDownloader.js @@ -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, diff --git a/src/php/staticredis.php b/src/php/staticredis.php index 0f793f8..4a7fd48 100644 --- a/src/php/staticredis.php +++ b/src/php/staticredis.php @@ -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; } } diff --git a/src/css/style.scss b/src/scss/style.scss similarity index 100% rename from src/css/style.scss rename to src/scss/style.scss diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..613095f --- /dev/null +++ b/webpack.config.js @@ -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') + }) + ] +}; \ No newline at end of file