@silo-code/sdk 0.21.0 → 0.22.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.
Files changed (45) hide show
  1. package/dist/editor-service.d.ts +135 -3
  2. package/dist/editor-service.d.ts.map +1 -1
  3. package/dist/event.d.ts +28 -0
  4. package/dist/event.d.ts.map +1 -0
  5. package/dist/event.js +2 -0
  6. package/dist/event.js.map +1 -0
  7. package/dist/file-service.d.ts +33 -2
  8. package/dist/file-service.d.ts.map +1 -1
  9. package/dist/index.d.ts +15 -7
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +15 -5
  12. package/dist/index.js.map +1 -1
  13. package/dist/network-service.d.ts +46 -2
  14. package/dist/network-service.d.ts.map +1 -1
  15. package/dist/path.d.ts +62 -0
  16. package/dist/path.d.ts.map +1 -0
  17. package/dist/path.js +150 -0
  18. package/dist/path.js.map +1 -0
  19. package/dist/process-service.d.ts +24 -4
  20. package/dist/process-service.d.ts.map +1 -1
  21. package/dist/processes-service.d.ts +1 -1
  22. package/dist/search-service.d.ts +11 -0
  23. package/dist/search-service.d.ts.map +1 -1
  24. package/dist/system-service.d.ts +2 -2
  25. package/dist/terminal-service.d.ts +37 -0
  26. package/dist/terminal-service.d.ts.map +1 -1
  27. package/dist/types.d.ts +12 -5
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/workspace-service.d.ts +13 -0
  30. package/dist/workspace-service.d.ts.map +1 -1
  31. package/package.json +1 -1
  32. package/src/editor-service.ts +141 -5
  33. package/src/event.ts +28 -0
  34. package/src/file-service.ts +33 -2
  35. package/src/index.ts +24 -5
  36. package/src/network-service.ts +51 -2
  37. package/src/path.test.ts +135 -0
  38. package/src/path.ts +188 -0
  39. package/src/process-service.ts +24 -4
  40. package/src/processes-service.ts +1 -1
  41. package/src/search-service.ts +11 -0
  42. package/src/system-service.ts +2 -2
  43. package/src/terminal-service.ts +40 -0
  44. package/src/types.ts +12 -5
  45. package/src/workspace-service.ts +13 -0
@@ -1,4 +1,6 @@
1
1
  import type { Disposable } from "./types";
2
+ import type { Event } from "./event";
3
+ import type { EditorMode } from "./domain-types";
2
4
  /**
3
5
  * Options for the editor open methods.
4
6
  *
@@ -58,7 +60,7 @@ export interface EditorViewInfo {
58
60
  isDefault: boolean;
59
61
  }
60
62
  /**
61
- * Save callbacks an editor viewer registers via
63
+ * Save callbacks an editor registers via
62
64
  * {@link EditorService.registerSaveHandler}, so the active-editor `save` /
63
65
  * `saveAs` commands can dispatch to whichever editor is focused.
64
66
  *
@@ -129,11 +131,75 @@ export interface DiffContentRequest {
129
131
  * @public
130
132
  */
131
133
  export type DiffContentProvider = (request: DiffContentRequest) => Promise<DiffContent>;
