@dxos/plugin-wnfs 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33
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/README.md +1 -1
- package/dist/lib/browser/chunk-4D4K5JCC.mjs +66 -0
- package/dist/lib/browser/chunk-4D4K5JCC.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-CGW32EZB.mjs → browser/chunk-7KFJ6LYH.mjs} +44 -21
- package/dist/lib/browser/chunk-7KFJ6LYH.mjs.map +7 -0
- package/dist/lib/browser/chunk-DK62NQ5T.mjs +71 -0
- package/dist/lib/browser/chunk-DK62NQ5T.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/create-QRLX4IMZ.mjs +25 -0
- package/dist/lib/browser/create-QRLX4IMZ.mjs.map +7 -0
- package/dist/lib/browser/create-file-INAT56PX.mjs +42 -0
- package/dist/lib/browser/create-file-INAT56PX.mjs.map +7 -0
- package/dist/lib/browser/helpers/index.mjs +26 -0
- package/dist/lib/browser/helpers/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +79 -103
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +14 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/translations.mjs +30 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +8 -6
- package/dist/lib/browser/upload-ZQI66T4Y.mjs +35 -0
- package/dist/lib/browser/upload-ZQI66T4Y.mjs.map +7 -0
- package/dist/types/src/WnfsPlugin.d.ts +2 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +3 -2
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +4 -2
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +4 -2
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +1 -1
- package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
- package/dist/types/src/components/FileInput/index.d.ts +2 -0
- package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts +12 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/index.d.ts +2 -0
- package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FileContainer/index.d.ts +2 -0
- package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/image.d.ts +1 -1
- package/dist/types/src/extensions/image.d.ts.map +1 -1
- package/dist/types/src/extensions/image.stories.d.ts +5 -4
- package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
- package/dist/types/src/helpers/common.d.ts.map +1 -1
- package/dist/types/src/helpers/load.d.ts +2 -2
- package/dist/types/src/helpers/load.d.ts.map +1 -1
- package/dist/types/src/helpers/upload.d.ts +1 -1
- package/dist/types/src/helpers/upload.d.ts.map +1 -1
- package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-file.d.ts +5 -0
- package/dist/types/src/operations/create-file.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +38 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/upload.d.ts +5 -0
- package/dist/types/src/operations/upload.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +24 -10
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts +16 -0
- package/dist/types/src/types/File.d.ts.map +1 -0
- package/dist/types/src/{capabilities → types}/capabilities.d.ts +3 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +4 -46
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +73 -47
- package/src/WnfsPlugin.tsx +66 -85
- package/src/blockstore.ts +3 -3
- package/src/capabilities/blockstore.ts +15 -10
- package/src/capabilities/file-uploader.ts +25 -15
- package/src/capabilities/index.ts +10 -8
- package/src/capabilities/markdown.ts +25 -12
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +50 -35
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +8 -8
- package/src/components/FileInput/index.ts +5 -0
- package/src/components/FilePreview/FilePreview.tsx +43 -0
- package/src/components/FilePreview/index.ts +5 -0
- package/src/components/index.ts +1 -4
- package/src/containers/FileContainer/FileContainer.tsx +57 -0
- package/src/containers/FileContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +22 -19
- package/src/extensions/image.tsx +10 -9
- package/src/helpers/load.ts +14 -8
- package/src/helpers/upload.ts +6 -2
- package/src/index.ts +1 -1
- package/src/meta.ts +9 -6
- package/src/operations/create-file.ts +31 -0
- package/src/operations/create.ts +22 -0
- package/src/operations/definitions.ts +41 -0
- package/src/operations/index.ts +13 -0
- package/src/operations/upload.ts +29 -0
- package/src/translations.ts +14 -8
- package/src/types/File.ts +28 -0
- package/src/{capabilities → types}/capabilities.ts +4 -4
- package/src/types/index.ts +2 -1
- package/src/types/types.ts +3 -19
- package/dist/lib/browser/FileContainer-Q4GUPBVD.mjs +0 -107
- package/dist/lib/browser/FileContainer-Q4GUPBVD.mjs.map +0 -7
- package/dist/lib/browser/blockstore-KQO2NTVM.mjs +0 -191
- package/dist/lib/browser/blockstore-KQO2NTVM.mjs.map +0 -7
- package/dist/lib/browser/chunk-BANMVVJV.mjs +0 -16
- package/dist/lib/browser/chunk-BANMVVJV.mjs.map +0 -7
- package/dist/lib/browser/chunk-GVBV2QWA.mjs +0 -64
- package/dist/lib/browser/chunk-GVBV2QWA.mjs.map +0 -7
- package/dist/lib/browser/chunk-KZANQHJY.mjs +0 -16
- package/dist/lib/browser/chunk-KZANQHJY.mjs.map +0 -7
- package/dist/lib/browser/chunk-VDDGZWAY.mjs +0 -15
- package/dist/lib/browser/chunk-VDDGZWAY.mjs.map +0 -7
- package/dist/lib/browser/chunk-VRRXG6IB.mjs +0 -159
- package/dist/lib/browser/chunk-VRRXG6IB.mjs.map +0 -7
- package/dist/lib/browser/file-uploader-JA55DPMW.mjs +0 -29
- package/dist/lib/browser/file-uploader-JA55DPMW.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-YM6QRFIH.mjs +0 -49
- package/dist/lib/browser/intent-resolver-YM6QRFIH.mjs.map +0 -7
- package/dist/lib/browser/markdown-6VH477GB.mjs +0 -196
- package/dist/lib/browser/markdown-6VH477GB.mjs.map +0 -7
- package/dist/lib/browser/react-surface-XAHVMWIH.mjs +0 -88
- package/dist/lib/browser/react-surface-XAHVMWIH.mjs.map +0 -7
- package/dist/lib/node-esm/FileContainer-22IPNDDA.mjs +0 -108
- package/dist/lib/node-esm/FileContainer-22IPNDDA.mjs.map +0 -7
- package/dist/lib/node-esm/blockstore-7KQTFHK5.mjs +0 -192
- package/dist/lib/node-esm/blockstore-7KQTFHK5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-47QYKNA6.mjs +0 -17
- package/dist/lib/node-esm/chunk-47QYKNA6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BM37ZAHF.mjs +0 -65
- package/dist/lib/node-esm/chunk-BM37ZAHF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CGW32EZB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DWYM7FD7.mjs +0 -18
- package/dist/lib/node-esm/chunk-DWYM7FD7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YTWL64Z6.mjs +0 -17
- package/dist/lib/node-esm/chunk-YTWL64Z6.mjs.map +0 -7
- package/dist/lib/node-esm/file-uploader-WGDG2YV5.mjs +0 -30
- package/dist/lib/node-esm/file-uploader-WGDG2YV5.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -117
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-5QOT2SLD.mjs +0 -50
- package/dist/lib/node-esm/intent-resolver-5QOT2SLD.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-R4PBXDJO.mjs +0 -197
- package/dist/lib/node-esm/markdown-R4PBXDJO.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-HAOUJUXJ.mjs +0 -89
- package/dist/lib/node-esm/react-surface-HAOUJUXJ.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -11
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/FileContainer.d.ts +0 -9
- package/dist/types/src/components/FileContainer.d.ts.map +0 -1
- package/dist/types/src/components/FileInput.d.ts.map +0 -1
- package/dist/types/src/components/FilePreview.d.ts +0 -11
- package/dist/types/src/components/FilePreview.d.ts.map +0 -1
- package/dist/types/src/types/file.d.ts +0 -16
- package/dist/types/src/types/file.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -32
- package/src/components/FileContainer.tsx +0 -51
- package/src/components/FilePreview.tsx +0 -23
- package/src/types/file.ts +0 -17
- /package/dist/lib/{node-esm/types/index.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/capabilities.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAGjE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,yBAAiB,gBAAgB,CAAC;IACzB,MAAM,UAAU,wFAAuE,CAAC;IAE/F,KAAY,SAAS,GAAG,MAAM,CAAC,OAAO,EAAE;QAAE,SAAS,EAAE,gBAAgB,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;IACzF,MAAM,SAAS,uDAAqE,CAAC;CAC7F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent-resolver.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/intent-resolver.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,YAAY,EAAkB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;yBAOpF,SAAS,aAAa;AAAtC,wBAoBK"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type FileType } from '../types';
|
|
3
|
-
export type FileContainerProps = {
|
|
4
|
-
role: string;
|
|
5
|
-
file: FileType;
|
|
6
|
-
};
|
|
7
|
-
export declare const FileContainer: ({ role, file }: FileContainerProps) => React.JSX.Element | null;
|
|
8
|
-
export default FileContainer;
|
|
9
|
-
//# sourceMappingURL=FileContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/FileContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAUnD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,gBAAgB,kBAAkB,6BA2B/D,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../../src/components/FileInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAsB,MAAM,OAAO,CAAC;AAU3C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,sBAAsB,cAAc,sBA0B7D,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
3
|
-
export type FilePreviewProps = ThemedClassName<{
|
|
4
|
-
type: string;
|
|
5
|
-
url: string;
|
|
6
|
-
}>;
|
|
7
|
-
/**
|
|
8
|
-
* File/content preview iframe.
|
|
9
|
-
*/
|
|
10
|
-
export declare const FilePreview: ({ type, url, classNames }: FilePreviewProps) => React.JSX.Element;
|
|
11
|
-
//# sourceMappingURL=FilePreview.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../src/components/FilePreview.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,2BAA2B,gBAAgB,sBAQtE,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
declare const FileType_base: import("@dxos/echo-schema").TypedObjectPrototype<import("@dxos/echo-schema").TypedObjectFields<{
|
|
3
|
-
name: Schema.optional<typeof Schema.String>;
|
|
4
|
-
type: typeof Schema.String;
|
|
5
|
-
cid: typeof Schema.String;
|
|
6
|
-
timestamp: Schema.optional<typeof Schema.String>;
|
|
7
|
-
}, import("@dxos/echo-schema").TypedObjectOptions>, Schema.Struct.Encoded<{
|
|
8
|
-
name: Schema.optional<typeof Schema.String>;
|
|
9
|
-
type: typeof Schema.String;
|
|
10
|
-
cid: typeof Schema.String;
|
|
11
|
-
timestamp: Schema.optional<typeof Schema.String>;
|
|
12
|
-
}>>;
|
|
13
|
-
export declare class FileType extends FileType_base {
|
|
14
|
-
}
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../src/types/file.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;;;;;;;AAIhC,qBAAa,QAAS,SAAQ,aAQ5B;CAAG"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { contributes, Capabilities, createResolver, type PluginContext } from '@dxos/app-framework';
|
|
6
|
-
import { Obj } from '@dxos/echo';
|
|
7
|
-
|
|
8
|
-
import { WnfsCapabilities } from './capabilities';
|
|
9
|
-
import { upload } from '../helpers';
|
|
10
|
-
import { FileType, WnfsAction } from '../types';
|
|
11
|
-
|
|
12
|
-
export default (context: PluginContext) =>
|
|
13
|
-
contributes(Capabilities.IntentResolver, [
|
|
14
|
-
// TODO(wittjosiah): Deleting the object doesn't delete the wnfs blob.
|
|
15
|
-
// Consider ways to trigger blob deletion based on object deletion and/or adding file system manager.
|
|
16
|
-
createResolver({
|
|
17
|
-
intent: WnfsAction.Create,
|
|
18
|
-
resolve: ({ name, type, cid }) => ({
|
|
19
|
-
data: {
|
|
20
|
-
object: Obj.make(FileType, { name, type, cid }),
|
|
21
|
-
},
|
|
22
|
-
}),
|
|
23
|
-
}),
|
|
24
|
-
createResolver({
|
|
25
|
-
intent: WnfsAction.Upload,
|
|
26
|
-
resolve: async ({ file, space }) => {
|
|
27
|
-
const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
|
|
28
|
-
const info = await upload({ file, blockstore, space });
|
|
29
|
-
return { data: info };
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
]);
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { useCapability } from '@dxos/app-framework';
|
|
8
|
-
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import { getSpace } from '@dxos/react-client/echo';
|
|
10
|
-
import { StackItem } from '@dxos/react-ui-stack';
|
|
11
|
-
|
|
12
|
-
import { FilePreview } from './FilePreview';
|
|
13
|
-
import { WnfsCapabilities } from '../capabilities';
|
|
14
|
-
import { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../helpers';
|
|
15
|
-
import { type FileType } from '../types';
|
|
16
|
-
|
|
17
|
-
export type FileContainerProps = {
|
|
18
|
-
role: string;
|
|
19
|
-
file: FileType;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const FileContainer = ({ role, file }: FileContainerProps) => {
|
|
23
|
-
const blockstore = useCapability(WnfsCapabilities.Blockstore);
|
|
24
|
-
const instances = useCapability(WnfsCapabilities.Instances);
|
|
25
|
-
const [blobUrl, setBlobUrl] = useState<string>();
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
const timeout = setTimeout(async () => {
|
|
29
|
-
const space = getSpace(file);
|
|
30
|
-
invariant(space);
|
|
31
|
-
const { directory, forest } = await loadWnfs({ blockstore, instances, space });
|
|
32
|
-
const path = filePath(file.cid.toString(), space);
|
|
33
|
-
const url = await getBlobUrl({ wnfsUrl: wnfsUrl(path), blockstore, directory, forest, type: file.type });
|
|
34
|
-
setBlobUrl(url);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return () => clearTimeout(timeout);
|
|
38
|
-
}, [file]);
|
|
39
|
-
|
|
40
|
-
if (!blobUrl) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<StackItem.Content role={role}>
|
|
46
|
-
<FilePreview type={file.type} url={blobUrl} />
|
|
47
|
-
</StackItem.Content>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default FileContainer;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
-
|
|
10
|
-
export type FilePreviewProps = ThemedClassName<{ type: string; url: string }>;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* File/content preview iframe.
|
|
14
|
-
*/
|
|
15
|
-
export const FilePreview = ({ type, url, classNames }: FilePreviewProps) => {
|
|
16
|
-
if (type.startsWith('image/')) {
|
|
17
|
-
return <img className={mx('w-full h-full object-contain', classNames)} src={url} />;
|
|
18
|
-
} else if (type.startsWith('video/')) {
|
|
19
|
-
return <video className={mx('w-full h-full object-contain', classNames)} src={url} controls />;
|
|
20
|
-
} else {
|
|
21
|
-
return <iframe className={mx('w-full h-full overflow-auto', classNames)} src={url} />;
|
|
22
|
-
}
|
|
23
|
-
};
|
package/src/types/file.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { TypedObject } from '@dxos/echo-schema';
|
|
8
|
-
|
|
9
|
-
export class FileType extends TypedObject({
|
|
10
|
-
typename: 'dxos.org/type/File',
|
|
11
|
-
version: '0.1.0',
|
|
12
|
-
})({
|
|
13
|
-
name: Schema.optional(Schema.String),
|
|
14
|
-
type: Schema.String,
|
|
15
|
-
cid: Schema.String,
|
|
16
|
-
timestamp: Schema.optional(Schema.String),
|
|
17
|
-
}) {}
|
|
File without changes
|