@markupai/sidebar-adapter 0.0.23 → 1.0.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 +38 -21
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/pluginAdapter.d.ts +73 -0
- package/dist/adapters/pluginAdapter.d.ts.map +1 -0
- package/dist/adapters/sidebarAdapter.d.ts +43 -0
- package/dist/adapters/sidebarAdapter.d.ts.map +1 -0
- package/dist/errors.d.ts +48 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/ipc/call-signatures.d.ts +64 -0
- package/dist/ipc/call-signatures.d.ts.map +1 -0
- package/dist/ipc/deferred-promise.d.ts +49 -0
- package/dist/ipc/deferred-promise.d.ts.map +1 -0
- package/dist/ipc/index.d.ts +9 -0
- package/dist/ipc/index.d.ts.map +1 -0
- package/dist/ipc/ipc-core.d.ts +72 -0
- package/dist/ipc/ipc-core.d.ts.map +1 -0
- package/dist/ipc/message-types.d.ts +57 -0
- package/dist/ipc/message-types.d.ts.map +1 -0
- package/dist/ipc/plugin-ipc-adapter.d.ts +77 -0
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -0
- package/dist/ipc/sidebar-ipc-adapter.d.ts +38 -0
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -0
- package/dist/load-overlay/index.d.ts +2 -0
- package/dist/load-overlay/index.d.ts.map +1 -0
- package/dist/load-overlay/loadOverlayDom.d.ts +5 -0
- package/dist/load-overlay/loadOverlayDom.d.ts.map +1 -0
- package/dist/load-overlay/loadOverlayStyles.d.ts +3 -0
- package/dist/load-overlay/loadOverlayStyles.d.ts.map +1 -0
- package/dist/load-overlay/sidebarLoadOverlay.d.ts +14 -0
- package/dist/load-overlay/sidebarLoadOverlay.d.ts.map +1 -0
- package/dist/main.js +289 -517
- package/dist/main.umd.cjs +12 -12
- package/dist/sidebar-host/createSidebarHost.d.ts +84 -0
- package/dist/sidebar-host/createSidebarHost.d.ts.map +1 -0
- package/dist/sidebar-host/index.d.ts +3 -0
- package/dist/sidebar-host/index.d.ts.map +1 -0
- package/dist/sidebar-host/sidebarHostShell.d.ts +56 -0
- package/dist/sidebar-host/sidebarHostShell.d.ts.map +1 -0
- package/dist/types/common.d.ts +95 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/pluginInterface.d.ts +70 -0
- package/dist/types/pluginInterface.d.ts.map +1 -0
- package/dist/types/sidebarInterface.d.ts +41 -0
- package/dist/types/sidebarInterface.d.ts.map +1 -0
- package/package.json +5 -5
- package/dist/main.d.ts +0 -888
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
],
|
|
1
|
+
var v = /* @__PURE__ */ (function(e) {
|
|
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
|
+
})({}), ne = [
|
|
4
|
+
v.TEXT_PLAIN,
|
|
5
|
+
v.TEXT_MARKDOWN,
|
|
6
|
+
v.TEXT_HTML,
|
|
7
|
+
v.APPLICATION_DITA_XML
|
|
8
|
+
], oe = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
@@ -13,156 +13,86 @@ const re = [
|
|
|
13
13
|
dialogClosingScript: void 0,
|
|
14
14
|
useCheckPreviewDialog: !1,
|
|
15
15
|
supportCheckSelection: !0
|
|
16
|
-
}
|
|
17
|
-
class v extends Error {
|
|
16
|
+
}, R = class L extends Error {
|
|
18
17
|
name = "TextLookupError";
|
|
19
|
-
constructor(
|
|
20
|
-
super(
|
|
18
|
+
constructor(t) {
|
|
19
|
+
super(t), Object.setPrototypeOf(this, L.prototype);
|
|
21
20
|
}
|
|
22
|
-
}
|
|
23
|
-
function ne(r) {
|
|
24
|
-
return r instanceof v;
|
|
25
|
-
}
|
|
26
|
-
const C = {
|
|
27
|
-
TextLookupError: (r) => new v(r)
|
|
28
21
|
};
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
return i ? i(e, r) : Object.assign(new Error(e), t ? { name: t } : {});
|
|
22
|
+
function ae(e) {
|
|
23
|
+
return e instanceof R;
|
|
32
24
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
var E = { TextLookupError: (e) => new R(e) };
|
|
26
|
+
function H(e) {
|
|
27
|
+
const t = e.message ?? "", r = e.name, i = typeof r == "string" && r in E ? E[r] : void 0;
|
|
28
|
+
return i ? i(t, e) : Object.assign(new Error(t), r ? { name: r } : {});
|
|
29
|
+
}
|
|
30
|
+
var T = () => {
|
|
31
|
+
}, U = class {
|
|
36
32
|
_promise;
|
|
37
33
|
[Symbol.toStringTag] = "Promise";
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
* @param value - The value to resolve the promise with.
|
|
42
|
-
*/
|
|
43
|
-
resolve = O;
|
|
44
|
-
/**
|
|
45
|
-
* Rejects the underlying promise with a specified reason.
|
|
46
|
-
*
|
|
47
|
-
* @param reason - The reason for rejecting the promise.
|
|
48
|
-
*/
|
|
49
|
-
reject = O;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a new instance of DeferredPromise.
|
|
52
|
-
*/
|
|
34
|
+
resolve = T;
|
|
35
|
+
reject = T;
|
|
53
36
|
constructor() {
|
|
54
37
|
this._promise = new Promise((e, t) => {
|
|
55
38
|
this.resolve = e, this.reject = t;
|
|
56
39
|
});
|
|
57
40
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Attaches callbacks for the resolution and/or rejection of the promise.
|
|
60
|
-
*
|
|
61
|
-
* @param onFulfilled - The callback to execute when the promise is resolved.
|
|
62
|
-
* @param onRejected - The callback to execute when the promise is rejected.
|
|
63
|
-
* @returns - A new promise resolved or rejected by the onFulfilled or
|
|
64
|
-
* onRejected callback.
|
|
65
|
-
*/
|
|
66
41
|
then(e, t) {
|
|
67
42
|
return this._promise.then(e, t);
|
|
68
43
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Attaches a callback for the rejection of the promise.
|
|
71
|
-
*
|
|
72
|
-
* @param onRejected - The callback to execute when the promise is rejected.
|
|
73
|
-
* @returns - A new promise resolved by the onRejected callback.
|
|
74
|
-
*/
|
|
75
44
|
catch(e) {
|
|
76
45
|
return this._promise.catch(e);
|
|
77
46
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Attaches a callback that is executed when the promise is settled, whether
|
|
80
|
-
* fulfilled or rejected.
|
|
81
|
-
*
|
|
82
|
-
* @param onFinally - The callback to execute when the promise is settled.
|
|
83
|
-
* @returns - A new promise resolved by the onFinally callback.
|
|
84
|
-
*/
|
|
85
47
|
finally(e) {
|
|
86
48
|
return this._promise.finally(e);
|
|
87
49
|
}
|
|
88
|
-
}
|
|
89
|
-
const N = {
|
|
90
|
-
timeout: 1e4
|
|
91
|
-
};
|
|
92
|
-
class D {
|
|
50
|
+
}, j = { timeout: 1e4 }, M = class {
|
|
93
51
|
promisesByID = {};
|
|
94
52
|
receiversByName = {};
|
|
95
53
|
currentID = 0;
|
|
96
54
|
config;
|
|
97
55
|
postMessage;
|
|
98
56
|
constructor(e, t) {
|
|
99
|
-
this.postMessage = e, this.config = {
|
|
57
|
+
this.postMessage = e, this.config = {
|
|
58
|
+
...j,
|
|
59
|
+
...t
|
|
60
|
+
};
|
|
100
61
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Update IPC configuration
|
|
103
|
-
*/
|
|
104
62
|
configure(e) {
|
|
105
|
-
this.config = {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*
|
|
111
|
-
* @param name - The name of the receiver on the other side
|
|
112
|
-
* @param data - Parameters to send to the receiver
|
|
113
|
-
* @returns Promise that resolves with the receiver's response
|
|
114
|
-
*/
|
|
63
|
+
this.config = {
|
|
64
|
+
...this.config,
|
|
65
|
+
...e
|
|
66
|
+
};
|
|
67
|
+
}
|
|
115
68
|
call(e, ...t) {
|
|
116
69
|
return this.callWithOptions(e, {}, ...t);
|
|
117
70
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
* @param data - Parameters to send to the receiver
|
|
124
|
-
* @returns Promise that resolves with the receiver's response
|
|
125
|
-
*/
|
|
126
|
-
callWithOptions(e, t, ...i) {
|
|
127
|
-
const n = this.currentID++, s = new P(), o = t.timeout ?? this.config.timeout, a = setTimeout(() => {
|
|
128
|
-
if (n in this.promisesByID) {
|
|
129
|
-
const l = new Error(
|
|
130
|
-
`IPC call timeout: "${e}" did not respond within ${String(o)}ms`
|
|
131
|
-
);
|
|
132
|
-
s.reject(l), Reflect.deleteProperty(this.promisesByID, n);
|
|
71
|
+
callWithOptions(e, t, ...r) {
|
|
72
|
+
const i = this.currentID++, o = new U(), n = t.timeout ?? this.config.timeout, a = setTimeout(() => {
|
|
73
|
+
if (i in this.promisesByID) {
|
|
74
|
+
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(n)}ms`);
|
|
75
|
+
o.reject(l), Reflect.deleteProperty(this.promisesByID, i);
|
|
133
76
|
}
|
|
134
|
-
},
|
|
135
|
-
this.promisesByID[
|
|
136
|
-
|
|
77
|
+
}, n);
|
|
78
|
+
this.promisesByID[i] = {
|
|
79
|
+
promise: o,
|
|
80
|
+
timeoutId: a
|
|
81
|
+
};
|
|
82
|
+
const s = {
|
|
137
83
|
type: "call",
|
|
138
|
-
id:
|
|
84
|
+
id: i,
|
|
139
85
|
name: e,
|
|
140
|
-
data:
|
|
86
|
+
data: r
|
|
141
87
|
};
|
|
142
|
-
return this.postMessage(
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Registers a function to receive calls with a particular name.
|
|
146
|
-
* The return value will be sent back to the caller.
|
|
147
|
-
*
|
|
148
|
-
* @param name - The name of the receiver
|
|
149
|
-
* @param fn - The function that will receive calls
|
|
150
|
-
*/
|
|
88
|
+
return this.postMessage(s), o;
|
|
89
|
+
}
|
|
151
90
|
receive(e, t) {
|
|
152
91
|
this.receiversByName[e] = t;
|
|
153
92
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Unregisters a receiver for a given call name
|
|
156
|
-
*
|
|
157
|
-
* @param name - The name of the receiver to unregister
|
|
158
|
-
*/
|
|
159
93
|
ignore(e) {
|
|
160
94
|
delete this.receiversByName[e];
|
|
161
95
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Handles incoming messages from the other side
|
|
164
|
-
* @param message - The IPC message to handle
|
|
165
|
-
*/
|
|
166
96
|
async handleMessage(e) {
|
|
167
97
|
switch (e.type) {
|
|
168
98
|
case "call":
|
|
@@ -174,101 +104,88 @@ class D {
|
|
|
174
104
|
case "error":
|
|
175
105
|
this.handleError(e);
|
|
176
106
|
break;
|
|
107
|
+
default:
|
|
177
108
|
}
|
|
178
109
|
}
|
|
179
|
-
/**
|
|
180
|
-
* Handles incoming call messages
|
|
181
|
-
*/
|
|
182
110
|
async handleCall(e) {
|
|
183
|
-
const { id: t, name:
|
|
184
|
-
if (
|
|
185
|
-
const
|
|
111
|
+
const { id: t, name: r, data: i } = e;
|
|
112
|
+
if (r in this.receiversByName) {
|
|
113
|
+
const o = this.receiversByName[r];
|
|
186
114
|
try {
|
|
187
|
-
if (!Array.isArray(
|
|
188
|
-
|
|
189
|
-
const o = await s(...n), a = {
|
|
115
|
+
if (!Array.isArray(i)) throw new Error(`IPC: Expected array of arguments but got ${typeof i}`);
|
|
116
|
+
const n = await o(...i), a = {
|
|
190
117
|
type: "response",
|
|
191
118
|
id: t,
|
|
192
|
-
name:
|
|
193
|
-
data:
|
|
119
|
+
name: r,
|
|
120
|
+
data: n
|
|
194
121
|
};
|
|
195
122
|
this.postMessage(a);
|
|
196
|
-
} catch (
|
|
197
|
-
let a = JSON.stringify(
|
|
198
|
-
const
|
|
199
|
-
(
|
|
200
|
-
message:
|
|
201
|
-
name:
|
|
123
|
+
} catch (n) {
|
|
124
|
+
let a = JSON.stringify(n, Object.getOwnPropertyNames(n));
|
|
125
|
+
const s = JSON.parse(a);
|
|
126
|
+
(s.message === void 0 || s.message === "") && (a = JSON.stringify({
|
|
127
|
+
message: n instanceof Error ? n.message : String(n),
|
|
128
|
+
name: n instanceof Error ? n.name : void 0
|
|
202
129
|
}));
|
|
203
130
|
const l = {
|
|
204
131
|
type: "error",
|
|
205
132
|
id: t,
|
|
206
|
-
name:
|
|
133
|
+
name: r,
|
|
207
134
|
errorJSON: a
|
|
208
135
|
};
|
|
209
136
|
this.postMessage(l);
|
|
210
137
|
}
|
|
211
138
|
} else {
|
|
212
|
-
const
|
|
213
|
-
message: s.message,
|
|
214
|
-
name: s.name
|
|
215
|
-
}), a = {
|
|
139
|
+
const o = /* @__PURE__ */ new Error(`No receiver registered for: ${r}`), n = {
|
|
216
140
|
type: "error",
|
|
217
141
|
id: t,
|
|
218
|
-
name:
|
|
219
|
-
errorJSON:
|
|
142
|
+
name: r,
|
|
143
|
+
errorJSON: JSON.stringify({
|
|
144
|
+
message: o.message,
|
|
145
|
+
name: o.name
|
|
146
|
+
})
|
|
220
147
|
};
|
|
221
|
-
this.postMessage(
|
|
148
|
+
this.postMessage(n);
|
|
222
149
|
}
|
|
223
150
|
}
|
|
224
|
-
/**
|
|
225
|
-
* Handles incoming response messages
|
|
226
|
-
*/
|
|
227
151
|
handleResponse(e) {
|
|
228
152
|
const { id: t } = e;
|
|
229
153
|
if (t in this.promisesByID) {
|
|
230
|
-
const { promise:
|
|
231
|
-
clearTimeout(
|
|
154
|
+
const { promise: r, timeoutId: i } = this.promisesByID[t];
|
|
155
|
+
clearTimeout(i), r.resolve(e.data), Reflect.deleteProperty(this.promisesByID, t);
|
|
232
156
|
}
|
|
233
157
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Handles incoming error messages
|
|
236
|
-
*/
|
|
237
158
|
handleError(e) {
|
|
238
|
-
const { id: t, errorJSON:
|
|
159
|
+
const { id: t, errorJSON: r } = e;
|
|
239
160
|
if (t in this.promisesByID) {
|
|
240
|
-
const { promise:
|
|
241
|
-
clearTimeout(
|
|
161
|
+
const { promise: i, timeoutId: o } = this.promisesByID[t];
|
|
162
|
+
clearTimeout(o);
|
|
242
163
|
try {
|
|
243
|
-
const
|
|
244
|
-
|
|
164
|
+
const n = H(JSON.parse(r));
|
|
165
|
+
i.reject(n);
|
|
245
166
|
} catch {
|
|
246
|
-
|
|
167
|
+
i.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
247
168
|
}
|
|
248
169
|
Reflect.deleteProperty(this.promisesByID, t);
|
|
249
170
|
}
|
|
250
171
|
}
|
|
251
|
-
/**
|
|
252
|
-
* Cleanup all pending promises and receivers
|
|
253
|
-
*/
|
|
254
172
|
destroy() {
|
|
255
173
|
for (const { promise: e, timeoutId: t } of Object.values(this.promisesByID))
|
|
256
|
-
clearTimeout(t), e.reject(new Error("IPC destroyed"));
|
|
174
|
+
clearTimeout(t), e.reject(/* @__PURE__ */ new Error("IPC destroyed"));
|
|
257
175
|
this.promisesByID = {}, this.receiversByName = {};
|
|
258
176
|
}
|
|
259
|
-
}
|
|
260
|
-
class H {
|
|
177
|
+
}, $ = class {
|
|
261
178
|
ipc;
|
|
262
179
|
sidebar;
|
|
263
180
|
targetOrigin;
|
|
264
|
-
constructor(e, t,
|
|
265
|
-
this.sidebar = e || {}, this.targetOrigin =
|
|
266
|
-
window.parent.postMessage(
|
|
181
|
+
constructor(e, t, r = "*") {
|
|
182
|
+
this.sidebar = e || {}, this.targetOrigin = r, this.ipc = new M((i) => {
|
|
183
|
+
window.parent.postMessage(i, this.targetOrigin);
|
|
267
184
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
268
185
|
}
|
|
269
186
|
handleMessage = (e) => {
|
|
270
|
-
const t = globalThis.window.location.origin,
|
|
271
|
-
e.origin !== t && (
|
|
187
|
+
const t = globalThis.window.location.origin, r = this.targetOrigin;
|
|
188
|
+
e.origin !== t && (r !== "*" && e.origin !== r || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
272
189
|
};
|
|
273
190
|
registerReceivers() {
|
|
274
191
|
if (this.sidebar.onPluginStatusChange) {
|
|
@@ -283,222 +200,131 @@ class H {
|
|
|
283
200
|
await e(t);
|
|
284
201
|
});
|
|
285
202
|
}
|
|
203
|
+
if (this.sidebar.invalidateAgenticIssue) {
|
|
204
|
+
const e = this.sidebar.invalidateAgenticIssue;
|
|
205
|
+
this.ipc.receive("invalidateAgenticIssue", async (t) => {
|
|
206
|
+
await e(t);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
286
209
|
}
|
|
287
|
-
// ============================================
|
|
288
|
-
// Methods to call plugin functions
|
|
289
|
-
// ============================================
|
|
290
|
-
/**
|
|
291
|
-
* Request initialization configuration from the editor
|
|
292
|
-
*/
|
|
293
210
|
async getInitConfig() {
|
|
294
211
|
return await this.ipc.call("getInitConfig");
|
|
295
212
|
}
|
|
296
|
-
/**
|
|
297
|
-
* Request content from the editor in whatever format the integration supports
|
|
298
|
-
* @param options - Optional per-call overrides (e.g. timeout in ms; overrides default IPC timeout)
|
|
299
|
-
*/
|
|
300
213
|
async getContent(e) {
|
|
301
214
|
return this.ipc.callWithOptions("getContent", e ?? {});
|
|
302
215
|
}
|
|
303
|
-
/**
|
|
304
|
-
* Request selected content from the editor in whatever format the integration supports
|
|
305
|
-
* @param options - Optional per-call overrides (e.g. timeout in ms; overrides default IPC timeout)
|
|
306
|
-
*/
|
|
307
216
|
async getSelectedContent(e) {
|
|
308
217
|
return this.ipc.callWithOptions("getSelectedContent", e ?? {});
|
|
309
218
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
async
|
|
314
|
-
await this.ipc.call("
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
async selectContent(e, t) {
|
|
320
|
-
await this.ipc.call("selectContent", e, t);
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Show a dialog in the editor
|
|
324
|
-
*/
|
|
325
|
-
async showDialog(e, t, i, n) {
|
|
326
|
-
await this.ipc.call("showDialog", e, t, i, n);
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Close the dialog in the editor
|
|
330
|
-
*/
|
|
219
|
+
async replaceContent(e, t) {
|
|
220
|
+
await this.ipc.call("replaceContent", e, t);
|
|
221
|
+
}
|
|
222
|
+
async selectContent(e) {
|
|
223
|
+
await this.ipc.call("selectContent", e);
|
|
224
|
+
}
|
|
225
|
+
async showDialog(e, t, r, i) {
|
|
226
|
+
await this.ipc.call("showDialog", e, t, r, i);
|
|
227
|
+
}
|
|
331
228
|
async closeDialog() {
|
|
332
229
|
await this.ipc.call("closeDialog");
|
|
333
230
|
}
|
|
334
|
-
/**
|
|
335
|
-
* Replace multiple contents in the editor
|
|
336
|
-
*/
|
|
337
231
|
async replaceMultipleContents(e) {
|
|
338
232
|
await this.ipc.call("replaceMultipleContents", e);
|
|
339
233
|
}
|
|
340
|
-
/**
|
|
341
|
-
* Notify plugin that one agent's results are available (streaming).
|
|
342
|
-
*/
|
|
343
234
|
async onAgenticAgentResults(e, t) {
|
|
344
235
|
await this.ipc.call("onAgenticAgentResults", e, t);
|
|
345
236
|
}
|
|
346
|
-
/**
|
|
347
|
-
* Notify plugin that the agentic stream has finished.
|
|
348
|
-
*/
|
|
349
237
|
async onAgenticStreamComplete() {
|
|
350
238
|
await this.ipc.call("onAgenticStreamComplete");
|
|
351
239
|
}
|
|
352
|
-
/**
|
|
353
|
-
* Update IPC configuration
|
|
354
|
-
*/
|
|
355
240
|
configure(e) {
|
|
356
241
|
this.ipc.configure(e);
|
|
357
242
|
}
|
|
358
|
-
/**
|
|
359
|
-
* Set or update the target origin for postMessage communication
|
|
360
|
-
*/
|
|
361
243
|
setTargetOrigin(e) {
|
|
362
|
-
if (!e || typeof e != "string")
|
|
363
|
-
throw new Error("Invalid targetOrigin: must be a non-empty string");
|
|
244
|
+
if (!e || typeof e != "string") throw new Error("Invalid targetOrigin: must be a non-empty string");
|
|
364
245
|
try {
|
|
365
246
|
const t = new URL(e);
|
|
366
|
-
if (!["http:", "https:"].includes(t.protocol) || !t.host)
|
|
367
|
-
throw new Error(
|
|
368
|
-
"Invalid targetOrigin: protocol must be http or https and must have a host"
|
|
369
|
-
);
|
|
247
|
+
if (!["http:", "https:"].includes(t.protocol) || !t.host) throw new Error("Invalid targetOrigin: protocol must be http or https and must have a host");
|
|
370
248
|
} catch {
|
|
371
249
|
throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)");
|
|
372
250
|
}
|
|
373
251
|
this.targetOrigin = e;
|
|
374
252
|
}
|
|
375
|
-
/**
|
|
376
|
-
* Get the current target origin
|
|
377
|
-
*/
|
|
378
253
|
getTargetOrigin() {
|
|
379
254
|
return this.targetOrigin;
|
|
380
255
|
}
|
|
381
|
-
/**
|
|
382
|
-
* Cleanup and destroy the adapter
|
|
383
|
-
*/
|
|
384
256
|
destroy() {
|
|
385
257
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
386
258
|
}
|
|
387
|
-
}
|
|
388
|
-
class oe {
|
|
259
|
+
}, se = class {
|
|
389
260
|
ipcAdapter;
|
|
390
|
-
constructor(e, t,
|
|
391
|
-
this.ipcAdapter = new
|
|
261
|
+
constructor(e, t, r) {
|
|
262
|
+
this.ipcAdapter = new $(e, t, r);
|
|
392
263
|
}
|
|
393
|
-
/**
|
|
394
|
-
* Cleanup and destroy the adapter
|
|
395
|
-
*/
|
|
396
264
|
destroy() {
|
|
397
265
|
this.ipcAdapter.destroy();
|
|
398
266
|
}
|
|
399
|
-
/**
|
|
400
|
-
* Request initialization configuration from the editor
|
|
401
|
-
*/
|
|
402
267
|
async getInitConfig() {
|
|
403
268
|
return await this.ipcAdapter.getInitConfig();
|
|
404
269
|
}
|
|
405
|
-
/**
|
|
406
|
-
* Request content from the editor in whatever format the integration supports
|
|
407
|
-
* @param options - Optional per-call overrides (e.g. timeout in ms; overrides default IPC timeout)
|
|
408
|
-
*/
|
|
409
270
|
async getContent(e) {
|
|
410
271
|
return await this.ipcAdapter.getContent(e);
|
|
411
272
|
}
|
|
412
|
-
/**
|
|
413
|
-
* Request selected content from the editor in whatever format the integration supports
|
|
414
|
-
* @param options - Optional per-call overrides (e.g. timeout in ms; overrides default IPC timeout)
|
|
415
|
-
*/
|
|
416
273
|
async getSelectedContent(e) {
|
|
417
274
|
return await this.ipcAdapter.getSelectedContent(e);
|
|
418
275
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
async
|
|
423
|
-
await this.ipcAdapter.
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
async selectContent(e, t) {
|
|
429
|
-
await this.ipcAdapter.selectContent(e, t);
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* Show a dialog in the editor
|
|
433
|
-
*/
|
|
434
|
-
async showDialog(e, t, i, n) {
|
|
435
|
-
await this.ipcAdapter.showDialog(e, t, i, n);
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Close the dialog in the editor
|
|
439
|
-
*/
|
|
276
|
+
async replaceContent(e, t) {
|
|
277
|
+
await this.ipcAdapter.replaceContent(e, t);
|
|
278
|
+
}
|
|
279
|
+
async selectContent(e) {
|
|
280
|
+
await this.ipcAdapter.selectContent(e);
|
|
281
|
+
}
|
|
282
|
+
async showDialog(e, t, r, i) {
|
|
283
|
+
await this.ipcAdapter.showDialog(e, t, r, i);
|
|
284
|
+
}
|
|
440
285
|
async closeDialog() {
|
|
441
286
|
await this.ipcAdapter.closeDialog();
|
|
442
287
|
}
|
|
443
|
-
/**
|
|
444
|
-
* Replace multiple contents in the editor
|
|
445
|
-
*/
|
|
446
288
|
async replaceMultipleContents(e) {
|
|
447
289
|
await this.ipcAdapter.replaceMultipleContents(e);
|
|
448
290
|
}
|
|
449
|
-
/**
|
|
450
|
-
* Notify plugin that one agent's results are available (streaming).
|
|
451
|
-
*/
|
|
452
291
|
onAgenticAgentResults(e, t) {
|
|
453
292
|
return this.ipcAdapter.onAgenticAgentResults(e, t);
|
|
454
293
|
}
|
|
455
|
-
/**
|
|
456
|
-
* Notify plugin that the agentic stream has finished.
|
|
457
|
-
*/
|
|
458
294
|
onAgenticStreamComplete() {
|
|
459
295
|
return this.ipcAdapter.onAgenticStreamComplete();
|
|
460
296
|
}
|
|
461
|
-
/**
|
|
462
|
-
* Update IPC configuration
|
|
463
|
-
*/
|
|
464
297
|
configure(e) {
|
|
465
298
|
this.ipcAdapter.configure(e);
|
|
466
299
|
}
|
|
467
|
-
/**
|
|
468
|
-
* Set or update the target origin for postMessage communication
|
|
469
|
-
*/
|
|
470
300
|
setTargetOrigin(e) {
|
|
471
301
|
this.ipcAdapter.setTargetOrigin(e);
|
|
472
302
|
}
|
|
473
|
-
/**
|
|
474
|
-
* Get the current target origin
|
|
475
|
-
*/
|
|
476
303
|
getTargetOrigin() {
|
|
477
304
|
return this.ipcAdapter.getTargetOrigin();
|
|
478
305
|
}
|
|
479
|
-
}
|
|
480
|
-
class j {
|
|
306
|
+
}, F = class {
|
|
481
307
|
ipc;
|
|
482
308
|
plugin;
|
|
483
309
|
iframe;
|
|
484
310
|
window;
|
|
485
311
|
targetOrigin;
|
|
486
|
-
constructor(e, t,
|
|
487
|
-
this.plugin = e, this.iframe = t, this.window =
|
|
488
|
-
this.iframe.contentWindow?.postMessage(
|
|
489
|
-
},
|
|
312
|
+
constructor(e, t, r, i, o = "*") {
|
|
313
|
+
this.plugin = e, this.iframe = t, this.window = r ?? window, this.targetOrigin = o, this.ipc = new M((n) => {
|
|
314
|
+
this.iframe.contentWindow?.postMessage(n, this.targetOrigin);
|
|
315
|
+
}, i), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
490
316
|
}
|
|
491
317
|
handleMessage = (e) => {
|
|
492
|
-
const t = this.window.location.origin,
|
|
493
|
-
e.origin !== t && (
|
|
318
|
+
const t = this.window.location.origin, r = this.targetOrigin;
|
|
319
|
+
e.origin !== t && (r !== "*" && e.origin !== r || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
494
320
|
};
|
|
495
321
|
registerReceivers() {
|
|
496
|
-
this.ipc.receive("getInitConfig", async () => await this.plugin.getInitConfig()), this.ipc.receive("getContent", async () => await this.plugin.getContent()), this.ipc.receive("getSelectedContent", async () => await this.plugin.getSelectedContent()), this.ipc.receive("replaceContent", async (e, t
|
|
497
|
-
await this.plugin.replaceContent(e, t
|
|
498
|
-
}), this.ipc.receive("selectContent", async (e
|
|
499
|
-
await this.plugin.selectContent(e
|
|
500
|
-
}), this.ipc.receive("showDialog", async (e, t,
|
|
501
|
-
await this.plugin.showDialog(e, t,
|
|
322
|
+
this.ipc.receive("getInitConfig", async () => await this.plugin.getInitConfig()), this.ipc.receive("getContent", async () => await this.plugin.getContent()), this.ipc.receive("getSelectedContent", async () => await this.plugin.getSelectedContent()), this.ipc.receive("replaceContent", async (e, t) => {
|
|
323
|
+
await this.plugin.replaceContent(e, t);
|
|
324
|
+
}), this.ipc.receive("selectContent", async (e) => {
|
|
325
|
+
await this.plugin.selectContent(e);
|
|
326
|
+
}), this.ipc.receive("showDialog", async (e, t, r, i) => {
|
|
327
|
+
await this.plugin.showDialog(e, t, r, i);
|
|
502
328
|
}), this.ipc.receive("closeDialog", async () => {
|
|
503
329
|
await this.plugin.closeDialog();
|
|
504
330
|
}), this.ipc.receive("replaceMultipleContents", async (e) => {
|
|
@@ -506,80 +332,49 @@ class j {
|
|
|
506
332
|
}), this.ipc.receive("onAgenticAgentResults", async (e, t) => {
|
|
507
333
|
if (!Array.isArray(t))
|
|
508
334
|
return;
|
|
509
|
-
const
|
|
510
|
-
|
|
335
|
+
const r = this.plugin.onAgenticAgentResults;
|
|
336
|
+
r && await r(e, t);
|
|
511
337
|
}), this.ipc.receive("onAgenticStreamComplete", async () => {
|
|
512
338
|
const e = this.plugin.onAgenticStreamComplete;
|
|
513
339
|
e && await e();
|
|
514
340
|
});
|
|
515
341
|
}
|
|
516
|
-
// ============================================
|
|
517
|
-
// Methods to call sidebar functions (Plugin → Sidebar)
|
|
518
|
-
// ============================================
|
|
519
|
-
/**
|
|
520
|
-
* Request sidebar to activate (expand and scroll to) the card for the given issue.
|
|
521
|
-
*/
|
|
522
342
|
async activateAgenticIssue(e) {
|
|
523
343
|
await this.ipc.call("activateAgenticIssue", e);
|
|
524
344
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
*/
|
|
345
|
+
async invalidateAgenticIssue(e) {
|
|
346
|
+
await this.ipc.call("invalidateAgenticIssue", e);
|
|
347
|
+
}
|
|
529
348
|
async notifyPluginStatus(e) {
|
|
530
349
|
await this.ipc.call("onPluginStatusChange", e);
|
|
531
350
|
}
|
|
532
|
-
/**
|
|
533
|
-
* Update IPC configuration
|
|
534
|
-
*/
|
|
535
351
|
configure(e) {
|
|
536
352
|
this.ipc.configure(e);
|
|
537
353
|
}
|
|
538
|
-
/**
|
|
539
|
-
* Cleanup and destroy the adapter
|
|
540
|
-
*/
|
|
541
354
|
destroy() {
|
|
542
355
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
543
356
|
}
|
|
544
|
-
}
|
|
545
|
-
class U {
|
|
357
|
+
}, W = class {
|
|
546
358
|
ipcAdapter;
|
|
547
|
-
constructor(e, t,
|
|
548
|
-
this.ipcAdapter = new
|
|
549
|
-
|
|
550
|
-
t,
|
|
551
|
-
i?.win,
|
|
552
|
-
i?.config,
|
|
553
|
-
i?.targetOrigin
|
|
554
|
-
);
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Cleanup and destroy the adapter
|
|
558
|
-
*/
|
|
359
|
+
constructor(e, t, r) {
|
|
360
|
+
this.ipcAdapter = new F(e, t, r?.win, r?.config, r?.targetOrigin);
|
|
361
|
+
}
|
|
559
362
|
destroy() {
|
|
560
363
|
this.ipcAdapter.destroy();
|
|
561
364
|
}
|
|
562
|
-
/**
|
|
563
|
-
* Notify sidebar of plugin status changes
|
|
564
|
-
* Example method demonstrating Plugin → Sidebar communication
|
|
565
|
-
*/
|
|
566
365
|
async notifyPluginStatus(e) {
|
|
567
366
|
await this.ipcAdapter.notifyPluginStatus(e);
|
|
568
367
|
}
|
|
569
|
-
/**
|
|
570
|
-
* Request sidebar to activate (expand and scroll to) the card for the given issue.
|
|
571
|
-
*/
|
|
572
368
|
async activateAgenticIssue(e) {
|
|
573
369
|
await this.ipcAdapter.activateAgenticIssue(e);
|
|
574
370
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
371
|
+
async invalidateAgenticIssue(e) {
|
|
372
|
+
await this.ipcAdapter.invalidateAgenticIssue(e);
|
|
373
|
+
}
|
|
578
374
|
configure(e) {
|
|
579
375
|
this.ipcAdapter.configure(e);
|
|
580
376
|
}
|
|
581
|
-
}
|
|
582
|
-
const $ = `
|
|
377
|
+
}, z = `
|
|
583
378
|
<div class="sidebar-load-overlay-card">
|
|
584
379
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
585
380
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -600,14 +395,16 @@ const $ = `
|
|
|
600
395
|
<span>Retry</span>
|
|
601
396
|
</button>
|
|
602
397
|
</div>
|
|
603
|
-
`,
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
const
|
|
607
|
-
if (!
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
398
|
+
`, J = () => {
|
|
399
|
+
const e = document.createElement("div");
|
|
400
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = z;
|
|
401
|
+
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
402
|
+
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
403
|
+
return {
|
|
404
|
+
overlay: e,
|
|
405
|
+
button: t
|
|
406
|
+
};
|
|
407
|
+
}, O = "markupai-sidebar-load-overlay-styles", X = `
|
|
611
408
|
:root {
|
|
612
409
|
--background: #f5f5f4;
|
|
613
410
|
--foreground: #333332;
|
|
@@ -699,125 +496,116 @@ const $ = `
|
|
|
699
496
|
box-shadow: 0 0 0 2px
|
|
700
497
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
701
498
|
}
|
|
702
|
-
`,
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
timeoutMs: s = z,
|
|
712
|
-
retryIntervalMs: o = Y
|
|
713
|
-
} = t, a = () => i ?? e.src, c = () => {
|
|
714
|
-
if (n) return n;
|
|
499
|
+
`, Y = (e) => {
|
|
500
|
+
const t = e ?? document;
|
|
501
|
+
if (t.getElementById(O)) return;
|
|
502
|
+
const r = t.createElement("style");
|
|
503
|
+
r.id = O, r.textContent = X, t.head.appendChild(r);
|
|
504
|
+
}, G = 8e3, V = 12e3, q = (e, t, r = {}) => {
|
|
505
|
+
Y(e.ownerDocument);
|
|
506
|
+
const { sidebarUrl: i, targetOrigin: o, timeoutMs: n = G, retryIntervalMs: a = V, messageListenWindow: s } = r, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => i ?? t.src, N = () => {
|
|
507
|
+
if (o) return o;
|
|
715
508
|
try {
|
|
716
|
-
return new URL(
|
|
509
|
+
return new URL(p()).origin;
|
|
717
510
|
} catch {
|
|
718
511
|
return "*";
|
|
719
512
|
}
|
|
720
|
-
}, { overlay:
|
|
721
|
-
|
|
722
|
-
let
|
|
723
|
-
const
|
|
724
|
-
|
|
513
|
+
}, { overlay: y, button: I } = J();
|
|
514
|
+
e.appendChild(y);
|
|
515
|
+
let u = !1, h, d;
|
|
516
|
+
const g = (c) => {
|
|
517
|
+
y.style.display = c ? "flex" : "none";
|
|
725
518
|
};
|
|
726
|
-
|
|
519
|
+
g(!1);
|
|
727
520
|
const m = () => {
|
|
728
|
-
|
|
729
|
-
},
|
|
730
|
-
m(),
|
|
731
|
-
|
|
732
|
-
},
|
|
733
|
-
},
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
},
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
},
|
|
740
|
-
}, S = () => {
|
|
741
|
-
g && (globalThis.clearInterval(g), g = void 0);
|
|
742
|
-
}, E = (d) => {
|
|
743
|
-
if (!e.contentWindow || d.source !== e.contentWindow) return;
|
|
744
|
-
const y = c();
|
|
745
|
-
y !== "*" && d.origin !== y || (h = !0, m(), S(), p(!1));
|
|
521
|
+
h && (globalThis.clearTimeout(h), h = void 0);
|
|
522
|
+
}, C = () => {
|
|
523
|
+
m(), h = globalThis.setTimeout(() => {
|
|
524
|
+
u || g(!0);
|
|
525
|
+
}, n);
|
|
526
|
+
}, b = (c) => {
|
|
527
|
+
const f = c?.preserveOverlay ?? !0;
|
|
528
|
+
u = !1, f || g(!1), t.src = p(), C();
|
|
529
|
+
}, B = () => {
|
|
530
|
+
d || a <= 0 || (d = globalThis.setInterval(() => {
|
|
531
|
+
u || b({ preserveOverlay: !0 });
|
|
532
|
+
}, a));
|
|
746
533
|
}, A = () => {
|
|
747
|
-
|
|
748
|
-
},
|
|
749
|
-
|
|
534
|
+
d && (globalThis.clearInterval(d), d = void 0);
|
|
535
|
+
}, w = (c) => {
|
|
536
|
+
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
537
|
+
const f = N();
|
|
538
|
+
f !== "*" && c.origin !== f || (u = !0, m(), A(), g(!1));
|
|
539
|
+
}, S = () => {
|
|
540
|
+
m(), g(!0);
|
|
541
|
+
}, P = () => {
|
|
542
|
+
b();
|
|
750
543
|
};
|
|
751
|
-
return
|
|
752
|
-
m(),
|
|
544
|
+
return I.addEventListener("click", P), t.addEventListener("error", S), l.addEventListener("message", w), C(), B(), () => {
|
|
545
|
+
m(), A(), t.removeEventListener("error", S), l.removeEventListener("message", w), I.removeEventListener("click", P), y.remove();
|
|
753
546
|
};
|
|
754
|
-
},
|
|
755
|
-
function
|
|
547
|
+
}, K = "Markup AI Sidebar", Z = "clipboard-read; clipboard-write", le = "markupai.sidebarNextGen.overrideUrl", ce = "https://sidebar.markup.ai/";
|
|
548
|
+
function de(e) {
|
|
756
549
|
try {
|
|
757
|
-
return typeof globalThis.localStorage > "u" ?
|
|
550
|
+
return typeof globalThis.localStorage > "u" ? e : globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
758
551
|
} catch {
|
|
759
|
-
return
|
|
552
|
+
return e;
|
|
760
553
|
}
|
|
761
554
|
}
|
|
762
|
-
function
|
|
555
|
+
function ge(e, t) {
|
|
763
556
|
try {
|
|
764
|
-
return new URL(
|
|
765
|
-
} catch (
|
|
766
|
-
return
|
|
557
|
+
return new URL(e).origin;
|
|
558
|
+
} catch (r) {
|
|
559
|
+
return t?.onInvalidUrl?.(e, r), "*";
|
|
767
560
|
}
|
|
768
561
|
}
|
|
769
|
-
function
|
|
770
|
-
if (
|
|
771
|
-
throw new Error(e);
|
|
562
|
+
function pe(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
563
|
+
if (e.adapter === null) throw new Error(t);
|
|
772
564
|
}
|
|
773
|
-
function
|
|
774
|
-
const { iframe:
|
|
775
|
-
if (
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
const { container: i, src:
|
|
782
|
-
return
|
|
783
|
-
iframe:
|
|
565
|
+
function Q(e) {
|
|
566
|
+
const { iframe: t, iframeMount: r } = e;
|
|
567
|
+
if (t !== void 0 && r !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
568
|
+
if (t !== void 0) return {
|
|
569
|
+
iframe: t,
|
|
570
|
+
removeMountedIframe: null
|
|
571
|
+
};
|
|
572
|
+
if (r === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
573
|
+
const { container: i, src: o, allow: n = Z } = r, a = document.createElement("iframe");
|
|
574
|
+
return a.title = K, a.src = o, n && a.setAttribute("allow", n), i.appendChild(a), {
|
|
575
|
+
iframe: a,
|
|
784
576
|
removeMountedIframe: () => {
|
|
785
|
-
|
|
577
|
+
a.remove();
|
|
786
578
|
}
|
|
787
579
|
};
|
|
788
580
|
}
|
|
789
|
-
function
|
|
790
|
-
const { plugin:
|
|
791
|
-
if (
|
|
792
|
-
const
|
|
581
|
+
function ue(e) {
|
|
582
|
+
const { plugin: t, loadOverlayContainer: r, loadOverlayOptions: i, adapterOptions: o } = e, { iframe: n, removeMountedIframe: a } = Q(e), s = r !== void 0 ? q(r, n, i ?? {}) : null;
|
|
583
|
+
if (t !== void 0) {
|
|
584
|
+
const l = new W(t, n, o);
|
|
793
585
|
return {
|
|
794
|
-
iframe:
|
|
795
|
-
adapter:
|
|
586
|
+
iframe: n,
|
|
587
|
+
adapter: l,
|
|
796
588
|
destroy: () => {
|
|
797
|
-
|
|
589
|
+
s?.(), l.destroy(), a?.();
|
|
798
590
|
}
|
|
799
591
|
};
|
|
800
592
|
}
|
|
801
593
|
return {
|
|
802
|
-
iframe:
|
|
594
|
+
iframe: n,
|
|
803
595
|
adapter: null,
|
|
804
596
|
destroy: () => {
|
|
805
|
-
|
|
597
|
+
s?.(), a?.();
|
|
806
598
|
}
|
|
807
599
|
};
|
|
808
600
|
}
|
|
809
|
-
|
|
810
|
-
function
|
|
811
|
-
if (typeof CSS < "u" && typeof CSS.escape == "function")
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
throw new Error(
|
|
815
|
-
`sidebar host shell: containerId must match /^[a-zA-Z_][\\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(r)})`
|
|
816
|
-
);
|
|
817
|
-
return r;
|
|
601
|
+
var x = "sidebarContainer", D = "markupai-sidebar-host-shell-styles";
|
|
602
|
+
function _(e) {
|
|
603
|
+
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
604
|
+
if (!/^[a-zA-Z_][\w-]*$/.test(e)) throw new Error(`sidebar host shell: containerId must match /^[a-zA-Z_][\\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(e)})`);
|
|
605
|
+
return e;
|
|
818
606
|
}
|
|
819
|
-
function
|
|
820
|
-
const
|
|
607
|
+
function k(e = x) {
|
|
608
|
+
const t = _(e);
|
|
821
609
|
return `
|
|
822
610
|
html {
|
|
823
611
|
height: 100%;
|
|
@@ -826,12 +614,12 @@ body {
|
|
|
826
614
|
height: 100%;
|
|
827
615
|
margin: 0;
|
|
828
616
|
}
|
|
829
|
-
#${
|
|
617
|
+
#${t} {
|
|
830
618
|
height: 100%;
|
|
831
619
|
box-sizing: border-box;
|
|
832
620
|
position: relative;
|
|
833
621
|
}
|
|
834
|
-
#${
|
|
622
|
+
#${t} iframe {
|
|
835
623
|
width: 100%;
|
|
836
624
|
height: 100%;
|
|
837
625
|
border: 0;
|
|
@@ -842,96 +630,80 @@ body {
|
|
|
842
630
|
}
|
|
843
631
|
`.trim();
|
|
844
632
|
}
|
|
845
|
-
|
|
846
|
-
function
|
|
847
|
-
return
|
|
848
|
-
}
|
|
849
|
-
function
|
|
850
|
-
if (!
|
|
851
|
-
const i =
|
|
852
|
-
i.id =
|
|
853
|
-
}
|
|
854
|
-
function
|
|
855
|
-
const {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
if (
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
);
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
if (!(e instanceof Document)) {
|
|
870
|
-
const a = n.createElement("div");
|
|
871
|
-
return a.id = t, e.appendChild(a), a;
|
|
872
|
-
}
|
|
873
|
-
const o = n.createElement("div");
|
|
874
|
-
return o.id = t, n.body.appendChild(o), o;
|
|
875
|
-
}
|
|
876
|
-
function ee() {
|
|
633
|
+
var he = k();
|
|
634
|
+
function ee(e) {
|
|
635
|
+
return e instanceof Document ? e : e.ownerDocument;
|
|
636
|
+
}
|
|
637
|
+
function te(e, t, r) {
|
|
638
|
+
if (!t || e.getElementById(D)) return;
|
|
639
|
+
const i = e.createElement("style");
|
|
640
|
+
i.id = D, i.textContent = k(r), e.head.appendChild(i);
|
|
641
|
+
}
|
|
642
|
+
function me(e) {
|
|
643
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: r = x, includeDefaultStyles: i = !0 } = e ?? {};
|
|
644
|
+
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
645
|
+
const o = ee(t);
|
|
646
|
+
te(o, i, r);
|
|
647
|
+
const n = t instanceof Document ? o.getElementById(r) : t.querySelector(`#${_(r)}`);
|
|
648
|
+
if (n instanceof HTMLElement && (t instanceof Document || t.contains(n))) return n;
|
|
649
|
+
if (!(t instanceof Document)) {
|
|
650
|
+
const s = o.createElement("div");
|
|
651
|
+
return s.id = r, t.appendChild(s), s;
|
|
652
|
+
}
|
|
653
|
+
const a = o.createElement("div");
|
|
654
|
+
return a.id = r, o.body.appendChild(a), a;
|
|
655
|
+
}
|
|
656
|
+
function re() {
|
|
877
657
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
878
658
|
}
|
|
879
|
-
function
|
|
880
|
-
const {
|
|
881
|
-
title: e = "Markup AI Sidebar",
|
|
882
|
-
headInnerHtml: t = "",
|
|
883
|
-
includePluginHostHead: i = !1,
|
|
884
|
-
bodyScriptsHtml: n,
|
|
885
|
-
htmlLang: s = "en",
|
|
886
|
-
htmlAttrs: o = `lang="${s}" style="height:100%"`,
|
|
887
|
-
bodyAttrs: a = 'style="height:100%;margin:0"'
|
|
888
|
-
} = r, l = [i ? ee() : "", t].filter((u) => u.trim().length > 0).join(`
|
|
659
|
+
function fe(e) {
|
|
660
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: r = "", includePluginHostHead: i = !1, bodyScriptsHtml: o, htmlLang: n = "en", htmlAttrs: a = `lang="${n}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [i ? re() : "", r].filter((p) => p.trim().length > 0).join(`
|
|
889
661
|
`);
|
|
890
662
|
return `<!DOCTYPE html>
|
|
891
|
-
<html ${
|
|
663
|
+
<html ${a}>
|
|
892
664
|
<head>
|
|
893
665
|
<base target="_top" />
|
|
894
666
|
<meta charset="UTF-8" />
|
|
895
|
-
<title>${
|
|
667
|
+
<title>${ie(t)}</title>${l ? `
|
|
896
668
|
${l}` : ""}
|
|
897
669
|
</head>
|
|
898
|
-
<body ${
|
|
899
|
-
${
|
|
670
|
+
<body ${s}>
|
|
671
|
+
${o}
|
|
900
672
|
</body>
|
|
901
673
|
</html>
|
|
902
674
|
`;
|
|
903
675
|
}
|
|
904
|
-
function
|
|
905
|
-
return
|
|
676
|
+
function ie(e) {
|
|
677
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
906
678
|
}
|
|
907
679
|
export {
|
|
908
|
-
|
|
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
|
-
|
|
680
|
+
j as DEFAULT_IPC_CONFIG,
|
|
681
|
+
oe as DEFAULT_SIDEBAR_CONFIG,
|
|
682
|
+
U as DeferredPromise,
|
|
683
|
+
M as IPCCore,
|
|
684
|
+
v as MimeType,
|
|
685
|
+
se as PluginAdapter,
|
|
686
|
+
$ as PluginIPCAdapter,
|
|
687
|
+
ce as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
688
|
+
x as SIDEBAR_HOST_CONTAINER_ID,
|
|
689
|
+
he as SIDEBAR_HOST_SHELL_CSS,
|
|
690
|
+
Z as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
691
|
+
K as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
692
|
+
le as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
693
|
+
W as SidebarAdapter,
|
|
694
|
+
F as SidebarIPCAdapter,
|
|
695
|
+
ne as TEXT_MIME_TYPES,
|
|
696
|
+
R as TextLookupError,
|
|
697
|
+
pe as assertSidebarHostAdapter,
|
|
698
|
+
fe as buildSidebarHostHtmlDocument,
|
|
699
|
+
k as buildSidebarHostShellCss,
|
|
700
|
+
re as buildSidebarPluginHostHeadInnerHtml,
|
|
701
|
+
ue as createSidebarHost,
|
|
702
|
+
me as ensureSidebarHostShell,
|
|
703
|
+
de as getSidebarBaseUrlWithOverride,
|
|
704
|
+
E as ipcErrorReconstructors,
|
|
705
|
+
ae as isTextLookupError,
|
|
706
|
+
H as reconstructError,
|
|
707
|
+
q as setupSidebarLoadOverlay,
|
|
708
|
+
ge as sidebarPostMessageTargetOrigin
|
|
937
709
|
};
|