@immediately-run/sdk 0.72.0 → 0.74.1
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/dnd.cjs +2 -5
- package/dist/dnd.cjs.map +1 -1
- package/dist/dnd.d.cts +8 -1
- package/dist/dnd.d.ts +8 -1
- package/dist/dnd.js +2 -5
- package/dist/dnd.js.map +1 -1
- package/dist/editor.cjs +2 -5
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.d.cts +34 -5
- package/dist/editor.d.ts +34 -5
- package/dist/editor.js +2 -5
- package/dist/editor.js.map +1 -1
- package/dist/generated/spaces.cjs +40 -0
- package/dist/generated/spaces.cjs.map +1 -1
- package/dist/generated/spaces.d.cts +96 -1
- package/dist/generated/spaces.d.ts +96 -1
- package/dist/generated/spaces.js +35 -0
- package/dist/generated/spaces.js.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/ipc.cjs +3 -10
- package/dist/ipc.cjs.map +1 -1
- package/dist/ipc.js +3 -10
- package/dist/ipc.js.map +1 -1
- package/dist/llm.cjs.map +1 -1
- package/dist/llm.d.cts +14 -0
- package/dist/llm.d.ts +14 -0
- package/dist/llm.js.map +1 -1
- package/dist/mounts.cjs +14 -15
- package/dist/mounts.cjs.map +1 -1
- package/dist/mounts.d.cts +9 -2
- package/dist/mounts.d.ts +9 -2
- package/dist/mounts.js +15 -16
- package/dist/mounts.js.map +1 -1
- package/dist/openExternal.cjs +2 -7
- package/dist/openExternal.cjs.map +1 -1
- package/dist/openExternal.d.cts +7 -1
- package/dist/openExternal.d.ts +7 -1
- package/dist/openExternal.js +2 -7
- package/dist/openExternal.js.map +1 -1
- package/dist/openRepository.cjs +2 -7
- package/dist/openRepository.cjs.map +1 -1
- package/dist/openRepository.d.cts +7 -1
- package/dist/openRepository.d.ts +7 -1
- package/dist/openRepository.js +2 -7
- package/dist/openRepository.js.map +1 -1
- package/dist/protocolRefusal.cjs +35 -0
- package/dist/protocolRefusal.cjs.map +1 -0
- package/dist/protocolRefusal.d.cts +54 -0
- package/dist/protocolRefusal.d.ts +54 -0
- package/dist/protocolRefusal.js +12 -0
- package/dist/protocolRefusal.js.map +1 -0
- package/dist/protocolSchemes.cjs +1 -0
- package/dist/protocolSchemes.cjs.map +1 -1
- package/dist/protocolSchemes.d.cts +1 -0
- package/dist/protocolSchemes.d.ts +1 -0
- package/dist/protocolSchemes.js +2 -0
- package/dist/protocolSchemes.js.map +1 -1
- package/dist/secrets.cjs +2 -5
- package/dist/secrets.cjs.map +1 -1
- package/dist/secrets.d.cts +8 -1
- package/dist/secrets.d.ts +8 -1
- package/dist/secrets.js +2 -5
- package/dist/secrets.js.map +1 -1
- package/dist/spacesMode.cjs +101 -0
- package/dist/spacesMode.cjs.map +1 -0
- package/dist/spacesMode.d.cts +149 -0
- package/dist/spacesMode.d.ts +149 -0
- package/dist/spacesMode.js +75 -0
- package/dist/spacesMode.js.map +1 -0
- package/dist/vcs.cjs +2 -5
- package/dist/vcs.cjs.map +1 -1
- package/dist/vcs.d.cts +8 -1
- package/dist/vcs.d.ts +8 -1
- package/dist/vcs.js +2 -5
- package/dist/vcs.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +4 -3
package/dist/dnd.cjs
CHANGED
|
@@ -25,16 +25,13 @@ __export(dnd_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(dnd_exports);
|
|
27
27
|
var import_react = require("react");
|
|
28
|
+
var import_protocolRefusal = require("./protocolRefusal");
|
|
28
29
|
var import_sandboxUtils = require("./sandboxUtils");
|
|
29
30
|
var import_protocol = require("./generated/protocol");
|
|
30
31
|
var import_protocolSchemes = require("./protocolSchemes");
|
|
31
32
|
const startItemDrag = async (item) => {
|
|
32
33
|
const res = await (0, import_sandboxUtils.protocolRequest)(import_protocolSchemes.SCHEMES[import_protocol.PROTOCOL_DND], "startDrag", [item]);
|
|
33
|
-
|
|
34
|
-
const err = new Error(res?.message ?? "dnd startDrag failed");
|
|
35
|
-
err.code = res?.code ?? "unknown";
|
|
36
|
-
throw err;
|
|
37
|
-
}
|
|
34
|
+
(0, import_protocolRefusal.throwOnRefusal)(res, "dnd startDrag failed");
|
|
38
35
|
};
|
|
39
36
|
const cancelItemDrag = () => {
|
|
40
37
|
(0, import_sandboxUtils.sendMessage)(import_protocol.DND_CANCEL, {});
|
package/dist/dnd.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dnd.ts"],"sourcesContent":["// Cross-app drag-out (FILE_EXPLORER_SPEC §7; UI_AS_APPS_SPEC §2 host-mediated).\n//\n// Native HTML5 drag-and-drop does NOT cross the sandboxed cross-origin iframe\n// boundary, and pointer events inside one app's iframe never reach the host or a\n// sibling. So a drag that STARTS in one app (the file explorer) and ENDS over\n// another (the previewed app) can only be mediated by the host (the TCB). This\n// module is the SDK surface for that one net-new platform primitive:\n//\n// - SOURCE side (the file explorer, needs the first-party `dnd:source` cap):\n// `startItemDrag(item)` asks the host to begin a host-mediated drag carrying a\n// file/dir reference (+ optional inlined bytes for a small file). The host draws\n// the trusted drag ghost, tracks the pointer across regions, and on drop over the\n// preview delivers the item to that app. `cancelItemDrag()` aborts.\n// - RECEIVER side (the previewed app, NO new grant — it opts in by subscribing):\n// `onItemDrop(cb)` / `useDroppedItem()` deliver the dropped item with host-attached,\n// unspoofable provenance (`from` = source region id) and the drop position.\n//\n// The payload is UNTRUSTED app data (CLAUDE.md §5): the host attaches `from`; the app\n// validates everything else. v1 inlines bytes only for small files (the source can\n// only relay data it can already read — no new read authority is minted).\nimport { useEffect, useState } from 'react';\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport { DND_CANCEL, DROPPED_ITEM, PROTOCOL_DND } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** A file/dir being dragged out of an app. `bytes` is present only for a small file\n * the source chose to inline (transferred zero-copy); a dir or an over-cap file\n * carries the reference only (`kind`/`name`/`mountId`/`relPath`). */\nexport interface DraggableItem {\n kind: 'file' | 'dir';\n /** Basename — display only. */\n name: string;\n /** Which mounted filesystem the item lives in. */\n mountId: string;\n /** Path within that mount (leading slash, no `..`). */\n relPath: string;\n /** Optional inlined content for a small file. */\n bytes?: Uint8Array;\n}\n\n/** An item dropped onto THIS app by a host-mediated cross-app drag. */\nexport interface DroppedItem {\n /** The dragged item (`bytes` present iff the source inlined them). */\n item: DraggableItem;\n /** Host-attached source region id — unspoofable (T19), like an `ipc` `from`. */\n from: string;\n /** Drop point in this app's viewport. */\n position: { x: number; y: number };\n}\n\n/** An error from {@link startItemDrag}, carrying a machine-readable `.code`. */\nexport interface ItemDragError extends Error {\n code:\n | 'forbidden' // the frame lacks the first-party `dnd:source` capability\n | 'invalid-params' // the item was malformed (empty path / `..` / URI / bad kind)\n | 'too-large' // inlined `bytes` exceed the host's size limit\n | 'rate-limited' // too many drags started too fast (capacity-class, fail-open)\n | 'unknown';\n}\n\n/**\n * Begin a host-mediated drag of `item` out of this app. Resolves once the host has\n * taken over the drag (drawn the ghost, installed the pointer-capture layer); rejects\n * with an {@link ItemDragError} if this app may not initiate drags (`forbidden`) or the\n * item is invalid. Only a first-party chrome app holding `dnd:source` may call this — a\n * previewed/third-party app is refused at the gate (it must not synthesize drags into\n * sibling apps).\n */\nexport const startItemDrag = async (item: DraggableItem): Promise<void> => {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_DND], 'startDrag', [item])) as\n | { ok: true }\n | { ok: false; code?: string; message?: string }\n | undefined;\n
|
|
1
|
+
{"version":3,"sources":["../src/dnd.ts"],"sourcesContent":["// Cross-app drag-out (FILE_EXPLORER_SPEC §7; UI_AS_APPS_SPEC §2 host-mediated).\n//\n// Native HTML5 drag-and-drop does NOT cross the sandboxed cross-origin iframe\n// boundary, and pointer events inside one app's iframe never reach the host or a\n// sibling. So a drag that STARTS in one app (the file explorer) and ENDS over\n// another (the previewed app) can only be mediated by the host (the TCB). This\n// module is the SDK surface for that one net-new platform primitive:\n//\n// - SOURCE side (the file explorer, needs the first-party `dnd:source` cap):\n// `startItemDrag(item)` asks the host to begin a host-mediated drag carrying a\n// file/dir reference (+ optional inlined bytes for a small file). The host draws\n// the trusted drag ghost, tracks the pointer across regions, and on drop over the\n// preview delivers the item to that app. `cancelItemDrag()` aborts.\n// - RECEIVER side (the previewed app, NO new grant — it opts in by subscribing):\n// `onItemDrop(cb)` / `useDroppedItem()` deliver the dropped item with host-attached,\n// unspoofable provenance (`from` = source region id) and the drop position.\n//\n// The payload is UNTRUSTED app data (CLAUDE.md §5): the host attaches `from`; the app\n// validates everything else. v1 inlines bytes only for small files (the source can\n// only relay data it can already read — no new read authority is minted).\nimport { useEffect, useState } from 'react';\nimport { throwOnRefusal } from './protocolRefusal';\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport { DND_CANCEL, DROPPED_ITEM, PROTOCOL_DND } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** A file/dir being dragged out of an app. `bytes` is present only for a small file\n * the source chose to inline (transferred zero-copy); a dir or an over-cap file\n * carries the reference only (`kind`/`name`/`mountId`/`relPath`). */\nexport interface DraggableItem {\n kind: 'file' | 'dir';\n /** Basename — display only. */\n name: string;\n /** Which mounted filesystem the item lives in. */\n mountId: string;\n /** Path within that mount (leading slash, no `..`). */\n relPath: string;\n /** Optional inlined content for a small file. */\n bytes?: Uint8Array;\n}\n\n/** An item dropped onto THIS app by a host-mediated cross-app drag. */\nexport interface DroppedItem {\n /** The dragged item (`bytes` present iff the source inlined them). */\n item: DraggableItem;\n /** Host-attached source region id — unspoofable (T19), like an `ipc` `from`. */\n from: string;\n /** Drop point in this app's viewport. */\n position: { x: number; y: number };\n}\n\n/** An error from {@link startItemDrag}, carrying a machine-readable `.code`.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n * documents the `.code` VALUES the host sends; it was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test.\n */\nexport interface ItemDragError extends Error {\n code:\n | 'forbidden' // the frame lacks the first-party `dnd:source` capability\n | 'invalid-params' // the item was malformed (empty path / `..` / URI / bad kind)\n | 'too-large' // inlined `bytes` exceed the host's size limit\n | 'rate-limited' // too many drags started too fast (capacity-class, fail-open)\n | 'unknown';\n}\n\n/**\n * Begin a host-mediated drag of `item` out of this app. Resolves once the host has\n * taken over the drag (drawn the ghost, installed the pointer-capture layer); rejects\n * with an {@link ItemDragError} if this app may not initiate drags (`forbidden`) or the\n * item is invalid. Only a first-party chrome app holding `dnd:source` may call this — a\n * previewed/third-party app is refused at the gate (it must not synthesize drags into\n * sibling apps).\n */\nexport const startItemDrag = async (item: DraggableItem): Promise<void> => {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_DND], 'startDrag', [item])) as\n | { ok: true }\n | { ok: false; code?: string; message?: string }\n | undefined;\n throwOnRefusal(res, 'dnd startDrag failed');\n};\n\n/** Abort an in-progress host-mediated drag this app started (e.g. the user pressed\n * Escape, or the gesture was cancelled). Best-effort and fire-and-forget. */\nexport const cancelItemDrag = (): void => {\n sendMessage(DND_CANCEL, {});\n};\n\n/** Subscribe to items dropped onto this app by a host-mediated cross-app drag.\n * Returns an unsubscribe fn. Subscribing is the opt-in: an app that never subscribes\n * receives nothing (the host shows a \"not accepted\" cue and the drop is a no-op). */\nexport const onItemDrop = (listener: (d: DroppedItem) => void): (() => void) =>\n addListener(DROPPED_ITEM, (m: { item: DraggableItem; from: string; position: { x: number; y: number } }) =>\n listener({ item: m.item, from: m.from, position: m.position }),\n );\n\n/** React hook: the most recently dropped item (or `null`). */\nexport const useDroppedItem = (): DroppedItem | null => {\n const [dropped, setDropped] = useState<DroppedItem | null>(null);\n useEffect(() => onItemDrop(setDropped), []);\n return dropped;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBA,mBAAoC;AACpC,6BAA+B;AAC/B,0BAA0D;AAC1D,sBAAuD;AACvD,6BAAwB;AAoDjB,MAAM,gBAAgB,OAAO,SAAuC;AACzE,QAAM,MAAO,UAAM,qCAAgB,+BAAQ,4BAAY,GAAG,aAAa,CAAC,IAAI,CAAC;AAI7E,6CAAe,KAAK,sBAAsB;AAC5C;AAIO,MAAM,iBAAiB,MAAY;AACxC,uCAAY,4BAAY,CAAC,CAAC;AAC5B;AAKO,MAAM,aAAa,CAAC,iBACzB;AAAA,EAAY;AAAA,EAAc,CAAC,MACzB,SAAS,EAAE,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,UAAU,EAAE,SAAS,CAAC;AAC/D;AAGK,MAAM,iBAAiB,MAA0B;AACtD,QAAM,CAAC,SAAS,UAAU,QAAI,uBAA6B,IAAI;AAC/D,8BAAU,MAAM,WAAW,UAAU,GAAG,CAAC,CAAC;AAC1C,SAAO;AACT;","names":[]}
|
package/dist/dnd.d.cts
CHANGED
|
@@ -24,7 +24,14 @@ interface DroppedItem {
|
|
|
24
24
|
y: number;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
/** An error from {@link startItemDrag}, carrying a machine-readable `.code`.
|
|
27
|
+
/** An error from {@link startItemDrag}, carrying a machine-readable `.code`.
|
|
28
|
+
*
|
|
29
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
30
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface
|
|
31
|
+
* documents the `.code` VALUES the host sends; it was always a cast and is not enforced at
|
|
32
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
33
|
+
* reliable test.
|
|
34
|
+
*/
|
|
28
35
|
interface ItemDragError extends Error {
|
|
29
36
|
code: 'forbidden' | 'invalid-params' | 'too-large' | 'rate-limited' | 'unknown';
|
|
30
37
|
}
|
package/dist/dnd.d.ts
CHANGED
|
@@ -24,7 +24,14 @@ interface DroppedItem {
|
|
|
24
24
|
y: number;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
/** An error from {@link startItemDrag}, carrying a machine-readable `.code`.
|
|
27
|
+
/** An error from {@link startItemDrag}, carrying a machine-readable `.code`.
|
|
28
|
+
*
|
|
29
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
30
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface
|
|
31
|
+
* documents the `.code` VALUES the host sends; it was always a cast and is not enforced at
|
|
32
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
33
|
+
* reliable test.
|
|
34
|
+
*/
|
|
28
35
|
interface ItemDragError extends Error {
|
|
29
36
|
code: 'forbidden' | 'invalid-params' | 'too-large' | 'rate-limited' | 'unknown';
|
|
30
37
|
}
|
package/dist/dnd.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import "./chunk-VHAA22YE.js";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
+
import { throwOnRefusal } from "./protocolRefusal.js";
|
|
3
4
|
import { protocolRequest, sendMessage, addListener } from "./sandboxUtils.js";
|
|
4
5
|
import { DND_CANCEL, DROPPED_ITEM, PROTOCOL_DND } from "./generated/protocol.js";
|
|
5
6
|
import { SCHEMES } from "./protocolSchemes.js";
|
|
6
7
|
const startItemDrag = async (item) => {
|
|
7
8
|
const res = await protocolRequest(SCHEMES[PROTOCOL_DND], "startDrag", [item]);
|
|
8
|
-
|
|
9
|
-
const err = new Error(res?.message ?? "dnd startDrag failed");
|
|
10
|
-
err.code = res?.code ?? "unknown";
|
|
11
|
-
throw err;
|
|
12
|
-
}
|
|
9
|
+
throwOnRefusal(res, "dnd startDrag failed");
|
|
13
10
|
};
|
|
14
11
|
const cancelItemDrag = () => {
|
|
15
12
|
sendMessage(DND_CANCEL, {});
|
package/dist/dnd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dnd.ts"],"sourcesContent":["// Cross-app drag-out (FILE_EXPLORER_SPEC §7; UI_AS_APPS_SPEC §2 host-mediated).\n//\n// Native HTML5 drag-and-drop does NOT cross the sandboxed cross-origin iframe\n// boundary, and pointer events inside one app's iframe never reach the host or a\n// sibling. So a drag that STARTS in one app (the file explorer) and ENDS over\n// another (the previewed app) can only be mediated by the host (the TCB). This\n// module is the SDK surface for that one net-new platform primitive:\n//\n// - SOURCE side (the file explorer, needs the first-party `dnd:source` cap):\n// `startItemDrag(item)` asks the host to begin a host-mediated drag carrying a\n// file/dir reference (+ optional inlined bytes for a small file). The host draws\n// the trusted drag ghost, tracks the pointer across regions, and on drop over the\n// preview delivers the item to that app. `cancelItemDrag()` aborts.\n// - RECEIVER side (the previewed app, NO new grant — it opts in by subscribing):\n// `onItemDrop(cb)` / `useDroppedItem()` deliver the dropped item with host-attached,\n// unspoofable provenance (`from` = source region id) and the drop position.\n//\n// The payload is UNTRUSTED app data (CLAUDE.md §5): the host attaches `from`; the app\n// validates everything else. v1 inlines bytes only for small files (the source can\n// only relay data it can already read — no new read authority is minted).\nimport { useEffect, useState } from 'react';\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport { DND_CANCEL, DROPPED_ITEM, PROTOCOL_DND } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** A file/dir being dragged out of an app. `bytes` is present only for a small file\n * the source chose to inline (transferred zero-copy); a dir or an over-cap file\n * carries the reference only (`kind`/`name`/`mountId`/`relPath`). */\nexport interface DraggableItem {\n kind: 'file' | 'dir';\n /** Basename — display only. */\n name: string;\n /** Which mounted filesystem the item lives in. */\n mountId: string;\n /** Path within that mount (leading slash, no `..`). */\n relPath: string;\n /** Optional inlined content for a small file. */\n bytes?: Uint8Array;\n}\n\n/** An item dropped onto THIS app by a host-mediated cross-app drag. */\nexport interface DroppedItem {\n /** The dragged item (`bytes` present iff the source inlined them). */\n item: DraggableItem;\n /** Host-attached source region id — unspoofable (T19), like an `ipc` `from`. */\n from: string;\n /** Drop point in this app's viewport. */\n position: { x: number; y: number };\n}\n\n/** An error from {@link startItemDrag}, carrying a machine-readable `.code`. */\nexport interface ItemDragError extends Error {\n code:\n | 'forbidden' // the frame lacks the first-party `dnd:source` capability\n | 'invalid-params' // the item was malformed (empty path / `..` / URI / bad kind)\n | 'too-large' // inlined `bytes` exceed the host's size limit\n | 'rate-limited' // too many drags started too fast (capacity-class, fail-open)\n | 'unknown';\n}\n\n/**\n * Begin a host-mediated drag of `item` out of this app. Resolves once the host has\n * taken over the drag (drawn the ghost, installed the pointer-capture layer); rejects\n * with an {@link ItemDragError} if this app may not initiate drags (`forbidden`) or the\n * item is invalid. Only a first-party chrome app holding `dnd:source` may call this — a\n * previewed/third-party app is refused at the gate (it must not synthesize drags into\n * sibling apps).\n */\nexport const startItemDrag = async (item: DraggableItem): Promise<void> => {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_DND], 'startDrag', [item])) as\n | { ok: true }\n | { ok: false; code?: string; message?: string }\n | undefined;\n
|
|
1
|
+
{"version":3,"sources":["../src/dnd.ts"],"sourcesContent":["// Cross-app drag-out (FILE_EXPLORER_SPEC §7; UI_AS_APPS_SPEC §2 host-mediated).\n//\n// Native HTML5 drag-and-drop does NOT cross the sandboxed cross-origin iframe\n// boundary, and pointer events inside one app's iframe never reach the host or a\n// sibling. So a drag that STARTS in one app (the file explorer) and ENDS over\n// another (the previewed app) can only be mediated by the host (the TCB). This\n// module is the SDK surface for that one net-new platform primitive:\n//\n// - SOURCE side (the file explorer, needs the first-party `dnd:source` cap):\n// `startItemDrag(item)` asks the host to begin a host-mediated drag carrying a\n// file/dir reference (+ optional inlined bytes for a small file). The host draws\n// the trusted drag ghost, tracks the pointer across regions, and on drop over the\n// preview delivers the item to that app. `cancelItemDrag()` aborts.\n// - RECEIVER side (the previewed app, NO new grant — it opts in by subscribing):\n// `onItemDrop(cb)` / `useDroppedItem()` deliver the dropped item with host-attached,\n// unspoofable provenance (`from` = source region id) and the drop position.\n//\n// The payload is UNTRUSTED app data (CLAUDE.md §5): the host attaches `from`; the app\n// validates everything else. v1 inlines bytes only for small files (the source can\n// only relay data it can already read — no new read authority is minted).\nimport { useEffect, useState } from 'react';\nimport { throwOnRefusal } from './protocolRefusal';\nimport { protocolRequest, sendMessage, addListener } from './sandboxUtils';\nimport { DND_CANCEL, DROPPED_ITEM, PROTOCOL_DND } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** A file/dir being dragged out of an app. `bytes` is present only for a small file\n * the source chose to inline (transferred zero-copy); a dir or an over-cap file\n * carries the reference only (`kind`/`name`/`mountId`/`relPath`). */\nexport interface DraggableItem {\n kind: 'file' | 'dir';\n /** Basename — display only. */\n name: string;\n /** Which mounted filesystem the item lives in. */\n mountId: string;\n /** Path within that mount (leading slash, no `..`). */\n relPath: string;\n /** Optional inlined content for a small file. */\n bytes?: Uint8Array;\n}\n\n/** An item dropped onto THIS app by a host-mediated cross-app drag. */\nexport interface DroppedItem {\n /** The dragged item (`bytes` present iff the source inlined them). */\n item: DraggableItem;\n /** Host-attached source region id — unspoofable (T19), like an `ipc` `from`. */\n from: string;\n /** Drop point in this app's viewport. */\n position: { x: number; y: number };\n}\n\n/** An error from {@link startItemDrag}, carrying a machine-readable `.code`.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n * documents the `.code` VALUES the host sends; it was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test.\n */\nexport interface ItemDragError extends Error {\n code:\n | 'forbidden' // the frame lacks the first-party `dnd:source` capability\n | 'invalid-params' // the item was malformed (empty path / `..` / URI / bad kind)\n | 'too-large' // inlined `bytes` exceed the host's size limit\n | 'rate-limited' // too many drags started too fast (capacity-class, fail-open)\n | 'unknown';\n}\n\n/**\n * Begin a host-mediated drag of `item` out of this app. Resolves once the host has\n * taken over the drag (drawn the ghost, installed the pointer-capture layer); rejects\n * with an {@link ItemDragError} if this app may not initiate drags (`forbidden`) or the\n * item is invalid. Only a first-party chrome app holding `dnd:source` may call this — a\n * previewed/third-party app is refused at the gate (it must not synthesize drags into\n * sibling apps).\n */\nexport const startItemDrag = async (item: DraggableItem): Promise<void> => {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_DND], 'startDrag', [item])) as\n | { ok: true }\n | { ok: false; code?: string; message?: string }\n | undefined;\n throwOnRefusal(res, 'dnd startDrag failed');\n};\n\n/** Abort an in-progress host-mediated drag this app started (e.g. the user pressed\n * Escape, or the gesture was cancelled). Best-effort and fire-and-forget. */\nexport const cancelItemDrag = (): void => {\n sendMessage(DND_CANCEL, {});\n};\n\n/** Subscribe to items dropped onto this app by a host-mediated cross-app drag.\n * Returns an unsubscribe fn. Subscribing is the opt-in: an app that never subscribes\n * receives nothing (the host shows a \"not accepted\" cue and the drop is a no-op). */\nexport const onItemDrop = (listener: (d: DroppedItem) => void): (() => void) =>\n addListener(DROPPED_ITEM, (m: { item: DraggableItem; from: string; position: { x: number; y: number } }) =>\n listener({ item: m.item, from: m.from, position: m.position }),\n );\n\n/** React hook: the most recently dropped item (or `null`). */\nexport const useDroppedItem = (): DroppedItem | null => {\n const [dropped, setDropped] = useState<DroppedItem | null>(null);\n useEffect(() => onItemDrop(setDropped), []);\n return dropped;\n};\n"],"mappings":";AAoBA,SAAS,WAAW,gBAAgB;AACpC,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB,aAAa,mBAAmB;AAC1D,SAAS,YAAY,cAAc,oBAAoB;AACvD,SAAS,eAAe;AAoDjB,MAAM,gBAAgB,OAAO,SAAuC;AACzE,QAAM,MAAO,MAAM,gBAAgB,QAAQ,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC;AAI7E,iBAAe,KAAK,sBAAsB;AAC5C;AAIO,MAAM,iBAAiB,MAAY;AACxC,cAAY,YAAY,CAAC,CAAC;AAC5B;AAKO,MAAM,aAAa,CAAC,aACzB;AAAA,EAAY;AAAA,EAAc,CAAC,MACzB,SAAS,EAAE,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,UAAU,EAAE,SAAS,CAAC;AAC/D;AAGK,MAAM,iBAAiB,MAA0B;AACtD,QAAM,CAAC,SAAS,UAAU,IAAI,SAA6B,IAAI;AAC/D,YAAU,MAAM,WAAW,UAAU,GAAG,CAAC,CAAC;AAC1C,SAAO;AACT;","names":[]}
|
package/dist/editor.cjs
CHANGED
|
@@ -30,15 +30,12 @@ __export(editor_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(editor_exports);
|
|
32
32
|
var import_sandboxUtils = require("./sandboxUtils");
|
|
33
|
+
var import_protocolRefusal = require("./protocolRefusal");
|
|
33
34
|
var import_protocolSchemes = require("./protocolSchemes");
|
|
34
35
|
var import_protocol = require("./generated/protocol");
|
|
35
36
|
const editorRequest = async (method, arg) => {
|
|
36
37
|
const res = await (0, import_sandboxUtils.protocolRequest)(import_protocolSchemes.SCHEMES[import_protocol.PROTOCOL_EDITOR], method, [arg]);
|
|
37
|
-
|
|
38
|
-
const err = new Error(res?.message ?? `editor ${method} failed`);
|
|
39
|
-
err.code = res?.code ?? "unknown";
|
|
40
|
-
throw err;
|
|
41
|
-
}
|
|
38
|
+
(0, import_protocolRefusal.throwOnRefusal)(res, `editor ${method} failed`);
|
|
42
39
|
};
|
|
43
40
|
const openInEditor = (path, selection, opts) => editorRequest("open", {
|
|
44
41
|
path,
|
package/dist/editor.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/editor.ts"],"sourcesContent":["import { protocolRequest } from './sandboxUtils';\nimport { SCHEMES } from './protocolSchemes';\nimport { PROTOCOL_EDITOR } from './generated/protocol';\n\n/**\n * Open a working-tree file in the immediately.run host editor (UI_AS_APPS_SPEC §4 —\n * the file explorer's click-to-open). This is an INTENT: the app asks, the HOST\n * validates the path and drives the CodeMirror editor — the editor itself stays\n * host-owned (§2 recursion boundary), so an app can never own or script it beyond\n * \"please show this file\".\n *\n * Requires the elevated `editor:open` capability — a previewed app does not hold it\n * (it must not move the host's focus), so only a system app whose binding grants it\n * (the file explorer) can call this; anyone else is refused at the gate.\n */\n\n/** An error from {@link openInEditor}, carrying a machine-readable `.code`. */\nexport interface EditorOpenError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:open` (or `editor:reveal`, for a `reveal`)\n | 'not-found' // no such file in the live working tree (the host never creates)\n | 'invalid-params' // the path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session to open files in\n | 'unknown';\n}\n\ntype EditorResult = { ok: true; data: unknown } | { ok: false; code: string; message: string };\n\nconst editorRequest = async (method: string, arg: Record<string, unknown>): Promise<void> => {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_EDITOR], method, [arg])) as EditorResult;\n if (!res || res.ok !== true) {\n const err = new Error(res?.message ?? `editor ${method} failed`) as EditorWriteError;\n err.code = (res?.code as EditorWriteError['code']) ?? 'unknown';\n throw err;\n }\n};\n\n/** Where in a file to land when opening it (R3-388). 1-indexed `line`, matching every\n * diagnostic producer that feeds it (`tsc`, `eslint`, `BuildError`) and both VS Code\n * and IntelliJ. A `line` past end-of-file CLAMPS to the last line rather than\n * erroring — a diagnostic outlives the edit that shortened the file, and landing\n * close beats refusing to navigate. */\nexport interface EditorSelection {\n line: number;\n column?: number;\n}\n\n/** Options for {@link openInEditor} (R3-389). */\nexport interface EditorOpenOptions {\n /** Also bring the user to the editor, ACROSS activities (TOOLS_ACTIVITY_SPEC §5.2).\n * An app that owns the main pane (the Tools activity's runner sits where the editor\n * would) cannot rely on the file simply becoming visible — the editor is not on\n * screen — so this asks the host to switch to the activity that owns it.\n *\n * This is the elevated `editor:reveal` capability, not `editor:open`: a frame\n * without it is refused `forbidden` for the whole call (the file is NOT opened —\n * never silently opened-without-moving). The host decides whether the user actually\n * moves: it needs a real user gesture (a click in your frame within the last few\n * seconds counts; a call on a timer or on run completion does not) and is\n * rate-limited. The promise resolves the same either way, so treat a resolved\n * reveal as \"asked\", not \"moved\", and keep a visible fallback control. Where the\n * host owns the editor activity is host state; nothing here can name it. */\n reveal?: boolean;\n}\n\n/**\n * Ask the host to open `path` (a repo-relative working-tree path, e.g. `src/App.tsx`\n * or `/src/App.tsx`) in the editor. Resolves once the editor switches to it; rejects\n * with an {@link EditorOpenError} (`.code`) if the path is invalid, missing, or this\n * app may not open files.\n *\n * Pass `selection` to land the caret on a specific line — what a problems list needs\n * to make a diagnostic clickable. It widens nothing: a selection says where to look\n * inside a file the caller could already open, and the capability is unchanged\n * (`editor:open`).\n *\n * Pass `{ reveal: true }` to ALSO bring the user to the editor across activities —\n * see {@link EditorOpenOptions.reveal}; that one does need the elevated\n * `editor:reveal`, and is refused outright without it.\n *\n * Older hosts ignore `selection` and open the file at its existing position, so a\n * caller may pass it unconditionally. `reveal` is only sent when true, so a host that\n * predates it sees a plain open.\n */\nexport const openInEditor = (path: string, selection?: EditorSelection, opts?: EditorOpenOptions): Promise<void> =>\n editorRequest('open', {\n path,\n ...(selection ? { selection } : {}),\n ...(opts?.reveal === true ? { reveal: true } : {}),\n });\n\n/**\n * Where to land when entering the edit experience (EDITOR_FIRST_EDITING_SPEC §6).\n *\n * Two target classes, and **at most one** may be given — supplying both is refused\n * `invalid-params`. Omit both to edit the current route's entry.\n *\n * - **Own-source** (`path`): a repo-relative path in the CURRENT repo. Self-scoped —\n * the app you are already running; the host navigates within the current route,\n * never to another repo.\n * - **Mount-file** (`file`): a file in a mount you ALREADY HOLD, opened in the main\n * edit experience (§9, settled 2026-08-28). You can only name a mount you hold: an\n * unheld one is `forbidden`, and indistinguishably so from one that does not exist,\n * because an app must not be able to probe for mounts (no existence oracle).\n * Editing a file *outside* your mounts stays picker-mediated (`pick-file`).\n *\n * A URI, a `..` segment, or a NUL is refused `invalid-params` in either class.\n */\nexport interface EditTarget {\n /** A repo-relative working-tree path in the current repo to focus once in edit\n * mode (e.g. `src/App.tsx`). Omit to edit the current route's entry. */\n path?: string;\n /** A file in one of YOUR OWN mounts, by the portable mount reference. `relPath` is\n * mount-relative and leading-slash (e.g. `/notes/idea.mdx`). Mutually exclusive\n * with {@link EditTarget.path}.\n *\n * There is no `mode` here on purpose: writability is the HOST's live reading of\n * the mount, not the caller's claim. A `ro` mount — which is also how an anonymous\n * share-link viewer surfaces — is refused `read-only` at call time, before the\n * editor is entered, so you never land in an editor that cannot save. */\n file?: { mountId: string; relPath: string };\n}\n\n/** An error from {@link requestEdit}, carrying a machine-readable `.code`. */\nexport interface RequestEditError extends Error {\n code:\n | 'read-only' // editing isn't possible here (a `ro` mount / anonymous viewer) — HIDE the affordance\n | 'forbidden' // the host refuses: a cross-repo target, or a mount you do not hold\n | 'invalid-params' // the target was malformed (URI / `..` / NUL / both target classes at once)\n | 'not-found' // the mount-file target does not exist — and asking did NOT create it\n | 'no-target' // there is no host editor session to enter\n | 'unknown';\n}\n\n/**\n * Ask the host to enter the **edit experience** for the app you are running —\n * the present→edit transition (`/present/...` → `/edit/...`) an app cannot make\n * itself. This is an INTENT (§2 recursion boundary): the app asks, the HOST\n * performs the visible, user-observable navigation and draws all editor chrome;\n * the app never navigates or paints chrome.\n *\n * Use it to offer an \"edit this\" affordance from a run/present-mode app that opens\n * the app's own source in the platform editor — instead of shipping a bespoke\n * in-app editor (EDITOR_FIRST_EDITING_SPEC §1).\n *\n * Also opens a file from a mount you already hold, in the main edit experience:\n *\n * await requestEdit({ file: { mountId: 'space:abc', relPath: '/notes/idea.mdx' } });\n *\n * Resolves once the host begins the transition; rejects with a\n * {@link RequestEditError} (`.code`). Treat `read-only`/`forbidden` as \"editing is\n * not available — hide the affordance,\" never as an error to surface to the user.\n * `not-found` means the file is not there; nothing is created by asking to edit it.\n */\nexport const requestEdit = (target?: EditTarget): Promise<void> =>\n editorRequest('requestEdit', target ? { ...target } : {});\n\n// ---------------------------------------------------------------------------\n// Editor SESSION management (EDITOR_AS_APP_SPEC §5.1; editor-as-app plan Phase\n// 03). Unlike `openInEditor` (the explorer's cross-app intent, `editor:open`),\n// these drive the editor's OWN open-tab set + active file, so they are gated by\n// the editor app's `editor:document` capability — a file explorer holding only\n// `editor:open` cannot call them. The host re-validates the path against the live\n// working tree; the editor itself stays host-owned (§2 recursion boundary).\n// ---------------------------------------------------------------------------\n\n/** An error from a session intent ({@link setActiveFile} / {@link closeFile}),\n * carrying a machine-readable `.code`. */\nexport interface EditorSessionError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:document`\n | 'not-found' // no such file in the live working tree\n | 'invalid-params' // the path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session\n | 'unknown';\n}\n\n/** Switch the editor's active file to `path`, opening it (adding a tab) if it is\n * not already open — native `setActiveFile` parity. Rejects with an\n * {@link EditorSessionError} (`.code`) if the path is missing/invalid or this app\n * lacks `editor:document`. */\nexport const setActiveFile = (path: string): Promise<void> => editorRequest('setActive', { path });\n\n/** Close `path`'s tab in the editor (remove it from the open set) — native\n * `closeFile` parity. Rejects with an {@link EditorSessionError} (`.code`). */\nexport const closeFile = (path: string): Promise<void> => editorRequest('close', { path });\n\n// ---------------------------------------------------------------------------\n// Working-tree mutation (UI_AS_APPS_SPEC §4 / EDITOR_AS_APP_SPEC §5.2). The file\n// explorer NAMES a working-tree path and the HOST performs the COW write (and\n// refreshes the preview) — the app holds no write port; it asks. Gated by the\n// first-party `editor:write` capability, so only a first-party chrome app (the\n// file explorer) can call these; anyone else is refused at the gate.\n// ---------------------------------------------------------------------------\n\n/** An error from a working-tree mutation, carrying a machine-readable `.code`. */\nexport interface EditorWriteError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:write` (first-party-only)\n | 'not-found' // the target file/folder does not exist (delete/rename)\n | 'exists' // the target already exists (create/rename would clobber)\n | 'protected' // the host refuses to delete this file (e.g. package.json)\n | 'too-large' // an upload exceeds the host's size limit\n | 'invalid-params' // a path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session\n | 'unknown';\n}\n\n/** Create an empty working-tree file at `path` and open it. Rejects `exists` if a\n * file is already there. */\nexport const createFile = (path: string): Promise<void> => editorRequest('createFile', { path });\n\n/** Create a working-tree folder at `path` (materialised with a `.gitkeep`). */\nexport const createFolder = (path: string): Promise<void> => editorRequest('createFolder', { path });\n\n/** Delete a working-tree file, or a folder and everything under it. Rejects\n * `protected` for files the host won't remove, `not-found` if absent. */\nexport const deleteEntry = (path: string): Promise<void> => editorRequest('deleteEntry', { path });\n\n/** Rename/move a working-tree file from `from` to `to`. Rejects `exists` if `to`\n * is taken, `not-found` if `from` is absent. */\nexport const renameEntry = (from: string, to: string): Promise<void> => editorRequest('rename', { from, to });\n\n/** Upload binary/text `bytes` to a working-tree file at `path`. Rejects\n * `too-large` past the host's size limit. The bytes are transferred (zero-copy). */\nexport const uploadFile = (path: string, bytes: Uint8Array): Promise<void> => editorRequest('upload', { path, bytes });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC;AAChC,6BAAwB;AACxB,sBAAgC;AA0BhC,MAAM,gBAAgB,OAAO,QAAgB,QAAgD;AAC3F,QAAM,MAAO,UAAM,qCAAgB,+BAAQ,+BAAe,GAAG,QAAQ,CAAC,GAAG,CAAC;AAC1E,MAAI,CAAC,OAAO,IAAI,OAAO,MAAM;AAC3B,UAAM,MAAM,IAAI,MAAM,KAAK,WAAW,UAAU,MAAM,SAAS;AAC/D,QAAI,OAAQ,KAAK,QAAqC;AACtD,UAAM;AAAA,EACR;AACF;AAiDO,MAAM,eAAe,CAAC,MAAc,WAA6B,SACtE,cAAc,QAAQ;AAAA,EACpB;AAAA,EACA,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;AAAA,EACjC,GAAI,MAAM,WAAW,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;AAClD,CAAC;AAiEI,MAAM,cAAc,CAAC,WAC1B,cAAc,eAAe,SAAS,EAAE,GAAG,OAAO,IAAI,CAAC,CAAC;AA0BnD,MAAM,gBAAgB,CAAC,SAAgC,cAAc,aAAa,EAAE,KAAK,CAAC;AAI1F,MAAM,YAAY,CAAC,SAAgC,cAAc,SAAS,EAAE,KAAK,CAAC;AAyBlF,MAAM,aAAa,CAAC,SAAgC,cAAc,cAAc,EAAE,KAAK,CAAC;AAGxF,MAAM,eAAe,CAAC,SAAgC,cAAc,gBAAgB,EAAE,KAAK,CAAC;AAI5F,MAAM,cAAc,CAAC,SAAgC,cAAc,eAAe,EAAE,KAAK,CAAC;AAI1F,MAAM,cAAc,CAAC,MAAc,OAA8B,cAAc,UAAU,EAAE,MAAM,GAAG,CAAC;AAIrG,MAAM,aAAa,CAAC,MAAc,UAAqC,cAAc,UAAU,EAAE,MAAM,MAAM,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/editor.ts"],"sourcesContent":["import { protocolRequest } from './sandboxUtils';\nimport { throwOnRefusal } from './protocolRefusal';\nimport { SCHEMES } from './protocolSchemes';\nimport { PROTOCOL_EDITOR } from './generated/protocol';\n\n/**\n * Open a working-tree file in the immediately.run host editor (UI_AS_APPS_SPEC §4 —\n * the file explorer's click-to-open). This is an INTENT: the app asks, the HOST\n * validates the path and drives the CodeMirror editor — the editor itself stays\n * host-owned (§2 recursion boundary), so an app can never own or script it beyond\n * \"please show this file\".\n *\n * Requires the elevated `editor:open` capability — a previewed app does not hold it\n * (it must not move the host's focus), so only a system app whose binding grants it\n * (the file explorer) can call this; anyone else is refused at the gate.\n */\n\n/** An error from {@link openInEditor}, carrying a machine-readable `.code`.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n * documents the `.code` VALUES the host sends; it was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test.\n */\nexport interface EditorOpenError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:open` (or `editor:reveal`, for a `reveal`)\n | 'not-found' // no such file in the live working tree (the host never creates)\n | 'invalid-params' // the path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session to open files in\n | 'unknown';\n}\n\ntype EditorResult = { ok: true; data: unknown } | { ok: false; code: string; message: string };\n\nconst editorRequest = async (method: string, arg: Record<string, unknown>): Promise<void> => {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_EDITOR], method, [arg])) as EditorResult;\n throwOnRefusal(res, `editor ${method} failed`);\n};\n\n/** Where in a file to land when opening it (R3-388). 1-indexed `line`, matching every\n * diagnostic producer that feeds it (`tsc`, `eslint`, `BuildError`) and both VS Code\n * and IntelliJ. A `line` past end-of-file CLAMPS to the last line rather than\n * erroring — a diagnostic outlives the edit that shortened the file, and landing\n * close beats refusing to navigate. */\nexport interface EditorSelection {\n line: number;\n column?: number;\n}\n\n/** Options for {@link openInEditor} (R3-389). */\nexport interface EditorOpenOptions {\n /** Also bring the user to the editor, ACROSS activities (TOOLS_ACTIVITY_SPEC §5.2).\n * An app that owns the main pane (the Tools activity's runner sits where the editor\n * would) cannot rely on the file simply becoming visible — the editor is not on\n * screen — so this asks the host to switch to the activity that owns it.\n *\n * This is the elevated `editor:reveal` capability, not `editor:open`: a frame\n * without it is refused `forbidden` for the whole call (the file is NOT opened —\n * never silently opened-without-moving). The host decides whether the user actually\n * moves: it needs a real user gesture (a click in your frame within the last few\n * seconds counts; a call on a timer or on run completion does not) and is\n * rate-limited. The promise resolves the same either way, so treat a resolved\n * reveal as \"asked\", not \"moved\", and keep a visible fallback control. Where the\n * host owns the editor activity is host state; nothing here can name it. */\n reveal?: boolean;\n}\n\n/**\n * Ask the host to open `path` (a repo-relative working-tree path, e.g. `src/App.tsx`\n * or `/src/App.tsx`) in the editor. Resolves once the editor switches to it; rejects\n * with an {@link EditorOpenError} (`.code`) if the path is invalid, missing, or this\n * app may not open files.\n *\n * Pass `selection` to land the caret on a specific line — what a problems list needs\n * to make a diagnostic clickable. It widens nothing: a selection says where to look\n * inside a file the caller could already open, and the capability is unchanged\n * (`editor:open`).\n *\n * Pass `{ reveal: true }` to ALSO bring the user to the editor across activities —\n * see {@link EditorOpenOptions.reveal}; that one does need the elevated\n * `editor:reveal`, and is refused outright without it.\n *\n * Older hosts ignore `selection` and open the file at its existing position, so a\n * caller may pass it unconditionally. `reveal` is only sent when true, so a host that\n * predates it sees a plain open.\n */\nexport const openInEditor = (path: string, selection?: EditorSelection, opts?: EditorOpenOptions): Promise<void> =>\n editorRequest('open', {\n path,\n ...(selection ? { selection } : {}),\n ...(opts?.reveal === true ? { reveal: true } : {}),\n });\n\n/**\n * Where to land when entering the edit experience (EDITOR_FIRST_EDITING_SPEC §6).\n *\n * Two target classes, and **at most one** may be given — supplying both is refused\n * `invalid-params`. Omit both to edit the current route's entry.\n *\n * - **Own-source** (`path`): a repo-relative path in the CURRENT repo. Self-scoped —\n * the app you are already running; the host navigates within the current route,\n * never to another repo.\n * - **Mount-file** (`file`): a file in a mount you ALREADY HOLD, opened in the main\n * edit experience (§9, settled 2026-08-28). You can only name a mount you hold: an\n * unheld one is `forbidden`, and indistinguishably so from one that does not exist,\n * because an app must not be able to probe for mounts (no existence oracle).\n * Editing a file *outside* your mounts stays picker-mediated (`pick-file`).\n *\n * A URI, a `..` segment, or a NUL is refused `invalid-params` in either class.\n */\nexport interface EditTarget {\n /** A repo-relative working-tree path in the current repo to focus once in edit\n * mode (e.g. `src/App.tsx`). Omit to edit the current route's entry. */\n path?: string;\n /** A file in one of YOUR OWN mounts, by the portable mount reference. `relPath` is\n * mount-relative and leading-slash (e.g. `/notes/idea.mdx`). Mutually exclusive\n * with {@link EditTarget.path}.\n *\n * There is no `mode` here on purpose: writability is the HOST's live reading of\n * the mount, not the caller's claim. A `ro` mount — which is also how an anonymous\n * share-link viewer surfaces — is refused `read-only` at call time, before the\n * editor is entered, so you never land in an editor that cannot save. */\n file?: { mountId: string; relPath: string };\n}\n\n/** An error from {@link requestEdit}, carrying a machine-readable `.code`.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n * documents the `.code` VALUES the host sends; it was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test.\n */\nexport interface RequestEditError extends Error {\n code:\n | 'read-only' // editing isn't possible here (a `ro` mount / anonymous viewer) — HIDE the affordance\n | 'forbidden' // the host refuses: a cross-repo target, or a mount you do not hold\n | 'invalid-params' // the target was malformed (URI / `..` / NUL / both target classes at once)\n | 'not-found' // the mount-file target does not exist — and asking did NOT create it\n | 'no-target' // there is no host editor session to enter\n | 'unknown';\n}\n\n/**\n * Ask the host to enter the **edit experience** for the app you are running —\n * the present→edit transition (`/present/...` → `/edit/...`) an app cannot make\n * itself. This is an INTENT (§2 recursion boundary): the app asks, the HOST\n * performs the visible, user-observable navigation and draws all editor chrome;\n * the app never navigates or paints chrome.\n *\n * Use it to offer an \"edit this\" affordance from a run/present-mode app that opens\n * the app's own source in the platform editor — instead of shipping a bespoke\n * in-app editor (EDITOR_FIRST_EDITING_SPEC §1).\n *\n * Also opens a file from a mount you already hold, in the main edit experience:\n *\n * await requestEdit({ file: { mountId: 'space:abc', relPath: '/notes/idea.mdx' } });\n *\n * Resolves once the host begins the transition; rejects with a\n * {@link RequestEditError} (`.code`). Treat `read-only`/`forbidden` as \"editing is\n * not available — hide the affordance,\" never as an error to surface to the user.\n * `not-found` means the file is not there; nothing is created by asking to edit it.\n */\nexport const requestEdit = (target?: EditTarget): Promise<void> =>\n editorRequest('requestEdit', target ? { ...target } : {});\n\n// ---------------------------------------------------------------------------\n// Editor SESSION management (EDITOR_AS_APP_SPEC §5.1; editor-as-app plan Phase\n// 03). Unlike `openInEditor` (the explorer's cross-app intent, `editor:open`),\n// these drive the editor's OWN open-tab set + active file, so they are gated by\n// the editor app's `editor:document` capability — a file explorer holding only\n// `editor:open` cannot call them. The host re-validates the path against the live\n// working tree; the editor itself stays host-owned (§2 recursion boundary).\n// ---------------------------------------------------------------------------\n\n/** An error from a session intent ({@link setActiveFile} / {@link closeFile}),\n * carrying a machine-readable `.code`.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n * documents the `.code` VALUES the host sends; it was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test.\n */\nexport interface EditorSessionError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:document`\n | 'not-found' // no such file in the live working tree\n | 'invalid-params' // the path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session\n | 'unknown';\n}\n\n/** Switch the editor's active file to `path`, opening it (adding a tab) if it is\n * not already open — native `setActiveFile` parity. Rejects with an\n * {@link EditorSessionError} (`.code`) if the path is missing/invalid or this app\n * lacks `editor:document`. */\nexport const setActiveFile = (path: string): Promise<void> => editorRequest('setActive', { path });\n\n/** Close `path`'s tab in the editor (remove it from the open set) — native\n * `closeFile` parity. Rejects with an {@link EditorSessionError} (`.code`). */\nexport const closeFile = (path: string): Promise<void> => editorRequest('close', { path });\n\n// ---------------------------------------------------------------------------\n// Working-tree mutation (UI_AS_APPS_SPEC §4 / EDITOR_AS_APP_SPEC §5.2). The file\n// explorer NAMES a working-tree path and the HOST performs the COW write (and\n// refreshes the preview) — the app holds no write port; it asks. Gated by the\n// first-party `editor:write` capability, so only a first-party chrome app (the\n// file explorer) can call these; anyone else is refused at the gate.\n// ---------------------------------------------------------------------------\n\n/** An error from a working-tree mutation, carrying a machine-readable `.code`.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n * documents the `.code` VALUES the host sends; it was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test.\n */\nexport interface EditorWriteError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:write` (first-party-only)\n | 'not-found' // the target file/folder does not exist (delete/rename)\n | 'exists' // the target already exists (create/rename would clobber)\n | 'protected' // the host refuses to delete this file (e.g. package.json)\n | 'too-large' // an upload exceeds the host's size limit\n | 'invalid-params' // a path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session\n | 'unknown';\n}\n\n/** Create an empty working-tree file at `path` and open it. Rejects `exists` if a\n * file is already there — see {@link EditorWriteError} for the full code list, which\n * every helper below shares. */\nexport const createFile = (path: string): Promise<void> => editorRequest('createFile', { path });\n\n/** Create a working-tree folder at `path` (materialised with a `.gitkeep`). */\nexport const createFolder = (path: string): Promise<void> => editorRequest('createFolder', { path });\n\n/** Delete a working-tree file, or a folder and everything under it. Rejects\n * `protected` for files the host won't remove, `not-found` if absent. */\nexport const deleteEntry = (path: string): Promise<void> => editorRequest('deleteEntry', { path });\n\n/** Rename/move a working-tree file from `from` to `to`. Rejects `exists` if `to`\n * is taken, `not-found` if `from` is absent. */\nexport const renameEntry = (from: string, to: string): Promise<void> => editorRequest('rename', { from, to });\n\n/** Upload binary/text `bytes` to a working-tree file at `path`. Rejects\n * `too-large` past the host's size limit. The bytes are transferred (zero-copy). */\nexport const uploadFile = (path: string, bytes: Uint8Array): Promise<void> => editorRequest('upload', { path, bytes });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC;AAChC,6BAA+B;AAC/B,6BAAwB;AACxB,sBAAgC;AAiChC,MAAM,gBAAgB,OAAO,QAAgB,QAAgD;AAC3F,QAAM,MAAO,UAAM,qCAAgB,+BAAQ,+BAAe,GAAG,QAAQ,CAAC,GAAG,CAAC;AAC1E,6CAAe,KAAK,UAAU,MAAM,SAAS;AAC/C;AAiDO,MAAM,eAAe,CAAC,MAAc,WAA6B,SACtE,cAAc,QAAQ;AAAA,EACpB;AAAA,EACA,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;AAAA,EACjC,GAAI,MAAM,WAAW,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;AAClD,CAAC;AAwEI,MAAM,cAAc,CAAC,WAC1B,cAAc,eAAe,SAAS,EAAE,GAAG,OAAO,IAAI,CAAC,CAAC;AAiCnD,MAAM,gBAAgB,CAAC,SAAgC,cAAc,aAAa,EAAE,KAAK,CAAC;AAI1F,MAAM,YAAY,CAAC,SAAgC,cAAc,SAAS,EAAE,KAAK,CAAC;AAiClF,MAAM,aAAa,CAAC,SAAgC,cAAc,cAAc,EAAE,KAAK,CAAC;AAGxF,MAAM,eAAe,CAAC,SAAgC,cAAc,gBAAgB,EAAE,KAAK,CAAC;AAI5F,MAAM,cAAc,CAAC,SAAgC,cAAc,eAAe,EAAE,KAAK,CAAC;AAI1F,MAAM,cAAc,CAAC,MAAc,OAA8B,cAAc,UAAU,EAAE,MAAM,GAAG,CAAC;AAIrG,MAAM,aAAa,CAAC,MAAc,UAAqC,cAAc,UAAU,EAAE,MAAM,MAAM,CAAC;","names":[]}
|
package/dist/editor.d.cts
CHANGED
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
* (it must not move the host's focus), so only a system app whose binding grants it
|
|
10
10
|
* (the file explorer) can call this; anyone else is refused at the gate.
|
|
11
11
|
*/
|
|
12
|
-
/** An error from {@link openInEditor}, carrying a machine-readable `.code`.
|
|
12
|
+
/** An error from {@link openInEditor}, carrying a machine-readable `.code`.
|
|
13
|
+
*
|
|
14
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
15
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface
|
|
16
|
+
* documents the `.code` VALUES the host sends; it was always a cast and is not enforced at
|
|
17
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
18
|
+
* reliable test.
|
|
19
|
+
*/
|
|
13
20
|
interface EditorOpenError extends Error {
|
|
14
21
|
code: 'forbidden' | 'not-found' | 'invalid-params' | 'no-target' | 'unknown';
|
|
15
22
|
}
|
|
@@ -93,7 +100,14 @@ interface EditTarget {
|
|
|
93
100
|
relPath: string;
|
|
94
101
|
};
|
|
95
102
|
}
|
|
96
|
-
/** An error from {@link requestEdit}, carrying a machine-readable `.code`.
|
|
103
|
+
/** An error from {@link requestEdit}, carrying a machine-readable `.code`.
|
|
104
|
+
*
|
|
105
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
106
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface
|
|
107
|
+
* documents the `.code` VALUES the host sends; it was always a cast and is not enforced at
|
|
108
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
109
|
+
* reliable test.
|
|
110
|
+
*/
|
|
97
111
|
interface RequestEditError extends Error {
|
|
98
112
|
code: 'read-only' | 'forbidden' | 'invalid-params' | 'not-found' | 'no-target' | 'unknown';
|
|
99
113
|
}
|
|
@@ -119,7 +133,14 @@ interface RequestEditError extends Error {
|
|
|
119
133
|
*/
|
|
120
134
|
declare const requestEdit: (target?: EditTarget) => Promise<void>;
|
|
121
135
|
/** An error from a session intent ({@link setActiveFile} / {@link closeFile}),
|
|
122
|
-
* carrying a machine-readable `.code`.
|
|
136
|
+
* carrying a machine-readable `.code`.
|
|
137
|
+
*
|
|
138
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
139
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface
|
|
140
|
+
* documents the `.code` VALUES the host sends; it was always a cast and is not enforced at
|
|
141
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
142
|
+
* reliable test.
|
|
143
|
+
*/
|
|
123
144
|
interface EditorSessionError extends Error {
|
|
124
145
|
code: 'forbidden' | 'not-found' | 'invalid-params' | 'no-target' | 'unknown';
|
|
125
146
|
}
|
|
@@ -131,12 +152,20 @@ declare const setActiveFile: (path: string) => Promise<void>;
|
|
|
131
152
|
/** Close `path`'s tab in the editor (remove it from the open set) — native
|
|
132
153
|
* `closeFile` parity. Rejects with an {@link EditorSessionError} (`.code`). */
|
|
133
154
|
declare const closeFile: (path: string) => Promise<void>;
|
|
134
|
-
/** An error from a working-tree mutation, carrying a machine-readable `.code`.
|
|
155
|
+
/** An error from a working-tree mutation, carrying a machine-readable `.code`.
|
|
156
|
+
*
|
|
157
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
158
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface
|
|
159
|
+
* documents the `.code` VALUES the host sends; it was always a cast and is not enforced at
|
|
160
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
161
|
+
* reliable test.
|
|
162
|
+
*/
|
|
135
163
|
interface EditorWriteError extends Error {
|
|
136
164
|
code: 'forbidden' | 'not-found' | 'exists' | 'protected' | 'too-large' | 'invalid-params' | 'no-target' | 'unknown';
|
|
137
165
|
}
|
|
138
166
|
/** Create an empty working-tree file at `path` and open it. Rejects `exists` if a
|
|
139
|
-
* file is already there
|
|
167
|
+
* file is already there — see {@link EditorWriteError} for the full code list, which
|
|
168
|
+
* every helper below shares. */
|
|
140
169
|
declare const createFile: (path: string) => Promise<void>;
|
|
141
170
|
/** Create a working-tree folder at `path` (materialised with a `.gitkeep`). */
|
|
142
171
|
declare const createFolder: (path: string) => Promise<void>;
|
package/dist/editor.d.ts
CHANGED
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
* (it must not move the host's focus), so only a system app whose binding grants it
|
|
10
10
|
* (the file explorer) can call this; anyone else is refused at the gate.
|
|
11
11
|
*/
|
|
12
|
-
/** An error from {@link openInEditor}, carrying a machine-readable `.code`.
|
|
12
|
+
/** An error from {@link openInEditor}, carrying a machine-readable `.code`.
|
|
13
|
+
*
|
|
14
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
15
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface
|
|
16
|
+
* documents the `.code` VALUES the host sends; it was always a cast and is not enforced at
|
|
17
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
18
|
+
* reliable test.
|
|
19
|
+
*/
|
|
13
20
|
interface EditorOpenError extends Error {
|
|
14
21
|
code: 'forbidden' | 'not-found' | 'invalid-params' | 'no-target' | 'unknown';
|
|
15
22
|
}
|
|
@@ -93,7 +100,14 @@ interface EditTarget {
|
|
|
93
100
|
relPath: string;
|
|
94
101
|
};
|
|
95
102
|
}
|
|
96
|
-
/** An error from {@link requestEdit}, carrying a machine-readable `.code`.
|
|
103
|
+
/** An error from {@link requestEdit}, carrying a machine-readable `.code`.
|
|
104
|
+
*
|
|
105
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
106
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface
|
|
107
|
+
* documents the `.code` VALUES the host sends; it was always a cast and is not enforced at
|
|
108
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
109
|
+
* reliable test.
|
|
110
|
+
*/
|
|
97
111
|
interface RequestEditError extends Error {
|
|
98
112
|
code: 'read-only' | 'forbidden' | 'invalid-params' | 'not-found' | 'no-target' | 'unknown';
|
|
99
113
|
}
|
|
@@ -119,7 +133,14 @@ interface RequestEditError extends Error {
|
|
|
119
133
|
*/
|
|
120
134
|
declare const requestEdit: (target?: EditTarget) => Promise<void>;
|
|
121
135
|
/** An error from a session intent ({@link setActiveFile} / {@link closeFile}),
|
|
122
|
-
* carrying a machine-readable `.code`.
|
|
136
|
+
* carrying a machine-readable `.code`.
|
|
137
|
+
*
|
|
138
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
139
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface
|
|
140
|
+
* documents the `.code` VALUES the host sends; it was always a cast and is not enforced at
|
|
141
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
142
|
+
* reliable test.
|
|
143
|
+
*/
|
|
123
144
|
interface EditorSessionError extends Error {
|
|
124
145
|
code: 'forbidden' | 'not-found' | 'invalid-params' | 'no-target' | 'unknown';
|
|
125
146
|
}
|
|
@@ -131,12 +152,20 @@ declare const setActiveFile: (path: string) => Promise<void>;
|
|
|
131
152
|
/** Close `path`'s tab in the editor (remove it from the open set) — native
|
|
132
153
|
* `closeFile` parity. Rejects with an {@link EditorSessionError} (`.code`). */
|
|
133
154
|
declare const closeFile: (path: string) => Promise<void>;
|
|
134
|
-
/** An error from a working-tree mutation, carrying a machine-readable `.code`.
|
|
155
|
+
/** An error from a working-tree mutation, carrying a machine-readable `.code`.
|
|
156
|
+
*
|
|
157
|
+
* **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a
|
|
158
|
+
* `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface
|
|
159
|
+
* documents the `.code` VALUES the host sends; it was always a cast and is not enforced at
|
|
160
|
+
* runtime, so treat an unlisted code as possible and `instanceof Error` as the only
|
|
161
|
+
* reliable test.
|
|
162
|
+
*/
|
|
135
163
|
interface EditorWriteError extends Error {
|
|
136
164
|
code: 'forbidden' | 'not-found' | 'exists' | 'protected' | 'too-large' | 'invalid-params' | 'no-target' | 'unknown';
|
|
137
165
|
}
|
|
138
166
|
/** Create an empty working-tree file at `path` and open it. Rejects `exists` if a
|
|
139
|
-
* file is already there
|
|
167
|
+
* file is already there — see {@link EditorWriteError} for the full code list, which
|
|
168
|
+
* every helper below shares. */
|
|
140
169
|
declare const createFile: (path: string) => Promise<void>;
|
|
141
170
|
/** Create a working-tree folder at `path` (materialised with a `.gitkeep`). */
|
|
142
171
|
declare const createFolder: (path: string) => Promise<void>;
|
package/dist/editor.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import "./chunk-VHAA22YE.js";
|
|
2
2
|
import { protocolRequest } from "./sandboxUtils.js";
|
|
3
|
+
import { throwOnRefusal } from "./protocolRefusal.js";
|
|
3
4
|
import { SCHEMES } from "./protocolSchemes.js";
|
|
4
5
|
import { PROTOCOL_EDITOR } from "./generated/protocol.js";
|
|
5
6
|
const editorRequest = async (method, arg) => {
|
|
6
7
|
const res = await protocolRequest(SCHEMES[PROTOCOL_EDITOR], method, [arg]);
|
|
7
|
-
|
|
8
|
-
const err = new Error(res?.message ?? `editor ${method} failed`);
|
|
9
|
-
err.code = res?.code ?? "unknown";
|
|
10
|
-
throw err;
|
|
11
|
-
}
|
|
8
|
+
throwOnRefusal(res, `editor ${method} failed`);
|
|
12
9
|
};
|
|
13
10
|
const openInEditor = (path, selection, opts) => editorRequest("open", {
|
|
14
11
|
path,
|
package/dist/editor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/editor.ts"],"sourcesContent":["import { protocolRequest } from './sandboxUtils';\nimport { SCHEMES } from './protocolSchemes';\nimport { PROTOCOL_EDITOR } from './generated/protocol';\n\n/**\n * Open a working-tree file in the immediately.run host editor (UI_AS_APPS_SPEC §4 —\n * the file explorer's click-to-open). This is an INTENT: the app asks, the HOST\n * validates the path and drives the CodeMirror editor — the editor itself stays\n * host-owned (§2 recursion boundary), so an app can never own or script it beyond\n * \"please show this file\".\n *\n * Requires the elevated `editor:open` capability — a previewed app does not hold it\n * (it must not move the host's focus), so only a system app whose binding grants it\n * (the file explorer) can call this; anyone else is refused at the gate.\n */\n\n/** An error from {@link openInEditor}, carrying a machine-readable `.code`. */\nexport interface EditorOpenError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:open` (or `editor:reveal`, for a `reveal`)\n | 'not-found' // no such file in the live working tree (the host never creates)\n | 'invalid-params' // the path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session to open files in\n | 'unknown';\n}\n\ntype EditorResult = { ok: true; data: unknown } | { ok: false; code: string; message: string };\n\nconst editorRequest = async (method: string, arg: Record<string, unknown>): Promise<void> => {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_EDITOR], method, [arg])) as EditorResult;\n if (!res || res.ok !== true) {\n const err = new Error(res?.message ?? `editor ${method} failed`) as EditorWriteError;\n err.code = (res?.code as EditorWriteError['code']) ?? 'unknown';\n throw err;\n }\n};\n\n/** Where in a file to land when opening it (R3-388). 1-indexed `line`, matching every\n * diagnostic producer that feeds it (`tsc`, `eslint`, `BuildError`) and both VS Code\n * and IntelliJ. A `line` past end-of-file CLAMPS to the last line rather than\n * erroring — a diagnostic outlives the edit that shortened the file, and landing\n * close beats refusing to navigate. */\nexport interface EditorSelection {\n line: number;\n column?: number;\n}\n\n/** Options for {@link openInEditor} (R3-389). */\nexport interface EditorOpenOptions {\n /** Also bring the user to the editor, ACROSS activities (TOOLS_ACTIVITY_SPEC §5.2).\n * An app that owns the main pane (the Tools activity's runner sits where the editor\n * would) cannot rely on the file simply becoming visible — the editor is not on\n * screen — so this asks the host to switch to the activity that owns it.\n *\n * This is the elevated `editor:reveal` capability, not `editor:open`: a frame\n * without it is refused `forbidden` for the whole call (the file is NOT opened —\n * never silently opened-without-moving). The host decides whether the user actually\n * moves: it needs a real user gesture (a click in your frame within the last few\n * seconds counts; a call on a timer or on run completion does not) and is\n * rate-limited. The promise resolves the same either way, so treat a resolved\n * reveal as \"asked\", not \"moved\", and keep a visible fallback control. Where the\n * host owns the editor activity is host state; nothing here can name it. */\n reveal?: boolean;\n}\n\n/**\n * Ask the host to open `path` (a repo-relative working-tree path, e.g. `src/App.tsx`\n * or `/src/App.tsx`) in the editor. Resolves once the editor switches to it; rejects\n * with an {@link EditorOpenError} (`.code`) if the path is invalid, missing, or this\n * app may not open files.\n *\n * Pass `selection` to land the caret on a specific line — what a problems list needs\n * to make a diagnostic clickable. It widens nothing: a selection says where to look\n * inside a file the caller could already open, and the capability is unchanged\n * (`editor:open`).\n *\n * Pass `{ reveal: true }` to ALSO bring the user to the editor across activities —\n * see {@link EditorOpenOptions.reveal}; that one does need the elevated\n * `editor:reveal`, and is refused outright without it.\n *\n * Older hosts ignore `selection` and open the file at its existing position, so a\n * caller may pass it unconditionally. `reveal` is only sent when true, so a host that\n * predates it sees a plain open.\n */\nexport const openInEditor = (path: string, selection?: EditorSelection, opts?: EditorOpenOptions): Promise<void> =>\n editorRequest('open', {\n path,\n ...(selection ? { selection } : {}),\n ...(opts?.reveal === true ? { reveal: true } : {}),\n });\n\n/**\n * Where to land when entering the edit experience (EDITOR_FIRST_EDITING_SPEC §6).\n *\n * Two target classes, and **at most one** may be given — supplying both is refused\n * `invalid-params`. Omit both to edit the current route's entry.\n *\n * - **Own-source** (`path`): a repo-relative path in the CURRENT repo. Self-scoped —\n * the app you are already running; the host navigates within the current route,\n * never to another repo.\n * - **Mount-file** (`file`): a file in a mount you ALREADY HOLD, opened in the main\n * edit experience (§9, settled 2026-08-28). You can only name a mount you hold: an\n * unheld one is `forbidden`, and indistinguishably so from one that does not exist,\n * because an app must not be able to probe for mounts (no existence oracle).\n * Editing a file *outside* your mounts stays picker-mediated (`pick-file`).\n *\n * A URI, a `..` segment, or a NUL is refused `invalid-params` in either class.\n */\nexport interface EditTarget {\n /** A repo-relative working-tree path in the current repo to focus once in edit\n * mode (e.g. `src/App.tsx`). Omit to edit the current route's entry. */\n path?: string;\n /** A file in one of YOUR OWN mounts, by the portable mount reference. `relPath` is\n * mount-relative and leading-slash (e.g. `/notes/idea.mdx`). Mutually exclusive\n * with {@link EditTarget.path}.\n *\n * There is no `mode` here on purpose: writability is the HOST's live reading of\n * the mount, not the caller's claim. A `ro` mount — which is also how an anonymous\n * share-link viewer surfaces — is refused `read-only` at call time, before the\n * editor is entered, so you never land in an editor that cannot save. */\n file?: { mountId: string; relPath: string };\n}\n\n/** An error from {@link requestEdit}, carrying a machine-readable `.code`. */\nexport interface RequestEditError extends Error {\n code:\n | 'read-only' // editing isn't possible here (a `ro` mount / anonymous viewer) — HIDE the affordance\n | 'forbidden' // the host refuses: a cross-repo target, or a mount you do not hold\n | 'invalid-params' // the target was malformed (URI / `..` / NUL / both target classes at once)\n | 'not-found' // the mount-file target does not exist — and asking did NOT create it\n | 'no-target' // there is no host editor session to enter\n | 'unknown';\n}\n\n/**\n * Ask the host to enter the **edit experience** for the app you are running —\n * the present→edit transition (`/present/...` → `/edit/...`) an app cannot make\n * itself. This is an INTENT (§2 recursion boundary): the app asks, the HOST\n * performs the visible, user-observable navigation and draws all editor chrome;\n * the app never navigates or paints chrome.\n *\n * Use it to offer an \"edit this\" affordance from a run/present-mode app that opens\n * the app's own source in the platform editor — instead of shipping a bespoke\n * in-app editor (EDITOR_FIRST_EDITING_SPEC §1).\n *\n * Also opens a file from a mount you already hold, in the main edit experience:\n *\n * await requestEdit({ file: { mountId: 'space:abc', relPath: '/notes/idea.mdx' } });\n *\n * Resolves once the host begins the transition; rejects with a\n * {@link RequestEditError} (`.code`). Treat `read-only`/`forbidden` as \"editing is\n * not available — hide the affordance,\" never as an error to surface to the user.\n * `not-found` means the file is not there; nothing is created by asking to edit it.\n */\nexport const requestEdit = (target?: EditTarget): Promise<void> =>\n editorRequest('requestEdit', target ? { ...target } : {});\n\n// ---------------------------------------------------------------------------\n// Editor SESSION management (EDITOR_AS_APP_SPEC §5.1; editor-as-app plan Phase\n// 03). Unlike `openInEditor` (the explorer's cross-app intent, `editor:open`),\n// these drive the editor's OWN open-tab set + active file, so they are gated by\n// the editor app's `editor:document` capability — a file explorer holding only\n// `editor:open` cannot call them. The host re-validates the path against the live\n// working tree; the editor itself stays host-owned (§2 recursion boundary).\n// ---------------------------------------------------------------------------\n\n/** An error from a session intent ({@link setActiveFile} / {@link closeFile}),\n * carrying a machine-readable `.code`. */\nexport interface EditorSessionError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:document`\n | 'not-found' // no such file in the live working tree\n | 'invalid-params' // the path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session\n | 'unknown';\n}\n\n/** Switch the editor's active file to `path`, opening it (adding a tab) if it is\n * not already open — native `setActiveFile` parity. Rejects with an\n * {@link EditorSessionError} (`.code`) if the path is missing/invalid or this app\n * lacks `editor:document`. */\nexport const setActiveFile = (path: string): Promise<void> => editorRequest('setActive', { path });\n\n/** Close `path`'s tab in the editor (remove it from the open set) — native\n * `closeFile` parity. Rejects with an {@link EditorSessionError} (`.code`). */\nexport const closeFile = (path: string): Promise<void> => editorRequest('close', { path });\n\n// ---------------------------------------------------------------------------\n// Working-tree mutation (UI_AS_APPS_SPEC §4 / EDITOR_AS_APP_SPEC §5.2). The file\n// explorer NAMES a working-tree path and the HOST performs the COW write (and\n// refreshes the preview) — the app holds no write port; it asks. Gated by the\n// first-party `editor:write` capability, so only a first-party chrome app (the\n// file explorer) can call these; anyone else is refused at the gate.\n// ---------------------------------------------------------------------------\n\n/** An error from a working-tree mutation, carrying a machine-readable `.code`. */\nexport interface EditorWriteError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:write` (first-party-only)\n | 'not-found' // the target file/folder does not exist (delete/rename)\n | 'exists' // the target already exists (create/rename would clobber)\n | 'protected' // the host refuses to delete this file (e.g. package.json)\n | 'too-large' // an upload exceeds the host's size limit\n | 'invalid-params' // a path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session\n | 'unknown';\n}\n\n/** Create an empty working-tree file at `path` and open it. Rejects `exists` if a\n * file is already there. */\nexport const createFile = (path: string): Promise<void> => editorRequest('createFile', { path });\n\n/** Create a working-tree folder at `path` (materialised with a `.gitkeep`). */\nexport const createFolder = (path: string): Promise<void> => editorRequest('createFolder', { path });\n\n/** Delete a working-tree file, or a folder and everything under it. Rejects\n * `protected` for files the host won't remove, `not-found` if absent. */\nexport const deleteEntry = (path: string): Promise<void> => editorRequest('deleteEntry', { path });\n\n/** Rename/move a working-tree file from `from` to `to`. Rejects `exists` if `to`\n * is taken, `not-found` if `from` is absent. */\nexport const renameEntry = (from: string, to: string): Promise<void> => editorRequest('rename', { from, to });\n\n/** Upload binary/text `bytes` to a working-tree file at `path`. Rejects\n * `too-large` past the host's size limit. The bytes are transferred (zero-copy). */\nexport const uploadFile = (path: string, bytes: Uint8Array): Promise<void> => editorRequest('upload', { path, bytes });\n"],"mappings":";AAAA,SAAS,uBAAuB;AAChC,SAAS,eAAe;AACxB,SAAS,uBAAuB;AA0BhC,MAAM,gBAAgB,OAAO,QAAgB,QAAgD;AAC3F,QAAM,MAAO,MAAM,gBAAgB,QAAQ,eAAe,GAAG,QAAQ,CAAC,GAAG,CAAC;AAC1E,MAAI,CAAC,OAAO,IAAI,OAAO,MAAM;AAC3B,UAAM,MAAM,IAAI,MAAM,KAAK,WAAW,UAAU,MAAM,SAAS;AAC/D,QAAI,OAAQ,KAAK,QAAqC;AACtD,UAAM;AAAA,EACR;AACF;AAiDO,MAAM,eAAe,CAAC,MAAc,WAA6B,SACtE,cAAc,QAAQ;AAAA,EACpB;AAAA,EACA,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;AAAA,EACjC,GAAI,MAAM,WAAW,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;AAClD,CAAC;AAiEI,MAAM,cAAc,CAAC,WAC1B,cAAc,eAAe,SAAS,EAAE,GAAG,OAAO,IAAI,CAAC,CAAC;AA0BnD,MAAM,gBAAgB,CAAC,SAAgC,cAAc,aAAa,EAAE,KAAK,CAAC;AAI1F,MAAM,YAAY,CAAC,SAAgC,cAAc,SAAS,EAAE,KAAK,CAAC;AAyBlF,MAAM,aAAa,CAAC,SAAgC,cAAc,cAAc,EAAE,KAAK,CAAC;AAGxF,MAAM,eAAe,CAAC,SAAgC,cAAc,gBAAgB,EAAE,KAAK,CAAC;AAI5F,MAAM,cAAc,CAAC,SAAgC,cAAc,eAAe,EAAE,KAAK,CAAC;AAI1F,MAAM,cAAc,CAAC,MAAc,OAA8B,cAAc,UAAU,EAAE,MAAM,GAAG,CAAC;AAIrG,MAAM,aAAa,CAAC,MAAc,UAAqC,cAAc,UAAU,EAAE,MAAM,MAAM,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/editor.ts"],"sourcesContent":["import { protocolRequest } from './sandboxUtils';\nimport { throwOnRefusal } from './protocolRefusal';\nimport { SCHEMES } from './protocolSchemes';\nimport { PROTOCOL_EDITOR } from './generated/protocol';\n\n/**\n * Open a working-tree file in the immediately.run host editor (UI_AS_APPS_SPEC §4 —\n * the file explorer's click-to-open). This is an INTENT: the app asks, the HOST\n * validates the path and drives the CodeMirror editor — the editor itself stays\n * host-owned (§2 recursion boundary), so an app can never own or script it beyond\n * \"please show this file\".\n *\n * Requires the elevated `editor:open` capability — a previewed app does not hold it\n * (it must not move the host's focus), so only a system app whose binding grants it\n * (the file explorer) can call this; anyone else is refused at the gate.\n */\n\n/** An error from {@link openInEditor}, carrying a machine-readable `.code`.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n * documents the `.code` VALUES the host sends; it was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test.\n */\nexport interface EditorOpenError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:open` (or `editor:reveal`, for a `reveal`)\n | 'not-found' // no such file in the live working tree (the host never creates)\n | 'invalid-params' // the path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session to open files in\n | 'unknown';\n}\n\ntype EditorResult = { ok: true; data: unknown } | { ok: false; code: string; message: string };\n\nconst editorRequest = async (method: string, arg: Record<string, unknown>): Promise<void> => {\n const res = (await protocolRequest(SCHEMES[PROTOCOL_EDITOR], method, [arg])) as EditorResult;\n throwOnRefusal(res, `editor ${method} failed`);\n};\n\n/** Where in a file to land when opening it (R3-388). 1-indexed `line`, matching every\n * diagnostic producer that feeds it (`tsc`, `eslint`, `BuildError`) and both VS Code\n * and IntelliJ. A `line` past end-of-file CLAMPS to the last line rather than\n * erroring — a diagnostic outlives the edit that shortened the file, and landing\n * close beats refusing to navigate. */\nexport interface EditorSelection {\n line: number;\n column?: number;\n}\n\n/** Options for {@link openInEditor} (R3-389). */\nexport interface EditorOpenOptions {\n /** Also bring the user to the editor, ACROSS activities (TOOLS_ACTIVITY_SPEC §5.2).\n * An app that owns the main pane (the Tools activity's runner sits where the editor\n * would) cannot rely on the file simply becoming visible — the editor is not on\n * screen — so this asks the host to switch to the activity that owns it.\n *\n * This is the elevated `editor:reveal` capability, not `editor:open`: a frame\n * without it is refused `forbidden` for the whole call (the file is NOT opened —\n * never silently opened-without-moving). The host decides whether the user actually\n * moves: it needs a real user gesture (a click in your frame within the last few\n * seconds counts; a call on a timer or on run completion does not) and is\n * rate-limited. The promise resolves the same either way, so treat a resolved\n * reveal as \"asked\", not \"moved\", and keep a visible fallback control. Where the\n * host owns the editor activity is host state; nothing here can name it. */\n reveal?: boolean;\n}\n\n/**\n * Ask the host to open `path` (a repo-relative working-tree path, e.g. `src/App.tsx`\n * or `/src/App.tsx`) in the editor. Resolves once the editor switches to it; rejects\n * with an {@link EditorOpenError} (`.code`) if the path is invalid, missing, or this\n * app may not open files.\n *\n * Pass `selection` to land the caret on a specific line — what a problems list needs\n * to make a diagnostic clickable. It widens nothing: a selection says where to look\n * inside a file the caller could already open, and the capability is unchanged\n * (`editor:open`).\n *\n * Pass `{ reveal: true }` to ALSO bring the user to the editor across activities —\n * see {@link EditorOpenOptions.reveal}; that one does need the elevated\n * `editor:reveal`, and is refused outright without it.\n *\n * Older hosts ignore `selection` and open the file at its existing position, so a\n * caller may pass it unconditionally. `reveal` is only sent when true, so a host that\n * predates it sees a plain open.\n */\nexport const openInEditor = (path: string, selection?: EditorSelection, opts?: EditorOpenOptions): Promise<void> =>\n editorRequest('open', {\n path,\n ...(selection ? { selection } : {}),\n ...(opts?.reveal === true ? { reveal: true } : {}),\n });\n\n/**\n * Where to land when entering the edit experience (EDITOR_FIRST_EDITING_SPEC §6).\n *\n * Two target classes, and **at most one** may be given — supplying both is refused\n * `invalid-params`. Omit both to edit the current route's entry.\n *\n * - **Own-source** (`path`): a repo-relative path in the CURRENT repo. Self-scoped —\n * the app you are already running; the host navigates within the current route,\n * never to another repo.\n * - **Mount-file** (`file`): a file in a mount you ALREADY HOLD, opened in the main\n * edit experience (§9, settled 2026-08-28). You can only name a mount you hold: an\n * unheld one is `forbidden`, and indistinguishably so from one that does not exist,\n * because an app must not be able to probe for mounts (no existence oracle).\n * Editing a file *outside* your mounts stays picker-mediated (`pick-file`).\n *\n * A URI, a `..` segment, or a NUL is refused `invalid-params` in either class.\n */\nexport interface EditTarget {\n /** A repo-relative working-tree path in the current repo to focus once in edit\n * mode (e.g. `src/App.tsx`). Omit to edit the current route's entry. */\n path?: string;\n /** A file in one of YOUR OWN mounts, by the portable mount reference. `relPath` is\n * mount-relative and leading-slash (e.g. `/notes/idea.mdx`). Mutually exclusive\n * with {@link EditTarget.path}.\n *\n * There is no `mode` here on purpose: writability is the HOST's live reading of\n * the mount, not the caller's claim. A `ro` mount — which is also how an anonymous\n * share-link viewer surfaces — is refused `read-only` at call time, before the\n * editor is entered, so you never land in an editor that cannot save. */\n file?: { mountId: string; relPath: string };\n}\n\n/** An error from {@link requestEdit}, carrying a machine-readable `.code`.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n * documents the `.code` VALUES the host sends; it was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test.\n */\nexport interface RequestEditError extends Error {\n code:\n | 'read-only' // editing isn't possible here (a `ro` mount / anonymous viewer) — HIDE the affordance\n | 'forbidden' // the host refuses: a cross-repo target, or a mount you do not hold\n | 'invalid-params' // the target was malformed (URI / `..` / NUL / both target classes at once)\n | 'not-found' // the mount-file target does not exist — and asking did NOT create it\n | 'no-target' // there is no host editor session to enter\n | 'unknown';\n}\n\n/**\n * Ask the host to enter the **edit experience** for the app you are running —\n * the present→edit transition (`/present/...` → `/edit/...`) an app cannot make\n * itself. This is an INTENT (§2 recursion boundary): the app asks, the HOST\n * performs the visible, user-observable navigation and draws all editor chrome;\n * the app never navigates or paints chrome.\n *\n * Use it to offer an \"edit this\" affordance from a run/present-mode app that opens\n * the app's own source in the platform editor — instead of shipping a bespoke\n * in-app editor (EDITOR_FIRST_EDITING_SPEC §1).\n *\n * Also opens a file from a mount you already hold, in the main edit experience:\n *\n * await requestEdit({ file: { mountId: 'space:abc', relPath: '/notes/idea.mdx' } });\n *\n * Resolves once the host begins the transition; rejects with a\n * {@link RequestEditError} (`.code`). Treat `read-only`/`forbidden` as \"editing is\n * not available — hide the affordance,\" never as an error to surface to the user.\n * `not-found` means the file is not there; nothing is created by asking to edit it.\n */\nexport const requestEdit = (target?: EditTarget): Promise<void> =>\n editorRequest('requestEdit', target ? { ...target } : {});\n\n// ---------------------------------------------------------------------------\n// Editor SESSION management (EDITOR_AS_APP_SPEC §5.1; editor-as-app plan Phase\n// 03). Unlike `openInEditor` (the explorer's cross-app intent, `editor:open`),\n// these drive the editor's OWN open-tab set + active file, so they are gated by\n// the editor app's `editor:document` capability — a file explorer holding only\n// `editor:open` cannot call them. The host re-validates the path against the live\n// working tree; the editor itself stays host-owned (§2 recursion boundary).\n// ---------------------------------------------------------------------------\n\n/** An error from a session intent ({@link setActiveFile} / {@link closeFile}),\n * carrying a machine-readable `.code`.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n * documents the `.code` VALUES the host sends; it was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test.\n */\nexport interface EditorSessionError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:document`\n | 'not-found' // no such file in the live working tree\n | 'invalid-params' // the path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session\n | 'unknown';\n}\n\n/** Switch the editor's active file to `path`, opening it (adding a tab) if it is\n * not already open — native `setActiveFile` parity. Rejects with an\n * {@link EditorSessionError} (`.code`) if the path is missing/invalid or this app\n * lacks `editor:document`. */\nexport const setActiveFile = (path: string): Promise<void> => editorRequest('setActive', { path });\n\n/** Close `path`'s tab in the editor (remove it from the open set) — native\n * `closeFile` parity. Rejects with an {@link EditorSessionError} (`.code`). */\nexport const closeFile = (path: string): Promise<void> => editorRequest('close', { path });\n\n// ---------------------------------------------------------------------------\n// Working-tree mutation (UI_AS_APPS_SPEC §4 / EDITOR_AS_APP_SPEC §5.2). The file\n// explorer NAMES a working-tree path and the HOST performs the COW write (and\n// refreshes the preview) — the app holds no write port; it asks. Gated by the\n// first-party `editor:write` capability, so only a first-party chrome app (the\n// file explorer) can call these; anyone else is refused at the gate.\n// ---------------------------------------------------------------------------\n\n/** An error from a working-tree mutation, carrying a machine-readable `.code`.\n *\n * **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n * `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n * documents the `.code` VALUES the host sends; it was always a cast and is not enforced at\n * runtime, so treat an unlisted code as possible and `instanceof Error` as the only\n * reliable test.\n */\nexport interface EditorWriteError extends Error {\n code:\n | 'forbidden' // the frame lacks `editor:write` (first-party-only)\n | 'not-found' // the target file/folder does not exist (delete/rename)\n | 'exists' // the target already exists (create/rename would clobber)\n | 'protected' // the host refuses to delete this file (e.g. package.json)\n | 'too-large' // an upload exceeds the host's size limit\n | 'invalid-params' // a path was empty / contained `..` / looked like a URI\n | 'no-target' // there is no host editor session\n | 'unknown';\n}\n\n/** Create an empty working-tree file at `path` and open it. Rejects `exists` if a\n * file is already there — see {@link EditorWriteError} for the full code list, which\n * every helper below shares. */\nexport const createFile = (path: string): Promise<void> => editorRequest('createFile', { path });\n\n/** Create a working-tree folder at `path` (materialised with a `.gitkeep`). */\nexport const createFolder = (path: string): Promise<void> => editorRequest('createFolder', { path });\n\n/** Delete a working-tree file, or a folder and everything under it. Rejects\n * `protected` for files the host won't remove, `not-found` if absent. */\nexport const deleteEntry = (path: string): Promise<void> => editorRequest('deleteEntry', { path });\n\n/** Rename/move a working-tree file from `from` to `to`. Rejects `exists` if `to`\n * is taken, `not-found` if `from` is absent. */\nexport const renameEntry = (from: string, to: string): Promise<void> => editorRequest('rename', { from, to });\n\n/** Upload binary/text `bytes` to a working-tree file at `path`. Rejects\n * `too-large` past the host's size limit. The bytes are transferred (zero-copy). */\nexport const uploadFile = (path: string, bytes: Uint8Array): Promise<void> => editorRequest('upload', { path, bytes });\n"],"mappings":";AAAA,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAiChC,MAAM,gBAAgB,OAAO,QAAgB,QAAgD;AAC3F,QAAM,MAAO,MAAM,gBAAgB,QAAQ,eAAe,GAAG,QAAQ,CAAC,GAAG,CAAC;AAC1E,iBAAe,KAAK,UAAU,MAAM,SAAS;AAC/C;AAiDO,MAAM,eAAe,CAAC,MAAc,WAA6B,SACtE,cAAc,QAAQ;AAAA,EACpB;AAAA,EACA,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;AAAA,EACjC,GAAI,MAAM,WAAW,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC;AAClD,CAAC;AAwEI,MAAM,cAAc,CAAC,WAC1B,cAAc,eAAe,SAAS,EAAE,GAAG,OAAO,IAAI,CAAC,CAAC;AAiCnD,MAAM,gBAAgB,CAAC,SAAgC,cAAc,aAAa,EAAE,KAAK,CAAC;AAI1F,MAAM,YAAY,CAAC,SAAgC,cAAc,SAAS,EAAE,KAAK,CAAC;AAiClF,MAAM,aAAa,CAAC,SAAgC,cAAc,cAAc,EAAE,KAAK,CAAC;AAGxF,MAAM,eAAe,CAAC,SAAgC,cAAc,gBAAgB,EAAE,KAAK,CAAC;AAI5F,MAAM,cAAc,CAAC,SAAgC,cAAc,eAAe,EAAE,KAAK,CAAC;AAI1F,MAAM,cAAc,CAAC,MAAc,OAA8B,cAAc,UAAU,EAAE,MAAM,GAAG,CAAC;AAIrG,MAAM,aAAa,CAAC,MAAc,UAAqC,cAAc,UAAU,EAAE,MAAM,MAAM,CAAC;","names":[]}
|
|
@@ -19,15 +19,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var spaces_exports = {};
|
|
20
20
|
__export(spaces_exports, {
|
|
21
21
|
acceptInvite: () => acceptInvite,
|
|
22
|
+
convertSpaceToShared: () => convertSpaceToShared,
|
|
22
23
|
declineInvite: () => declineInvite,
|
|
24
|
+
deleteSpace: () => deleteSpace,
|
|
23
25
|
getSpaceMembers: () => getSpaceMembers,
|
|
24
26
|
inviteToSpace: () => inviteToSpace,
|
|
27
|
+
leaveSpace: () => leaveSpace,
|
|
25
28
|
listAllSpaces: () => listAllSpaces,
|
|
26
29
|
listGrants: () => listGrants,
|
|
27
30
|
listMyInvites: () => listMyInvites,
|
|
28
31
|
listPendingInvites: () => listPendingInvites,
|
|
29
32
|
listSpaces: () => listSpaces,
|
|
30
33
|
lookupUser: () => lookupUser,
|
|
34
|
+
renameSpace: () => renameSpace,
|
|
35
|
+
restoreSpace: () => restoreSpace,
|
|
31
36
|
revokeGrant: () => revokeGrant,
|
|
32
37
|
revokeInvite: () => revokeInvite,
|
|
33
38
|
setSpaceRole: () => setSpaceRole,
|
|
@@ -114,18 +119,53 @@ const declineInvite = withTry(
|
|
|
114
119
|
},
|
|
115
120
|
"unknown"
|
|
116
121
|
);
|
|
122
|
+
const deleteSpace = withTry(
|
|
123
|
+
async (spaceId) => {
|
|
124
|
+
await (0, import_catalog.invoke)("spaces:delete", { spaceId, confirm: true });
|
|
125
|
+
},
|
|
126
|
+
"unknown"
|
|
127
|
+
);
|
|
128
|
+
const restoreSpace = withTry(
|
|
129
|
+
async (spaceId) => {
|
|
130
|
+
await (0, import_catalog.invoke)("spaces:restore", { spaceId, confirm: true });
|
|
131
|
+
},
|
|
132
|
+
"unknown"
|
|
133
|
+
);
|
|
134
|
+
const leaveSpace = withTry(
|
|
135
|
+
async (spaceId) => {
|
|
136
|
+
await (0, import_catalog.invoke)("spaces:leave", { spaceId, confirm: true });
|
|
137
|
+
},
|
|
138
|
+
"unknown"
|
|
139
|
+
);
|
|
140
|
+
const renameSpace = withTry(
|
|
141
|
+
async (spaceId, name) => {
|
|
142
|
+
await (0, import_catalog.invoke)("spaces:rename", { spaceId, name });
|
|
143
|
+
},
|
|
144
|
+
"unknown"
|
|
145
|
+
);
|
|
146
|
+
const convertSpaceToShared = withTry(
|
|
147
|
+
async (spaceId) => {
|
|
148
|
+
await (0, import_catalog.invoke)("spaces:convertToShared", { spaceId, confirm: true });
|
|
149
|
+
},
|
|
150
|
+
"unknown"
|
|
151
|
+
);
|
|
117
152
|
// Annotate the CommonJS export names for ESM import in node:
|
|
118
153
|
0 && (module.exports = {
|
|
119
154
|
acceptInvite,
|
|
155
|
+
convertSpaceToShared,
|
|
120
156
|
declineInvite,
|
|
157
|
+
deleteSpace,
|
|
121
158
|
getSpaceMembers,
|
|
122
159
|
inviteToSpace,
|
|
160
|
+
leaveSpace,
|
|
123
161
|
listAllSpaces,
|
|
124
162
|
listGrants,
|
|
125
163
|
listMyInvites,
|
|
126
164
|
listPendingInvites,
|
|
127
165
|
listSpaces,
|
|
128
166
|
lookupUser,
|
|
167
|
+
renameSpace,
|
|
168
|
+
restoreSpace,
|
|
129
169
|
revokeGrant,
|
|
130
170
|
revokeInvite,
|
|
131
171
|
setSpaceRole,
|