@dxos/plugin-wnfs 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef

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.
Files changed (172) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/browser/chunk-4D4K5JCC.mjs +66 -0
  3. package/dist/lib/browser/chunk-4D4K5JCC.mjs.map +7 -0
  4. package/dist/lib/browser/{chunk-NCTUASHL.mjs → chunk-7KFJ6LYH.mjs} +36 -19
  5. package/dist/lib/browser/chunk-7KFJ6LYH.mjs.map +7 -0
  6. package/dist/lib/browser/chunk-DK62NQ5T.mjs +71 -0
  7. package/dist/lib/browser/chunk-DK62NQ5T.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  9. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  10. package/dist/lib/browser/create-QRLX4IMZ.mjs +25 -0
  11. package/dist/lib/browser/create-QRLX4IMZ.mjs.map +7 -0
  12. package/dist/lib/browser/create-file-INAT56PX.mjs +42 -0
  13. package/dist/lib/browser/create-file-INAT56PX.mjs.map +7 -0
  14. package/dist/lib/browser/helpers/index.mjs +26 -0
  15. package/dist/lib/browser/helpers/index.mjs.map +7 -0
  16. package/dist/lib/browser/index.mjs +22 -108
  17. package/dist/lib/browser/index.mjs.map +4 -4
  18. package/dist/lib/browser/meta.json +1 -1
  19. package/dist/lib/browser/operations/index.mjs +14 -0
  20. package/dist/lib/browser/operations/index.mjs.map +7 -0
  21. package/dist/lib/browser/translations.mjs +30 -0
  22. package/dist/lib/browser/translations.mjs.map +7 -0
  23. package/dist/lib/browser/types/index.mjs +4 -5
  24. package/dist/lib/browser/upload-ZQI66T4Y.mjs +35 -0
  25. package/dist/lib/browser/upload-ZQI66T4Y.mjs.map +7 -0
  26. package/dist/types/src/WnfsPlugin.d.ts +1 -0
  27. package/dist/types/src/WnfsPlugin.d.ts.map +1 -1
  28. package/dist/types/src/WnfsPlugin.node.d.ts +4 -0
  29. package/dist/types/src/WnfsPlugin.node.d.ts.map +1 -0
  30. package/dist/types/src/WnfsPlugin.test.d.ts +2 -0
  31. package/dist/types/src/WnfsPlugin.test.d.ts.map +1 -0
  32. package/dist/types/src/blockstore.d.ts.map +1 -1
  33. package/dist/types/src/capabilities/blockstore.d.ts +5 -0
  34. package/dist/types/src/capabilities/blockstore.d.ts.map +1 -0
  35. package/dist/types/src/capabilities/file-uploader.d.ts +6 -0
  36. package/dist/types/src/capabilities/file-uploader.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/index.d.ts +7 -5
  38. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  39. package/dist/types/src/capabilities/markdown.d.ts +6 -0
  40. package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
  41. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  42. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  43. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  44. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  45. package/dist/types/src/components/FileInput/FileInput.d.ts.map +1 -0
  46. package/dist/types/src/components/FileInput/index.d.ts +2 -0
  47. package/dist/types/src/components/FileInput/index.d.ts.map +1 -0
  48. package/dist/types/src/components/FilePreview/FilePreview.d.ts +12 -0
  49. package/dist/types/src/components/FilePreview/FilePreview.d.ts.map +1 -0
  50. package/dist/types/src/components/FilePreview/index.d.ts +2 -0
  51. package/dist/types/src/components/FilePreview/index.d.ts.map +1 -0
  52. package/dist/types/src/components/index.d.ts +1 -1
  53. package/dist/types/src/components/index.d.ts.map +1 -1
  54. package/dist/types/src/containers/FileContainer/FileContainer.d.ts +7 -0
  55. package/dist/types/src/containers/FileContainer/FileContainer.d.ts.map +1 -0
  56. package/dist/types/src/containers/FileContainer/index.d.ts +2 -0
  57. package/dist/types/src/containers/FileContainer/index.d.ts.map +1 -0
  58. package/dist/types/src/containers/index.d.ts +3 -0
  59. package/dist/types/src/containers/index.d.ts.map +1 -0
  60. package/dist/types/src/extensions/image.d.ts +1 -1
  61. package/dist/types/src/extensions/image.d.ts.map +1 -1
  62. package/dist/types/src/extensions/image.stories.d.ts.map +1 -1
  63. package/dist/types/src/helpers/common.d.ts.map +1 -1
  64. package/dist/types/src/helpers/load.d.ts +1 -1
  65. package/dist/types/src/helpers/load.d.ts.map +1 -1
  66. package/dist/types/src/helpers/upload.d.ts +1 -1
  67. package/dist/types/src/helpers/upload.d.ts.map +1 -1
  68. package/dist/types/src/helpers/wnfs-url.d.ts.map +1 -1
  69. package/dist/types/src/index.d.ts +3 -2
  70. package/dist/types/src/index.d.ts.map +1 -1
  71. package/dist/types/src/operations/create-file.d.ts +5 -0
  72. package/dist/types/src/operations/create-file.d.ts.map +1 -0
  73. package/dist/types/src/operations/create.d.ts +5 -0
  74. package/dist/types/src/operations/create.d.ts.map +1 -0
  75. package/dist/types/src/operations/definitions.d.ts +38 -0
  76. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  77. package/dist/types/src/operations/index.d.ts +4 -0
  78. package/dist/types/src/operations/index.d.ts.map +1 -0
  79. package/dist/types/src/operations/upload.d.ts +5 -0
  80. package/dist/types/src/operations/upload.d.ts.map +1 -0
  81. package/dist/types/src/translations.d.ts +24 -15
  82. package/dist/types/src/translations.d.ts.map +1 -1
  83. package/dist/types/src/types/File.d.ts +1 -1
  84. package/dist/types/src/types/File.d.ts.map +1 -1
  85. package/dist/types/src/types/capabilities.d.ts.map +1 -1
  86. package/dist/types/src/types/types.d.ts +1 -104
  87. package/dist/types/src/types/types.d.ts.map +1 -1
  88. package/dist/types/tsconfig.tsbuildinfo +1 -1
  89. package/package.json +62 -37
  90. package/src/WnfsPlugin.node.ts +47 -0
  91. package/src/WnfsPlugin.test.ts +27 -0
  92. package/src/WnfsPlugin.tsx +40 -39
  93. package/src/blockstore.ts +1 -1
  94. package/src/capabilities/{blockstore/blockstore.ts → blockstore.ts} +4 -3
  95. package/src/capabilities/{file-uploader/file-uploader.ts → file-uploader.ts} +6 -5
  96. package/src/capabilities/index.ts +11 -5
  97. package/src/capabilities/markdown.ts +38 -0
  98. package/src/capabilities/operation-handler.ts +16 -0
  99. package/src/capabilities/react-surface.tsx +60 -0
  100. package/src/components/{FileInput.tsx → FileInput/FileInput.tsx} +5 -5
  101. package/src/components/FileInput/index.ts +5 -0
  102. package/src/components/FilePreview/FilePreview.tsx +43 -0
  103. package/src/components/FilePreview/index.ts +5 -0
  104. package/src/components/index.ts +1 -4
  105. package/src/{components → containers/FileContainer}/FileContainer.tsx +12 -11
  106. package/src/containers/FileContainer/index.ts +5 -0
  107. package/src/containers/index.ts +7 -0
  108. package/src/extensions/image.stories.tsx +9 -10
  109. package/src/extensions/image.tsx +2 -1
  110. package/src/helpers/load.ts +6 -6
  111. package/src/helpers/upload.ts +3 -3
  112. package/src/index.ts +8 -2
  113. package/src/meta.ts +1 -1
  114. package/src/operations/create-file.ts +31 -0
  115. package/src/operations/create.ts +22 -0
  116. package/src/operations/definitions.ts +41 -0
  117. package/src/operations/index.ts +13 -0
  118. package/src/operations/upload.ts +29 -0
  119. package/src/translations.ts +13 -12
  120. package/src/types/File.ts +6 -2
  121. package/src/types/capabilities.ts +3 -3
  122. package/src/types/types.ts +3 -59
  123. package/dist/lib/browser/FileContainer-O5YFSIWV.mjs +0 -91
  124. package/dist/lib/browser/FileContainer-O5YFSIWV.mjs.map +0 -7
  125. package/dist/lib/browser/blockstore-KKFOALUH.mjs +0 -191
  126. package/dist/lib/browser/blockstore-KKFOALUH.mjs.map +0 -7
  127. package/dist/lib/browser/chunk-GXXEH7H6.mjs +0 -154
  128. package/dist/lib/browser/chunk-GXXEH7H6.mjs.map +0 -7
  129. package/dist/lib/browser/chunk-NCTUASHL.mjs.map +0 -7
  130. package/dist/lib/browser/file-uploader-BUHAXRSV.mjs +0 -34
  131. package/dist/lib/browser/file-uploader-BUHAXRSV.mjs.map +0 -7
  132. package/dist/lib/browser/markdown-BRT2MN6C.mjs +0 -201
  133. package/dist/lib/browser/markdown-BRT2MN6C.mjs.map +0 -7
  134. package/dist/lib/browser/operation-resolver-F6GUL54A.mjs +0 -99
  135. package/dist/lib/browser/operation-resolver-F6GUL54A.mjs.map +0 -7
  136. package/dist/lib/browser/react-surface-UNAYSIAC.mjs +0 -81
  137. package/dist/lib/browser/react-surface-UNAYSIAC.mjs.map +0 -7
  138. package/dist/types/src/capabilities/blockstore/blockstore.d.ts +0 -5
  139. package/dist/types/src/capabilities/blockstore/blockstore.d.ts.map +0 -1
  140. package/dist/types/src/capabilities/blockstore/index.d.ts +0 -3
  141. package/dist/types/src/capabilities/blockstore/index.d.ts.map +0 -1
  142. package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts +0 -5
  143. package/dist/types/src/capabilities/file-uploader/file-uploader.d.ts.map +0 -1
  144. package/dist/types/src/capabilities/file-uploader/index.d.ts +0 -3
  145. package/dist/types/src/capabilities/file-uploader/index.d.ts.map +0 -1
  146. package/dist/types/src/capabilities/markdown/index.d.ts +0 -3
  147. package/dist/types/src/capabilities/markdown/index.d.ts.map +0 -1
  148. package/dist/types/src/capabilities/markdown/markdown.d.ts +0 -5
  149. package/dist/types/src/capabilities/markdown/markdown.d.ts.map +0 -1
  150. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  151. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  152. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  153. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  154. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  155. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  156. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  157. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  158. package/dist/types/src/components/FileContainer.d.ts +0 -7
  159. package/dist/types/src/components/FileContainer.d.ts.map +0 -1
  160. package/dist/types/src/components/FileInput.d.ts.map +0 -1
  161. package/dist/types/src/components/FilePreview.d.ts +0 -11
  162. package/dist/types/src/components/FilePreview.d.ts.map +0 -1
  163. package/src/capabilities/blockstore/index.ts +0 -7
  164. package/src/capabilities/file-uploader/index.ts +0 -7
  165. package/src/capabilities/markdown/index.ts +0 -7
  166. package/src/capabilities/markdown/markdown.ts +0 -33
  167. package/src/capabilities/operation-resolver/index.ts +0 -7
  168. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -62
  169. package/src/capabilities/react-surface/index.ts +0 -7
  170. package/src/capabilities/react-surface/react-surface.tsx +0 -49
  171. package/src/components/FilePreview.tsx +0 -23
  172. /package/dist/types/src/components/{FileInput.d.ts → FileInput/FileInput.d.ts} +0 -0
