@dxos/plugin-wnfs 0.8.4-main.fcfe5033a5 → 0.8.4-staging.60fe92afc8
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/LICENSE +102 -5
- package/PLUGIN.mdl +371 -0
- package/README.md +2 -2
- package/dist/lib/neutral/WnfsPlugin.mjs +51 -0
- package/dist/lib/neutral/WnfsPlugin.mjs.map +7 -0
- package/dist/lib/neutral/WnfsPlugin.node.mjs +12 -0
- package/dist/lib/neutral/WnfsPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/WnfsPlugin.workerd.mjs +12 -0
- package/dist/lib/neutral/WnfsPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/backend-4HPTHS33.mjs +47 -0
- package/dist/lib/neutral/backend-4HPTHS33.mjs.map +7 -0
- package/dist/lib/neutral/blockstore-U6SPNL2C.mjs +190 -0
- package/dist/lib/neutral/blockstore-U6SPNL2C.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +13 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-KUQHRT52.mjs +39 -0
- package/dist/lib/neutral/chunk-KUQHRT52.mjs.map +7 -0
- package/dist/lib/{browser/chunk-N6Y4QPNF.mjs → neutral/chunk-L33MOD23.mjs} +97 -28
- package/dist/lib/neutral/chunk-L33MOD23.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QODCKFTY.mjs +19 -0
- package/dist/lib/neutral/chunk-QODCKFTY.mjs.map +7 -0
- package/dist/lib/neutral/helpers/index.mjs +26 -0
- package/dist/lib/neutral/helpers/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +36 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +12 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +17 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +8 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/neutral/url-resolver-BIRH7WHL.mjs +47 -0
- package/dist/lib/neutral/url-resolver-BIRH7WHL.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/WnfsPlugin.workerd.d.ts +4 -0
- package/dist/types/src/WnfsPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/annotations.d.ts +7 -0
- package/dist/types/src/annotations.d.ts.map +1 -0
- package/dist/types/src/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/backend.d.ts +7 -0
- package/dist/types/src/capabilities/backend.d.ts.map +1 -0
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/url-resolver.d.ts +7 -0
- package/dist/types/src/capabilities/url-resolver.d.ts.map +1 -0
- package/dist/types/src/helpers/common.d.ts.map +1 -1
- package/dist/types/src/helpers/load.d.ts.map +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/meta.d.ts +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +2 -16
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/WnfsCapabilities.d.ts +11 -0
- package/dist/types/src/types/WnfsCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -3
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +74 -61
- package/src/WnfsPlugin.node.ts +11 -0
- package/src/WnfsPlugin.test.ts +20 -0
- package/src/WnfsPlugin.tsx +16 -40
- package/src/WnfsPlugin.workerd.ts +11 -0
- package/src/annotations.ts +16 -0
- package/src/capabilities/backend.ts +43 -0
- package/src/capabilities/blockstore.ts +1 -1
- package/src/capabilities/index.ts +11 -8
- package/src/capabilities/url-resolver.ts +44 -0
- package/src/helpers/load.ts +32 -18
- package/src/helpers/upload.ts +12 -3
- package/src/index.ts +3 -2
- package/src/meta.ts +22 -6
- package/src/plugin.ts +9 -0
- package/src/translations.ts +1 -14
- package/src/types/WnfsCapabilities.ts +18 -0
- package/src/types/index.ts +1 -3
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/chunk-BM3MEFES.mjs +0 -69
- package/dist/lib/browser/chunk-BM3MEFES.mjs.map +0 -7
- package/dist/lib/browser/chunk-N6Y4QPNF.mjs.map +0 -7
- package/dist/lib/browser/chunk-VXUCZHVZ.mjs +0 -69
- package/dist/lib/browser/chunk-VXUCZHVZ.mjs.map +0 -7
- package/dist/lib/browser/create-NOHKWE67.mjs +0 -24
- package/dist/lib/browser/create-NOHKWE67.mjs.map +0 -7
- package/dist/lib/browser/create-file-N7ADCFOF.mjs +0 -49
- package/dist/lib/browser/create-file-N7ADCFOF.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -117
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operations/index.mjs +0 -13
- package/dist/lib/browser/operations/index.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -11
- package/dist/lib/browser/upload-DA7GBOXF.mjs +0 -42
- package/dist/lib/browser/upload-DA7GBOXF.mjs.map +0 -7
- package/dist/types/src/capabilities/file-uploader.d.ts +0 -6
- package/dist/types/src/capabilities/file-uploader.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown.d.ts +0 -5
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +0 -6
- package/dist/types/src/capabilities/operation-handler.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/FileInput/FileInput.d.ts +0 -8
- package/dist/types/src/components/FileInput/FileInput.d.ts.map +0 -1
- package/dist/types/src/components/FileInput/index.d.ts +0 -2
- package/dist/types/src/components/FileInput/index.d.ts.map +0 -1
- package/dist/types/src/components/FilePreview/FilePreview.d.ts +0 -12
- package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +0 -1
- package/dist/types/src/components/FilePreview/index.d.ts +0 -2
- package/dist/types/src/components/FilePreview/index.d.ts.map +0 -1
- package/dist/types/src/components/index.d.ts +0 -3
- package/dist/types/src/components/index.d.ts.map +0 -1
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts +0 -7
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +0 -1
- package/dist/types/src/containers/FileContainer/index.d.ts +0 -2
- package/dist/types/src/containers/FileContainer/index.d.ts.map +0 -1
- package/dist/types/src/containers/index.d.ts +0 -3
- package/dist/types/src/containers/index.d.ts.map +0 -1
- package/dist/types/src/extensions/image.d.ts +0 -14
- package/dist/types/src/extensions/image.d.ts.map +0 -1
- package/dist/types/src/extensions/image.stories.d.ts +0 -11
- package/dist/types/src/extensions/image.stories.d.ts.map +0 -1
- package/dist/types/src/extensions/index.d.ts +0 -2
- package/dist/types/src/extensions/index.d.ts.map +0 -1
- package/dist/types/src/operations/create-file.d.ts +0 -5
- package/dist/types/src/operations/create-file.d.ts.map +0 -1
- package/dist/types/src/operations/create.d.ts +0 -5
- package/dist/types/src/operations/create.d.ts.map +0 -1
- package/dist/types/src/operations/definitions.d.ts +0 -38
- package/dist/types/src/operations/definitions.d.ts.map +0 -1
- package/dist/types/src/operations/index.d.ts +0 -4
- package/dist/types/src/operations/index.d.ts.map +0 -1
- package/dist/types/src/operations/upload.d.ts +0 -5
- package/dist/types/src/operations/upload.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/dist/types/src/types/capabilities.d.ts +0 -13
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -9
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/capabilities/file-uploader.ts +0 -34
- package/src/capabilities/markdown.ts +0 -34
- package/src/capabilities/operation-handler.ts +0 -16
- package/src/capabilities/react-surface.tsx +0 -54
- package/src/components/FileInput/FileInput.tsx +0 -47
- package/src/components/FileInput/index.ts +0 -5
- package/src/components/FilePreview/FilePreview.tsx +0 -43
- package/src/components/FilePreview/index.ts +0 -5
- package/src/components/index.ts +0 -6
- package/src/containers/FileContainer/FileContainer.tsx +0 -57
- package/src/containers/FileContainer/index.ts +0 -5
- package/src/containers/index.ts +0 -7
- package/src/extensions/image.stories.tsx +0 -103
- package/src/extensions/image.tsx +0 -204
- package/src/extensions/index.ts +0 -5
- package/src/operations/create-file.ts +0 -31
- package/src/operations/create.ts +0 -22
- package/src/operations/definitions.ts +0 -41
- package/src/operations/index.ts +0 -13
- package/src/operations/upload.ts +0 -29
- package/src/types/File.ts +0 -28
- package/src/types/capabilities.ts +0 -18
- package/src/types/types.ts +0 -24
- /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
upload
|
|
3
|
-
} from "./chunk-N6Y4QPNF.mjs";
|
|
4
|
-
import {
|
|
5
|
-
Upload
|
|
6
|
-
} from "./chunk-BM3MEFES.mjs";
|
|
7
|
-
import {
|
|
8
|
-
WnfsCapabilities
|
|
9
|
-
} from "./chunk-VXUCZHVZ.mjs";
|
|
10
|
-
|
|
11
|
-
// src/operations/upload.ts
|
|
12
|
-
import * as Effect from "effect/Effect";
|
|
13
|
-
import { Capability } from "@dxos/app-framework";
|
|
14
|
-
import { invariant } from "@dxos/invariant";
|
|
15
|
-
import { Operation } from "@dxos/operation";
|
|
16
|
-
import { ClientCapabilities } from "@dxos/plugin-client/types";
|
|
17
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-wnfs/src/operations/upload.ts";
|
|
18
|
-
var handler = Upload.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ file, db }) {
|
|
19
|
-
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
20
|
-
const blockstore = yield* Capability.get(WnfsCapabilities.Blockstore);
|
|
21
|
-
const space = client.spaces.get(db.spaceId);
|
|
22
|
-
invariant(space, "Space not found", {
|
|
23
|
-
F: __dxlog_file,
|
|
24
|
-
L: 22,
|
|
25
|
-
S: this,
|
|
26
|
-
A: [
|
|
27
|
-
"space",
|
|
28
|
-
"'Space not found'"
|
|
29
|
-
]
|
|
30
|
-
});
|
|
31
|
-
const info = yield* Effect.promise(() => upload({
|
|
32
|
-
file,
|
|
33
|
-
blockstore,
|
|
34
|
-
space
|
|
35
|
-
}));
|
|
36
|
-
return info;
|
|
37
|
-
})));
|
|
38
|
-
var upload_default = handler;
|
|
39
|
-
export {
|
|
40
|
-
upload_default as default
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=upload-DA7GBOXF.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/operations/upload.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { invariant } from '@dxos/invariant';\nimport { Operation } from '@dxos/operation';\nimport { ClientCapabilities } from '@dxos/plugin-client/types';\n\nimport { upload } from '../helpers';\nimport { WnfsCapabilities } from '../types';\nimport { Upload } from './definitions';\n\nconst handler: Operation.WithHandler<typeof Upload> = Upload.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ file, db }) {\n const client = yield* Capability.get(ClientCapabilities.Client);\n const blockstore = yield* Capability.get(WnfsCapabilities.Blockstore);\n const space = client.spaces.get(db.spaceId);\n invariant(space, 'Space not found');\n const info = yield* Effect.promise(() => upload({ file, blockstore, space }));\n return info;\n }),\n ),\n);\n\nexport default handler;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,0BAA0B;;AAMnC,IAAMC,UAAgDC,OAAOC,KAC3DC,UAAUC,YACDC,kBAAW,WAAW,EAAEC,MAAMC,GAAE,GAAE;AACvC,QAAMC,SAAS,OAAOC,WAAWC,IAAIC,mBAAmBC,MAAM;AAC9D,QAAMC,aAAa,OAAOJ,WAAWC,IAAII,iBAAiBC,UAAU;AACpE,QAAMC,QAAQR,OAAOS,OAAOP,IAAIH,GAAGW,OAAO;AAC1CC,YAAUH,OAAO,mBAAA;;;;;;;;;AACjB,QAAMI,OAAO,OAAcC,eAAQ,MAAMC,OAAO;IAAEhB;IAAMO;IAAYG;EAAM,CAAA,CAAA;AAC1E,SAAOI;AACT,CAAA,CAAA,CAAA;AAIJ,IAAA,iBAAepB;",
|
|
6
|
-
"names": ["Effect", "Capability", "invariant", "Operation", "ClientCapabilities", "handler", "Upload", "pipe", "Operation", "withHandler", "fnUntraced", "file", "db", "client", "Capability", "get", "ClientCapabilities", "Client", "blockstore", "WnfsCapabilities", "Blockstore", "space", "spaces", "spaceId", "invariant", "info", "promise", "upload"]
|
|
7
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as Effect from 'effect/Effect';
|
|
2
|
-
import { Capability } from '@dxos/app-framework';
|
|
3
|
-
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
4
|
-
declare const _default: (props: void) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<AppCapabilities.FileUploader>>, never, Capability.Service>;
|
|
5
|
-
export default _default;
|
|
6
|
-
//# sourceMappingURL=file-uploader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-uploader.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/file-uploader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;;AAMpD,wBAoBE"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as Effect from 'effect/Effect';
|
|
2
|
-
import { Capability } from '@dxos/app-framework';
|
|
3
|
-
declare const _default: (props: void) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<import("@dxos/plugin-markdown").MarkdownExtensionProvider[]>>, never, Capability.Service>;
|
|
4
|
-
export default _default;
|
|
5
|
-
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/markdown.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;;AAQjD,wBAmBE"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as Effect from 'effect/Effect';
|
|
2
|
-
import { Capability } from '@dxos/app-framework';
|
|
3
|
-
import type { OperationHandlerSet } from '@dxos/operation';
|
|
4
|
-
declare const _default: (props: OperationHandlerSet.OperationHandlerSet) => Effect.Effect<Capability.ModuleReturn, Error, Capability.Service>;
|
|
5
|
-
export default _default;
|
|
6
|
-
//# sourceMappingURL=operation-handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operation-handler.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/operation-handler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAgB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;;AAI3D,wBAIE"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as Effect from 'effect/Effect';
|
|
2
|
-
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
3
|
-
declare const _default: (props: void) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<Capabilities.ReactSurface>>, never, never>;
|
|
4
|
-
export default _default;
|
|
5
|
-
//# sourceMappingURL=react-surface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/react-surface.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;;AAU/D,wBAmCE"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type * as Schema from 'effect/Schema';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export type FileInputProps = {
|
|
4
|
-
schema: Schema.Schema.Any;
|
|
5
|
-
onChange: (file: File) => void;
|
|
6
|
-
};
|
|
7
|
-
export declare const FileInput: ({ schema, onChange }: FileInputProps) => React.JSX.Element;
|
|
8
|
-
//# sourceMappingURL=FileInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/FileInput/FileInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/FileInput/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export type FilePreviewProps = {
|
|
3
|
-
type: string;
|
|
4
|
-
url: string;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* File/content preview iframe.
|
|
8
|
-
*/
|
|
9
|
-
export declare const FilePreview: React.ForwardRefExoticComponent<Omit<FilePreviewProps, "className"> & {
|
|
10
|
-
classNames?: import("@dxos/ui-types").ClassNameValue;
|
|
11
|
-
} & Pick<React.HTMLAttributes<Element>, "style" | "children" | "className" | "role"> & React.RefAttributes<HTMLElement>>;
|
|
12
|
-
//# sourceMappingURL=FilePreview.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../../src/components/FilePreview/FilePreview.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAI5C,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,WAAW;;wHA6BvB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/FilePreview/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
3
|
-
import { type WnfsFile } from '#types';
|
|
4
|
-
export type FileContainerProps = AppSurface.ObjectArticleProps<WnfsFile.File>;
|
|
5
|
-
export declare const FileContainer: ({ role, subject: file }: FileContainerProps) => React.JSX.Element | null;
|
|
6
|
-
export default FileContainer;
|
|
7
|
-
//# sourceMappingURL=FileContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileContainer.d.ts","sourceRoot":"","sources":["../../../../../src/containers/FileContainer/FileContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAMvD,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIzD,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAE9E,eAAO,MAAM,aAAa,GAAI,yBAAyB,kBAAkB,6BAmCxE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/containers/FileContainer/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/containers/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAQ,MAAM,OAAO,CAAC;AAEjD,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,GAAG,CAAyC,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type Extension } from '@codemirror/state';
|
|
2
|
-
import type { Blockstore } from 'interface-blockstore';
|
|
3
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
4
|
-
import { type WnfsCapabilities } from '#types';
|
|
5
|
-
export type ImageOptions = {
|
|
6
|
-
blockstore: Blockstore;
|
|
7
|
-
instances: WnfsCapabilities.Instances;
|
|
8
|
-
space: Space;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Create WNFS image decorations.
|
|
12
|
-
*/
|
|
13
|
-
export declare const image: (options: ImageOptions) => Extension[];
|
|
14
|
-
//# sourceMappingURL=image.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/extensions/image.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,SAAS,EAA0B,MAAM,mBAAmB,CAAC;AAE7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIvD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAMrD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAM/C,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,gBAAgB,CAAC,SAAS,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,YAAY,KAAG,SAAS,EAgDtD,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
declare const meta: {
|
|
4
|
-
title: string;
|
|
5
|
-
render: () => React.JSX.Element;
|
|
6
|
-
decorators: import("@storybook/react").Decorator[];
|
|
7
|
-
};
|
|
8
|
-
export default meta;
|
|
9
|
-
type Story = StoryObj<typeof meta>;
|
|
10
|
-
export declare const Default: Story;
|
|
11
|
-
//# sourceMappingURL=image.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image.stories.d.ts","sourceRoot":"","sources":["../../../../src/extensions/image.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAgD,MAAM,OAAO,CAAC;AAsFrE,QAAA,MAAM,IAAI;;;;CAI2B,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-file.d.ts","sourceRoot":"","sources":["../../../../src/operations/create-file.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,QAAA,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,OAAO,UAAU,CAarD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/operations/create.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,QAAA,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,OAAO,MAAM,CAQjD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Capability } from '@dxos/app-framework';
|
|
2
|
-
import { Database } from '@dxos/echo';
|
|
3
|
-
import { Operation } from '@dxos/operation';
|
|
4
|
-
export declare const Create: Operation.Definition<{
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly type: string;
|
|
7
|
-
readonly cid: string;
|
|
8
|
-
}, {
|
|
9
|
-
readonly object: import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & {
|
|
10
|
-
readonly name?: string | undefined;
|
|
11
|
-
readonly type: string;
|
|
12
|
-
readonly cid: string;
|
|
13
|
-
readonly timestamp?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
}, Capability.Service>;
|
|
16
|
-
export declare const Upload: Operation.Definition<{
|
|
17
|
-
readonly file: File;
|
|
18
|
-
} & {
|
|
19
|
-
readonly db: Database.Database;
|
|
20
|
-
}, {
|
|
21
|
-
readonly name: string;
|
|
22
|
-
readonly type: string;
|
|
23
|
-
readonly cid: string;
|
|
24
|
-
readonly url: string;
|
|
25
|
-
}, Capability.Service>;
|
|
26
|
-
export declare const CreateFile: Operation.Definition<{
|
|
27
|
-
readonly file: File;
|
|
28
|
-
} & {
|
|
29
|
-
readonly db: Database.Database;
|
|
30
|
-
}, {
|
|
31
|
-
readonly object: import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & {
|
|
32
|
-
readonly name?: string | undefined;
|
|
33
|
-
readonly type: string;
|
|
34
|
-
readonly cid: string;
|
|
35
|
-
readonly timestamp?: string | undefined;
|
|
36
|
-
};
|
|
37
|
-
}, Capability.Service>;
|
|
38
|
-
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../../src/operations/definitions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,eAAO,MAAM,MAAM;;;;;;;;;;;sBAOjB,CAAC;AAEH,eAAO,MAAM,MAAM;;;;;;;;;sBAKjB,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;sBAOrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/operations/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,aAAa,MAAM,eAAe,CAAC;AAE/C,eAAO,MAAM,uBAAuB,yCAInC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../../src/operations/upload.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,QAAA,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,OAAO,MAAM,CAWjD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as Schema from 'effect/Schema';
|
|
2
|
-
import { Obj, Type } from '@dxos/echo';
|
|
3
|
-
export declare const File: Type.Obj<{
|
|
4
|
-
readonly name?: string | undefined;
|
|
5
|
-
readonly type: string;
|
|
6
|
-
readonly cid: string;
|
|
7
|
-
readonly timestamp?: string | undefined;
|
|
8
|
-
}, Schema.Struct.Fields>;
|
|
9
|
-
export type File = Schema.Schema.Type<typeof File>;
|
|
10
|
-
export declare const make: (props: Obj.MakeProps<typeof File>) => Obj.OfShape<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & {
|
|
11
|
-
readonly name?: string | undefined;
|
|
12
|
-
readonly type: string;
|
|
13
|
-
readonly cid: string;
|
|
14
|
-
readonly timestamp?: string | undefined;
|
|
15
|
-
}>;
|
|
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,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAc,GAAG,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGnD,eAAO,MAAM,IAAI;;;;;wBAchB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnD,eAAO,MAAM,IAAI,GAAI,OAAO,GAAG,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC;;;;;EAA0B,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type Blockstore } from 'interface-blockstore';
|
|
2
|
-
import { type PrivateDirectory, type PrivateForest } from 'wnfs';
|
|
3
|
-
import { Capability } from '@dxos/app-framework';
|
|
4
|
-
import { type SpaceId } from '@dxos/keys';
|
|
5
|
-
export declare namespace WnfsCapabilities {
|
|
6
|
-
const Blockstore: Capability.InterfaceDef<Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>>;
|
|
7
|
-
type Instances = Record<SpaceId, {
|
|
8
|
-
directory: PrivateDirectory;
|
|
9
|
-
forest: PrivateForest;
|
|
10
|
-
}>;
|
|
11
|
-
const Instances: Capability.InterfaceDef<Instances>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../../src/types/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;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1C,yBAAiB,gBAAgB,CAAC;IACzB,MAAM,UAAU,qEAAkE,CAAC;IAE1F,KAAY,SAAS,GAAG,MAAM,CAAC,OAAO,EAAE;QAAE,SAAS,EAAE,gBAAgB,CAAC;QAAC,MAAM,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;IACzF,MAAM,SAAS,oCAAgE,CAAC;CACxF"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as Schema from 'effect/Schema';
|
|
2
|
-
export declare namespace WnfsAction {
|
|
3
|
-
const UploadAnnotationId: unique symbol;
|
|
4
|
-
const UploadFileSchema: Schema.Struct<{
|
|
5
|
-
file: Schema.instanceOf<File>;
|
|
6
|
-
}>;
|
|
7
|
-
type UploadFileForm = Schema.Schema.Type<typeof UploadFileSchema>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,yBAAiB,UAAU,CAAC;IACnB,MAAM,kBAAkB,eAA6C,CAAC;IAEtE,MAAM,gBAAgB;;MAS3B,CAAC;IAEH,KAAY,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;CAC1E"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
|
|
7
|
-
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
-
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
9
|
-
import { runAndForwardErrors } from '@dxos/effect';
|
|
10
|
-
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
11
|
-
|
|
12
|
-
import { WnfsOperation } from '#operations';
|
|
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(AppCapabilities.FileUploader, (db, file) => {
|
|
20
|
-
const { invoke } = capabilities.get(Capabilities.OperationInvoker);
|
|
21
|
-
const program = Effect.gen(function* () {
|
|
22
|
-
const fileInfo = yield* invoke(WnfsOperation.Upload, { db, file });
|
|
23
|
-
const createResult = yield* invoke(WnfsOperation.Create, fileInfo);
|
|
24
|
-
if (createResult?.object) {
|
|
25
|
-
yield* invoke(SpaceOperation.AddObject, { target: db, object: createResult.object });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return fileInfo;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return runAndForwardErrors(program);
|
|
32
|
-
});
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
@@ -1,34 +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 { WnfsCapabilities } from '#types';
|
|
12
|
-
|
|
13
|
-
import { image } from '../extensions';
|
|
14
|
-
|
|
15
|
-
export default Capability.makeModule(
|
|
16
|
-
Effect.fnUntraced(function* () {
|
|
17
|
-
// Get context for lazy capability access in callbacks.
|
|
18
|
-
const capabilities = yield* Capability.Service;
|
|
19
|
-
|
|
20
|
-
return Capability.contributes(MarkdownCapabilities.Extensions, [
|
|
21
|
-
({ document }: { document?: any }) => {
|
|
22
|
-
const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
|
|
23
|
-
const instances = capabilities.get(WnfsCapabilities.Instances);
|
|
24
|
-
|
|
25
|
-
if (document) {
|
|
26
|
-
const space = getSpace(document);
|
|
27
|
-
return space ? [image({ blockstore, instances, space })] : [];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return [];
|
|
31
|
-
},
|
|
32
|
-
]);
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Effect from 'effect/Effect';
|
|
6
|
-
|
|
7
|
-
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
-
import type { OperationHandlerSet } from '@dxos/operation';
|
|
9
|
-
|
|
10
|
-
import { WnfsOperationHandlerSet } from '#operations';
|
|
11
|
-
|
|
12
|
-
export default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(
|
|
13
|
-
Effect.fnUntraced(function* () {
|
|
14
|
-
return Capability.contributes(Capabilities.OperationHandler, WnfsOperationHandlerSet);
|
|
15
|
-
}),
|
|
16
|
-
);
|
|
@@ -1,54 +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 { Capabilities, Capability } from '@dxos/app-framework';
|
|
10
|
-
import { Surface } from '@dxos/app-framework/ui';
|
|
11
|
-
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
12
|
-
import { findAnnotation } from '@dxos/effect';
|
|
13
|
-
import { type FormFieldComponentProps } from '@dxos/react-ui-form';
|
|
14
|
-
|
|
15
|
-
import { FileInput } from '#components';
|
|
16
|
-
import { FileContainer } from '#containers';
|
|
17
|
-
import { WnfsAction, WnfsFile } from '#types';
|
|
18
|
-
|
|
19
|
-
export default Capability.makeModule(() =>
|
|
20
|
-
Effect.succeed(
|
|
21
|
-
Capability.contributes(Capabilities.ReactSurface, [
|
|
22
|
-
Surface.create({
|
|
23
|
-
id: 'article',
|
|
24
|
-
// TODO(wittjosiah): Split into multiple surfaces if this filter proves too strict for non-article roles.
|
|
25
|
-
filter: AppSurface.oneOf(
|
|
26
|
-
AppSurface.object(AppSurface.Article, WnfsFile.File),
|
|
27
|
-
AppSurface.object(AppSurface.Section, WnfsFile.File),
|
|
28
|
-
AppSurface.object(AppSurface.Slide, WnfsFile.File),
|
|
29
|
-
),
|
|
30
|
-
component: ({ data, role }) => <FileContainer role={role} subject={data.subject} />,
|
|
31
|
-
}),
|
|
32
|
-
Surface.create({
|
|
33
|
-
id: 'create-form',
|
|
34
|
-
role: 'form-input',
|
|
35
|
-
filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
|
|
36
|
-
const annotation = findAnnotation<boolean>(
|
|
37
|
-
(data.schema as Schema.Schema.All).ast,
|
|
38
|
-
WnfsAction.UploadAnnotationId,
|
|
39
|
-
);
|
|
40
|
-
return !!annotation;
|
|
41
|
-
},
|
|
42
|
-
component: ({ data: { schema }, ...props }) => {
|
|
43
|
-
const inputProps = props as unknown as FormFieldComponentProps;
|
|
44
|
-
const handleChange = useCallback(
|
|
45
|
-
(file: File) => inputProps.onValueChange?.(inputProps.type, file),
|
|
46
|
-
[inputProps.type, inputProps.onValueChange],
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return <FileInput schema={schema} onChange={handleChange} />;
|
|
50
|
-
},
|
|
51
|
-
}),
|
|
52
|
-
]),
|
|
53
|
-
),
|
|
54
|
-
);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import type * as Schema from 'effect/Schema';
|
|
6
|
-
import React, { useCallback } from 'react';
|
|
7
|
-
import { useDropzone } from 'react-dropzone';
|
|
8
|
-
|
|
9
|
-
import { findAnnotation } from '@dxos/effect';
|
|
10
|
-
import { useTranslation } from '@dxos/react-ui';
|
|
11
|
-
import { mx } from '@dxos/ui-theme';
|
|
12
|
-
|
|
13
|
-
import { meta } from '#meta';
|
|
14
|
-
import { WnfsAction } from '#types';
|
|
15
|
-
|
|
16
|
-
export type FileInputProps = {
|
|
17
|
-
schema: Schema.Schema.Any;
|
|
18
|
-
onChange: (file: File) => void;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const FileInput = ({ schema, onChange }: FileInputProps) => {
|
|
22
|
-
const { t } = useTranslation(meta.id);
|
|
23
|
-
const accept = findAnnotation<Record<string, string[]>>(schema.ast, WnfsAction.UploadAnnotationId);
|
|
24
|
-
|
|
25
|
-
const onDropAccepted = useCallback((files: File[]) => onChange?.(files[0]), [onChange]);
|
|
26
|
-
|
|
27
|
-
const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({
|
|
28
|
-
multiple: false,
|
|
29
|
-
accept,
|
|
30
|
-
onDropAccepted,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div
|
|
35
|
-
{...getRootProps()}
|
|
36
|
-
className={mx(
|
|
37
|
-
'flex flex-col items-center p-8 border border-separator',
|
|
38
|
-
isFocused && 'focus-ring',
|
|
39
|
-
isDragAccept && 'bg-attention-surface',
|
|
40
|
-
isDragReject && 'border-rose-fill',
|
|
41
|
-
)}
|
|
42
|
-
>
|
|
43
|
-
<input {...getInputProps()} />
|
|
44
|
-
{acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file-input.placeholder')}</p>}
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { ForwardedRef } from 'react';
|
|
6
|
-
|
|
7
|
-
import { composable, composableProps } from '@dxos/ui-theme';
|
|
8
|
-
|
|
9
|
-
export type FilePreviewProps = { type: string; url: string };
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* File/content preview iframe.
|
|
13
|
-
*/
|
|
14
|
-
export const FilePreview = composable<HTMLElement, FilePreviewProps>(
|
|
15
|
-
({ type, url, children, ...props }, forwardedRef) => {
|
|
16
|
-
if (type.startsWith('image/')) {
|
|
17
|
-
return (
|
|
18
|
-
<img
|
|
19
|
-
{...composableProps(props, { classNames: 'h-full w-full object-contain' })}
|
|
20
|
-
src={url}
|
|
21
|
-
ref={forwardedRef as ForwardedRef<HTMLImageElement>}
|
|
22
|
-
/>
|
|
23
|
-
);
|
|
24
|
-
} else if (type.startsWith('video/')) {
|
|
25
|
-
return (
|
|
26
|
-
<video
|
|
27
|
-
{...composableProps(props, { classNames: 'h-full w-full object-contain' })}
|
|
28
|
-
src={url}
|
|
29
|
-
controls
|
|
30
|
-
ref={forwardedRef as ForwardedRef<HTMLVideoElement>}
|
|
31
|
-
/>
|
|
32
|
-
);
|
|
33
|
-
} else {
|
|
34
|
-
return (
|
|
35
|
-
<iframe
|
|
36
|
-
{...composableProps(props, { classNames: 'h-full w-full overflow-auto' })}
|
|
37
|
-
src={url}
|
|
38
|
-
ref={forwardedRef as ForwardedRef<HTMLIFrameElement>}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
);
|