@markupai/sidebar-adapter 1.3.2 → 1.4.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 CHANGED
@@ -16,7 +16,7 @@ You do **not** need prior knowledge of how the sidebar is built internally. As a
16
16
  8. [createSidebarHost](#createsidebarhost) (iframe + overlay + adapter in one step)
17
17
  9. [Authentication](#authentication-optional) (declaring an Auth0 login strategy)
18
18
  10. [Sidebar load overlay (standalone)](#sidebarloadoverlay-editor-ui)
19
- 11. [Agentic issue lifecycle](#agentic-issue-lifecycle)
19
+ 11. [Agentic issue lifecycle](#agentic-issue-lifecycle) · [Document references](#document-references)
20
20
  12. [API reference](#api-reference) · [Development](#development)
21
21
 
22
22
  ## Features
@@ -44,7 +44,13 @@ Use this if you are **embedding Markup AI’s sidebar** in your product for the
44
44
  5. **Test the basics** — After load, the sidebar will request **`getInitConfig`** and **`getContent`**. Confirm your app returns sensible values before testing edits and dialogs.
45
45
  6. **Tear down on exit** — Call **`destroy()`** on the host returned by `createSidebarHost`, or on your `SidebarAdapter`, when the user leaves the screen or you remove the iframe.
46
46
 
47
- If you use the **agentic** layout, implement the optional hooks **`onAgenticAgentResults`** and **`onAgenticStreamComplete`** on `PluginInterface` when you need streaming results or completion signals in your host UI (see [PluginInterface](#plugininterface)). To stay in sync with per-issue lifecycle changes (Open / Resolved / Dismissed), also implement **`onAgenticIssueStatusChanged`** — the sidebar emits it after every transition so you can update annotations or other host UI. Hosts may also drive transitions programmatically via **`markAgenticIssueResolved`** and **`restoreAgenticIssue`** (paralleling the existing **`invalidateAgenticIssue`** dismiss RPC). See [Agentic issue lifecycle](#agentic-issue-lifecycle).
47
+ The sidebar runs the **agentic** experience. Its optional `PluginInterface` hooks and `SidebarInterface` RPCs let a host mirror the sidebar's issues in its own UI — useful for tracking issues and for context-menu flows such as applying a suggestion inline or activating an issue's card:
48
+
49
+ - **Receive streaming results** — implement **`onAgenticAgentResults`** and **`onAgenticStreamComplete`** to get issues (each with its suggestions) as they stream plus a completion signal, so you can draw your own underlines or build a context menu (see [PluginInterface](#plugininterface)).
50
+ - **Track issue state** — implement **`onAgenticIssueStatusChanged`**; the sidebar emits it after every Open / Resolved / Dismissed transition so you can keep annotations or other host UI in sync.
51
+ - **Drive the sidebar** — call **`activateAgenticIssue`** to expand and scroll to a card (e.g. when the user clicks an underline or picks the issue from a context menu), and **`markAgenticIssueResolved`** / **`restoreAgenticIssue`** / **`invalidateAgenticIssue`** to resolve / restore / dismiss a card — for example after applying a suggestion inline from your own context menu.
52
+
53
+ See [Agentic issue lifecycle](#agentic-issue-lifecycle).
48
54
 
49
55
  ## How the pieces fit together
50
56
 
@@ -72,15 +78,6 @@ If you use the **agentic** layout, implement the optional hooks **`onAgenticAgen
72
78
  npm install @markupai/sidebar-adapter
73
79
  ```
74
80
 
75
- ### Upgrading from 0.x to 1.x
76
-
77
- These releases introduce **breaking** IPC and TypeScript contract updates:
78
-
79
- - **`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).
80
- - **`replaceContent`** is `replaceContent(suggestion, range)` with a **required** **`ContentRange`** (`[range.start, range.end)` half-open semantics).
81
- - **`ContentReplacement`** batch entries are **`{ suggestion, range }`** only (no `original` field).
82
- - 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).
83
-
84
81
  ## Architecture options
85
82
 
86
83
  | Integration style | Where the sidebar iframe runs | Where your document/editor code runs | Typical approach |
@@ -153,6 +150,7 @@ import {
153
150
  type ContentRange,
154
151
  type ContentReplacement,
155
152
  type ContentInfo,
153
+ buildDocumentReference,
156
154
  } from "@markupai/sidebar-adapter";
157
155
 
158
156
  // Implement the PluginInterface
@@ -163,7 +161,9 @@ const pluginInterface: PluginInterface = {
163
161
  const content = getContentFromEditor();
164
162
  return {
165
163
  content: content,
166
- documentReference: "my-document.md", // Required: unique identifier for the document
164
+ // Required. "<prefix>:<id>" so the same document correlates across Markup surfaces.
165
+ // Pick the prefix once for your platform and never change it.
166
+ documentReference: buildDocumentReference("my-host", getStableDocumentId()),
167
167
  mimeType: MimeType.TEXT_MARKDOWN, // Optional: can use MimeType enum or any string
168
168
  };
169
169
  },
@@ -187,6 +187,11 @@ const pluginInterface: PluginInterface = {
187
187
  integrationId: "my-editor",
188
188
  useCheckPreviewDialog: true,
189
189
  supportCheckSelection: true,
190
+ // Optional. Allow the sidebar to run several agents in one check, each
191
+ // cancellable on its own. Defaults to false (Style agent only). The
192
+ // agents actually offered are the intersection of this flag and the
193
+ // organization's entitlement.
194
+ multiAgent: false,
190
195
  pluginOrigin: globalThis.location.origin,
191
196
  // Optional. Declare the Auth0 login strategy the sidebar should run.
192
197
  // Omit to let the sidebar pick heuristically (legacy behavior).
@@ -213,13 +218,13 @@ const pluginInterface: PluginInterface = {
213
218
  replaceMultipleContentsInEditor(replacements);
214
219
  },
215
220
 
216
- // Show a dialog
221
+ // Show a dialog (optional — omit on hosts without dialog support)
217
222
  showDialog: async (dialogHtml: string, width?: number, height?: number, title?: string) => {
218
223
  console.log("Show dialog:", title);
219
224
  showDialogInEditor(dialogHtml, width, height, title);
220
225
  },
221
226
 
222
- // Close the dialog
227
+ // Close the dialog (optional — omit on hosts without dialog support)
223
228
  closeDialog: async () => {
224
229
  console.log("Close dialog");
225
230
  closeDialogInEditor();
@@ -237,6 +242,11 @@ const sidebarAdapter = new SidebarAdapter(pluginInterface, iframe);
237
242
  sidebarAdapter.destroy();
238
243
  ```
239
244
 
245
+ > **`integrationName` vs `integrationId`** — two distinct concerns:
246
+ >
247
+ > - **`integrationName`** (required) is the **human-readable** name of the integration, **display only** (e.g. shown on the sidebar's About page). Example: `"Madcap Flare Desktop"`. Never derive a machine identifier from it.
248
+ > - **`integrationId`** (optional) is the **stable, machine-readable slug** (lowercase, hyphenated, no spaces) used for everything non-display: the Auth0 mediation login provider, PostHog analytics keys, the `x-integration-id` API header, and per-integration settings storage. Example: `"madcap-flare-desktop"`. Keep it stable across releases. When omitted it falls back to `DEFAULT_SIDEBAR_CONFIG.integrationId` (`"markupai-sidebar-app"`); mediation-login hosts **must** set it to match their Auth0 relay connection name (e.g. Figma → `"figma"`), since the sidebar feeds it straight to the login provider.
249
+
240
250
  ### SidebarLoadOverlay (Editor UI)
241
251
 
242
252
  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**.
@@ -339,6 +349,14 @@ getInitConfig: async () => ({
339
349
  });
340
350
  ```
341
351
 
352
+ For mediation, you may also set **`provider`** — the Auth0 relay-connection slug the sidebar sends to start the OAuth handshake:
353
+
354
+ ```typescript
355
+ auth: { type: "mediation", provider: "microsoft-365" }
356
+ ```
357
+
358
+ Set `provider` when **one** login provider must serve **several** `integrationId`s — e.g. a single add-in spanning multiple editors that each report a distinct `integrationId` (for analytics / the `x-integration-id` header / settings storage) but share one Auth0 relay connection. When omitted, the sidebar derives the provider from `integrationId`.
359
+
342
360
  When **`auth`** is omitted, the sidebar falls back to **legacy heuristic selection** for backwards compatibility.
343
361
 
344
362
  #### openAuthUrl (sandboxed hosts)
@@ -462,14 +480,14 @@ For agentic streaming callbacks, issue objects match the exported **`AgenticIssu
462
480
 
463
481
  Implement these **on the host** as async functions. The sidebar calls them over IPC and waits on the returned promises (pull style):
464
482
 
465
- - `getInitConfig(): Promise<SidebarConfig>` — Integration name, version, feature flags, dialog closing script, etc.
483
+ - `getInitConfig(): Promise<SidebarConfig>` — Integration display name (`integrationName`), stable machine id (`integrationId`), version, feature flags, dialog closing script, etc. See the `integrationName` vs `integrationId` note above.
466
484
  - `getContent(): Promise<ContentInfo>` — Full document (or main buffer) text; must include `documentReference`; `mimeType` optional
467
485
  - `getSelectedContent(): Promise<ContentInfo>` — Current selection; same `ContentInfo` rules as `getContent`
468
486
  - `selectContent(range: ContentRange): Promise<void>` — Focus/highlight the document span `[range.start, range.end)`
469
487
  - `replaceContent(suggestion: string, range: ContentRange): Promise<void>` — Apply a single edit to `[range.start, range.end)`
470
488
  - `replaceMultipleContents(replacements: ContentReplacement[]): Promise<void>` — Batch edits
471
- - `showDialog(dialogHtml: string, width?: number, height?: number, title?: string): Promise<void>` — Host-rendered dialog chrome around HTML from the sidebar
472
- - `closeDialog(): Promise<void>` — Dismiss that dialog
489
+ - `showDialog?(dialogHtml: string, width?: number, height?: number, title?: string): Promise<void>` — Host-rendered dialog chrome around HTML from the sidebar. **Optional** — omit on hosts without dialog support (also leave `useCheckPreviewDialog: false`).
490
+ - `closeDialog?(): Promise<void>` — Dismiss that dialog. **Optional**, pairs with `showDialog`.
473
491
 
474
492
  Optional (agentic / streaming flows):
475
493
 
@@ -642,6 +660,32 @@ async function onHostReopenClicked(issueId: string) {
642
660
  }
643
661
  ```
644
662
 
663
+ ## Document references
664
+
665
+ `ContentInfo.documentReference` identifies a document across scans. The backend keys its document registry on it, and the Markup session id derives its document component from `SHA-256(documentReference)`.
666
+
667
+ That only works if every Markup surface spells the same document the same way, so the format is `<prefix>:<id>` — a prefix naming your platform, then an id that is stable for the document. **You supply both**, because you know what platform you are and which identifier is stable there:
668
+
669
+ ```ts
670
+ import { buildDocumentReference } from "@markupai/sidebar-adapter";
671
+
672
+ buildDocumentReference("word", fileGuid); // → "word:aabb"
673
+ buildDocumentReference("gdocs", `${docId}/tab:${tabId}`); // → "gdocs:1A2B3C/tab:t.0"
674
+ buildDocumentReference("url", "https://example.com/page"); // → "url:https://example.com/page"
675
+ ```
676
+
677
+ Reuse an existing prefix when your platform already has one, so the same document seen from another Markup surface correlates: `gdocs`, `word`, `heretto`, `madcapflare`, `ixiasoft`, or `url` for anything addressed by a plain URL. If none fits, pick a new one — there is no fixed list, and adding a platform needs no adapter release.
678
+
679
+ ### What you are responsible for
680
+
681
+ - **Choose a prefix once and never change it.** The prefix is part of the document's identity. Changing it re-keys every document you have ever checked and breaks continuity with your own history — coordinate a change with the data team rather than shipping one quietly.
682
+ - **Use an id that is stable for the document.** Not the editor URL with its volatile query parameters, not a per-session handle — the thing that still identifies the document tomorrow.
683
+ - **Use the same reference for the whole document and for a selection.** A selection is a view of one document, not a different document; varying the reference between the two splits one document into two everywhere downstream.
684
+
685
+ `buildDocumentReference` is idempotent for its own prefix, so a host that stores composed references can pass them straight back. It throws on an empty id or a prefix that is not a lowercase name, since both would yield a reference that silently fails to correlate. `isDocumentReference(value)` reports whether a value already carries the `<prefix>:<id>` shape.
686
+
687
+ A bare, unprefixed value is still accepted and behaves exactly as before; it simply cannot be correlated with the same document seen on another surface.
688
+
645
689
  ## Integration settings
646
690
 
647
691
  A host MAY declare a small schema of settings it wants the sidebar to render and persist on its behalf. The sidebar shows a section in its Settings surface, persists user choices per-`integrationId` in `localStorage`, and notifies the host on user edits. The host can also push values and per-field UI state (`disabled`, `hidden`, `allowedValues`) to enforce its own rules — for example, "annotations off ⇒ view mode locked to `original`".
@@ -654,7 +698,7 @@ This is **opt-in and additive**. Hosts that omit `integrationSettings` from thei
654
698
  import type { SidebarConfig } from "@markupai/sidebar-adapter";
655
699
 
656
700
  const config: SidebarConfig = {
657
- integrationName: "my-integration",
701
+ integrationName: "My Integration",
658
702
  integrationVersion: "1.0.0",
659
703
  integrationId: "my-integration",
660
704
  useCheckPreviewDialog: false,
package/asyncapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "asyncapi": "3.0.0",
3
3
  "info": {
4
4
  "title": "Markup AI Sidebar IPC contract",
5
- "version": "1.3.2",
5
+ "version": "1.4.0",
6
6
  "description": "Bidirectional RPC-over-postMessage contract between the Markup AI sidebar and its host. Generated from the @markupai/sidebar-adapter TypeScript types — do not hand-edit."
7
7
  },
8
8
  "channels": {
@@ -1319,12 +1319,18 @@
1319
1319
  },
1320
1320
  "required": ["content", "documentReference"],
1321
1321
  "additionalProperties": false,
1322
- "description": "Content information including the content, document reference, optional document name, and optional mime type The integration must provide content and documentReference - documentName and mimeType are optional\n\n- documentReference: A unique identifier for the document (e.g., URL, file path, or document ID). Required because the API uses it to track a document across scans.\n- documentName: A human-readable name/title for the document (e.g., \"My Report.docx\"). Optional; when absent, the sidebar will attempt to derive it from documentReference if it contains a filename with extension.\n- mimeType: Any valid MIME type string, not limited to MimeType enum values.",
1322
+ "description": "Content information including the content, document reference, optional document name, and optional mime type The integration must provide content and documentReference - documentName and mimeType are optional\n\n- documentReference: A unique identifier for the document, used to track it across scans. Compose it with `buildDocumentReference(prefix, id)`: you pick a prefix naming your platform and supply an id that is stable for the document. The `<prefix>:<id>` format is shared with every other Markup surface, so the same document correlates across products, and the Markup session id's document component is derived from it.\n\n Choose the prefix once and never change it — it is part of the document's identity, and changing it re-keys every document you have checked. Use the same reference for a whole document and for a selection within it. A bare, unprefixed value is still accepted and behaves as before; it simply cannot be correlated with the same document seen elsewhere.\n- documentName: A human-readable name/title for the document (e.g., \"My Report.docx\"). Optional; when absent, the sidebar will attempt to derive it from documentReference if it contains a filename with extension.\n- mimeType: Any valid MIME type string, not limited to MimeType enum values.",
1323
1323
  "title": "ContentInfo"
1324
1324
  },
1325
1325
  "AuthConfigMediation": {
1326
1326
  "type": "object",
1327
- "properties": { "type": { "type": "string", "const": "mediation" } },
1327
+ "properties": {
1328
+ "type": { "type": "string", "const": "mediation" },
1329
+ "provider": {
1330
+ "type": "string",
1331
+ "description": "Explicit Auth0 relay-connection slug for the mediation login flow. Set this when one login provider must serve several `integrationId`s — e.g. a single add-in spanning multiple editors that each report a distinct `integrationId` (for analytics / the `x-integration-id` header / settings storage) but share one Auth0 relay connection. Example: `provider: \"microsoft-365\"` while `integrationId` is `\"markupai-m365-word\"` / `\"markupai-m365-excel\"` / ….\n\nWhen omitted, the sidebar derives the provider from `integrationId` (via its legacy compat map). Only meaningful for `type: \"mediation\"`."
1332
+ }
1333
+ },
1328
1334
  "required": ["type"],
1329
1335
  "additionalProperties": false,
1330
1336
  "description": "How the sidebar should run the Auth0 login flow in a given host.\n\n- `\"mediation\"` — backend-mediated authorization code flow. The sidebar asks the backend to start an OAuth handshake, opens the returned `authorizeUrl` in an external browser (via the host, see {@link PluginInterface.openAuthUrl } if provided, else `globalThis.open(url, \"_blank\", \"noopener,noreferrer\")`), and polls the backend for the code + token exchange. Works in restricted iframe contexts such as Figma and Office task panes.\n- `\"popup\"` — Auth0 SPA client `loginWithPopup`. Requires a secure origin and Web Crypto; breaks in iframes with `null` origin.",
@@ -1353,11 +1359,26 @@
1353
1359
  "SidebarConfig": {
1354
1360
  "type": "object",
1355
1361
  "properties": {
1356
- "integrationName": { "type": "string" },
1357
- "integrationVersion": { "type": "string" },
1358
- "integrationId": { "type": "string" },
1359
- "hideBanner": { "type": "boolean" },
1360
- "dialogClosingScript": { "type": "string" },
1362
+ "integrationName": {
1363
+ "type": "string",
1364
+ "description": "Human-readable name of the underlying integration. **Display only** — shown verbatim to the user (e.g. on the sidebar's About page). Never derive a machine identifier from this string; use {@link SidebarConfig.integrationId } for that. Example: `\"Madcap Flare Desktop\"`."
1365
+ },
1366
+ "integrationVersion": {
1367
+ "type": "string",
1368
+ "description": "Version string of the host integration (the plugin/add-in build, not the sidebar or this adapter). Display only — e.g. shown on the sidebar's About page next to {@link SidebarConfig.integrationName } . Free-form; hosts typically pass their own package/build version such as `\"1.4.2\"`."
1369
+ },
1370
+ "integrationId": {
1371
+ "type": "string",
1372
+ "description": "Stable, machine-readable identifier for the integration. Used for everything non-display: the Auth0 mediation login provider, PostHog analytics keys, the `x-integration-id` API header, and per-integration settings storage. Should be a stable slug (lowercase, hyphenated, no spaces) that does not change between releases. Example: `\"madcap-flare-desktop\"`.\n\nOptional for backward compatibility: when omitted the sidebar falls back to `DEFAULT_SIDEBAR_CONFIG.integrationId` (`\"markupai-sidebar-app\"`). Hosts that use mediation login or want per-integration analytics/storage should set it."
1373
+ },
1374
+ "hideBanner": {
1375
+ "type": "boolean",
1376
+ "description": "Hide the promotional/upsell banner the sidebar shows by default. Set `true` for embedded hosts where the banner is inappropriate (e.g. Figma, Office task pane). Defaults to `false` when omitted."
1377
+ },
1378
+ "dialogClosingScript": {
1379
+ "type": "string",
1380
+ "description": "JavaScript source the sidebar runs inside a host-rendered dialog to close it (see {@link PluginInterface.showDialog } /`closeDialog`). Lets hosts that render dialog chrome themselves supply the exact close call for their environment (e.g. `google.script.host.close();`). Omit when the host closes dialogs through the normal `closeDialog` IPC."
1381
+ },
1361
1382
  "pluginOrigin": {
1362
1383
  "type": "string",
1363
1384
  "description": "Origin of the plugin/editor window where messages should be sent This is the origin where the plugin is listening for messages from the sidebar"
@@ -1370,6 +1391,10 @@
1370
1391
  "type": "boolean",
1371
1392
  "description": "Whether to support selection-based check and rewrite functionality If true or undefined (default), the selection toggle UI will be shown and users can toggle between full content and selection modes If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false"
1372
1393
  },
1394
+ "multiAgent": {
1395
+ "type": "boolean",
1396
+ "description": "Whether the sidebar may run several agents concurrently in one check.\n\nWhen `false` or omitted (the default), only the Style agent is offered and run, and a check is dispatched as a single-agent run. When `true`, the sidebar offers every agent the organization is entitled to and fans the selected ones out through the parallel executor, streaming results per agent; each agent can then be cancelled independently of the others.\n\nThe host flag and the organization's entitlement **intersect**: enabling this never grants access to an agent the organization does not have, and an entitled agent is never offered while this is `false`."
1397
+ },
1373
1398
  "auth": {
1374
1399
  "$ref": "#/components/schemas/AuthConfig",
1375
1400
  "description": "How the sidebar should run the Auth0 login flow. When omitted, the sidebar falls back to heuristic strategy selection (iframe context, secure origin, etc.) for backwards compatibility. New integrations should set this explicitly; `\"mediation\"` is the correct choice for hosts that embed the sidebar in an iframe (Figma, Office task pane).\n\nIn dev builds, the sidebar also honors a `localStorage` override at the key exported as `AUTH_CONFIG_OVERRIDE_STORAGE_KEY` — see `getAuthConfigWithOverride` in `sidebar-host`."
@@ -1549,11 +1574,11 @@
1549
1574
  "additionalProperties": false
1550
1575
  }
1551
1576
  },
1552
- "description": "Show a dialog in the editor"
1577
+ "description": "Show a dialog in the editor.\n\nOptional: not every host embedding the sidebar has dialog support. Hosts without a dialog surface should omit this method (and `closeDialog`). The sidebar gates dialog workflows behind `SidebarConfig.useCheckPreviewDialog`, so a host that omits these should also leave that flag `false`."
1553
1578
  },
1554
1579
  "closeDialog": {
1555
1580
  "$comment": "() => Promise<void>",
1556
- "description": "Close the dialog in the editor"
1581
+ "description": "Close the dialog in the editor.\n\nOptional: see `showDialog`. Omit on hosts without dialog support."
1557
1582
  },
1558
1583
  "replaceMultipleContents": {
1559
1584
  "$comment": "(replacements: ContentReplacement[]) => Promise<void>",
@@ -1665,8 +1690,6 @@
1665
1690
  "getSelectedContent",
1666
1691
  "replaceContent",
1667
1692
  "selectContent",
1668
- "showDialog",
1669
- "closeDialog",
1670
1693
  "replaceMultipleContents",
1671
1694
  "getInitConfig"
1672
1695
  ],
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Canonical `document_ref` composition.
3
+ *
4
+ * A `document_ref` identifies a document across scans and across Markup
5
+ * products. Its value is only useful if **every** surface spells the same
6
+ * document the same way: the backend keys `document_registry` on it, and the
7
+ * Markup session id embeds the high 48 bits of `SHA-256(document_ref)` so a
8
+ * session can be recognised as belonging to a known document.
9
+ *
10
+ * The format is `<prefix>:<id>` — a platform prefix, then an id that is stable
11
+ * and unique within that platform. **The integration supplies both.** It knows
12
+ * what platform it is and which identifier is stable there; the adapter cannot
13
+ * infer either, and hard-coding a list of platforms here would mean an adapter
14
+ * release every time a new one appears — and would still be wrong for hosts
15
+ * whose stable id is not derivable from a URL.
16
+ *
17
+ * ## What an integration is responsible for
18
+ *
19
+ * - **Choose a prefix once and never change it.** The prefix is part of the
20
+ * document's identity. Changing it re-keys every document that integration
21
+ * has ever checked, breaking continuity with its own history. Coordinate a
22
+ * change with the data team; do not ship one quietly.
23
+ * - **Use an id that is stable for the document.** Not the editor URL with its
24
+ * volatile query parameters, not a per-session handle — the thing that still
25
+ * identifies the document tomorrow.
26
+ * - **Use the same reference for the whole document and for a selection.** A
27
+ * selection is a view of one document, not a different document. Varying the
28
+ * reference between them splits one document into two everywhere downstream.
29
+ *
30
+ * Reuse an existing prefix when the platform already has one, so the same
31
+ * document seen from another Markup surface correlates: `gdocs`, `word`,
32
+ * `heretto`, `madcapflare`, `ixiasoft`, or `url` for anything addressed by a
33
+ * plain URL.
34
+ */
35
+ /**
36
+ * Whether a value already looks like a composed reference.
37
+ *
38
+ * A shape test, not a membership test — there is no list of known prefixes to
39
+ * check against, by design.
40
+ */
41
+ export declare function isDocumentReference(value: string): boolean;
42
+ /**
43
+ * Compose a `document_ref` from a platform prefix and a document id.
44
+ *
45
+ * Idempotent: a value already prefixed with `prefix` is returned unchanged, so
46
+ * a host that stores composed references can pass them back through without
47
+ * doubling the prefix.
48
+ *
49
+ * @param prefix Platform identifier the integration owns, e.g. `"word"`. Case
50
+ * and surrounding whitespace are normalized; the value is otherwise yours.
51
+ * @param id Stable, unique id for the document within that platform.
52
+ * @throws If either part is empty, or the prefix is not a lowercase
53
+ * alphanumeric name. Both are programming errors that would otherwise
54
+ * produce a reference silently unusable for correlation.
55
+ */
56
+ export declare function buildDocumentReference(prefix: string, id: string): string;
57
+ //# sourceMappingURL=documentReference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentReference.d.ts","sourceRoot":"","sources":["../../src/document-reference/documentReference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAQH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAI1D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAiBzE"}
@@ -0,0 +1,2 @@
1
+ export { buildDocumentReference, isDocumentReference } from "./documentReference";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/document-reference/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./types";
2
2
  export * from "./errors";
3
+ export * from "./document-reference";
3
4
  export * from "./adapters";
4
5
  export * from "./ipc";
5
6
  export * from "./load-overlay";
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC;AAGzB,cAAc,sBAAsB,CAAC;AAGrC,cAAc,YAAY,CAAC;AAG3B,cAAc,OAAO,CAAC;AAGtB,cAAc,gBAAgB,CAAC;AAG/B,cAAc,gBAAgB,CAAC"}
@@ -1,10 +1,15 @@
1
1
  /**
2
- * Represents a deferred promise that can be resolved or rejected via method
3
- * calls on the instance.
2
+ * A promise whose resolution is deferred: it can be settled via the
3
+ * {@link DeferredPromise.resolve} / {@link DeferredPromise.reject} methods on
4
+ * the instance.
5
+ *
6
+ * It extends the native `Promise`, so instances stay real, awaitable promises
7
+ * (inheriting `then` / `catch` / `finally`) without declaring a thenable
8
+ * `then` method on the class itself.
4
9
  */
5
- export declare class DeferredPromise<T> implements Promise<T> {
6
- private _promise;
7
- readonly [Symbol.toStringTag]: string;
10
+ export declare class DeferredPromise<T> extends Promise<T> {
11
+ /** Chained promises (`then`/`catch`/`finally`) are plain `Promise`s, not deferred ones. */
12
+ static get [Symbol.species](): PromiseConstructor;
8
13
  /**
9
14
  * Resolves the underlying promise with a specified value.
10
15
  *
@@ -19,31 +24,11 @@ export declare class DeferredPromise<T> implements Promise<T> {
19
24
  reject: (reason?: any) => void;
20
25
  /**
21
26
  * 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
27
  *
44
- * @param onFinally - The callback to execute when the promise is settled.
45
- * @returns - A new promise resolved by the onFinally callback.
28
+ * @param executor - Optional executor. Callers building a deferred promise
29
+ * omit it and settle the promise later via {@link resolve} / {@link reject};
30
+ * it exists so native Promise machinery can still supply one when required.
46
31
  */
47
- finally(onFinally?: (() => void) | null): Promise<T>;
32
+ constructor(executor?: (resolve: (value: PromiseLike<T> | T) => void, reject: (reason?: any) => void) => void);
48
33
  }
49
34
  //# sourceMappingURL=deferred-promise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deferred-promise.d.ts","sourceRoot":"","sources":["../../src/ipc/deferred-promise.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,eAAe,CAAC,CAA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