@markupai/sidebar-adapter 1.3.1 → 1.3.3
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 +50 -16
- package/asyncapi.json +1912 -0
- package/dist/adapters/pluginAdapter.d.ts +7 -0
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/ipc/call-signatures.d.ts +5 -0
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/deferred-promise.d.ts +14 -29
- package/dist/ipc/deferred-promise.d.ts.map +1 -1
- package/dist/ipc/ipc-core.d.ts.map +1 -1
- package/dist/ipc/plugin-ipc-adapter.d.ts +6 -0
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/main.js +164 -155
- package/dist/main.umd.cjs +6 -6
- package/dist/types/common.d.ts +60 -7
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/integrationSettings.d.ts +9 -4
- package/dist/types/integrationSettings.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +31 -4
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/package.json +14 -6
package/dist/main.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ne = /* @__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
|
})({}), ae = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
"text/plain",
|
|
5
|
+
"text/markdown",
|
|
6
|
+
"text/html",
|
|
7
|
+
"application/dita+xml"
|
|
8
8
|
], oe = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
@@ -21,41 +21,42 @@ var y = /* @__PURE__ */ (function(e) {
|
|
|
21
21
|
const r = i;
|
|
22
22
|
return typeof r.value == "string" && typeof r.label == "string";
|
|
23
23
|
}) : !1;
|
|
24
|
-
},
|
|
24
|
+
}, T = class O extends Error {
|
|
25
25
|
name = "TextLookupError";
|
|
26
26
|
constructor(t) {
|
|
27
|
-
super(t), Object.setPrototypeOf(this,
|
|
27
|
+
super(t), Object.setPrototypeOf(this, O.prototype);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
function ce(e) {
|
|
31
|
-
return e instanceof
|
|
31
|
+
return e instanceof T;
|
|
32
32
|
}
|
|
33
|
-
var
|
|
34
|
-
function
|
|
35
|
-
const t = e.message ?? "", i = e.name, r = typeof i == "string" && i in
|
|
33
|
+
var P = { TextLookupError: (e) => new T(e) };
|
|
34
|
+
function N(e) {
|
|
35
|
+
const t = e.message ?? "", i = e.name, r = typeof i == "string" && i in P ? P[i] : void 0;
|
|
36
36
|
return r ? r(t, e) : Object.assign(new Error(t), i ? { name: i } : {});
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
resolve
|
|
43
|
-
reject
|
|
44
|
-
constructor() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}
|
|
38
|
+
var B = class extends Promise {
|
|
39
|
+
static get [Symbol.species]() {
|
|
40
|
+
return Promise;
|
|
41
|
+
}
|
|
42
|
+
resolve;
|
|
43
|
+
reject;
|
|
44
|
+
constructor(e = () => {
|
|
45
|
+
}) {
|
|
46
|
+
let t, i;
|
|
47
|
+
super((r, a) => {
|
|
48
|
+
t = r, i = a, e(r, a);
|
|
49
|
+
}), this.resolve = t, this.reject = i;
|
|
50
|
+
}
|
|
51
|
+
}, U = { timeout: 1e4 };
|
|
52
|
+
function H(e) {
|
|
53
|
+
const t = JSON.stringify(e, Object.getOwnPropertyNames(e)), i = JSON.parse(t);
|
|
54
|
+
return i.message === void 0 || i.message === "" ? JSON.stringify({
|
|
55
|
+
message: e instanceof Error ? e.message : String(e),
|
|
56
|
+
name: e instanceof Error ? e.name : void 0
|
|
57
|
+
}) : t;
|
|
58
|
+
}
|
|
59
|
+
var D = class {
|
|
59
60
|
promisesByID = {};
|
|
60
61
|
receiversByName = {};
|
|
61
62
|
currentID = 0;
|
|
@@ -63,7 +64,7 @@ var R = () => {
|
|
|
63
64
|
postMessage;
|
|
64
65
|
constructor(e, t) {
|
|
65
66
|
this.postMessage = e, this.config = {
|
|
66
|
-
...
|
|
67
|
+
...U,
|
|
67
68
|
...t
|
|
68
69
|
};
|
|
69
70
|
}
|
|
@@ -77,7 +78,7 @@ var R = () => {
|
|
|
77
78
|
return this.callWithOptions(e, {}, ...t);
|
|
78
79
|
}
|
|
79
80
|
callWithOptions(e, t, ...i) {
|
|
80
|
-
const r = this.currentID++, a = new
|
|
81
|
+
const r = this.currentID++, a = new B(), n = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
81
82
|
if (r in this.promisesByID) {
|
|
82
83
|
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(n)}ms`);
|
|
83
84
|
a.reject(l), Reflect.deleteProperty(this.promisesByID, r);
|
|
@@ -117,43 +118,37 @@ var R = () => {
|
|
|
117
118
|
}
|
|
118
119
|
async handleCall(e) {
|
|
119
120
|
const { id: t, name: i, data: r } = e;
|
|
120
|
-
if (i in this.receiversByName) {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
} else {
|
|
147
|
-
const a = /* @__PURE__ */ new Error(`No receiver registered for: ${i}`), n = {
|
|
121
|
+
if (!(i in this.receiversByName)) {
|
|
122
|
+
const n = /* @__PURE__ */ new Error(`No receiver registered for: ${i}`), o = JSON.stringify({
|
|
123
|
+
message: n.message,
|
|
124
|
+
name: n.name
|
|
125
|
+
});
|
|
126
|
+
this.postMessage({
|
|
127
|
+
type: "error",
|
|
128
|
+
id: t,
|
|
129
|
+
name: i,
|
|
130
|
+
errorJSON: o
|
|
131
|
+
});
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const a = this.receiversByName[i];
|
|
135
|
+
try {
|
|
136
|
+
if (!Array.isArray(r)) throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);
|
|
137
|
+
const n = await a(...r), o = {
|
|
138
|
+
type: "response",
|
|
139
|
+
id: t,
|
|
140
|
+
name: i,
|
|
141
|
+
data: n
|
|
142
|
+
};
|
|
143
|
+
this.postMessage(o);
|
|
144
|
+
} catch (n) {
|
|
145
|
+
const o = {
|
|
148
146
|
type: "error",
|
|
149
147
|
id: t,
|
|
150
148
|
name: i,
|
|
151
|
-
errorJSON:
|
|
152
|
-
message: a.message,
|
|
153
|
-
name: a.name
|
|
154
|
-
})
|
|
149
|
+
errorJSON: H(n)
|
|
155
150
|
};
|
|
156
|
-
this.postMessage(
|
|
151
|
+
this.postMessage(o);
|
|
157
152
|
}
|
|
158
153
|
}
|
|
159
154
|
handleResponse(e) {
|
|
@@ -169,7 +164,7 @@ var R = () => {
|
|
|
169
164
|
const { promise: r, timeoutId: a } = this.promisesByID[t];
|
|
170
165
|
clearTimeout(a);
|
|
171
166
|
try {
|
|
172
|
-
const n =
|
|
167
|
+
const n = N(JSON.parse(i));
|
|
173
168
|
r.reject(n);
|
|
174
169
|
} catch {
|
|
175
170
|
r.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
@@ -182,12 +177,12 @@ var R = () => {
|
|
|
182
177
|
clearTimeout(t), e.reject(/* @__PURE__ */ new Error("IPC destroyed"));
|
|
183
178
|
this.promisesByID = {}, this.receiversByName = {};
|
|
184
179
|
}
|
|
185
|
-
},
|
|
180
|
+
}, j = class {
|
|
186
181
|
ipc;
|
|
187
182
|
sidebar;
|
|
188
183
|
targetOrigin;
|
|
189
184
|
constructor(e, t, i = "*") {
|
|
190
|
-
this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new
|
|
185
|
+
this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new D((r) => {
|
|
191
186
|
window.parent.postMessage(r, this.targetOrigin);
|
|
192
187
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
193
188
|
}
|
|
@@ -273,6 +268,9 @@ var R = () => {
|
|
|
273
268
|
async openAuthUrl(e) {
|
|
274
269
|
await this.ipc.call("openAuthUrl", e);
|
|
275
270
|
}
|
|
271
|
+
async copyToClipboard(e) {
|
|
272
|
+
await this.ipc.call("copyToClipboard", e);
|
|
273
|
+
}
|
|
276
274
|
async onIntegrationSettingsChange(e, t) {
|
|
277
275
|
await this.ipc.call("onIntegrationSettingsChange", e, t);
|
|
278
276
|
}
|
|
@@ -295,10 +293,10 @@ var R = () => {
|
|
|
295
293
|
destroy() {
|
|
296
294
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
297
295
|
}
|
|
298
|
-
},
|
|
296
|
+
}, de = class {
|
|
299
297
|
ipcAdapter;
|
|
300
298
|
constructor(e, t, i) {
|
|
301
|
-
this.ipcAdapter = new
|
|
299
|
+
this.ipcAdapter = new j(e, t, i);
|
|
302
300
|
}
|
|
303
301
|
destroy() {
|
|
304
302
|
this.ipcAdapter.destroy();
|
|
@@ -339,6 +337,9 @@ var R = () => {
|
|
|
339
337
|
openAuthUrl(e) {
|
|
340
338
|
return this.ipcAdapter.openAuthUrl(e);
|
|
341
339
|
}
|
|
340
|
+
copyToClipboard(e) {
|
|
341
|
+
return this.ipcAdapter.copyToClipboard(e);
|
|
342
|
+
}
|
|
342
343
|
onIntegrationSettingsChange(e, t) {
|
|
343
344
|
return this.ipcAdapter.onIntegrationSettingsChange(e, t);
|
|
344
345
|
}
|
|
@@ -351,14 +352,14 @@ var R = () => {
|
|
|
351
352
|
getTargetOrigin() {
|
|
352
353
|
return this.ipcAdapter.getTargetOrigin();
|
|
353
354
|
}
|
|
354
|
-
},
|
|
355
|
+
}, F = class {
|
|
355
356
|
ipc;
|
|
356
357
|
plugin;
|
|
357
358
|
iframe;
|
|
358
359
|
window;
|
|
359
360
|
targetOrigin;
|
|
360
361
|
constructor(e, t, i, r, a = "*") {
|
|
361
|
-
this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin = a, this.ipc = new
|
|
362
|
+
this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin = a, this.ipc = new D((n) => {
|
|
362
363
|
this.iframe.contentWindow?.postMessage(n, this.targetOrigin);
|
|
363
364
|
}, r), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
364
365
|
}
|
|
@@ -372,8 +373,10 @@ var R = () => {
|
|
|
372
373
|
}), this.ipc.receive("selectContent", async (e) => {
|
|
373
374
|
await this.plugin.selectContent(e);
|
|
374
375
|
}), this.ipc.receive("showDialog", async (e, t, i, r) => {
|
|
376
|
+
if (!this.plugin.showDialog) throw new Error("SidebarIPCAdapter: host does not implement showDialog");
|
|
375
377
|
await this.plugin.showDialog(e, t, i, r);
|
|
376
378
|
}), this.ipc.receive("closeDialog", async () => {
|
|
379
|
+
if (!this.plugin.closeDialog) throw new Error("SidebarIPCAdapter: host does not implement closeDialog");
|
|
377
380
|
await this.plugin.closeDialog();
|
|
378
381
|
}), this.ipc.receive("replaceMultipleContents", async (e) => {
|
|
379
382
|
await this.plugin.replaceMultipleContents(e);
|
|
@@ -398,6 +401,12 @@ var R = () => {
|
|
|
398
401
|
await e(t);
|
|
399
402
|
});
|
|
400
403
|
}
|
|
404
|
+
if (this.plugin.copyToClipboard) {
|
|
405
|
+
const e = this.plugin.copyToClipboard;
|
|
406
|
+
this.ipc.receive("copyToClipboard", async (t) => {
|
|
407
|
+
await e(t);
|
|
408
|
+
});
|
|
409
|
+
}
|
|
401
410
|
if (this.plugin.onIntegrationSettingsChange) {
|
|
402
411
|
const e = this.plugin.onIntegrationSettingsChange;
|
|
403
412
|
this.ipc.receive("onIntegrationSettingsChange", async (t, i) => {
|
|
@@ -432,10 +441,10 @@ var R = () => {
|
|
|
432
441
|
destroy() {
|
|
433
442
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
434
443
|
}
|
|
435
|
-
},
|
|
444
|
+
}, $ = class {
|
|
436
445
|
ipcAdapter;
|
|
437
446
|
constructor(e, t, i) {
|
|
438
|
-
this.ipcAdapter = new
|
|
447
|
+
this.ipcAdapter = new F(e, t, i?.win, i?.config, i?.targetOrigin);
|
|
439
448
|
}
|
|
440
449
|
destroy() {
|
|
441
450
|
this.ipcAdapter.destroy();
|
|
@@ -464,7 +473,7 @@ var R = () => {
|
|
|
464
473
|
configure(e) {
|
|
465
474
|
this.ipcAdapter.configure(e);
|
|
466
475
|
}
|
|
467
|
-
},
|
|
476
|
+
}, W = `
|
|
468
477
|
<div class="sidebar-load-overlay-card">
|
|
469
478
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
470
479
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -487,14 +496,14 @@ var R = () => {
|
|
|
487
496
|
</div>
|
|
488
497
|
`, z = () => {
|
|
489
498
|
const e = document.createElement("div");
|
|
490
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
499
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = W;
|
|
491
500
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
492
501
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
493
502
|
return {
|
|
494
503
|
overlay: e,
|
|
495
504
|
button: t
|
|
496
505
|
};
|
|
497
|
-
},
|
|
506
|
+
}, E = "markupai-sidebar-load-overlay-styles", G = `
|
|
498
507
|
:root {
|
|
499
508
|
--background: #f5f5f4;
|
|
500
509
|
--foreground: #333332;
|
|
@@ -586,55 +595,55 @@ var R = () => {
|
|
|
586
595
|
box-shadow: 0 0 0 2px
|
|
587
596
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
588
597
|
}
|
|
589
|
-
`,
|
|
598
|
+
`, J = (e) => {
|
|
590
599
|
const t = e ?? document;
|
|
591
|
-
if (t.getElementById(
|
|
600
|
+
if (t.getElementById(E)) return;
|
|
592
601
|
const i = t.createElement("style");
|
|
593
|
-
i.id =
|
|
602
|
+
i.id = E, i.textContent = G, t.head.appendChild(i);
|
|
594
603
|
}, Y = 8e3, V = 12e3, K = (e, t, i = {}) => {
|
|
595
|
-
|
|
596
|
-
const { sidebarUrl: r, targetOrigin: a, timeoutMs: n = Y, retryIntervalMs: o = V, messageListenWindow: s } = i, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src,
|
|
604
|
+
J(e.ownerDocument);
|
|
605
|
+
const { sidebarUrl: r, targetOrigin: a, timeoutMs: n = Y, retryIntervalMs: o = V, messageListenWindow: s } = i, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, _ = () => {
|
|
597
606
|
if (a) return a;
|
|
598
607
|
try {
|
|
599
608
|
return new URL(p()).origin;
|
|
600
609
|
} catch {
|
|
601
610
|
return "*";
|
|
602
611
|
}
|
|
603
|
-
}, { overlay:
|
|
604
|
-
e.appendChild(
|
|
605
|
-
let u = !1, h,
|
|
606
|
-
const
|
|
607
|
-
|
|
612
|
+
}, { overlay: m, button: I } = z();
|
|
613
|
+
e.appendChild(m);
|
|
614
|
+
let u = !1, h, d;
|
|
615
|
+
const g = (c) => {
|
|
616
|
+
m.style.display = c ? "flex" : "none";
|
|
608
617
|
};
|
|
609
|
-
|
|
618
|
+
g(!1);
|
|
610
619
|
const f = () => {
|
|
611
620
|
h && (globalThis.clearTimeout(h), h = void 0);
|
|
612
|
-
},
|
|
621
|
+
}, v = () => {
|
|
613
622
|
f(), h = globalThis.setTimeout(() => {
|
|
614
|
-
u ||
|
|
623
|
+
u || g(!0);
|
|
615
624
|
}, n);
|
|
616
|
-
},
|
|
617
|
-
const
|
|
618
|
-
u = !1,
|
|
619
|
-
},
|
|
620
|
-
|
|
621
|
-
u ||
|
|
625
|
+
}, A = (c) => {
|
|
626
|
+
const y = c?.preserveOverlay ?? !0;
|
|
627
|
+
u = !1, y || g(!1), t.src = p(), v();
|
|
628
|
+
}, k = () => {
|
|
629
|
+
d || o <= 0 || (d = globalThis.setInterval(() => {
|
|
630
|
+
u || A({ preserveOverlay: !0 });
|
|
622
631
|
}, o));
|
|
623
|
-
},
|
|
624
|
-
|
|
625
|
-
},
|
|
632
|
+
}, C = () => {
|
|
633
|
+
d && (globalThis.clearInterval(d), d = void 0);
|
|
634
|
+
}, b = (c) => {
|
|
626
635
|
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
627
|
-
const
|
|
628
|
-
|
|
636
|
+
const y = _();
|
|
637
|
+
y !== "*" && c.origin !== y || (u = !0, f(), C(), g(!1));
|
|
629
638
|
}, w = () => {
|
|
630
|
-
f(),
|
|
631
|
-
},
|
|
632
|
-
|
|
639
|
+
f(), g(!0);
|
|
640
|
+
}, S = () => {
|
|
641
|
+
A();
|
|
633
642
|
};
|
|
634
|
-
return
|
|
635
|
-
f(),
|
|
643
|
+
return I.addEventListener("click", S), t.addEventListener("error", w), l.addEventListener("message", b), v(), k(), () => {
|
|
644
|
+
f(), C(), t.removeEventListener("error", w), l.removeEventListener("message", b), I.removeEventListener("click", S), m.remove();
|
|
636
645
|
};
|
|
637
|
-
},
|
|
646
|
+
}, X = "Markup AI Sidebar", q = "clipboard-read; clipboard-write", ge = "markupai.sidebarNextGen.overrideUrl", pe = "https://sidebar.markup.ai/";
|
|
638
647
|
function ue(e) {
|
|
639
648
|
try {
|
|
640
649
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
@@ -642,12 +651,12 @@ function ue(e) {
|
|
|
642
651
|
return e;
|
|
643
652
|
}
|
|
644
653
|
}
|
|
645
|
-
var
|
|
654
|
+
var Z = "markupai.sidebarNextGen.authOverride";
|
|
646
655
|
function he(e, t) {
|
|
647
656
|
if (!t) return e;
|
|
648
657
|
try {
|
|
649
658
|
if (!("localStorage" in globalThis)) return e;
|
|
650
|
-
const i = globalThis.localStorage.getItem(
|
|
659
|
+
const i = globalThis.localStorage.getItem(Z)?.trim();
|
|
651
660
|
if (!i) return e;
|
|
652
661
|
const r = JSON.parse(i);
|
|
653
662
|
return r !== null && typeof r == "object" && "type" in r && (r.type === "mediation" || r.type === "popup") ? r : e;
|
|
@@ -662,10 +671,10 @@ function fe(e, t) {
|
|
|
662
671
|
return t?.onInvalidUrl?.(e, i), "*";
|
|
663
672
|
}
|
|
664
673
|
}
|
|
665
|
-
function
|
|
674
|
+
function ye(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
666
675
|
if (e.adapter === null) throw new Error(t);
|
|
667
676
|
}
|
|
668
|
-
function
|
|
677
|
+
function Q(e) {
|
|
669
678
|
const { iframe: t, iframeMount: i } = e;
|
|
670
679
|
if (t !== void 0 && i !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
671
680
|
if (t !== void 0) return {
|
|
@@ -673,18 +682,18 @@ function ee(e) {
|
|
|
673
682
|
removeMountedIframe: null
|
|
674
683
|
};
|
|
675
684
|
if (i === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
676
|
-
const { container: r, src: a, allow: n =
|
|
677
|
-
return o.title =
|
|
685
|
+
const { container: r, src: a, allow: n = q } = i, o = document.createElement("iframe");
|
|
686
|
+
return o.title = X, o.src = a, n && o.setAttribute("allow", n), r.appendChild(o), {
|
|
678
687
|
iframe: o,
|
|
679
688
|
removeMountedIframe: () => {
|
|
680
689
|
o.remove();
|
|
681
690
|
}
|
|
682
691
|
};
|
|
683
692
|
}
|
|
684
|
-
function
|
|
685
|
-
const { plugin: t, loadOverlayContainer: i, loadOverlayOptions: r, adapterOptions: a } = e, { iframe: n, removeMountedIframe: o } =
|
|
693
|
+
function me(e) {
|
|
694
|
+
const { plugin: t, loadOverlayContainer: i, loadOverlayOptions: r, adapterOptions: a } = e, { iframe: n, removeMountedIframe: o } = Q(e), s = i !== void 0 ? K(i, n, r ?? {}) : null;
|
|
686
695
|
if (t !== void 0) {
|
|
687
|
-
const l = new
|
|
696
|
+
const l = new $(t, n, a);
|
|
688
697
|
return {
|
|
689
698
|
iframe: n,
|
|
690
699
|
adapter: l,
|
|
@@ -701,14 +710,14 @@ function ye(e) {
|
|
|
701
710
|
}
|
|
702
711
|
};
|
|
703
712
|
}
|
|
704
|
-
var
|
|
705
|
-
function
|
|
713
|
+
var x = "sidebarContainer", R = "markupai-sidebar-host-shell-styles";
|
|
714
|
+
function L(e) {
|
|
706
715
|
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
707
716
|
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)})`);
|
|
708
717
|
return e;
|
|
709
718
|
}
|
|
710
|
-
function
|
|
711
|
-
const t =
|
|
719
|
+
function M(e = x) {
|
|
720
|
+
const t = L(e);
|
|
712
721
|
return `
|
|
713
722
|
html {
|
|
714
723
|
height: 100%;
|
|
@@ -733,21 +742,21 @@ body {
|
|
|
733
742
|
}
|
|
734
743
|
`.trim();
|
|
735
744
|
}
|
|
736
|
-
var Ie =
|
|
737
|
-
function
|
|
745
|
+
var Ie = M();
|
|
746
|
+
function ee(e) {
|
|
738
747
|
return e instanceof Document ? e : e.ownerDocument;
|
|
739
748
|
}
|
|
740
|
-
function
|
|
741
|
-
if (!t || e.getElementById(
|
|
749
|
+
function te(e, t, i) {
|
|
750
|
+
if (!t || e.getElementById(R)) return;
|
|
742
751
|
const r = e.createElement("style");
|
|
743
|
-
r.id =
|
|
752
|
+
r.id = R, r.textContent = M(i), e.head.appendChild(r);
|
|
744
753
|
}
|
|
745
754
|
function ve(e) {
|
|
746
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId: i =
|
|
755
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: i = x, includeDefaultStyles: r = !0 } = e ?? {};
|
|
747
756
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
748
|
-
const a =
|
|
749
|
-
|
|
750
|
-
const n = t instanceof Document ? a.getElementById(i) : t.querySelector(`#${
|
|
757
|
+
const a = ee(t);
|
|
758
|
+
te(a, r, i);
|
|
759
|
+
const n = t instanceof Document ? a.getElementById(i) : t.querySelector(`#${L(i)}`);
|
|
751
760
|
if (n instanceof HTMLElement && (t instanceof Document || t.contains(n))) return n;
|
|
752
761
|
if (!(t instanceof Document)) {
|
|
753
762
|
const s = a.createElement("div");
|
|
@@ -756,18 +765,18 @@ function ve(e) {
|
|
|
756
765
|
const o = a.createElement("div");
|
|
757
766
|
return o.id = i, a.body.appendChild(o), o;
|
|
758
767
|
}
|
|
759
|
-
function
|
|
768
|
+
function ie() {
|
|
760
769
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
761
770
|
}
|
|
762
771
|
function Ae(e) {
|
|
763
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml: i = "", includePluginHostHead: r = !1, bodyScriptsHtml: a, htmlLang: n = "en", htmlAttrs: o = `lang="${n}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [r ?
|
|
772
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: i = "", includePluginHostHead: r = !1, bodyScriptsHtml: a, htmlLang: n = "en", htmlAttrs: o = `lang="${n}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [r ? ie() : "", i].filter((p) => p.trim().length > 0).join(`
|
|
764
773
|
`);
|
|
765
774
|
return `<!DOCTYPE html>
|
|
766
775
|
<html ${o}>
|
|
767
776
|
<head>
|
|
768
777
|
<base target="_top" />
|
|
769
778
|
<meta charset="UTF-8" />
|
|
770
|
-
<title>${
|
|
779
|
+
<title>${re(t)}</title>${l ? `
|
|
771
780
|
${l}` : ""}
|
|
772
781
|
</head>
|
|
773
782
|
<body ${s}>
|
|
@@ -776,41 +785,41 @@ ${l}` : ""}
|
|
|
776
785
|
</html>
|
|
777
786
|
`;
|
|
778
787
|
}
|
|
779
|
-
function
|
|
788
|
+
function re(e) {
|
|
780
789
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
781
790
|
}
|
|
782
791
|
export {
|
|
783
|
-
|
|
784
|
-
|
|
792
|
+
Z as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
793
|
+
U as DEFAULT_IPC_CONFIG,
|
|
785
794
|
oe as DEFAULT_SIDEBAR_CONFIG,
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
795
|
+
B as DeferredPromise,
|
|
796
|
+
D as IPCCore,
|
|
797
|
+
ne as MimeType,
|
|
798
|
+
de as PluginAdapter,
|
|
799
|
+
j as PluginIPCAdapter,
|
|
791
800
|
pe as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
792
|
-
|
|
801
|
+
x as SIDEBAR_HOST_CONTAINER_ID,
|
|
793
802
|
Ie as SIDEBAR_HOST_SHELL_CSS,
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
803
|
+
q as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
804
|
+
X as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
805
|
+
ge as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
806
|
+
$ as SidebarAdapter,
|
|
807
|
+
F as SidebarIPCAdapter,
|
|
799
808
|
ae as TEXT_MIME_TYPES,
|
|
800
|
-
|
|
801
|
-
|
|
809
|
+
T as TextLookupError,
|
|
810
|
+
ye as assertSidebarHostAdapter,
|
|
802
811
|
Ae as buildSidebarHostHtmlDocument,
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
812
|
+
M as buildSidebarHostShellCss,
|
|
813
|
+
ie as buildSidebarPluginHostHeadInnerHtml,
|
|
814
|
+
me as createSidebarHost,
|
|
806
815
|
ve as ensureSidebarHostShell,
|
|
807
816
|
he as getAuthConfigWithOverride,
|
|
808
817
|
ue as getSidebarBaseUrlWithOverride,
|
|
809
|
-
|
|
818
|
+
P as ipcErrorReconstructors,
|
|
810
819
|
le as isIntegrationSettingField,
|
|
811
820
|
se as isIntegrationSettingsSchema,
|
|
812
821
|
ce as isTextLookupError,
|
|
813
|
-
|
|
822
|
+
N as reconstructError,
|
|
814
823
|
K as setupSidebarLoadOverlay,
|
|
815
824
|
fe as sidebarPostMessageTargetOrigin
|
|
816
825
|
};
|