@markupai/sidebar-adapter 2.2.0 → 2.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 +80 -6
- package/asyncapi.json +208 -49
- package/dist/adapters/index.d.ts +2 -2
- package/dist/adapters/pluginAdapter.d.ts +10 -2
- package/dist/adapters/pluginAdapter.d.ts.map +1 -1
- package/dist/adapters/sidebarAdapter.d.ts +2 -2
- package/dist/adapters/sidebarAdapter.d.ts.map +1 -1
- package/dist/errors.d.ts +38 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/ipc/call-signatures.d.ts +7 -2
- package/dist/ipc/call-signatures.d.ts.map +1 -1
- package/dist/ipc/deferred-promise.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 +11 -4
- package/dist/ipc/plugin-ipc-adapter.d.ts.map +1 -1
- package/dist/ipc/sidebar-build-info.d.ts +1 -1
- package/dist/ipc/sidebar-ipc-adapter.d.ts +4 -4
- package/dist/ipc/sidebar-ipc-adapter.d.ts.map +1 -1
- package/dist/load-overlay/loadOverlayStyles.d.ts.map +1 -1
- package/dist/load-overlay/sidebarLoadOverlay.d.ts.map +1 -1
- package/dist/main.js +190 -136
- package/dist/main.umd.cjs +6 -6
- package/dist/sidebar-host/createSidebarHost.d.ts +4 -4
- package/dist/types/common.d.ts +30 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/errors.d.ts +47 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/integrationSettings.d.ts.map +1 -1
- package/dist/types/pluginInterface.d.ts +29 -1
- package/dist/types/pluginInterface.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
var
|
|
1
|
+
var fe = /* @__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
|
+
})({}), me = [
|
|
4
4
|
"text/plain",
|
|
5
5
|
"text/markdown",
|
|
6
6
|
"text/html",
|
|
7
7
|
"application/dita+xml"
|
|
8
|
-
],
|
|
8
|
+
], ye = {
|
|
9
9
|
integrationName: "unknown",
|
|
10
10
|
integrationVersion: "unknown",
|
|
11
11
|
integrationId: "markupai-sidebar-app",
|
|
12
12
|
hideBanner: !1,
|
|
13
13
|
supportCheckSelection: !0,
|
|
14
|
+
supportComments: !1,
|
|
14
15
|
multiAgent: !1,
|
|
15
16
|
multiDocument: !1
|
|
16
|
-
},
|
|
17
|
+
}, Ie = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), ve = (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((n) => {
|
|
@@ -21,33 +22,72 @@ var ge = /* @__PURE__ */ (function(e) {
|
|
|
21
22
|
const r = n;
|
|
22
23
|
return typeof r.value == "string" && typeof r.label == "string";
|
|
23
24
|
}) : !1;
|
|
24
|
-
},
|
|
25
|
+
}, V = "2.4.0", v = class x extends Error {
|
|
25
26
|
name = "TextLookupError";
|
|
26
27
|
constructor(t) {
|
|
27
|
-
super(t), Object.setPrototypeOf(this,
|
|
28
|
+
super(t), Object.setPrototypeOf(this, x.prototype);
|
|
29
|
+
}
|
|
30
|
+
}, M = class _ extends v {
|
|
31
|
+
name = "ReplaceBatchError";
|
|
32
|
+
applied;
|
|
33
|
+
failed;
|
|
34
|
+
constructor(t, n) {
|
|
35
|
+
super(t), this.applied = n.applied.map((r) => ({
|
|
36
|
+
start: r.start,
|
|
37
|
+
end: r.end
|
|
38
|
+
})), this.failed = n.failed.map((r) => L(r, r.message)), Object.setPrototypeOf(this, _.prototype);
|
|
28
39
|
}
|
|
29
40
|
};
|
|
30
|
-
function
|
|
31
|
-
return e instanceof
|
|
41
|
+
function Ae(e) {
|
|
42
|
+
return e instanceof M;
|
|
32
43
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
function L(e, t) {
|
|
45
|
+
const n = {
|
|
46
|
+
start: e.start,
|
|
47
|
+
end: e.end
|
|
48
|
+
};
|
|
49
|
+
return typeof t == "string" && t.trim() !== "" && (n.message = t), n;
|
|
50
|
+
}
|
|
51
|
+
function R(e) {
|
|
52
|
+
return Array.isArray(e) ? e.flatMap((t) => {
|
|
53
|
+
if (t === null || typeof t != "object") return [];
|
|
54
|
+
const { start: n, end: r, message: i } = t;
|
|
55
|
+
return typeof n != "number" || typeof r != "number" ? [] : [{
|
|
56
|
+
range: {
|
|
57
|
+
start: n,
|
|
58
|
+
end: r
|
|
59
|
+
},
|
|
60
|
+
message: i
|
|
61
|
+
}];
|
|
62
|
+
}) : [];
|
|
63
|
+
}
|
|
64
|
+
function Ce(e) {
|
|
65
|
+
return e instanceof v;
|
|
66
|
+
}
|
|
67
|
+
var O = {
|
|
68
|
+
TextLookupError: (e) => new v(e),
|
|
69
|
+
ReplaceBatchError: (e, t) => new M(e, {
|
|
70
|
+
applied: R(t.applied).map((n) => n.range),
|
|
71
|
+
failed: R(t.failed).map((n) => L(n.range, n.message))
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
function z(e) {
|
|
75
|
+
const t = e.message ?? "", n = e.name, r = typeof n == "string" && n in O ? O[n] : void 0;
|
|
36
76
|
return r ? r(t, e) : Object.assign(new Error(t), n ? { name: n } : {});
|
|
37
77
|
}
|
|
38
|
-
var
|
|
39
|
-
function
|
|
40
|
-
const t = e.indexOf(
|
|
41
|
-
return t <= 0 || t === e.length - 1 ? !1 :
|
|
78
|
+
var k = ":", B = /^[a-z][a-z0-9-]*$/;
|
|
79
|
+
function be(e) {
|
|
80
|
+
const t = e.indexOf(k);
|
|
81
|
+
return t <= 0 || t === e.length - 1 ? !1 : B.test(e.slice(0, t));
|
|
42
82
|
}
|
|
43
|
-
function
|
|
83
|
+
function Se(e, t) {
|
|
44
84
|
const n = e.trim().toLowerCase(), r = t.trim();
|
|
45
|
-
if (!
|
|
85
|
+
if (!B.test(n)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
|
|
46
86
|
if (r.length === 0) throw new Error("Invalid document reference: the document id is empty.");
|
|
47
|
-
const i = `${n}${
|
|
87
|
+
const i = `${n}${k}`;
|
|
48
88
|
return r.startsWith(i) ? r : `${i}${r}`;
|
|
49
89
|
}
|
|
50
|
-
var
|
|
90
|
+
var W = class extends Promise {
|
|
51
91
|
static get [Symbol.species]() {
|
|
52
92
|
return Promise;
|
|
53
93
|
}
|
|
@@ -60,16 +100,16 @@ var j = class extends Promise {
|
|
|
60
100
|
t = r, n = i, e(r, i);
|
|
61
101
|
}), this.resolve = t, this.reject = n;
|
|
62
102
|
}
|
|
63
|
-
},
|
|
64
|
-
function
|
|
65
|
-
const t = typeof e == "object" && e !== null ?
|
|
103
|
+
}, G = { timeout: 1e4 };
|
|
104
|
+
function J(e) {
|
|
105
|
+
const t = typeof e == "object" && e !== null ? Object.fromEntries(Object.getOwnPropertyNames(e).map((o) => [o, e[o]])) : {}, 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
106
|
return JSON.stringify({
|
|
67
107
|
...t,
|
|
68
108
|
message: r,
|
|
69
109
|
...a !== void 0 && { name: a }
|
|
70
110
|
});
|
|
71
111
|
}
|
|
72
|
-
var
|
|
112
|
+
var N = class {
|
|
73
113
|
promisesByID = {};
|
|
74
114
|
receiversByName = {};
|
|
75
115
|
currentID = 0;
|
|
@@ -77,7 +117,7 @@ var _ = class {
|
|
|
77
117
|
postMessage;
|
|
78
118
|
constructor(e, t) {
|
|
79
119
|
this.postMessage = e, this.config = {
|
|
80
|
-
...
|
|
120
|
+
...G,
|
|
81
121
|
...t
|
|
82
122
|
};
|
|
83
123
|
}
|
|
@@ -91,7 +131,7 @@ var _ = class {
|
|
|
91
131
|
return this.callWithOptions(e, {}, ...t);
|
|
92
132
|
}
|
|
93
133
|
callWithOptions(e, t, ...n) {
|
|
94
|
-
const r = this.currentID++, i = new
|
|
134
|
+
const r = this.currentID++, i = new W(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
|
|
95
135
|
if (r in this.promisesByID) {
|
|
96
136
|
const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);
|
|
97
137
|
i.reject(l), Reflect.deleteProperty(this.promisesByID, r);
|
|
@@ -159,7 +199,7 @@ var _ = class {
|
|
|
159
199
|
type: "error",
|
|
160
200
|
id: t,
|
|
161
201
|
name: n,
|
|
162
|
-
errorJSON:
|
|
202
|
+
errorJSON: J(a)
|
|
163
203
|
};
|
|
164
204
|
this.postMessage(o);
|
|
165
205
|
}
|
|
@@ -177,7 +217,7 @@ var _ = class {
|
|
|
177
217
|
const { promise: r, timeoutId: i } = this.promisesByID[t];
|
|
178
218
|
clearTimeout(i);
|
|
179
219
|
try {
|
|
180
|
-
const a = JSON.parse(n), o =
|
|
220
|
+
const a = JSON.parse(n), o = z(a);
|
|
181
221
|
r.reject(o);
|
|
182
222
|
} catch {
|
|
183
223
|
r.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
|
|
@@ -191,12 +231,12 @@ var _ = class {
|
|
|
191
231
|
this.promisesByID = {}, this.receiversByName = {};
|
|
192
232
|
}
|
|
193
233
|
};
|
|
194
|
-
var
|
|
234
|
+
var Y = /* @__PURE__ */ new Set(["auto", "prompt"]), I = (e, t) => {
|
|
195
235
|
const n = e[t];
|
|
196
236
|
if (!(typeof n != "string" || n.length === 0))
|
|
197
237
|
return n.slice(0, 64);
|
|
198
238
|
};
|
|
199
|
-
function
|
|
239
|
+
function X(e) {
|
|
200
240
|
if (typeof e != "object" || e === null || Array.isArray(e)) return null;
|
|
201
241
|
const t = e, n = I(t, "version"), r = I(t, "commitHash");
|
|
202
242
|
if (n === void 0 || r === void 0) return null;
|
|
@@ -204,20 +244,20 @@ function W(e) {
|
|
|
204
244
|
version: n,
|
|
205
245
|
commitHash: r
|
|
206
246
|
};
|
|
207
|
-
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled),
|
|
247
|
+
typeof t.swControlled == "boolean" && (i.swControlled = t.swControlled), Y.has(t.pwaUpdateMode) && (i.pwaUpdateMode = t.pwaUpdateMode);
|
|
208
248
|
const a = I(t, "adapterVersion");
|
|
209
249
|
return a !== void 0 && (i.adapterVersion = a), i;
|
|
210
250
|
}
|
|
211
|
-
function
|
|
251
|
+
function K(e) {
|
|
212
252
|
return typeof e != "string" || e.length === 0 ? null : e.slice(0, 64);
|
|
213
253
|
}
|
|
214
|
-
var
|
|
254
|
+
var q = class {
|
|
215
255
|
ipc;
|
|
216
256
|
sidebar;
|
|
217
257
|
targetOrigin;
|
|
218
258
|
latestHostAdapterVersion = null;
|
|
219
259
|
constructor(e, t, n = "*") {
|
|
220
|
-
this.sidebar = e || {}, this.targetOrigin = n, this.ipc = new
|
|
260
|
+
this.sidebar = e || {}, this.targetOrigin = n, this.ipc = new N((r) => {
|
|
221
261
|
window.parent.postMessage(r, this.targetOrigin);
|
|
222
262
|
}, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
|
|
223
263
|
}
|
|
@@ -276,9 +316,9 @@ var J = class {
|
|
|
276
316
|
async getInitConfig(e) {
|
|
277
317
|
const { hostAdapterVersion: t, ...n } = e ? await this.ipc.call("getInitConfig", {
|
|
278
318
|
...e,
|
|
279
|
-
adapterVersion: e.adapterVersion ?? "2.
|
|
319
|
+
adapterVersion: e.adapterVersion ?? "2.4.0"
|
|
280
320
|
}) : await this.ipc.call("getInitConfig");
|
|
281
|
-
return this.latestHostAdapterVersion =
|
|
321
|
+
return this.latestHostAdapterVersion = K(t), n;
|
|
282
322
|
}
|
|
283
323
|
getHostAdapterVersion() {
|
|
284
324
|
return this.latestHostAdapterVersion;
|
|
@@ -316,6 +356,9 @@ var J = class {
|
|
|
316
356
|
async copyToClipboard(e) {
|
|
317
357
|
await this.ipc.call("copyToClipboard", e);
|
|
318
358
|
}
|
|
359
|
+
async addComment(e, t = null) {
|
|
360
|
+
await this.ipc.call("addComment", e, t);
|
|
361
|
+
}
|
|
319
362
|
async onIntegrationSettingsChange(e, t) {
|
|
320
363
|
await this.ipc.call("onIntegrationSettingsChange", e, t);
|
|
321
364
|
}
|
|
@@ -338,10 +381,10 @@ var J = class {
|
|
|
338
381
|
destroy() {
|
|
339
382
|
window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
340
383
|
}
|
|
341
|
-
},
|
|
384
|
+
}, we = class {
|
|
342
385
|
ipcAdapter;
|
|
343
386
|
constructor(e, t, n) {
|
|
344
|
-
this.ipcAdapter = new
|
|
387
|
+
this.ipcAdapter = new q(e, t, n);
|
|
345
388
|
}
|
|
346
389
|
destroy() {
|
|
347
390
|
this.ipcAdapter.destroy();
|
|
@@ -385,6 +428,9 @@ var J = class {
|
|
|
385
428
|
copyToClipboard(e) {
|
|
386
429
|
return this.ipcAdapter.copyToClipboard(e);
|
|
387
430
|
}
|
|
431
|
+
addComment(e, t = null) {
|
|
432
|
+
return this.ipcAdapter.addComment(e, t);
|
|
433
|
+
}
|
|
388
434
|
onIntegrationSettingsChange(e, t) {
|
|
389
435
|
return this.ipcAdapter.onIntegrationSettingsChange(e, t);
|
|
390
436
|
}
|
|
@@ -397,7 +443,7 @@ var J = class {
|
|
|
397
443
|
getTargetOrigin() {
|
|
398
444
|
return this.ipcAdapter.getTargetOrigin();
|
|
399
445
|
}
|
|
400
|
-
},
|
|
446
|
+
}, Z = class {
|
|
401
447
|
ipc;
|
|
402
448
|
plugin;
|
|
403
449
|
iframe;
|
|
@@ -405,7 +451,7 @@ var J = class {
|
|
|
405
451
|
targetOrigin;
|
|
406
452
|
latestSidebarBuildInfo = null;
|
|
407
453
|
constructor(e, t, n, r, i = "*") {
|
|
408
|
-
this.plugin = e, this.iframe = t, this.window = n ?? window, this.targetOrigin = i, this.ipc = new
|
|
454
|
+
this.plugin = e, this.iframe = t, this.window = n ?? window, this.targetOrigin = i, this.ipc = new N((a) => {
|
|
409
455
|
this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
|
|
410
456
|
}, r), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
|
|
411
457
|
}
|
|
@@ -415,10 +461,10 @@ var J = class {
|
|
|
415
461
|
};
|
|
416
462
|
registerReceivers() {
|
|
417
463
|
if (this.ipc.receive("getInitConfig", async (e) => {
|
|
418
|
-
const t =
|
|
464
|
+
const t = X(e);
|
|
419
465
|
return this.latestSidebarBuildInfo = t, {
|
|
420
466
|
...await this.plugin.getInitConfig(t ?? void 0),
|
|
421
|
-
hostAdapterVersion:
|
|
467
|
+
hostAdapterVersion: V
|
|
422
468
|
};
|
|
423
469
|
}), 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) => {
|
|
424
470
|
await this.plugin.replaceContent(e, t, typeof n == "string" ? n : null);
|
|
@@ -460,6 +506,12 @@ var J = class {
|
|
|
460
506
|
await e(t);
|
|
461
507
|
});
|
|
462
508
|
}
|
|
509
|
+
if (this.plugin.addComment) {
|
|
510
|
+
const e = this.plugin.addComment;
|
|
511
|
+
this.ipc.receive("addComment", async (t, n) => {
|
|
512
|
+
await e(t, typeof n == "string" ? n : null);
|
|
513
|
+
});
|
|
514
|
+
}
|
|
463
515
|
if (this.plugin.onIntegrationSettingsChange) {
|
|
464
516
|
const e = this.plugin.onIntegrationSettingsChange;
|
|
465
517
|
this.ipc.receive("onIntegrationSettingsChange", async (t, n) => {
|
|
@@ -500,10 +552,10 @@ var J = class {
|
|
|
500
552
|
destroy() {
|
|
501
553
|
this.window.removeEventListener("message", this.handleMessage), this.ipc.destroy();
|
|
502
554
|
}
|
|
503
|
-
},
|
|
555
|
+
}, Q = class {
|
|
504
556
|
ipcAdapter;
|
|
505
557
|
constructor(e, t, n) {
|
|
506
|
-
this.ipcAdapter = new
|
|
558
|
+
this.ipcAdapter = new Z(e, t, n?.win, n?.config, n?.targetOrigin);
|
|
507
559
|
}
|
|
508
560
|
destroy() {
|
|
509
561
|
this.ipcAdapter.destroy();
|
|
@@ -538,7 +590,7 @@ var J = class {
|
|
|
538
590
|
configure(e) {
|
|
539
591
|
this.ipcAdapter.configure(e);
|
|
540
592
|
}
|
|
541
|
-
},
|
|
593
|
+
}, ee = `
|
|
542
594
|
<div class="sidebar-load-overlay-card">
|
|
543
595
|
<div class="sidebar-load-overlay-title">Sidebar failed to load</div>
|
|
544
596
|
<div class="sidebar-load-overlay-description">Check your connection or try again.</div>
|
|
@@ -559,16 +611,16 @@ var J = class {
|
|
|
559
611
|
<span>Retry</span>
|
|
560
612
|
</button>
|
|
561
613
|
</div>
|
|
562
|
-
`,
|
|
614
|
+
`, te = () => {
|
|
563
615
|
const e = document.createElement("div");
|
|
564
|
-
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML =
|
|
616
|
+
e.className = "sidebar-load-overlay", e.style.display = "none", e.innerHTML = ee;
|
|
565
617
|
const t = e.querySelector(".sidebar-load-overlay-button");
|
|
566
618
|
if (!t) throw new Error("Missing retry button in load overlay template.");
|
|
567
619
|
return {
|
|
568
620
|
overlay: e,
|
|
569
621
|
button: t
|
|
570
622
|
};
|
|
571
|
-
},
|
|
623
|
+
}, T = "markupai-sidebar-load-overlay-styles", ne = `
|
|
572
624
|
:root {
|
|
573
625
|
--background: #f5f5f4;
|
|
574
626
|
--foreground: #333332;
|
|
@@ -660,21 +712,21 @@ var J = class {
|
|
|
660
712
|
box-shadow: 0 0 0 2px
|
|
661
713
|
color-mix(in srgb, var(--accent, #ef4640) 60%, transparent);
|
|
662
714
|
}
|
|
663
|
-
`,
|
|
715
|
+
`, re = (e) => {
|
|
664
716
|
const t = e ?? document;
|
|
665
|
-
if (t.getElementById(
|
|
717
|
+
if (t.getElementById(T)) return;
|
|
666
718
|
const n = t.createElement("style");
|
|
667
|
-
n.id =
|
|
668
|
-
},
|
|
669
|
-
|
|
670
|
-
const { sidebarUrl: r, targetOrigin: i, timeoutMs: a =
|
|
719
|
+
n.id = T, n.textContent = ne, t.head.appendChild(n);
|
|
720
|
+
}, ie = 8e3, ae = 12e3, oe = (e, t, n = {}) => {
|
|
721
|
+
re(e.ownerDocument);
|
|
722
|
+
const { sidebarUrl: r, targetOrigin: i, timeoutMs: a = ie, retryIntervalMs: o = ae, messageListenWindow: s } = n, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, j = () => {
|
|
671
723
|
if (i) return i;
|
|
672
724
|
try {
|
|
673
725
|
return new URL(p()).origin;
|
|
674
726
|
} catch {
|
|
675
727
|
return "*";
|
|
676
728
|
}
|
|
677
|
-
}, { overlay: y, button:
|
|
729
|
+
}, { overlay: y, button: A } = te();
|
|
678
730
|
e.appendChild(y);
|
|
679
731
|
let u = !1, h, d;
|
|
680
732
|
const g = (c) => {
|
|
@@ -683,45 +735,45 @@ var J = class {
|
|
|
683
735
|
g(!1);
|
|
684
736
|
const f = () => {
|
|
685
737
|
h && (globalThis.clearTimeout(h), h = void 0);
|
|
686
|
-
},
|
|
738
|
+
}, C = () => {
|
|
687
739
|
f(), h = globalThis.setTimeout(() => {
|
|
688
740
|
u || g(!0);
|
|
689
741
|
}, a);
|
|
690
|
-
},
|
|
742
|
+
}, b = (c) => {
|
|
691
743
|
const m = c?.preserveOverlay ?? !0;
|
|
692
|
-
u = !1, m || g(!1), t.src = p(),
|
|
693
|
-
},
|
|
744
|
+
u = !1, m || g(!1), t.src = p(), C();
|
|
745
|
+
}, F = () => {
|
|
694
746
|
d || o <= 0 || (d = globalThis.setInterval(() => {
|
|
695
|
-
u ||
|
|
747
|
+
u || b({ preserveOverlay: !0 });
|
|
696
748
|
}, o));
|
|
697
|
-
},
|
|
749
|
+
}, S = () => {
|
|
698
750
|
d && (globalThis.clearInterval(d), d = void 0);
|
|
699
|
-
},
|
|
751
|
+
}, w = (c) => {
|
|
700
752
|
if (!t.contentWindow || c.source !== t.contentWindow) return;
|
|
701
|
-
const m =
|
|
702
|
-
m !== "*" && c.origin !== m || (u = !0, f(),
|
|
703
|
-
}, w = () => {
|
|
704
|
-
f(), g(!0);
|
|
753
|
+
const m = j();
|
|
754
|
+
m !== "*" && c.origin !== m || (u = !0, f(), S(), g(!1));
|
|
705
755
|
}, P = () => {
|
|
706
|
-
|
|
756
|
+
f(), g(!0);
|
|
757
|
+
}, E = () => {
|
|
758
|
+
b();
|
|
707
759
|
};
|
|
708
|
-
return
|
|
709
|
-
f(),
|
|
760
|
+
return A.addEventListener("click", E), t.addEventListener("error", P), l.addEventListener("message", w), C(), F(), () => {
|
|
761
|
+
f(), S(), t.removeEventListener("error", P), l.removeEventListener("message", w), A.removeEventListener("click", E), y.remove();
|
|
710
762
|
};
|
|
711
|
-
},
|
|
712
|
-
function
|
|
763
|
+
}, se = "Markup AI Sidebar", le = "clipboard-read; clipboard-write", Pe = "markupai.sidebarNextGen.overrideUrl", Ee = "https://sidebar.markup.ai/";
|
|
764
|
+
function Re(e) {
|
|
713
765
|
try {
|
|
714
766
|
return "localStorage" in globalThis && globalThis.localStorage.getItem("markupai.sidebarNextGen.overrideUrl")?.trim() || e;
|
|
715
767
|
} catch {
|
|
716
768
|
return e;
|
|
717
769
|
}
|
|
718
770
|
}
|
|
719
|
-
var
|
|
720
|
-
function
|
|
771
|
+
var ce = "markupai.sidebarNextGen.authOverride";
|
|
772
|
+
function Oe(e, t) {
|
|
721
773
|
if (!t) return e;
|
|
722
774
|
try {
|
|
723
775
|
if (!("localStorage" in globalThis)) return e;
|
|
724
|
-
const n = globalThis.localStorage.getItem(
|
|
776
|
+
const n = globalThis.localStorage.getItem(ce)?.trim();
|
|
725
777
|
if (!n) return e;
|
|
726
778
|
const r = JSON.parse(n);
|
|
727
779
|
return r !== null && typeof r == "object" && "type" in r && (r.type === "mediation" || r.type === "popup") ? r : e;
|
|
@@ -729,17 +781,17 @@ function Se(e, t) {
|
|
|
729
781
|
return e;
|
|
730
782
|
}
|
|
731
783
|
}
|
|
732
|
-
function
|
|
784
|
+
function Te(e, t) {
|
|
733
785
|
try {
|
|
734
786
|
return new URL(e).origin;
|
|
735
787
|
} catch (n) {
|
|
736
788
|
return t?.onInvalidUrl?.(e, n), "*";
|
|
737
789
|
}
|
|
738
790
|
}
|
|
739
|
-
function
|
|
791
|
+
function De(e, t = "Expected SidebarAdapter from createSidebarHost") {
|
|
740
792
|
if (e.adapter === null) throw new Error(t);
|
|
741
793
|
}
|
|
742
|
-
function
|
|
794
|
+
function de(e) {
|
|
743
795
|
const { iframe: t, iframeMount: n } = e;
|
|
744
796
|
if (t !== void 0 && n !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
|
|
745
797
|
if (t !== void 0) return {
|
|
@@ -747,18 +799,18 @@ function oe(e) {
|
|
|
747
799
|
removeMountedIframe: null
|
|
748
800
|
};
|
|
749
801
|
if (n === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
|
|
750
|
-
const { container: r, src: i, allow: a =
|
|
751
|
-
return o.title =
|
|
802
|
+
const { container: r, src: i, allow: a = le } = n, o = document.createElement("iframe");
|
|
803
|
+
return o.title = se, o.src = i, a && o.setAttribute("allow", a), r.appendChild(o), {
|
|
752
804
|
iframe: o,
|
|
753
805
|
removeMountedIframe: () => {
|
|
754
806
|
o.remove();
|
|
755
807
|
}
|
|
756
808
|
};
|
|
757
809
|
}
|
|
758
|
-
function
|
|
759
|
-
const { plugin: t, loadOverlayContainer: n, loadOverlayOptions: r, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } =
|
|
810
|
+
function xe(e) {
|
|
811
|
+
const { plugin: t, loadOverlayContainer: n, loadOverlayOptions: r, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } = de(e), s = n !== void 0 ? oe(n, a, r ?? {}) : null;
|
|
760
812
|
if (t !== void 0) {
|
|
761
|
-
const l = new
|
|
813
|
+
const l = new Q(t, a, i);
|
|
762
814
|
return {
|
|
763
815
|
iframe: a,
|
|
764
816
|
adapter: l,
|
|
@@ -775,14 +827,14 @@ function Ee(e) {
|
|
|
775
827
|
}
|
|
776
828
|
};
|
|
777
829
|
}
|
|
778
|
-
var
|
|
779
|
-
function
|
|
830
|
+
var H = "sidebarContainer", D = "markupai-sidebar-host-shell-styles";
|
|
831
|
+
function U(e) {
|
|
780
832
|
if (typeof CSS < "u" && typeof CSS.escape == "function") return CSS.escape(e);
|
|
781
833
|
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)})`);
|
|
782
834
|
return e;
|
|
783
835
|
}
|
|
784
|
-
function
|
|
785
|
-
const t =
|
|
836
|
+
function $(e = H) {
|
|
837
|
+
const t = U(e);
|
|
786
838
|
return `
|
|
787
839
|
html {
|
|
788
840
|
height: 100%;
|
|
@@ -807,21 +859,21 @@ body {
|
|
|
807
859
|
}
|
|
808
860
|
`.trim();
|
|
809
861
|
}
|
|
810
|
-
var
|
|
811
|
-
function
|
|
862
|
+
var Me = $();
|
|
863
|
+
function ge(e) {
|
|
812
864
|
return e instanceof Document ? e : e.ownerDocument;
|
|
813
865
|
}
|
|
814
|
-
function
|
|
815
|
-
if (!t || e.getElementById(
|
|
866
|
+
function pe(e, t, n) {
|
|
867
|
+
if (!t || e.getElementById(D)) return;
|
|
816
868
|
const r = e.createElement("style");
|
|
817
|
-
r.id =
|
|
869
|
+
r.id = D, r.textContent = $(n), e.head.appendChild(r);
|
|
818
870
|
}
|
|
819
|
-
function
|
|
820
|
-
const { root: t = typeof document < "u" ? document : void 0, containerId: n =
|
|
871
|
+
function _e(e) {
|
|
872
|
+
const { root: t = typeof document < "u" ? document : void 0, containerId: n = H, includeDefaultStyles: r = !0 } = e ?? {};
|
|
821
873
|
if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
|
|
822
|
-
const i =
|
|
823
|
-
|
|
824
|
-
const a = t instanceof Document ? i.getElementById(n) : t.querySelector(`#${
|
|
874
|
+
const i = ge(t);
|
|
875
|
+
pe(i, r, n);
|
|
876
|
+
const a = t instanceof Document ? i.getElementById(n) : t.querySelector(`#${U(n)}`);
|
|
825
877
|
if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
|
|
826
878
|
if (!(t instanceof Document)) {
|
|
827
879
|
const s = i.createElement("div");
|
|
@@ -830,18 +882,18 @@ function Te(e) {
|
|
|
830
882
|
const o = i.createElement("div");
|
|
831
883
|
return o.id = n, i.body.appendChild(o), o;
|
|
832
884
|
}
|
|
833
|
-
function
|
|
885
|
+
function ue() {
|
|
834
886
|
return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
|
|
835
887
|
}
|
|
836
|
-
function
|
|
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 ?
|
|
888
|
+
function Le(e) {
|
|
889
|
+
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 ? ue() : "", n].filter((p) => p.trim().length > 0).join(`
|
|
838
890
|
`);
|
|
839
891
|
return `<!DOCTYPE html>
|
|
840
892
|
<html ${o}>
|
|
841
893
|
<head>
|
|
842
894
|
<base target="_top" />
|
|
843
895
|
<meta charset="UTF-8" />
|
|
844
|
-
<title>${
|
|
896
|
+
<title>${he(t)}</title>${l ? `
|
|
845
897
|
${l}` : ""}
|
|
846
898
|
</head>
|
|
847
899
|
<body ${s}>
|
|
@@ -850,44 +902,46 @@ ${l}` : ""}
|
|
|
850
902
|
</html>
|
|
851
903
|
`;
|
|
852
904
|
}
|
|
853
|
-
function
|
|
905
|
+
function he(e) {
|
|
854
906
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
855
907
|
}
|
|
856
908
|
export {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
909
|
+
V as ADAPTER_VERSION,
|
|
910
|
+
ce as AUTH_CONFIG_OVERRIDE_STORAGE_KEY,
|
|
911
|
+
G as DEFAULT_IPC_CONFIG,
|
|
912
|
+
ye as DEFAULT_SIDEBAR_CONFIG,
|
|
913
|
+
W as DeferredPromise,
|
|
914
|
+
N as IPCCore,
|
|
915
|
+
fe as MimeType,
|
|
916
|
+
we as PluginAdapter,
|
|
917
|
+
q as PluginIPCAdapter,
|
|
918
|
+
M as ReplaceBatchError,
|
|
919
|
+
Ee as SIDEBAR_DEFAULT_PRODUCTION_BASE_URL,
|
|
920
|
+
H as SIDEBAR_HOST_CONTAINER_ID,
|
|
921
|
+
Me as SIDEBAR_HOST_SHELL_CSS,
|
|
922
|
+
le as SIDEBAR_IFRAME_DEFAULT_ALLOW,
|
|
923
|
+
se as SIDEBAR_IFRAME_DEFAULT_TITLE,
|
|
924
|
+
Pe as SIDEBAR_URL_OVERRIDE_STORAGE_KEY,
|
|
925
|
+
Q as SidebarAdapter,
|
|
926
|
+
Z as SidebarIPCAdapter,
|
|
927
|
+
me as TEXT_MIME_TYPES,
|
|
928
|
+
v as TextLookupError,
|
|
929
|
+
De as assertSidebarHostAdapter,
|
|
930
|
+
Se as buildDocumentReference,
|
|
931
|
+
Le as buildSidebarHostHtmlDocument,
|
|
932
|
+
$ as buildSidebarHostShellCss,
|
|
933
|
+
ue as buildSidebarPluginHostHeadInnerHtml,
|
|
934
|
+
xe as createSidebarHost,
|
|
935
|
+
_e as ensureSidebarHostShell,
|
|
936
|
+
Oe as getAuthConfigWithOverride,
|
|
937
|
+
Re as getSidebarBaseUrlWithOverride,
|
|
938
|
+
O as ipcErrorReconstructors,
|
|
939
|
+
be as isDocumentReference,
|
|
940
|
+
ve as isIntegrationSettingField,
|
|
941
|
+
Ie as isIntegrationSettingsSchema,
|
|
942
|
+
Ae as isReplaceBatchError,
|
|
943
|
+
Ce as isTextLookupError,
|
|
944
|
+
z as reconstructError,
|
|
945
|
+
oe as setupSidebarLoadOverlay,
|
|
946
|
+
Te as sidebarPostMessageTargetOrigin
|
|
893
947
|
};
|