@nocobase/plugin-file-manager 2.1.0-beta.27 → 2.1.0-beta.30

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.
Files changed (33) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +1 -0
  3. package/dist/client/index.d.ts +1 -1
  4. package/dist/client/index.js +1 -1
  5. package/dist/client/locale/index.d.ts +2 -1
  6. package/dist/client/previewer/filePreviewTypes.d.ts +1 -32
  7. package/dist/client-v2/855.e7d2e24a0b457a89.js +10 -0
  8. package/dist/client-v2/index.d.ts +10 -0
  9. package/dist/client-v2/index.js +10 -0
  10. package/dist/client-v2/locale.d.ts +10 -0
  11. package/dist/{client → client-v2}/models/DisplayPreviewFieldModel.d.ts +1 -1
  12. package/dist/{client → client-v2}/models/UploadActionModel.d.ts +1 -1
  13. package/dist/{client → client-v2}/models/UploadFieldModel.d.ts +1 -1
  14. package/dist/client-v2/models/index.d.ts +11 -0
  15. package/dist/{client → client-v2}/models/uploadFieldUtils.d.ts +8 -0
  16. package/dist/client-v2/pages/FileStoragePage.d.ts +10 -0
  17. package/dist/client-v2/plugin.d.ts +46 -0
  18. package/dist/client-v2/storageTypes/index.d.ts +10 -0
  19. package/dist/client-v2/storageTypes/types.d.ts +26 -0
  20. package/dist/externalVersion.js +11 -8
  21. package/dist/node_modules/@aws-sdk/client-s3/package.json +1 -1
  22. package/dist/node_modules/@aws-sdk/lib-storage/package.json +1 -1
  23. package/dist/node_modules/ali-oss/package.json +1 -1
  24. package/dist/node_modules/mime-match/package.json +1 -1
  25. package/dist/node_modules/mime-types/package.json +1 -1
  26. package/dist/node_modules/mkdirp/package.json +1 -1
  27. package/dist/node_modules/multer-cos/package.json +1 -1
  28. package/dist/node_modules/url-join/package.json +1 -1
  29. package/dist/shared/locale.d.ts +9 -0
  30. package/dist/shared/locale.js +36 -0
  31. package/dist/shared/previewer/filePreviewTypes.d.ts +41 -0
  32. package/dist/shared/previewer/filePreviewTypes.js +438 -0
  33. package/package.json +5 -2
