@dxos/plugin-wnfs 0.8.2-staging.7ac8446 → 0.8.2
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-SEU43TLT.mjs +106 -0
- package/dist/lib/browser/FileContainer-SEU43TLT.mjs.map +7 -0
- package/dist/lib/browser/{blockstore-G47Q25U6.mjs → blockstore-UT7233RJ.mjs} +5 -5
- package/dist/lib/browser/blockstore-UT7233RJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NIDFBTNY.mjs → chunk-DL7BBH57.mjs} +3 -3
- package/dist/lib/browser/{chunk-NIDFBTNY.mjs.map → chunk-DL7BBH57.mjs.map} +1 -1
- package/dist/lib/browser/chunk-LQYDI474.mjs +16 -0
- package/dist/lib/browser/{chunk-X54OT4V3.mjs → chunk-PHTWWADN.mjs} +2 -2
- package/dist/lib/browser/{chunk-X54OT4V3.mjs.map → chunk-PHTWWADN.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-FKYLWLNM.mjs → chunk-RY5XZCVP.mjs} +21 -17
- package/dist/lib/browser/chunk-RY5XZCVP.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-OQHVKRQ5.mjs} +4 -4
- package/dist/lib/browser/file-uploader-OQHVKRQ5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +4 -4
- package/dist/lib/browser/{intent-resolver-VSMIQLGS.mjs → intent-resolver-42B3MXJZ.mjs} +8 -8
- package/dist/lib/browser/intent-resolver-42B3MXJZ.mjs.map +7 -0
- package/dist/lib/browser/{markdown-MWMZVPEX.mjs → markdown-BWBHUHHH.mjs} +7 -9
- package/dist/lib/browser/markdown-BWBHUHHH.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-MKJYHQ4P.mjs → react-surface-GTYQZY3L.mjs} +28 -22
- package/dist/lib/browser/react-surface-GTYQZY3L.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/types/src/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +2 -2
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +2 -2
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +4 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +2 -2
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/FileContainer.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/FilePreview.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.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 +3 -2
- package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -10
- package/dist/types/src/translations.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/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -23
- package/src/blockstore.ts +9 -9
- package/src/capabilities/blockstore.ts +3 -3
- package/src/capabilities/file-uploader.ts +3 -3
- package/src/capabilities/intent-resolver.ts +5 -5
- package/src/capabilities/markdown.ts +4 -4
- 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/extensions/image.tsx +2 -2
- package/src/helpers/wnfs-url.ts +5 -3
- package/src/meta.ts +1 -1
- package/src/types/file.ts +7 -5
- package/src/types/types.ts +12 -10
- package/dist/lib/browser/FileContainer-4HNP22HU.mjs +0 -93
- package/dist/lib/browser/FileContainer-4HNP22HU.mjs.map +0 -7
- package/dist/lib/browser/blockstore-G47Q25U6.mjs.map +0 -7
- package/dist/lib/browser/chunk-FH2Q7ZBE.mjs +0 -16
- package/dist/lib/browser/chunk-FKYLWLNM.mjs.map +0 -7
- package/dist/lib/browser/file-uploader-L4TDVJBE.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-VSMIQLGS.mjs.map +0 -7
- package/dist/lib/browser/markdown-MWMZVPEX.mjs.map +0 -7
- package/dist/lib/browser/react-surface-MKJYHQ4P.mjs.map +0 -7
- /package/dist/lib/browser/{chunk-FH2Q7ZBE.mjs.map → chunk-LQYDI474.mjs.map} +0 -0
|
@@ -1,17 +1,9 @@
|
|
|
1
|
+
import { FileType } from './types';
|
|
1
2
|
declare const _default: {
|
|
2
3
|
'en-US': {
|
|
3
|
-
[
|
|
4
|
+
[FileType.typename]: {
|
|
4
5
|
'typename label': string;
|
|
5
6
|
'object name placeholder': string;
|
|
6
|
-
'plugin name'?: undefined;
|
|
7
|
-
'delete object label'?: undefined;
|
|
8
|
-
'file input placeholder'?: undefined;
|
|
9
|
-
} | {
|
|
10
|
-
'plugin name': string;
|
|
11
|
-
'delete object label': string;
|
|
12
|
-
'file input placeholder': string;
|
|
13
|
-
'typename label'?: undefined;
|
|
14
|
-
'object name placeholder'?: undefined;
|
|
15
7
|
};
|
|
16
8
|
"dxos.org/plugin/wnfs": {
|
|
17
9
|
'plugin name': string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;;;QAK7B,CAAC,QAAQ,CAAC,QAAQ,CAAC;;;UAGlB;;;;;;;;AANP,wBAcE"}
|
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.
|
|
1
|
+
{"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-wnfs",
|
|
3
|
-
"version": "0.8.2
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "WNFS file management plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -34,10 +34,11 @@
|
|
|
34
34
|
"@codemirror/state": "^6.4.1",
|
|
35
35
|
"@codemirror/view": "^6.34.1",
|
|
36
36
|
"@ipld/car": "^5.3.3",
|
|
37
|
+
"@preact-signals/safe-react": "^0.9.0",
|
|
37
38
|
"blockstore-core": "^5.0.1",
|
|
38
39
|
"blockstore-idb": "^2.0.0",
|
|
39
40
|
"debounce": "^2.2.0",
|
|
40
|
-
"effect": "3.
|
|
41
|
+
"effect": "3.14.21",
|
|
41
42
|
"idb-keyval": "^6.2.1",
|
|
42
43
|
"interface-blockstore": "^5.2.10",
|
|
43
44
|
"it-all": "^3.0.6",
|
|
@@ -45,22 +46,23 @@
|
|
|
45
46
|
"react-dropzone": "^14.2.3",
|
|
46
47
|
"uint8arrays": "^5.1.0",
|
|
47
48
|
"wnfs": "0.2.2",
|
|
48
|
-
"@dxos/app-framework": "0.8.2
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/echo-schema": "0.8.2
|
|
51
|
-
"@dxos/invariant": "0.8.2
|
|
52
|
-
"@dxos/effect": "0.8.2
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/plugin-
|
|
57
|
-
"@dxos/plugin-
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/react-ui": "0.8.2
|
|
60
|
-
"@dxos/react-ui
|
|
61
|
-
"@dxos/react-
|
|
62
|
-
"@dxos/react-ui-
|
|
63
|
-
"@dxos/
|
|
49
|
+
"@dxos/app-framework": "0.8.2",
|
|
50
|
+
"@dxos/echo": "0.8.2",
|
|
51
|
+
"@dxos/echo-schema": "0.8.2",
|
|
52
|
+
"@dxos/invariant": "0.8.2",
|
|
53
|
+
"@dxos/effect": "0.8.2",
|
|
54
|
+
"@dxos/crypto": "0.8.2",
|
|
55
|
+
"@dxos/local-storage": "0.8.2",
|
|
56
|
+
"@dxos/log": "0.8.2",
|
|
57
|
+
"@dxos/plugin-client": "0.8.2",
|
|
58
|
+
"@dxos/plugin-markdown": "0.8.2",
|
|
59
|
+
"@dxos/plugin-space": "0.8.2",
|
|
60
|
+
"@dxos/react-ui-editor": "0.8.2",
|
|
61
|
+
"@dxos/react-ui": "0.8.2",
|
|
62
|
+
"@dxos/react-client": "0.8.2",
|
|
63
|
+
"@dxos/react-ui-stack": "0.8.2",
|
|
64
|
+
"@dxos/react-ui-form": "0.8.2",
|
|
65
|
+
"@dxos/util": "0.8.2"
|
|
64
66
|
},
|
|
65
67
|
"devDependencies": {
|
|
66
68
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -69,16 +71,17 @@
|
|
|
69
71
|
"react": "~18.2.0",
|
|
70
72
|
"react-dom": "~18.2.0",
|
|
71
73
|
"vite": "5.4.7",
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/storybook-utils": "0.8.2
|
|
74
|
+
"@dxos/random": "0.8.2",
|
|
75
|
+
"@dxos/react-ui-theme": "0.8.2",
|
|
76
|
+
"@dxos/storybook-utils": "0.8.2"
|
|
75
77
|
},
|
|
76
78
|
"peerDependencies": {
|
|
77
79
|
"@phosphor-icons/react": "^2.0.5",
|
|
80
|
+
"effect": "^3.13.3",
|
|
78
81
|
"react": "~18.2.0",
|
|
79
82
|
"react-dom": "~18.2.0",
|
|
80
|
-
"@dxos/react-ui": "0.8.2
|
|
81
|
-
"@dxos/react-ui
|
|
83
|
+
"@dxos/react-ui-theme": "0.8.2",
|
|
84
|
+
"@dxos/react-ui": "0.8.2"
|
|
82
85
|
},
|
|
83
86
|
"publishConfig": {
|
|
84
87
|
"access": "public"
|
package/src/blockstore.ts
CHANGED
|
@@ -41,7 +41,7 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
41
41
|
this.#flushQueue = debounce(this.#flushQueueInt, 5000);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
async open() {
|
|
44
|
+
async open(): Promise<void> {
|
|
45
45
|
await this.#localStore.open();
|
|
46
46
|
await this.#restoreQueue();
|
|
47
47
|
|
|
@@ -55,7 +55,7 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
url(apiHost: string, cid?: CID) {
|
|
58
|
+
url(apiHost: string, cid?: CID): string {
|
|
59
59
|
const path = cid ? cid.toString() : '';
|
|
60
60
|
return `${apiHost}/api/file${path.length ? '/' + path : ''}`;
|
|
61
61
|
}
|
|
@@ -122,7 +122,7 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
122
122
|
|
|
123
123
|
// REMOTE
|
|
124
124
|
|
|
125
|
-
async putRemote(key: CID, val: Uint8Array) {
|
|
125
|
+
async putRemote(key: CID, val: Uint8Array): Promise<void> {
|
|
126
126
|
if (this.#apiHost) {
|
|
127
127
|
await fetch(this.url(this.#apiHost, key), {
|
|
128
128
|
method: 'POST',
|
|
@@ -131,7 +131,7 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
async putCarRemote(car: Uint8Array) {
|
|
134
|
+
async putCarRemote(car: Uint8Array): Promise<void> {
|
|
135
135
|
if (this.#apiHost) {
|
|
136
136
|
await fetch(this.url(this.#apiHost), {
|
|
137
137
|
method: 'POST',
|
|
@@ -147,11 +147,11 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
147
147
|
|
|
148
148
|
readonly queueCacheName = `${storeName()}/state/queue`;
|
|
149
149
|
|
|
150
|
-
async #addToQueue(key: CID) {
|
|
150
|
+
async #addToQueue(key: CID): Promise<void> {
|
|
151
151
|
await this.#saveQueue([...this.#queue, key.toString()]);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
async #flushQueueInt() {
|
|
154
|
+
async #flushQueueInt(): Promise<void> {
|
|
155
155
|
if (!this.#isConnected || !this.#apiHost) {
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
@@ -186,7 +186,7 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
186
186
|
await this.#saveQueue(queue);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
async #restoreQueue() {
|
|
189
|
+
async #restoreQueue(): Promise<void> {
|
|
190
190
|
const fromCache = await IDB.get(this.queueCacheName);
|
|
191
191
|
if (fromCache && Array.isArray(fromCache)) {
|
|
192
192
|
this.#queue = fromCache;
|
|
@@ -194,7 +194,7 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
async #saveQueue(items: string[]) {
|
|
197
|
+
async #saveQueue(items: string[]): Promise<void> {
|
|
198
198
|
const arr = [...items];
|
|
199
199
|
this.#queue = arr;
|
|
200
200
|
await IDB.set(this.queueCacheName, arr);
|
|
@@ -202,7 +202,7 @@ export class MixedBlockstore extends BaseBlockstore {
|
|
|
202
202
|
|
|
203
203
|
// 🛠️
|
|
204
204
|
|
|
205
|
-
async #createCar(blocks: Block[]) {
|
|
205
|
+
async #createCar(blocks: Block[]): Promise<Uint8Array> {
|
|
206
206
|
const { writer, out } = CarWriter.create();
|
|
207
207
|
const outPromise = all(out);
|
|
208
208
|
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { contributes, type
|
|
5
|
+
import { contributes, type PluginContext } from '@dxos/app-framework';
|
|
6
6
|
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
7
7
|
|
|
8
8
|
import { WnfsCapabilities } from './capabilities';
|
|
9
9
|
import * as Blockstore from '../blockstore';
|
|
10
10
|
|
|
11
|
-
export default async (context:
|
|
12
|
-
const client = context.
|
|
11
|
+
export default async (context: PluginContext) => {
|
|
12
|
+
const client = context.getCapability(ClientCapabilities.Client);
|
|
13
13
|
const apiHost = client.config.values.runtime?.services?.edge?.url || 'http://localhost:8787';
|
|
14
14
|
const blockstore = Blockstore.create(apiHost);
|
|
15
15
|
await blockstore.open();
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import { Effect, pipe } from 'effect';
|
|
6
6
|
|
|
7
|
-
import { Capabilities, chain, contributes, createIntent, type
|
|
7
|
+
import { Capabilities, chain, contributes, createIntent, type PluginContext } from '@dxos/app-framework';
|
|
8
8
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
9
9
|
|
|
10
10
|
import { WnfsAction } from '../types';
|
|
11
11
|
|
|
12
|
-
export default (context:
|
|
12
|
+
export default (context: PluginContext) => {
|
|
13
13
|
return contributes(Capabilities.FileUploader, (file, space) => {
|
|
14
|
-
const { dispatch } = context.
|
|
14
|
+
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
15
15
|
|
|
16
16
|
const program = Effect.gen(function* () {
|
|
17
17
|
const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, { file, space }));
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { contributes, Capabilities, createResolver, type
|
|
6
|
-
import {
|
|
5
|
+
import { contributes, Capabilities, createResolver, type PluginContext } from '@dxos/app-framework';
|
|
6
|
+
import { live } from '@dxos/react-client/echo';
|
|
7
7
|
|
|
8
8
|
import { WnfsCapabilities } from './capabilities';
|
|
9
9
|
import { upload } from '../helpers';
|
|
10
10
|
import { FileType, WnfsAction } from '../types';
|
|
11
11
|
|
|
12
|
-
export default (context:
|
|
12
|
+
export default (context: PluginContext) =>
|
|
13
13
|
contributes(Capabilities.IntentResolver, [
|
|
14
14
|
// TODO(wittjosiah): Deleting the object doesn't delete the wnfs blob.
|
|
15
15
|
// Consider ways to trigger blob deletion based on object deletion and/or adding file system manager.
|
|
@@ -17,14 +17,14 @@ 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
|
}),
|
|
24
24
|
createResolver({
|
|
25
25
|
intent: WnfsAction.Upload,
|
|
26
26
|
resolve: async ({ file, space }) => {
|
|
27
|
-
const blockstore = context.
|
|
27
|
+
const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
|
|
28
28
|
const info = await upload({ file, blockstore, space });
|
|
29
29
|
return { data: info };
|
|
30
30
|
},
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { contributes, type
|
|
5
|
+
import { contributes, type PluginContext } from '@dxos/app-framework';
|
|
6
6
|
import { MarkdownCapabilities } from '@dxos/plugin-markdown';
|
|
7
7
|
import { getSpace } from '@dxos/react-client/echo';
|
|
8
8
|
|
|
9
9
|
import { WnfsCapabilities } from './capabilities';
|
|
10
10
|
import { image } from '../extensions';
|
|
11
11
|
|
|
12
|
-
export default (context:
|
|
12
|
+
export default (context: PluginContext) =>
|
|
13
13
|
contributes(MarkdownCapabilities.Extensions, [
|
|
14
14
|
({ document }) => {
|
|
15
|
-
const blockstore = context.
|
|
16
|
-
const instances = context.
|
|
15
|
+
const blockstore = context.getCapability(WnfsCapabilities.Blockstore);
|
|
16
|
+
const instances = context.getCapability(WnfsCapabilities.Instances);
|
|
17
17
|
|
|
18
18
|
if (document) {
|
|
19
19
|
const space = getSpace(document);
|
|
@@ -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/extensions/image.tsx
CHANGED
|
@@ -165,11 +165,11 @@ class WnfsImageWidget extends WidgetType {
|
|
|
165
165
|
super();
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
override eq(other: this) {
|
|
168
|
+
override eq(other: this): boolean {
|
|
169
169
|
return this._wnfsUrl === (other as any as WnfsImageWidget)._wnfsUrl;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
override toDOM(view: EditorView) {
|
|
172
|
+
override toDOM(view: EditorView): HTMLDivElement {
|
|
173
173
|
if (typeof this._url === 'string') {
|
|
174
174
|
return createImg(view, this._url);
|
|
175
175
|
}
|
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/meta.ts
CHANGED
|
@@ -11,5 +11,5 @@ export const meta: PluginMeta = {
|
|
|
11
11
|
name: 'WNFS',
|
|
12
12
|
description: 'Manage and view files with via the Web Native File System (WNFS).',
|
|
13
13
|
icon: 'ph--file-cloud--regular',
|
|
14
|
-
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/
|
|
14
|
+
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-wnfs',
|
|
15
15
|
};
|
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
|
}
|