@markupai/sidebar-adapter 1.3.2 → 1.4.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 +62 -18
- package/asyncapi.json +35 -12
- package/dist/document-reference/documentReference.d.ts +57 -0
- package/dist/document-reference/documentReference.d.ts.map +1 -0
- package/dist/document-reference/index.d.ts +2 -0
- package/dist/document-reference/index.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.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/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/main.js +190 -178
- package/dist/main.umd.cjs +7 -7
- package/dist/types/common.d.ts +71 -2
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +13 -4
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
var
|
|
1
|
+
var oe = /* @__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
|
+
})({}), se = [
|
|
4
4
|
"text/plain",
|
|
5
5
|
"text/markdown",
|
|
6
6
|
"text/html",
|
|
7
7
|
"application/dita+xml"
|
|
8
|
-
],
|
|
8
|
+
], le = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
12
12
|
hideBanner: !1,
|
|
13
13
|
dialogClosingScript: void 0,
|
|
14
14
|
useCheckPreviewDialog: !1,
|
|
15
|
-
supportCheckSelection: !0
|
|
16
|
-
|
|
15
|
+
supportCheckSelection: !0,
|
|
16
|
+
multiAgent: !1
|
|
17
|
+
}, ce = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), de = (e) => {
|
|
17
18
|
if (typeof e != "object" || e === null) return !1;
|
|
18
19
|
const t = e;
|
|
19
20
|
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((i) => {
|
|
@@ -21,41 +22,54 @@ var ne = /* @__PURE__ */ (function(e) {
|
|
|
21
22
|
const r = i;
|
|
22
23
|
return typeof r.value == "string" && typeof r.label == "string";
|
|
23
24
|
}) : !1;
|
|
24
|
-
}, O = class
|
|
25
|
+
}, O = class T extends Error {
|
|
25
26
|
name = "TextLookupError";
|
|
26
27
|
constructor(t) {
|
|
27
|
-
super(t), Object.setPrototypeOf(this,
|
|
28
|
+
super(t), Object.setPrototypeOf(this, T.prototype);
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
|
-
function
|
|
31
|
+
function ge(e) {
|
|
31
32
|
return e instanceof O;
|
|
32
33
|
}
|
|
33
34
|
var P = { TextLookupError: (e) => new O(e) };
|
|
34
|
-
function
|
|
35
|
+
function U(e) {
|
|
35
36
|
const t = e.message ?? "", i = e.name, r = typeof i == "string" && i in P ? P[i] : void 0;
|
|
36
37
|
return r ? r(t, e) : Object.assign(new Error(t), i ? { name: i } : {});
|
|
37
38
|
}
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
39
|
+
var D = ":", x = /^[a-z][a-z0-9-]*$/;
|
|
40
|
+
function pe(e) {
|
|
41
|
+
const t = e.indexOf(D);
|
|
42
|
+
return t <= 0 || t === e.length - 1 ? !1 : x.test(e.slice(0, t));
|
|
43
|
+
}
|
|
44
|
+
function ue(e, t) {
|
|
45
|
+
const i = e.trim().toLowerCase(), r = t.trim();
|
|
46
|
+
if (!x.test(i)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
|
|
47
|
+
if (r.length === 0) throw new Error("Invalid document reference: the document id is empty.");
|
|
48
|
+
const n = `${i}${D}`;
|
|
49
|
+
return r.startsWith(n) ? r : `${n}${r}`;
|
|
50
|
+
}
|
|
51
|
+
var H = class extends Promise {
|
|
52
|
+
static get [Symbol.species]() {
|
|
53
|
+
return Promise;
|
|
54
|
+
}
|
|
55
|
+
resolve;
|
|
56
|
+
reject;
|
|
57
|
+
constructor(e = () => {
|
|
58
|
+
}) {
|
|
59
|
+
let t, i;
|
|
60
|
+
super((r, n) => {
|
|
61
|
+
t = r, i = n, e(r, n);
|
|
62
|
+
}), this.resolve = t, this.reject = i;
|
|
63
|
+
}
|
|
64
|
+
}, $ = { timeout: 1e4 };
|
|
65
|
+
function j(e) {
|
|
66
|
+
const t = JSON.stringify(e, Object.getOwnPropertyNames(e)), i = JSON.parse(t);
|
|
67
|
+
return i.message === void 0 || i.message === "" ? JSON.stringify({
|
|
68
|
+
message: e instanceof Error ? e.message : String(e),
|
|
69
|
+
name: e instanceof Error ? e.name : void 0
|
|
70
|
+
}) : t;
|
|
71
|
+
}
|
|
72
|
+
var L = class {
|
|
59
73
|
promisesByID = {};
|
|
60
74
|
receiversByName = {};
|
|
61
75
|
currentID = 0;
|
|
@@ -63,7 +77,7 @@ var E = () => {
|
|
|
63
77
|
postMessage;
|
|
64
78
|
constructor(e, t) {
|
|
65
79
|
this.postMessage = e, this.config = {
|
|
66
|
-
|
|
80
|
+
...$,
|
|
67
81
|
...t
|
|
68
82
|
};
|
|
69
83
|
}
|
|
@@ -77,14 +91,14 @@ var E = () => {
|
|
|
77
91
|
return this.callWithOptions(e, {}, ...t);
|
|
78
92
|
}
|
|
79
93
|
callWithOptions(e, t, ...i) {
|
|
80
|
-
const r = this.currentID++,
|
|
94
|
+
const r = this.currentID++, n = new H(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
81
95
|
if (r in this.promisesByID) {
|
|
82
|
-
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(
|
|
83
|
-
|
|
96
|
+
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);
|
|
97
|
+
n.reject(l), Reflect.deleteProperty(this.promisesByID, r);
|
|
84
98
|
}
|
|
85
|
-
},
|
|
99
|
+
}, a);
|
|
86
100
|
this.promisesByID[r] = {
|
|
87
|
-
promise:
|
|
101
|
+
promise: n,
|
|
88
102
|
timeoutId: o
|
|
89
103
|
};
|
|
90
104
|
const s = {
|
|
@@ -93,7 +107,7 @@ var E = () => {
|
|
|
93
107
|
name: e,
|
|
94
108
|
data: i
|
|
95
109
|
};
|
|
96
|
-
return this.postMessage(s),
|
|
110
|
+
return this.postMessage(s), n;
|
|
97
111
|
}
|
|
98
112
|
receive(e, t) {
|
|
99
113
|
this.receiversByName[e] = t;
|
|
@@ -117,43 +131,37 @@ var E = () => {
|
|
|
117
131
|
}
|
|
118
132
|
async handleCall(e) {
|
|
119
133
|
const { id: t, name: i, data: r } = e;
|
|
120
|
-
if (i in this.receiversByName) {
|
|
121
|
-
const a =
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
id: t,
|
|
127
|
-
name: i,
|
|
128
|
-
data: n
|
|
129
|
-
};
|
|
130
|
-
this.postMessage(o);
|
|
131
|
-
} catch (n) {
|
|
132
|
-
let o = JSON.stringify(n, Object.getOwnPropertyNames(n));
|
|
133
|
-
const s = JSON.parse(o);
|
|
134
|
-
(s.message === void 0 || s.message === "") && (o = JSON.stringify({
|
|
135
|
-
message: n instanceof Error ? n.message : String(n),
|
|
136
|
-
name: n instanceof Error ? n.name : void 0
|
|
137
|
-
}));
|
|
138
|
-
const l = {
|
|
139
|
-
type: "error",
|
|
140
|
-
id: t,
|
|
141
|
-
name: i,
|
|
142
|
-
errorJSON: o
|
|
143
|
-
};
|
|
144
|
-
this.postMessage(l);
|
|
145
|
-
}
|
|
146
|
-
} else {
|
|
147
|
-
const a = /* @__PURE__ */ new Error(`No receiver registered for: ${i}`), n = {
|
|
134
|
+
if (!(i in this.receiversByName)) {
|
|
135
|
+
const a = /* @__PURE__ */ new Error(`No receiver registered for: ${i}`), o = JSON.stringify({
|
|
136
|
+
message: a.message,
|
|
137
|
+
name: a.name
|
|
138
|
+
});
|
|
139
|
+
this.postMessage({
|
|
148
140
|
type: "error",
|
|
149
141
|
id: t,
|
|
150
142
|
name: i,
|
|
151
|
-
errorJSON:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
143
|
+
errorJSON: o
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const n = this.receiversByName[i];
|
|
148
|
+
try {
|
|
149
|
+
if (!Array.isArray(r)) throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);
|
|
150
|
+
const a = await n(...r), o = {
|
|
151
|
+
type: "response",
|
|
152
|
+
id: t,
|
|
153
|
+
name: i,
|
|
154
|
+
data: a
|
|
155
|
+
};
|
|
156
|
+
this.postMessage(o);
|
|
157
|
+
} catch (a) {
|
|
158
|
+
const o = {
|
|
159
|
+
type: "error",
|
|
160
|
+
id: t,
|
|
161
|
+
name: i,
|
|
162
|
+
errorJSON: j(a)
|
|
155
163
|
};
|
|
156
|
-
this.postMessage(
|
|
164
|
+
this.postMessage(o);
|
|
157
165
|
}
|
|
158
166
|
}
|
|
159
167
|
handleResponse(e) {
|
|
@@ -166,11 +174,11 @@ var E = () => {
|
|
|
166
174
|
handleError(e) {
|
|
167
175
|
const { id: t, errorJSON: i } = e;
|
|
168
176
|
if (t in this.promisesByID) {
|
|
169
|
-
const { promise: r, timeoutId:
|
|
170
|
-
clearTimeout(
|
|
177
|
+
const { promise: r, timeoutId: n } = this.promisesByID[t];
|
|
178
|
+
clearTimeout(n);
|
|
171
179
|
try {
|
|
172
|
-
const
|
|
173
|
-
r.reject(
|
|
180
|
+
const a = U(JSON.parse(i));
|
|
181
|
+
r.reject(a);
|
|
174
182
|
} catch {
|
|
175
183
|
r.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
176
184
|
}
|
|
@@ -182,12 +190,12 @@ var E = () => {
|
|
|
182
190
|
clearTimeout(t), e.reject(/* @__PURE__ */ new Error("IPC destroyed"));
|
|
183
191
|
this.promisesByID = {}, this.receiversByName = {};
|
|
184
192
|
}
|
|
185
|
-
},
|
|
193
|
+
}, F = class {
|
|
186
194
|
ipc;
|
|
187
195
|
sidebar;
|
|
188
196
|
targetOrigin;
|
|
189
197
|
constructor(e, t, i = "*") {
|
|
190
|
-
this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new
|
|
198
|
+
this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new L((r) => {
|
|
191
199
|
window.parent.postMessage(r, this.targetOrigin);
|
|
192
200
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
193
201
|
}
|
|
@@ -298,10 +306,10 @@ var E = () => {
|
|
|
298
306
|
destroy() {
|
|
299
307
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
300
308
|
}
|
|
301
|
-
},
|
|
309
|
+
}, he = class {
|
|
302
310
|
ipcAdapter;
|
|
303
311
|
constructor(e, t, i) {
|
|
304
|
-
this.ipcAdapter = new
|
|
312
|
+
this.ipcAdapter = new F(e, t, i);
|
|
305
313
|
}
|
|
306
314
|
destroy() {
|
|
307
315
|
this.ipcAdapter.destroy();
|
|
@@ -357,15 +365,15 @@ var E = () => {
|
|
|
357
365
|
getTargetOrigin() {
|
|
358
366
|
return this.ipcAdapter.getTargetOrigin();
|
|
359
367
|
}
|
|
360
|
-
},
|
|
368
|
+
}, z = class {
|
|
361
369
|
ipc;
|
|
362
370
|
plugin;
|
|
363
371
|
iframe;
|
|
364
372
|
window;
|
|
365
373
|
targetOrigin;
|
|
366
|
-
constructor(e, t, i, r,
|
|
367
|
-
this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin =
|
|
368
|
-
this.iframe.contentWindow?.postMessage(
|
|
374
|
+
constructor(e, t, i, r, n = "*") {
|
|
375
|
+
this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin = n, this.ipc = new L((a) => {
|
|
376
|
+
this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
|
|
369
377
|
}, r), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
370
378
|
}
|
|
371
379
|
handleMessage = (e) => {
|
|
@@ -378,8 +386,10 @@ var E = () => {
|
|
|
378
386
|
}), this.ipc.receive("selectContent", async (e) => {
|
|
379
387
|
await this.plugin.selectContent(e);
|
|
380
388
|
}), this.ipc.receive("showDialog", async (e, t, i, r) => {
|
|
389
|
+
if (!this.plugin.showDialog) throw new Error("SidebarIPCAdapter: host does not implement showDialog");
|
|
381
390
|
await this.plugin.showDialog(e, t, i, r);
|
|
382
391
|
}), this.ipc.receive("closeDialog", async () => {
|
|
392
|
+
if (!this.plugin.closeDialog) throw new Error("SidebarIPCAdapter: host does not implement closeDialog");
|
|
383
393
|
await this.plugin.closeDialog();
|
|
384
394
|
}), this.ipc.receive("replaceMultipleContents", async (e) => {
|
|
385
395
|
await this.plugin.replaceMultipleContents(e);
|
|
@@ -444,10 +454,10 @@ var E = () => {
|
|
|
444
454
|
destroy() {
|
|
445
455
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
446
456
|
}
|
|
447
|
-
},
|
|
457
|
+
}, W = class {
|
|
448
458
|
ipcAdapter;
|
|
449
459
|
constructor(e, t, i) {
|
|
450
|
-
this.ipcAdapter = new
|
|
460
|
+
this.ipcAdapter = new z(e, t, i?.win, i?.config, i?.targetOrigin);
|
|
451
461
|
}
|
|
452
462
|
destroy() {
|
|
453
463
|
this.ipcAdapter.destroy();
|
|
@@ -476,7 +486,7 @@ var E = () => {
|
|
|
476
486
|
configure(e) {
|
|
477
487
|
this.ipcAdapter.configure(e);
|
|
478
488
|
}
|
|
479
|
-
},
|
|
489
|
+
}, G = `
|
|
480
490
|
<div class="sidebar-load-overlay-card">
|
|
481
491
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
482
492
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -497,16 +507,16 @@ var E = () => {
|
|
|
497
507
|
<span>Retry</span>
|
|
498
508
|
</button>
|
|
499
509
|
</div>
|
|
500
|
-
`,
|
|
510
|
+
`, J = () => {
|
|
501
511
|
const e = document.createElement("div");
|
|
502
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
512
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = G;
|
|
503
513
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
504
514
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
505
515
|
return {
|
|
506
516
|
overlay: e,
|
|
507
517
|
button: t
|
|
508
518
|
};
|
|
509
|
-
},
|
|
519
|
+
}, E = "markupai-sidebar-load-overlay-styles", Y = `
|
|
510
520
|
:root {
|
|
511
521
|
--background: #f5f5f4;
|
|
512
522
|
--foreground: #333332;
|
|
@@ -598,37 +608,37 @@ var E = () => {
|
|
|
598
608
|
box-shadow: 0 0 0 2px
|
|
599
609
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
600
610
|
}
|
|
601
|
-
`,
|
|
611
|
+
`, V = (e) => {
|
|
602
612
|
const t = e ?? document;
|
|
603
|
-
if (t.getElementById(
|
|
613
|
+
if (t.getElementById(E)) return;
|
|
604
614
|
const i = t.createElement("style");
|
|
605
|
-
i.id =
|
|
606
|
-
},
|
|
607
|
-
|
|
608
|
-
const { sidebarUrl: r, targetOrigin:
|
|
609
|
-
if (
|
|
615
|
+
i.id = E, i.textContent = Y, t.head.appendChild(i);
|
|
616
|
+
}, X = 8e3, K = 12e3, q = (e, t, i = {}) => {
|
|
617
|
+
V(e.ownerDocument);
|
|
618
|
+
const { sidebarUrl: r, targetOrigin: n, timeoutMs: a = X, retryIntervalMs: o = K, messageListenWindow: s } = i, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, N = () => {
|
|
619
|
+
if (n) return n;
|
|
610
620
|
try {
|
|
611
621
|
return new URL(p()).origin;
|
|
612
622
|
} catch {
|
|
613
623
|
return "*";
|
|
614
624
|
}
|
|
615
|
-
}, { overlay:
|
|
616
|
-
e.appendChild(
|
|
625
|
+
}, { overlay: y, button: I } = J();
|
|
626
|
+
e.appendChild(y);
|
|
617
627
|
let u = !1, h, d;
|
|
618
628
|
const g = (c) => {
|
|
619
|
-
|
|
629
|
+
y.style.display = c ? "flex" : "none";
|
|
620
630
|
};
|
|
621
631
|
g(!1);
|
|
622
632
|
const f = () => {
|
|
623
633
|
h && (globalThis.clearTimeout(h), h = void 0);
|
|
624
|
-
},
|
|
634
|
+
}, v = () => {
|
|
625
635
|
f(), h = globalThis.setTimeout(() => {
|
|
626
636
|
u || g(!0);
|
|
627
|
-
},
|
|
637
|
+
}, a);
|
|
628
638
|
}, A = (c) => {
|
|
629
|
-
const
|
|
630
|
-
u = !1,
|
|
631
|
-
},
|
|
639
|
+
const m = c?.preserveOverlay ?? !0;
|
|
640
|
+
u = !1, m || g(!1), t.src = p(), v();
|
|
641
|
+
}, B = () => {
|
|
632
642
|
d || o <= 0 || (d = globalThis.setInterval(() => {
|
|
633
643
|
u || A({ preserveOverlay: !0 });
|
|
634
644
|
}, o));
|
|
@@ -636,30 +646,30 @@ var E = () => {
|
|
|
636
646
|
d && (globalThis.clearInterval(d), d = void 0);
|
|
637
647
|
}, b = (c) => {
|
|
638
648
|
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
639
|
-
const
|
|
640
|
-
|
|
649
|
+
const m = N();
|
|
650
|
+
m !== "*" && c.origin !== m || (u = !0, f(), C(), g(!1));
|
|
641
651
|
}, w = () => {
|
|
642
652
|
f(), g(!0);
|
|
643
653
|
}, S = () => {
|
|
644
654
|
A();
|
|
645
655
|
};
|
|
646
|
-
return
|
|
647
|
-
f(), C(), t.removeEventListener("error", w), l.removeEventListener("message", b),
|
|
656
|
+
return I.addEventListener("click", S), t.addEventListener("error", w), l.addEventListener("message", b), v(), B(), () => {
|
|
657
|
+
f(), C(), t.removeEventListener("error", w), l.removeEventListener("message", b), I.removeEventListener("click", S), y.remove();
|
|
648
658
|
};
|
|
649
|
-
},
|
|
650
|
-
function
|
|
659
|
+
}, Z = "Markup AI Sidebar", Q = "clipboard-read; clipboard-write", fe = "markupai.sidebarNextGen.overrideUrl", me = "https://sidebar.markup.ai/";
|
|
660
|
+
function ye(e) {
|
|
651
661
|
try {
|
|
652
662
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
653
663
|
} catch {
|
|
654
664
|
return e;
|
|
655
665
|
}
|
|
656
666
|
}
|
|
657
|
-
var
|
|
658
|
-
function
|
|
667
|
+
var ee = "markupai.sidebarNextGen.authOverride";
|
|
668
|
+
function Ie(e, t) {
|
|
659
669
|
if (!t) return e;
|
|
660
670
|
try {
|
|
661
671
|
if (!("localStorage" in globalThis)) return e;
|
|
662
|
-
const i = globalThis.localStorage.getItem(
|
|
672
|
+
const i = globalThis.localStorage.getItem(ee)?.trim();
|
|
663
673
|
if (!i) return e;
|
|
664
674
|
const r = JSON.parse(i);
|
|
665
675
|
return r !== null && typeof r == "object" && "type" in r && (r.type === "mediation" || r.type === "popup") ? r : e;
|
|
@@ -667,17 +677,17 @@ function he(e, t) {
|
|
|
667
677
|
return e;
|
|
668
678
|
}
|
|
669
679
|
}
|
|
670
|
-
function
|
|
680
|
+
function ve(e, t) {
|
|
671
681
|
try {
|
|
672
682
|
return new URL(e).origin;
|
|
673
683
|
} catch (i) {
|
|
674
684
|
return t?.onInvalidUrl?.(e, i), "*";
|
|
675
685
|
}
|
|
676
686
|
}
|
|
677
|
-
function
|
|
687
|
+
function Ae(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
678
688
|
if (e.adapter === null) throw new Error(t);
|
|
679
689
|
}
|
|
680
|
-
function
|
|
690
|
+
function te(e) {
|
|
681
691
|
const { iframe: t, iframeMount: i } = e;
|
|
682
692
|
if (t !== void 0 && i !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
683
693
|
if (t !== void 0) return {
|
|
@@ -685,20 +695,20 @@ function Q(e) {
|
|
|
685
695
|
removeMountedIframe: null
|
|
686
696
|
};
|
|
687
697
|
if (i === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
688
|
-
const { container: r, src:
|
|
689
|
-
return o.title =
|
|
698
|
+
const { container: r, src: n, allow: a = Q } = i, o = document.createElement("iframe");
|
|
699
|
+
return o.title = Z, o.src = n, a && o.setAttribute("allow", a), r.appendChild(o), {
|
|
690
700
|
iframe: o,
|
|
691
701
|
removeMountedIframe: () => {
|
|
692
702
|
o.remove();
|
|
693
703
|
}
|
|
694
704
|
};
|
|
695
705
|
}
|
|
696
|
-
function
|
|
697
|
-
const { plugin: t, loadOverlayContainer: i, loadOverlayOptions: r, adapterOptions:
|
|
706
|
+
function Ce(e) {
|
|
707
|
+
const { plugin: t, loadOverlayContainer: i, loadOverlayOptions: r, adapterOptions: n } = e, { iframe: a, removeMountedIframe: o } = te(e), s = i !== void 0 ? q(i, a, r ?? {}) : null;
|
|
698
708
|
if (t !== void 0) {
|
|
699
|
-
const l = new
|
|
709
|
+
const l = new W(t, a, n);
|
|
700
710
|
return {
|
|
701
|
-
iframe:
|
|
711
|
+
iframe: a,
|
|
702
712
|
adapter: l,
|
|
703
713
|
destroy: () => {
|
|
704
714
|
s?.(), l.destroy(), o?.();
|
|
@@ -706,21 +716,21 @@ function me(e) {
|
|
|
706
716
|
};
|
|
707
717
|
}
|
|
708
718
|
return {
|
|
709
|
-
iframe:
|
|
719
|
+
iframe: a,
|
|
710
720
|
adapter: null,
|
|
711
721
|
destroy: () => {
|
|
712
722
|
s?.(), o?.();
|
|
713
723
|
}
|
|
714
724
|
};
|
|
715
725
|
}
|
|
716
|
-
var
|
|
717
|
-
function
|
|
726
|
+
var M = "sidebarContainer", R = "markupai-sidebar-host-shell-styles";
|
|
727
|
+
function _(e) {
|
|
718
728
|
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
719
|
-
if (!/^[a-zA-Z_][\w-]*$/.test(e)) throw new Error(`sidebar host shell: containerId must match /^[a-zA-Z_][
|
|
729
|
+
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)})`);
|
|
720
730
|
return e;
|
|
721
731
|
}
|
|
722
|
-
function
|
|
723
|
-
const t =
|
|
732
|
+
function k(e = M) {
|
|
733
|
+
const t = _(e);
|
|
724
734
|
return `
|
|
725
735
|
html {
|
|
726
736
|
height: 100%;
|
|
@@ -745,84 +755,86 @@ body {
|
|
|
745
755
|
}
|
|
746
756
|
`.trim();
|
|
747
757
|
}
|
|
748
|
-
var
|
|
749
|
-
function
|
|
758
|
+
var be = k();
|
|
759
|
+
function ie(e) {
|
|
750
760
|
return e instanceof Document ? e : e.ownerDocument;
|
|
751
761
|
}
|
|
752
|
-
function
|
|
753
|
-
if (!t || e.getElementById(
|
|
762
|
+
function re(e, t, i) {
|
|
763
|
+
if (!t || e.getElementById(R)) return;
|
|
754
764
|
const r = e.createElement("style");
|
|
755
|
-
r.id =
|
|
765
|
+
r.id = R, r.textContent = k(i), e.head.appendChild(r);
|
|
756
766
|
}
|
|
757
|
-
function
|
|
758
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId: i =
|
|
767
|
+
function we(e) {
|
|
768
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: i = M, includeDefaultStyles: r = !0 } = e ?? {};
|
|
759
769
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
const
|
|
763
|
-
if (
|
|
770
|
+
const n = ie(t);
|
|
771
|
+
re(n, r, i);
|
|
772
|
+
const a = t instanceof Document ? n.getElementById(i) : t.querySelector(`#${_(i)}`);
|
|
773
|
+
if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
|
|
764
774
|
if (!(t instanceof Document)) {
|
|
765
|
-
const s =
|
|
775
|
+
const s = n.createElement("div");
|
|
766
776
|
return s.id = i, t.appendChild(s), s;
|
|
767
777
|
}
|
|
768
|
-
const o =
|
|
769
|
-
return o.id = i,
|
|
778
|
+
const o = n.createElement("div");
|
|
779
|
+
return o.id = i, n.body.appendChild(o), o;
|
|
770
780
|
}
|
|
771
|
-
function
|
|
781
|
+
function ne() {
|
|
772
782
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
773
783
|
}
|
|
774
|
-
function
|
|
775
|
-
const { title: t = "Markup AI Sidebar", headInnerHtml: i = "", includePluginHostHead: r = !1, bodyScriptsHtml:
|
|
784
|
+
function Se(e) {
|
|
785
|
+
const { title: t = "Markup AI Sidebar", headInnerHtml: i = "", includePluginHostHead: r = !1, bodyScriptsHtml: n, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [r ? ne() : "", i].filter((p) => p.trim().length > 0).join(`
|
|
776
786
|
`);
|
|
777
787
|
return `<!DOCTYPE html>
|
|
778
788
|
<html ${o}>
|
|
779
789
|
<head>
|
|
780
790
|
<base target="_top" />
|
|
781
791
|
<meta charset="UTF-8" />
|
|
782
|
-
<title>${
|
|
792
|
+
<title>${ae(t)}</title>${l ? `
|
|
783
793
|
${l}` : ""}
|
|
784
794
|
</head>
|
|
785
795
|
<body ${s}>
|
|
786
|
-
${
|
|
796
|
+
${n}
|
|
787
797
|
</body>
|
|
788
798
|
</html>
|
|
789
799
|
`;
|
|
790
800
|
}
|
|
791
|
-
function
|
|
801
|
+
function ae(e) {
|
|
792
802
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
793
803
|
}
|
|
794
804
|
export {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
805
|
+
ee as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
806
|
+
$ as DEFAULT_IPC_CONFIG,
|
|
807
|
+
le as DEFAULT_SIDEBAR_CONFIG,
|
|
808
|
+
H as DeferredPromise,
|
|
809
|
+
L as IPCCore,
|
|
810
|
+
oe as MimeType,
|
|
811
|
+
he as PluginAdapter,
|
|
812
|
+
F as PluginIPCAdapter,
|
|
813
|
+
me as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
814
|
+
M as SIDEBAR_HOST_CONTAINER_ID,
|
|
815
|
+
be as SIDEBAR_HOST_SHELL_CSS,
|
|
816
|
+
Q as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
817
|
+
Z as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
818
|
+
fe as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
819
|
+
W as SidebarAdapter,
|
|
820
|
+
z as SidebarIPCAdapter,
|
|
821
|
+
se as TEXT_MIME_TYPES,
|
|
812
822
|
O as TextLookupError,
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
823
|
+
Ae as assertSidebarHostAdapter,
|
|
824
|
+
ue as buildDocumentReference,
|
|
825
|
+
Se as buildSidebarHostHtmlDocument,
|
|
826
|
+
k as buildSidebarHostShellCss,
|
|
827
|
+
ne as buildSidebarPluginHostHeadInnerHtml,
|
|
828
|
+
Ce as createSidebarHost,
|
|
829
|
+
we as ensureSidebarHostShell,
|
|
830
|
+
Ie as getAuthConfigWithOverride,
|
|
831
|
+
ye as getSidebarBaseUrlWithOverride,
|
|
821
832
|
P as ipcErrorReconstructors,
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
ce as
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
833
|
+
pe as isDocumentReference,
|
|
834
|
+
de as isIntegrationSettingField,
|
|
835
|
+
ce as isIntegrationSettingsSchema,
|
|
836
|
+
ge as isTextLookupError,
|
|
837
|
+
U as reconstructError,
|
|
838
|
+
q as setupSidebarLoadOverlay,
|
|
839
|
+
ve as sidebarPostMessageTargetOrigin
|
|
828
840
|
};
|