@dxos/plugin-wnfs 0.8.4-main.72ec0f3 → 0.8.4-main.765dc60934
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 +2 -2
- 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/{browser/blockstore-2JFU4NBU.mjs → neutral/blockstore-3NLSWC7Z.mjs} +12 -13
- 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/chunk-D6VTEQIE.mjs → neutral/chunk-7KFJ6LYH.mjs} +43 -18
- package/dist/lib/neutral/chunk-7KFJ6LYH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/{browser/chunk-OGPGLJCV.mjs → neutral/chunk-LHUHUCBD.mjs} +2 -9
- 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/neutral/create-4ERE5CA4.mjs +23 -0
- package/dist/lib/neutral/create-4ERE5CA4.mjs.map +7 -0
- package/dist/lib/neutral/create-file-RAHDIJVU.mjs +40 -0
- 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/helpers/index.mjs +26 -0
- package/dist/lib/neutral/helpers/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +40 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{browser/markdown-WYQDCVFQ.mjs → neutral/markdown-I4FYAUCA.mjs} +23 -17
- 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/neutral/translations.mjs +30 -0
- 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/neutral/upload-VA5CSUEP.mjs +33 -0
- package/dist/lib/neutral/upload-VA5CSUEP.mjs.map +7 -0
- package/dist/types/src/WnfsPlugin.d.ts +3 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/WnfsPlugin.node.d.ts +4 -0
- package/dist/types/src/WnfsPlugin.node.d.ts.map +1 -0
- package/dist/types/src/WnfsPlugin.test.d.ts +2 -0
- package/dist/types/src/WnfsPlugin.test.d.ts.map +1 -0
- package/dist/types/src/blockstore.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore.d.ts +3 -2
- package/dist/types/src/capabilities/blockstore.d.ts.map +1 -1
- 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/file-uploader.d.ts +4 -2
- package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +13 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +4 -2
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
- package/dist/types/src/components/FileInput/index.d.ts +2 -0
- package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts +12 -0
- package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
- package/dist/types/src/components/FilePreview/index.d.ts +2 -0
- package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/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 +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/image.d.ts +1 -1
- package/dist/types/src/extensions/image.d.ts.map +1 -1
- package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
- package/dist/types/src/helpers/common.d.ts.map +1 -1
- package/dist/types/src/helpers/load.d.ts +1 -1
- package/dist/types/src/helpers/load.d.ts.map +1 -1
- package/dist/types/src/helpers/upload.d.ts +1 -1
- package/dist/types/src/helpers/upload.d.ts.map +1 -1
- package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-file.d.ts +5 -0
- package/dist/types/src/operations/create-file.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/upload.d.ts +5 -0
- package/dist/types/src/operations/upload.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +24 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- 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/WnfsFile.d.ts +16 -0
- package/dist/types/src/types/WnfsFile.d.ts.map +1 -0
- package/dist/types/src/types/WnfsOperation.d.ts +38 -0
- package/dist/types/src/types/WnfsOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +4 -50
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +104 -49
- package/src/WnfsPlugin.node.ts +19 -0
- package/src/WnfsPlugin.test.ts +27 -0
- package/src/WnfsPlugin.tsx +28 -73
- package/src/blockstore.ts +1 -1
- package/src/capabilities/blockstore.ts +14 -10
- package/src/capabilities/create-object.ts +33 -0
- package/src/capabilities/file-uploader.ts +24 -17
- package/src/capabilities/index.ts +11 -8
- package/src/capabilities/markdown.ts +24 -12
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +49 -34
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +6 -6
- package/src/components/FileInput/index.ts +5 -0
- package/src/components/FilePreview/FilePreview.tsx +43 -0
- package/src/components/FilePreview/index.ts +5 -0
- package/src/components/index.ts +1 -4
- package/src/{components/FileContainer.tsx → containers/FileArticle/FileArticle.tsx} +14 -16
- package/src/containers/FileArticle/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +10 -11
- package/src/extensions/image.tsx +4 -3
- package/src/helpers/load.ts +12 -7
- package/src/helpers/upload.ts +5 -2
- package/src/index.ts +2 -2
- package/src/meta.ts +3 -3
- package/src/operations/create-file.ts +30 -0
- package/src/operations/create.ts +21 -0
- package/src/operations/index.ts +11 -0
- package/src/operations/upload.ts +28 -0
- package/src/plugin.ts +11 -0
- package/src/translations.ts +14 -10
- package/src/types/WnfsCapabilities.ts +18 -0
- package/src/types/WnfsFile.ts +30 -0
- package/src/types/WnfsOperation.ts +44 -0
- package/src/types/index.ts +4 -1
- package/src/types/types.ts +3 -20
- package/dist/lib/browser/FileContainer-LLNI7WXR.mjs +0 -103
- package/dist/lib/browser/FileContainer-LLNI7WXR.mjs.map +0 -7
- package/dist/lib/browser/blockstore-2JFU4NBU.mjs.map +0 -7
- package/dist/lib/browser/chunk-CWMKN2F6.mjs +0 -71
- package/dist/lib/browser/chunk-CWMKN2F6.mjs.map +0 -7
- package/dist/lib/browser/chunk-D6VTEQIE.mjs.map +0 -7
- package/dist/lib/browser/chunk-F4QHZWQD.mjs +0 -16
- package/dist/lib/browser/chunk-F4QHZWQD.mjs.map +0 -7
- package/dist/lib/browser/chunk-OGPGLJCV.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZFPJA5F4.mjs +0 -16
- package/dist/lib/browser/chunk-ZFPJA5F4.mjs.map +0 -7
- package/dist/lib/browser/file-uploader-W6TJLAAK.mjs +0 -30
- package/dist/lib/browser/file-uploader-W6TJLAAK.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -116
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-FSW2EQF4.mjs +0 -48
- package/dist/lib/browser/intent-resolver-FSW2EQF4.mjs.map +0 -7
- package/dist/lib/browser/markdown-WYQDCVFQ.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-DMU47U3X.mjs +0 -88
- package/dist/lib/browser/react-surface-DMU47U3X.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -10
- package/dist/types/src/capabilities/capabilities.d.ts +0 -12
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/FileContainer.d.ts +0 -9
- package/dist/types/src/components/FileContainer.d.ts.map +0 -1
- package/dist/types/src/components/FileInput.d.ts.map +0 -1
- package/dist/types/src/components/FilePreview.d.ts +0 -11
- package/dist/types/src/components/FilePreview.d.ts.map +0 -1
- package/dist/types/src/types/File.d.ts +0 -16
- package/dist/types/src/types/File.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -18
- package/src/capabilities/intent-resolver.ts +0 -32
- package/src/components/FilePreview.tsx +0 -23
- package/src/types/File.ts +0 -24
- /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +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;;;;;A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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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WnfsFile_exports,
|
|
3
|
+
WnfsOperation_exports
|
|
4
|
+
} from "./chunk-VWVCHTUK.mjs";
|
|
5
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
6
|
+
|
|
7
|
+
// src/operations/create.ts
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { Operation } from "@dxos/compute";
|
|
10
|
+
var handler = WnfsOperation_exports.Create.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ name, type, cid }) {
|
|
11
|
+
return {
|
|
12
|
+
object: WnfsFile_exports.make({
|
|
13
|
+
name,
|
|
14
|
+
type,
|
|
15
|
+
cid
|
|
16
|
+
})
|
|
17
|
+
};
|
|
18
|
+
})));
|
|
19
|
+
var create_default = handler;
|
|
20
|
+
export {
|
|
21
|
+
create_default as default
|
|
22
|
+
};
|
|
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
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WnfsCapabilities_exports,
|
|
3
|
+
WnfsFile_exports,
|
|
4
|
+
WnfsOperation_exports
|
|
5
|
+
} from "./chunk-VWVCHTUK.mjs";
|
|
6
|
+
import {
|
|
7
|
+
upload
|
|
8
|
+
} from "./chunk-7KFJ6LYH.mjs";
|
|
9
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
10
|
+
|
|
11
|
+
// src/operations/create-file.ts
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import { Capability } from "@dxos/app-framework";
|
|
14
|
+
import { Operation } from "@dxos/compute";
|
|
15
|
+
import { invariant } from "@dxos/invariant";
|
|
16
|
+
import { ClientCapabilities } from "@dxos/plugin-client";
|
|
17
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-wnfs/src/operations/create-file.ts";
|
|
18
|
+
var handler = WnfsOperation_exports.CreateFile.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ file, db }) {
|
|
19
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
20
|
+
const blockstore = yield* Capability.get(WnfsCapabilities_exports.Blockstore);
|
|
21
|
+
const space = client.spaces.get(db.spaceId);
|
|
22
|
+
invariant(space, "Space not found", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 15, S: this, A: ["space", "'Space not found'"] });
|
|
23
|
+
const info = yield* Effect.promise(() => upload({
|
|
24
|
+
file,
|
|
25
|
+
blockstore,
|
|
26
|
+
space
|
|
27
|
+
}));
|
|
28
|
+
return {
|
|
29
|
+
object: WnfsFile_exports.make({
|
|
30
|
+
name: info.name,
|
|
31
|
+
type: info.type,
|
|
32
|
+
cid: info.cid
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
})));
|
|
36
|
+
var create_file_default = handler;
|
|
37
|
+
export {
|
|
38
|
+
create_file_default as default
|
|
39
|
+
};
|
|
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,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Rng,
|
|
3
|
+
filePath,
|
|
4
|
+
getBlobUrl,
|
|
5
|
+
getPathFromUrl,
|
|
6
|
+
loadWnfs,
|
|
7
|
+
readFile,
|
|
8
|
+
store,
|
|
9
|
+
storeName,
|
|
10
|
+
upload,
|
|
11
|
+
wnfsUrl
|
|
12
|
+
} from "../chunk-7KFJ6LYH.mjs";
|
|
13
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
14
|
+
export {
|
|
15
|
+
Rng,
|
|
16
|
+
filePath,
|
|
17
|
+
getBlobUrl,
|
|
18
|
+
getPathFromUrl,
|
|
19
|
+
loadWnfs,
|
|
20
|
+
readFile,
|
|
21
|
+
store,
|
|
22
|
+
storeName,
|
|
23
|
+
upload,
|
|
24
|
+
wnfsUrl
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WnfsAction,
|
|
3
|
+
WnfsCapabilities_exports,
|
|
4
|
+
WnfsFile_exports,
|
|
5
|
+
WnfsOperation_exports
|
|
6
|
+
} from "./chunk-VWVCHTUK.mjs";
|
|
7
|
+
import {
|
|
8
|
+
Rng,
|
|
9
|
+
filePath,
|
|
10
|
+
getBlobUrl,
|
|
11
|
+
getPathFromUrl,
|
|
12
|
+
loadWnfs,
|
|
13
|
+
readFile,
|
|
14
|
+
store,
|
|
15
|
+
storeName,
|
|
16
|
+
upload,
|
|
17
|
+
wnfsUrl
|
|
18
|
+
} from "./chunk-7KFJ6LYH.mjs";
|
|
19
|
+
import {
|
|
20
|
+
meta
|
|
21
|
+
} from "./chunk-LHUHUCBD.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
|
|
@@ -2,16 +2,15 @@ import {
|
|
|
2
2
|
getBlobUrl,
|
|
3
3
|
getPathFromUrl,
|
|
4
4
|
loadWnfs
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import
|
|
7
|
-
WnfsCapabilities
|
|
8
|
-
} from "./chunk-F4QHZWQD.mjs";
|
|
9
|
-
import "./chunk-OGPGLJCV.mjs";
|
|
5
|
+
} from "./chunk-7KFJ6LYH.mjs";
|
|
6
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
10
7
|
|
|
11
8
|
// src/capabilities/markdown.ts
|
|
12
|
-
import
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import { Capability } from "@dxos/app-framework";
|
|
13
11
|
import { MarkdownCapabilities } from "@dxos/plugin-markdown";
|
|
14
12
|
import { getSpace } from "@dxos/react-client/echo";
|
|
13
|
+
import { WnfsCapabilities } from "#types";
|
|
15
14
|
|
|
16
15
|
// src/extensions/image.tsx
|
|
17
16
|
import { syntaxTree } from "@codemirror/language";
|
|
@@ -20,8 +19,8 @@ import { Decoration, EditorView, WidgetType } from "@codemirror/view";
|
|
|
20
19
|
import React from "react";
|
|
21
20
|
import { createRoot } from "react-dom/client";
|
|
22
21
|
import { Status, ThemeProvider } from "@dxos/react-ui";
|
|
23
|
-
import { focusField } from "@dxos/
|
|
24
|
-
import { defaultTx } from "@dxos/
|
|
22
|
+
import { focusField } from "@dxos/ui-editor";
|
|
23
|
+
import { defaultTx } from "@dxos/ui-theme";
|
|
25
24
|
var WAIT_UNTIL_LOADER = 1500;
|
|
26
25
|
var image = (options) => {
|
|
27
26
|
const blobUrlCache = {};
|
|
@@ -175,10 +174,14 @@ var WnfsImageWidget = class extends WidgetType {
|
|
|
175
174
|
};
|
|
176
175
|
|
|
177
176
|
// src/capabilities/markdown.ts
|
|
178
|
-
var markdown_default = ((
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
var markdown_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
178
|
+
const capabilities = yield* Capability.Service;
|
|
179
|
+
const provider = ({ document: document2, viewMode }) => {
|
|
180
|
+
if (viewMode === "source") {
|
|
181
|
+
return void 0;
|
|
182
|
+
}
|
|
183
|
+
const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
|
|
184
|
+
const instances = capabilities.get(WnfsCapabilities.Instances);
|
|
182
185
|
if (document2) {
|
|
183
186
|
const space = getSpace(document2);
|
|
184
187
|
return space ? [
|
|
@@ -187,12 +190,15 @@ var markdown_default = ((context) => contributes(MarkdownCapabilities.Extensions
|
|
|
187
190
|
instances,
|
|
188
191
|
space
|
|
189
192
|
})
|
|
190
|
-
] :
|
|
193
|
+
] : void 0;
|
|
191
194
|
}
|
|
192
|
-
return
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
+
return void 0;
|
|
196
|
+
};
|
|
197
|
+
return Capability.contributes(MarkdownCapabilities.Extensions, [
|
|
198
|
+
provider
|
|
199
|
+
]);
|
|
200
|
+
}));
|
|
195
201
|
export {
|
|
196
202
|
markdown_default as default
|
|
197
203
|
};
|
|
198
|
-
//# sourceMappingURL=markdown-
|
|
204
|
+
//# sourceMappingURL=markdown-I4FYAUCA.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/markdown.ts", "../../../src/extensions/image.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { type MarkdownExtensionProvider, MarkdownCapabilities } from '@dxos/plugin-markdown';\nimport { getSpace } from '@dxos/react-client/echo';\n\nimport { WnfsCapabilities } from '#types';\n\nimport { image } from '../extensions';\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 const provider: MarkdownExtensionProvider = ({ document, viewMode }) => {\n if (viewMode === 'source') {\n return undefined;\n }\n\n const blockstore = capabilities.get(WnfsCapabilities.Blockstore);\n const instances = capabilities.get(WnfsCapabilities.Instances);\n\n if (document) {\n const space = getSpace(document);\n return space ? [image({ blockstore, instances, space })] : undefined;\n }\n\n return undefined;\n };\n\n return Capability.contributes(MarkdownCapabilities.Extensions, [provider]);\n }),\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { syntaxTree } from '@codemirror/language';\nimport { type EditorState, type Extension, type Range, StateField } from '@codemirror/state';\nimport { Decoration, EditorView, WidgetType } from '@codemirror/view';\nimport type { Blockstore } from 'interface-blockstore';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { type Space } from '@dxos/react-client/echo';\nimport { Status, ThemeProvider } from '@dxos/react-ui';\nimport { focusField } from '@dxos/ui-editor';\nimport { defaultTx } from '@dxos/ui-theme';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { type WnfsCapabilities } from '#types';\n\nimport { getBlobUrl, getPathFromUrl, loadWnfs } from '../helpers';\n\nconst WAIT_UNTIL_LOADER = 1500;\n\nexport type ImageOptions = {\n blockstore: Blockstore;\n instances: WnfsCapabilities.Instances;\n space: Space;\n};\n\n/**\n * Create WNFS image decorations.\n */\nexport const image = (options: ImageOptions): Extension[] => {\n const blobUrlCache: Record<string, string> = {};\n const preloaded = new Set<string>();\n\n const preload = (url: string) => {\n if (!preloaded.has(url)) {\n const img = document.createElement('img');\n img.src = url;\n preloaded.add(url);\n }\n };\n\n return [\n StateField.define({\n create: (state) => {\n return Decoration.set(\n buildDecorations({ from: 0, to: state.doc.length, state, blobUrlCache, preload, options }),\n );\n },\n update: (value, tr) => {\n if (!tr.docChanged && !tr.selection) {\n return value;\n }\n\n // Find range of changes and cursor changes.\n const cursor = tr.state.selection.main.head;\n const oldCursor = tr.changes.mapPos(tr.startState.selection.main.head);\n let from = Math.min(cursor, oldCursor);\n let to = Math.max(cursor, oldCursor);\n tr.changes.iterChangedRanges((fromA, toA, fromB, toB) => {\n from = Math.min(from, fromB);\n to = Math.max(to, toB);\n });\n\n // Expand to cover lines.\n from = tr.state.doc.lineAt(from).from;\n to = tr.state.doc.lineAt(to).to;\n\n return value.map(tr.changes).update({\n filterFrom: from,\n filterTo: to,\n filter: () => false,\n add: buildDecorations({ from, to, state: tr.state, blobUrlCache, preload, options }),\n });\n },\n provide: (field) => EditorView.decorations.from(field),\n }),\n ];\n};\n\nconst buildDecorations = ({\n state,\n from,\n to,\n blobUrlCache,\n preload,\n options: { blockstore, instances, space },\n}: {\n state: EditorState;\n from: number;\n to: number;\n blobUrlCache: Record<string, string>;\n preload: (url: string) => void;\n options: ImageOptions;\n}) => {\n const decorations: Range<Decoration>[] = [];\n const cursor = state.selection.main.head;\n syntaxTree(state).iterate({\n enter: (node) => {\n if (node.name !== 'Image') {\n return;\n }\n\n const urlNode = node.node.getChild('URL');\n if (!urlNode) {\n return;\n }\n\n const hide = state.readOnly || cursor < node.from || cursor > node.to;\n const wnfsUrl = state.sliceDoc(urlNode.from, urlNode.to);\n if (!wnfsUrl.startsWith('wnfs://')) {\n return;\n }\n\n const path = getPathFromUrl(wnfsUrl);\n\n // Cannot load images from other spaces\n const spaceId = path[1];\n if (spaceId !== space.id) {\n return;\n }\n\n // Load image contents into memory blob\n const blobUrlPromise = (async () => {\n const { directory, forest } = await loadWnfs({ blockstore, instances, space });\n const url = await getBlobUrl({ wnfsUrl, blockstore, directory, forest });\n blobUrlCache[path.join('/')] = url;\n preload(url);\n return url;\n })();\n\n decorations.push(\n Decoration.replace({\n block: true, // Prevent cursor from entering.\n widget: new WnfsImageWidget(wnfsUrl, blobUrlCache[path.join('/')] ?? blobUrlPromise),\n }).range(hide ? node.from : node.to, node.to),\n );\n },\n from,\n to,\n });\n\n return decorations;\n};\n\nconst createImg = (view: EditorView, url: string) => {\n const img = document.createElement('img');\n img.setAttribute('src', url);\n img.setAttribute('class', 'cm-image-with-loader');\n // If focused, hide image until successfully loaded to avoid flickering effects.\n if (view.state.field(focusField)) {\n img.onload = () => img.classList.add('cm-loaded-image');\n } else {\n img.classList.add('cm-loaded-image');\n }\n return img;\n};\n\nclass WnfsImageWidget extends WidgetType {\n constructor(\n readonly _wnfsUrl: string,\n readonly _url: MaybePromise<string>,\n ) {\n super();\n }\n\n override eq(other: this) {\n return this._wnfsUrl === other._wnfsUrl;\n }\n\n override toDOM(view: EditorView) {\n if (typeof this._url === 'string') {\n return createImg(view, this._url);\n }\n\n const widget = document.createElement('div');\n widget.className = 'cm-image-wrapper';\n const loader = document.createElement('div');\n loader.className = 'mx-auto transition-opacity';\n let loaderAdded = false;\n\n const timeout = setTimeout(() => {\n const root = createRoot(loader);\n root.render(\n <ThemeProvider tx={defaultTx}>\n <Status indeterminate />\n </ThemeProvider>,\n );\n widget.appendChild(loader);\n loaderAdded = true;\n }, WAIT_UNTIL_LOADER);\n\n void this._url.then((url) => {\n clearTimeout(timeout);\n const img = createImg(view, url);\n loaderAdded && widget.removeChild(loader);\n widget.appendChild(img);\n });\n\n return widget;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAAyCC,4BAA4B;AACrE,SAASC,gBAAgB;AAEzB,SAASC,wBAAwB;;;ACNjC,SAASC,kBAAkB;AAC3B,SAAuDC,kBAAkB;AACzE,SAASC,YAAYC,YAAYC,kBAAkB;AAEnD,OAAOC,WAAW;AAClB,SAASC,kBAAkB;AAG3B,SAASC,QAAQC,qBAAqB;AACtC,SAASC,kBAAkB;AAC3B,SAASC,iBAAiB;AAO1B,IAAMC,oBAAoB;AAWnB,IAAMC,QAAQ,CAACC,YAAAA;AACpB,QAAMC,eAAuC,CAAC;AAC9C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AA;AAC5B4F,qBAAejB,OAAO+B,YAAYf,MAAAA;AAClChB,aAAO4B,YAAYrG,GAAAA;IACrB,CAAA;AAEA,WAAOyE;EACT;AACF;;;AD7LA,IAAA,mBAAegC,WAAWC,WACjBC,kBAAW,aAAA;AAEhB,QAAMC,eAAe,OAAOH,WAAWI;AAEvC,QAAMC,WAAsC,CAAC,EAAEC,UAAAA,WAAUC,SAAQ,MAAE;AACjE,QAAIA,aAAa,UAAU;AACzB,aAAOC;IACT;AAEA,UAAMC,aAAaN,aAAaO,IAAIC,iBAAiBC,UAAU;AAC/D,UAAMC,YAAYV,aAAaO,IAAIC,iBAAiBG,SAAS;AAE7D,QAAIR,WAAU;AACZ,YAAMS,QAAQC,SAASV,SAAAA;AACvB,aAAOS,QAAQ;QAACE,MAAM;UAAER;UAAYI;UAAWE;QAAM,CAAA;UAAMP;IAC7D;AAEA,WAAOA;EACT;AAEA,SAAOR,WAAWkB,YAAYC,qBAAqBC,YAAY;IAACf;GAAS;AAC3E,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "Capability", "MarkdownCapabilities", "getSpace", "WnfsCapabilities", "syntaxTree", "StateField", "Decoration", "EditorView", "WidgetType", "React", "createRoot", "Status", "ThemeProvider", "focusField", "defaultTx", "WAIT_UNTIL_LOADER", "image", "options", "blobUrlCache", "preloaded", "Set", "preload", "url", "has", "img", "document", "createElement", "src", "add", "StateField", "define", "create", "state", "Decoration", "set", "buildDecorations", "from", "to", "doc", "length", "update", "value", "tr", "docChanged", "selection", "cursor", "main", "head", "oldCursor", "changes", "mapPos", "startState", "Math", "min", "max", "iterChangedRanges", "fromA", "toA", "fromB", "toB", "lineAt", "map", "filterFrom", "filterTo", "filter", "provide", "field", "EditorView", "decorations", "blockstore", "instances", "space", "syntaxTree", "iterate", "enter", "node", "name", "urlNode", "getChild", "hide", "readOnly", "wnfsUrl", "sliceDoc", "startsWith", "path", "getPathFromUrl", "spaceId", "id", "blobUrlPromise", "directory", "forest", "loadWnfs", "getBlobUrl", "join", "push", "replace", "block", "widget", "WnfsImageWidget", "range", "createImg", "view", "setAttribute", "focusField", "onload", "classList", "WidgetType", "_wnfsUrl", "_url", "eq", "other", "toDOM", "className", "loader", "loaderAdded", "timeout", "setTimeout", "root", "createRoot", "render", "ThemeProvider", "tx", "defaultTx", "Status", "indeterminate", "appendChild", "then", "clearTimeout", "removeChild", "Capability", "makeModule", "fnUntraced", "capabilities", "Service", "provider", "document", "viewMode", "undefined", "blockstore", "get", "WnfsCapabilities", "Blockstore", "instances", "Instances", "space", "getSpace", "image", "contributes", "MarkdownCapabilities", "Extensions"]
|
|
7
|
+
}
|