@markupai/sidebar-adapter 1.3.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -2
- package/asyncapi.json +6 -2
- package/dist/document-reference/documentReference.d.ts +57 -0
- package/dist/document-reference/documentReference.d.ts.map +1 -0
- package/dist/document-reference/index.d.ts +2 -0
- package/dist/document-reference/index.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/main.js +153 -138
- package/dist/main.umd.cjs +7 -7
- package/dist/types/common.d.ts +24 -2
- package/dist/types/common.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ You do **not** need prior knowledge of how the sidebar is built internally. As a
|
|
|
16
16
|
8. [createSidebarHost](#createsidebarhost) (iframe + overlay + adapter in one step)
|
|
17
17
|
9. [Authentication](#authentication-optional) (declaring an Auth0 login strategy)
|
|
18
18
|
10. [Sidebar load overlay (standalone)](#sidebarloadoverlay-editor-ui)
|
|
19
|
-
11. [Agentic issue lifecycle](#agentic-issue-lifecycle)
|
|
19
|
+
11. [Agentic issue lifecycle](#agentic-issue-lifecycle) · [Document references](#document-references)
|
|
20
20
|
12. [API reference](#api-reference) · [Development](#development)
|
|
21
21
|
|
|
22
22
|
## Features
|
|
@@ -150,6 +150,7 @@ import {
|
|
|
150
150
|
type ContentRange,
|
|
151
151
|
type ContentReplacement,
|
|
152
152
|
type ContentInfo,
|
|
153
|
+
buildDocumentReference,
|
|
153
154
|
} from "@markupai/sidebar-adapter";
|
|
154
155
|
|
|
155
156
|
// Implement the PluginInterface
|
|
@@ -160,7 +161,9 @@ const pluginInterface: PluginInterface = {
|
|
|
160
161
|
const content = getContentFromEditor();
|
|
161
162
|
return {
|
|
162
163
|
content: content,
|
|
163
|
-
|
|
164
|
+
// Required. "<prefix>:<id>" so the same document correlates across Markup surfaces.
|
|
165
|
+
// Pick the prefix once for your platform and never change it.
|
|
166
|
+
documentReference: buildDocumentReference("my-host", getStableDocumentId()),
|
|
164
167
|
mimeType: MimeType.TEXT_MARKDOWN, // Optional: can use MimeType enum or any string
|
|
165
168
|
};
|
|
166
169
|
},
|
|
@@ -184,6 +187,11 @@ const pluginInterface: PluginInterface = {
|
|
|
184
187
|
integrationId: "my-editor",
|
|
185
188
|
useCheckPreviewDialog: true,
|
|
186
189
|
supportCheckSelection: true,
|
|
190
|
+
// Optional. Allow the sidebar to run several agents in one check, each
|
|
191
|
+
// cancellable on its own. Defaults to false (Style agent only). The
|
|
192
|
+
// agents actually offered are the intersection of this flag and the
|
|
193
|
+
// organization's entitlement.
|
|
194
|
+
multiAgent: false,
|
|
187
195
|
pluginOrigin: globalThis.location.origin,
|
|
188
196
|
// Optional. Declare the Auth0 login strategy the sidebar should run.
|
|
189
197
|
// Omit to let the sidebar pick heuristically (legacy behavior).
|
|
@@ -652,6 +660,32 @@ async function onHostReopenClicked(issueId: string) {
|
|
|
652
660
|
}
|
|
653
661
|
```
|
|
654
662
|
|
|
663
|
+
## Document references
|
|
664
|
+
|
|
665
|
+
`ContentInfo.documentReference` identifies a document across scans. The backend keys its document registry on it, and the Markup session id derives its document component from `SHA-256(documentReference)`.
|
|
666
|
+
|
|
667
|
+
That only works if every Markup surface spells the same document the same way, so the format is `<prefix>:<id>` — a prefix naming your platform, then an id that is stable for the document. **You supply both**, because you know what platform you are and which identifier is stable there:
|
|
668
|
+
|
|
669
|
+
```ts
|
|
670
|
+
import { buildDocumentReference } from "@markupai/sidebar-adapter";
|
|
671
|
+
|
|
672
|
+
buildDocumentReference("word", fileGuid); // → "word:aabb"
|
|
673
|
+
buildDocumentReference("gdocs", `${docId}/tab:${tabId}`); // → "gdocs:1A2B3C/tab:t.0"
|
|
674
|
+
buildDocumentReference("url", "https://example.com/page"); // → "url:https://example.com/page"
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
Reuse an existing prefix when your platform already has one, so the same document seen from another Markup surface correlates: `gdocs`, `word`, `heretto`, `madcapflare`, `ixiasoft`, or `url` for anything addressed by a plain URL. If none fits, pick a new one — there is no fixed list, and adding a platform needs no adapter release.
|
|
678
|
+
|
|
679
|
+
### What you are responsible for
|
|
680
|
+
|
|
681
|
+
- **Choose a prefix once and never change it.** The prefix is part of the document's identity. Changing it re-keys every document you have ever checked and breaks continuity with your own history — coordinate a change with the data team rather than shipping one quietly.
|
|
682
|
+
- **Use an id that is stable for the document.** Not the editor URL with its volatile query parameters, not a per-session handle — the thing that still identifies the document tomorrow.
|
|
683
|
+
- **Use the same reference for the whole document and for a selection.** A selection is a view of one document, not a different document; varying the reference between the two splits one document into two everywhere downstream.
|
|
684
|
+
|
|
685
|
+
`buildDocumentReference` is idempotent for its own prefix, so a host that stores composed references can pass them straight back. It throws on an empty id or a prefix that is not a lowercase name, since both would yield a reference that silently fails to correlate. `isDocumentReference(value)` reports whether a value already carries the `<prefix>:<id>` shape.
|
|
686
|
+
|
|
687
|
+
A bare, unprefixed value is still accepted and behaves exactly as before; it simply cannot be correlated with the same document seen on another surface.
|
|
688
|
+
|
|
655
689
|
## Integration settings
|
|
656
690
|
|
|
657
691
|
A host MAY declare a small schema of settings it wants the sidebar to render and persist on its behalf. The sidebar shows a section in its Settings surface, persists user choices per-`integrationId` in `localStorage`, and notifies the host on user edits. The host can also push values and per-field UI state (`disabled`, `hidden`, `allowedValues`) to enforce its own rules — for example, "annotations off ⇒ view mode locked to `original`".
|
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.
|
|
5
|
+
"version": "1.4.0",
|
|
6
6
|
"description": "Bidirectional RPC-over-postMessage contract between the Markup AI sidebar and its host. Generated from the @markupai/sidebar-adapter TypeScript types — do not hand-edit."
|
|
7
7
|
},
|
|
8
8
|
"channels": {
|
|
@@ -1319,7 +1319,7 @@
|
|
|
1319
1319
|
},
|
|
1320
1320
|
"required": ["content", "documentReference"],
|
|
1321
1321
|
"additionalProperties": false,
|
|
1322
|
-
"description": "Content information including the content, document reference, optional document name, and optional mime type The integration must provide content and documentReference - documentName and mimeType are optional\n\n- documentReference: A unique identifier for the document
|
|
1322
|
+
"description": "Content information including the content, document reference, optional document name, and optional mime type The integration must provide content and documentReference - documentName and mimeType are optional\n\n- documentReference: A unique identifier for the document, used to track it across scans. Compose it with `buildDocumentReference(prefix, id)`: you pick a prefix naming your platform and supply an id that is stable for the document. The `<prefix>:<id>` format is shared with every other Markup surface, so the same document correlates across products, and the Markup session id's document component is derived from it.\n\n Choose the prefix once and never change it — it is part of the document's identity, and changing it re-keys every document you have checked. Use the same reference for a whole document and for a selection within it. A bare, unprefixed value is still accepted and behaves as before; it simply cannot be correlated with the same document seen elsewhere.\n- documentName: A human-readable name/title for the document (e.g., \"My Report.docx\"). Optional; when absent, the sidebar will attempt to derive it from documentReference if it contains a filename with extension.\n- mimeType: Any valid MIME type string, not limited to MimeType enum values.",
|
|
1323
1323
|
"title": "ContentInfo"
|
|
1324
1324
|
},
|
|
1325
1325
|
"AuthConfigMediation": {
|
|
@@ -1391,6 +1391,10 @@
|
|
|
1391
1391
|
"type": "boolean",
|
|
1392
1392
|
"description": "Whether to support selection-based check and rewrite functionality If true or undefined (default), the selection toggle UI will be shown and users can toggle between full content and selection modes If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false"
|
|
1393
1393
|
},
|
|
1394
|
+
"multiAgent": {
|
|
1395
|
+
"type": "boolean",
|
|
1396
|
+
"description": "Whether the sidebar may run several agents concurrently in one check.\n\nWhen `false` or omitted (the default), only the Style agent is offered and run, and a check is dispatched as a single-agent run. When `true`, the sidebar offers every agent the organization is entitled to and fans the selected ones out through the parallel executor, streaming results per agent; each agent can then be cancelled independently of the others.\n\nThe host flag and the organization's entitlement **intersect**: enabling this never grants access to an agent the organization does not have, and an entitled agent is never offered while this is `false`."
|
|
1397
|
+
},
|
|
1394
1398
|
"auth": {
|
|
1395
1399
|
"$ref": "#/components/schemas/AuthConfig",
|
|
1396
1400
|
"description": "How the sidebar should run the Auth0 login flow. When omitted, the sidebar falls back to heuristic strategy selection (iframe context, secure origin, etc.) for backwards compatibility. New integrations should set this explicitly; `\"mediation\"` is the correct choice for hosts that embed the sidebar in an iframe (Figma, Office task pane).\n\nIn dev builds, the sidebar also honors a `localStorage` override at the key exported as `AUTH_CONFIG_OVERRIDE_STORAGE_KEY` — see `getAuthConfigWithOverride` in `sidebar-host`."
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical `document_ref` composition.
|
|
3
|
+
*
|
|
4
|
+
* A `document_ref` identifies a document across scans and across Markup
|
|
5
|
+
* products. Its value is only useful if **every** surface spells the same
|
|
6
|
+
* document the same way: the backend keys `document_registry` on it, and the
|
|
7
|
+
* Markup session id embeds the high 48 bits of `SHA-256(document_ref)` so a
|
|
8
|
+
* session can be recognised as belonging to a known document.
|
|
9
|
+
*
|
|
10
|
+
* The format is `<prefix>:<id>` — a platform prefix, then an id that is stable
|
|
11
|
+
* and unique within that platform. **The integration supplies both.** It knows
|
|
12
|
+
* what platform it is and which identifier is stable there; the adapter cannot
|
|
13
|
+
* infer either, and hard-coding a list of platforms here would mean an adapter
|
|
14
|
+
* release every time a new one appears — and would still be wrong for hosts
|
|
15
|
+
* whose stable id is not derivable from a URL.
|
|
16
|
+
*
|
|
17
|
+
* ## What an integration is responsible for
|
|
18
|
+
*
|
|
19
|
+
* - **Choose a prefix once and never change it.** The prefix is part of the
|
|
20
|
+
* document's identity. Changing it re-keys every document that integration
|
|
21
|
+
* has ever checked, breaking continuity with its own history. Coordinate a
|
|
22
|
+
* change with the data team; do not ship one quietly.
|
|
23
|
+
* - **Use an id that is stable for the document.** Not the editor URL with its
|
|
24
|
+
* volatile query parameters, not a per-session handle — the thing that still
|
|
25
|
+
* identifies the document tomorrow.
|
|
26
|
+
* - **Use the same reference for the whole document and for a selection.** A
|
|
27
|
+
* selection is a view of one document, not a different document. Varying the
|
|
28
|
+
* reference between them splits one document into two everywhere downstream.
|
|
29
|
+
*
|
|
30
|
+
* Reuse an existing prefix when the platform already has one, so the same
|
|
31
|
+
* document seen from another Markup surface correlates: `gdocs`, `word`,
|
|
32
|
+
* `heretto`, `madcapflare`, `ixiasoft`, or `url` for anything addressed by a
|
|
33
|
+
* plain URL.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Whether a value already looks like a composed reference.
|
|
37
|
+
*
|
|
38
|
+
* A shape test, not a membership test — there is no list of known prefixes to
|
|
39
|
+
* check against, by design.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isDocumentReference(value: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Compose a `document_ref` from a platform prefix and a document id.
|
|
44
|
+
*
|
|
45
|
+
* Idempotent: a value already prefixed with `prefix` is returned unchanged, so
|
|
46
|
+
* a host that stores composed references can pass them back through without
|
|
47
|
+
* doubling the prefix.
|
|
48
|
+
*
|
|
49
|
+
* @param prefix Platform identifier the integration owns, e.g. `"word"`. Case
|
|
50
|
+
* and surrounding whitespace are normalized; the value is otherwise yours.
|
|
51
|
+
* @param id Stable, unique id for the document within that platform.
|
|
52
|
+
* @throws If either part is empty, or the prefix is not a lowercase
|
|
53
|
+
* alphanumeric name. Both are programming errors that would otherwise
|
|
54
|
+
* produce a reference silently unusable for correlation.
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildDocumentReference(prefix: string, id: string): string;
|
|
57
|
+
//# sourceMappingURL=documentReference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentReference.d.ts","sourceRoot":"","sources":["../../src/document-reference/documentReference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAQH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAI1D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAiBzE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/document-reference/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC;AAGzB,cAAc,YAAY,CAAC;AAG3B,cAAc,OAAO,CAAC;AAGtB,cAAc,gBAAgB,CAAC;AAG/B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC;AAGzB,cAAc,sBAAsB,CAAC;AAGrC,cAAc,YAAY,CAAC;AAG3B,cAAc,OAAO,CAAC;AAGtB,cAAc,gBAAgB,CAAC;AAG/B,cAAc,gBAAgB,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
var
|
|
1
|
+
var oe = /* @__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
|
+
})({}), se = [
|
|
4
4
|
"text/plain",
|
|
5
5
|
"text/markdown",
|
|
6
6
|
"text/html",
|
|
7
7
|
"application/dita+xml"
|
|
8
|
-
],
|
|
8
|
+
], le = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
12
12
|
hideBanner: !1,
|
|
13
13
|
dialogClosingScript: void 0,
|
|
14
14
|
useCheckPreviewDialog: !1,
|
|
15
|
-
supportCheckSelection: !0
|
|
16
|
-
|
|
15
|
+
supportCheckSelection: !0,
|
|
16
|
+
multiAgent: !1
|
|
17
|
+
}, ce = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), de = (e) => {
|
|
17
18
|
if (typeof e != "object" || e === null) return !1;
|
|
18
19
|
const t = e;
|
|
19
20
|
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) => {
|
|
@@ -21,21 +22,33 @@ var ne = /* @__PURE__ */ (function(e) {
|
|
|
21
22
|
const r = i;
|
|
22
23
|
return typeof r.value == "string" && typeof r.label == "string";
|
|
23
24
|
}) : !1;
|
|
24
|
-
},
|
|
25
|
+
}, O = class T extends Error {
|
|
25
26
|
name = "TextLookupError";
|
|
26
27
|
constructor(t) {
|
|
27
|
-
super(t), Object.setPrototypeOf(this,
|
|
28
|
+
super(t), Object.setPrototypeOf(this, T.prototype);
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
|
-
function
|
|
31
|
-
return e instanceof
|
|
31
|
+
function ge(e) {
|
|
32
|
+
return e instanceof O;
|
|
32
33
|
}
|
|
33
|
-
var P = { TextLookupError: (e) => new
|
|
34
|
-
function
|
|
34
|
+
var P = { TextLookupError: (e) => new O(e) };
|
|
35
|
+
function U(e) {
|
|
35
36
|
const t = e.message ?? "", i = e.name, r = typeof i == "string" && i in P ? P[i] : void 0;
|
|
36
37
|
return r ? r(t, e) : Object.assign(new Error(t), i ? { name: i } : {});
|
|
37
38
|
}
|
|
38
|
-
var
|
|
39
|
+
var D = ":", x = /^[a-z][a-z0-9-]*$/;
|
|
40
|
+
function pe(e) {
|
|
41
|
+
const t = e.indexOf(D);
|
|
42
|
+
return t <= 0 || t === e.length - 1 ? !1 : x.test(e.slice(0, t));
|
|
43
|
+
}
|
|
44
|
+
function ue(e, t) {
|
|
45
|
+
const i = e.trim().toLowerCase(), r = t.trim();
|
|
46
|
+
if (!x.test(i)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
|
|
47
|
+
if (r.length === 0) throw new Error("Invalid document reference: the document id is empty.");
|
|
48
|
+
const n = `${i}${D}`;
|
|
49
|
+
return r.startsWith(n) ? r : `${n}${r}`;
|
|
50
|
+
}
|
|
51
|
+
var H = class extends Promise {
|
|
39
52
|
static get [Symbol.species]() {
|
|
40
53
|
return Promise;
|
|
41
54
|
}
|
|
@@ -44,19 +57,19 @@ var B = class extends Promise {
|
|
|
44
57
|
constructor(e = () => {
|
|
45
58
|
}) {
|
|
46
59
|
let t, i;
|
|
47
|
-
super((r,
|
|
48
|
-
t = r, i =
|
|
60
|
+
super((r, n) => {
|
|
61
|
+
t = r, i = n, e(r, n);
|
|
49
62
|
}), this.resolve = t, this.reject = i;
|
|
50
63
|
}
|
|
51
|
-
},
|
|
52
|
-
function
|
|
64
|
+
}, $ = { timeout: 1e4 };
|
|
65
|
+
function j(e) {
|
|
53
66
|
const t = JSON.stringify(e, Object.getOwnPropertyNames(e)), i = JSON.parse(t);
|
|
54
67
|
return i.message === void 0 || i.message === "" ? JSON.stringify({
|
|
55
68
|
message: e instanceof Error ? e.message : String(e),
|
|
56
69
|
name: e instanceof Error ? e.name : void 0
|
|
57
70
|
}) : t;
|
|
58
71
|
}
|
|
59
|
-
var
|
|
72
|
+
var L = class {
|
|
60
73
|
promisesByID = {};
|
|
61
74
|
receiversByName = {};
|
|
62
75
|
currentID = 0;
|
|
@@ -64,7 +77,7 @@ var D = class {
|
|
|
64
77
|
postMessage;
|
|
65
78
|
constructor(e, t) {
|
|
66
79
|
this.postMessage = e, this.config = {
|
|
67
|
-
|
|
80
|
+
...$,
|
|
68
81
|
...t
|
|
69
82
|
};
|
|
70
83
|
}
|
|
@@ -78,14 +91,14 @@ var D = class {
|
|
|
78
91
|
return this.callWithOptions(e, {}, ...t);
|
|
79
92
|
}
|
|
80
93
|
callWithOptions(e, t, ...i) {
|
|
81
|
-
const r = this.currentID++,
|
|
94
|
+
const r = this.currentID++, n = new H(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
82
95
|
if (r in this.promisesByID) {
|
|
83
|
-
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(
|
|
84
|
-
|
|
96
|
+
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);
|
|
97
|
+
n.reject(l), Reflect.deleteProperty(this.promisesByID, r);
|
|
85
98
|
}
|
|
86
|
-
},
|
|
99
|
+
}, a);
|
|
87
100
|
this.promisesByID[r] = {
|
|
88
|
-
promise:
|
|
101
|
+
promise: n,
|
|
89
102
|
timeoutId: o
|
|
90
103
|
};
|
|
91
104
|
const s = {
|
|
@@ -94,7 +107,7 @@ var D = class {
|
|
|
94
107
|
name: e,
|
|
95
108
|
data: i
|
|
96
109
|
};
|
|
97
|
-
return this.postMessage(s),
|
|
110
|
+
return this.postMessage(s), n;
|
|
98
111
|
}
|
|
99
112
|
receive(e, t) {
|
|
100
113
|
this.receiversByName[e] = t;
|
|
@@ -119,9 +132,9 @@ var D = class {
|
|
|
119
132
|
async handleCall(e) {
|
|
120
133
|
const { id: t, name: i, data: r } = e;
|
|
121
134
|
if (!(i in this.receiversByName)) {
|
|
122
|
-
const
|
|
123
|
-
message:
|
|
124
|
-
name:
|
|
135
|
+
const a = /* @__PURE__ */ new Error(`No receiver registered for: ${i}`), o = JSON.stringify({
|
|
136
|
+
message: a.message,
|
|
137
|
+
name: a.name
|
|
125
138
|
});
|
|
126
139
|
this.postMessage({
|
|
127
140
|
type: "error",
|
|
@@ -131,22 +144,22 @@ var D = class {
|
|
|
131
144
|
});
|
|
132
145
|
return;
|
|
133
146
|
}
|
|
134
|
-
const
|
|
147
|
+
const n = this.receiversByName[i];
|
|
135
148
|
try {
|
|
136
149
|
if (!Array.isArray(r)) throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);
|
|
137
|
-
const
|
|
150
|
+
const a = await n(...r), o = {
|
|
138
151
|
type: "response",
|
|
139
152
|
id: t,
|
|
140
153
|
name: i,
|
|
141
|
-
data:
|
|
154
|
+
data: a
|
|
142
155
|
};
|
|
143
156
|
this.postMessage(o);
|
|
144
|
-
} catch (
|
|
157
|
+
} catch (a) {
|
|
145
158
|
const o = {
|
|
146
159
|
type: "error",
|
|
147
160
|
id: t,
|
|
148
161
|
name: i,
|
|
149
|
-
errorJSON:
|
|
162
|
+
errorJSON: j(a)
|
|
150
163
|
};
|
|
151
164
|
this.postMessage(o);
|
|
152
165
|
}
|
|
@@ -161,11 +174,11 @@ var D = class {
|
|
|
161
174
|
handleError(e) {
|
|
162
175
|
const { id: t, errorJSON: i } = e;
|
|
163
176
|
if (t in this.promisesByID) {
|
|
164
|
-
const { promise: r, timeoutId:
|
|
165
|
-
clearTimeout(
|
|
177
|
+
const { promise: r, timeoutId: n } = this.promisesByID[t];
|
|
178
|
+
clearTimeout(n);
|
|
166
179
|
try {
|
|
167
|
-
const
|
|
168
|
-
r.reject(
|
|
180
|
+
const a = U(JSON.parse(i));
|
|
181
|
+
r.reject(a);
|
|
169
182
|
} catch {
|
|
170
183
|
r.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
171
184
|
}
|
|
@@ -177,12 +190,12 @@ var D = class {
|
|
|
177
190
|
clearTimeout(t), e.reject(/* @__PURE__ */ new Error("IPC destroyed"));
|
|
178
191
|
this.promisesByID = {}, this.receiversByName = {};
|
|
179
192
|
}
|
|
180
|
-
},
|
|
193
|
+
}, F = class {
|
|
181
194
|
ipc;
|
|
182
195
|
sidebar;
|
|
183
196
|
targetOrigin;
|
|
184
197
|
constructor(e, t, i = "*") {
|
|
185
|
-
this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new
|
|
198
|
+
this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new L((r) => {
|
|
186
199
|
window.parent.postMessage(r, this.targetOrigin);
|
|
187
200
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
188
201
|
}
|
|
@@ -293,10 +306,10 @@ var D = class {
|
|
|
293
306
|
destroy() {
|
|
294
307
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
295
308
|
}
|
|
296
|
-
},
|
|
309
|
+
}, he = class {
|
|
297
310
|
ipcAdapter;
|
|
298
311
|
constructor(e, t, i) {
|
|
299
|
-
this.ipcAdapter = new
|
|
312
|
+
this.ipcAdapter = new F(e, t, i);
|
|
300
313
|
}
|
|
301
314
|
destroy() {
|
|
302
315
|
this.ipcAdapter.destroy();
|
|
@@ -352,15 +365,15 @@ var D = class {
|
|
|
352
365
|
getTargetOrigin() {
|
|
353
366
|
return this.ipcAdapter.getTargetOrigin();
|
|
354
367
|
}
|
|
355
|
-
},
|
|
368
|
+
}, z = class {
|
|
356
369
|
ipc;
|
|
357
370
|
plugin;
|
|
358
371
|
iframe;
|
|
359
372
|
window;
|
|
360
373
|
targetOrigin;
|
|
361
|
-
constructor(e, t, i, r,
|
|
362
|
-
this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin =
|
|
363
|
-
this.iframe.contentWindow?.postMessage(
|
|
374
|
+
constructor(e, t, i, r, n = "*") {
|
|
375
|
+
this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin = n, this.ipc = new L((a) => {
|
|
376
|
+
this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
|
|
364
377
|
}, r), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
365
378
|
}
|
|
366
379
|
handleMessage = (e) => {
|
|
@@ -441,10 +454,10 @@ var D = class {
|
|
|
441
454
|
destroy() {
|
|
442
455
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
443
456
|
}
|
|
444
|
-
},
|
|
457
|
+
}, W = class {
|
|
445
458
|
ipcAdapter;
|
|
446
459
|
constructor(e, t, i) {
|
|
447
|
-
this.ipcAdapter = new
|
|
460
|
+
this.ipcAdapter = new z(e, t, i?.win, i?.config, i?.targetOrigin);
|
|
448
461
|
}
|
|
449
462
|
destroy() {
|
|
450
463
|
this.ipcAdapter.destroy();
|
|
@@ -473,7 +486,7 @@ var D = class {
|
|
|
473
486
|
configure(e) {
|
|
474
487
|
this.ipcAdapter.configure(e);
|
|
475
488
|
}
|
|
476
|
-
},
|
|
489
|
+
}, G = `
|
|
477
490
|
<div class="sidebar-load-overlay-card">
|
|
478
491
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
479
492
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -494,16 +507,16 @@ var D = class {
|
|
|
494
507
|
<span>Retry</span>
|
|
495
508
|
</button>
|
|
496
509
|
</div>
|
|
497
|
-
`,
|
|
510
|
+
`, J = () => {
|
|
498
511
|
const e = document.createElement("div");
|
|
499
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
512
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = G;
|
|
500
513
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
501
514
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
502
515
|
return {
|
|
503
516
|
overlay: e,
|
|
504
517
|
button: t
|
|
505
518
|
};
|
|
506
|
-
}, E = "markupai-sidebar-load-overlay-styles",
|
|
519
|
+
}, E = "markupai-sidebar-load-overlay-styles", Y = `
|
|
507
520
|
:root {
|
|
508
521
|
--background: #f5f5f4;
|
|
509
522
|
--foreground: #333332;
|
|
@@ -595,25 +608,25 @@ var D = class {
|
|
|
595
608
|
box-shadow: 0 0 0 2px
|
|
596
609
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
597
610
|
}
|
|
598
|
-
`,
|
|
611
|
+
`, V = (e) => {
|
|
599
612
|
const t = e ?? document;
|
|
600
613
|
if (t.getElementById(E)) return;
|
|
601
614
|
const i = t.createElement("style");
|
|
602
|
-
i.id = E, i.textContent =
|
|
603
|
-
},
|
|
604
|
-
|
|
605
|
-
const { sidebarUrl: r, targetOrigin:
|
|
606
|
-
if (
|
|
615
|
+
i.id = E, i.textContent = Y, t.head.appendChild(i);
|
|
616
|
+
}, X = 8e3, K = 12e3, q = (e, t, i = {}) => {
|
|
617
|
+
V(e.ownerDocument);
|
|
618
|
+
const { sidebarUrl: r, targetOrigin: n, timeoutMs: a = X, retryIntervalMs: o = K, messageListenWindow: s } = i, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, N = () => {
|
|
619
|
+
if (n) return n;
|
|
607
620
|
try {
|
|
608
621
|
return new URL(p()).origin;
|
|
609
622
|
} catch {
|
|
610
623
|
return "*";
|
|
611
624
|
}
|
|
612
|
-
}, { overlay:
|
|
613
|
-
e.appendChild(
|
|
625
|
+
}, { overlay: y, button: I } = J();
|
|
626
|
+
e.appendChild(y);
|
|
614
627
|
let u = !1, h, d;
|
|
615
628
|
const g = (c) => {
|
|
616
|
-
|
|
629
|
+
y.style.display = c ? "flex" : "none";
|
|
617
630
|
};
|
|
618
631
|
g(!1);
|
|
619
632
|
const f = () => {
|
|
@@ -621,11 +634,11 @@ var D = class {
|
|
|
621
634
|
}, v = () => {
|
|
622
635
|
f(), h = globalThis.setTimeout(() => {
|
|
623
636
|
u || g(!0);
|
|
624
|
-
},
|
|
637
|
+
}, a);
|
|
625
638
|
}, A = (c) => {
|
|
626
|
-
const
|
|
627
|
-
u = !1,
|
|
628
|
-
},
|
|
639
|
+
const m = c?.preserveOverlay ?? !0;
|
|
640
|
+
u = !1, m || g(!1), t.src = p(), v();
|
|
641
|
+
}, B = () => {
|
|
629
642
|
d || o <= 0 || (d = globalThis.setInterval(() => {
|
|
630
643
|
u || A({ preserveOverlay: !0 });
|
|
631
644
|
}, o));
|
|
@@ -633,30 +646,30 @@ var D = class {
|
|
|
633
646
|
d && (globalThis.clearInterval(d), d = void 0);
|
|
634
647
|
}, b = (c) => {
|
|
635
648
|
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
636
|
-
const
|
|
637
|
-
|
|
649
|
+
const m = N();
|
|
650
|
+
m !== "*" && c.origin !== m || (u = !0, f(), C(), g(!1));
|
|
638
651
|
}, w = () => {
|
|
639
652
|
f(), g(!0);
|
|
640
653
|
}, S = () => {
|
|
641
654
|
A();
|
|
642
655
|
};
|
|
643
|
-
return I.addEventListener("click", S), t.addEventListener("error", w), l.addEventListener("message", b), v(),
|
|
644
|
-
f(), C(), t.removeEventListener("error", w), l.removeEventListener("message", b), I.removeEventListener("click", S),
|
|
656
|
+
return I.addEventListener("click", S), t.addEventListener("error", w), l.addEventListener("message", b), v(), B(), () => {
|
|
657
|
+
f(), C(), t.removeEventListener("error", w), l.removeEventListener("message", b), I.removeEventListener("click", S), y.remove();
|
|
645
658
|
};
|
|
646
|
-
},
|
|
647
|
-
function
|
|
659
|
+
}, Z = "Markup AI Sidebar", Q = "clipboard-read; clipboard-write", fe = "markupai.sidebarNextGen.overrideUrl", me = "https://sidebar.markup.ai/";
|
|
660
|
+
function ye(e) {
|
|
648
661
|
try {
|
|
649
662
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
650
663
|
} catch {
|
|
651
664
|
return e;
|
|
652
665
|
}
|
|
653
666
|
}
|
|
654
|
-
var
|
|
655
|
-
function
|
|
667
|
+
var ee = "markupai.sidebarNextGen.authOverride";
|
|
668
|
+
function Ie(e, t) {
|
|
656
669
|
if (!t) return e;
|
|
657
670
|
try {
|
|
658
671
|
if (!("localStorage" in globalThis)) return e;
|
|
659
|
-
const i = globalThis.localStorage.getItem(
|
|
672
|
+
const i = globalThis.localStorage.getItem(ee)?.trim();
|
|
660
673
|
if (!i) return e;
|
|
661
674
|
const r = JSON.parse(i);
|
|
662
675
|
return r !== null && typeof r == "object" && "type" in r && (r.type === "mediation" || r.type === "popup") ? r : e;
|
|
@@ -664,17 +677,17 @@ function he(e, t) {
|
|
|
664
677
|
return e;
|
|
665
678
|
}
|
|
666
679
|
}
|
|
667
|
-
function
|
|
680
|
+
function ve(e, t) {
|
|
668
681
|
try {
|
|
669
682
|
return new URL(e).origin;
|
|
670
683
|
} catch (i) {
|
|
671
684
|
return t?.onInvalidUrl?.(e, i), "*";
|
|
672
685
|
}
|
|
673
686
|
}
|
|
674
|
-
function
|
|
687
|
+
function Ae(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
675
688
|
if (e.adapter === null) throw new Error(t);
|
|
676
689
|
}
|
|
677
|
-
function
|
|
690
|
+
function te(e) {
|
|
678
691
|
const { iframe: t, iframeMount: i } = e;
|
|
679
692
|
if (t !== void 0 && i !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
680
693
|
if (t !== void 0) return {
|
|
@@ -682,20 +695,20 @@ function Q(e) {
|
|
|
682
695
|
removeMountedIframe: null
|
|
683
696
|
};
|
|
684
697
|
if (i === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
685
|
-
const { container: r, src:
|
|
686
|
-
return o.title =
|
|
698
|
+
const { container: r, src: n, allow: a = Q } = i, o = document.createElement("iframe");
|
|
699
|
+
return o.title = Z, o.src = n, a && o.setAttribute("allow", a), r.appendChild(o), {
|
|
687
700
|
iframe: o,
|
|
688
701
|
removeMountedIframe: () => {
|
|
689
702
|
o.remove();
|
|
690
703
|
}
|
|
691
704
|
};
|
|
692
705
|
}
|
|
693
|
-
function
|
|
694
|
-
const { plugin: t, loadOverlayContainer: i, loadOverlayOptions: r, adapterOptions:
|
|
706
|
+
function Ce(e) {
|
|
707
|
+
const { plugin: t, loadOverlayContainer: i, loadOverlayOptions: r, adapterOptions: n } = e, { iframe: a, removeMountedIframe: o } = te(e), s = i !== void 0 ? q(i, a, r ?? {}) : null;
|
|
695
708
|
if (t !== void 0) {
|
|
696
|
-
const l = new
|
|
709
|
+
const l = new W(t, a, n);
|
|
697
710
|
return {
|
|
698
|
-
iframe:
|
|
711
|
+
iframe: a,
|
|
699
712
|
adapter: l,
|
|
700
713
|
destroy: () => {
|
|
701
714
|
s?.(), l.destroy(), o?.();
|
|
@@ -703,21 +716,21 @@ function me(e) {
|
|
|
703
716
|
};
|
|
704
717
|
}
|
|
705
718
|
return {
|
|
706
|
-
iframe:
|
|
719
|
+
iframe: a,
|
|
707
720
|
adapter: null,
|
|
708
721
|
destroy: () => {
|
|
709
722
|
s?.(), o?.();
|
|
710
723
|
}
|
|
711
724
|
};
|
|
712
725
|
}
|
|
713
|
-
var
|
|
714
|
-
function
|
|
726
|
+
var M = "sidebarContainer", R = "markupai-sidebar-host-shell-styles";
|
|
727
|
+
function _(e) {
|
|
715
728
|
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
716
|
-
if (!/^[a-zA-Z_][\w-]*$/.test(e)) throw new Error(`sidebar host shell: containerId must match /^[a-zA-Z_][
|
|
729
|
+
if (!/^[a-zA-Z_][\w-]*$/.test(e)) throw new Error(String.raw`sidebar host shell: containerId must match /^[a-zA-Z_][\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(e)})`);
|
|
717
730
|
return e;
|
|
718
731
|
}
|
|
719
|
-
function
|
|
720
|
-
const t =
|
|
732
|
+
function k(e = M) {
|
|
733
|
+
const t = _(e);
|
|
721
734
|
return `
|
|
722
735
|
html {
|
|
723
736
|
height: 100%;
|
|
@@ -742,84 +755,86 @@ body {
|
|
|
742
755
|
}
|
|
743
756
|
`.trim();
|
|
744
757
|
}
|
|
745
|
-
var
|
|
746
|
-
function
|
|
758
|
+
var be = k();
|
|
759
|
+
function ie(e) {
|
|
747
760
|
return e instanceof Document ? e : e.ownerDocument;
|
|
748
761
|
}
|
|
749
|
-
function
|
|
762
|
+
function re(e, t, i) {
|
|
750
763
|
if (!t || e.getElementById(R)) return;
|
|
751
764
|
const r = e.createElement("style");
|
|
752
|
-
r.id = R, r.textContent =
|
|
765
|
+
r.id = R, r.textContent = k(i), e.head.appendChild(r);
|
|
753
766
|
}
|
|
754
|
-
function
|
|
755
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId: i =
|
|
767
|
+
function we(e) {
|
|
768
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: i = M, includeDefaultStyles: r = !0 } = e ?? {};
|
|
756
769
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
const
|
|
760
|
-
if (
|
|
770
|
+
const n = ie(t);
|
|
771
|
+
re(n, r, i);
|
|
772
|
+
const a = t instanceof Document ? n.getElementById(i) : t.querySelector(`#${_(i)}`);
|
|
773
|
+
if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
|
|
761
774
|
if (!(t instanceof Document)) {
|
|
762
|
-
const s =
|
|
775
|
+
const s = n.createElement("div");
|
|
763
776
|
return s.id = i, t.appendChild(s), s;
|
|
764
777
|
}
|
|
765
|
-
const o =
|
|
766
|
-
return o.id = i,
|
|
778
|
+
const o = n.createElement("div");
|
|
779
|
+
return o.id = i, n.body.appendChild(o), o;
|
|
767
780
|
}
|
|
768
|
-
function
|
|
781
|
+
function ne() {
|
|
769
782
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
770
783
|
}
|
|
771
|
-
function
|
|
772
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml: i = "", includePluginHostHead: r = !1, bodyScriptsHtml:
|
|
784
|
+
function Se(e) {
|
|
785
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: i = "", includePluginHostHead: r = !1, bodyScriptsHtml: n, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [r ? ne() : "", i].filter((p) => p.trim().length > 0).join(`
|
|
773
786
|
`);
|
|
774
787
|
return `<!DOCTYPE html>
|
|
775
788
|
<html ${o}>
|
|
776
789
|
<head>
|
|
777
790
|
<base target="_top" />
|
|
778
791
|
<meta charset="UTF-8" />
|
|
779
|
-
<title>${
|
|
792
|
+
<title>${ae(t)}</title>${l ? `
|
|
780
793
|
${l}` : ""}
|
|
781
794
|
</head>
|
|
782
795
|
<body ${s}>
|
|
783
|
-
${
|
|
796
|
+
${n}
|
|
784
797
|
</body>
|
|
785
798
|
</html>
|
|
786
799
|
`;
|
|
787
800
|
}
|
|
788
|
-
function
|
|
801
|
+
function ae(e) {
|
|
789
802
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
790
803
|
}
|
|
791
804
|
export {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
805
|
+
ee as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
806
|
+
$ as DEFAULT_IPC_CONFIG,
|
|
807
|
+
le as DEFAULT_SIDEBAR_CONFIG,
|
|
808
|
+
H as DeferredPromise,
|
|
809
|
+
L as IPCCore,
|
|
810
|
+
oe as MimeType,
|
|
811
|
+
he as PluginAdapter,
|
|
812
|
+
F as PluginIPCAdapter,
|
|
813
|
+
me as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
814
|
+
M as SIDEBAR_HOST_CONTAINER_ID,
|
|
815
|
+
be as SIDEBAR_HOST_SHELL_CSS,
|
|
816
|
+
Q as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
817
|
+
Z as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
818
|
+
fe as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
819
|
+
W as SidebarAdapter,
|
|
820
|
+
z as SidebarIPCAdapter,
|
|
821
|
+
se as TEXT_MIME_TYPES,
|
|
822
|
+
O as TextLookupError,
|
|
823
|
+
Ae as assertSidebarHostAdapter,
|
|
824
|
+
ue as buildDocumentReference,
|
|
825
|
+
Se as buildSidebarHostHtmlDocument,
|
|
826
|
+
k as buildSidebarHostShellCss,
|
|
827
|
+
ne as buildSidebarPluginHostHeadInnerHtml,
|
|
828
|
+
Ce as createSidebarHost,
|
|
829
|
+
we as ensureSidebarHostShell,
|
|
830
|
+
Ie as getAuthConfigWithOverride,
|
|
831
|
+
ye as getSidebarBaseUrlWithOverride,
|
|
818
832
|
P as ipcErrorReconstructors,
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
ce as
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
833
|
+
pe as isDocumentReference,
|
|
834
|
+
de as isIntegrationSettingField,
|
|
835
|
+
ce as isIntegrationSettingsSchema,
|
|
836
|
+
ge as isTextLookupError,
|
|
837
|
+
U as reconstructError,
|
|
838
|
+
q as setupSidebarLoadOverlay,
|
|
839
|
+
ve as sidebarPostMessageTargetOrigin
|
|
825
840
|
};
|
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})({}),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=`
|
|
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})({}),K=["text/plain","text/markdown","text/html","application/dita+xml"],X={integrationName:"unknown",integrationVersion:"unknown",integrationId:"markupai-sidebar-app",hideBanner:!1,dialogClosingScript:void 0,useCheckPreviewDialog:!1,supportCheckSelection:!0,multiAgent:!1},q=e=>typeof e!="object"||e===null?!1:Array.isArray(e.fields),Z=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},A=class V extends Error{name="TextLookupError";constructor(t){super(t),Object.setPrototypeOf(this,V.prototype)}};function Q(e){return e instanceof A}var v={TextLookupError:e=>new A(e)};function E(e){const t=e.message??"",i=e.name,r=typeof i=="string"&&i in v?v[i]:void 0;return r?r(t,e):Object.assign(new Error(t),i?{name:i}:{})}var P=":",R=/^[a-z][a-z0-9-]*$/;function ee(e){const t=e.indexOf(P);return t<=0||t===e.length-1?!1:R.test(e.slice(0,t))}function te(e,t){const i=e.trim().toLowerCase(),r=t.trim();if(!R.test(i))throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);if(r.length===0)throw new Error("Invalid document reference: the document id is empty.");const a=`${i}${P}`;return r.startsWith(a)?r:`${a}${r}`}var T=class extends Promise{static get[Symbol.species](){return Promise}resolve;reject;constructor(e=()=>{}){let t,i;super((r,a)=>{t=r,i=a,e(r,a)}),this.resolve=t,this.reject=i}},O={timeout:1e4};function ie(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={...O,...t}}configure(e){this.config={...this.config,...e}}call(e,...t){return this.callWithOptions(e,{},...t)}callWithOptions(e,t,...i){const r=this.currentID++,a=new T,o=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(o)}ms`);a.reject(c),Reflect.deleteProperty(this.promisesByID,r)}},o);this.promisesByID[r]={promise:a,timeoutId:s};const l={type:"call",id:r,name:e,data:i};return this.postMessage(l),a}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=new Error(`No receiver registered for: ${i}`),s=JSON.stringify({message:o.message,name:o.name});this.postMessage({type:"error",id:t,name:i,errorJSON:s});return}const a=this.receiversByName[i];try{if(!Array.isArray(r))throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);const o=await a(...r),s={type:"response",id:t,name:i,data:o};this.postMessage(s)}catch(o){const s={type:"error",id:t,name:i,errorJSON:ie(o)};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:a}=this.promisesByID[t];clearTimeout(a);try{const o=E(JSON.parse(i));r.reject(o)}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={}}},D=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()}},re=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new D(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()}},_=class{ipc;plugin;iframe;window;targetOrigin;constructor(e,t,i,r,a="*"){this.plugin=e,this.iframe=t,this.window=i??window,this.targetOrigin=a,this.ipc=new C(o=>{this.iframe.contentWindow?.postMessage(o,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()}},L=class{ipcAdapter;constructor(e,t,i){this.ipcAdapter=new _(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)}},ne=`
|
|
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
|
+
`,ae=()=>{const e=document.createElement("div");e.className="sidebar-load-overlay",e.style.display="none",e.innerHTML=ne;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}},M="markupai-sidebar-load-overlay-styles",oe=`
|
|
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
|
+
`,se=e=>{const t=e??document;if(t.getElementById(M))return;const i=t.createElement("style");i.id=M,i.textContent=oe,t.head.appendChild(i)},le=8e3,ce=12e3,k=(e,t,i={})=>{se(e.ownerDocument);const{sidebarUrl:r,targetOrigin:a,timeoutMs:o=le,retryIntervalMs:s=ce,messageListenWindow:l}=i,c=l??(typeof globalThis.window<"u"?globalThis.window:globalThis),h=()=>r??t.src,we=()=>{if(a)return a;try{return new URL(h()).origin}catch{return"*"}},{overlay:w,button:j}=ae();e.appendChild(w);let f=!1,I,p;const u=d=>{w.style.display=d?"flex":"none"};u(!1);const m=()=>{I&&(globalThis.clearTimeout(I),I=void 0)},$=()=>{m(),I=globalThis.setTimeout(()=>{f||u(!0)},o)},W=d=>{const y=d?.preserveOverlay??!0;f=!1,y||u(!1),t.src=h(),$()},Ee=()=>{p||s<=0||(p=globalThis.setInterval(()=>{f||W({preserveOverlay:!0})},s))},G=()=>{p&&(globalThis.clearInterval(p),p=void 0)},z=d=>{if(!t.contentWindow||d.source!==t.contentWindow)return;const y=we();y!=="*"&&d.origin!==y||(f=!0,m(),G(),u(!1))},J=()=>{m(),u(!0)},Y=()=>{W()};return j.addEventListener("click",Y),t.addEventListener("error",J),c.addEventListener("message",z),$(),Ee(),()=>{m(),G(),t.removeEventListener("error",J),c.removeEventListener("message",z),j.removeEventListener("click",Y),w.remove()}},N="Markup AI Sidebar",H="clipboard-read; clipboard-write",de="markupai.sidebarNextGen.overrideUrl",ge="https://sidebar.markup.ai/";function pe(e){try{return"localStorage"in globalThis&&globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim()||e}catch{return e}}var U="markupai.sidebarNextGen.authOverride";function ue(e,t){if(!t)return e;try{if(!("localStorage"in globalThis))return e;const i=globalThis.localStorage.getItem(U)?.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 he(e,t){try{return new URL(e).origin}catch(i){return t?.onInvalidUrl?.(e,i),"*"}}function fe(e,t="Expected SidebarAdapter from createSidebarHost"){if(e.adapter===null)throw new Error(t)}function Ie(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:a,allow:o=H}=i,s=document.createElement("iframe");return s.title=N,s.src=a,o&&s.setAttribute("allow",o),r.appendChild(s),{iframe:s,removeMountedIframe:()=>{s.remove()}}}function me(e){const{plugin:t,loadOverlayContainer:i,loadOverlayOptions:r,adapterOptions:a}=e,{iframe:o,removeMountedIframe:s}=Ie(e),l=i!==void 0?k(i,o,r??{}):null;if(t!==void 0){const c=new L(t,o,a);return{iframe:o,adapter:c,destroy:()=>{l?.(),c.destroy(),s?.()}}}return{iframe:o,adapter:null,destroy:()=>{l?.(),s?.()}}}var b="sidebarContainer",B="markupai-sidebar-host-shell-styles";function x(e){if(typeof CSS<"u"&&typeof CSS.escape=="function")return CSS.escape(e);if(!/^[a-zA-Z_][\w-]*$/.test(e))throw new Error(String.raw`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=x(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 ye=S();function Ae(e){return e instanceof Document?e:e.ownerDocument}function ve(e,t,i){if(!t||e.getElementById(B))return;const r=e.createElement("style");r.id=B,r.textContent=S(i),e.head.appendChild(r)}function Ce(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 a=Ae(t);ve(a,r,i);const o=t instanceof Document?a.getElementById(i):t.querySelector(`#${x(i)}`);if(o instanceof HTMLElement&&(t instanceof Document||t.contains(o)))return o;if(!(t instanceof Document)){const l=a.createElement("div");return l.id=i,t.appendChild(l),l}const s=a.createElement("div");return s.id=i,a.body.appendChild(s),s}function F(){return' <meta name="viewport" content="width=device-width, initial-scale=1.0" />'}function be(e){const{title:t="Markup AI Sidebar",headInnerHtml:i="",includePluginHostHead:r=!1,bodyScriptsHtml:a,htmlLang:o="en",htmlAttrs:s=`lang="${o}" style="height:100%"`,bodyAttrs:l='style="height:100%;margin:0"'}=e,c=[r?F():"",i].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>${Se(t)}</title>${c?`
|
|
143
143
|
${c}`:""}
|
|
144
144
|
</head>
|
|
145
145
|
<body ${l}>
|
|
146
|
-
${
|
|
146
|
+
${a}
|
|
147
147
|
</body>
|
|
148
148
|
</html>
|
|
149
|
-
`}function
|
|
149
|
+
`}function Se(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}n.AUTH_CONFIG_OVERRIDE_STORAGE_KEY=U,n.DEFAULT_IPC_CONFIG=O,n.DEFAULT_SIDEBAR_CONFIG=X,n.DeferredPromise=T,n.IPCCore=C,n.MimeType=g,n.PluginAdapter=re,n.PluginIPCAdapter=D,n.SIDEBAR_DEFAULT_PRODUCTION_BASE_URL=ge,n.SIDEBAR_HOST_CONTAINER_ID=b,n.SIDEBAR_HOST_SHELL_CSS=ye,n.SIDEBAR_IFRAME_DEFAULT_ALLOW=H,n.SIDEBAR_IFRAME_DEFAULT_TITLE=N,n.SIDEBAR_URL_OVERRIDE_STORAGE_KEY=de,n.SidebarAdapter=L,n.SidebarIPCAdapter=_,n.TEXT_MIME_TYPES=K,n.TextLookupError=A,n.assertSidebarHostAdapter=fe,n.buildDocumentReference=te,n.buildSidebarHostHtmlDocument=be,n.buildSidebarHostShellCss=S,n.buildSidebarPluginHostHeadInnerHtml=F,n.createSidebarHost=me,n.ensureSidebarHostShell=Ce,n.getAuthConfigWithOverride=ue,n.getSidebarBaseUrlWithOverride=pe,n.ipcErrorReconstructors=v,n.isDocumentReference=ee,n.isIntegrationSettingField=Z,n.isIntegrationSettingsSchema=q,n.isTextLookupError=Q,n.reconstructError=E,n.setupSidebarLoadOverlay=k,n.sidebarPostMessageTargetOrigin=he});
|
package/dist/types/common.d.ts
CHANGED
|
@@ -38,8 +38,16 @@ export type ContentReplacement = {
|
|
|
38
38
|
* Content information including the content, document reference, optional document name, and optional mime type
|
|
39
39
|
* The integration must provide content and documentReference - documentName and mimeType are optional
|
|
40
40
|
*
|
|
41
|
-
* - documentReference: A unique identifier for the document
|
|
42
|
-
*
|
|
41
|
+
* - documentReference: A unique identifier for the document, used to track it across scans.
|
|
42
|
+
* Compose it with `buildDocumentReference(prefix, id)`: you pick a prefix naming your
|
|
43
|
+
* platform and supply an id that is stable for the document. The `<prefix>:<id>` format is
|
|
44
|
+
* shared with every other Markup surface, so the same document correlates across products,
|
|
45
|
+
* and the Markup session id's document component is derived from it.
|
|
46
|
+
*
|
|
47
|
+
* Choose the prefix once and never change it — it is part of the document's identity, and
|
|
48
|
+
* changing it re-keys every document you have checked. Use the same reference for a whole
|
|
49
|
+
* document and for a selection within it. A bare, unprefixed value is still accepted and
|
|
50
|
+
* behaves as before; it simply cannot be correlated with the same document seen elsewhere.
|
|
43
51
|
* - documentName: A human-readable name/title for the document (e.g., "My Report.docx").
|
|
44
52
|
* Optional; when absent, the sidebar will attempt to derive it from documentReference if it
|
|
45
53
|
* contains a filename with extension.
|
|
@@ -152,6 +160,20 @@ export interface SidebarConfig {
|
|
|
152
160
|
* If false, the selection toggle UI will be hidden and checkSelectionEnabled will be forced to false
|
|
153
161
|
*/
|
|
154
162
|
supportCheckSelection?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Whether the sidebar may run several agents concurrently in one check.
|
|
165
|
+
*
|
|
166
|
+
* When `false` or omitted (the default), only the Style agent is offered and
|
|
167
|
+
* run, and a check is dispatched as a single-agent run. When `true`, the
|
|
168
|
+
* sidebar offers every agent the organization is entitled to and fans the
|
|
169
|
+
* selected ones out through the parallel executor, streaming results per
|
|
170
|
+
* agent; each agent can then be cancelled independently of the others.
|
|
171
|
+
*
|
|
172
|
+
* The host flag and the organization's entitlement **intersect**: enabling
|
|
173
|
+
* this never grants access to an agent the organization does not have, and an
|
|
174
|
+
* entitled agent is never offered while this is `false`.
|
|
175
|
+
*/
|
|
176
|
+
multiAgent?: boolean;
|
|
155
177
|
/**
|
|
156
178
|
* How the sidebar should run the Auth0 login flow. When omitted, the sidebar
|
|
157
179
|
* falls back to heuristic strategy selection (iframe context, secure origin,
|
|
@@ -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
|
|
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;;;;;;;;;;;;;;;;;;GAkBG;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,GAAG;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAChD,MAAM,MAAM,UAAU,GAAG,mBAAmB,GAAG,eAAe,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,yBAAyB,CAAC;CACjD;AAED,eAAO,MAAM,sBAAsB,EAAE,aASpC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;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,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"}
|