@markupai/sidebar-adapter 1.3.2 → 1.3.3

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
@@ -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 |
@@ -213,13 +210,13 @@ const pluginInterface: PluginInterface = {
213
210
  replaceMultipleContentsInEditor(replacements);
214
211
  },
215
212
 
216
- // Show a dialog
213
+ // Show a dialog (optional — omit on hosts without dialog support)
217
214
  showDialog: async (dialogHtml: string, width?: number, height?: number, title?: string) => {
218
215
  console.log("Show dialog:", title);
219
216
  showDialogInEditor(dialogHtml, width, height, title);
220
217
  },
221
218
 
222
- // Close the dialog
219
+ // Close the dialog (optional — omit on hosts without dialog support)
223
220
  closeDialog: async () => {
224
221
  console.log("Close dialog");
225
222
  closeDialogInEditor();
@@ -237,6 +234,11 @@ const sidebarAdapter = new SidebarAdapter(pluginInterface, iframe);
237
234
  sidebarAdapter.destroy();
238
235
  ```
239
236
 
237
+ > **`integrationName` vs `integrationId`** — two distinct concerns:
238
+ >
239
+ > - **`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.
240
+ > - **`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.
241
+
240
242
  ### SidebarLoadOverlay (Editor UI)
241
243
 
242
244
  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 +341,14 @@ getInitConfig: async () => ({
339
341
  });
340
342
  ```
341
343
 
344
+ For mediation, you may also set **`provider`** — the Auth0 relay-connection slug the sidebar sends to start the OAuth handshake:
345
+
346
+ ```typescript
347
+ auth: { type: "mediation", provider: "microsoft-365" }
348
+ ```
349
+
350
+ 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`.
351
+
342
352
  When **`auth`** is omitted, the sidebar falls back to **legacy heuristic selection** for backwards compatibility.
343
353
 
344
354
  #### openAuthUrl (sandboxed hosts)
@@ -462,14 +472,14 @@ For agentic streaming callbacks, issue objects match the exported **`AgenticIssu
462
472
 
463
473
  Implement these **on the host** as async functions. The sidebar calls them over IPC and waits on the returned promises (pull style):
464
474
 
465
- - `getInitConfig(): Promise<SidebarConfig>` — Integration name, version, feature flags, dialog closing script, etc.
475
+ - `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
476
  - `getContent(): Promise<ContentInfo>` — Full document (or main buffer) text; must include `documentReference`; `mimeType` optional
467
477
  - `getSelectedContent(): Promise<ContentInfo>` — Current selection; same `ContentInfo` rules as `getContent`
468
478
  - `selectContent(range: ContentRange): Promise<void>` — Focus/highlight the document span `[range.start, range.end)`
469
479
  - `replaceContent(suggestion: string, range: ContentRange): Promise<void>` — Apply a single edit to `[range.start, range.end)`
470
480
  - `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
481
+ - `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`).
482
+ - `closeDialog?(): Promise<void>` — Dismiss that dialog. **Optional**, pairs with `showDialog`.
473
483
 
474
484
  Optional (agentic / streaming flows):
475
485
 
@@ -654,7 +664,7 @@ This is **opt-in and additive**. Hosts that omit `integrationSettings` from thei
654
664
  import type { SidebarConfig } from "@markupai/sidebar-adapter";
655
665
 
656
666
  const config: SidebarConfig = {
657
- integrationName: "my-integration",
667
+ integrationName: "My Integration",
658
668
  integrationVersion: "1.0.0",
659
669
  integrationId: "my-integration",
660
670
  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.3.3",
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": {
@@ -1324,7 +1324,13 @@
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"
@@ -1549,11 +1570,11 @@
1549
1570
  "additionalProperties": false
1550
1571
  }
1551
1572
  },
1552
- "description": "Show a dialog in the editor"
1573
+ "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
1574
  },
1554
1575
  "closeDialog": {
1555
1576
  "$comment": "() => Promise<void>",
1556
- "description": "Close the dialog in the editor"
1577
+ "description": "Close the dialog in the editor.\n\nOptional: see `showDialog`. Omit on hosts without dialog support."
1557
1578
  },
1558
1579
  "replaceMultipleContents": {
1559
1580
  "$comment": "(replacements: ContentReplacement[]) => Promise<void>",
@@ -1665,8 +1686,6 @@
1665
1686
  "getSelectedContent",
1666
1687
  "replaceContent",
1667
1688
  "selectContent",
1668
- "showDialog",
1669
- "closeDialog",
1670
1689
  "replaceMultipleContents",
1671
1690
  "getInitConfig"
1672
1691
  ],
@@ -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,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"}
1
+ {"version":3,"file":"deferred-promise.d.ts","sourceRoot":"","sources":["../../src/ipc/deferred-promise.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,qBAAa,eAAe,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IAChD,2FAA2F;IAC3F,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,kBAAkB,CAEhD;IAED;;;;OAIG;IACH,OAAO,EAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IAE9C;;;;OAIG;IACH,MAAM,EAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAEhC;;;;;;OAMG;gBAED,QAAQ,GAAE,CACR,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,KAC3B,IAAmB;CAY3B"}
@@ -1 +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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C,MAAM,EAAE,SAAS,GAAG,IAAI;IAIzC;;OAEG;IACI,OAAO,IAAI,IAAI;CAKvB"}
package/dist/main.js CHANGED
@@ -21,41 +21,42 @@ var ne = /* @__PURE__ */ (function(e) {
21
21
  const r = i;
22
22
  return typeof r.value == "string" && typeof r.label == "string";
23
23
  }) : !1;
24
- }, O = class D extends Error {
24
+ }, T = class O extends Error {
25
25
  name = "TextLookupError";
26
26
  constructor(t) {
27
- super(t), Object.setPrototypeOf(this, D.prototype);
27
+ super(t), Object.setPrototypeOf(this, O.prototype);
28
28
  }
29
29
  };
30
30
  function ce(e) {
31
- return e instanceof O;
31
+ return e instanceof T;
32
32
  }
