@silo-code/sdk 0.20.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.
- package/dist/context-keys.d.ts +18 -3
- package/dist/context-keys.d.ts.map +1 -1
- package/dist/domain-types.d.ts +8 -32
- package/dist/domain-types.d.ts.map +1 -1
- package/dist/editor-service.d.ts +135 -3
- package/dist/editor-service.d.ts.map +1 -1
- package/dist/event.d.ts +28 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +2 -0
- package/dist/event.js.map +1 -0
- package/dist/extension-storage.d.ts +7 -3
- package/dist/extension-storage.d.ts.map +1 -1
- package/dist/file-service.d.ts +48 -4
- package/dist/file-service.d.ts.map +1 -1
- package/dist/index.d.ts +17 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/layout-service.d.ts +13 -13
- package/dist/layout-service.d.ts.map +1 -1
- package/dist/network-service.d.ts +70 -4
- package/dist/network-service.d.ts.map +1 -1
- package/dist/network-service.js +35 -1
- package/dist/network-service.js.map +1 -1
- package/dist/path.d.ts +62 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +150 -0
- package/dist/path.js.map +1 -0
- package/dist/process-service.d.ts +24 -4
- package/dist/process-service.d.ts.map +1 -1
- package/dist/processes-service.d.ts +1 -1
- package/dist/search-service.d.ts +11 -0
- package/dist/search-service.d.ts.map +1 -1
- package/dist/system-service.d.ts +2 -2
- package/dist/terminal-service.d.ts +66 -0
- package/dist/terminal-service.d.ts.map +1 -1
- package/dist/theme-service.d.ts +23 -7
- package/dist/theme-service.d.ts.map +1 -1
- package/dist/types.d.ts +102 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/workspace-service.d.ts +13 -0
- package/dist/workspace-service.d.ts.map +1 -1
- package/package.json +2 -4
- package/src/context-keys.ts +18 -3
- package/src/domain-types.ts +8 -29
- package/src/editor-service.ts +141 -5
- package/src/event.ts +28 -0
- package/src/extension-storage.ts +8 -3
- package/src/file-service.ts +49 -4
- package/src/index.ts +31 -6
- package/src/layout-service.ts +15 -13
- package/src/network-service.ts +85 -4
- package/src/path.test.ts +135 -0
- package/src/path.ts +188 -0
- package/src/process-service.ts +24 -4
- package/src/processes-service.ts +1 -1
- package/src/search-service.ts +11 -0
- package/src/system-service.ts +2 -2
- package/src/terminal-service.ts +71 -0
- package/src/theme-service.ts +23 -7
- package/src/types.ts +104 -25
- package/src/workspace-service.ts +13 -0
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown by {@link NetworkService.fetch} and {@link NetworkService.fetchHeaders}
|
|
3
|
+
* when a request fails (network error, DNS failure, TLS error, timeout, etc.).
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* try {
|
|
7
|
+
* const res = await ctx.net.fetch("https://api.example.com/data");
|
|
8
|
+
* } catch (err) {
|
|
9
|
+
* if (err instanceof NetworkError) {
|
|
10
|
+
* console.error(`Request to ${err.url} failed: ${err.message}`);
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @category Core Types
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare class NetworkError extends Error {
|
|
19
|
+
/** The URL that was requested when the error occurred. */
|
|
20
|
+
readonly url: string;
|
|
21
|
+
constructor(url: string, message: string);
|
|
22
|
+
}
|
|
1
23
|
/**
|
|
2
24
|
* Options for {@link NetworkService.fetch} and {@link NetworkService.fetchHeaders}.
|
|
3
25
|
*
|
|
@@ -12,8 +34,12 @@ export interface NetworkRequestOptions {
|
|
|
12
34
|
method?: "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
13
35
|
/** Request headers to send. */
|
|
14
36
|
headers?: Record<string, string>;
|
|
15
|
-
/**
|
|
16
|
-
|
|
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;
|
|
17
43
|
/** Follow HTTP redirects. Defaults to `true`. */
|
|
18
44
|
followRedirects?: boolean;
|
|
19
45
|
/** Request timeout in milliseconds. Omit for the platform default (~30 s). */
|
|
@@ -38,6 +64,23 @@ export interface NetworkResponse {
|
|
|
38
64
|
/** Final URL after redirects. */
|
|
39
65
|
finalUrl: string;
|
|
40
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
|
+
}
|
|
41
84
|
/**
|
|
42
85
|
* Server-side HTTP client exposed as {@link ExtensionContext.net}. Requests
|
|
43
86
|
* run in the Rust backend via `reqwest`, so they bypass the browser's CORS
|
|
@@ -60,7 +103,7 @@ export interface NetworkService {
|
|
|
60
103
|
*
|
|
61
104
|
* @param url - The URL to fetch.
|
|
62
105
|
* @param options - Method, headers, body, redirect and timeout controls.
|
|
63
|
-
* @throws
|
|
106
|
+
* @throws {@link NetworkError} if the request fails (network error, DNS
|
|
64
107
|
* failure, TLS error, etc.).
|
|
65
108
|
*
|
|
66
109
|
* @example
|
|
@@ -69,6 +112,29 @@ export interface NetworkService {
|
|
|
69
112
|
* ```
|
|
70
113
|
*/
|
|
71
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>;
|
|
72
138
|
/**
|
|
73
139
|
* Send a `HEAD` request and return only the response headers — no body is
|
|
74
140
|
* downloaded. More efficient than {@link NetworkService.fetch} when you only
|
|
@@ -80,7 +146,7 @@ export interface NetworkService {
|
|
|
80
146
|
* @param url - The URL to probe.
|
|
81
147
|
* @param options - Redirect and timeout controls (`method` and `body` are
|
|
82
148
|
* ignored — this is always a HEAD request).
|
|
83
|
-
* @throws
|
|
149
|
+
* @throws {@link NetworkError} if the request fails.
|
|
84
150
|
*
|
|
85
151
|
* @example
|
|
86
152
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-service.d.ts","sourceRoot":"","sources":["../src/network-service.ts"],"names":[],"mappings":"AAAA;;;;;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AM,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/network-service.js
CHANGED
|
@@ -1,2 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Thrown by {@link NetworkService.fetch} and {@link NetworkService.fetchHeaders}
|
|
3
|
+
* when a request fails (network error, DNS failure, TLS error, timeout, etc.).
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* try {
|
|
7
|
+
* const res = await ctx.net.fetch("https://api.example.com/data");
|
|
8
|
+
* } catch (err) {
|
|
9
|
+
* if (err instanceof NetworkError) {
|
|
10
|
+
* console.error(`Request to ${err.url} failed: ${err.message}`);
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @category Core Types
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export class NetworkError extends Error {
|
|
19
|
+
constructor(url, message) {
|
|
20
|
+
super(message);
|
|
21
|
+
/** The URL that was requested when the error occurred. */
|
|
22
|
+
Object.defineProperty(this, "url", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
this.name = "NetworkError";
|
|
29
|
+
this.url = url;
|
|
30
|
+
// Restore the prototype chain so `instanceof` works across the down-leveled
|
|
31
|
+
// class output the SDK ships (and across the host↔extension boundary, where
|
|
32
|
+
// there's a single shared SDK instance).
|
|
33
|
+
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
2
36
|
//# sourceMappingURL=network-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-service.js","sourceRoot":"","sources":["../src/network-service.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"network-service.js","sourceRoot":"","sources":["../src/network-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAIrC,YAAY,GAAW,EAAE,OAAe;QACtC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJjB,0DAA0D;QACjD;;;;;WAAY;QAInB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,4EAA4E;QAC5E,4EAA4E;QAC5E,yCAAyC;QACzC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACF"}
|
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"}
|
package/dist/path.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Pure path utilities for extensions. A cross-platform replacement for
|
|
2
|
+
// `node:path`, which extensions are banned from importing (platform ban).
|
|
3
|
+
// All outputs use forward-slash separators — the form FileService accepts on
|
|
4
|
+
// every platform. Both "/" and "\" are accepted as inputs.
|
|
5
|
+
/** Normalize all separators to forward-slash. */
|
|
6
|
+
function normSep(p) {
|
|
7
|
+
return p.replace(/\\/g, "/");
|
|
8
|
+
}
|
|
9
|
+
/** Extract a Windows drive-letter prefix ("C:") from a forward-slash path, or null. */
|
|
10
|
+
function parseDrive(p) {
|
|
11
|
+
const m = /^([A-Za-z]):/.exec(p);
|
|
12
|
+
return m ? m[1].toUpperCase() + ":" : null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Normalize segments of a forward-slash path: collapse duplicate slashes,
|
|
16
|
+
* resolve "." and ".." segments. Preserves leading "/" (POSIX absolute),
|
|
17
|
+
* "C:/" (Windows drive-letter), and "//" (UNC paths).
|
|
18
|
+
*/
|
|
19
|
+
function normSegments(s) {
|
|
20
|
+
const drive = parseDrive(s);
|
|
21
|
+
const afterDrive = drive ? s.slice(2) : s;
|
|
22
|
+
const isUnc = afterDrive.startsWith("//");
|
|
23
|
+
const isAbs = isUnc || afterDrive.startsWith("/");
|
|
24
|
+
const stack = [];
|
|
25
|
+
for (const seg of afterDrive.split("/")) {
|
|
26
|
+
if (seg === "" || seg === ".")
|
|
27
|
+
continue;
|
|
28
|
+
if (seg === "..") {
|
|
29
|
+
if (stack.length > 0 && stack[stack.length - 1] !== "..") {
|
|
30
|
+
stack.pop();
|
|
31
|
+
}
|
|
32
|
+
else if (!isAbs) {
|
|
33
|
+
stack.push("..");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
stack.push(seg);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
let result = stack.join("/");
|
|
41
|
+
if (isUnc)
|
|
42
|
+
result = "//" + result;
|
|
43
|
+
else if (isAbs)
|
|
44
|
+
result = "/" + result;
|
|
45
|
+
if (drive)
|
|
46
|
+
result = drive + result;
|
|
47
|
+
if (!result)
|
|
48
|
+
return isAbs ? (drive ? drive + "/" : "/") : ".";
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Path utilities for extensions — a cross-platform replacement for
|
|
53
|
+
* `node:path`, which extensions are banned from importing. All output paths
|
|
54
|
+
* use forward-slash separators (the form {@link FileService} accepts on every
|
|
55
|
+
* platform). Both `/` and `\` are accepted as input separators.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { path } from "@silo-code/sdk";
|
|
60
|
+
*
|
|
61
|
+
* const dir = path.dirname(filePath); // "/home/user/docs"
|
|
62
|
+
* const full = path.join(dir, "images/fig.png"); // "/home/user/docs/images/fig.png"
|
|
63
|
+
* const rel = path.relative(dir, full); // "images/fig.png"
|
|
64
|
+
* const ext = path.extname(full); // ".png"
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @category Core Types
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export const path = {
|
|
71
|
+
normalize(p) {
|
|
72
|
+
return normSegments(normSep(p));
|
|
73
|
+
},
|
|
74
|
+
join(...parts) {
|
|
75
|
+
const nonEmpty = parts.filter((p) => p.length > 0);
|
|
76
|
+
if (nonEmpty.length === 0)
|
|
77
|
+
return ".";
|
|
78
|
+
// Concatenate without adding "/" when adjacent parts already supply the
|
|
79
|
+
// boundary, so join("/", "rel") → "/rel" rather than "//rel" (UNC).
|
|
80
|
+
const raw = nonEmpty.map(normSep).reduce((a, b) => {
|
|
81
|
+
if (a.endsWith("/") || b.startsWith("/"))
|
|
82
|
+
return a + b;
|
|
83
|
+
return a + "/" + b;
|
|
84
|
+
});
|
|
85
|
+
return normSegments(raw);
|
|
86
|
+
},
|
|
87
|
+
dirname(p) {
|
|
88
|
+
const n = normSegments(normSep(p));
|
|
89
|
+
const drive = parseDrive(n);
|
|
90
|
+
const rest = drive ? n.slice(2) : n;
|
|
91
|
+
const i = rest.lastIndexOf("/");
|
|
92
|
+
if (i < 0)
|
|
93
|
+
return drive ? drive + "." : ".";
|
|
94
|
+
if (i === 0)
|
|
95
|
+
return drive ? drive + "/" : "/";
|
|
96
|
+
return drive ? drive + rest.slice(0, i) : rest.slice(0, i);
|
|
97
|
+
},
|
|
98
|
+
basename(p, ext) {
|
|
99
|
+
const n = normSep(p);
|
|
100
|
+
const segs = n.split("/");
|
|
101
|
+
let name = segs[segs.length - 1] ?? "";
|
|
102
|
+
// Trailing slash: "foo/" → last segment is "" → fall back to prior segment
|
|
103
|
+
if (name === "" && segs.length > 1)
|
|
104
|
+
name = segs[segs.length - 2] ?? "";
|
|
105
|
+
if (ext !== undefined && name.endsWith(ext)) {
|
|
106
|
+
name = name.slice(0, name.length - ext.length);
|
|
107
|
+
}
|
|
108
|
+
return name;
|
|
109
|
+
},
|
|
110
|
+
extname(p) {
|
|
111
|
+
const base = path.basename(normSep(p));
|
|
112
|
+
const i = base.lastIndexOf(".");
|
|
113
|
+
// i === 0 means a dotfile like ".gitignore" — no extension
|
|
114
|
+
if (i <= 0)
|
|
115
|
+
return "";
|
|
116
|
+
return base.slice(i);
|
|
117
|
+
},
|
|
118
|
+
isAbsolute(p) {
|
|
119
|
+
const n = normSep(p);
|
|
120
|
+
if (n.startsWith("//"))
|
|
121
|
+
return true; // UNC (\\server\share or //server/share)
|
|
122
|
+
if (/^[A-Za-z]:\//.test(n))
|
|
123
|
+
return true; // Windows drive with slash (C:/ or C:\)
|
|
124
|
+
return n.startsWith("/"); // POSIX
|
|
125
|
+
},
|
|
126
|
+
relative(from, to) {
|
|
127
|
+
const nFrom = normSegments(normSep(from));
|
|
128
|
+
const nTo = normSegments(normSep(to));
|
|
129
|
+
const driveFrom = parseDrive(nFrom);
|
|
130
|
+
const driveTo = parseDrive(nTo);
|
|
131
|
+
// Can't express a relative path across different drives
|
|
132
|
+
if (driveFrom !== driveTo)
|
|
133
|
+
return nTo;
|
|
134
|
+
const segsFrom = (driveFrom ? nFrom.slice(2) : nFrom)
|
|
135
|
+
.split("/")
|
|
136
|
+
.filter(Boolean);
|
|
137
|
+
const segsTo = (driveTo ? nTo.slice(2) : nTo).split("/").filter(Boolean);
|
|
138
|
+
let common = 0;
|
|
139
|
+
while (common < segsFrom.length &&
|
|
140
|
+
common < segsTo.length &&
|
|
141
|
+
segsFrom[common] === segsTo[common]) {
|
|
142
|
+
common++;
|
|
143
|
+
}
|
|
144
|
+
const ups = segsFrom.length - common;
|
|
145
|
+
const downs = segsTo.slice(common);
|
|
146
|
+
const parts = [...Array(ups).fill(".."), ...downs];
|
|
147
|
+
return parts.join("/") || ".";
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=path.js.map
|
package/dist/path.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,0EAA0E;AAC1E,6EAA6E;AAC7E,2DAA2D;AAE3D,iDAAiD;AACjD,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC;AAED,uFAAuF;AACvF,SAAS,UAAU,CAAC,CAAS;IAC3B,MAAM,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,CAAS;IAC7B,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,KAAK,G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ACD,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAS,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC;QAC3D,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;IAChC,CAAC;CACF,CAAC"}
|
|
@@ -61,6 +61,24 @@ export interface ProcessExecOptions {
|
|
|
61
61
|
* {@link Permission}. First-party (bundled) extensions are unscoped.
|
|
62
62
|
*/
|
|
63
63
|
cwd?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Extra environment variables, **merged over** the host's environment (the
|
|
66
|
+
* command inherits the host env; these keys add to or override it). Use it to
|
|
67
|
+
* set things like `GIT_PAGER=cat` or a locale without clobbering `PATH`.
|
|
68
|
+
*/
|
|
69
|
+
env?: Record<string, string>;
|
|
70
|
+
/**
|
|
71
|
+
* Kill the process and reject after this many milliseconds. The whole process
|
|
72
|
+
* group is terminated (not just the direct child), so shell wrappers don't
|
|
73
|
+
* leak orphans. The rejection is an `Error` whose `name` is `"AbortError"`.
|
|
74
|
+
*/
|
|
75
|
+
timeoutMs?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Abort handle. Aborting kills the process (and its group) and rejects the
|
|
78
|
+
* `exec` promise with an `Error` whose `name` is `"AbortError"` — the same
|
|
79
|
+
* shape as a `timeoutMs` expiry, so callers branch on `err.name`.
|
|
80
|
+
*/
|
|
81
|
+
signal?: AbortSignal;
|
|
64
82
|
}
|
|
65
83
|
/**
|
|
66
84
|
* The captured result of a one-shot subprocess, returned by
|
|
@@ -108,10 +126,12 @@ export interface ProcessService {
|
|
|
108
126
|
* interactive sessions instead.
|
|
109
127
|
*
|
|
110
128
|
* Runs **off the UI thread**, so a slow or network-bound command never
|
|
111
|
-
* stutters the app. The returned promise rejects
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
129
|
+
* stutters the app. The returned promise rejects if the process could not be
|
|
130
|
+
* spawned (e.g. the command was not found), or if a
|
|
131
|
+
* {@link ProcessExecOptions.timeoutMs | timeout} / {@link ProcessExecOptions.signal | abort}
|
|
132
|
+
* fires (an `Error` with `name === "AbortError"`); a command that runs to
|
|
133
|
+
* completion but exits non-zero **resolves** — check
|
|
134
|
+
* {@link ProcessExecResult.code} and {@link ProcessExecResult.stderr}.
|
|
115
135
|
*
|
|
116
136
|
* @param command - Executable to run (resolved via `PATH`), e.g. `"git"`.
|
|
117
137
|
* @param args - Arguments passed verbatim — not shell-interpreted, so no
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-service.d.ts","sourceRoot":"","sources":["../src/process-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oDAAoD;IACpD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,4CAA4C;IAC5C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,6EAA6E;IAC7E,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,kDAAkD;IAClD,UAAU,CAAC,IAAI,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KAAK,IAAI,GAAG,UAAU,CAAC;IACrD,4DAA4D;IAC5D,MAAM,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,UAAU,CAAC;CAC1D;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,KAAK,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC1D;;;OAGG;IACH,MAAM,CACJ,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GACtC,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,IAAI,CACF,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC/B"}
|
|
@@ -80,7 +80,7 @@ export interface ProcessInfo {
|
|
|
80
80
|
* // Notify when all agents in the workspace are idle.
|
|
81
81
|
* const sub = ctx.processes.subscribe((procs) => {
|
|
82
82
|
* const allIdle = procs.every((p) => p.atPrompt);
|
|
83
|
-
* if (allIdle) ctx.ui.notify(
|
|
83
|
+
* if (allIdle) ctx.ui.notify("info", "All agents finished");
|
|
84
84
|
* });
|
|
85
85
|
* ctx.subscriptions.push(sub);
|
|
86
86
|
*
|
package/dist/search-service.d.ts
CHANGED
|
@@ -38,6 +38,17 @@ export interface SearchOptions {
|
|
|
38
38
|
* is hit, the search stops early and {@link SearchResponse.truncated} is true.
|
|
39
39
|
*/
|
|
40
40
|
maxResults?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Cancel the search. When the signal aborts, the promise returned by
|
|
43
|
+
* {@link SearchService.search} rejects with an `Error` whose `name` is
|
|
44
|
+
* `"AbortError"` (the `fetch` convention — branch on `err.name`).
|
|
45
|
+
*
|
|
46
|
+
* Cancellation is observable immediately, but the native search may still run
|
|
47
|
+
* to completion in the background — its result is simply discarded. Use this
|
|
48
|
+
* to abandon a stale query (e.g. superseded by the next keystroke) rather than
|
|
49
|
+
* to reclaim native CPU the instant you abort.
|
|
50
|
+
*/
|
|
51
|
+
signal?: AbortSignal;
|
|
41
52
|
}
|
|
42
53
|
/**
|
|
43
54
|
* One matching line within a file, returned in {@link SearchFileResult.matches}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-service.d.ts","sourceRoot":"","sources":["../src/search-service.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,yEAAyE;IACzE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"search-service.d.ts","sourceRoot":"","sources":["../src/search-service.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,yEAAyE;IACzE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjC;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,iDAAiD;IACjD,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACzE"}
|
package/dist/system-service.d.ts
CHANGED
|
@@ -48,13 +48,13 @@ export interface SystemInfo {
|
|
|
48
48
|
* ctx.subscriptions.push(
|
|
49
49
|
* ctx.registerCommand({
|
|
50
50
|
* id: "my.reveal-in-finder",
|
|
51
|
-
*
|
|
51
|
+
* label: "Reveal in Finder",
|
|
52
52
|
* run() { ... },
|
|
53
53
|
* }),
|
|
54
54
|
* );
|
|
55
55
|
* }
|
|
56
56
|
*
|
|
57
|
-
* ctx.ui.notify(
|
|
57
|
+
* ctx.ui.notify("info", `Running Silo ${siloVersion} on ${os}/${arch}`);
|
|
58
58
|
* },
|
|
59
59
|
* };
|
|
60
60
|
* ```
|
|
@@ -91,10 +91,47 @@ export interface TerminalService {
|
|
|
91
91
|
* Open a new terminal in a workspace (defaults to the active one). Returns the
|
|
92
92
|
* created {@link TerminalRecord}; the PTY session spawns lazily when its tab
|
|
93
93
|
* mounts.
|
|
94
|
+
*
|
|
95
|
+
* Returns `undefined` only when `input.workspaceId` is not given and there is
|
|
96
|
+
* no active workspace at the time of the call — in normal use this does not
|
|
97
|
+
* happen because activating any workspace happens before extensions run.
|
|
94
98
|
*/
|
|
95
99
|
create(input?: CreateTerminalInput): TerminalRecord | undefined;
|
|
96
100
|
/** Close and kill every terminal in a workspace (e.g. on workspace delete). */
|
|
97
101
|
closeWorkspace(workspaceId: string): void;
|
|
102
|
+
/**
|
|
103
|
+
* Write text to a terminal's PTY as if the user typed it. By default a
|
|
104
|
+
* carriage return is appended so the line executes; pass `addNewline: false`
|
|
105
|
+
* to stage text without running it.
|
|
106
|
+
*
|
|
107
|
+
* Works even if the terminal tab has never been shown: the PTY spawns lazily
|
|
108
|
+
* on first mount, and `sendText` force-spawns it on demand (a later mount then
|
|
109
|
+
* attaches to that same session). No-op for an unknown `terminalId`.
|
|
110
|
+
*
|
|
111
|
+
* @param terminalId - The {@link TerminalRecord.id} to write to.
|
|
112
|
+
* @param text - The text to send.
|
|
113
|
+
* @param addNewline - Append a carriage return to execute. Defaults to `true`.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const term = ctx.terminals.create({ cwd: workspaceFolder });
|
|
118
|
+
* if (term) ctx.terminals.sendText(term.id, "npm run build");
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
sendText(terminalId: string, text: string, addNewline?: boolean): void;
|
|
122
|
+
/**
|
|
123
|
+
* Close one terminal tab and kill its PTY session. No-op if the id is unknown.
|
|
124
|
+
* To reap every terminal in a workspace at once use
|
|
125
|
+
* {@link TerminalService.closeWorkspace}.
|
|
126
|
+
*/
|
|
127
|
+
close(terminalId: string): void;
|
|
128
|
+
/**
|
|
129
|
+
* Set a terminal's user-facing name ({@link TerminalRecord.customName}),
|
|
130
|
+
* shown on its tab and persisted across restarts. Passing an empty string
|
|
131
|
+
* clears the custom name, letting the PTY-derived title take over again.
|
|
132
|
+
* No-op for an unknown `terminalId`.
|
|
133
|
+
*/
|
|
134
|
+
rename(terminalId: string, name: string): void;
|
|
98
135
|
/**
|
|
99
136
|
* Switch to the workspace containing this terminal and activate its tab in
|
|
100
137
|
* the center dock. No-ops if the terminal id is unknown.
|
|
@@ -152,5 +189,34 @@ export interface TerminalService {
|
|
|
152
189
|
* ```
|
|
153
190
|
*/
|
|
154
191
|
subscribeOsc(terminalId: string, handler: (event: OscEvent) => void): Disposable;
|
|
192
|
+
/**
|
|
193
|
+
* The record id of the terminal tab that is currently active in the active
|
|
194
|
+
* workspace's center dock, or `null` when an editor tab (or nothing) is
|
|
195
|
+
* active. "Active" is the dock's single active panel — the tab the user is
|
|
196
|
+
* looking at and typing into — so a terminal merely visible in a non-active
|
|
197
|
+
* split does not count.
|
|
198
|
+
*/
|
|
199
|
+
getActive(): string | null;
|
|
200
|
+
/**
|
|
201
|
+
* Subscribe to active-terminal changes. The listener receives the terminal
|
|
202
|
+
* record id whenever a terminal tab becomes the active center-dock panel,
|
|
203
|
+
* and `null` when activation moves elsewhere (an editor tab, or no panel —
|
|
204
|
+
* including transiently during a workspace switch, before the incoming
|
|
205
|
+
* workspace's active tab is published).
|
|
206
|
+
*
|
|
207
|
+
* Fires on tab activation, group activation, and workspace switches.
|
|
208
|
+
* Returns a {@link Disposable} that cancels the subscription.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* // Clear a "needs attention" marker once the user views the terminal.
|
|
213
|
+
* ctx.subscriptions.push(
|
|
214
|
+
* ctx.terminals.subscribeActive((terminalId) => {
|
|
215
|
+
* if (terminalId) attention.delete(terminalId);
|
|
216
|
+
* }),
|
|
217
|
+
* );
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
subscribeActive(listener: (terminalId: string | null) => void): Disposable;
|
|
155
221
|
}
|
|
156
222
|
//# sourceMappingURL=terminal-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-service.d.ts","sourceRoot":"","sources":["../src/terminal-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEnE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,QAAQ;IACvB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;CACjB;AAGD,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM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AGG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAAC;IAEnE;;;;OAIG;IACH,wBAAwB,IAAI,IAAI,CAAC;IAEjC;;;OAGG;IACH,uBAAuB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,UAAU,CAAC;IAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,YAAY,CACV,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,GACjC,UAAU,CAAC;IAEd;;;;;;OAMG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI,CAAC;IAE3B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,UAAU,CAAC;CAC5E"}
|
package/dist/theme-service.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import type { Disposable } from "./types";
|
|
|
2
2
|
import type { ThemeBase, ThemeVars, CustomTheme, ThemeExport } from "./domain-types";
|
|
3
3
|
export type { ThemeBase, ThemeVars, CustomTheme, ThemeExport, } from "./domain-types";
|
|
4
4
|
/**
|
|
5
|
-
* A selectable theme contributed via
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* A selectable theme contributed via {@link ThemeService.registerPreset}.
|
|
6
|
+
* Built-in presets (Tokyo Night, Solarized Light, Gruvbox Dark, …) are
|
|
7
|
+
* registered by the `theme-presets` extension; core ships only Dark and Light.
|
|
8
|
+
* A preset's {@link ThemePreset.vars} are injected as CSS custom properties
|
|
9
|
+
* when it is the active theme.
|
|
10
10
|
*
|
|
11
11
|
* @category Registration
|
|
12
12
|
* @public
|
|
@@ -58,8 +58,7 @@ export interface ThemeState {
|
|
|
58
58
|
* Read via {@link ThemeService.getState | getState} /
|
|
59
59
|
* {@link ThemeService.subscribe | subscribe} (e.g. with `useSyncExternalStore`);
|
|
60
60
|
* drive via {@link ThemeService.setActive | setActive} and the custom-theme
|
|
61
|
-
* methods.
|
|
62
|
-
* {@link ExtensionContext.registerThemePreset}.
|
|
61
|
+
* methods. Contribute a new preset via {@link ThemeService.registerPreset}.
|
|
63
62
|
*
|
|
64
63
|
* @category Consumer Services
|
|
65
64
|
* @public
|
|
@@ -83,5 +82,22 @@ export interface ThemeService {
|
|
|
83
82
|
exportTheme(theme: CustomTheme): ThemeExport;
|
|
84
83
|
/** Validate/parse imported JSON into a custom theme (assigns a fresh id). */
|
|
85
84
|
importTheme(data: unknown): CustomTheme;
|
|
85
|
+
/**
|
|
86
|
+
* Register a {@link ThemePreset} (a selectable theme in the picker). The
|
|
87
|
+
* preset appears immediately and is removed when the returned
|
|
88
|
+
* {@link Disposable} is disposed (typically when the extension deactivates).
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* ctx.theme.registerPreset({
|
|
93
|
+
* id: "my-theme",
|
|
94
|
+
* name: "My Theme",
|
|
95
|
+
* base: "dark",
|
|
96
|
+
* colorScheme: "dark",
|
|
97
|
+
* vars: { "--silo-color-bg": "#1a1a2e" },
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
registerPreset(preset: ThemePreset): Disposable;
|
|
86
102
|
}
|
|
87
103
|
//# sourceMappingURL=theme-service.d.ts.map
|