@dxos/plugin-wnfs 0.8.4-main.72ec0f3 → 0.8.4-main.7996785055
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/FileContainer-TFENLFD5.mjs +72 -0
- package/dist/lib/browser/FileContainer-TFENLFD5.mjs.map +7 -0
- package/dist/lib/browser/{blockstore-2JFU4NBU.mjs → blockstore-TUV5YIC5.mjs} +13 -13
- package/dist/lib/browser/blockstore-TUV5YIC5.mjs.map +7 -0
- package/dist/lib/browser/chunk-3I3QQNA3.mjs +84 -0
- package/dist/lib/browser/chunk-3I3QQNA3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D6VTEQIE.mjs → chunk-A7ETWNGC.mjs} +23 -13
- package/dist/lib/browser/chunk-A7ETWNGC.mjs.map +7 -0
- package/dist/lib/browser/chunk-CXWUR7YI.mjs +8 -0
- package/dist/lib/browser/chunk-CXWUR7YI.mjs.map +7 -0
- package/dist/lib/browser/chunk-HXGK35WW.mjs +65 -0
- package/dist/lib/browser/chunk-HXGK35WW.mjs.map +7 -0
- package/dist/lib/browser/chunk-QE7ZSOYG.mjs +69 -0
- package/dist/lib/browser/chunk-QE7ZSOYG.mjs.map +7 -0
- package/dist/lib/browser/create-WQ6CUUDN.mjs +24 -0
- package/dist/lib/browser/create-WQ6CUUDN.mjs.map +7 -0
- package/dist/lib/browser/create-file-NGKX6CFL.mjs +49 -0
- package/dist/lib/browser/create-file-NGKX6CFL.mjs.map +7 -0
- package/dist/lib/browser/file-uploader-THECEDM2.mjs +37 -0
- package/dist/lib/browser/file-uploader-THECEDM2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +89 -81
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{markdown-WYQDCVFQ.mjs → markdown-IEDBXCLX.mjs} +28 -25
- package/dist/lib/browser/markdown-IEDBXCLX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-handler-YAYDKG7R.mjs +16 -0
- package/dist/lib/browser/operation-handler-YAYDKG7R.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +12 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/react-surface-UGRUPU56.mjs +60 -0
- package/dist/lib/browser/react-surface-UGRUPU56.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -3
- package/dist/lib/browser/upload-42ZL2AE4.mjs +42 -0
- package/dist/lib/browser/upload-42ZL2AE4.mjs.map +7 -0
- package/dist/types/src/WnfsPlugin.d.ts +2 -1
- package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts +5 -0
- package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +1 -0
- package/dist/types/src/capabilities/blockstore/index.d.ts +3 -0
- package/dist/types/src/capabilities/blockstore/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +6 -0
- package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +1 -0
- package/dist/types/src/capabilities/file-uploader/index.d.ts +3 -0
- package/dist/types/src/capabilities/file-uploader/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
- package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler/index.d.ts +4 -0
- package/dist/types/src/capabilities/operation-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- 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 +16 -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/FileContainer/FileContainer.d.ts +7 -0
- package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FileContainer/index.d.ts +3 -0
- package/dist/types/src/containers/FileContainer/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/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/index.d.ts +1 -1
- 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/definitions.d.ts +38 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -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/translations.d.ts +5 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/File.d.ts +11 -11
- package/dist/types/src/types/File.d.ts.map +1 -1
- package/dist/types/src/{capabilities → types}/capabilities.d.ts +3 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- 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 +51 -36
- package/src/WnfsPlugin.tsx +50 -71
- package/src/blockstore.ts +1 -1
- package/src/capabilities/blockstore/blockstore.ts +22 -0
- package/src/capabilities/blockstore/index.ts +7 -0
- package/src/capabilities/file-uploader/file-uploader.ts +34 -0
- package/src/capabilities/file-uploader/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/markdown/index.ts +7 -0
- package/src/capabilities/markdown/markdown.ts +33 -0
- package/src/capabilities/operation-handler/index.ts +11 -0
- package/src/capabilities/operation-handler/operation-handler.ts +16 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +51 -0
- package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +5 -5
- 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 → containers/FileContainer}/FileContainer.tsx +13 -16
- package/src/containers/FileContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/extensions/image.stories.tsx +5 -5
- package/src/extensions/image.tsx +3 -3
- package/src/helpers/load.ts +12 -7
- package/src/helpers/upload.ts +5 -2
- package/src/index.ts +1 -1
- package/src/meta.ts +3 -3
- package/src/operations/create-file.ts +32 -0
- package/src/operations/create.ts +23 -0
- package/src/operations/definitions.ts +40 -0
- package/src/operations/index.ts +13 -0
- package/src/operations/upload.ts +30 -0
- package/src/translations.ts +5 -1
- package/src/types/File.ts +11 -7
- package/src/{capabilities → types}/capabilities.ts +3 -3
- package/src/types/index.ts +1 -0
- package/src/types/types.ts +2 -19
- 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 +0 -25
- 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/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/react-surface-DMU47U3X.mjs +0 -88
- package/dist/lib/browser/react-surface-DMU47U3X.mjs.map +0 -7
- package/dist/types/src/capabilities/blockstore.d.ts +0 -4
- package/dist/types/src/capabilities/blockstore.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/file-uploader.d.ts +0 -4
- package/dist/types/src/capabilities/file-uploader.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/capabilities/markdown.d.ts +0 -4
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.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/src/capabilities/blockstore.ts +0 -19
- package/src/capabilities/file-uploader.ts +0 -27
- package/src/capabilities/intent-resolver.ts +0 -32
- package/src/capabilities/markdown.ts +0 -26
- package/src/capabilities/react-surface.tsx +0 -45
- package/src/components/FilePreview.tsx +0 -23
- /package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
upload
|
|
3
|
+
} from "./chunk-A7ETWNGC.mjs";
|
|
4
|
+
import {
|
|
5
|
+
CreateFile
|
|
6
|
+
} from "./chunk-QE7ZSOYG.mjs";
|
|
7
|
+
import {
|
|
8
|
+
File_exports,
|
|
9
|
+
WnfsCapabilities
|
|
10
|
+
} from "./chunk-3I3QQNA3.mjs";
|
|
11
|
+
|
|
12
|
+
// src/operations/create-file.ts
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
import { Capability } from "@dxos/app-framework";
|
|
15
|
+
import { invariant } from "@dxos/invariant";
|
|
16
|
+
import { Operation } from "@dxos/operation";
|
|
17
|
+
import { ClientCapabilities } from "@dxos/plugin-client";
|
|
18
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-wnfs/src/operations/create-file.ts";
|
|
19
|
+
var handler = CreateFile.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ file, db }) {
|
|
20
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
21
|
+
const blockstore = yield* Capability.get(WnfsCapabilities.Blockstore);
|
|
22
|
+
const space = client.spaces.get(db.spaceId);
|
|
23
|
+
invariant(space, "Space not found", {
|
|
24
|
+
F: __dxlog_file,
|
|
25
|
+
L: 23,
|
|
26
|
+
S: this,
|
|
27
|
+
A: [
|
|
28
|
+
"space",
|
|
29
|
+
"'Space not found'"
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
const info = yield* Effect.promise(() => upload({
|
|
33
|
+
file,
|
|
34
|
+
blockstore,
|
|
35
|
+
space
|
|
36
|
+
}));
|
|
37
|
+
return {
|
|
38
|
+
object: File_exports.make({
|
|
39
|
+
name: info.name,
|
|
40
|
+
type: info.type,
|
|
41
|
+
cid: info.cid
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
})));
|
|
45
|
+
var create_file_default = handler;
|
|
46
|
+
export {
|
|
47
|
+
create_file_default as default
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=create-file-NGKX6CFL.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 { invariant } from '@dxos/invariant';\nimport { Operation } from '@dxos/operation';\nimport { ClientCapabilities } from '@dxos/plugin-client';\n\nimport { upload } from '../helpers';\nimport { WnfsCapabilities, WnfsFile } from '../types';\n\nimport { CreateFile } from './definitions';\n\nconst handler: Operation.WithHandler<typeof CreateFile> = CreateFile.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ file, db }) {\n const client = yield* Capability.get(ClientCapabilities.Client);\n const blockstore = yield* Capability.get(WnfsCapabilities.Blockstore);\n const space = client.spaces.get(db.spaceId);\n invariant(space, 'Space not found');\n const info = yield* Effect.promise(() => upload({ file, blockstore, space }));\n return {\n object: WnfsFile.make({ name: info.name, type: info.type, cid: info.cid }),\n };\n }),\n ),\n);\n\nexport default handler;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,0BAA0B;;AAOnC,IAAMC,UAAoDC,WAAWC,KACnEC,UAAUC,YACDC,kBAAW,WAAW,EAAEC,MAAMC,GAAE,GAAE;AACvC,QAAMC,SAAS,OAAOC,WAAWC,IAAIC,mBAAmBC,MAAM;AAC9D,QAAMC,aAAa,OAAOJ,WAAWC,IAAII,iBAAiBC,UAAU;AACpE,QAAMC,QAAQR,OAAOS,OAAOP,IAAIH,GAAGW,OAAO;AAC1CC,YAAUH,OAAO,mBAAA;;;;;;;;;AACjB,QAAMI,OAAO,OAAcC,eAAQ,MAAMC,OAAO;IAAEhB;IAAMO;IAAYG;EAAM,CAAA,CAAA;AAC1E,SAAO;IACLO,QAAQC,aAASC,KAAK;MAAEC,MAAMN,KAAKM;MAAMC,MAAMP,KAAKO;MAAMC,KAAKR,KAAKQ;IAAI,CAAA;EAC1E;AACF,CAAA,CAAA,CAAA;AAIJ,IAAA,sBAAe5B;",
|
|
6
|
+
"names": ["Effect", "Capability", "invariant", "Operation", "ClientCapabilities", "handler", "CreateFile", "pipe", "Operation", "withHandler", "fnUntraced", "file", "db", "client", "Capability", "get", "ClientCapabilities", "Client", "blockstore", "WnfsCapabilities", "Blockstore", "space", "spaces", "spaceId", "invariant", "info", "promise", "upload", "object", "WnfsFile", "make", "name", "type", "cid"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import "./chunk-CXWUR7YI.mjs";
|
|
2
|
+
import {
|
|
3
|
+
definitions_exports
|
|
4
|
+
} from "./chunk-QE7ZSOYG.mjs";
|
|
5
|
+
import "./chunk-3I3QQNA3.mjs";
|
|
6
|
+
|
|
7
|
+
// src/capabilities/file-uploader/file-uploader.ts
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
10
|
+
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
11
|
+
import { runAndForwardErrors } from "@dxos/effect";
|
|
12
|
+
import { SpaceOperation } from "@dxos/plugin-space/operations";
|
|
13
|
+
var file_uploader_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
14
|
+
const capabilities = yield* Capability.Service;
|
|
15
|
+
return Capability.contributes(AppCapabilities.FileUploader, (db, file) => {
|
|
16
|
+
const { invoke } = capabilities.get(Capabilities.OperationInvoker);
|
|
17
|
+
const program = Effect.gen(function* () {
|
|
18
|
+
const fileInfo = yield* invoke(definitions_exports.Upload, {
|
|
19
|
+
db,
|
|
20
|
+
file
|
|
21
|
+
});
|
|
22
|
+
const createResult = yield* invoke(definitions_exports.Create, fileInfo);
|
|
23
|
+
if (createResult?.object) {
|
|
24
|
+
yield* invoke(SpaceOperation.AddObject, {
|
|
25
|
+
target: db,
|
|
26
|
+
object: createResult.object
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return fileInfo;
|
|
30
|
+
});
|
|
31
|
+
return runAndForwardErrors(program);
|
|
32
|
+
});
|
|
33
|
+
}));
|
|
34
|
+
export {
|
|
35
|
+
file_uploader_default as default
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=file-uploader-THECEDM2.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/file-uploader/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/operations';\n\nimport { WnfsOperation } from '../../operations';\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;AAI/B,IAAA,wBAAeC,WAAWC,WACjBC,kBAAW,aAAA;AAEhB,QAAMC,eAAe,OAAOH,WAAWI;AAEvC,SAAOJ,WAAWK,YAAYC,gBAAgBC,cAAc,CAACC,IAAIC,SAAAA;AAC/D,UAAM,EAAEC,OAAM,IAAKP,aAAaQ,IAAIC,aAAaC,gBAAgB;AACjE,UAAMC,UAAiBC,WAAI,aAAA;AACzB,YAAMC,WAAW,OAAON,OAAOO,oBAAcC,QAAQ;QAAEV;QAAIC;MAAK,CAAA;AAChE,YAAMU,eAAe,OAAOT,OAAOO,oBAAcG,QAAQJ,QAAAA;AACzD,UAAIG,cAAcE,QAAQ;AACxB,eAAOX,OAAOY,eAAeC,WAAW;UAAEC,QAAQhB;UAAIa,QAAQF,aAAaE;QAAO,CAAA;MACpF;AAEA,aAAOL;IACT,CAAA;AAEA,WAAOS,oBAAoBX,OAAAA;EAC7B,CAAA;AACF,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "Capabilities", "Capability", "AppCapabilities", "runAndForwardErrors", "SpaceOperation", "Capability", "makeModule", "fnUntraced", "capabilities", "Service", "contributes", "AppCapabilities", "FileUploader", "db", "file", "invoke", "get", "Capabilities", "OperationInvoker", "program", "gen", "fileInfo", "WnfsOperation", "Upload", "createResult", "Create", "object", "SpaceOperation", "AddObject", "target", "runAndForwardErrors"]
|
|
7
|
+
}
|
|
@@ -1,28 +1,44 @@
|
|
|
1
|
+
import "./chunk-CXWUR7YI.mjs";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
IntentResolver,
|
|
5
|
-
Markdown,
|
|
6
|
-
ReactSurface
|
|
7
|
-
} from "./chunk-ZFPJA5F4.mjs";
|
|
8
|
-
import {
|
|
9
|
-
WnfsCapabilities
|
|
10
|
-
} from "./chunk-F4QHZWQD.mjs";
|
|
3
|
+
definitions_exports
|
|
4
|
+
} from "./chunk-QE7ZSOYG.mjs";
|
|
11
5
|
import {
|
|
12
6
|
File_exports,
|
|
13
|
-
WnfsAction
|
|
14
|
-
|
|
15
|
-
import {
|
|
7
|
+
WnfsAction,
|
|
8
|
+
WnfsCapabilities,
|
|
16
9
|
meta
|
|
17
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3I3QQNA3.mjs";
|
|
18
11
|
|
|
19
12
|
// src/WnfsPlugin.tsx
|
|
20
|
-
import * as
|
|
21
|
-
import
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
import * as Option from "effect/Option";
|
|
15
|
+
import { Capability as Capability6, Plugin } from "@dxos/app-framework";
|
|
16
|
+
import { AppPlugin } from "@dxos/app-toolkit";
|
|
17
|
+
import { Annotation } from "@dxos/echo";
|
|
18
|
+
import { Operation } from "@dxos/operation";
|
|
22
19
|
import { ClientEvents } from "@dxos/plugin-client";
|
|
23
20
|
import { MarkdownEvents } from "@dxos/plugin-markdown";
|
|
24
|
-
import {
|
|
25
|
-
|
|
21
|
+
import { SpaceOperation } from "@dxos/plugin-space/operations";
|
|
22
|
+
|
|
23
|
+
// src/capabilities/blockstore/index.ts
|
|
24
|
+
import { Capability } from "@dxos/app-framework";
|
|
25
|
+
var Blockstore = Capability.lazy("Blockstore", () => import("./blockstore-TUV5YIC5.mjs"));
|
|
26
|
+
|
|
27
|
+
// src/capabilities/file-uploader/index.ts
|
|
28
|
+
import { Capability as Capability2 } from "@dxos/app-framework";
|
|
29
|
+
var FileUploader = Capability2.lazy("FileUploader", () => import("./file-uploader-THECEDM2.mjs"));
|
|
30
|
+
|
|
31
|
+
// src/capabilities/markdown/index.ts
|
|
32
|
+
import { Capability as Capability3 } from "@dxos/app-framework";
|
|
33
|
+
var Markdown = Capability3.lazy("Markdown", () => import("./markdown-IEDBXCLX.mjs"));
|
|
34
|
+
|
|
35
|
+
// src/capabilities/operation-handler/index.ts
|
|
36
|
+
import { Capability as Capability4 } from "@dxos/app-framework";
|
|
37
|
+
var OperationHandler = Capability4.lazy("OperationHandler", () => import("./operation-handler-YAYDKG7R.mjs"));
|
|
38
|
+
|
|
39
|
+
// src/capabilities/react-surface/index.ts
|
|
40
|
+
import { Capability as Capability5 } from "@dxos/app-framework";
|
|
41
|
+
var ReactSurface = Capability5.lazy("ReactSurface", () => import("./react-surface-UGRUPU56.mjs"));
|
|
26
42
|
|
|
27
43
|
// src/translations.ts
|
|
28
44
|
var translations = [
|
|
@@ -30,13 +46,17 @@ var translations = [
|
|
|
30
46
|
"en-US": {
|
|
31
47
|
[File_exports.File.typename]: {
|
|
32
48
|
"typename label": "File",
|
|
49
|
+
"typename label_zero": "Files",
|
|
50
|
+
"typename label_one": "File",
|
|
51
|
+
"typename label_other": "Files",
|
|
33
52
|
"object name placeholder": "New file",
|
|
53
|
+
"add object label": "Add file",
|
|
34
54
|
"rename object label": "Rename file",
|
|
35
|
-
"delete object label": "Delete file"
|
|
55
|
+
"delete object label": "Delete file",
|
|
56
|
+
"object deleted label": "File deleted"
|
|
36
57
|
},
|
|
37
58
|
[meta.id]: {
|
|
38
59
|
"plugin name": "Files",
|
|
39
|
-
"delete object label": "Delete",
|
|
40
60
|
"file input placeholder": "Drop a file here, or click to select a file"
|
|
41
61
|
}
|
|
42
62
|
}
|
|
@@ -44,70 +64,58 @@ var translations = [
|
|
|
44
64
|
];
|
|
45
65
|
|
|
46
66
|
// src/WnfsPlugin.tsx
|
|
47
|
-
var WnfsPlugin =
|
|
48
|
-
|
|
49
|
-
id:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
var WnfsPlugin = Plugin.define(meta).pipe(AppPlugin.addMetadataModule({
|
|
68
|
+
metadata: {
|
|
69
|
+
id: File_exports.File.typename,
|
|
70
|
+
metadata: {
|
|
71
|
+
// TODO(wittjosiah): Would be nice if icon could change based on the type of the file.
|
|
72
|
+
icon: Annotation.IconAnnotation.get(File_exports.File).pipe(Option.getOrThrow).icon,
|
|
73
|
+
iconHue: Annotation.IconAnnotation.get(File_exports.File).pipe(Option.getOrThrow).hue ?? "white",
|
|
74
|
+
inputSchema: WnfsAction.UploadFileSchema,
|
|
75
|
+
createObject: (props, options) => Effect.gen(function* () {
|
|
76
|
+
const { object } = yield* Operation.invoke(definitions_exports.CreateFile, {
|
|
77
|
+
...props,
|
|
78
|
+
db: options.db
|
|
79
|
+
});
|
|
80
|
+
return yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
81
|
+
object,
|
|
82
|
+
target: options.target,
|
|
83
|
+
hidden: true,
|
|
84
|
+
targetNodeId: options.targetNodeId
|
|
85
|
+
});
|
|
86
|
+
})
|
|
59
87
|
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
activate: () => contributes(SpaceCapabilities.ObjectForm, defineObjectForm({
|
|
82
|
-
objectSchema: File_exports.File,
|
|
83
|
-
formSchema: WnfsAction.UploadFileSchema,
|
|
84
|
-
getIntent: (props, options) => Function.pipe(createIntent(WnfsAction.Upload, {
|
|
85
|
-
...props,
|
|
86
|
-
space: options.space
|
|
87
|
-
}), chain(WnfsAction.Create, {}))
|
|
88
|
-
}))
|
|
89
|
-
}),
|
|
90
|
-
defineModule({
|
|
91
|
-
id: `${meta.id}/module/file-uploader`,
|
|
92
|
-
activatesOn: ClientEvents.ClientReady,
|
|
93
|
-
activate: FileUploader
|
|
94
|
-
}),
|
|
95
|
-
defineModule({
|
|
96
|
-
id: `${meta.id}/module/markdown`,
|
|
97
|
-
activatesOn: MarkdownEvents.SetupExtensions,
|
|
98
|
-
activate: Markdown
|
|
99
|
-
}),
|
|
100
|
-
defineModule({
|
|
101
|
-
id: `${meta.id}/module/react-surface`,
|
|
102
|
-
activatesOn: Events.SetupReactSurface,
|
|
103
|
-
activate: ReactSurface
|
|
104
|
-
}),
|
|
105
|
-
defineModule({
|
|
106
|
-
id: `${meta.id}/module/intent-resolver`,
|
|
107
|
-
activatesOn: Events.SetupIntentResolver,
|
|
108
|
-
activate: IntentResolver
|
|
88
|
+
}
|
|
89
|
+
}), AppPlugin.addOperationHandlerModule({
|
|
90
|
+
activate: OperationHandler
|
|
91
|
+
}), AppPlugin.addSchemaModule({
|
|
92
|
+
schema: [
|
|
93
|
+
File_exports.File
|
|
94
|
+
]
|
|
95
|
+
}), AppPlugin.addSurfaceModule({
|
|
96
|
+
activate: ReactSurface
|
|
97
|
+
}), AppPlugin.addTranslationsModule({
|
|
98
|
+
translations
|
|
99
|
+
}), Plugin.addModule({
|
|
100
|
+
id: "blockstore",
|
|
101
|
+
activatesOn: ClientEvents.ClientReady,
|
|
102
|
+
activate: Blockstore
|
|
103
|
+
}), Plugin.addModule({
|
|
104
|
+
id: "instances",
|
|
105
|
+
activatesOn: ClientEvents.ClientReady,
|
|
106
|
+
activate: () => Effect.sync(() => {
|
|
107
|
+
const instances = {};
|
|
108
|
+
return Capability6.contributes(WnfsCapabilities.Instances, instances);
|
|
109
109
|
})
|
|
110
|
-
|
|
110
|
+
}), Plugin.addModule({
|
|
111
|
+
id: "file-uploader",
|
|
112
|
+
activatesOn: ClientEvents.ClientReady,
|
|
113
|
+
activate: FileUploader
|
|
114
|
+
}), Plugin.addModule({
|
|
115
|
+
id: "markdown",
|
|
116
|
+
activatesOn: MarkdownEvents.SetupExtensions,
|
|
117
|
+
activate: Markdown
|
|
118
|
+
}), Plugin.make);
|
|
111
119
|
export {
|
|
112
120
|
WnfsCapabilities,
|
|
113
121
|
WnfsPlugin,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/WnfsPlugin.tsx", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/WnfsPlugin.tsx", "../../../src/capabilities/blockstore/index.ts", "../../../src/capabilities/file-uploader/index.ts", "../../../src/capabilities/markdown/index.ts", "../../../src/capabilities/operation-handler/index.ts", "../../../src/capabilities/react-surface/index.ts", "../../../src/translations.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nimport { Capability, Plugin } from '@dxos/app-framework';\nimport { AppPlugin } from '@dxos/app-toolkit';\nimport { Annotation } from '@dxos/echo';\nimport { Operation } from '@dxos/operation';\nimport { ClientEvents } from '@dxos/plugin-client';\nimport { MarkdownEvents } from '@dxos/plugin-markdown';\nimport { type CreateObject } from '@dxos/plugin-space/types';\nimport { SpaceOperation } from '@dxos/plugin-space/operations';\n\nimport { Blockstore, FileUploader, Markdown, OperationHandler, ReactSurface } from './capabilities';\nimport { meta } from './meta';\nimport { translations } from './translations';\nimport { WnfsAction, WnfsCapabilities, WnfsFile } from './types';\nimport { WnfsOperation } from './operations';\n\nexport const WnfsPlugin = Plugin.define(meta).pipe(\n AppPlugin.addMetadataModule({\n metadata: {\n id: WnfsFile.File.typename,\n metadata: {\n // TODO(wittjosiah): Would be nice if icon could change based on the type of the file.\n icon: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).icon,\n iconHue: Annotation.IconAnnotation.get(WnfsFile.File).pipe(Option.getOrThrow).hue ?? 'white',\n inputSchema: WnfsAction.UploadFileSchema,\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 })) satisfies CreateObject,\n },\n },\n }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n AppPlugin.addSchemaModule({ schema: [WnfsFile.File] }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.addModule({\n id: 'blockstore',\n activatesOn: ClientEvents.ClientReady,\n activate: Blockstore,\n }),\n Plugin.addModule({\n id: 'instances',\n activatesOn: ClientEvents.ClientReady,\n activate: () =>\n Effect.sync(() => {\n const instances: WnfsCapabilities.Instances = {};\n return Capability.contributes(WnfsCapabilities.Instances, instances);\n }),\n }),\n Plugin.addModule({\n id: 'file-uploader',\n activatesOn: ClientEvents.ClientReady,\n activate: FileUploader,\n }),\n Plugin.addModule({\n id: 'markdown',\n activatesOn: MarkdownEvents.SetupExtensions,\n activate: Markdown,\n }),\n Plugin.make,\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const Blockstore = Capability.lazy('Blockstore', () => import('./blockstore'));\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const FileUploader = Capability.lazy('FileUploader', () => import('./file-uploader'));\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const Markdown = Capability.lazy('Markdown', () => import('./markdown'));\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\nimport { OperationHandlerSet } from '@dxos/operation';\n\nexport const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(\n 'OperationHandler',\n () => import('./operation-handler'),\n);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Resource } from '@dxos/react-ui';\n\nimport { meta } from './meta';\nimport { WnfsFile } from './types';\n\nexport const translations = [\n {\n 'en-US': {\n [WnfsFile.File.typename]: {\n 'typename label': 'File',\n 'typename label_zero': 'Files',\n 'typename label_one': 'File',\n 'typename label_other': 'Files',\n 'object name placeholder': 'New file',\n 'add object label': 'Add file',\n 'rename object label': 'Rename file',\n 'delete object label': 'Delete file',\n 'object deleted label': 'File deleted',\n },\n [meta.id]: {\n 'plugin name': 'Files',\n 'file input placeholder': 'Drop a file here, or click to select a file',\n },\n },\n },\n] as const satisfies Resource[];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAIA,YAAYA,YAAY;AACxB,YAAYC,YAAY;AAExB,SAASC,cAAAA,aAAYC,cAAc;AACnC,SAASC,iBAAiB;AAC1B,SAASC,kBAAkB;AAC3B,SAASC,iBAAiB;AAC1B,SAASC,oBAAoB;AAC7B,SAASC,sBAAsB;AAE/B,SAASC,sBAAsB;;;ACV/B,SAASC,kBAAkB;AAEpB,IAAMC,aAAaC,WAAWC,KAAK,cAAc,MAAM,OAAO,2BAAA,CAAA;;;ACFrE,SAASC,cAAAA,mBAAkB;AAEpB,IAAMC,eAAeC,YAAWC,KAAK,gBAAgB,MAAM,OA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,GACA/B,UAAUgC,0BAA0B;EAAEC,UAAUC;AAAiB,CAAA,GACjElC,UAAUmC,gBAAgB;EAAEC,QAAQ;IAAChC,aAASC;;AAAM,CAAA,GACpDL,UAAUqC,iBAAiB;EAAEJ,UAAUK;AAAa,CAAA,GACpDtC,UAAUuC,sBAAsB;EAAEC;AAAa,CAAA,GAC/C5C,OAAO6C,UAAU;EACftC,IAAI;EACJuC,aAAaC,aAAaC;EAC1BX,UAAUY;AACZ,CAAA,GACAjD,OAAO6C,UAAU;EACftC,IAAI;EACJuC,aAAaC,aAAaC;EAC1BX,UAAU,MACDa,YAAK,MAAA;AACV,UAAMC,YAAwC,CAAC;AAC/C,WAAOC,YAAWC,YAAYC,iBAAiBC,WAAWJ,SAAAA;EAC5D,CAAA;AACJ,CAAA,GACAnD,OAAO6C,UAAU;EACftC,IAAI;EACJuC,aAAaC,aAAaC;EAC1BX,UAAUmB;AACZ,CAAA,GACAxD,OAAO6C,UAAU;EACftC,IAAI;EACJuC,aAAaW,eAAeC;EAC5BrB,UAAUsB;AACZ,CAAA,GACA3D,OAAO4D,IAAI;",
|
|
6
|
+
"names": ["Effect", "Option", "Capability", "Plugin", "AppPlugin", "Annotation", "Operation", "ClientEvents", "MarkdownEvents", "SpaceOperation", "Capability", "Blockstore", "Capability", "lazy", "Capability", "FileUploader", "Capability", "lazy", "Capability", "Markdown", "Capability", "lazy", "Capability", "OperationHandler", "Capability", "lazy", "Capability", "ReactSurface", "Capability", "lazy", "translations", "WnfsFile", "File", "typename", "meta", "id", "WnfsPlugin", "Plugin", "define", "meta", "pipe", "AppPlugin", "addMetadataModule", "metadata", "id", "WnfsFile", "File", "typename", "icon", "Annotation", "IconAnnotation", "get", "getOrThrow", "iconHue", "hue", "inputSchema", "WnfsAction", "UploadFileSchema", "createObject", "props", "options", "gen", "object", "Operation", "invoke", "WnfsOperation", "CreateFile", "db", "SpaceOperation", "AddObject", "target", "hidden", "targetNodeId", "addOperationHandlerModule", "activate", "OperationHandler", "addSchemaModule", "schema", "addSurfaceModule", "ReactSurface", "addTranslationsModule", "translations", "addModule", "activatesOn", "ClientEvents", "ClientReady", "Blockstore", "sync", "instances", "Capability", "contributes", "WnfsCapabilities", "Instances", "FileUploader", "MarkdownEvents", "SetupExtensions", "Markdown", "make"]
|
|
7
7
|
}
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
getBlobUrl,
|
|
3
3
|
getPathFromUrl,
|
|
4
4
|
loadWnfs
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-A7ETWNGC.mjs";
|
|
6
6
|
import {
|
|
7
7
|
WnfsCapabilities
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-OGPGLJCV.mjs";
|
|
8
|
+
} from "./chunk-3I3QQNA3.mjs";
|
|
10
9
|
|
|
11
|
-
// src/capabilities/markdown.ts
|
|
12
|
-
import
|
|
10
|
+
// src/capabilities/markdown/markdown.ts
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
import { Capability } from "@dxos/app-framework";
|
|
13
13
|
import { MarkdownCapabilities } from "@dxos/plugin-markdown";
|
|
14
14
|
import { getSpace } from "@dxos/react-client/echo";
|
|
15
15
|
|
|
@@ -20,8 +20,8 @@ import { Decoration, EditorView, WidgetType } from "@codemirror/view";
|
|
|
20
20
|
import React from "react";
|
|
21
21
|
import { createRoot } from "react-dom/client";
|
|
22
22
|
import { Status, ThemeProvider } from "@dxos/react-ui";
|
|
23
|
-
import { focusField } from "@dxos/
|
|
24
|
-
import { defaultTx } from "@dxos/
|
|
23
|
+
import { focusField } from "@dxos/ui-editor";
|
|
24
|
+
import { defaultTx } from "@dxos/ui-theme";
|
|
25
25
|
var WAIT_UNTIL_LOADER = 1500;
|
|
26
26
|
var image = (options) => {
|
|
27
27
|
const blobUrlCache = {};
|
|
@@ -174,25 +174,28 @@ var WnfsImageWidget = class extends WidgetType {
|
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
-
// src/capabilities/markdown.ts
|
|
178
|
-
var markdown_default = ((
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
177
|
+
// src/capabilities/markdown/markdown.ts
|
|
178
|
+
var markdown_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
179
|
+
const capabilities = yield* Capability.Service;
|
|
180
|
+
return Capability.contributes(MarkdownCapabilities.Extensions, [
|
|
181
|
+
({ document: document2 }) => {
|
|
182
|
+
const blockstore = capabilities.get(WnfsCapabilities.Blockstore);
|
|
183
|
+
const instances = capabilities.get(WnfsCapabilities.Instances);
|
|
184
|
+
if (document2) {
|
|
185
|
+
const space = getSpace(document2);
|
|
186
|
+
return space ? [
|
|
187
|
+
image({
|
|
188
|
+
blockstore,
|
|
189
|
+
instances,
|
|
190
|
+
space
|
|
191
|
+
})
|
|
192
|
+
] : [];
|
|
193
|
+
}
|
|
194
|
+
return [];
|
|
191
195
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
]));
|
|
196
|
+
]);
|
|
197
|
+
}));
|
|
195
198
|
export {
|
|
196
199
|
markdown_default as default
|
|
197
200
|
};
|
|
198
|
-
//# sourceMappingURL=markdown-
|
|
201
|
+
//# sourceMappingURL=markdown-IEDBXCLX.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/markdown/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 { MarkdownCapabilities } from '@dxos/plugin-markdown';\nimport { getSpace } from '@dxos/react-client/echo';\n\nimport { image } from '../../extensions';\nimport { WnfsCapabilities } 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(MarkdownCapabilities.Extensions, [\n ({ document }: { document?: any }) => {\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 })] : [];\n }\n\n return [];\n },\n ]);\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 { getBlobUrl, getPathFromUrl, loadWnfs } from '../helpers';\nimport { type WnfsCapabilities } from '../types';\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,SAASC,4BAA4B;AACrC,SAASC,gBAAgB;;;ACJzB,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;AAM1B,IAAMC,oBAAoB;AAWnB,IAAMC,QAAQ,CAACC,YAAAA;AACpB,QAAMC,eAAuC,CAAC;AAC9C,QAAMC,YAAY,oBAAIC,IAAAA;AAEtB,QAAMC,UAAU,CAACC,QAAAA;AACf,QAAI,CAACH,UAAUI,IAAID,GAAAA,GAAM;AACvB,YAAME,MAAMC,SAASC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AegC,WAAWC,WACjBC,kBAAW,aAAA;AAEhB,QAAMC,eAAe,OAAOH,WAAWI;AAEvC,SAAOJ,WAAWK,YAAYC,qBAAqBC,YAAY;IAC7D,CAAC,EAAEC,UAAAA,UAAQ,MAAsB;AAC/B,YAAMC,aAAaN,aAAaO,IAAIC,iBAAiBC,UAAU;AAC/D,YAAMC,YAAYV,aAAaO,IAAIC,iBAAiBG,SAAS;AAE7D,UAAIN,WAAU;AACZ,cAAMO,QAAQC,SAASR,SAAAA;AACvB,eAAOO,QAAQ;UAACE,MAAM;YAAER;YAAYI;YAAWE;UAAM,CAAA;YAAM,CAAA;MAC7D;AAEA,aAAO,CAAA;IACT;GACD;AACH,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "Capability", "MarkdownCapabilities", "getSpace", "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", "contributes", "MarkdownCapabilities", "Extensions", "document", "blockstore", "get", "WnfsCapabilities", "Blockstore", "instances", "Instances", "space", "getSpace", "image"]
|
|
7
|
+
}
|