@markupai/sidebar-adapter 2.4.0 → 2.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 +41 -8
- package/asyncapi.json +62 -5
- package/dist/adapters/pluginAdapter.d.ts +6 -2
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/ipc/call-signatures.d.ts +8 -0
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/index.d.ts +4 -4
- package/dist/ipc/index.d.ts.map +1 -1
- package/dist/ipc/ipc-core.d.ts +31 -2
- package/dist/ipc/ipc-core.d.ts.map +1 -1
- package/dist/ipc/message-types.d.ts +35 -4
- package/dist/ipc/message-types.d.ts.map +1 -1
- package/dist/ipc/plugin-ipc-adapter.d.ts +6 -2
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/replace-progress.d.ts +9 -0
- package/dist/ipc/replace-progress.d.ts.map +1 -0
- package/dist/main.js +399 -303
- package/dist/main.umd.cjs +7 -7
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +12 -1
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/dist/types/progress.d.ts +18 -0
- package/dist/types/progress.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Pe = /* @__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
|
+
})({}), Ee = [
|
|
4
4
|
"text/plain",
|
|
5
5
|
"text/markdown",
|
|
6
6
|
"text/html",
|
|
7
7
|
"application/dita+xml"
|
|
8
|
-
],
|
|
8
|
+
], Re = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
@@ -14,80 +14,88 @@ var fe = /* @__PURE__ */ (function(e) {
|
|
|
14
14
|
supportComments: !1,
|
|
15
15
|
multiAgent: !1,
|
|
16
16
|
multiDocument: !1
|
|
17
|
-
},
|
|
17
|
+
}, Oe = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), Te = (e) => {
|
|
18
18
|
if (typeof e != "object" || e === null) return !1;
|
|
19
19
|
const t = e;
|
|
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((
|
|
21
|
-
if (typeof
|
|
22
|
-
const
|
|
23
|
-
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((r) => {
|
|
21
|
+
if (typeof r != "object" || r === null) return !1;
|
|
22
|
+
const n = r;
|
|
23
|
+
return typeof n.value == "string" && typeof n.label == "string";
|
|
24
24
|
}) : !1;
|
|
25
|
-
},
|
|
25
|
+
}, Y = "2.5.0", A = class _ extends Error {
|
|
26
26
|
name = "TextLookupError";
|
|
27
27
|
constructor(t) {
|
|
28
|
-
super(t), Object.setPrototypeOf(this,
|
|
28
|
+
super(t), Object.setPrototypeOf(this, _.prototype);
|
|
29
29
|
}
|
|
30
|
-
},
|
|
30
|
+
}, L = class k extends A {
|
|
31
31
|
name = "ReplaceBatchError";
|
|
32
32
|
applied;
|
|
33
33
|
failed;
|
|
34
|
-
constructor(t,
|
|
35
|
-
super(t), this.applied =
|
|
36
|
-
start:
|
|
37
|
-
end:
|
|
38
|
-
})), this.failed =
|
|
34
|
+
constructor(t, r) {
|
|
35
|
+
super(t), this.applied = r.applied.map((n) => ({
|
|
36
|
+
start: n.start,
|
|
37
|
+
end: n.end
|
|
38
|
+
})), this.failed = r.failed.map((n) => U(n, n.message)), Object.setPrototypeOf(this, k.prototype);
|
|
39
|
+
}
|
|
40
|
+
}, N = class B extends Error {
|
|
41
|
+
name = "IpcTimeoutError";
|
|
42
|
+
constructor(t, r, n) {
|
|
43
|
+
super(`IPC call timeout: "${t}" did not respond within ${String(r)}ms` + (n === void 0 ? "" : ` (timeout ${String(n)} could not be used)`)), Object.setPrototypeOf(this, B.prototype);
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
|
-
function
|
|
42
|
-
return e instanceof
|
|
46
|
+
function De(e) {
|
|
47
|
+
return e instanceof N;
|
|
48
|
+
}
|
|
49
|
+
function Me(e) {
|
|
50
|
+
return e instanceof L;
|
|
43
51
|
}
|
|
44
|
-
function
|
|
45
|
-
const
|
|
52
|
+
function U(e, t) {
|
|
53
|
+
const r = {
|
|
46
54
|
start: e.start,
|
|
47
55
|
end: e.end
|
|
48
56
|
};
|
|
49
|
-
return typeof t == "string" && t.trim() !== "" && (
|
|
57
|
+
return typeof t == "string" && t.trim() !== "" && (r.message = t), r;
|
|
50
58
|
}
|
|
51
|
-
function
|
|
59
|
+
function O(e) {
|
|
52
60
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
53
61
|
if (t === null || typeof t != "object") return [];
|
|
54
|
-
const { start:
|
|
55
|
-
return typeof
|
|
62
|
+
const { start: r, end: n, message: i } = t;
|
|
63
|
+
return typeof r != "number" || typeof n != "number" ? [] : [{
|
|
56
64
|
range: {
|
|
57
|
-
start:
|
|
58
|
-
end:
|
|
65
|
+
start: r,
|
|
66
|
+
end: n
|
|
59
67
|
},
|
|
60
68
|
message: i
|
|
61
69
|
}];
|
|
62
70
|
}) : [];
|
|
63
71
|
}
|
|
64
|
-
function
|
|
65
|
-
return e instanceof
|
|
72
|
+
function xe(e) {
|
|
73
|
+
return e instanceof A;
|
|
66
74
|
}
|
|
67
|
-
var
|
|
68
|
-
TextLookupError: (e) => new
|
|
69
|
-
ReplaceBatchError: (e, t) => new
|
|
70
|
-
applied:
|
|
71
|
-
failed:
|
|
75
|
+
var T = {
|
|
76
|
+
TextLookupError: (e) => new A(e),
|
|
77
|
+
ReplaceBatchError: (e, t) => new L(e, {
|
|
78
|
+
applied: O(t.applied).map((r) => r.range),
|
|
79
|
+
failed: O(t.failed).map((r) => U(r.range, r.message))
|
|
72
80
|
})
|
|
73
81
|
};
|
|
74
|
-
function
|
|
75
|
-
const t = e.message ?? "",
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
var
|
|
79
|
-
function
|
|
80
|
-
const t = e.indexOf(
|
|
81
|
-
return t <= 0 || t === e.length - 1 ? !1 :
|
|
82
|
-
}
|
|
83
|
-
function
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
if (
|
|
87
|
-
const i = `${
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
var
|
|
82
|
+
function X(e) {
|
|
83
|
+
const t = e.message ?? "", r = e.name, n = typeof r == "string" && r in T ? T[r] : void 0;
|
|
84
|
+
return n ? n(t, e) : Object.assign(new Error(t), r ? { name: r } : {});
|
|
85
|
+
}
|
|
86
|
+
var H = ":", $ = /^[a-z][a-z0-9-]*$/;
|
|
87
|
+
function _e(e) {
|
|
88
|
+
const t = e.indexOf(H);
|
|
89
|
+
return t <= 0 || t === e.length - 1 ? !1 : $.test(e.slice(0, t));
|
|
90
|
+
}
|
|
91
|
+
function Le(e, t) {
|
|
92
|
+
const r = e.trim().toLowerCase(), n = t.trim();
|
|
93
|
+
if (!$.test(r)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
|
|
94
|
+
if (n.length === 0) throw new Error("Invalid document reference: the document id is empty.");
|
|
95
|
+
const i = `${r}${H}`;
|
|
96
|
+
return n.startsWith(i) ? n : `${i}${n}`;
|
|
97
|
+
}
|
|
98
|
+
var K = class extends Promise {
|
|
91
99
|
static get [Symbol.species]() {
|
|
92
100
|
return Promise;
|
|
93
101
|
}
|
|
@@ -95,29 +103,49 @@ var W = class extends Promise {
|
|
|
95
103
|
reject;
|
|
96
104
|
constructor(e = () => {
|
|
97
105
|
}) {
|
|
98
|
-
let t,
|
|
99
|
-
super((
|
|
100
|
-
t =
|
|
101
|
-
}), this.resolve = t, this.reject =
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
+
let t, r;
|
|
107
|
+
super((n, i) => {
|
|
108
|
+
t = n, r = i, e(n, i);
|
|
109
|
+
}), this.resolve = t, this.reject = r;
|
|
110
|
+
}
|
|
111
|
+
}, j = { timeout: 1e4 };
|
|
112
|
+
function I(e, t) {
|
|
113
|
+
try {
|
|
114
|
+
e?.(t);
|
|
115
|
+
} catch {
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function q(e) {
|
|
119
|
+
const t = typeof e == "object" && e !== null ? Object.fromEntries(Object.getOwnPropertyNames(e).map((s) => [s, e[s]])) : {}, 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;
|
|
106
120
|
return JSON.stringify({
|
|
107
121
|
...t,
|
|
108
|
-
message:
|
|
122
|
+
message: n,
|
|
109
123
|
...a !== void 0 && { name: a }
|
|
110
124
|
});
|
|
111
125
|
}
|
|
112
|
-
|
|
126
|
+
function Z(e) {
|
|
127
|
+
try {
|
|
128
|
+
return X(JSON.parse(e));
|
|
129
|
+
} catch {
|
|
130
|
+
return /* @__PURE__ */ new Error("Failed to parse error from IPC");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
var Q = 3e5, ee = 2147483647;
|
|
134
|
+
function te(e, t) {
|
|
135
|
+
const r = (i) => !Number.isNaN(i) && i > 0;
|
|
136
|
+
let n = j.timeout;
|
|
137
|
+
return r(e) ? n = e : r(t) && (n = t), Math.min(Math.max(1, Math.ceil(n)), ee);
|
|
138
|
+
}
|
|
139
|
+
var F = class {
|
|
113
140
|
promisesByID = {};
|
|
114
141
|
receiversByName = {};
|
|
142
|
+
progressReceiverNames = /* @__PURE__ */ new Set();
|
|
115
143
|
currentID = 0;
|
|
116
144
|
config;
|
|
117
145
|
postMessage;
|
|
118
146
|
constructor(e, t) {
|
|
119
147
|
this.postMessage = e, this.config = {
|
|
120
|
-
...
|
|
148
|
+
...j,
|
|
121
149
|
...t
|
|
122
150
|
};
|
|
123
151
|
}
|
|
@@ -130,30 +158,39 @@ var N = class {
|
|
|
130
158
|
call(e, ...t) {
|
|
131
159
|
return this.callWithOptions(e, {}, ...t);
|
|
132
160
|
}
|
|
133
|
-
callWithOptions(e, t, ...
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
161
|
+
callWithOptions(e, t, ...r) {
|
|
162
|
+
const n = t.timeout ?? this.config.timeout, i = te(n, this.config.timeout), a = this.currentID++, s = new K(), o = setTimeout(() => {
|
|
163
|
+
if (a in this.promisesByID)
|
|
164
|
+
if (s.reject(new N(e, i, i === n ? void 0 : n)), t.onProgress || t.onLateResult) {
|
|
165
|
+
const c = this.promisesByID[a];
|
|
166
|
+
c.timedOut = !0, c.timeoutId = setTimeout(() => {
|
|
167
|
+
this.promisesByID[a] === c && Reflect.deleteProperty(this.promisesByID, a);
|
|
168
|
+
}, Q);
|
|
169
|
+
} else Reflect.deleteProperty(this.promisesByID, a);
|
|
170
|
+
}, i);
|
|
171
|
+
this.promisesByID[a] = {
|
|
172
|
+
promise: s,
|
|
173
|
+
timeoutId: o,
|
|
174
|
+
onProgress: t.onProgress,
|
|
175
|
+
onLateResult: t.onLateResult,
|
|
176
|
+
timedOut: !1
|
|
143
177
|
};
|
|
144
|
-
const
|
|
178
|
+
const l = {
|
|
145
179
|
type: "call",
|
|
146
|
-
id:
|
|
180
|
+
id: a,
|
|
147
181
|
name: e,
|
|
148
|
-
data:
|
|
182
|
+
data: r
|
|
149
183
|
};
|
|
150
|
-
return this.postMessage(
|
|
184
|
+
return this.postMessage(l), s;
|
|
151
185
|
}
|
|
152
186
|
receive(e, t) {
|
|
153
|
-
this.receiversByName[e] = t;
|
|
187
|
+
this.receiversByName[e] = t, this.progressReceiverNames.delete(e);
|
|
188
|
+
}
|
|
189
|
+
receiveWithProgress(e, t) {
|
|
190
|
+
this.receiversByName[e] = t, this.progressReceiverNames.add(e);
|
|
154
191
|
}
|
|
155
192
|
ignore(e) {
|
|
156
|
-
delete this.receiversByName[e];
|
|
193
|
+
delete this.receiversByName[e], this.progressReceiverNames.delete(e);
|
|
157
194
|
}
|
|
158
195
|
async handleMessage(e) {
|
|
159
196
|
switch (e.type) {
|
|
@@ -166,116 +203,164 @@ var N = class {
|
|
|
166
203
|
case "error":
|
|
167
204
|
this.handleError(e);
|
|
168
205
|
break;
|
|
206
|
+
case "progress":
|
|
207
|
+
this.handleProgress(e);
|
|
208
|
+
break;
|
|
169
209
|
default:
|
|
170
210
|
}
|
|
171
211
|
}
|
|
172
212
|
async handleCall(e) {
|
|
173
|
-
const { id: t, name:
|
|
174
|
-
if (!(
|
|
175
|
-
const
|
|
176
|
-
message:
|
|
177
|
-
name:
|
|
213
|
+
const { id: t, name: r, data: n } = e;
|
|
214
|
+
if (!(r in this.receiversByName)) {
|
|
215
|
+
const o = /* @__PURE__ */ new Error(`No receiver registered for: ${r}`), l = JSON.stringify({
|
|
216
|
+
message: o.message,
|
|
217
|
+
name: o.name
|
|
178
218
|
});
|
|
179
219
|
this.postMessage({
|
|
180
220
|
type: "error",
|
|
181
221
|
id: t,
|
|
182
|
-
name:
|
|
183
|
-
errorJSON:
|
|
222
|
+
name: r,
|
|
223
|
+
errorJSON: l
|
|
184
224
|
});
|
|
185
225
|
return;
|
|
186
226
|
}
|
|
187
|
-
const i = this.receiversByName[
|
|
227
|
+
const i = this.receiversByName[r];
|
|
228
|
+
let a = !1;
|
|
229
|
+
const s = (o) => {
|
|
230
|
+
if (!a)
|
|
231
|
+
try {
|
|
232
|
+
this.postMessage({
|
|
233
|
+
type: "progress",
|
|
234
|
+
id: t,
|
|
235
|
+
name: r,
|
|
236
|
+
data: o
|
|
237
|
+
});
|
|
238
|
+
} catch {
|
|
239
|
+
}
|
|
240
|
+
};
|
|
188
241
|
try {
|
|
189
|
-
if (!Array.isArray(
|
|
190
|
-
const
|
|
242
|
+
if (!Array.isArray(n)) throw new TypeError(`IPC: Expected array of arguments but got ${typeof n}`);
|
|
243
|
+
const o = n, l = await (this.progressReceiverNames.has(r) ? i(s, ...o) : i(...o));
|
|
244
|
+
a = !0;
|
|
245
|
+
const c = {
|
|
191
246
|
type: "response",
|
|
192
247
|
id: t,
|
|
193
|
-
name:
|
|
194
|
-
data:
|
|
248
|
+
name: r,
|
|
249
|
+
data: l
|
|
195
250
|
};
|
|
196
|
-
this.postMessage(
|
|
197
|
-
} catch (
|
|
198
|
-
|
|
251
|
+
this.postMessage(c);
|
|
252
|
+
} catch (o) {
|
|
253
|
+
a = !0;
|
|
254
|
+
const l = {
|
|
199
255
|
type: "error",
|
|
200
256
|
id: t,
|
|
201
|
-
name:
|
|
202
|
-
errorJSON:
|
|
257
|
+
name: r,
|
|
258
|
+
errorJSON: q(o)
|
|
203
259
|
};
|
|
204
|
-
this.postMessage(
|
|
260
|
+
this.postMessage(l);
|
|
205
261
|
}
|
|
206
262
|
}
|
|
207
263
|
handleResponse(e) {
|
|
208
264
|
const { id: t } = e;
|
|
209
265
|
if (t in this.promisesByID) {
|
|
210
|
-
const { promise:
|
|
211
|
-
clearTimeout(
|
|
266
|
+
const { promise: r, timeoutId: n, timedOut: i, onLateResult: a } = this.promisesByID[t];
|
|
267
|
+
if (clearTimeout(n), Reflect.deleteProperty(this.promisesByID, t), i) {
|
|
268
|
+
I(a, { status: "success" });
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
r.resolve(e.data);
|
|
212
272
|
}
|
|
213
273
|
}
|
|
214
274
|
handleError(e) {
|
|
215
|
-
const { id: t, errorJSON:
|
|
275
|
+
const { id: t, errorJSON: r } = e;
|
|
216
276
|
if (t in this.promisesByID) {
|
|
217
|
-
const { promise:
|
|
218
|
-
clearTimeout(i);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
277
|
+
const { promise: n, timeoutId: i, timedOut: a, onLateResult: s } = this.promisesByID[t];
|
|
278
|
+
clearTimeout(i), Reflect.deleteProperty(this.promisesByID, t);
|
|
279
|
+
const o = Z(r);
|
|
280
|
+
if (a) {
|
|
281
|
+
I(s, {
|
|
282
|
+
status: "error",
|
|
283
|
+
error: o
|
|
284
|
+
});
|
|
285
|
+
return;
|
|
224
286
|
}
|
|
225
|
-
|
|
287
|
+
n.reject(o);
|
|
226
288
|
}
|
|
227
289
|
}
|
|
290
|
+
handleProgress(e) {
|
|
291
|
+
const { id: t } = e;
|
|
292
|
+
t in this.promisesByID && I(this.promisesByID[t].onProgress, e.data);
|
|
293
|
+
}
|
|
228
294
|
destroy() {
|
|
229
295
|
for (const { promise: e, timeoutId: t } of Object.values(this.promisesByID))
|
|
230
296
|
clearTimeout(t), e.reject(/* @__PURE__ */ new Error("IPC destroyed"));
|
|
231
|
-
this.promisesByID = {}, this.receiversByName = {};
|
|
297
|
+
this.promisesByID = {}, this.receiversByName = {}, this.progressReceiverNames.clear();
|
|
232
298
|
}
|
|
233
299
|
};
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
300
|
+
function re(e) {
|
|
301
|
+
if (typeof e != "object" || e === null) return !1;
|
|
302
|
+
const { start: t, end: r } = e;
|
|
303
|
+
return typeof t == "number" && typeof r == "number";
|
|
304
|
+
}
|
|
305
|
+
var D = (e) => `${String(e.start)}:${String(e.end)}`;
|
|
306
|
+
function ne(e, t) {
|
|
307
|
+
if (typeof e != "object" || e === null) return null;
|
|
308
|
+
const { total: r, applied: n } = e;
|
|
309
|
+
if (typeof r != "number" || !Array.isArray(n) || !n.every(re)) return null;
|
|
310
|
+
const i = new Set(t.map(({ range: a }) => D(a)));
|
|
311
|
+
return {
|
|
312
|
+
total: r,
|
|
313
|
+
applied: n.filter((a) => i.has(D(a))).map(({ start: a, end: s }) => ({
|
|
314
|
+
start: a,
|
|
315
|
+
end: s
|
|
316
|
+
}))
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
var ie = /* @__PURE__ */ new Set(["auto", "prompt"]), v = (e, t) => {
|
|
320
|
+
const r = e[t];
|
|
321
|
+
if (!(typeof r != "string" || r.length === 0))
|
|
322
|
+
return r.slice(0, 64);
|
|
238
323
|
};
|
|
239
|
-
function
|
|
324
|
+
function ae(e) {
|
|
240
325
|
if (typeof e != "object" || e === null || Array.isArray(e)) return null;
|
|
241
|
-
const t = e,
|
|
242
|
-
if (
|
|
326
|
+
const t = e, r = v(t, "version"), n = v(t, "commitHash");
|
|
327
|
+
if (r === void 0 || n === void 0) return null;
|
|
243
328
|
const i = {
|
|
244
|
-
version:
|
|
245
|
-
commitHash:
|
|
329
|
+
version: r,
|
|
330
|
+
commitHash: n
|
|
246
331
|
};
|
|
247
|
-
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled),
|
|
248
|
-
const a =
|
|
332
|
+
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled), ie.has(t.pwaUpdateMode) && (i.pwaUpdateMode = t.pwaUpdateMode);
|
|
333
|
+
const a = v(t, "adapterVersion");
|
|
249
334
|
return a !== void 0 && (i.adapterVersion = a), i;
|
|
250
335
|
}
|
|
251
|
-
function
|
|
336
|
+
function se(e) {
|
|
252
337
|
return typeof e != "string" || e.length === 0 ? null : e.slice(0, 64);
|
|
253
338
|
}
|
|
254
|
-
var
|
|
339
|
+
var oe = class {
|
|
255
340
|
ipc;
|
|
256
341
|
sidebar;
|
|
257
342
|
targetOrigin;
|
|
258
343
|
latestHostAdapterVersion = null;
|
|
259
|
-
constructor(e, t,
|
|
260
|
-
this.sidebar = e || {}, this.targetOrigin =
|
|
261
|
-
window.parent.postMessage(
|
|
344
|
+
constructor(e, t, r = "*") {
|
|
345
|
+
this.sidebar = e || {}, this.targetOrigin = r, this.ipc = new F((n) => {
|
|
346
|
+
window.parent.postMessage(n, this.targetOrigin);
|
|
262
347
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
263
348
|
}
|
|
264
349
|
handleMessage = (e) => {
|
|
265
|
-
const t = globalThis.window.location.origin,
|
|
266
|
-
e.origin !== t && (
|
|
350
|
+
const t = globalThis.window.location.origin, r = this.targetOrigin;
|
|
351
|
+
e.origin !== t && (r !== "*" && e.origin !== r || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
267
352
|
};
|
|
268
353
|
registerReceivers() {
|
|
269
354
|
if (this.sidebar.onPluginStatusChange) {
|
|
270
355
|
const e = this.sidebar.onPluginStatusChange;
|
|
271
|
-
this.ipc.receive("onPluginStatusChange", async (t,
|
|
272
|
-
await e(t,
|
|
356
|
+
this.ipc.receive("onPluginStatusChange", async (t, r) => {
|
|
357
|
+
await e(t, r);
|
|
273
358
|
});
|
|
274
359
|
}
|
|
275
360
|
if (this.sidebar.activateAgenticIssue) {
|
|
276
361
|
const e = this.sidebar.activateAgenticIssue;
|
|
277
|
-
this.ipc.receive("activateAgenticIssue", async (t,
|
|
278
|
-
await e(t, typeof
|
|
362
|
+
this.ipc.receive("activateAgenticIssue", async (t, r) => {
|
|
363
|
+
await e(t, typeof r == "string" ? r : null);
|
|
279
364
|
});
|
|
280
365
|
}
|
|
281
366
|
if (this.sidebar.invalidateAgenticIssue) {
|
|
@@ -314,11 +399,11 @@ var q = class {
|
|
|
314
399
|
}
|
|
315
400
|
}
|
|
316
401
|
async getInitConfig(e) {
|
|
317
|
-
const { hostAdapterVersion: t, ...
|
|
402
|
+
const { hostAdapterVersion: t, ...r } = e ? await this.ipc.call("getInitConfig", {
|
|
318
403
|
...e,
|
|
319
|
-
adapterVersion: e.adapterVersion ?? "2.
|
|
404
|
+
adapterVersion: e.adapterVersion ?? "2.5.0"
|
|
320
405
|
}) : await this.ipc.call("getInitConfig");
|
|
321
|
-
return this.latestHostAdapterVersion =
|
|
406
|
+
return this.latestHostAdapterVersion = se(t), r;
|
|
322
407
|
}
|
|
323
408
|
getHostAdapterVersion() {
|
|
324
409
|
return this.latestHostAdapterVersion;
|
|
@@ -329,23 +414,30 @@ var q = class {
|
|
|
329
414
|
async getSelectedContent(e) {
|
|
330
415
|
return this.ipc.callWithOptions("getSelectedContent", e ?? {});
|
|
331
416
|
}
|
|
332
|
-
async replaceContent(e, t,
|
|
333
|
-
await this.ipc.call("replaceContent", e, t,
|
|
417
|
+
async replaceContent(e, t, r = null) {
|
|
418
|
+
await this.ipc.call("replaceContent", e, t, r);
|
|
334
419
|
}
|
|
335
420
|
async selectContent(e, t = null) {
|
|
336
421
|
await this.ipc.call("selectContent", e, t);
|
|
337
422
|
}
|
|
338
|
-
async replaceMultipleContents(e) {
|
|
339
|
-
|
|
423
|
+
async replaceMultipleContents(e, t) {
|
|
424
|
+
const { onProgress: r, ...n } = t ?? {};
|
|
425
|
+
await this.ipc.callWithOptions("replaceMultipleContents", {
|
|
426
|
+
...n,
|
|
427
|
+
...r && { onProgress: (i) => {
|
|
428
|
+
const a = ne(i, e);
|
|
429
|
+
a && r(a);
|
|
430
|
+
} }
|
|
431
|
+
}, e);
|
|
340
432
|
}
|
|
341
|
-
async onAgenticAgentResults(e, t,
|
|
342
|
-
await this.ipc.call("onAgenticAgentResults", e, t,
|
|
433
|
+
async onAgenticAgentResults(e, t, r = null) {
|
|
434
|
+
await this.ipc.call("onAgenticAgentResults", e, t, r);
|
|
343
435
|
}
|
|
344
436
|
async onAgenticStreamComplete(e = null) {
|
|
345
437
|
await this.ipc.call("onAgenticStreamComplete", e);
|
|
346
438
|
}
|
|
347
|
-
async onAgenticIssueStatusChanged(e, t,
|
|
348
|
-
await this.ipc.call("onAgenticIssueStatusChanged", e, t,
|
|
439
|
+
async onAgenticIssueStatusChanged(e, t, r) {
|
|
440
|
+
await this.ipc.call("onAgenticIssueStatusChanged", e, t, r);
|
|
349
441
|
}
|
|
350
442
|
async onAgenticIssuesCleared(e = null) {
|
|
351
443
|
await this.ipc.call("onAgenticIssuesCleared", e);
|
|
@@ -381,10 +473,10 @@ var q = class {
|
|
|
381
473
|
destroy() {
|
|
382
474
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
383
475
|
}
|
|
384
|
-
},
|
|
476
|
+
}, ke = class {
|
|
385
477
|
ipcAdapter;
|
|
386
|
-
constructor(e, t,
|
|
387
|
-
this.ipcAdapter = new
|
|
478
|
+
constructor(e, t, r) {
|
|
479
|
+
this.ipcAdapter = new oe(e, t, r);
|
|
388
480
|
}
|
|
389
481
|
destroy() {
|
|
390
482
|
this.ipcAdapter.destroy();
|
|
@@ -401,23 +493,23 @@ var q = class {
|
|
|
401
493
|
async getSelectedContent(e) {
|
|
402
494
|
return await this.ipcAdapter.getSelectedContent(e);
|
|
403
495
|
}
|
|
404
|
-
async replaceContent(e, t,
|
|
405
|
-
await this.ipcAdapter.replaceContent(e, t,
|
|
496
|
+
async replaceContent(e, t, r = null) {
|
|
497
|
+
await this.ipcAdapter.replaceContent(e, t, r);
|
|
406
498
|
}
|
|
407
499
|
async selectContent(e, t = null) {
|
|
408
500
|
await this.ipcAdapter.selectContent(e, t);
|
|
409
501
|
}
|
|
410
|
-
async replaceMultipleContents(e) {
|
|
411
|
-
await this.ipcAdapter.replaceMultipleContents(e);
|
|
502
|
+
async replaceMultipleContents(e, t) {
|
|
503
|
+
await this.ipcAdapter.replaceMultipleContents(e, t);
|
|
412
504
|
}
|
|
413
|
-
onAgenticAgentResults(e, t,
|
|
414
|
-
return this.ipcAdapter.onAgenticAgentResults(e, t,
|
|
505
|
+
onAgenticAgentResults(e, t, r = null) {
|
|
506
|
+
return this.ipcAdapter.onAgenticAgentResults(e, t, r);
|
|
415
507
|
}
|
|
416
508
|
onAgenticStreamComplete(e = null) {
|
|
417
509
|
return this.ipcAdapter.onAgenticStreamComplete(e);
|
|
418
510
|
}
|
|
419
|
-
onAgenticIssueStatusChanged(e, t,
|
|
420
|
-
return this.ipcAdapter.onAgenticIssueStatusChanged(e, t,
|
|
511
|
+
onAgenticIssueStatusChanged(e, t, r) {
|
|
512
|
+
return this.ipcAdapter.onAgenticIssueStatusChanged(e, t, r);
|
|
421
513
|
}
|
|
422
514
|
onAgenticIssuesCleared(e = null) {
|
|
423
515
|
return this.ipcAdapter.onAgenticIssuesCleared(e);
|
|
@@ -443,48 +535,48 @@ var q = class {
|
|
|
443
535
|
getTargetOrigin() {
|
|
444
536
|
return this.ipcAdapter.getTargetOrigin();
|
|
445
537
|
}
|
|
446
|
-
},
|
|
538
|
+
}, le = class {
|
|
447
539
|
ipc;
|
|
448
540
|
plugin;
|
|
449
541
|
iframe;
|
|
450
542
|
window;
|
|
451
543
|
targetOrigin;
|
|
452
544
|
latestSidebarBuildInfo = null;
|
|
453
|
-
constructor(e, t,
|
|
454
|
-
this.plugin = e, this.iframe = t, this.window =
|
|
545
|
+
constructor(e, t, r, n, i = "*") {
|
|
546
|
+
this.plugin = e, this.iframe = t, this.window = r ?? window, this.targetOrigin = i, this.ipc = new F((a) => {
|
|
455
547
|
this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
|
|
456
|
-
},
|
|
548
|
+
}, n), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
457
549
|
}
|
|
458
550
|
handleMessage = (e) => {
|
|
459
|
-
const t = this.window.location.origin,
|
|
460
|
-
e.origin !== t && (
|
|
551
|
+
const t = this.window.location.origin, r = this.targetOrigin;
|
|
552
|
+
e.origin !== t && (r !== "*" && e.origin !== r || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
461
553
|
};
|
|
462
554
|
registerReceivers() {
|
|
463
555
|
if (this.ipc.receive("getInitConfig", async (e) => {
|
|
464
|
-
const t =
|
|
556
|
+
const t = ae(e);
|
|
465
557
|
return this.latestSidebarBuildInfo = t, {
|
|
466
558
|
...await this.plugin.getInitConfig(t ?? void 0),
|
|
467
|
-
hostAdapterVersion:
|
|
559
|
+
hostAdapterVersion: Y
|
|
468
560
|
};
|
|
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,
|
|
470
|
-
await this.plugin.replaceContent(e, t, typeof
|
|
561
|
+
}), 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) => {
|
|
562
|
+
await this.plugin.replaceContent(e, t, typeof r == "string" ? r : null);
|
|
471
563
|
}), this.ipc.receive("selectContent", async (e, t) => {
|
|
472
564
|
await this.plugin.selectContent(e, typeof t == "string" ? t : null);
|
|
473
|
-
}), this.ipc.
|
|
474
|
-
await this.plugin.replaceMultipleContents(e);
|
|
475
|
-
}), this.ipc.receive("onAgenticAgentResults", async (e, t,
|
|
565
|
+
}), this.ipc.receiveWithProgress("replaceMultipleContents", async (e, t) => {
|
|
566
|
+
await this.plugin.replaceMultipleContents(t, { reportProgress: e });
|
|
567
|
+
}), this.ipc.receive("onAgenticAgentResults", async (e, t, r) => {
|
|
476
568
|
if (!Array.isArray(t))
|
|
477
569
|
return;
|
|
478
|
-
const
|
|
479
|
-
|
|
570
|
+
const n = this.plugin.onAgenticAgentResults;
|
|
571
|
+
n && await n(e, t, typeof r == "string" ? r : null);
|
|
480
572
|
}), this.ipc.receive("onAgenticStreamComplete", async (e) => {
|
|
481
573
|
const t = this.plugin.onAgenticStreamComplete;
|
|
482
574
|
t && await t(typeof e == "string" ? e : null);
|
|
483
|
-
}), this.ipc.receive("onAgenticIssueStatusChanged", async (e, t,
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
575
|
+
}), this.ipc.receive("onAgenticIssueStatusChanged", async (e, t, r) => {
|
|
576
|
+
const n = this.plugin.onAgenticIssueStatusChanged;
|
|
577
|
+
if (n && !(t !== "active" && t !== "resolved" && t !== "dismissed" || r !== "user" && r !== "host"))
|
|
486
578
|
try {
|
|
487
|
-
await
|
|
579
|
+
await n(e, t, r);
|
|
488
580
|
} catch {
|
|
489
581
|
}
|
|
490
582
|
}), this.ipc.receive("onAgenticIssuesCleared", async (e) => {
|
|
@@ -508,14 +600,14 @@ var q = class {
|
|
|
508
600
|
}
|
|
509
601
|
if (this.plugin.addComment) {
|
|
510
602
|
const e = this.plugin.addComment;
|
|
511
|
-
this.ipc.receive("addComment", async (t,
|
|
512
|
-
await e(t, typeof
|
|
603
|
+
this.ipc.receive("addComment", async (t, r) => {
|
|
604
|
+
await e(t, typeof r == "string" ? r : null);
|
|
513
605
|
});
|
|
514
606
|
}
|
|
515
607
|
if (this.plugin.onIntegrationSettingsChange) {
|
|
516
608
|
const e = this.plugin.onIntegrationSettingsChange;
|
|
517
|
-
this.ipc.receive("onIntegrationSettingsChange", async (t,
|
|
518
|
-
await e(t,
|
|
609
|
+
this.ipc.receive("onIntegrationSettingsChange", async (t, r) => {
|
|
610
|
+
await e(t, r);
|
|
519
611
|
});
|
|
520
612
|
}
|
|
521
613
|
}
|
|
@@ -552,10 +644,10 @@ var q = class {
|
|
|
552
644
|
destroy() {
|
|
553
645
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
554
646
|
}
|
|
555
|
-
},
|
|
647
|
+
}, ce = class {
|
|
556
648
|
ipcAdapter;
|
|
557
|
-
constructor(e, t,
|
|
558
|
-
this.ipcAdapter = new
|
|
649
|
+
constructor(e, t, r) {
|
|
650
|
+
this.ipcAdapter = new le(e, t, r?.win, r?.config, r?.targetOrigin);
|
|
559
651
|
}
|
|
560
652
|
destroy() {
|
|
561
653
|
this.ipcAdapter.destroy();
|
|
@@ -590,7 +682,7 @@ var q = class {
|
|
|
590
682
|
configure(e) {
|
|
591
683
|
this.ipcAdapter.configure(e);
|
|
592
684
|
}
|
|
593
|
-
},
|
|
685
|
+
}, de = `
|
|
594
686
|
<div class="sidebar-load-overlay-card">
|
|
595
687
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
596
688
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -611,16 +703,16 @@ var q = class {
|
|
|
611
703
|
<span>Retry</span>
|
|
612
704
|
</button>
|
|
613
705
|
</div>
|
|
614
|
-
`,
|
|
706
|
+
`, ge = () => {
|
|
615
707
|
const e = document.createElement("div");
|
|
616
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
708
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = de;
|
|
617
709
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
618
710
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
619
711
|
return {
|
|
620
712
|
overlay: e,
|
|
621
713
|
button: t
|
|
622
714
|
};
|
|
623
|
-
},
|
|
715
|
+
}, M = "markupai-sidebar-load-overlay-styles", pe = `
|
|
624
716
|
:root {
|
|
625
717
|
--background: #f5f5f4;
|
|
626
718
|
--foreground: #333332;
|
|
@@ -712,110 +804,110 @@ var q = class {
|
|
|
712
804
|
box-shadow: 0 0 0 2px
|
|
713
805
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
714
806
|
}
|
|
715
|
-
`,
|
|
807
|
+
`, ue = (e) => {
|
|
716
808
|
const t = e ?? document;
|
|
717
|
-
if (t.getElementById(
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
},
|
|
721
|
-
|
|
722
|
-
const { sidebarUrl:
|
|
809
|
+
if (t.getElementById(M)) return;
|
|
810
|
+
const r = t.createElement("style");
|
|
811
|
+
r.id = M, r.textContent = pe, t.head.appendChild(r);
|
|
812
|
+
}, he = 8e3, fe = 12e3, me = (e, t, r = {}) => {
|
|
813
|
+
ue(e.ownerDocument);
|
|
814
|
+
const { sidebarUrl: n, targetOrigin: i, timeoutMs: a = he, retryIntervalMs: s = fe, messageListenWindow: o } = r, l = o ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), c = () => n ?? t.src, G = () => {
|
|
723
815
|
if (i) return i;
|
|
724
816
|
try {
|
|
725
|
-
return new URL(
|
|
817
|
+
return new URL(c()).origin;
|
|
726
818
|
} catch {
|
|
727
819
|
return "*";
|
|
728
820
|
}
|
|
729
|
-
}, { overlay: y, button:
|
|
821
|
+
}, { overlay: y, button: C } = ge();
|
|
730
822
|
e.appendChild(y);
|
|
731
|
-
let u = !1, h,
|
|
732
|
-
const
|
|
733
|
-
y.style.display =
|
|
823
|
+
let u = !1, h, g;
|
|
824
|
+
const p = (d) => {
|
|
825
|
+
y.style.display = d ? "flex" : "none";
|
|
734
826
|
};
|
|
735
|
-
|
|
827
|
+
p(!1);
|
|
736
828
|
const f = () => {
|
|
737
829
|
h && (globalThis.clearTimeout(h), h = void 0);
|
|
738
|
-
},
|
|
830
|
+
}, b = () => {
|
|
739
831
|
f(), h = globalThis.setTimeout(() => {
|
|
740
|
-
u ||
|
|
832
|
+
u || p(!0);
|
|
741
833
|
}, a);
|
|
742
|
-
},
|
|
743
|
-
const m =
|
|
744
|
-
u = !1, m ||
|
|
745
|
-
},
|
|
746
|
-
|
|
747
|
-
u ||
|
|
748
|
-
},
|
|
749
|
-
},
|
|
750
|
-
|
|
751
|
-
},
|
|
752
|
-
if (!t.contentWindow ||
|
|
753
|
-
const m =
|
|
754
|
-
m !== "*" &&
|
|
755
|
-
}, P = () => {
|
|
756
|
-
f(), g(!0);
|
|
834
|
+
}, S = (d) => {
|
|
835
|
+
const m = d?.preserveOverlay ?? !0;
|
|
836
|
+
u = !1, m || p(!1), t.src = c(), b();
|
|
837
|
+
}, J = () => {
|
|
838
|
+
g || s <= 0 || (g = globalThis.setInterval(() => {
|
|
839
|
+
u || S({ preserveOverlay: !0 });
|
|
840
|
+
}, s));
|
|
841
|
+
}, w = () => {
|
|
842
|
+
g && (globalThis.clearInterval(g), g = void 0);
|
|
843
|
+
}, P = (d) => {
|
|
844
|
+
if (!t.contentWindow || d.source !== t.contentWindow) return;
|
|
845
|
+
const m = G();
|
|
846
|
+
m !== "*" && d.origin !== m || (u = !0, f(), w(), p(!1));
|
|
757
847
|
}, E = () => {
|
|
758
|
-
|
|
848
|
+
f(), p(!0);
|
|
849
|
+
}, R = () => {
|
|
850
|
+
S();
|
|
759
851
|
};
|
|
760
|
-
return
|
|
761
|
-
f(),
|
|
852
|
+
return C.addEventListener("click", R), t.addEventListener("error", E), l.addEventListener("message", P), b(), J(), () => {
|
|
853
|
+
f(), w(), t.removeEventListener("error", E), l.removeEventListener("message", P), C.removeEventListener("click", R), y.remove();
|
|
762
854
|
};
|
|
763
|
-
},
|
|
764
|
-
function
|
|
855
|
+
}, ye = "Markup AI Sidebar", Ie = "clipboard-read; clipboard-write", Ne = "markupai.sidebarNextGen.overrideUrl", Be = "https://sidebar.markup.ai/";
|
|
856
|
+
function Ue(e) {
|
|
765
857
|
try {
|
|
766
858
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
767
859
|
} catch {
|
|
768
860
|
return e;
|
|
769
861
|
}
|
|
770
862
|
}
|
|
771
|
-
var
|
|
772
|
-
function
|
|
863
|
+
var ve = "markupai.sidebarNextGen.authOverride";
|
|
864
|
+
function He(e, t) {
|
|
773
865
|
if (!t) return e;
|
|
774
866
|
try {
|
|
775
867
|
if (!("localStorage" in globalThis)) return e;
|
|
776
|
-
const
|
|
777
|
-
if (!
|
|
778
|
-
const
|
|
779
|
-
return
|
|
868
|
+
const r = globalThis.localStorage.getItem(ve)?.trim();
|
|
869
|
+
if (!r) return e;
|
|
870
|
+
const n = JSON.parse(r);
|
|
871
|
+
return n !== null && typeof n == "object" && "type" in n && (n.type === "mediation" || n.type === "popup") ? n : e;
|
|
780
872
|
} catch {
|
|
781
873
|
return e;
|
|
782
874
|
}
|
|
783
875
|
}
|
|
784
|
-
function
|
|
876
|
+
function $e(e, t) {
|
|
785
877
|
try {
|
|
786
878
|
return new URL(e).origin;
|
|
787
|
-
} catch (
|
|
788
|
-
return t?.onInvalidUrl?.(e,
|
|
879
|
+
} catch (r) {
|
|
880
|
+
return t?.onInvalidUrl?.(e, r), "*";
|
|
789
881
|
}
|
|
790
882
|
}
|
|
791
|
-
function
|
|
883
|
+
function je(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
792
884
|
if (e.adapter === null) throw new Error(t);
|
|
793
885
|
}
|
|
794
|
-
function
|
|
795
|
-
const { iframe: t, iframeMount:
|
|
796
|
-
if (t !== void 0 &&
|
|
886
|
+
function Ae(e) {
|
|
887
|
+
const { iframe: t, iframeMount: r } = e;
|
|
888
|
+
if (t !== void 0 && r !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
797
889
|
if (t !== void 0) return {
|
|
798
890
|
iframe: t,
|
|
799
891
|
removeMountedIframe: null
|
|
800
892
|
};
|
|
801
|
-
if (
|
|
802
|
-
const { container:
|
|
803
|
-
return
|
|
804
|
-
iframe:
|
|
893
|
+
if (r === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
894
|
+
const { container: n, src: i, allow: a = Ie } = r, s = document.createElement("iframe");
|
|
895
|
+
return s.title = ye, s.src = i, a && s.setAttribute("allow", a), n.appendChild(s), {
|
|
896
|
+
iframe: s,
|
|
805
897
|
removeMountedIframe: () => {
|
|
806
|
-
|
|
898
|
+
s.remove();
|
|
807
899
|
}
|
|
808
900
|
};
|
|
809
901
|
}
|
|
810
|
-
function
|
|
811
|
-
const { plugin: t, loadOverlayContainer:
|
|
902
|
+
function Fe(e) {
|
|
903
|
+
const { plugin: t, loadOverlayContainer: r, loadOverlayOptions: n, adapterOptions: i } = e, { iframe: a, removeMountedIframe: s } = Ae(e), o = r !== void 0 ? me(r, a, n ?? {}) : null;
|
|
812
904
|
if (t !== void 0) {
|
|
813
|
-
const l = new
|
|
905
|
+
const l = new ce(t, a, i);
|
|
814
906
|
return {
|
|
815
907
|
iframe: a,
|
|
816
908
|
adapter: l,
|
|
817
909
|
destroy: () => {
|
|
818
|
-
|
|
910
|
+
o?.(), l.destroy(), s?.();
|
|
819
911
|
}
|
|
820
912
|
};
|
|
821
913
|
}
|
|
@@ -823,18 +915,18 @@ function xe(e) {
|
|
|
823
915
|
iframe: a,
|
|
824
916
|
adapter: null,
|
|
825
917
|
destroy: () => {
|
|
826
|
-
|
|
918
|
+
o?.(), s?.();
|
|
827
919
|
}
|
|
828
920
|
};
|
|
829
921
|
}
|
|
830
|
-
var
|
|
831
|
-
function
|
|
922
|
+
var V = "sidebarContainer", x = "markupai-sidebar-host-shell-styles";
|
|
923
|
+
function W(e) {
|
|
832
924
|
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
833
925
|
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)})`);
|
|
834
926
|
return e;
|
|
835
927
|
}
|
|
836
|
-
function
|
|
837
|
-
const t =
|
|
928
|
+
function z(e = V) {
|
|
929
|
+
const t = W(e);
|
|
838
930
|
return `
|
|
839
931
|
html {
|
|
840
932
|
height: 100%;
|
|
@@ -859,89 +951,93 @@ body {
|
|
|
859
951
|
}
|
|
860
952
|
`.trim();
|
|
861
953
|
}
|
|
862
|
-
var
|
|
863
|
-
function
|
|
954
|
+
var Ve = z();
|
|
955
|
+
function Ce(e) {
|
|
864
956
|
return e instanceof Document ? e : e.ownerDocument;
|
|
865
957
|
}
|
|
866
|
-
function
|
|
867
|
-
if (!t || e.getElementById(
|
|
868
|
-
const
|
|
869
|
-
|
|
958
|
+
function be(e, t, r) {
|
|
959
|
+
if (!t || e.getElementById(x)) return;
|
|
960
|
+
const n = e.createElement("style");
|
|
961
|
+
n.id = x, n.textContent = z(r), e.head.appendChild(n);
|
|
870
962
|
}
|
|
871
|
-
function
|
|
872
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId:
|
|
963
|
+
function We(e) {
|
|
964
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: r = V, includeDefaultStyles: n = !0 } = e ?? {};
|
|
873
965
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
874
|
-
const i =
|
|
875
|
-
|
|
876
|
-
const a = t instanceof Document ? i.getElementById(
|
|
966
|
+
const i = Ce(t);
|
|
967
|
+
be(i, n, r);
|
|
968
|
+
const a = t instanceof Document ? i.getElementById(r) : t.querySelector(`#${W(r)}`);
|
|
877
969
|
if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
|
|
878
970
|
if (!(t instanceof Document)) {
|
|
879
|
-
const
|
|
880
|
-
return
|
|
971
|
+
const o = i.createElement("div");
|
|
972
|
+
return o.id = r, t.appendChild(o), o;
|
|
881
973
|
}
|
|
882
|
-
const
|
|
883
|
-
return
|
|
974
|
+
const s = i.createElement("div");
|
|
975
|
+
return s.id = r, i.body.appendChild(s), s;
|
|
884
976
|
}
|
|
885
|
-
function
|
|
977
|
+
function Se() {
|
|
886
978
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
887
979
|
}
|
|
888
|
-
function
|
|
889
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml:
|
|
980
|
+
function ze(e) {
|
|
981
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: r = "", includePluginHostHead: n = !1, bodyScriptsHtml: i, htmlLang: a = "en", htmlAttrs: s = `lang="${a}" style="height:100%"`, bodyAttrs: o = 'style="height:100%;margin:0"' } = e, l = [n ? Se() : "", r].filter((c) => c.trim().length > 0).join(`
|
|
890
982
|
`);
|
|
891
983
|
return `<!DOCTYPE html>
|
|
892
|
-
<html ${
|
|
984
|
+
<html ${s}>
|
|
893
985
|
<head>
|
|
894
986
|
<base target="_top" />
|
|
895
987
|
<meta charset="UTF-8" />
|
|
896
|
-
<title>${
|
|
988
|
+
<title>${we(t)}</title>${l ? `
|
|
897
989
|
${l}` : ""}
|
|
898
990
|
</head>
|
|
899
|
-
<body ${
|
|
991
|
+
<body ${o}>
|
|
900
992
|
${i}
|
|
901
993
|
</body>
|
|
902
994
|
</html>
|
|
903
995
|
`;
|
|
904
996
|
}
|
|
905
|
-
function
|
|
997
|
+
function we(e) {
|
|
906
998
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
907
999
|
}
|
|
908
1000
|
export {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1001
|
+
Y as ADAPTER_VERSION,
|
|
1002
|
+
ve as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
1003
|
+
j as DEFAULT_IPC_CONFIG,
|
|
1004
|
+
Re as DEFAULT_SIDEBAR_CONFIG,
|
|
1005
|
+
K as DeferredPromise,
|
|
1006
|
+
F as IPCCore,
|
|
1007
|
+
N as IpcTimeoutError,
|
|
1008
|
+
Q as LATE_RESULT_WINDOW_MS,
|
|
1009
|
+
ee as MAX_IPC_TIMEOUT_MS,
|
|
1010
|
+
Pe as MimeType,
|
|
1011
|
+
ke as PluginAdapter,
|
|
1012
|
+
oe as PluginIPCAdapter,
|
|
1013
|
+
L as ReplaceBatchError,
|
|
1014
|
+
Be as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
1015
|
+
V as SIDEBAR_HOST_CONTAINER_ID,
|
|
1016
|
+
Ve as SIDEBAR_HOST_SHELL_CSS,
|
|
1017
|
+
Ie as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
1018
|
+
ye as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
1019
|
+
Ne as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
1020
|
+
ce as SidebarAdapter,
|
|
1021
|
+
le as SidebarIPCAdapter,
|
|
1022
|
+
Ee as TEXT_MIME_TYPES,
|
|
1023
|
+
A as TextLookupError,
|
|
1024
|
+
je as assertSidebarHostAdapter,
|
|
1025
|
+
Le as buildDocumentReference,
|
|
1026
|
+
ze as buildSidebarHostHtmlDocument,
|
|
1027
|
+
z as buildSidebarHostShellCss,
|
|
1028
|
+
Se as buildSidebarPluginHostHeadInnerHtml,
|
|
1029
|
+
Fe as createSidebarHost,
|
|
1030
|
+
We as ensureSidebarHostShell,
|
|
1031
|
+
He as getAuthConfigWithOverride,
|
|
1032
|
+
Ue as getSidebarBaseUrlWithOverride,
|
|
1033
|
+
T as ipcErrorReconstructors,
|
|
1034
|
+
_e as isDocumentReference,
|
|
1035
|
+
Te as isIntegrationSettingField,
|
|
1036
|
+
Oe as isIntegrationSettingsSchema,
|
|
1037
|
+
De as isIpcTimeoutError,
|
|
1038
|
+
Me as isReplaceBatchError,
|
|
1039
|
+
xe as isTextLookupError,
|
|
1040
|
+
X as reconstructError,
|
|
1041
|
+
me as setupSidebarLoadOverlay,
|
|
1042
|
+
$e as sidebarPostMessageTargetOrigin
|
|
947
1043
|
};
|