@markupai/sidebar-adapter 0.0.23 → 1.0.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/README.md +38 -21
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/pluginAdapter.d.ts +73 -0
- package/dist/adapters/pluginAdapter.d.ts.map +1 -0
- package/dist/adapters/sidebarAdapter.d.ts +43 -0
- package/dist/adapters/sidebarAdapter.d.ts.map +1 -0
- package/dist/errors.d.ts +48 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/ipc/call-signatures.d.ts +64 -0
- package/dist/ipc/call-signatures.d.ts.map +1 -0
- package/dist/ipc/deferred-promise.d.ts +49 -0
- package/dist/ipc/deferred-promise.d.ts.map +1 -0
- package/dist/ipc/index.d.ts +9 -0
- package/dist/ipc/index.d.ts.map +1 -0
- package/dist/ipc/ipc-core.d.ts +72 -0
- package/dist/ipc/ipc-core.d.ts.map +1 -0
- package/dist/ipc/message-types.d.ts +57 -0
- package/dist/ipc/message-types.d.ts.map +1 -0
- package/dist/ipc/plugin-ipc-adapter.d.ts +77 -0
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -0
- package/dist/ipc/sidebar-ipc-adapter.d.ts +38 -0
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -0
- package/dist/load-overlay/index.d.ts +2 -0
- package/dist/load-overlay/index.d.ts.map +1 -0
- package/dist/load-overlay/loadOverlayDom.d.ts +5 -0
- package/dist/load-overlay/loadOverlayDom.d.ts.map +1 -0
- package/dist/load-overlay/loadOverlayStyles.d.ts +3 -0
- package/dist/load-overlay/loadOverlayStyles.d.ts.map +1 -0
- package/dist/load-overlay/sidebarLoadOverlay.d.ts +14 -0
- package/dist/load-overlay/sidebarLoadOverlay.d.ts.map +1 -0
- package/dist/main.js +289 -517
- package/dist/main.umd.cjs +12 -12
- package/dist/sidebar-host/createSidebarHost.d.ts +84 -0
- package/dist/sidebar-host/createSidebarHost.d.ts.map +1 -0
- package/dist/sidebar-host/index.d.ts +3 -0
- package/dist/sidebar-host/index.d.ts.map +1 -0
- package/dist/sidebar-host/sidebarHostShell.d.ts +56 -0
- package/dist/sidebar-host/sidebarHostShell.d.ts.map +1 -0
- package/dist/types/common.d.ts +95 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/pluginInterface.d.ts +70 -0
- package/dist/types/pluginInterface.d.ts.map +1 -0
- package/dist/types/sidebarInterface.d.ts +41 -0
- package/dist/types/sidebarInterface.d.ts.map +1 -0
- package/package.json +5 -5
- package/dist/main.d.ts +0 -888
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ You do **not** need prior knowledge of how the sidebar is built internally. As a
|
|
|
32
32
|
|
|
33
33
|
Use this if you are **embedding Markup AI’s sidebar** in your product for the first time.
|
|
34
34
|
|
|
35
|
-
1. **Get the sidebar URL from Markup AI** — Base URL plus any required **hash route** (for example
|
|
35
|
+
1. **Get the sidebar URL from Markup AI** — Base URL plus any required **hash route**. For the default **agentic** experience at the hash root, both the plain base URL (for example, `https://…/`) and **`#/`** are equivalent with `HashRouter`; **`#/`** only makes the root route explicit. Use **`#/original`** or **`#/previous`** for the legacy Original layout, or **`#/agentic`** for explicit agentic (same as default). The exact URL and routing are part of your integration agreement.
|
|
36
36
|
2. **Add an iframe** on your host page whose `src` is that URL (or let **`createSidebarHost`** create the iframe for you).
|
|
37
37
|
3. **Implement `PluginInterface`** — Async functions that return document text, apply replacements, open/close dialogs, etc. The sidebar calls these over `postMessage`; your code performs the real work in your editor model.
|
|
38
38
|
4. **Create a `SidebarAdapter`** (or call **`createSidebarHost`**) with:
|
|
@@ -69,6 +69,15 @@ If you use the **agentic** layout, implement the optional hooks **`onAgenticAgen
|
|
|
69
69
|
npm install @markupai/sidebar-adapter
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
### Upgrading from 0.x to 1.x
|
|
73
|
+
|
|
74
|
+
These releases introduce **breaking** IPC and TypeScript contract updates:
|
|
75
|
+
|
|
76
|
+
- **`selectContent`** is `selectContent(range: ContentRange)` with a **required** **`ContentRange`** and highlights the half-open document span **`[range.start, range.end)`** using offsets only (no separate `original` string on the contract).
|
|
77
|
+
- **`replaceContent`** is `replaceContent(suggestion, range)` with a **required** **`ContentRange`** (`[range.start, range.end)` half-open semantics).
|
|
78
|
+
- **`ContentReplacement`** batch entries are **`{ suggestion, range }`** only (no `original` field).
|
|
79
|
+
- Update every **`PluginInterface`** implementation and any code that decodes **`selectContent`** / **`replaceContent`** IPC payloads so they match the published shapes: **`selectContent`** is one argument **`[range]`** on the wire; **`replaceContent`** is **`[suggestion, range]`** (argument order matters).
|
|
80
|
+
|
|
72
81
|
## Architecture options
|
|
73
82
|
|
|
74
83
|
| Integration style | Where the sidebar iframe runs | Where your document/editor code runs | Typical approach |
|
|
@@ -107,16 +116,16 @@ const selectedContent = await adapter.getSelectedContent();
|
|
|
107
116
|
console.log("Selected content:", selectedContent.content);
|
|
108
117
|
console.log("Document reference:", selectedContent.documentReference);
|
|
109
118
|
|
|
110
|
-
// Select content in the editor
|
|
111
|
-
await adapter.selectContent(
|
|
119
|
+
// Select content in the editor (half-open range [0, 11))
|
|
120
|
+
await adapter.selectContent({ start: 0, end: 11 });
|
|
112
121
|
|
|
113
|
-
// Replace content in the editor
|
|
114
|
-
await adapter.replaceContent("Hello
|
|
122
|
+
// Replace content in the editor (apply suggestion to [start, end))
|
|
123
|
+
await adapter.replaceContent("Hello universe", { start: 0, end: 11 });
|
|
115
124
|
|
|
116
125
|
// Replace multiple contents in the editor
|
|
117
126
|
await adapter.replaceMultipleContents([
|
|
118
|
-
{
|
|
119
|
-
{
|
|
127
|
+
{ suggestion: "Hello universe", range: { start: 0, end: 11 } },
|
|
128
|
+
{ suggestion: "bar", range: { start: 20, end: 23 } },
|
|
120
129
|
]);
|
|
121
130
|
|
|
122
131
|
// Show a dialog
|
|
@@ -138,6 +147,7 @@ import {
|
|
|
138
147
|
SidebarAdapter,
|
|
139
148
|
MimeType,
|
|
140
149
|
type PluginInterface,
|
|
150
|
+
type ContentRange,
|
|
141
151
|
type ContentReplacement,
|
|
142
152
|
type ContentInfo,
|
|
143
153
|
} from "@markupai/sidebar-adapter";
|
|
@@ -179,15 +189,15 @@ const pluginInterface: PluginInterface = {
|
|
|
179
189
|
},
|
|
180
190
|
|
|
181
191
|
// Select content in the editor
|
|
182
|
-
selectContent: async (
|
|
183
|
-
console.log("Select content
|
|
184
|
-
selectContentInEditor(
|
|
192
|
+
selectContent: async (range: ContentRange) => {
|
|
193
|
+
console.log("Select content range:", range);
|
|
194
|
+
selectContentInEditor(range);
|
|
185
195
|
},
|
|
186
196
|
|
|
187
197
|
// Replace content in the editor
|
|
188
|
-
replaceContent: async (
|
|
189
|
-
console.log("Replace content:",
|
|
190
|
-
replaceContentInEditor(
|
|
198
|
+
replaceContent: async (suggestion: string, range: ContentRange) => {
|
|
199
|
+
console.log("Replace content span:", range, "with:", suggestion);
|
|
200
|
+
replaceContentInEditor(suggestion, range);
|
|
191
201
|
},
|
|
192
202
|
|
|
193
203
|
// Replace multiple contents in the editor
|
|
@@ -222,7 +232,9 @@ sidebarAdapter.destroy();
|
|
|
222
232
|
|
|
223
233
|
### SidebarLoadOverlay (Editor UI)
|
|
224
234
|
|
|
225
|
-
Use `setupSidebarLoadOverlay` when you manage the iframe yourself and only want the **failed-to-load / retry** UI.
|
|
235
|
+
Use `setupSidebarLoadOverlay` when you manage the iframe yourself and only want the **failed-to-load / retry** UI. Overlay styles are injected into **`container.ownerDocument`** (usually the same as the global `document` when the container lives in your host page). That keeps styles aligned with the document that actually contains the overlay—important if the container is in another **window** (e.g. undocked popup) or **frame**.
|
|
236
|
+
|
|
237
|
+
The overlay listens for the first qualifying **`message`** from **`iframe.contentWindow`** to treat the sidebar as loaded. By default it attaches to the global **`window`**. If the iframe’s **`parent`** is not that window (popup, separate host document), pass **`messageListenWindow`** in options so it matches the iframe’s parent—otherwise the timeout may fire even when the sidebar is healthy.
|
|
226
238
|
|
|
227
239
|

|
|
228
240
|
|
|
@@ -241,7 +253,11 @@ const teardownLoadOverlay = setupSidebarLoadOverlay(container, iframe, {
|
|
|
241
253
|
teardownLoadOverlay();
|
|
242
254
|
```
|
|
243
255
|
|
|
244
|
-
|
|
256
|
+
**`SidebarLoadOverlayOptions`** (all optional beyond defaults): **`sidebarUrl`**, **`targetOrigin`**, **`timeoutMs`**, **`retryIntervalMs`**, **`messageListenWindow`** (see above).
|
|
257
|
+
|
|
258
|
+
**`injectSidebarLoadOverlayStyles(targetDocument?)`** — injects the overlay CSS once per document. Omit **`targetDocument`** to use the global **`document`** (backward-compatible). You rarely need to call this yourself; **`setupSidebarLoadOverlay`** handles it via **`container.ownerDocument`**.
|
|
259
|
+
|
|
260
|
+
Prefer **`createSidebarHost`** if you also want **`SidebarAdapter`** and/or **`iframeMount`** in one place. Pass **`loadOverlayOptions`** (same shape as the third argument to **`setupSidebarLoadOverlay`**) when using **`loadOverlayContainer`**.
|
|
245
261
|
|
|
246
262
|
### createSidebarHost
|
|
247
263
|
|
|
@@ -267,8 +283,8 @@ import {
|
|
|
267
283
|
} from "@markupai/sidebar-adapter";
|
|
268
284
|
|
|
269
285
|
const container = document.getElementById("sidebar-container") as HTMLElement;
|
|
270
|
-
// Use the URL Markup AI provides
|
|
271
|
-
const sidebarUrl = "https://your-sidebar-host
|
|
286
|
+
// Use the URL Markup AI provides. Default Agentic: base URL (equivalent to #/). Explicit overrides: #/original, #/previous, #/next-ui, or #/agentic.
|
|
287
|
+
const sidebarUrl = "https://your-sidebar-host/";
|
|
272
288
|
|
|
273
289
|
// `myPlugin` is your PluginInterface implementation (see SidebarAdapter example above).
|
|
274
290
|
const host = createSidebarHost({
|
|
@@ -290,6 +306,7 @@ host.destroy();
|
|
|
290
306
|
|
|
291
307
|
- If you already have an iframe, pass **`iframe`** and omit **`iframeMount`**.
|
|
292
308
|
- If you omit **`loadOverlayContainer`**, no overlay is mounted (same as using `new SidebarAdapter` only, plus optional iframe creation).
|
|
309
|
+
- **`loadOverlayOptions`:** forwarded to **`setupSidebarLoadOverlay`**. Use **`messageListenWindow`** when the iframe parent is not the host **`window`** (e.g. sidebar iframe inside a popup; plugin / **`SidebarAdapter`** may use **`adapterOptions.win`** for the same window).
|
|
293
310
|
- **Split-context integration:** omit **`plugin`**, set **`loadOverlayContainer`** + **`iframeMount`** (or **`iframe`**), then forward **`postMessage`** traffic between `host.iframe` and the context where your `PluginInterface` runs (see [Architecture options](#architecture-options)).
|
|
294
311
|
|
|
295
312
|
### Sidebar host shell (shared HTML/DOM)
|
|
@@ -366,13 +383,13 @@ Structure for batch content replacement operations.
|
|
|
366
383
|
|
|
367
384
|
```typescript
|
|
368
385
|
type ContentReplacement = {
|
|
369
|
-
original: string;
|
|
370
386
|
suggestion: string;
|
|
371
387
|
range: ContentRange;
|
|
372
388
|
};
|
|
373
389
|
|
|
374
390
|
type ContentRange = {
|
|
375
391
|
start: number;
|
|
392
|
+
end: number;
|
|
376
393
|
};
|
|
377
394
|
```
|
|
378
395
|
|
|
@@ -385,8 +402,8 @@ Implement these **on the host** as async functions. The sidebar calls them over
|
|
|
385
402
|
- `getInitConfig(): Promise<SidebarConfig>` — Integration name, version, feature flags, dialog closing script, etc.
|
|
386
403
|
- `getContent(): Promise<ContentInfo>` — Full document (or main buffer) text; must include `documentReference`; `mimeType` optional
|
|
387
404
|
- `getSelectedContent(): Promise<ContentInfo>` — Current selection; same `ContentInfo` rules as `getContent`
|
|
388
|
-
- `selectContent(
|
|
389
|
-
- `replaceContent(
|
|
405
|
+
- `selectContent(range: ContentRange): Promise<void>` — Focus/highlight the document span `[range.start, range.end)`
|
|
406
|
+
- `replaceContent(suggestion: string, range: ContentRange): Promise<void>` — Apply a single edit to `[range.start, range.end)`
|
|
390
407
|
- `replaceMultipleContents(replacements: ContentReplacement[]): Promise<void>` — Batch edits
|
|
391
408
|
- `showDialog(dialogHtml: string, width?: number, height?: number, title?: string): Promise<void>` — Host-rendered dialog chrome around HTML from the sidebar
|
|
392
409
|
- `closeDialog(): Promise<void>` — Dismiss that dialog
|
|
@@ -415,7 +432,7 @@ Errors sent over IPC are reconstructed on the sidebar, so you can type-check wit
|
|
|
415
432
|
import { isTextLookupError, type TextLookupError } from "@markupai/sidebar-adapter";
|
|
416
433
|
|
|
417
434
|
try {
|
|
418
|
-
await adapter.selectContent(
|
|
435
|
+
await adapter.selectContent({ start: 0, end: 5 });
|
|
419
436
|
} catch (error) {
|
|
420
437
|
if (isTextLookupError(error)) {
|
|
421
438
|
// error is TextLookupError; e.g. invalidate issue card with error.message
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { CallOptions, IPCConfig } from "../ipc/message-types";
|
|
2
|
+
import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, SidebarInterface, AgenticIssuePayload } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* PluginAdapter - Use in the Sidebar to communicate with the Plugin in the editor
|
|
5
|
+
* This is a wrapper around PluginIPCAdapter for backwards compatibility and ease of use
|
|
6
|
+
*
|
|
7
|
+
* @param sidebar - Optional SidebarInterface implementation for Plugin → Sidebar callbacks
|
|
8
|
+
* @param config - Optional IPC configuration
|
|
9
|
+
* @param targetOrigin - Optional target origin for postMessage (defaults to '*')
|
|
10
|
+
*/
|
|
11
|
+
export declare class PluginAdapter {
|
|
12
|
+
private readonly ipcAdapter;
|
|
13
|
+
constructor(sidebar?: SidebarInterface, config?: IPCConfig, targetOrigin?: string);
|
|
14
|
+
/**
|
|
15
|
+
* Cleanup and destroy the adapter
|
|
16
|
+
*/
|
|
17
|
+
destroy(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Request initialization configuration from the editor
|
|
20
|
+
*/
|
|
21
|
+
getInitConfig(): Promise<SidebarConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* Request content from the editor in whatever format the integration supports
|
|
24
|
+
* @param options - Optional per-call overrides (e.g. timeout in ms; overrides default IPC timeout)
|
|
25
|
+
*/
|
|
26
|
+
getContent(options?: CallOptions): Promise<ContentInfo>;
|
|
27
|
+
/**
|
|
28
|
+
* Request selected content from the editor in whatever format the integration supports
|
|
29
|
+
* @param options - Optional per-call overrides (e.g. timeout in ms; overrides default IPC timeout)
|
|
30
|
+
*/
|
|
31
|
+
getSelectedContent(options?: CallOptions): Promise<ContentInfo>;
|
|
32
|
+
/**
|
|
33
|
+
* Replace content in the editor
|
|
34
|
+
*/
|
|
35
|
+
replaceContent(suggestion: string, range: ContentRange): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Select content in the editor
|
|
38
|
+
*/
|
|
39
|
+
selectContent(range: ContentRange): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Show a dialog in the editor
|
|
42
|
+
*/
|
|
43
|
+
showDialog(dialogHtml: string, width?: number, height?: number, title?: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Close the dialog in the editor
|
|
46
|
+
*/
|
|
47
|
+
closeDialog(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Replace multiple contents in the editor
|
|
50
|
+
*/
|
|
51
|
+
replaceMultipleContents(replacements: ContentReplacement[]): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Notify plugin that one agent's results are available (streaming).
|
|
54
|
+
*/
|
|
55
|
+
onAgenticAgentResults(agentName: string, issues: AgenticIssuePayload[]): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Notify plugin that the agentic stream has finished.
|
|
58
|
+
*/
|
|
59
|
+
onAgenticStreamComplete(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Update IPC configuration
|
|
62
|
+
*/
|
|
63
|
+
configure(config: IPCConfig): void;
|
|
64
|
+
/**
|
|
65
|
+
* Set or update the target origin for postMessage communication
|
|
66
|
+
*/
|
|
67
|
+
setTargetOrigin(targetOrigin: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Get the current target origin
|
|
70
|
+
*/
|
|
71
|
+
getTargetOrigin(): string;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=pluginAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/pluginAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB;;;;;;;GAOG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;gBAElC,OAAO,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,MAAM;IAKjF;;OAEG;IACI,OAAO,IAAI,IAAI;IAKtB;;OAEG;IACU,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAKpD;;;OAGG;IACU,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAKpE;;;OAGG;IACU,kBAAkB,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAK5E;;OAEG;IACU,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnF;;OAEG;IACU,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9D;;OAEG;IACU,UAAU,CACrB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAKhB;;OAEG;IACU,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAKzC;;OAEG;IACU,uBAAuB,CAAC,YAAY,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvF;;OAEG;IACI,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7F;;OAEG;IACI,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/C;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIzC;;OAEG;IACI,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAIlD;;OAEG;IACI,eAAe,IAAI,MAAM;CAGjC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { IPCConfig } from "../ipc/message-types";
|
|
2
|
+
import type { PluginInterface } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Options for SidebarAdapter constructor
|
|
5
|
+
*/
|
|
6
|
+
export interface SidebarAdapterOptions {
|
|
7
|
+
/** Optional window object (defaults to globalThis.window) */
|
|
8
|
+
win?: Window;
|
|
9
|
+
/** Optional IPC configuration */
|
|
10
|
+
config?: IPCConfig;
|
|
11
|
+
/** Optional target origin for postMessage (defaults to '*') */
|
|
12
|
+
targetOrigin?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* SidebarAdapter - Use in the Editor to communicate with the Sidebar in the iframe
|
|
16
|
+
* This is a wrapper around SidebarIPCAdapter for backwards compatibility and ease of use
|
|
17
|
+
*/
|
|
18
|
+
export declare class SidebarAdapter {
|
|
19
|
+
private readonly ipcAdapter;
|
|
20
|
+
constructor(plugin: PluginInterface, iframe: HTMLIFrameElement, options?: SidebarAdapterOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Cleanup and destroy the adapter
|
|
23
|
+
*/
|
|
24
|
+
destroy(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Notify sidebar of plugin status changes
|
|
27
|
+
* Example method demonstrating Plugin → Sidebar communication
|
|
28
|
+
*/
|
|
29
|
+
notifyPluginStatus(status: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Request sidebar to activate (expand and scroll to) the card for the given issue.
|
|
32
|
+
*/
|
|
33
|
+
activateAgenticIssue(issueId: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Request sidebar to invalidate (dismiss) the card for the given issue.
|
|
36
|
+
*/
|
|
37
|
+
invalidateAgenticIssue(issueId: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Update IPC configuration
|
|
40
|
+
*/
|
|
41
|
+
configure(config: IPCConfig): void;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=sidebarAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidebarAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/sidebarAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;gBAEnC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAW/F;;OAEG;IACI,OAAO,IAAI,IAAI;IAKtB;;;OAGG;IACU,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9D;;OAEG;IACU,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjE;;OAEG;IACU,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;CAG1C"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown by integration/plugin code when text lookup (e.g. selection or
|
|
3
|
+
* positioning) fails. The sidebar treats this as a selection failure and can
|
|
4
|
+
* invalidate the issue card with the error message.
|
|
5
|
+
*
|
|
6
|
+
* Plugin developers should throw this from selectContent (and optionally
|
|
7
|
+
* replaceContent) when the requested text cannot be found or located.
|
|
8
|
+
*/
|
|
9
|
+
export declare class TextLookupError extends Error {
|
|
10
|
+
readonly name = "TextLookupError";
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Type guard for TextLookupError. Use when catching errors from adapter methods
|
|
15
|
+
* (e.g. selectContent, replaceContent) to narrow the type and handle text
|
|
16
|
+
* lookup failures specifically.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isTextLookupError(error: unknown): error is TextLookupError;
|
|
19
|
+
/**
|
|
20
|
+
* Union of errors that selectContent may throw. Use for control-flow typing when
|
|
21
|
+
* catching (e.g. narrow with isTextLookupError).
|
|
22
|
+
*/
|
|
23
|
+
export type SelectContentError = TextLookupError;
|
|
24
|
+
/**
|
|
25
|
+
* Union of errors that replaceContent may throw. Use for control-flow typing when
|
|
26
|
+
* catching. Extend when adding new known errors for replaceContent.
|
|
27
|
+
*/
|
|
28
|
+
export type ReplaceContentError = TextLookupError;
|
|
29
|
+
/**
|
|
30
|
+
* Serialized shape of an error sent over IPC (name + message; extend for custom payloads).
|
|
31
|
+
*/
|
|
32
|
+
export interface SerializedError {
|
|
33
|
+
name?: string;
|
|
34
|
+
message?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
export type ErrorReconstructor = (message: string, parsed: SerializedError) => Error;
|
|
38
|
+
/**
|
|
39
|
+
* Registry of known error names to reconstructors. Add entries here when introducing
|
|
40
|
+
* new error types that should be reconstructed on the receiving side (e.g. for instanceof).
|
|
41
|
+
*/
|
|
42
|
+
export declare const ipcErrorReconstructors: Record<string, ErrorReconstructor>;
|
|
43
|
+
/**
|
|
44
|
+
* Reconstructs an Error from IPC-serialized payload. Uses ipcErrorReconstructors
|
|
45
|
+
* when name is known; otherwise returns a plain Error with the message.
|
|
46
|
+
*/
|
|
47
|
+
export declare function reconstructError(parsed: SerializedError): Error;
|
|
48
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAkB,IAAI,qBAAqB;gBAE/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAEjD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,KAAK,KAAK,CAAC;AAErF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAErE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,KAAK,CAW/D"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC;AAGzB,cAAc,YAAY,CAAC;AAG3B,cAAc,OAAO,CAAC;AAGtB,cAAc,gBAAgB,CAAC;AAG/B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, AgenticIssuePayload } from "../types/common";
|
|
2
|
+
/**
|
|
3
|
+
* Call signatures for all bidirectional IPC communication.
|
|
4
|
+
* This interface maps method names to their parameter types and return types.
|
|
5
|
+
*/
|
|
6
|
+
export interface CallSignatures {
|
|
7
|
+
/**
|
|
8
|
+
* Request content from the editor in whatever format the integration supports
|
|
9
|
+
*/
|
|
10
|
+
getContent(): Promise<ContentInfo>;
|
|
11
|
+
/**
|
|
12
|
+
* Request selected content from the editor in whatever format the integration supports
|
|
13
|
+
*/
|
|
14
|
+
getSelectedContent(): Promise<ContentInfo>;
|
|
15
|
+
/**
|
|
16
|
+
* Replace content in the editor over the half-open span `[range.start, range.end)`.
|
|
17
|
+
* @throws {TextLookupError} When the requested text cannot be found or located
|
|
18
|
+
*/
|
|
19
|
+
replaceContent(suggestion: string, range: ContentRange): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Select content in the editor at the half-open span `[range.start, range.end)`.
|
|
22
|
+
* @throws {TextLookupError} When the requested text cannot be found or located
|
|
23
|
+
*/
|
|
24
|
+
selectContent(range: ContentRange): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Show a dialog in the editor
|
|
27
|
+
*/
|
|
28
|
+
showDialog(dialogHtml: string, width?: number, height?: number, title?: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Close the dialog in the editor
|
|
31
|
+
*/
|
|
32
|
+
closeDialog(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Replace multiple contents in the editor
|
|
35
|
+
*/
|
|
36
|
+
replaceMultipleContents(replacements: ContentReplacement[]): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Get initialization configuration from the editor
|
|
39
|
+
* This is called by the sidebar when it's ready to initialize
|
|
40
|
+
*/
|
|
41
|
+
getInitConfig(): Promise<SidebarConfig>;
|
|
42
|
+
/**
|
|
43
|
+
* Notify plugin when one agent's agentic results are available (streaming).
|
|
44
|
+
*/
|
|
45
|
+
onAgenticAgentResults(agentName: string, issues: AgenticIssuePayload[]): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Notify plugin when the agentic stream has finished.
|
|
48
|
+
*/
|
|
49
|
+
onAgenticStreamComplete(): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Notify sidebar of plugin status changes
|
|
52
|
+
* Optional method - demonstrates Plugin → Sidebar communication pattern
|
|
53
|
+
*/
|
|
54
|
+
onPluginStatusChange?(status: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Request sidebar to activate (expand and scroll to) the card for the given issue id.
|
|
57
|
+
*/
|
|
58
|
+
activateAgenticIssue(issueId: string): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Request sidebar to invalidate (dismiss) the card for the given issue id.
|
|
61
|
+
*/
|
|
62
|
+
invalidateAgenticIssue(issueId: string): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=call-signatures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-signatures.d.ts","sourceRoot":"","sources":["../../src/ipc/call-signatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,WAAW,cAAc;IAK7B;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAEnC;;OAEG;IACH,kBAAkB,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAE3C;;;OAGG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvE;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD;;OAEG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/F;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B;;OAEG;IACH,uBAAuB,CAAC,YAAY,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3E;;;OAGG;IACH,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAExC;;OAEG;IACH,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvF;;OAEG;IACH,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAMzC;;;OAGG;IACH,oBAAoB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErD;;OAEG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErD;;OAEG;IACH,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a deferred promise that can be resolved or rejected via method
|
|
3
|
+
* calls on the instance.
|
|
4
|
+
*/
|
|
5
|
+
export declare class DeferredPromise<T> implements Promise<T> {
|
|
6
|
+
private _promise;
|
|
7
|
+
readonly [Symbol.toStringTag]: string;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the underlying promise with a specified value.
|
|
10
|
+
*
|
|
11
|
+
* @param value - The value to resolve the promise with.
|
|
12
|
+
*/
|
|
13
|
+
resolve: (value: PromiseLike<T> | T) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Rejects the underlying promise with a specified reason.
|
|
16
|
+
*
|
|
17
|
+
* @param reason - The reason for rejecting the promise.
|
|
18
|
+
*/
|
|
19
|
+
reject: (reason?: any) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new instance of DeferredPromise.
|
|
22
|
+
*/
|
|
23
|
+
constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Attaches callbacks for the resolution and/or rejection of the promise.
|
|
26
|
+
*
|
|
27
|
+
* @param onFulfilled - The callback to execute when the promise is resolved.
|
|
28
|
+
* @param onRejected - The callback to execute when the promise is rejected.
|
|
29
|
+
* @returns - A new promise resolved or rejected by the onFulfilled or
|
|
30
|
+
* onRejected callback.
|
|
31
|
+
*/
|
|
32
|
+
then<TResult1 = T, TResult2 = never>(onFulfilled?: (value: T) => PromiseLike<TResult1> | TResult1, onRejected?: (reason: any) => PromiseLike<TResult2> | TResult2): Promise<TResult1 | TResult2>;
|
|
33
|
+
/**
|
|
34
|
+
* Attaches a callback for the rejection of the promise.
|
|
35
|
+
*
|
|
36
|
+
* @param onRejected - The callback to execute when the promise is rejected.
|
|
37
|
+
* @returns - A new promise resolved by the onRejected callback.
|
|
38
|
+
*/
|
|
39
|
+
catch<TResult2 = never>(onRejected: (reason: any) => PromiseLike<TResult2> | TResult2): Promise<T | TResult2>;
|
|
40
|
+
/**
|
|
41
|
+
* Attaches a callback that is executed when the promise is settled, whether
|
|
42
|
+
* fulfilled or rejected.
|
|
43
|
+
*
|
|
44
|
+
* @param onFinally - The callback to execute when the promise is settled.
|
|
45
|
+
* @returns - A new promise resolved by the onFinally callback.
|
|
46
|
+
*/
|
|
47
|
+
finally(onFinally?: (() => void) | null): Promise<T>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=deferred-promise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deferred-promise.d.ts","sourceRoot":"","sources":["../../src/ipc/deferred-promise.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,eAAe,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IACnD,OAAO,CAAC,QAAQ,CAAa;IAE7B,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,CAAa;IAElD;;;;OAIG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,CAAQ;IAEpD;;;;OAIG;IACH,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAQ;IAEtC;;OAEG;;IAQH;;;;;;;OAOG;IACH,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,EACjC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,WAAW,CAAC,QAAQ,CAAC,GAAG,QAAQ,EAC5D,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,WAAW,CAAC,QAAQ,CAAC,GAAG,QAAQ;IAKhE;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,GAAG,KAAK,EAAE,UAAU,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,WAAW,CAAC,QAAQ,CAAC,GAAG,QAAQ;IAIrF;;;;;;OAMG;IACH,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI;CAGxC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { DeferredPromise } from "../ipc/deferred-promise";
|
|
2
|
+
export { IPCCore } from "../ipc/ipc-core";
|
|
3
|
+
export type { ReceiverFn } from "../ipc/ipc-core";
|
|
4
|
+
export { PluginIPCAdapter } from "../ipc/plugin-ipc-adapter";
|
|
5
|
+
export { SidebarIPCAdapter } from "../ipc/sidebar-ipc-adapter";
|
|
6
|
+
export type { MessageBase, CallMessage, ResponseMessage, ErrorMessage, IPCMessage, IPCConfig, CallOptions, } from "../ipc/message-types";
|
|
7
|
+
export { DEFAULT_IPC_CONFIG } from "../ipc/message-types";
|
|
8
|
+
export type { CallSignatures } from "../ipc/call-signatures";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ipc/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,YAAY,EACV,WAAW,EACX,WAAW,EACX,eAAe,EACf,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { CallSignatures } from "../ipc/call-signatures";
|
|
2
|
+
import type { IPCMessage, IPCConfig, CallOptions } from "../ipc/message-types";
|
|
3
|
+
export type ReceiverFn<R extends keyof CallSignatures> = (...data: Parameters<NonNullable<CallSignatures[R]>>) => ReturnType<NonNullable<CallSignatures[R]>>;
|
|
4
|
+
/**
|
|
5
|
+
* Core IPC system managing bidirectional communication
|
|
6
|
+
*/
|
|
7
|
+
export declare class IPCCore {
|
|
8
|
+
private promisesByID;
|
|
9
|
+
private receiversByName;
|
|
10
|
+
private currentID;
|
|
11
|
+
private config;
|
|
12
|
+
private readonly postMessage;
|
|
13
|
+
constructor(postMessage: (message: IPCMessage) => void, config?: IPCConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Update IPC configuration
|
|
16
|
+
*/
|
|
17
|
+
configure(config: IPCConfig): void;
|
|
18
|
+
/**
|
|
19
|
+
* Makes a call to the other side. Returns a promise that resolves when
|
|
20
|
+
* the other side responds.
|
|
21
|
+
*
|
|
22
|
+
* @param name - The name of the receiver on the other side
|
|
23
|
+
* @param data - Parameters to send to the receiver
|
|
24
|
+
* @returns Promise that resolves with the receiver's response
|
|
25
|
+
*/
|
|
26
|
+
call<T extends keyof CallSignatures>(name: T, ...data: Parameters<NonNullable<CallSignatures[T]>>): Promise<ReturnType<NonNullable<CallSignatures[T]>>>;
|
|
27
|
+
/**
|
|
28
|
+
* Makes a call with per-call overrides (e.g. timeout).
|
|
29
|
+
*
|
|
30
|
+
* @param name - The name of the receiver on the other side
|
|
31
|
+
* @param options - Per-call overrides (e.g. timeout in ms)
|
|
32
|
+
* @param data - Parameters to send to the receiver
|
|
33
|
+
* @returns Promise that resolves with the receiver's response
|
|
34
|
+
*/
|
|
35
|
+
callWithOptions<T extends keyof CallSignatures>(name: T, options: CallOptions, ...data: Parameters<NonNullable<CallSignatures[T]>>): Promise<ReturnType<NonNullable<CallSignatures[T]>>>;
|
|
36
|
+
/**
|
|
37
|
+
* Registers a function to receive calls with a particular name.
|
|
38
|
+
* The return value will be sent back to the caller.
|
|
39
|
+
*
|
|
40
|
+
* @param name - The name of the receiver
|
|
41
|
+
* @param fn - The function that will receive calls
|
|
42
|
+
*/
|
|
43
|
+
receive<R extends keyof CallSignatures>(name: R, fn: ReceiverFn<R>): void;
|
|
44
|
+
/**
|
|
45
|
+
* Unregisters a receiver for a given call name
|
|
46
|
+
*
|
|
47
|
+
* @param name - The name of the receiver to unregister
|
|
48
|
+
*/
|
|
49
|
+
ignore(name: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Handles incoming messages from the other side
|
|
52
|
+
* @param message - The IPC message to handle
|
|
53
|
+
*/
|
|
54
|
+
handleMessage(message: IPCMessage): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Handles incoming call messages
|
|
57
|
+
*/
|
|
58
|
+
private handleCall;
|
|
59
|
+
/**
|
|
60
|
+
* Handles incoming response messages
|
|
61
|
+
*/
|
|
62
|
+
private handleResponse;
|
|
63
|
+
/**
|
|
64
|
+
* Handles incoming error messages
|
|
65
|
+
*/
|
|
66
|
+
private handleError;
|
|
67
|
+
/**
|
|
68
|
+
* Cleanup all pending promises and receivers
|
|
69
|
+
*/
|
|
70
|
+
destroy(): void;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=ipc-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipc-core.d.ts","sourceRoot":"","sources":["../../src/ipc/ipc-core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAGV,UAAU,EAEV,SAAS,EACT,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAK7B,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,cAAc,IAAI,CACvD,GAAG,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAChD,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAUhD;;GAEG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,YAAY,CAA+C;IACnE,OAAO,CAAC,eAAe,CAAoE;IAC3F,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgC;gBAEhD,WAAW,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,EAAE,MAAM,CAAC,EAAE,SAAS;IAK1E;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIzC;;;;;;;OAOG;IACI,IAAI,CAAC,CAAC,SAAS,MAAM,cAAc,EACxC,IAAI,EAAE,CAAC,EACP,GAAG,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAClD,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAItD;;;;;;;OAOG;IACI,eAAe,CAAC,CAAC,SAAS,MAAM,cAAc,EACnD,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,WAAW,EACpB,GAAG,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAClD,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IA+BtD;;;;;;OAMG;IACI,OAAO,CAAC,CAAC,SAAS,MAAM,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI;IAKhF;;;;OAIG;IACI,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAMjC;;;OAGG;IACU,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB9D;;OAEG;YACW,UAAU;IAkExB;;OAEG;IACH,OAAO,CAAC,cAAc;IActB;;OAEG;IACH,OAAO,CAAC,WAAW;IAuBnB;;OAEG;IACI,OAAO,IAAI,IAAI;CAWvB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base message structure for IPC communication
|
|
3
|
+
*/
|
|
4
|
+
export type MessageBase = {
|
|
5
|
+
type: "call" | "response" | "error";
|
|
6
|
+
id: number;
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Message sent when calling a remote function
|
|
11
|
+
*/
|
|
12
|
+
export type CallMessage = MessageBase & {
|
|
13
|
+
type: "call";
|
|
14
|
+
data: any[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Message sent when responding to a call
|
|
18
|
+
*/
|
|
19
|
+
export type ResponseMessage = MessageBase & {
|
|
20
|
+
type: "response";
|
|
21
|
+
data: any;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Message sent when an error occurs during call handling
|
|
25
|
+
*/
|
|
26
|
+
export type ErrorMessage = MessageBase & {
|
|
27
|
+
type: "error";
|
|
28
|
+
errorJSON: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Union of all possible message types
|
|
32
|
+
*/
|
|
33
|
+
export type IPCMessage = CallMessage | ResponseMessage | ErrorMessage;
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for IPC system
|
|
36
|
+
*/
|
|
37
|
+
export interface IPCConfig {
|
|
38
|
+
/**
|
|
39
|
+
* Timeout in milliseconds for waiting for a response
|
|
40
|
+
* @default 10000 (10 seconds)
|
|
41
|
+
*/
|
|
42
|
+
timeout?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Optional overrides for a single IPC call (e.g. timeout).
|
|
46
|
+
*/
|
|
47
|
+
export interface CallOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Timeout in milliseconds for this call. Overrides default IPC config timeout.
|
|
50
|
+
*/
|
|
51
|
+
timeout?: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Default IPC configuration
|
|
55
|
+
*/
|
|
56
|
+
export declare const DEFAULT_IPC_CONFIG: Required<IPCConfig>;
|
|
57
|
+
//# sourceMappingURL=message-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-types.d.ts","sourceRoot":"","sources":["../../src/ipc/message-types.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,EAAE,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAC1C,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACvC,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,eAAe,GAAG,YAAY,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,SAAS,CAElD,CAAC"}
|