@markupai/sidebar-adapter 2.0.0 → 2.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 +45 -2
- package/asyncapi.json +46 -6
- package/dist/adapters/index.d.ts +2 -2
- package/dist/adapters/pluginAdapter.d.ts +5 -2
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/adapters/sidebarAdapter.d.ts +10 -1
- package/dist/adapters/sidebarAdapter.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/ipc/call-signatures.d.ts +6 -3
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/index.d.ts +8 -8
- package/dist/ipc/ipc-core.d.ts +2 -2
- package/dist/ipc/plugin-ipc-adapter.d.ts +6 -3
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-build-info.d.ts +22 -0
- package/dist/ipc/sidebar-build-info.d.ts.map +1 -0
- package/dist/ipc/sidebar-ipc-adapter.d.ts +10 -2
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/load-overlay/sidebarLoadOverlay.d.ts +11 -0
- package/dist/load-overlay/sidebarLoadOverlay.d.ts.map +1 -1
- package/dist/main.js +161 -129
- package/dist/main.umd.cjs +6 -6
- package/dist/types/common.d.ts +27 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +15 -3
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/dist/version.d.ts +10 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ce = /* @__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
|
+
})({}), de = [
|
|
4
4
|
"text/plain",
|
|
5
5
|
"text/markdown",
|
|
6
6
|
"text/html",
|
|
7
7
|
"application/dita+xml"
|
|
8
|
-
],
|
|
8
|
+
], ge = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
@@ -13,7 +13,7 @@ var oe = /* @__PURE__ */ (function(e) {
|
|
|
13
13
|
supportCheckSelection: !0,
|
|
14
14
|
multiAgent: !1,
|
|
15
15
|
multiDocument: !1
|
|
16
|
-
},
|
|
16
|
+
}, pe = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), ue = (e) => {
|
|
17
17
|
if (typeof e != "object" || e === null) return !1;
|
|
18
18
|
const t = e;
|
|
19
19
|
return typeof t.id != "string" || t.id.length === 0 || typeof t.label != "string" ? !1 : t.type === "boolean" ? typeof t.default == "boolean" : t.type === "enum" ? typeof t.default != "string" || !Array.isArray(t.options) || t.options.length === 0 ? !1 : t.options.every((n) => {
|
|
@@ -21,33 +21,33 @@ var oe = /* @__PURE__ */ (function(e) {
|
|
|
21
21
|
const r = n;
|
|
22
22
|
return typeof r.value == "string" && typeof r.label == "string";
|
|
23
23
|
}) : !1;
|
|
24
|
-
},
|
|
24
|
+
}, he = "2.1.0", T = class D extends Error {
|
|
25
25
|
name = "TextLookupError";
|
|
26
26
|
constructor(t) {
|
|
27
|
-
super(t), Object.setPrototypeOf(this,
|
|
27
|
+
super(t), Object.setPrototypeOf(this, D.prototype);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
function
|
|
31
|
-
return e instanceof
|
|
30
|
+
function fe(e) {
|
|
31
|
+
return e instanceof T;
|
|
32
32
|
}
|
|
33
|
-
var
|
|
34
|
-
function
|
|
35
|
-
const t = e.message ?? "", n = e.name, r = typeof n == "string" && n in
|
|
33
|
+
var E = { TextLookupError: (e) => new T(e) };
|
|
34
|
+
function H(e) {
|
|
35
|
+
const t = e.message ?? "", n = e.name, r = typeof n == "string" && n in E ? E[n] : void 0;
|
|
36
36
|
return r ? r(t, e) : Object.assign(new Error(t), n ? { name: n } : {});
|
|
37
37
|
}
|
|
38
|
-
var x = ":",
|
|
39
|
-
function
|
|
38
|
+
var x = ":", _ = /^[a-z][a-z0-9-]*$/;
|
|
39
|
+
function me(e) {
|
|
40
40
|
const t = e.indexOf(x);
|
|
41
|
-
return t <= 0 || t === e.length - 1 ? !1 :
|
|
41
|
+
return t <= 0 || t === e.length - 1 ? !1 : _.test(e.slice(0, t));
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function ye(e, t) {
|
|
44
44
|
const n = e.trim().toLowerCase(), r = t.trim();
|
|
45
|
-
if (!
|
|
45
|
+
if (!_.test(n)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
|
|
46
46
|
if (r.length === 0) throw new Error("Invalid document reference: the document id is empty.");
|
|
47
47
|
const i = `${n}${x}`;
|
|
48
48
|
return r.startsWith(i) ? r : `${i}${r}`;
|
|
49
49
|
}
|
|
50
|
-
var
|
|
50
|
+
var $ = class extends Promise {
|
|
51
51
|
static get [Symbol.species]() {
|
|
52
52
|
return Promise;
|
|
53
53
|
}
|
|
@@ -60,15 +60,15 @@ var H = class extends Promise {
|
|
|
60
60
|
t = r, n = i, e(r, i);
|
|
61
61
|
}), this.resolve = t, this.reject = n;
|
|
62
62
|
}
|
|
63
|
-
},
|
|
64
|
-
function
|
|
63
|
+
}, j = { timeout: 1e4 };
|
|
64
|
+
function F(e) {
|
|
65
65
|
const t = JSON.stringify(e, Object.getOwnPropertyNames(e)), n = JSON.parse(t);
|
|
66
66
|
return n.message === void 0 || n.message === "" ? JSON.stringify({
|
|
67
67
|
message: e instanceof Error ? e.message : String(e),
|
|
68
68
|
name: e instanceof Error ? e.name : void 0
|
|
69
69
|
}) : t;
|
|
70
70
|
}
|
|
71
|
-
var
|
|
71
|
+
var M = class {
|
|
72
72
|
promisesByID = {};
|
|
73
73
|
receiversByName = {};
|
|
74
74
|
currentID = 0;
|
|
@@ -76,7 +76,7 @@ var L = class {
|
|
|
76
76
|
postMessage;
|
|
77
77
|
constructor(e, t) {
|
|
78
78
|
this.postMessage = e, this.config = {
|
|
79
|
-
|
|
79
|
+
...j,
|
|
80
80
|
...t
|
|
81
81
|
};
|
|
82
82
|
}
|
|
@@ -90,7 +90,7 @@ var L = class {
|
|
|
90
90
|
return this.callWithOptions(e, {}, ...t);
|
|
91
91
|
}
|
|
92
92
|
callWithOptions(e, t, ...n) {
|
|
93
|
-
const r = this.currentID++, i = new
|
|
93
|
+
const r = this.currentID++, i = new $(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
94
94
|
if (r in this.promisesByID) {
|
|
95
95
|
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);
|
|
96
96
|
i.reject(l), Reflect.deleteProperty(this.promisesByID, r);
|
|
@@ -158,7 +158,7 @@ var L = class {
|
|
|
158
158
|
type: "error",
|
|
159
159
|
id: t,
|
|
160
160
|
name: n,
|
|
161
|
-
errorJSON:
|
|
161
|
+
errorJSON: F(a)
|
|
162
162
|
};
|
|
163
163
|
this.postMessage(o);
|
|
164
164
|
}
|
|
@@ -176,7 +176,7 @@ var L = class {
|
|
|
176
176
|
const { promise: r, timeoutId: i } = this.promisesByID[t];
|
|
177
177
|
clearTimeout(i);
|
|
178
178
|
try {
|
|
179
|
-
const a = JSON.parse(n), o =
|
|
179
|
+
const a = JSON.parse(n), o = H(a);
|
|
180
180
|
r.reject(o);
|
|
181
181
|
} catch {
|
|
182
182
|
r.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
@@ -189,12 +189,12 @@ var L = class {
|
|
|
189
189
|
clearTimeout(t), e.reject(/* @__PURE__ */ new Error("IPC destroyed"));
|
|
190
190
|
this.promisesByID = {}, this.receiversByName = {};
|
|
191
191
|
}
|
|
192
|
-
},
|
|
192
|
+
}, z = class {
|
|
193
193
|
ipc;
|
|
194
194
|
sidebar;
|
|
195
195
|
targetOrigin;
|
|
196
196
|
constructor(e, t, n = "*") {
|
|
197
|
-
this.sidebar = e || {}, this.targetOrigin = n, this.ipc = new
|
|
197
|
+
this.sidebar = e || {}, this.targetOrigin = n, this.ipc = new M((r) => {
|
|
198
198
|
window.parent.postMessage(r, this.targetOrigin);
|
|
199
199
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
200
200
|
}
|
|
@@ -250,8 +250,11 @@ var L = class {
|
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
async getInitConfig() {
|
|
254
|
-
return await this.ipc.call("getInitConfig"
|
|
253
|
+
async getInitConfig(e) {
|
|
254
|
+
return e ? await this.ipc.call("getInitConfig", {
|
|
255
|
+
...e,
|
|
256
|
+
adapterVersion: e.adapterVersion ?? "2.1.0"
|
|
257
|
+
}) : await this.ipc.call("getInitConfig");
|
|
255
258
|
}
|
|
256
259
|
async getContent(e) {
|
|
257
260
|
return this.ipc.callWithOptions("getContent", e ?? {});
|
|
@@ -308,16 +311,16 @@ var L = class {
|
|
|
308
311
|
destroy() {
|
|
309
312
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
310
313
|
}
|
|
311
|
-
},
|
|
314
|
+
}, Ie = class {
|
|
312
315
|
ipcAdapter;
|
|
313
316
|
constructor(e, t, n) {
|
|
314
|
-
this.ipcAdapter = new
|
|
317
|
+
this.ipcAdapter = new z(e, t, n);
|
|
315
318
|
}
|
|
316
319
|
destroy() {
|
|
317
320
|
this.ipcAdapter.destroy();
|
|
318
321
|
}
|
|
319
|
-
async getInitConfig() {
|
|
320
|
-
return await this.ipcAdapter.getInitConfig();
|
|
322
|
+
async getInitConfig(e) {
|
|
323
|
+
return await this.ipcAdapter.getInitConfig(e);
|
|
321
324
|
}
|
|
322
325
|
async getContent(e) {
|
|
323
326
|
return await this.ipcAdapter.getContent(e);
|
|
@@ -364,14 +367,33 @@ var L = class {
|
|
|
364
367
|
getTargetOrigin() {
|
|
365
368
|
return this.ipcAdapter.getTargetOrigin();
|
|
366
369
|
}
|
|
367
|
-
}
|
|
370
|
+
};
|
|
371
|
+
var V = /* @__PURE__ */ new Set(["auto", "prompt"]), I = (e, t) => {
|
|
372
|
+
const n = e[t];
|
|
373
|
+
if (!(typeof n != "string" || n.length === 0))
|
|
374
|
+
return n.slice(0, 64);
|
|
375
|
+
};
|
|
376
|
+
function W(e) {
|
|
377
|
+
if (typeof e != "object" || e === null || Array.isArray(e)) return null;
|
|
378
|
+
const t = e, n = I(t, "version"), r = I(t, "commitHash");
|
|
379
|
+
if (n === void 0 || r === void 0) return null;
|
|
380
|
+
const i = {
|
|
381
|
+
version: n,
|
|
382
|
+
commitHash: r
|
|
383
|
+
};
|
|
384
|
+
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled), V.has(t.pwaUpdateMode) && (i.pwaUpdateMode = t.pwaUpdateMode);
|
|
385
|
+
const a = I(t, "adapterVersion");
|
|
386
|
+
return a !== void 0 && (i.adapterVersion = a), i;
|
|
387
|
+
}
|
|
388
|
+
var G = class {
|
|
368
389
|
ipc;
|
|
369
390
|
plugin;
|
|
370
391
|
iframe;
|
|
371
392
|
window;
|
|
372
393
|
targetOrigin;
|
|
394
|
+
latestSidebarBuildInfo = null;
|
|
373
395
|
constructor(e, t, n, r, i = "*") {
|
|
374
|
-
this.plugin = e, this.iframe = t, this.window = n ?? window, this.targetOrigin = i, this.ipc = new
|
|
396
|
+
this.plugin = e, this.iframe = t, this.window = n ?? window, this.targetOrigin = i, this.ipc = new M((a) => {
|
|
375
397
|
this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
|
|
376
398
|
}, r), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
377
399
|
}
|
|
@@ -380,7 +402,10 @@ var L = class {
|
|
|
380
402
|
e.origin !== t && (n !== "*" && e.origin !== n || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
381
403
|
};
|
|
382
404
|
registerReceivers() {
|
|
383
|
-
if (this.ipc.receive("getInitConfig", async (
|
|
405
|
+
if (this.ipc.receive("getInitConfig", async (e) => {
|
|
406
|
+
const t = W(e);
|
|
407
|
+
return this.latestSidebarBuildInfo = t, await this.plugin.getInitConfig(t ?? void 0);
|
|
408
|
+
}), 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, n) => {
|
|
384
409
|
await this.plugin.replaceContent(e, t, typeof n == "string" ? n : null);
|
|
385
410
|
}), this.ipc.receive("selectContent", async (e, t) => {
|
|
386
411
|
await this.plugin.selectContent(e, typeof t == "string" ? t : null);
|
|
@@ -451,16 +476,19 @@ var L = class {
|
|
|
451
476
|
async notifyActiveDocumentChanged(e) {
|
|
452
477
|
await this.ipc.call("onActiveDocumentChanged", e);
|
|
453
478
|
}
|
|
479
|
+
getSidebarBuildInfo() {
|
|
480
|
+
return this.latestSidebarBuildInfo;
|
|
481
|
+
}
|
|
454
482
|
configure(e) {
|
|
455
483
|
this.ipc.configure(e);
|
|
456
484
|
}
|
|
457
485
|
destroy() {
|
|
458
486
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
459
487
|
}
|
|
460
|
-
},
|
|
488
|
+
}, J = class {
|
|
461
489
|
ipcAdapter;
|
|
462
490
|
constructor(e, t, n) {
|
|
463
|
-
this.ipcAdapter = new
|
|
491
|
+
this.ipcAdapter = new G(e, t, n?.win, n?.config, n?.targetOrigin);
|
|
464
492
|
}
|
|
465
493
|
destroy() {
|
|
466
494
|
this.ipcAdapter.destroy();
|
|
@@ -489,10 +517,13 @@ var L = class {
|
|
|
489
517
|
async notifyActiveDocumentChanged(e) {
|
|
490
518
|
await this.ipcAdapter.notifyActiveDocumentChanged(e);
|
|
491
519
|
}
|
|
520
|
+
getSidebarBuildInfo() {
|
|
521
|
+
return this.ipcAdapter.getSidebarBuildInfo();
|
|
522
|
+
}
|
|
492
523
|
configure(e) {
|
|
493
524
|
this.ipcAdapter.configure(e);
|
|
494
525
|
}
|
|
495
|
-
},
|
|
526
|
+
}, Y = `
|
|
496
527
|
<div class="sidebar-load-overlay-card">
|
|
497
528
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
498
529
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -513,16 +544,16 @@ var L = class {
|
|
|
513
544
|
<span>Retry</span>
|
|
514
545
|
</button>
|
|
515
546
|
</div>
|
|
516
|
-
`,
|
|
547
|
+
`, X = () => {
|
|
517
548
|
const e = document.createElement("div");
|
|
518
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
549
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = Y;
|
|
519
550
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
520
551
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
521
552
|
return {
|
|
522
553
|
overlay: e,
|
|
523
554
|
button: t
|
|
524
555
|
};
|
|
525
|
-
},
|
|
556
|
+
}, R = "markupai-sidebar-load-overlay-styles", K = `
|
|
526
557
|
:root {
|
|
527
558
|
--background: #f5f5f4;
|
|
528
559
|
--foreground: #333332;
|
|
@@ -614,21 +645,21 @@ var L = class {
|
|
|
614
645
|
box-shadow: 0 0 0 2px
|
|
615
646
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
616
647
|
}
|
|
617
|
-
`,
|
|
648
|
+
`, q = (e) => {
|
|
618
649
|
const t = e ?? document;
|
|
619
|
-
if (t.getElementById(
|
|
650
|
+
if (t.getElementById(R)) return;
|
|
620
651
|
const n = t.createElement("style");
|
|
621
|
-
n.id =
|
|
622
|
-
},
|
|
623
|
-
|
|
624
|
-
const { sidebarUrl: r, targetOrigin: i, timeoutMs: a =
|
|
652
|
+
n.id = R, n.textContent = K, t.head.appendChild(n);
|
|
653
|
+
}, Z = 8e3, Q = 12e3, ee = (e, t, n = {}) => {
|
|
654
|
+
q(e.ownerDocument);
|
|
655
|
+
const { sidebarUrl: r, targetOrigin: i, timeoutMs: a = Z, retryIntervalMs: o = Q, messageListenWindow: s } = n, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, B = () => {
|
|
625
656
|
if (i) return i;
|
|
626
657
|
try {
|
|
627
658
|
return new URL(p()).origin;
|
|
628
659
|
} catch {
|
|
629
660
|
return "*";
|
|
630
661
|
}
|
|
631
|
-
}, { overlay: y, button:
|
|
662
|
+
}, { overlay: y, button: v } = X();
|
|
632
663
|
e.appendChild(y);
|
|
633
664
|
let u = !1, h, d;
|
|
634
665
|
const g = (c) => {
|
|
@@ -637,45 +668,45 @@ var L = class {
|
|
|
637
668
|
g(!1);
|
|
638
669
|
const f = () => {
|
|
639
670
|
h && (globalThis.clearTimeout(h), h = void 0);
|
|
640
|
-
},
|
|
671
|
+
}, A = () => {
|
|
641
672
|
f(), h = globalThis.setTimeout(() => {
|
|
642
673
|
u || g(!0);
|
|
643
674
|
}, a);
|
|
644
|
-
},
|
|
675
|
+
}, C = (c) => {
|
|
645
676
|
const m = c?.preserveOverlay ?? !0;
|
|
646
|
-
u = !1, m || g(!1), t.src = p(),
|
|
647
|
-
},
|
|
677
|
+
u = !1, m || g(!1), t.src = p(), A();
|
|
678
|
+
}, U = () => {
|
|
648
679
|
d || o <= 0 || (d = globalThis.setInterval(() => {
|
|
649
|
-
u ||
|
|
680
|
+
u || C({ preserveOverlay: !0 });
|
|
650
681
|
}, o));
|
|
651
|
-
},
|
|
682
|
+
}, b = () => {
|
|
652
683
|
d && (globalThis.clearInterval(d), d = void 0);
|
|
653
|
-
},
|
|
684
|
+
}, S = (c) => {
|
|
654
685
|
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
655
|
-
const m =
|
|
656
|
-
m !== "*" && c.origin !== m || (u = !0, f(),
|
|
657
|
-
}, S = () => {
|
|
658
|
-
f(), g(!0);
|
|
686
|
+
const m = B();
|
|
687
|
+
m !== "*" && c.origin !== m || (u = !0, f(), b(), g(!1));
|
|
659
688
|
}, w = () => {
|
|
660
|
-
|
|
689
|
+
f(), g(!0);
|
|
690
|
+
}, P = () => {
|
|
691
|
+
C();
|
|
661
692
|
};
|
|
662
|
-
return
|
|
663
|
-
f(),
|
|
693
|
+
return v.addEventListener("click", P), t.addEventListener("error", w), l.addEventListener("message", S), A(), U(), () => {
|
|
694
|
+
f(), b(), t.removeEventListener("error", w), l.removeEventListener("message", S), v.removeEventListener("click", P), y.remove();
|
|
664
695
|
};
|
|
665
|
-
},
|
|
666
|
-
function
|
|
696
|
+
}, te = "Markup AI Sidebar", ne = "clipboard-read; clipboard-write", ve = "markupai.sidebarNextGen.overrideUrl", Ae = "https://sidebar.markup.ai/";
|
|
697
|
+
function Ce(e) {
|
|
667
698
|
try {
|
|
668
699
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
669
700
|
} catch {
|
|
670
701
|
return e;
|
|
671
702
|
}
|
|
672
703
|
}
|
|
673
|
-
var
|
|
674
|
-
function
|
|
704
|
+
var re = "markupai.sidebarNextGen.authOverride";
|
|
705
|
+
function be(e, t) {
|
|
675
706
|
if (!t) return e;
|
|
676
707
|
try {
|
|
677
708
|
if (!("localStorage" in globalThis)) return e;
|
|
678
|
-
const n = globalThis.localStorage.getItem(
|
|
709
|
+
const n = globalThis.localStorage.getItem(re)?.trim();
|
|
679
710
|
if (!n) return e;
|
|
680
711
|
const r = JSON.parse(n);
|
|
681
712
|
return r !== null && typeof r == "object" && "type" in r && (r.type === "mediation" || r.type === "popup") ? r : e;
|
|
@@ -683,17 +714,17 @@ function Ie(e, t) {
|
|
|
683
714
|
return e;
|
|
684
715
|
}
|
|
685
716
|
}
|
|
686
|
-
function
|
|
717
|
+
function Se(e, t) {
|
|
687
718
|
try {
|
|
688
719
|
return new URL(e).origin;
|
|
689
720
|
} catch (n) {
|
|
690
721
|
return t?.onInvalidUrl?.(e, n), "*";
|
|
691
722
|
}
|
|
692
723
|
}
|
|
693
|
-
function
|
|
724
|
+
function we(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
694
725
|
if (e.adapter === null) throw new Error(t);
|
|
695
726
|
}
|
|
696
|
-
function
|
|
727
|
+
function ie(e) {
|
|
697
728
|
const { iframe: t, iframeMount: n } = e;
|
|
698
729
|
if (t !== void 0 && n !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
699
730
|
if (t !== void 0) return {
|
|
@@ -701,18 +732,18 @@ function te(e) {
|
|
|
701
732
|
removeMountedIframe: null
|
|
702
733
|
};
|
|
703
734
|
if (n === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
704
|
-
const { container: r, src: i, allow: a =
|
|
705
|
-
return o.title =
|
|
735
|
+
const { container: r, src: i, allow: a = ne } = n, o = document.createElement("iframe");
|
|
736
|
+
return o.title = te, o.src = i, a && o.setAttribute("allow", a), r.appendChild(o), {
|
|
706
737
|
iframe: o,
|
|
707
738
|
removeMountedIframe: () => {
|
|
708
739
|
o.remove();
|
|
709
740
|
}
|
|
710
741
|
};
|
|
711
742
|
}
|
|
712
|
-
function
|
|
713
|
-
const { plugin: t, loadOverlayContainer: n, loadOverlayOptions: r, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } =
|
|
743
|
+
function Pe(e) {
|
|
744
|
+
const { plugin: t, loadOverlayContainer: n, loadOverlayOptions: r, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } = ie(e), s = n !== void 0 ? ee(n, a, r ?? {}) : null;
|
|
714
745
|
if (t !== void 0) {
|
|
715
|
-
const l = new
|
|
746
|
+
const l = new J(t, a, i);
|
|
716
747
|
return {
|
|
717
748
|
iframe: a,
|
|
718
749
|
adapter: l,
|
|
@@ -729,14 +760,14 @@ function Ce(e) {
|
|
|
729
760
|
}
|
|
730
761
|
};
|
|
731
762
|
}
|
|
732
|
-
var
|
|
733
|
-
function
|
|
763
|
+
var L = "sidebarContainer", O = "markupai-sidebar-host-shell-styles";
|
|
764
|
+
function k(e) {
|
|
734
765
|
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
735
766
|
if (!/^[a-zA-Z_][\w-]*$/.test(e)) throw new Error(String.raw`sidebar host shell: containerId must match /^[a-zA-Z_][\w-]*$/ when CSS.escape is unavailable (got ${JSON.stringify(e)})`);
|
|
736
767
|
return e;
|
|
737
768
|
}
|
|
738
|
-
function
|
|
739
|
-
const t =
|
|
769
|
+
function N(e = L) {
|
|
770
|
+
const t = k(e);
|
|
740
771
|
return `
|
|
741
772
|
html {
|
|
742
773
|
height: 100%;
|
|
@@ -761,21 +792,21 @@ body {
|
|
|
761
792
|
}
|
|
762
793
|
`.trim();
|
|
763
794
|
}
|
|
764
|
-
var
|
|
765
|
-
function
|
|
795
|
+
var Ee = N();
|
|
796
|
+
function ae(e) {
|
|
766
797
|
return e instanceof Document ? e : e.ownerDocument;
|
|
767
798
|
}
|
|
768
|
-
function
|
|
769
|
-
if (!t || e.getElementById(
|
|
799
|
+
function oe(e, t, n) {
|
|
800
|
+
if (!t || e.getElementById(O)) return;
|
|
770
801
|
const r = e.createElement("style");
|
|
771
|
-
r.id =
|
|
802
|
+
r.id = O, r.textContent = N(n), e.head.appendChild(r);
|
|
772
803
|
}
|
|
773
|
-
function
|
|
774
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId: n =
|
|
804
|
+
function Re(e) {
|
|
805
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: n = L, includeDefaultStyles: r = !0 } = e ?? {};
|
|
775
806
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
776
|
-
const i =
|
|
777
|
-
|
|
778
|
-
const a = t instanceof Document ? i.getElementById(n) : t.querySelector(`#${
|
|
807
|
+
const i = ae(t);
|
|
808
|
+
oe(i, r, n);
|
|
809
|
+
const a = t instanceof Document ? i.getElementById(n) : t.querySelector(`#${k(n)}`);
|
|
779
810
|
if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
|
|
780
811
|
if (!(t instanceof Document)) {
|
|
781
812
|
const s = i.createElement("div");
|
|
@@ -784,18 +815,18 @@ function Se(e) {
|
|
|
784
815
|
const o = i.createElement("div");
|
|
785
816
|
return o.id = n, i.body.appendChild(o), o;
|
|
786
817
|
}
|
|
787
|
-
function
|
|
818
|
+
function se() {
|
|
788
819
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
789
820
|
}
|
|
790
|
-
function
|
|
791
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml: n = "", includePluginHostHead: r = !1, bodyScriptsHtml: i, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [r ?
|
|
821
|
+
function Oe(e) {
|
|
822
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: n = "", includePluginHostHead: r = !1, bodyScriptsHtml: i, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [r ? se() : "", n].filter((p) => p.trim().length > 0).join(`
|
|
792
823
|
`);
|
|
793
824
|
return `<!DOCTYPE html>
|
|
794
825
|
<html ${o}>
|
|
795
826
|
<head>
|
|
796
827
|
<base target="_top" />
|
|
797
828
|
<meta charset="UTF-8" />
|
|
798
|
-
<title>${
|
|
829
|
+
<title>${le(t)}</title>${l ? `
|
|
799
830
|
${l}` : ""}
|
|
800
831
|
</head>
|
|
801
832
|
<body ${s}>
|
|
@@ -804,43 +835,44 @@ ${l}` : ""}
|
|
|
804
835
|
</html>
|
|
805
836
|
`;
|
|
806
837
|
}
|
|
807
|
-
function
|
|
838
|
+
function le(e) {
|
|
808
839
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
809
840
|
}
|
|
810
841
|
export {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
842
|
+
he as ADAPTER_VERSION,
|
|
843
|
+
re as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
844
|
+
j as DEFAULT_IPC_CONFIG,
|
|
845
|
+
ge as DEFAULT_SIDEBAR_CONFIG,
|
|
846
|
+
$ as DeferredPromise,
|
|
847
|
+
M as IPCCore,
|
|
848
|
+
ce as MimeType,
|
|
849
|
+
Ie as PluginAdapter,
|
|
850
|
+
z as PluginIPCAdapter,
|
|
851
|
+
Ae as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
852
|
+
L as SIDEBAR_HOST_CONTAINER_ID,
|
|
853
|
+
Ee as SIDEBAR_HOST_SHELL_CSS,
|
|
854
|
+
ne as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
855
|
+
te as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
856
|
+
ve as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
857
|
+
J as SidebarAdapter,
|
|
858
|
+
G as SidebarIPCAdapter,
|
|
859
|
+
de as TEXT_MIME_TYPES,
|
|
860
|
+
T as TextLookupError,
|
|
861
|
+
we as assertSidebarHostAdapter,
|
|
862
|
+
ye as buildDocumentReference,
|
|
863
|
+
Oe as buildSidebarHostHtmlDocument,
|
|
864
|
+
N as buildSidebarHostShellCss,
|
|
865
|
+
se as buildSidebarPluginHostHeadInnerHtml,
|
|
866
|
+
Pe as createSidebarHost,
|
|
867
|
+
Re as ensureSidebarHostShell,
|
|
868
|
+
be as getAuthConfigWithOverride,
|
|
869
|
+
Ce as getSidebarBaseUrlWithOverride,
|
|
870
|
+
E as ipcErrorReconstructors,
|
|
871
|
+
me as isDocumentReference,
|
|
872
|
+
ue as isIntegrationSettingField,
|
|
873
|
+
pe as isIntegrationSettingsSchema,
|
|
874
|
+
fe as isTextLookupError,
|
|
875
|
+
H as reconstructError,
|
|
876
|
+
ee as setupSidebarLoadOverlay,
|
|
877
|
+
Se as sidebarPostMessageTargetOrigin
|
|
846
878
|
};
|