@@ -0,0 +1,36 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var locale_exports = {};
28
+ __export(locale_exports, {
29
+ NAMESPACE: () => NAMESPACE
30
+ });
31
+ module.exports = __toCommonJS(locale_exports);
32
+ const NAMESPACE = "file-manager";
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ NAMESPACE
36
+ });
@@ -0,0 +1,41 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import React from 'react';
10
+ export interface FilePreviewerProps {
11
+ file: any;
12
+ index: number;
13
+ list: any[];
14
+ open?: boolean;
15
+ onOpenChange?: (open: boolean) => void;
16
+ onSwitchIndex?: (index: number) => void;
17
+ onClose?: () => void;
18
+ onDownload: (file: any) => void;
19
+ }
20
+ export interface FilePreviewType {
21
+ match(file: any): boolean;
22
+ getThumbnailURL?: (file: any) => string | null;
23
+ Previewer?: React.ComponentType<FilePreviewerProps>;
24
+ }
25
+ export declare class FilePreviewTypes {
26
+ types: FilePreviewType[];
27
+ add(type: FilePreviewType): void;
28
+ getTypeByFile(file: any): Omit<FilePreviewType, 'match'> | undefined;
29
+ }
30
+ export declare const filePreviewTypes: FilePreviewTypes;
31
+ export declare function normalizePreviewFile(file: any): any;
32
+ export declare function getPreviewFileUrl(file: any): any;
33
+ export declare function getFileUrl(file: any): any;
34
+ export declare function matchMimetype(file: any, type: string): any;
35
+ export declare const getFileExt: (file: any, url?: string) => string;
36
+ export declare const getFileName: (file: any, url?: string) => any;
37
+ export declare const getDownloadFileName: (file: any, url?: string) => string;
38
+ export declare const getFallbackIcon: (file: any, url?: string) => string;
39
+ export declare const getPreviewThumbnailUrl: (file: any) => string;
40
+ export declare const wrapWithModalPreviewer: (Previewer: React.ComponentType<FilePreviewerProps>) => (props: FilePreviewerProps) => React.JSX.Element;
41
+ export declare const FilePreviewRenderer: (props: FilePreviewerProps) => React.JSX.Element;
@@ -0,0 +1,438 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var filePreviewTypes_exports = {};
38
+ __export(filePreviewTypes_exports, {
39
+ FilePreviewRenderer: () => FilePreviewRenderer,
40
+ FilePreviewTypes: () => FilePreviewTypes,
41
+ filePreviewTypes: () => filePreviewTypes,
42
+ getDownloadFileName: () => getDownloadFileName,
43
+ getFallbackIcon: () => getFallbackIcon,
44
+ getFileExt: () => getFileExt,
45
+ getFileName: () => getFileName,
46
+ getFileUrl: () => getFileUrl,
47
+ getPreviewFileUrl: () => getPreviewFileUrl,
48
+ getPreviewThumbnailUrl: () => getPreviewThumbnailUrl,
49
+ matchMimetype: () => matchMimetype,
50
+ normalizePreviewFile: () => normalizePreviewFile,
51
+ wrapWithModalPreviewer: () => wrapWithModalPreviewer
52
+ });
53
+ module.exports = __toCommonJS(filePreviewTypes_exports);
54
+ var import_react = __toESM(require("react"));
55
+ var import_icons = require("@ant-design/icons");
56
+ var import_antd = require("antd");
57
+ var import_mime_match = __toESM(require("mime-match"));
58
+ var import_react_i18next = require("react-i18next");
59
+ var import_locale = require("../locale");
60
+ class FilePreviewTypes {
61
+ types = [];
62
+ add(type) {
63
+ this.types.unshift(type);
64
+ }
65
+ getTypeByFile(file) {
66
+ const normalized = normalizePreviewFile(file);
67
+ return this.types.find((type) => type.match(normalized));
68
+ }
69
+ }
70
+ const filePreviewTypes = new FilePreviewTypes();
71
+ function normalizePreviewFile(file) {
72
+ if (!file) {
73
+ return file;
74
+ }
75
+ if (typeof file === "string") {
76
+ return { url: file };
77
+ }
78
+ return file;
79
+ }
80
+ function getPreviewFileUrl(file) {
81
+ if (!file) {
82
+ return "";
83
+ }
84
+ if (typeof file === "string") {
85
+ return file;
86
+ }
87
+ return file.preview || file.url || "";
88
+ }
89
+ function getFileUrl(file) {
90
+ if (!file) {
91
+ return "";
92
+ }
93
+ if (typeof file === "string") {
94
+ return file;
95
+ }
96
+ return file.url || file.preview || "";
97
+ }
98
+ const FALLBACK_ICON_MAP = {
99
+ pdf: "/file-placeholder/pdf-200-200.png",
100
+ mp4: "/file-placeholder/video-200-200.png",
101
+ mov: "/file-placeholder/video-200-200.png",
102
+ avi: "/file-placeholder/video-200-200.png",
103
+ wmv: "/file-placeholder/video-200-200.png",
104
+ flv: "/file-placeholder/video-200-200.png",
105
+ mkv: "/file-placeholder/video-200-200.png",
106
+ mp3: "/file-placeholder/audio-200-200.png",
107
+ wav: "/file-placeholder/audio-200-200.png",
108
+ aac: "/file-placeholder/audio-200-200.png",
109
+ ogg: "/file-placeholder/audio-200-200.png",
110
+ doc: "/file-placeholder/docx-200-200.png",
111
+ docx: "/file-placeholder/docx-200-200.png",
112
+ odt: "/file-placeholder/docx-200-200.png",
113
+ xls: "/file-placeholder/xlsx-200-200.png",
114
+ xlsx: "/file-placeholder/xlsx-200-200.png",
115
+ csv: "/file-placeholder/xlsx-200-200.png",
116
+ ppt: "/file-placeholder/pptx-200-200.png",
117
+ pptx: "/file-placeholder/pptx-200-200.png",
118
+ jpg: "/file-placeholder/jpeg-200-200.png",
119
+ jpeg: "/file-placeholder/jpeg-200-200.png",
120
+ png: "/file-placeholder/png-200-200.png",
121
+ gif: "/file-placeholder/gif-200-200.png",
122
+ webp: "/file-placeholder/png-200-200.png",
123
+ bmp: "/file-placeholder/png-200-200.png",
124
+ svg: "/file-placeholder/svg-200-200.png",
125
+ default: "/file-placeholder/unknown-200-200.png"
126
+ };
127
+ const stripQueryAndHash = (url) => url.split("?")[0].split("#")[0];
128
+ const getExtFromName = (value) => {
129
+ if (!value) {
130
+ return "";
131
+ }
132
+ const clean = stripQueryAndHash(value);
133
+ const index = clean.lastIndexOf(".");
134
+ return index !== -1 ? clean.slice(index + 1).toLowerCase() : "";
135
+ };
136
+ const EXT_MIMETYPE_MAP = {
137
+ aac: "audio/aac",
138
+ avi: "video/x-msvideo",
139
+ bmp: "image/bmp",
140
+ csv: "text/csv",
141
+ doc: "application/msword",
142
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
143
+ flv: "video/x-flv",
144
+ gif: "image/gif",
145
+ jpeg: "image/jpeg",
146
+ jpg: "image/jpeg",
147
+ json: "application/json",
148
+ mkv: "video/x-matroska",
149
+ mov: "video/quicktime",
150
+ mp3: "audio/mpeg",
151
+ mp4: "video/mp4",
152
+ odt: "application/vnd.oasis.opendocument.text",
153
+ ogg: "audio/ogg",
154
+ pdf: "application/pdf",
155
+ png: "image/png",
156
+ ppt: "application/vnd.ms-powerpoint",
157
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
158
+ svg: "image/svg+xml",
159
+ txt: "text/plain",
160
+ wav: "audio/wav",
161
+ webp: "image/webp",
162
+ wmv: "video/x-ms-wmv",
163
+ xls: "application/vnd.ms-excel",
164
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
165
+ };
166
+ function matchMimetype(file, type) {
167
+ if (!file) {
168
+ return false;
169
+ }
170
+ if (file.originFileObj) {
171
+ return (0, import_mime_match.default)(file.type, type);
172
+ }
173
+ if (file.mimetype) {
174
+ return (0, import_mime_match.default)(file.mimetype, type);
175
+ }
176
+ if (file.url) {
177
+ return (0, import_mime_match.default)(EXT_MIMETYPE_MAP[getExtFromName(file.url)] || "", type);
178
+ }
179
+ return false;
180
+ }
181
+ const getNameFromUrl = (url) => {
182
+ if (!url) {
183
+ return "";
184
+ }
185
+ const clean = stripQueryAndHash(url);
186
+ const index = clean.lastIndexOf("/");
187
+ return index !== -1 ? clean.slice(index + 1) : clean;
188
+ };
189
+ const getFileExt = (file, url) => {
190
+ if (file && typeof file === "object") {
191
+ if (file.extname) {
192
+ return String(file.extname).replace(/^\./, "").toLowerCase();
193
+ }
194
+ const nameExt = getExtFromName(file.name || file.filename || file.title);
195
+ if (nameExt) {
196
+ return nameExt;
197
+ }
198
+ }
199
+ return getExtFromName(url);
200
+ };
201
+ const getFileName = (file, url) => {
202
+ const nameFromUrl = getNameFromUrl(url);
203
+ if (!file || typeof file === "string") {
204
+ return nameFromUrl;
205
+ }
206
+ return file.name || file.filename || file.title || nameFromUrl;
207
+ };
208
+ const getDownloadFileName = (file, url) => {
209
+ const resolvedUrl = url || getFileUrl(file);
210
+ let filename = getFileName(file, resolvedUrl);
211
+ const ext = getFileExt(file, resolvedUrl);
212
+ if (filename && ext && !filename.toLowerCase().endsWith(`.${ext}`)) {
213
+ filename = `${filename}.${ext}`;
214
+ }
215
+ return `${Date.now()}_${filename || "file"}`;
216
+ };
217
+ const getFallbackIcon = (file, url) => {
218
+ const ext = getFileExt(file, url);
219
+ return FALLBACK_ICON_MAP[ext] || FALLBACK_ICON_MAP.default;
220
+ };
221
+ const getPreviewThumbnailUrl = (file) => {
222
+ const previewFile = normalizePreviewFile(file);
223
+ const src = getPreviewFileUrl(previewFile);
224
+ const { getThumbnailURL } = filePreviewTypes.getTypeByFile(previewFile) ?? {};
225
+ const thumbnail = getThumbnailURL == null ? void 0 : getThumbnailURL(previewFile);
226
+ if (thumbnail) {
227
+ return thumbnail;
228
+ }
229
+ if (matchMimetype(previewFile, "image/*")) {
230
+ return "";
231
+ }
232
+ return getFallbackIcon(previewFile, src);
233
+ };
234
+ const renderModalFooter = (props) => {
235
+ const { index, list, onSwitchIndex, onDownload, file } = props;
236
+ const canPrev = typeof index === "number" && !!onSwitchIndex && index > 0;
237
+ const canNext = typeof index === "number" && !!onSwitchIndex && index < list.length - 1;
238
+ return /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { size: 14, style: { fontSize: "20px" } }, /* @__PURE__ */ import_react.default.createElement(
239
+ import_icons.LeftOutlined,
240
+ {
241
+ style: { cursor: canPrev ? "pointer" : "not-allowed" },
242
+ disabled: !canPrev,
243
+ onClick: () => canPrev && (onSwitchIndex == null ? void 0 : onSwitchIndex(index - 1))
244
+ }
245
+ ), /* @__PURE__ */ import_react.default.createElement(
246
+ import_icons.RightOutlined,
247
+ {
248
+ style: { cursor: canNext ? "pointer" : "not-allowed" },
249
+ disabled: !canNext,
250
+ onClick: () => canNext && (onSwitchIndex == null ? void 0 : onSwitchIndex(index + 1))
251
+ }
252
+ ), /* @__PURE__ */ import_react.default.createElement(import_icons.DownloadOutlined, { onClick: () => onDownload(file) }));
253
+ };
254
+ const wrapWithModalPreviewer = (Previewer) => {
255
+ return function WrappedPreviewer(props) {
256
+ const { open, onOpenChange, onClose, file } = props;
257
+ if (typeof open !== "boolean") {
258
+ return /* @__PURE__ */ import_react.default.createElement(Previewer, { ...props });
259
+ }
260
+ const title = getFileName(file, getFileUrl(file));
261
+ return /* @__PURE__ */ import_react.default.createElement(
262
+ import_antd.Modal,
263
+ {
264
+ open,
265
+ title,
266
+ onCancel: () => {
267
+ onOpenChange == null ? void 0 : onOpenChange(false);
268
+ onClose == null ? void 0 : onClose();
269
+ },
270
+ footer: renderModalFooter(props),
271
+ width: "90vw",
272
+ centered: true
273
+ },
274
+ /* @__PURE__ */ import_react.default.createElement(
275
+ "div",
276
+ {
277
+ style: {
278
+ maxWidth: "100%",
279
+ maxHeight: "calc(100vh - 256px)",
280
+ height: "80vh",
281
+ width: "100%",
282
+ background: "white",
283
+ display: "flex",
284
+ flexDirection: "column",
285
+ justifyContent: "center",
286
+ alignItems: "center",
287
+ overflowY: "auto"
288
+ }
289
+ },
290
+ /* @__PURE__ */ import_react.default.createElement(Previewer, { ...props })
291
+ )
292
+ );
293
+ };
294
+ };
295
+ const ImagePreviewer = (props) => {
296
+ const { file, list, index, open, onOpenChange, onSwitchIndex, onClose, onDownload } = props;
297
+ if (typeof open !== "boolean") {
298
+ return null;
299
+ }
300
+ const src = getFileUrl(file);
301
+ if (!src) {
302
+ return null;
303
+ }
304
+ const canPrev = typeof index === "number" && index > 0;
305
+ const canNext = typeof index === "number" && index < list.length - 1;
306
+ return /* @__PURE__ */ import_react.default.createElement(
307
+ import_antd.Image,
308
+ {
309
+ wrapperStyle: { display: "none" },
310
+ preview: {
311
+ visible: open,
312
+ onVisibleChange: (visible) => onOpenChange == null ? void 0 : onOpenChange(visible),
313
+ afterOpenChange: (visible) => {
314
+ if (!visible) {
315
+ onClose == null ? void 0 : onClose();
316
+ }
317
+ },
318
+ toolbarRender: (_, {
319
+ transform: { scale },
320
+ actions: { onFlipY, onFlipX, onRotateLeft, onRotateRight, onZoomOut, onZoomIn, onReset }
321
+ }) => /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { size: 14, className: "toolbar-wrapper", style: { fontSize: "20px" } }, /* @__PURE__ */ import_react.default.createElement(
322
+ import_icons.LeftOutlined,
323
+ {
324
+ style: { cursor: canPrev ? "pointer" : "not-allowed" },
325
+ disabled: !canPrev,
326
+ onClick: () => canPrev && (onSwitchIndex == null ? void 0 : onSwitchIndex(index - 1))
327
+ }
328
+ ), /* @__PURE__ */ import_react.default.createElement(
329
+ import_icons.RightOutlined,
330
+ {
331
+ style: { cursor: canNext ? "pointer" : "not-allowed" },
332
+ disabled: !canNext,
333
+ onClick: () => canNext && (onSwitchIndex == null ? void 0 : onSwitchIndex(index + 1))
334
+ }
335
+ ), onDownload ? /* @__PURE__ */ import_react.default.createElement(import_icons.DownloadOutlined, { onClick: () => onDownload(file) }) : null, /* @__PURE__ */ import_react.default.createElement(import_icons.SwapOutlined, { rotate: 90, onClick: onFlipY }), /* @__PURE__ */ import_react.default.createElement(import_icons.SwapOutlined, { onClick: onFlipX }), /* @__PURE__ */ import_react.default.createElement(import_icons.RotateLeftOutlined, { onClick: onRotateLeft }), /* @__PURE__ */ import_react.default.createElement(import_icons.RotateRightOutlined, { onClick: onRotateRight }), /* @__PURE__ */ import_react.default.createElement(import_icons.ZoomOutOutlined, { disabled: scale === 1, onClick: onZoomOut }), /* @__PURE__ */ import_react.default.createElement(import_icons.ZoomInOutlined, { disabled: scale === 50, onClick: onZoomIn }), /* @__PURE__ */ import_react.default.createElement(import_icons.UndoOutlined, { onClick: onReset }))
336
+ },
337
+ src
338
+ }
339
+ );
340
+ };
341
+ const IframePreviewer = ({ file }) => {
342
+ const src = getFileUrl(file);
343
+ if (!src) {
344
+ return null;
345
+ }
346
+ return /* @__PURE__ */ import_react.default.createElement("iframe", { src, width: "100%", height: "100%", style: { border: "none" } });
347
+ };
348
+ const AudioPreviewer = ({ file }) => {
349
+ const { t } = (0, import_react_i18next.useTranslation)();
350
+ const src = getFileUrl(file);
351
+ if (!src) {
352
+ return null;
353
+ }
354
+ return /* @__PURE__ */ import_react.default.createElement("audio", { controls: true }, /* @__PURE__ */ import_react.default.createElement("source", { src, type: (file == null ? void 0 : file.type) || (file == null ? void 0 : file.mimetype) }), t("Your browser does not support the audio tag."));
355
+ };
356
+ const VideoPreviewer = ({ file }) => {
357
+ const { t } = (0, import_react_i18next.useTranslation)();
358
+ const src = getFileUrl(file);
359
+ if (!src) {
360
+ return null;
361
+ }
362
+ return /* @__PURE__ */ import_react.default.createElement("video", { controls: true, width: "100%", height: "100%" }, /* @__PURE__ */ import_react.default.createElement("source", { src, type: (file == null ? void 0 : file.type) || (file == null ? void 0 : file.mimetype) }), t("Your browser does not support the video tag."));
363
+ };
364
+ const UnsupportedPreviewer = (props) => {
365
+ const { t } = (0, import_react_i18next.useTranslation)();
366
+ const { file } = props;
367
+ return /* @__PURE__ */ import_react.default.createElement(
368
+ import_antd.Alert,
369
+ {
370
+ type: "warning",
371
+ description: /* @__PURE__ */ import_react.default.createElement(import_react_i18next.Trans, { ns: import_locale.NAMESPACE }, "File type is not supported for previewing, please ", props.onDownload ? /* @__PURE__ */ import_react.default.createElement("a", { onClick: () => {
372
+ var _a;
373
+ return (_a = props.onDownload) == null ? void 0 : _a.call(props, file);
374
+ }, style: { textDecoration: "underline", cursor: "pointer" } }, "download it to preview") : /* @__PURE__ */ import_react.default.createElement("span", null, "download it to preview")),
375
+ showIcon: true
376
+ }
377
+ );
378
+ };
379
+ filePreviewTypes.add({
380
+ match() {
381
+ return true;
382
+ },
383
+ Previewer: wrapWithModalPreviewer(UnsupportedPreviewer)
384
+ });
385
+ filePreviewTypes.add({
386
+ match(file) {
387
+ return matchMimetype(file, "image/*");
388
+ },
389
+ getThumbnailURL(file) {
390
+ return getPreviewFileUrl(file);
391
+ },
392
+ Previewer: ImagePreviewer
393
+ });
394
+ filePreviewTypes.add({
395
+ match(file) {
396
+ return ["text/plain", "application/pdf", "application/json"].some((type) => matchMimetype(file, type));
397
+ },
398
+ Previewer: wrapWithModalPreviewer(IframePreviewer)
399
+ });
400
+ filePreviewTypes.add({
401
+ match(file) {
402
+ return matchMimetype(file, "audio/*");
403
+ },
404
+ Previewer: wrapWithModalPreviewer(AudioPreviewer)
405
+ });
406
+ filePreviewTypes.add({
407
+ match(file) {
408
+ return matchMimetype(file, "video/*");
409
+ },
410
+ Previewer: wrapWithModalPreviewer(VideoPreviewer)
411
+ });
412
+ const FilePreviewRenderer = (props) => {
413
+ const normalized = normalizePreviewFile(props.file);
414
+ if (!normalized) {
415
+ return null;
416
+ }
417
+ const { Previewer } = filePreviewTypes.getTypeByFile(normalized) ?? {};
418
+ if (!Previewer) {
419
+ return null;
420
+ }
421
+ return /* @__PURE__ */ import_react.default.createElement(Previewer, { ...props, file: normalized });
422
+ };
423
+ // Annotate the CommonJS export names for ESM import in node:
424
+ 0 && (module.exports = {
425
+ FilePreviewRenderer,
426
+ FilePreviewTypes,
427
+ filePreviewTypes,
428
+ getDownloadFileName,
429
+ getFallbackIcon,
430
+ getFileExt,
431
+ getFileName,
432
+ getFileUrl,
433
+ getPreviewFileUrl,
434
+ getPreviewThumbnailUrl,
435
+ matchMimetype,
436
+ normalizePreviewFile,
437
+ wrapWithModalPreviewer
438
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-file-manager",
3
- "version": "2.1.0-beta.27",
3
+ "version": "2.1.0-beta.30",
4
4
  "displayName": "File manager",
5
5
  "displayName.ru-RU": "Менеджер файлов",
6
6
  "displayName.zh-CN": "文件管理器",
@@ -46,8 +46,11 @@
46
46
  "peerDependencies": {
47
47
  "@nocobase/actions": "2.x",
48
48
  "@nocobase/client": "2.x",
49
+ "@nocobase/client-v2": "2.x",
49
50
  "@nocobase/database": "2.x",
51
+ "@nocobase/flow-engine": "2.x",
50
52
  "@nocobase/plugin-data-source-main": "2.x",
53
+ "@nocobase/plugin-environment-variables": "2.x",
51
54
  "@nocobase/server": "2.x",
52
55
  "@nocobase/test": "2.x",
53
56
  "@nocobase/utils": "2.x"
@@ -56,5 +59,5 @@
56
59
  "Collections",
57
60
  "Collection fields"
58
61
  ],
59
- "gitHead": "6d9e2d4ac3c6bf40951c8eb252860e47aa3a3c37"
62
+ "gitHead": "1a493069cd0d8a4f403668bfe592879678c894b2"
60
63
  }