@filebox/core 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 简单的MIME类型扩展系统
3
+ */
4
+ export declare class TypeManager {
5
+ private extToMime;
6
+ private mimeToExt;
7
+ /**
8
+ * 注册自定义MIME类型映射
9
+ * @param extension 文件扩展名(不带点)
10
+ * @param mimeType MIME类型
11
+ */
12
+ register(extension: string, mimeType: string): void;
13
+ /**
14
+ * 批量注册MIME类型映射
15
+ * @param mappings MIME类型映射对象 {扩展名: MIME类型}
16
+ */
17
+ registerBatch(mappings: Record<string, string>): void;
18
+ /**
19
+ * 根据文件名或扩展名获取MIME类型
20
+ * @param filenameOrExt 文件名或扩展名
21
+ * @returns MIME类型字符串或false
22
+ */
23
+ lookup(filenameOrExt: string): string | false;
24
+ /**
25
+ * 根据MIME类型获取扩展名
26
+ * @param mimeType MIME类型
27
+ * @returns 扩展名(不带点)或false
28
+ */
29
+ extension(mimeType: string): string | false;
30
+ /**
31
+ * 获取格式化的Content-Type头
32
+ * @param typeOrFilename MIME类型或文件名
33
+ * @returns Content-Type值(带charset)
34
+ */
35
+ contentType(typeOrFilename: string): string | false;
36
+ /**
37
+ * 获取自定义注册的所有MIME类型映射
38
+ * @returns 对象格式的映射 {扩展名: MIME类型}
39
+ */
40
+ getCustomTypes(): Record<string, string>;
41
+ /**
42
+ * 清除所有自定义MIME类型映射
43
+ */
44
+ reset(): void;
45
+ }
46
+ declare const typeManager: TypeManager;
47
+ export default typeManager;
@@ -0,0 +1,4 @@
1
+ declare function isObject(value: any): boolean;
2
+ declare function createProxy<T extends object>(obj: T, cb: () => Promise<void>): T;
3
+ declare function randomString(length?: number): string;
4
+ export { isObject, createProxy, randomString };
@@ -0,0 +1,48 @@
1
+ import Stat from "./stat";
2
+ import Lock from "./lock";
3
+ declare class BaseVolume {
4
+ static lock: Lock;
5
+ name: string;
6
+ _fs: any;
7
+ emitter: any;
8
+ instance: any;
9
+ constructor(name: string, fs: any, emitter?: any);
10
+ refresh(path: string): Promise<void>;
11
+ _get(path: string): Promise<Stat>;
12
+ stat(path: string | Stat): Promise<Stat>;
13
+ list(path: string | Stat, options?: any): Promise<any>;
14
+ readFile(path: string): Promise<any>;
15
+ hasMethod(method: string): any;
16
+ }
17
+ declare class ReadOnlyVolume extends BaseVolume {
18
+ constructor(name: string, fs: any, emitter?: any);
19
+ }
20
+ declare class Volume extends BaseVolume {
21
+ constructor(name: string, fs: any, emitter?: any);
22
+ mkdir(path: string | Stat, options?: any): Promise<any>;
23
+ rapidUpload(path: string, file: any, type: string): Promise<any>;
24
+ rename(path: string, newName: string): Promise<any>;
25
+ save(option: {
26
+ password: string;
27
+ link: string;
28
+ [key: string]: any;
29
+ }, dest?: string | null): Promise<any>;
30
+ share(options: {
31
+ password?: string;
32
+ expire?: string | number;
33
+ expired?: string | number;
34
+ [key: string]: any;
35
+ }, path?: string): Promise<any>;
36
+ search(data: any): Promise<any>;
37
+ remove(path: string, options?: any): Promise<any>;
38
+ bulkCopy(src: string[], dest: string, options?: any): Promise<any>;
39
+ createUpload(path: string, file: any, uploadProgress: any): Promise<any>;
40
+ upload(path: string, file: any, uploadProgress: any): Promise<any>;
41
+ remoteUpload(path: string | Stat, url: string): Promise<any>;
42
+ download(path: string, options?: any): Promise<any>;
43
+ copy(source: string, destination: string, options?: any): Promise<any>;
44
+ move(source: string, destination: string, options?: any): Promise<any>;
45
+ bulkRemove(paths: string[], options?: any): Promise<any>;
46
+ unmount(): Promise<void>;
47
+ }
48
+ export { Volume, ReadOnlyVolume };
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@filebox/core",
3
+ "email": "ppnows@gmail.com",
4
+ "version": "1.0.10",
5
+ "description": "filebox-core",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "browser": "./dist/index.browser.js",
9
+ "types": "./dist/index.d.ts",
10
+ "scripts": {
11
+ "watch": "nodemon --watch './**/*' --ext 'js' --exec npm run build:cjs",
12
+ "build:esm": "cross-env BUILD_FORMAT=es node esbuild.config.js",
13
+ "build:cjs": "cross-env BUILD_FORMAT=cjs node esbuild.config.js",
14
+ "build:umd": "cross-env BUILD_FORMAT=umd node esbuild.config.js",
15
+ "build:types": "tsc -p tsconfig.types.json",
16
+ "build": "npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:types",
17
+ "prepublishOnly": "npm run build",
18
+ "publish:patch": "npm version patch && npm publish --access public",
19
+ "publish:minor": "npm version minor && npm publish --access public",
20
+ "publish:major": "npm version major && npm publish --access public",
21
+ "test": "jest"
22
+ },
23
+ "keywords": [],
24
+ "files": [
25
+ "dist/index.cjs",
26
+ "dist/index.mjs",
27
+ "dist/index.browser.js",
28
+ "dist/**/*.d.ts",
29
+ "LICENSE",
30
+ "README.md"
31
+ ],
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "author": "ppnow",
36
+ "license": "MIT",
37
+ "dependencies": {
38
+ "bytes": "^3.1.2",
39
+ "dayjs": "^1.11.10",
40
+ "debug": "^4.4.1",
41
+ "lru-cache": "^11.0.1",
42
+ "mime-types": "^3.0.0",
43
+ "mitt": "^3.0.1",
44
+ "path-browserify": "^1.0.1"
45
+ },
46
+ "devDependencies": {
47
+ "@types/bytes": "^3.1.4",
48
+ "@types/debug": "^4.1.12",
49
+ "@types/mime-types": "^2.1.4",
50
+ "@types/node": "^22.5.4",
51
+ "@types/path-browserify": "^1.0.3",
52
+ "cross-env": "^7.0.3",
53
+ "esbuild": "^0.24.0",
54
+ "jest": "^29.7.0",
55
+ "nodemon": "^3.0.2",
56
+ "typescript": "^5.9.3"
57
+ },
58
+ "type": "module"
59
+ }