@dxos/plugin-wnfs 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/lib/browser/{chunk-VXUCZHVZ.mjs → chunk-4D4K5JCC.mjs} +4 -7
- package/dist/lib/browser/{chunk-VXUCZHVZ.mjs.map → chunk-4D4K5JCC.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-N6Y4QPNF.mjs → chunk-7KFJ6LYH.mjs} +51 -17
- package/dist/lib/browser/chunk-7KFJ6LYH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BM3MEFES.mjs → chunk-DK62NQ5T.mjs} +6 -4
- package/dist/lib/browser/chunk-DK62NQ5T.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{create-NOHKWE67.mjs → create-QRLX4IMZ.mjs} +5 -4
- package/dist/lib/browser/create-QRLX4IMZ.mjs.map +7 -0
- package/dist/lib/browser/{create-file-N7ADCFOF.mjs → create-file-INAT56PX.mjs} +7 -14
- 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 +7 -94
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +5 -4
- package/dist/lib/browser/operations/index.mjs.map +3 -3
- package/dist/lib/browser/translations.mjs +30 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -1
- package/dist/lib/browser/{upload-DA7GBOXF.mjs → upload-ZQI66T4Y.mjs} +7 -14
- package/dist/lib/browser/upload-ZQI66T4Y.mjs.map +7 -0
- package/dist/types/src/WnfsPlugin.d.ts +1 -0
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/WnfsPlugin.node.d.ts +4 -0
- package/dist/types/src/WnfsPlugin.node.d.ts.map +1 -0
- package/dist/types/src/WnfsPlugin.test.d.ts +2 -0
- package/dist/types/src/WnfsPlugin.test.d.ts.map +1 -0
- package/dist/types/src/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +2 -1
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -1
- package/dist/types/src/components/FilePreview/FilePreview.d.ts +1 -1
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -1
- package/dist/types/src/extensions/image.d.ts.map +1 -1
- package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
- package/dist/types/src/helpers/common.d.ts.map +1 -1
- package/dist/types/src/helpers/load.d.ts.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/operations/create-file.d.ts +1 -1
- package/dist/types/src/operations/create-file.d.ts.map +1 -1
- package/dist/types/src/operations/create.d.ts +1 -1
- package/dist/types/src/operations/create.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +2 -2
- package/dist/types/src/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +1 -1
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/upload.d.ts +1 -1
- package/dist/types/src/operations/upload.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +24 -16
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -37
- package/src/WnfsPlugin.node.ts +47 -0
- package/src/WnfsPlugin.test.ts +27 -0
- package/src/WnfsPlugin.tsx +5 -4
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/markdown.ts +16 -12
- package/src/capabilities/operation-handler.ts +1 -1
- package/src/capabilities/react-surface.tsx +16 -7
- package/src/helpers/load.ts +2 -2
- package/src/helpers/upload.ts +1 -1
- package/src/index.ts +8 -2
- package/src/operations/create-file.ts +1 -1
- package/src/operations/create.ts +1 -1
- package/src/operations/definitions.ts +1 -1
- package/src/operations/index.ts +1 -1
- package/src/operations/upload.ts +1 -1
- package/dist/lib/browser/chunk-BM3MEFES.mjs.map +0 -7
- package/dist/lib/browser/chunk-N6Y4QPNF.mjs.map +0 -7
- package/dist/lib/browser/create-NOHKWE67.mjs.map +0 -7
- package/dist/lib/browser/create-file-N7ADCFOF.mjs.map +0 -7
- package/dist/lib/browser/upload-DA7GBOXF.mjs.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-wnfs",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.abd8ff62ef",
|
|
4
4
|
"description": "WNFS file management plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
"#containers": "./src/containers/index.ts",
|
|
18
18
|
"#meta": "./src/meta.ts",
|
|
19
19
|
"#operations": "./src/operations/index.ts",
|
|
20
|
+
"#plugin": {
|
|
21
|
+
"browser": "./src/WnfsPlugin.tsx",
|
|
22
|
+
"node": "./src/WnfsPlugin.node.ts",
|
|
23
|
+
"default": "./src/WnfsPlugin.tsx"
|
|
24
|
+
},
|
|
25
|
+
"#translations": "./src/translations.ts",
|
|
20
26
|
"#types": "./src/types/index.ts"
|
|
21
27
|
},
|
|
22
28
|
"exports": {
|
|
@@ -25,11 +31,22 @@
|
|
|
25
31
|
"browser": "./dist/lib/browser/index.mjs",
|
|
26
32
|
"types": "./dist/types/src/index.d.ts"
|
|
27
33
|
},
|
|
34
|
+
"./helpers": {
|
|
35
|
+
"source": "./src/helpers/index.ts",
|
|
36
|
+
"browser": "./dist/lib/browser/helpers/index.mjs",
|
|
37
|
+
"types": "./dist/types/src/helpers/index.d.ts"
|
|
38
|
+
},
|
|
28
39
|
"./operations": {
|
|
29
40
|
"source": "./src/operations/index.ts",
|
|
30
41
|
"browser": "./dist/lib/browser/operations/index.mjs",
|
|
31
42
|
"types": "./dist/types/src/operations/index.d.ts"
|
|
32
43
|
},
|
|
44
|
+
"./translations": {
|
|
45
|
+
"source": "./src/translations.ts",
|
|
46
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
47
|
+
"browser": "./dist/lib/browser/translations.mjs",
|
|
48
|
+
"node": "./dist/lib/node-esm/translations.mjs"
|
|
49
|
+
},
|
|
33
50
|
"./types": {
|
|
34
51
|
"source": "./src/types/index.ts",
|
|
35
52
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
@@ -37,16 +54,6 @@
|
|
|
37
54
|
}
|
|
38
55
|
},
|
|
39
56
|
"types": "dist/types/src/index.d.ts",
|
|
40
|
-
"typesVersions": {
|
|
41
|
-
"*": {
|
|
42
|
-
"types": [
|
|
43
|
-
"dist/types/src/types/index.d.ts"
|
|
44
|
-
],
|
|
45
|
-
"operations": [
|
|
46
|
-
"dist/types/src/operations/index.d.ts"
|
|
47
|
-
]
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
57
|
"files": [
|
|
51
58
|
"dist",
|
|
52
59
|
"src"
|
|
@@ -67,43 +74,44 @@
|
|
|
67
74
|
"react-dropzone": "^14.2.3",
|
|
68
75
|
"uint8arrays": "^5.1.0",
|
|
69
76
|
"wnfs": "0.2.2",
|
|
70
|
-
"@dxos/app-toolkit": "0.8.4-main.
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/plugin-
|
|
80
|
-
"@dxos/react-client": "0.8.4-main.
|
|
81
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
82
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/react-ui-form": "0.8.4-main.
|
|
85
|
-
"@dxos/
|
|
86
|
-
"@dxos/ui-
|
|
87
|
-
"@dxos/
|
|
88
|
-
"@dxos/util": "0.8.4-main.
|
|
89
|
-
"@dxos/
|
|
77
|
+
"@dxos/app-toolkit": "0.8.4-main.abd8ff62ef",
|
|
78
|
+
"@dxos/compute": "0.8.4-main.abd8ff62ef",
|
|
79
|
+
"@dxos/app-framework": "0.8.4-main.abd8ff62ef",
|
|
80
|
+
"@dxos/crypto": "0.8.4-main.abd8ff62ef",
|
|
81
|
+
"@dxos/echo": "0.8.4-main.abd8ff62ef",
|
|
82
|
+
"@dxos/invariant": "0.8.4-main.abd8ff62ef",
|
|
83
|
+
"@dxos/plugin-client": "0.8.4-main.abd8ff62ef",
|
|
84
|
+
"@dxos/plugin-space": "0.8.4-main.abd8ff62ef",
|
|
85
|
+
"@dxos/log": "0.8.4-main.abd8ff62ef",
|
|
86
|
+
"@dxos/plugin-markdown": "0.8.4-main.abd8ff62ef",
|
|
87
|
+
"@dxos/react-client": "0.8.4-main.abd8ff62ef",
|
|
88
|
+
"@dxos/react-ui": "0.8.4-main.abd8ff62ef",
|
|
89
|
+
"@dxos/react-ui-editor": "0.8.4-main.abd8ff62ef",
|
|
90
|
+
"@dxos/effect": "0.8.4-main.abd8ff62ef",
|
|
91
|
+
"@dxos/react-ui-form": "0.8.4-main.abd8ff62ef",
|
|
92
|
+
"@dxos/react-ui-stack": "0.8.4-main.abd8ff62ef",
|
|
93
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.abd8ff62ef",
|
|
94
|
+
"@dxos/schema": "0.8.4-main.abd8ff62ef",
|
|
95
|
+
"@dxos/util": "0.8.4-main.abd8ff62ef",
|
|
96
|
+
"@dxos/ui-editor": "0.8.4-main.abd8ff62ef"
|
|
90
97
|
},
|
|
91
98
|
"devDependencies": {
|
|
92
99
|
"@types/react": "~19.2.7",
|
|
93
100
|
"@types/react-dom": "~19.2.3",
|
|
94
101
|
"react": "~19.2.3",
|
|
95
102
|
"react-dom": "~19.2.3",
|
|
96
|
-
"vite": "^
|
|
97
|
-
"@dxos/random": "0.8.4-main.
|
|
98
|
-
"@dxos/
|
|
99
|
-
"@dxos/
|
|
103
|
+
"vite": "^8.0.10",
|
|
104
|
+
"@dxos/random": "0.8.4-main.abd8ff62ef",
|
|
105
|
+
"@dxos/plugin-testing": "0.8.4-main.abd8ff62ef",
|
|
106
|
+
"@dxos/storybook-utils": "0.8.4-main.abd8ff62ef",
|
|
107
|
+
"@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
|
|
100
108
|
},
|
|
101
109
|
"peerDependencies": {
|
|
102
110
|
"effect": "3.20.0",
|
|
103
111
|
"react": "~19.2.3",
|
|
104
112
|
"react-dom": "~19.2.3",
|
|
105
|
-
"@dxos/ui
|
|
106
|
-
"@dxos/
|
|
113
|
+
"@dxos/react-ui": "0.8.4-main.abd8ff62ef",
|
|
114
|
+
"@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
|
|
107
115
|
},
|
|
108
116
|
"publishConfig": {
|
|
109
117
|
"access": "public"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
|
+
|
|
8
|
+
import { Plugin } from '@dxos/app-framework';
|
|
9
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
import { Annotation } from '@dxos/echo';
|
|
12
|
+
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
13
|
+
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
14
|
+
|
|
15
|
+
import { OperationHandler } from '#capabilities';
|
|
16
|
+
import { meta } from '#meta';
|
|
17
|
+
import { WnfsOperation } from '#operations';
|
|
18
|
+
import { WnfsAction, WnfsFile } from '#types';
|
|
19
|
+
|
|
20
|
+
export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
21
|
+
AppPlugin.addMetadataModule({
|
|
22
|
+
metadata: {
|
|
23
|
+
id: WnfsFile.File.typename,
|
|
24
|
+
metadata: {
|
|
25
|
+
// TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
|
|
26
|
+
icon: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).icon,
|
|
27
|
+
iconHue: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).hue ?? 'white',
|
|
28
|
+
inputSchema: WnfsAction.UploadFileSchema,
|
|
29
|
+
createObject: ((props, options) =>
|
|
30
|
+
Effect.gen(function* () {
|
|
31
|
+
const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, { ...props, db: options.db });
|
|
32
|
+
return yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
33
|
+
object,
|
|
34
|
+
target: options.target,
|
|
35
|
+
hidden: true,
|
|
36
|
+
targetNodeId: options.targetNodeId,
|
|
37
|
+
});
|
|
38
|
+
})) satisfies CreateObject,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),
|
|
43
|
+
AppPlugin.addSchemaModule({ schema: [WnfsFile.File] }),
|
|
44
|
+
Plugin.make,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export default WnfsPlugin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
8
|
+
import { createComposerTestApp } from '@dxos/plugin-testing/harness';
|
|
9
|
+
|
|
10
|
+
import { WnfsPlugin } from '#plugin';
|
|
11
|
+
|
|
12
|
+
import { meta } from './meta';
|
|
13
|
+
|
|
14
|
+
const moduleId = (name: string) => `${meta.id}.module.${name}`;
|
|
15
|
+
|
|
16
|
+
describe('WnfsPlugin', () => {
|
|
17
|
+
test('modules activate on the expected events', async ({ expect }) => {
|
|
18
|
+
await using harness = await createComposerTestApp({
|
|
19
|
+
plugins: [ClientPlugin({}), WnfsPlugin()],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// After autoStart: metadata, schema, and OperationHandler all auto-cascade.
|
|
23
|
+
expect(harness.manager.getActive()).toEqual(
|
|
24
|
+
expect.arrayContaining([moduleId('metadata'), moduleId('schema'), moduleId('OperationHandler')]),
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
});
|
package/src/WnfsPlugin.tsx
CHANGED
|
@@ -7,20 +7,19 @@ import * as Option from 'effect/Option';
|
|
|
7
7
|
|
|
8
8
|
import { Capability, Plugin } from '@dxos/app-framework';
|
|
9
9
|
import { AppPlugin } from '@dxos/app-toolkit';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
10
11
|
import { Annotation } from '@dxos/echo';
|
|
11
|
-
import { Operation } from '@dxos/operation';
|
|
12
12
|
import { ClientEvents } from '@dxos/plugin-client/types';
|
|
13
|
-
import { MarkdownEvents } from '@dxos/plugin-markdown';
|
|
13
|
+
import { MarkdownEvents } from '@dxos/plugin-markdown/types';
|
|
14
14
|
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
15
15
|
import { type CreateObject } from '@dxos/plugin-space/types';
|
|
16
16
|
|
|
17
17
|
import { Blockstore, FileUploader, Markdown, OperationHandler, ReactSurface } from '#capabilities';
|
|
18
18
|
import { meta } from '#meta';
|
|
19
19
|
import { WnfsOperation } from '#operations';
|
|
20
|
+
import { translations } from '#translations';
|
|
20
21
|
import { WnfsAction, WnfsCapabilities, WnfsFile } from '#types';
|
|
21
22
|
|
|
22
|
-
import { translations } from './translations';
|
|
23
|
-
|
|
24
23
|
export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
25
24
|
AppPlugin.addMetadataModule({
|
|
26
25
|
metadata: {
|
|
@@ -73,3 +72,5 @@ export const WnfsPlugin = Plugin.define(meta).pipe(
|
|
|
73
72
|
}),
|
|
74
73
|
Plugin.make,
|
|
75
74
|
);
|
|
75
|
+
|
|
76
|
+
export default WnfsPlugin;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Capability } from '@dxos/app-framework';
|
|
6
|
-
import { OperationHandlerSet } from '@dxos/
|
|
6
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
7
7
|
|
|
8
8
|
export const Blockstore = Capability.lazy('Blockstore', () => import('./blockstore'));
|
|
9
9
|
export const FileUploader = Capability.lazy('FileUploader', () => import('./file-uploader'));
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
7
|
import { Capability } from '@dxos/app-framework';
|
|
8
|
-
import { MarkdownCapabilities } from '@dxos/plugin-markdown';
|
|
8
|
+
import { type MarkdownExtensionProvider, MarkdownCapabilities } from '@dxos/plugin-markdown/types';
|
|
9
9
|
import { getSpace } from '@dxos/react-client/echo';
|
|
10
10
|
|
|
11
11
|
import { WnfsCapabilities } from '#types';
|
|
@@ -17,18 +17,22 @@ export default Capability.makeModule(
|
|
|
17
17
|
// Get context for lazy capability access in callbacks.
|
|
18
18
|
const capabilities = yield* Capability.Service;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const provider: MarkdownExtensionProvider = ({ document, viewMode }) => {
|
|
21
|
+
if (viewMode === 'source') {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return space ? [image({ blockstore, instances, space })] : [];
|
|
28
|
-
}
|
|
25
|
+
const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
|
|
26
|
+
const instances = capabilities.get(WnfsCapabilities.Instances);
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
if (document) {
|
|
29
|
+
const space = getSpace(document);
|
|
30
|
+
return space ? [image({ blockstore, instances, space })] : undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return undefined;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return Capability.contributes(MarkdownCapabilities.Extensions, [provider]);
|
|
33
37
|
}),
|
|
34
38
|
);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
7
|
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
-
import type { OperationHandlerSet } from '@dxos/
|
|
8
|
+
import type { OperationHandlerSet } from '@dxos/compute';
|
|
9
9
|
|
|
10
10
|
import { WnfsOperationHandlerSet } from '#operations';
|
|
11
11
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
import type * as Schema from 'effect/Schema';
|
|
7
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
8
|
import React, { useCallback } from 'react';
|
|
8
9
|
|
|
9
10
|
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
@@ -22,25 +23,33 @@ export default Capability.makeModule(() =>
|
|
|
22
23
|
Surface.create({
|
|
23
24
|
id: 'article',
|
|
24
25
|
// TODO(wittjosiah): Split into multiple surfaces if this filter proves too strict for non-article roles.
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
filter: AppSurface.oneOf(
|
|
27
|
+
AppSurface.object(AppSurface.Article, WnfsFile.File),
|
|
28
|
+
AppSurface.object(AppSurface.Section, WnfsFile.File),
|
|
29
|
+
AppSurface.object(AppSurface.Slide, WnfsFile.File),
|
|
30
|
+
),
|
|
27
31
|
component: ({ data, role }) => <FileContainer role={role} subject={data.subject} />,
|
|
28
32
|
}),
|
|
29
33
|
Surface.create({
|
|
30
34
|
id: 'create-form',
|
|
31
35
|
role: 'form-input',
|
|
32
|
-
filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {
|
|
36
|
+
filter: (data): data is { prop: string; schema: Schema.Schema.Any; fieldPropertyAst?: SchemaAST.AST } => {
|
|
33
37
|
const annotation = findAnnotation<boolean>(
|
|
34
38
|
(data.schema as Schema.Schema.All).ast,
|
|
35
39
|
WnfsAction.UploadAnnotationId,
|
|
36
40
|
);
|
|
37
41
|
return !!annotation;
|
|
38
42
|
},
|
|
39
|
-
component: ({ data: { schema }, ...props }) => {
|
|
40
|
-
const
|
|
43
|
+
component: ({ data: { schema, fieldPropertyAst }, ...props }) => {
|
|
44
|
+
const ast = fieldPropertyAst;
|
|
45
|
+
if (!ast) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const inputProps = { ...props, type: ast } as unknown as FormFieldComponentProps;
|
|
41
50
|
const handleChange = useCallback(
|
|
42
|
-
(file: File) => inputProps.onValueChange?.(
|
|
43
|
-
[
|
|
51
|
+
(file: File) => inputProps.onValueChange?.(ast, file),
|
|
52
|
+
[ast, inputProps.onValueChange],
|
|
44
53
|
);
|
|
45
54
|
|
|
46
55
|
return <FileInput schema={schema} onChange={handleChange} />;
|
package/src/helpers/load.ts
CHANGED
|
@@ -30,7 +30,7 @@ export const loadWnfs = async ({
|
|
|
30
30
|
// TODO(wittjosiah): Remove.
|
|
31
31
|
// Delete old properties if they exist.
|
|
32
32
|
if (space.properties.wnfs_access_key !== undefined && space.properties.wnfs_private_forest_cid !== undefined) {
|
|
33
|
-
Obj.
|
|
33
|
+
Obj.update(space.properties, (obj) => {
|
|
34
34
|
delete obj['wnfs_access_key'];
|
|
35
35
|
delete obj['wnfs_private_forest_cid'];
|
|
36
36
|
});
|
|
@@ -68,7 +68,7 @@ const createWnfsDir = async (blockstore: Blockstore, space: Space) => {
|
|
|
68
68
|
|
|
69
69
|
const cidBytes = await newForest.store(wnfsStore);
|
|
70
70
|
|
|
71
|
-
Obj.
|
|
71
|
+
Obj.update(space.properties, (obj) => {
|
|
72
72
|
obj.wnfs = {
|
|
73
73
|
accessKey: Uint8Arrays.toString(accessKeyRaw.toBytes(), 'base64'),
|
|
74
74
|
privateForestCid: CID.decode(cidBytes).toString(),
|
package/src/helpers/upload.ts
CHANGED
|
@@ -47,7 +47,7 @@ export const upload = async ({
|
|
|
47
47
|
const cidBytes = await updatedForest.store(wnfsStore);
|
|
48
48
|
|
|
49
49
|
// Update the forest pointer on the associated space.
|
|
50
|
-
Obj.
|
|
50
|
+
Obj.update(space.properties, (obj) => {
|
|
51
51
|
obj.wnfs.privateForestCid = CID.decode(cidBytes).toString();
|
|
52
52
|
});
|
|
53
53
|
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const WnfsPlugin = Plugin.lazy(meta, () => import('#plugin'));
|
|
10
|
+
|
|
6
11
|
export * from './meta';
|
|
7
|
-
|
|
12
|
+
|
|
13
|
+
export { WnfsCapabilities } from './types';
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
7
|
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
8
9
|
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import { Operation } from '@dxos/operation';
|
|
10
10
|
import { ClientCapabilities } from '@dxos/plugin-client/types';
|
|
11
11
|
|
|
12
12
|
import { upload } from '../helpers';
|
package/src/operations/create.ts
CHANGED
|
@@ -6,8 +6,8 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
|
|
7
7
|
import { Capability } from '@dxos/app-framework';
|
|
8
8
|
import { FileInfoSchema } from '@dxos/app-toolkit';
|
|
9
|
+
import { Operation } from '@dxos/compute';
|
|
9
10
|
import { Database } from '@dxos/echo';
|
|
10
|
-
import { Operation } from '@dxos/operation';
|
|
11
11
|
|
|
12
12
|
import { meta } from '#meta';
|
|
13
13
|
|
package/src/operations/index.ts
CHANGED
package/src/operations/upload.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
7
|
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
8
9
|
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import { Operation } from '@dxos/operation';
|
|
10
10
|
import { ClientCapabilities } from '@dxos/plugin-client/types';
|
|
11
11
|
|
|
12
12
|
import { upload } from '../helpers';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/operations/definitions.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Capability } from '@dxos/app-framework';\nimport { FileInfoSchema } from '@dxos/app-toolkit';\nimport { Database } from '@dxos/echo';\nimport { Operation } from '@dxos/operation';\n\nimport { meta } from '#meta';\n\nimport { WnfsFile, WnfsAction } from '../types';\n\nconst WNFS_OPERATION = `${meta.id}.operation`;\n\nexport const Create = Operation.make({\n meta: { key: `${WNFS_OPERATION}.create`, name: 'Create WNFS File' },\n services: [Capability.Service],\n input: FileInfoSchema.pick('name', 'type', 'cid').pipe(Schema.required),\n output: Schema.Struct({\n object: WnfsFile.File,\n }),\n});\n\nexport const Upload = Operation.make({\n meta: { key: `${WNFS_OPERATION}.upload`, name: 'Upload File' },\n services: [Capability.Service],\n input: Schema.extend(WnfsAction.UploadFileSchema, Schema.Struct({ db: Database.Database })),\n output: Schema.required(FileInfoSchema),\n});\n\nexport const CreateFile = Operation.make({\n meta: { key: `${WNFS_OPERATION}.create-file`, name: 'Create File' },\n services: [Capability.Service],\n input: Schema.extend(WnfsAction.UploadFileSchema, Schema.Struct({ db: Database.Database })),\n output: Schema.Struct({\n object: WnfsFile.File,\n }),\n});\n"],
|
|
5
|
-
"mappings": ";;;;;;;AAAA;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,sBAAsB;AAC/B,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAE1B,SAASC,YAAY;AAIrB,IAAMC,iBAAiB,GAAGC,KAAKC,EAAE;AAE1B,IAAMC,SAASC,UAAUC,KAAK;EACnCJ,MAAM;IAAEK,KAAK,GAAGN,cAAAA;IAAyBO,MAAM;EAAmB;EAClEC,UAAU;IAACC,WAAWC;;EACtBC,OAAOC,eAAeC,KAAK,QAAQ,QAAQ,KAAA,EAAOC,KAAYC,eAAQ;EACtEC,QAAeC,cAAO;IACpBC,QAAQC,aAASC;EACnB,CAAA;AACF,CAAA;AAEO,IAAMC,SAASjB,UAAUC,KAAK;EACnCJ,MAAM;IAAEK,KAAK,GAAGN,cAAAA;IAAyBO,MAAM;EAAc;EAC7DC,UAAU;IAACC,WAAWC;;EACtBC,OAAcW,cAAOC,WAAWC,kBAAyBP,cAAO;IAAEQ,IAAIC,SAASA;EAAS,CAAA,CAAA;EACxFV,QAAeD,gBAASH,cAAAA;AAC1B,CAAA;AAEO,IAAMe,aAAavB,UAAUC,KAAK;EACvCJ,MAAM;IAAEK,KAAK,GAAGN,cAAAA;IAA8BO,MAAM;EAAc;EAClEC,UAAU;IAACC,WAAWC;;EACtBC,OAAcW,cAAOC,WAAWC,kBAAyBP,cAAO;IAAEQ,IAAIC,SAASA;EAAS,CAAA,CAAA;EACxFV,QAAeC,cAAO;IACpBC,QAAQC,aAASC;EACnB,CAAA;AACF,CAAA;",
|
|
6
|
-
"names": ["Schema", "Capability", "FileInfoSchema", "Database", "Operation", "meta", "WNFS_OPERATION", "meta", "id", "Create", "Operation", "make", "key", "name", "services", "Capability", "Service", "input", "FileInfoSchema", "pick", "pipe", "required", "output", "Struct", "object", "WnfsFile", "File", "Upload", "extend", "WnfsAction", "UploadFileSchema", "db", "Database", "CreateFile"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/helpers/upload.ts", "../../../src/helpers/common.ts", "../../../src/helpers/load.ts", "../../../src/helpers/wnfs-url.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Blockstore } from 'interface-blockstore';\nimport { CID } from 'multiformats';\nimport * as Raw from 'multiformats/codecs/raw';\nimport { sha256 } from 'multiformats/hashes/sha2';\n\nimport type { Space } from '@dxos/client/echo';\nimport { Obj } from '@dxos/echo';\nimport { log } from '@dxos/log';\n\nimport { type WnfsCapabilities } from '#types';\n\nimport { Rng, filePath, store } from './common';\nimport { loadWnfs } from './load';\nimport { wnfsUrl } from './wnfs-url';\n\nexport const upload = async ({\n file,\n blockstore,\n instances,\n space,\n}: {\n file: File;\n blockstore: Blockstore;\n instances?: WnfsCapabilities.Instances;\n space: Space;\n}) => {\n const { directory, forest } = await loadWnfs({ blockstore, instances, space });\n const wnfsStore = store(blockstore);\n\n const bytes = new Uint8Array(await file.arrayBuffer());\n const hash = await sha256.digest(bytes);\n const cid = CID.create(1, Raw.code, hash);\n\n const path = filePath(cid.toString(), space);\n\n // Given the root directory of the private file system,\n // write the file contents to `path` in said directory.\n const result = await directory.write(path, true, bytes, new Date(), forest, wnfsStore, new Rng());\n\n // Given the new immutable instance of the root directory after writing to it,\n // **store** the changes in the \"dark forest\" and the associated (block) store.\n const [_, updatedForest] = await result.rootDir.store(result.forest, wnfsStore, new Rng());\n const cidBytes = await updatedForest.store(wnfsStore);\n\n // Update the forest pointer on the associated space.\n Obj.change(space.properties, (obj) => {\n obj.wnfs.privateForestCid = CID.decode(cidBytes).toString();\n });\n\n // Generate `wnfs://` URL & return the info.\n const info = {\n name: file.name,\n type: file.type,\n url: wnfsUrl(path),\n cid: cid.toString(),\n };\n\n log('upload', { file, info });\n return info;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Blockstore } from 'interface-blockstore';\nimport { CID } from 'multiformats/cid';\nimport { sha256 } from 'multiformats/hashes/sha2';\nimport { type BlockStore as WnfsBlockStore } from 'wnfs';\n\nimport * as crypto from '@dxos/crypto';\nimport { type Space } from '@dxos/react-client/echo';\n\n//\n// PATH\n//\n\nexport const filePath = (fileName: string, space: Space) => {\n return ['spaces', space.id, 'files', fileName];\n};\n\n//\n// RNG\n//\n\nexport class Rng {\n randomBytes(count: number): Uint8Array {\n return new Uint8Array(crypto.randomBytes(count));\n }\n}\n\n//\n// STORE\n//\n\nexport const store = (blockstore: Blockstore): WnfsBlockStore => {\n const getBlock = async (cid: Uint8Array): Promise<Uint8Array | undefined> => {\n const decodedCid = CID.decode(cid);\n return await blockstore.get(decodedCid);\n };\n\n const hasBlock = async (cid: Uint8Array): Promise<boolean> => {\n const decodedCid = CID.decode(cid);\n return await blockstore.has(decodedCid);\n };\n\n const putBlockKeyed = async (cid: Uint8Array, bytes: Uint8Array): Promise<void> => {\n const decodedCid = CID.decode(cid);\n await blockstore.put(decodedCid, bytes);\n };\n\n // Don't hash blocks with the rs-wnfs default Blake 3, sha256 has better support.\n const putBlock = async (bytes: Uint8Array, codec: number): Promise<Uint8Array> => {\n const hash = await sha256.digest(bytes);\n const cid = CID.create(1, codec, hash);\n await blockstore.put(cid, bytes);\n return cid.bytes;\n };\n\n return { getBlock, hasBlock, putBlockKeyed, putBlock };\n};\n\nexport const storeName = () => 'dxos/wnfs';\n\n//\n// OTHER\n//\n\nexport const readFile = (file: File): Promise<Uint8Array> => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (event) => {\n const result = event.target?.result;\n if (result === null || result === undefined || typeof result === 'string') {\n reject(new Error('Expected an ArrayBuffer'));\n return;\n }\n resolve(new Uint8Array(result));\n };\n reader.onerror = (err) => {\n reject(err);\n };\n reader.readAsArrayBuffer(file);\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Blockstore } from 'interface-blockstore';\nimport { CID } from 'multiformats';\nimport * as Uint8Arrays from 'uint8arrays';\nimport { AccessKey, PrivateDirectory, PrivateForest, PrivateNode } from 'wnfs';\n\nimport { Obj } from '@dxos/echo';\nimport { type Space } from '@dxos/react-client/echo';\n\nimport { type WnfsCapabilities } from '#types';\n\nimport { Rng, store } from './common';\n\n//\n// LOAD\n//\n\nexport const loadWnfs = async ({\n space,\n blockstore,\n instances,\n}: {\n space: Space;\n blockstore: Blockstore;\n instances?: WnfsCapabilities.Instances;\n}) => {\n // TODO(wittjosiah): Remove.\n // Delete old properties if they exist.\n if (space.properties.wnfs_access_key !== undefined && space.properties.wnfs_private_forest_cid !== undefined) {\n Obj.change(space.properties, (obj) => {\n delete obj['wnfs_access_key'];\n delete obj['wnfs_private_forest_cid'];\n });\n }\n\n const cacheKey = space.properties.wnfs?.privateForestCid;\n if (instances?.[cacheKey]) {\n return instances[cacheKey];\n }\n\n const exists = !!space.properties.wnfs;\n const instance = exists ? await loadWnfsDir(blockstore, space) : await createWnfsDir(blockstore, space);\n if (instances) {\n instances[cacheKey] = instance;\n }\n\n return instance;\n};\n\n//\n// PRIVATE\n//\n\nconst createWnfsDir = async (blockstore: Blockstore, space: Space) => {\n const wnfsStore = store(blockstore);\n const rng = new Rng();\n const forest = new PrivateForest(rng);\n\n const dirResult = await PrivateDirectory.newAndStore(forest.emptyName(), new Date(), forest, wnfsStore, rng);\n const dir = dirResult.rootDir as PrivateDirectory;\n\n const [accessKeyRaw, newForest]: [AccessKey, PrivateForest] = await dir\n .asNode()\n .store(dirResult.forest as PrivateForest, wnfsStore, rng);\n\n const cidBytes = await newForest.store(wnfsStore);\n\n Obj.change(space.properties, (obj) => {\n obj.wnfs = {\n accessKey: Uint8Arrays.toString(accessKeyRaw.toBytes(), 'base64'),\n privateForestCid: CID.decode(cidBytes).toString(),\n };\n });\n\n return {\n directory: dir,\n forest: newForest,\n };\n};\n\nconst loadWnfsDir = async (blockstore: Blockstore, space: Space) => {\n const wnfsStore = store(blockstore);\n\n const accessKey = AccessKey.fromBytes(Uint8Arrays.fromString(space.properties.wnfs.accessKey, 'base64'));\n const forest: PrivateForest = await PrivateForest.load(\n CID.parse(space.properties.wnfs.privateForestCid).bytes,\n wnfsStore,\n );\n const node: PrivateNode = await PrivateNode.load(accessKey, forest, wnfsStore);\n\n return {\n directory: node.asDir(),\n forest,\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { Blockstore } from 'interface-blockstore';\nimport { type PrivateDirectory, type PrivateForest } from 'wnfs';\n\nimport { store } from './common';\n\nexport const wnfsUrl = (filePath: string[]) => {\n return 'wnfs://' + filePath.map((f) => encodeURIComponent(f)).join('/');\n};\n\nexport const getPathFromUrl = (wnfsUrl: string) =>\n wnfsUrl\n .replace(/^wnfs:\\/\\//, '')\n .split('/')\n .map((p) => decodeURIComponent(p));\n\nexport const getBlobUrl = async ({\n wnfsUrl,\n blockstore,\n forest,\n directory,\n type,\n}: {\n wnfsUrl: string;\n blockstore: Blockstore;\n forest: PrivateForest;\n directory: PrivateDirectory;\n type?: string;\n}) => {\n const path = getPathFromUrl(wnfsUrl);\n const wnfsStore = store(blockstore);\n const { result } = await directory.read(path, true, forest, wnfsStore);\n const blob = new Blob([result], { type });\n return URL.createObjectURL(blob);\n};\n"],
|
|
5
|
-
"mappings": ";AAKA,SAASA,OAAAA,YAAW;AACpB,YAAYC,SAAS;AACrB,SAASC,UAAAA,eAAc;AAGvB,SAASC,OAAAA,YAAW;AACpB,SAASC,WAAW;;;ACNpB,SAASC,WAAW;AACpB,SAASC,cAAc;AAGvB,YAAYC,YAAY;AAOjB,IAAMC,WAAW,CAACC,UAAkBC,UAAAA;AACzC,SAAO;IAAC;IAAUA,MAAMC;IAAI;IAASF;;AACvC;AAMO,IAAMG,MAAN,MAAMA;EACXC,YAAYC,OAA2B;AACrC,WAAO,IAAIC,WAAkBF,mBAAYC,KAAAA,CAAAA;EAC3C;AACF;AAMO,IAAME,QAAQ,CAACC,eAAAA;AACpB,QAAMC,WAAW,OAAOC,QAAAA;AACtB,UAAMC,aAAaC,IAAIC,OAAOH,GAAAA;AAC9B,WAAO,MAAMF,WAAWM,IAAIH,UAAAA;EAC9B;AAEA,QAAMI,WAAW,OAAOL,QAAAA;AACtB,UAAMC,aAAaC,IAAIC,OAAOH,GAAAA;AAC9B,WAAO,MAAMF,WAAWQ,IAAIL,UAAAA;EAC9B;AAEA,QAAMM,gBAAgB,OAAOP,KAAiBQ,UAAAA;AAC5C,UAAMP,aAAaC,IAAIC,OAAOH,GAAAA;AAC9B,UAAMF,WAAWW,IAAIR,YAAYO,KAAAA;EACnC;AAGA,QAAME,WAAW,OAAOF,OAAmBG,UAAAA;AACzC,UAAMC,OAAO,MAAMC,OAAOC,OAAON,KAAAA;AACjC,UAAMR,MAAME,IAAIa,OAAO,GAAGJ,OAAOC,IAAAA;AACjC,UAAMd,WAAWW,IAAIT,KAAKQ,KAAAA;AAC1B,WAAOR,IAAIQ;EACb;AAEA,SAAO;IAAET;IAAUM;IAAUE;IAAeG;EAAS;AACvD;;;ACtDA,SAASM,OAAAA,YAAW;AACpB,YAAYC,iBAAiB;AAC7B,SAASC,WAAWC,kBAAkBC,eAAeC,mBAAmB;AAExE,SAASC,WAAW;AAWb,IAAMC,WAAW,OAAO,EAC7BC,OACAC,YACAC,UAAS,MAKV;AAGC,MAAIF,MAAMG,WAAWC,oBAAoBC,UAAaL,MAAMG,WAAWG,4BAA4BD,QAAW;AAC5GE,QAAIC,OAAOR,MAAMG,YAAY,CAACM,QAAAA;AAC5B,aAAOA,IAAI,iBAAA;AACX,aAAOA,IAAI,yBAAA;IACb,CAAA;EACF;AAEA,QAAMC,WAAWV,MAAMG,WAAWQ,MAAMC;AACxC,MAAIV,YAAYQ,QAAAA,GAAW;AACzB,WAAOR,UAAUQ,QAAAA;EACnB;AAEA,QAAMG,SAAS,CAAC,CAACb,MAAMG,WAAWQ;AAClC,QAAMG,WAAWD,SAAS,MAAME,YAAYd,YAAYD,KAAAA,IAAS,MAAMgB,cAAcf,YAAYD,KAAAA;AACjG,MAAIE,WAAW;AACbA,cAAUQ,QAAAA,IAAYI;EACxB;AAEA,SAAOA;AACT;AAMA,IAAME,gBAAgB,OAAOf,YAAwBD,UAAAA;AACnD,QAAMiB,YAAYC,MAAMjB,UAAAA;AACxB,QAAMkB,MAAM,IAAIC,IAAAA;AAChB,QAAMC,SAAS,IAAIC,cAAcH,GAAAA;AAEjC,QAAMI,YAAY,MAAMC,iBAAiBC,YAAYJ,OAAOK,UAAS,GAAI,oBAAIC,KAAAA,GAAQN,QAAQJ,WAAWE,GAAAA;AACxG,QAAMS,MAAML,UAAUM;AAEtB,QAAM,CAACC,cAAcC,SAAAA,IAAyC,MAAMH,IACjEI,OAAM,EACNd,MAAMK,UAAUF,QAAyBJ,WAAWE,GAAAA;AAEvD,QAAMc,WAAW,MAAMF,UAAUb,MAAMD,SAAAA;AAEvCV,MAAIC,OAAOR,MAAMG,YAAY,CAACM,QAAAA;AAC5BA,QAAIE,OAAO;MACTuB,WAAuBC,qBAASL,aAAaM,QAAO,GAAI,QAAA;MACxDxB,kBAAkByB,KAAIC,OAAOL,QAAAA,EAAUE,SAAQ;IACjD;EACF,CAAA;AAEA,SAAO;IACLI,WAAWX;IACXP,QAAQU;EACV;AACF;AAEA,IAAMhB,cAAc,OAAOd,YAAwBD,UAAAA;AACjD,QAAMiB,YAAYC,MAAMjB,UAAAA;AAExB,QAAMiC,YAAYM,UAAUC,UAAsBC,uBAAW1C,MAAMG,WAAWQ,KAAKuB,WAAW,QAAA,CAAA;AAC9F,QAAMb,SAAwB,MAAMC,cAAcqB,KAChDN,KAAIO,MAAM5C,MAAMG,WAAWQ,KAAKC,gBAAgB,EAAEiC,OAClD5B,SAAAA;AAEF,QAAM6B,OAAoB,MAAMC,YAAYJ,KAAKT,WAAWb,QAAQJ,SAAAA;AAEpE,SAAO;IACLsB,WAAWO,KAAKE,MAAK;IACrB3B;EACF;AACF;;;ACxFO,IAAM4B,UAAU,CAACC,cAAAA;AACtB,SAAO,YAAYA,UAASC,IAAI,CAACC,MAAMC,mBAAmBD,CAAAA,CAAAA,EAAIE,KAAK,GAAA;AACrE;;;;AHQO,IAAMC,SAAS,OAAO,EAC3BC,MACAC,YACAC,WACAC,MAAK,MAMN;AACC,QAAM,EAAEC,WAAWC,OAAM,IAAK,MAAMC,SAAS;IAAEL;IAAYC;IAAWC;EAAM,CAAA;AAC5E,QAAMI,YAAYC,MAAMP,UAAAA;AAExB,QAAMQ,QAAQ,IAAIC,WAAW,MAAMV,KAAKW,YAAW,CAAA;AACnD,QAAMC,OAAO,MAAMC,QAAOC,OAAOL,KAAAA;AACjC,QAAMM,MAAMC,KAAIC,OAAO,GAAOC,UAAMN,IAAAA;AAEpC,QAAMO,OAAOC,SAASL,IAAIM,SAAQ,GAAIlB,KAAAA;AAItC,QAAMmB,SAAS,MAAMlB,UAAUmB,MAAMJ,MAAM,MAAMV,OAAO,oBAAIe,KAAAA,GAAQnB,QAAQE,WAAW,IAAIkB,IAAAA,CAAAA;AAI3F,QAAM,CAACC,GAAGC,aAAAA,IAAiB,MAAML,OAAOM,QAAQpB,MAAMc,OAAOjB,QAAQE,WAAW,IAAIkB,IAAAA,CAAAA;AACpF,QAAMI,WAAW,MAAMF,cAAcnB,MAAMD,SAAAA;AAG3CuB,EAAAA,KAAIC,OAAO5B,MAAM6B,YAAY,CAACC,QAAAA;AAC5BA,QAAIC,KAAKC,mBAAmBnB,KAAIoB,OAAOP,QAAAA,EAAUR,SAAQ;EAC3D,CAAA;AAGA,QAAMgB,OAAO;IACXC,MAAMtC,KAAKsC;IACXC,MAAMvC,KAAKuC;IACXC,KAAKC,QAAQtB,IAAAA;IACbJ,KAAKA,IAAIM,SAAQ;EACnB;AAEAqB,MAAI,UAAU;IAAE1C;IAAMqC;EAAK,GAAA;;;;;;AAC3B,SAAOA;AACT;",
|
|
6
|
-
"names": ["CID", "Raw", "sha256", "Obj", "log", "CID", "sha256", "crypto", "filePath", "fileName", "space", "id", "Rng", "randomBytes", "count", "Uint8Array", "store", "blockstore", "getBlock", "cid", "decodedCid", "CID", "decode", "get", "hasBlock", "has", "putBlockKeyed", "bytes", "put", "putBlock", "codec", "hash", "sha256", "digest", "create", "CID", "Uint8Arrays", "AccessKey", "PrivateDirectory", "PrivateForest", "PrivateNode", "Obj", "loadWnfs", "space", "blockstore", "instances", "properties", "wnfs_access_key", "undefined", "wnfs_private_forest_cid", "Obj", "change", "obj", "cacheKey", "wnfs", "privateForestCid", "exists", "instance", "loadWnfsDir", "createWnfsDir", "wnfsStore", "store", "rng", "Rng", "forest", "PrivateForest", "dirResult", "PrivateDirectory", "newAndStore", "emptyName", "Date", "dir", "rootDir", "accessKeyRaw", "newForest", "asNode", "cidBytes", "accessKey", "toString", "toBytes", "CID", "decode", "directory", "AccessKey", "fromBytes", "fromString", "load", "parse", "bytes", "node", "PrivateNode", "asDir", "wnfsUrl", "filePath", "map", "f", "encodeURIComponent", "join", "upload", "file", "blockstore", "instances", "space", "directory", "forest", "loadWnfs", "wnfsStore", "store", "bytes", "Uint8Array", "arrayBuffer", "hash", "sha256", "digest", "cid", "CID", "create", "code", "path", "filePath", "toString", "result", "write", "Date", "Rng", "_", "updatedForest", "rootDir", "cidBytes", "Obj", "change", "properties", "obj", "wnfs", "privateForestCid", "decode", "info", "name", "type", "url", "wnfsUrl", "log"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/operations/create.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Operation } from '@dxos/operation';\n\nimport { WnfsFile } from '../types';\nimport { Create } from './definitions';\n\nconst handler: Operation.WithHandler<typeof Create> = Create.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ name, type, cid }) {\n return {\n object: WnfsFile.make({ name, type, cid }),\n };\n }),\n ),\n);\n\nexport default handler;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,iBAAiB;AAK1B,IAAMC,UAAgDC,OAAOC,KAC3DC,UAAUC,YACDC,kBAAW,WAAW,EAAEC,MAAMC,MAAMC,IAAG,GAAE;AAC9C,SAAO;IACLC,QAAQC,aAASC,KAAK;MAAEL;MAAMC;MAAMC;IAAI,CAAA;EAC1C;AACF,CAAA,CAAA,CAAA;AAIJ,IAAA,iBAAeR;",
|
|
6
|
-
"names": ["Effect", "Operation", "handler", "Create", "pipe", "Operation", "withHandler", "fnUntraced", "name", "type", "cid", "object", "WnfsFile", "make"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/operations/create-file.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, WnfsFile } from '../types';\nimport { CreateFile } from './definitions';\n\nconst handler: Operation.WithHandler<typeof CreateFile> = CreateFile.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 {\n object: WnfsFile.make({ name: info.name, type: info.type, cid: info.cid }),\n };\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,UAAoDC,WAAWC,KACnEC,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,SAAO;IACLO,QAAQC,aAASC,KAAK;MAAEC,MAAMN,KAAKM;MAAMC,MAAMP,KAAKO;MAAMC,KAAKR,KAAKQ;IAAI,CAAA;EAC1E;AACF,CAAA,CAAA,CAAA;AAIJ,IAAA,sBAAe5B;",
|
|
6
|
-
"names": ["Effect", "Capability", "invariant", "Operation", "ClientCapabilities", "handler", "CreateFile", "pipe", "Operation", "withHandler", "fnUntraced", "file", "db", "client", "Capability", "get", "ClientCapabilities", "Client", "blockstore", "WnfsCapabilities", "Blockstore", "space", "spaces", "spaceId", "invariant", "info", "promise", "upload", "object", "WnfsFile", "make", "name", "type", "cid"]
|
|
7
|
-
}
|
|
@@ -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
|
-
}
|