Compile with webpack

This commit is contained in:
Kieran 2023-05-22 14:49:30 +01:00
parent 596f141323
commit 1babc8e4e0
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
7 changed files with 2375 additions and 8208 deletions

View File

@ -0,0 +1,5 @@
src/
nodes_modules/
yarn*
tsconfig.json
webpack.config.js

View File

@ -0,0 +1,28 @@
{
"name": "@void-cat/api",
"version": "1.0.1",
"description": "void.cat API package",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "https://git.v0l.io/Kieran/void.cat",
"author": "Kieran",
"license": "MIT",
"private": false,
"scripts": {
"build": "webpack --mode=production --node-env=production",
"build:dev": "webpack --mode=development",
"build:prod": "webpack --mode=production --node-env=production",
"watch": "webpack --watch"
},
"devDependencies": {
"@types/sjcl": "^1.0.30",
"@webpack-cli/generators": "^3.0.4",
"ts-loader": "^9.4.2",
"typescript": "^5.0.4",
"webpack": "^5.83.1",
"webpack-cli": "^5.1.1"
},
"dependencies": {
"sjcl": "^1.0.8"
}
}

View File

@ -58,7 +58,7 @@ export class StreamUploader extends VoidUploader {
const headers = {
"Content-Type": "application/octet-stream",
"V-Content-Type": !this.file.type ? "application/octet-stream" : this.file.type,
"V-Filename": this.file.name,
"V-Filename": "name" in this.file ? this.file.name : "",
"V-Full-Digest": hash
} as Record<string, string>;
if (this.#encrypt) {

View File

@ -25,7 +25,7 @@ export class XHRUploader extends VoidUploader {
}
async #doSplitXHRUpload(hash: string, splitSize: number) {
let xhr = null;
let xhr: VoidUploadResult | null = null;
const segments = Math.ceil(this.file.size / splitSize);
for (let s = 0; s < segments; s++) {
const offset = s * splitSize;
@ -74,7 +74,7 @@ export class XHRUploader extends VoidUploader {
req.open("POST", id ? `${this.uri}/upload/${id}` : `${this.uri}/upload`);
req.setRequestHeader("Content-Type", "application/octet-stream");
req.setRequestHeader("V-Content-Type", !this.file.type ? "application/octet-stream" : this.file.type);
req.setRequestHeader("V-Filename", this.file.name);
req.setRequestHeader("V-Filename", "name" in this.file ? this.file.name : "");
req.setRequestHeader("V-Full-Digest", fullDigest);
req.setRequestHeader("V-Segment", `${part}/${partOf}`)
if (this.auth) {

View File

@ -97,11 +97,13 @@ export interface VoidFileMeta {
size: number
uploaded: string
mimeType: string
digest?: string
expires?: string
url?: string
editSecret?: string
encryptionParams?: string
magnetLink?: string
storage: string
}
export interface VirusScanStatus {

View File

@ -0,0 +1,43 @@
// Generated using webpack-cli https://github.com/webpack/webpack-cli
const path = require('path');
const isProduction = process.env.NODE_ENV == 'production';
const config = {
entry: './src/index.ts',
devtool: isProduction ? "source-map" : "eval",
output: {
path: path.resolve(__dirname, 'dist'),
clean: true,
library: {
name: "@void-cat/api",
type: "umd"
}
},
plugins: [],
module: {
rules: [
{
test: /\.(ts|tsx)$/i,
loader: 'ts-loader',
exclude: ['/node_modules/'],
}
],
},
resolve: {
preferRelative: true,
roots: [path.resolve(__dirname, 'src'), "..."],
extensions: ['.tsx', '.ts', '.jsx', '.js', '...'],
fallback: {
crypto: false
}
},
};
module.exports = () => {
if (isProduction) {
config.mode = 'production';
} else {
config.mode = 'development';
}
return config;
};

File diff suppressed because it is too large Load Diff