134
+ /**
135
+ * A point-in-time snapshot of the focused editor tab. Part of
136
+ * {@link EditorsState}, returned by {@link EditorService.getState} and
137
+ * delivered to {@link EditorService.subscribe} listeners.
138
+ *
139
+ * @category Consumer Services
140
+ * @public
141
+ */
142
+ export interface ActiveEditorInfo {
143
+ /** The focused editor tab's record id — matches {@link EditorRecord.id}. */
144
+ editorId: string;
145
+ /**
146
+ * The absolute file path of the focused tab, or `null` for an untitled
147
+ * buffer.
148
+ */
149
+ filePath: string | null;
150
+ /**
151
+ * The {@link Editor.id} of the presenter rendering the tab
152
+ * (e.g. `"core.text-editor"`, `"silo.markdown-preview"`). Empty string
153
+ * when the presenter could not be resolved (rare: editor registered after
154
+ * the tab was opened).
155
+ */
156
+ viewId: string;
157
+ /** Whether the tab is in text or diff mode. */
158
+ mode: EditorMode;
159
+ }
160
+ /**
161
+ * A frozen, referentially-stable snapshot of editor domain state. Returned by
162
+ * {@link EditorService.getState} and delivered to
163
+ * {@link EditorService.subscribe} listeners.
164
+ *
165
+ * Compatible with `useServiceState` — just pass `ctx.editors` directly.
166
+ *
167
+ * @category Consumer Services
168
+ * @public
169
+ */
170
+ export interface EditorsState {
171
+ /**
172
+ * The focused editor tab, or `null` when the active dock panel is not an
173
+ * editor tab (e.g. a terminal, a dock panel kind, or nothing at all).
174
+ */
175
+ active: ActiveEditorInfo | null;
176
+ /**
177
+ * `true` once the persisted workspace state has loaded from disk. Matches
178
+ * `WorkspaceState.hydrated` — guard state-restoring code on this flag.
179
+ */
180
+ hydrated: boolean;
181
+ }
182
+ /**
183
+ * Payload delivered to {@link EditorService.onDidSave} listeners after an
184
+ * editor tab's contents are written to disk.
185
+ *
186
+ * @category Consumer Services
187
+ * @public
188
+ */
189
+ export interface EditorSaveEvent {
190
+ /** The saved tab's editor record id — matches {@link EditorRecord.id}. */
191
+ editorId: string;
192
+ /**
193
+ * Absolute path the contents were written to. For a save-as (or first save
194
+ * of an untitled buffer) this is the newly chosen path, not the old one.
195
+ */
196
+ filePath: string;
197
+ }
132
198
  /**
133
199
  * The editor & document domain, exposed as {@link ExtensionContext.editors}.
134
200
  * Open files into editor tabs, drive the active editor (save / close), and let
135
- * editor viewers register save handlers. The single entry point for opening
136
- * editors — prefer it over reaching into workspace/editor state.
201
+ * editors register save handlers. The single entry point for opening editors —
202
+ * prefer it over reaching into workspace/editor state.
137
203
  *
138
204
  * @category Consumer Services
139
205
  * @public
@@ -189,5 +255,71 @@ export interface EditorService {
189
255
  * through this provider, on every mount. Dispose to unregister.
190
256
  */
191
257
  registerDiffContentProvider(providerId: string, provider: DiffContentProvider): Disposable;
258
+ /**
259
+ * The current buffer text of an open editor tab, including unsaved edits.
260
+ *
261
+ * Resolves `undefined` when the tab isn't text-backed (e.g. the image
262
+ * viewer) or hasn't mounted yet — a lazy-mounted dock panel is **not**
263
+ * force-mounted to read its text. It is async precisely because the text
264
+ * lives in the mounted editor component, not in host state.
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * const text = await ctx.editors.getText(editorId);
269
+ * if (text !== undefined) ctx.log.info(`${text.length} chars`);
270
+ * ```
271
+ */
272
+ getText(editorId: string): Promise<string | undefined>;
273
+ /**
274
+ * Whether an open editor tab has unsaved changes. Returns `false` for an
275
+ * unknown id or a tab that isn't mounted / text-backed.
276
+ */
277
+ isDirty(editorId: string): boolean;
278
+ /**
279
+ * Fires after an editor tab's contents are saved to disk — a formatter,
280
+ * linter, or build-on-save extension's entry point. See {@link Event}.
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * ctx.subscriptions.push(
285
+ * ctx.editors.onDidSave(({ editorId, filePath }) => {
286
+ * ctx.log.info(`saved ${filePath}`);
287
+ * }),
288
+ * );
289
+ * ```
290
+ */
291
+ onDidSave: Event<EditorSaveEvent>;
292
+ /**
293
+ * Current frozen snapshot of editor state. The returned object is
294
+ * referentially stable between renders — `getState() === getState()` when
295
+ * nothing has changed, which satisfies `useSyncExternalStore`'s contract and
296
+ * means `useServiceState(ctx.editors)` works without extra memoization.
297
+ *
298
+ * @example
299
+ * ```ts
300
+ * const { active } = ctx.editors.getState();
301
+ * if (active) ctx.log.info(`Active file: ${active.filePath ?? "(untitled)"}`);
302
+ * ```
303
+ */
304
+ getState(): EditorsState;
305
+ /**
306
+ * Subscribe to changes in the active editor. The listener is called whenever
307
+ * `active` changes (tab focus moves, workspace switches, editor opens or
308
+ * closes) or `hydrated` flips. Returns a {@link Disposable} that cancels the
309
+ * subscription.
310
+ *
311
+ * Use `useServiceState(ctx.editors)` in React components instead of calling
312
+ * `subscribe` directly — it wraps `getState` + `subscribe` for you.
313
+ *
314
+ * @example
315
+ * ```ts
316
+ * ctx.subscriptions.push(
317
+ * ctx.editors.subscribe(({ active }) => {
318
+ * statusItem.setTitle(active?.filePath ?? "No file");
319
+ * }),
320
+ * );
321
+ * ```
322
+ */
323
+ subscribe(listener: (state: EditorsState) => void): Disposable;
192
324
  }
