@markupai/sidebar-adapter 2.0.0 → 2.2.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 +65 -2
- package/asyncapi.json +108 -7
- package/dist/adapters/index.d.ts +2 -2
- package/dist/adapters/pluginAdapter.d.ts +14 -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 +9 -4
- 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/ipc-core.d.ts.map +1 -1
- package/dist/ipc/plugin-ipc-adapter.d.ts +14 -3
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-build-info.d.ts +32 -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 +179 -132
- package/dist/main.umd.cjs +6 -6
- package/dist/types/common.d.ts +43 -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 ge = /* @__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
|
+
})({}), pe = [
|
|
4
4
|
"text/plain",
|
|
5
5
|
"text/markdown",
|
|
6
6
|
"text/html",
|
|
7
7
|
"application/dita+xml"
|
|
8
|
-
],
|
|
8
|
+
], ue = {
|
|
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
|
+
}, he = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), fe = (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
|
-
}, O = class
|
|
24
|
+
}, U = "2.2.0", O = 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
|
|
30
|
+
function me(e) {
|
|
31
31
|
return e instanceof O;
|
|
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 O(e) };
|
|
34
|
+
function $(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 = ":", M = /^[a-z][a-z0-9-]*$/;
|
|
39
|
+
function ye(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 : M.test(e.slice(0, t));
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function Ie(e, t) {
|
|
44
44
|
const n = e.trim().toLowerCase(), r = t.trim();
|
|
45
|
-
if (!
|
|
45
|
+
if (!M.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 j = class extends Promise {
|
|
51
51
|
static get [Symbol.species]() {
|
|
52
52
|
return Promise;
|
|
53
53
|
}
|
|
@@ -60,15 +60,16 @@ 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
|
|
65
|
-
const t = JSON.stringify(e, Object.getOwnPropertyNames(e)), n =
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
}, V = { timeout: 1e4 };
|
|
64
|
+
function F(e) {
|
|
65
|
+
const t = typeof e == "object" && e !== null ? JSON.parse(JSON.stringify(e, Object.getOwnPropertyNames(e))) : {}, n = e instanceof Error ? e.message : String(e), r = typeof t.message == "string" && t.message !== "" ? t.message : n, i = e instanceof Error ? e.name : void 0, a = typeof t.name == "string" ? t.name : i;
|
|
66
|
+
return JSON.stringify({
|
|
67
|
+
...t,
|
|
68
|
+
message: r,
|
|
69
|
+
...a !== void 0 && { name: a }
|
|
70
|
+
});
|
|
70
71
|
}
|
|
71
|
-
var
|
|
72
|
+
var _ = class {
|
|
72
73
|
promisesByID = {};
|
|
73
74
|
receiversByName = {};
|
|
74
75
|
currentID = 0;
|
|
@@ -76,7 +77,7 @@ var L = class {
|
|
|
76
77
|
postMessage;
|
|
77
78
|
constructor(e, t) {
|
|
78
79
|
this.postMessage = e, this.config = {
|
|
79
|
-
|
|
80
|
+
...V,
|
|
80
81
|
...t
|
|
81
82
|
};
|
|
82
83
|
}
|
|
@@ -90,7 +91,7 @@ var L = class {
|
|
|
90
91
|
return this.callWithOptions(e, {}, ...t);
|
|
91
92
|
}
|
|
92
93
|
callWithOptions(e, t, ...n) {
|
|
93
|
-
const r = this.currentID++, i = new
|
|
94
|
+
const r = this.currentID++, i = new j(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
94
95
|
if (r in this.promisesByID) {
|
|
95
96
|
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);
|
|
96
97
|
i.reject(l), Reflect.deleteProperty(this.promisesByID, r);
|
|
@@ -158,7 +159,7 @@ var L = class {
|
|
|
158
159
|
type: "error",
|
|
159
160
|
id: t,
|
|
160
161
|
name: n,
|
|
161
|
-
errorJSON:
|
|
162
|
+
errorJSON: F(a)
|
|
162
163
|
};
|
|
163
164
|
this.postMessage(o);
|
|
164
165
|
}
|
|
@@ -176,7 +177,7 @@ var L = class {
|
|
|
176
177
|
const { promise: r, timeoutId: i } = this.promisesByID[t];
|
|
177
178
|
clearTimeout(i);
|
|
178
179
|
try {
|
|
179
|
-
const a = JSON.parse(n), o =
|
|
180
|
+
const a = JSON.parse(n), o = $(a);
|
|
180
181
|
r.reject(o);
|
|
181
182
|
} catch {
|
|
182
183
|
r.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
@@ -189,12 +190,34 @@ var L = class {
|
|
|
189
190
|
clearTimeout(t), e.reject(/* @__PURE__ */ new Error("IPC destroyed"));
|
|
190
191
|
this.promisesByID = {}, this.receiversByName = {};
|
|
191
192
|
}
|
|
192
|
-
}
|
|
193
|
+
};
|
|
194
|
+
var z = /* @__PURE__ */ new Set(["auto", "prompt"]), I = (e, t) => {
|
|
195
|
+
const n = e[t];
|
|
196
|
+
if (!(typeof n != "string" || n.length === 0))
|
|
197
|
+
return n.slice(0, 64);
|
|
198
|
+
};
|
|
199
|
+
function W(e) {
|
|
200
|
+
if (typeof e != "object" || e === null || Array.isArray(e)) return null;
|
|
201
|
+
const t = e, n = I(t, "version"), r = I(t, "commitHash");
|
|
202
|
+
if (n === void 0 || r === void 0) return null;
|
|
203
|
+
const i = {
|
|
204
|
+
version: n,
|
|
205
|
+
commitHash: r
|
|
206
|
+
};
|
|
207
|
+
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled), z.has(t.pwaUpdateMode) && (i.pwaUpdateMode = t.pwaUpdateMode);
|
|
208
|
+
const a = I(t, "adapterVersion");
|
|
209
|
+
return a !== void 0 && (i.adapterVersion = a), i;
|
|
210
|
+
}
|
|
211
|
+
function G(e) {
|
|
212
|
+
return typeof e != "string" || e.length === 0 ? null : e.slice(0, 64);
|
|
213
|
+
}
|
|
214
|
+
var J = class {
|
|
193
215
|
ipc;
|
|
194
216
|
sidebar;
|
|
195
217
|
targetOrigin;
|
|
218
|
+
latestHostAdapterVersion = null;
|
|
196
219
|
constructor(e, t, n = "*") {
|
|
197
|
-
this.sidebar = e || {}, this.targetOrigin = n, this.ipc = new
|
|
220
|
+
this.sidebar = e || {}, this.targetOrigin = n, this.ipc = new _((r) => {
|
|
198
221
|
window.parent.postMessage(r, this.targetOrigin);
|
|
199
222
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
200
223
|
}
|
|
@@ -250,8 +273,15 @@ var L = class {
|
|
|
250
273
|
});
|
|
251
274
|
}
|
|
252
275
|
}
|
|
253
|
-
async getInitConfig() {
|
|
254
|
-
|
|
276
|
+
async getInitConfig(e) {
|
|
277
|
+
const { hostAdapterVersion: t, ...n } = e ? await this.ipc.call("getInitConfig", {
|
|
278
|
+
...e,
|
|
279
|
+
adapterVersion: e.adapterVersion ?? "2.2.0"
|
|
280
|
+
}) : await this.ipc.call("getInitConfig");
|
|
281
|
+
return this.latestHostAdapterVersion = G(t), n;
|
|
282
|
+
}
|
|
283
|
+
getHostAdapterVersion() {
|
|
284
|
+
return this.latestHostAdapterVersion;
|
|
255
285
|
}
|
|
256
286
|
async getContent(e) {
|
|
257
287
|
return this.ipc.callWithOptions("getContent", e ?? {});
|
|
@@ -308,16 +338,19 @@ var L = class {
|
|
|
308
338
|
destroy() {
|
|
309
339
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
310
340
|
}
|
|
311
|
-
},
|
|
341
|
+
}, ve = class {
|
|
312
342
|
ipcAdapter;
|
|
313
343
|
constructor(e, t, n) {
|
|
314
|
-
this.ipcAdapter = new
|
|
344
|
+
this.ipcAdapter = new J(e, t, n);
|
|
315
345
|
}
|
|
316
346
|
destroy() {
|
|
317
347
|
this.ipcAdapter.destroy();
|
|
318
348
|
}
|
|
319
|
-
async getInitConfig() {
|
|
320
|
-
return await this.ipcAdapter.getInitConfig();
|
|
349
|
+
async getInitConfig(e) {
|
|
350
|
+
return await this.ipcAdapter.getInitConfig(e);
|
|
351
|
+
}
|
|
352
|
+
getHostAdapterVersion() {
|
|
353
|
+
return this.ipcAdapter.getHostAdapterVersion();
|
|
321
354
|
}
|
|
322
355
|
async getContent(e) {
|
|
323
356
|
return await this.ipcAdapter.getContent(e);
|
|
@@ -364,14 +397,15 @@ var L = class {
|
|
|
364
397
|
getTargetOrigin() {
|
|
365
398
|
return this.ipcAdapter.getTargetOrigin();
|
|
366
399
|
}
|
|
367
|
-
},
|
|
400
|
+
}, Y = class {
|
|
368
401
|
ipc;
|
|
369
402
|
plugin;
|
|
370
403
|
iframe;
|
|
371
404
|
window;
|
|
372
405
|
targetOrigin;
|
|
406
|
+
latestSidebarBuildInfo = null;
|
|
373
407
|
constructor(e, t, n, r, i = "*") {
|
|
374
|
-
this.plugin = e, this.iframe = t, this.window = n ?? window, this.targetOrigin = i, this.ipc = new
|
|
408
|
+
this.plugin = e, this.iframe = t, this.window = n ?? window, this.targetOrigin = i, this.ipc = new _((a) => {
|
|
375
409
|
this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
|
|
376
410
|
}, r), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
377
411
|
}
|
|
@@ -380,7 +414,13 @@ var L = class {
|
|
|
380
414
|
e.origin !== t && (n !== "*" && e.origin !== n || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
|
|
381
415
|
};
|
|
382
416
|
registerReceivers() {
|
|
383
|
-
if (this.ipc.receive("getInitConfig", async (
|
|
417
|
+
if (this.ipc.receive("getInitConfig", async (e) => {
|
|
418
|
+
const t = W(e);
|
|
419
|
+
return this.latestSidebarBuildInfo = t, {
|
|
420
|
+
...await this.plugin.getInitConfig(t ?? void 0),
|
|
421
|
+
hostAdapterVersion: U
|
|
422
|
+
};
|
|
423
|
+
}), 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
424
|
await this.plugin.replaceContent(e, t, typeof n == "string" ? n : null);
|
|
385
425
|
}), this.ipc.receive("selectContent", async (e, t) => {
|
|
386
426
|
await this.plugin.selectContent(e, typeof t == "string" ? t : null);
|
|
@@ -451,16 +491,19 @@ var L = class {
|
|
|
451
491
|
async notifyActiveDocumentChanged(e) {
|
|
452
492
|
await this.ipc.call("onActiveDocumentChanged", e);
|
|
453
493
|
}
|
|
494
|
+
getSidebarBuildInfo() {
|
|
495
|
+
return this.latestSidebarBuildInfo;
|
|
496
|
+
}
|
|
454
497
|
configure(e) {
|
|
455
498
|
this.ipc.configure(e);
|
|
456
499
|
}
|
|
457
500
|
destroy() {
|
|
458
501
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
459
502
|
}
|
|
460
|
-
},
|
|
503
|
+
}, X = class {
|
|
461
504
|
ipcAdapter;
|
|
462
505
|
constructor(e, t, n) {
|
|
463
|
-
this.ipcAdapter = new
|
|
506
|
+
this.ipcAdapter = new Y(e, t, n?.win, n?.config, n?.targetOrigin);
|
|
464
507
|
}
|
|
465
508
|
destroy() {
|
|
466
509
|
this.ipcAdapter.destroy();
|
|
@@ -489,10 +532,13 @@ var L = class {
|
|
|
489
532
|
async notifyActiveDocumentChanged(e) {
|
|
490
533
|
await this.ipcAdapter.notifyActiveDocumentChanged(e);
|
|
491
534
|
}
|
|
535
|
+
getSidebarBuildInfo() {
|
|
536
|
+
return this.ipcAdapter.getSidebarBuildInfo();
|
|
537
|
+
}
|
|
492
538
|
configure(e) {
|
|
493
539
|
this.ipcAdapter.configure(e);
|
|
494
540
|
}
|
|
495
|
-
},
|
|
541
|
+
}, K = `
|
|
496
542
|
<div class="sidebar-load-overlay-card">
|
|
497
543
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
498
544
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -513,16 +559,16 @@ var L = class {
|
|
|
513
559
|
<span>Retry</span>
|
|
514
560
|
</button>
|
|
515
561
|
</div>
|
|
516
|
-
`,
|
|
562
|
+
`, q = () => {
|
|
517
563
|
const e = document.createElement("div");
|
|
518
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
564
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = K;
|
|
519
565
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
520
566
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
521
567
|
return {
|
|
522
568
|
overlay: e,
|
|
523
569
|
button: t
|
|
524
570
|
};
|
|
525
|
-
},
|
|
571
|
+
}, R = "markupai-sidebar-load-overlay-styles", Z = `
|
|
526
572
|
:root {
|
|
527
573
|
--background: #f5f5f4;
|
|
528
574
|
--foreground: #333332;
|
|
@@ -614,21 +660,21 @@ var L = class {
|
|
|
614
660
|
box-shadow: 0 0 0 2px
|
|
615
661
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
616
662
|
}
|
|
617
|
-
`,
|
|
663
|
+
`, Q = (e) => {
|
|
618
664
|
const t = e ?? document;
|
|
619
|
-
if (t.getElementById(
|
|
665
|
+
if (t.getElementById(R)) return;
|
|
620
666
|
const n = t.createElement("style");
|
|
621
|
-
n.id =
|
|
622
|
-
},
|
|
623
|
-
|
|
624
|
-
const { sidebarUrl: r, targetOrigin: i, timeoutMs: a =
|
|
667
|
+
n.id = R, n.textContent = Z, t.head.appendChild(n);
|
|
668
|
+
}, ee = 8e3, te = 12e3, ne = (e, t, n = {}) => {
|
|
669
|
+
Q(e.ownerDocument);
|
|
670
|
+
const { sidebarUrl: r, targetOrigin: i, timeoutMs: a = ee, retryIntervalMs: o = te, messageListenWindow: s } = n, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, B = () => {
|
|
625
671
|
if (i) return i;
|
|
626
672
|
try {
|
|
627
673
|
return new URL(p()).origin;
|
|
628
674
|
} catch {
|
|
629
675
|
return "*";
|
|
630
676
|
}
|
|
631
|
-
}, { overlay: y, button:
|
|
677
|
+
}, { overlay: y, button: v } = q();
|
|
632
678
|
e.appendChild(y);
|
|
633
679
|
let u = !1, h, d;
|
|
634
680
|
const g = (c) => {
|
|
@@ -637,45 +683,45 @@ var L = class {
|
|
|
637
683
|
g(!1);
|
|
638
684
|
const f = () => {
|
|
639
685
|
h && (globalThis.clearTimeout(h), h = void 0);
|
|
640
|
-
},
|
|
686
|
+
}, A = () => {
|
|
641
687
|
f(), h = globalThis.setTimeout(() => {
|
|
642
688
|
u || g(!0);
|
|
643
689
|
}, a);
|
|
644
|
-
},
|
|
690
|
+
}, C = (c) => {
|
|
645
691
|
const m = c?.preserveOverlay ?? !0;
|
|
646
|
-
u = !1, m || g(!1), t.src = p(),
|
|
647
|
-
},
|
|
692
|
+
u = !1, m || g(!1), t.src = p(), A();
|
|
693
|
+
}, H = () => {
|
|
648
694
|
d || o <= 0 || (d = globalThis.setInterval(() => {
|
|
649
|
-
u ||
|
|
695
|
+
u || C({ preserveOverlay: !0 });
|
|
650
696
|
}, o));
|
|
651
|
-
},
|
|
697
|
+
}, b = () => {
|
|
652
698
|
d && (globalThis.clearInterval(d), d = void 0);
|
|
653
|
-
},
|
|
699
|
+
}, S = (c) => {
|
|
654
700
|
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);
|
|
701
|
+
const m = B();
|
|
702
|
+
m !== "*" && c.origin !== m || (u = !0, f(), b(), g(!1));
|
|
659
703
|
}, w = () => {
|
|
660
|
-
|
|
704
|
+
f(), g(!0);
|
|
705
|
+
}, P = () => {
|
|
706
|
+
C();
|
|
661
707
|
};
|
|
662
|
-
return
|
|
663
|
-
f(),
|
|
708
|
+
return v.addEventListener("click", P), t.addEventListener("error", w), l.addEventListener("message", S), A(), H(), () => {
|
|
709
|
+
f(), b(), t.removeEventListener("error", w), l.removeEventListener("message", S), v.removeEventListener("click", P), y.remove();
|
|
664
710
|
};
|
|
665
|
-
},
|
|
666
|
-
function
|
|
711
|
+
}, re = "Markup AI Sidebar", ie = "clipboard-read; clipboard-write", Ae = "markupai.sidebarNextGen.overrideUrl", Ce = "https://sidebar.markup.ai/";
|
|
712
|
+
function be(e) {
|
|
667
713
|
try {
|
|
668
714
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
669
715
|
} catch {
|
|
670
716
|
return e;
|
|
671
717
|
}
|
|
672
718
|
}
|
|
673
|
-
var
|
|
674
|
-
function
|
|
719
|
+
var ae = "markupai.sidebarNextGen.authOverride";
|
|
720
|
+
function Se(e, t) {
|
|
675
721
|
if (!t) return e;
|
|
676
722
|
try {
|
|
677
723
|
if (!("localStorage" in globalThis)) return e;
|
|
678
|
-
const n = globalThis.localStorage.getItem(
|
|
724
|
+
const n = globalThis.localStorage.getItem(ae)?.trim();
|
|
679
725
|
if (!n) return e;
|
|
680
726
|
const r = JSON.parse(n);
|
|
681
727
|
return r !== null && typeof r == "object" && "type" in r && (r.type === "mediation" || r.type === "popup") ? r : e;
|
|
@@ -683,17 +729,17 @@ function Ie(e, t) {
|
|
|
683
729
|
return e;
|
|
684
730
|
}
|
|
685
731
|
}
|
|
686
|
-
function
|
|
732
|
+
function we(e, t) {
|
|
687
733
|
try {
|
|
688
734
|
return new URL(e).origin;
|
|
689
735
|
} catch (n) {
|
|
690
736
|
return t?.onInvalidUrl?.(e, n), "*";
|
|
691
737
|
}
|
|
692
738
|
}
|
|
693
|
-
function
|
|
739
|
+
function Pe(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
694
740
|
if (e.adapter === null) throw new Error(t);
|
|
695
741
|
}
|
|
696
|
-
function
|
|
742
|
+
function oe(e) {
|
|
697
743
|
const { iframe: t, iframeMount: n } = e;
|
|
698
744
|
if (t !== void 0 && n !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
699
745
|
if (t !== void 0) return {
|
|
@@ -701,18 +747,18 @@ function te(e) {
|
|
|
701
747
|
removeMountedIframe: null
|
|
702
748
|
};
|
|
703
749
|
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 =
|
|
750
|
+
const { container: r, src: i, allow: a = ie } = n, o = document.createElement("iframe");
|
|
751
|
+
return o.title = re, o.src = i, a && o.setAttribute("allow", a), r.appendChild(o), {
|
|
706
752
|
iframe: o,
|
|
707
753
|
removeMountedIframe: () => {
|
|
708
754
|
o.remove();
|
|
709
755
|
}
|
|
710
756
|
};
|
|
711
757
|
}
|
|
712
|
-
function
|
|
713
|
-
const { plugin: t, loadOverlayContainer: n, loadOverlayOptions: r, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } =
|
|
758
|
+
function Ee(e) {
|
|
759
|
+
const { plugin: t, loadOverlayContainer: n, loadOverlayOptions: r, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } = oe(e), s = n !== void 0 ? ne(n, a, r ?? {}) : null;
|
|
714
760
|
if (t !== void 0) {
|
|
715
|
-
const l = new
|
|
761
|
+
const l = new X(t, a, i);
|
|
716
762
|
return {
|
|
717
763
|
iframe: a,
|
|
718
764
|
adapter: l,
|
|
@@ -729,14 +775,14 @@ function Ce(e) {
|
|
|
729
775
|
}
|
|
730
776
|
};
|
|
731
777
|
}
|
|
732
|
-
var
|
|
733
|
-
function
|
|
778
|
+
var L = "sidebarContainer", T = "markupai-sidebar-host-shell-styles";
|
|
779
|
+
function k(e) {
|
|
734
780
|
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
735
781
|
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
782
|
return e;
|
|
737
783
|
}
|
|
738
|
-
function
|
|
739
|
-
const t =
|
|
784
|
+
function N(e = L) {
|
|
785
|
+
const t = k(e);
|
|
740
786
|
return `
|
|
741
787
|
html {
|
|
742
788
|
height: 100%;
|
|
@@ -761,21 +807,21 @@ body {
|
|
|
761
807
|
}
|
|
762
808
|
`.trim();
|
|
763
809
|
}
|
|
764
|
-
var
|
|
765
|
-
function
|
|
810
|
+
var Re = N();
|
|
811
|
+
function se(e) {
|
|
766
812
|
return e instanceof Document ? e : e.ownerDocument;
|
|
767
813
|
}
|
|
768
|
-
function
|
|
769
|
-
if (!t || e.getElementById(
|
|
814
|
+
function le(e, t, n) {
|
|
815
|
+
if (!t || e.getElementById(T)) return;
|
|
770
816
|
const r = e.createElement("style");
|
|
771
|
-
r.id =
|
|
817
|
+
r.id = T, r.textContent = N(n), e.head.appendChild(r);
|
|
772
818
|
}
|
|
773
|
-
function
|
|
774
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId: n =
|
|
819
|
+
function Te(e) {
|
|
820
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: n = L, includeDefaultStyles: r = !0 } = e ?? {};
|
|
775
821
|
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(`#${
|
|
822
|
+
const i = se(t);
|
|
823
|
+
le(i, r, n);
|
|
824
|
+
const a = t instanceof Document ? i.getElementById(n) : t.querySelector(`#${k(n)}`);
|
|
779
825
|
if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
|
|
780
826
|
if (!(t instanceof Document)) {
|
|
781
827
|
const s = i.createElement("div");
|
|
@@ -784,18 +830,18 @@ function Se(e) {
|
|
|
784
830
|
const o = i.createElement("div");
|
|
785
831
|
return o.id = n, i.body.appendChild(o), o;
|
|
786
832
|
}
|
|
787
|
-
function
|
|
833
|
+
function ce() {
|
|
788
834
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
789
835
|
}
|
|
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 ?
|
|
836
|
+
function Oe(e) {
|
|
837
|
+
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 ? ce() : "", n].filter((p) => p.trim().length > 0).join(`
|
|
792
838
|
`);
|
|
793
839
|
return `<!DOCTYPE html>
|
|
794
840
|
<html ${o}>
|
|
795
841
|
<head>
|
|
796
842
|
<base target="_top" />
|
|
797
843
|
<meta charset="UTF-8" />
|
|
798
|
-
<title>${
|
|
844
|
+
<title>${de(t)}</title>${l ? `
|
|
799
845
|
${l}` : ""}
|
|
800
846
|
</head>
|
|
801
847
|
<body ${s}>
|
|
@@ -804,43 +850,44 @@ ${l}` : ""}
|
|
|
804
850
|
</html>
|
|
805
851
|
`;
|
|
806
852
|
}
|
|
807
|
-
function
|
|
853
|
+
function de(e) {
|
|
808
854
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
809
855
|
}
|
|
810
856
|
export {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
857
|
+
U as ADAPTER_VERSION,
|
|
858
|
+
ae as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
859
|
+
V as DEFAULT_IPC_CONFIG,
|
|
860
|
+
ue as DEFAULT_SIDEBAR_CONFIG,
|
|
861
|
+
j as DeferredPromise,
|
|
862
|
+
_ as IPCCore,
|
|
863
|
+
ge as MimeType,
|
|
864
|
+
ve as PluginAdapter,
|
|
865
|
+
J as PluginIPCAdapter,
|
|
866
|
+
Ce as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
867
|
+
L as SIDEBAR_HOST_CONTAINER_ID,
|
|
868
|
+
Re as SIDEBAR_HOST_SHELL_CSS,
|
|
869
|
+
ie as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
870
|
+
re as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
871
|
+
Ae as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
872
|
+
X as SidebarAdapter,
|
|
873
|
+
Y as SidebarIPCAdapter,
|
|
874
|
+
pe as TEXT_MIME_TYPES,
|
|
828
875
|
O as TextLookupError,
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
876
|
+
Pe as assertSidebarHostAdapter,
|
|
877
|
+
Ie as buildDocumentReference,
|
|
878
|
+
Oe as buildSidebarHostHtmlDocument,
|
|
879
|
+
N as buildSidebarHostShellCss,
|
|
880
|
+
ce as buildSidebarPluginHostHeadInnerHtml,
|
|
881
|
+
Ee as createSidebarHost,
|
|
882
|
+
Te as ensureSidebarHostShell,
|
|
883
|
+
Se as getAuthConfigWithOverride,
|
|
884
|
+
be as getSidebarBaseUrlWithOverride,
|
|
885
|
+
E as ipcErrorReconstructors,
|
|
886
|
+
ye as isDocumentReference,
|
|
887
|
+
fe as isIntegrationSettingField,
|
|
888
|
+
he as isIntegrationSettingsSchema,
|
|
889
|
+
me as isTextLookupError,
|
|
890
|
+
$ as reconstructError,
|
|
891
|
+
ne as setupSidebarLoadOverlay,
|
|
892
|
+
we as sidebarPostMessageTargetOrigin
|
|
846
893
|
};
|