@markupai/sidebar-adapter 2.3.0 → 2.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 +56 -4
- package/asyncapi.json +151 -48
- package/dist/adapters/index.d.ts +2 -2
- package/dist/adapters/pluginAdapter.d.ts +10 -2
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/adapters/sidebarAdapter.d.ts +2 -2
- package/dist/adapters/sidebarAdapter.d.ts.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/ipc/call-signatures.d.ts +7 -2
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/deferred-promise.d.ts.map +1 -1
- package/dist/ipc/index.d.ts +8 -8
- package/dist/ipc/ipc-core.d.ts +2 -2
- package/dist/ipc/ipc-core.d.ts.map +1 -1
- package/dist/ipc/plugin-ipc-adapter.d.ts +11 -4
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-build-info.d.ts +1 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts +4 -4
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/load-overlay/loadOverlayStyles.d.ts.map +1 -1
- package/dist/load-overlay/sidebarLoadOverlay.d.ts.map +1 -1
- package/dist/main.js +146 -133
- package/dist/main.umd.cjs +4 -4
- package/dist/sidebar-host/createSidebarHost.d.ts +4 -4
- package/dist/types/common.d.ts +30 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/integrationSettings.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +26 -1
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebarLoadOverlay.d.ts","sourceRoot":"","sources":["../../src/load-overlay/sidebarLoadOverlay.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAKF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"sidebarLoadOverlay.d.ts","sourceRoot":"","sources":["../../src/load-overlay/sidebarLoadOverlay.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAKF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,cACvB,WAAW,UACd,iBAAiB,YAChB,yBAAyB,eAoHnC,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -11,17 +11,18 @@ var fe = /* @__PURE__ */ (function(e) {
|
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
12
12
|
hideBanner: !1,
|
|
13
13
|
supportCheckSelection: !0,
|
|
14
|
+
supportComments: !1,
|
|
14
15
|
multiAgent: !1,
|
|
15
16
|
multiDocument: !1
|
|
16
17
|
}, Ie = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), ve = (e) => {
|
|
17
18
|
if (typeof e != "object" || e === null) return !1;
|
|
18
19
|
const t = e;
|
|
19
|
-
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((
|
|
20
|
-
if (typeof
|
|
21
|
-
const
|
|
22
|
-
return typeof
|
|
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((n) => {
|
|
21
|
+
if (typeof n != "object" || n === null) return !1;
|
|
22
|
+
const r = n;
|
|
23
|
+
return typeof r.value == "string" && typeof r.label == "string";
|
|
23
24
|
}) : !1;
|
|
24
|
-
}, V = "2.
|
|
25
|
+
}, V = "2.4.0", v = class x extends Error {
|
|
25
26
|
name = "TextLookupError";
|
|
26
27
|
constructor(t) {
|
|
27
28
|
super(t), Object.setPrototypeOf(this, x.prototype);
|
|
@@ -30,31 +31,31 @@ var fe = /* @__PURE__ */ (function(e) {
|
|
|
30
31
|
name = "ReplaceBatchError";
|
|
31
32
|
applied;
|
|
32
33
|
failed;
|
|
33
|
-
constructor(t,
|
|
34
|
-
super(t), this.applied =
|
|
35
|
-
start:
|
|
36
|
-
end:
|
|
37
|
-
})), this.failed =
|
|
34
|
+
constructor(t, n) {
|
|
35
|
+
super(t), this.applied = n.applied.map((r) => ({
|
|
36
|
+
start: r.start,
|
|
37
|
+
end: r.end
|
|
38
|
+
})), this.failed = n.failed.map((r) => L(r, r.message)), Object.setPrototypeOf(this, _.prototype);
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
function Ae(e) {
|
|
41
42
|
return e instanceof M;
|
|
42
43
|
}
|
|
43
44
|
function L(e, t) {
|
|
44
|
-
const
|
|
45
|
+
const n = {
|
|
45
46
|
start: e.start,
|
|
46
47
|
end: e.end
|
|
47
48
|
};
|
|
48
|
-
return typeof t == "string" && t.trim() !== "" && (
|
|
49
|
+
return typeof t == "string" && t.trim() !== "" && (n.message = t), n;
|
|
49
50
|
}
|
|
50
51
|
function R(e) {
|
|
51
52
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
52
53
|
if (t === null || typeof t != "object") return [];
|
|
53
|
-
const { start:
|
|
54
|
-
return typeof
|
|
54
|
+
const { start: n, end: r, message: i } = t;
|
|
55
|
+
return typeof n != "number" || typeof r != "number" ? [] : [{
|
|
55
56
|
range: {
|
|
56
|
-
start:
|
|
57
|
-
end:
|
|
57
|
+
start: n,
|
|
58
|
+
end: r
|
|
58
59
|
},
|
|
59
60
|
message: i
|
|
60
61
|
}];
|
|
@@ -66,13 +67,13 @@ function Ce(e) {
|
|
|
66
67
|
var O = {
|
|
67
68
|
TextLookupError: (e) => new v(e),
|
|
68
69
|
ReplaceBatchError: (e, t) => new M(e, {
|
|
69
|
-
applied: R(t.applied).map((
|
|
70
|
-
failed: R(t.failed).map((
|
|
70
|
+
applied: R(t.applied).map((n) => n.range),
|
|
71
|
+
failed: R(t.failed).map((n) => L(n.range, n.message))
|
|
71
72
|
})
|
|
72
73
|
};
|
|
73
74
|
function z(e) {
|
|
74
|
-
const t = e.message ?? "",
|
|
75
|
-
return
|
|
75
|
+
const t = e.message ?? "", n = e.name, r = typeof n == "string" && n in O ? O[n] : void 0;
|
|
76
|
+
return r ? r(t, e) : Object.assign(new Error(t), n ? { name: n } : {});
|
|
76
77
|
}
|
|
77
78
|
var k = ":", B = /^[a-z][a-z0-9-]*$/;
|
|
78
79
|
function be(e) {
|
|
@@ -80,11 +81,11 @@ function be(e) {
|
|
|
80
81
|
return t <= 0 || t === e.length - 1 ? !1 : B.test(e.slice(0, t));
|
|
81
82
|
}
|
|
82
83
|
function Se(e, t) {
|
|
83
|
-
const
|
|
84
|
-
if (!B.test(
|
|
85
|
-
if (
|
|
86
|
-
const i = `${
|
|
87
|
-
return
|
|
84
|
+
const n = e.trim().toLowerCase(), r = t.trim();
|
|
85
|
+
if (!B.test(n)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
|
|
86
|
+
if (r.length === 0) throw new Error("Invalid document reference: the document id is empty.");
|
|
87
|
+
const i = `${n}${k}`;
|
|
88
|
+
return r.startsWith(i) ? r : `${i}${r}`;
|
|
88
89
|
}
|
|
89
90
|
var W = class extends Promise {
|
|
90
91
|
static get [Symbol.species]() {
|
|
@@ -94,17 +95,17 @@ var W = class extends Promise {
|
|
|
94
95
|
reject;
|
|
95
96
|
constructor(e = () => {
|
|
96
97
|
}) {
|
|
97
|
-
let t,
|
|
98
|
-
super((
|
|
99
|
-
t =
|
|
100
|
-
}), this.resolve = t, this.reject =
|
|
98
|
+
let t, n;
|
|
99
|
+
super((r, i) => {
|
|
100
|
+
t = r, n = i, e(r, i);
|
|
101
|
+
}), this.resolve = t, this.reject = n;
|
|
101
102
|
}
|
|
102
103
|
}, G = { timeout: 1e4 };
|
|
103
104
|
function J(e) {
|
|
104
|
-
const t = typeof e == "object" && e !== null ? Object.fromEntries(Object.getOwnPropertyNames(e).map((o) => [o, e[o]])) : {},
|
|
105
|
+
const t = typeof e == "object" && e !== null ? Object.fromEntries(Object.getOwnPropertyNames(e).map((o) => [o, e[o]])) : {}, n = e instanceof Error ? e.message : String(e), r = typeof t.message == "string" && t.message !== "" ? t.message : n, i = e instanceof Error ? e.name : void 0, a = typeof t.name == "string" ? t.name : i;
|
|
105
106
|
return JSON.stringify({
|
|
106
107
|
...t,
|
|
107
|
-
message:
|
|
108
|
+
message: r,
|
|
108
109
|
...a !== void 0 && { name: a }
|
|
109
110
|
});
|
|
110
111
|
}
|
|
@@ -129,22 +130,22 @@ var N = class {
|
|
|
129
130
|
call(e, ...t) {
|
|
130
131
|
return this.callWithOptions(e, {}, ...t);
|
|
131
132
|
}
|
|
132
|
-
callWithOptions(e, t, ...
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
133
|
+
callWithOptions(e, t, ...n) {
|
|
134
|
+
const r = this.currentID++, i = new W(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
135
|
+
if (r in this.promisesByID) {
|
|
135
136
|
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);
|
|
136
|
-
i.reject(l), Reflect.deleteProperty(this.promisesByID,
|
|
137
|
+
i.reject(l), Reflect.deleteProperty(this.promisesByID, r);
|
|
137
138
|
}
|
|
138
139
|
}, a);
|
|
139
|
-
this.promisesByID[
|
|
140
|
+
this.promisesByID[r] = {
|
|
140
141
|
promise: i,
|
|
141
142
|
timeoutId: o
|
|
142
143
|
};
|
|
143
144
|
const s = {
|
|
144
145
|
type: "call",
|
|
145
|
-
id:
|
|
146
|
+
id: r,
|
|
146
147
|
name: e,
|
|
147
|
-
data:
|
|
148
|
+
data: n
|
|
148
149
|
};
|
|
149
150
|
return this.postMessage(s), i;
|
|
150
151
|
}
|
|
@@ -169,27 +170,27 @@ var N = class {
|
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
async handleCall(e) {
|
|
172
|
-
const { id: t, name:
|
|
173
|
-
if (!(
|
|
174
|
-
const a = /* @__PURE__ */ new Error(`No receiver registered for: ${
|
|
173
|
+
const { id: t, name: n, data: r } = e;
|
|
174
|
+
if (!(n in this.receiversByName)) {
|
|
175
|
+
const a = /* @__PURE__ */ new Error(`No receiver registered for: ${n}`), o = JSON.stringify({
|
|
175
176
|
message: a.message,
|
|
176
177
|
name: a.name
|
|
177
178
|
});
|
|
178
179
|
this.postMessage({
|
|
179
180
|
type: "error",
|
|
180
181
|
id: t,
|
|
181
|
-
name:
|
|
182
|
+
name: n,
|
|
182
183
|
errorJSON: o
|
|
183
184
|
});
|
|
184
185
|
return;
|
|
185
186
|
}
|
|
186
|
-
const i = this.receiversByName[
|
|
187
|
+
const i = this.receiversByName[n];
|
|
187
188
|
try {
|
|
188
|
-
if (!Array.isArray(
|
|
189
|
-
const a = await i(...
|
|
189
|
+
if (!Array.isArray(r)) throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);
|
|
190
|
+
const a = await i(...r), o = {
|
|
190
191
|
type: "response",
|
|
191
192
|
id: t,
|
|
192
|
-
name:
|
|
193
|
+
name: n,
|
|
193
194
|
data: a
|
|
194
195
|
};
|
|
195
196
|
this.postMessage(o);
|
|
@@ -197,7 +198,7 @@ var N = class {
|
|
|
197
198
|
const o = {
|
|
198
199
|
type: "error",
|
|
199
200
|
id: t,
|
|
200
|
-
name:
|
|
201
|
+
name: n,
|
|
201
202
|
errorJSON: J(a)
|
|
202
203
|
};
|
|
203
204
|
this.postMessage(o);
|
|
@@ -206,20 +207,20 @@ var N = class {
|
|
|
206
207
|
handleResponse(e) {
|
|
207
208
|
const { id: t } = e;
|
|
208
209
|
if (t in this.promisesByID) {
|
|
209
|
-
const { promise:
|
|
210
|
-
clearTimeout(
|
|
210
|
+
const { promise: n, timeoutId: r } = this.promisesByID[t];
|
|
211
|
+
clearTimeout(r), n.resolve(e.data), Reflect.deleteProperty(this.promisesByID, t);
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
214
|
handleError(e) {
|
|
214
|
-
const { id: t, errorJSON:
|
|
215
|
+
const { id: t, errorJSON: n } = e;
|
|
215
216
|
if (t in this.promisesByID) {
|
|
216
|
-
const { promise:
|
|
217
|
+
const { promise: r, timeoutId: i } = this.promisesByID[t];
|
|
217
218
|
clearTimeout(i);
|
|
218
219
|
try {
|
|
219
|
-
const a = JSON.parse(
|
|
220
|
-
|
|
220
|
+
const a = JSON.parse(n), o = z(a);
|
|
221
|
+
r.reject(o);
|
|
221
222
|
} catch {
|
|
222
|
-
|
|
223
|
+
r.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
223
224
|
}
|
|
224
225
|
Reflect.deleteProperty(this.promisesByID, t);
|
|
225
226
|
}
|
|
@@ -231,17 +232,17 @@ var N = class {
|
|
|
231
232
|
}
|
|
232
233
|
};
|
|
233
234
|
var Y = /* @__PURE__ */ new Set(["auto", "prompt"]), I = (e, t) => {
|
|
234
|
-
const
|
|
235
|
-
if (!(typeof
|
|
236
|
-
return
|
|
235
|
+
const n = e[t];
|
|
236
|
+
if (!(typeof n != "string" || n.length === 0))
|
|
237
|
+
return n.slice(0, 64);
|
|
237
238
|
};
|
|
238
239
|
function X(e) {
|
|
239
240
|
if (typeof e != "object" || e === null || Array.isArray(e)) return null;
|
|
240
|
-
const t = e,
|
|
241
|
-
if (
|
|
241
|
+
const t = e, n = I(t, "version"), r = I(t, "commitHash");
|
|
242
|
+
if (n === void 0 || r === void 0) return null;
|
|
242
243
|
const i = {
|
|
243
|
-
version:
|
|
244
|
-
commitHash:
|
|
244
|
+
version: n,
|
|
245
|
+
commitHash: r
|
|
245
246
|
};
|
|
246
247
|
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled), Y.has(t.pwaUpdateMode) && (i.pwaUpdateMode = t.pwaUpdateMode);
|
|
247
248
|
const a = I(t, "adapterVersion");
|
|
@@ -255,26 +256,26 @@ var q = class {
|
|
|
255
256
|
sidebar;
|
|
256
257
|
targetOrigin;
|
|
257
258
|
latestHostAdapterVersion = null;
|
|
258
|
-
constructor(e, t,
|
|
259
|
-
this.sidebar = e || {}, this.targetOrigin =
|
|
260
|
-
window.parent.postMessage(
|
|
259
|
+
constructor(e, t, n = "*") {
|
|
260
|
+
this.sidebar = e || {}, this.targetOrigin = n, this.ipc = new N((r) => {
|
|
261
|
+
window.parent.postMessage(r, this.targetOrigin);
|
|
261
262
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
262
263
|
}
|
|
263
264
|
handleMessage = (e) => {
|
|
264
|
-
const t = globalThis.window.location.origin,
|
|
265
|
-
e.origin !== t && (
|
|
265
|
+
const t = globalThis.window.location.origin, n = this.targetOrigin;
|
|
266
|
+
e.origin !== t && (n !== "*" && e.origin !== n || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
266
267
|
};
|
|
267
268
|
registerReceivers() {
|
|
268
269
|
if (this.sidebar.onPluginStatusChange) {
|
|
269
270
|
const e = this.sidebar.onPluginStatusChange;
|
|
270
|
-
this.ipc.receive("onPluginStatusChange", async (t,
|
|
271
|
-
await e(t,
|
|
271
|
+
this.ipc.receive("onPluginStatusChange", async (t, n) => {
|
|
272
|
+
await e(t, n);
|
|
272
273
|
});
|
|
273
274
|
}
|
|
274
275
|
if (this.sidebar.activateAgenticIssue) {
|
|
275
276
|
const e = this.sidebar.activateAgenticIssue;
|
|
276
|
-
this.ipc.receive("activateAgenticIssue", async (t,
|
|
277
|
-
await e(t, typeof
|
|
277
|
+
this.ipc.receive("activateAgenticIssue", async (t, n) => {
|
|
278
|
+
await e(t, typeof n == "string" ? n : null);
|
|
278
279
|
});
|
|
279
280
|
}
|
|
280
281
|
if (this.sidebar.invalidateAgenticIssue) {
|
|
@@ -313,11 +314,11 @@ var q = class {
|
|
|
313
314
|
}
|
|
314
315
|
}
|
|
315
316
|
async getInitConfig(e) {
|
|
316
|
-
const { hostAdapterVersion: t, ...
|
|
317
|
+
const { hostAdapterVersion: t, ...n } = e ? await this.ipc.call("getInitConfig", {
|
|
317
318
|
...e,
|
|
318
|
-
adapterVersion: e.adapterVersion ?? "2.
|
|
319
|
+
adapterVersion: e.adapterVersion ?? "2.4.0"
|
|
319
320
|
}) : await this.ipc.call("getInitConfig");
|
|
320
|
-
return this.latestHostAdapterVersion = K(t),
|
|
321
|
+
return this.latestHostAdapterVersion = K(t), n;
|
|
321
322
|
}
|
|
322
323
|
getHostAdapterVersion() {
|
|
323
324
|
return this.latestHostAdapterVersion;
|
|
@@ -328,8 +329,8 @@ var q = class {
|
|
|
328
329
|
async getSelectedContent(e) {
|
|
329
330
|
return this.ipc.callWithOptions("getSelectedContent", e ?? {});
|
|
330
331
|
}
|
|
331
|
-
async replaceContent(e, t,
|
|
332
|
-
await this.ipc.call("replaceContent", e, t,
|
|
332
|
+
async replaceContent(e, t, n = null) {
|
|
333
|
+
await this.ipc.call("replaceContent", e, t, n);
|
|
333
334
|
}
|
|
334
335
|
async selectContent(e, t = null) {
|
|
335
336
|
await this.ipc.call("selectContent", e, t);
|
|
@@ -337,14 +338,14 @@ var q = class {
|
|
|
337
338
|
async replaceMultipleContents(e) {
|
|
338
339
|
await this.ipc.call("replaceMultipleContents", e);
|
|
339
340
|
}
|
|
340
|
-
async onAgenticAgentResults(e, t,
|
|
341
|
-
await this.ipc.call("onAgenticAgentResults", e, t,
|
|
341
|
+
async onAgenticAgentResults(e, t, n = null) {
|
|
342
|
+
await this.ipc.call("onAgenticAgentResults", e, t, n);
|
|
342
343
|
}
|
|
343
344
|
async onAgenticStreamComplete(e = null) {
|
|
344
345
|
await this.ipc.call("onAgenticStreamComplete", e);
|
|
345
346
|
}
|
|
346
|
-
async onAgenticIssueStatusChanged(e, t,
|
|
347
|
-
await this.ipc.call("onAgenticIssueStatusChanged", e, t,
|
|
347
|
+
async onAgenticIssueStatusChanged(e, t, n) {
|
|
348
|
+
await this.ipc.call("onAgenticIssueStatusChanged", e, t, n);
|
|
348
349
|
}
|
|
349
350
|
async onAgenticIssuesCleared(e = null) {
|
|
350
351
|
await this.ipc.call("onAgenticIssuesCleared", e);
|
|
@@ -355,6 +356,9 @@ var q = class {
|
|
|
355
356
|
async copyToClipboard(e) {
|
|
356
357
|
await this.ipc.call("copyToClipboard", e);
|
|
357
358
|
}
|
|
359
|
+
async addComment(e, t = null) {
|
|
360
|
+
await this.ipc.call("addComment", e, t);
|
|
361
|
+
}
|
|
358
362
|
async onIntegrationSettingsChange(e, t) {
|
|
359
363
|
await this.ipc.call("onIntegrationSettingsChange", e, t);
|
|
360
364
|
}
|
|
@@ -379,8 +383,8 @@ var q = class {
|
|
|
379
383
|
}
|
|
380
384
|
}, we = class {
|
|
381
385
|
ipcAdapter;
|
|
382
|
-
constructor(e, t,
|
|
383
|
-
this.ipcAdapter = new q(e, t,
|
|
386
|
+
constructor(e, t, n) {
|
|
387
|
+
this.ipcAdapter = new q(e, t, n);
|
|
384
388
|
}
|
|
385
389
|
destroy() {
|
|
386
390
|
this.ipcAdapter.destroy();
|
|
@@ -397,8 +401,8 @@ var q = class {
|
|
|
397
401
|
async getSelectedContent(e) {
|
|
398
402
|
return await this.ipcAdapter.getSelectedContent(e);
|
|
399
403
|
}
|
|
400
|
-
async replaceContent(e, t,
|
|
401
|
-
await this.ipcAdapter.replaceContent(e, t,
|
|
404
|
+
async replaceContent(e, t, n = null) {
|
|
405
|
+
await this.ipcAdapter.replaceContent(e, t, n);
|
|
402
406
|
}
|
|
403
407
|
async selectContent(e, t = null) {
|
|
404
408
|
await this.ipcAdapter.selectContent(e, t);
|
|
@@ -406,14 +410,14 @@ var q = class {
|
|
|
406
410
|
async replaceMultipleContents(e) {
|
|
407
411
|
await this.ipcAdapter.replaceMultipleContents(e);
|
|
408
412
|
}
|
|
409
|
-
onAgenticAgentResults(e, t,
|
|
410
|
-
return this.ipcAdapter.onAgenticAgentResults(e, t,
|
|
413
|
+
onAgenticAgentResults(e, t, n = null) {
|
|
414
|
+
return this.ipcAdapter.onAgenticAgentResults(e, t, n);
|
|
411
415
|
}
|
|
412
416
|
onAgenticStreamComplete(e = null) {
|
|
413
417
|
return this.ipcAdapter.onAgenticStreamComplete(e);
|
|
414
418
|
}
|
|
415
|
-
onAgenticIssueStatusChanged(e, t,
|
|
416
|
-
return this.ipcAdapter.onAgenticIssueStatusChanged(e, t,
|
|
419
|
+
onAgenticIssueStatusChanged(e, t, n) {
|
|
420
|
+
return this.ipcAdapter.onAgenticIssueStatusChanged(e, t, n);
|
|
417
421
|
}
|
|
418
422
|
onAgenticIssuesCleared(e = null) {
|
|
419
423
|
return this.ipcAdapter.onAgenticIssuesCleared(e);
|
|
@@ -424,6 +428,9 @@ var q = class {
|
|
|
424
428
|
copyToClipboard(e) {
|
|
425
429
|
return this.ipcAdapter.copyToClipboard(e);
|
|
426
430
|
}
|
|
431
|
+
addComment(e, t = null) {
|
|
432
|
+
return this.ipcAdapter.addComment(e, t);
|
|
433
|
+
}
|
|
427
434
|
onIntegrationSettingsChange(e, t) {
|
|
428
435
|
return this.ipcAdapter.onIntegrationSettingsChange(e, t);
|
|
429
436
|
}
|
|
@@ -443,14 +450,14 @@ var q = class {
|
|
|
443
450
|
window;
|
|
444
451
|
targetOrigin;
|
|
445
452
|
latestSidebarBuildInfo = null;
|
|
446
|
-
constructor(e, t,
|
|
447
|
-
this.plugin = e, this.iframe = t, this.window =
|
|
453
|
+
constructor(e, t, n, r, i = "*") {
|
|
454
|
+
this.plugin = e, this.iframe = t, this.window = n ?? window, this.targetOrigin = i, this.ipc = new N((a) => {
|
|
448
455
|
this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
|
|
449
|
-
},
|
|
456
|
+
}, r), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
450
457
|
}
|
|
451
458
|
handleMessage = (e) => {
|
|
452
|
-
const t = this.window.location.origin,
|
|
453
|
-
e.origin !== t && (
|
|
459
|
+
const t = this.window.location.origin, n = this.targetOrigin;
|
|
460
|
+
e.origin !== t && (n !== "*" && e.origin !== n || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
454
461
|
};
|
|
455
462
|
registerReceivers() {
|
|
456
463
|
if (this.ipc.receive("getInitConfig", async (e) => {
|
|
@@ -459,25 +466,25 @@ var q = class {
|
|
|
459
466
|
...await this.plugin.getInitConfig(t ?? void 0),
|
|
460
467
|
hostAdapterVersion: V
|
|
461
468
|
};
|
|
462
|
-
}), 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,
|
|
463
|
-
await this.plugin.replaceContent(e, t, typeof
|
|
469
|
+
}), 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, n) => {
|
|
470
|
+
await this.plugin.replaceContent(e, t, typeof n == "string" ? n : null);
|
|
464
471
|
}), this.ipc.receive("selectContent", async (e, t) => {
|
|
465
472
|
await this.plugin.selectContent(e, typeof t == "string" ? t : null);
|
|
466
473
|
}), this.ipc.receive("replaceMultipleContents", async (e) => {
|
|
467
474
|
await this.plugin.replaceMultipleContents(e);
|
|
468
|
-
}), this.ipc.receive("onAgenticAgentResults", async (e, t,
|
|
475
|
+
}), this.ipc.receive("onAgenticAgentResults", async (e, t, n) => {
|
|
469
476
|
if (!Array.isArray(t))
|
|
470
477
|
return;
|
|
471
|
-
const
|
|
472
|
-
|
|
478
|
+
const r = this.plugin.onAgenticAgentResults;
|
|
479
|
+
r && await r(e, t, typeof n == "string" ? n : null);
|
|
473
480
|
}), this.ipc.receive("onAgenticStreamComplete", async (e) => {
|
|
474
481
|
const t = this.plugin.onAgenticStreamComplete;
|
|
475
482
|
t && await t(typeof e == "string" ? e : null);
|
|
476
|
-
}), this.ipc.receive("onAgenticIssueStatusChanged", async (e, t,
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
483
|
+
}), this.ipc.receive("onAgenticIssueStatusChanged", async (e, t, n) => {
|
|
484
|
+
const r = this.plugin.onAgenticIssueStatusChanged;
|
|
485
|
+
if (r && !(t !== "active" && t !== "resolved" && t !== "dismissed" || n !== "user" && n !== "host"))
|
|
479
486
|
try {
|
|
480
|
-
await
|
|
487
|
+
await r(e, t, n);
|
|
481
488
|
} catch {
|
|
482
489
|
}
|
|
483
490
|
}), this.ipc.receive("onAgenticIssuesCleared", async (e) => {
|
|
@@ -499,10 +506,16 @@ var q = class {
|
|
|
499
506
|
await e(t);
|
|
500
507
|
});
|
|
501
508
|
}
|
|
509
|
+
if (this.plugin.addComment) {
|
|
510
|
+
const e = this.plugin.addComment;
|
|
511
|
+
this.ipc.receive("addComment", async (t, n) => {
|
|
512
|
+
await e(t, typeof n == "string" ? n : null);
|
|
513
|
+
});
|
|
514
|
+
}
|
|
502
515
|
if (this.plugin.onIntegrationSettingsChange) {
|
|
503
516
|
const e = this.plugin.onIntegrationSettingsChange;
|
|
504
|
-
this.ipc.receive("onIntegrationSettingsChange", async (t,
|
|
505
|
-
await e(t,
|
|
517
|
+
this.ipc.receive("onIntegrationSettingsChange", async (t, n) => {
|
|
518
|
+
await e(t, n);
|
|
506
519
|
});
|
|
507
520
|
}
|
|
508
521
|
}
|
|
@@ -541,8 +554,8 @@ var q = class {
|
|
|
541
554
|
}
|
|
542
555
|
}, Q = class {
|
|
543
556
|
ipcAdapter;
|
|
544
|
-
constructor(e, t,
|
|
545
|
-
this.ipcAdapter = new Z(e, t,
|
|
557
|
+
constructor(e, t, n) {
|
|
558
|
+
this.ipcAdapter = new Z(e, t, n?.win, n?.config, n?.targetOrigin);
|
|
546
559
|
}
|
|
547
560
|
destroy() {
|
|
548
561
|
this.ipcAdapter.destroy();
|
|
@@ -607,7 +620,7 @@ var q = class {
|
|
|
607
620
|
overlay: e,
|
|
608
621
|
button: t
|
|
609
622
|
};
|
|
610
|
-
}, T = "markupai-sidebar-load-overlay-styles",
|
|
623
|
+
}, T = "markupai-sidebar-load-overlay-styles", ne = `
|
|
611
624
|
:root {
|
|
612
625
|
--background: #f5f5f4;
|
|
613
626
|
--foreground: #333332;
|
|
@@ -699,14 +712,14 @@ var q = class {
|
|
|
699
712
|
box-shadow: 0 0 0 2px
|
|
700
713
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
701
714
|
}
|
|
702
|
-
`,
|
|
715
|
+
`, re = (e) => {
|
|
703
716
|
const t = e ?? document;
|
|
704
717
|
if (t.getElementById(T)) return;
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
}, ie = 8e3, ae = 12e3, oe = (e, t,
|
|
708
|
-
|
|
709
|
-
const { sidebarUrl:
|
|
718
|
+
const n = t.createElement("style");
|
|
719
|
+
n.id = T, n.textContent = ne, t.head.appendChild(n);
|
|
720
|
+
}, ie = 8e3, ae = 12e3, oe = (e, t, n = {}) => {
|
|
721
|
+
re(e.ownerDocument);
|
|
722
|
+
const { sidebarUrl: r, targetOrigin: i, timeoutMs: a = ie, retryIntervalMs: o = ae, messageListenWindow: s } = n, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, j = () => {
|
|
710
723
|
if (i) return i;
|
|
711
724
|
try {
|
|
712
725
|
return new URL(p()).origin;
|
|
@@ -760,10 +773,10 @@ function Oe(e, t) {
|
|
|
760
773
|
if (!t) return e;
|
|
761
774
|
try {
|
|
762
775
|
if (!("localStorage" in globalThis)) return e;
|
|
763
|
-
const
|
|
764
|
-
if (!
|
|
765
|
-
const
|
|
766
|
-
return
|
|
776
|
+
const n = globalThis.localStorage.getItem(ce)?.trim();
|
|
777
|
+
if (!n) return e;
|
|
778
|
+
const r = JSON.parse(n);
|
|
779
|
+
return r !== null && typeof r == "object" && "type" in r && (r.type === "mediation" || r.type === "popup") ? r : e;
|
|
767
780
|
} catch {
|
|
768
781
|
return e;
|
|
769
782
|
}
|
|
@@ -771,23 +784,23 @@ function Oe(e, t) {
|
|
|
771
784
|
function Te(e, t) {
|
|
772
785
|
try {
|
|
773
786
|
return new URL(e).origin;
|
|
774
|
-
} catch (
|
|
775
|
-
return t?.onInvalidUrl?.(e,
|
|
787
|
+
} catch (n) {
|
|
788
|
+
return t?.onInvalidUrl?.(e, n), "*";
|
|
776
789
|
}
|
|
777
790
|
}
|
|
778
791
|
function De(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
779
792
|
if (e.adapter === null) throw new Error(t);
|
|
780
793
|
}
|
|
781
794
|
function de(e) {
|
|
782
|
-
const { iframe: t, iframeMount:
|
|
783
|
-
if (t !== void 0 &&
|
|
795
|
+
const { iframe: t, iframeMount: n } = e;
|
|
796
|
+
if (t !== void 0 && n !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
784
797
|
if (t !== void 0) return {
|
|
785
798
|
iframe: t,
|
|
786
799
|
removeMountedIframe: null
|
|
787
800
|
};
|
|
788
|
-
if (
|
|
789
|
-
const { container:
|
|
790
|
-
return o.title = se, o.src = i, a && o.setAttribute("allow", a),
|
|
801
|
+
if (n === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
802
|
+
const { container: r, src: i, allow: a = le } = n, o = document.createElement("iframe");
|
|
803
|
+
return o.title = se, o.src = i, a && o.setAttribute("allow", a), r.appendChild(o), {
|
|
791
804
|
iframe: o,
|
|
792
805
|
removeMountedIframe: () => {
|
|
793
806
|
o.remove();
|
|
@@ -795,7 +808,7 @@ function de(e) {
|
|
|
795
808
|
};
|
|
796
809
|
}
|
|
797
810
|
function xe(e) {
|
|
798
|
-
const { plugin: t, loadOverlayContainer:
|
|
811
|
+
const { plugin: t, loadOverlayContainer: n, loadOverlayOptions: r, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } = de(e), s = n !== void 0 ? oe(n, a, r ?? {}) : null;
|
|
799
812
|
if (t !== void 0) {
|
|
800
813
|
const l = new Q(t, a, i);
|
|
801
814
|
return {
|
|
@@ -850,30 +863,30 @@ var Me = $();
|
|
|
850
863
|
function ge(e) {
|
|
851
864
|
return e instanceof Document ? e : e.ownerDocument;
|
|
852
865
|
}
|
|
853
|
-
function pe(e, t,
|
|
866
|
+
function pe(e, t, n) {
|
|
854
867
|
if (!t || e.getElementById(D)) return;
|
|
855
|
-
const
|
|
856
|
-
|
|
868
|
+
const r = e.createElement("style");
|
|
869
|
+
r.id = D, r.textContent = $(n), e.head.appendChild(r);
|
|
857
870
|
}
|
|
858
871
|
function _e(e) {
|
|
859
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId:
|
|
872
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: n = H, includeDefaultStyles: r = !0 } = e ?? {};
|
|
860
873
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
861
874
|
const i = ge(t);
|
|
862
|
-
pe(i,
|
|
863
|
-
const a = t instanceof Document ? i.getElementById(
|
|
875
|
+
pe(i, r, n);
|
|
876
|
+
const a = t instanceof Document ? i.getElementById(n) : t.querySelector(`#${U(n)}`);
|
|
864
877
|
if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
|
|
865
878
|
if (!(t instanceof Document)) {
|
|
866
879
|
const s = i.createElement("div");
|
|
867
|
-
return s.id =
|
|
880
|
+
return s.id = n, t.appendChild(s), s;
|
|
868
881
|
}
|
|
869
882
|
const o = i.createElement("div");
|
|
870
|
-
return o.id =
|
|
883
|
+
return o.id = n, i.body.appendChild(o), o;
|
|
871
884
|
}
|
|
872
885
|
function ue() {
|
|
873
886
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
874
887
|
}
|
|
875
888
|
function Le(e) {
|
|
876
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml:
|
|
889
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: n = "", includePluginHostHead: r = !1, bodyScriptsHtml: i, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [r ? ue() : "", n].filter((p) => p.trim().length > 0).join(`
|
|
877
890
|
`);
|
|
878
891
|
return `<!DOCTYPE html>
|
|
879
892
|
<html ${o}>
|