@dxos/plugin-wnfs 0.8.4-main.abd8ff62ef → 0.8.4-main.bc2380dfbc
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/FileArticle-B3NF2VKL.mjs +58 -0
- package/dist/lib/neutral/FileArticle-B3NF2VKL.mjs.map +7 -0
- package/dist/lib/neutral/WnfsPlugin.mjs +50 -0
- package/dist/lib/neutral/WnfsPlugin.mjs.map +7 -0
- package/dist/lib/neutral/WnfsPlugin.node.mjs +23 -0
- package/dist/lib/neutral/WnfsPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/WnfsPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/WnfsPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/blockstore-3NLSWC7Z.mjs +190 -0
- package/dist/lib/neutral/blockstore-3NLSWC7Z.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +19 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/{browser/index.mjs → neutral/chunk-LHUHUCBD.mjs} +1 -13
- package/dist/lib/neutral/chunk-LHUHUCBD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UIZBWELF.mjs +8 -0
- package/dist/lib/neutral/chunk-UIZBWELF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VWVCHTUK.mjs +125 -0
- package/dist/lib/neutral/chunk-VWVCHTUK.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +63 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +9 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/{browser/create-QRLX4IMZ.mjs → neutral/create-4ERE5CA4.mjs} +6 -8
- package/dist/lib/neutral/create-4ERE5CA4.mjs.map +7 -0
- package/dist/lib/{browser/create-file-INAT56PX.mjs → neutral/create-file-RAHDIJVU.mjs} +11 -13
- package/dist/lib/neutral/create-file-RAHDIJVU.mjs.map +7 -0
- package/dist/lib/neutral/create-object-7PJC47BB.mjs +33 -0
- package/dist/lib/neutral/create-object-7PJC47BB.mjs.map +7 -0
- package/dist/lib/neutral/file-uploader-WOF3H3FN.mjs +34 -0
- package/dist/lib/neutral/file-uploader-WOF3H3FN.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +40 -0
- package/dist/lib/neutral/markdown-I4FYAUCA.mjs +204 -0
- package/dist/lib/neutral/markdown-I4FYAUCA.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-NPYSIPMR.mjs +13 -0
- package/dist/lib/neutral/operation-handler-NPYSIPMR.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-6QHCDYC3.mjs +53 -0
- package/dist/lib/neutral/react-surface-6QHCDYC3.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/translations.mjs +1 -1
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +14 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/{browser/upload-ZQI66T4Y.mjs → neutral/upload-VA5CSUEP.mjs} +9 -11
- package/dist/lib/neutral/upload-VA5CSUEP.mjs.map +7 -0
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/WnfsPlugin.node.d.ts.map +1 -1
- package/dist/types/src/WnfsPlugin.workerd.d.ts +4 -0
- package/dist/types/src/WnfsPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +7 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +1 -1
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/containers/FileArticle/FileArticle.d.ts +7 -0
- package/dist/types/src/containers/FileArticle/FileArticle.d.ts.map +1 -0
- package/dist/types/src/containers/FileArticle/index.d.ts +2 -0
- package/dist/types/src/containers/FileArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +1 -1
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/create-file.d.ts +2 -2
- package/dist/types/src/operations/create-file.d.ts.map +1 -1
- package/dist/types/src/operations/create.d.ts +2 -2
- package/dist/types/src/operations/create.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +0 -1
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/upload.d.ts +2 -2
- package/dist/types/src/operations/upload.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/types/WnfsCapabilities.d.ts +11 -0
- package/dist/types/src/types/WnfsCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/{File.d.ts → WnfsFile.d.ts} +4 -4
- package/dist/types/src/types/WnfsFile.d.ts.map +1 -0
- package/dist/types/src/{operations/definitions.d.ts → types/WnfsOperation.d.ts} +1 -1
- package/dist/types/src/types/WnfsOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +87 -61
- package/src/WnfsPlugin.node.ts +4 -32
- package/src/WnfsPlugin.test.ts +3 -3
- package/src/WnfsPlugin.tsx +6 -32
- package/src/WnfsPlugin.workerd.ts +18 -0
- package/src/capabilities/blockstore.ts +1 -1
- package/src/capabilities/create-object.ts +33 -0
- package/src/capabilities/file-uploader.ts +2 -2
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/markdown.ts +1 -1
- package/src/capabilities/react-surface.tsx +5 -5
- package/src/containers/{FileContainer/FileContainer.tsx → FileArticle/FileArticle.tsx} +3 -3
- package/src/containers/FileArticle/index.ts +5 -0
- package/src/containers/index.ts +1 -1
- package/src/index.ts +2 -8
- package/src/operations/create-file.ts +3 -4
- package/src/operations/create.ts +2 -3
- package/src/operations/index.ts +0 -2
- package/src/operations/upload.ts +3 -4
- package/src/plugin.ts +11 -0
- package/src/translations.ts +1 -1
- package/src/types/WnfsCapabilities.ts +18 -0
- package/src/types/{File.ts → WnfsFile.ts} +5 -3
- package/src/{operations/definitions.ts → types/WnfsOperation.ts} +6 -3
- package/src/types/index.ts +4 -2
- package/dist/lib/browser/chunk-4D4K5JCC.mjs +0 -66
- package/dist/lib/browser/chunk-4D4K5JCC.mjs.map +0 -7
- package/dist/lib/browser/chunk-DK62NQ5T.mjs +0 -71
- package/dist/lib/browser/chunk-DK62NQ5T.mjs.map +0 -7
- package/dist/lib/browser/create-QRLX4IMZ.mjs.map +0 -7
- package/dist/lib/browser/create-file-INAT56PX.mjs.map +0 -7
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operations/index.mjs +0 -14
- package/dist/lib/browser/operations/index.mjs.map +0 -7
- package/dist/lib/browser/translations.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -12
- package/dist/lib/browser/upload-ZQI66T4Y.mjs.map +0 -7
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts +0 -7
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +0 -1
- package/dist/types/src/containers/FileContainer/index.d.ts +0 -2
- package/dist/types/src/containers/FileContainer/index.d.ts.map +0 -1
- package/dist/types/src/operations/definitions.d.ts.map +0 -1
- package/dist/types/src/types/File.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts +0 -13
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/src/containers/FileContainer/index.ts +0 -5
- package/src/types/capabilities.ts +0 -18
- /package/dist/lib/{browser → neutral}/chunk-7KFJ6LYH.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-7KFJ6LYH.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/helpers/index.mjs +0 -0
- /package/dist/lib/{browser → neutral}/helpers/index.mjs.map +0 -0
- /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/types/types.ts
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import { meta } from "#meta";
|
|
8
|
+
(function(WnfsAction2) {
|
|
9
|
+
WnfsAction2.UploadAnnotationId = /* @__PURE__ */ Symbol.for(`${meta.id}.annotation.upload`);
|
|
10
|
+
WnfsAction2.UploadFileSchema = Schema.Struct({
|
|
11
|
+
file: Schema.instanceOf(File).annotations({
|
|
12
|
+
[WnfsAction2.UploadAnnotationId]: {
|
|
13
|
+
// Accept file types.
|
|
14
|
+
"image/*": [
|
|
15
|
+
".jpg",
|
|
16
|
+
".jpeg",
|
|
17
|
+
".png",
|
|
18
|
+
".gif"
|
|
19
|
+
],
|
|
20
|
+
"application/pdf": [
|
|
21
|
+
".pdf"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
})(WnfsAction || (WnfsAction = {}));
|
|
27
|
+
var WnfsAction;
|
|
28
|
+
|
|
29
|
+
// src/types/WnfsCapabilities.ts
|
|
30
|
+
var WnfsCapabilities_exports = {};
|
|
31
|
+
__export(WnfsCapabilities_exports, {
|
|
32
|
+
Blockstore: () => Blockstore,
|
|
33
|
+
Instances: () => Instances
|
|
34
|
+
});
|
|
35
|
+
import { Capability } from "@dxos/app-framework";
|
|
36
|
+
import { meta as meta2 } from "#meta";
|
|
37
|
+
var Blockstore = Capability.make(`${meta2.id}.capability.blockstore`);
|
|
38
|
+
var Instances = Capability.make(`${meta2.id}.capability.instances`);
|
|
39
|
+
|
|
40
|
+
// src/types/WnfsFile.ts
|
|
41
|
+
var WnfsFile_exports = {};
|
|
42
|
+
__export(WnfsFile_exports, {
|
|
43
|
+
WnfsFile: () => WnfsFile,
|
|
44
|
+
make: () => make
|
|
45
|
+
});
|
|
46
|
+
import * as Schema2 from "effect/Schema";
|
|
47
|
+
import { Annotation, Obj, Type } from "@dxos/echo";
|
|
48
|
+
import { FormInputAnnotation } from "@dxos/echo/internal";
|
|
49
|
+
var WnfsFile = Schema2.Struct({
|
|
50
|
+
name: Schema2.String.pipe(Schema2.optional),
|
|
51
|
+
type: Schema2.String.pipe(FormInputAnnotation.set(false)),
|
|
52
|
+
cid: Schema2.String.pipe(FormInputAnnotation.set(false)),
|
|
53
|
+
timestamp: Schema2.String.pipe(FormInputAnnotation.set(false), Schema2.optional)
|
|
54
|
+
}).pipe(Type.object({
|
|
55
|
+
typename: "org.dxos.type.file",
|
|
56
|
+
version: "0.1.0"
|
|
57
|
+
}), Annotation.IconAnnotation.set({
|
|
58
|
+
icon: "ph--file--regular",
|
|
59
|
+
hue: "teal"
|
|
60
|
+
}));
|
|
61
|
+
var make = (props) => Obj.make(WnfsFile, props);
|
|
62
|
+
|
|
63
|
+
// src/types/WnfsOperation.ts
|
|
64
|
+
var WnfsOperation_exports = {};
|
|
65
|
+
__export(WnfsOperation_exports, {
|
|
66
|
+
Create: () => Create,
|
|
67
|
+
CreateFile: () => CreateFile,
|
|
68
|
+
Upload: () => Upload
|
|
69
|
+
});
|
|
70
|
+
import * as Schema3 from "effect/Schema";
|
|
71
|
+
import { Capability as Capability2 } from "@dxos/app-framework";
|
|
72
|
+
import { FileInfoSchema } from "@dxos/app-toolkit";
|
|
73
|
+
import { Operation } from "@dxos/compute";
|
|
74
|
+
import { Database } from "@dxos/echo";
|
|
75
|
+
import { meta as meta3 } from "#meta";
|
|
76
|
+
var WNFS_OPERATION = `${meta3.id}.operation`;
|
|
77
|
+
var Create = Operation.make({
|
|
78
|
+
meta: {
|
|
79
|
+
key: `${WNFS_OPERATION}.create`,
|
|
80
|
+
name: "Create WNFS File"
|
|
81
|
+
},
|
|
82
|
+
services: [
|
|
83
|
+
Capability2.Service
|
|
84
|
+
],
|
|
85
|
+
input: FileInfoSchema.pick("name", "type", "cid").pipe(Schema3.required),
|
|
86
|
+
output: Schema3.Struct({
|
|
87
|
+
object: WnfsFile
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
var Upload = Operation.make({
|
|
91
|
+
meta: {
|
|
92
|
+
key: `${WNFS_OPERATION}.upload`,
|
|
93
|
+
name: "Upload File"
|
|
94
|
+
},
|
|
95
|
+
services: [
|
|
96
|
+
Capability2.Service
|
|
97
|
+
],
|
|
98
|
+
input: Schema3.extend(WnfsAction.UploadFileSchema, Schema3.Struct({
|
|
99
|
+
db: Database.Database
|
|
100
|
+
})),
|
|
101
|
+
output: Schema3.required(FileInfoSchema)
|
|
102
|
+
});
|
|
103
|
+
var CreateFile = Operation.make({
|
|
104
|
+
meta: {
|
|
105
|
+
key: `${WNFS_OPERATION}.create-file`,
|
|
106
|
+
name: "Create File"
|
|
107
|
+
},
|
|
108
|
+
services: [
|
|
109
|
+
Capability2.Service
|
|
110
|
+
],
|
|
111
|
+
input: Schema3.extend(WnfsAction.UploadFileSchema, Schema3.Struct({
|
|
112
|
+
db: Database.Database
|
|
113
|
+
})),
|
|
114
|
+
output: Schema3.Struct({
|
|
115
|
+
object: WnfsFile
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
WnfsAction,
|
|
121
|
+
WnfsCapabilities_exports,
|
|
122
|
+
WnfsFile_exports,
|
|
123
|
+
WnfsOperation_exports
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=chunk-VWVCHTUK.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/types.ts", "../../../src/types/WnfsCapabilities.ts", "../../../src/types/WnfsFile.ts", "../../../src/types/WnfsOperation.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { meta } from '#meta';\n\nexport namespace WnfsAction {\n export const UploadAnnotationId = Symbol.for(`${meta.id}.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", "//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { type Blockstore as BlockstoreInterface } from 'interface-blockstore';\nimport { type PrivateDirectory, type PrivateForest } from 'wnfs';\n\nimport { Capability } from '@dxos/app-framework';\nimport { type SpaceId } from '@dxos/keys';\n\nimport { meta } from '#meta';\n\nexport const Blockstore = Capability.make<BlockstoreInterface>(`${meta.id}.capability.blockstore`);\n\nexport type Instances = Record<SpaceId, { directory: PrivateDirectory; forest: PrivateForest }>;\nexport const Instances = Capability.make<Instances>(`${meta.id}.capability.instances`);\n", "//\n// Copyright 2024 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Annotation, Obj, Type } from '@dxos/echo';\nimport { FormInputAnnotation } from '@dxos/echo/internal';\n\nexport const WnfsFile = Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n type: Schema.String.pipe(FormInputAnnotation.set(false)),\n cid: Schema.String.pipe(FormInputAnnotation.set(false)),\n timestamp: Schema.String.pipe(FormInputAnnotation.set(false), Schema.optional),\n}).pipe(\n Type.object({\n typename: 'org.dxos.type.file',\n version: '0.1.0',\n }),\n Annotation.IconAnnotation.set({\n icon: 'ph--file--regular',\n hue: 'teal',\n }),\n);\n\nexport type WnfsFile = Schema.Schema.Type<typeof WnfsFile>;\n\nexport const make = (props: Obj.MakeProps<typeof WnfsFile>) => Obj.make(WnfsFile, props);\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { Capability } from '@dxos/app-framework';\nimport { FileInfoSchema } from '@dxos/app-toolkit';\nimport { Operation } from '@dxos/compute';\nimport { Database } from '@dxos/echo';\n\nimport { meta } from '#meta';\n\nimport { WnfsAction } from './types';\nimport * as WnfsFile from './WnfsFile';\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.WnfsFile,\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.WnfsFile,\n }),\n});\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,YAAY;UAEJC,aAAAA;cACFC,qBAAqBC,uBAAOC,IAAI,GAAGJ,KAAKK,EAAE,oBAAoB;cAE9DC,mBAA0BC,cAAO;IAC5CC,MAAaC,kBAAWC,IAAAA,EAAMC,YAAY;MACxC,CAAAV,YAACC,kBAAAA,GAAqB;;QAEpB,WAAW;UAAC;UAAQ;UAAS;UAAQ;;QACrC,mBAAmB;UAAC;;MAEtB;IACF,CAAA;EACF,CAAA;AAGF,GAfiBD,eAAAA,aAAAA,CAAAA,EAAAA;;;;ACRjB;;;;;AASA,SAASW,kBAAkB;AAG3B,SAASC,QAAAA,aAAY;AAEd,IAAMC,aAAaF,WAAWG,KAA0B,GAAGF,MAAKG,EAAE,wBAAwB;AAG1F,IAAMC,YAAYL,WAAWG,KAAgB,GAAGF,MAAKG,EAAE,uBAAuB;;;ACjBrF;;;;;AAMA,YAAYE,aAAY;AAExB,SAASC,YAAYC,KAAKC,YAAY;AACtC,SAASC,2BAA2B;AAE7B,IAAMC,WAAkBC,eAAO;EACpCC,MAAaC,eAAOC,KAAYC,gBAAQ;EACxCC,MAAaH,eAAOC,KAAKL,oBAAoBQ,IAAI,KAAA,CAAA;EACjDC,KAAYL,eAAOC,KAAKL,oBAAoBQ,IAAI,KAAA,CAAA;EAChDE,WAAkBN,eAAOC,KAAKL,oBAAoBQ,IAAI,KAAA,GAAeF,gBAAQ;AAC/E,CAAA,EAAGD,KACDN,KAAKY,OAAO;EACVC,UAAU;EACVC,SAAS;AACX,CAAA,GACAhB,WAAWiB,eAAeN,IAAI;EAC5BO,MAAM;EACNC,KAAK;AACP,CAAA,CAAA;AAKK,IAAMC,OAAO,CAACC,UAA0CpB,IAAImB,KAAKhB,UAAUiB,KAAAA;;;AC7BlF;;;;;;AAMA,YAAYC,aAAY;AAExB,SAASC,cAAAA,mBAAkB;AAC3B,SAASC,sBAAsB;AAC/B,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AAEzB,SAASC,QAAAA,aAAY;AAKrB,IAAMC,iBAAiB,GAAGC,MAAKC,EAAE;AAE1B,IAAMC,SAASC,UAAUC,KAAK;EACnCJ,MAAM;IAAEK,KAAK,GAAGN,cAAAA;IAAyBO,MAAM;EAAmB;EAClEC,UAAU;IAACC,YAAWC;;EACtBC,OAAOC,eAAeC,KAAK,QAAQ,QAAQ,KAAA,EAAOC,KAAYC,gBAAQ;EACtEC,QAAeC,eAAO;IACpBC,QAAiBC;EACnB,CAAA;AACF,CAAA;AAEO,IAAMC,SAAShB,UAAUC,KAAK;EACnCJ,MAAM;IAAEK,KAAK,GAAGN,cAAAA;IAAyBO,MAAM;EAAc;EAC7DC,UAAU;IAACC,YAAWC;;EACtBC,OAAcU,eAAOC,WAAWC,kBAAyBN,eAAO;IAAEO,IAAIC,SAASA;EAAS,CAAA,CAAA;EACxFT,QAAeD,iBAASH,cAAAA;AAC1B,CAAA;AAEO,IAAMc,aAAatB,UAAUC,KAAK;EACvCJ,MAAM;IAAEK,KAAK,GAAGN,cAAAA;IAA8BO,MAAM;EAAc;EAClEC,UAAU;IAACC,YAAWC;;EACtBC,OAAcU,eAAOC,WAAWC,kBAAyBN,eAAO;IAAEO,IAAIC,SAASA;EAAS,CAAA,CAAA;EACxFT,QAAeC,eAAO;IACpBC,QAAiBC;EACnB,CAAA;AACF,CAAA;",
|
|
6
|
+
"names": ["Schema", "meta", "WnfsAction", "UploadAnnotationId", "Symbol", "for", "id", "UploadFileSchema", "Struct", "file", "instanceOf", "File", "annotations", "Capability", "meta", "Blockstore", "make", "id", "Instances", "Schema", "Annotation", "Obj", "Type", "FormInputAnnotation", "WnfsFile", "Struct", "name", "String", "pipe", "optional", "type", "set", "cid", "timestamp", "object", "typename", "version", "IconAnnotation", "icon", "hue", "make", "props", "Schema", "Capability", "FileInfoSchema", "Operation", "Database", "meta", "WNFS_OPERATION", "meta", "id", "Create", "Operation", "make", "key", "name", "services", "Capability", "Service", "input", "FileInfoSchema", "pick", "pipe", "required", "output", "Struct", "object", "WnfsFile", "Upload", "extend", "WnfsAction", "UploadFileSchema", "db", "Database", "CreateFile"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/components/FileInput/FileInput.tsx
|
|
4
|
+
import React, { useCallback } from "react";
|
|
5
|
+
import { useDropzone } from "react-dropzone";
|
|
6
|
+
import { findAnnotation } from "@dxos/effect";
|
|
7
|
+
import { useTranslation } from "@dxos/react-ui";
|
|
8
|
+
import { mx } from "@dxos/ui-theme";
|
|
9
|
+
import { meta } from "#meta";
|
|
10
|
+
import { WnfsAction } from "#types";
|
|
11
|
+
var FileInput = ({ schema, onChange }) => {
|
|
12
|
+
const { t } = useTranslation(meta.id);
|
|
13
|
+
const accept = findAnnotation(schema.ast, WnfsAction.UploadAnnotationId);
|
|
14
|
+
const onDropAccepted = useCallback((files) => onChange?.(files[0]), [
|
|
15
|
+
onChange
|
|
16
|
+
]);
|
|
17
|
+
const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({
|
|
18
|
+
multiple: false,
|
|
19
|
+
accept,
|
|
20
|
+
onDropAccepted
|
|
21
|
+
});
|
|
22
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
23
|
+
...getRootProps(),
|
|
24
|
+
className: mx("flex flex-col items-center p-8 border border-separator", isFocused && "focus-ring", isDragAccept && "bg-attention-surface", isDragReject && "border-rose-fill")
|
|
25
|
+
}, /* @__PURE__ */ React.createElement("input", getInputProps()), acceptedFiles[0] ? /* @__PURE__ */ React.createElement("p", null, acceptedFiles[0].name) : /* @__PURE__ */ React.createElement("p", null, t("file-input.placeholder")));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/components/FilePreview/FilePreview.tsx
|
|
29
|
+
import React2 from "react";
|
|
30
|
+
import { composable, composableProps } from "@dxos/ui-theme";
|
|
31
|
+
var FilePreview = composable(({ type, url, children, ...props }, forwardedRef) => {
|
|
32
|
+
if (type.startsWith("image/")) {
|
|
33
|
+
return /* @__PURE__ */ React2.createElement("img", {
|
|
34
|
+
...composableProps(props, {
|
|
35
|
+
classNames: "h-full w-full object-contain"
|
|
36
|
+
}),
|
|
37
|
+
src: url,
|
|
38
|
+
ref: forwardedRef
|
|
39
|
+
});
|
|
40
|
+
} else if (type.startsWith("video/")) {
|
|
41
|
+
return /* @__PURE__ */ React2.createElement("video", {
|
|
42
|
+
...composableProps(props, {
|
|
43
|
+
classNames: "h-full w-full object-contain"
|
|
44
|
+
}),
|
|
45
|
+
src: url,
|
|
46
|
+
controls: true,
|
|
47
|
+
ref: forwardedRef
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
return /* @__PURE__ */ React2.createElement("iframe", {
|
|
51
|
+
...composableProps(props, {
|
|
52
|
+
classNames: "h-full w-full overflow-auto"
|
|
53
|
+
}),
|
|
54
|
+
src: url,
|
|
55
|
+
ref: forwardedRef
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
export {
|
|
60
|
+
FileInput,
|
|
61
|
+
FilePreview
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/FileInput/FileInput.tsx", "../../../../src/components/FilePreview/FilePreview.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\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/ui-theme';\n\nimport { meta } 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(meta.id);\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-surface',\n isDragReject && 'border-rose-fill',\n )}\n >\n <input {...getInputProps()} />\n {acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file-input.placeholder')}</p>}\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { ForwardedRef } from 'react';\n\nimport { composable, composableProps } from '@dxos/ui-theme';\n\nexport type FilePreviewProps = { type: string; url: string };\n\n/**\n * File/content preview iframe.\n */\nexport const FilePreview = composable<HTMLElement, FilePreviewProps>(\n ({ type, url, children, ...props }, forwardedRef) => {\n if (type.startsWith('image/')) {\n return (\n <img\n {...composableProps(props, { classNames: 'h-full w-full object-contain' })}\n src={url}\n ref={forwardedRef as ForwardedRef<HTMLImageElement>}\n />\n );\n } else if (type.startsWith('video/')) {\n return (\n <video\n {...composableProps(props, { classNames: 'h-full w-full object-contain' })}\n src={url}\n controls\n ref={forwardedRef as ForwardedRef<HTMLVideoElement>}\n />\n );\n } else {\n return (\n <iframe\n {...composableProps(props, { classNames: 'h-full w-full overflow-auto' })}\n src={url}\n ref={forwardedRef as ForwardedRef<HTMLIFrameElement>}\n />\n );\n }\n },\n);\n"],
|
|
5
|
+
"mappings": ";;;AAKA,OAAOA,SAASC,mBAAmB;AACnC,SAASC,mBAAmB;AAE5B,SAASC,sBAAsB;AAC/B,SAASC,sBAAsB;AAC/B,SAASC,UAAU;AAEnB,SAASC,YAAY;AACrB,SAASC,kBAAkB;AAOpB,IAAMC,YAAY,CAAC,EAAEC,QAAQC,SAAQ,MAAkB;AAC5D,QAAM,EAAEC,EAAC,IAAKP,eAAeE,KAAKM,EAAE;AACpC,QAAMC,SAASV,eAAyCM,OAAOK,KAAKP,WAAWQ,kBAAkB;AAEjG,QAAMC,iBAAiBf,YAAY,CAACgB,UAAkBP,WAAWO,MAAM,CAAA,CAAE,GAAG;IAACP;GAAS;AAEtF,QAAM,EAAEQ,eAAeC,cAAcC,eAAeC,WAAWC,cAAcC,aAAY,IAAKrB,YAAY;IACxGsB,UAAU;IACVX;IACAG;EACF,CAAA;AAEA,SACE,sBAAA,cAACS,OAAAA;IACE,GAAGN,aAAAA;IACJO,WAAWrB,GACT,0DACAgB,aAAa,cACbC,gBAAgB,wBAChBC,gBAAgB,kBAAA;KAGlB,sBAAA,cAACI,SAAUP,cAAAA,CAAAA,GACVF,cAAc,CAAA,IAAK,sBAAA,cAACU,KAAAA,MAAGV,cAAc,CAAA,EAAGW,IAAI,IAAQ,sBAAA,cAACD,KAAAA,MAAGjB,EAAE,wBAAA,CAAA,CAAA;AAGjE;;;AC1CA,OAAOmB,YAA6B;AAEpC,SAASC,YAAYC,uBAAuB;AAOrC,IAAMC,cAAcF,WACzB,CAAC,EAAEG,MAAMC,KAAKC,UAAU,GAAGC,MAAAA,GAASC,iBAAAA;AAClC,MAAIJ,KAAKK,WAAW,QAAA,GAAW;AAC7B,WACE,gBAAAT,OAAA,cAACU,OAAAA;MACE,GAAGR,gBAAgBK,OAAO;QAAEI,YAAY;MAA+B,CAAA;MACxEC,KAAKP;MACLQ,KAAKL;;EAGX,WAAWJ,KAAKK,WAAW,QAAA,GAAW;AACpC,WACE,gBAAAT,OAAA,cAACc,SAAAA;MACE,GAAGZ,gBAAgBK,OAAO;QAAEI,YAAY;MAA+B,CAAA;MACxEC,KAAKP;MACLU,UAAAA;MACAF,KAAKL;;EAGX,OAAO;AACL,WACE,gBAAAR,OAAA,cAACgB,UAAAA;MACE,GAAGd,gBAAgBK,OAAO;QAAEI,YAAY;MAA8B,CAAA;MACvEC,KAAKP;MACLQ,KAAKL;;EAGX;AACF,CAAA;",
|
|
6
|
+
"names": ["React", "useCallback", "useDropzone", "findAnnotation", "useTranslation", "mx", "meta", "WnfsAction", "FileInput", "schema", "onChange", "t", "id", "accept", "ast", "UploadAnnotationId", "onDropAccepted", "files", "acceptedFiles", "getRootProps", "getInputProps", "isFocused", "isDragAccept", "isDragReject", "multiple", "div", "className", "input", "p", "name", "React", "composable", "composableProps", "FilePreview", "type", "url", "children", "props", "forwardedRef", "startsWith", "img", "classNames", "src", "ref", "video", "controls", "iframe"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/containers/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ComponentType, lazy } from 'react';\n\nexport const FileArticle: ComponentType<any> = lazy(() => import('./FileArticle'));\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAA6BA,YAAY;AAElC,IAAMC,cAAkCD,KAAK,MAAM,OAAO,6BAAA,CAAA;",
|
|
6
|
+
"names": ["lazy", "FileArticle"]
|
|
7
|
+
}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
File_exports
|
|
6
|
-
} from "./chunk-4D4K5JCC.mjs";
|
|
2
|
+
WnfsFile_exports,
|
|
3
|
+
WnfsOperation_exports
|
|
4
|
+
} from "./chunk-VWVCHTUK.mjs";
|
|
7
5
|
import "./chunk-J5LGTIGS.mjs";
|
|
8
6
|
|
|
9
7
|
// src/operations/create.ts
|
|
10
8
|
import * as Effect from "effect/Effect";
|
|
11
9
|
import { Operation } from "@dxos/compute";
|
|
12
|
-
var handler = Create.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ name, type, cid }) {
|
|
10
|
+
var handler = WnfsOperation_exports.Create.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ name, type, cid }) {
|
|
13
11
|
return {
|
|
14
|
-
object:
|
|
12
|
+
object: WnfsFile_exports.make({
|
|
15
13
|
name,
|
|
16
14
|
type,
|
|
17
15
|
cid
|
|
@@ -22,4 +20,4 @@ var create_default = handler;
|
|
|
22
20
|
export {
|
|
23
21
|
create_default as default
|
|
24
22
|
};
|
|
25
|
-
//# sourceMappingURL=create-
|
|
23
|
+
//# sourceMappingURL=create-4ERE5CA4.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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/compute';\n\nimport { WnfsFile, WnfsOperation } from '../types';\n\nconst handler: Operation.WithHandler<typeof WnfsOperation.Create> = WnfsOperation.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;AAI1B,IAAMC,UAA8DC,sBAAcC,OAAOC,KACvFC,UAAUC,YACDC,kBAAW,WAAW,EAAEC,MAAMC,MAAMC,IAAG,GAAE;AAC9C,SAAO;IACLC,QAAQC,iBAASC,KAAK;MAAEL;MAAMC;MAAMC;IAAI,CAAA;EAC1C;AACF,CAAA,CAAA,CAAA;AAIJ,IAAA,iBAAeT;",
|
|
6
|
+
"names": ["Effect", "Operation", "handler", "WnfsOperation", "Create", "pipe", "Operation", "withHandler", "fnUntraced", "name", "type", "cid", "object", "WnfsFile", "make"]
|
|
7
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WnfsCapabilities_exports,
|
|
3
|
+
WnfsFile_exports,
|
|
4
|
+
WnfsOperation_exports
|
|
5
|
+
} from "./chunk-VWVCHTUK.mjs";
|
|
1
6
|
import {
|
|
2
7
|
upload
|
|
3
8
|
} from "./chunk-7KFJ6LYH.mjs";
|
|
4
|
-
import {
|
|
5
|
-
CreateFile
|
|
6
|
-
} from "./chunk-DK62NQ5T.mjs";
|
|
7
|
-
import {
|
|
8
|
-
File_exports,
|
|
9
|
-
WnfsCapabilities
|
|
10
|
-
} from "./chunk-4D4K5JCC.mjs";
|
|
11
9
|
import "./chunk-J5LGTIGS.mjs";
|
|
12
10
|
|
|
13
11
|
// src/operations/create-file.ts
|
|
@@ -15,20 +13,20 @@ import * as Effect from "effect/Effect";
|
|
|
15
13
|
import { Capability } from "@dxos/app-framework";
|
|
16
14
|
import { Operation } from "@dxos/compute";
|
|
17
15
|
import { invariant } from "@dxos/invariant";
|
|
18
|
-
import { ClientCapabilities } from "@dxos/plugin-client
|
|
16
|
+
import { ClientCapabilities } from "@dxos/plugin-client";
|
|
19
17
|
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-wnfs/src/operations/create-file.ts";
|
|
20
|
-
var handler = CreateFile.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ file, db }) {
|
|
18
|
+
var handler = WnfsOperation_exports.CreateFile.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ file, db }) {
|
|
21
19
|
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
22
|
-
const blockstore = yield* Capability.get(
|
|
20
|
+
const blockstore = yield* Capability.get(WnfsCapabilities_exports.Blockstore);
|
|
23
21
|
const space = client.spaces.get(db.spaceId);
|
|
24
|
-
invariant(space, "Space not found", { "~LogMeta": "~LogMeta", F: __dxlog_file, L:
|
|
22
|
+
invariant(space, "Space not found", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 15, S: this, A: ["space", "'Space not found'"] });
|
|
25
23
|
const info = yield* Effect.promise(() => upload({
|
|
26
24
|
file,
|
|
27
25
|
blockstore,
|
|
28
26
|
space
|
|
29
27
|
}));
|
|
30
28
|
return {
|
|
31
|
-
object:
|
|
29
|
+
object: WnfsFile_exports.make({
|
|
32
30
|
name: info.name,
|
|
33
31
|
type: info.type,
|
|
34
32
|
cid: info.cid
|
|
@@ -39,4 +37,4 @@ var create_file_default = handler;
|
|
|
39
37
|
export {
|
|
40
38
|
create_file_default as default
|
|
41
39
|
};
|
|
42
|
-
//# sourceMappingURL=create-file-
|
|
40
|
+
//# sourceMappingURL=create-file-RAHDIJVU.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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 { Operation } from '@dxos/compute';\nimport { invariant } from '@dxos/invariant';\nimport { ClientCapabilities } from '@dxos/plugin-client';\n\nimport { upload } from '../helpers';\nimport { WnfsCapabilities, WnfsFile, WnfsOperation } from '../types';\n\nconst handler: Operation.WithHandler<typeof WnfsOperation.CreateFile> = WnfsOperation.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;AAKnC,IAAA,eAAwEC;IAIlE,UAAMC,sBAAoBC,WAAWC,KAAIC,UAAAA,YAA2B,kBAAA,WAAA,EAAA,MAAA,GAAA,GAAA;AACpE,QAAMC,SAAQC,OAAOC,WAAWC,IAAGC,mBAAO,MAAA;AAC1CC,QAAAA,aAAiB,OAAA,WAAA,IAAA,yBAAA,UAAA;AACjB,QAAMC,QAAO,OAAOC,OAAOC,IAAAA,GAAQ,OAAMC;YAASC,OAAAA,mBAAAA,EAAAA,YAAAA,YAAAA,GAAAA,cAAAA,GAAAA,IAAAA,GAAAA,MAAAA,GAAAA,CAAAA,SAAAA,mBAAAA,EAAAA,CAAAA;eAAMd,OAAAA,eAAAA,MAAAA,OAAAA;IAAYI;IAAM;IACnE;EACLW,CAAAA,CAAAA;;YAAyCC,iBAAWA,KAAI;MAAEC,MAAKP,KAAKO;MAAI,MAAA,KAAA;MAC1E,KAAA,KAAA;IACF,CAAA;EAIJ;;;",
|
|
6
|
+
"names": ["Effect", "Capability", "Operation", "invariant", "ClientCapabilities", "WnfsOperation", "blockstore", "Capability", "get", "WnfsCapabilities", "space", "client", "spaces", "db", "spaceId", "invariant", "info", "Effect", "promise", "upload", "file", "object", "type", "cid"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/capabilities/create-object.ts
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { Capability } from "@dxos/app-framework";
|
|
6
|
+
import { Operation } from "@dxos/compute";
|
|
7
|
+
import { SpaceOperation } from "@dxos/plugin-space";
|
|
8
|
+
import { SpaceCapabilities } from "@dxos/plugin-space";
|
|
9
|
+
import { WnfsOperation } from "#types";
|
|
10
|
+
import { WnfsAction, WnfsFile } from "#types";
|
|
11
|
+
var create_object_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
12
|
+
return Capability.contributes(SpaceCapabilities.CreateObjectEntry, {
|
|
13
|
+
id: WnfsFile.WnfsFile.typename,
|
|
14
|
+
inputSchema: WnfsAction.UploadFileSchema,
|
|
15
|
+
// TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
|
|
16
|
+
createObject: (props, options) => Effect.gen(function* () {
|
|
17
|
+
const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, {
|
|
18
|
+
...props,
|
|
19
|
+
db: options.db
|
|
20
|
+
});
|
|
21
|
+
return yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
22
|
+
object,
|
|
23
|
+
target: options.target,
|
|
24
|
+
hidden: true,
|
|
25
|
+
targetNodeId: options.targetNodeId
|
|
26
|
+
});
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}));
|
|
30
|
+
export {
|
|
31
|
+
create_object_default as default
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=create-object-7PJC47BB.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/create-object.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { Operation } from '@dxos/compute';\nimport { SpaceOperation } from '@dxos/plugin-space';\nimport { SpaceCapabilities } from '@dxos/plugin-space';\n\nimport { WnfsOperation } from '#types';\nimport { WnfsAction, WnfsFile } from '#types';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n return Capability.contributes(SpaceCapabilities.CreateObjectEntry, {\n id: WnfsFile.WnfsFile.typename,\n inputSchema: WnfsAction.UploadFileSchema,\n // TODO(wittjosiah): Would be nice if icon could change based on the type of the file.\n createObject: (props, options) =>\n Effect.gen(function* () {\n const { object } = yield* Operation.invoke(WnfsOperation.CreateFile, { ...props, db: options.db });\n return yield* Operation.invoke(SpaceOperation.AddObject, {\n object,\n target: options.target,\n hidden: true,\n targetNodeId: options.targetNodeId,\n });\n }),\n });\n }),\n);\n"],
|
|
5
|
+
"mappings": ";;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,iBAAiB;AAC1B,SAASC,sBAAsB;AAC/B,SAASC,yBAAyB;AAElC,SAASC,qBAAqB;AAC9B,SAASC,YAAYC,gBAAgB;AAErC,IAAA,wBAAeN,WAAWO,WACjBC,kBAAW,aAAA;AAChB,SAAOR,WAAWS,YAAYN,kBAAkBO,mBAAmB;IACjEC,IAAIL,SAASA,SAASM;IACtBC,aAAaR,WAAWS;;IAExBC,cAAc,CAACC,OAAOC,YACbC,WAAI,aAAA;AACT,YAAM,EAAEC,OAAM,IAAK,OAAOlB,UAAUmB,OAAOhB,cAAciB,YAAY;QAAE,GAAGL;QAAOM,IAAIL,QAAQK;MAAG,CAAA;AAChG,aAAO,OAAOrB,UAAUmB,OAAOlB,eAAeqB,WAAW;QACvDJ;QACAK,QAAQP,QAAQO;QAChBC,QAAQ;QACRC,cAAcT,QAAQS;MACxB,CAAA;IACF,CAAA;EACJ,CAAA;AACF,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "Capability", "Operation", "SpaceOperation", "SpaceCapabilities", "WnfsOperation", "WnfsAction", "WnfsFile", "makeModule", "fnUntraced", "contributes", "CreateObjectEntry", "id", "typename", "inputSchema", "UploadFileSchema", "createObject", "props", "options", "gen", "object", "invoke", "CreateFile", "db", "AddObject", "target", "hidden", "targetNodeId"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/capabilities/file-uploader.ts
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
6
|
+
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
7
|
+
import { runAndForwardErrors } from "@dxos/effect";
|
|
8
|
+
import { SpaceOperation } from "@dxos/plugin-space";
|
|
9
|
+
import { WnfsOperation } from "#types";
|
|
10
|
+
var file_uploader_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
11
|
+
const capabilities = yield* Capability.Service;
|
|
12
|
+
return Capability.contributes(AppCapabilities.FileUploader, (db, file) => {
|
|
13
|
+
const { invoke } = capabilities.get(Capabilities.OperationInvoker);
|
|
14
|
+
const program = Effect.gen(function* () {
|
|
15
|
+
const fileInfo = yield* invoke(WnfsOperation.Upload, {
|
|
16
|
+
db,
|
|
17
|
+
file
|
|
18
|
+
});
|
|
19
|
+
const createResult = yield* invoke(WnfsOperation.Create, fileInfo);
|
|
20
|
+
if (createResult?.object) {
|
|
21
|
+
yield* invoke(SpaceOperation.AddObject, {
|
|
22
|
+
target: db,
|
|
23
|
+
object: createResult.object
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return fileInfo;
|
|
27
|
+
});
|
|
28
|
+
return runAndForwardErrors(program);
|
|
29
|
+
});
|
|
30
|
+
}));
|
|
31
|
+
export {
|
|
32
|
+
file_uploader_default as default
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=file-uploader-WOF3H3FN.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/file-uploader.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { AppCapabilities } from '@dxos/app-toolkit';\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { SpaceOperation } from '@dxos/plugin-space';\n\nimport { WnfsOperation } from '#types';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n // Get context for lazy capability access in callbacks.\n const capabilities = yield* Capability.Service;\n\n return Capability.contributes(AppCapabilities.FileUploader, (db, file) => {\n const { invoke } = capabilities.get(Capabilities.OperationInvoker);\n const program = Effect.gen(function* () {\n const fileInfo = yield* invoke(WnfsOperation.Upload, { db, file });\n const createResult = yield* invoke(WnfsOperation.Create, fileInfo);\n if (createResult?.object) {\n yield* invoke(SpaceOperation.AddObject, { target: db, object: createResult.object });\n }\n\n return fileInfo;\n });\n\n return runAndForwardErrors(program);\n });\n }),\n);\n"],
|
|
5
|
+
"mappings": ";;;AAIA,YAAYA,YAAY;AAExB,SAASC,cAAcC,kBAAkB;AACzC,SAASC,uBAAuB;AAChC,SAASC,2BAA2B;AACpC,SAASC,sBAAsB;AAE/B,SAASC,qBAAqB;AAE9B,IAAA,wBAAeJ,WAAWK,WACjBC,kBAAW,aAAA;AAEhB,QAAMC,eAAe,OAAOP,WAAWQ;AAEvC,SAAOR,WAAWS,YAAYR,gBAAgBS,cAAc,CAACC,IAAIC,SAAAA;AAC/D,UAAM,EAAEC,OAAM,IAAKN,aAAaO,IAAIf,aAAagB,gBAAgB;AACjE,UAAMC,UAAiBC,WAAI,aAAA;AACzB,YAAMC,WAAW,OAAOL,OAAOT,cAAce,QAAQ;QAAER;QAAIC;MAAK,CAAA;AAChE,YAAMQ,eAAe,OAAOP,OAAOT,cAAciB,QAAQH,QAAAA;AACzD,UAAIE,cAAcE,QAAQ;AACxB,eAAOT,OAAOV,eAAeoB,WAAW;UAAEC,QAAQb;UAAIW,QAAQF,aAAaE;QAAO,CAAA;MACpF;AAEA,aAAOJ;IACT,CAAA;AAEA,WAAOhB,oBAAoBc,OAAAA;EAC7B,CAAA;AACF,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "Capabilities", "Capability", "AppCapabilities", "runAndForwardErrors", "SpaceOperation", "WnfsOperation", "makeModule", "fnUntraced", "capabilities", "Service", "contributes", "FileUploader", "db", "file", "invoke", "get", "OperationInvoker", "program", "gen", "fileInfo", "Upload", "createResult", "Create", "object", "AddObject", "target"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
meta
|
|
3
|
+
} from "./chunk-LHUHUCBD.mjs";
|
|
4
|
+
import {
|
|
5
|
+
WnfsAction,
|
|
6
|
+
WnfsCapabilities_exports,
|
|
7
|
+
WnfsFile_exports,
|
|
8
|
+
WnfsOperation_exports
|
|
9
|
+
} from "./chunk-VWVCHTUK.mjs";
|
|
10
|
+
import {
|
|
11
|
+
Rng,
|
|
12
|
+
filePath,
|
|
13
|
+
getBlobUrl,
|
|
14
|
+
getPathFromUrl,
|
|
15
|
+
loadWnfs,
|
|
16
|
+
readFile,
|
|
17
|
+
store,
|
|
18
|
+
storeName,
|
|
19
|
+
upload,
|
|
20
|
+
wnfsUrl
|
|
21
|
+
} from "./chunk-7KFJ6LYH.mjs";
|
|
22
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
23
|
+
export {
|
|
24
|
+
Rng,
|
|
25
|
+
WnfsAction,
|
|
26
|
+
WnfsCapabilities_exports as WnfsCapabilities,
|
|
27
|
+
WnfsFile_exports as WnfsFile,
|
|
28
|
+
WnfsOperation_exports as WnfsOperation,
|
|
29
|
+
filePath,
|
|
30
|
+
getBlobUrl,
|
|
31
|
+
getPathFromUrl,
|
|
32
|
+
loadWnfs,
|
|
33
|
+
meta,
|
|
34
|
+
readFile,
|
|
35
|
+
store,
|
|
36
|
+
storeName,
|
|
37
|
+
upload,
|
|
38
|
+
wnfsUrl
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=index.mjs.map
|