@fungi.computer/inkcap 0.0.1 → 0.1.0
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/backend/methods.ts +22 -0
- package/backend/test/present.test.ts +25 -0
- package/dist/assets/{FileTab-bwd_G6y3.js → FileTab-B9q_XVEC.js} +1 -1
- package/dist/assets/{InkcapFileTree-Cx3HsaWr.js → InkcapFileTree-CdYnx2Jy.js} +1 -1
- package/dist/assets/{index-BNEzthyN.js → index-Iod2z-L_.js} +60 -60
- package/dist/assets/index-nLv8PMRJ.css +2 -0
- package/dist/index.html +2 -2
- package/package.json +7 -7
- package/dist/assets/index-ByFi_OY2.css +0 -2
package/backend/methods.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resultRows } from "@fungi.computer/agar/method-presentation";
|
|
1
2
|
import { recentFilesGill } from "./gills.js";
|
|
2
3
|
import {
|
|
3
4
|
documentIdentitySchema,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
type DocumentActivityStore,
|
|
12
13
|
} from "./document-activity.js";
|
|
13
14
|
import * as z from "zod";
|
|
15
|
+
import { filesNavigateIntent } from "@fungi.computer/agar/roles/files";
|
|
14
16
|
import type { AppMethodCallContext } from "@fungi.computer/puffball/app-method-runtime";
|
|
15
17
|
import {
|
|
16
18
|
defineAppBackend,
|
|
@@ -185,6 +187,26 @@ export const appBackend = defineAppBackend({
|
|
|
185
187
|
requires: ["computer.writeFile"],
|
|
186
188
|
input: writeInput,
|
|
187
189
|
output: writeReply,
|
|
190
|
+
present: {
|
|
191
|
+
rows: resultRows,
|
|
192
|
+
verb: "wrote",
|
|
193
|
+
row: ({ output }) =>
|
|
194
|
+
"error" in output
|
|
195
|
+
? {
|
|
196
|
+
id: "refused",
|
|
197
|
+
title: "Inkcap could not write the file",
|
|
198
|
+
detail: output.error,
|
|
199
|
+
tone: "error",
|
|
200
|
+
}
|
|
201
|
+
: {
|
|
202
|
+
id: output.path,
|
|
203
|
+
title: `Inkcap wrote ${output.path.split("/").at(-1) ?? output.path}`,
|
|
204
|
+
detail: `${output.path} · ${String(output.bytes)} bytes`,
|
|
205
|
+
open: {
|
|
206
|
+
params: filesNavigateIntent({ path: output.path }).params,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
},
|
|
188
210
|
handler: async (input, context: InkcapBackendContext, caller) =>
|
|
189
211
|
caller.computerId === null || !context.env.COMPUTER?.write
|
|
190
212
|
? refusal.parse({ error: "not_granted" })
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expect, it } from "vitest";
|
|
2
|
+
import { appBackend } from "../methods.js";
|
|
3
|
+
|
|
4
|
+
it("reads a written file as a row that opens it in Inkcap", () => {
|
|
5
|
+
expect(
|
|
6
|
+
appBackend.methods.writeFile?.present?.(
|
|
7
|
+
{ path: "/storyboard/storyboard.md", content: "# Panels" },
|
|
8
|
+
{ path: "/storyboard/storyboard.md", bytes: 8 },
|
|
9
|
+
),
|
|
10
|
+
).toEqual({
|
|
11
|
+
id: "/storyboard/storyboard.md",
|
|
12
|
+
title: "Inkcap wrote storyboard.md",
|
|
13
|
+
detail: "/storyboard/storyboard.md · 8 bytes",
|
|
14
|
+
open: { params: [{ key: "path", value: "/storyboard/storyboard.md" }] },
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("reads a refused write as an error row", () => {
|
|
19
|
+
expect(
|
|
20
|
+
appBackend.methods.writeFile?.present?.(
|
|
21
|
+
{ path: "/a.md", content: "x" },
|
|
22
|
+
{ error: "not_granted" },
|
|
23
|
+
),
|
|
24
|
+
).toMatchObject({ title: "Inkcap could not write the file", tone: "error" });
|
|
25
|
+
});
|