@dxos/plugin-wnfs 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef
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/browser/{chunk-NCTUASHL.mjs → chunk-7KFJ6LYH.mjs} +36 -19
- 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/chunk-J5LGTIGS.mjs.map +7 -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 +22 -108
- 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 +4 -5
- 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 +1 -0
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/WnfsPlugin.node.d.ts +4 -0
- package/dist/types/src/WnfsPlugin.node.d.ts.map +1 -0
- package/dist/types/src/WnfsPlugin.test.d.ts +2 -0
- package/dist/types/src/WnfsPlugin.test.d.ts.map +1 -0
- package/dist/types/src/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +5 -0
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader.d.ts +6 -0
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +7 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +6 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- 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 +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- 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.map +1 -1
- package/dist/types/src/helpers/common.d.ts.map +1 -1
- package/dist/types/src/helpers/load.d.ts +1 -1
- 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 +3 -2
- package/dist/types/src/index.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 -15
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts +1 -1
- package/dist/types/src/types/File.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +1 -104
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +62 -37
- package/src/WnfsPlugin.node.ts +47 -0
- package/src/WnfsPlugin.test.ts +27 -0
- package/src/WnfsPlugin.tsx +40 -39
- package/src/blockstore.ts +1 -1
- package/src/capabilities/{blockstore/blockstore.ts → blockstore.ts} +4 -3
- package/src/capabilities/{file-uploader/file-uploader.ts → file-uploader.ts} +6 -5
- package/src/capabilities/index.ts +11 -5
- package/src/capabilities/markdown.ts +38 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +60 -0
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +5 -5
- 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/{components → containers/FileContainer}/FileContainer.tsx +12 -11
- package/src/containers/FileContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +9 -10
- package/src/extensions/image.tsx +2 -1
- package/src/helpers/load.ts +6 -6
- package/src/helpers/upload.ts +3 -3
- package/src/index.ts +8 -2
- package/src/meta.ts +1 -1
- 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 +13 -12
- package/src/types/File.ts +6 -2
- package/src/types/capabilities.ts +3 -3
- package/src/types/types.ts +3 -59
- package/dist/lib/browser/FileContainer-O5YFSIWV.mjs +0 -91
- package/dist/lib/browser/FileContainer-O5YFSIWV.mjs.map +0 -7
- package/dist/lib/browser/blockstore-KKFOALUH.mjs +0 -191
- package/dist/lib/browser/blockstore-KKFOALUH.mjs.map +0 -7
- package/dist/lib/browser/chunk-GXXEH7H6.mjs +0 -154
- package/dist/lib/browser/chunk-GXXEH7H6.mjs.map +0 -7
- package/dist/lib/browser/chunk-NCTUASHL.mjs.map +0 -7
- package/dist/lib/browser/file-uploader-BUHAXRSV.mjs +0 -34
- package/dist/lib/browser/file-uploader-BUHAXRSV.mjs.map +0 -7
- package/dist/lib/browser/markdown-BRT2MN6C.mjs +0 -201
- package/dist/lib/browser/markdown-BRT2MN6C.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-F6GUL54A.mjs +0 -99
- package/dist/lib/browser/operation-resolver-F6GUL54A.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UNAYSIAC.mjs +0 -81
- package/dist/lib/browser/react-surface-UNAYSIAC.mjs.map +0 -7
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts +0 -5
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +0 -1
- package/dist/types/src/capabilities/blockstore/index.d.ts +0 -3
- package/dist/types/src/capabilities/blockstore/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +0 -5
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +0 -1
- package/dist/types/src/capabilities/file-uploader/index.d.ts +0 -3
- package/dist/types/src/capabilities/file-uploader/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +0 -3
- package/dist/types/src/capabilities/markdown/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/markdown.d.ts +0 -5
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/FileContainer.d.ts +0 -7
- 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/src/capabilities/blockstore/index.ts +0 -7
- package/src/capabilities/file-uploader/index.ts +0 -7
- package/src/capabilities/markdown/index.ts +0 -7
- package/src/capabilities/markdown/markdown.ts +0 -33
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -62
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -49
- package/src/components/FilePreview.tsx +0 -23
- /package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +0 -0
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
|
|
7
|
-
import { Capability } from '@dxos/app-framework';
|
|
8
|
-
import { MarkdownCapabilities } from '@dxos/plugin-markdown';
|
|
9
|
-
import { getSpace } from '@dxos/react-client/echo';
|
|
10
|
-
|
|
11
|
-
import { image } from '../../extensions';
|
|
12
|
-
import { WnfsCapabilities } from '../../types';
|
|
13
|
-
|
|
14
|
-
export default Capability.makeModule(
|
|
15
|
-
Effect.fnUntraced(function* () {
|
|
16
|
-
// Get context for lazy capability access in callbacks.
|
|
17
|
-
const capabilities = yield* Capability.Service;
|
|
18
|
-
|
|
19
|
-
return Capability.contributes(MarkdownCapabilities.Extensions, [
|
|
20
|
-
({ document }: { document?: any }) => {
|
|
21
|
-
const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
|
|
22
|
-
const instances = capabilities.get(WnfsCapabilities.Instances);
|
|
23
|
-
|
|
24
|
-
if (document) {
|
|
25
|
-
const space = getSpace(document);
|
|
26
|
-
return space ? [image({ blockstore, instances, space })] : [];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return [];
|
|
30
|
-
},
|
|
31
|
-
]);
|
|
32
|
-
}),
|
|
33
|
-
);
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
|
|
7
|
-
import { Capability, Common } from '@dxos/app-framework';
|
|
8
|
-
import { Obj, Ref, Type } from '@dxos/echo';
|
|
9
|
-
import { invariant } from '@dxos/invariant';
|
|
10
|
-
import { OperationResolver } from '@dxos/operation';
|
|
11
|
-
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
12
|
-
import { Collection } from '@dxos/schema';
|
|
13
|
-
|
|
14
|
-
import { upload } from '../../helpers';
|
|
15
|
-
import { WnfsCapabilities, WnfsFile, WnfsOperation } from '../../types';
|
|
16
|
-
|
|
17
|
-
export default Capability.makeModule(
|
|
18
|
-
Effect.fnUntraced(function* () {
|
|
19
|
-
return Capability.contributes(Common.Capability.OperationResolver, [
|
|
20
|
-
OperationResolver.make({
|
|
21
|
-
operation: WnfsOperation.OnCreateSpace,
|
|
22
|
-
handler: Effect.fnUntraced(function* ({ rootCollection }) {
|
|
23
|
-
const collection = Collection.makeManaged({ key: Type.getTypename(WnfsFile.File) });
|
|
24
|
-
Obj.change(rootCollection, (c) => {
|
|
25
|
-
c.objects.push(Ref.make(collection));
|
|
26
|
-
});
|
|
27
|
-
}),
|
|
28
|
-
}),
|
|
29
|
-
OperationResolver.make({
|
|
30
|
-
operation: WnfsOperation.Create,
|
|
31
|
-
handler: ({ name, type, cid }) =>
|
|
32
|
-
Effect.succeed({
|
|
33
|
-
object: WnfsFile.make({ name, type, cid }),
|
|
34
|
-
}),
|
|
35
|
-
}),
|
|
36
|
-
OperationResolver.make({
|
|
37
|
-
operation: WnfsOperation.Upload,
|
|
38
|
-
handler: Effect.fnUntraced(function* ({ file, db }) {
|
|
39
|
-
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
40
|
-
const blockstore = yield* Capability.get(WnfsCapabilities.Blockstore);
|
|
41
|
-
const space = client.spaces.get(db.spaceId);
|
|
42
|
-
invariant(space, 'Space not found');
|
|
43
|
-
const info = yield* Effect.promise(() => upload({ file, blockstore, space }));
|
|
44
|
-
return info;
|
|
45
|
-
}),
|
|
46
|
-
}),
|
|
47
|
-
OperationResolver.make({
|
|
48
|
-
operation: WnfsOperation.CreateFile,
|
|
49
|
-
handler: Effect.fnUntraced(function* ({ file, db }) {
|
|
50
|
-
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
51
|
-
const blockstore = yield* Capability.get(WnfsCapabilities.Blockstore);
|
|
52
|
-
const space = client.spaces.get(db.spaceId);
|
|
53
|
-
invariant(space, 'Space not found');
|
|
54
|
-
const info = yield* Effect.promise(() => upload({ file, blockstore, space }));
|
|
55
|
-
return {
|
|
56
|
-
object: WnfsFile.make({ name: info.name, type: info.type, cid: info.cid }),
|
|
57
|
-
};
|
|
58
|
-
}),
|
|
59
|
-
}),
|
|
60
|
-
]);
|
|
61
|
-
}),
|
|
62
|
-
);
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
import type * as Schema from 'effect/Schema';
|
|
7
|
-
import React, { useCallback } from 'react';
|
|
8
|
-
|
|
9
|
-
import { Capability, Common } from '@dxos/app-framework';
|
|
10
|
-
import { Obj } from '@dxos/echo';
|
|
11
|
-
import { findAnnotation } from '@dxos/effect';
|
|
12
|
-
import { type FormFieldComponentProps } from '@dxos/react-ui-form';
|
|
13
|
-
|
|
14
|
-
import { FileContainer, FileInput } from '../../components';
|
|
15
|
-
import { meta } from '../../meta';
|
|
16
|
-
import { WnfsAction, WnfsFile } from '../../types';
|
|
17
|
-
|
|
18
|
-
export default Capability.makeModule(() =>
|
|
19
|
-
Effect.succeed(
|
|
20
|
-
Capability.contributes(Common.Capability.ReactSurface, [
|
|
21
|
-
Common.createSurface({
|
|
22
|
-
id: `${meta.id}/article`,
|
|
23
|
-
role: ['article', 'section', 'slide'],
|
|
24
|
-
filter: (data): data is { subject: WnfsFile.File } => Obj.instanceOf(WnfsFile.File, data.subject),
|
|
25
|
-
component: ({ data, role }) => <FileContainer role={role} subject={data.subject} />,
|
|
26
|
-
}),
|
|
27
|
-
Common.createSurface({
|
|
28
|
-
id: `${meta.id}/create-form`,
|
|
29
|
-
role: 'form-input',
|
|
30
|
-
filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
|
|
31
|
-
const annotation = findAnnotation<boolean>(
|
|
32
|
-
(data.schema as Schema.Schema.All).ast,
|
|
33
|
-
WnfsAction.UploadAnnotationId,
|
|
34
|
-
);
|
|
35
|
-
return !!annotation;
|
|
36
|
-
},
|
|
37
|
-
component: ({ data: { schema }, ...props }) => {
|
|
38
|
-
const inputProps = props as unknown as FormFieldComponentProps;
|
|
39
|
-
const handleChange = useCallback(
|
|
40
|
-
(file: File) => inputProps.onValueChange?.(inputProps.type, file),
|
|
41
|
-
[inputProps.type, inputProps.onValueChange],
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return <FileInput schema={schema} onChange={handleChange} />;
|
|
45
|
-
},
|
|
46
|
-
}),
|
|
47
|
-
]),
|
|
48
|
-
),
|
|
49
|
-
);
|
|
@@ -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/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('is-full bs-full object-contain', classNames)} src={url} />;
|
|
18
|
-
} else if (type.startsWith('video/')) {
|
|
19
|
-
return <video className={mx('is-full bs-full object-contain', classNames)} src={url} controls />;
|
|
20
|
-
} else {
|
|
21
|
-
return <iframe className={mx('is-full bs-full overflow-auto', classNames)} src={url} />;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
File without changes
|