@silo-code/sdk 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/context-keys.d.ts +19 -0
- package/dist/context-keys.d.ts.map +1 -0
- package/dist/context-keys.js +2 -0
- package/dist/context-keys.js.map +1 -0
- package/dist/dnd-service.d.ts +140 -0
- package/dist/dnd-service.d.ts.map +1 -0
- package/dist/dnd-service.js +17 -0
- package/dist/dnd-service.js.map +1 -0
- package/dist/domain-types.d.ts +237 -0
- package/dist/domain-types.d.ts.map +1 -0
- package/dist/domain-types.js +11 -0
- package/dist/domain-types.js.map +1 -0
- package/dist/editor-service.d.ts +175 -0
- package/dist/editor-service.d.ts.map +1 -0
- package/dist/editor-service.js +2 -0
- package/dist/editor-service.js.map +1 -0
- package/dist/extension-storage.d.ts +26 -0
- package/dist/extension-storage.d.ts.map +1 -0
- package/dist/extension-storage.js +2 -0
- package/dist/extension-storage.js.map +1 -0
- package/dist/file-service.d.ts +84 -0
- package/dist/file-service.d.ts.map +1 -0
- package/dist/file-service.js +2 -0
- package/dist/file-service.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/layout-service.d.ts +46 -0
- package/dist/layout-service.d.ts.map +1 -0
- package/dist/layout-service.js +2 -0
- package/dist/layout-service.js.map +1 -0
- package/dist/permissions.d.ts +41 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +40 -0
- package/dist/permissions.js.map +1 -0
- package/dist/process-service.d.ts +132 -0
- package/dist/process-service.d.ts.map +1 -0
- package/dist/process-service.js +2 -0
- package/dist/process-service.js.map +1 -0
- package/dist/terminal-service.d.ts +38 -0
- package/dist/terminal-service.d.ts.map +1 -0
- package/dist/terminal-service.js +2 -0
- package/dist/terminal-service.js.map +1 -0
- package/dist/theme-service.d.ts +87 -0
- package/dist/theme-service.d.ts.map +1 -0
- package/dist/theme-service.js +2 -0
- package/dist/theme-service.js.map +1 -0
- package/dist/types.d.ts +495 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui-service.d.ts +469 -0
- package/dist/ui-service.d.ts.map +1 -0
- package/dist/ui-service.js +2 -0
- package/dist/ui-service.js.map +1 -0
- package/dist/use-focus-group.d.ts +202 -0
- package/dist/use-focus-group.d.ts.map +1 -0
- package/dist/use-focus-group.js +236 -0
- package/dist/use-focus-group.js.map +1 -0
- package/dist/use-service-state.d.ts +36 -0
- package/dist/use-service-state.d.ts.map +1 -0
- package/dist/use-service-state.js +25 -0
- package/dist/use-service-state.js.map +1 -0
- package/dist/workspace-service.d.ts +72 -0
- package/dist/workspace-service.d.ts.map +1 -0
- package/dist/workspace-service.js +2 -0
- package/dist/workspace-service.js.map +1 -0
- package/package.json +54 -0
- package/src/context-keys.ts +18 -0
- package/src/dnd-service.ts +151 -0
- package/src/domain-types.ts +252 -0
- package/src/editor-service.ts +196 -0
- package/src/extension-storage.ts +25 -0
- package/src/file-service.ts +90 -0
- package/src/index.ts +151 -0
- package/src/layout-service.ts +49 -0
- package/src/permissions.ts +55 -0
- package/src/process-service.ts +143 -0
- package/src/terminal-service.ts +41 -0
- package/src/theme-service.ts +102 -0
- package/src/types.ts +513 -0
- package/src/ui-service.ts +487 -0
- package/src/use-focus-group.test.ts +168 -0
- package/src/use-focus-group.ts +382 -0
- package/src/use-service-state.ts +43 -0
- package/src/workspace-service.ts +76 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { Disposable } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the editor open methods.
|
|
4
|
+
*
|
|
5
|
+
* @category Consumer Services
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface OpenFileOptions {
|
|
9
|
+
/** Target workspace. Defaults to the active workspace. */
|
|
10
|
+
workspaceId?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Open as a preview tab (single-click style — replaced by the next preview,
|
|
13
|
+
* italic title) instead of a permanent editor. Defaults to false.
|
|
14
|
+
*/
|
|
15
|
+
preview?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Open with a specific editor view — an {@link Editor.id}, e.g. from an
|
|
18
|
+
* "Open With" menu. Persisted on the tab as {@link EditorRecord.viewType}.
|
|
19
|
+
* Ignored if no registered editor with that id matches the path (the host
|
|
20
|
+
* falls back to the highest-priority match). When omitted the default view is
|
|
21
|
+
* used and any existing tab's view is left unchanged.
|
|
22
|
+
*/
|
|
23
|
+
viewType?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* One editor view that can render a given file — its id, user-facing label, and
|
|
27
|
+
* whether it is the view the host would pick by default. Returned by
|
|
28
|
+
* {@link EditorService.editorsFor}; used to build "Open With" menus and the
|
|
29
|
+
* breadcrumb view-switcher.
|
|
30
|
+
*
|
|
31
|
+
* @category Consumer Services
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export interface EditorViewInfo {
|
|
35
|
+
/** The editor's id (an {@link Editor.id}); pass back as `viewType`. */
|
|
36
|
+
id: string;
|
|
37
|
+
/** Human-facing label (falls back to {@link EditorViewInfo.id}). */
|
|
38
|
+
label: string;
|
|
39
|
+
/** True for the editor the host resolves by default (highest priority). */
|
|
40
|
+
isDefault: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Save callbacks an editor viewer registers via
|
|
44
|
+
* {@link EditorService.registerSaveHandler}, so the active-editor `save` /
|
|
45
|
+
* `saveAs` commands can dispatch to whichever editor is focused.
|
|
46
|
+
*
|
|
47
|
+
* @category Consumer Services
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export interface EditorSaveHandlers {
|
|
51
|
+
/** Save the editor's contents. */
|
|
52
|
+
save: () => void | Promise<void>;
|
|
53
|
+
/** Save-as (prompt for a new path). Optional. */
|
|
54
|
+
saveAs?: () => void | Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* What to open in a diff view, passed to {@link EditorService.openDiff}. The
|
|
58
|
+
* diff is **generic** — it renders two contents and knows nothing about where
|
|
59
|
+
* they come from. `providerId` names a {@link DiffContentProvider} (registered
|
|
60
|
+
* via {@link EditorService.registerDiffContentProvider}) that resolves the two
|
|
61
|
+
* sides; `args` is the serializable payload that provider needs (e.g. a git
|
|
62
|
+
* revision/mode) and is persisted so the content can be recomputed on restart.
|
|
63
|
+
*
|
|
64
|
+
* @category Consumer Services
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
export interface OpenDiffSpec {
|
|
68
|
+
/** The file the diff is OF — drives language detection, breadcrumb, title. */
|
|
69
|
+
filePath: string;
|
|
70
|
+
/** Id of the registered content provider that resolves the two sides. */
|
|
71
|
+
providerId: string;
|
|
72
|
+
/** Serializable args handed back to the provider to (re)compute content. */
|
|
73
|
+
args?: Record<string, unknown>;
|
|
74
|
+
/** Tab title. Defaults to the file's base name. */
|
|
75
|
+
title?: string;
|
|
76
|
+
}
|
|
77
|
+
/** The two sides of a diff, resolved by a {@link DiffContentProvider}.
|
|
78
|
+
*
|
|
79
|
+
* @category Consumer Services
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export interface DiffContent {
|
|
83
|
+
/** Left/original side. */
|
|
84
|
+
original: string;
|
|
85
|
+
/** Right/modified side. */
|
|
86
|
+
modified: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The request a {@link DiffContentProvider} receives to resolve a diff's two
|
|
90
|
+
* sides — the {@link OpenDiffSpec}'s `filePath`/`args` plus the folder of the
|
|
91
|
+
* workspace the diff lives in (the natural cwd for path-relative providers).
|
|
92
|
+
*
|
|
93
|
+
* @category Consumer Services
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export interface DiffContentRequest {
|
|
97
|
+
/** The file the diff is OF (from {@link OpenDiffSpec.filePath}). */
|
|
98
|
+
filePath: string;
|
|
99
|
+
/** The provider's args (from {@link OpenDiffSpec.args}). */
|
|
100
|
+
args?: Record<string, unknown>;
|
|
101
|
+
/** Folder of the workspace the diff lives in, or `null` if none. */
|
|
102
|
+
workspaceFolder: string | null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Resolves the two sides of a diff on demand — called by the host whenever a
|
|
106
|
+
* diff panel mounts (open, tab switch, app restart), so content stays a pure
|
|
107
|
+
* computed view and never has to be persisted. Register one with
|
|
108
|
+
* {@link EditorService.registerDiffContentProvider}.
|
|
109
|
+
*
|
|
110
|
+
* @category Consumer Services
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export type DiffContentProvider = (request: DiffContentRequest) => Promise<DiffContent>;
|
|
114
|
+
/**
|
|
115
|
+
* The editor & document domain, exposed as {@link ExtensionContext.editors}.
|
|
116
|
+
* Open files into editor tabs, drive the active editor (save / close), and let
|
|
117
|
+
* editor viewers register save handlers. The single entry point for opening
|
|
118
|
+
* editors — prefer it over reaching into workspace/editor state.
|
|
119
|
+
*
|
|
120
|
+
* @category Consumer Services
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
export interface EditorService {
|
|
124
|
+
/**
|
|
125
|
+
* Open a file in an editor tab. Promotes an existing preview, focuses an
|
|
126
|
+
* already-open tab, or opens a new one.
|
|
127
|
+
*/
|
|
128
|
+
open(path: string, opts?: OpenFileOptions): void;
|
|
129
|
+
/** Open a fresh untitled editor. */
|
|
130
|
+
openUntitled(opts?: OpenFileOptions): void;
|
|
131
|
+
/**
|
|
132
|
+
* Open a diff view. The content is supplied by the {@link OpenDiffSpec.providerId | provider}
|
|
133
|
+
* named in `spec` — the editor itself is content-agnostic.
|
|
134
|
+
*/
|
|
135
|
+
openDiff(spec: OpenDiffSpec, opts?: OpenFileOptions): void;
|
|
136
|
+
/** Save the active editor. Returns false if there's no active saveable editor. */
|
|
137
|
+
save(): boolean;
|
|
138
|
+
/** Save-as the active editor. Returns false if unavailable. */
|
|
139
|
+
saveAs(): boolean;
|
|
140
|
+
/** Close the active dock panel. Returns false if there's nothing to close. */
|
|
141
|
+
closeActive(): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* List the editor views that match `path` (or `null` for an untitled buffer),
|
|
144
|
+
* highest-priority first, each flagged whether it's the one the host resolves
|
|
145
|
+
* by default. Read-only enumeration for building "Open With" menus and the
|
|
146
|
+
* breadcrumb view-switcher. Returns `[]` only when nothing matches — in
|
|
147
|
+
* practice never empty for a real path, since the core text editor matches
|
|
148
|
+
* everything.
|
|
149
|
+
*/
|
|
150
|
+
editorsFor(path: string | null): EditorViewInfo[];
|
|
151
|
+
/**
|
|
152
|
+
* Switch an already-open editor tab to a different view in place — without
|
|
153
|
+
* closing and reopening it — and persist the choice on the tab. No-op if the
|
|
154
|
+
* editor isn't found, `viewType` names no registered editor, or that editor
|
|
155
|
+
* doesn't match the tab's file. The panel remounts onto the new view, so
|
|
156
|
+
* per-instance state (scroll, selection) resets — expected, it's a different
|
|
157
|
+
* presenter.
|
|
158
|
+
*/
|
|
159
|
+
setViewType(editorId: string, viewType: string, opts?: {
|
|
160
|
+
workspaceId?: string;
|
|
161
|
+
}): void;
|
|
162
|
+
/**
|
|
163
|
+
* Register save handlers for an editor instance (by its `editorId`), so the
|
|
164
|
+
* active-editor `save` / `saveAs` dispatch to it while it's focused. Dispose
|
|
165
|
+
* to unregister (do this when the editor unmounts).
|
|
166
|
+
*/
|
|
167
|
+
registerSaveHandler(editorId: string, handlers: EditorSaveHandlers): Disposable;
|
|
168
|
+
/**
|
|
169
|
+
* Register a {@link DiffContentProvider} under `providerId`. A diff opened
|
|
170
|
+
* with that `providerId` (see {@link OpenDiffSpec}) resolves its two sides
|
|
171
|
+
* through this provider, on every mount. Dispose to unregister.
|
|
172
|
+
*/
|
|
173
|
+
registerDiffContentProvider(providerId: string, provider: DiffContentProvider): Disposable;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=editor-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-service.d.ts","sourceRoot":"","sources":["../src/editor-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAM1C;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,IAAI,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,oEAAoE;IACpE,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,kBAAkB,KACxB,OAAO,CAAC,WAAW,CAAC,CAAC;AAE1B;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACjD,oCAAoC;IACpC,YAAY,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3D,kFAAkF;IAClF,IAAI,IAAI,OAAO,CAAC;IAChB,+DAA+D;IAC/D,MAAM,IAAI,OAAO,CAAC;IAClB,8EAA8E;IAC9E,WAAW,IAAI,OAAO,CAAC;IACvB;;;;;;;OAOG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,cAAc,EAAE,CAAC;IAClD;;;;;;;OAOG;IACH,WAAW,CACT,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9B,IAAI,CAAC;IACR;;;;OAIG;IACH,mBAAmB,CACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,kBAAkB,GAC3B,UAAU,CAAC;IACd;;;;OAIG;IACH,2BAA2B,CACzB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,mBAAmB,GAC5B,UAAU,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-service.js","sourceRoot":"","sources":["../src/editor-service.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Namespaced, persisted key/value storage handed to side-panel components
|
|
3
|
+
* via `SidePanelProps.storage`. Each panel id gets its own bag; values are
|
|
4
|
+
* persisted alongside the rest of the app state.
|
|
5
|
+
*
|
|
6
|
+
* The store is hydrated asynchronously after the panels mount, so consumers
|
|
7
|
+
* that need to wait for restored values should check `props.hydrated` or
|
|
8
|
+
* use `subscribe` to re-read once it flips.
|
|
9
|
+
*
|
|
10
|
+
* @category Consumer Services
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface ExtensionStorage {
|
|
14
|
+
/** Read a value. Returns `fallback` if the key is missing. */
|
|
15
|
+
get<T>(key: string): T | undefined;
|
|
16
|
+
get<T>(key: string, fallback: T): T;
|
|
17
|
+
/** Write a value. `undefined` deletes the key. */
|
|
18
|
+
set(key: string, value: unknown): void;
|
|
19
|
+
/**
|
|
20
|
+
* Subscribe to changes in this namespace. Called on any set within this
|
|
21
|
+
* namespace, and also whenever the underlying app state finishes hydrating
|
|
22
|
+
* (so callers can re-read after persisted state loads).
|
|
23
|
+
*/
|
|
24
|
+
subscribe(listener: () => void): () => void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=extension-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-storage.d.ts","sourceRoot":"","sources":["../src/extension-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IACnC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IACpC,kDAAkD;IAClD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-storage.js","sourceRoot":"","sources":["../src/extension-storage.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Disposable } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Metadata for a single directory entry, as returned by
|
|
4
|
+
* {@link FileService.readDir}.
|
|
5
|
+
*
|
|
6
|
+
* @category Core Types
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface FileMeta {
|
|
10
|
+
/** The entry's base name (no path). */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Absolute path to the entry. */
|
|
13
|
+
path: string;
|
|
14
|
+
/** True if the entry is a directory. */
|
|
15
|
+
isDir: boolean;
|
|
16
|
+
/** Size in bytes (0 for directories). */
|
|
17
|
+
size: number;
|
|
18
|
+
/** Last-modified time, milliseconds since the Unix epoch. */
|
|
19
|
+
modifiedMs: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A filesystem change event delivered to a {@link FileService.watch} listener,
|
|
23
|
+
* for changes under that watch's path.
|
|
24
|
+
*
|
|
25
|
+
* @category Core Types
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export interface FileChangeEvent {
|
|
29
|
+
/** The paths that changed in this event. */
|
|
30
|
+
paths: string[];
|
|
31
|
+
/** The backend's change kind (e.g. `"create"`, `"modify"`, `"remove"`). */
|
|
32
|
+
kind: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The filesystem domain, exposed as {@link ExtensionContext.files}. All access
|
|
36
|
+
* is host-mediated: extensions read, write, and watch the filesystem through
|
|
37
|
+
* here rather than calling Tauri directly.
|
|
38
|
+
*
|
|
39
|
+
* **Paths are workspace-scoped.** A relative path resolves against the open
|
|
40
|
+
* workspace folder (`"src/index.ts"` → `<workspace>/src/index.ts`); an absolute
|
|
41
|
+
* path is allowed only if it falls inside a workspace folder. A path outside the
|
|
42
|
+
* workspace throws {@link PathDeniedError} unless the extension declared the
|
|
43
|
+
* matching {@link Permission} (`fs:read` for reads, `fs:write` for writes).
|
|
44
|
+
* First-party (bundled) extensions are unscoped. Prefer relative paths — they're
|
|
45
|
+
* portable across machines.
|
|
46
|
+
*
|
|
47
|
+
* Watching is host-owned: {@link FileService.watch} expresses intent — "tell me
|
|
48
|
+
* about changes under this path" — and the host owns the underlying OS
|
|
49
|
+
* watcher(s). Many in-workspace subscriptions are served from a single,
|
|
50
|
+
* ref-counted workspace watcher the host manages; extensions never start or
|
|
51
|
+
* stop watchers themselves, and each listener receives only events scoped to
|
|
52
|
+
* its path.
|
|
53
|
+
*
|
|
54
|
+
* @category Consumer Services
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export interface FileService {
|
|
58
|
+
/** Read a file's contents as UTF-8 text. */
|
|
59
|
+
readText(path: string): Promise<string>;
|
|
60
|
+
/** Read a file's raw bytes. */
|
|
61
|
+
readBytes(path: string): Promise<ArrayBuffer>;
|
|
62
|
+
/** List a directory's immediate entries. */
|
|
63
|
+
readDir(path: string): Promise<FileMeta[]>;
|
|
64
|
+
/** Resolve true if a file or directory exists at `path`. */
|
|
65
|
+
pathExists(path: string): Promise<boolean>;
|
|
66
|
+
/** Write UTF-8 text to a file, creating or overwriting it. */
|
|
67
|
+
writeText(path: string, content: string): Promise<void>;
|
|
68
|
+
/** Create a directory (and any missing parents). */
|
|
69
|
+
createDir(path: string): Promise<void>;
|
|
70
|
+
/** Rename / move a file or directory. */
|
|
71
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
72
|
+
/** Delete a file or directory. */
|
|
73
|
+
delete(path: string): Promise<void>;
|
|
74
|
+
/** Reveal a path in the OS file manager (Finder / Explorer). */
|
|
75
|
+
reveal(path: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Watch `path` recursively, invoking `listener` for each change under it.
|
|
78
|
+
* Returns a {@link Disposable} that stops listening when disposed. Watcher
|
|
79
|
+
* lifecycle is the host's concern — in-workspace paths ride the host's
|
|
80
|
+
* ref-counted workspace watcher rather than each spinning up its own.
|
|
81
|
+
*/
|
|
82
|
+
watch(path: string, listener: (event: FileChangeEvent) => void): Disposable;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=file-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-service.d.ts","sourceRoot":"","sources":["../src/file-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAM1C;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,KAAK,EAAE,OAAO,CAAC;IACf,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,+BAA+B;IAC/B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,4CAA4C;IAC5C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3C,4DAA4D;IAC5D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,8DAA8D;IAC9D,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,oDAAoD;IACpD,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,yCAAyC;IACzC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,kCAAkC;IAClC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,gEAAgE;IAChE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC;;;;;OAKG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,GAAG,UAAU,CAAC;CAC7E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-service.js","sourceRoot":"","sources":["../src/file-service.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public Silo extension API surface — the single curated entry point an
|
|
3
|
+
* extension author imports from. This is the seed of the future `@silo-code/sdk`
|
|
4
|
+
* package: it re-exports **only** the blessed, permanently supported types.
|
|
5
|
+
* Anything not re-exported here is host-internal and may change without notice.
|
|
6
|
+
*
|
|
7
|
+
* It is also the entry point the API-reference generator (TypeDoc) reads, so
|
|
8
|
+
* the published reference is exactly this surface — no more, no less.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export type { Disposable, DockPanelApi, EditorProps, EditorCapabilities, Editor, NewFileTemplate, FileType, Command, MenuId, MenuItemContribution, Keybinding, SidePanelProps, SidePanel, DockPanelKind, StatusItem, SettingsPage, ExtensionContext, Extension, ExtensionHandle, } from "./types";
|
|
13
|
+
export type { Workspace, EditorMode, EditorRecord, SidePanelSlot, } from "./domain-types";
|
|
14
|
+
export type { WorkspaceService, WorkspaceState, CreateWorkspaceInput, } from "./workspace-service";
|
|
15
|
+
export type { EditorService, EditorSaveHandlers, OpenFileOptions, EditorViewInfo, OpenDiffSpec, DiffContent, DiffContentRequest, DiffContentProvider, } from "./editor-service";
|
|
16
|
+
export type { LayoutService, LayoutState, SidePanelColumnState, SideLocation, } from "./layout-service";
|
|
17
|
+
export type { ProcessService, ProcessSession, ProcessSpawnOptions, ProcessExecOptions, ProcessExecResult, } from "./process-service";
|
|
18
|
+
export type { TerminalService, CreateTerminalInput, TerminalKind, TerminalRecord, } from "./terminal-service";
|
|
19
|
+
export type { FileService, FileMeta, FileChangeEvent } from "./file-service";
|
|
20
|
+
export type { Permission } from "./permissions";
|
|
21
|
+
export { PathDeniedError } from "./permissions";
|
|
22
|
+
export type { ThemeService, ThemeState, ThemePreset, ResolvedTheme, ThemeBase, ThemeVars, CustomTheme, ThemeExport, } from "./theme-service";
|
|
23
|
+
export type { ExtensionStorage } from "./extension-storage";
|
|
24
|
+
export type { DndService, DndItem, DndMime, DragInit, DndMode, DropContext, DropTargetHandlers, } from "./dnd-service";
|
|
25
|
+
export { DND_MIME } from "./dnd-service";
|
|
26
|
+
export type { UiService, FileFilter, MenuItem, MenuItemTrailing, MenuSeparator, MenuHeader, MenuEntry, ShowMenuOptions, ConfirmOptions, PromptOptions, ModalOptions, NotifyAction, NotifyOptions, } from "./ui-service";
|
|
27
|
+
export type { ContextKeys } from "./context-keys";
|
|
28
|
+
export { useServiceState } from "./use-service-state";
|
|
29
|
+
export type { ReactiveService } from "./use-service-state";
|
|
30
|
+
export { useFocusGroup, focusGroupNextIndex } from "./use-focus-group";
|
|
31
|
+
export type { FocusGroup, FocusGroupOptions, FocusGroupContainerProps, FocusGroupItemProps, FocusGroupOrientation, FocusGroupNavQuery, } from "./use-focus-group";
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,YAAY,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,MAAM,EACN,eAAe,EACf,QAAQ,EACR,OAAO,EACP,MAAM,EACN,oBAAoB,EACpB,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,EACb,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,eAAe,GAChB,MAAM,SAAS,CAAC;AAKjB,YAAY,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,aAAa,GACd,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAI7E,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIhD,YAAY,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,YAAY,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,QAAQ,EACR,OAAO,EACP,WAAW,EACX,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,YAAY,EACV,SAAS,EACT,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,SAAS,EACT,eAAe,EACf,cAAc,EACd,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public Silo extension API surface — the single curated entry point an
|
|
3
|
+
* extension author imports from. This is the seed of the future `@silo-code/sdk`
|
|
4
|
+
* package: it re-exports **only** the blessed, permanently supported types.
|
|
5
|
+
* Anything not re-exported here is host-internal and may change without notice.
|
|
6
|
+
*
|
|
7
|
+
* It is also the entry point the API-reference generator (TypeDoc) reads, so
|
|
8
|
+
* the published reference is exactly this surface — no more, no less.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export { PathDeniedError } from "./permissions";
|
|
13
|
+
export { DND_MIME } from "./dnd-service";
|
|
14
|
+
// Runtime helpers. The one blessed way for an extension to read a `ctx`
|
|
15
|
+
// service's reactive state in React — replaces hand-rolled useSyncExternalStore.
|
|
16
|
+
export { useServiceState } from "./use-service-state";
|
|
17
|
+
// Headless keyboard navigation for a focus group (list / menu / toolbar / …):
|
|
18
|
+
// one tab stop, arrow/Home/End movement, the WebKit-safe keyboard ring. The
|
|
19
|
+
// `focusGroupNextIndex` helper is the pure roving-index core for widgets that
|
|
20
|
+
// can't use the focus-driven hook (e.g. menus driven by a document listener).
|
|
21
|
+
export { useFocusGroup, focusGroupNextIndex } from "./use-focus-group";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA2EH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA0BhD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAuBzC,wEAAwE;AACxE,iFAAiF;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,8EAA8E;AAC9E,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Disposable } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Which side column a layout operation targets.
|
|
4
|
+
*
|
|
5
|
+
* @category Consumer Services
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export type SideLocation = "left" | "right";
|
|
9
|
+
/**
|
|
10
|
+
* Collapse state for one side column.
|
|
11
|
+
*
|
|
12
|
+
* @category Consumer Services
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface SidePanelColumnState {
|
|
16
|
+
/** True when the column is collapsed (hidden). */
|
|
17
|
+
collapsed: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An immutable view of side-column layout state.
|
|
21
|
+
*
|
|
22
|
+
* @category Consumer Services
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export interface LayoutState {
|
|
26
|
+
left: SidePanelColumnState;
|
|
27
|
+
right: SidePanelColumnState;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Consumer API for app layout, exposed as {@link ExtensionContext.layout}.
|
|
31
|
+
* Read side-panel collapse state and drive it.
|
|
32
|
+
*
|
|
33
|
+
* @category Consumer Services
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export interface LayoutService {
|
|
37
|
+
/** Current frozen layout state. */
|
|
38
|
+
getState(): LayoutState;
|
|
39
|
+
/** Subscribe to layout changes; dispose to stop. */
|
|
40
|
+
subscribe(listener: (s: LayoutState) => void): Disposable;
|
|
41
|
+
/** Toggle a side column between collapsed and expanded. */
|
|
42
|
+
toggleSidePanel(location: SideLocation): void;
|
|
43
|
+
/** Set a side column's collapsed state explicitly. */
|
|
44
|
+
setSidePanelCollapsed(location: SideLocation, collapsed: boolean): void;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=layout-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-service.d.ts","sourceRoot":"","sources":["../src/layout-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,oBAAoB,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,QAAQ,IAAI,WAAW,CAAC;IACxB,oDAAoD;IACpD,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,GAAG,UAAU,CAAC;IAC1D,2DAA2D;IAC3D,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9C,sDAAsD;IACtD,qBAAqB,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;CACzE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-service.js","sourceRoot":"","sources":["../src/layout-service.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A capability an extension declares in its manifest (`silo.permissions`) to
|
|
3
|
+
* request access **beyond the open workspace**. With none declared, an
|
|
4
|
+
* extension's {@link FileService} / {@link ProcessService} access is confined to
|
|
5
|
+
* the workspace folder(s); each permission lifts one part of that confinement,
|
|
6
|
+
* and the user consents to the set at install.
|
|
7
|
+
*
|
|
8
|
+
* - `fs:read` — read files outside the workspace.
|
|
9
|
+
* - `fs:write` — write files outside the workspace.
|
|
10
|
+
* - `process` — run commands with a working directory outside the workspace.
|
|
11
|
+
* - `network` — make outbound network requests. Declarative consent only until
|
|
12
|
+
* sandboxed execution lands (in-process code can reach the network directly);
|
|
13
|
+
* declare it so the capability is reviewable and shown at install.
|
|
14
|
+
*
|
|
15
|
+
* @category Extension Contract
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export type Permission = "fs:read" | "fs:write" | "process" | "network";
|
|
19
|
+
/**
|
|
20
|
+
* Thrown by {@link FileService} and {@link ProcessService} when an extension
|
|
21
|
+
* touches a path — or runs a process with a working directory — outside the open
|
|
22
|
+
* workspace without the matching {@link Permission}. Catch it and degrade
|
|
23
|
+
* gracefully, the same way you'd handle a missing file:
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* try {
|
|
27
|
+
* const text = await ctx.files.readText(path);
|
|
28
|
+
* } catch (err) {
|
|
29
|
+
* if (err instanceof PathDeniedError) showMessage("That file is outside the workspace.");
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @category Core Types
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare class PathDeniedError extends Error {
|
|
37
|
+
/** The offending path, exactly as the extension passed it. */
|
|
38
|
+
readonly path: string;
|
|
39
|
+
constructor(path: string, message?: string);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAExE;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAS3C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// The extension permission surface — what an extension may declare it needs
|
|
2
|
+
// (`silo.permissions` in its manifest) and the error the host throws when an
|
|
3
|
+
// extension reaches outside the workspace without the matching grant. See the
|
|
4
|
+
// "Permissions & access" guide and ADR 0015 (phased security model).
|
|
5
|
+
/**
|
|
6
|
+
* Thrown by {@link FileService} and {@link ProcessService} when an extension
|
|
7
|
+
* touches a path — or runs a process with a working directory — outside the open
|
|
8
|
+
* workspace without the matching {@link Permission}. Catch it and degrade
|
|
9
|
+
* gracefully, the same way you'd handle a missing file:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* try {
|
|
13
|
+
* const text = await ctx.files.readText(path);
|
|
14
|
+
* } catch (err) {
|
|
15
|
+
* if (err instanceof PathDeniedError) showMessage("That file is outside the workspace.");
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @category Core Types
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export class PathDeniedError extends Error {
|
|
23
|
+
constructor(path, message) {
|
|
24
|
+
super(message ?? `Path is outside the workspace: ${path}`);
|
|
25
|
+
/** The offending path, exactly as the extension passed it. */
|
|
26
|
+
Object.defineProperty(this, "path", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
value: void 0
|
|
31
|
+
});
|
|
32
|
+
this.name = "PathDeniedError";
|
|
33
|
+
this.path = path;
|
|
34
|
+
// Restore the prototype chain so `instanceof` works across the down-leveled
|
|
35
|
+
// class output the SDK ships (and across the host↔extension boundary, where
|
|
36
|
+
// there's a single shared SDK instance).
|
|
37
|
+
Object.setPrototypeOf(this, PathDeniedError.prototype);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,qEAAqE;AAqBrE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAIxC,YAAY,IAAY,EAAE,OAAgB;QACxC,KAAK,CAAC,OAAO,IAAI,kCAAkC,IAAI,EAAE,CAAC,CAAC;QAJ7D,8DAA8D;QACrD;;;;;WAAa;QAIpB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,4EAA4E;QAC5E,4EAA4E;QAC5E,yCAAyC;QACzC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;CACF"}
|