@markupai/sidebar-adapter 1.3.3 → 1.5.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 +170 -17
- package/asyncapi.json +125 -20
- package/dist/adapters/pluginAdapter.d.ts +4 -4
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/adapters/sidebarAdapter.d.ts +12 -1
- package/dist/adapters/sidebarAdapter.d.ts.map +1 -1
- 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/ipc/call-signatures.d.ts +30 -6
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/plugin-ipc-adapter.d.ts +4 -4
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts +12 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/main.js +225 -197
- package/dist/main.umd.cjs +7 -7
- package/dist/types/common.d.ts +54 -2
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +21 -6
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/dist/types/sidebarInterface.d.ts +22 -1
- package/dist/types/sidebarInterface.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,41 +1,55 @@
|
|
|
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
|
+
multiDocument: !1
|
|
18
|
+
}, ce = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), de = (e) => {
|
|
17
19
|
if (typeof e != "object" || e === null) return !1;
|
|
18
20
|
const t = e;
|
|
19
21
|
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) => {
|
|
20
22
|
if (typeof i != "object" || i === null) return !1;
|
|
21
|
-
const
|
|
22
|
-
return typeof
|
|
23
|
+
const n = i;
|
|
24
|
+
return typeof n.value == "string" && typeof n.label == "string";
|
|
23
25
|
}) : !1;
|
|
24
|
-
},
|
|
26
|
+
}, O = class T extends Error {
|
|
25
27
|
name = "TextLookupError";
|
|
26
28
|
constructor(t) {
|
|
27
|
-
super(t), Object.setPrototypeOf(this,
|
|
29
|
+
super(t), Object.setPrototypeOf(this, T.prototype);
|
|
28
30
|
}
|
|
29
31
|
};
|
|
30
|
-
function
|
|
31
|
-
return e instanceof
|
|
32
|
+
function ge(e) {
|
|
33
|
+
return e instanceof O;
|
|
32
34
|
}
|
|
33
|
-
var P = { TextLookupError: (e) => new
|
|
34
|
-
function
|
|
35
|
-
const t = e.message ?? "", i = e.name,
|
|
36
|
-
return
|
|
35
|
+
var P = { TextLookupError: (e) => new O(e) };
|
|
36
|
+
function U(e) {
|
|
37
|
+
const t = e.message ?? "", i = e.name, n = typeof i == "string" && i in P ? P[i] : void 0;
|
|
38
|
+
return n ? n(t, e) : Object.assign(new Error(t), i ? { name: i } : {});
|
|
37
39
|
}
|
|
38
|
-
var
|
|
40
|
+
var D = ":", x = /^[a-z][a-z0-9-]*$/;
|
|
41
|
+
function pe(e) {
|
|
42
|
+
const t = e.indexOf(D);
|
|
43
|
+
return t <= 0 || t === e.length - 1 ? !1 : x.test(e.slice(0, t));
|
|
44
|
+
}
|
|
45
|
+
function ue(e, t) {
|
|
46
|
+
const i = e.trim().toLowerCase(), n = t.trim();
|
|
47
|
+
if (!x.test(i)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
|
|
48
|
+
if (n.length === 0) throw new Error("Invalid document reference: the document id is empty.");
|
|
49
|
+
const r = `${i}${D}`;
|
|
50
|
+
return n.startsWith(r) ? n : `${r}${n}`;
|
|
51
|
+
}
|
|
52
|
+
var H = class extends Promise {
|
|
39
53
|
static get [Symbol.species]() {
|
|
40
54
|
return Promise;
|
|
41
55
|
}
|
|
@@ -44,19 +58,19 @@ var B = class extends Promise {
|
|
|
44
58
|
constructor(e = () => {
|
|
45
59
|
}) {
|
|
46
60
|
let t, i;
|
|
47
|
-
super((
|
|
48
|
-
t =
|
|
61
|
+
super((n, r) => {
|
|
62
|
+
t = n, i = r, e(n, r);
|
|
49
63
|
}), this.resolve = t, this.reject = i;
|
|
50
64
|
}
|
|
51
|
-
},
|
|
52
|
-
function
|
|
65
|
+
}, $ = { timeout: 1e4 };
|
|
66
|
+
function j(e) {
|
|
53
67
|
const t = JSON.stringify(e, Object.getOwnPropertyNames(e)), i = JSON.parse(t);
|
|
54
68
|
return i.message === void 0 || i.message === "" ? JSON.stringify({
|
|
55
69
|
message: e instanceof Error ? e.message : String(e),
|
|
56
70
|
name: e instanceof Error ? e.name : void 0
|
|
57
71
|
}) : t;
|
|
58
72
|
}
|
|
59
|
-
var
|
|
73
|
+
var L = class {
|
|
60
74
|
promisesByID = {};
|
|
61
75
|
receiversByName = {};
|
|
62
76
|
currentID = 0;
|
|
@@ -64,7 +78,7 @@ var D = class {
|
|
|
64
78
|
postMessage;
|
|
65
79
|
constructor(e, t) {
|
|
66
80
|
this.postMessage = e, this.config = {
|
|
67
|
-
|
|
81
|
+
...$,
|
|
68
82
|
...t
|
|
69
83
|
};
|
|
70
84
|
}
|
|
@@ -78,23 +92,23 @@ var D = class {
|
|
|
78
92
|
return this.callWithOptions(e, {}, ...t);
|
|
79
93
|
}
|
|
80
94
|
callWithOptions(e, t, ...i) {
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(
|
|
84
|
-
|
|
95
|
+
const n = this.currentID++, r = new H(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
96
|
+
if (n in this.promisesByID) {
|
|
97
|
+
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);
|
|
98
|
+
r.reject(l), Reflect.deleteProperty(this.promisesByID, n);
|
|
85
99
|
}
|
|
86
|
-
},
|
|
87
|
-
this.promisesByID[
|
|
88
|
-
promise:
|
|
100
|
+
}, a);
|
|
101
|
+
this.promisesByID[n] = {
|
|
102
|
+
promise: r,
|
|
89
103
|
timeoutId: o
|
|
90
104
|
};
|
|
91
105
|
const s = {
|
|
92
106
|
type: "call",
|
|
93
|
-
id:
|
|
107
|
+
id: n,
|
|
94
108
|
name: e,
|
|
95
109
|
data: i
|
|
96
110
|
};
|
|
97
|
-
return this.postMessage(s),
|
|
111
|
+
return this.postMessage(s), r;
|
|
98
112
|
}
|
|
99
113
|
receive(e, t) {
|
|
100
114
|
this.receiversByName[e] = t;
|
|
@@ -117,11 +131,11 @@ var D = class {
|
|
|
117
131
|
}
|
|
118
132
|
}
|
|
119
133
|
async handleCall(e) {
|
|
120
|
-
const { id: t, name: i, data:
|
|
134
|
+
const { id: t, name: i, data: n } = e;
|
|
121
135
|
if (!(i in this.receiversByName)) {
|
|
122
|
-
const
|
|
123
|
-
message:
|
|
124
|
-
name:
|
|
136
|
+
const a = /* @__PURE__ */ new Error(`No receiver registered for: ${i}`), o = JSON.stringify({
|
|
137
|
+
message: a.message,
|
|
138
|
+
name: a.name
|
|
125
139
|
});
|
|
126
140
|
this.postMessage({
|
|
127
141
|
type: "error",
|
|
@@ -131,22 +145,22 @@ var D = class {
|
|
|
131
145
|
});
|
|
132
146
|
return;
|
|
133
147
|
}
|
|
134
|
-
const
|
|
148
|
+
const r = this.receiversByName[i];
|
|
135
149
|
try {
|
|
136
|
-
if (!Array.isArray(
|
|
137
|
-
const
|
|
150
|
+
if (!Array.isArray(n)) throw new TypeError(`IPC: Expected array of arguments but got ${typeof n}`);
|
|
151
|
+
const a = await r(...n), o = {
|
|
138
152
|
type: "response",
|
|
139
153
|
id: t,
|
|
140
154
|
name: i,
|
|
141
|
-
data:
|
|
155
|
+
data: a
|
|
142
156
|
};
|
|
143
157
|
this.postMessage(o);
|
|
144
|
-
} catch (
|
|
158
|
+
} catch (a) {
|
|
145
159
|
const o = {
|
|
146
160
|
type: "error",
|
|
147
161
|
id: t,
|
|
148
162
|
name: i,
|
|
149
|
-
errorJSON:
|
|
163
|
+
errorJSON: j(a)
|
|
150
164
|
};
|
|
151
165
|
this.postMessage(o);
|
|
152
166
|
}
|
|
@@ -154,20 +168,20 @@ var D = class {
|
|
|
154
168
|
handleResponse(e) {
|
|
155
169
|
const { id: t } = e;
|
|
156
170
|
if (t in this.promisesByID) {
|
|
157
|
-
const { promise: i, timeoutId:
|
|
158
|
-
clearTimeout(
|
|
171
|
+
const { promise: i, timeoutId: n } = this.promisesByID[t];
|
|
172
|
+
clearTimeout(n), i.resolve(e.data), Reflect.deleteProperty(this.promisesByID, t);
|
|
159
173
|
}
|
|
160
174
|
}
|
|
161
175
|
handleError(e) {
|
|
162
176
|
const { id: t, errorJSON: i } = e;
|
|
163
177
|
if (t in this.promisesByID) {
|
|
164
|
-
const { promise:
|
|
165
|
-
clearTimeout(
|
|
178
|
+
const { promise: n, timeoutId: r } = this.promisesByID[t];
|
|
179
|
+
clearTimeout(r);
|
|
166
180
|
try {
|
|
167
|
-
const
|
|
168
|
-
|
|
181
|
+
const a = U(JSON.parse(i));
|
|
182
|
+
n.reject(a);
|
|
169
183
|
} catch {
|
|
170
|
-
|
|
184
|
+
n.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
171
185
|
}
|
|
172
186
|
Reflect.deleteProperty(this.promisesByID, t);
|
|
173
187
|
}
|
|
@@ -177,13 +191,13 @@ var D = class {
|
|
|
177
191
|
clearTimeout(t), e.reject(/* @__PURE__ */ new Error("IPC destroyed"));
|
|
178
192
|
this.promisesByID = {}, this.receiversByName = {};
|
|
179
193
|
}
|
|
180
|
-
},
|
|
194
|
+
}, F = class {
|
|
181
195
|
ipc;
|
|
182
196
|
sidebar;
|
|
183
197
|
targetOrigin;
|
|
184
198
|
constructor(e, t, i = "*") {
|
|
185
|
-
this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new
|
|
186
|
-
window.parent.postMessage(
|
|
199
|
+
this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new L((n) => {
|
|
200
|
+
window.parent.postMessage(n, this.targetOrigin);
|
|
187
201
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
188
202
|
}
|
|
189
203
|
handleMessage = (e) => {
|
|
@@ -199,8 +213,8 @@ var D = class {
|
|
|
199
213
|
}
|
|
200
214
|
if (this.sidebar.activateAgenticIssue) {
|
|
201
215
|
const e = this.sidebar.activateAgenticIssue;
|
|
202
|
-
this.ipc.receive("activateAgenticIssue", async (t) => {
|
|
203
|
-
await e(t);
|
|
216
|
+
this.ipc.receive("activateAgenticIssue", async (t, i) => {
|
|
217
|
+
await e(t, typeof i == "string" ? i : null);
|
|
204
218
|
});
|
|
205
219
|
}
|
|
206
220
|
if (this.sidebar.invalidateAgenticIssue) {
|
|
@@ -231,6 +245,12 @@ var D = class {
|
|
|
231
245
|
const e = this.sidebar.getIntegrationSettings;
|
|
232
246
|
this.ipc.receive("getIntegrationSettings", async () => await e());
|
|
233
247
|
}
|
|
248
|
+
if (this.sidebar.onActiveDocumentChanged) {
|
|
249
|
+
const e = this.sidebar.onActiveDocumentChanged;
|
|
250
|
+
this.ipc.receive("onActiveDocumentChanged", async (t) => {
|
|
251
|
+
await e(t);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
234
254
|
}
|
|
235
255
|
async getInitConfig() {
|
|
236
256
|
return await this.ipc.call("getInitConfig");
|
|
@@ -241,14 +261,14 @@ var D = class {
|
|
|
241
261
|
async getSelectedContent(e) {
|
|
242
262
|
return this.ipc.callWithOptions("getSelectedContent", e ?? {});
|
|
243
263
|
}
|
|
244
|
-
async replaceContent(e, t) {
|
|
245
|
-
await this.ipc.call("replaceContent", e, t);
|
|
264
|
+
async replaceContent(e, t, i = null) {
|
|
265
|
+
await this.ipc.call("replaceContent", e, t, i);
|
|
246
266
|
}
|
|
247
|
-
async selectContent(e) {
|
|
248
|
-
await this.ipc.call("selectContent", e);
|
|
267
|
+
async selectContent(e, t = null) {
|
|
268
|
+
await this.ipc.call("selectContent", e, t);
|
|
249
269
|
}
|
|
250
|
-
async showDialog(e, t, i,
|
|
251
|
-
await this.ipc.call("showDialog", e, t, i,
|
|
270
|
+
async showDialog(e, t, i, n) {
|
|
271
|
+
await this.ipc.call("showDialog", e, t, i, n);
|
|
252
272
|
}
|
|
253
273
|
async closeDialog() {
|
|
254
274
|
await this.ipc.call("closeDialog");
|
|
@@ -256,11 +276,11 @@ var D = class {
|
|
|
256
276
|
async replaceMultipleContents(e) {
|
|
257
277
|
await this.ipc.call("replaceMultipleContents", e);
|
|
258
278
|
}
|
|
259
|
-
async onAgenticAgentResults(e, t) {
|
|
260
|
-
await this.ipc.call("onAgenticAgentResults", e, t);
|
|
279
|
+
async onAgenticAgentResults(e, t, i = null) {
|
|
280
|
+
await this.ipc.call("onAgenticAgentResults", e, t, i);
|
|
261
281
|
}
|
|
262
|
-
async onAgenticStreamComplete() {
|
|
263
|
-
await this.ipc.call("onAgenticStreamComplete");
|
|
282
|
+
async onAgenticStreamComplete(e = null) {
|
|
283
|
+
await this.ipc.call("onAgenticStreamComplete", e);
|
|
264
284
|
}
|
|
265
285
|
async onAgenticIssueStatusChanged(e, t, i) {
|
|
266
286
|
await this.ipc.call("onAgenticIssueStatusChanged", e, t, i);
|
|
@@ -293,10 +313,10 @@ var D = class {
|
|
|
293
313
|
destroy() {
|
|
294
314
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
295
315
|
}
|
|
296
|
-
},
|
|
316
|
+
}, he = class {
|
|
297
317
|
ipcAdapter;
|
|
298
318
|
constructor(e, t, i) {
|
|
299
|
-
this.ipcAdapter = new
|
|
319
|
+
this.ipcAdapter = new F(e, t, i);
|
|
300
320
|
}
|
|
301
321
|
destroy() {
|
|
302
322
|
this.ipcAdapter.destroy();
|
|
@@ -310,14 +330,14 @@ var D = class {
|
|
|
310
330
|
async getSelectedContent(e) {
|
|
311
331
|
return await this.ipcAdapter.getSelectedContent(e);
|
|
312
332
|
}
|
|
313
|
-
async replaceContent(e, t) {
|
|
314
|
-
await this.ipcAdapter.replaceContent(e, t);
|
|
333
|
+
async replaceContent(e, t, i = null) {
|
|
334
|
+
await this.ipcAdapter.replaceContent(e, t, i);
|
|
315
335
|
}
|
|
316
|
-
async selectContent(e) {
|
|
317
|
-
await this.ipcAdapter.selectContent(e);
|
|
336
|
+
async selectContent(e, t = null) {
|
|
337
|
+
await this.ipcAdapter.selectContent(e, t);
|
|
318
338
|
}
|
|
319
|
-
async showDialog(e, t, i,
|
|
320
|
-
await this.ipcAdapter.showDialog(e, t, i,
|
|
339
|
+
async showDialog(e, t, i, n) {
|
|
340
|
+
await this.ipcAdapter.showDialog(e, t, i, n);
|
|
321
341
|
}
|
|
322
342
|
async closeDialog() {
|
|
323
343
|
await this.ipcAdapter.closeDialog();
|
|
@@ -325,11 +345,11 @@ var D = class {
|
|
|
325
345
|
async replaceMultipleContents(e) {
|
|
326
346
|
await this.ipcAdapter.replaceMultipleContents(e);
|
|
327
347
|
}
|
|
328
|
-
onAgenticAgentResults(e, t) {
|
|
329
|
-
return this.ipcAdapter.onAgenticAgentResults(e, t);
|
|
348
|
+
onAgenticAgentResults(e, t, i = null) {
|
|
349
|
+
return this.ipcAdapter.onAgenticAgentResults(e, t, i);
|
|
330
350
|
}
|
|
331
|
-
onAgenticStreamComplete() {
|
|
332
|
-
return this.ipcAdapter.onAgenticStreamComplete();
|
|
351
|
+
onAgenticStreamComplete(e = null) {
|
|
352
|
+
return this.ipcAdapter.onAgenticStreamComplete(e);
|
|
333
353
|
}
|
|
334
354
|
onAgenticIssueStatusChanged(e, t, i) {
|
|
335
355
|
return this.ipcAdapter.onAgenticIssueStatusChanged(e, t, i);
|
|
@@ -352,47 +372,47 @@ var D = class {
|
|
|
352
372
|
getTargetOrigin() {
|
|
353
373
|
return this.ipcAdapter.getTargetOrigin();
|
|
354
374
|
}
|
|
355
|
-
},
|
|
375
|
+
}, z = class {
|
|
356
376
|
ipc;
|
|
357
377
|
plugin;
|
|
358
378
|
iframe;
|
|
359
379
|
window;
|
|
360
380
|
targetOrigin;
|
|
361
|
-
constructor(e, t, i,
|
|
362
|
-
this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin =
|
|
363
|
-
this.iframe.contentWindow?.postMessage(
|
|
364
|
-
},
|
|
381
|
+
constructor(e, t, i, n, r = "*") {
|
|
382
|
+
this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin = r, this.ipc = new L((a) => {
|
|
383
|
+
this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
|
|
384
|
+
}, n), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
365
385
|
}
|
|
366
386
|
handleMessage = (e) => {
|
|
367
387
|
const t = this.window.location.origin, i = this.targetOrigin;
|
|
368
388
|
e.origin !== t && (i !== "*" && e.origin !== i || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
369
389
|
};
|
|
370
390
|
registerReceivers() {
|
|
371
|
-
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) => {
|
|
372
|
-
await this.plugin.replaceContent(e, t);
|
|
373
|
-
}), this.ipc.receive("selectContent", async (e) => {
|
|
374
|
-
await this.plugin.selectContent(e);
|
|
375
|
-
}), this.ipc.receive("showDialog", async (e, t, i,
|
|
391
|
+
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, i) => {
|
|
392
|
+
await this.plugin.replaceContent(e, t, typeof i == "string" ? i : null);
|
|
393
|
+
}), this.ipc.receive("selectContent", async (e, t) => {
|
|
394
|
+
await this.plugin.selectContent(e, typeof t == "string" ? t : null);
|
|
395
|
+
}), this.ipc.receive("showDialog", async (e, t, i, n) => {
|
|
376
396
|
if (!this.plugin.showDialog) throw new Error("SidebarIPCAdapter: host does not implement showDialog");
|
|
377
|
-
await this.plugin.showDialog(e, t, i,
|
|
397
|
+
await this.plugin.showDialog(e, t, i, n);
|
|
378
398
|
}), this.ipc.receive("closeDialog", async () => {
|
|
379
399
|
if (!this.plugin.closeDialog) throw new Error("SidebarIPCAdapter: host does not implement closeDialog");
|
|
380
400
|
await this.plugin.closeDialog();
|
|
381
401
|
}), this.ipc.receive("replaceMultipleContents", async (e) => {
|
|
382
402
|
await this.plugin.replaceMultipleContents(e);
|
|
383
|
-
}), this.ipc.receive("onAgenticAgentResults", async (e, t) => {
|
|
403
|
+
}), this.ipc.receive("onAgenticAgentResults", async (e, t, i) => {
|
|
384
404
|
if (!Array.isArray(t))
|
|
385
405
|
return;
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
}), this.ipc.receive("onAgenticStreamComplete", async () => {
|
|
389
|
-
const
|
|
390
|
-
|
|
406
|
+
const n = this.plugin.onAgenticAgentResults;
|
|
407
|
+
n && await n(e, t, typeof i == "string" ? i : null);
|
|
408
|
+
}), this.ipc.receive("onAgenticStreamComplete", async (e) => {
|
|
409
|
+
const t = this.plugin.onAgenticStreamComplete;
|
|
410
|
+
t && await t(typeof e == "string" ? e : null);
|
|
391
411
|
}), this.ipc.receive("onAgenticIssueStatusChanged", async (e, t, i) => {
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
412
|
+
const n = this.plugin.onAgenticIssueStatusChanged;
|
|
413
|
+
if (n && !(t !== "active" && t !== "resolved" && t !== "dismissed" || i !== "user" && i !== "host"))
|
|
394
414
|
try {
|
|
395
|
-
await
|
|
415
|
+
await n(e, t, i);
|
|
396
416
|
} catch {
|
|
397
417
|
}
|
|
398
418
|
}), this.plugin.openAuthUrl) {
|
|
@@ -414,8 +434,8 @@ var D = class {
|
|
|
414
434
|
});
|
|
415
435
|
}
|
|
416
436
|
}
|
|
417
|
-
async activateAgenticIssue(e) {
|
|
418
|
-
await this.ipc.call("activateAgenticIssue", e);
|
|
437
|
+
async activateAgenticIssue(e, t = null) {
|
|
438
|
+
await this.ipc.call("activateAgenticIssue", e, t);
|
|
419
439
|
}
|
|
420
440
|
async invalidateAgenticIssue(e) {
|
|
421
441
|
await this.ipc.call("invalidateAgenticIssue", e);
|
|
@@ -435,16 +455,19 @@ var D = class {
|
|
|
435
455
|
async getIntegrationSettings() {
|
|
436
456
|
return await this.ipc.call("getIntegrationSettings");
|
|
437
457
|
}
|
|
458
|
+
async notifyActiveDocumentChanged(e) {
|
|
459
|
+
await this.ipc.call("onActiveDocumentChanged", e);
|
|
460
|
+
}
|
|
438
461
|
configure(e) {
|
|
439
462
|
this.ipc.configure(e);
|
|
440
463
|
}
|
|
441
464
|
destroy() {
|
|
442
465
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
443
466
|
}
|
|
444
|
-
},
|
|
467
|
+
}, W = class {
|
|
445
468
|
ipcAdapter;
|
|
446
469
|
constructor(e, t, i) {
|
|
447
|
-
this.ipcAdapter = new
|
|
470
|
+
this.ipcAdapter = new z(e, t, i?.win, i?.config, i?.targetOrigin);
|
|
448
471
|
}
|
|
449
472
|
destroy() {
|
|
450
473
|
this.ipcAdapter.destroy();
|
|
@@ -452,8 +475,8 @@ var D = class {
|
|
|
452
475
|
async notifyPluginStatus(e, t) {
|
|
453
476
|
await this.ipcAdapter.notifyPluginStatus(e, t);
|
|
454
477
|
}
|
|
455
|
-
async activateAgenticIssue(e) {
|
|
456
|
-
await this.ipcAdapter.activateAgenticIssue(e);
|
|
478
|
+
async activateAgenticIssue(e, t = null) {
|
|
479
|
+
await this.ipcAdapter.activateAgenticIssue(e, t);
|
|
457
480
|
}
|
|
458
481
|
async invalidateAgenticIssue(e) {
|
|
459
482
|
await this.ipcAdapter.invalidateAgenticIssue(e);
|
|
@@ -470,10 +493,13 @@ var D = class {
|
|
|
470
493
|
async getIntegrationSettings() {
|
|
471
494
|
return await this.ipcAdapter.getIntegrationSettings();
|
|
472
495
|
}
|
|
496
|
+
async notifyActiveDocumentChanged(e) {
|
|
497
|
+
await this.ipcAdapter.notifyActiveDocumentChanged(e);
|
|
498
|
+
}
|
|
473
499
|
configure(e) {
|
|
474
500
|
this.ipcAdapter.configure(e);
|
|
475
501
|
}
|
|
476
|
-
},
|
|
502
|
+
}, G = `
|
|
477
503
|
<div class="sidebar-load-overlay-card">
|
|
478
504
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
479
505
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -494,16 +520,16 @@ var D = class {
|
|
|
494
520
|
<span>Retry</span>
|
|
495
521
|
</button>
|
|
496
522
|
</div>
|
|
497
|
-
`,
|
|
523
|
+
`, J = () => {
|
|
498
524
|
const e = document.createElement("div");
|
|
499
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
525
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = G;
|
|
500
526
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
501
527
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
502
528
|
return {
|
|
503
529
|
overlay: e,
|
|
504
530
|
button: t
|
|
505
531
|
};
|
|
506
|
-
}, E = "markupai-sidebar-load-overlay-styles",
|
|
532
|
+
}, E = "markupai-sidebar-load-overlay-styles", Y = `
|
|
507
533
|
:root {
|
|
508
534
|
--background: #f5f5f4;
|
|
509
535
|
--foreground: #333332;
|
|
@@ -595,37 +621,37 @@ var D = class {
|
|
|
595
621
|
box-shadow: 0 0 0 2px
|
|
596
622
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
597
623
|
}
|
|
598
|
-
`,
|
|
624
|
+
`, V = (e) => {
|
|
599
625
|
const t = e ?? document;
|
|
600
626
|
if (t.getElementById(E)) return;
|
|
601
627
|
const i = t.createElement("style");
|
|
602
|
-
i.id = E, i.textContent =
|
|
603
|
-
},
|
|
604
|
-
|
|
605
|
-
const { sidebarUrl:
|
|
606
|
-
if (
|
|
628
|
+
i.id = E, i.textContent = Y, t.head.appendChild(i);
|
|
629
|
+
}, X = 8e3, K = 12e3, q = (e, t, i = {}) => {
|
|
630
|
+
V(e.ownerDocument);
|
|
631
|
+
const { sidebarUrl: n, targetOrigin: r, timeoutMs: a = X, retryIntervalMs: o = K, messageListenWindow: s } = i, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => n ?? t.src, N = () => {
|
|
632
|
+
if (r) return r;
|
|
607
633
|
try {
|
|
608
634
|
return new URL(p()).origin;
|
|
609
635
|
} catch {
|
|
610
636
|
return "*";
|
|
611
637
|
}
|
|
612
|
-
}, { overlay:
|
|
613
|
-
e.appendChild(
|
|
638
|
+
}, { overlay: y, button: v } = J();
|
|
639
|
+
e.appendChild(y);
|
|
614
640
|
let u = !1, h, d;
|
|
615
641
|
const g = (c) => {
|
|
616
|
-
|
|
642
|
+
y.style.display = c ? "flex" : "none";
|
|
617
643
|
};
|
|
618
644
|
g(!1);
|
|
619
645
|
const f = () => {
|
|
620
646
|
h && (globalThis.clearTimeout(h), h = void 0);
|
|
621
|
-
},
|
|
647
|
+
}, I = () => {
|
|
622
648
|
f(), h = globalThis.setTimeout(() => {
|
|
623
649
|
u || g(!0);
|
|
624
|
-
},
|
|
650
|
+
}, a);
|
|
625
651
|
}, A = (c) => {
|
|
626
|
-
const
|
|
627
|
-
u = !1,
|
|
628
|
-
},
|
|
652
|
+
const m = c?.preserveOverlay ?? !0;
|
|
653
|
+
u = !1, m || g(!1), t.src = p(), I();
|
|
654
|
+
}, B = () => {
|
|
629
655
|
d || o <= 0 || (d = globalThis.setInterval(() => {
|
|
630
656
|
u || A({ preserveOverlay: !0 });
|
|
631
657
|
}, o));
|
|
@@ -633,48 +659,48 @@ var D = class {
|
|
|
633
659
|
d && (globalThis.clearInterval(d), d = void 0);
|
|
634
660
|
}, b = (c) => {
|
|
635
661
|
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
636
|
-
const
|
|
637
|
-
|
|
662
|
+
const m = N();
|
|
663
|
+
m !== "*" && c.origin !== m || (u = !0, f(), C(), g(!1));
|
|
638
664
|
}, w = () => {
|
|
639
665
|
f(), g(!0);
|
|
640
666
|
}, S = () => {
|
|
641
667
|
A();
|
|
642
668
|
};
|
|
643
|
-
return
|
|
644
|
-
f(), C(), t.removeEventListener("error", w), l.removeEventListener("message", b),
|
|
669
|
+
return v.addEventListener("click", S), t.addEventListener("error", w), l.addEventListener("message", b), I(), B(), () => {
|
|
670
|
+
f(), C(), t.removeEventListener("error", w), l.removeEventListener("message", b), v.removeEventListener("click", S), y.remove();
|
|
645
671
|
};
|
|
646
|
-
},
|
|
647
|
-
function
|
|
672
|
+
}, Z = "Markup AI Sidebar", Q = "clipboard-read; clipboard-write", fe = "markupai.sidebarNextGen.overrideUrl", me = "https://sidebar.markup.ai/";
|
|
673
|
+
function ye(e) {
|
|
648
674
|
try {
|
|
649
675
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
650
676
|
} catch {
|
|
651
677
|
return e;
|
|
652
678
|
}
|
|
653
679
|
}
|
|
654
|
-
var
|
|
655
|
-
function
|
|
680
|
+
var ee = "markupai.sidebarNextGen.authOverride";
|
|
681
|
+
function ve(e, t) {
|
|
656
682
|
if (!t) return e;
|
|
657
683
|
try {
|
|
658
684
|
if (!("localStorage" in globalThis)) return e;
|
|
659
|
-
const i = globalThis.localStorage.getItem(
|
|
685
|
+
const i = globalThis.localStorage.getItem(ee)?.trim();
|
|
660
686
|
if (!i) return e;
|
|
661
|
-
const
|
|
662
|
-
return
|
|
687
|
+
const n = JSON.parse(i);
|
|
688
|
+
return n !== null && typeof n == "object" && "type" in n && (n.type === "mediation" || n.type === "popup") ? n : e;
|
|
663
689
|
} catch {
|
|
664
690
|
return e;
|
|
665
691
|
}
|
|
666
692
|
}
|
|
667
|
-
function
|
|
693
|
+
function Ie(e, t) {
|
|
668
694
|
try {
|
|
669
695
|
return new URL(e).origin;
|
|
670
696
|
} catch (i) {
|
|
671
697
|
return t?.onInvalidUrl?.(e, i), "*";
|
|
672
698
|
}
|
|
673
699
|
}
|
|
674
|
-
function
|
|
700
|
+
function Ae(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
675
701
|
if (e.adapter === null) throw new Error(t);
|
|
676
702
|
}
|
|
677
|
-
function
|
|
703
|
+
function te(e) {
|
|
678
704
|
const { iframe: t, iframeMount: i } = e;
|
|
679
705
|
if (t !== void 0 && i !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
680
706
|
if (t !== void 0) return {
|
|
@@ -682,20 +708,20 @@ function Q(e) {
|
|
|
682
708
|
removeMountedIframe: null
|
|
683
709
|
};
|
|
684
710
|
if (i === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
685
|
-
const { container:
|
|
686
|
-
return o.title =
|
|
711
|
+
const { container: n, src: r, allow: a = Q } = i, o = document.createElement("iframe");
|
|
712
|
+
return o.title = Z, o.src = r, a && o.setAttribute("allow", a), n.appendChild(o), {
|
|
687
713
|
iframe: o,
|
|
688
714
|
removeMountedIframe: () => {
|
|
689
715
|
o.remove();
|
|
690
716
|
}
|
|
691
717
|
};
|
|
692
718
|
}
|
|
693
|
-
function
|
|
694
|
-
const { plugin: t, loadOverlayContainer: i, loadOverlayOptions:
|
|
719
|
+
function Ce(e) {
|
|
720
|
+
const { plugin: t, loadOverlayContainer: i, loadOverlayOptions: n, adapterOptions: r } = e, { iframe: a, removeMountedIframe: o } = te(e), s = i !== void 0 ? q(i, a, n ?? {}) : null;
|
|
695
721
|
if (t !== void 0) {
|
|
696
|
-
const l = new
|
|
722
|
+
const l = new W(t, a, r);
|
|
697
723
|
return {
|
|
698
|
-
iframe:
|
|
724
|
+
iframe: a,
|
|
699
725
|
adapter: l,
|
|
700
726
|
destroy: () => {
|
|
701
727
|
s?.(), l.destroy(), o?.();
|
|
@@ -703,21 +729,21 @@ function me(e) {
|
|
|
703
729
|
};
|
|
704
730
|
}
|
|
705
731
|
return {
|
|
706
|
-
iframe:
|
|
732
|
+
iframe: a,
|
|
707
733
|
adapter: null,
|
|
708
734
|
destroy: () => {
|
|
709
735
|
s?.(), o?.();
|
|
710
736
|
}
|
|
711
737
|
};
|
|
712
738
|
}
|
|
713
|
-
var
|
|
714
|
-
function
|
|
739
|
+
var M = "sidebarContainer", R = "markupai-sidebar-host-shell-styles";
|
|
740
|
+
function _(e) {
|
|
715
741
|
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_][
|
|
742
|
+
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
743
|
return e;
|
|
718
744
|
}
|
|
719
|
-
function
|
|
720
|
-
const t =
|
|
745
|
+
function k(e = M) {
|
|
746
|
+
const t = _(e);
|
|
721
747
|
return `
|
|
722
748
|
html {
|
|
723
749
|
height: 100%;
|
|
@@ -742,84 +768,86 @@ body {
|
|
|
742
768
|
}
|
|
743
769
|
`.trim();
|
|
744
770
|
}
|
|
745
|
-
var
|
|
746
|
-
function
|
|
771
|
+
var be = k();
|
|
772
|
+
function ie(e) {
|
|
747
773
|
return e instanceof Document ? e : e.ownerDocument;
|
|
748
774
|
}
|
|
749
|
-
function
|
|
775
|
+
function ne(e, t, i) {
|
|
750
776
|
if (!t || e.getElementById(R)) return;
|
|
751
|
-
const
|
|
752
|
-
|
|
777
|
+
const n = e.createElement("style");
|
|
778
|
+
n.id = R, n.textContent = k(i), e.head.appendChild(n);
|
|
753
779
|
}
|
|
754
|
-
function
|
|
755
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId: i =
|
|
780
|
+
function we(e) {
|
|
781
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: i = M, includeDefaultStyles: n = !0 } = e ?? {};
|
|
756
782
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
const
|
|
760
|
-
if (
|
|
783
|
+
const r = ie(t);
|
|
784
|
+
ne(r, n, i);
|
|
785
|
+
const a = t instanceof Document ? r.getElementById(i) : t.querySelector(`#${_(i)}`);
|
|
786
|
+
if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
|
|
761
787
|
if (!(t instanceof Document)) {
|
|
762
|
-
const s =
|
|
788
|
+
const s = r.createElement("div");
|
|
763
789
|
return s.id = i, t.appendChild(s), s;
|
|
764
790
|
}
|
|
765
|
-
const o =
|
|
766
|
-
return o.id = i,
|
|
791
|
+
const o = r.createElement("div");
|
|
792
|
+
return o.id = i, r.body.appendChild(o), o;
|
|
767
793
|
}
|
|
768
|
-
function
|
|
794
|
+
function re() {
|
|
769
795
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
770
796
|
}
|
|
771
|
-
function
|
|
772
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml: i = "", includePluginHostHead:
|
|
797
|
+
function Se(e) {
|
|
798
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: i = "", includePluginHostHead: n = !1, bodyScriptsHtml: r, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [n ? re() : "", i].filter((p) => p.trim().length > 0).join(`
|
|
773
799
|
`);
|
|
774
800
|
return `<!DOCTYPE html>
|
|
775
801
|
<html ${o}>
|
|
776
802
|
<head>
|
|
777
803
|
<base target="_top" />
|
|
778
804
|
<meta charset="UTF-8" />
|
|
779
|
-
<title>${
|
|
805
|
+
<title>${ae(t)}</title>${l ? `
|
|
780
806
|
${l}` : ""}
|
|
781
807
|
</head>
|
|
782
808
|
<body ${s}>
|
|
783
|
-
${
|
|
809
|
+
${r}
|
|
784
810
|
</body>
|
|
785
811
|
</html>
|
|
786
812
|
`;
|
|
787
813
|
}
|
|
788
|
-
function
|
|
814
|
+
function ae(e) {
|
|
789
815
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
790
816
|
}
|
|
791
817
|
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
|
-
|
|
818
|
+
ee as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
819
|
+
$ as DEFAULT_IPC_CONFIG,
|
|
820
|
+
le as DEFAULT_SIDEBAR_CONFIG,
|
|
821
|
+
H as DeferredPromise,
|
|
822
|
+
L as IPCCore,
|
|
823
|
+
oe as MimeType,
|
|
824
|
+
he as PluginAdapter,
|
|
825
|
+
F as PluginIPCAdapter,
|
|
826
|
+
me as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
827
|
+
M as SIDEBAR_HOST_CONTAINER_ID,
|
|
828
|
+
be as SIDEBAR_HOST_SHELL_CSS,
|
|
829
|
+
Q as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
830
|
+
Z as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
831
|
+
fe as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
832
|
+
W as SidebarAdapter,
|
|
833
|
+
z as SidebarIPCAdapter,
|
|
834
|
+
se as TEXT_MIME_TYPES,
|
|
835
|
+
O as TextLookupError,
|
|
836
|
+
Ae as assertSidebarHostAdapter,
|
|
837
|
+
ue as buildDocumentReference,
|
|
838
|
+
Se as buildSidebarHostHtmlDocument,
|
|
839
|
+
k as buildSidebarHostShellCss,
|
|
840
|
+
re as buildSidebarPluginHostHeadInnerHtml,
|
|
841
|
+
Ce as createSidebarHost,
|
|
842
|
+
we as ensureSidebarHostShell,
|
|
843
|
+
ve as getAuthConfigWithOverride,
|
|
844
|
+
ye as getSidebarBaseUrlWithOverride,
|
|
818
845
|
P as ipcErrorReconstructors,
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
ce as
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
846
|
+
pe as isDocumentReference,
|
|
847
|
+
de as isIntegrationSettingField,
|
|
848
|
+
ce as isIntegrationSettingsSchema,
|
|
849
|
+
ge as isTextLookupError,
|
|
850
|
+
U as reconstructError,
|
|
851
|
+
q as setupSidebarLoadOverlay,
|
|
852
|
+
Ie as sidebarPostMessageTargetOrigin
|
|
825
853
|
};
|