@macrowing/filepilot-types 0.1.0
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.
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +47 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +0 -0
- package/package.json +35 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var index_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(index_exports);
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ComponentType, CSSProperties, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type FilePilotSource = string | Blob | ArrayBuffer | Uint8Array;
|
|
4
|
+
type FilePilotKind = 'markdown' | 'text' | 'pdf' | 'office' | (string & {});
|
|
5
|
+
type FilePilotLocale = 'zh-CN' | 'en-US' | 'zh' | 'en';
|
|
6
|
+
interface FilePilotFile {
|
|
7
|
+
source: FilePilotSource;
|
|
8
|
+
name?: string;
|
|
9
|
+
mimeType?: string;
|
|
10
|
+
extension?: string;
|
|
11
|
+
}
|
|
12
|
+
interface FilePilotRenderProps<TOptions = unknown> {
|
|
13
|
+
file: FilePilotFile;
|
|
14
|
+
options?: TOptions;
|
|
15
|
+
locale?: FilePilotLocale;
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
}
|
|
19
|
+
interface FilePilotParser<TOptions = any> {
|
|
20
|
+
id: string;
|
|
21
|
+
kind: FilePilotKind;
|
|
22
|
+
extensions: readonly string[];
|
|
23
|
+
mimeTypes?: readonly string[];
|
|
24
|
+
load: () => Promise<{
|
|
25
|
+
default: ComponentType<FilePilotRenderProps<TOptions>>;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
interface FilePilotRegistry {
|
|
29
|
+
register: (parser: FilePilotParser) => () => void;
|
|
30
|
+
unregister: (id: string) => void;
|
|
31
|
+
resolve: (file: FilePilotFile, parserId?: string) => FilePilotParser | undefined;
|
|
32
|
+
list: () => FilePilotParser[];
|
|
33
|
+
}
|
|
34
|
+
interface FilePilotProps<TOptions = unknown> {
|
|
35
|
+
file: FilePilotFile;
|
|
36
|
+
registry?: FilePilotRegistry;
|
|
37
|
+
parserId?: string;
|
|
38
|
+
options?: TOptions;
|
|
39
|
+
locale?: FilePilotLocale;
|
|
40
|
+
className?: string;
|
|
41
|
+
style?: CSSProperties;
|
|
42
|
+
fallback?: ReactNode;
|
|
43
|
+
unsupported?: ReactNode | ((file: FilePilotFile) => ReactNode);
|
|
44
|
+
onError?: (error: unknown) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type { FilePilotFile, FilePilotKind, FilePilotLocale, FilePilotParser, FilePilotProps, FilePilotRegistry, FilePilotRenderProps, FilePilotSource };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ComponentType, CSSProperties, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type FilePilotSource = string | Blob | ArrayBuffer | Uint8Array;
|
|
4
|
+
type FilePilotKind = 'markdown' | 'text' | 'pdf' | 'office' | (string & {});
|
|
5
|
+
type FilePilotLocale = 'zh-CN' | 'en-US' | 'zh' | 'en';
|
|
6
|
+
interface FilePilotFile {
|
|
7
|
+
source: FilePilotSource;
|
|
8
|
+
name?: string;
|
|
9
|
+
mimeType?: string;
|
|
10
|
+
extension?: string;
|
|
11
|
+
}
|
|
12
|
+
interface FilePilotRenderProps<TOptions = unknown> {
|
|
13
|
+
file: FilePilotFile;
|
|
14
|
+
options?: TOptions;
|
|
15
|
+
locale?: FilePilotLocale;
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: CSSProperties;
|
|
18
|
+
}
|
|
19
|
+
interface FilePilotParser<TOptions = any> {
|
|
20
|
+
id: string;
|
|
21
|
+
kind: FilePilotKind;
|
|
22
|
+
extensions: readonly string[];
|
|
23
|
+
mimeTypes?: readonly string[];
|
|
24
|
+
load: () => Promise<{
|
|
25
|
+
default: ComponentType<FilePilotRenderProps<TOptions>>;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
interface FilePilotRegistry {
|
|
29
|
+
register: (parser: FilePilotParser) => () => void;
|
|
30
|
+
unregister: (id: string) => void;
|
|
31
|
+
resolve: (file: FilePilotFile, parserId?: string) => FilePilotParser | undefined;
|
|
32
|
+
list: () => FilePilotParser[];
|
|
33
|
+
}
|
|
34
|
+
interface FilePilotProps<TOptions = unknown> {
|
|
35
|
+
file: FilePilotFile;
|
|
36
|
+
registry?: FilePilotRegistry;
|
|
37
|
+
parserId?: string;
|
|
38
|
+
options?: TOptions;
|
|
39
|
+
locale?: FilePilotLocale;
|
|
40
|
+
className?: string;
|
|
41
|
+
style?: CSSProperties;
|
|
42
|
+
fallback?: ReactNode;
|
|
43
|
+
unsupported?: ReactNode | ((file: FilePilotFile) => ReactNode);
|
|
44
|
+
onError?: (error: unknown) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type { FilePilotFile, FilePilotKind, FilePilotLocale, FilePilotParser, FilePilotProps, FilePilotRegistry, FilePilotRenderProps, FilePilotSource };
|
package/dist/index.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@macrowing/filepilot-types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared contracts for FilePilot and parser packages.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react": ">=18.2.0 || >=19.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/react": "^19.0.12",
|
|
24
|
+
"rimraf": "^6.0.1",
|
|
25
|
+
"tsup": "^8.4.0"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
32
|
+
"clean": "rimraf dist",
|
|
33
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
34
|
+
}
|
|
35
|
+
}
|