@markupai/sidebar-adapter 2.2.0 → 2.3.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 +24 -2
- package/asyncapi.json +58 -2
- package/dist/errors.d.ts +38 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/ipc/ipc-core.d.ts.map +1 -1
- package/dist/main.js +273 -232
- package/dist/main.umd.cjs +6 -6
- package/dist/types/errors.d.ts +47 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +3 -0
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var fe = /* @__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
|
+
})({}), me = [
|
|
4
4
|
"text/plain",
|
|
5
5
|
"text/markdown",
|
|
6
6
|
"text/html",
|
|
7
7
|
"application/dita+xml"
|
|
8
|
-
],
|
|
8
|
+
], ye = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
@@ -13,41 +13,80 @@ var ge = /* @__PURE__ */ (function(e) {
|
|
|
13
13
|
supportCheckSelection: !0,
|
|
14
14
|
multiAgent: !1,
|
|
15
15
|
multiDocument: !1
|
|
16
|
-
},
|
|
16
|
+
}, Ie = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), ve = (e) => {
|
|
17
17
|
if (typeof e != "object" || e === null) return !1;
|
|
18
18
|
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
|
|
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((r) => {
|
|
20
|
+
if (typeof r != "object" || r === null) return !1;
|
|
21
|
+
const n = r;
|
|
22
|
+
return typeof n.value == "string" && typeof n.label == "string";
|
|
23
23
|
}) : !1;
|
|
24
|
-
},
|
|
24
|
+
}, V = "2.3.0", v = class x extends Error {
|
|
25
25
|
name = "TextLookupError";
|
|
26
26
|
constructor(t) {
|
|
27
|
-
super(t), Object.setPrototypeOf(this,
|
|
27
|
+
super(t), Object.setPrototypeOf(this, x.prototype);
|
|
28
|
+
}
|
|
29
|
+
}, M = class _ extends v {
|
|
30
|
+
name = "ReplaceBatchError";
|
|
31
|
+
applied;
|
|
32
|
+
failed;
|
|
33
|
+
constructor(t, r) {
|
|
34
|
+
super(t), this.applied = r.applied.map((n) => ({
|
|
35
|
+
start: n.start,
|
|
36
|
+
end: n.end
|
|
37
|
+
})), this.failed = r.failed.map((n) => L(n, n.message)), Object.setPrototypeOf(this, _.prototype);
|
|
28
38
|
}
|
|
29
39
|
};
|
|
30
|
-
function
|
|
31
|
-
return e instanceof
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
function Ae(e) {
|
|
41
|
+
return e instanceof M;
|
|
42
|
+
}
|
|
43
|
+
function L(e, t) {
|
|
44
|
+
const r = {
|
|
45
|
+
start: e.start,
|
|
46
|
+
end: e.end
|
|
47
|
+
};
|
|
48
|
+
return typeof t == "string" && t.trim() !== "" && (r.message = t), r;
|
|
49
|
+
}
|
|
50
|
+
function R(e) {
|
|
51
|
+
return Array.isArray(e) ? e.flatMap((t) => {
|
|
52
|
+
if (t === null || typeof t != "object") return [];
|
|
53
|
+
const { start: r, end: n, message: i } = t;
|
|
54
|
+
return typeof r != "number" || typeof n != "number" ? [] : [{
|
|
55
|
+
range: {
|
|
56
|
+
start: r,
|
|
57
|
+
end: n
|
|
58
|
+
},
|
|
59
|
+
message: i
|
|
60
|
+
}];
|
|
61
|
+
}) : [];
|
|
62
|
+
}
|
|
63
|
+
function Ce(e) {
|
|
64
|
+
return e instanceof v;
|
|
65
|
+
}
|
|
66
|
+
var O = {
|
|
67
|
+
TextLookupError: (e) => new v(e),
|
|
68
|
+
ReplaceBatchError: (e, t) => new M(e, {
|
|
69
|
+
applied: R(t.applied).map((r) => r.range),
|
|
70
|
+
failed: R(t.failed).map((r) => L(r.range, r.message))
|
|
71
|
+
})
|
|
72
|
+
};
|
|
73
|
+
function z(e) {
|
|
74
|
+
const t = e.message ?? "", r = e.name, n = typeof r == "string" && r in O ? O[r] : void 0;
|
|
75
|
+
return n ? n(t, e) : Object.assign(new Error(t), r ? { name: r } : {});
|
|
76
|
+
}
|
|
77
|
+
var k = ":", B = /^[a-z][a-z0-9-]*$/;
|
|
78
|
+
function be(e) {
|
|
79
|
+
const t = e.indexOf(k);
|
|
80
|
+
return t <= 0 || t === e.length - 1 ? !1 : B.test(e.slice(0, t));
|
|
81
|
+
}
|
|
82
|
+
function Se(e, t) {
|
|
83
|
+
const r = e.trim().toLowerCase(), n = t.trim();
|
|
84
|
+
if (!B.test(r)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
|
|
85
|
+
if (n.length === 0) throw new Error("Invalid document reference: the document id is empty.");
|
|
86
|
+
const i = `${r}${k}`;
|
|
87
|
+
return n.startsWith(i) ? n : `${i}${n}`;
|
|
88
|
+
}
|
|
89
|
+
var W = class extends Promise {
|
|
51
90
|
static get [Symbol.species]() {
|
|
52
91
|
return Promise;
|
|
53
92
|
}
|
|
@@ -55,21 +94,21 @@ var j = class extends Promise {
|
|
|
55
94
|
reject;
|
|
56
95
|
constructor(e = () => {
|
|
57
96
|
}) {
|
|
58
|
-
let t,
|
|
59
|
-
super((
|
|
60
|
-
t =
|
|
61
|
-
}), this.resolve = t, this.reject =
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
function
|
|
65
|
-
const t = typeof e == "object" && e !== null ?
|
|
97
|
+
let t, r;
|
|
98
|
+
super((n, i) => {
|
|
99
|
+
t = n, r = i, e(n, i);
|
|
100
|
+
}), this.resolve = t, this.reject = r;
|
|
101
|
+
}
|
|
102
|
+
}, G = { timeout: 1e4 };
|
|
103
|
+
function J(e) {
|
|
104
|
+
const t = typeof e == "object" && e !== null ? Object.fromEntries(Object.getOwnPropertyNames(e).map((o) => [o, e[o]])) : {}, r = e instanceof Error ? e.message : String(e), n = typeof t.message == "string" && t.message !== "" ? t.message : r, i = e instanceof Error ? e.name : void 0, a = typeof t.name == "string" ? t.name : i;
|
|
66
105
|
return JSON.stringify({
|
|
67
106
|
...t,
|
|
68
|
-
message:
|
|
107
|
+
message: n,
|
|
69
108
|
...a !== void 0 && { name: a }
|
|
70
109
|
});
|
|
71
110
|
}
|
|
72
|
-
var
|
|
111
|
+
var N = class {
|
|
73
112
|
promisesByID = {};
|
|
74
113
|
receiversByName = {};
|
|
75
114
|
currentID = 0;
|
|
@@ -77,7 +116,7 @@ var _ = class {
|
|
|
77
116
|
postMessage;
|
|
78
117
|
constructor(e, t) {
|
|
79
118
|
this.postMessage = e, this.config = {
|
|
80
|
-
...
|
|
119
|
+
...G,
|
|
81
120
|
...t
|
|
82
121
|
};
|
|
83
122
|
}
|
|
@@ -90,22 +129,22 @@ var _ = class {
|
|
|
90
129
|
call(e, ...t) {
|
|
91
130
|
return this.callWithOptions(e, {}, ...t);
|
|
92
131
|
}
|
|
93
|
-
callWithOptions(e, t, ...
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
132
|
+
callWithOptions(e, t, ...r) {
|
|
133
|
+
const n = this.currentID++, i = new W(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
134
|
+
if (n in this.promisesByID) {
|
|
96
135
|
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);
|
|
97
|
-
i.reject(l), Reflect.deleteProperty(this.promisesByID,
|
|
136
|
+
i.reject(l), Reflect.deleteProperty(this.promisesByID, n);
|
|
98
137
|
}
|
|
99
138
|
}, a);
|
|
100
|
-
this.promisesByID[
|
|
139
|
+
this.promisesByID[n] = {
|
|
101
140
|
promise: i,
|
|
102
141
|
timeoutId: o
|
|
103
142
|
};
|
|
104
143
|
const s = {
|
|
105
144
|
type: "call",
|
|
106
|
-
id:
|
|
145
|
+
id: n,
|
|
107
146
|
name: e,
|
|
108
|
-
data:
|
|
147
|
+
data: r
|
|
109
148
|
};
|
|
110
149
|
return this.postMessage(s), i;
|
|
111
150
|
}
|
|
@@ -130,27 +169,27 @@ var _ = class {
|
|
|
130
169
|
}
|
|
131
170
|
}
|
|
132
171
|
async handleCall(e) {
|
|
133
|
-
const { id: t, name:
|
|
134
|
-
if (!(
|
|
135
|
-
const a = /* @__PURE__ */ new Error(`No receiver registered for: ${
|
|
172
|
+
const { id: t, name: r, data: n } = e;
|
|
173
|
+
if (!(r in this.receiversByName)) {
|
|
174
|
+
const a = /* @__PURE__ */ new Error(`No receiver registered for: ${r}`), o = JSON.stringify({
|
|
136
175
|
message: a.message,
|
|
137
176
|
name: a.name
|
|
138
177
|
});
|
|
139
178
|
this.postMessage({
|
|
140
179
|
type: "error",
|
|
141
180
|
id: t,
|
|
142
|
-
name:
|
|
181
|
+
name: r,
|
|
143
182
|
errorJSON: o
|
|
144
183
|
});
|
|
145
184
|
return;
|
|
146
185
|
}
|
|
147
|
-
const i = this.receiversByName[
|
|
186
|
+
const i = this.receiversByName[r];
|
|
148
187
|
try {
|
|
149
|
-
if (!Array.isArray(
|
|
150
|
-
const a = await i(...
|
|
188
|
+
if (!Array.isArray(n)) throw new TypeError(`IPC: Expected array of arguments but got ${typeof n}`);
|
|
189
|
+
const a = await i(...n), o = {
|
|
151
190
|
type: "response",
|
|
152
191
|
id: t,
|
|
153
|
-
name:
|
|
192
|
+
name: r,
|
|
154
193
|
data: a
|
|
155
194
|
};
|
|
156
195
|
this.postMessage(o);
|
|
@@ -158,8 +197,8 @@ var _ = class {
|
|
|
158
197
|
const o = {
|
|
159
198
|
type: "error",
|
|
160
199
|
id: t,
|
|
161
|
-
name:
|
|
162
|
-
errorJSON:
|
|
200
|
+
name: r,
|
|
201
|
+
errorJSON: J(a)
|
|
163
202
|
};
|
|
164
203
|
this.postMessage(o);
|
|
165
204
|
}
|
|
@@ -167,20 +206,20 @@ var _ = class {
|
|
|
167
206
|
handleResponse(e) {
|
|
168
207
|
const { id: t } = e;
|
|
169
208
|
if (t in this.promisesByID) {
|
|
170
|
-
const { promise:
|
|
171
|
-
clearTimeout(
|
|
209
|
+
const { promise: r, timeoutId: n } = this.promisesByID[t];
|
|
210
|
+
clearTimeout(n), r.resolve(e.data), Reflect.deleteProperty(this.promisesByID, t);
|
|
172
211
|
}
|
|
173
212
|
}
|
|
174
213
|
handleError(e) {
|
|
175
|
-
const { id: t, errorJSON:
|
|
214
|
+
const { id: t, errorJSON: r } = e;
|
|
176
215
|
if (t in this.promisesByID) {
|
|
177
|
-
const { promise:
|
|
216
|
+
const { promise: n, timeoutId: i } = this.promisesByID[t];
|
|
178
217
|
clearTimeout(i);
|
|
179
218
|
try {
|
|
180
|
-
const a = JSON.parse(
|
|
181
|
-
|
|
219
|
+
const a = JSON.parse(r), o = z(a);
|
|
220
|
+
n.reject(o);
|
|
182
221
|
} catch {
|
|
183
|
-
|
|
222
|
+
n.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
184
223
|
}
|
|
185
224
|
Reflect.deleteProperty(this.promisesByID, t);
|
|
186
225
|
}
|
|
@@ -191,51 +230,51 @@ var _ = class {
|
|
|
191
230
|
this.promisesByID = {}, this.receiversByName = {};
|
|
192
231
|
}
|
|
193
232
|
};
|
|
194
|
-
var
|
|
195
|
-
const
|
|
196
|
-
if (!(typeof
|
|
197
|
-
return
|
|
233
|
+
var Y = /* @__PURE__ */ new Set(["auto", "prompt"]), I = (e, t) => {
|
|
234
|
+
const r = e[t];
|
|
235
|
+
if (!(typeof r != "string" || r.length === 0))
|
|
236
|
+
return r.slice(0, 64);
|
|
198
237
|
};
|
|
199
|
-
function
|
|
238
|
+
function X(e) {
|
|
200
239
|
if (typeof e != "object" || e === null || Array.isArray(e)) return null;
|
|
201
|
-
const t = e,
|
|
202
|
-
if (
|
|
240
|
+
const t = e, r = I(t, "version"), n = I(t, "commitHash");
|
|
241
|
+
if (r === void 0 || n === void 0) return null;
|
|
203
242
|
const i = {
|
|
204
|
-
version:
|
|
205
|
-
commitHash:
|
|
243
|
+
version: r,
|
|
244
|
+
commitHash: n
|
|
206
245
|
};
|
|
207
|
-
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled),
|
|
246
|
+
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled), Y.has(t.pwaUpdateMode) && (i.pwaUpdateMode = t.pwaUpdateMode);
|
|
208
247
|
const a = I(t, "adapterVersion");
|
|
209
248
|
return a !== void 0 && (i.adapterVersion = a), i;
|
|
210
249
|
}
|
|
211
|
-
function
|
|
250
|
+
function K(e) {
|
|
212
251
|
return typeof e != "string" || e.length === 0 ? null : e.slice(0, 64);
|
|
213
252
|
}
|
|
214
|
-
var
|
|
253
|
+
var q = class {
|
|
215
254
|
ipc;
|
|
216
255
|
sidebar;
|
|
217
256
|
targetOrigin;
|
|
218
257
|
latestHostAdapterVersion = null;
|
|
219
|
-
constructor(e, t,
|
|
220
|
-
this.sidebar = e || {}, this.targetOrigin =
|
|
221
|
-
window.parent.postMessage(
|
|
258
|
+
constructor(e, t, r = "*") {
|
|
259
|
+
this.sidebar = e || {}, this.targetOrigin = r, this.ipc = new N((n) => {
|
|
260
|
+
window.parent.postMessage(n, this.targetOrigin);
|
|
222
261
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
223
262
|
}
|
|
224
263
|
handleMessage = (e) => {
|
|
225
|
-
const t = globalThis.window.location.origin,
|
|
226
|
-
e.origin !== t && (
|
|
264
|
+
const t = globalThis.window.location.origin, r = this.targetOrigin;
|
|
265
|
+
e.origin !== t && (r !== "*" && e.origin !== r || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
227
266
|
};
|
|
228
267
|
registerReceivers() {
|
|
229
268
|
if (this.sidebar.onPluginStatusChange) {
|
|
230
269
|
const e = this.sidebar.onPluginStatusChange;
|
|
231
|
-
this.ipc.receive("onPluginStatusChange", async (t,
|
|
232
|
-
await e(t,
|
|
270
|
+
this.ipc.receive("onPluginStatusChange", async (t, r) => {
|
|
271
|
+
await e(t, r);
|
|
233
272
|
});
|
|
234
273
|
}
|
|
235
274
|
if (this.sidebar.activateAgenticIssue) {
|
|
236
275
|
const e = this.sidebar.activateAgenticIssue;
|
|
237
|
-
this.ipc.receive("activateAgenticIssue", async (t,
|
|
238
|
-
await e(t, typeof
|
|
276
|
+
this.ipc.receive("activateAgenticIssue", async (t, r) => {
|
|
277
|
+
await e(t, typeof r == "string" ? r : null);
|
|
239
278
|
});
|
|
240
279
|
}
|
|
241
280
|
if (this.sidebar.invalidateAgenticIssue) {
|
|
@@ -274,11 +313,11 @@ var J = class {
|
|
|
274
313
|
}
|
|
275
314
|
}
|
|
276
315
|
async getInitConfig(e) {
|
|
277
|
-
const { hostAdapterVersion: t, ...
|
|
316
|
+
const { hostAdapterVersion: t, ...r } = e ? await this.ipc.call("getInitConfig", {
|
|
278
317
|
...e,
|
|
279
|
-
adapterVersion: e.adapterVersion ?? "2.
|
|
318
|
+
adapterVersion: e.adapterVersion ?? "2.3.0"
|
|
280
319
|
}) : await this.ipc.call("getInitConfig");
|
|
281
|
-
return this.latestHostAdapterVersion =
|
|
320
|
+
return this.latestHostAdapterVersion = K(t), r;
|
|
282
321
|
}
|
|
283
322
|
getHostAdapterVersion() {
|
|
284
323
|
return this.latestHostAdapterVersion;
|
|
@@ -289,8 +328,8 @@ var J = class {
|
|
|
289
328
|
async getSelectedContent(e) {
|
|
290
329
|
return this.ipc.callWithOptions("getSelectedContent", e ?? {});
|
|
291
330
|
}
|
|
292
|
-
async replaceContent(e, t,
|
|
293
|
-
await this.ipc.call("replaceContent", e, t,
|
|
331
|
+
async replaceContent(e, t, r = null) {
|
|
332
|
+
await this.ipc.call("replaceContent", e, t, r);
|
|
294
333
|
}
|
|
295
334
|
async selectContent(e, t = null) {
|
|
296
335
|
await this.ipc.call("selectContent", e, t);
|
|
@@ -298,14 +337,14 @@ var J = class {
|
|
|
298
337
|
async replaceMultipleContents(e) {
|
|
299
338
|
await this.ipc.call("replaceMultipleContents", e);
|
|
300
339
|
}
|
|
301
|
-
async onAgenticAgentResults(e, t,
|
|
302
|
-
await this.ipc.call("onAgenticAgentResults", e, t,
|
|
340
|
+
async onAgenticAgentResults(e, t, r = null) {
|
|
341
|
+
await this.ipc.call("onAgenticAgentResults", e, t, r);
|
|
303
342
|
}
|
|
304
343
|
async onAgenticStreamComplete(e = null) {
|
|
305
344
|
await this.ipc.call("onAgenticStreamComplete", e);
|
|
306
345
|
}
|
|
307
|
-
async onAgenticIssueStatusChanged(e, t,
|
|
308
|
-
await this.ipc.call("onAgenticIssueStatusChanged", e, t,
|
|
346
|
+
async onAgenticIssueStatusChanged(e, t, r) {
|
|
347
|
+
await this.ipc.call("onAgenticIssueStatusChanged", e, t, r);
|
|
309
348
|
}
|
|
310
349
|
async onAgenticIssuesCleared(e = null) {
|
|
311
350
|
await this.ipc.call("onAgenticIssuesCleared", e);
|
|
@@ -338,10 +377,10 @@ var J = class {
|
|
|
338
377
|
destroy() {
|
|
339
378
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
340
379
|
}
|
|
341
|
-
},
|
|
380
|
+
}, we = class {
|
|
342
381
|
ipcAdapter;
|
|
343
|
-
constructor(e, t,
|
|
344
|
-
this.ipcAdapter = new
|
|
382
|
+
constructor(e, t, r) {
|
|
383
|
+
this.ipcAdapter = new q(e, t, r);
|
|
345
384
|
}
|
|
346
385
|
destroy() {
|
|
347
386
|
this.ipcAdapter.destroy();
|
|
@@ -358,8 +397,8 @@ var J = class {
|
|
|
358
397
|
async getSelectedContent(e) {
|
|
359
398
|
return await this.ipcAdapter.getSelectedContent(e);
|
|
360
399
|
}
|
|
361
|
-
async replaceContent(e, t,
|
|
362
|
-
await this.ipcAdapter.replaceContent(e, t,
|
|
400
|
+
async replaceContent(e, t, r = null) {
|
|
401
|
+
await this.ipcAdapter.replaceContent(e, t, r);
|
|
363
402
|
}
|
|
364
403
|
async selectContent(e, t = null) {
|
|
365
404
|
await this.ipcAdapter.selectContent(e, t);
|
|
@@ -367,14 +406,14 @@ var J = class {
|
|
|
367
406
|
async replaceMultipleContents(e) {
|
|
368
407
|
await this.ipcAdapter.replaceMultipleContents(e);
|
|
369
408
|
}
|
|
370
|
-
onAgenticAgentResults(e, t,
|
|
371
|
-
return this.ipcAdapter.onAgenticAgentResults(e, t,
|
|
409
|
+
onAgenticAgentResults(e, t, r = null) {
|
|
410
|
+
return this.ipcAdapter.onAgenticAgentResults(e, t, r);
|
|
372
411
|
}
|
|
373
412
|
onAgenticStreamComplete(e = null) {
|
|
374
413
|
return this.ipcAdapter.onAgenticStreamComplete(e);
|
|
375
414
|
}
|
|
376
|
-
onAgenticIssueStatusChanged(e, t,
|
|
377
|
-
return this.ipcAdapter.onAgenticIssueStatusChanged(e, t,
|
|
415
|
+
onAgenticIssueStatusChanged(e, t, r) {
|
|
416
|
+
return this.ipcAdapter.onAgenticIssueStatusChanged(e, t, r);
|
|
378
417
|
}
|
|
379
418
|
onAgenticIssuesCleared(e = null) {
|
|
380
419
|
return this.ipcAdapter.onAgenticIssuesCleared(e);
|
|
@@ -397,48 +436,48 @@ var J = class {
|
|
|
397
436
|
getTargetOrigin() {
|
|
398
437
|
return this.ipcAdapter.getTargetOrigin();
|
|
399
438
|
}
|
|
400
|
-
},
|
|
439
|
+
}, Z = class {
|
|
401
440
|
ipc;
|
|
402
441
|
plugin;
|
|
403
442
|
iframe;
|
|
404
443
|
window;
|
|
405
444
|
targetOrigin;
|
|
406
445
|
latestSidebarBuildInfo = null;
|
|
407
|
-
constructor(e, t,
|
|
408
|
-
this.plugin = e, this.iframe = t, this.window =
|
|
446
|
+
constructor(e, t, r, n, i = "*") {
|
|
447
|
+
this.plugin = e, this.iframe = t, this.window = r ?? window, this.targetOrigin = i, this.ipc = new N((a) => {
|
|
409
448
|
this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
|
|
410
|
-
},
|
|
449
|
+
}, n), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
411
450
|
}
|
|
412
451
|
handleMessage = (e) => {
|
|
413
|
-
const t = this.window.location.origin,
|
|
414
|
-
e.origin !== t && (
|
|
452
|
+
const t = this.window.location.origin, r = this.targetOrigin;
|
|
453
|
+
e.origin !== t && (r !== "*" && e.origin !== r || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
415
454
|
};
|
|
416
455
|
registerReceivers() {
|
|
417
456
|
if (this.ipc.receive("getInitConfig", async (e) => {
|
|
418
|
-
const t =
|
|
457
|
+
const t = X(e);
|
|
419
458
|
return this.latestSidebarBuildInfo = t, {
|
|
420
459
|
...await this.plugin.getInitConfig(t ?? void 0),
|
|
421
|
-
hostAdapterVersion:
|
|
460
|
+
hostAdapterVersion: V
|
|
422
461
|
};
|
|
423
|
-
}), 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,
|
|
424
|
-
await this.plugin.replaceContent(e, t, typeof
|
|
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, r) => {
|
|
463
|
+
await this.plugin.replaceContent(e, t, typeof r == "string" ? r : null);
|
|
425
464
|
}), this.ipc.receive("selectContent", async (e, t) => {
|
|
426
465
|
await this.plugin.selectContent(e, typeof t == "string" ? t : null);
|
|
427
466
|
}), this.ipc.receive("replaceMultipleContents", async (e) => {
|
|
428
467
|
await this.plugin.replaceMultipleContents(e);
|
|
429
|
-
}), this.ipc.receive("onAgenticAgentResults", async (e, t,
|
|
468
|
+
}), this.ipc.receive("onAgenticAgentResults", async (e, t, r) => {
|
|
430
469
|
if (!Array.isArray(t))
|
|
431
470
|
return;
|
|
432
|
-
const
|
|
433
|
-
|
|
471
|
+
const n = this.plugin.onAgenticAgentResults;
|
|
472
|
+
n && await n(e, t, typeof r == "string" ? r : null);
|
|
434
473
|
}), this.ipc.receive("onAgenticStreamComplete", async (e) => {
|
|
435
474
|
const t = this.plugin.onAgenticStreamComplete;
|
|
436
475
|
t && await t(typeof e == "string" ? e : null);
|
|
437
|
-
}), this.ipc.receive("onAgenticIssueStatusChanged", async (e, t,
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
476
|
+
}), this.ipc.receive("onAgenticIssueStatusChanged", async (e, t, r) => {
|
|
477
|
+
const n = this.plugin.onAgenticIssueStatusChanged;
|
|
478
|
+
if (n && !(t !== "active" && t !== "resolved" && t !== "dismissed" || r !== "user" && r !== "host"))
|
|
440
479
|
try {
|
|
441
|
-
await
|
|
480
|
+
await n(e, t, r);
|
|
442
481
|
} catch {
|
|
443
482
|
}
|
|
444
483
|
}), this.ipc.receive("onAgenticIssuesCleared", async (e) => {
|
|
@@ -462,8 +501,8 @@ var J = class {
|
|
|
462
501
|
}
|
|
463
502
|
if (this.plugin.onIntegrationSettingsChange) {
|
|
464
503
|
const e = this.plugin.onIntegrationSettingsChange;
|
|
465
|
-
this.ipc.receive("onIntegrationSettingsChange", async (t,
|
|
466
|
-
await e(t,
|
|
504
|
+
this.ipc.receive("onIntegrationSettingsChange", async (t, r) => {
|
|
505
|
+
await e(t, r);
|
|
467
506
|
});
|
|
468
507
|
}
|
|
469
508
|
}
|
|
@@ -500,10 +539,10 @@ var J = class {
|
|
|
500
539
|
destroy() {
|
|
501
540
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
502
541
|
}
|
|
503
|
-
},
|
|
542
|
+
}, Q = class {
|
|
504
543
|
ipcAdapter;
|
|
505
|
-
constructor(e, t,
|
|
506
|
-
this.ipcAdapter = new
|
|
544
|
+
constructor(e, t, r) {
|
|
545
|
+
this.ipcAdapter = new Z(e, t, r?.win, r?.config, r?.targetOrigin);
|
|
507
546
|
}
|
|
508
547
|
destroy() {
|
|
509
548
|
this.ipcAdapter.destroy();
|
|
@@ -538,7 +577,7 @@ var J = class {
|
|
|
538
577
|
configure(e) {
|
|
539
578
|
this.ipcAdapter.configure(e);
|
|
540
579
|
}
|
|
541
|
-
},
|
|
580
|
+
}, ee = `
|
|
542
581
|
<div class="sidebar-load-overlay-card">
|
|
543
582
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
544
583
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -559,16 +598,16 @@ var J = class {
|
|
|
559
598
|
<span>Retry</span>
|
|
560
599
|
</button>
|
|
561
600
|
</div>
|
|
562
|
-
`,
|
|
601
|
+
`, te = () => {
|
|
563
602
|
const e = document.createElement("div");
|
|
564
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
603
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = ee;
|
|
565
604
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
566
605
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
567
606
|
return {
|
|
568
607
|
overlay: e,
|
|
569
608
|
button: t
|
|
570
609
|
};
|
|
571
|
-
},
|
|
610
|
+
}, T = "markupai-sidebar-load-overlay-styles", re = `
|
|
572
611
|
:root {
|
|
573
612
|
--background: #f5f5f4;
|
|
574
613
|
--foreground: #333332;
|
|
@@ -660,21 +699,21 @@ var J = class {
|
|
|
660
699
|
box-shadow: 0 0 0 2px
|
|
661
700
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
662
701
|
}
|
|
663
|
-
`,
|
|
702
|
+
`, ne = (e) => {
|
|
664
703
|
const t = e ?? document;
|
|
665
|
-
if (t.getElementById(
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
},
|
|
669
|
-
|
|
670
|
-
const { sidebarUrl:
|
|
704
|
+
if (t.getElementById(T)) return;
|
|
705
|
+
const r = t.createElement("style");
|
|
706
|
+
r.id = T, r.textContent = re, t.head.appendChild(r);
|
|
707
|
+
}, ie = 8e3, ae = 12e3, oe = (e, t, r = {}) => {
|
|
708
|
+
ne(e.ownerDocument);
|
|
709
|
+
const { sidebarUrl: n, targetOrigin: i, timeoutMs: a = ie, retryIntervalMs: o = ae, messageListenWindow: s } = r, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => n ?? t.src, j = () => {
|
|
671
710
|
if (i) return i;
|
|
672
711
|
try {
|
|
673
712
|
return new URL(p()).origin;
|
|
674
713
|
} catch {
|
|
675
714
|
return "*";
|
|
676
715
|
}
|
|
677
|
-
}, { overlay: y, button:
|
|
716
|
+
}, { overlay: y, button: A } = te();
|
|
678
717
|
e.appendChild(y);
|
|
679
718
|
let u = !1, h, d;
|
|
680
719
|
const g = (c) => {
|
|
@@ -683,82 +722,82 @@ var J = class {
|
|
|
683
722
|
g(!1);
|
|
684
723
|
const f = () => {
|
|
685
724
|
h && (globalThis.clearTimeout(h), h = void 0);
|
|
686
|
-
},
|
|
725
|
+
}, C = () => {
|
|
687
726
|
f(), h = globalThis.setTimeout(() => {
|
|
688
727
|
u || g(!0);
|
|
689
728
|
}, a);
|
|
690
|
-
},
|
|
729
|
+
}, b = (c) => {
|
|
691
730
|
const m = c?.preserveOverlay ?? !0;
|
|
692
|
-
u = !1, m || g(!1), t.src = p(),
|
|
693
|
-
},
|
|
731
|
+
u = !1, m || g(!1), t.src = p(), C();
|
|
732
|
+
}, F = () => {
|
|
694
733
|
d || o <= 0 || (d = globalThis.setInterval(() => {
|
|
695
|
-
u ||
|
|
734
|
+
u || b({ preserveOverlay: !0 });
|
|
696
735
|
}, o));
|
|
697
|
-
},
|
|
736
|
+
}, S = () => {
|
|
698
737
|
d && (globalThis.clearInterval(d), d = void 0);
|
|
699
|
-
},
|
|
738
|
+
}, w = (c) => {
|
|
700
739
|
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
701
|
-
const m =
|
|
702
|
-
m !== "*" && c.origin !== m || (u = !0, f(),
|
|
703
|
-
}, w = () => {
|
|
704
|
-
f(), g(!0);
|
|
740
|
+
const m = j();
|
|
741
|
+
m !== "*" && c.origin !== m || (u = !0, f(), S(), g(!1));
|
|
705
742
|
}, P = () => {
|
|
706
|
-
|
|
743
|
+
f(), g(!0);
|
|
744
|
+
}, E = () => {
|
|
745
|
+
b();
|
|
707
746
|
};
|
|
708
|
-
return
|
|
709
|
-
f(),
|
|
747
|
+
return A.addEventListener("click", E), t.addEventListener("error", P), l.addEventListener("message", w), C(), F(), () => {
|
|
748
|
+
f(), S(), t.removeEventListener("error", P), l.removeEventListener("message", w), A.removeEventListener("click", E), y.remove();
|
|
710
749
|
};
|
|
711
|
-
},
|
|
712
|
-
function
|
|
750
|
+
}, se = "Markup AI Sidebar", le = "clipboard-read; clipboard-write", Pe = "markupai.sidebarNextGen.overrideUrl", Ee = "https://sidebar.markup.ai/";
|
|
751
|
+
function Re(e) {
|
|
713
752
|
try {
|
|
714
753
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
715
754
|
} catch {
|
|
716
755
|
return e;
|
|
717
756
|
}
|
|
718
757
|
}
|
|
719
|
-
var
|
|
720
|
-
function
|
|
758
|
+
var ce = "markupai.sidebarNextGen.authOverride";
|
|
759
|
+
function Oe(e, t) {
|
|
721
760
|
if (!t) return e;
|
|
722
761
|
try {
|
|
723
762
|
if (!("localStorage" in globalThis)) return e;
|
|
724
|
-
const
|
|
725
|
-
if (!
|
|
726
|
-
const
|
|
727
|
-
return
|
|
763
|
+
const r = globalThis.localStorage.getItem(ce)?.trim();
|
|
764
|
+
if (!r) return e;
|
|
765
|
+
const n = JSON.parse(r);
|
|
766
|
+
return n !== null && typeof n == "object" && "type" in n && (n.type === "mediation" || n.type === "popup") ? n : e;
|
|
728
767
|
} catch {
|
|
729
768
|
return e;
|
|
730
769
|
}
|
|
731
770
|
}
|
|
732
|
-
function
|
|
771
|
+
function Te(e, t) {
|
|
733
772
|
try {
|
|
734
773
|
return new URL(e).origin;
|
|
735
|
-
} catch (
|
|
736
|
-
return t?.onInvalidUrl?.(e,
|
|
774
|
+
} catch (r) {
|
|
775
|
+
return t?.onInvalidUrl?.(e, r), "*";
|
|
737
776
|
}
|
|
738
777
|
}
|
|
739
|
-
function
|
|
778
|
+
function De(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
740
779
|
if (e.adapter === null) throw new Error(t);
|
|
741
780
|
}
|
|
742
|
-
function
|
|
743
|
-
const { iframe: t, iframeMount:
|
|
744
|
-
if (t !== void 0 &&
|
|
781
|
+
function de(e) {
|
|
782
|
+
const { iframe: t, iframeMount: r } = e;
|
|
783
|
+
if (t !== void 0 && r !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
745
784
|
if (t !== void 0) return {
|
|
746
785
|
iframe: t,
|
|
747
786
|
removeMountedIframe: null
|
|
748
787
|
};
|
|
749
|
-
if (
|
|
750
|
-
const { container:
|
|
751
|
-
return o.title =
|
|
788
|
+
if (r === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
789
|
+
const { container: n, src: i, allow: a = le } = r, o = document.createElement("iframe");
|
|
790
|
+
return o.title = se, o.src = i, a && o.setAttribute("allow", a), n.appendChild(o), {
|
|
752
791
|
iframe: o,
|
|
753
792
|
removeMountedIframe: () => {
|
|
754
793
|
o.remove();
|
|
755
794
|
}
|
|
756
795
|
};
|
|
757
796
|
}
|
|
758
|
-
function
|
|
759
|
-
const { plugin: t, loadOverlayContainer:
|
|
797
|
+
function xe(e) {
|
|
798
|
+
const { plugin: t, loadOverlayContainer: r, loadOverlayOptions: n, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } = de(e), s = r !== void 0 ? oe(r, a, n ?? {}) : null;
|
|
760
799
|
if (t !== void 0) {
|
|
761
|
-
const l = new
|
|
800
|
+
const l = new Q(t, a, i);
|
|
762
801
|
return {
|
|
763
802
|
iframe: a,
|
|
764
803
|
adapter: l,
|
|
@@ -775,14 +814,14 @@ function Ee(e) {
|
|
|
775
814
|
}
|
|
776
815
|
};
|
|
777
816
|
}
|
|
778
|
-
var
|
|
779
|
-
function
|
|
817
|
+
var H = "sidebarContainer", D = "markupai-sidebar-host-shell-styles";
|
|
818
|
+
function U(e) {
|
|
780
819
|
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
781
820
|
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)})`);
|
|
782
821
|
return e;
|
|
783
822
|
}
|
|
784
|
-
function
|
|
785
|
-
const t =
|
|
823
|
+
function $(e = H) {
|
|
824
|
+
const t = U(e);
|
|
786
825
|
return `
|
|
787
826
|
html {
|
|
788
827
|
height: 100%;
|
|
@@ -807,41 +846,41 @@ body {
|
|
|
807
846
|
}
|
|
808
847
|
`.trim();
|
|
809
848
|
}
|
|
810
|
-
var
|
|
811
|
-
function
|
|
849
|
+
var Me = $();
|
|
850
|
+
function ge(e) {
|
|
812
851
|
return e instanceof Document ? e : e.ownerDocument;
|
|
813
852
|
}
|
|
814
|
-
function
|
|
815
|
-
if (!t || e.getElementById(
|
|
816
|
-
const
|
|
817
|
-
|
|
853
|
+
function pe(e, t, r) {
|
|
854
|
+
if (!t || e.getElementById(D)) return;
|
|
855
|
+
const n = e.createElement("style");
|
|
856
|
+
n.id = D, n.textContent = $(r), e.head.appendChild(n);
|
|
818
857
|
}
|
|
819
|
-
function
|
|
820
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId:
|
|
858
|
+
function _e(e) {
|
|
859
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: r = H, includeDefaultStyles: n = !0 } = e ?? {};
|
|
821
860
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
822
|
-
const i =
|
|
823
|
-
|
|
824
|
-
const a = t instanceof Document ? i.getElementById(
|
|
861
|
+
const i = ge(t);
|
|
862
|
+
pe(i, n, r);
|
|
863
|
+
const a = t instanceof Document ? i.getElementById(r) : t.querySelector(`#${U(r)}`);
|
|
825
864
|
if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
|
|
826
865
|
if (!(t instanceof Document)) {
|
|
827
866
|
const s = i.createElement("div");
|
|
828
|
-
return s.id =
|
|
867
|
+
return s.id = r, t.appendChild(s), s;
|
|
829
868
|
}
|
|
830
869
|
const o = i.createElement("div");
|
|
831
|
-
return o.id =
|
|
870
|
+
return o.id = r, i.body.appendChild(o), o;
|
|
832
871
|
}
|
|
833
|
-
function
|
|
872
|
+
function ue() {
|
|
834
873
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
835
874
|
}
|
|
836
|
-
function
|
|
837
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml:
|
|
875
|
+
function Le(e) {
|
|
876
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: r = "", includePluginHostHead: n = !1, bodyScriptsHtml: i, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [n ? ue() : "", r].filter((p) => p.trim().length > 0).join(`
|
|
838
877
|
`);
|
|
839
878
|
return `<!DOCTYPE html>
|
|
840
879
|
<html ${o}>
|
|
841
880
|
<head>
|
|
842
881
|
<base target="_top" />
|
|
843
882
|
<meta charset="UTF-8" />
|
|
844
|
-
<title>${
|
|
883
|
+
<title>${he(t)}</title>${l ? `
|
|
845
884
|
${l}` : ""}
|
|
846
885
|
</head>
|
|
847
886
|
<body ${s}>
|
|
@@ -850,44 +889,46 @@ ${l}` : ""}
|
|
|
850
889
|
</html>
|
|
851
890
|
`;
|
|
852
891
|
}
|
|
853
|
-
function
|
|
892
|
+
function he(e) {
|
|
854
893
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
855
894
|
}
|
|
856
895
|
export {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
896
|
+
V as ADAPTER_VERSION,
|
|
897
|
+
ce as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
898
|
+
G as DEFAULT_IPC_CONFIG,
|
|
899
|
+
ye as DEFAULT_SIDEBAR_CONFIG,
|
|
900
|
+
W as DeferredPromise,
|
|
901
|
+
N as IPCCore,
|
|
902
|
+
fe as MimeType,
|
|
903
|
+
we as PluginAdapter,
|
|
904
|
+
q as PluginIPCAdapter,
|
|
905
|
+
M as ReplaceBatchError,
|
|
906
|
+
Ee as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
907
|
+
H as SIDEBAR_HOST_CONTAINER_ID,
|
|
908
|
+
Me as SIDEBAR_HOST_SHELL_CSS,
|
|
909
|
+
le as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
910
|
+
se as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
911
|
+
Pe as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
912
|
+
Q as SidebarAdapter,
|
|
913
|
+
Z as SidebarIPCAdapter,
|
|
914
|
+
me as TEXT_MIME_TYPES,
|
|
915
|
+
v as TextLookupError,
|
|
916
|
+
De as assertSidebarHostAdapter,
|
|
917
|
+
Se as buildDocumentReference,
|
|
918
|
+
Le as buildSidebarHostHtmlDocument,
|
|
919
|
+
$ as buildSidebarHostShellCss,
|
|
920
|
+
ue as buildSidebarPluginHostHeadInnerHtml,
|
|
921
|
+
xe as createSidebarHost,
|
|
922
|
+
_e as ensureSidebarHostShell,
|
|
923
|
+
Oe as getAuthConfigWithOverride,
|
|
924
|
+
Re as getSidebarBaseUrlWithOverride,
|
|
925
|
+
O as ipcErrorReconstructors,
|
|
926
|
+
be as isDocumentReference,
|
|
927
|
+
ve as isIntegrationSettingField,
|
|
928
|
+
Ie as isIntegrationSettingsSchema,
|
|
929
|
+
Ae as isReplaceBatchError,
|
|
930
|
+
Ce as isTextLookupError,
|
|
931
|
+
z as reconstructError,
|
|
932
|
+
oe as setupSidebarLoadOverlay,
|
|
933
|
+
Te as sidebarPostMessageTargetOrigin
|
|
893
934
|
};
|