@markupai/sidebar-adapter 1.0.0 → 1.1.1
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 +68 -2
- package/dist/adapters/pluginAdapter.d.ts +6 -0
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/ipc/call-signatures.d.ts +5 -0
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/plugin-ipc-adapter.d.ts +6 -0
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/main.js +120 -94
- package/dist/main.umd.cjs +6 -6
- package/dist/sidebar-host/createSidebarHost.d.ts +23 -0
- package/dist/sidebar-host/createSidebarHost.d.ts.map +1 -1
- package/dist/sidebar-host/index.d.ts +1 -1
- package/dist/sidebar-host/index.d.ts.map +1 -1
- package/dist/types/common.d.ts +40 -3
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +23 -4
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -14,8 +14,9 @@ You do **not** need prior knowledge of how the sidebar is built internally. As a
|
|
|
14
14
|
6. [SidebarAdapter](#sidebaradapter-editor--sidebar) (host page → serves the sidebar)
|
|
15
15
|
7. [Host shell & HTML helpers](#sidebar-host-shell-shared-htmldom)
|
|
16
16
|
8. [createSidebarHost](#createsidebarhost) (iframe + overlay + adapter in one step)
|
|
17
|
-
9. [
|
|
18
|
-
10. [
|
|
17
|
+
9. [Authentication](#authentication-optional) (declaring an Auth0 login strategy)
|
|
18
|
+
10. [Sidebar load overlay (standalone)](#sidebarloadoverlay-editor-ui)
|
|
19
|
+
11. [API reference](#api-reference) · [Development](#development)
|
|
19
20
|
|
|
20
21
|
## Features
|
|
21
22
|
|
|
@@ -26,6 +27,7 @@ You do **not** need prior knowledge of how the sidebar is built internally. As a
|
|
|
26
27
|
- **Host shell helpers** — `ensureSidebarHostShell` / `buildSidebarHostHtmlDocument` so you don’t duplicate container markup and layout CSS
|
|
27
28
|
- **MIME helpers** — `MimeType` enum plus arbitrary MIME strings for `ContentInfo`
|
|
28
29
|
- **Errors** — `TextLookupError` and guards for editor lookup failures
|
|
30
|
+
- **Auth** — `SidebarConfig.auth` for declaring the Auth0 login strategy (`"mediation" | "popup"`) and optional `PluginInterface.openAuthUrl` for routing the authorize URL through a host-owned external-browser primitive (see [Authentication](#authentication-optional))
|
|
29
31
|
- **Cleanup** — `destroy()` / teardown functions on adapters and hosts
|
|
30
32
|
|
|
31
33
|
## Host integration checklist
|
|
@@ -185,6 +187,10 @@ const pluginInterface: PluginInterface = {
|
|
|
185
187
|
useCheckPreviewDialog: true,
|
|
186
188
|
supportCheckSelection: true,
|
|
187
189
|
pluginOrigin: globalThis.location.origin,
|
|
190
|
+
// Optional. Declare the Auth0 login strategy the sidebar should run.
|
|
191
|
+
// Omit to let the sidebar pick heuristically (legacy behavior).
|
|
192
|
+
// See the "Authentication" section below.
|
|
193
|
+
auth: { type: "mediation" },
|
|
188
194
|
};
|
|
189
195
|
},
|
|
190
196
|
|
|
@@ -273,6 +279,7 @@ Creates the sidebar iframe (or uses yours), optionally mounts the **load overlay
|
|
|
273
279
|
- **`SIDEBAR_URL_OVERRIDE_STORAGE_KEY`** — `localStorage` key for the override; use **`getSidebarBaseUrlWithOverride(defaultUrl)`** to resolve the base URL (reads override when set, otherwise `defaultUrl`; safe when `localStorage` is missing or throws).
|
|
274
280
|
- **`sidebarPostMessageTargetOrigin(sidebarUrl, options?)`** — derives **`adapterOptions.targetOrigin`** from the sidebar URL (falls back to `"*"`; optional **`onInvalidUrl`** callback).
|
|
275
281
|
- **`assertSidebarHostAdapter(host, message?)`** — type-narrows **`host`** after **`createSidebarHost`** when you passed **`plugin`** (throws if **`adapter`** is **`null`**).
|
|
282
|
+
- **`AUTH_CONFIG_OVERRIDE_STORAGE_KEY`** — `localStorage` key for forcing an `AuthConfig` at runtime (dev/test only); used together with **`getAuthConfigWithOverride(hostConfig, allowOverride)`** which honors the override only when `allowOverride` is `true`. See [Authentication](#authentication-optional).
|
|
276
283
|
|
|
277
284
|
```typescript
|
|
278
285
|
import {
|
|
@@ -309,6 +316,61 @@ host.destroy();
|
|
|
309
316
|
- **`loadOverlayOptions`:** forwarded to **`setupSidebarLoadOverlay`**. Use **`messageListenWindow`** when the iframe parent is not the host **`window`** (e.g. sidebar iframe inside a popup; plugin / **`SidebarAdapter`** may use **`adapterOptions.win`** for the same window).
|
|
310
317
|
- **Split-context integration:** omit **`plugin`**, set **`loadOverlayContainer`** + **`iframeMount`** (or **`iframe`**), then forward **`postMessage`** traffic between `host.iframe` and the context where your `PluginInterface` runs (see [Architecture options](#architecture-options)).
|
|
311
318
|
|
|
319
|
+
### Authentication (optional)
|
|
320
|
+
|
|
321
|
+
The sidebar runs an Auth0 login flow when the user signs in. You can tell it **which** strategy to use from the host via **`SidebarConfig.auth`**, and — for sandboxed hosts where `globalThis.open` is blocked — route the Auth0 `authorizeUrl` through your own external-browser primitive via the optional **`PluginInterface.openAuthUrl`** hook.
|
|
322
|
+
|
|
323
|
+
#### AuthConfig
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
type AuthConfig = { type: "mediation" } | { type: "popup" };
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
- **`"mediation"`** — backend-mediated authorization code flow. The sidebar asks the backend to start an OAuth handshake, opens the returned `authorizeUrl` in an external browser, and polls the backend for the code + token exchange. Required for hosts embedded in iframes with restricted origins (Figma plugin UI, Office task pane).
|
|
330
|
+
- **`"popup"`** — Auth0 SPA `loginWithPopup`. Requires a secure origin and Web Crypto.
|
|
331
|
+
|
|
332
|
+
Declare it in your **`PluginInterface.getInitConfig`** return value:
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
getInitConfig: async () => ({
|
|
336
|
+
// ...other fields...
|
|
337
|
+
auth: { type: "mediation" },
|
|
338
|
+
});
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
When **`auth`** is omitted, the sidebar falls back to **legacy heuristic selection** for backwards compatibility.
|
|
342
|
+
|
|
343
|
+
#### openAuthUrl (sandboxed hosts)
|
|
344
|
+
|
|
345
|
+
Mediation needs to open the Auth0 `authorizeUrl` in an external browser. By default the sidebar uses `globalThis.open(url, "_blank", "noopener,noreferrer")`. In hosts where that's blocked — notably M365 / Office task panes — implement the optional **`openAuthUrl`** method on **`PluginInterface`**:
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
import type { PluginInterface } from "@markupai/sidebar-adapter";
|
|
349
|
+
|
|
350
|
+
const plugin: PluginInterface = {
|
|
351
|
+
// ...other methods...
|
|
352
|
+
openAuthUrl: async (url) => {
|
|
353
|
+
// In an Office add-in:
|
|
354
|
+
Office.context.ui.openBrowserWindow(url);
|
|
355
|
+
// If the host cannot open the URL, throw so the sidebar fails the
|
|
356
|
+
// mediation login fast (instead of polling to a 120 s timeout).
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
When the plugin does not implement **`openAuthUrl`**, the sidebar detects the absence via the standard **`"No receiver registered for: openAuthUrl"`** IPC error and falls back to its own `globalThis.open`. Any **other** error thrown by your handler (e.g. popup blocked) is re-raised to the user unchanged.
|
|
362
|
+
|
|
363
|
+
#### Dev/test override
|
|
364
|
+
|
|
365
|
+
In dev builds you can force an `AuthConfig` without changing host code by writing a JSON string to `localStorage` under the key exported as **`AUTH_CONFIG_OVERRIDE_STORAGE_KEY`**. The sidebar applies the override only when the consumer passes **`allowOverride: true`** to **`getAuthConfigWithOverride(hostConfig, allowOverride)`** — for example, gated on **`import.meta.env.DEV`**:
|
|
366
|
+
|
|
367
|
+
```js
|
|
368
|
+
// Force mediation in a local dev tab:
|
|
369
|
+
localStorage.setItem("markupai.sidebarNextGen.authOverride", '{"type":"mediation"}');
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Invalid JSON or unknown `type` values are logged and ignored; the host's declared `auth` is used instead.
|
|
373
|
+
|
|
312
374
|
### Sidebar host shell (shared HTML/DOM)
|
|
313
375
|
|
|
314
376
|
Avoid copying the same **`#sidebarContainer`** + full-height layout CSS into every host HTML file.
|
|
@@ -413,6 +475,10 @@ Optional (agentic / streaming flows):
|
|
|
413
475
|
- `onAgenticAgentResults?(agentName: string, issues: AgenticIssuePayload[]): Promise<void>` — Per-agent results as they stream
|
|
414
476
|
- `onAgenticStreamComplete?(): Promise<void>` — Stream finished (success or terminal state)
|
|
415
477
|
|
|
478
|
+
Optional (authentication):
|
|
479
|
+
|
|
480
|
+
- `openAuthUrl?(url: string): Promise<void>` — Open the Auth0 `authorizeUrl` in whatever external-browser primitive the host provides. Implement this in sandboxed hosts where `globalThis.open` is blocked or unavailable (e.g. Office task panes should call `Office.context.ui.openBrowserWindow(url)`). Throw if the window cannot be opened so the mediation flow fails fast instead of polling to timeout. When omitted, the sidebar falls back to `globalThis.open(url, "_blank", "noopener,noreferrer")`.
|
|
481
|
+
|
|
416
482
|
#### Error control flows
|
|
417
483
|
|
|
418
484
|
When implementing `selectContent` or `replaceContent`, throw `TextLookupError` from this package when text lookup (e.g. locating the selection or target range) fails. The sidebar will treat it as a selection failure and can invalidate the issue card with the error message.
|
|
@@ -57,6 +57,12 @@ export declare class PluginAdapter {
|
|
|
57
57
|
* Notify plugin that the agentic stream has finished.
|
|
58
58
|
*/
|
|
59
59
|
onAgenticStreamComplete(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Ask the host plugin to open an external URL during an auth flow.
|
|
62
|
+
* The returned promise rejects if the host has not implemented the handler;
|
|
63
|
+
* callers should then fall back to `globalThis.open`.
|
|
64
|
+
*/
|
|
65
|
+
openAuthUrl(url: string): Promise<void>;
|
|
60
66
|
/**
|
|
61
67
|
* Update IPC configuration
|
|
62
68
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginAdapter.d.ts","sourceRoot":"","sources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ClB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAKhB;;OAEG;IACU,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAKzC;;OAEG;IACU,uBAAuB,CAAC,YAAY,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvF;;OAEG;IACI,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7F;;OAEG;IACI,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/C;;;;OAIG;IACI,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIzC;;OAEG;IACI,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAIlD;;OAEG;IACI,eAAe,IAAI,MAAM;CAGjC"}
|
|
@@ -47,6 +47,11 @@ export interface CallSignatures {
|
|
|
47
47
|
* Notify plugin when the agentic stream has finished.
|
|
48
48
|
*/
|
|
49
49
|
onAgenticStreamComplete(): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Ask the plugin to open an external URL during an auth flow.
|
|
52
|
+
* See {@link PluginInterface.openAuthUrl}.
|
|
53
|
+
*/
|
|
54
|
+
openAuthUrl(url: string): Promise<void>;
|
|
50
55
|
/**
|
|
51
56
|
* Notify sidebar of plugin status changes
|
|
52
57
|
* Optional method - demonstrates Plugin → Sidebar communication pattern
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-signatures.d.ts","sourceRoot":"","sources":["../../src/ipc/call-signatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAA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
|
@@ -57,6 +57,12 @@ export declare class PluginIPCAdapter {
|
|
|
57
57
|
* Notify plugin that the agentic stream has finished.
|
|
58
58
|
*/
|
|
59
59
|
onAgenticStreamComplete(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Ask the plugin to open an external URL during an auth flow.
|
|
62
|
+
* Throws if the plugin has not registered a handler, so callers can fall
|
|
63
|
+
* back (e.g. to `globalThis.open`).
|
|
64
|
+
*/
|
|
65
|
+
openAuthUrl(url: string): Promise<void>;
|
|
60
66
|
/**
|
|
61
67
|
* Update IPC configuration
|
|
62
68
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-ipc-adapter.d.ts","sourceRoot":"","sources":["../../src/ipc/plugin-ipc-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAc,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAAO,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,YAAY,GAAE,MAAY;IAkBtF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAqB5B;IAEF,OAAO,CAAC,iBAAiB;IAiCzB;;OAEG;IACU,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC;IAKpD;;;OAGG;IACU,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAKpE;;;OAGG;IACU,kBAAkB,CAAC,OAA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AAO,CAAC,IAAI,CAAC;IAIrD;;;;OAIG;IACU,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpD;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIzC;;OAEG;IACI,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAkBlD;;OAEG;IACI,eAAe,IAAI,MAAM;IAIhC;;OAEG;IACI,OAAO,IAAI,IAAI;CAKvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-ipc-adapter.d.ts","sourceRoot":"","sources":["../../src/ipc/sidebar-ipc-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,qBAAqB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAGpC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,iBAAiB,EACzB,GAAG,CAAC,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,SAAS,EAClB,YAAY,GAAE,MAAY;IAqB5B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAqB5B;IAEF,OAAO,CAAC,iBAAiB;
|
|
1
|
+
{"version":3,"file":"sidebar-ipc-adapter.d.ts","sourceRoot":"","sources":["../../src/ipc/sidebar-ipc-adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,qBAAqB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAU;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAGpC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,iBAAiB,EACzB,GAAG,CAAC,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,SAAS,EAClB,YAAY,GAAE,MAAY;IAqB5B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAqB5B;IAEF,OAAO,CAAC,iBAAiB;IAmFzB;;OAEG;IACU,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjE;;OAEG;IACU,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnE;;;OAGG;IACU,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9D;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAIzC;;OAEG;IACI,OAAO,IAAI,IAAI;CAKvB"}
|
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var v = /* @__PURE__ */ (function(e) {
|
|
2
2
|
return e.TEXT_PLAIN = "text/plain", e.TEXT_MARKDOWN = "text/markdown", e.TEXT_HTML = "text/html", e.APPLICATION_DITA_XML = "application/dita+xml", e;
|
|
3
|
-
})({}),
|
|
3
|
+
})({}), oe = [
|
|
4
4
|
v.TEXT_PLAIN,
|
|
5
5
|
v.TEXT_MARKDOWN,
|
|
6
6
|
v.TEXT_HTML,
|
|
7
7
|
v.APPLICATION_DITA_XML
|
|
8
|
-
],
|
|
8
|
+
], ae = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
@@ -13,26 +13,26 @@ var v = /* @__PURE__ */ (function(e) {
|
|
|
13
13
|
dialogClosingScript: void 0,
|
|
14
14
|
useCheckPreviewDialog: !1,
|
|
15
15
|
supportCheckSelection: !0
|
|
16
|
-
},
|
|
16
|
+
}, D = class _ extends Error {
|
|
17
17
|
name = "TextLookupError";
|
|
18
18
|
constructor(t) {
|
|
19
|
-
super(t), Object.setPrototypeOf(this,
|
|
19
|
+
super(t), Object.setPrototypeOf(this, _.prototype);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
function
|
|
23
|
-
return e instanceof
|
|
22
|
+
function se(e) {
|
|
23
|
+
return e instanceof D;
|
|
24
24
|
}
|
|
25
|
-
var
|
|
25
|
+
var P = { TextLookupError: (e) => new D(e) };
|
|
26
26
|
function H(e) {
|
|
27
|
-
const t = e.message ?? "", r = e.name, i = typeof r == "string" && r in
|
|
27
|
+
const t = e.message ?? "", r = e.name, i = typeof r == "string" && r in P ? P[r] : void 0;
|
|
28
28
|
return i ? i(t, e) : Object.assign(new Error(t), r ? { name: r } : {});
|
|
29
29
|
}
|
|
30
|
-
var
|
|
30
|
+
var O = () => {
|
|
31
31
|
}, U = class {
|
|
32
32
|
_promise;
|
|
33
33
|
[Symbol.toStringTag] = "Promise";
|
|
34
|
-
resolve =
|
|
35
|
-
reject =
|
|
34
|
+
resolve = O;
|
|
35
|
+
reject = O;
|
|
36
36
|
constructor() {
|
|
37
37
|
this._promise = new Promise((e, t) => {
|
|
38
38
|
this.resolve = e, this.reject = t;
|
|
@@ -47,7 +47,7 @@ var T = () => {
|
|
|
47
47
|
finally(e) {
|
|
48
48
|
return this._promise.finally(e);
|
|
49
49
|
}
|
|
50
|
-
}, j = { timeout: 1e4 },
|
|
50
|
+
}, j = { timeout: 1e4 }, L = class {
|
|
51
51
|
promisesByID = {};
|
|
52
52
|
receiversByName = {};
|
|
53
53
|
currentID = 0;
|
|
@@ -174,12 +174,12 @@ var T = () => {
|
|
|
174
174
|
clearTimeout(t), e.reject(/* @__PURE__ */ new Error("IPC destroyed"));
|
|
175
175
|
this.promisesByID = {}, this.receiversByName = {};
|
|
176
176
|
}
|
|
177
|
-
},
|
|
177
|
+
}, F = class {
|
|
178
178
|
ipc;
|
|
179
179
|
sidebar;
|
|
180
180
|
targetOrigin;
|
|
181
181
|
constructor(e, t, r = "*") {
|
|
182
|
-
this.sidebar = e || {}, this.targetOrigin = r, this.ipc = new
|
|
182
|
+
this.sidebar = e || {}, this.targetOrigin = r, this.ipc = new L((i) => {
|
|
183
183
|
window.parent.postMessage(i, this.targetOrigin);
|
|
184
184
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
185
185
|
}
|
|
@@ -237,6 +237,9 @@ var T = () => {
|
|
|
237
237
|
async onAgenticStreamComplete() {
|
|
238
238
|
await this.ipc.call("onAgenticStreamComplete");
|
|
239
239
|
}
|
|
240
|
+
async openAuthUrl(e) {
|
|
241
|
+
await this.ipc.call("openAuthUrl", e);
|
|
242
|
+
}
|
|
240
243
|
configure(e) {
|
|
241
244
|
this.ipc.configure(e);
|
|
242
245
|
}
|
|
@@ -256,10 +259,10 @@ var T = () => {
|
|
|
256
259
|
destroy() {
|
|
257
260
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
258
261
|
}
|
|
259
|
-
},
|
|
262
|
+
}, le = class {
|
|
260
263
|
ipcAdapter;
|
|
261
264
|
constructor(e, t, r) {
|
|
262
|
-
this.ipcAdapter = new
|
|
265
|
+
this.ipcAdapter = new F(e, t, r);
|
|
263
266
|
}
|
|
264
267
|
destroy() {
|
|
265
268
|
this.ipcAdapter.destroy();
|
|
@@ -294,6 +297,9 @@ var T = () => {
|
|
|
294
297
|
onAgenticStreamComplete() {
|
|
295
298
|
return this.ipcAdapter.onAgenticStreamComplete();
|
|
296
299
|
}
|
|
300
|
+
openAuthUrl(e) {
|
|
301
|
+
return this.ipcAdapter.openAuthUrl(e);
|
|
302
|
+
}
|
|
297
303
|
configure(e) {
|
|
298
304
|
this.ipcAdapter.configure(e);
|
|
299
305
|
}
|
|
@@ -303,14 +309,14 @@ var T = () => {
|
|
|
303
309
|
getTargetOrigin() {
|
|
304
310
|
return this.ipcAdapter.getTargetOrigin();
|
|
305
311
|
}
|
|
306
|
-
},
|
|
312
|
+
}, $ = class {
|
|
307
313
|
ipc;
|
|
308
314
|
plugin;
|
|
309
315
|
iframe;
|
|
310
316
|
window;
|
|
311
317
|
targetOrigin;
|
|
312
318
|
constructor(e, t, r, i, o = "*") {
|
|
313
|
-
this.plugin = e, this.iframe = t, this.window = r ?? window, this.targetOrigin = o, this.ipc = new
|
|
319
|
+
this.plugin = e, this.iframe = t, this.window = r ?? window, this.targetOrigin = o, this.ipc = new L((n) => {
|
|
314
320
|
this.iframe.contentWindow?.postMessage(n, this.targetOrigin);
|
|
315
321
|
}, i), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
316
322
|
}
|
|
@@ -319,7 +325,7 @@ var T = () => {
|
|
|
319
325
|
e.origin !== t && (r !== "*" && e.origin !== r || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
320
326
|
};
|
|
321
327
|
registerReceivers() {
|
|
322
|
-
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) => {
|
|
328
|
+
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) => {
|
|
323
329
|
await this.plugin.replaceContent(e, t);
|
|
324
330
|
}), this.ipc.receive("selectContent", async (e) => {
|
|
325
331
|
await this.plugin.selectContent(e);
|
|
@@ -337,7 +343,12 @@ var T = () => {
|
|
|
337
343
|
}), this.ipc.receive("onAgenticStreamComplete", async () => {
|
|
338
344
|
const e = this.plugin.onAgenticStreamComplete;
|
|
339
345
|
e && await e();
|
|
340
|
-
})
|
|
346
|
+
}), this.plugin.openAuthUrl) {
|
|
347
|
+
const e = this.plugin.openAuthUrl;
|
|
348
|
+
this.ipc.receive("openAuthUrl", async (t) => {
|
|
349
|
+
await e(t);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
341
352
|
}
|
|
342
353
|
async activateAgenticIssue(e) {
|
|
343
354
|
await this.ipc.call("activateAgenticIssue", e);
|
|
@@ -357,7 +368,7 @@ var T = () => {
|
|
|
357
368
|
}, W = class {
|
|
358
369
|
ipcAdapter;
|
|
359
370
|
constructor(e, t, r) {
|
|
360
|
-
this.ipcAdapter = new
|
|
371
|
+
this.ipcAdapter = new $(e, t, r?.win, r?.config, r?.targetOrigin);
|
|
361
372
|
}
|
|
362
373
|
destroy() {
|
|
363
374
|
this.ipcAdapter.destroy();
|
|
@@ -374,7 +385,7 @@ var T = () => {
|
|
|
374
385
|
configure(e) {
|
|
375
386
|
this.ipcAdapter.configure(e);
|
|
376
387
|
}
|
|
377
|
-
},
|
|
388
|
+
}, G = `
|
|
378
389
|
<div class="sidebar-load-overlay-card">
|
|
379
390
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
380
391
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -395,16 +406,16 @@ var T = () => {
|
|
|
395
406
|
<span>Retry</span>
|
|
396
407
|
</button>
|
|
397
408
|
</div>
|
|
398
|
-
`,
|
|
409
|
+
`, z = () => {
|
|
399
410
|
const e = document.createElement("div");
|
|
400
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
411
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = G;
|
|
401
412
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
402
413
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
403
414
|
return {
|
|
404
415
|
overlay: e,
|
|
405
416
|
button: t
|
|
406
417
|
};
|
|
407
|
-
},
|
|
418
|
+
}, T = "markupai-sidebar-load-overlay-styles", J = `
|
|
408
419
|
:root {
|
|
409
420
|
--background: #f5f5f4;
|
|
410
421
|
--foreground: #333332;
|
|
@@ -496,21 +507,21 @@ var T = () => {
|
|
|
496
507
|
box-shadow: 0 0 0 2px
|
|
497
508
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
498
509
|
}
|
|
499
|
-
`,
|
|
510
|
+
`, X = (e) => {
|
|
500
511
|
const t = e ?? document;
|
|
501
|
-
if (t.getElementById(
|
|
512
|
+
if (t.getElementById(T)) return;
|
|
502
513
|
const r = t.createElement("style");
|
|
503
|
-
r.id =
|
|
504
|
-
},
|
|
505
|
-
|
|
506
|
-
const { sidebarUrl: i, targetOrigin: o, timeoutMs: n =
|
|
514
|
+
r.id = T, r.textContent = J, t.head.appendChild(r);
|
|
515
|
+
}, Y = 8e3, V = 12e3, K = (e, t, r = {}) => {
|
|
516
|
+
X(e.ownerDocument);
|
|
517
|
+
const { sidebarUrl: i, targetOrigin: o, timeoutMs: n = Y, retryIntervalMs: a = V, messageListenWindow: s } = r, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => i ?? t.src, k = () => {
|
|
507
518
|
if (o) return o;
|
|
508
519
|
try {
|
|
509
520
|
return new URL(p()).origin;
|
|
510
521
|
} catch {
|
|
511
522
|
return "*";
|
|
512
523
|
}
|
|
513
|
-
}, { overlay: y, button: I } =
|
|
524
|
+
}, { overlay: y, button: I } = z();
|
|
514
525
|
e.appendChild(y);
|
|
515
526
|
let u = !1, h, d;
|
|
516
527
|
const g = (c) => {
|
|
@@ -519,50 +530,63 @@ var T = () => {
|
|
|
519
530
|
g(!1);
|
|
520
531
|
const m = () => {
|
|
521
532
|
h && (globalThis.clearTimeout(h), h = void 0);
|
|
522
|
-
},
|
|
533
|
+
}, A = () => {
|
|
523
534
|
m(), h = globalThis.setTimeout(() => {
|
|
524
535
|
u || g(!0);
|
|
525
536
|
}, n);
|
|
526
|
-
},
|
|
537
|
+
}, C = (c) => {
|
|
527
538
|
const f = c?.preserveOverlay ?? !0;
|
|
528
|
-
u = !1, f || g(!1), t.src = p(),
|
|
539
|
+
u = !1, f || g(!1), t.src = p(), A();
|
|
529
540
|
}, B = () => {
|
|
530
541
|
d || a <= 0 || (d = globalThis.setInterval(() => {
|
|
531
|
-
u ||
|
|
542
|
+
u || C({ preserveOverlay: !0 });
|
|
532
543
|
}, a));
|
|
533
|
-
},
|
|
544
|
+
}, b = () => {
|
|
534
545
|
d && (globalThis.clearInterval(d), d = void 0);
|
|
535
546
|
}, w = (c) => {
|
|
536
547
|
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
537
|
-
const f =
|
|
538
|
-
f !== "*" && c.origin !== f || (u = !0, m(),
|
|
548
|
+
const f = k();
|
|
549
|
+
f !== "*" && c.origin !== f || (u = !0, m(), b(), g(!1));
|
|
539
550
|
}, S = () => {
|
|
540
551
|
m(), g(!0);
|
|
541
|
-
},
|
|
542
|
-
|
|
552
|
+
}, E = () => {
|
|
553
|
+
C();
|
|
543
554
|
};
|
|
544
|
-
return I.addEventListener("click",
|
|
545
|
-
m(),
|
|
555
|
+
return I.addEventListener("click", E), t.addEventListener("error", S), l.addEventListener("message", w), A(), B(), () => {
|
|
556
|
+
m(), b(), t.removeEventListener("error", S), l.removeEventListener("message", w), I.removeEventListener("click", E), y.remove();
|
|
546
557
|
};
|
|
547
|
-
},
|
|
548
|
-
function
|
|
558
|
+
}, q = "Markup AI Sidebar", Z = "clipboard-read; clipboard-write", ce = "markupai.sidebarNextGen.overrideUrl", de = "https://sidebar.markup.ai/";
|
|
559
|
+
function ge(e) {
|
|
560
|
+
try {
|
|
561
|
+
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
562
|
+
} catch {
|
|
563
|
+
return e;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
var Q = "markupai.sidebarNextGen.authOverride";
|
|
567
|
+
function pe(e, t) {
|
|
568
|
+
if (!t) return e;
|
|
549
569
|
try {
|
|
550
|
-
|
|
570
|
+
if (!("localStorage" in globalThis)) return e;
|
|
571
|
+
const r = globalThis.localStorage.getItem(Q)?.trim();
|
|
572
|
+
if (!r) return e;
|
|
573
|
+
const i = JSON.parse(r);
|
|
574
|
+
return i !== null && typeof i == "object" && "type" in i && (i.type === "mediation" || i.type === "popup") ? i : e;
|
|
551
575
|
} catch {
|
|
552
576
|
return e;
|
|
553
577
|
}
|
|
554
578
|
}
|
|
555
|
-
function
|
|
579
|
+
function ue(e, t) {
|
|
556
580
|
try {
|
|
557
581
|
return new URL(e).origin;
|
|
558
582
|
} catch (r) {
|
|
559
583
|
return t?.onInvalidUrl?.(e, r), "*";
|
|
560
584
|
}
|
|
561
585
|
}
|
|
562
|
-
function
|
|
586
|
+
function he(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
563
587
|
if (e.adapter === null) throw new Error(t);
|
|
564
588
|
}
|
|
565
|
-
function
|
|
589
|
+
function ee(e) {
|
|
566
590
|
const { iframe: t, iframeMount: r } = e;
|
|
567
591
|
if (t !== void 0 && r !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
568
592
|
if (t !== void 0) return {
|
|
@@ -571,15 +595,15 @@ function Q(e) {
|
|
|
571
595
|
};
|
|
572
596
|
if (r === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
573
597
|
const { container: i, src: o, allow: n = Z } = r, a = document.createElement("iframe");
|
|
574
|
-
return a.title =
|
|
598
|
+
return a.title = q, a.src = o, n && a.setAttribute("allow", n), i.appendChild(a), {
|
|
575
599
|
iframe: a,
|
|
576
600
|
removeMountedIframe: () => {
|
|
577
601
|
a.remove();
|
|
578
602
|
}
|
|
579
603
|
};
|
|
580
604
|
}
|
|
581
|
-
function
|
|
582
|
-
const { plugin: t, loadOverlayContainer: r, loadOverlayOptions: i, adapterOptions: o } = e, { iframe: n, removeMountedIframe: a } =
|
|
605
|
+
function me(e) {
|
|
606
|
+
const { plugin: t, loadOverlayContainer: r, loadOverlayOptions: i, adapterOptions: o } = e, { iframe: n, removeMountedIframe: a } = ee(e), s = r !== void 0 ? K(r, n, i ?? {}) : null;
|
|
583
607
|
if (t !== void 0) {
|
|
584
608
|
const l = new W(t, n, o);
|
|
585
609
|
return {
|
|
@@ -598,14 +622,14 @@ function ue(e) {
|
|
|
598
622
|
}
|
|
599
623
|
};
|
|
600
624
|
}
|
|
601
|
-
var
|
|
602
|
-
function
|
|
625
|
+
var M = "sidebarContainer", R = "markupai-sidebar-host-shell-styles";
|
|
626
|
+
function x(e) {
|
|
603
627
|
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
604
628
|
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)})`);
|
|
605
629
|
return e;
|
|
606
630
|
}
|
|
607
|
-
function
|
|
608
|
-
const t =
|
|
631
|
+
function N(e = M) {
|
|
632
|
+
const t = x(e);
|
|
609
633
|
return `
|
|
610
634
|
html {
|
|
611
635
|
height: 100%;
|
|
@@ -630,21 +654,21 @@ body {
|
|
|
630
654
|
}
|
|
631
655
|
`.trim();
|
|
632
656
|
}
|
|
633
|
-
var
|
|
634
|
-
function
|
|
657
|
+
var fe = N();
|
|
658
|
+
function te(e) {
|
|
635
659
|
return e instanceof Document ? e : e.ownerDocument;
|
|
636
660
|
}
|
|
637
|
-
function
|
|
638
|
-
if (!t || e.getElementById(
|
|
661
|
+
function re(e, t, r) {
|
|
662
|
+
if (!t || e.getElementById(R)) return;
|
|
639
663
|
const i = e.createElement("style");
|
|
640
|
-
i.id =
|
|
664
|
+
i.id = R, i.textContent = N(r), e.head.appendChild(i);
|
|
641
665
|
}
|
|
642
|
-
function
|
|
643
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId: r =
|
|
666
|
+
function ve(e) {
|
|
667
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: r = M, includeDefaultStyles: i = !0 } = e ?? {};
|
|
644
668
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
645
|
-
const o =
|
|
646
|
-
|
|
647
|
-
const n = t instanceof Document ? o.getElementById(r) : t.querySelector(`#${
|
|
669
|
+
const o = te(t);
|
|
670
|
+
re(o, i, r);
|
|
671
|
+
const n = t instanceof Document ? o.getElementById(r) : t.querySelector(`#${x(r)}`);
|
|
648
672
|
if (n instanceof HTMLElement && (t instanceof Document || t.contains(n))) return n;
|
|
649
673
|
if (!(t instanceof Document)) {
|
|
650
674
|
const s = o.createElement("div");
|
|
@@ -653,18 +677,18 @@ function me(e) {
|
|
|
653
677
|
const a = o.createElement("div");
|
|
654
678
|
return a.id = r, o.body.appendChild(a), a;
|
|
655
679
|
}
|
|
656
|
-
function
|
|
680
|
+
function ie() {
|
|
657
681
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
658
682
|
}
|
|
659
|
-
function
|
|
660
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml: r = "", includePluginHostHead: i = !1, bodyScriptsHtml: o, htmlLang: n = "en", htmlAttrs: a = `lang="${n}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [i ?
|
|
683
|
+
function ye(e) {
|
|
684
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: r = "", includePluginHostHead: i = !1, bodyScriptsHtml: o, htmlLang: n = "en", htmlAttrs: a = `lang="${n}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [i ? ie() : "", r].filter((p) => p.trim().length > 0).join(`
|
|
661
685
|
`);
|
|
662
686
|
return `<!DOCTYPE html>
|
|
663
687
|
<html ${a}>
|
|
664
688
|
<head>
|
|
665
689
|
<base target="_top" />
|
|
666
690
|
<meta charset="UTF-8" />
|
|
667
|
-
<title>${
|
|
691
|
+
<title>${ne(t)}</title>${l ? `
|
|
668
692
|
${l}` : ""}
|
|
669
693
|
</head>
|
|
670
694
|
<body ${s}>
|
|
@@ -673,37 +697,39 @@ ${l}` : ""}
|
|
|
673
697
|
</html>
|
|
674
698
|
`;
|
|
675
699
|
}
|
|
676
|
-
function
|
|
700
|
+
function ne(e) {
|
|
677
701
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
678
702
|
}
|
|
679
703
|
export {
|
|
704
|
+
Q as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
680
705
|
j as DEFAULT_IPC_CONFIG,
|
|
681
|
-
|
|
706
|
+
ae as DEFAULT_SIDEBAR_CONFIG,
|
|
682
707
|
U as DeferredPromise,
|
|
683
|
-
|
|
708
|
+
L as IPCCore,
|
|
684
709
|
v as MimeType,
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
710
|
+
le as PluginAdapter,
|
|
711
|
+
F as PluginIPCAdapter,
|
|
712
|
+
de as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
713
|
+
M as SIDEBAR_HOST_CONTAINER_ID,
|
|
714
|
+
fe as SIDEBAR_HOST_SHELL_CSS,
|
|
690
715
|
Z as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
691
|
-
|
|
692
|
-
|
|
716
|
+
q as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
717
|
+
ce as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
693
718
|
W as SidebarAdapter,
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
719
|
+
$ as SidebarIPCAdapter,
|
|
720
|
+
oe as TEXT_MIME_TYPES,
|
|
721
|
+
D as TextLookupError,
|
|
722
|
+
he as assertSidebarHostAdapter,
|
|
723
|
+
ye as buildSidebarHostHtmlDocument,
|
|
724
|
+
N as buildSidebarHostShellCss,
|
|
725
|
+
ie as buildSidebarPluginHostHeadInnerHtml,
|
|
726
|
+
me as createSidebarHost,
|
|
727
|
+
ve as ensureSidebarHostShell,
|
|
728
|
+
pe as getAuthConfigWithOverride,
|
|
729
|
+
ge as getSidebarBaseUrlWithOverride,
|
|
730
|
+
P as ipcErrorReconstructors,
|
|
731
|
+
se as isTextLookupError,
|
|
706
732
|
H as reconstructError,
|
|
707
|
-
|
|
708
|
-
|
|
733
|
+
K as setupSidebarLoadOverlay,
|
|
734
|
+
ue as sidebarPostMessageTargetOrigin
|
|
709
735
|
};
|
package/dist/main.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(n,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(n=typeof globalThis<"u"?globalThis:n||self,d(n.main={}))})(this,function(n){Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});var d=(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})({}),X=[d.TEXT_PLAIN,d.TEXT_MARKDOWN,d.TEXT_HTML,d.APPLICATION_DITA_XML],V={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0},A=class J extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,J.prototype)}};function K(e){return e instanceof A}var I={TextLookupError:e=>new A(e)};function E(e){const t=e.message??"",r=e.name,i=typeof r=="string"&&r in I?I[r]:void 0;return i?i(t,e):Object.assign(new Error(t),r?{name:r}:{})}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)}},O={timeout:1e4},C=class{promisesByID={};receiversByName={};currentID=0;config;postMessage;constructor(e,t){this.postMessage=e,this.config={...O,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...r){const i=this.currentID++,o=new T,a=t.timeout??this.config.timeout,s=setTimeout(()=>{if(i 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,i)}},a);this.promisesByID[i]={promise:o,timeoutId:s};const l={type:"call",id:i,name:e,data:r};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:r,data:i}=e;if(r in this.receiversByName){const o=this.receiversByName[r];try{if(!Array.isArray(i))throw new Error(`IPC: Expected array of arguments but got ${typeof i}`);const a=await o(...i),s={type:"response",id:t,name:r,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:r,errorJSON:s};this.postMessage(c)}}else{const o=new Error(`No receiver registered for: ${r}`),a={type:"error",id:t,name:r,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:r,timeoutId:i}=this.promisesByID[t];clearTimeout(i),r.resolve(e.data),Reflect.deleteProperty(this.promisesByID,t)}}handleError(e){const{id:t,errorJSON:r}=e;if(t in this.promisesByID){const{promise:i,timeoutId:o}=this.promisesByID[t];clearTimeout(o);try{const a=E(JSON.parse(r));i.reject(a)}catch{i.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,r="*"){this.sidebar=e||{},this.targetOrigin=r,this.ipc=new C(i=>{window.parent.postMessage(i,this.targetOrigin)},t),window.addEventListener("message",this.handleMessage),this.registerReceivers()}handleMessage=e=>{const t=globalThis.window.location.origin,r=this.targetOrigin;e.origin!==t&&(r!=="*"&&e.origin!==r||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=>{await e(t)})}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)})}}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,r,i){await this.ipc.call("showDialog",e,t,r,i)}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 openAuthUrl(e){await this.ipc.call("openAuthUrl",e)}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,r){this.ipcAdapter=new R(e,t,r)}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,r,i){await this.ipcAdapter.showDialog(e,t,r,i)}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()}openAuthUrl(e){return this.ipcAdapter.openAuthUrl(e)}configure(e){this.ipcAdapter.configure(e)}setTargetOrigin(e){this.ipcAdapter.setTargetOrigin(e)}getTargetOrigin(){return this.ipcAdapter.getTargetOrigin()}},_=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,r,i,o="*"){this.plugin=e,this.iframe=t,this.window=r??window,this.targetOrigin=o,this.ipc=new C(a=>{this.iframe.contentWindow?.postMessage(a,this.targetOrigin)},i),this.window.addEventListener("message",this.handleMessage,!1),this.registerReceivers()}handleMessage=e=>{const t=this.window.location.origin,r=this.targetOrigin;e.origin!==t&&(r!=="*"&&e.origin!==r||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,r,i)=>{await this.plugin.showDialog(e,t,r,i)}),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 r=this.plugin.onAgenticAgentResults;r&&await r(e,t)}),this.ipc.receive("onAgenticStreamComplete",async()=>{const e=this.plugin.onAgenticStreamComplete;e&&await e()}),this.plugin.openAuthUrl){const e=this.plugin.openAuthUrl;this.ipc.receive("openAuthUrl",async t=>{await e(t)})}}async activateAgenticIssue(e){await this.ipc.call("activateAgenticIssue",e)}async invalidateAgenticIssue(e){await this.ipc.call("invalidateAgenticIssue",e)}async notifyPluginStatus(e){await this.ipc.call("onPluginStatusChange",e)}configure(e){this.ipc.configure(e)}destroy(){this.window.removeEventListener("message",this.handleMessage),this.ipc.destroy()}},D=class{ipcAdapter;constructor(e,t,r){this.ipcAdapter=new _(e,t,r?.win,r?.config,r?.targetOrigin)}destroy(){this.ipcAdapter.destroy()}async notifyPluginStatus(e){await this.ipcAdapter.notifyPluginStatus(e)}async activateAgenticIssue(e){await this.ipcAdapter.activateAgenticIssue(e)}async invalidateAgenticIssue(e){await this.ipcAdapter.invalidateAgenticIssue(e)}configure(e){this.ipcAdapter.configure(e)}},Z=`
|
|
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
|
-
`,
|
|
22
|
+
`,Q=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=Z;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",ee=`
|
|
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
|
-
`,
|
|
114
|
+
`,te=e=>{const t=e??document;if(t.getElementById(L))return;const r=t.createElement("style");r.id=L,r.textContent=ee,t.head.appendChild(r)},re=8e3,ie=12e3,M=(e,t,r={})=>{te(e.ownerDocument);const{sidebarUrl:i,targetOrigin:o,timeoutMs:a=re,retryIntervalMs:s=ie,messageListenWindow:l}=r,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>i??t.src,ye=()=>{if(o)return o;try{return new URL(h()).origin}catch{return"*"}},{overlay:w,button:F}=Q();e.appendChild(w);let m=!1,f,p;const u=g=>{w.style.display=g?"flex":"none"};u(!1);const v=()=>{f&&(globalThis.clearTimeout(f),f=void 0)},j=()=>{v(),f=globalThis.setTimeout(()=>{m||u(!0)},a)},$=g=>{const y=g?.preserveOverlay??!0;m=!1,y||u(!1),t.src=h(),j()},Ae=()=>{p||s<=0||(p=globalThis.setInterval(()=>{m||$({preserveOverlay:!0})},s))},W=()=>{p&&(globalThis.clearInterval(p),p=void 0)},G=g=>{if(!t.contentWindow||g.source!==t.contentWindow)return;const y=ye();y!=="*"&&g.origin!==y||(m=!0,v(),W(),u(!1))},Y=()=>{v(),u(!0)},z=()=>{$()};return F.addEventListener("click",z),t.addEventListener("error",Y),c.addEventListener("message",G),j(),Ae(),()=>{v(),W(),t.removeEventListener("error",Y),c.removeEventListener("message",G),F.removeEventListener("click",z),w.remove()}},N="Markup AI Sidebar",H="clipboard-read; clipboard-write",ne="markupai.sidebarNextGen.overrideUrl",ae="https://sidebar.markup.ai/";function oe(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var k="markupai.sidebarNextGen.authOverride";function se(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const r=globalThis.localStorage.getItem(k)?.trim();if(!r)return e;const i=JSON.parse(r);return i!==null&&typeof i=="object"&&"type"in i&&(i.type==="mediation"||i.type==="popup")?i:e}catch{return e}}function le(e,t){try{return new URL(e).origin}catch(r){return t?.onInvalidUrl?.(e,r),"*"}}function ce(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function de(e){const{iframe:t,iframeMount:r}=e;if(t!==void 0&&r!==void 0)throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");if(t!==void 0)return{iframe:t,removeMountedIframe:null};if(r===void 0)throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");const{container:i,src:o,allow:a=H}=r,s=document.createElement("iframe");return s.title=N,s.src=o,a&&s.setAttribute("allow",a),i.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function ge(e){const{plugin:t,loadOverlayContainer:r,loadOverlayOptions:i,adapterOptions:o}=e,{iframe:a,removeMountedIframe:s}=de(e),l=r!==void 0?M(r,a,i??{}):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",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`
|
|
115
115
|
html {
|
|
116
116
|
height: 100%;
|
|
117
117
|
}
|
|
@@ -133,17 +133,17 @@ body {
|
|
|
133
133
|
margin: 0;
|
|
134
134
|
display: block;
|
|
135
135
|
}
|
|
136
|
-
`.trim()}var
|
|
136
|
+
`.trim()}var pe=S();function ue(e){return e instanceof Document?e:e.ownerDocument}function he(e,t,r){if(!t||e.getElementById(U))return;const i=e.createElement("style");i.id=U,i.textContent=S(r),e.head.appendChild(i)}function me(e){const{root:t=typeof document<"u"?document:void 0,containerId:r=b,includeDefaultStyles:i=!0}=e??{};if(t===void 0)throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");const o=ue(t);he(o,i,r);const a=t instanceof Document?o.getElementById(r):t.querySelector(`#${B(r)}`);if(a instanceof HTMLElement&&(t instanceof Document||t.contains(a)))return a;if(!(t instanceof Document)){const l=o.createElement("div");return l.id=r,t.appendChild(l),l}const s=o.createElement("div");return s.id=r,o.body.appendChild(s),s}function x(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function fe(e){const{title:t="Markup AI Sidebar",headInnerHtml:r="",includePluginHostHead:i=!1,bodyScriptsHtml:o,htmlLang:a="en",htmlAttrs:s=`lang="${a}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[i?x():"",r].filter(h=>h.trim().length>0).join(`
|
|
137
137
|
`);return`<!DOCTYPE html>
|
|
138
138
|
<html ${s}>
|
|
139
139
|
<head>
|
|
140
140
|
<base target="_top" />
|
|
141
141
|
<meta charset="UTF-8" />
|
|
142
|
-
<title>${
|
|
142
|
+
<title>${ve(t)}</title>${c?`
|
|
143
143
|
${c}`:""}
|
|
144
144
|
</head>
|
|
145
145
|
<body ${l}>
|
|
146
146
|
${o}
|
|
147
147
|
</body>
|
|
148
148
|
</html>
|
|
149
|
-
`}function
|
|
149
|
+
`}function ve(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}n.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=k,n.DEFAULT_IPC_CONFIG=O,n.DEFAULT_SIDEBAR_CONFIG=V,n.DeferredPromise=T,n.IPCCore=C,n.MimeType=d,n.PluginAdapter=q,n.PluginIPCAdapter=R,n.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=ae,n.SIDEBAR_HOST_CONTAINER_ID=b,n.SIDEBAR_HOST_SHELL_CSS=pe,n.SIDEBAR_IFRAME_DEFAULT_ALLOW=H,n.SIDEBAR_IFRAME_DEFAULT_TITLE=N,n.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=ne,n.SidebarAdapter=D,n.SidebarIPCAdapter=_,n.TEXT_MIME_TYPES=X,n.TextLookupError=A,n.assertSidebarHostAdapter=ce,n.buildSidebarHostHtmlDocument=fe,n.buildSidebarHostShellCss=S,n.buildSidebarPluginHostHeadInnerHtml=x,n.createSidebarHost=ge,n.ensureSidebarHostShell=me,n.getAuthConfigWithOverride=se,n.getSidebarBaseUrlWithOverride=oe,n.ipcErrorReconstructors=I,n.isTextLookupError=K,n.reconstructError=E,n.setupSidebarLoadOverlay=M,n.sidebarPostMessageTargetOrigin=le});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SidebarAdapter, type SidebarAdapterOptions } from "../adapters/sidebarAdapter";
|
|
2
2
|
import { type SidebarLoadOverlayOptions } from "../load-overlay";
|
|
3
|
+
import type { AuthConfig } from "../types/common";
|
|
3
4
|
import type { PluginInterface } from "../types/pluginInterface";
|
|
4
5
|
/** Fixed `iframe.title` for accessibility on adapter-created sidebars. */
|
|
5
6
|
export declare const SIDEBAR_IFRAME_DEFAULT_TITLE = "Markup AI Sidebar";
|
|
@@ -20,6 +21,28 @@ export declare const SIDEBAR_DEFAULT_PRODUCTION_BASE_URL: "https://sidebar.marku
|
|
|
20
21
|
* when present (trimmed), otherwise returns `defaultUrl`. Safe when `localStorage` is unavailable or throws.
|
|
21
22
|
*/
|
|
22
23
|
export declare function getSidebarBaseUrlWithOverride(defaultUrl: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* `localStorage` key for forcing an {@link AuthConfig} at runtime, used for
|
|
26
|
+
* local dev + automated tests where the host-supplied config may be missing
|
|
27
|
+
* or wrong. Value is a JSON-serialized {@link AuthConfig}, e.g.
|
|
28
|
+
* `'{"type":"mediation"}'`. Read by {@link getAuthConfigWithOverride}.
|
|
29
|
+
*/
|
|
30
|
+
export declare const AUTH_CONFIG_OVERRIDE_STORAGE_KEY = "markupai.sidebarNextGen.authOverride";
|
|
31
|
+
/**
|
|
32
|
+
* Returns the effective {@link AuthConfig} for the sidebar. Priority:
|
|
33
|
+
*
|
|
34
|
+
* 1. Dev/test override from `localStorage[AUTH_CONFIG_OVERRIDE_STORAGE_KEY]`
|
|
35
|
+
* (honored only when `allowOverride` is `true` — sidebar-app gates this on
|
|
36
|
+
* `import.meta.env.DEV` so production builds can't be coerced).
|
|
37
|
+
* 2. The `hostConfig` value passed in (from the integration's
|
|
38
|
+
* `SidebarConfig.auth`).
|
|
39
|
+
* 3. `undefined` — meaning the sidebar should fall back to its legacy
|
|
40
|
+
* heuristic strategy selection.
|
|
41
|
+
*
|
|
42
|
+
* Invalid JSON in the override is logged and ignored. Safe when
|
|
43
|
+
* `localStorage` is unavailable or throws.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getAuthConfigWithOverride(hostConfig: AuthConfig | undefined, allowOverride: boolean): AuthConfig | undefined;
|
|
23
46
|
export type SidebarPostMessageTargetOriginOptions = {
|
|
24
47
|
/** Invoked when `sidebarUrl` is not a valid URL; the return value falls back to `"*"`. */
|
|
25
48
|
onInvalidUrl?: (sidebarUrl: string, error: unknown) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSidebarHost.d.ts","sourceRoot":"","sources":["../../src/sidebar-host/createSidebarHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvF,O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AAI,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,WAAW,GAAG,sBAAsB,GAAG,gBAAgB,CAAC;AAEpE;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,WAAW,EACjB,OAAO,SAAmD,GACzD,OAAO,CAAC,IAAI,IAAI,sBAAsB,CAIxC;AAgCD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,WAAW,CA8BhF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { assertSidebarHostAdapter, createSidebarHost, getSidebarBaseUrlWithOverride, SIDEBAR_DEFAULT_PRODUCTION_BASE_URL, SIDEBAR_IFRAME_DEFAULT_ALLOW, SIDEBAR_IFRAME_DEFAULT_TITLE, SIDEBAR_URL_OVERRIDE_STORAGE_KEY, sidebarPostMessageTargetOrigin, type CreateSidebarHostOptions, type CreateSidebarIframeMount, type SidebarHost, type SidebarHostWithAdapter, type SidebarPostMessageTargetOriginOptions, type SidebarShellHost, } from "./createSidebarHost";
|
|
1
|
+
export { assertSidebarHostAdapter, AUTH_CONFIG_OVERRIDE_STORAGE_KEY, createSidebarHost, getAuthConfigWithOverride, getSidebarBaseUrlWithOverride, SIDEBAR_DEFAULT_PRODUCTION_BASE_URL, SIDEBAR_IFRAME_DEFAULT_ALLOW, SIDEBAR_IFRAME_DEFAULT_TITLE, SIDEBAR_URL_OVERRIDE_STORAGE_KEY, sidebarPostMessageTargetOrigin, type CreateSidebarHostOptions, type CreateSidebarIframeMount, type SidebarHost, type SidebarHostWithAdapter, type SidebarPostMessageTargetOriginOptions, type SidebarShellHost, } from "./createSidebarHost";
|
|
2
2
|
export { SIDEBAR_HOST_CONTAINER_ID, SIDEBAR_HOST_SHELL_CSS, buildSidebarHostHtmlDocument, buildSidebarHostShellCss, buildSidebarPluginHostHeadInnerHtml, ensureSidebarHostShell, type BuildSidebarHostHtmlDocumentOptions, type EnsureSidebarHostShellOptions, } from "./sidebarHostShell";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sidebar-host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,6BAA6B,EAC7B,mCAAmC,EACnC,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,8BAA8B,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,qCAAqC,EAC1C,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,mCAAmC,EACnC,sBAAsB,EACtB,KAAK,mCAAmC,EACxC,KAAK,6BAA6B,GACnC,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sidebar-host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,iBAAiB,EACjB,yBAAyB,EACzB,6BAA6B,EAC7B,mCAAmC,EACnC,4BAA4B,EAC5B,4BAA4B,EAC5B,gCAAgC,EAChC,8BAA8B,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,qCAAqC,EAC1C,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,mCAAmC,EACnC,sBAAsB,EACtB,KAAK,mCAAmC,EACxC,KAAK,6BAA6B,GACnC,MAAM,oBAAoB,CAAC"}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -34,15 +34,39 @@ export type ContentReplacement = {
|
|
|
34
34
|
range: ContentRange;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
|
-
* Content information including the content, document reference, and optional mime type
|
|
38
|
-
* The integration must provide content and documentReference - mimeType
|
|
39
|
-
*
|
|
37
|
+
* Content information including the content, document reference, optional document name, and optional mime type
|
|
38
|
+
* The integration must provide content and documentReference - documentName and mimeType are optional
|
|
39
|
+
*
|
|
40
|
+
* - documentReference: A unique identifier for the document (e.g., URL, file path, or document ID).
|
|
41
|
+
* Required because the API uses it to track a document across scans.
|
|
42
|
+
* - documentName: A human-readable name/title for the document (e.g., "My Report.docx").
|
|
43
|
+
* Optional; when absent, the sidebar will attempt to derive it from documentReference if it
|
|
44
|
+
* contains a filename with extension.
|
|
45
|
+
* - mimeType: Any valid MIME type string, not limited to MimeType enum values.
|
|
40
46
|
*/
|
|
41
47
|
export interface ContentInfo {
|
|
42
48
|
content: string | number[];
|
|
43
49
|
documentReference: string;
|
|
50
|
+
documentName?: string;
|
|
44
51
|
mimeType?: string;
|
|
45
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* How the sidebar should run the Auth0 login flow in a given host.
|
|
55
|
+
*
|
|
56
|
+
* - `"mediation"` — backend-mediated authorization code flow. The sidebar asks
|
|
57
|
+
* the backend to start an OAuth handshake, opens the returned `authorizeUrl`
|
|
58
|
+
* in an external browser (via the host, see {@link PluginInterface.openAuthUrl}
|
|
59
|
+
* if provided, else `globalThis.open(url, "_blank", "noopener,noreferrer")`),
|
|
60
|
+
* and polls the backend for the code + token exchange. Works in restricted
|
|
61
|
+
* iframe contexts such as Figma and Office task panes.
|
|
62
|
+
* - `"popup"` — Auth0 SPA client `loginWithPopup`. Requires a secure origin and
|
|
63
|
+
* Web Crypto; breaks in iframes with `null` origin.
|
|
64
|
+
*/
|
|
65
|
+
export type AuthConfig = {
|
|
66
|
+
type: "mediation";
|
|
67
|
+
} | {
|
|
68
|
+
type: "popup";
|
|
69
|
+
};
|
|
46
70
|
/**
|
|
47
71
|
* Configuration for the sidebar
|
|
48
72
|
*/
|
|
@@ -69,6 +93,18 @@ export interface SidebarConfig {
|
|
|
69
93
|
* If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false
|
|
70
94
|
*/
|
|
71
95
|
supportCheckSelection?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* How the sidebar should run the Auth0 login flow. When omitted, the sidebar
|
|
98
|
+
* falls back to heuristic strategy selection (iframe context, secure origin,
|
|
99
|
+
* etc.) for backwards compatibility. New integrations should set this
|
|
100
|
+
* explicitly; `"mediation"` is the correct choice for hosts that embed the
|
|
101
|
+
* sidebar in an iframe (Figma, Office task pane).
|
|
102
|
+
*
|
|
103
|
+
* In dev builds, the sidebar also honors a `localStorage` override at the
|
|
104
|
+
* key exported as `AUTH_CONFIG_OVERRIDE_STORAGE_KEY` — see
|
|
105
|
+
* `getAuthConfigWithOverride` in `sidebar-host`.
|
|
106
|
+
*/
|
|
107
|
+
auth?: AuthConfig;
|
|
72
108
|
}
|
|
73
109
|
export declare const DEFAULT_SIDEBAR_CONFIG: SidebarConfig;
|
|
74
110
|
/**
|
|
@@ -90,6 +126,7 @@ export interface AgenticIssuePayload {
|
|
|
90
126
|
sentence: string;
|
|
91
127
|
};
|
|
92
128
|
suggestion?: string;
|
|
129
|
+
suggestions?: string[];
|
|
93
130
|
category?: string;
|
|
94
131
|
}
|
|
95
132
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA;;;;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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AY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,eAAO,MAAM,sBAAsB,EAAE,aAQpC,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -6,14 +6,14 @@ import type { ContentRange, ContentReplacement, ContentInfo, SidebarConfig, Agen
|
|
|
6
6
|
export interface PluginInterface {
|
|
7
7
|
/**
|
|
8
8
|
* Get content from the editor in whatever format the integration supports
|
|
9
|
-
* The integration must provide content and documentReference; mimeType
|
|
10
|
-
* @returns Promise that resolves with content info including documentReference and optional mimeType
|
|
9
|
+
* The integration must provide content and documentReference; documentName and mimeType are optional
|
|
10
|
+
* @returns Promise that resolves with content info including documentReference and optional documentName/mimeType
|
|
11
11
|
*/
|
|
12
12
|
getContent: () => Promise<ContentInfo>;
|
|
13
13
|
/**
|
|
14
14
|
* Get selected content from the editor in whatever format the integration supports
|
|
15
|
-
* The integration must provide content and documentReference; mimeType
|
|
16
|
-
* @returns Promise that resolves with content info including documentReference and optional mimeType
|
|
15
|
+
* The integration must provide content and documentReference; documentName and mimeType are optional
|
|
16
|
+
* @returns Promise that resolves with content info including documentReference and optional documentName/mimeType
|
|
17
17
|
*/
|
|
18
18
|
getSelectedContent: () => Promise<ContentInfo>;
|
|
19
19
|
/**
|
|
@@ -66,5 +66,24 @@ export interface PluginInterface {
|
|
|
66
66
|
* Called when the agentic stream has finished (all agents done or completion/error event).
|
|
67
67
|
*/
|
|
68
68
|
onAgenticStreamComplete?: () => Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Open an external URL during an authentication flow (typically the Auth0
|
|
71
|
+
* `authorizeUrl` returned by the backend-mediated OAuth flow).
|
|
72
|
+
*
|
|
73
|
+
* Optional. When the host does not provide this, the sidebar falls back to
|
|
74
|
+
* `globalThis.open(url, "_blank", "noopener,noreferrer")` (the
|
|
75
|
+
* `noopener,noreferrer` mitigates reverse-tabnabbing when opening a
|
|
76
|
+
* third-party auth domain). The fallback is blocked or silently broken in
|
|
77
|
+
* some embedded contexts (Office task pane, some Figma builds).
|
|
78
|
+
*
|
|
79
|
+
* Hosts that live inside a sandboxed container should implement this with
|
|
80
|
+
* their platform primitive — for example, Office add-ins should call
|
|
81
|
+
* `Office.context.ui.openBrowserWindow(url)`.
|
|
82
|
+
*
|
|
83
|
+
* The returned promise resolves once the host has handed off the URL; it
|
|
84
|
+
* does **not** need to wait for the user to complete the auth flow (the
|
|
85
|
+
* sidebar handles that via backend polling).
|
|
86
|
+
*/
|
|
87
|
+
openAuthUrl?: (url: string) => Promise<void>;
|
|
69
88
|
}
|
|
70
89
|
//# sourceMappingURL=pluginInterface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginInterface.d.ts","sourceRoot":"","sources":["../../src/types/pluginInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markupai/sidebar-adapter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Adapter package for MarkupAI Sidebar integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markupai",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/markupai/
|
|
13
|
+
"url": "https://github.com/markupai/sidebar-app.git",
|
|
14
14
|
"directory": "packages/adapter"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"type-check": "tsc --project tsconfig.json --noEmit"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"tsc-alias": "1.8.
|
|
41
|
+
"tsc-alias": "1.8.17"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|