33
- var P = { TextLookupError: (e) => new O(e) };
34
- function B(e) {
33
+ var P = { TextLookupError: (e) => new T(e) };
34
+ function N(e) {
35
35
  const t = e.message ?? "", i = e.name, r = typeof i == "string" && i in P ? P[i] : void 0;
36
36
  return r ? r(t, e) : Object.assign(new Error(t), i ? { name: i } : {});
37
37
  }
38
- var E = () => {
39
- }, U = class {
40
- _promise;
41
- [Symbol.toStringTag] = "Promise";
42
- resolve = E;
43
- reject = E;
44
- constructor() {
45
- this._promise = new Promise((e, t) => {
46
- this.resolve = e, this.reject = t;
47
- });
48
- }
49
- then(e, t) {
50
- return this._promise.then(e, t);
51
- }
52
- catch(e) {
53
- return this._promise.catch(e);
54
- }
55
- finally(e) {
56
- return this._promise.finally(e);
57
- }
58
- }, H = { timeout: 1e4 }, x = class {
38
+ var B = class extends Promise {
39
+ static get [Symbol.species]() {
40
+ return Promise;
41
+ }
42
+ resolve;
43
+ reject;
44
+ constructor(e = () => {
45
+ }) {
46
+ let t, i;
47
+ super((r, a) => {
48
+ t = r, i = a, e(r, a);
49
+ }), this.resolve = t, this.reject = i;
50
+ }
51
+ }, U = { timeout: 1e4 };
52
+ function H(e) {
53
+ const t = JSON.stringify(e, Object.getOwnPropertyNames(e)), i = JSON.parse(t);
54
+ return i.message === void 0 || i.message === "" ? JSON.stringify({
55
+ message: e instanceof Error ? e.message : String(e),
56
+ name: e instanceof Error ? e.name : void 0
57
+ }) : t;
58
+ }
59
+ var D = class {
59
60
  promisesByID = {};
60
61
  receiversByName = {};
61
62
  currentID = 0;
@@ -63,7 +64,7 @@ var E = () => {
63
64
  postMessage;
64
65
  constructor(e, t) {
65
66
  this.postMessage = e, this.config = {
66
- ...H,
67
+ ...U,
67
68
  ...t
68
69
  };
69
70
  }
@@ -77,7 +78,7 @@ var E = () => {
77
78
  return this.callWithOptions(e, {}, ...t);
78
79
  }
79
80
  callWithOptions(e, t, ...i) {
80
- const r = this.currentID++, a = new U(), n = t.timeout ?? this.config.timeout, o = setTimeout(() => {
81
+ const r = this.currentID++, a = new B(), n = t.timeout ?? this.config.timeout, o = setTimeout(() => {
81
82
  if (r in this.promisesByID) {
82
83
  const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(n)}ms`);
83
84
  a.reject(l), Reflect.deleteProperty(this.promisesByID, r);
@@ -117,43 +118,37 @@ var E = () => {
117
118
  }
118
119
  async handleCall(e) {
119
120
  const { id: t, name: i, data: r } = e;
120
- if (i in this.receiversByName) {
121
- const a = this.receiversByName[i];
122
- try {
123
- if (!Array.isArray(r)) throw new Error(`IPC: Expected array of arguments but got ${typeof r}`);
124
- const n = await a(...r), o = {
125
- type: "response",
126
- id: t,
127
- name: i,
128
- data: n
129
- };
130
- this.postMessage(o);
131
- } catch (n) {
132
- let o = JSON.stringify(n, Object.getOwnPropertyNames(n));
133
- const s = JSON.parse(o);
134
- (s.message === void 0 || s.message === "") && (o = JSON.stringify({
135
- message: n instanceof Error ? n.message : String(n),
136
- name: n instanceof Error ? n.name : void 0
137
- }));
138
- const l = {
139
- type: "error",
140
- id: t,
141
- name: i,
142
- errorJSON: o
143
- };
144
- this.postMessage(l);
145
- }
146
- } else {
147
- const a = /* @__PURE__ */ new Error(`No receiver registered for: ${i}`), n = {
121
+ if (!(i in this.receiversByName)) {
122
+ const n = /* @__PURE__ */ new Error(`No receiver registered for: ${i}`), o = JSON.stringify({
123
+ message: n.message,
124
+ name: n.name
125
+ });
126
+ this.postMessage({
127
+ type: "error",
128
+ id: t,
129
+ name: i,
130
+ errorJSON: o
131
+ });
132
+ return;
133
+ }
134
+ const a = this.receiversByName[i];
135
+ try {
136
+ if (!Array.isArray(r)) throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);
137
+ const n = await a(...r), o = {
138
+ type: "response",
139
+ id: t,
140
+ name: i,
141
+ data: n
142
+ };
143
+ this.postMessage(o);
144
+ } catch (n) {
145
+ const o = {
148
146
  type: "error",
149
147
  id: t,
150
148
  name: i,
151
- errorJSON: JSON.stringify({
152
- message: a.message,
153
- name: a.name
154
- })
149
+ errorJSON: H(n)
155
150
  };
156
- this.postMessage(n);
151
+ this.postMessage(o);
157
152
  }
158
153
  }
159
154
  handleResponse(e) {
@@ -169,7 +164,7 @@ var E = () => {
169
164
  const { promise: r, timeoutId: a } = this.promisesByID[t];
170
165
  clearTimeout(a);
171
166
  try {
172
- const n = B(JSON.parse(i));
167
+ const n = N(JSON.parse(i));
173
168
  r.reject(n);
174
169
  } catch {
175
170
  r.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
@@ -187,7 +182,7 @@ var E = () => {
187
182
  sidebar;
188
183
  targetOrigin;
189
184
  constructor(e, t, i = "*") {
190
- this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new x((r) => {
185
+ this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new D((r) => {
191
186
  window.parent.postMessage(r, this.targetOrigin);
192
187
  }, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
193
188
  }
@@ -364,7 +359,7 @@ var E = () => {
364
359
  window;
365
360
  targetOrigin;
366
361
  constructor(e, t, i, r, a = "*") {
367
- this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin = a, this.ipc = new x((n) => {
362
+ this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin = a, this.ipc = new D((n) => {
368
363
  this.iframe.contentWindow?.postMessage(n, this.targetOrigin);
369
364
  }, r), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
370
365
  }
@@ -378,8 +373,10 @@ var E = () => {
378
373
  }), this.ipc.receive("selectContent", async (e) => {
379
374
  await this.plugin.selectContent(e);
380
375
  }), this.ipc.receive("showDialog", async (e, t, i, r) => {
376
+ if (!this.plugin.showDialog) throw new Error("SidebarIPCAdapter: host does not implement showDialog");
381
377
  await this.plugin.showDialog(e, t, i, r);
382
378
  }), this.ipc.receive("closeDialog", async () => {
379
+ if (!this.plugin.closeDialog) throw new Error("SidebarIPCAdapter: host does not implement closeDialog");
383
380
  await this.plugin.closeDialog();
384
381
  }), this.ipc.receive("replaceMultipleContents", async (e) => {
385
382
  await this.plugin.replaceMultipleContents(e);
@@ -497,7 +494,7 @@ var E = () => {
497
494
  <span>Retry</span>
498
495
  </button>
499
496
  </div>
500
- `, G = () => {
497
+ `, z = () => {
501
498
  const e = document.createElement("div");
502
499
  e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = W;
503
500
  const t = e.querySelector(".sidebar-load-overlay-button");
@@ -506,7 +503,7 @@ var E = () => {
506
503
  overlay: e,
507
504
  button: t
508
505
  };
509
- }, R = "markupai-sidebar-load-overlay-styles", z = `
506
+ }, E = "markupai-sidebar-load-overlay-styles", G = `
510
507
  :root {
511
508
  --background: #f5f5f4;
512
509
  --foreground: #333332;
@@ -600,19 +597,19 @@ var E = () => {
600
597
  }
601
598
  `, J = (e) => {
602
599
  const t = e ?? document;
603
- if (t.getElementById(R)) return;
600
+ if (t.getElementById(E)) return;
604
601
  const i = t.createElement("style");
605
- i.id = R, i.textContent = z, t.head.appendChild(i);
602
+ i.id = E, i.textContent = G, t.head.appendChild(i);
606
603
  }, Y = 8e3, V = 12e3, K = (e, t, i = {}) => {
607
604
  J(e.ownerDocument);
608
- const { sidebarUrl: r, targetOrigin: a, timeoutMs: n = Y, retryIntervalMs: o = V, messageListenWindow: s } = i, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, k = () => {
605
+ const { sidebarUrl: r, targetOrigin: a, timeoutMs: n = Y, retryIntervalMs: o = V, messageListenWindow: s } = i, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, _ = () => {
609
606
  if (a) return a;
610
607
  try {
611
608
  return new URL(p()).origin;
612
609
  } catch {
613
610
  return "*";
614
611
  }
615
- }, { overlay: m, button: v } = G();
612
+ }, { overlay: m, button: I } = z();
616
613
  e.appendChild(m);
617
614
  let u = !1, h, d;
618
615
  const g = (c) => {
@@ -621,14 +618,14 @@ var E = () => {
621
618
  g(!1);
622
619
  const f = () => {
623
620
  h && (globalThis.clearTimeout(h), h = void 0);
624
- }, I = () => {
621
+ }, v = () => {
625
622
  f(), h = globalThis.setTimeout(() => {
626
623
  u || g(!0);
627
624
  }, n);
628
625
  }, A = (c) => {
629
626
  const y = c?.preserveOverlay ?? !0;
630
- u = !1, y || g(!1), t.src = p(), I();
631
- }, N = () => {
627
+ u = !1, y || g(!1), t.src = p(), v();
628
+ }, k = () => {
632
629
  d || o <= 0 || (d = globalThis.setInterval(() => {
633
630
  u || A({ preserveOverlay: !0 });
634
631
  }, o));
@@ -636,15 +633,15 @@ var E = () => {
636
633
  d && (globalThis.clearInterval(d), d = void 0);
637
634
  }, b = (c) => {
638
635
  if (!t.contentWindow || c.source !== t.contentWindow) return;
639
- const y = k();
636
+ const y = _();
640
637
  y !== "*" && c.origin !== y || (u = !0, f(), C(), g(!1));
641
638
  }, w = () => {
642
639
  f(), g(!0);
643
640
  }, S = () => {
644
641
  A();
645
642
  };
646
- return v.addEventListener("click", S), t.addEventListener("error", w), l.addEventListener("message", b), I(), N(), () => {
647
- f(), C(), t.removeEventListener("error", w), l.removeEventListener("message", b), v.removeEventListener("click", S), m.remove();
643
+ return I.addEventListener("click", S), t.addEventListener("error", w), l.addEventListener("message", b), v(), k(), () => {
644
+ f(), C(), t.removeEventListener("error", w), l.removeEventListener("message", b), I.removeEventListener("click", S), m.remove();
648
645
  };
649
646
  }, X = "Markup AI Sidebar", q = "clipboard-read; clipboard-write", ge = "markupai.sidebarNextGen.overrideUrl", pe = "https://sidebar.markup.ai/";
650
647
  function ue(e) {
@@ -713,14 +710,14 @@ function me(e) {
713
710
  }
714
711
  };
715
712
  }
716
- var _ = "sidebarContainer", T = "markupai-sidebar-host-shell-styles";
717
- function M(e) {
713
+ var x = "sidebarContainer", R = "markupai-sidebar-host-shell-styles";
714
+ function L(e) {
718
715
  if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
719
716
  if (!/^[a-zA-Z_][\w-]*$/.test(e)) throw new Error(`sidebar host shell: containerId must match /^[a-zA-Z_][\\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(e)})`);
720
717
  return e;
721
718
  }
722
- function L(e = _) {
723
- const t = M(e);
719
+ function M(e = x) {
720
+ const t = L(e);
724
721
  return `
725
722
  html {
726
723
  height: 100%;
@@ -745,21 +742,21 @@ body {
745
742
  }
746
743
  `.trim();
747
744
  }
748
- var ve = L();
745
+ var Ie = M();
749
746
  function ee(e) {
750
747
  return e instanceof Document ? e : e.ownerDocument;
751
748
  }
752
749
  function te(e, t, i) {
753
- if (!t || e.getElementById(T)) return;
750
+ if (!t || e.getElementById(R)) return;
754
751
  const r = e.createElement("style");
755
- r.id = T, r.textContent = L(i), e.head.appendChild(r);
752
+ r.id = R, r.textContent = M(i), e.head.appendChild(r);
756
753
  }
757
- function Ie(e) {
758
- const { root: t = typeof document < "u" ? document : void 0, containerId: i = _, includeDefaultStyles: r = !0 } = e ?? {};
754
+ function ve(e) {
755
+ const { root: t = typeof document < "u" ? document : void 0, containerId: i = x, includeDefaultStyles: r = !0 } = e ?? {};
759
756
  if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
760
757
  const a = ee(t);
761
758
  te(a, r, i);
762
- const n = t instanceof Document ? a.getElementById(i) : t.querySelector(`#${M(i)}`);
759
+ const n = t instanceof Document ? a.getElementById(i) : t.querySelector(`#${L(i)}`);
763
760
  if (n instanceof HTMLElement && (t instanceof Document || t.contains(n))) return n;
764
761
  if (!(t instanceof Document)) {
765
762
  const s = a.createElement("div");
@@ -793,36 +790,36 @@ function re(e) {
793
790
  }
794
791
  export {
795
792
  Z as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
796
- H as DEFAULT_IPC_CONFIG,
793
+ U as DEFAULT_IPC_CONFIG,
797
794
  oe as DEFAULT_SIDEBAR_CONFIG,
798
- U as DeferredPromise,
799
- x as IPCCore,
795
+ B as DeferredPromise,
796
+ D as IPCCore,
800
797
  ne as MimeType,
801
798
  de as PluginAdapter,
802
799
  j as PluginIPCAdapter,
803
800
  pe as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
804
- _ as SIDEBAR_HOST_CONTAINER_ID,
805
- ve as SIDEBAR_HOST_SHELL_CSS,
801
+ x as SIDEBAR_HOST_CONTAINER_ID,
802
+ Ie as SIDEBAR_HOST_SHELL_CSS,
806
803
  q as SIDEBAR_IFRAME_DEFAULT_ALLOW,
807
804
  X as SIDEBAR_IFRAME_DEFAULT_TITLE,
808
805
  ge as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
809
806
  $ as SidebarAdapter,
810
807
  F as SidebarIPCAdapter,
811
808
  ae as TEXT_MIME_TYPES,
812
- O as TextLookupError,
809
+ T as TextLookupError,
813
810
  ye as assertSidebarHostAdapter,
814
811
  Ae as buildSidebarHostHtmlDocument,
815
- L as buildSidebarHostShellCss,
812
+ M as buildSidebarHostShellCss,
816
813
  ie as buildSidebarPluginHostHeadInnerHtml,
817
814
  me as createSidebarHost,
818
- Ie as ensureSidebarHostShell,
815
+ ve as ensureSidebarHostShell,
819
816
  he as getAuthConfigWithOverride,
820
817
  ue as getSidebarBaseUrlWithOverride,
821
818
  P as ipcErrorReconstructors,
822
819
  le as isIntegrationSettingField,
823
820
  se as isIntegrationSettingsSchema,
824
821
  ce as isTextLookupError,
825
- B as reconstructError,
822
+ N as reconstructError,
826
823
  K as setupSidebarLoadOverlay,
827
824
  fe as sidebarPostMessageTargetOrigin
828
825
  };
package/dist/main.umd.cjs CHANGED
@@ -1,4 +1,4 @@
1
- (function(n,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(n=typeof globalThis<"u"?globalThis:n||self,g(n.main={}))})(this,function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});var g=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),V=["text/plain","text/markdown","text/html","application/dita+xml"],K={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0},X=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),q=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.id!="string"||t.id.length===0||typeof t.label!="string"?!1:t.type==="boolean"?typeof t.default=="boolean":t.type==="enum"?typeof t.default!="string"||!Array.isArray(t.options)||t.options.length===0?!1:t.options.every(i=>{if(typeof i!="object"||i===null)return!1;const r=i;return typeof r.value=="string"&&typeof r.label=="string"}):!1},v=class J extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,J.prototype)}};function Z(e){return e instanceof v}var A={TextLookupError:e=>new v(e)};function E(e){const t=e.message??"",i=e.name,r=typeof i=="string"&&i in A?A[i]:void 0;return r?r(t,e):Object.assign(new Error(t),i?{name:i}:{})}var P=()=>{},T=class{_promise;[Symbol.toStringTag]="Promise";resolve=P;reject=P;constructor(){this._promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}},R={timeout:1e4},C=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...R,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...i){const r=this.currentID++,o=new T,a=t.timeout??this.config.timeout,s=setTimeout(()=>{if(r in this.promisesByID){const c=new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);o.reject(c),Reflect.deleteProperty(this.promisesByID,r)}},a);this.promisesByID[r]={promise:o,timeoutId:s};const l={type:"call",id:r,name:e,data:i};return this.postMessage(l),o}receive(e,t){this.receiversByName[e]=t}ignore(e){delete this.receiversByName[e]}async handleMessage(e){switch(e.type){case"call":await this.handleCall(e);break;case"response":this.handleResponse(e);break;case"error":this.handleError(e);break;default:}}async handleCall(e){const{id:t,name:i,data:r}=e;if(i in this.receiversByName){const o=this.receiversByName[i];try{if(!Array.isArray(r))throw new Error(`IPC: Expected array of arguments but got ${typeof r}`);const a=await o(...r),s={type:"response",id:t,name:i,data:a};this.postMessage(s)}catch(a){let s=JSON.stringify(a,Object.getOwnPropertyNames(a));const l=JSON.parse(s);(l.message===void 0||l.message==="")&&(s=JSON.stringify({message:a instanceof Error?a.message:String(a),name:a instanceof Error?a.name:void 0}));const c={type:"error",id:t,name:i,errorJSON:s};this.postMessage(c)}}else{const o=new Error(`No receiver registered for: ${i}`),a={type:"error",id:t,name:i,errorJSON:JSON.stringify({message:o.message,name:o.name})};this.postMessage(a)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:i,timeoutId:r}=this.promisesByID[t];clearTimeout(r),i.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:i}=e;if(t in this.promisesByID){const{promise:r,timeoutId:o}=this.promisesByID[t];clearTimeout(o);try{const a=E(JSON.parse(i));r.reject(a)}catch{r.reject(new Error("Failed to parse error from IPC"))}Reflect.deleteProperty(this.promisesByID,t)}}destroy(){for(const{promise:e,timeoutId:t}of Object.values(this.promisesByID))clearTimeout(t),e.reject(new Error("IPC destroyed"));this.promisesByID={},this.receiversByName={}}},O=class{ipc;sidebar;targetOrigin;constructor(e,t,i="*"){this.sidebar=e||{},this.targetOrigin=i,this.ipc=new C(r=>{window.parent.postMessage(r,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.sidebar.onPluginStatusChange){const e=this.sidebar.onPluginStatusChange;this.ipc.receive("onPluginStatusChange",async(t,i)=>{await e(t,i)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.invalidateAgenticIssue){const e=this.sidebar.invalidateAgenticIssue;this.ipc.receive("invalidateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.markAgenticIssueResolved){const e=this.sidebar.markAgenticIssueResolved;this.ipc.receive("markAgenticIssueResolved",async t=>{await e(t)})}if(this.sidebar.restoreAgenticIssue){const e=this.sidebar.restoreAgenticIssue;this.ipc.receive("restoreAgenticIssue",async t=>{await e(t)})}if(this.sidebar.applyIntegrationSettings){const e=this.sidebar.applyIntegrationSettings;this.ipc.receive("applyIntegrationSettings",async t=>{await e(t)})}if(this.sidebar.getIntegrationSettings){const e=this.sidebar.getIntegrationSettings;this.ipc.receive("getIntegrationSettings",async()=>await e())}}async getInitConfig(){return await this.ipc.call("getInitConfig")}async getContent(e){return this.ipc.callWithOptions("getContent",e??{})}async getSelectedContent(e){return this.ipc.callWithOptions("getSelectedContent",e??{})}async replaceContent(e,t){await this.ipc.call("replaceContent",e,t)}async selectContent(e){await this.ipc.call("selectContent",e)}async showDialog(e,t,i,r){await this.ipc.call("showDialog",e,t,i,r)}async closeDialog(){await this.ipc.call("closeDialog")}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t){await this.ipc.call("onAgenticAgentResults",e,t)}async onAgenticStreamComplete(){await this.ipc.call("onAgenticStreamComplete")}async onAgenticIssueStatusChanged(e,t,i){await this.ipc.call("onAgenticIssueStatusChanged",e,t,i)}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}async copyToClipboard(e){await this.ipc.call("copyToClipboard",e)}async onIntegrationSettingsChange(e,t){await this.ipc.call("onIntegrationSettingsChange",e,t)}configure(e){this.ipc.configure(e)}setTargetOrigin(e){if(!e||typeof e!="string")throw new Error("Invalid targetOrigin: must be a non-empty string");try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol)||!t.host)throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host")}catch{throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)")}this.targetOrigin=e}getTargetOrigin(){return this.targetOrigin}destroy(){window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},Q=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new O(e,t,i)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(){return await this.ipcAdapter.getInitConfig()}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t){await this.ipcAdapter.replaceContent(e,t)}async selectContent(e){await this.ipcAdapter.selectContent(e)}async showDialog(e,t,i,r){await this.ipcAdapter.showDialog(e,t,i,r)}async closeDialog(){await this.ipcAdapter.closeDialog()}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t){return this.ipcAdapter.onAgenticAgentResults(e,t)}onAgenticStreamComplete(){return this.ipcAdapter.onAgenticStreamComplete()}onAgenticIssueStatusChanged(e,t,i){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,i)}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}copyToClipboard(e){return this.ipcAdapter.copyToClipboard(e)}onIntegrationSettingsChange(e,t){return this.ipcAdapter.onIntegrationSettingsChange(e,t)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},D=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,i,r,o="*"){this.plugin=e,this.iframe=t,this.window=i??window,this.targetOrigin=o,this.ipc=new C(a=>{this.iframe.contentWindow?.postMessage(a,this.targetOrigin)},r),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async()=>await this.plugin.getInitConfig()),this.ipc.receive("getContent",async()=>await this.plugin.getContent()),this.ipc.receive("getSelectedContent",async()=>await this.plugin.getSelectedContent()),this.ipc.receive("replaceContent",async(e,t)=>{await this.plugin.replaceContent(e,t)}),this.ipc.receive("selectContent",async e=>{await this.plugin.selectContent(e)}),this.ipc.receive("showDialog",async(e,t,i,r)=>{await this.plugin.showDialog(e,t,i,r)}),this.ipc.receive("closeDialog",async()=>{await this.plugin.closeDialog()}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t)=>{if(!Array.isArray(t))return;const i=this.plugin.onAgenticAgentResults;i&&await i(e,t)}),this.ipc.receive("onAgenticStreamComplete",async()=>{const e=this.plugin.onAgenticStreamComplete;e&&await e()}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,i)=>{const r=this.plugin.onAgenticIssueStatusChanged;if(r&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||i!=="user"&&i!=="host"))try{await r(e,t,i)}catch{}}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}if(this.plugin.copyToClipboard){const e=this.plugin.copyToClipboard;this.ipc.receive("copyToClipboard",async t=>{await e(t)})}if(this.plugin.onIntegrationSettingsChange){const e=this.plugin.onIntegrationSettingsChange;this.ipc.receive("onIntegrationSettingsChange",async(t,i)=>{await e(t,i)})}}async activateAgenticIssue(e){await this.ipc.call("activateAgenticIssue",e)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async markAgenticIssueResolved(e){await this.ipc.call("markAgenticIssueResolved",e)}async restoreAgenticIssue(e){await this.ipc.call("restoreAgenticIssue",e)}async notifyPluginStatus(e,t){await this.ipc.call("onPluginStatusChange",e,t)}async applyIntegrationSettings(e){await this.ipc.call("applyIntegrationSettings",e)}async getIntegrationSettings(){return await this.ipc.call("getIntegrationSettings")}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},_=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new D(e,t,i?.win,i?.config,i?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e){await this.ipcAdapter.activateAgenticIssue(e)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}async markAgenticIssueResolved(e){await this.ipcAdapter.markAgenticIssueResolved(e)}async restoreAgenticIssue(e){await this.ipcAdapter.restoreAgenticIssue(e)}async applyIntegrationSettings(e){await this.ipcAdapter.applyIntegrationSettings(e)}async getIntegrationSettings(){return await this.ipcAdapter.getIntegrationSettings()}configure(e){this.ipcAdapter.configure(e)}},ee=`
1
+ (function(n,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(n=typeof globalThis<"u"?globalThis:n||self,g(n.main={}))})(this,function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});var g=(function(e){return e.TEXT_PLAIN="text/plain",e.TEXT_MARKDOWN="text/markdown",e.TEXT_HTML="text/html",e.APPLICATION_DITA_XML="application/dita+xml",e})({}),J=["text/plain","text/markdown","text/html","application/dita+xml"],V={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0},K=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),X=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.id!="string"||t.id.length===0||typeof t.label!="string"?!1:t.type==="boolean"?typeof t.default=="boolean":t.type==="enum"?typeof t.default!="string"||!Array.isArray(t.options)||t.options.length===0?!1:t.options.every(i=>{if(typeof i!="object"||i===null)return!1;const r=i;return typeof r.value=="string"&&typeof r.label=="string"}):!1},v=class Y extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,Y.prototype)}};function q(e){return e instanceof v}var A={TextLookupError:e=>new v(e)};function E(e){const t=e.message??"",i=e.name,r=typeof i=="string"&&i in A?A[i]:void 0;return r?r(t,e):Object.assign(new Error(t),i?{name:i}:{})}var P=class extends Promise{static get[Symbol.species](){return Promise}resolve;reject;constructor(e=()=>{}){let t,i;super((r,o)=>{t=r,i=o,e(r,o)}),this.resolve=t,this.reject=i}},T={timeout:1e4};function Z(e){const t=JSON.stringify(e,Object.getOwnPropertyNames(e)),i=JSON.parse(t);return i.message===void 0||i.message===""?JSON.stringify({message:e instanceof Error?e.message:String(e),name:e instanceof Error?e.name:void 0}):t}var C=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...T,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...i){const r=this.currentID++,o=new P,a=t.timeout??this.config.timeout,s=setTimeout(()=>{if(r in this.promisesByID){const c=new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);o.reject(c),Reflect.deleteProperty(this.promisesByID,r)}},a);this.promisesByID[r]={promise:o,timeoutId:s};const l={type:"call",id:r,name:e,data:i};return this.postMessage(l),o}receive(e,t){this.receiversByName[e]=t}ignore(e){delete this.receiversByName[e]}async handleMessage(e){switch(e.type){case"call":await this.handleCall(e);break;case"response":this.handleResponse(e);break;case"error":this.handleError(e);break;default:}}async handleCall(e){const{id:t,name:i,data:r}=e;if(!(i in this.receiversByName)){const a=new Error(`No receiver registered for: ${i}`),s=JSON.stringify({message:a.message,name:a.name});this.postMessage({type:"error",id:t,name:i,errorJSON:s});return}const o=this.receiversByName[i];try{if(!Array.isArray(r))throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);const a=await o(...r),s={type:"response",id:t,name:i,data:a};this.postMessage(s)}catch(a){const s={type:"error",id:t,name:i,errorJSON:Z(a)};this.postMessage(s)}}handleResponse(e){const{id:t}=e;if(t in this.promisesByID){const{promise:i,timeoutId:r}=this.promisesByID[t];clearTimeout(r),i.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:i}=e;if(t in this.promisesByID){const{promise:r,timeoutId:o}=this.promisesByID[t];clearTimeout(o);try{const a=E(JSON.parse(i));r.reject(a)}catch{r.reject(new Error("Failed to parse error from IPC"))}Reflect.deleteProperty(this.promisesByID,t)}}destroy(){for(const{promise:e,timeoutId:t}of Object.values(this.promisesByID))clearTimeout(t),e.reject(new Error("IPC destroyed"));this.promisesByID={},this.receiversByName={}}},R=class{ipc;sidebar;targetOrigin;constructor(e,t,i="*"){this.sidebar=e||{},this.targetOrigin=i,this.ipc=new C(r=>{window.parent.postMessage(r,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.sidebar.onPluginStatusChange){const e=this.sidebar.onPluginStatusChange;this.ipc.receive("onPluginStatusChange",async(t,i)=>{await e(t,i)})}if(this.sidebar.activateAgenticIssue){const e=this.sidebar.activateAgenticIssue;this.ipc.receive("activateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.invalidateAgenticIssue){const e=this.sidebar.invalidateAgenticIssue;this.ipc.receive("invalidateAgenticIssue",async t=>{await e(t)})}if(this.sidebar.markAgenticIssueResolved){const e=this.sidebar.markAgenticIssueResolved;this.ipc.receive("markAgenticIssueResolved",async t=>{await e(t)})}if(this.sidebar.restoreAgenticIssue){const e=this.sidebar.restoreAgenticIssue;this.ipc.receive("restoreAgenticIssue",async t=>{await e(t)})}if(this.sidebar.applyIntegrationSettings){const e=this.sidebar.applyIntegrationSettings;this.ipc.receive("applyIntegrationSettings",async t=>{await e(t)})}if(this.sidebar.getIntegrationSettings){const e=this.sidebar.getIntegrationSettings;this.ipc.receive("getIntegrationSettings",async()=>await e())}}async getInitConfig(){return await this.ipc.call("getInitConfig")}async getContent(e){return this.ipc.callWithOptions("getContent",e??{})}async getSelectedContent(e){return this.ipc.callWithOptions("getSelectedContent",e??{})}async replaceContent(e,t){await this.ipc.call("replaceContent",e,t)}async selectContent(e){await this.ipc.call("selectContent",e)}async showDialog(e,t,i,r){await this.ipc.call("showDialog",e,t,i,r)}async closeDialog(){await this.ipc.call("closeDialog")}async replaceMultipleContents(e){await this.ipc.call("replaceMultipleContents",e)}async onAgenticAgentResults(e,t){await this.ipc.call("onAgenticAgentResults",e,t)}async onAgenticStreamComplete(){await this.ipc.call("onAgenticStreamComplete")}async onAgenticIssueStatusChanged(e,t,i){await this.ipc.call("onAgenticIssueStatusChanged",e,t,i)}async openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}async copyToClipboard(e){await this.ipc.call("copyToClipboard",e)}async onIntegrationSettingsChange(e,t){await this.ipc.call("onIntegrationSettingsChange",e,t)}configure(e){this.ipc.configure(e)}setTargetOrigin(e){if(!e||typeof e!="string")throw new Error("Invalid targetOrigin: must be a non-empty string");try{const t=new URL(e);if(!["http:","https:"].includes(t.protocol)||!t.host)throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host")}catch{throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)")}this.targetOrigin=e}getTargetOrigin(){return this.targetOrigin}destroy(){window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},Q=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new R(e,t,i)}destroy(){this.ipcAdapter.destroy()}async getInitConfig(){return await this.ipcAdapter.getInitConfig()}async getContent(e){return await this.ipcAdapter.getContent(e)}async getSelectedContent(e){return await this.ipcAdapter.getSelectedContent(e)}async replaceContent(e,t){await this.ipcAdapter.replaceContent(e,t)}async selectContent(e){await this.ipcAdapter.selectContent(e)}async showDialog(e,t,i,r){await this.ipcAdapter.showDialog(e,t,i,r)}async closeDialog(){await this.ipcAdapter.closeDialog()}async replaceMultipleContents(e){await this.ipcAdapter.replaceMultipleContents(e)}onAgenticAgentResults(e,t){return this.ipcAdapter.onAgenticAgentResults(e,t)}onAgenticStreamComplete(){return this.ipcAdapter.onAgenticStreamComplete()}onAgenticIssueStatusChanged(e,t,i){return this.ipcAdapter.onAgenticIssueStatusChanged(e,t,i)}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}copyToClipboard(e){return this.ipcAdapter.copyToClipboard(e)}onIntegrationSettingsChange(e,t){return this.ipcAdapter.onIntegrationSettingsChange(e,t)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},O=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,i,r,o="*"){this.plugin=e,this.iframe=t,this.window=i??window,this.targetOrigin=o,this.ipc=new C(a=>{this.iframe.contentWindow?.postMessage(a,this.targetOrigin)},r),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,i=this.targetOrigin;e.origin!==t&&(i!=="*"&&e.origin!==i||e.data&&typeof e.data=="object"&&this.ipc.handleMessage(e.data))};registerReceivers(){if(this.ipc.receive("getInitConfig",async()=>await this.plugin.getInitConfig()),this.ipc.receive("getContent",async()=>await this.plugin.getContent()),this.ipc.receive("getSelectedContent",async()=>await this.plugin.getSelectedContent()),this.ipc.receive("replaceContent",async(e,t)=>{await this.plugin.replaceContent(e,t)}),this.ipc.receive("selectContent",async e=>{await this.plugin.selectContent(e)}),this.ipc.receive("showDialog",async(e,t,i,r)=>{if(!this.plugin.showDialog)throw new Error("SidebarIPCAdapter: host does not implement showDialog");await this.plugin.showDialog(e,t,i,r)}),this.ipc.receive("closeDialog",async()=>{if(!this.plugin.closeDialog)throw new Error("SidebarIPCAdapter: host does not implement closeDialog");await this.plugin.closeDialog()}),this.ipc.receive("replaceMultipleContents",async e=>{await this.plugin.replaceMultipleContents(e)}),this.ipc.receive("onAgenticAgentResults",async(e,t)=>{if(!Array.isArray(t))return;const i=this.plugin.onAgenticAgentResults;i&&await i(e,t)}),this.ipc.receive("onAgenticStreamComplete",async()=>{const e=this.plugin.onAgenticStreamComplete;e&&await e()}),this.ipc.receive("onAgenticIssueStatusChanged",async(e,t,i)=>{const r=this.plugin.onAgenticIssueStatusChanged;if(r&&!(t!=="active"&&t!=="resolved"&&t!=="dismissed"||i!=="user"&&i!=="host"))try{await r(e,t,i)}catch{}}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}if(this.plugin.copyToClipboard){const e=this.plugin.copyToClipboard;this.ipc.receive("copyToClipboard",async t=>{await e(t)})}if(this.plugin.onIntegrationSettingsChange){const e=this.plugin.onIntegrationSettingsChange;this.ipc.receive("onIntegrationSettingsChange",async(t,i)=>{await e(t,i)})}}async activateAgenticIssue(e){await this.ipc.call("activateAgenticIssue",e)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async markAgenticIssueResolved(e){await this.ipc.call("markAgenticIssueResolved",e)}async restoreAgenticIssue(e){await this.ipc.call("restoreAgenticIssue",e)}async notifyPluginStatus(e,t){await this.ipc.call("onPluginStatusChange",e,t)}async applyIntegrationSettings(e){await this.ipc.call("applyIntegrationSettings",e)}async getIntegrationSettings(){return await this.ipc.call("getIntegrationSettings")}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},D=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new O(e,t,i?.win,i?.config,i?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e,t){await this.ipcAdapter.notifyPluginStatus(e,t)}async activateAgenticIssue(e){await this.ipcAdapter.activateAgenticIssue(e)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}async markAgenticIssueResolved(e){await this.ipcAdapter.markAgenticIssueResolved(e)}async restoreAgenticIssue(e){await this.ipcAdapter.restoreAgenticIssue(e)}async applyIntegrationSettings(e){await this.ipcAdapter.applyIntegrationSettings(e)}async getIntegrationSettings(){return await this.ipcAdapter.getIntegrationSettings()}configure(e){this.ipcAdapter.configure(e)}},ee=`
2
2
  <div class="sidebar-load-overlay-card">
3
3
  <div class="sidebar-load-overlay-title">Sidebar failed to load</div>
4
4
  <div class="sidebar-load-overlay-description">Check your connection or try again.</div>
@@ -19,7 +19,7 @@
19
19
  <span>Retry</span>
20
20
  </button>
21
21
  </div>
22
- `,te=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=ee;const t=e.querySelector(".sidebar-load-overlay-button");if(!t)throw new Error("Missing retry button in load overlay template.");return{overlay:e,button:t}},L="markupai-sidebar-load-overlay-styles",ie=`
22
+ `,te=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=ee;const t=e.querySelector(".sidebar-load-overlay-button");if(!t)throw new Error("Missing retry button in load overlay template.");return{overlay:e,button:t}},_="markupai-sidebar-load-overlay-styles",ie=`
23
23
  :root {
24
24
  --background: #f5f5f4;
25
25
  --foreground: #333332;
@@ -111,7 +111,7 @@
111
111
  box-shadow: 0 0 0 2px
112
112
  color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
113
113
  }
114
- `,re=e=>{const t=e??document;if(t.getElementById(L))return;const i=t.createElement("style");i.id=L,i.textContent=ie,t.head.appendChild(i)},ne=8e3,ae=12e3,M=(e,t,i={})=>{re(e.ownerDocument);const{sidebarUrl:r,targetOrigin:o,timeoutMs:a=ne,retryIntervalMs:s=ae,messageListenWindow:l}=i,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>r??t.src,Ae=()=>{if(o)return o;try{return new URL(h()).origin}catch{return"*"}},{overlay:w,button:F}=te();e.appendChild(w);let f=!1,I,p;const u=d=>{w.style.display=d?"flex":"none"};u(!1);const y=()=>{I&&(globalThis.clearTimeout(I),I=void 0)},j=()=>{y(),I=globalThis.setTimeout(()=>{f||u(!0)},a)},$=d=>{const m=d?.preserveOverlay??!0;f=!1,m||u(!1),t.src=h(),j()},Ce=()=>{p||s<=0||(p=globalThis.setInterval(()=>{f||$({preserveOverlay:!0})},s))},G=()=>{p&&(globalThis.clearInterval(p),p=void 0)},W=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const m=Ae();m!=="*"&&d.origin!==m||(f=!0,y(),G(),u(!1))},Y=()=>{y(),u(!0)},z=()=>{$()};return F.addEventListener("click",z),t.addEventListener("error",Y),c.addEventListener("message",W),j(),Ce(),()=>{y(),G(),t.removeEventListener("error",Y),c.removeEventListener("message",W),F.removeEventListener("click",z),w.remove()}},k="Markup AI Sidebar",N="clipboard-read; clipboard-write",oe="markupai.sidebarNextGen.overrideUrl",se="https://sidebar.markup.ai/";function le(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var H="markupai.sidebarNextGen.authOverride";function ce(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const i=globalThis.localStorage.getItem(H)?.trim();if(!i)return e;const r=JSON.parse(i);return r!==null&&typeof r=="object"&&"type"in r&&(r.type==="mediation"||r.type==="popup")?r:e}catch{return e}}function de(e,t){try{return new URL(e).origin}catch(i){return t?.onInvalidUrl?.(e,i),"*"}}function ge(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function pe(e){const{iframe:t,iframeMount:i}=e;if(t!==void 0&&i!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(i===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:r,src:o,allow:a=N}=i,s=document.createElement("iframe");return s.title=k,s.src=o,a&&s.setAttribute("allow",a),r.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function ue(e){const{plugin:t,loadOverlayContainer:i,loadOverlayOptions:r,adapterOptions:o}=e,{iframe:a,removeMountedIframe:s}=pe(e),l=i!==void 0?M(i,a,r??{}):null;if(t!==void 0){const c=new _(t,a,o);return{iframe:a,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:a,adapter:null,destroy:()=>{l?.(),s?.()}}}var b="sidebarContainer",U="markupai-sidebar-host-shell-styles";function B(e){if(typeof CSS<"u"&&typeof CSS.escape=="function")return CSS.escape(e);if(!/^[a-zA-Z_][\w-]*$/.test(e))throw new Error(`sidebar host shell: containerId must match /^[a-zA-Z_][\\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(e)})`);return e}function S(e=b){const t=B(e);return`
114
+ `,re=e=>{const t=e??document;if(t.getElementById(_))return;const i=t.createElement("style");i.id=_,i.textContent=ie,t.head.appendChild(i)},ne=8e3,ae=12e3,L=(e,t,i={})=>{re(e.ownerDocument);const{sidebarUrl:r,targetOrigin:o,timeoutMs:a=ne,retryIntervalMs:s=ae,messageListenWindow:l}=i,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>r??t.src,Ae=()=>{if(o)return o;try{return new URL(h()).origin}catch{return"*"}},{overlay:w,button:x}=te();e.appendChild(w);let f=!1,I,p;const u=d=>{w.style.display=d?"flex":"none"};u(!1);const y=()=>{I&&(globalThis.clearTimeout(I),I=void 0)},F=()=>{y(),I=globalThis.setTimeout(()=>{f||u(!0)},a)},j=d=>{const m=d?.preserveOverlay??!0;f=!1,m||u(!1),t.src=h(),F()},Ce=()=>{p||s<=0||(p=globalThis.setInterval(()=>{f||j({preserveOverlay:!0})},s))},$=()=>{p&&(globalThis.clearInterval(p),p=void 0)},G=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const m=Ae();m!=="*"&&d.origin!==m||(f=!0,y(),$(),u(!1))},W=()=>{y(),u(!0)},z=()=>{j()};return x.addEventListener("click",z),t.addEventListener("error",W),c.addEventListener("message",G),F(),Ce(),()=>{y(),$(),t.removeEventListener("error",W),c.removeEventListener("message",G),x.removeEventListener("click",z),w.remove()}},M="Markup AI Sidebar",k="clipboard-read; clipboard-write",oe="markupai.sidebarNextGen.overrideUrl",se="https://sidebar.markup.ai/";function le(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var N="markupai.sidebarNextGen.authOverride";function ce(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const i=globalThis.localStorage.getItem(N)?.trim();if(!i)return e;const r=JSON.parse(i);return r!==null&&typeof r=="object"&&"type"in r&&(r.type==="mediation"||r.type==="popup")?r:e}catch{return e}}function de(e,t){try{return new URL(e).origin}catch(i){return t?.onInvalidUrl?.(e,i),"*"}}function ge(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function pe(e){const{iframe:t,iframeMount:i}=e;if(t!==void 0&&i!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(i===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:r,src:o,allow:a=k}=i,s=document.createElement("iframe");return s.title=M,s.src=o,a&&s.setAttribute("allow",a),r.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function ue(e){const{plugin:t,loadOverlayContainer:i,loadOverlayOptions:r,adapterOptions:o}=e,{iframe:a,removeMountedIframe:s}=pe(e),l=i!==void 0?L(i,a,r??{}):null;if(t!==void 0){const c=new D(t,a,o);return{iframe:a,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:a,adapter:null,destroy:()=>{l?.(),s?.()}}}var b="sidebarContainer",H="markupai-sidebar-host-shell-styles";function U(e){if(typeof CSS<"u"&&typeof CSS.escape=="function")return CSS.escape(e);if(!/^[a-zA-Z_][\w-]*$/.test(e))throw new Error(`sidebar host shell: containerId must match /^[a-zA-Z_][\\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(e)})`);return e}function S(e=b){const t=U(e);return`
115
115
  html {
116
116
  height: 100%;
117
117
  }
@@ -133,7 +133,7 @@ body {
133
133
  margin: 0;
134
134
  display: block;
135
135
  }
136
- `.trim()}var he=S();function fe(e){return e instanceof Document?e:e.ownerDocument}function Ie(e,t,i){if(!t||e.getElementById(U))return;const r=e.createElement("style");r.id=U,r.textContent=S(i),e.head.appendChild(r)}function ye(e){const{root:t=typeof document<"u"?document:void 0,containerId:i=b,includeDefaultStyles:r=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const o=fe(t);Ie(o,r,i);const a=t instanceof Document?o.getElementById(i):t.querySelector(`#${B(i)}`);if(a instanceof HTMLElement&&(t instanceof Document||t.contains(a)))return a;if(!(t instanceof Document)){const l=o.createElement("div");return l.id=i,t.appendChild(l),l}const s=o.createElement("div");return s.id=i,o.body.appendChild(s),s}function x(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function me(e){const{title:t="Markup AI Sidebar",headInnerHtml:i="",includePluginHostHead:r=!1,bodyScriptsHtml:o,htmlLang:a="en",htmlAttrs:s=`lang="${a}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[r?x():"",i].filter(h=>h.trim().length>0).join(`
136
+ `.trim()}var he=S();function fe(e){return e instanceof Document?e:e.ownerDocument}function Ie(e,t,i){if(!t||e.getElementById(H))return;const r=e.createElement("style");r.id=H,r.textContent=S(i),e.head.appendChild(r)}function ye(e){const{root:t=typeof document<"u"?document:void 0,containerId:i=b,includeDefaultStyles:r=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const o=fe(t);Ie(o,r,i);const a=t instanceof Document?o.getElementById(i):t.querySelector(`#${U(i)}`);if(a instanceof HTMLElement&&(t instanceof Document||t.contains(a)))return a;if(!(t instanceof Document)){const l=o.createElement("div");return l.id=i,t.appendChild(l),l}const s=o.createElement("div");return s.id=i,o.body.appendChild(s),s}function B(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function me(e){const{title:t="Markup AI Sidebar",headInnerHtml:i="",includePluginHostHead:r=!1,bodyScriptsHtml:o,htmlLang:a="en",htmlAttrs:s=`lang="${a}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[r?B():"",i].filter(h=>h.trim().length>0).join(`
137
137
  `);return`<!DOCTYPE html>
138
138
  <html ${s}>
139
139
  <head>
@@ -146,4 +146,4 @@ ${c}`:""}
146
146
  ${o}
147
147
  </body>
148
148
  </html>
149
- `}function ve(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}n.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=H,n.DEFAULT_IPC_CONFIG=R,n.DEFAULT_SIDEBAR_CONFIG=K,n.DeferredPromise=T,n.IPCCore=C,n.MimeType=g,n.PluginAdapter=Q,n.PluginIPCAdapter=O,n.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=se,n.SIDEBAR_HOST_CONTAINER_ID=b,n.SIDEBAR_HOST_SHELL_CSS=he,n.SIDEBAR_IFRAME_DEFAULT_ALLOW=N,n.SIDEBAR_IFRAME_DEFAULT_TITLE=k,n.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=oe,n.SidebarAdapter=_,n.SidebarIPCAdapter=D,n.TEXT_MIME_TYPES=V,n.TextLookupError=v,n.assertSidebarHostAdapter=ge,n.buildSidebarHostHtmlDocument=me,n.buildSidebarHostShellCss=S,n.buildSidebarPluginHostHeadInnerHtml=x,n.createSidebarHost=ue,n.ensureSidebarHostShell=ye,n.getAuthConfigWithOverride=ce,n.getSidebarBaseUrlWithOverride=le,n.ipcErrorReconstructors=A,n.isIntegrationSettingField=q,n.isIntegrationSettingsSchema=X,n.isTextLookupError=Z,n.reconstructError=E,n.setupSidebarLoadOverlay=M,n.sidebarPostMessageTargetOrigin=de});
149
+ `}function ve(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}n.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=N,n.DEFAULT_IPC_CONFIG=T,n.DEFAULT_SIDEBAR_CONFIG=V,n.DeferredPromise=P,n.IPCCore=C,n.MimeType=g,n.PluginAdapter=Q,n.PluginIPCAdapter=R,n.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=se,n.SIDEBAR_HOST_CONTAINER_ID=b,n.SIDEBAR_HOST_SHELL_CSS=he,n.SIDEBAR_IFRAME_DEFAULT_ALLOW=k,n.SIDEBAR_IFRAME_DEFAULT_TITLE=M,n.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=oe,n.SidebarAdapter=D,n.SidebarIPCAdapter=O,n.TEXT_MIME_TYPES=J,n.TextLookupError=v,n.assertSidebarHostAdapter=ge,n.buildSidebarHostHtmlDocument=me,n.buildSidebarHostShellCss=S,n.buildSidebarPluginHostHeadInnerHtml=B,n.createSidebarHost=ue,n.ensureSidebarHostShell=ye,n.getAuthConfigWithOverride=ce,n.getSidebarBaseUrlWithOverride=le,n.ipcErrorReconstructors=A,n.isIntegrationSettingField=X,n.isIntegrationSettingsSchema=K,n.isTextLookupError=q,n.reconstructError=E,n.setupSidebarLoadOverlay=L,n.sidebarPostMessageTargetOrigin=de});
@@ -65,6 +65,18 @@ export interface ContentInfo {
65
65
  */
66
66
  export type AuthConfigMediation = {
67
67
  type: "mediation";
68
+ /**
69
+ * Explicit Auth0 relay-connection slug for the mediation login flow. Set this
70
+ * when one login provider must serve several `integrationId`s — e.g. a single
71
+ * add-in spanning multiple editors that each report a distinct `integrationId`
72
+ * (for analytics / the `x-integration-id` header / settings storage) but share
73
+ * one Auth0 relay connection. Example: `provider: "microsoft-365"` while
74
+ * `integrationId` is `"markupai-m365-word"` / `"markupai-m365-excel"` / ….
75
+ *
76
+ * When omitted, the sidebar derives the provider from `integrationId` (via its
77
+ * legacy compat map). Only meaningful for `type: "mediation"`.
78
+ */
79
+ provider?: string;
68
80
  };
69
81
  export type AuthConfigPopup = {
70
82
  type: "popup";
@@ -83,10 +95,45 @@ export type PluginStatusType = "error" | "warning" | "info";
83
95
  * Configuration for the sidebar
84
96
  */
85
97
  export interface SidebarConfig {
98
+ /**
99
+ * Human-readable name of the underlying integration. **Display only** — shown
100
+ * verbatim to the user (e.g. on the sidebar's About page). Never derive a
101
+ * machine identifier from this string; use {@link SidebarConfig.integrationId}
102
+ * for that. Example: `"Madcap Flare Desktop"`.
103
+ */
86
104
  integrationName: string;
105
+ /**
106
+ * Version string of the host integration (the plugin/add-in build, not the
107
+ * sidebar or this adapter). Display only — e.g. shown on the sidebar's About
108
+ * page next to {@link SidebarConfig.integrationName}. Free-form; hosts typically
109
+ * pass their own package/build version such as `"1.4.2"`.
110
+ */
87
111
  integrationVersion: string;
112
+ /**
113
+ * Stable, machine-readable identifier for the integration. Used for everything
114
+ * non-display: the Auth0 mediation login provider, PostHog analytics keys, the
115
+ * `x-integration-id` API header, and per-integration settings storage. Should be
116
+ * a stable slug (lowercase, hyphenated, no spaces) that does not change between
117
+ * releases. Example: `"madcap-flare-desktop"`.
118
+ *
119
+ * Optional for backward compatibility: when omitted the sidebar falls back to
120
+ * `DEFAULT_SIDEBAR_CONFIG.integrationId` (`"markupai-sidebar-app"`). Hosts that
121
+ * use mediation login or want per-integration analytics/storage should set it.
122
+ */
88
123
  integrationId?: string;
124
+ /**
125
+ * Hide the promotional/upsell banner the sidebar shows by default. Set `true`
126
+ * for embedded hosts where the banner is inappropriate (e.g. Figma, Office task
127
+ * pane). Defaults to `false` when omitted.
128
+ */
89
129
  hideBanner?: boolean;
130
+ /**
131
+ * JavaScript source the sidebar runs inside a host-rendered dialog to close it
132
+ * (see {@link PluginInterface.showDialog}/`closeDialog`). Lets hosts that render
133
+ * dialog chrome themselves supply the exact close call for their environment
134
+ * (e.g. `google.script.host.close();`). Omit when the host closes dialogs
135
+ * through the normal `closeDialog` IPC.
136
+ */
90
137
  dialogClosingScript?: string;
91
138
  /**
92
139
  * Origin of the plugin/editor window where messages should be sent
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvE;;;;GAIG;AACH,oBAAY,QAAQ;IAClB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,oBAAoB,yBAAyB;CAC9C;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,2GAKlB,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,mBAAmB,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AAQ,EAAE,oBAAoB,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yGAAyG;IACzG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
@@ -33,19 +33,28 @@ export interface PluginInterface {
33
33
  */
34
34
  selectContent: (range: ContentRange) => Promise<void>;
35
35
  /**
36
- * Show a dialog in the editor
36
+ * Show a dialog in the editor.
37
+ *
38
+ * Optional: not every host embedding the sidebar has dialog support. Hosts
39
+ * without a dialog surface should omit this method (and `closeDialog`). The
40
+ * sidebar gates dialog workflows behind `SidebarConfig.useCheckPreviewDialog`,
41
+ * so a host that omits these should also leave that flag `false`.
42
+ *
37
43
  * @param dialogHtml - The HTML content of the dialog
38
44
  * @param width - Optional dialog width
39
45
  * @param height - Optional dialog height
40
46
  * @param title - Optional dialog title
41
47
  * @returns Promise that resolves when dialog is shown
42
48
  */
43
- showDialog: (dialogHtml: string, width?: number, height?: number, title?: string) => Promise<void>;
49
+ showDialog?: (dialogHtml: string, width?: number, height?: number, title?: string) => Promise<void>;
44
50
  /**
45
- * Close the dialog in the editor
51
+ * Close the dialog in the editor.
52
+ *
53
+ * Optional: see `showDialog`. Omit on hosts without dialog support.
54
+ *
46
55
  * @returns Promise that resolves when dialog is closed
47
56
  */
48
- closeDialog: () => Promise<void>;
57
+ closeDialog?: () => Promise<void>;
49
58
  /**
50
59
  * Replace multiple contents in the editor
51
60
  * @param replacements - Array of content replacements to apply
@@ -1 +1 @@
1
- {"version":3,"file":"pluginInterface.d.ts","sourceRoot":"","sources":["../../src/types/pluginInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,uB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CAAC;IAEnB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;;;OAIG;IACH,uBAAuB,EAAE,CAAC,YAAY,EAAE,kBAAkB,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/E;;;;OAIG;IACH,aAAa,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IAE5C;;;OAGG;IACH,qBAAqB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5F;;OAEG;IACH,uBAAuB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;;;;;;;;;;OAWG;IACH,2BAA2B,CAAC,EAAE,CAC5B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,EAC3C,MAAM,EAAE,MAAM,GAAG,MAAM,KACpB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7C;;;;;;;;;;;;;;;;OAgBG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD;;;;;;;;;;;OAWG;IACH,2BAA2B,CAAC,EAAE,CAC5B,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE,6BAA6B,KAChC,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markupai/sidebar-adapter",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Adapter package for MarkupAI Sidebar integration",
5
5
  "keywords": [
6
6
  "markupai",