@macrowing/filepilot 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/builtin.cjs +147 -0
- package/dist/builtin.d.cts +7 -0
- package/dist/builtin.d.ts +7 -0
- package/dist/builtin.js +8 -0
- package/dist/chunk-EQYOJW24.js +111 -0
- package/dist/chunk-MHWH3ZGP.js +59 -0
- package/dist/index.cjs +203 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +14 -0
- package/dist/react.cjs +197 -0
- package/dist/react.d.cts +7 -0
- package/dist/react.d.ts +7 -0
- package/dist/react.js +7 -0
- package/package.json +64 -0
package/dist/builtin.cjs
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/builtin.ts
|
|
31
|
+
var builtin_exports = {};
|
|
32
|
+
__export(builtin_exports, {
|
|
33
|
+
builtinParsers: () => builtinParsers,
|
|
34
|
+
defaultRegistry: () => defaultRegistry
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(builtin_exports);
|
|
37
|
+
|
|
38
|
+
// src/registry.ts
|
|
39
|
+
var normalizeExtension = (extension) => extension?.replace(/^\./, "").toLowerCase();
|
|
40
|
+
var getFileExtension = (file) => {
|
|
41
|
+
if (file.extension) return normalizeExtension(file.extension);
|
|
42
|
+
const name = file.name?.split(/[?#]/)[0];
|
|
43
|
+
const index = name?.lastIndexOf(".") ?? -1;
|
|
44
|
+
return index >= 0 ? normalizeExtension(name?.slice(index + 1)) : void 0;
|
|
45
|
+
};
|
|
46
|
+
var hasExtensionMatch = (parser, extension) => Boolean(
|
|
47
|
+
extension && parser.extensions.some((item) => normalizeExtension(item) === extension)
|
|
48
|
+
);
|
|
49
|
+
var hasMimeTypeMatch = (parser, mimeType) => Boolean(
|
|
50
|
+
mimeType && parser.mimeTypes?.some((item) => item.toLowerCase() === mimeType)
|
|
51
|
+
);
|
|
52
|
+
var createFilePilotRegistry = (initialParsers = []) => {
|
|
53
|
+
const parsers = /* @__PURE__ */ new Map();
|
|
54
|
+
initialParsers.forEach((parser) => parsers.set(parser.id, parser));
|
|
55
|
+
return {
|
|
56
|
+
register(parser) {
|
|
57
|
+
parsers.set(parser.id, parser);
|
|
58
|
+
return () => parsers.delete(parser.id);
|
|
59
|
+
},
|
|
60
|
+
unregister(id) {
|
|
61
|
+
parsers.delete(id);
|
|
62
|
+
},
|
|
63
|
+
resolve(file, parserId) {
|
|
64
|
+
const extension = getFileExtension(file);
|
|
65
|
+
const mimeType = file.mimeType?.toLowerCase();
|
|
66
|
+
if (parserId) return parsers.get(parserId);
|
|
67
|
+
const list = Array.from(parsers.values());
|
|
68
|
+
return list.find((parser) => hasExtensionMatch(parser, extension)) ?? list.find((parser) => hasMimeTypeMatch(parser, mimeType));
|
|
69
|
+
},
|
|
70
|
+
list() {
|
|
71
|
+
return Array.from(parsers.values());
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/builtin.ts
|
|
77
|
+
var builtinParsers = [
|
|
78
|
+
{
|
|
79
|
+
id: "filepilot-parser-drawio",
|
|
80
|
+
kind: "drawing",
|
|
81
|
+
extensions: ["drawio", "dio"],
|
|
82
|
+
mimeTypes: ["application/vnd.jgraph.mxfile", "application/x-drawio", "application/drawio"],
|
|
83
|
+
load: () => import("@macrowing/filepilot-parser-drawio")
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "filepilot-parser-viewer",
|
|
87
|
+
kind: "viewer",
|
|
88
|
+
extensions: ["md", "markdown", "mdx", "txt", "text", "log", "csv", "json", "xml", "yaml", "yml", "png", "jpg", "jpeg", "gif", "webp", "bmp", "svg"],
|
|
89
|
+
mimeTypes: [
|
|
90
|
+
"text/markdown",
|
|
91
|
+
"text/x-markdown",
|
|
92
|
+
"text/plain",
|
|
93
|
+
"text/csv",
|
|
94
|
+
"application/json",
|
|
95
|
+
"application/xml",
|
|
96
|
+
"text/xml",
|
|
97
|
+
"image/png",
|
|
98
|
+
"image/jpeg",
|
|
99
|
+
"image/gif",
|
|
100
|
+
"image/webp",
|
|
101
|
+
"image/bmp",
|
|
102
|
+
"image/svg+xml"
|
|
103
|
+
],
|
|
104
|
+
load: () => import("@macrowing/filepilot-parser-viewer")
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "filepilot-parser-pdf",
|
|
108
|
+
kind: "pdf",
|
|
109
|
+
extensions: ["pdf"],
|
|
110
|
+
mimeTypes: ["application/pdf"],
|
|
111
|
+
load: () => import("@macrowing/filepilot-parser-pdf")
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "filepilot-parser-office",
|
|
115
|
+
kind: "office",
|
|
116
|
+
extensions: ["doc", "docx", "ppt", "pptx", "xls", "xlsx"],
|
|
117
|
+
mimeTypes: [
|
|
118
|
+
"application/msword",
|
|
119
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
120
|
+
"application/vnd.ms-powerpoint",
|
|
121
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
122
|
+
"application/vnd.ms-excel",
|
|
123
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
124
|
+
],
|
|
125
|
+
load: () => import("@macrowing/filepilot-parser-office")
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: "filepilot-parser-mmind",
|
|
129
|
+
kind: "mindmap",
|
|
130
|
+
extensions: ["mmind"],
|
|
131
|
+
mimeTypes: ["application/json", "application/x-mmind"],
|
|
132
|
+
load: () => import("@macrowing/filepilot-parser-mmind")
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: "filepilot-parser-mdoc",
|
|
136
|
+
kind: "docflow",
|
|
137
|
+
extensions: ["mdoc"],
|
|
138
|
+
mimeTypes: ["application/x-mdoc", "application/vnd.docflow.mdoc", "application/octet-stream"],
|
|
139
|
+
load: () => import("@macrowing/filepilot-parser-mdoc")
|
|
140
|
+
}
|
|
141
|
+
];
|
|
142
|
+
var defaultRegistry = createFilePilotRegistry(builtinParsers);
|
|
143
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
144
|
+
0 && (module.exports = {
|
|
145
|
+
builtinParsers,
|
|
146
|
+
defaultRegistry
|
|
147
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as _macrowing_filepilot_types from '@macrowing/filepilot-types';
|
|
2
|
+
import { FilePilotParser } from '@macrowing/filepilot-types';
|
|
3
|
+
|
|
4
|
+
declare const builtinParsers: FilePilotParser[];
|
|
5
|
+
declare const defaultRegistry: _macrowing_filepilot_types.FilePilotRegistry;
|
|
6
|
+
|
|
7
|
+
export { builtinParsers, defaultRegistry };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as _macrowing_filepilot_types from '@macrowing/filepilot-types';
|
|
2
|
+
import { FilePilotParser } from '@macrowing/filepilot-types';
|
|
3
|
+
|
|
4
|
+
declare const builtinParsers: FilePilotParser[];
|
|
5
|
+
declare const defaultRegistry: _macrowing_filepilot_types.FilePilotRegistry;
|
|
6
|
+
|
|
7
|
+
export { builtinParsers, defaultRegistry };
|
package/dist/builtin.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/registry.ts
|
|
2
|
+
var normalizeExtension = (extension) => extension?.replace(/^\./, "").toLowerCase();
|
|
3
|
+
var getFileExtension = (file) => {
|
|
4
|
+
if (file.extension) return normalizeExtension(file.extension);
|
|
5
|
+
const name = file.name?.split(/[?#]/)[0];
|
|
6
|
+
const index = name?.lastIndexOf(".") ?? -1;
|
|
7
|
+
return index >= 0 ? normalizeExtension(name?.slice(index + 1)) : void 0;
|
|
8
|
+
};
|
|
9
|
+
var hasExtensionMatch = (parser, extension) => Boolean(
|
|
10
|
+
extension && parser.extensions.some((item) => normalizeExtension(item) === extension)
|
|
11
|
+
);
|
|
12
|
+
var hasMimeTypeMatch = (parser, mimeType) => Boolean(
|
|
13
|
+
mimeType && parser.mimeTypes?.some((item) => item.toLowerCase() === mimeType)
|
|
14
|
+
);
|
|
15
|
+
var createFilePilotRegistry = (initialParsers = []) => {
|
|
16
|
+
const parsers = /* @__PURE__ */ new Map();
|
|
17
|
+
initialParsers.forEach((parser) => parsers.set(parser.id, parser));
|
|
18
|
+
return {
|
|
19
|
+
register(parser) {
|
|
20
|
+
parsers.set(parser.id, parser);
|
|
21
|
+
return () => parsers.delete(parser.id);
|
|
22
|
+
},
|
|
23
|
+
unregister(id) {
|
|
24
|
+
parsers.delete(id);
|
|
25
|
+
},
|
|
26
|
+
resolve(file, parserId) {
|
|
27
|
+
const extension = getFileExtension(file);
|
|
28
|
+
const mimeType = file.mimeType?.toLowerCase();
|
|
29
|
+
if (parserId) return parsers.get(parserId);
|
|
30
|
+
const list = Array.from(parsers.values());
|
|
31
|
+
return list.find((parser) => hasExtensionMatch(parser, extension)) ?? list.find((parser) => hasMimeTypeMatch(parser, mimeType));
|
|
32
|
+
},
|
|
33
|
+
list() {
|
|
34
|
+
return Array.from(parsers.values());
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/builtin.ts
|
|
40
|
+
var builtinParsers = [
|
|
41
|
+
{
|
|
42
|
+
id: "filepilot-parser-drawio",
|
|
43
|
+
kind: "drawing",
|
|
44
|
+
extensions: ["drawio", "dio"],
|
|
45
|
+
mimeTypes: ["application/vnd.jgraph.mxfile", "application/x-drawio", "application/drawio"],
|
|
46
|
+
load: () => import("@macrowing/filepilot-parser-drawio")
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "filepilot-parser-viewer",
|
|
50
|
+
kind: "viewer",
|
|
51
|
+
extensions: ["md", "markdown", "mdx", "txt", "text", "log", "csv", "json", "xml", "yaml", "yml", "png", "jpg", "jpeg", "gif", "webp", "bmp", "svg"],
|
|
52
|
+
mimeTypes: [
|
|
53
|
+
"text/markdown",
|
|
54
|
+
"text/x-markdown",
|
|
55
|
+
"text/plain",
|
|
56
|
+
"text/csv",
|
|
57
|
+
"application/json",
|
|
58
|
+
"application/xml",
|
|
59
|
+
"text/xml",
|
|
60
|
+
"image/png",
|
|
61
|
+
"image/jpeg",
|
|
62
|
+
"image/gif",
|
|
63
|
+
"image/webp",
|
|
64
|
+
"image/bmp",
|
|
65
|
+
"image/svg+xml"
|
|
66
|
+
],
|
|
67
|
+
load: () => import("@macrowing/filepilot-parser-viewer")
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "filepilot-parser-pdf",
|
|
71
|
+
kind: "pdf",
|
|
72
|
+
extensions: ["pdf"],
|
|
73
|
+
mimeTypes: ["application/pdf"],
|
|
74
|
+
load: () => import("@macrowing/filepilot-parser-pdf")
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "filepilot-parser-office",
|
|
78
|
+
kind: "office",
|
|
79
|
+
extensions: ["doc", "docx", "ppt", "pptx", "xls", "xlsx"],
|
|
80
|
+
mimeTypes: [
|
|
81
|
+
"application/msword",
|
|
82
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
83
|
+
"application/vnd.ms-powerpoint",
|
|
84
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
85
|
+
"application/vnd.ms-excel",
|
|
86
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
87
|
+
],
|
|
88
|
+
load: () => import("@macrowing/filepilot-parser-office")
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "filepilot-parser-mmind",
|
|
92
|
+
kind: "mindmap",
|
|
93
|
+
extensions: ["mmind"],
|
|
94
|
+
mimeTypes: ["application/json", "application/x-mmind"],
|
|
95
|
+
load: () => import("@macrowing/filepilot-parser-mmind")
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: "filepilot-parser-mdoc",
|
|
99
|
+
kind: "docflow",
|
|
100
|
+
extensions: ["mdoc"],
|
|
101
|
+
mimeTypes: ["application/x-mdoc", "application/vnd.docflow.mdoc", "application/octet-stream"],
|
|
102
|
+
load: () => import("@macrowing/filepilot-parser-mdoc")
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
var defaultRegistry = createFilePilotRegistry(builtinParsers);
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
createFilePilotRegistry,
|
|
109
|
+
builtinParsers,
|
|
110
|
+
defaultRegistry
|
|
111
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultRegistry
|
|
3
|
+
} from "./chunk-EQYOJW24.js";
|
|
4
|
+
|
|
5
|
+
// src/react.tsx
|
|
6
|
+
import React, { Suspense, useEffect, useMemo, useRef } from "react";
|
|
7
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
8
|
+
var normalizeLocale = (locale) => locale?.startsWith("en") ? "en-US" : "zh-CN";
|
|
9
|
+
var viewerCache = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
var getLazyViewerEntry = (parser) => {
|
|
11
|
+
const cached = viewerCache.get(parser);
|
|
12
|
+
if (cached) return cached;
|
|
13
|
+
const entry = {
|
|
14
|
+
Viewer: React.lazy(() => parser.load().catch((error) => {
|
|
15
|
+
entry.loadError = error;
|
|
16
|
+
entry.errorListeners.forEach((listener) => listener(error));
|
|
17
|
+
throw error;
|
|
18
|
+
})),
|
|
19
|
+
errorListeners: /* @__PURE__ */ new Set()
|
|
20
|
+
};
|
|
21
|
+
viewerCache.set(parser, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var FilePilot = ({
|
|
25
|
+
file,
|
|
26
|
+
registry = defaultRegistry,
|
|
27
|
+
parserId,
|
|
28
|
+
options,
|
|
29
|
+
locale,
|
|
30
|
+
className,
|
|
31
|
+
style,
|
|
32
|
+
fallback = null,
|
|
33
|
+
unsupported = null,
|
|
34
|
+
onError
|
|
35
|
+
}) => {
|
|
36
|
+
const parser = registry.resolve(file, parserId);
|
|
37
|
+
const resolvedLocale = normalizeLocale(locale);
|
|
38
|
+
const viewerEntry = useMemo(() => parser ? getLazyViewerEntry(parser) : void 0, [parser]);
|
|
39
|
+
const onErrorRef = useRef(onError);
|
|
40
|
+
onErrorRef.current = onError;
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!viewerEntry) return;
|
|
43
|
+
const listener = (error) => onErrorRef.current?.(error);
|
|
44
|
+
viewerEntry.errorListeners.add(listener);
|
|
45
|
+
if (viewerEntry.loadError !== void 0) listener(viewerEntry.loadError);
|
|
46
|
+
return () => {
|
|
47
|
+
viewerEntry.errorListeners.delete(listener);
|
|
48
|
+
};
|
|
49
|
+
}, [viewerEntry]);
|
|
50
|
+
const Viewer = viewerEntry?.Viewer;
|
|
51
|
+
if (!Viewer) {
|
|
52
|
+
return /* @__PURE__ */ jsx(Fragment, { children: typeof unsupported === "function" ? unsupported(file) : unsupported });
|
|
53
|
+
}
|
|
54
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback, children: /* @__PURE__ */ jsx(Viewer, { file, options, locale: resolvedLocale, className, style }) });
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
FilePilot
|
|
59
|
+
};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
FilePilot: () => FilePilot,
|
|
34
|
+
builtinParsers: () => builtinParsers,
|
|
35
|
+
createFilePilotRegistry: () => createFilePilotRegistry,
|
|
36
|
+
defaultRegistry: () => defaultRegistry
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
39
|
+
|
|
40
|
+
// src/registry.ts
|
|
41
|
+
var normalizeExtension = (extension) => extension?.replace(/^\./, "").toLowerCase();
|
|
42
|
+
var getFileExtension = (file) => {
|
|
43
|
+
if (file.extension) return normalizeExtension(file.extension);
|
|
44
|
+
const name = file.name?.split(/[?#]/)[0];
|
|
45
|
+
const index = name?.lastIndexOf(".") ?? -1;
|
|
46
|
+
return index >= 0 ? normalizeExtension(name?.slice(index + 1)) : void 0;
|
|
47
|
+
};
|
|
48
|
+
var hasExtensionMatch = (parser, extension) => Boolean(
|
|
49
|
+
extension && parser.extensions.some((item) => normalizeExtension(item) === extension)
|
|
50
|
+
);
|
|
51
|
+
var hasMimeTypeMatch = (parser, mimeType) => Boolean(
|
|
52
|
+
mimeType && parser.mimeTypes?.some((item) => item.toLowerCase() === mimeType)
|
|
53
|
+
);
|
|
54
|
+
var createFilePilotRegistry = (initialParsers = []) => {
|
|
55
|
+
const parsers = /* @__PURE__ */ new Map();
|
|
56
|
+
initialParsers.forEach((parser) => parsers.set(parser.id, parser));
|
|
57
|
+
return {
|
|
58
|
+
register(parser) {
|
|
59
|
+
parsers.set(parser.id, parser);
|
|
60
|
+
return () => parsers.delete(parser.id);
|
|
61
|
+
},
|
|
62
|
+
unregister(id) {
|
|
63
|
+
parsers.delete(id);
|
|
64
|
+
},
|
|
65
|
+
resolve(file, parserId) {
|
|
66
|
+
const extension = getFileExtension(file);
|
|
67
|
+
const mimeType = file.mimeType?.toLowerCase();
|
|
68
|
+
if (parserId) return parsers.get(parserId);
|
|
69
|
+
const list = Array.from(parsers.values());
|
|
70
|
+
return list.find((parser) => hasExtensionMatch(parser, extension)) ?? list.find((parser) => hasMimeTypeMatch(parser, mimeType));
|
|
71
|
+
},
|
|
72
|
+
list() {
|
|
73
|
+
return Array.from(parsers.values());
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/builtin.ts
|
|
79
|
+
var builtinParsers = [
|
|
80
|
+
{
|
|
81
|
+
id: "filepilot-parser-drawio",
|
|
82
|
+
kind: "drawing",
|
|
83
|
+
extensions: ["drawio", "dio"],
|
|
84
|
+
mimeTypes: ["application/vnd.jgraph.mxfile", "application/x-drawio", "application/drawio"],
|
|
85
|
+
load: () => import("@macrowing/filepilot-parser-drawio")
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: "filepilot-parser-viewer",
|
|
89
|
+
kind: "viewer",
|
|
90
|
+
extensions: ["md", "markdown", "mdx", "txt", "text", "log", "csv", "json", "xml", "yaml", "yml", "png", "jpg", "jpeg", "gif", "webp", "bmp", "svg"],
|
|
91
|
+
mimeTypes: [
|
|
92
|
+
"text/markdown",
|
|
93
|
+
"text/x-markdown",
|
|
94
|
+
"text/plain",
|
|
95
|
+
"text/csv",
|
|
96
|
+
"application/json",
|
|
97
|
+
"application/xml",
|
|
98
|
+
"text/xml",
|
|
99
|
+
"image/png",
|
|
100
|
+
"image/jpeg",
|
|
101
|
+
"image/gif",
|
|
102
|
+
"image/webp",
|
|
103
|
+
"image/bmp",
|
|
104
|
+
"image/svg+xml"
|
|
105
|
+
],
|
|
106
|
+
load: () => import("@macrowing/filepilot-parser-viewer")
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: "filepilot-parser-pdf",
|
|
110
|
+
kind: "pdf",
|
|
111
|
+
extensions: ["pdf"],
|
|
112
|
+
mimeTypes: ["application/pdf"],
|
|
113
|
+
load: () => import("@macrowing/filepilot-parser-pdf")
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: "filepilot-parser-office",
|
|
117
|
+
kind: "office",
|
|
118
|
+
extensions: ["doc", "docx", "ppt", "pptx", "xls", "xlsx"],
|
|
119
|
+
mimeTypes: [
|
|
120
|
+
"application/msword",
|
|
121
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
122
|
+
"application/vnd.ms-powerpoint",
|
|
123
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
124
|
+
"application/vnd.ms-excel",
|
|
125
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
126
|
+
],
|
|
127
|
+
load: () => import("@macrowing/filepilot-parser-office")
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: "filepilot-parser-mmind",
|
|
131
|
+
kind: "mindmap",
|
|
132
|
+
extensions: ["mmind"],
|
|
133
|
+
mimeTypes: ["application/json", "application/x-mmind"],
|
|
134
|
+
load: () => import("@macrowing/filepilot-parser-mmind")
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "filepilot-parser-mdoc",
|
|
138
|
+
kind: "docflow",
|
|
139
|
+
extensions: ["mdoc"],
|
|
140
|
+
mimeTypes: ["application/x-mdoc", "application/vnd.docflow.mdoc", "application/octet-stream"],
|
|
141
|
+
load: () => import("@macrowing/filepilot-parser-mdoc")
|
|
142
|
+
}
|
|
143
|
+
];
|
|
144
|
+
var defaultRegistry = createFilePilotRegistry(builtinParsers);
|
|
145
|
+
|
|
146
|
+
// src/react.tsx
|
|
147
|
+
var import_react = __toESM(require("react"), 1);
|
|
148
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
149
|
+
var normalizeLocale = (locale) => locale?.startsWith("en") ? "en-US" : "zh-CN";
|
|
150
|
+
var viewerCache = /* @__PURE__ */ new WeakMap();
|
|
151
|
+
var getLazyViewerEntry = (parser) => {
|
|
152
|
+
const cached = viewerCache.get(parser);
|
|
153
|
+
if (cached) return cached;
|
|
154
|
+
const entry = {
|
|
155
|
+
Viewer: import_react.default.lazy(() => parser.load().catch((error) => {
|
|
156
|
+
entry.loadError = error;
|
|
157
|
+
entry.errorListeners.forEach((listener) => listener(error));
|
|
158
|
+
throw error;
|
|
159
|
+
})),
|
|
160
|
+
errorListeners: /* @__PURE__ */ new Set()
|
|
161
|
+
};
|
|
162
|
+
viewerCache.set(parser, entry);
|
|
163
|
+
return entry;
|
|
164
|
+
};
|
|
165
|
+
var FilePilot = ({
|
|
166
|
+
file,
|
|
167
|
+
registry = defaultRegistry,
|
|
168
|
+
parserId,
|
|
169
|
+
options,
|
|
170
|
+
locale,
|
|
171
|
+
className,
|
|
172
|
+
style,
|
|
173
|
+
fallback = null,
|
|
174
|
+
unsupported = null,
|
|
175
|
+
onError
|
|
176
|
+
}) => {
|
|
177
|
+
const parser = registry.resolve(file, parserId);
|
|
178
|
+
const resolvedLocale = normalizeLocale(locale);
|
|
179
|
+
const viewerEntry = (0, import_react.useMemo)(() => parser ? getLazyViewerEntry(parser) : void 0, [parser]);
|
|
180
|
+
const onErrorRef = (0, import_react.useRef)(onError);
|
|
181
|
+
onErrorRef.current = onError;
|
|
182
|
+
(0, import_react.useEffect)(() => {
|
|
183
|
+
if (!viewerEntry) return;
|
|
184
|
+
const listener = (error) => onErrorRef.current?.(error);
|
|
185
|
+
viewerEntry.errorListeners.add(listener);
|
|
186
|
+
if (viewerEntry.loadError !== void 0) listener(viewerEntry.loadError);
|
|
187
|
+
return () => {
|
|
188
|
+
viewerEntry.errorListeners.delete(listener);
|
|
189
|
+
};
|
|
190
|
+
}, [viewerEntry]);
|
|
191
|
+
const Viewer = viewerEntry?.Viewer;
|
|
192
|
+
if (!Viewer) {
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: typeof unsupported === "function" ? unsupported(file) : unsupported });
|
|
194
|
+
}
|
|
195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Viewer, { file, options, locale: resolvedLocale, className, style }) });
|
|
196
|
+
};
|
|
197
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
198
|
+
0 && (module.exports = {
|
|
199
|
+
FilePilot,
|
|
200
|
+
builtinParsers,
|
|
201
|
+
createFilePilotRegistry,
|
|
202
|
+
defaultRegistry
|
|
203
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FilePilotParser, FilePilotRegistry } from '@macrowing/filepilot-types';
|
|
2
|
+
export { FilePilotFile, FilePilotKind, FilePilotLocale, FilePilotParser, FilePilotProps, FilePilotRegistry, FilePilotRenderProps, FilePilotSource } from '@macrowing/filepilot-types';
|
|
3
|
+
export { builtinParsers, defaultRegistry } from './builtin.cjs';
|
|
4
|
+
export { FilePilot } from './react.cjs';
|
|
5
|
+
import 'react';
|
|
6
|
+
|
|
7
|
+
declare const createFilePilotRegistry: (initialParsers?: FilePilotParser[]) => FilePilotRegistry;
|
|
8
|
+
|
|
9
|
+
export { createFilePilotRegistry };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FilePilotParser, FilePilotRegistry } from '@macrowing/filepilot-types';
|
|
2
|
+
export { FilePilotFile, FilePilotKind, FilePilotLocale, FilePilotParser, FilePilotProps, FilePilotRegistry, FilePilotRenderProps, FilePilotSource } from '@macrowing/filepilot-types';
|
|
3
|
+
export { builtinParsers, defaultRegistry } from './builtin.js';
|
|
4
|
+
export { FilePilot } from './react.js';
|
|
5
|
+
import 'react';
|
|
6
|
+
|
|
7
|
+
declare const createFilePilotRegistry: (initialParsers?: FilePilotParser[]) => FilePilotRegistry;
|
|
8
|
+
|
|
9
|
+
export { createFilePilotRegistry };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FilePilot
|
|
3
|
+
} from "./chunk-MHWH3ZGP.js";
|
|
4
|
+
import {
|
|
5
|
+
builtinParsers,
|
|
6
|
+
createFilePilotRegistry,
|
|
7
|
+
defaultRegistry
|
|
8
|
+
} from "./chunk-EQYOJW24.js";
|
|
9
|
+
export {
|
|
10
|
+
FilePilot,
|
|
11
|
+
builtinParsers,
|
|
12
|
+
createFilePilotRegistry,
|
|
13
|
+
defaultRegistry
|
|
14
|
+
};
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/react.tsx
|
|
31
|
+
var react_exports = {};
|
|
32
|
+
__export(react_exports, {
|
|
33
|
+
FilePilot: () => FilePilot
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(react_exports);
|
|
36
|
+
var import_react = __toESM(require("react"), 1);
|
|
37
|
+
|
|
38
|
+
// src/registry.ts
|
|
39
|
+
var normalizeExtension = (extension) => extension?.replace(/^\./, "").toLowerCase();
|
|
40
|
+
var getFileExtension = (file) => {
|
|
41
|
+
if (file.extension) return normalizeExtension(file.extension);
|
|
42
|
+
const name = file.name?.split(/[?#]/)[0];
|
|
43
|
+
const index = name?.lastIndexOf(".") ?? -1;
|
|
44
|
+
return index >= 0 ? normalizeExtension(name?.slice(index + 1)) : void 0;
|
|
45
|
+
};
|
|
46
|
+
var hasExtensionMatch = (parser, extension) => Boolean(
|
|
47
|
+
extension && parser.extensions.some((item) => normalizeExtension(item) === extension)
|
|
48
|
+
);
|
|
49
|
+
var hasMimeTypeMatch = (parser, mimeType) => Boolean(
|
|
50
|
+
mimeType && parser.mimeTypes?.some((item) => item.toLowerCase() === mimeType)
|
|
51
|
+
);
|
|
52
|
+
var createFilePilotRegistry = (initialParsers = []) => {
|
|
53
|
+
const parsers = /* @__PURE__ */ new Map();
|
|
54
|
+
initialParsers.forEach((parser) => parsers.set(parser.id, parser));
|
|
55
|
+
return {
|
|
56
|
+
register(parser) {
|
|
57
|
+
parsers.set(parser.id, parser);
|
|
58
|
+
return () => parsers.delete(parser.id);
|
|
59
|
+
},
|
|
60
|
+
unregister(id) {
|
|
61
|
+
parsers.delete(id);
|
|
62
|
+
},
|
|
63
|
+
resolve(file, parserId) {
|
|
64
|
+
const extension = getFileExtension(file);
|
|
65
|
+
const mimeType = file.mimeType?.toLowerCase();
|
|
66
|
+
if (parserId) return parsers.get(parserId);
|
|
67
|
+
const list = Array.from(parsers.values());
|
|
68
|
+
return list.find((parser) => hasExtensionMatch(parser, extension)) ?? list.find((parser) => hasMimeTypeMatch(parser, mimeType));
|
|
69
|
+
},
|
|
70
|
+
list() {
|
|
71
|
+
return Array.from(parsers.values());
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/builtin.ts
|
|
77
|
+
var builtinParsers = [
|
|
78
|
+
{
|
|
79
|
+
id: "filepilot-parser-drawio",
|
|
80
|
+
kind: "drawing",
|
|
81
|
+
extensions: ["drawio", "dio"],
|
|
82
|
+
mimeTypes: ["application/vnd.jgraph.mxfile", "application/x-drawio", "application/drawio"],
|
|
83
|
+
load: () => import("@macrowing/filepilot-parser-drawio")
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: "filepilot-parser-viewer",
|
|
87
|
+
kind: "viewer",
|
|
88
|
+
extensions: ["md", "markdown", "mdx", "txt", "text", "log", "csv", "json", "xml", "yaml", "yml", "png", "jpg", "jpeg", "gif", "webp", "bmp", "svg"],
|
|
89
|
+
mimeTypes: [
|
|
90
|
+
"text/markdown",
|
|
91
|
+
"text/x-markdown",
|
|
92
|
+
"text/plain",
|
|
93
|
+
"text/csv",
|
|
94
|
+
"application/json",
|
|
95
|
+
"application/xml",
|
|
96
|
+
"text/xml",
|
|
97
|
+
"image/png",
|
|
98
|
+
"image/jpeg",
|
|
99
|
+
"image/gif",
|
|
100
|
+
"image/webp",
|
|
101
|
+
"image/bmp",
|
|
102
|
+
"image/svg+xml"
|
|
103
|
+
],
|
|
104
|
+
load: () => import("@macrowing/filepilot-parser-viewer")
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "filepilot-parser-pdf",
|
|
108
|
+
kind: "pdf",
|
|
109
|
+
extensions: ["pdf"],
|
|
110
|
+
mimeTypes: ["application/pdf"],
|
|
111
|
+
load: () => import("@macrowing/filepilot-parser-pdf")
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: "filepilot-parser-office",
|
|
115
|
+
kind: "office",
|
|
116
|
+
extensions: ["doc", "docx", "ppt", "pptx", "xls", "xlsx"],
|
|
117
|
+
mimeTypes: [
|
|
118
|
+
"application/msword",
|
|
119
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
120
|
+
"application/vnd.ms-powerpoint",
|
|
121
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
122
|
+
"application/vnd.ms-excel",
|
|
123
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
124
|
+
],
|
|
125
|
+
load: () => import("@macrowing/filepilot-parser-office")
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: "filepilot-parser-mmind",
|
|
129
|
+
kind: "mindmap",
|
|
130
|
+
extensions: ["mmind"],
|
|
131
|
+
mimeTypes: ["application/json", "application/x-mmind"],
|
|
132
|
+
load: () => import("@macrowing/filepilot-parser-mmind")
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: "filepilot-parser-mdoc",
|
|
136
|
+
kind: "docflow",
|
|
137
|
+
extensions: ["mdoc"],
|
|
138
|
+
mimeTypes: ["application/x-mdoc", "application/vnd.docflow.mdoc", "application/octet-stream"],
|
|
139
|
+
load: () => import("@macrowing/filepilot-parser-mdoc")
|
|
140
|
+
}
|
|
141
|
+
];
|
|
142
|
+
var defaultRegistry = createFilePilotRegistry(builtinParsers);
|
|
143
|
+
|
|
144
|
+
// src/react.tsx
|
|
145
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
146
|
+
var normalizeLocale = (locale) => locale?.startsWith("en") ? "en-US" : "zh-CN";
|
|
147
|
+
var viewerCache = /* @__PURE__ */ new WeakMap();
|
|
148
|
+
var getLazyViewerEntry = (parser) => {
|
|
149
|
+
const cached = viewerCache.get(parser);
|
|
150
|
+
if (cached) return cached;
|
|
151
|
+
const entry = {
|
|
152
|
+
Viewer: import_react.default.lazy(() => parser.load().catch((error) => {
|
|
153
|
+
entry.loadError = error;
|
|
154
|
+
entry.errorListeners.forEach((listener) => listener(error));
|
|
155
|
+
throw error;
|
|
156
|
+
})),
|
|
157
|
+
errorListeners: /* @__PURE__ */ new Set()
|
|
158
|
+
};
|
|
159
|
+
viewerCache.set(parser, entry);
|
|
160
|
+
return entry;
|
|
161
|
+
};
|
|
162
|
+
var FilePilot = ({
|
|
163
|
+
file,
|
|
164
|
+
registry = defaultRegistry,
|
|
165
|
+
parserId,
|
|
166
|
+
options,
|
|
167
|
+
locale,
|
|
168
|
+
className,
|
|
169
|
+
style,
|
|
170
|
+
fallback = null,
|
|
171
|
+
unsupported = null,
|
|
172
|
+
onError
|
|
173
|
+
}) => {
|
|
174
|
+
const parser = registry.resolve(file, parserId);
|
|
175
|
+
const resolvedLocale = normalizeLocale(locale);
|
|
176
|
+
const viewerEntry = (0, import_react.useMemo)(() => parser ? getLazyViewerEntry(parser) : void 0, [parser]);
|
|
177
|
+
const onErrorRef = (0, import_react.useRef)(onError);
|
|
178
|
+
onErrorRef.current = onError;
|
|
179
|
+
(0, import_react.useEffect)(() => {
|
|
180
|
+
if (!viewerEntry) return;
|
|
181
|
+
const listener = (error) => onErrorRef.current?.(error);
|
|
182
|
+
viewerEntry.errorListeners.add(listener);
|
|
183
|
+
if (viewerEntry.loadError !== void 0) listener(viewerEntry.loadError);
|
|
184
|
+
return () => {
|
|
185
|
+
viewerEntry.errorListeners.delete(listener);
|
|
186
|
+
};
|
|
187
|
+
}, [viewerEntry]);
|
|
188
|
+
const Viewer = viewerEntry?.Viewer;
|
|
189
|
+
if (!Viewer) {
|
|
190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: typeof unsupported === "function" ? unsupported(file) : unsupported });
|
|
191
|
+
}
|
|
192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Viewer, { file, options, locale: resolvedLocale, className, style }) });
|
|
193
|
+
};
|
|
194
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
195
|
+
0 && (module.exports = {
|
|
196
|
+
FilePilot
|
|
197
|
+
});
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FilePilotProps } from '@macrowing/filepilot-types';
|
|
3
|
+
export { FilePilotLocale, FilePilotProps } from '@macrowing/filepilot-types';
|
|
4
|
+
|
|
5
|
+
declare const FilePilot: ({ file, registry, parserId, options, locale, className, style, fallback, unsupported, onError }: FilePilotProps) => React.JSX.Element;
|
|
6
|
+
|
|
7
|
+
export { FilePilot };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FilePilotProps } from '@macrowing/filepilot-types';
|
|
3
|
+
export { FilePilotLocale, FilePilotProps } from '@macrowing/filepilot-types';
|
|
4
|
+
|
|
5
|
+
declare const FilePilot: ({ file, registry, parserId, options, locale, className, style, fallback, unsupported, onError }: FilePilotProps) => React.JSX.Element;
|
|
6
|
+
|
|
7
|
+
export { FilePilot };
|
package/dist/react.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@macrowing/filepilot",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Extensible, lazy-loaded React file preview toolkit.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./react": {
|
|
17
|
+
"types": "./dist/react.d.ts",
|
|
18
|
+
"import": "./dist/react.js",
|
|
19
|
+
"require": "./dist/react.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./builtin": {
|
|
22
|
+
"types": "./dist/builtin.d.ts",
|
|
23
|
+
"import": "./dist/builtin.js",
|
|
24
|
+
"require": "./dist/builtin.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@macrowing/filepilot-parser-drawio": "0.1.0",
|
|
32
|
+
"@macrowing/filepilot-parser-mdoc": "0.1.0",
|
|
33
|
+
"@macrowing/filepilot-parser-mmind": "0.1.0",
|
|
34
|
+
"@macrowing/filepilot-parser-pdf": "0.1.0",
|
|
35
|
+
"@macrowing/filepilot-parser-office": "0.1.0",
|
|
36
|
+
"@macrowing/filepilot-types": "0.1.0",
|
|
37
|
+
"@macrowing/filepilot-parser-viewer": "0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"react": ">=18.2.0 || >=19.0.0",
|
|
41
|
+
"react-dom": ">=18.2.0 || >=19.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"rimraf": "^6.0.1",
|
|
45
|
+
"tsup": "^8.4.0"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"file",
|
|
52
|
+
"preview",
|
|
53
|
+
"viewer",
|
|
54
|
+
"react",
|
|
55
|
+
"pdf",
|
|
56
|
+
"office"
|
|
57
|
+
],
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsup src/index.ts src/react.tsx src/builtin.ts --format esm,cjs --dts --clean --external react --external react-dom",
|
|
60
|
+
"clean": "rimraf dist",
|
|
61
|
+
"dev": "tsup src/index.ts src/react.tsx src/builtin.ts --format esm,cjs --dts --watch --external react --external react-dom",
|
|
62
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
63
|
+
}
|
|
64
|
+
}
|