@markupai/sidebar-adapter 0.0.23 → 1.1.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 +106 -23
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/pluginAdapter.d.ts +79 -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 +69 -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 +83 -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 +312 -514
- package/dist/main.umd.cjs +12 -12
- package/dist/sidebar-host/createSidebarHost.d.ts +107 -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 +132 -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 +89 -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
|
+
})({}), oe = [
|
|
4
|
+
v.TEXT_PLAIN,
|
|
5
|
+
v.TEXT_MARKDOWN,
|
|
6
|
+
v.TEXT_HTML,
|
|
7
|
+
v.APPLICATION_DITA_XML
|
|
8
|
+
], ae = {
|
|
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
|
+
}, D = class _ extends Error {
|
|
18
17
|
name = "TextLookupError";
|
|
19
|
-
constructor(
|
|
20
|
-
super(
|
|
18
|
+
constructor(t) {
|
|
19
|
+
super(t), Object.setPrototypeOf(this, _.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 se(e) {
|
|
23
|
+
return e instanceof D;
|
|
32
24
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
var P = { TextLookupError: (e) => new D(e) };
|
|
26
|
+
function H(e) {
|
|
27
|
+
const t = e.message ?? "", r = e.name, i = typeof r == "string" && r in P ? P[r] : void 0;
|
|
28
|
+
return i ? i(t, e) : Object.assign(new Error(t), r ? { name: r } : {});
|
|
29
|
+
}
|
|
30
|
+
var O = () => {
|
|
31
|
+
}, U = class {
|
|
36
32
|
_promise;
|
|
37
33
|
[Symbol.toStringTag] = "Promise";
|
|
38
|
-
/**
|
|
39
|
-
* Resolves the underlying promise with a specified value.
|
|
40
|
-
*
|
|
41
|
-
* @param value - The value to resolve the promise with.
|
|
42
|
-
*/
|
|
43
34
|
resolve = O;
|
|
44
|
-
/**
|
|
45
|
-
* Rejects the underlying promise with a specified reason.
|
|
46
|
-
*
|
|
47
|
-
* @param reason - The reason for rejecting the promise.
|
|
48
|
-
*/
|
|
49
35
|
reject = O;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a new instance of DeferredPromise.
|
|
52
|
-
*/
|
|
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 }, L = 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
|
+
}, F = 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 L((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,137 @@ 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
|
-
|
|
354
|
-
|
|
240
|
+
async openAuthUrl(e) {
|
|
241
|
+
await this.ipc.call("openAuthUrl", e);
|
|
242
|
+
}
|
|
355
243
|
configure(e) {
|
|
356
244
|
this.ipc.configure(e);
|
|
357
245
|
}
|
|
358
|
-
/**
|
|
359
|
-
* Set or update the target origin for postMessage communication
|
|
360
|
-
*/
|
|
361
246
|
setTargetOrigin(e) {
|
|
362
|
-
if (!e || typeof e != "string")
|
|
363
|
-
throw new Error("Invalid targetOrigin: must be a non-empty string");
|
|
247
|
+
if (!e || typeof e != "string") throw new Error("Invalid targetOrigin: must be a non-empty string");
|
|
364
248
|
try {
|
|
365
249
|
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
|
-
);
|
|
250
|
+
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
251
|
} catch {
|
|
371
252
|
throw new Error("Invalid targetOrigin: must be a valid origin (e.g., https://example.com)");
|
|
372
253
|
}
|
|
373
254
|
this.targetOrigin = e;
|
|
374
255
|
}
|
|
375
|
-
/**
|
|
376
|
-
* Get the current target origin
|
|
377
|
-
*/
|
|
378
256
|
getTargetOrigin() {
|
|
379
257
|
return this.targetOrigin;
|
|
380
258
|
}
|
|
381
|
-
/**
|
|
382
|
-
* Cleanup and destroy the adapter
|
|
383
|
-
*/
|
|
384
259
|
destroy() {
|
|
385
260
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
386
261
|
}
|
|
387
|
-
}
|
|
388
|
-
class oe {
|
|
262
|
+
}, le = class {
|
|
389
263
|
ipcAdapter;
|
|
390
|
-
constructor(e, t,
|
|
391
|
-
this.ipcAdapter = new
|
|
264
|
+
constructor(e, t, r) {
|
|
265
|
+
this.ipcAdapter = new F(e, t, r);
|
|
392
266
|
}
|
|
393
|
-
/**
|
|
394
|
-
* Cleanup and destroy the adapter
|
|
395
|
-
*/
|
|
396
267
|
destroy() {
|
|
397
268
|
this.ipcAdapter.destroy();
|
|
398
269
|
}
|
|
399
|
-
/**
|
|
400
|
-
* Request initialization configuration from the editor
|
|
401
|
-
*/
|
|
402
270
|
async getInitConfig() {
|
|
403
271
|
return await this.ipcAdapter.getInitConfig();
|
|
404
272
|
}
|
|
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
273
|
async getContent(e) {
|
|
410
274
|
return await this.ipcAdapter.getContent(e);
|
|
411
275
|
}
|
|
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
276
|
async getSelectedContent(e) {
|
|
417
277
|
return await this.ipcAdapter.getSelectedContent(e);
|
|
418
278
|
}
|
|
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
|
-
*/
|
|
279
|
+
async replaceContent(e, t) {
|
|
280
|
+
await this.ipcAdapter.replaceContent(e, t);
|
|
281
|
+
}
|
|
282
|
+
async selectContent(e) {
|
|
283
|
+
await this.ipcAdapter.selectContent(e);
|
|
284
|
+
}
|
|
285
|
+
async showDialog(e, t, r, i) {
|
|
286
|
+
await this.ipcAdapter.showDialog(e, t, r, i);
|
|
287
|
+
}
|
|
440
288
|
async closeDialog() {
|
|
441
289
|
await this.ipcAdapter.closeDialog();
|
|
442
290
|
}
|
|
443
|
-
/**
|
|
444
|
-
* Replace multiple contents in the editor
|
|
445
|
-
*/
|
|
446
291
|
async replaceMultipleContents(e) {
|
|
447
292
|
await this.ipcAdapter.replaceMultipleContents(e);
|
|
448
293
|
}
|
|
449
|
-
/**
|
|
450
|
-
* Notify plugin that one agent's results are available (streaming).
|
|
451
|
-
*/
|
|
452
294
|
onAgenticAgentResults(e, t) {
|
|
453
295
|
return this.ipcAdapter.onAgenticAgentResults(e, t);
|
|
454
296
|
}
|
|
455
|
-
/**
|
|
456
|
-
* Notify plugin that the agentic stream has finished.
|
|
457
|
-
*/
|
|
458
297
|
onAgenticStreamComplete() {
|
|
459
298
|
return this.ipcAdapter.onAgenticStreamComplete();
|
|
460
299
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
300
|
+
openAuthUrl(e) {
|
|
301
|
+
return this.ipcAdapter.openAuthUrl(e);
|
|
302
|
+
}
|
|
464
303
|
configure(e) {
|
|
465
304
|
this.ipcAdapter.configure(e);
|
|
466
305
|
}
|
|
467
|
-
/**
|
|
468
|
-
* Set or update the target origin for postMessage communication
|
|
469
|
-
*/
|
|
470
306
|
setTargetOrigin(e) {
|
|
471
307
|
this.ipcAdapter.setTargetOrigin(e);
|
|
472
308
|
}
|
|
473
|
-
/**
|
|
474
|
-
* Get the current target origin
|
|
475
|
-
*/
|
|
476
309
|
getTargetOrigin() {
|
|
477
310
|
return this.ipcAdapter.getTargetOrigin();
|
|
478
311
|
}
|
|
479
|
-
}
|
|
480
|
-
class j {
|
|
312
|
+
}, $ = class {
|
|
481
313
|
ipc;
|
|
482
314
|
plugin;
|
|
483
315
|
iframe;
|
|
484
316
|
window;
|
|
485
317
|
targetOrigin;
|
|
486
|
-
constructor(e, t,
|
|
487
|
-
this.plugin = e, this.iframe = t, this.window =
|
|
488
|
-
this.iframe.contentWindow?.postMessage(
|
|
489
|
-
},
|
|
318
|
+
constructor(e, t, r, i, o = "*") {
|
|
319
|
+
this.plugin = e, this.iframe = t, this.window = r ?? window, this.targetOrigin = o, this.ipc = new L((n) => {
|
|
320
|
+
this.iframe.contentWindow?.postMessage(n, this.targetOrigin);
|
|
321
|
+
}, i), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
490
322
|
}
|
|
491
323
|
handleMessage = (e) => {
|
|
492
|
-
const t = this.window.location.origin,
|
|
493
|
-
e.origin !== t && (
|
|
324
|
+
const t = this.window.location.origin, r = this.targetOrigin;
|
|
325
|
+
e.origin !== t && (r !== "*" && e.origin !== r || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
494
326
|
};
|
|
495
327
|
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,
|
|
328
|
+
if (this.ipc.receive("getInitConfig", async () => await this.plugin.getInitConfig()), this.ipc.receive("getContent", async () => await this.plugin.getContent()), this.ipc.receive("getSelectedContent", async () => await this.plugin.getSelectedContent()), this.ipc.receive("replaceContent", async (e, t) => {
|
|
329
|
+
await this.plugin.replaceContent(e, t);
|
|
330
|
+
}), this.ipc.receive("selectContent", async (e) => {
|
|
331
|
+
await this.plugin.selectContent(e);
|
|
332
|
+
}), this.ipc.receive("showDialog", async (e, t, r, i) => {
|
|
333
|
+
await this.plugin.showDialog(e, t, r, i);
|
|
502
334
|
}), this.ipc.receive("closeDialog", async () => {
|
|
503
335
|
await this.plugin.closeDialog();
|
|
504
336
|
}), this.ipc.receive("replaceMultipleContents", async (e) => {
|
|
@@ -506,80 +338,54 @@ class j {
|
|
|
506
338
|
}), this.ipc.receive("onAgenticAgentResults", async (e, t) => {
|
|
507
339
|
if (!Array.isArray(t))
|
|
508
340
|
return;
|
|
509
|
-
const
|
|
510
|
-
|
|
341
|
+
const r = this.plugin.onAgenticAgentResults;
|
|
342
|
+
r && await r(e, t);
|
|
511
343
|
}), this.ipc.receive("onAgenticStreamComplete", async () => {
|
|
512
344
|
const e = this.plugin.onAgenticStreamComplete;
|
|
513
345
|
e && await e();
|
|
514
|
-
})
|
|
346
|
+
}), this.plugin.openAuthUrl) {
|
|
347
|
+
const e = this.plugin.openAuthUrl;
|
|
348
|
+
this.ipc.receive("openAuthUrl", async (t) => {
|
|
349
|
+
await e(t);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
515
352
|
}
|
|
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
353
|
async activateAgenticIssue(e) {
|
|
523
354
|
await this.ipc.call("activateAgenticIssue", e);
|
|
524
355
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
*/
|
|
356
|
+
async invalidateAgenticIssue(e) {
|
|
357
|
+
await this.ipc.call("invalidateAgenticIssue", e);
|
|
358
|
+
}
|
|
529
359
|
async notifyPluginStatus(e) {
|
|
530
360
|
await this.ipc.call("onPluginStatusChange", e);
|
|
531
361
|
}
|
|
532
|
-
/**
|
|
533
|
-
* Update IPC configuration
|
|
534
|
-
*/
|
|
535
362
|
configure(e) {
|
|
536
363
|
this.ipc.configure(e);
|
|
537
364
|
}
|
|
538
|
-
/**
|
|
539
|
-
* Cleanup and destroy the adapter
|
|
540
|
-
*/
|
|
541
365
|
destroy() {
|
|
542
366
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
543
367
|
}
|
|
544
|
-
}
|
|
545
|
-
class U {
|
|
368
|
+
}, W = class {
|
|
546
369
|
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
|
-
*/
|
|
370
|
+
constructor(e, t, r) {
|
|
371
|
+
this.ipcAdapter = new $(e, t, r?.win, r?.config, r?.targetOrigin);
|
|
372
|
+
}
|
|
559
373
|
destroy() {
|
|
560
374
|
this.ipcAdapter.destroy();
|
|
561
375
|
}
|
|
562
|
-
/**
|
|
563
|
-
* Notify sidebar of plugin status changes
|
|
564
|
-
* Example method demonstrating Plugin → Sidebar communication
|
|
565
|
-
*/
|
|
566
376
|
async notifyPluginStatus(e) {
|
|
567
377
|
await this.ipcAdapter.notifyPluginStatus(e);
|
|
568
378
|
}
|
|
569
|
-
/**
|
|
570
|
-
* Request sidebar to activate (expand and scroll to) the card for the given issue.
|
|
571
|
-
*/
|
|
572
379
|
async activateAgenticIssue(e) {
|
|
573
380
|
await this.ipcAdapter.activateAgenticIssue(e);
|
|
574
381
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
382
|
+
async invalidateAgenticIssue(e) {
|
|
383
|
+
await this.ipcAdapter.invalidateAgenticIssue(e);
|
|
384
|
+
}
|
|
578
385
|
configure(e) {
|
|
579
386
|
this.ipcAdapter.configure(e);
|
|
580
387
|
}
|
|
581
|
-
}
|
|
582
|
-
const $ = `
|
|
388
|
+
}, G = `
|
|
583
389
|
<div class="sidebar-load-overlay-card">
|
|
584
390
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
585
391
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -600,14 +406,16 @@ const $ = `
|
|
|
600
406
|
<span>Retry</span>
|
|
601
407
|
</button>
|
|
602
408
|
</div>
|
|
603
|
-
`,
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
const
|
|
607
|
-
if (!
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
409
|
+
`, z = () => {
|
|
410
|
+
const e = document.createElement("div");
|
|
411
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = G;
|
|
412
|
+
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
413
|
+
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
414
|
+
return {
|
|
415
|
+
overlay: e,
|
|
416
|
+
button: t
|
|
417
|
+
};
|
|
418
|
+
}, T = "markupai-sidebar-load-overlay-styles", J = `
|
|
611
419
|
:root {
|
|
612
420
|
--background: #f5f5f4;
|
|
613
421
|
--foreground: #333332;
|
|
@@ -699,125 +507,129 @@ const $ = `
|
|
|
699
507
|
box-shadow: 0 0 0 2px
|
|
700
508
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
701
509
|
}
|
|
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;
|
|
510
|
+
`, X = (e) => {
|
|
511
|
+
const t = e ?? document;
|
|
512
|
+
if (t.getElementById(T)) return;
|
|
513
|
+
const r = t.createElement("style");
|
|
514
|
+
r.id = T, r.textContent = J, t.head.appendChild(r);
|
|
515
|
+
}, Y = 8e3, V = 12e3, K = (e, t, r = {}) => {
|
|
516
|
+
X(e.ownerDocument);
|
|
517
|
+
const { sidebarUrl: i, targetOrigin: o, timeoutMs: n = Y, retryIntervalMs: a = V, messageListenWindow: s } = r, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => i ?? t.src, k = () => {
|
|
518
|
+
if (o) return o;
|
|
715
519
|
try {
|
|
716
|
-
return new URL(
|
|
520
|
+
return new URL(p()).origin;
|
|
717
521
|
} catch {
|
|
718
522
|
return "*";
|
|
719
523
|
}
|
|
720
|
-
}, { overlay:
|
|
721
|
-
|
|
722
|
-
let
|
|
723
|
-
const
|
|
724
|
-
|
|
524
|
+
}, { overlay: y, button: I } = z();
|
|
525
|
+
e.appendChild(y);
|
|
526
|
+
let u = !1, h, d;
|
|
527
|
+
const g = (c) => {
|
|
528
|
+
y.style.display = c ? "flex" : "none";
|
|
725
529
|
};
|
|
726
|
-
|
|
530
|
+
g(!1);
|
|
727
531
|
const m = () => {
|
|
728
|
-
|
|
532
|
+
h && (globalThis.clearTimeout(h), h = void 0);
|
|
533
|
+
}, A = () => {
|
|
534
|
+
m(), h = globalThis.setTimeout(() => {
|
|
535
|
+
u || g(!0);
|
|
536
|
+
}, n);
|
|
537
|
+
}, C = (c) => {
|
|
538
|
+
const f = c?.preserveOverlay ?? !0;
|
|
539
|
+
u = !1, f || g(!1), t.src = p(), A();
|
|
540
|
+
}, B = () => {
|
|
541
|
+
d || a <= 0 || (d = globalThis.setInterval(() => {
|
|
542
|
+
u || C({ preserveOverlay: !0 });
|
|
543
|
+
}, a));
|
|
729
544
|
}, b = () => {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
h = !1, y || p(!1), e.src = a(), b();
|
|
736
|
-
}, R = () => {
|
|
737
|
-
g || o <= 0 || (g = globalThis.setInterval(() => {
|
|
738
|
-
h || w({ preserveOverlay: !0 });
|
|
739
|
-
}, o));
|
|
545
|
+
d && (globalThis.clearInterval(d), d = void 0);
|
|
546
|
+
}, w = (c) => {
|
|
547
|
+
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
548
|
+
const f = k();
|
|
549
|
+
f !== "*" && c.origin !== f || (u = !0, m(), b(), g(!1));
|
|
740
550
|
}, S = () => {
|
|
741
|
-
|
|
742
|
-
}, E = (
|
|
743
|
-
|
|
744
|
-
const y = c();
|
|
745
|
-
y !== "*" && d.origin !== y || (h = !0, m(), S(), p(!1));
|
|
746
|
-
}, A = () => {
|
|
747
|
-
m(), p(!0);
|
|
748
|
-
}, I = () => {
|
|
749
|
-
w();
|
|
551
|
+
m(), g(!0);
|
|
552
|
+
}, E = () => {
|
|
553
|
+
C();
|
|
750
554
|
};
|
|
751
|
-
return
|
|
752
|
-
m(),
|
|
555
|
+
return I.addEventListener("click", E), t.addEventListener("error", S), l.addEventListener("message", w), A(), B(), () => {
|
|
556
|
+
m(), b(), t.removeEventListener("error", S), l.removeEventListener("message", w), I.removeEventListener("click", E), y.remove();
|
|
753
557
|
};
|
|
754
|
-
},
|
|
755
|
-
function
|
|
558
|
+
}, q = "Markup AI Sidebar", Z = "clipboard-read; clipboard-write", ce = "markupai.sidebarNextGen.overrideUrl", de = "https://sidebar.markup.ai/";
|
|
559
|
+
function ge(e) {
|
|
756
560
|
try {
|
|
757
|
-
return
|
|
561
|
+
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
758
562
|
} catch {
|
|
759
|
-
return
|
|
563
|
+
return e;
|
|
760
564
|
}
|
|
761
565
|
}
|
|
762
|
-
|
|
566
|
+
var Q = "markupai.sidebarNextGen.authOverride";
|
|
567
|
+
function pe(e, t) {
|
|
568
|
+
if (!t) return e;
|
|
763
569
|
try {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
570
|
+
if (!("localStorage" in globalThis)) return e;
|
|
571
|
+
const r = globalThis.localStorage.getItem(Q)?.trim();
|
|
572
|
+
if (!r) return e;
|
|
573
|
+
const i = JSON.parse(r);
|
|
574
|
+
return i !== null && typeof i == "object" && "type" in i && (i.type === "mediation" || i.type === "popup") ? i : e;
|
|
575
|
+
} catch {
|
|
576
|
+
return e;
|
|
767
577
|
}
|
|
768
578
|
}
|
|
769
|
-
function
|
|
770
|
-
|
|
771
|
-
|
|
579
|
+
function ue(e, t) {
|
|
580
|
+
try {
|
|
581
|
+
return new URL(e).origin;
|
|
582
|
+
} catch (r) {
|
|
583
|
+
return t?.onInvalidUrl?.(e, r), "*";
|
|
584
|
+
}
|
|
772
585
|
}
|
|
773
|
-
function
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
if (t
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
586
|
+
function he(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
587
|
+
if (e.adapter === null) throw new Error(t);
|
|
588
|
+
}
|
|
589
|
+
function ee(e) {
|
|
590
|
+
const { iframe: t, iframeMount: r } = e;
|
|
591
|
+
if (t !== void 0 && r !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
592
|
+
if (t !== void 0) return {
|
|
593
|
+
iframe: t,
|
|
594
|
+
removeMountedIframe: null
|
|
595
|
+
};
|
|
596
|
+
if (r === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
597
|
+
const { container: i, src: o, allow: n = Z } = r, a = document.createElement("iframe");
|
|
598
|
+
return a.title = q, a.src = o, n && a.setAttribute("allow", n), i.appendChild(a), {
|
|
599
|
+
iframe: a,
|
|
784
600
|
removeMountedIframe: () => {
|
|
785
|
-
|
|
601
|
+
a.remove();
|
|
786
602
|
}
|
|
787
603
|
};
|
|
788
604
|
}
|
|
789
|
-
function
|
|
790
|
-
const { plugin:
|
|
791
|
-
if (
|
|
792
|
-
const
|
|
605
|
+
function me(e) {
|
|
606
|
+
const { plugin: t, loadOverlayContainer: r, loadOverlayOptions: i, adapterOptions: o } = e, { iframe: n, removeMountedIframe: a } = ee(e), s = r !== void 0 ? K(r, n, i ?? {}) : null;
|
|
607
|
+
if (t !== void 0) {
|
|
608
|
+
const l = new W(t, n, o);
|
|
793
609
|
return {
|
|
794
|
-
iframe:
|
|
795
|
-
adapter:
|
|
610
|
+
iframe: n,
|
|
611
|
+
adapter: l,
|
|
796
612
|
destroy: () => {
|
|
797
|
-
|
|
613
|
+
s?.(), l.destroy(), a?.();
|
|
798
614
|
}
|
|
799
615
|
};
|
|
800
616
|
}
|
|
801
617
|
return {
|
|
802
|
-
iframe:
|
|
618
|
+
iframe: n,
|
|
803
619
|
adapter: null,
|
|
804
620
|
destroy: () => {
|
|
805
|
-
|
|
621
|
+
s?.(), a?.();
|
|
806
622
|
}
|
|
807
623
|
};
|
|
808
624
|
}
|
|
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;
|
|
625
|
+
var M = "sidebarContainer", R = "markupai-sidebar-host-shell-styles";
|
|
626
|
+
function x(e) {
|
|
627
|
+
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
628
|
+
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)})`);
|
|
629
|
+
return e;
|
|
818
630
|
}
|
|
819
|
-
function
|
|
820
|
-
const
|
|
631
|
+
function N(e = M) {
|
|
632
|
+
const t = x(e);
|
|
821
633
|
return `
|
|
822
634
|
html {
|
|
823
635
|
height: 100%;
|
|
@@ -826,12 +638,12 @@ body {
|
|
|
826
638
|
height: 100%;
|
|
827
639
|
margin: 0;
|
|
828
640
|
}
|
|
829
|
-
#${
|
|
641
|
+
#${t} {
|
|
830
642
|
height: 100%;
|
|
831
643
|
box-sizing: border-box;
|
|
832
644
|
position: relative;
|
|
833
645
|
}
|
|
834
|
-
#${
|
|
646
|
+
#${t} iframe {
|
|
835
647
|
width: 100%;
|
|
836
648
|
height: 100%;
|
|
837
649
|
border: 0;
|
|
@@ -842,96 +654,82 @@ body {
|
|
|
842
654
|
}
|
|
843
655
|
`.trim();
|
|
844
656
|
}
|
|
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() {
|
|
657
|
+
var fe = N();
|
|
658
|
+
function te(e) {
|
|
659
|
+
return e instanceof Document ? e : e.ownerDocument;
|
|
660
|
+
}
|
|
661
|
+
function re(e, t, r) {
|
|
662
|
+
if (!t || e.getElementById(R)) return;
|
|
663
|
+
const i = e.createElement("style");
|
|
664
|
+
i.id = R, i.textContent = N(r), e.head.appendChild(i);
|
|
665
|
+
}
|
|
666
|
+
function ve(e) {
|
|
667
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: r = M, includeDefaultStyles: i = !0 } = e ?? {};
|
|
668
|
+
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
669
|
+
const o = te(t);
|
|
670
|
+
re(o, i, r);
|
|
671
|
+
const n = t instanceof Document ? o.getElementById(r) : t.querySelector(`#${x(r)}`);
|
|
672
|
+
if (n instanceof HTMLElement && (t instanceof Document || t.contains(n))) return n;
|
|
673
|
+
if (!(t instanceof Document)) {
|
|
674
|
+
const s = o.createElement("div");
|
|
675
|
+
return s.id = r, t.appendChild(s), s;
|
|
676
|
+
}
|
|
677
|
+
const a = o.createElement("div");
|
|
678
|
+
return a.id = r, o.body.appendChild(a), a;
|
|
679
|
+
}
|
|
680
|
+
function ie() {
|
|
877
681
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
878
682
|
}
|
|
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(`
|
|
683
|
+
function ye(e) {
|
|
684
|
+
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 ? ie() : "", r].filter((p) => p.trim().length > 0).join(`
|
|
889
685
|
`);
|
|
890
686
|
return `<!DOCTYPE html>
|
|
891
|
-
<html ${
|
|
687
|
+
<html ${a}>
|
|
892
688
|
<head>
|
|
893
689
|
<base target="_top" />
|
|
894
690
|
<meta charset="UTF-8" />
|
|
895
|
-
<title>${
|
|
691
|
+
<title>${ne(t)}</title>${l ? `
|
|
896
692
|
${l}` : ""}
|
|
897
693
|
</head>
|
|
898
|
-
<body ${
|
|
899
|
-
${
|
|
694
|
+
<body ${s}>
|
|
695
|
+
${o}
|
|
900
696
|
</body>
|
|
901
697
|
</html>
|
|
902
698
|
`;
|
|
903
699
|
}
|
|
904
|
-
function
|
|
905
|
-
return
|
|
700
|
+
function ne(e) {
|
|
701
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
906
702
|
}
|
|
907
703
|
export {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
704
|
+
Q as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
705
|
+
j as DEFAULT_IPC_CONFIG,
|
|
706
|
+
ae as DEFAULT_SIDEBAR_CONFIG,
|
|
707
|
+
U as DeferredPromise,
|
|
708
|
+
L as IPCCore,
|
|
709
|
+
v as MimeType,
|
|
710
|
+
le as PluginAdapter,
|
|
711
|
+
F as PluginIPCAdapter,
|
|
712
|
+
de as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
916
713
|
M as SIDEBAR_HOST_CONTAINER_ID,
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
714
|
+
fe as SIDEBAR_HOST_SHELL_CSS,
|
|
715
|
+
Z as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
716
|
+
q as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
717
|
+
ce as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
718
|
+
W as SidebarAdapter,
|
|
719
|
+
$ as SidebarIPCAdapter,
|
|
720
|
+
oe as TEXT_MIME_TYPES,
|
|
721
|
+
D as TextLookupError,
|
|
722
|
+
he as assertSidebarHostAdapter,
|
|
723
|
+
ye as buildSidebarHostHtmlDocument,
|
|
724
|
+
N as buildSidebarHostShellCss,
|
|
725
|
+
ie as buildSidebarPluginHostHeadInnerHtml,
|
|
726
|
+
me as createSidebarHost,
|
|
727
|
+
ve as ensureSidebarHostShell,
|
|
728
|
+
pe as getAuthConfigWithOverride,
|
|
729
|
+
ge as getSidebarBaseUrlWithOverride,
|
|
730
|
+
P as ipcErrorReconstructors,
|
|
731
|
+
se as isTextLookupError,
|
|
732
|
+
H as reconstructError,
|
|
733
|
+
K as setupSidebarLoadOverlay,
|
|
734
|
+
ue as sidebarPostMessageTargetOrigin
|
|
937
735
|
};
|