@@ -1,201 +0,0 @@
1
- import {
2
- getBlobUrl,
3
- getPathFromUrl,
4
- loadWnfs
5
- } from "./chunk-NCTUASHL.mjs";
6
- import {
7
- WnfsCapabilities
8
- } from "./chunk-GXXEH7H6.mjs";
9
-
10
- // src/capabilities/markdown/markdown.ts
11
- import * as Effect from "effect/Effect";
12
- import { Capability } from "@dxos/app-framework";
13
- import { MarkdownCapabilities } from "@dxos/plugin-markdown";
14
- import { getSpace } from "@dxos/react-client/echo";
15
-
16
- // src/extensions/image.tsx
17
- import { syntaxTree } from "@codemirror/language";
18
- import { StateField } from "@codemirror/state";
19
- import { Decoration, EditorView, WidgetType } from "@codemirror/view";
20
- import React from "react";
21
- import { createRoot } from "react-dom/client";
22
- import { Status, ThemeProvider } from "@dxos/react-ui";
23
- import { focusField } from "@dxos/ui-editor";
24
- import { defaultTx } from "@dxos/ui-theme";
25
- var WAIT_UNTIL_LOADER = 1500;
26
- var image = (options) => {
27
- const blobUrlCache = {};
28
- const preloaded = /* @__PURE__ */ new Set();
29
- const preload = (url) => {
30
- if (!preloaded.has(url)) {
31
- const img = document.createElement("img");
32
- img.src = url;
33
- preloaded.add(url);
34
- }
35
- };
36
- return [
37
- StateField.define({
38
- create: (state) => {
39
- return Decoration.set(buildDecorations({
40
- from: 0,
41
- to: state.doc.length,
42
- state,
43
- blobUrlCache,
44
- preload,
45
- options
46
- }));
47
- },
48
- update: (value, tr) => {
49
- if (!tr.docChanged && !tr.selection) {
50
- return value;
51
- }
52
- const cursor = tr.state.selection.main.head;
53
- const oldCursor = tr.changes.mapPos(tr.startState.selection.main.head);
54
- let from = Math.min(cursor, oldCursor);
55
- let to = Math.max(cursor, oldCursor);
56
- tr.changes.iterChangedRanges((fromA, toA, fromB, toB) => {
57
- from = Math.min(from, fromB);
58
- to = Math.max(to, toB);
59
- });
60
- from = tr.state.doc.lineAt(from).from;
61
- to = tr.state.doc.lineAt(to).to;
62
- return value.map(tr.changes).update({
63
- filterFrom: from,
64
- filterTo: to,
65
- filter: () => false,
66
- add: buildDecorations({
67
- from,
68
- to,
69
- state: tr.state,
70
- blobUrlCache,
71
- preload,
72
- options
73
- })
74
- });
75
- },
76
- provide: (field) => EditorView.decorations.from(field)
77
- })
78
- ];
79
- };
80
- var buildDecorations = ({ state, from, to, blobUrlCache, preload, options: { blockstore, instances, space } }) => {
81
- const decorations = [];
82
- const cursor = state.selection.main.head;
83
- syntaxTree(state).iterate({
84
- enter: (node) => {
85
- if (node.name !== "Image") {
86
- return;
87
- }
88
- const urlNode = node.node.getChild("URL");
89
- if (!urlNode) {
90
- return;
91
- }
92
- const hide = state.readOnly || cursor < node.from || cursor > node.to;
93
- const wnfsUrl = state.sliceDoc(urlNode.from, urlNode.to);
94
- if (!wnfsUrl.startsWith("wnfs://")) {
95
- return;
96
- }
97
- const path = getPathFromUrl(wnfsUrl);
98
- const spaceId = path[1];
99
- if (spaceId !== space.id) {
100
- return;
101
- }
102
- const blobUrlPromise = (async () => {
103
- const { directory, forest } = await loadWnfs({
104
- blockstore,
105
- instances,
106
- space
107
- });
108
- const url = await getBlobUrl({
109
- wnfsUrl,
110
- blockstore,
111
- directory,
112
- forest
113
- });
114
- blobUrlCache[path.join("/")] = url;
115
- preload(url);
116
- return url;
117
- })();
118
- decorations.push(Decoration.replace({
119
- block: true,
120
- widget: new WnfsImageWidget(wnfsUrl, blobUrlCache[path.join("/")] ?? blobUrlPromise)
121
- }).range(hide ? node.from : node.to, node.to));
122
- },
123
- from,
124
- to
125
- });
126
- return decorations;
127
- };
128
- var createImg = (view, url) => {
129
- const img = document.createElement("img");
130
- img.setAttribute("src", url);
131
- img.setAttribute("class", "cm-image-with-loader");
132
- if (view.state.field(focusField)) {
133
- img.onload = () => img.classList.add("cm-loaded-image");
134
- } else {
135
- img.classList.add("cm-loaded-image");
136
- }
137
- return img;
138
- };
139
- var WnfsImageWidget = class extends WidgetType {
140
- _wnfsUrl;
141
- _url;
142
- constructor(_wnfsUrl, _url) {
143
- super(), this._wnfsUrl = _wnfsUrl, this._url = _url;
144
- }
145
- eq(other) {
146
- return this._wnfsUrl === other._wnfsUrl;
147
- }
148
- toDOM(view) {
149
- if (typeof this._url === "string") {
150
- return createImg(view, this._url);
151
- }
152
- const widget = document.createElement("div");
153
- widget.className = "cm-image-wrapper";
154
- const loader = document.createElement("div");
155
- loader.className = "mx-auto transition-opacity";
156
- let loaderAdded = false;
157
- const timeout = setTimeout(() => {
158
- const root = createRoot(loader);
159
- root.render(/* @__PURE__ */ React.createElement(ThemeProvider, {
160
- tx: defaultTx
161
- }, /* @__PURE__ */ React.createElement(Status, {
162
- indeterminate: true
163
- })));
164
- widget.appendChild(loader);
165
- loaderAdded = true;
166
- }, WAIT_UNTIL_LOADER);
167
- void this._url.then((url) => {
168
- clearTimeout(timeout);
169
- const img = createImg(view, url);
170
- loaderAdded && widget.removeChild(loader);
171
- widget.appendChild(img);
172
- });
173
- return widget;
174
- }
175
- };
176
-
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 [];
195
- }
196
- ]);
197
- }));
198
- export {
199
- markdown_default as default
200
- };
201
- //# sourceMappingURL=markdown-BRT2MN6C.mjs.map
@@ -1,7 +0,0 @@
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": ";;;;;;;;;;AA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B,QAAIE,cAAc;AAElB,UAAMC,UAAUC,WAAW,MAAA;AACzB,YAAMC,OAAOC,WAAWL,MAAAA;AACxBI,WAAKE,OACH,sBAAA,cAACC,eAAAA;QAAcC,IAAIC;SACjB,sBAAA,cAACC,QAAAA;QAAOC,eAAAA;;AAGZ3B,aAAO4B,YAAYZ,MAAAA;AACnBC,oBAAc;IAChB,GAAGnG,iBAAAA;AAEH,SAAK,KAAK6F,KAAKkB,KAAK,CAACxG,QAAAA;AACnByG,mBAAaZ,OAAAA;AACb,YAAM3F,MAAM4E,UAAUC,MAAM/E,GAAAA;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,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
- }
@@ -1,99 +0,0 @@
1
- import {
2
- upload
3
- } from "./chunk-NCTUASHL.mjs";
4
- import {
5
- File_exports,
6
- WnfsCapabilities,
7
- WnfsOperation
8
- } from "./chunk-GXXEH7H6.mjs";
9
-
10
- // src/capabilities/operation-resolver/operation-resolver.ts
11
- import * as Effect from "effect/Effect";
12
- import { Capability, Common } from "@dxos/app-framework";
13
- import { Obj, Ref, Type } from "@dxos/echo";
14
- import { invariant } from "@dxos/invariant";
15
- import { OperationResolver } from "@dxos/operation";
16
- import { ClientCapabilities } from "@dxos/plugin-client";
17
- import { Collection } from "@dxos/schema";
18
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-wnfs/src/capabilities/operation-resolver/operation-resolver.ts";
19
- var operation_resolver_default = Capability.makeModule(Effect.fnUntraced(function* () {
20
- return Capability.contributes(Common.Capability.OperationResolver, [
21
- OperationResolver.make({
22
- operation: WnfsOperation.OnCreateSpace,
23
- handler: Effect.fnUntraced(function* ({ rootCollection }) {
24
- const collection = Collection.makeManaged({
25
- key: Type.getTypename(File_exports.File)
26
- });
27
- Obj.change(rootCollection, (c) => {
28
- c.objects.push(Ref.make(collection));
29
- });
30
- })
31
- }),
32
- OperationResolver.make({
33
- operation: WnfsOperation.Create,
34
- handler: ({ name, type, cid }) => Effect.succeed({
35
- object: File_exports.make({
36
- name,
37
- type,
38
- cid
39
- })
40
- })
41
- }),
42
- OperationResolver.make({
43
- operation: WnfsOperation.Upload,
44
- handler: Effect.fnUntraced(function* ({ file, db }) {
45
- const client = yield* Capability.get(ClientCapabilities.Client);
46
- const blockstore = yield* Capability.get(WnfsCapabilities.Blockstore);
47
- const space = client.spaces.get(db.spaceId);
48
- invariant(space, "Space not found", {
49
- F: __dxlog_file,
50
- L: 42,
51
- S: this,
52
- A: [
53
- "space",
54
- "'Space not found'"
55
- ]
56
- });
57
- const info = yield* Effect.promise(() => upload({
58
- file,
59
- blockstore,
60
- space
61
- }));
62
- return info;
63
- })
64
- }),
65
- OperationResolver.make({
66
- operation: WnfsOperation.CreateFile,
67
- handler: Effect.fnUntraced(function* ({ file, db }) {
68
- const client = yield* Capability.get(ClientCapabilities.Client);
69
- const blockstore = yield* Capability.get(WnfsCapabilities.Blockstore);
70
- const space = client.spaces.get(db.spaceId);
71
- invariant(space, "Space not found", {
72
- F: __dxlog_file,
73
- L: 53,
74
- S: this,
75
- A: [
76
- "space",
77
- "'Space not found'"
78
- ]
79
- });
80
- const info = yield* Effect.promise(() => upload({
81
- file,
82
- blockstore,
83
- space
84
- }));
85
- return {
86
- object: File_exports.make({
87
- name: info.name,
88
- type: info.type,
89
- cid: info.cid
90
- })
91
- };
92
- })
93
- })
94
- ]);
95
- }));
96
- export {
97
- operation_resolver_default as default
98
- };
99
- //# sourceMappingURL=operation-resolver-F6GUL54A.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/operation-resolver/operation-resolver.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability, Common } from '@dxos/app-framework';\nimport { Obj, Ref, Type } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { OperationResolver } from '@dxos/operation';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { Collection } from '@dxos/schema';\n\nimport { upload } from '../../helpers';\nimport { WnfsCapabilities, WnfsFile, WnfsOperation } from '../../types';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n return Capability.contributes(Common.Capability.OperationResolver, [\n OperationResolver.make({\n operation: WnfsOperation.OnCreateSpace,\n handler: Effect.fnUntraced(function* ({ rootCollection }) {\n const collection = Collection.makeManaged({ key: Type.getTypename(WnfsFile.File) });\n Obj.change(rootCollection, (c) => {\n c.objects.push(Ref.make(collection));\n });\n }),\n }),\n OperationResolver.make({\n operation: WnfsOperation.Create,\n handler: ({ name, type, cid }) =>\n Effect.succeed({\n object: WnfsFile.make({ name, type, cid }),\n }),\n }),\n OperationResolver.make({\n operation: WnfsOperation.Upload,\n handler: 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 info;\n }),\n }),\n OperationResolver.make({\n operation: WnfsOperation.CreateFile,\n handler: 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 }),\n);\n"],
5
- "mappings": ";;;;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC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BvC,SAAgBR,kBAAW,WAAW,EAAE+B,MAAMC,GAAE,GAAE;AAChD,cAAMC,SAAS,OAAOnC,WAAWoC,IAAIC,mBAAmBC,MAAM;AAC9D,cAAMC,aAAa,OAAOvC,WAAWoC,IAAII,iBAAiBC,UAAU;AACpE,cAAMC,QAAQP,OAAOQ,OAAOP,IAAIF,GAAGU,OAAO;AAC1CC,kBAAUH,OAAO,mBAAA;;;;;;;;;AACjB,cAAMI,OAAO,OAAcC,eAAQ,MAAMC,OAAO;UAAEf;UAAMM;UAAYG;QAAM,CAAA,CAAA;AAC1E,eAAO;UACLX,QAAQb,aAASZ,KAAK;YAAEqB,MAAMmB,KAAKnB;YAAMC,MAAMkB,KAAKlB;YAAMC,KAAKiB,KAAKjB;UAAI,CAAA;QAC1E;MACF,CAAA;IACF,CAAA;GACD;AACH,CAAA,CAAA;",
6
- "names": ["Effect", "Capability", "Common", "Obj", "Ref", "Type", "invariant", "OperationResolver", "ClientCapabilities", "Collection", "Capability", "makeModule", "fnUntraced", "contributes", "Common", "OperationResolver", "make", "operation", "WnfsOperation", "OnCreateSpace", "handler", "rootCollection", "collection", "Collection", "makeManaged", "key", "Type", "getTypename", "WnfsFile", "File", "Obj", "change", "c", "objects", "push", "Ref", "Create", "name", "type", "cid", "succeed", "object", "Upload", "file", "db", "client", "get", "ClientCapabilities", "Client", "blockstore", "WnfsCapabilities", "Blockstore", "space", "spaces", "spaceId", "invariant", "info", "promise", "upload", "CreateFile"]
7
- }
@@ -1,81 +0,0 @@
1
- import {
2
- File_exports,
3
- WnfsAction,
4
- meta
5
- } from "./chunk-GXXEH7H6.mjs";
6
-
7
- // src/capabilities/react-surface/react-surface.tsx
8
- import * as Effect from "effect/Effect";
9
- import React2, { useCallback as useCallback2 } from "react";
10
- import { Capability, Common } from "@dxos/app-framework";
11
- import { Obj } from "@dxos/echo";
12
- import { findAnnotation as findAnnotation2 } from "@dxos/effect";
13
-
14
- // src/components/index.ts
15
- import { lazy } from "react";
16
-
17
- // src/components/FileInput.tsx
18
- import React, { useCallback } from "react";
19
- import { useDropzone } from "react-dropzone";
20
- import { findAnnotation } from "@dxos/effect";
21
- import { useTranslation } from "@dxos/react-ui";
22
- import { mx } from "@dxos/ui-theme";
23
- var FileInput = ({ schema, onChange }) => {
24
- const { t } = useTranslation(meta.id);
25
- const accept = findAnnotation(schema.ast, WnfsAction.UploadAnnotationId);
26
- const onDropAccepted = useCallback((files) => onChange?.(files[0]), [
27
- onChange
28
- ]);
29
- const { acceptedFiles, getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({
30
- multiple: false,
31
- accept,
32
- onDropAccepted
33
- });
34
- return /* @__PURE__ */ React.createElement("div", {
35
- ...getRootProps(),
36
- className: mx("flex flex-col items-center p-8 border border-separator", isFocused && "focus-ring", isDragAccept && "bg-attention", isDragReject && "border-roseFill")
37
- }, /* @__PURE__ */ React.createElement("input", getInputProps()), acceptedFiles[0] ? /* @__PURE__ */ React.createElement("p", null, acceptedFiles[0].name) : /* @__PURE__ */ React.createElement("p", null, t("file input placeholder")));
38
- };
39
-
40
- // src/components/index.ts
41
- var FileContainer = lazy(() => import("./FileContainer-O5YFSIWV.mjs"));
42
-
43
- // src/capabilities/react-surface/react-surface.tsx
44
- var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Common.Capability.ReactSurface, [
45
- Common.createSurface({
46
- id: `${meta.id}/article`,
47
- role: [
48
- "article",
49
- "section",
50
- "slide"
51
- ],
52
- filter: (data) => Obj.instanceOf(File_exports.File, data.subject),
53
- component: ({ data, role }) => /* @__PURE__ */ React2.createElement(FileContainer, {
54
- role,
55
- subject: data.subject
56
- })
57
- }),
58
- Common.createSurface({
59
- id: `${meta.id}/create-form`,
60
- role: "form-input",
61
- filter: (data) => {
62
- const annotation = findAnnotation2(data.schema.ast, WnfsAction.UploadAnnotationId);
63
- return !!annotation;
64
- },
65
- component: ({ data: { schema }, ...props }) => {
66
- const inputProps = props;
67
- const handleChange = useCallback2((file) => inputProps.onValueChange?.(inputProps.type, file), [
68
- inputProps.type,
69
- inputProps.onValueChange
70
- ]);
71
- return /* @__PURE__ */ React2.createElement(FileInput, {
72
- schema,
73
- onChange: handleChange
74
- });
75
- }
76
- })
77
- ])));
78
- export {
79
- react_surface_default as default
80
- };
81
- //# sourceMappingURL=react-surface-UNAYSIAC.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/react-surface/react-surface.tsx", "../../../src/components/index.ts", "../../../src/components/FileInput.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport type * as Schema from 'effect/Schema';\nimport React, { useCallback } from 'react';\n\nimport { Capability, Common } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\nimport { findAnnotation } from '@dxos/effect';\nimport { type FormFieldComponentProps } from '@dxos/react-ui-form';\n\nimport { FileContainer, FileInput } from '../../components';\nimport { meta } from '../../meta';\nimport { WnfsAction, WnfsFile } from '../../types';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(Common.Capability.ReactSurface, [\n Common.createSurface({\n id: `${meta.id}/article`,\n role: ['article', 'section', 'slide'],\n filter: (data): data is { subject: WnfsFile.File } => Obj.instanceOf(WnfsFile.File, data.subject),\n component: ({ data, role }) => <FileContainer role={role} subject={data.subject} />,\n }),\n Common.createSurface({\n id: `${meta.id}/create-form`,\n role: 'form-input',\n filter: (data): data is { prop: string; schema: Schema.Schema.Any } => {\n const annotation = findAnnotation<boolean>(\n (data.schema as Schema.Schema.All).ast,\n WnfsAction.UploadAnnotationId,\n );\n return !!annotation;\n },\n component: ({ data: { schema }, ...props }) => {\n const inputProps = props as unknown as FormFieldComponentProps;\n const handleChange = useCallback(\n (file: File) => inputProps.onValueChange?.(inputProps.type, file),\n [inputProps.type, inputProps.onValueChange],\n );\n\n return <FileInput schema={schema} onChange={handleChange} />;\n },\n }),\n ]),\n ),\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport const FileContainer = lazy(() => import('./FileContainer'));\n\nexport * from './FileInput';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * 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',\n isDragReject && 'border-roseFill',\n )}\n >\n <input {...getInputProps()} />\n {acceptedFiles[0] ? <p>{acceptedFiles[0].name}</p> : <p>{t('file input placeholder')}</p>}\n </div>\n );\n};\n"],
5
- "mappings": ";;;;;;;AAIA,YAAYA,YAAY;AAExB,OAAOC,UAASC,eAAAA,oBAAmB;AAEnC,SAASC,YAAYC,cAAc;AACnC,SAASC,WAAW;AACpB,SAASC,kBAAAA,uBAAsB;;;ACN/B,SAASC,YAAY;;;ACCrB,OAAOC,SAASC,mBAAmB;AACnC,SAASC,mBAAmB;AAE5B,SAASC,sBAAsB;AAC/B,SAASC,sBAAsB;AAC/B,SAASC,UAAU;AAUZ,IAAMC,YAAY,CAAC,EAAEC,QAAQC,SAAQ,MAAkB;AAC5D,QAAM,EAAEC,EAAC,IAAKC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,EAAEW,OAAM,GAAI,GAAGI,MAAAA,MAAO;AACxC,YAAMC,aAAaD;AACnB,YAAME,eAAeC,aACnB,CAACC,SAAeH,WAAWI,gBAAgBJ,WAAWK,MAAMF,IAAAA,GAC5D;QAACH,WAAWK;QAAML,WAAWI;OAAc;AAG7C,aAAO,gBAAAb,OAAA,cAACe,WAAAA;QAAUX;QAAgBY,UAAUN;;IAC9C;EACF,CAAA;CACD,CAAA,CAAA;",
6
- "names": ["Effect", "React", "useCallback", "Capability", "Common", "Obj", "findAnnotation", "lazy", "React", "useCallback", "useDropzone", "findAnnotation", "useTranslation", "mx", "FileInput", "schema", "onChange", "t", "useTranslation", "meta", "id", "accept", "findAnnotation", "ast", "WnfsAction", "UploadAnnotationId", "onDropAccepted", "useCallback", "files", "acceptedFiles", "getRootProps", "getInputProps", "isFocused", "isDragAccept", "isDragReject", "useDropzone", "multiple", "div", "className", "mx", "input", "p", "name", "FileContainer", "lazy", "Capability", "makeModule", "succeed", "contributes", "Common", "ReactSurface", "createSurface", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "WnfsFile", "File", "subject", "component", "React", "FileContainer", "annotation", "findAnnotation", "schema", "ast", "WnfsAction", "UploadAnnotationId", "props", "inputProps", "handleChange", "useCallback", "file", "onValueChange", "type", "FileInput", "onChange"]
7
- }
@@ -1,5 +0,0 @@
1
- import * as Effect from 'effect/Effect';
2
- import { Capability } from '@dxos/app-framework';
3
- declare const _default: (props?: void | undefined) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<import("interface-blockstore").Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>>>, Error, Capability.Service>;
4
- export default _default;
5
- //# sourceMappingURL=blockstore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blockstore.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/blockstore/blockstore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;;AAMjD,wBASE"}
@@ -1,3 +0,0 @@
1
- import { Capability } from '@dxos/app-framework';
2
- export declare const Blockstore: Capability.LazyCapability<void, Capability.Capability<Capability.InterfaceDef<import("interface-blockstore").Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>>>, Error>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/blockstore/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,UAAU,mKAA8D,CAAC"}
@@ -1,5 +0,0 @@
1
- import * as Effect from 'effect/Effect';
2
- import { Capability, Common } from '@dxos/app-framework';
3
- declare const _default: (props?: void | undefined) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<Common.Capability.FileUploader>>, never, Capability.Service>;
4
- export default _default;
5
- //# sourceMappingURL=file-uploader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-uploader.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/file-uploader/file-uploader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;;AAMzD,wBAoBE"}
@@ -1,3 +0,0 @@
1
- import { Capability } from '@dxos/app-framework';
2
- export declare const FileUploader: Capability.LazyCapability<void, Capability.Capability<Capability.InterfaceDef<import("@dxos/app-framework/Common").Capability.FileUploader>>, Error>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/file-uploader/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,YAAY,sJAAmE,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Capability } from '@dxos/app-framework';
2
- export declare const Markdown: Capability.LazyCapability<void, Capability.Capability<Capability.InterfaceDef<import("@dxos/plugin-markdown").MarkdownExtensionProvider[]>>, Error>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/markdown/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,QAAQ,qJAA0D,CAAC"}
@@ -1,5 +0,0 @@
1
- import * as Effect from 'effect/Effect';
2
- import { Capability } from '@dxos/app-framework';
3
- declare const _default: (props?: void | undefined) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<import("@dxos/plugin-markdown").MarkdownExtensionProvider[]>>, never, Capability.Service>;
4
- export default _default;
5
- //# sourceMappingURL=markdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/markdown/markdown.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;;AAOjD,wBAmBE"}
@@ -1,3 +0,0 @@
1
- import { Capability } from '@dxos/app-framework';
2
- export declare const OperationResolver: Capability.LazyCapability<void, Capability.Capability<Capability.InterfaceDef<import("@dxos/app-framework/Common").Capability.OperationResolver[]>>, Error>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/operation-resolver/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,6JAA6E,CAAC"}
@@ -1,5 +0,0 @@
1
- import * as Effect from 'effect/Effect';
2
- import { Capability, Common } from '@dxos/app-framework';
3
- declare const _default: (props?: void | undefined) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<Common.Capability.OperationResolver[]>>, never, never>;
4
- export default _default;
5
- //# sourceMappingURL=operation-resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operation-resolver.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/operation-resolver/operation-resolver.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;;AAUzD,wBA6CE"}
@@ -1,3 +0,0 @@
1
- import { Capability } from '@dxos/app-framework';
2
- export declare const ReactSurface: Capability.LazyCapability<void, Capability.Capability<Capability.InterfaceDef<import("@dxos/app-framework/Common").Capability.ReactSurface>>, Error>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/react-surface/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,YAAY,sJAAmE,CAAC"}
@@ -1,5 +0,0 @@
1
- import * as Effect from 'effect/Effect';
2
- import { Capability, Common } from '@dxos/app-framework';
3
- declare const _default: (props?: void | undefined) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<Common.Capability.ReactSurface>>, never, never>;
4
- export default _default;
5
- //# sourceMappingURL=react-surface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/react-surface/react-surface.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;;AASzD,wBA+BE"}
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { type SurfaceComponentProps } from '@dxos/app-framework/react';
3
- import { type WnfsFile } from '../types';
4
- export type FileContainerProps = SurfaceComponentProps<WnfsFile.File>;
5
- export declare const FileContainer: ({ role, subject: file }: FileContainerProps) => React.JSX.Element | null;
6
- export default FileContainer;
7
- //# sourceMappingURL=FileContainer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/FileContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,KAAK,qBAAqB,EAAiB,MAAM,2BAA2B,CAAC;AAQtF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAEtE,eAAO,MAAM,aAAa,GAAI,yBAAyB,kBAAkB,6BAiCxE,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../../../src/components/FileInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAsB,MAAM,OAAO,CAAC;AAU3C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,sBAAsB,cAAc,sBA0B7D,CAAC"}
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { type ThemedClassName } from '@dxos/react-ui';
3
- export type FilePreviewProps = ThemedClassName<{
4
- type: string;
5
- url: string;
6
- }>;
7
- /**
8
- * File/content preview iframe.
9
- */
10
- export declare const FilePreview: ({ type, url, classNames }: FilePreviewProps) => React.JSX.Element;
11
- //# sourceMappingURL=FilePreview.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../src/components/FilePreview.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,2BAA2B,gBAAgB,sBAQtE,CAAC"}
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const Blockstore = Capability.lazy('Blockstore', () => import('./blockstore'));
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const FileUploader = Capability.lazy('FileUploader', () => import('./file-uploader'));
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capability } from '@dxos/app-framework';
6
-
7
- export const Markdown = Capability.lazy('Markdown', () => import('./markdown'));