@dxos/plugin-wnfs 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/lib/browser/chunk-4D4K5JCC.mjs +66 -0
- package/dist/lib/browser/chunk-4D4K5JCC.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-CGW32EZB.mjs → browser/chunk-7KFJ6LYH.mjs} +44 -21
- package/dist/lib/browser/chunk-7KFJ6LYH.mjs.map +7 -0
- package/dist/lib/browser/chunk-DK62NQ5T.mjs +71 -0
- package/dist/lib/browser/chunk-DK62NQ5T.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/create-QRLX4IMZ.mjs +25 -0
- package/dist/lib/browser/create-QRLX4IMZ.mjs.map +7 -0
- package/dist/lib/browser/create-file-INAT56PX.mjs +42 -0
- package/dist/lib/browser/create-file-INAT56PX.mjs.map +7 -0
- package/dist/lib/browser/helpers/index.mjs +26 -0
- package/dist/lib/browser/helpers/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +79 -103
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +14 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/translations.mjs +30 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +8 -6
- package/dist/lib/browser/upload-ZQI66T4Y.mjs +35 -0
- package/dist/lib/browser/upload-ZQI66T4Y.mjs.map +7 -0
- package/dist/types/src/WnfsPlugin.d.ts +2 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +3 -2
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +4 -2
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +4 -2
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +1 -1
- package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
- package/dist/types/src/components/FileInput/index.d.ts +2 -0
- package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts +12 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/index.d.ts +2 -0
- package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FileContainer/index.d.ts +2 -0
- package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/image.d.ts +1 -1
- package/dist/types/src/extensions/image.d.ts.map +1 -1
- package/dist/types/src/extensions/image.stories.d.ts +5 -4
- package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
- package/dist/types/src/helpers/common.d.ts.map +1 -1
- package/dist/types/src/helpers/load.d.ts +2 -2
- package/dist/types/src/helpers/load.d.ts.map +1 -1
- package/dist/types/src/helpers/upload.d.ts +1 -1
- package/dist/types/src/helpers/upload.d.ts.map +1 -1
- package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-file.d.ts +5 -0
- package/dist/types/src/operations/create-file.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +38 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/upload.d.ts +5 -0
- package/dist/types/src/operations/upload.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +24 -10
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts +16 -0
- package/dist/types/src/types/File.d.ts.map +1 -0
- package/dist/types/src/{capabilities → types}/capabilities.d.ts +3 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +4 -46
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +73 -47
- package/src/WnfsPlugin.tsx +66 -85
- package/src/blockstore.ts +3 -3
- package/src/capabilities/blockstore.ts +15 -10
- package/src/capabilities/file-uploader.ts +25 -15
- package/src/capabilities/index.ts +10 -8
- package/src/capabilities/markdown.ts +25 -12
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +50 -35
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +8 -8
- package/src/components/FileInput/index.ts +5 -0
- package/src/components/FilePreview/FilePreview.tsx +43 -0
- package/src/components/FilePreview/index.ts +5 -0
- package/src/components/index.ts +1 -4
- package/src/containers/FileContainer/FileContainer.tsx +57 -0
- package/src/containers/FileContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +22 -19
- package/src/extensions/image.tsx +10 -9
- package/src/helpers/load.ts +14 -8
- package/src/helpers/upload.ts +6 -2
- package/src/index.ts +1 -1
- package/src/meta.ts +9 -6
- package/src/operations/create-file.ts +31 -0
- package/src/operations/create.ts +22 -0
- package/src/operations/definitions.ts +41 -0
- package/src/operations/index.ts +13 -0
- package/src/operations/upload.ts +29 -0
- package/src/translations.ts +14 -8
- package/src/types/File.ts +28 -0
- package/src/{capabilities → types}/capabilities.ts +4 -4
- package/src/types/index.ts +2 -1
- package/src/types/types.ts +3 -19
- package/dist/lib/browser/FileContainer-Q4GUPBVD.mjs +0 -107
- package/dist/lib/browser/FileContainer-Q4GUPBVD.mjs.map +0 -7
- package/dist/lib/browser/blockstore-KQO2NTVM.mjs +0 -191
- package/dist/lib/browser/blockstore-KQO2NTVM.mjs.map +0 -7
- package/dist/lib/browser/chunk-BANMVVJV.mjs +0 -16
- package/dist/lib/browser/chunk-BANMVVJV.mjs.map +0 -7
- package/dist/lib/browser/chunk-GVBV2QWA.mjs +0 -64
- package/dist/lib/browser/chunk-GVBV2QWA.mjs.map +0 -7
- package/dist/lib/browser/chunk-KZANQHJY.mjs +0 -16
- package/dist/lib/browser/chunk-KZANQHJY.mjs.map +0 -7
- package/dist/lib/browser/chunk-VDDGZWAY.mjs +0 -15
- package/dist/lib/browser/chunk-VDDGZWAY.mjs.map +0 -7
- package/dist/lib/browser/chunk-VRRXG6IB.mjs +0 -159
- package/dist/lib/browser/chunk-VRRXG6IB.mjs.map +0 -7
- package/dist/lib/browser/file-uploader-JA55DPMW.mjs +0 -29
- package/dist/lib/browser/file-uploader-JA55DPMW.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-YM6QRFIH.mjs +0 -49
- package/dist/lib/browser/intent-resolver-YM6QRFIH.mjs.map +0 -7
- package/dist/lib/browser/markdown-6VH477GB.mjs +0 -196
- package/dist/lib/browser/markdown-6VH477GB.mjs.map +0 -7
- package/dist/lib/browser/react-surface-XAHVMWIH.mjs +0 -88
- package/dist/lib/browser/react-surface-XAHVMWIH.mjs.map +0 -7
- package/dist/lib/node-esm/FileContainer-22IPNDDA.mjs +0 -108
- package/dist/lib/node-esm/FileContainer-22IPNDDA.mjs.map +0 -7
- package/dist/lib/node-esm/blockstore-7KQTFHK5.mjs +0 -192
- package/dist/lib/node-esm/blockstore-7KQTFHK5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-47QYKNA6.mjs +0 -17
- package/dist/lib/node-esm/chunk-47QYKNA6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BM37ZAHF.mjs +0 -65
- package/dist/lib/node-esm/chunk-BM37ZAHF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CGW32EZB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DWYM7FD7.mjs +0 -18
- package/dist/lib/node-esm/chunk-DWYM7FD7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YTWL64Z6.mjs +0 -17
- package/dist/lib/node-esm/chunk-YTWL64Z6.mjs.map +0 -7
- package/dist/lib/node-esm/file-uploader-WGDG2YV5.mjs +0 -30
- package/dist/lib/node-esm/file-uploader-WGDG2YV5.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -117
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-5QOT2SLD.mjs +0 -50
- package/dist/lib/node-esm/intent-resolver-5QOT2SLD.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-R4PBXDJO.mjs +0 -197
- package/dist/lib/node-esm/markdown-R4PBXDJO.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-HAOUJUXJ.mjs +0 -89
- package/dist/lib/node-esm/react-surface-HAOUJUXJ.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -11
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/FileContainer.d.ts +0 -9
- package/dist/types/src/components/FileContainer.d.ts.map +0 -1
- package/dist/types/src/components/FileInput.d.ts.map +0 -1
- package/dist/types/src/components/FilePreview.d.ts +0 -11
- package/dist/types/src/components/FilePreview.d.ts.map +0 -1
- package/dist/types/src/types/file.d.ts +0 -16
- package/dist/types/src/types/file.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -32
- package/src/components/FileContainer.tsx +0 -51
- package/src/components/FilePreview.tsx +0 -23
- package/src/types/file.ts +0 -17
- /package/dist/lib/{node-esm/types/index.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
package/src/types/types.ts
CHANGED
|
@@ -2,23 +2,12 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { SpaceSchema } from '@dxos/react-client/echo';
|
|
9
|
-
|
|
10
|
-
import { FileType } from './file';
|
|
11
|
-
import { WNFS_PLUGIN } from '../meta';
|
|
7
|
+
import { meta } from '#meta';
|
|
12
8
|
|
|
13
9
|
export namespace WnfsAction {
|
|
14
|
-
export
|
|
15
|
-
input: FileInfoSchema.pick('name', 'type', 'cid').pipe(Schema.required),
|
|
16
|
-
output: Schema.Struct({
|
|
17
|
-
object: FileType,
|
|
18
|
-
}),
|
|
19
|
-
}) {}
|
|
20
|
-
|
|
21
|
-
export const UploadAnnotationId = Symbol.for(`${WNFS_PLUGIN}/annotation/upload`);
|
|
10
|
+
export const UploadAnnotationId = Symbol.for(`${meta.id}.annotation.upload`);
|
|
22
11
|
|
|
23
12
|
export const UploadFileSchema = Schema.Struct({
|
|
24
13
|
file: Schema.instanceOf(File).annotations({
|
|
@@ -32,9 +21,4 @@ export namespace WnfsAction {
|
|
|
32
21
|
});
|
|
33
22
|
|
|
34
23
|
export type UploadFileForm = Schema.Schema.Type<typeof UploadFileSchema>;
|
|
35
|
-
|
|
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),
|
|
39
|
-
}) {}
|
|
40
24
|
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import "./chunk-BANMVVJV.mjs";
|
|
2
|
-
import {
|
|
3
|
-
filePath,
|
|
4
|
-
getBlobUrl,
|
|
5
|
-
loadWnfs,
|
|
6
|
-
wnfsUrl
|
|
7
|
-
} from "./chunk-VRRXG6IB.mjs";
|
|
8
|
-
import {
|
|
9
|
-
WnfsCapabilities
|
|
10
|
-
} from "./chunk-KZANQHJY.mjs";
|
|
11
|
-
import "./chunk-VDDGZWAY.mjs";
|
|
12
|
-
|
|
13
|
-
// src/components/FileContainer.tsx
|
|
14
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
15
|
-
import React2, { useEffect, useState } from "react";
|
|
16
|
-
import { useCapability } from "@dxos/app-framework";
|
|
17
|
-
import { invariant } from "@dxos/invariant";
|
|
18
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
19
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
20
|
-
|
|
21
|
-
// src/components/FilePreview.tsx
|
|
22
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
23
|
-
import React from "react";
|
|
24
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
25
|
-
var FilePreview = ({ type, url, classNames }) => {
|
|
26
|
-
var _effect = _useSignals();
|
|
27
|
-
try {
|
|
28
|
-
if (type.startsWith("image/")) {
|
|
29
|
-
return /* @__PURE__ */ React.createElement("img", {
|
|
30
|
-
className: mx("w-full h-full object-contain", classNames),
|
|
31
|
-
src: url
|
|
32
|
-
});
|
|
33
|
-
} else if (type.startsWith("video/")) {
|
|
34
|
-
return /* @__PURE__ */ React.createElement("video", {
|
|
35
|
-
className: mx("w-full h-full object-contain", classNames),
|
|
36
|
-
src: url,
|
|
37
|
-
controls: true
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
return /* @__PURE__ */ React.createElement("iframe", {
|
|
41
|
-
className: mx("w-full h-full overflow-auto", classNames),
|
|
42
|
-
src: url
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
} finally {
|
|
46
|
-
_effect.f();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// src/components/FileContainer.tsx
|
|
51
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-wnfs/src/components/FileContainer.tsx";
|
|
52
|
-
var FileContainer = ({ role, file }) => {
|
|
53
|
-
var _effect = _useSignals2();
|
|
54
|
-
try {
|
|
55
|
-
const blockstore = useCapability(WnfsCapabilities.Blockstore);
|
|
56
|
-
const instances = useCapability(WnfsCapabilities.Instances);
|
|
57
|
-
const [blobUrl, setBlobUrl] = useState();
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
const timeout = setTimeout(async () => {
|
|
60
|
-
const space = getSpace(file);
|
|
61
|
-
invariant(space, void 0, {
|
|
62
|
-
F: __dxlog_file,
|
|
63
|
-
L: 30,
|
|
64
|
-
S: void 0,
|
|
65
|
-
A: [
|
|
66
|
-
"space",
|
|
67
|
-
""
|
|
68
|
-
]
|
|
69
|
-
});
|
|
70
|
-
const { directory, forest } = await loadWnfs({
|
|
71
|
-
blockstore,
|
|
72
|
-
instances,
|
|
73
|
-
space
|
|
74
|
-
});
|
|
75
|
-
const path = filePath(file.cid.toString(), space);
|
|
76
|
-
const url = await getBlobUrl({
|
|
77
|
-
wnfsUrl: wnfsUrl(path),
|
|
78
|
-
blockstore,
|
|
79
|
-
directory,
|
|
80
|
-
forest,
|
|
81
|
-
type: file.type
|
|
82
|
-
});
|
|
83
|
-
setBlobUrl(url);
|
|
84
|
-
});
|
|
85
|
-
return () => clearTimeout(timeout);
|
|
86
|
-
}, [
|
|
87
|
-
file
|
|
88
|
-
]);
|
|
89
|
-
if (!blobUrl) {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
return /* @__PURE__ */ React2.createElement(StackItem.Content, {
|
|
93
|
-
role
|
|
94
|
-
}, /* @__PURE__ */ React2.createElement(FilePreview, {
|
|
95
|
-
type: file.type,
|
|
96
|
-
url: blobUrl
|
|
97
|
-
}));
|
|
98
|
-
} finally {
|
|
99
|
-
_effect.f();
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
var FileContainer_default = FileContainer;
|
|
103
|
-
export {
|
|
104
|
-
FileContainer,
|
|
105
|
-
FileContainer_default as default
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=FileContainer-Q4GUPBVD.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/FileContainer.tsx", "../../../src/components/FilePreview.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useEffect, useState } from 'react';\n\nimport { useCapability } from '@dxos/app-framework';\nimport { invariant } from '@dxos/invariant';\nimport { getSpace } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { FilePreview } from './FilePreview';\nimport { WnfsCapabilities } from '../capabilities';\nimport { filePath, getBlobUrl, loadWnfs, wnfsUrl } from '../helpers';\nimport { type FileType } from '../types';\n\nexport type FileContainerProps = {\n role: string;\n file: FileType;\n};\n\nexport const FileContainer = ({ role, file }: FileContainerProps) => {\n const blockstore = useCapability(WnfsCapabilities.Blockstore);\n const instances = useCapability(WnfsCapabilities.Instances);\n const [blobUrl, setBlobUrl] = useState<string>();\n\n useEffect(() => {\n const timeout = setTimeout(async () => {\n const space = getSpace(file);\n invariant(space);\n const { directory, forest } = await loadWnfs({ blockstore, instances, space });\n const path = filePath(file.cid.toString(), space);\n const url = await getBlobUrl({ wnfsUrl: wnfsUrl(path), blockstore, directory, forest, type: file.type });\n setBlobUrl(url);\n });\n\n return () => clearTimeout(timeout);\n }, [file]);\n\n if (!blobUrl) {\n return null;\n }\n\n return (\n <StackItem.Content role={role}>\n <FilePreview type={file.type} url={blobUrl} />\n </StackItem.Content>\n );\n};\n\nexport default FileContainer;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nexport type FilePreviewProps = ThemedClassName<{ type: string; url: string }>;\n\n/**\n * File/content preview iframe.\n */\nexport const FilePreview = ({ type, url, classNames }: FilePreviewProps) => {\n if (type.startsWith('image/')) {\n return <img className={mx('w-full h-full object-contain', classNames)} src={url} />;\n } else if (type.startsWith('video/')) {\n return <video className={mx('w-full h-full object-contain', classNames)} src={url} controls />;\n } else {\n return <iframe className={mx('w-full h-full overflow-auto', classNames)} src={url} />;\n }\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;AAIA,OAAOA,UAASC,WAAWC,gBAAgB;AAE3C,SAASC,qBAAqB;AAC9B,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;;;;ACL1B,OAAOC,WAAW;AAGlB,SAASC,UAAU;AAOZ,IAAMC,cAAc,CAAC,EAAEC,MAAMC,KAAKC,WAAU,MAAoB;;;AACrE,QAAIF,KAAKG,WAAW,QAAA,GAAW;AAC7B,aAAO,sBAAA,cAACC,OAAAA;QAAIC,WAAWC,GAAG,gCAAgCJ,UAAAA;QAAaK,KAAKN;;IAC9E,WAAWD,KAAKG,WAAW,QAAA,GAAW;AACpC,aAAO,sBAAA,cAACK,SAAAA;QAAMH,WAAWC,GAAG,gCAAgCJ,UAAAA;QAAaK,KAAKN;QAAKQ,UAAAA;;IACrF,OAAO;AACL,aAAO,sBAAA,cAACC,UAAAA;QAAOL,WAAWC,GAAG,+BAA+BJ,UAAAA;QAAaK,KAAKN;;IAChF;;;;AACF;;;;ADDO,IAAMU,gBAAgB,CAAC,EAAEC,MAAMC,KAAI,MAAsB;;;AAC9D,UAAMC,aAAaC,cAAcC,iBAAiBC,UAAU;AAC5D,UAAMC,YAAYH,cAAcC,iBAAiBG,SAAS;AAC1D,UAAM,CAACC,SAASC,UAAAA,IAAcC,SAAAA;AAE9BC,cAAU,MAAA;AACR,YAAMC,UAAUC,WAAW,YAAA;AACzB,cAAMC,QAAQC,SAASd,IAAAA;AACvBe,kBAAUF,OAAAA,QAAAA;;;;;;;;;AACV,cAAM,EAAEG,WAAWC,OAAM,IAAK,MAAMC,SAAS;UAAEjB;UAAYI;UAAWQ;QAAM,CAAA;AAC5E,cAAMM,OAAOC,SAASpB,KAAKqB,IAAIC,SAAQ,GAAIT,KAAAA;AAC3C,cAAMU,MAAM,MAAMC,WAAW;UAAEC,SAASA,QAAQN,IAAAA;UAAOlB;UAAYe;UAAWC;UAAQS,MAAM1B,KAAK0B;QAAK,CAAA;AACtGlB,mBAAWe,GAAAA;MACb,CAAA;AAEA,aAAO,MAAMI,aAAahB,OAAAA;IAC5B,GAAG;MAACX;KAAK;AAET,QAAI,CAACO,SAAS;AACZ,aAAO;IACT;AAEA,WACE,gBAAAqB,OAAA,cAACC,UAAUC,SAAO;MAAC/B;OACjB,gBAAA6B,OAAA,cAACG,aAAAA;MAAYL,MAAM1B,KAAK0B;MAAMH,KAAKhB;;;;;AAGzC;AAEA,IAAA,wBAAeT;",
|
|
6
|
-
"names": ["React", "useEffect", "useState", "useCapability", "invariant", "getSpace", "StackItem", "React", "mx", "FilePreview", "type", "url", "classNames", "startsWith", "img", "className", "mx", "src", "video", "controls", "iframe", "FileContainer", "role", "file", "blockstore", "useCapability", "WnfsCapabilities", "Blockstore", "instances", "Instances", "blobUrl", "setBlobUrl", "useState", "useEffect", "timeout", "setTimeout", "space", "getSpace", "invariant", "directory", "forest", "loadWnfs", "path", "filePath", "cid", "toString", "url", "getBlobUrl", "wnfsUrl", "type", "clearTimeout", "React", "StackItem", "Content", "FilePreview"]
|
|
7
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
storeName
|
|
3
|
-
} from "./chunk-VRRXG6IB.mjs";
|
|
4
|
-
import {
|
|
5
|
-
WnfsCapabilities
|
|
6
|
-
} from "./chunk-KZANQHJY.mjs";
|
|
7
|
-
import "./chunk-VDDGZWAY.mjs";
|
|
8
|
-
|
|
9
|
-
// src/capabilities/blockstore.ts
|
|
10
|
-
import { contributes } from "@dxos/app-framework";
|
|
11
|
-
import { ClientCapabilities } from "@dxos/plugin-client";
|
|
12
|
-
|
|
13
|
-
// src/blockstore.ts
|
|
14
|
-
import { CarWriter } from "@ipld/car";
|
|
15
|
-
import { BaseBlockstore } from "blockstore-core";
|
|
16
|
-
import { IDBBlockstore } from "blockstore-idb";
|
|
17
|
-
import debounce from "debounce";
|
|
18
|
-
import * as IDB from "idb-keyval";
|
|
19
|
-
import all from "it-all";
|
|
20
|
-
import { CID } from "multiformats";
|
|
21
|
-
import * as Uint8Arrays from "uint8arrays";
|
|
22
|
-
var create = (apiHost) => {
|
|
23
|
-
return new MixedBlockstore(apiHost);
|
|
24
|
-
};
|
|
25
|
-
var MixedBlockstore = class extends BaseBlockstore {
|
|
26
|
-
constructor(apiHost) {
|
|
27
|
-
super();
|
|
28
|
-
// QUEUE
|
|
29
|
-
this.queueCacheName = `${storeName()}/state/queue`;
|
|
30
|
-
this.#apiHost = apiHost ? apiHost.replace(/\/?$/, "") : void 0;
|
|
31
|
-
this.#localStore = new IDBBlockstore(storeName());
|
|
32
|
-
this.#isConnected = navigator.onLine;
|
|
33
|
-
this.#queue = [];
|
|
34
|
-
this.#flushQueue = debounce(this.#flushQueueInt, 5e3);
|
|
35
|
-
}
|
|
36
|
-
#apiHost;
|
|
37
|
-
#localStore;
|
|
38
|
-
#isConnected;
|
|
39
|
-
#flushQueue;
|
|
40
|
-
#queue;
|
|
41
|
-
async open() {
|
|
42
|
-
await this.#localStore.open();
|
|
43
|
-
await this.#restoreQueue();
|
|
44
|
-
window.addEventListener("offline", async () => {
|
|
45
|
-
this.#isConnected = false;
|
|
46
|
-
});
|
|
47
|
-
window.addEventListener("online", async () => {
|
|
48
|
-
this.#isConnected = true;
|
|
49
|
-
this.#flushQueue();
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
url(apiHost, cid) {
|
|
53
|
-
const path = cid ? cid.toString() : "";
|
|
54
|
-
return `${apiHost}/api/file${path.length ? "/" + path : ""}`;
|
|
55
|
-
}
|
|
56
|
-
// BLOCKSTORE IMPLEMENTATION
|
|
57
|
-
async delete(key) {
|
|
58
|
-
await this.#localStore.delete(key);
|
|
59
|
-
if (this.#isConnected && this.#apiHost) {
|
|
60
|
-
await fetch(this.url(this.#apiHost, key), {
|
|
61
|
-
method: "DELETE"
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async get(key) {
|
|
66
|
-
if (await this.#localStore.has(key)) {
|
|
67
|
-
return await this.#localStore.get(key);
|
|
68
|
-
}
|
|
69
|
-
if (this.#isConnected && this.#apiHost) {
|
|
70
|
-
const block = await fetch(this.url(this.#apiHost, key), {
|
|
71
|
-
method: "GET"
|
|
72
|
-
}).then((r) => r.arrayBuffer()).then((r) => new Uint8Array(r));
|
|
73
|
-
await this.#localStore.put(key, block);
|
|
74
|
-
return block;
|
|
75
|
-
}
|
|
76
|
-
return await this.#localStore.get(key);
|
|
77
|
-
}
|
|
78
|
-
async has(key) {
|
|
79
|
-
if (await this.#localStore.has(key)) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
if (this.#isConnected && this.#apiHost) {
|
|
83
|
-
return await fetch(this.url(this.#apiHost, key), {
|
|
84
|
-
method: "HEAD"
|
|
85
|
-
}).then((r) => r.ok);
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
async put(key, val) {
|
|
90
|
-
await this.#localStore.put(key, val);
|
|
91
|
-
await this.#addToQueue(key);
|
|
92
|
-
this.#flushQueue();
|
|
93
|
-
return key;
|
|
94
|
-
}
|
|
95
|
-
async destroy() {
|
|
96
|
-
await this.#localStore.destroy();
|
|
97
|
-
}
|
|
98
|
-
// REMOTE
|
|
99
|
-
async putRemote(key, val) {
|
|
100
|
-
if (this.#apiHost) {
|
|
101
|
-
await fetch(this.url(this.#apiHost, key), {
|
|
102
|
-
method: "POST",
|
|
103
|
-
body: val
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async putCarRemote(car) {
|
|
108
|
-
if (this.#apiHost) {
|
|
109
|
-
await fetch(this.url(this.#apiHost), {
|
|
110
|
-
method: "POST",
|
|
111
|
-
headers: {
|
|
112
|
-
"Content-Type": "application/vnd.ipld.car"
|
|
113
|
-
},
|
|
114
|
-
body: car
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
async #addToQueue(key) {
|
|
119
|
-
await this.#saveQueue([
|
|
120
|
-
...this.#queue,
|
|
121
|
-
key.toString()
|
|
122
|
-
]);
|
|
123
|
-
}
|
|
124
|
-
async #flushQueueInt() {
|
|
125
|
-
if (!this.#isConnected || !this.#apiHost) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const keys = [
|
|
129
|
-
...this.#queue
|
|
130
|
-
];
|
|
131
|
-
if (keys.length === 0) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const blocks = await Promise.all(keys.map(async (key) => {
|
|
135
|
-
const cid = CID.parse(key);
|
|
136
|
-
const bytes = await this.#localStore.get(cid);
|
|
137
|
-
return {
|
|
138
|
-
cid,
|
|
139
|
-
bytes
|
|
140
|
-
};
|
|
141
|
-
}));
|
|
142
|
-
const car = await this.#createCar(blocks);
|
|
143
|
-
await this.putCarRemote(car);
|
|
144
|
-
const queue = [
|
|
145
|
-
...this.#queue
|
|
146
|
-
].filter((k) => {
|
|
147
|
-
if (keys.includes(k)) {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
return true;
|
|
151
|
-
});
|
|
152
|
-
await this.#saveQueue(queue);
|
|
153
|
-
}
|
|
154
|
-
async #restoreQueue() {
|
|
155
|
-
const fromCache = await IDB.get(this.queueCacheName);
|
|
156
|
-
if (fromCache && Array.isArray(fromCache)) {
|
|
157
|
-
this.#queue = fromCache;
|
|
158
|
-
this.#flushQueue();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
async #saveQueue(items) {
|
|
162
|
-
const arr = [
|
|
163
|
-
...items
|
|
164
|
-
];
|
|
165
|
-
this.#queue = arr;
|
|
166
|
-
await IDB.set(this.queueCacheName, arr);
|
|
167
|
-
}
|
|
168
|
-
// 🛠️
|
|
169
|
-
async #createCar(blocks) {
|
|
170
|
-
const { writer, out } = CarWriter.create();
|
|
171
|
-
const outPromise = all(out);
|
|
172
|
-
await Promise.all(blocks.map((block) => {
|
|
173
|
-
return writer.put(block);
|
|
174
|
-
}));
|
|
175
|
-
await writer.close();
|
|
176
|
-
return Uint8Arrays.concat(await outPromise);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
// src/capabilities/blockstore.ts
|
|
181
|
-
var blockstore_default = async (context) => {
|
|
182
|
-
const client = context.getCapability(ClientCapabilities.Client);
|
|
183
|
-
const apiHost = client.config.values.runtime?.services?.edge?.url || "http://localhost:8787";
|
|
184
|
-
const blockstore = create(apiHost);
|
|
185
|
-
await blockstore.open();
|
|
186
|
-
return contributes(WnfsCapabilities.Blockstore, blockstore);
|
|
187
|
-
};
|
|
188
|
-
export {
|
|
189
|
-
blockstore_default as default
|
|
190
|
-
};
|
|
191
|
-
//# sourceMappingURL=blockstore-KQO2NTVM.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/blockstore.ts", "../../../src/blockstore.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { contributes, type PluginContext } from '@dxos/app-framework';\nimport { ClientCapabilities } from '@dxos/plugin-client';\n\nimport { WnfsCapabilities } from './capabilities';\nimport * as Blockstore from '../blockstore';\n\nexport default async (context: PluginContext) => {\n const client = context.getCapability(ClientCapabilities.Client);\n const apiHost = client.config.values.runtime?.services?.edge?.url || 'http://localhost:8787';\n const blockstore = Blockstore.create(apiHost);\n await blockstore.open();\n\n return contributes(WnfsCapabilities.Blockstore, blockstore);\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { CarWriter } from '@ipld/car';\nimport type { Block } from '@ipld/car/reader';\nimport { BaseBlockstore } from 'blockstore-core';\nimport { IDBBlockstore } from 'blockstore-idb';\nimport debounce from 'debounce';\nimport * as IDB from 'idb-keyval';\nimport all from 'it-all';\nimport { CID } from 'multiformats';\nimport * as Uint8Arrays from 'uint8arrays';\n\nimport { storeName } from './helpers';\n\nexport const create = (apiHost?: string) => {\n return new MixedBlockstore(apiHost);\n};\n\n/**\n * A blockstore that communicates with the DXOS blob service,\n * and which uses an indexedDB blockstore as a client cache.\n */\nexport class MixedBlockstore extends BaseBlockstore {\n readonly #apiHost: string | undefined;\n readonly #localStore: IDBBlockstore;\n\n #isConnected: boolean;\n #flushQueue: () => void;\n #queue: string[];\n\n constructor(apiHost?: string) {\n super();\n\n this.#apiHost = apiHost ? apiHost.replace(/\\/?$/, '') : undefined;\n this.#localStore = new IDBBlockstore(storeName());\n this.#isConnected = navigator.onLine;\n this.#queue = [];\n\n this.#flushQueue = debounce(this.#flushQueueInt, 5000);\n }\n\n async open(): Promise<void> {\n await this.#localStore.open();\n await this.#restoreQueue();\n\n window.addEventListener('offline', async () => {\n this.#isConnected = false;\n });\n\n window.addEventListener('online', async () => {\n this.#isConnected = true;\n this.#flushQueue();\n });\n }\n\n url(apiHost: string, cid?: CID): string {\n const path = cid ? cid.toString() : '';\n return `${apiHost}/api/file${path.length ? '/' + path : ''}`;\n }\n\n // BLOCKSTORE IMPLEMENTATION\n\n override async delete(key: CID): Promise<void> {\n await this.#localStore.delete(key);\n\n if (this.#isConnected && this.#apiHost) {\n await fetch(this.url(this.#apiHost, key), {\n method: 'DELETE',\n });\n }\n }\n\n override async get(key: CID): Promise<Uint8Array> {\n if (await this.#localStore.has(key)) {\n return await this.#localStore.get(key);\n }\n\n if (this.#isConnected && this.#apiHost) {\n const block = await fetch(this.url(this.#apiHost, key), {\n method: 'GET',\n })\n .then((r) => r.arrayBuffer())\n .then((r) => new Uint8Array(r));\n\n // Make sure it is cached locally\n await this.#localStore.put(key, block);\n\n return block;\n }\n\n return await this.#localStore.get(key);\n }\n\n override async has(key: CID): Promise<boolean> {\n if (await this.#localStore.has(key)) {\n return true;\n }\n\n if (this.#isConnected && this.#apiHost) {\n return await fetch(this.url(this.#apiHost, key), {\n method: 'HEAD',\n }).then((r) => r.ok);\n }\n\n return false;\n }\n\n override async put(key: CID, val: Uint8Array): Promise<CID> {\n await this.#localStore.put(key, val);\n\n await this.#addToQueue(key);\n this.#flushQueue();\n\n return key;\n }\n\n async destroy(): Promise<void> {\n await this.#localStore.destroy();\n }\n\n // REMOTE\n\n async putRemote(key: CID, val: Uint8Array): Promise<void> {\n if (this.#apiHost) {\n await fetch(this.url(this.#apiHost, key), {\n method: 'POST',\n body: val,\n });\n }\n }\n\n async putCarRemote(car: Uint8Array): Promise<void> {\n if (this.#apiHost) {\n await fetch(this.url(this.#apiHost), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/vnd.ipld.car',\n },\n body: car,\n });\n }\n }\n\n // QUEUE\n\n readonly queueCacheName = `${storeName()}/state/queue`;\n\n async #addToQueue(key: CID): Promise<void> {\n await this.#saveQueue([...this.#queue, key.toString()]);\n }\n\n async #flushQueueInt(): Promise<void> {\n if (!this.#isConnected || !this.#apiHost) {\n return;\n }\n\n const keys = [...this.#queue];\n if (keys.length === 0) {\n return;\n }\n\n // Collect blocks\n const blocks = await Promise.all(\n keys.map(async (key) => {\n const cid = CID.parse(key);\n const bytes = await this.#localStore.get(cid);\n return { cid, bytes };\n }),\n );\n\n // Create & submit CAR\n const car = await this.#createCar(blocks);\n await this.putCarRemote(car);\n\n // Adjust queue\n const queue = [...this.#queue].filter((k) => {\n if (keys.includes(k)) {\n return false;\n }\n\n return true;\n });\n\n await this.#saveQueue(queue);\n }\n\n async #restoreQueue(): Promise<void> {\n const fromCache = await IDB.get(this.queueCacheName);\n if (fromCache && Array.isArray(fromCache)) {\n this.#queue = fromCache;\n this.#flushQueue();\n }\n }\n\n async #saveQueue(items: string[]): Promise<void> {\n const arr = [...items];\n this.#queue = arr;\n await IDB.set(this.queueCacheName, arr);\n }\n\n // 🛠️\n\n async #createCar(blocks: Block[]): Promise<Uint8Array> {\n const { writer, out } = CarWriter.create();\n const outPromise = all(out);\n\n await Promise.all(\n blocks.map((block) => {\n return writer.put(block);\n }),\n );\n\n await writer.close();\n return Uint8Arrays.concat(await outPromise);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,SAASA,mBAAuC;AAChD,SAASC,0BAA0B;;;ACDnC,SAASC,iBAAiB;AAE1B,SAASC,sBAAsB;AAC/B,SAASC,qBAAqB;AAC9B,OAAOC,cAAc;AACrB,YAAYC,SAAS;AACrB,OAAOC,SAAS;AAChB,SAASC,WAAW;AACpB,YAAYC,iBAAiB;AAItB,IAAMC,SAAS,CAACC,YAAAA;AACrB,SAAO,IAAIC,gBAAgBD,OAAAA;AAC7B;AAMO,IAAMC,kBAAN,cAA8BC,eAAAA;EAQnC,YAAYF,SAAkB;AAC5B,UAAK;AAkHEG;0BAAiB,GAAGC,UAAAA,CAAAA;AAhH3B,SAAK,WAAWJ,UAAUA,QAAQK,QAAQ,QAAQ,EAAA,IAAMC;AACxD,SAAK,cAAc,IAA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6
|
-
"names": ["contributes", "ClientCapabilities", "CarWriter", "BaseBlockstore", "IDBBlockstore", "debounce", "IDB", "all", "CID", "Uint8Arrays", "create", "apiHost", "MixedBlockstore", "BaseBlockstore", "queueCacheName", "storeName", "replace", "undefined", "IDBBlockstore", "navigator", "onLine", "debounce", "open", "window", "addEventListener", "url", "cid", "path", "toString", "length", "delete", "key", "fetch", "method", "get", "has", "block", "then", "r", "arrayBuffer", "Uint8Array", "put", "ok", "val", "destroy", "putRemote", "body", "putCarRemote", "car", "headers", "keys", "blocks", "Promise", "all", "map", "CID", "parse", "bytes", "queue", "filter", "k", "includes", "fromCache", "Array", "isArray", "items", "arr", "set", "writer", "out", "CarWriter", "outPromise", "close", "concat", "context", "client", "getCapability", "ClientCapabilities", "Client", "apiHost", "config", "values", "runtime", "services", "edge", "url", "blockstore", "create", "open", "contributes", "WnfsCapabilities", "Blockstore"]
|
|
7
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// src/capabilities/index.ts
|
|
2
|
-
import { lazy } from "@dxos/app-framework";
|
|
3
|
-
var Blockstore = lazy(() => import("./blockstore-KQO2NTVM.mjs"));
|
|
4
|
-
var FileUploader = lazy(() => import("./file-uploader-JA55DPMW.mjs"));
|
|
5
|
-
var IntentResolver = lazy(() => import("./intent-resolver-YM6QRFIH.mjs"));
|
|
6
|
-
var Markdown = lazy(() => import("./markdown-6VH477GB.mjs"));
|
|
7
|
-
var ReactSurface = lazy(() => import("./react-surface-XAHVMWIH.mjs"));
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
Blockstore,
|
|
11
|
-
FileUploader,
|
|
12
|
-
IntentResolver,
|
|
13
|
-
Markdown,
|
|
14
|
-
ReactSurface
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=chunk-BANMVVJV.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const Blockstore = lazy(() => import('./blockstore'));\nexport const FileUploader = lazy(() => import('./file-uploader'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const Markdown = lazy(() => import('./markdown'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n\nexport * from './capabilities';\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,YAAY;AAEd,IAAMC,aAAaC,KAAK,MAAM,OAAO,2BAAA,CAAA;AACrC,IAAMC,eAAeD,KAAK,MAAM,OAAO,8BAAA,CAAA;AACvC,IAAME,iBAAiBF,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAMG,WAAWH,KAAK,MAAM,OAAO,yBAAA,CAAA;AACnC,IAAMI,eAAeJ,KAAK,MAAM,OAAO,8BAAA,CAAA;",
|
|
6
|
-
"names": ["lazy", "Blockstore", "lazy", "FileUploader", "IntentResolver", "Markdown", "ReactSurface"]
|
|
7
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WNFS_PLUGIN
|
|
3
|
-
} from "./chunk-VDDGZWAY.mjs";
|
|
4
|
-
|
|
5
|
-
// src/types/file.ts
|
|
6
|
-
import { Schema } from "effect";
|
|
7
|
-
import { TypedObject } from "@dxos/echo-schema";
|
|
8
|
-
var FileType = class extends TypedObject({
|
|
9
|
-
typename: "dxos.org/type/File",
|
|
10
|
-
version: "0.1.0"
|
|
11
|
-
})({
|
|
12
|
-
name: Schema.optional(Schema.String),
|
|
13
|
-
type: Schema.String,
|
|
14
|
-
cid: Schema.String,
|
|
15
|
-
timestamp: Schema.optional(Schema.String)
|
|
16
|
-
}) {
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// src/types/types.ts
|
|
20
|
-
import { Schema as Schema2 } from "effect";
|
|
21
|
-
import { FileInfoSchema } from "@dxos/app-framework";
|
|
22
|
-
import { SpaceSchema } from "@dxos/react-client/echo";
|
|
23
|
-
(function(WnfsAction2) {
|
|
24
|
-
class Create extends Schema2.TaggedClass()(`${WNFS_PLUGIN}/action/create`, {
|
|
25
|
-
input: FileInfoSchema.pick("name", "type", "cid").pipe(Schema2.required),
|
|
26
|
-
output: Schema2.Struct({
|
|
27
|
-
object: FileType
|
|
28
|
-
})
|
|
29
|
-
}) {
|
|
30
|
-
}
|
|
31
|
-
WnfsAction2.Create = Create;
|
|
32
|
-
WnfsAction2.UploadAnnotationId = Symbol.for(`${WNFS_PLUGIN}/annotation/upload`);
|
|
33
|
-
WnfsAction2.UploadFileSchema = Schema2.Struct({
|
|
34
|
-
file: Schema2.instanceOf(File).annotations({
|
|
35
|
-
[WnfsAction2.UploadAnnotationId]: {
|
|
36
|
-
// Accept file types.
|
|
37
|
-
"image/*": [
|
|
38
|
-
".jpg",
|
|
39
|
-
".jpeg",
|
|
40
|
-
".png",
|
|
41
|
-
".gif"
|
|
42
|
-
],
|
|
43
|
-
"application/pdf": [
|
|
44
|
-
".pdf"
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
});
|
|
49
|
-
class Upload extends Schema2.TaggedClass()(`${WNFS_PLUGIN}/action/upload`, {
|
|
50
|
-
input: Schema2.extend(WnfsAction2.UploadFileSchema, Schema2.Struct({
|
|
51
|
-
space: SpaceSchema
|
|
52
|
-
})),
|
|
53
|
-
output: Schema2.required(FileInfoSchema)
|
|
54
|
-
}) {
|
|
55
|
-
}
|
|
56
|
-
WnfsAction2.Upload = Upload;
|
|
57
|
-
})(WnfsAction || (WnfsAction = {}));
|
|
58
|
-
var WnfsAction;
|
|
59
|
-
|
|
60
|
-
export {
|
|
61
|
-
FileType,
|
|
62
|
-
WnfsAction
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=chunk-GVBV2QWA.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 { Schema } from 'effect';\n\nimport { TypedObject } from '@dxos/echo-schema';\n\nexport class FileType extends TypedObject({\n typename: 'dxos.org/type/File',\n version: '0.1.0',\n})({\n name: Schema.optional(Schema.String),\n type: Schema.String,\n cid: Schema.String,\n timestamp: Schema.optional(Schema.String),\n}) {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { FileInfoSchema } from '@dxos/app-framework';\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 Schema.TaggedClass<Create>()(`${WNFS_PLUGIN}/action/create`, {\n input: FileInfoSchema.pick('name', 'type', 'cid').pipe(Schema.required),\n output: Schema.Struct({\n object: FileType,\n }),\n }) {}\n\n export const UploadAnnotationId = Symbol.for(`${WNFS_PLUGIN}/annotation/upload`);\n\n export const UploadFileSchema = Schema.Struct({\n file: Schema.instanceOf(File).annotations({\n [UploadAnnotationId]: {\n // Accept file types.\n 'image/*': ['.jpg', '.jpeg', '.png', '.gif'],\n 'application/pdf': ['.pdf'],\n // TODO(wittjosiah): Add more file types.\n },\n }),\n });\n\n export type UploadFileForm = Schema.Schema.Type<typeof UploadFileSchema>;\n\n export class Upload extends Schema.TaggedClass<Upload>()(`${WNFS_PLUGIN}/action/upload`, {\n input: Schema.extend(UploadFileSchema, Schema.Struct({ space: SpaceSchema })),\n output: Schema.required(FileInfoSchema),\n }) {}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,SAASA,cAAc;AAEvB,SAASC,mBAAmB;AAErB,IAAMC,WAAN,cAAuBC,YAAY;EACxCC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDC,MAAMC,OAAOC,SAASD,OAAOE,MAAM;EACnCC,MAAMH,OAAOE;EACbE,KAAKJ,OAAOE;EACZG,WAAWL,OAAOC,SAASD,OAAOE,MAAM;AAC1C,CAAA,EAAA;AAAI;;;ACZJ,SAASI,UAAAA,eAAc;AAEvB,SAASC,sBAAsB;AAC/B,SAASC,mBAAmB;UAKXC,aAAAA;EACR,MAAMC,eAAeC,QAAOC,YAAW,EAAW,GAAGC,WAAAA,kBAA6B;IACvFC,OAAOC,eAAeC,KAAK,QAAQ,QAAQ,KAAA,EAAOC,KAAKN,QAAOO,QAAQ;IACtEC,QAAQR,QAAOS,OAAO;MACpBC,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;cALSZ,SAAAA;cAOAa,qBAAqBC,OAAOC,IAAI,GAAGZ,WAAAA,oBAA+B;cAElEa,mBAAmBf,QAAOS,OAAO;IAC5CO,MAAMhB,QAAOiB,WAAWC,IAAAA,EAAMC,YAAY;MACxC,CAAArB,YAACc,kBAAAA,GAAqB;;QAEpB,WAAW;UAAC;UAAQ;UAAS;UAAQ;;QACrC,mBAAmB;UAAC;;MAEtB;IACF,CAAA;EACF,CAAA;EAIO,MAAMQ,eAAepB,QAAOC,YAAW,EAAW,GAAGC,WAAAA,kBAA6B;IACvFC,OAAOH,QAAOqB,OAAMvB,YAACiB,kBAAkBf,QAAOS,OAAO;MAAEa,OAAOC;IAAY,CAAA,CAAA;IAC1Ef,QAAQR,QAAOO,SAASH,cAAAA;EAC1B,CAAA,EAAA;EAAI;cAHSgB,SAAAA;AAIf,GA3BiBtB,eAAAA,aAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["Schema", "TypedObject", "FileType", "TypedObject", "typename", "version", "name", "Schema", "optional", "String", "type", "cid", "timestamp", "Schema", "FileInfoSchema", "SpaceSchema", "WnfsAction", "Create", "Schema", "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,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WNFS_PLUGIN
|
|
3
|
-
} from "./chunk-VDDGZWAY.mjs";
|
|
4
|
-
|
|
5
|
-
// src/capabilities/capabilities.ts
|
|
6
|
-
import { defineCapability } from "@dxos/app-framework";
|
|
7
|
-
(function(WnfsCapabilities2) {
|
|
8
|
-
WnfsCapabilities2.Blockstore = defineCapability(`${WNFS_PLUGIN}/capability/blockstore`);
|
|
9
|
-
WnfsCapabilities2.Instances = defineCapability(`${WNFS_PLUGIN}/capability/instances`);
|
|
10
|
-
})(WnfsCapabilities || (WnfsCapabilities = {}));
|
|
11
|
-
var WnfsCapabilities;
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
WnfsCapabilities
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=chunk-KZANQHJY.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/capabilities.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Blockstore } from 'interface-blockstore';\nimport { type PrivateDirectory, type PrivateForest } from 'wnfs';\n\nimport { defineCapability } from '@dxos/app-framework';\nimport { type SpaceId } from '@dxos/keys';\n\nimport { WNFS_PLUGIN } from '../meta';\n\nexport namespace WnfsCapabilities {\n export const Blockstore = defineCapability<Blockstore>(`${WNFS_PLUGIN}/capability/blockstore`);\n\n export type Instances = Record<SpaceId, { directory: PrivateDirectory; forest: PrivateForest }>;\n export const Instances = defineCapability<Instances>(`${WNFS_PLUGIN}/capability/instances`);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAOA,SAASA,wBAAwB;UAKhBC,mBAAAA;oBACFC,aAAaC,iBAA6B,GAAGC,WAAAA,wBAAmC;oBAGhFC,YAAYF,iBAA4B,GAAGC,WAAAA,uBAAkC;AAC5F,GALiBH,qBAAAA,mBAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["defineCapability", "WnfsCapabilities", "Blockstore", "defineCapability", "WNFS_PLUGIN", "Instances"]
|
|
7
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
var WNFS_PLUGIN = "dxos.org/plugin/wnfs";
|
|
3
|
-
var meta = {
|
|
4
|
-
id: WNFS_PLUGIN,
|
|
5
|
-
name: "WNFS",
|
|
6
|
-
description: "Manage and view files with via the Web Native File System (WNFS).",
|
|
7
|
-
icon: "ph--file-cloud--regular",
|
|
8
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-wnfs"
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
WNFS_PLUGIN,
|
|
13
|
-
meta
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=chunk-VDDGZWAY.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const WNFS_PLUGIN = 'dxos.org/plugin/wnfs';\n\nexport const meta: PluginMeta = {\n id: WNFS_PLUGIN,\n name: 'WNFS',\n description: 'Manage and view files with via the Web Native File System (WNFS).',\n icon: 'ph--file-cloud--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-wnfs',\n};\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,cAAc;AAEpB,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
-
"names": ["WNFS_PLUGIN", "meta", "id", "name", "description", "icon", "source"]
|
|
7
|
-
}
|