@dxos/plugin-wnfs 0.8.4-main.67995b8 → 0.8.4-main.6fa680abb7
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/lib/browser/FileContainer-MPHQF5UK.mjs +72 -0
- package/dist/lib/browser/FileContainer-MPHQF5UK.mjs.map +7 -0
- package/dist/lib/browser/{blockstore-KQO2NTVM.mjs → blockstore-FZHYPYGC.mjs} +19 -19
- package/dist/lib/browser/blockstore-FZHYPYGC.mjs.map +7 -0
- package/dist/lib/browser/chunk-KVFGUEQD.mjs +56 -0
- package/dist/lib/browser/chunk-KVFGUEQD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VRRXG6IB.mjs → chunk-UC4HMNZZ.mjs} +24 -14
- package/dist/lib/browser/chunk-UC4HMNZZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-YU2LIVB5.mjs +136 -0
- package/dist/lib/browser/chunk-YU2LIVB5.mjs.map +7 -0
- package/dist/lib/browser/file-uploader-FPEN2ZIO.mjs +35 -0
- package/dist/lib/browser/file-uploader-FPEN2ZIO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +81 -86
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{markdown-6VH477GB.mjs → markdown-5WOMJPEH.mjs} +31 -26
- package/dist/lib/browser/markdown-5WOMJPEH.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-ZU5F3K5U.mjs +86 -0
- package/dist/lib/browser/operation-resolver-ZU5F3K5U.mjs.map +7 -0
- package/dist/lib/browser/react-surface-2DTU3HUO.mjs +60 -0
- package/dist/lib/browser/react-surface-2DTU3HUO.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +9 -6
- package/dist/types/src/WnfsPlugin.d.ts +2 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts +5 -0
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +1 -0
- package/dist/types/src/capabilities/blockstore/index.d.ts +3 -0
- package/dist/types/src/capabilities/blockstore/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +6 -0
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader/index.d.ts +3 -0
- package/dist/types/src/capabilities/file-uploader/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
- package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- 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.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 +3 -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/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/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/translations.d.ts +7 -3
- 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 +88 -47
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +46 -40
- package/src/WnfsPlugin.tsx +53 -81
- package/src/blockstore.ts +3 -3
- package/src/capabilities/blockstore/blockstore.ts +22 -0
- package/src/capabilities/blockstore/index.ts +7 -0
- package/src/capabilities/file-uploader/file-uploader.ts +34 -0
- package/src/capabilities/file-uploader/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/markdown/index.ts +7 -0
- package/src/capabilities/markdown/markdown.ts +33 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +51 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +51 -0
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +7 -7
- package/src/components/FileInput/index.ts +5 -0
- package/src/components/{FilePreview.tsx → FilePreview/FilePreview.tsx} +1 -1
- package/src/components/FilePreview/index.ts +5 -0
- package/src/components/index.ts +1 -4
- package/src/containers/FileContainer/FileContainer.tsx +56 -0
- package/src/containers/FileContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +18 -14
- package/src/extensions/image.tsx +9 -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/translations.ts +7 -3
- package/src/types/File.ts +24 -0
- package/src/{capabilities → types}/capabilities.ts +4 -4
- package/src/types/index.ts +2 -1
- package/src/types/types.ts +44 -18
- package/dist/lib/browser/FileContainer-6P2SYTVH.mjs +0 -105
- package/dist/lib/browser/FileContainer-6P2SYTVH.mjs.map +0 -7
- package/dist/lib/browser/blockstore-KQO2NTVM.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.map +0 -7
- package/dist/lib/browser/chunk-WTYTESSC.mjs +0 -16
- package/dist/lib/browser/chunk-WTYTESSC.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.map +0 -7
- package/dist/lib/browser/react-surface-NOSB5MZ2.mjs +0 -88
- package/dist/lib/browser/react-surface-NOSB5MZ2.mjs.map +0 -7
- package/dist/types/src/capabilities/blockstore.d.ts +0 -4
- package/dist/types/src/capabilities/blockstore.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +0 -4
- package/dist/types/src/capabilities/file-uploader.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/capabilities/markdown.d.ts +0 -4
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.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.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/blockstore.ts +0 -18
- package/src/capabilities/file-uploader.ts +0 -24
- package/src/capabilities/intent-resolver.ts +0 -32
- package/src/capabilities/markdown.ts +0 -25
- package/src/capabilities/react-surface.tsx +0 -45
- package/src/components/FileContainer.tsx +0 -51
- package/src/types/file.ts +0 -17
- /package/dist/types/src/components/{FilePreview.d.ts → FilePreview/FilePreview.d.ts} +0 -0
|
@@ -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,25 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { contributes, type PluginContext } from '@dxos/app-framework';
|
|
6
|
-
import { MarkdownCapabilities } from '@dxos/plugin-markdown';
|
|
7
|
-
import { getSpace } from '@dxos/react-client/echo';
|
|
8
|
-
|
|
9
|
-
import { WnfsCapabilities } from './capabilities';
|
|
10
|
-
import { image } from '../extensions';
|
|
11
|
-
|
|
12
|
-
export default (context: PluginContext) =>
|
|
13
|
-
contributes(MarkdownCapabilities.Extensions, [
|
|
14
|
-
({ document }) => {
|
|
15
|
-
const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
|
|
16
|
-
const instances = context.getCapability(WnfsCapabilities.Instances);
|
|
17
|
-
|
|
18
|
-
if (document) {
|
|
19
|
-
const space = getSpace(document);
|
|
20
|
-
return space ? [image({ blockstore, instances, space })] : [];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return [];
|
|
24
|
-
},
|
|
25
|
-
]);
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Schema } from 'effect';
|
|
6
|
-
import React, { useCallback } from 'react';
|
|
7
|
-
|
|
8
|
-
import { contributes, Capabilities, createSurface } from '@dxos/app-framework';
|
|
9
|
-
import { Obj } from '@dxos/echo';
|
|
10
|
-
import { findAnnotation } from '@dxos/effect';
|
|
11
|
-
import { type InputProps } from '@dxos/react-ui-form';
|
|
12
|
-
|
|
13
|
-
import { FileContainer, FileInput } from '../components';
|
|
14
|
-
import { WNFS_PLUGIN } from '../meta';
|
|
15
|
-
import { FileType, WnfsAction } from '../types';
|
|
16
|
-
|
|
17
|
-
export default () =>
|
|
18
|
-
contributes(Capabilities.ReactSurface, [
|
|
19
|
-
createSurface({
|
|
20
|
-
id: `${WNFS_PLUGIN}/article`,
|
|
21
|
-
role: ['article', 'section', 'slide'],
|
|
22
|
-
filter: (data): data is { subject: FileType } => Obj.instanceOf(FileType, data.subject),
|
|
23
|
-
component: ({ data, role }) => <FileContainer role={role} file={data.subject} />,
|
|
24
|
-
}),
|
|
25
|
-
createSurface({
|
|
26
|
-
id: `${WNFS_PLUGIN}/create-form`,
|
|
27
|
-
role: 'form-input',
|
|
28
|
-
filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
|
|
29
|
-
const annotation = findAnnotation<boolean>(
|
|
30
|
-
(data.schema as Schema.Schema.All).ast,
|
|
31
|
-
WnfsAction.UploadAnnotationId,
|
|
32
|
-
);
|
|
33
|
-
return !!annotation;
|
|
34
|
-
},
|
|
35
|
-
component: ({ data: { prop, schema }, ...props }) => {
|
|
36
|
-
const inputProps = props as unknown as InputProps;
|
|
37
|
-
const handleChange = useCallback(
|
|
38
|
-
(file: File) => inputProps.onValueChange?.('object', file),
|
|
39
|
-
[prop, inputProps.onValueChange],
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
return <FileInput schema={schema} onChange={handleChange} />;
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
]);
|
|
@@ -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 = ({ 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>
|
|
46
|
-
<FilePreview type={file.type} url={blobUrl} />
|
|
47
|
-
</StackItem.Content>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default FileContainer;
|
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
|