@markupai/sidebar-adapter 0.0.23 → 1.1.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 +106 -23
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/pluginAdapter.d.ts +79 -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 +69 -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 +83 -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 +312 -514
- package/dist/main.umd.cjs +12 -12
- package/dist/sidebar-host/createSidebarHost.d.ts +107 -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 +132 -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 +89 -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
|
@@ -14,8 +14,9 @@ You do **not** need prior knowledge of how the sidebar is built internally. As a
|
|
|
14
14
|
6. [SidebarAdapter](#sidebaradapter-editor--sidebar) (host page → serves the sidebar)
|
|
15
15
|
7. [Host shell & HTML helpers](#sidebar-host-shell-shared-htmldom)
|
|
16
16
|
8. [createSidebarHost](#createsidebarhost) (iframe + overlay + adapter in one step)
|
|
17
|
-
9. [
|
|
18
|
-
10. [
|
|
17
|
+
9. [Authentication](#authentication-optional) (declaring an Auth0 login strategy)
|
|
18
|
+
10. [Sidebar load overlay (standalone)](#sidebarloadoverlay-editor-ui)
|
|
19
|
+
11. [API reference](#api-reference) · [Development](#development)
|
|
19
20
|
|
|
20
21
|
## Features
|
|
21
22
|
|
|
@@ -26,13 +27,14 @@ You do **not** need prior knowledge of how the sidebar is built internally. As a
|
|
|
26
27
|
- **Host shell helpers** — `ensureSidebarHostShell` / `buildSidebarHostHtmlDocument` so you don’t duplicate container markup and layout CSS
|
|
27
28
|
- **MIME helpers** — `MimeType` enum plus arbitrary MIME strings for `ContentInfo`
|
|
28
29
|
- **Errors** — `TextLookupError` and guards for editor lookup failures
|
|
30
|
+
- **Auth** — `SidebarConfig.auth` for declaring the Auth0 login strategy (`"mediation" | "popup"`) and optional `PluginInterface.openAuthUrl` for routing the authorize URL through a host-owned external-browser primitive (see [Authentication](#authentication-optional))
|
|
29
31
|
- **Cleanup** — `destroy()` / teardown functions on adapters and hosts
|
|
30
32
|
|
|
31
33
|
## Host integration checklist
|
|
32
34
|
|
|
33
35
|
Use this if you are **embedding Markup AI’s sidebar** in your product for the first time.
|
|
34
36
|
|
|
35
|
-
1. **Get the sidebar URL from Markup AI** — Base URL plus any required **hash route** (for example
|
|
37
|
+
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
38
|
2. **Add an iframe** on your host page whose `src` is that URL (or let **`createSidebarHost`** create the iframe for you).
|
|
37
39
|
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
40
|
4. **Create a `SidebarAdapter`** (or call **`createSidebarHost`**) with:
|
|
@@ -69,6 +71,15 @@ If you use the **agentic** layout, implement the optional hooks **`onAgenticAgen
|
|
|
69
71
|
npm install @markupai/sidebar-adapter
|
|
70
72
|
```
|
|
71
73
|
|
|
74
|
+
### Upgrading from 0.x to 1.x
|
|
75
|
+
|
|
76
|
+
These releases introduce **breaking** IPC and TypeScript contract updates:
|
|
77
|
+
|
|
78
|
+
- **`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).
|
|
79
|
+
- **`replaceContent`** is `replaceContent(suggestion, range)` with a **required** **`ContentRange`** (`[range.start, range.end)` half-open semantics).
|
|
80
|
+
- **`ContentReplacement`** batch entries are **`{ suggestion, range }`** only (no `original` field).
|
|
81
|
+
- 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).
|
|
82
|
+
|
|
72
83
|
## Architecture options
|
|
73
84
|
|
|
74
85
|
| Integration style | Where the sidebar iframe runs | Where your document/editor code runs | Typical approach |
|
|
@@ -107,16 +118,16 @@ const selectedContent = await adapter.getSelectedContent();
|
|
|
107
118
|
console.log("Selected content:", selectedContent.content);
|
|
108
119
|
console.log("Document reference:", selectedContent.documentReference);
|
|
109
120
|
|
|
110
|
-
// Select content in the editor
|
|
111
|
-
await adapter.selectContent(
|
|
121
|
+
// Select content in the editor (half-open range [0, 11))
|
|
122
|
+
await adapter.selectContent({ start: 0, end: 11 });
|
|
112
123
|
|
|
113
|
-
// Replace content in the editor
|
|
114
|
-
await adapter.replaceContent("Hello
|
|
124
|
+
// Replace content in the editor (apply suggestion to [start, end))
|
|
125
|
+
await adapter.replaceContent("Hello universe", { start: 0, end: 11 });
|
|
115
126
|
|
|
116
127
|
// Replace multiple contents in the editor
|
|
117
128
|
await adapter.replaceMultipleContents([
|
|
118
|
-
{
|
|
119
|
-
{
|
|
129
|
+
{ suggestion: "Hello universe", range: { start: 0, end: 11 } },
|
|
130
|
+
{ suggestion: "bar", range: { start: 20, end: 23 } },
|
|
120
131
|
]);
|
|
121
132
|
|
|
122
133
|
// Show a dialog
|
|
@@ -138,6 +149,7 @@ import {
|
|
|
138
149
|
SidebarAdapter,
|
|
139
150
|
MimeType,
|
|
140
151
|
type PluginInterface,
|
|
152
|
+
type ContentRange,
|
|
141
153
|
type ContentReplacement,
|
|
142
154
|
type ContentInfo,
|
|
143
155
|
} from "@markupai/sidebar-adapter";
|
|
@@ -175,19 +187,23 @@ const pluginInterface: PluginInterface = {
|
|
|
175
187
|
useCheckPreviewDialog: true,
|
|
176
188
|
supportCheckSelection: true,
|
|
177
189
|
pluginOrigin: globalThis.location.origin,
|
|
190
|
+
// Optional. Declare the Auth0 login strategy the sidebar should run.
|
|
191
|
+
// Omit to let the sidebar pick heuristically (legacy behavior).
|
|
192
|
+
// See the "Authentication" section below.
|
|
193
|
+
auth: { type: "mediation" },
|
|
178
194
|
};
|
|
179
195
|
},
|
|
180
196
|
|
|
181
197
|
// Select content in the editor
|
|
182
|
-
selectContent: async (
|
|
183
|
-
console.log("Select content
|
|
184
|
-
selectContentInEditor(
|
|
198
|
+
selectContent: async (range: ContentRange) => {
|
|
199
|
+
console.log("Select content range:", range);
|
|
200
|
+
selectContentInEditor(range);
|
|
185
201
|
},
|
|
186
202
|
|
|
187
203
|
// Replace content in the editor
|
|
188
|
-
replaceContent: async (
|
|
189
|
-
console.log("Replace content:",
|
|
190
|
-
replaceContentInEditor(
|
|
204
|
+
replaceContent: async (suggestion: string, range: ContentRange) => {
|
|
205
|
+
console.log("Replace content span:", range, "with:", suggestion);
|
|
206
|
+
replaceContentInEditor(suggestion, range);
|
|
191
207
|
},
|
|
192
208
|
|
|
193
209
|
// Replace multiple contents in the editor
|
|
@@ -222,7 +238,9 @@ sidebarAdapter.destroy();
|
|
|
222
238
|
|
|
223
239
|
### SidebarLoadOverlay (Editor UI)
|
|
224
240
|
|
|
225
|
-
Use `setupSidebarLoadOverlay` when you manage the iframe yourself and only want the **failed-to-load / retry** UI.
|
|
241
|
+
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**.
|
|
242
|
+
|
|
243
|
+
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
244
|
|
|
227
245
|

|
|
228
246
|
|
|
@@ -241,7 +259,11 @@ const teardownLoadOverlay = setupSidebarLoadOverlay(container, iframe, {
|
|
|
241
259
|
teardownLoadOverlay();
|
|
242
260
|
```
|
|
243
261
|
|
|
244
|
-
|
|
262
|
+
**`SidebarLoadOverlayOptions`** (all optional beyond defaults): **`sidebarUrl`**, **`targetOrigin`**, **`timeoutMs`**, **`retryIntervalMs`**, **`messageListenWindow`** (see above).
|
|
263
|
+
|
|
264
|
+
**`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`**.
|
|
265
|
+
|
|
266
|
+
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
267
|
|
|
246
268
|
### createSidebarHost
|
|
247
269
|
|
|
@@ -257,6 +279,7 @@ Creates the sidebar iframe (or uses yours), optionally mounts the **load overlay
|
|
|
257
279
|
- **`SIDEBAR_URL_OVERRIDE_STORAGE_KEY`** — `localStorage` key for the override; use **`getSidebarBaseUrlWithOverride(defaultUrl)`** to resolve the base URL (reads override when set, otherwise `defaultUrl`; safe when `localStorage` is missing or throws).
|
|
258
280
|
- **`sidebarPostMessageTargetOrigin(sidebarUrl, options?)`** — derives **`adapterOptions.targetOrigin`** from the sidebar URL (falls back to `"*"`; optional **`onInvalidUrl`** callback).
|
|
259
281
|
- **`assertSidebarHostAdapter(host, message?)`** — type-narrows **`host`** after **`createSidebarHost`** when you passed **`plugin`** (throws if **`adapter`** is **`null`**).
|
|
282
|
+
- **`AUTH_CONFIG_OVERRIDE_STORAGE_KEY`** — `localStorage` key for forcing an `AuthConfig` at runtime (dev/test only); used together with **`getAuthConfigWithOverride(hostConfig, allowOverride)`** which honors the override only when `allowOverride` is `true`. See [Authentication](#authentication-optional).
|
|
260
283
|
|
|
261
284
|
```typescript
|
|
262
285
|
import {
|
|
@@ -267,8 +290,8 @@ import {
|
|
|
267
290
|
} from "@markupai/sidebar-adapter";
|
|
268
291
|
|
|
269
292
|
const container = document.getElementById("sidebar-container") as HTMLElement;
|
|
270
|
-
// Use the URL Markup AI provides
|
|
271
|
-
const sidebarUrl = "https://your-sidebar-host
|
|
293
|
+
// Use the URL Markup AI provides. Default Agentic: base URL (equivalent to #/). Explicit overrides: #/original, #/previous, #/next-ui, or #/agentic.
|
|
294
|
+
const sidebarUrl = "https://your-sidebar-host/";
|
|
272
295
|
|
|
273
296
|
// `myPlugin` is your PluginInterface implementation (see SidebarAdapter example above).
|
|
274
297
|
const host = createSidebarHost({
|
|
@@ -290,8 +313,64 @@ host.destroy();
|
|
|
290
313
|
|
|
291
314
|
- If you already have an iframe, pass **`iframe`** and omit **`iframeMount`**.
|
|
292
315
|
- If you omit **`loadOverlayContainer`**, no overlay is mounted (same as using `new SidebarAdapter` only, plus optional iframe creation).
|
|
316
|
+
- **`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
317
|
- **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
318
|
|
|
319
|
+
### Authentication (optional)
|
|
320
|
+
|
|
321
|
+
The sidebar runs an Auth0 login flow when the user signs in. You can tell it **which** strategy to use from the host via **`SidebarConfig.auth`**, and — for sandboxed hosts where `globalThis.open` is blocked — route the Auth0 `authorizeUrl` through your own external-browser primitive via the optional **`PluginInterface.openAuthUrl`** hook.
|
|
322
|
+
|
|
323
|
+
#### AuthConfig
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
type AuthConfig = { type: "mediation" } | { type: "popup" };
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
- **`"mediation"`** — backend-mediated authorization code flow. The sidebar asks the backend to start an OAuth handshake, opens the returned `authorizeUrl` in an external browser, and polls the backend for the code + token exchange. Required for hosts embedded in iframes with restricted origins (Figma plugin UI, Office task pane).
|
|
330
|
+
- **`"popup"`** — Auth0 SPA `loginWithPopup`. Requires a secure origin and Web Crypto.
|
|
331
|
+
|
|
332
|
+
Declare it in your **`PluginInterface.getInitConfig`** return value:
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
getInitConfig: async () => ({
|
|
336
|
+
// ...other fields...
|
|
337
|
+
auth: { type: "mediation" },
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
When **`auth`** is omitted, the sidebar falls back to **legacy heuristic selection** for backwards compatibility.
|
|
342
|
+
|
|
343
|
+
#### openAuthUrl (sandboxed hosts)
|
|
344
|
+
|
|
345
|
+
Mediation needs to open the Auth0 `authorizeUrl` in an external browser. By default the sidebar uses `globalThis.open(url, "_blank", "noopener,noreferrer")`. In hosts where that's blocked — notably M365 / Office task panes — implement the optional **`openAuthUrl`** method on **`PluginInterface`**:
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
import type { PluginInterface } from "@markupai/sidebar-adapter";
|
|
349
|
+
|
|
350
|
+
const plugin: PluginInterface = {
|
|
351
|
+
// ...other methods...
|
|
352
|
+
openAuthUrl: async (url) => {
|
|
353
|
+
// In an Office add-in:
|
|
354
|
+
Office.context.ui.openBrowserWindow(url);
|
|
355
|
+
// If the host cannot open the URL, throw so the sidebar fails the
|
|
356
|
+
// mediation login fast (instead of polling to a 120 s timeout).
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
When the plugin does not implement **`openAuthUrl`**, the sidebar detects the absence via the standard **`"No receiver registered for: openAuthUrl"`** IPC error and falls back to its own `globalThis.open`. Any **other** error thrown by your handler (e.g. popup blocked) is re-raised to the user unchanged.
|
|
362
|
+
|
|
363
|
+
#### Dev/test override
|
|
364
|
+
|
|
365
|
+
In dev builds you can force an `AuthConfig` without changing host code by writing a JSON string to `localStorage` under the key exported as **`AUTH_CONFIG_OVERRIDE_STORAGE_KEY`**. The sidebar applies the override only when the consumer passes **`allowOverride: true`** to **`getAuthConfigWithOverride(hostConfig, allowOverride)`** — for example, gated on **`import.meta.env.DEV`**:
|
|
366
|
+
|
|
367
|
+
```js
|
|
368
|
+
// Force mediation in a local dev tab:
|
|
369
|
+
localStorage.setItem("markupai.sidebarNextGen.authOverride", '{"type":"mediation"}');
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Invalid JSON or unknown `type` values are logged and ignored; the host's declared `auth` is used instead.
|
|
373
|
+
|
|
295
374
|
### Sidebar host shell (shared HTML/DOM)
|
|
296
375
|
|
|
297
376
|
Avoid copying the same **`#sidebarContainer`** + full-height layout CSS into every host HTML file.
|
|
@@ -366,13 +445,13 @@ Structure for batch content replacement operations.
|
|
|
366
445
|
|
|
367
446
|
```typescript
|
|
368
447
|
type ContentReplacement = {
|
|
369
|
-
original: string;
|
|
370
448
|
suggestion: string;
|
|
371
449
|
range: ContentRange;
|
|
372
450
|
};
|
|
373
451
|
|
|
374
452
|
type ContentRange = {
|
|
375
453
|
start: number;
|
|
454
|
+
end: number;
|
|
376
455
|
};
|
|
377
456
|
```
|
|
378
457
|
|
|
@@ -385,8 +464,8 @@ Implement these **on the host** as async functions. The sidebar calls them over
|
|
|
385
464
|
- `getInitConfig(): Promise<SidebarConfig>` — Integration name, version, feature flags, dialog closing script, etc.
|
|
386
465
|
- `getContent(): Promise<ContentInfo>` — Full document (or main buffer) text; must include `documentReference`; `mimeType` optional
|
|
387
466
|
- `getSelectedContent(): Promise<ContentInfo>` — Current selection; same `ContentInfo` rules as `getContent`
|
|
388
|
-
- `selectContent(
|
|
389
|
-
- `replaceContent(
|
|
467
|
+
- `selectContent(range: ContentRange): Promise<void>` — Focus/highlight the document span `[range.start, range.end)`
|
|
468
|
+
- `replaceContent(suggestion: string, range: ContentRange): Promise<void>` — Apply a single edit to `[range.start, range.end)`
|
|
390
469
|
- `replaceMultipleContents(replacements: ContentReplacement[]): Promise<void>` — Batch edits
|
|
391
470
|
- `showDialog(dialogHtml: string, width?: number, height?: number, title?: string): Promise<void>` — Host-rendered dialog chrome around HTML from the sidebar
|
|
392
471
|
- `closeDialog(): Promise<void>` — Dismiss that dialog
|
|
@@ -396,6 +475,10 @@ Optional (agentic / streaming flows):
|
|
|
396
475
|
- `onAgenticAgentResults?(agentName: string, issues: AgenticIssuePayload[]): Promise<void>` — Per-agent results as they stream
|
|
397
476
|
- `onAgenticStreamComplete?(): Promise<void>` — Stream finished (success or terminal state)
|
|
398
477
|
|
|
478
|
+
Optional (authentication):
|
|
479
|
+
|
|
480
|
+
- `openAuthUrl?(url: string): Promise<void>` — Open the Auth0 `authorizeUrl` in whatever external-browser primitive the host provides. Implement this in sandboxed hosts where `globalThis.open` is blocked or unavailable (e.g. Office task panes should call `Office.context.ui.openBrowserWindow(url)`). Throw if the window cannot be opened so the mediation flow fails fast instead of polling to timeout. When omitted, the sidebar falls back to `globalThis.open(url, "_blank", "noopener,noreferrer")`.
|
|
481
|
+
|
|
399
482
|
#### Error control flows
|
|
400
483
|
|
|
401
484
|
When implementing `selectContent` or `replaceContent`, throw `TextLookupError` from this package when text lookup (e.g. locating the selection or target range) fails. The sidebar will treat it as a selection failure and can invalidate the issue card with the error message.
|
|
@@ -415,7 +498,7 @@ Errors sent over IPC are reconstructed on the sidebar, so you can type-check wit
|
|
|
415
498
|
import { isTextLookupError, type TextLookupError } from "@markupai/sidebar-adapter";
|
|
416
499
|
|
|
417
500
|
try {
|
|
418
|
-
await adapter.selectContent(
|
|
501
|
+
await adapter.selectContent({ start: 0, end: 5 });
|
|
419
502
|
} catch (error) {
|
|
420
503
|
if (isTextLookupError(error)) {
|
|
421
504
|
// 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,79 @@
|
|
|
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
|
+
* Ask the host plugin to open an external URL during an auth flow.
|
|
62
|
+
* The returned promise rejects if the host has not implemented the handler;
|
|
63
|
+
* callers should then fall back to `globalThis.open`.
|
|
64
|
+
*/
|
|
65
|
+
openAuthUrl(url: string): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Update IPC configuration
|
|
68
|
+
*/
|
|
69
|
+
configure(config: IPCConfig): void;
|
|
70
|
+
/**
|
|
71
|
+
* Set or update the target origin for postMessage communication
|
|
72
|
+
*/
|
|
73
|
+
setTargetOrigin(targetOrigin: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Get the current target origin
|
|
76
|
+
*/
|
|
77
|
+
getTargetOrigin(): string;
|
|
78
|
+
}
|
|
79
|
+
//# 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;;;;OAIG;IACI,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C;;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,69 @@
|
|
|
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
|
+
* Ask the plugin to open an external URL during an auth flow.
|
|
52
|
+
* See {@link PluginInterface.openAuthUrl}.
|
|
53
|
+
*/
|
|
54
|
+
openAuthUrl(url: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Notify sidebar of plugin status changes
|
|
57
|
+
* Optional method - demonstrates Plugin → Sidebar communication pattern
|
|
58
|
+
*/
|
|
59
|
+
onPluginStatusChange?(status: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Request sidebar to activate (expand and scroll to) the card for the given issue id.
|
|
62
|
+
*/
|
|
63
|
+
activateAgenticIssue(issueId: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Request sidebar to invalidate (dismiss) the card for the given issue id.
|
|
66
|
+
*/
|
|
67
|
+
invalidateAgenticIssue(issueId: string): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
//# 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;IAEzC;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAMxC;;;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"}
|