forked from Kieran/void.cat
Compile with webpack
This commit is contained in:
parent
596f141323
commit
1babc8e4e0
5
VoidCat/spa/src/api/.npmignore
Normal file
5
VoidCat/spa/src/api/.npmignore
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
src/
|
||||||
|
nodes_modules/
|
||||||
|
yarn*
|
||||||
|
tsconfig.json
|
||||||
|
webpack.config.js
|
28
VoidCat/spa/src/api/package.json
Normal file
28
VoidCat/spa/src/api/package.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
@ -58,7 +58,7 @@ export class StreamUploader extends VoidUploader {
|
|||||||
const headers = {
|
const headers = {
|
||||||
"Content-Type": "application/octet-stream",
|
"Content-Type": "application/octet-stream",
|
||||||
"V-Content-Type": !this.file.type ? "application/octet-stream" : this.file.type,
|
"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
|
"V-Full-Digest": hash
|
||||||
} as Record<string, string>;
|
} as Record<string, string>;
|
||||||
if (this.#encrypt) {
|
if (this.#encrypt) {
|
||||||
|
@ -25,7 +25,7 @@ export class XHRUploader extends VoidUploader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async #doSplitXHRUpload(hash: string, splitSize: number) {
|
async #doSplitXHRUpload(hash: string, splitSize: number) {
|
||||||
let xhr = null;
|
let xhr: VoidUploadResult | null = null;
|
||||||
const segments = Math.ceil(this.file.size / splitSize);
|
const segments = Math.ceil(this.file.size / splitSize);
|
||||||
for (let s = 0; s < segments; s++) {
|
for (let s = 0; s < segments; s++) {
|
||||||
const offset = s * splitSize;
|
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.open("POST", id ? `${this.uri}/upload/${id}` : `${this.uri}/upload`);
|
||||||
req.setRequestHeader("Content-Type", "application/octet-stream");
|
req.setRequestHeader("Content-Type", "application/octet-stream");
|
||||||
req.setRequestHeader("V-Content-Type", !this.file.type ? "application/octet-stream" : this.file.type);
|
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-Full-Digest", fullDigest);
|
||||||
req.setRequestHeader("V-Segment", `${part}/${partOf}`)
|
req.setRequestHeader("V-Segment", `${part}/${partOf}`)
|
||||||
if (this.auth) {
|
if (this.auth) {
|
||||||
|
@ -97,11 +97,13 @@ export interface VoidFileMeta {
|
|||||||
size: number
|
size: number
|
||||||
uploaded: string
|
uploaded: string
|
||||||
mimeType: string
|
mimeType: string
|
||||||
|
digest?: string
|
||||||
expires?: string
|
expires?: string
|
||||||
url?: string
|
url?: string
|
||||||
editSecret?: string
|
editSecret?: string
|
||||||
encryptionParams?: string
|
encryptionParams?: string
|
||||||
magnetLink?: string
|
magnetLink?: string
|
||||||
|
storage: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VirusScanStatus {
|
export interface VirusScanStatus {
|
||||||
|
43
VoidCat/spa/src/api/webpack.config.js
Normal file
43
VoidCat/spa/src/api/webpack.config.js
Normal 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;
|
||||||
|
};
|
10499
VoidCat/spa/yarn.lock
10499
VoidCat/spa/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user