193
325
  //# sourceMappingURL=editor-service.d.ts.map
@@ -1 +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,WAA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,GAAG,UAAU,CAAC;CAChE"}
@@ -0,0 +1,28 @@
1
+ import type { Disposable } from "./types";
2
+ /**
3
+ * A subscribable event: call it with a listener and receive a
4
+ * {@link Disposable} that cancels the subscription. Modeled on VS Code's
5
+ * `Event<T>` convention.
6
+ *
7
+ * Services that emit events expose a member typed as `Event<T>` — the
8
+ * consuming extension calls it directly and pushes the returned disposable
9
+ * onto `ctx.subscriptions`:
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * ctx.subscriptions.push(
14
+ * ctx.editors.onDidSave(({ editorId, filePath }) => {
15
+ * console.log("saved", filePath);
16
+ * }),
17
+ * );
18
+ * ```
19
+ *
20
+ * **Host-side:** the matching emitter (`EventEmitter<T>`) lives in the
21
+ * extension-host package (not the SDK). Only the subscribable `Event<T>` type
22
+ * is public — extensions never construct emitters.
23
+ *
24
+ * @category Core Types
25
+ * @public
26
+ */
27
+ export type Event<T> = (listener: (e: T) => void) => Disposable;
28
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,UAAU,CAAC"}
package/dist/event.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":""}
@@ -74,15 +74,46 @@ export interface FileService {
74
74
  readBytes(path: string): Promise<ArrayBuffer>;
75
75
  /** List a directory's immediate entries. */
76
76
  readDir(path: string): Promise<FileMeta[]>;
77
- /** Resolve true if a file or directory exists at `path`. */
77
+ /**
78
+ * Resolve true if a file or directory exists at `path`. Prefer
79
+ * {@link FileService.stat} when you also need the entry's metadata — `stat`
80
+ * returning non-`null` subsumes this check in one call.
81
+ */
78
82
  pathExists(path: string): Promise<boolean>;
83
+ /**
84
+ * Metadata for a single path, following symlinks, or `null` if nothing
85
+ * exists there. Resolving `null` (rather than rejecting) for an absent path
86
+ * is deliberate — it makes `stat` a one-call replacement for
87
+ * {@link FileService.pathExists} that also returns size / mtime / type.
88
+ * Rejects only on a real I/O error (e.g. a permission failure).
89
+ */
90
+ stat(path: string): Promise<FileMeta | null>;
79
91
  /** Write UTF-8 text to a file, creating or overwriting it. */
80
92
  writeText(path: string, content: string): Promise<void>;
93
+ /**
94
+ * Write raw bytes to a file, creating or overwriting it (and creating any
95
+ * missing parent directories). The byte-oriented counterpart to
96
+ * {@link FileService.writeText} / {@link FileService.readBytes} — use it for
97
+ * binary assets (images, archives) where `writeText` would corrupt the data.
98
+ */
99
+ writeBytes(path: string, data: ArrayBuffer | Uint8Array): Promise<void>;
81
100
  /** Create a directory (and any missing parents). */
82
101
  createDir(path: string): Promise<void>;
102
+ /**
103
+ * Copy a file or directory from `src` to `dest`, recursively for
104
+ * directories, creating any missing parent directories. Requires read access
105
+ * to `src` and write access to `dest` (both are workspace-scoped). Overwrites
106
+ * existing files at the destination.
107
+ */
108
+ copy(src: string, dest: string): Promise<void>;
83
109
  /** Rename / move a file or directory. */
84
110
  rename(oldPath: string, newPath: string): Promise<void>;
85
- /** Delete a file or directory. */
111
+ /**
112
+ * **Permanently** delete a file or directory (directories are removed
113
+ * recursively). This does **not** move the entry to the OS trash/recycle
114
+ * bin — the delete is irreversible, so confirm destructive removals with the
115
+ * user first. Rejects if the path does not exist.
116
+ */
86
117
  delete(path: string): Promise<void>;
87
118
  /** Reveal a path in the OS file manager (Finder / Explorer). */
88
119
  reveal(path: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"file-service.d.ts","sourceRoot":"","sources":["../src/file-service.ts"],"names":[],"mappings":"AAAA,O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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.
2
+ * The `@silo-code/sdk` public surface — the single curated entry point an
3
+ * extension author imports from. Re-exports **only** the blessed, permanently
4
+ * supported types and runtime helpers. Anything not re-exported here is
5
+ * host-internal and may change without notice.
6
6
  *
7
- * It is also the entry point the API-reference generator (TypeDoc) reads, so
7
+ * **What's here:** the types-first extension contract (see `types.ts`) plus a
8
+ * small set of blessed runtime helpers (`Tooltip`, `useFocusGroup`,
9
+ * `useServiceState`, `DND_MIME`, `PathDeniedError`, `NetworkError`). The SDK
10
+ * peer-depends on React 19; changes to the runtime helpers can be breaking
11
+ * even when the types are unchanged.
12
+ *
13
+ * This is also the entry point the API-reference generator (TypeDoc) reads, so
8
14
  * the published reference is exactly this surface — no more, no less.
9
15
  *
10
16
  * @packageDocumentation
@@ -12,7 +18,7 @@
12
18
  export type { Disposable, DockPanelApi, DockPanelProps, EditorProps, EditorCapabilities, Editor, NewFileTemplate, FileType, Command, MenuId, MenuItemContribution, Keybinding, SidePanelProps, SidePanel, DockPanelKind, StatusItem, SettingsPage, ExtensionContext, Extension, ExtensionManifest, ExtensionHandle, } from "./types";
13
19
  export type { Workspace, EditorMode, EditorRecord, SidePanelSlot, } from "./domain-types";
14
20
  export type { WorkspaceService, WorkspaceState, CreateWorkspaceInput, WorkspaceStatusRow, WorkspaceStatusProvider, WorkspaceSectionProps, WorkspaceSectionProvider, WorkspaceBadge, WorkspaceBadgeProvider, } from "./workspace-service";
15
- export type { EditorService, EditorSaveHandlers, OpenFileOptions, EditorViewInfo, OpenDiffSpec, DiffContent, DiffContentRequest, DiffContentProvider, } from "./editor-service";
21
+ export type { EditorService, EditorSaveHandlers, OpenFileOptions, EditorViewInfo, OpenDiffSpec, DiffContent, DiffContentRequest, DiffContentProvider, ActiveEditorInfo, EditorsState, EditorSaveEvent, } from "./editor-service";
16
22
  export type { LayoutService, LayoutState, SidePanelColumnState, SideLocation, } from "./layout-service";
17
23
  export type { ProcessService, ProcessSession, ProcessSpawnOptions, ProcessExecOptions, ProcessExecResult, } from "./process-service";
18
24
  export type { ProcessesService, ProcessInfo, ProcessStats, } from "./processes-service";
@@ -27,10 +33,12 @@ export type { DndService, DndItem, DndMime, DragInit, DndMode, DropContext, Drop
27
33
  export { DND_MIME } from "./dnd-service";
28
34
  export type { UiService, FileFilter, MenuItem, MenuItemTrailing, MenuSeparator, MenuHeader, MenuEntry, ShowMenuOptions, ConfirmOptions, PromptOptions, ModalOptions, NotifyAction, NotifyOptions, } from "./ui-service";
29
35
  export { NetworkError } from "./network-service";
30
- export type { NetworkService, NetworkRequestOptions, NetworkResponse, } from "./network-service";
36
+ export type { NetworkService, NetworkRequestOptions, NetworkResponse, NetworkBytesResponse, } from "./network-service";
31
37
  export type { SystemService, SystemInfo } from "./system-service";
32
38
  export type { LogService, LogLevel } from "./output-service";
33
39
  export type { ContextKeys } from "./context-keys";
40
+ export type { Event } from "./event";
41
+ export { path } from "./path";
34
42
  export { Tooltip } from "./Tooltip";
35
43
  export { useServiceState } from "./use-service-state";
36
44
  export type { ReactiveService } from "./use-service-state";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,YAAY,EACV,UAAU,EACV,YAAY,EACZ,cAAc,EACd,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,iBAAiB,EACjB,eAAe,GAChB,MAAM,SAAS,CAAC;AAKjB,YAAY,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,aAAa,GACd,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,gBAAgB,EACh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,16 @@
1
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.
2
+ * The `@silo-code/sdk` public surface — the single curated entry point an
3
+ * extension author imports from. Re-exports **only** the blessed, permanently
4
+ * supported types and runtime helpers. Anything not re-exported here is
5
+ * host-internal and may change without notice.
6
6
  *
7
- * It is also the entry point the API-reference generator (TypeDoc) reads, so
7
+ * **What's here:** the types-first extension contract (see `types.ts`) plus a
8
+ * small set of blessed runtime helpers (`Tooltip`, `useFocusGroup`,
9
+ * `useServiceState`, `DND_MIME`, `PathDeniedError`, `NetworkError`). The SDK
10
+ * peer-depends on React 19; changes to the runtime helpers can be breaking
11
+ * even when the types are unchanged.
12
+ *
13
+ * This is also the entry point the API-reference generator (TypeDoc) reads, so
8
14
  * the published reference is exactly this surface — no more, no less.
9
15
  *
10
16
  * @packageDocumentation
@@ -13,6 +19,10 @@ export { PathDeniedError } from "./permissions";
13
19
  export { DND_MIME } from "./dnd-service";
14
20
  // Server-side HTTP client — bypasses CORS, readable response headers.
15
21
  export { NetworkError } from "./network-service";
22
+ // Pure path utilities — cross-platform replacement for `node:path` (banned in
23
+ // extensions). All outputs use forward-slash separators. Both "/" and "\" are
24
+ // accepted as input. Exported as a namespaced `path` object.
25
+ export { path } from "./path";
16
26
  // Tooltip — the same styled hover popup the host uses in the status bar.
17
27
  // Extensions use this instead of native `title` attributes to match host chrome.
18
28
  export { Tooltip } from "./Tooltip";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAwGH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA6BhD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAoBzC,sEAAsE;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAkBjD,yEAAyE;AACzE,iFAAiF;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA2GH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA6BhD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAoBzC,sEAAsE;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAuBjD,8EAA8E;AAC9E,8EAA8E;AAC9E,6DAA6D;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,yEAAyE;AACzE,iFAAiF;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,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"}
@@ -34,8 +34,12 @@ export interface NetworkRequestOptions {
34
34
  method?: "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "PATCH";
35
35
  /** Request headers to send. */
36
36
  headers?: Record<string, string>;
37
- /** Request body (string). Only meaningful for methods that carry a body. */
38
- body?: string;
37
+ /**
38
+ * Request body. A string is sent as-is; an `ArrayBuffer` / `Uint8Array` is
39
+ * sent as raw bytes (e.g. uploading a file). Only meaningful for methods that
40
+ * carry a body.
41
+ */
42
+ body?: string | ArrayBuffer | Uint8Array;
39
43
  /** Follow HTTP redirects. Defaults to `true`. */
40
44
  followRedirects?: boolean;
41
45
  /** Request timeout in milliseconds. Omit for the platform default (~30 s). */
@@ -60,6 +64,23 @@ export interface NetworkResponse {
60
64
  /** Final URL after redirects. */
61
65
  finalUrl: string;
62
66
  }
67
+ /**
68
+ * Response from {@link NetworkService.fetchBytes} — identical to
69
+ * {@link NetworkResponse} but with the body delivered as raw bytes.
70
+ *
71
+ * @category Core Types
72
+ * @public
73
+ */
74
+ export interface NetworkBytesResponse {
75
+ /** HTTP status code. */
76
+ status: number;
77
+ /** Response headers, lowercased (multi-value joined with `", "`). */
78
+ headers: Record<string, string>;
79
+ /** Response body as raw bytes. */
80
+ body: ArrayBuffer;
81
+ /** Final URL after redirects. */
82
+ finalUrl: string;
83
+ }
63
84
  /**
64
85
  * Server-side HTTP client exposed as {@link ExtensionContext.net}. Requests
65
86
  * run in the Rust backend via `reqwest`, so they bypass the browser's CORS
@@ -91,6 +112,29 @@ export interface NetworkService {
91
112
  * ```
92
113
  */
93
114
  fetch(url: string, options?: NetworkRequestOptions): Promise<NetworkResponse>;
115
+ /**
116
+ * Like {@link NetworkService.fetch}, but resolves the response body as raw
117
+ * bytes ({@link NetworkBytesResponse}) instead of decoding it as UTF-8 text —
118
+ * for downloading images, archives, or any binary payload.
119
+ *
120
+ * @param url - The URL to fetch.
121
+ * @param options - Method, headers, body, redirect and timeout controls. The
122
+ * body may itself be binary (`ArrayBuffer` / `Uint8Array`).
123
+ * @throws {@link NetworkError} if the request fails.
124
+ *
125
+ * @remarks
126
+ * The body rides Tauri's binary IPC channel (no base64), but the whole
127
+ * response is still buffered in memory on both sides — suitable for typical
128
+ * asset downloads (up to a few tens of MB), not for streaming multi-hundred-MB
129
+ * files.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * const { body } = await ctx.net.fetchBytes("https://example.com/logo.png");
134
+ * await ctx.files.writeBytes("logo.png", body);
135
+ * ```
136
+ */
137
+ fetchBytes(url: string, options?: NetworkRequestOptions): Promise<NetworkBytesResponse>;
94
138
  /**
95
139
  * Send a `HEAD` request and return only the response headers — no body is
96
140
  * downloaded. More efficient than {@link NetworkService.fetch} when you only
@@ -1 +1 @@
1
- {"version":3,"file":"network-service.d.ts","sourceRoot":"","sources":["../src/network-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,0DAA0D;IAC1D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBAET,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CASzC;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC9D,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,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E,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,kCAAkC;IAClC,IAAI,EAAE,WAAW,CAAC;IAClB,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE9E;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,UAAU,CACR,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEjC;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,CACV,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,iBAAiB,GAAG,WAAW,CAAC,GACrE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpC"}
package/dist/path.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Path utilities for extensions — a cross-platform replacement for
3
+ * `node:path`, which extensions are banned from importing. All output paths
4
+ * use forward-slash separators (the form {@link FileService} accepts on every
5
+ * platform). Both `/` and `\` are accepted as input separators.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { path } from "@silo-code/sdk";
10
+ *
11
+ * const dir = path.dirname(filePath); // "/home/user/docs"
12
+ * const full = path.join(dir, "images/fig.png"); // "/home/user/docs/images/fig.png"
13
+ * const rel = path.relative(dir, full); // "images/fig.png"
14
+ * const ext = path.extname(full); // ".png"
15
+ * ```
16
+ *
17
+ * @category Core Types
18
+ * @public
19
+ */
20
+ export declare const path: {
21
+ /**
22
+ * Join path segments and normalize the result. Empty segments are ignored;
23
+ * `\` separators in any segment are treated as `/`.
24
+ */
25
+ join(...parts: string[]): string;
26
+ /**
27
+ * Return the directory portion of a path — everything up to (not including)
28
+ * the last `/`. Returns `"."` for a bare filename with no directory component.
29
+ */
30
+ dirname(p: string): string;
31
+ /**
32
+ * Return the final component of a path. If `ext` is supplied and the
33
+ * basename ends with that string, it is stripped from the result.
34
+ */
35
+ basename(p: string, ext?: string): string;
36
+ /**
37
+ * Return the extension of a path — the portion from the last `.` of the
38
+ * basename, including the dot. Returns `""` for paths with no extension and
39
+ * for dotfiles with no secondary extension (e.g. `".gitignore"` → `""`).
40
+ */
41
+ extname(p: string): string;
42
+ /**
43
+ * Compute the relative path from `from` to `to`. Both should be absolute
44
+ * paths on the same drive. When they are on different Windows drive letters,
45
+ * `to` (normalized) is returned unchanged — no relative path exists between
46
+ * drives.
47
+ */
48
+ relative(from: string, to: string): string;
49
+ /**
50
+ * Return `true` if `p` is an absolute path: starts with `/` (POSIX), has a
51
+ * drive letter followed by a slash (`C:/`, `C:\`), or is a UNC path
52
+ * (`\\server\share` / `//server/share`). Note: `C:foo` (drive-relative,
53
+ * no slash) is NOT absolute.
54
+ */
55
+ isAbsolute(p: string): boolean;
56
+ /**
57
+ * Normalize a path: convert `\` to `/`, collapse duplicate slashes, and
58
+ * resolve `.` and `..` segments.
59
+ */
60
+ normalize(p: string): string;
61
+ };
62
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAiDA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,IAAI,EAAE;IACjB;;;OAGG;IACH,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACjC;;;OAGG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1C;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3C;;;;;OAKG;IACH,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B;;;OAGG;IACH,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CA+E9B,CAAC"}