@dxos/plugin-wnfs 0.8.1 → 0.8.2-main.2f9c567
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-4HNP22HU.mjs → FileContainer-D4GEWVR6.mjs} +5 -4
- package/dist/lib/browser/{FileContainer-4HNP22HU.mjs.map → FileContainer-D4GEWVR6.mjs.map} +3 -3
- package/dist/lib/browser/{blockstore-G47Q25U6.mjs → blockstore-CTEISOKD.mjs} +2 -2
- package/dist/lib/browser/chunk-4K6XXKUI.mjs +16 -0
- package/dist/lib/browser/{chunk-FKYLWLNM.mjs → chunk-I4YFQNT3.mjs} +19 -15
- package/dist/lib/browser/chunk-I4YFQNT3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SCQWJNHD.mjs → chunk-YYAW4U6J.mjs} +5 -3
- package/dist/lib/browser/{chunk-SCQWJNHD.mjs.map → chunk-YYAW4U6J.mjs.map} +3 -3
- package/dist/lib/browser/{file-uploader-L4TDVJBE.mjs → file-uploader-J7Y2T3ZT.mjs} +2 -2
- package/dist/lib/browser/index.mjs +2 -2
- package/dist/lib/browser/{intent-resolver-VSMIQLGS.mjs → intent-resolver-LDV6U4RN.mjs} +5 -5
- package/dist/lib/browser/intent-resolver-LDV6U4RN.mjs.map +7 -0
- package/dist/lib/browser/{markdown-MWMZVPEX.mjs → markdown-G6DTBWWO.mjs} +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-MKJYHQ4P.mjs → react-surface-DP33T53X.mjs} +7 -7
- package/dist/lib/browser/react-surface-DP33T53X.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/FileInput.d.ts +2 -2
- package/dist/types/src/components/FileInput.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
- package/dist/types/src/helpers/wnfs-url.d.ts +3 -2
- package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
- package/dist/types/src/types/file.d.ts +10 -10
- package/dist/types/src/types/file.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +15 -15
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +24 -23
- package/src/capabilities/intent-resolver.ts +2 -2
- package/src/capabilities/react-surface.tsx +6 -3
- package/src/components/FileContainer.tsx +1 -1
- package/src/components/FileInput.tsx +2 -2
- package/src/components/index.ts +2 -2
- package/src/extensions/image.stories.tsx +2 -2
- package/src/helpers/wnfs-url.ts +5 -3
- package/src/types/file.ts +7 -5
- package/src/types/types.ts +12 -10
- package/dist/lib/browser/chunk-FH2Q7ZBE.mjs +0 -16
- package/dist/lib/browser/chunk-FKYLWLNM.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-VSMIQLGS.mjs.map +0 -7
- package/dist/lib/browser/react-surface-MKJYHQ4P.mjs.map +0 -7
- /package/dist/lib/browser/{blockstore-G47Q25U6.mjs.map → blockstore-CTEISOKD.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-FH2Q7ZBE.mjs.map → chunk-4K6XXKUI.mjs.map} +0 -0
- /package/dist/lib/browser/{file-uploader-L4TDVJBE.mjs.map → file-uploader-J7Y2T3ZT.mjs.map} +0 -0
- /package/dist/lib/browser/{markdown-MWMZVPEX.mjs.map → markdown-G6DTBWWO.mjs.map} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FileType,
|
|
3
3
|
WnfsAction
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-I4YFQNT3.mjs";
|
|
5
5
|
import {
|
|
6
6
|
WNFS_PLUGIN
|
|
7
7
|
} from "./chunk-X54OT4V3.mjs";
|
|
8
8
|
|
|
9
9
|
// packages/plugins/plugin-wnfs/src/capabilities/react-surface.tsx
|
|
10
|
-
import
|
|
10
|
+
import React2, { useCallback as useCallback2 } from "react";
|
|
11
11
|
import { contributes, Capabilities, createSurface } from "@dxos/app-framework";
|
|
12
12
|
import { isInstanceOf } from "@dxos/echo-schema";
|
|
13
13
|
import { findAnnotation as findAnnotation2 } from "@dxos/effect";
|
|
14
14
|
|
|
15
15
|
// packages/plugins/plugin-wnfs/src/components/index.ts
|
|
16
|
-
import
|
|
16
|
+
import { lazy } from "react";
|
|
17
17
|
|
|
18
18
|
// packages/plugins/plugin-wnfs/src/components/FileInput.tsx
|
|
19
19
|
import React, { useCallback } from "react";
|
|
@@ -39,7 +39,7 @@ var FileInput = ({ schema, onChange }) => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
// packages/plugins/plugin-wnfs/src/components/index.ts
|
|
42
|
-
var FileContainer =
|
|
42
|
+
var FileContainer = lazy(() => import("./FileContainer-D4GEWVR6.mjs"));
|
|
43
43
|
|
|
44
44
|
// packages/plugins/plugin-wnfs/src/capabilities/react-surface.tsx
|
|
45
45
|
var react_surface_default = () => contributes(Capabilities.ReactSurface, [
|
|
@@ -51,7 +51,7 @@ var react_surface_default = () => contributes(Capabilities.ReactSurface, [
|
|
|
51
51
|
"slide"
|
|
52
52
|
],
|
|
53
53
|
filter: (data) => isInstanceOf(FileType, data.subject),
|
|
54
|
-
component: ({ data, role }) => /* @__PURE__ */
|
|
54
|
+
component: ({ data, role }) => /* @__PURE__ */ React2.createElement(FileContainer, {
|
|
55
55
|
role,
|
|
56
56
|
file: data.subject
|
|
57
57
|
})
|
|
@@ -69,7 +69,7 @@ var react_surface_default = () => contributes(Capabilities.ReactSurface, [
|
|
|
69
69
|
prop,
|
|
70
70
|
inputProps.onValueChange
|
|
71
71
|
]);
|
|
72
|
-
return /* @__PURE__ */
|
|
72
|
+
return /* @__PURE__ */ React2.createElement(FileInput, {
|
|
73
73
|
schema,
|
|
74
74
|
onChange: handleChange
|
|
75
75
|
});
|
|
@@ -79,4 +79,4 @@ var react_surface_default = () => contributes(Capabilities.ReactSurface, [
|
|
|
79
79
|
export {
|
|
80
80
|
react_surface_default as default
|
|
81
81
|
};
|
|
82
|
-
//# sourceMappingURL=react-surface-
|
|
82
|
+
//# sourceMappingURL=react-surface-DP33T53X.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/react-surface.tsx", "../../../src/components/index.ts", "../../../src/components/FileInput.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\nimport React, { useCallback } from 'react';\n\nimport { contributes, Capabilities, createSurface } from '@dxos/app-framework';\nimport { isInstanceOf } from '@dxos/echo-schema';\nimport { findAnnotation } from '@dxos/effect';\nimport { type InputProps } from '@dxos/react-ui-form';\n\nimport { FileContainer, FileInput } from '../components';\nimport { WNFS_PLUGIN } from '../meta';\nimport { FileType, WnfsAction } from '../types';\n\nexport default () =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: `${WNFS_PLUGIN}/article`,\n role: ['article', 'section', 'slide'],\n filter: (data): data is { subject: FileType } => isInstanceOf(FileType, data.subject),\n component: ({ data, role }) => <FileContainer role={role} file={data.subject} />,\n }),\n createSurface({\n id: `${WNFS_PLUGIN}/create-form`,\n role: 'form-input',\n filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {\n const annotation = findAnnotation<boolean>(\n (data.schema as Schema.Schema.All).ast,\n WnfsAction.UploadAnnotationId,\n );\n return !!annotation;\n },\n component: ({ data: { prop, schema }, ...props }) => {\n const inputProps = props as unknown as InputProps;\n const handleChange = useCallback(\n (file: File) => inputProps.onValueChange?.('object', file),\n [prop, inputProps.onValueChange],\n );\n\n return <FileInput schema={schema} onChange={handleChange} />;\n },\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport const FileContainer = lazy(() => import('./FileContainer'));\n\nexport * from './FileInput';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\nimport React, { useCallback } from 'react';\nimport { useDropzone } from 'react-dropzone';\n\nimport { findAnnotation } from '@dxos/effect';\nimport { useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { WNFS_PLUGIN } from '../meta';\nimport { WnfsAction } from '../types';\n\nexport type FileInputProps = {\n schema: Schema.Schema.Any;\n onChange: (file: File) => void;\n};\n\nexport const FileInput = ({ schema, onChange }: FileInputProps) => {\n const { t } = useTranslation(WNFS_PLUGIN);\n const accept = findAnnotation<Record<string, string[]>>(schema.ast, WnfsAction.UploadAnnotationId);\n\n const onDropAccepted = useCallback((files: File[]) => onChange?.(files[0]), [onChange]);\n\n const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({\n multiple: false,\n accept,\n onDropAccepted,\n });\n\n return (\n <div\n {...getRootProps()}\n className={mx(\n 'flex flex-col items-center p-8 border border-separator',\n isFocused && 'focus-ring',\n isDragAccept && 'bg-attention',\n isDragReject && 'border-error',\n )}\n >\n <input {...getInputProps()} />\n {acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file input placeholder')}</p>}\n </div>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAKA,OAAOA,UAASC,eAAAA,oBAAmB;AAEnC,SAASC,aAAaC,cAAcC,qBAAqB;AACzD,SAASC,oBAAoB;AAC7B,SAASC,kBAAAA,uBAAsB;;;ACL/B,SAASC,YAAY;;;ACCrB,OAAOC,SAASC,mBAAmB;AACnC,SAASC,mBAAmB;AAE5B,SAASC,sBAAsB;AAC/B,SAASC,sBAAsB;AAC/B,SAASC,UAAU;AAUZ,IAAMC,YAAY,CAAC,EAAEC,QAAQC,SAAQ,MAAkB;AAC5D,QAAM,EAAEC,EAAC,IAAKC,eAAeC,WAAAA;AAC7B,QAAMC,SAASC,eAAyCN,OAAOO,KAAKC,WAAWC,kBAAkB;AAEjG,QAAMC,iBAAiBC,YAAY,CAACC,UAAkBX,WAAWW,MAAM,CAAA,CAAE,GAAG;IAACX;GAAS;AAEtF,QAAM,EAAEY,eAAeC,cAAcC,eAAeC,WAAWC,cAAcC,aAAY,IAAKC,YAAY;IACxGC,UAAU;IACVf;IACAK;EACF,CAAA;AAEA,SACE,sBAAA,cAACW,OAAAA;IACE,GAAGP,aAAAA;IACJQ,WAAWC,GACT,0DACAP,aAAa,cACbC,gBAAgB,gBAChBC,gBAAgB,cAAA;KAGlB,sBAAA,cAACM,SAAUT,cAAAA,CAAAA,GACVF,cAAc,CAAA,IAAK,sBAAA,cAACY,KAAAA,MAAGZ,cAAc,CAAA,EAAGa,IAAI,IAAQ,sBAAA,cAACD,KAAAA,MAAGvB,EAAE,wBAAA,CAAA,CAAA;AAGjE;;;ADxCO,IAAMyB,gBAAgBC,KAAK,MAAM,OAAO,8BAAA,CAAA;;;ADU/C,IAAA,wBAAe,MACbC,YAAYC,aAAaC,cAAc;EACrCC,cAAc;IACZC,IAAI,GAAGC,WAAAA;IACPC,MAAM;MAAC;MAAW;MAAW;;IAC7BC,QAAQ,CAACC,SAAwCC,aAAaC,UAAUF,KAAKG,OAAO;IACpFC,WAAW,CAAC,EAAEJ,MAAMF,KAAI,MAAO,gBAAAO,OAAA,cAACC,eAAAA;MAAcR;MAAYS,MAAMP,KAAKG;;EACvE,CAAA;EACAR,cAAc;IACZC,IAAI,GAAGC,WAAAA;IACPC,MAAM;IACNC,QAAQ,CAACC,SAAAA;AACP,YAAMQ,aAAaC,gBAChBT,KAAKU,OAA6BC,KACnCC,WAAWC,kBAAkB;AAE/B,aAAO,CAAC,CAACL;IACX;IACAJ,WAAW,CAAC,EAAEJ,MAAM,EAAEc,MAAMJ,OAAM,GAAI,GAAGK,MAAAA,MAAO;AAC9C,YAAMC,aAAaD;AACnB,YAAME,eAAeC,aACnB,CAACX,SAAeS,WAAWG,gBAAgB,UAAUZ,IAAAA,GACrD;QAACO;QAAME,WAAWG;OAAc;AAGlC,aAAO,gBAAAd,OAAA,cAACe,WAAAA;QAAUV;QAAgBW,UAAUJ;;IAC9C;EACF,CAAA;CACD;",
|
|
6
|
+
"names": ["React", "useCallback", "contributes", "Capabilities", "createSurface", "isInstanceOf", "findAnnotation", "lazy", "React", "useCallback", "useDropzone", "findAnnotation", "useTranslation", "mx", "FileInput", "schema", "onChange", "t", "useTranslation", "WNFS_PLUGIN", "accept", "findAnnotation", "ast", "WnfsAction", "UploadAnnotationId", "onDropAccepted", "useCallback", "files", "acceptedFiles", "getRootProps", "getInputProps", "isFocused", "isDragAccept", "isDragReject", "useDropzone", "multiple", "div", "className", "mx", "input", "p", "name", "FileContainer", "lazy", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "WNFS_PLUGIN", "role", "filter", "data", "isInstanceOf", "FileType", "subject", "component", "React", "FileContainer", "file", "annotation", "findAnnotation", "schema", "ast", "WnfsAction", "UploadAnnotationId", "prop", "props", "inputProps", "handleChange", "useCallback", "onValueChange", "FileInput", "onChange"]
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/react-surface.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/react-surface.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAe,YAAY,EAAiB,MAAM,qBAAqB,CAAC;;AAS/E,wBA4BK"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Schema
|
|
1
|
+
import { type Schema } from 'effect';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export type FileInputProps = {
|
|
4
|
-
schema:
|
|
4
|
+
schema: Schema.Schema.Any;
|
|
5
5
|
onChange: (file: File) => void;
|
|
6
6
|
};
|
|
7
7
|
export declare const FileInput: ({ schema, onChange }: FileInputProps) => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../../src/components/FileInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,
|
|
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,yBAA0B,cAAc,sBA0B7D,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const FileContainer: React.LazyExoticComponent<({ file, role }: {
|
|
1
|
+
export declare const FileContainer: import("react").LazyExoticComponent<({ file, role }: {
|
|
3
2
|
file: import("../types").FileType;
|
|
4
3
|
role: string;
|
|
5
|
-
}) =>
|
|
4
|
+
}) => import("react").JSX.Element | null>;
|
|
6
5
|
export * from './FileInput';
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa;;;yCAAwC,CAAC;AAEnE,cAAc,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.stories.d.ts","sourceRoot":"","sources":["../../../../src/extensions/image.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,
|
|
1
|
+
{"version":3,"file":"image.stories.d.ts","sourceRoot":"","sources":["../../../../src/extensions/image.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAgD,MAAM,OAAO,CAAC;;;;;;AAsFrE,wBAIE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
|
|
@@ -2,10 +2,11 @@ import type { Blockstore } from 'interface-blockstore';
|
|
|
2
2
|
import { type PrivateDirectory, type PrivateForest } from 'wnfs';
|
|
3
3
|
export declare const wnfsUrl: (filePath: string[]) => string;
|
|
4
4
|
export declare const getPathFromUrl: (wnfsUrl: string) => string[];
|
|
5
|
-
export declare const getBlobUrl: ({ wnfsUrl, blockstore, directory,
|
|
5
|
+
export declare const getBlobUrl: ({ wnfsUrl, blockstore, forest, directory, type, }: {
|
|
6
6
|
wnfsUrl: string;
|
|
7
7
|
blockstore: Blockstore;
|
|
8
|
-
directory: PrivateDirectory;
|
|
9
8
|
forest: PrivateForest;
|
|
9
|
+
directory: PrivateDirectory;
|
|
10
|
+
type?: string;
|
|
10
11
|
}) => Promise<string>;
|
|
11
12
|
//# sourceMappingURL=wnfs-url.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wnfs-url.d.ts","sourceRoot":"","sources":["../../../../src/helpers/wnfs-url.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAIjE,eAAO,MAAM,OAAO,aAAc,MAAM,EAAE,WAEzC,CAAC;AAEF,eAAO,MAAM,cAAc,YAAa,MAAM,aAIR,CAAC;AAEvC,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"wnfs-url.d.ts","sourceRoot":"","sources":["../../../../src/helpers/wnfs-url.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAIjE,eAAO,MAAM,OAAO,aAAc,MAAM,EAAE,WAEzC,CAAC;AAEF,eAAO,MAAM,cAAc,YAAa,MAAM,aAIR,CAAC;AAEvC,eAAO,MAAM,UAAU,sDAMpB;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,oBAMA,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
2
|
declare const FileType_base: import("@dxos/echo-schema").TypedObjectPrototype<import("@dxos/echo-schema").TypedObjectFields<{
|
|
3
|
-
name:
|
|
4
|
-
type: typeof
|
|
5
|
-
cid: typeof
|
|
6
|
-
timestamp:
|
|
7
|
-
}, import("@dxos/echo-schema").TypedObjectOptions>,
|
|
8
|
-
name:
|
|
9
|
-
type: typeof
|
|
10
|
-
cid: typeof
|
|
11
|
-
timestamp:
|
|
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
12
|
}>>;
|
|
13
13
|
export declare class FileType extends FileType_base {
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../src/types/file.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
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,aAK5B;CAAG"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
2
|
import { FileType } from './file';
|
|
3
3
|
export declare namespace WnfsAction {
|
|
4
|
-
const Create_base:
|
|
5
|
-
readonly _tag:
|
|
4
|
+
const Create_base: Schema.TaggedClass<Create, "dxos.org/plugin/wnfs/action/create", {
|
|
5
|
+
readonly _tag: Schema.tag<"dxos.org/plugin/wnfs/action/create">;
|
|
6
6
|
} & {
|
|
7
|
-
input:
|
|
7
|
+
input: Schema.SchemaClass<{
|
|
8
8
|
readonly name: string;
|
|
9
9
|
readonly type: string;
|
|
10
10
|
readonly cid: string;
|
|
@@ -13,26 +13,26 @@ export declare namespace WnfsAction {
|
|
|
13
13
|
readonly type: string;
|
|
14
14
|
readonly cid: string;
|
|
15
15
|
}, never>;
|
|
16
|
-
output:
|
|
16
|
+
output: Schema.Struct<{
|
|
17
17
|
object: typeof FileType;
|
|
18
18
|
}>;
|
|
19
19
|
}>;
|
|
20
20
|
export class Create extends Create_base {
|
|
21
21
|
}
|
|
22
22
|
export const UploadAnnotationId: unique symbol;
|
|
23
|
-
export const UploadFileSchema:
|
|
24
|
-
file:
|
|
23
|
+
export const UploadFileSchema: Schema.Struct<{
|
|
24
|
+
file: Schema.instanceOf<File>;
|
|
25
25
|
}>;
|
|
26
|
-
export type UploadFileForm =
|
|
27
|
-
const Upload_base:
|
|
28
|
-
readonly _tag:
|
|
26
|
+
export type UploadFileForm = Schema.Schema.Type<typeof UploadFileSchema>;
|
|
27
|
+
const Upload_base: Schema.TaggedClass<Upload, "dxos.org/plugin/wnfs/action/upload", {
|
|
28
|
+
readonly _tag: Schema.tag<"dxos.org/plugin/wnfs/action/upload">;
|
|
29
29
|
} & {
|
|
30
|
-
input:
|
|
31
|
-
file:
|
|
32
|
-
}>,
|
|
33
|
-
space:
|
|
30
|
+
input: Schema.extend<Schema.Struct<{
|
|
31
|
+
file: Schema.instanceOf<File>;
|
|
32
|
+
}>, Schema.Struct<{
|
|
33
|
+
space: Schema.Schema<import("@dxos/client-protocol").Space, import("@dxos/client-protocol").Space, never>;
|
|
34
34
|
}>>;
|
|
35
|
-
output:
|
|
35
|
+
output: Schema.SchemaClass<{
|
|
36
36
|
readonly name: string;
|
|
37
37
|
readonly type: string;
|
|
38
38
|
readonly cid: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,yBAAiB,UAAU,CAAC;;;;;;;;;;;;;;;;;IAC1B,MAAM,OAAO,MAAO,SAAQ,WAK1B;KAAG;IAEL,MAAM,CAAC,MAAM,kBAAkB,eAAiD,CAAC;IAEjF,MAAM,CAAC,MAAM,gBAAgB;;MAS3B,CAAC;IAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;IAEzE,MAAM,OAAO,MAAO,SAAQ,WAG1B;KAAG;;CACN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-wnfs",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2-main.2f9c567",
|
|
4
4
|
"description": "WNFS file management plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"blockstore-core": "^5.0.1",
|
|
38
38
|
"blockstore-idb": "^2.0.0",
|
|
39
39
|
"debounce": "^2.2.0",
|
|
40
|
-
"effect": "3.
|
|
40
|
+
"effect": "3.14.21",
|
|
41
41
|
"idb-keyval": "^6.2.1",
|
|
42
42
|
"interface-blockstore": "^5.2.10",
|
|
43
43
|
"it-all": "^3.0.6",
|
|
@@ -45,22 +45,22 @@
|
|
|
45
45
|
"react-dropzone": "^14.2.3",
|
|
46
46
|
"uint8arrays": "^5.1.0",
|
|
47
47
|
"wnfs": "0.2.2",
|
|
48
|
-
"@dxos/app-framework": "0.8.
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/effect": "0.8.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/log": "0.8.
|
|
55
|
-
"@dxos/plugin-client": "0.8.
|
|
56
|
-
"@dxos/plugin-markdown": "0.8.
|
|
57
|
-
"@dxos/plugin-space": "0.8.
|
|
58
|
-
"@dxos/react-
|
|
59
|
-
"@dxos/react-
|
|
60
|
-
"@dxos/react-ui-
|
|
61
|
-
"@dxos/react-ui-
|
|
62
|
-
"@dxos/react-ui-stack": "0.8.
|
|
63
|
-
"@dxos/util": "0.8.
|
|
48
|
+
"@dxos/app-framework": "0.8.2-main.2f9c567",
|
|
49
|
+
"@dxos/echo-schema": "0.8.2-main.2f9c567",
|
|
50
|
+
"@dxos/crypto": "0.8.2-main.2f9c567",
|
|
51
|
+
"@dxos/effect": "0.8.2-main.2f9c567",
|
|
52
|
+
"@dxos/local-storage": "0.8.2-main.2f9c567",
|
|
53
|
+
"@dxos/invariant": "0.8.2-main.2f9c567",
|
|
54
|
+
"@dxos/log": "0.8.2-main.2f9c567",
|
|
55
|
+
"@dxos/plugin-client": "0.8.2-main.2f9c567",
|
|
56
|
+
"@dxos/plugin-markdown": "0.8.2-main.2f9c567",
|
|
57
|
+
"@dxos/plugin-space": "0.8.2-main.2f9c567",
|
|
58
|
+
"@dxos/react-client": "0.8.2-main.2f9c567",
|
|
59
|
+
"@dxos/react-ui": "0.8.2-main.2f9c567",
|
|
60
|
+
"@dxos/react-ui-form": "0.8.2-main.2f9c567",
|
|
61
|
+
"@dxos/react-ui-editor": "0.8.2-main.2f9c567",
|
|
62
|
+
"@dxos/react-ui-stack": "0.8.2-main.2f9c567",
|
|
63
|
+
"@dxos/util": "0.8.2-main.2f9c567"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -69,16 +69,17 @@
|
|
|
69
69
|
"react": "~18.2.0",
|
|
70
70
|
"react-dom": "~18.2.0",
|
|
71
71
|
"vite": "5.4.7",
|
|
72
|
-
"@dxos/random": "0.8.
|
|
73
|
-
"@dxos/react-ui-theme": "0.8.
|
|
74
|
-
"@dxos/storybook-utils": "0.8.
|
|
72
|
+
"@dxos/random": "0.8.2-main.2f9c567",
|
|
73
|
+
"@dxos/react-ui-theme": "0.8.2-main.2f9c567",
|
|
74
|
+
"@dxos/storybook-utils": "0.8.2-main.2f9c567"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@phosphor-icons/react": "^2.0.5",
|
|
78
|
+
"effect": "^3.13.3",
|
|
78
79
|
"react": "~18.2.0",
|
|
79
80
|
"react-dom": "~18.2.0",
|
|
80
|
-
"@dxos/react-ui": "0.8.
|
|
81
|
-
"@dxos/react-ui-theme": "0.8.
|
|
81
|
+
"@dxos/react-ui": "0.8.2-main.2f9c567",
|
|
82
|
+
"@dxos/react-ui-theme": "0.8.2-main.2f9c567"
|
|
82
83
|
},
|
|
83
84
|
"publishConfig": {
|
|
84
85
|
"access": "public"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { contributes, Capabilities, createResolver, type PluginsContext } from '@dxos/app-framework';
|
|
6
|
-
import {
|
|
6
|
+
import { live } from '@dxos/react-client/echo';
|
|
7
7
|
|
|
8
8
|
import { WnfsCapabilities } from './capabilities';
|
|
9
9
|
import { upload } from '../helpers';
|
|
@@ -17,7 +17,7 @@ export default (context: PluginsContext) =>
|
|
|
17
17
|
intent: WnfsAction.Create,
|
|
18
18
|
resolve: ({ name, type, cid }) => ({
|
|
19
19
|
data: {
|
|
20
|
-
object:
|
|
20
|
+
object: live(FileType, { name, type, cid }),
|
|
21
21
|
},
|
|
22
22
|
}),
|
|
23
23
|
}),
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type Schema } from 'effect';
|
|
5
6
|
import React, { useCallback } from 'react';
|
|
6
7
|
|
|
7
8
|
import { contributes, Capabilities, createSurface } from '@dxos/app-framework';
|
|
8
9
|
import { isInstanceOf } from '@dxos/echo-schema';
|
|
9
|
-
import { type S } from '@dxos/echo-schema';
|
|
10
10
|
import { findAnnotation } from '@dxos/effect';
|
|
11
11
|
import { type InputProps } from '@dxos/react-ui-form';
|
|
12
12
|
|
|
@@ -25,8 +25,11 @@ export default () =>
|
|
|
25
25
|
createSurface({
|
|
26
26
|
id: `${WNFS_PLUGIN}/create-form`,
|
|
27
27
|
role: 'form-input',
|
|
28
|
-
filter: (data): data is { prop: string; schema:
|
|
29
|
-
const annotation = findAnnotation<boolean>(
|
|
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
|
+
);
|
|
30
33
|
return !!annotation;
|
|
31
34
|
},
|
|
32
35
|
component: ({ data: { prop, schema }, ...props }) => {
|
|
@@ -25,7 +25,7 @@ const FileContainer = ({ file, role }: { file: FileType; role: string }) => {
|
|
|
25
25
|
invariant(space);
|
|
26
26
|
const { directory, forest } = await loadWnfs({ blockstore, instances, space });
|
|
27
27
|
const path = filePath(file.cid.toString(), space);
|
|
28
|
-
const url = await getBlobUrl({ wnfsUrl: wnfsUrl(path), blockstore, directory, forest });
|
|
28
|
+
const url = await getBlobUrl({ wnfsUrl: wnfsUrl(path), blockstore, directory, forest, type: file.type });
|
|
29
29
|
setBlobUrl(url);
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Schema
|
|
5
|
+
import { type Schema } from 'effect';
|
|
6
6
|
import React, { useCallback } from 'react';
|
|
7
7
|
import { useDropzone } from 'react-dropzone';
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ import { WNFS_PLUGIN } from '../meta';
|
|
|
14
14
|
import { WnfsAction } from '../types';
|
|
15
15
|
|
|
16
16
|
export type FileInputProps = {
|
|
17
|
-
schema:
|
|
17
|
+
schema: Schema.Schema.Any;
|
|
18
18
|
onChange: (file: File) => void;
|
|
19
19
|
};
|
|
20
20
|
|
package/src/components/index.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { lazy } from 'react';
|
|
6
6
|
|
|
7
|
-
export const FileContainer =
|
|
7
|
+
export const FileContainer = lazy(() => import('./FileContainer'));
|
|
8
8
|
|
|
9
9
|
export * from './FileInput';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import type { Blockstore } from 'interface-blockstore';
|
|
8
|
-
import React, { useEffect, useState } from 'react';
|
|
8
|
+
import React, { type ChangeEvent, useEffect, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { faker } from '@dxos/random';
|
|
11
11
|
import { useSpace } from '@dxos/react-client/echo';
|
|
@@ -63,7 +63,7 @@ const Story = () => {
|
|
|
63
63
|
[themeMode, blockstore, space],
|
|
64
64
|
);
|
|
65
65
|
|
|
66
|
-
const onFileChange = async (event:
|
|
66
|
+
const onFileChange = async (event: ChangeEvent<HTMLInputElement>) => {
|
|
67
67
|
const file = event.target.files?.[0];
|
|
68
68
|
if (file) {
|
|
69
69
|
if (blockstore) {
|
package/src/helpers/wnfs-url.ts
CHANGED
|
@@ -20,17 +20,19 @@ export const getPathFromUrl = (wnfsUrl: string) =>
|
|
|
20
20
|
export const getBlobUrl = async ({
|
|
21
21
|
wnfsUrl,
|
|
22
22
|
blockstore,
|
|
23
|
-
directory,
|
|
24
23
|
forest,
|
|
24
|
+
directory,
|
|
25
|
+
type,
|
|
25
26
|
}: {
|
|
26
27
|
wnfsUrl: string;
|
|
27
28
|
blockstore: Blockstore;
|
|
28
|
-
directory: PrivateDirectory;
|
|
29
29
|
forest: PrivateForest;
|
|
30
|
+
directory: PrivateDirectory;
|
|
31
|
+
type?: string;
|
|
30
32
|
}) => {
|
|
31
33
|
const path = getPathFromUrl(wnfsUrl);
|
|
32
34
|
const wnfsStore = store(blockstore);
|
|
33
35
|
const { result } = await directory.read(path, true, forest, wnfsStore);
|
|
34
|
-
const blob = new Blob([result]);
|
|
36
|
+
const blob = new Blob([result], { type });
|
|
35
37
|
return URL.createObjectURL(blob);
|
|
36
38
|
};
|
package/src/types/file.ts
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { TypedObject } from '@dxos/echo-schema';
|
|
6
8
|
|
|
7
9
|
export class FileType extends TypedObject({ typename: 'dxos.org/type/File', version: '0.1.0' })({
|
|
8
|
-
name:
|
|
9
|
-
type:
|
|
10
|
-
cid:
|
|
11
|
-
timestamp:
|
|
10
|
+
name: Schema.optional(Schema.String),
|
|
11
|
+
type: Schema.String,
|
|
12
|
+
cid: Schema.String,
|
|
13
|
+
timestamp: Schema.optional(Schema.String),
|
|
12
14
|
}) {}
|
package/src/types/types.ts
CHANGED
|
@@ -2,37 +2,39 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
5
7
|
import { FileInfoSchema } from '@dxos/app-framework';
|
|
6
|
-
import { S } from '@dxos/echo-schema';
|
|
7
8
|
import { SpaceSchema } from '@dxos/react-client/echo';
|
|
8
9
|
|
|
9
10
|
import { FileType } from './file';
|
|
10
11
|
import { WNFS_PLUGIN } from '../meta';
|
|
11
12
|
|
|
12
13
|
export namespace WnfsAction {
|
|
13
|
-
export class Create extends
|
|
14
|
-
input: FileInfoSchema.pick('name', 'type', 'cid').pipe(
|
|
15
|
-
output:
|
|
14
|
+
export class Create extends Schema.TaggedClass<Create>()(`${WNFS_PLUGIN}/action/create`, {
|
|
15
|
+
input: FileInfoSchema.pick('name', 'type', 'cid').pipe(Schema.required),
|
|
16
|
+
output: Schema.Struct({
|
|
16
17
|
object: FileType,
|
|
17
18
|
}),
|
|
18
19
|
}) {}
|
|
19
20
|
|
|
20
21
|
export const UploadAnnotationId = Symbol.for(`${WNFS_PLUGIN}/annotation/upload`);
|
|
21
22
|
|
|
22
|
-
export const UploadFileSchema =
|
|
23
|
-
file:
|
|
23
|
+
export const UploadFileSchema = Schema.Struct({
|
|
24
|
+
file: Schema.instanceOf(File).annotations({
|
|
24
25
|
[UploadAnnotationId]: {
|
|
25
26
|
// Accept file types.
|
|
26
27
|
'image/*': ['.jpg', '.jpeg', '.png', '.gif'],
|
|
28
|
+
'application/pdf': ['.pdf'],
|
|
27
29
|
// TODO(wittjosiah): Add more file types.
|
|
28
30
|
},
|
|
29
31
|
}),
|
|
30
32
|
});
|
|
31
33
|
|
|
32
|
-
export type UploadFileForm =
|
|
34
|
+
export type UploadFileForm = Schema.Schema.Type<typeof UploadFileSchema>;
|
|
33
35
|
|
|
34
|
-
export class Upload extends
|
|
35
|
-
input:
|
|
36
|
-
output:
|
|
36
|
+
export class Upload extends Schema.TaggedClass<Upload>()(`${WNFS_PLUGIN}/action/upload`, {
|
|
37
|
+
input: Schema.extend(UploadFileSchema, Schema.Struct({ space: SpaceSchema })),
|
|
38
|
+
output: Schema.required(FileInfoSchema),
|
|
37
39
|
}) {}
|
|
38
40
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// packages/plugins/plugin-wnfs/src/capabilities/index.ts
|
|
2
|
-
import { lazy } from "@dxos/app-framework";
|
|
3
|
-
var Blockstore = lazy(() => import("./blockstore-G47Q25U6.mjs"));
|
|
4
|
-
var FileUploader = lazy(() => import("./file-uploader-L4TDVJBE.mjs"));
|
|
5
|
-
var IntentResolver = lazy(() => import("./intent-resolver-VSMIQLGS.mjs"));
|
|
6
|
-
var Markdown = lazy(() => import("./markdown-MWMZVPEX.mjs"));
|
|
7
|
-
var ReactSurface = lazy(() => import("./react-surface-MKJYHQ4P.mjs"));
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
Blockstore,
|
|
11
|
-
FileUploader,
|
|
12
|
-
IntentResolver,
|
|
13
|
-
Markdown,
|
|
14
|
-
ReactSurface
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=chunk-FH2Q7ZBE.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/file.ts", "../../../src/types/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { S, TypedObject } from '@dxos/echo-schema';\n\nexport class FileType extends TypedObject({ typename: 'dxos.org/type/File', version: '0.1.0' })({\n name: S.optional(S.String),\n type: S.String,\n cid: S.String,\n timestamp: S.optional(S.String),\n}) {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { FileInfoSchema } from '@dxos/app-framework';\nimport { S } from '@dxos/echo-schema';\nimport { SpaceSchema } from '@dxos/react-client/echo';\n\nimport { FileType } from './file';\nimport { WNFS_PLUGIN } from '../meta';\n\nexport namespace WnfsAction {\n export class Create extends S.TaggedClass<Create>()(`${WNFS_PLUGIN}/action/create`, {\n input: FileInfoSchema.pick('name', 'type', 'cid').pipe(S.required),\n output: S.Struct({\n object: FileType,\n }),\n }) {}\n\n export const UploadAnnotationId = Symbol.for(`${WNFS_PLUGIN}/annotation/upload`);\n\n export const UploadFileSchema = S.Struct({\n file: S.instanceOf(File).annotations({\n [UploadAnnotationId]: {\n // Accept file types.\n 'image/*': ['.jpg', '.jpeg', '.png', '.gif'],\n // TODO(wittjosiah): Add more file types.\n },\n }),\n });\n\n export type UploadFileForm = S.Schema.Type<typeof UploadFileSchema>;\n\n export class Upload extends S.TaggedClass<Upload>()(`${WNFS_PLUGIN}/action/upload`, {\n input: S.extend(UploadFileSchema, S.Struct({ space: SpaceSchema })),\n output: S.required(FileInfoSchema),\n }) {}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,SAASA,GAAGC,mBAAmB;AAExB,IAAMC,WAAN,cAAuBC,YAAY;EAAEC,UAAU;EAAsBC,SAAS;AAAQ,CAAA,EAAG;EAC9FC,MAAMC,EAAEC,SAASD,EAAEE,MAAM;EACzBC,MAAMH,EAAEE;EACRE,KAAKJ,EAAEE;EACPG,WAAWL,EAAEC,SAASD,EAAEE,MAAM;AAChC,CAAA,EAAA;AAAI;;;ACPJ,SAASI,sBAAsB;AAC/B,SAASC,KAAAA,UAAS;AAClB,SAASC,mBAAmB;;UAKXC,aAAAA;EACR,MAAMC,eAAeC,GAAEC,YAAW,EAAW,GAAGC,WAAAA,kBAA6B;IAClFC,OAAOC,eAAeC,KAAK,QAAQ,QAAQ,KAAA,EAAOC,KAAKN,GAAEO,QAAQ;IACjEC,QAAQR,GAAES,OAAO;MACfC,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;cALSZ,SAAAA;cAOAa,qBAAqBC,OAAOC,IAAI,GAAGZ,WAAAA,oBAA+B;cAElEa,mBAAmBf,GAAES,OAAO;IACvCO,MAAMhB,GAAEiB,WAAWC,IAAAA,EAAMC,YAAY;MACnC,CAAArB,YAACc,kBAAAA,GAAqB;;QAEpB,WAAW;UAAC;UAAQ;UAAS;UAAQ;;MAEvC;IACF,CAAA;EACF,CAAA;EAIO,MAAMQ,eAAepB,GAAEC,YAAW,EAAW,GAAGC,WAAAA,kBAA6B;IAClFC,OAAOH,GAAEqB,OAAMvB,YAACiB,kBAAkBf,GAAES,OAAO;MAAEa,OAAOC;IAAY,CAAA,CAAA;IAChEf,QAAQR,GAAEO,SAASH,cAAAA;EACrB,CAAA,EAAA;EAAI;cAHSgB,SAAAA;AAIf,GA1BiBtB,eAAAA,aAAAA,CAAAA,EAAAA;",
|
|
6
|
-
"names": ["S", "TypedObject", "FileType", "TypedObject", "typename", "version", "name", "S", "optional", "String", "type", "cid", "timestamp", "FileInfoSchema", "S", "SpaceSchema", "WnfsAction", "Create", "S", "TaggedClass", "WNFS_PLUGIN", "input", "FileInfoSchema", "pick", "pipe", "required", "output", "Struct", "object", "FileType", "UploadAnnotationId", "Symbol", "for", "UploadFileSchema", "file", "instanceOf", "File", "annotations", "Upload", "extend", "space", "SpaceSchema"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/intent-resolver.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { contributes, Capabilities, createResolver, type PluginsContext } from '@dxos/app-framework';\nimport { create } from '@dxos/react-client/echo';\n\nimport { WnfsCapabilities } from './capabilities';\nimport { upload } from '../helpers';\nimport { FileType, WnfsAction } from '../types';\n\nexport default (context: PluginsContext) =>\n contributes(Capabilities.IntentResolver, [\n // TODO(wittjosiah): Deleting the object doesn't delete the wnfs blob.\n // Consider ways to trigger blob deletion based on object deletion and/or adding file system manager.\n createResolver({\n intent: WnfsAction.Create,\n resolve: ({ name, type, cid }) => ({\n data: {\n object: create(FileType, { name, type, cid }),\n },\n }),\n }),\n createResolver({\n intent: WnfsAction.Upload,\n resolve: async ({ file, space }) => {\n const blockstore = context.requestCapability(WnfsCapabilities.Blockstore);\n const info = await upload({ file, blockstore, space });\n return { data: info };\n },\n }),\n ]);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;AAIA,SAASA,aAAaC,cAAcC,sBAA2C;AAC/E,SAASC,cAAc;AAMvB,IAAA,0BAAe,CAACC,YACdC,YAAYC,aAAaC,gBAAgB;;;EAGvCC,eAAe;IACbC,QAAQC,WAAWC;IACnBC,SAAS,CAAC,EAAEC,MAAMC,MAAMC,IAAG,OAAQ;MACjCC,MAAM;QACJC,QAAQC,OAAOC,UAAU;UAAEN;UAAMC;UAAMC;QAAI,CAAA;MAC7C;IACF;EACF,CAAA;EACAP,eAAe;IACbC,QAAQC,WAAWU;IACnBR,SAAS,OAAO,EAAES,MAAMC,MAAK,MAAE;AAC7B,YAAMC,aAAanB,QAAQoB,kBAAkBC,iBAAiBC,UAAU;AACxE,YAAMC,OAAO,MAAMC,OAAO;QAAEP;QAAME;QAAYD;MAAM,CAAA;AACpD,aAAO;QAAEN,MAAMW;MAAK;IACtB;EACF,CAAA;CACD;",
|
|
6
|
-
"names": ["contributes", "Capabilities", "createResolver", "create", "context", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "WnfsAction", "Create", "resolve", "name", "type", "cid", "data", "object", "create", "FileType", "Upload", "file", "space", "blockstore", "requestCapability", "WnfsCapabilities", "Blockstore", "info", "upload"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface.tsx", "../../../src/components/index.ts", "../../../src/components/FileInput.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { contributes, Capabilities, createSurface } from '@dxos/app-framework';\nimport { isInstanceOf } from '@dxos/echo-schema';\nimport { type S } from '@dxos/echo-schema';\nimport { findAnnotation } from '@dxos/effect';\nimport { type InputProps } from '@dxos/react-ui-form';\n\nimport { FileContainer, FileInput } from '../components';\nimport { WNFS_PLUGIN } from '../meta';\nimport { FileType, WnfsAction } from '../types';\n\nexport default () =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: `${WNFS_PLUGIN}/article`,\n role: ['article', 'section', 'slide'],\n filter: (data): data is { subject: FileType } => isInstanceOf(FileType, data.subject),\n component: ({ data, role }) => <FileContainer role={role} file={data.subject} />,\n }),\n createSurface({\n id: `${WNFS_PLUGIN}/create-form`,\n role: 'form-input',\n filter: (data): data is { prop: string; schema: S.Schema.Any } => {\n const annotation = findAnnotation<boolean>((data.schema as S.Schema.All).ast, WnfsAction.UploadAnnotationId);\n return !!annotation;\n },\n component: ({ data: { prop, schema }, ...props }) => {\n const inputProps = props as unknown as InputProps;\n const handleChange = useCallback(\n (file: File) => inputProps.onValueChange?.('object', file),\n [prop, inputProps.onValueChange],\n );\n\n return <FileInput schema={schema} onChange={handleChange} />;\n },\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nexport const FileContainer = React.lazy(() => import('./FileContainer'));\n\nexport * from './FileInput';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema as S } from 'effect';\nimport React, { useCallback } from 'react';\nimport { useDropzone } from 'react-dropzone';\n\nimport { findAnnotation } from '@dxos/effect';\nimport { useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { WNFS_PLUGIN } from '../meta';\nimport { WnfsAction } from '../types';\n\nexport type FileInputProps = {\n schema: S.Schema.Any;\n onChange: (file: File) => void;\n};\n\nexport const FileInput = ({ schema, onChange }: FileInputProps) => {\n const { t } = useTranslation(WNFS_PLUGIN);\n const accept = findAnnotation<Record<string, string[]>>(schema.ast, WnfsAction.UploadAnnotationId);\n\n const onDropAccepted = useCallback((files: File[]) => onChange?.(files[0]), [onChange]);\n\n const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({\n multiple: false,\n accept,\n onDropAccepted,\n });\n\n return (\n <div\n {...getRootProps()}\n className={mx(\n 'flex flex-col items-center p-8 border border-separator',\n isFocused && 'focus-ring',\n isDragAccept && 'bg-attention',\n isDragReject && 'border-error',\n )}\n >\n <input {...getInputProps()} />\n {acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file input placeholder')}</p>}\n </div>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,OAAOA,UAASC,eAAAA,oBAAmB;AAEnC,SAASC,aAAaC,cAAcC,qBAAqB;AACzD,SAASC,oBAAoB;AAE7B,SAASC,kBAAAA,uBAAsB;;;ACL/B,OAAOC,YAAW;;;ACClB,OAAOC,SAASC,mBAAmB;AACnC,SAASC,mBAAmB;AAE5B,SAASC,sBAAsB;AAC/B,SAASC,sBAAsB;AAC/B,SAASC,UAAU;AAUZ,IAAMC,YAAY,CAAC,EAAEC,QAAQC,SAAQ,MAAkB;AAC5D,QAAM,EAAEC,EAAC,IAAKC,eAAeC,WAAAA;AAC7B,QAAMC,SAASC,eAAyCN,OAAOO,KAAKC,WAAWC,kBAAkB;AAEjG,QAAMC,iBAAiBC,YAAY,CAACC,UAAkBX,WAAWW,MAAM,CAAA,CAAE,GAAG;IAACX;GAAS;AAEtF,QAAM,EAAEY,eAAeC,cAAcC,eAAeC,WAAWC,cAAcC,aAAY,IAAKC,YAAY;IACxGC,UAAU;IACVf;IACAK;EACF,CAAA;AAEA,SACE,sBAAA,cAACW,OAAAA;IACE,GAAGP,aAAAA;IACJQ,WAAWC,GACT,0DACAP,aAAa,cACbC,gBAAgB,gBAChBC,gBAAgB,cAAA;KAGlB,sBAAA,cAACM,SAAUT,cAAAA,CAAAA,GACVF,cAAc,CAAA,IAAK,sBAAA,cAACY,KAAAA,MAAGZ,cAAc,CAAA,EAAGa,IAAI,IAAQ,sBAAA,cAACD,KAAAA,MAAGvB,EAAE,wBAAA,CAAA,CAAA;AAGjE;;;ADxCO,IAAMyB,gBAAgBC,OAAMC,KAAK,MAAM,OAAO,8BAAA,CAAA;;;ADUrD,IAAA,wBAAe,MACbC,YAAYC,aAAaC,cAAc;EACrCC,cAAc;IACZC,IAAI,GAAGC,WAAAA;IACPC,MAAM;MAAC;MAAW;MAAW;;IAC7BC,QAAQ,CAACC,SAAwCC,aAAaC,UAAUF,KAAKG,OAAO;IACpFC,WAAW,CAAC,EAAEJ,MAAMF,KAAI,MAAO,gBAAAO,OAAA,cAACC,eAAAA;MAAcR;MAAYS,MAAMP,KAAKG;;EACvE,CAAA;EACAR,cAAc;IACZC,IAAI,GAAGC,WAAAA;IACPC,MAAM;IACNC,QAAQ,CAACC,SAAAA;AACP,YAAMQ,aAAaC,gBAAyBT,KAAKU,OAAwBC,KAAKC,WAAWC,kBAAkB;AAC3G,aAAO,CAAC,CAACL;IACX;IACAJ,WAAW,CAAC,EAAEJ,MAAM,EAAEc,MAAMJ,OAAM,GAAI,GAAGK,MAAAA,MAAO;AAC9C,YAAMC,aAAaD;AACnB,YAAME,eAAeC,aACnB,CAACX,SAAeS,WAAWG,gBAAgB,UAAUZ,IAAAA,GACrD;QAACO;QAAME,WAAWG;OAAc;AAGlC,aAAO,gBAAAd,OAAA,cAACe,WAAAA;QAAUV;QAAgBW,UAAUJ;;IAC9C;EACF,CAAA;CACD;",
|
|
6
|
-
"names": ["React", "useCallback", "contributes", "Capabilities", "createSurface", "isInstanceOf", "findAnnotation", "React", "React", "useCallback", "useDropzone", "findAnnotation", "useTranslation", "mx", "FileInput", "schema", "onChange", "t", "useTranslation", "WNFS_PLUGIN", "accept", "findAnnotation", "ast", "WnfsAction", "UploadAnnotationId", "onDropAccepted", "useCallback", "files", "acceptedFiles", "getRootProps", "getInputProps", "isFocused", "isDragAccept", "isDragReject", "useDropzone", "multiple", "div", "className", "mx", "input", "p", "name", "FileContainer", "React", "lazy", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "WNFS_PLUGIN", "role", "filter", "data", "isInstanceOf", "FileType", "subject", "component", "React", "FileContainer", "file", "annotation", "findAnnotation", "schema", "ast", "WnfsAction", "UploadAnnotationId", "prop", "props", "inputProps", "handleChange", "useCallback", "onValueChange", "FileInput", "onChange"]
|
|
7
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|