@dxos/plugin-wnfs 0.8.4-main.28f8d3d → 0.8.4-main.406dc2a
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-LTKYOYSO.mjs → FileContainer-A4OJVMVS.mjs} +30 -32
- package/dist/lib/browser/FileContainer-A4OJVMVS.mjs.map +7 -0
- package/dist/lib/browser/blockstore-HK4IYHJJ.mjs +273 -0
- package/dist/lib/browser/{blockstore-PSYZCC2O.mjs.map → blockstore-HK4IYHJJ.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-VDDGZWAY.mjs → chunk-FYRZOKHG.mjs} +2 -4
- package/dist/lib/browser/chunk-FYRZOKHG.mjs.map +7 -0
- package/dist/lib/browser/chunk-PAIK4SJ3.mjs +16 -0
- package/dist/lib/browser/chunk-PAIK4SJ3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CW4BENRQ.mjs → chunk-QQB5IBX7.mjs} +9 -9
- package/dist/lib/browser/chunk-QQB5IBX7.mjs.map +7 -0
- package/dist/lib/browser/chunk-Y5JMTQ74.mjs +16 -0
- package/dist/lib/browser/{file-uploader-YRZPRETS.mjs → file-uploader-5S37ZZCW.mjs} +8 -7
- package/dist/lib/browser/file-uploader-5S37ZZCW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +7 -9
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-CKGJNE6P.mjs → intent-resolver-3KMIEDBO.mjs} +6 -6
- package/dist/lib/browser/{intent-resolver-CKGJNE6P.mjs.map → intent-resolver-3KMIEDBO.mjs.map} +1 -1
- package/dist/lib/browser/{markdown-RAGCVYGE.mjs → markdown-5XD3I2NQ.mjs} +22 -11
- package/dist/lib/browser/{markdown-RAGCVYGE.mjs.map → markdown-5XD3I2NQ.mjs.map} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-HGWZDLP2.mjs → react-surface-5D7M3Y4W.mjs} +10 -10
- package/dist/lib/browser/react-surface-5D7M3Y4W.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/types/src/WnfsPlugin.d.ts +1 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +1 -1
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +5 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/components/FileContainer.d.ts.map +1 -1
- package/dist/types/src/components/FileInput.d.ts +1 -1
- package/dist/types/src/components/FileInput.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/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types/file.d.ts +3 -3
- package/dist/types/src/types/file.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +5 -5
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -34
- package/src/WnfsPlugin.tsx +70 -68
- package/src/capabilities/capabilities.ts +3 -3
- package/src/capabilities/file-uploader.ts +5 -2
- package/src/capabilities/react-surface.tsx +4 -4
- package/src/components/FileContainer.tsx +9 -12
- package/src/components/FileInput.tsx +3 -3
- package/src/extensions/image.stories.tsx +13 -10
- package/src/extensions/image.tsx +2 -2
- package/src/meta.ts +1 -3
- package/src/types/file.ts +2 -2
- package/src/types/types.ts +5 -5
- package/dist/lib/browser/FileContainer-LTKYOYSO.mjs.map +0 -7
- package/dist/lib/browser/blockstore-PSYZCC2O.mjs +0 -191
- package/dist/lib/browser/chunk-CW4BENRQ.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.map +0 -7
- package/dist/lib/browser/chunk-ZMH2OULB.mjs +0 -16
- package/dist/lib/browser/file-uploader-YRZPRETS.mjs.map +0 -7
- package/dist/lib/browser/react-surface-HGWZDLP2.mjs.map +0 -7
- /package/dist/lib/browser/{chunk-ZMH2OULB.mjs.map → chunk-Y5JMTQ74.mjs.map} +0 -0
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
storeName
|
|
3
|
-
} from "./chunk-D6VTEQIE.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
|
-
#apiHost;
|
|
27
|
-
#localStore;
|
|
28
|
-
#isConnected;
|
|
29
|
-
#flushQueue;
|
|
30
|
-
#queue;
|
|
31
|
-
constructor(apiHost) {
|
|
32
|
-
super();
|
|
33
|
-
this.#apiHost = apiHost ? apiHost.replace(/\/?$/, "") : void 0;
|
|
34
|
-
this.#localStore = new IDBBlockstore(storeName());
|
|
35
|
-
this.#isConnected = navigator.onLine;
|
|
36
|
-
this.#queue = [];
|
|
37
|
-
this.#flushQueue = debounce(this.#flushQueueInt, 5e3);
|
|
38
|
-
}
|
|
39
|
-
async open() {
|
|
40
|
-
await this.#localStore.open();
|
|
41
|
-
await this.#restoreQueue();
|
|
42
|
-
window.addEventListener("offline", async () => {
|
|
43
|
-
this.#isConnected = false;
|
|
44
|
-
});
|
|
45
|
-
window.addEventListener("online", async () => {
|
|
46
|
-
this.#isConnected = true;
|
|
47
|
-
this.#flushQueue();
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
url(apiHost, cid) {
|
|
51
|
-
const path = cid ? cid.toString() : "";
|
|
52
|
-
return `${apiHost}/api/file${path.length ? "/" + path : ""}`;
|
|
53
|
-
}
|
|
54
|
-
// BLOCKSTORE IMPLEMENTATION
|
|
55
|
-
async delete(key) {
|
|
56
|
-
await this.#localStore.delete(key);
|
|
57
|
-
if (this.#isConnected && this.#apiHost) {
|
|
58
|
-
await fetch(this.url(this.#apiHost, key), {
|
|
59
|
-
method: "DELETE"
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async get(key) {
|
|
64
|
-
if (await this.#localStore.has(key)) {
|
|
65
|
-
return await this.#localStore.get(key);
|
|
66
|
-
}
|
|
67
|
-
if (this.#isConnected && this.#apiHost) {
|
|
68
|
-
const block = await fetch(this.url(this.#apiHost, key), {
|
|
69
|
-
method: "GET"
|
|
70
|
-
}).then((r) => r.arrayBuffer()).then((r) => new Uint8Array(r));
|
|
71
|
-
await this.#localStore.put(key, block);
|
|
72
|
-
return block;
|
|
73
|
-
}
|
|
74
|
-
return await this.#localStore.get(key);
|
|
75
|
-
}
|
|
76
|
-
async has(key) {
|
|
77
|
-
if (await this.#localStore.has(key)) {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
if (this.#isConnected && this.#apiHost) {
|
|
81
|
-
return await fetch(this.url(this.#apiHost, key), {
|
|
82
|
-
method: "HEAD"
|
|
83
|
-
}).then((r) => r.ok);
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
async put(key, val) {
|
|
88
|
-
await this.#localStore.put(key, val);
|
|
89
|
-
await this.#addToQueue(key);
|
|
90
|
-
this.#flushQueue();
|
|
91
|
-
return key;
|
|
92
|
-
}
|
|
93
|
-
async destroy() {
|
|
94
|
-
await this.#localStore.destroy();
|
|
95
|
-
}
|
|
96
|
-
// REMOTE
|
|
97
|
-
async putRemote(key, val) {
|
|
98
|
-
if (this.#apiHost) {
|
|
99
|
-
await fetch(this.url(this.#apiHost, key), {
|
|
100
|
-
method: "POST",
|
|
101
|
-
body: val
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async putCarRemote(car) {
|
|
106
|
-
if (this.#apiHost) {
|
|
107
|
-
await fetch(this.url(this.#apiHost), {
|
|
108
|
-
method: "POST",
|
|
109
|
-
headers: {
|
|
110
|
-
"Content-Type": "application/vnd.ipld.car"
|
|
111
|
-
},
|
|
112
|
-
body: car
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// QUEUE
|
|
117
|
-
queueCacheName = `${storeName()}/state/queue`;
|
|
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-PSYZCC2O.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 { WNFS_PLUGIN } from '../meta';\n\nimport { FileType } from './file';\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,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["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,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
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// src/capabilities/index.ts
|
|
2
|
-
import { lazy } from "@dxos/app-framework";
|
|
3
|
-
var Blockstore = lazy(() => import("./blockstore-PSYZCC2O.mjs"));
|
|
4
|
-
var FileUploader = lazy(() => import("./file-uploader-YRZPRETS.mjs"));
|
|
5
|
-
var IntentResolver = lazy(() => import("./intent-resolver-CKGJNE6P.mjs"));
|
|
6
|
-
var Markdown = lazy(() => import("./markdown-RAGCVYGE.mjs"));
|
|
7
|
-
var ReactSurface = lazy(() => import("./react-surface-HGWZDLP2.mjs"));
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
Blockstore,
|
|
11
|
-
FileUploader,
|
|
12
|
-
IntentResolver,
|
|
13
|
-
Markdown,
|
|
14
|
-
ReactSurface
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=chunk-ZMH2OULB.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/file-uploader.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect, pipe } from 'effect';\n\nimport { Capabilities, type PluginContext, chain, contributes, createIntent } from '@dxos/app-framework';\nimport { SpaceAction } from '@dxos/plugin-space/types';\n\nimport { WnfsAction } from '../types';\n\nexport default (context: PluginContext) => {\n return contributes(Capabilities.FileUploader, (file, space) => {\n const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);\n\n const program = Effect.gen(function* () {\n const fileInfo = yield* dispatch(createIntent(WnfsAction.Upload, { file, space }));\n yield* dispatch(pipe(createIntent(WnfsAction.Create, fileInfo), chain(SpaceAction.AddObject, { target: space })));\n return fileInfo;\n });\n\n return Effect.runPromise(program);\n });\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,SAASA,QAAQC,YAAY;AAE7B,SAASC,cAAkCC,OAAOC,aAAaC,oBAAoB;AACnF,SAASC,mBAAmB;AAI5B,IAAA,wBAAe,CAACC,YAAAA;AACd,SAAOC,YAAYC,aAAaC,cAAc,CAACC,MAAMC,UAAAA;AACnD,UAAM,EAAEC,SAAQ,IAAKN,QAAQO,cAAcL,aAAaM,gBAAgB;AAExE,UAAMC,UAAUC,OAAOC,IAAI,aAAA;AACzB,YAAMC,WAAW,OAAON,SAASO,aAAaC,WAAWC,QAAQ;QAAEX;QAAMC;MAAM,CAAA,CAAA;AAC/E,aAAOC,SAASU,KAAKH,aAAaC,WAAWG,QAAQL,QAAAA,GAAWM,MAAMC,YAAYC,WAAW;QAAEC,QAAQhB;MAAM,CAAA,CAAA,CAAA;AAC7G,aAAOO;IACT,CAAA;AAEA,WAAOF,OAAOY,WAAWb,OAAAA;EAC3B,CAAA;AACF;",
|
|
6
|
-
"names": ["Effect", "pipe", "Capabilities", "chain", "contributes", "createIntent", "SpaceAction", "context", "contributes", "Capabilities", "FileUploader", "file", "space", "dispatch", "getCapability", "IntentDispatcher", "program", "Effect", "gen", "fileInfo", "createIntent", "WnfsAction", "Upload", "pipe", "Create", "chain", "SpaceAction", "AddObject", "target", "runPromise"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface.tsx", "../../../src/components/index.ts", "../../../src/components/FileInput.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\nimport React, { useCallback } from 'react';\n\nimport { Capabilities, contributes, createSurface } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\nimport { findAnnotation } from '@dxos/effect';\nimport { type InputProps } from '@dxos/react-ui-form';\n\nimport { FileContainer, FileInput } from '../components';\nimport { WNFS_PLUGIN } from '../meta';\nimport { FileType, WnfsAction } from '../types';\n\nexport default () =>\n contributes(Capabilities.ReactSurface, [\n createSurface({\n id: `${WNFS_PLUGIN}/article`,\n role: ['article', 'section', 'slide'],\n filter: (data): data is { subject: FileType } => Obj.instanceOf(FileType, data.subject),\n component: ({ data, role }) => <FileContainer role={role} file={data.subject} />,\n }),\n createSurface({\n id: `${WNFS_PLUGIN}/create-form`,\n role: 'form-input',\n filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {\n const annotation = findAnnotation<boolean>(\n (data.schema as Schema.Schema.All).ast,\n WnfsAction.UploadAnnotationId,\n );\n return !!annotation;\n },\n component: ({ data: { prop, schema }, ...props }) => {\n const inputProps = props as unknown as InputProps;\n const handleChange = useCallback(\n (file: File) => inputProps.onValueChange?.('object', file),\n [prop, inputProps.onValueChange],\n );\n\n return <FileInput schema={schema} onChange={handleChange} />;\n },\n }),\n ]);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport const FileContainer = lazy(() => import('./FileContainer'));\n\nexport * from './FileInput';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\nimport React, { useCallback } from 'react';\nimport { useDropzone } from 'react-dropzone';\n\nimport { findAnnotation } from '@dxos/effect';\nimport { useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { WNFS_PLUGIN } from '../meta';\nimport { WnfsAction } from '../types';\n\nexport type FileInputProps = {\n schema: Schema.Schema.Any;\n onChange: (file: File) => void;\n};\n\nexport const FileInput = ({ schema, onChange }: FileInputProps) => {\n const { t } = useTranslation(WNFS_PLUGIN);\n const accept = findAnnotation<Record<string, string[]>>(schema.ast, WnfsAction.UploadAnnotationId);\n\n const onDropAccepted = useCallback((files: File[]) => onChange?.(files[0]), [onChange]);\n\n const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({\n multiple: false,\n accept,\n onDropAccepted,\n });\n\n return (\n <div\n {...getRootProps()}\n className={mx(\n 'flex flex-col items-center p-8 border border-separator',\n isFocused && 'focus-ring',\n isDragAccept && 'bg-attention',\n isDragReject && 'border-error',\n )}\n >\n <input {...getInputProps()} />\n {acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file input placeholder')}</p>}\n </div>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAKA,OAAOA,UAASC,eAAAA,oBAAmB;AAEnC,SAASC,cAAcC,aAAaC,qBAAqB;AACzD,SAASC,WAAW;AACpB,SAASC,k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PC,MAAM;IACNC,QAAQ,CAACC,SAAAA;AACP,YAAMS,aAAaC,gBAChBV,KAAKW,OAA6BC,KACnCC,WAAWC,kBAAkB;AAE/B,aAAO,CAAC,CAACL;IACX;IACAJ,WAAW,CAAC,EAAEL,MAAM,EAAEe,MAAMJ,OAAM,GAAI,GAAGK,MAAAA,MAAO;AAC9C,YAAMC,aAAaD;AACnB,YAAME,eAAeC,aACnB,CAACX,SAAeS,WAAWG,gBAAgB,UAAUZ,IAAAA,GACrD;QAACO;QAAME,WAAWG;OAAc;AAGlC,aAAO,gBAAAd,OAAA,cAACe,WAAAA;QAAUV;QAAgBW,UAAUJ;;IAC9C;EACF,CAAA;CACD;",
|
|
6
|
-
"names": ["React", "useCallback", "Capabilities", "contributes", "createSurface", "Obj", "findAnnotation", "lazy", "React", "useCallback", "useDropzone", "findAnnotation", "useTranslation", "mx", "FileInput", "schema", "onChange", "t", "useTranslation", "WNFS_PLUGIN", "accept", "findAnnotation", "ast", "WnfsAction", "UploadAnnotationId", "onDropAccepted", "useCallback", "files", "acceptedFiles", "getRootProps", "getInputProps", "isFocused", "isDragAccept", "isDragReject", "useDropzone", "multiple", "div", "className", "mx", "input", "p", "name", "FileContainer", "lazy", "contributes", "Capabilities", "ReactSurface", "createSurface", "id", "WNFS_PLUGIN", "role", "filter", "data", "Obj", "instanceOf", "FileType", "subject", "component", "React", "FileContainer", "file", "annotation", "findAnnotation", "schema", "ast", "WnfsAction", "UploadAnnotationId", "prop", "props", "inputProps", "handleChange", "useCallback", "onValueChange", "FileInput", "onChange"]
|
|
7
|
-
}
|
|
File without changes
|