@panda-lingo/goldendict 0.1.0 → 0.1.2
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 +48 -0
- package/dist/element/goldendict-view.d.ts +8 -2
- package/dist/element/goldendict-view.d.ts.map +1 -1
- package/dist/index.js +357 -165
- package/dist/index.js.map +1 -1
- package/dist/renderer/article-document.d.ts +2 -1
- package/dist/renderer/article-document.d.ts.map +1 -1
- package/dist/styles/responsive.d.ts +6 -0
- package/dist/styles/responsive.d.ts.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
class
|
|
1
|
+
class q extends Error {
|
|
2
2
|
status;
|
|
3
3
|
body;
|
|
4
4
|
constructor(e, o, t) {
|
|
5
5
|
super(e), this.name = "DictionaryApiError", this.status = o, this.body = t;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function L(i) {
|
|
9
9
|
const e = i.trim() || "/api/v1";
|
|
10
10
|
return e.length > 1 ? e.replace(/\/+$/, "") : e;
|
|
11
11
|
}
|
|
@@ -25,7 +25,7 @@ function y(i) {
|
|
|
25
25
|
...i.wordCount !== void 0 ? { wordCount: i.wordCount } : {}
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
async function
|
|
28
|
+
async function B(i) {
|
|
29
29
|
const e = await i.text();
|
|
30
30
|
if (e)
|
|
31
31
|
try {
|
|
@@ -40,7 +40,7 @@ class v {
|
|
|
40
40
|
headers;
|
|
41
41
|
credentials;
|
|
42
42
|
constructor(e = {}) {
|
|
43
|
-
this.baseUrl =
|
|
43
|
+
this.baseUrl = L(e.baseUrl ?? "/api/v1");
|
|
44
44
|
const o = e.fetch ?? globalThis.fetch;
|
|
45
45
|
if (!o)
|
|
46
46
|
throw new TypeError("A fetch implementation is required");
|
|
@@ -94,12 +94,12 @@ class v {
|
|
|
94
94
|
...this.headers,
|
|
95
95
|
...o.headers
|
|
96
96
|
}
|
|
97
|
-
}), n = await
|
|
97
|
+
}), n = await B(t);
|
|
98
98
|
if (!t.ok) {
|
|
99
99
|
let a = t.statusText;
|
|
100
100
|
throw typeof n == "object" && n && ("message" in n ? a = String(n.message) : "error" in n && typeof n.error == "object" && n.error && "message" in n.error && (a = String(
|
|
101
101
|
n.error.message
|
|
102
|
-
))), new
|
|
102
|
+
))), new q(
|
|
103
103
|
a || `Dictionary request failed (${t.status})`,
|
|
104
104
|
t.status,
|
|
105
105
|
n
|
|
@@ -108,7 +108,7 @@ class v {
|
|
|
108
108
|
return n;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
const
|
|
111
|
+
const M = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
112
112
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
113
113
|
|
|
114
114
|
<svg
|
|
@@ -154,7 +154,7 @@ const B = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
154
154
|
sodipodi:nodetypes="cccc" />
|
|
155
155
|
</g>
|
|
156
156
|
</svg>
|
|
157
|
-
`, U = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfmAxMKDTHgIis/AAAAwUlEQVQoz33RsUtCcRTF8U+vJ8/RCAKHdEoc+isachBcMhranQQXt/YIGmxrLAgRac/JFsP+jVqaHVvkuTy0V/08dzzfC/eew2+1FWxRz1KCG42/ZuxeKpWgaeYub++ZStcAsRcddgwdgCPVDC1qOHat7F2dz2xvMwluXeDBWQgomeDSIAp8s1DEh8PIdqUhoOQbFV8h4MojTsxjb9mbNZW13bIwtu9U72dQr7mgeNIPR10z9CwKlzXStfv/eef5uldwrDr7rieveQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wMy0xOVQxMDoxMzo0OSswMDowMH0jItoAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDMtMTlUMTA6MTM6NDkrMDA6MDAMfppmAAAAAElFTkSuQmCC",
|
|
157
|
+
`, U = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfmAxMKDTHgIis/AAAAwUlEQVQoz33RsUtCcRTF8U+vJ8/RCAKHdEoc+isachBcMhranQQXt/YIGmxrLAgRac/JFsP+jVqaHVvkuTy0V/08dzzfC/eew2+1FWxRz1KCG42/ZuxeKpWgaeYub++ZStcAsRcddgwdgCPVDC1qOHat7F2dz2xvMwluXeDBWQgomeDSIAp8s1DEh8PIdqUhoOQbFV8h4MojTsxjb9mbNZW13bIwtu9U72dQr7mgeNIPR10z9CwKlzXStfv/eef5uldwrDr7rieveQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wMy0xOVQxMDoxMzo0OSswMDowMH0jItoAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDMtMTlUMTA6MTM6NDkrMDA6MDAMfppmAAAAAElFTkSuQmCC", $ = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
158
158
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
159
159
|
|
|
160
160
|
<svg
|
|
@@ -196,7 +196,7 @@ const B = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
196
196
|
d="m 9.8109427,14.803704 8.9999993,-8.9999986 -17.9999995,2e-7 z m 0,-4.225584 -4.7744158,-4.7744144 9.5488291,-2e-7 z"
|
|
197
197
|
id="rect1"
|
|
198
198
|
sodipodi:nodetypes="cccccccc" /></g></svg>
|
|
199
|
-
`,
|
|
199
|
+
`, F = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
200
200
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
201
201
|
|
|
202
202
|
<svg
|
|
@@ -311,7 +311,7 @@ const B = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
311
311
|
x="1.1215118e-09"
|
|
312
312
|
y="4.9718442"
|
|
313
313
|
ry="0.64957041" /></svg>
|
|
314
|
-
`,
|
|
314
|
+
`, R = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAATrAAAE6wHYKlsNAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAcRJREFUOI2lkztvE0EQgL8Z7/rB2T5fCixhQQc00FAjJCRkiTYV/JH0adIgfgJVGn4CKRBUSIjCHYiOBimK7KA4ORw/dofC3Ck2dhpGGu1r5pvZmV0xM/5HXDEZDAbf2u12BkiM0UIImBlmRoyxHBeLBaPRaNzv9++tAJIkyVS1673HzBCRUtfFzEo/d/VAVRERzvf2uDw6AqB6eMhlt1va9Hq9FWgJiDEiIqgqcTwmnp4CUPeearu9EmRjDYp7qiqVNEV3dgCYx8hlniMimBlZlm0GFN0QERoHB7j9/bIGVUDiHCrVfzLQqwDvPSLCZDIhz3MuLi6YTye4eY58fkOnUbkeUERMkoRWq0WaptRqDaYfXvPr3StmP75cX4PZbIb3HoDx6TmttImveZoPn9N+0KfWvbsdYGY45xARvn76zvu3H8m6GS/2dpnefLRsb4Bb2wAhBJxbLoc/hwCcDc9QqVCvuzLy+uPa2IUnu4+p36hz5/5tGkmdxWKBc45Op0MIYXsNClAzTXj28imquqKFzUbA8fHxbzMbi0glhKBmpsuEREQkqmpU1Sgi8eTkJC/8ZNN3FhEHNIHG360pkJvZdN32D0SOwDehr1HXAAAAAElFTkSuQmCC", N = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
315
315
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
316
316
|
|
|
317
317
|
<svg
|
|
@@ -399,7 +399,7 @@ const B = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
399
399
|
d="m 14.310942,9.9316324 -8.9999991,-8.9999982 2e-7,17.9999978 z m -4.225584,0 -4.7744149,4.7744156 -2e-7,-9.5488279 z"
|
|
400
400
|
id="rect1"
|
|
401
401
|
sodipodi:nodetypes="cccccccc" /></g></svg>
|
|
402
|
-
`,
|
|
402
|
+
`, O = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
403
403
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
404
404
|
|
|
405
405
|
<svg
|
|
@@ -515,7 +515,7 @@ const B = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
515
515
|
x="1.1215118e-09"
|
|
516
516
|
y="4.9718442"
|
|
517
517
|
ry="0.64957041" /></svg>
|
|
518
|
-
`,
|
|
518
|
+
`, H = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
519
519
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
520
520
|
|
|
521
521
|
<svg
|
|
@@ -575,7 +575,7 @@ const B = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
575
575
|
id="path2"
|
|
576
576
|
style="fill:url(#radialGradient2)" />
|
|
577
577
|
</svg>
|
|
578
|
-
`,
|
|
578
|
+
`, W = `<?xml version="1.0" encoding="UTF-8"?>
|
|
579
579
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
580
580
|
<svg width="32" height="32" version="1.1" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
|
581
581
|
<defs>
|
|
@@ -699,7 +699,7 @@ const B = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
699
699
|
transform="matrix(0.71827705,0,0,0.71827705,-3.1349141,-8.3199121)"
|
|
700
700
|
style="fill:url(#linearGradient9);fill-opacity:1;stroke:none" />
|
|
701
701
|
</svg>
|
|
702
|
-
`,
|
|
702
|
+
`, Z = `<svg fill="none" stroke="white" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
703
703
|
<defs>
|
|
704
704
|
<linearGradient id="videoGrad" y2="100%">
|
|
705
705
|
<stop stop-color="#FF5F6D" offset="0"/>
|
|
@@ -709,7 +709,7 @@ const B = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
709
709
|
<rect x="2" y="5" width="20" height="14" rx="2" ry="2" fill="url(#videoGrad)" stroke="none"/>
|
|
710
710
|
<polygon points="10 9 15 12 10 15" fill="#fff"/>
|
|
711
711
|
</svg>
|
|
712
|
-
`,
|
|
712
|
+
`, Q = `<svg fill="none" stroke="white" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
713
713
|
<defs>
|
|
714
714
|
<linearGradient id="warnGrad" y2="100%">
|
|
715
715
|
<stop stop-color="#FF5F6D" offset="0"/>
|
|
@@ -724,31 +724,31 @@ const B = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
724
724
|
function s(i) {
|
|
725
725
|
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`;
|
|
726
726
|
}
|
|
727
|
-
const
|
|
728
|
-
"arrow.svg": s(
|
|
727
|
+
const u = {
|
|
728
|
+
"arrow.svg": s(M),
|
|
729
729
|
"audio.png": U,
|
|
730
|
-
"collapse_article.svg": s(
|
|
731
|
-
"collapse_article_hovered.svg": s(
|
|
730
|
+
"collapse_article.svg": s(F),
|
|
731
|
+
"collapse_article_hovered.svg": s($),
|
|
732
732
|
"collapse_opt.svg": s(P),
|
|
733
|
-
"document.png":
|
|
734
|
-
"downarrow.svg": s(
|
|
735
|
-
"expand_article.svg": s(
|
|
733
|
+
"document.png": R,
|
|
734
|
+
"downarrow.svg": s(N),
|
|
735
|
+
"expand_article.svg": s(O),
|
|
736
736
|
"expand_article_hovered.svg": s(G),
|
|
737
737
|
"expand_opt.svg": s(V),
|
|
738
|
-
"old-arrow.svg": s(
|
|
739
|
-
"old-downarrow.svg": s(
|
|
738
|
+
"old-arrow.svg": s(H),
|
|
739
|
+
"old-downarrow.svg": s(W),
|
|
740
740
|
"playsound.svg": s(j),
|
|
741
|
-
"video.svg": s(
|
|
742
|
-
"warning.svg": s(
|
|
741
|
+
"video.svg": s(Z),
|
|
742
|
+
"warning.svg": s(Q)
|
|
743
743
|
};
|
|
744
744
|
function A(i) {
|
|
745
745
|
const e = /^qrc:\/{2,3}(?:icons\/)?([^?#]+)(?:[?#].*)?$/i.exec(i);
|
|
746
|
-
return e?.[1] ?
|
|
746
|
+
return e?.[1] ? u[e[1]] : void 0;
|
|
747
747
|
}
|
|
748
748
|
function z(i) {
|
|
749
749
|
return i.replace(
|
|
750
750
|
/qrc:\/{2,3}icons\/([a-z0-9_.-]+)/gi,
|
|
751
|
-
(e, o) =>
|
|
751
|
+
(e, o) => u[o] ?? e
|
|
752
752
|
);
|
|
753
753
|
}
|
|
754
754
|
const h = { "article-style.css": `/******** Global, non-dictionary-specific classes ***********/
|
|
@@ -7883,25 +7883,151 @@ a:hover {
|
|
|
7883
7883
|
code::selection {
|
|
7884
7884
|
background: #333333;
|
|
7885
7885
|
}
|
|
7886
|
-
` },
|
|
7886
|
+
` }, X = h["article-style.css"], K = h["article-style-print.css"], J = h["article-style-st-babylon.css"], Y = h["article-style-st-classic.css"], ee = h["article-style-st-lingoes-blue.css"], ie = h["article-style-st-lingoes.css"], te = h["article-style-st-lingvo.css"], oe = h["article-style-st-modern.css"], ne = {
|
|
7887
7887
|
default: "",
|
|
7888
|
-
classic:
|
|
7889
|
-
modern:
|
|
7890
|
-
lingvo:
|
|
7888
|
+
classic: Y,
|
|
7889
|
+
modern: oe,
|
|
7890
|
+
lingvo: te,
|
|
7891
7891
|
babylon: J,
|
|
7892
|
-
lingoes:
|
|
7893
|
-
"lingoes-blue":
|
|
7894
|
-
},
|
|
7895
|
-
function
|
|
7896
|
-
return z(
|
|
7897
|
-
}
|
|
7898
|
-
const
|
|
7892
|
+
lingoes: ie,
|
|
7893
|
+
"lingoes-blue": ee
|
|
7894
|
+
}, re = z(X), ae = z(K);
|
|
7895
|
+
function de(i = "default") {
|
|
7896
|
+
return z(ne[i]);
|
|
7897
|
+
}
|
|
7898
|
+
const le = `
|
|
7899
|
+
:root {
|
|
7900
|
+
--gd-responsive-gutter: clamp(0.5rem, 2.5vw, 1rem);
|
|
7901
|
+
}
|
|
7902
|
+
|
|
7903
|
+
html,
|
|
7904
|
+
body {
|
|
7905
|
+
box-sizing: border-box;
|
|
7906
|
+
inline-size: 100%;
|
|
7907
|
+
min-inline-size: 0;
|
|
7908
|
+
max-inline-size: 100%;
|
|
7909
|
+
}
|
|
7910
|
+
|
|
7911
|
+
*,
|
|
7912
|
+
*::before,
|
|
7913
|
+
*::after {
|
|
7914
|
+
box-sizing: inherit;
|
|
7915
|
+
}
|
|
7916
|
+
|
|
7917
|
+
body {
|
|
7918
|
+
margin: 0;
|
|
7919
|
+
padding: var(--gd-responsive-gutter);
|
|
7920
|
+
overflow-wrap: break-word;
|
|
7921
|
+
}
|
|
7922
|
+
|
|
7923
|
+
.gdarticle,
|
|
7924
|
+
.gdarticlebody,
|
|
7925
|
+
.gdstemmedsuggestion {
|
|
7926
|
+
min-inline-size: 0;
|
|
7927
|
+
max-inline-size: 100%;
|
|
7928
|
+
}
|
|
7929
|
+
|
|
7930
|
+
.gddictname {
|
|
7931
|
+
display: flex;
|
|
7932
|
+
align-items: center;
|
|
7933
|
+
gap: 0.4rem;
|
|
7934
|
+
max-inline-size: 100%;
|
|
7935
|
+
}
|
|
7936
|
+
|
|
7937
|
+
.gddicticon,
|
|
7938
|
+
.collapse_expand_area {
|
|
7939
|
+
flex: 0 0 auto;
|
|
7940
|
+
}
|
|
7941
|
+
|
|
7942
|
+
.gddicttitle {
|
|
7943
|
+
flex: 1 1 auto;
|
|
7944
|
+
min-inline-size: 0;
|
|
7945
|
+
overflow-wrap: anywhere;
|
|
7946
|
+
}
|
|
7947
|
+
|
|
7948
|
+
.collapse_expand_area {
|
|
7949
|
+
margin-inline-start: auto;
|
|
7950
|
+
}
|
|
7951
|
+
|
|
7952
|
+
.gddictname:focus-visible {
|
|
7953
|
+
outline: 2px solid var(--link-color, currentColor);
|
|
7954
|
+
outline-offset: -2px;
|
|
7955
|
+
}
|
|
7956
|
+
|
|
7957
|
+
/* Keep nested, absolutely positioned sidecar controls at their authored size. */
|
|
7958
|
+
.gdarticlebody > :where(div, section, article, aside, header, footer, figure),
|
|
7959
|
+
.gdarticlebody :where(img, picture, video, canvas, svg, iframe, object, embed),
|
|
7960
|
+
.gdarticlebody :where(pre, table) {
|
|
7961
|
+
max-inline-size: 100% !important;
|
|
7962
|
+
}
|
|
7963
|
+
|
|
7964
|
+
.gdarticlebody :where(img, video, canvas, svg) {
|
|
7965
|
+
block-size: auto !important;
|
|
7966
|
+
}
|
|
7967
|
+
|
|
7968
|
+
.gdarticlebody :where(a, p, li, dd, dt, td, th, code) {
|
|
7969
|
+
overflow-wrap: anywhere;
|
|
7970
|
+
}
|
|
7971
|
+
|
|
7972
|
+
.gdarticlebody pre {
|
|
7973
|
+
overflow-x: auto !important;
|
|
7974
|
+
overscroll-behavior-inline: contain;
|
|
7975
|
+
-webkit-overflow-scrolling: touch;
|
|
7976
|
+
}
|
|
7977
|
+
|
|
7978
|
+
.gdstemmedsuggestion_body {
|
|
7979
|
+
inline-size: auto;
|
|
7980
|
+
margin-inline: 0.75rem;
|
|
7981
|
+
}
|
|
7982
|
+
|
|
7983
|
+
.empty-space {
|
|
7984
|
+
block-size: clamp(6rem, 20vw, 15rem);
|
|
7985
|
+
}
|
|
7986
|
+
|
|
7987
|
+
@media (max-width: 64rem) {
|
|
7988
|
+
.gdarticlebody table {
|
|
7989
|
+
display: block !important;
|
|
7990
|
+
overflow-x: auto !important;
|
|
7991
|
+
overscroll-behavior-inline: contain;
|
|
7992
|
+
-webkit-overflow-scrolling: touch;
|
|
7993
|
+
}
|
|
7994
|
+
}
|
|
7995
|
+
|
|
7996
|
+
@media (max-width: 40rem) {
|
|
7997
|
+
:root {
|
|
7998
|
+
--gd-responsive-gutter: 0.5rem;
|
|
7999
|
+
}
|
|
8000
|
+
|
|
8001
|
+
.gddictname {
|
|
8002
|
+
min-block-size: 2.75rem;
|
|
8003
|
+
margin-block: 0.35rem;
|
|
8004
|
+
}
|
|
8005
|
+
|
|
8006
|
+
.gdarticlebody :where(.infobox, .navbox, .thumb, .tright, .tleft) {
|
|
8007
|
+
float: none !important;
|
|
8008
|
+
inline-size: auto !important;
|
|
8009
|
+
max-inline-size: 100% !important;
|
|
8010
|
+
margin-inline: 0 !important;
|
|
8011
|
+
}
|
|
8012
|
+
|
|
8013
|
+
.gdarticlebody .thumbinner {
|
|
8014
|
+
inline-size: 100% !important;
|
|
8015
|
+
max-inline-size: 100% !important;
|
|
8016
|
+
}
|
|
8017
|
+
}
|
|
8018
|
+
|
|
8019
|
+
@media (pointer: coarse) {
|
|
8020
|
+
.gddictname {
|
|
8021
|
+
min-block-size: 2.75rem;
|
|
8022
|
+
}
|
|
8023
|
+
}
|
|
8024
|
+
`, T = /* @__PURE__ */ new Set([
|
|
7899
8025
|
"bres",
|
|
7900
8026
|
"qrcx",
|
|
7901
8027
|
"gico",
|
|
7902
8028
|
"gdau",
|
|
7903
8029
|
"gdvideo"
|
|
7904
|
-
]),
|
|
8030
|
+
]), se = {
|
|
7905
8031
|
gdlookup: "lookup",
|
|
7906
8032
|
bword: "lookup",
|
|
7907
8033
|
entry: "lookup",
|
|
@@ -7916,8 +8042,8 @@ const T = /* @__PURE__ */ new Set([
|
|
|
7916
8042
|
gdinternal: "unsupported",
|
|
7917
8043
|
ankicard: "unsupported",
|
|
7918
8044
|
ankisearch: "unsupported"
|
|
7919
|
-
},
|
|
7920
|
-
Object.entries(
|
|
8045
|
+
}, ce = new Set(
|
|
8046
|
+
Object.entries(se).filter(([, i]) => i === "unsupported").map(([i]) => i)
|
|
7921
8047
|
);
|
|
7922
8048
|
function f(i) {
|
|
7923
8049
|
try {
|
|
@@ -7929,10 +8055,10 @@ function f(i) {
|
|
|
7929
8055
|
function I(i, e) {
|
|
7930
8056
|
return `${i.replace(/\/+$/, "")}/${e.replace(/^\/+/, "")}`;
|
|
7931
8057
|
}
|
|
7932
|
-
function
|
|
8058
|
+
function me(i) {
|
|
7933
8059
|
return i.pathname.replace(/^\/+/, "").split("/").map((e) => encodeURIComponent(f(e))).join("/");
|
|
7934
8060
|
}
|
|
7935
|
-
function
|
|
8061
|
+
function pe(i, e) {
|
|
7936
8062
|
return /^[a-z][a-z\d+.-]*:/i.test(i) || i.startsWith("//") ? i : /^[a-z][a-z\d+.-]*:/i.test(e) ? new URL(i, e.endsWith("/") ? e : `${e}/`).toString() : I(e, i);
|
|
7937
8063
|
}
|
|
7938
8064
|
function S(i) {
|
|
@@ -7940,7 +8066,7 @@ function S(i) {
|
|
|
7940
8066
|
if (e)
|
|
7941
8067
|
return e.startsWith("/") && !e.startsWith("//") && /^[a-z][a-z\d+.-]*:/i.test(i.apiBaseUrl) ? new URL(e, i.apiBaseUrl).toString() : e;
|
|
7942
8068
|
}
|
|
7943
|
-
function
|
|
8069
|
+
function p(i, e) {
|
|
7944
8070
|
const o = A(i);
|
|
7945
8071
|
if (o)
|
|
7946
8072
|
return o;
|
|
@@ -7950,22 +8076,22 @@ function m(i, e) {
|
|
|
7950
8076
|
try {
|
|
7951
8077
|
t = new URL(i);
|
|
7952
8078
|
} catch {
|
|
7953
|
-
const
|
|
7954
|
-
return
|
|
8079
|
+
const d = S(e);
|
|
8080
|
+
return d ? pe(i, d) : i;
|
|
7955
8081
|
}
|
|
7956
8082
|
const n = t.protocol.slice(0, -1).toLowerCase();
|
|
7957
8083
|
if (!T.has(n))
|
|
7958
8084
|
return i;
|
|
7959
8085
|
const a = t.hostname || e.dictionaryId;
|
|
7960
8086
|
if (n === "gico")
|
|
7961
|
-
return e.iconUrl ?
|
|
8087
|
+
return e.iconUrl ? p(e.iconUrl, {
|
|
7962
8088
|
...e,
|
|
7963
8089
|
iconUrl: void 0
|
|
7964
8090
|
}) : A("qrc:///icons/document.png") ?? "";
|
|
7965
|
-
const r =
|
|
7966
|
-
return t.hash ? `${
|
|
8091
|
+
const r = me(t), l = `${e.apiBaseUrl.replace(/\/+$/, "")}/dictionaries/${encodeURIComponent(a)}/resources`, m = I(S(e) ?? l, r);
|
|
8092
|
+
return t.hash ? `${m}${t.hash}` : m;
|
|
7967
8093
|
}
|
|
7968
|
-
function
|
|
8094
|
+
function ge(i) {
|
|
7969
8095
|
const e = /^([a-z][a-z\d+.-]*):(.*)$/i.exec(i);
|
|
7970
8096
|
if (!e)
|
|
7971
8097
|
return;
|
|
@@ -7977,8 +8103,8 @@ function me(i) {
|
|
|
7977
8103
|
const r = new URL(i);
|
|
7978
8104
|
t = r.searchParams.get("word") ?? r.pathname.replace(/^\/+/, ""), n = r.searchParams.get("gdanchor") ?? (r.hash.slice(1) || void 0), a = r.searchParams.get("dictionaries")?.split(",").filter(Boolean), !t && (o === "bword" || o === "entry") && (t = r.hostname);
|
|
7979
8105
|
} catch {
|
|
7980
|
-
const r = e[2]?.replace(/^\/{0,2}/, "") ?? "", [
|
|
7981
|
-
t =
|
|
8106
|
+
const r = e[2]?.replace(/^\/{0,2}/, "") ?? "", [l, m] = r.split("#", 2), [d, w] = (l ?? "").split("?", 2);
|
|
8107
|
+
t = d ?? "", n = new URLSearchParams(w ?? "").get("gdanchor") ?? (m || void 0);
|
|
7982
8108
|
}
|
|
7983
8109
|
return t = f(t.replace(/^\/+/, "")), t ? {
|
|
7984
8110
|
kind: "lookup",
|
|
@@ -7993,22 +8119,22 @@ function D(i, e) {
|
|
|
7993
8119
|
return { kind: "anchor", anchor: "" };
|
|
7994
8120
|
if (o.startsWith("#"))
|
|
7995
8121
|
return { kind: "anchor", anchor: f(o.slice(1)) };
|
|
7996
|
-
const t =
|
|
8122
|
+
const t = ge(o);
|
|
7997
8123
|
if (t)
|
|
7998
8124
|
return t;
|
|
7999
8125
|
const n = /^([a-z][a-z\d+.-]*):/i.exec(o)?.[1]?.toLowerCase();
|
|
8000
8126
|
if (n === "javascript" || n === "vbscript" || n === "file" || n === "data")
|
|
8001
8127
|
return { kind: "unsafe" };
|
|
8002
|
-
if (n &&
|
|
8128
|
+
if (n && ce.has(n))
|
|
8003
8129
|
return { kind: "unsafe" };
|
|
8004
8130
|
if (n && T.has(n))
|
|
8005
|
-
return { kind: n === "gdau" ? "audio" : n === "gdvideo" ? "video" : "resource", url:
|
|
8131
|
+
return { kind: n === "gdau" ? "audio" : n === "gdvideo" ? "video" : "resource", url: p(o, e) };
|
|
8006
8132
|
if (o.startsWith("//") || n === "http" || n === "https" || n === "mailto" || n === "tel")
|
|
8007
8133
|
return { kind: "external", url: o };
|
|
8008
8134
|
if (n)
|
|
8009
8135
|
return { kind: "unsafe" };
|
|
8010
8136
|
if (o.startsWith("/"))
|
|
8011
|
-
return { kind: "resource", url:
|
|
8137
|
+
return { kind: "resource", url: p(o, e) };
|
|
8012
8138
|
const [a, r] = o.split("#", 2);
|
|
8013
8139
|
return a ? {
|
|
8014
8140
|
kind: "lookup",
|
|
@@ -8016,11 +8142,11 @@ function D(i, e) {
|
|
|
8016
8142
|
...r ? { anchor: f(r) } : {}
|
|
8017
8143
|
} : { kind: "anchor", anchor: f(r ?? "") };
|
|
8018
8144
|
}
|
|
8019
|
-
const
|
|
8020
|
-
function
|
|
8145
|
+
const he = ["src", "poster", "data"];
|
|
8146
|
+
function x(i) {
|
|
8021
8147
|
return /^(?:data:|blob:|https?:|#)/i.test(i);
|
|
8022
8148
|
}
|
|
8023
|
-
function
|
|
8149
|
+
function fe(i, e, o) {
|
|
8024
8150
|
const t = [
|
|
8025
8151
|
["data-gd-audio", "audio"],
|
|
8026
8152
|
["data-gd-video", "video"],
|
|
@@ -8028,15 +8154,15 @@ function ge(i, e, o) {
|
|
|
8028
8154
|
];
|
|
8029
8155
|
for (const [a, r] of t)
|
|
8030
8156
|
if (i.hasAttribute(a)) {
|
|
8031
|
-
const
|
|
8157
|
+
const l = i.getAttribute(a)?.trim();
|
|
8032
8158
|
return {
|
|
8033
8159
|
kind: r,
|
|
8034
|
-
url:
|
|
8160
|
+
url: p(l || e, o)
|
|
8035
8161
|
};
|
|
8036
8162
|
}
|
|
8037
8163
|
const n = i.getAttribute("data-gd-action")?.trim().toLowerCase();
|
|
8038
8164
|
if (n === "audio" || n === "video" || n === "resource")
|
|
8039
|
-
return { kind: n, url:
|
|
8165
|
+
return { kind: n, url: p(e, o) };
|
|
8040
8166
|
if (i.hasAttribute("data-gd-lookup") || n === "lookup") {
|
|
8041
8167
|
const a = i.getAttribute("data-gd-lookup")?.trim();
|
|
8042
8168
|
if (a && a !== "true" && a !== "1")
|
|
@@ -8044,13 +8170,13 @@ function ge(i, e, o) {
|
|
|
8044
8170
|
const r = D(e, o);
|
|
8045
8171
|
if (r.kind === "lookup")
|
|
8046
8172
|
return r;
|
|
8047
|
-
const
|
|
8048
|
-
return
|
|
8173
|
+
const l = i.getAttribute("data-gd-word")?.trim();
|
|
8174
|
+
return l ? { kind: "lookup", word: l } : { kind: "unsafe" };
|
|
8049
8175
|
}
|
|
8050
8176
|
if (n === "unsafe")
|
|
8051
8177
|
return { kind: "unsafe" };
|
|
8052
8178
|
}
|
|
8053
|
-
function
|
|
8179
|
+
function we(i, e, o) {
|
|
8054
8180
|
switch (e.kind) {
|
|
8055
8181
|
case "anchor":
|
|
8056
8182
|
i.setAttribute(
|
|
@@ -8082,20 +8208,20 @@ function C(i, e) {
|
|
|
8082
8208
|
/url\(\s*(["']?)([^"')]+)\1\s*\)/gi,
|
|
8083
8209
|
(t, n, a) => {
|
|
8084
8210
|
const r = a.trim();
|
|
8085
|
-
return
|
|
8211
|
+
return x(r) ? t : `url(${n}${p(r, e)}${n})`;
|
|
8086
8212
|
}
|
|
8087
8213
|
).replace(
|
|
8088
8214
|
/@import\s+(["'])([^"']+)\1/gi,
|
|
8089
|
-
(t, n, a) =>
|
|
8215
|
+
(t, n, a) => x(a) ? t : `@import ${n}${p(a, e)}${n}`
|
|
8090
8216
|
);
|
|
8091
8217
|
}
|
|
8092
|
-
function
|
|
8218
|
+
function be(i, e) {
|
|
8093
8219
|
return i.split(/,\s+(?=[^,]+(?:\s+\d+(?:\.\d+)?[wx])?(?:,|$))/).map((o) => {
|
|
8094
8220
|
const t = /^(\S+)([\s\S]*)$/.exec(o.trim());
|
|
8095
|
-
return !t?.[1] ||
|
|
8221
|
+
return !t?.[1] || x(t[1]) ? o.trim() : `${p(t[1], e)}${t[2] ?? ""}`;
|
|
8096
8222
|
}).join(", ");
|
|
8097
8223
|
}
|
|
8098
|
-
function
|
|
8224
|
+
function ke(i) {
|
|
8099
8225
|
if (!i.classList.contains("hidden_expand_opt"))
|
|
8100
8226
|
return;
|
|
8101
8227
|
const e = i.getAttribute("onclick") ?? "", o = /gdExpandOptPart\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/.exec(
|
|
@@ -8103,7 +8229,7 @@ function we(i) {
|
|
|
8103
8229
|
);
|
|
8104
8230
|
o?.[1] && o[2] && (i.setAttribute("data-gd-expander", o[1]), i.setAttribute("data-gd-optional", o[2]));
|
|
8105
8231
|
}
|
|
8106
|
-
function
|
|
8232
|
+
function ue(i, e, o) {
|
|
8107
8233
|
if (typeof document > "u")
|
|
8108
8234
|
throw new Error("Article rendering requires a browser document");
|
|
8109
8235
|
const t = {
|
|
@@ -8116,37 +8242,37 @@ function be(i, e, o) {
|
|
|
8116
8242
|
r.remove();
|
|
8117
8243
|
}), o === "none" && a.querySelectorAll("script").forEach((r) => r.remove());
|
|
8118
8244
|
for (const r of a.querySelectorAll("*")) {
|
|
8119
|
-
if (
|
|
8120
|
-
for (const
|
|
8121
|
-
(/^on/i.test(
|
|
8245
|
+
if (ke(r), o === "none")
|
|
8246
|
+
for (const d of [...r.attributes])
|
|
8247
|
+
(/^on/i.test(d.name) || d.name.toLowerCase() === "srcdoc") && r.removeAttribute(d.name);
|
|
8122
8248
|
if (r instanceof HTMLAnchorElement || r.tagName === "AREA") {
|
|
8123
|
-
const
|
|
8124
|
-
|
|
8249
|
+
const d = r.getAttribute("href");
|
|
8250
|
+
d !== null && we(
|
|
8125
8251
|
r,
|
|
8126
|
-
|
|
8252
|
+
fe(r, d, t) ?? D(d, t),
|
|
8127
8253
|
i.dictionaryId
|
|
8128
8254
|
);
|
|
8129
8255
|
} else if (r.hasAttribute("href")) {
|
|
8130
|
-
const
|
|
8131
|
-
|
|
8256
|
+
const d = r.getAttribute("href") ?? "";
|
|
8257
|
+
x(d) || r.setAttribute("href", p(d, t));
|
|
8132
8258
|
}
|
|
8133
|
-
for (const
|
|
8134
|
-
const w = r.getAttribute(
|
|
8135
|
-
w === null ||
|
|
8259
|
+
for (const d of he) {
|
|
8260
|
+
const w = r.getAttribute(d);
|
|
8261
|
+
w === null || x(w) || (/^(?:javascript|vbscript|file):/i.test(w) ? r.removeAttribute(d) : r.setAttribute(d, p(w, t)));
|
|
8136
8262
|
}
|
|
8137
|
-
const
|
|
8138
|
-
|
|
8139
|
-
const
|
|
8140
|
-
|
|
8263
|
+
const l = r.getAttribute("srcset");
|
|
8264
|
+
l && r.setAttribute("srcset", be(l, t));
|
|
8265
|
+
const m = r.getAttribute("style");
|
|
8266
|
+
m && r.setAttribute(
|
|
8141
8267
|
"style",
|
|
8142
|
-
C(
|
|
8268
|
+
C(m, t)
|
|
8143
8269
|
);
|
|
8144
8270
|
}
|
|
8145
8271
|
for (const r of a.querySelectorAll("style"))
|
|
8146
8272
|
r.textContent = C(r.textContent ?? "", t);
|
|
8147
8273
|
return a.innerHTML;
|
|
8148
8274
|
}
|
|
8149
|
-
const
|
|
8275
|
+
const xe = {
|
|
8150
8276
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Arial, sans-serif',
|
|
8151
8277
|
textColor: "#222222",
|
|
8152
8278
|
mutedTextColor: "#555555",
|
|
@@ -8160,8 +8286,8 @@ const ke = {
|
|
|
8160
8286
|
selectionTextColor: "#ffffff",
|
|
8161
8287
|
radius: "8px",
|
|
8162
8288
|
spacing: "8px"
|
|
8163
|
-
},
|
|
8164
|
-
fontFamily:
|
|
8289
|
+
}, ye = {
|
|
8290
|
+
fontFamily: xe.fontFamily,
|
|
8165
8291
|
textColor: "#edf1f5",
|
|
8166
8292
|
mutedTextColor: "#aeb8c3",
|
|
8167
8293
|
linkColor: "#79bfff",
|
|
@@ -8175,17 +8301,17 @@ const ke = {
|
|
|
8175
8301
|
radius: "8px",
|
|
8176
8302
|
spacing: "8px"
|
|
8177
8303
|
};
|
|
8178
|
-
function
|
|
8304
|
+
function E(i = "light") {
|
|
8179
8305
|
return i !== "auto" ? i : globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
8180
8306
|
}
|
|
8181
8307
|
function c(i, e) {
|
|
8182
8308
|
return e === void 0 ? "" : `${i}:${e};`;
|
|
8183
8309
|
}
|
|
8184
|
-
function
|
|
8310
|
+
function k(i) {
|
|
8185
8311
|
return i.replace(/<\/style/gi, "<\\/style");
|
|
8186
8312
|
}
|
|
8187
|
-
function
|
|
8188
|
-
const e =
|
|
8313
|
+
function ve(i = {}) {
|
|
8314
|
+
const e = E(i.mode), o = i.tokens ?? {}, t = e === "dark" ? { ...ye, ...o } : o, n = [
|
|
8189
8315
|
c("--gd-font-family", t.fontFamily),
|
|
8190
8316
|
c("--gd-text-color", t.textColor),
|
|
8191
8317
|
c("--gd-muted-text-color", t.mutedTextColor),
|
|
@@ -8212,36 +8338,36 @@ function ye(i = {}) {
|
|
|
8212
8338
|
t.selectionColor || t.selectionTextColor ? "::selection{background:var(--gd-selection-color,var(--selection-bg));color:var(--gd-selection-text-color,var(--selection-text));}" : "",
|
|
8213
8339
|
t.radius ? ".gdarticle{border-radius:var(--gd-radius);}" : ""
|
|
8214
8340
|
].join("");
|
|
8215
|
-
return
|
|
8341
|
+
return k(
|
|
8216
8342
|
`:root{color-scheme:${e};${n}}${a}${i.cssText ?? ""}`
|
|
8217
8343
|
);
|
|
8218
8344
|
}
|
|
8219
8345
|
function g(i) {
|
|
8220
8346
|
return i.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
8221
8347
|
}
|
|
8222
|
-
function
|
|
8348
|
+
function _e(i) {
|
|
8223
8349
|
return i.replace(
|
|
8224
8350
|
/[^a-zA-Z0-9_-]/g,
|
|
8225
8351
|
(e) => `_u${e.codePointAt(0)?.toString(16) ?? "0"}_`
|
|
8226
8352
|
);
|
|
8227
8353
|
}
|
|
8228
|
-
function
|
|
8354
|
+
function ze(i) {
|
|
8229
8355
|
return (i ?? "unknown").toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
8230
8356
|
}
|
|
8231
|
-
function
|
|
8232
|
-
return i.iconUrl ?
|
|
8357
|
+
function Ae(i, e) {
|
|
8358
|
+
return i.iconUrl ? p(i.iconUrl, {
|
|
8233
8359
|
apiBaseUrl: e,
|
|
8234
8360
|
dictionaryId: i.dictionaryId,
|
|
8235
8361
|
...i.resourceBaseUrl ? { resourceBaseUrl: i.resourceBaseUrl } : {}
|
|
8236
|
-
}) :
|
|
8362
|
+
}) : u["document.png"];
|
|
8237
8363
|
}
|
|
8238
|
-
function
|
|
8239
|
-
const t = g(i.dictionaryId), n =
|
|
8364
|
+
function Se(i, e, o) {
|
|
8365
|
+
const t = g(i.dictionaryId), n = _e(i.dictionaryId), a = ue(i, e, o), r = ze(i.sourceLanguage), l = g(i.targetLanguage ?? ""), m = g(Ae(i, e));
|
|
8240
8366
|
return `
|
|
8241
8367
|
<article class="gdarticle" id="gdfrom-${n}" data-gd-id="${t}">
|
|
8242
8368
|
<gd-dict-header class="gddictname" id="gddictname-${n}"
|
|
8243
8369
|
role="button" tabindex="0" aria-expanded="true" aria-controls="gd-${n}">
|
|
8244
|
-
<span class="gddicticon"><img src="${
|
|
8370
|
+
<span class="gddicticon"><img src="${m}" alt=""></span>
|
|
8245
8371
|
<span class="gdfromprefix">From </span>
|
|
8246
8372
|
<span class="gddicttitle">${g(i.dictionaryName)}</span>
|
|
8247
8373
|
<span class="collapse_expand_area" aria-hidden="true">
|
|
@@ -8249,12 +8375,12 @@ function Ae(i, e, o) {
|
|
|
8249
8375
|
</span>
|
|
8250
8376
|
</gd-dict-header>
|
|
8251
8377
|
<section class="gdarticlebody gdlangfrom-${r}"
|
|
8252
|
-
lang="${
|
|
8378
|
+
lang="${l}" style="display:block" id="gd-${n}">${a}</section>
|
|
8253
8379
|
</article>
|
|
8254
|
-
<div
|
|
8380
|
+
<div style="clear:both;" aria-hidden="true"></div>
|
|
8255
8381
|
<span class="gdarticleseparator"></span>`;
|
|
8256
8382
|
}
|
|
8257
|
-
function
|
|
8383
|
+
function Ce(i) {
|
|
8258
8384
|
return i.length ? `<div class="gdstemmedsuggestion">
|
|
8259
8385
|
<span class="gdstemmedsuggestion_head">Close words: </span>
|
|
8260
8386
|
<span class="gdstemmedsuggestion_body">${i.map(
|
|
@@ -8262,14 +8388,15 @@ function Se(i) {
|
|
|
8262
8388
|
).join(", ")}</span>
|
|
8263
8389
|
</div>` : "";
|
|
8264
8390
|
}
|
|
8265
|
-
function
|
|
8391
|
+
function Te(i, e) {
|
|
8266
8392
|
return `(function(){
|
|
8267
8393
|
"use strict";
|
|
8268
8394
|
const config=${JSON.stringify({
|
|
8269
8395
|
namespace: "goldendict-web",
|
|
8270
8396
|
instanceId: i,
|
|
8271
|
-
|
|
8272
|
-
|
|
8397
|
+
themeMode: e,
|
|
8398
|
+
expandOptIcon: u["expand_opt.svg"],
|
|
8399
|
+
collapseOptIcon: u["collapse_opt.svg"]
|
|
8273
8400
|
}).replace(/<\//g, "<\\/")};
|
|
8274
8401
|
const post=(type,detail={})=>parent.postMessage({
|
|
8275
8402
|
namespace:config.namespace,
|
|
@@ -8279,6 +8406,27 @@ function Ce(i) {
|
|
|
8279
8406
|
},"*");
|
|
8280
8407
|
const articleOf=(target)=>target instanceof Element?target.closest(".gdarticle"):null;
|
|
8281
8408
|
const articleId=(article)=>article?.getAttribute("data-gd-id")||"";
|
|
8409
|
+
const syncDictionaryTheme=()=>{
|
|
8410
|
+
if(document.documentElement.getAttribute("data-gd-theme")!==config.themeMode){
|
|
8411
|
+
document.documentElement.setAttribute("data-gd-theme",config.themeMode);
|
|
8412
|
+
}
|
|
8413
|
+
if(document.documentElement.getAttribute("data-darkreader-scheme")!==config.themeMode){
|
|
8414
|
+
document.documentElement.setAttribute("data-darkreader-scheme",config.themeMode);
|
|
8415
|
+
}
|
|
8416
|
+
document.querySelectorAll(".oaldpe").forEach((container)=>{
|
|
8417
|
+
if(container.getAttribute("data-theme")!==config.themeMode){
|
|
8418
|
+
container.setAttribute("data-theme",config.themeMode);
|
|
8419
|
+
}
|
|
8420
|
+
});
|
|
8421
|
+
};
|
|
8422
|
+
const themeObserver=new MutationObserver(syncDictionaryTheme);
|
|
8423
|
+
themeObserver.observe(document.documentElement,{
|
|
8424
|
+
subtree:true,
|
|
8425
|
+
childList:true,
|
|
8426
|
+
attributes:true,
|
|
8427
|
+
attributeFilter:["data-theme","data-darkreader-scheme"]
|
|
8428
|
+
});
|
|
8429
|
+
syncDictionaryTheme();
|
|
8282
8430
|
const setActive=(article,notify=true)=>{
|
|
8283
8431
|
if(!article)return;
|
|
8284
8432
|
document.querySelector(".gdactivearticle")?.classList.remove("gdactivearticle");
|
|
@@ -8369,9 +8517,22 @@ function Ce(i) {
|
|
|
8369
8517
|
const header=target.closest(".gddictname");
|
|
8370
8518
|
if(header){event.preventDefault();toggleArticle(articleOf(header));}
|
|
8371
8519
|
});
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8520
|
+
let resizeFrame=0;
|
|
8521
|
+
let lastHeight=0;
|
|
8522
|
+
const requestSize=()=>{
|
|
8523
|
+
cancelAnimationFrame(resizeFrame);
|
|
8524
|
+
resizeFrame=requestAnimationFrame(()=>{
|
|
8525
|
+
resizeFrame=0;
|
|
8526
|
+
const height=Math.ceil(Math.max(
|
|
8527
|
+
document.body.scrollHeight,
|
|
8528
|
+
document.body.offsetHeight,
|
|
8529
|
+
document.body.getBoundingClientRect().height
|
|
8530
|
+
));
|
|
8531
|
+
if(height===lastHeight)return;
|
|
8532
|
+
lastHeight=height;
|
|
8533
|
+
post("height",{height});
|
|
8534
|
+
});
|
|
8535
|
+
};
|
|
8375
8536
|
addEventListener("message",(event)=>{
|
|
8376
8537
|
const message=event.data;
|
|
8377
8538
|
if(event.source!==parent||message?.namespace!==config.namespace||message?.instanceId!==config.instanceId)return;
|
|
@@ -8381,11 +8542,13 @@ function Ce(i) {
|
|
|
8381
8542
|
article?.scrollIntoView({block:"start"});setActive(article,false);
|
|
8382
8543
|
}
|
|
8383
8544
|
});
|
|
8384
|
-
new ResizeObserver(requestSize)
|
|
8545
|
+
const resizeObserver=new ResizeObserver(requestSize);
|
|
8546
|
+
resizeObserver.observe(document.body);
|
|
8547
|
+
addEventListener("resize",requestSize,{passive:true});
|
|
8385
8548
|
addEventListener("load",()=>{requestSize();post("ready",{});});
|
|
8386
8549
|
})();`;
|
|
8387
8550
|
}
|
|
8388
|
-
function
|
|
8551
|
+
function Ie(i, e) {
|
|
8389
8552
|
const o = i === "none" ? `'nonce-${e}'` : "'unsafe-inline' 'unsafe-eval' data: blob: http: https:", t = i === "none" ? "'none'" : "http: https:";
|
|
8390
8553
|
return [
|
|
8391
8554
|
"default-src 'none'",
|
|
@@ -8401,24 +8564,25 @@ function Te(i, e) {
|
|
|
8401
8564
|
"base-uri 'none'"
|
|
8402
8565
|
].join("; ");
|
|
8403
8566
|
}
|
|
8404
|
-
function
|
|
8405
|
-
const o = e.theme ?? {}, t = e.instanceId.replace(/[^a-zA-Z0-9_-]/g, ""),
|
|
8406
|
-
(d) =>
|
|
8407
|
-
).join(""),
|
|
8567
|
+
function De(i, e) {
|
|
8568
|
+
const o = e.theme ?? {}, t = E(o.mode), n = e.layoutMode ?? "responsive", a = e.instanceId.replace(/[^a-zA-Z0-9_-]/g, ""), r = i.articles.map(
|
|
8569
|
+
(d) => Se(d, e.apiBaseUrl, e.scriptPolicy)
|
|
8570
|
+
).join(""), l = r ? `${r}<div class="empty-space" aria-hidden="true"></div>` : `<div class="gdnotfound"><p>No translation for <b>${g(i.word)}</b> was found.</p></div>`, m = o.brandName ? `${i.word} — ${o.brandName}` : i.word;
|
|
8408
8571
|
return `<!doctype html>
|
|
8409
|
-
<html><head>
|
|
8572
|
+
<html data-gd-theme="${t}" data-gd-layout="${n}" data-darkreader-scheme="${t}"><head>
|
|
8410
8573
|
<meta charset="utf-8">
|
|
8411
8574
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
8412
|
-
<meta http-equiv="Content-Security-Policy" content="${g(
|
|
8413
|
-
<title>${g(
|
|
8414
|
-
<style>${
|
|
8415
|
-
<style>${
|
|
8416
|
-
|
|
8417
|
-
<style
|
|
8575
|
+
<meta http-equiv="Content-Security-Policy" content="${g(Ie(e.scriptPolicy, a))}">
|
|
8576
|
+
<title>${g(m)}</title>
|
|
8577
|
+
<style>${k(re)}</style>
|
|
8578
|
+
<style>${k(de(o.preset))}</style>
|
|
8579
|
+
${n === "responsive" ? `<style data-gd-style="responsive">${k(le)}</style>` : ""}
|
|
8580
|
+
<style>${ve(o)}</style>
|
|
8581
|
+
<style media="print">${k(ae)}</style>
|
|
8418
8582
|
</head><body>
|
|
8419
|
-
${
|
|
8420
|
-
${
|
|
8421
|
-
<script nonce="${
|
|
8583
|
+
${l}
|
|
8584
|
+
${Ce(i.suggestions)}
|
|
8585
|
+
<script nonce="${a}">${Te(e.instanceId, t).replace(/<\/script/gi, "<\\/script")}<\/script>
|
|
8422
8586
|
</body></html>`;
|
|
8423
8587
|
}
|
|
8424
8588
|
const b = {
|
|
@@ -8428,26 +8592,28 @@ const b = {
|
|
|
8428
8592
|
mediaRequest: "goldendict-media-request",
|
|
8429
8593
|
externalLink: "goldendict-external-link",
|
|
8430
8594
|
stateChange: "goldendict-state-change"
|
|
8431
|
-
},
|
|
8432
|
-
:host{display:block;min-width:0;color:#222;font-family:system-ui,sans-serif}
|
|
8433
|
-
.shell{position:relative;min-height:8rem;border-radius:var(--gd-host-radius,8px);overflow:hidden;background:var(--gd-host-background,#fff)}
|
|
8434
|
-
.brand{display:flex;align-items:center;gap:.65rem;padding:.65rem .9rem;border-bottom:1px solid var(--gd-host-border,#e3e3e3);background:var(--gd-host-surface,#f7f9fb);font-weight:650}
|
|
8595
|
+
}, Ee = `
|
|
8596
|
+
:host{display:block;box-sizing:border-box;width:100%;min-width:0;max-width:100%;color:#222;font-family:system-ui,sans-serif;container:goldendict-view / inline-size}
|
|
8597
|
+
.shell{position:relative;box-sizing:border-box;width:100%;min-width:0;max-width:100%;min-height:8rem;border-radius:var(--gd-host-radius,8px);overflow:hidden;background:var(--gd-host-background,#fff)}
|
|
8598
|
+
.brand{display:flex;align-items:center;gap:.65rem;min-width:0;padding:.65rem .9rem;border-bottom:1px solid var(--gd-host-border,#e3e3e3);background:var(--gd-host-surface,#f7f9fb);font-weight:650}
|
|
8435
8599
|
.brand[hidden]{display:none}
|
|
8436
|
-
.brand img{display:block;width:1.75rem;height:1.75rem;object-fit:contain}
|
|
8600
|
+
.brand img{display:block;flex:0 0 auto;width:1.75rem;height:1.75rem;object-fit:contain}
|
|
8437
8601
|
.brand img[hidden]{display:none}
|
|
8602
|
+
.brand span{min-width:0;overflow-wrap:anywhere}
|
|
8438
8603
|
.status{display:grid;place-items:center;min-height:8rem;padding:1.25rem;text-align:center;color:var(--gd-host-muted,#59636e)}
|
|
8439
8604
|
.status[hidden]{display:none}
|
|
8440
8605
|
.status[data-state="error"]{color:var(--gd-host-error,#a21d2d)}
|
|
8441
8606
|
.spinner{width:1.25rem;height:1.25rem;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:spin .75s linear infinite;margin:0 auto .7rem}
|
|
8442
|
-
iframe{display:block;width:100%;min-height:8rem;border:0;background:transparent}
|
|
8607
|
+
iframe{display:block;box-sizing:border-box;width:100%;min-width:0;max-width:100%;min-height:8rem;border:0;background:transparent}
|
|
8443
8608
|
iframe[hidden]{display:none}
|
|
8444
8609
|
@keyframes spin{to{transform:rotate(360deg)}}
|
|
8610
|
+
@container goldendict-view (max-width:30rem){.brand{gap:.5rem;padding:.55rem .65rem}.status{padding:1rem .75rem}}
|
|
8445
8611
|
@media (prefers-reduced-motion:reduce){.spinner{animation:none}}
|
|
8446
8612
|
`;
|
|
8447
|
-
function
|
|
8613
|
+
function qe() {
|
|
8448
8614
|
return globalThis.crypto?.randomUUID?.() ?? `gd-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
8449
8615
|
}
|
|
8450
|
-
function
|
|
8616
|
+
function Le(i) {
|
|
8451
8617
|
return (i instanceof DOMException || i instanceof Error) && i.name === "AbortError";
|
|
8452
8618
|
}
|
|
8453
8619
|
class _ extends HTMLElement {
|
|
@@ -8456,9 +8622,10 @@ class _ extends HTMLElement {
|
|
|
8456
8622
|
"word",
|
|
8457
8623
|
"preset",
|
|
8458
8624
|
"theme-mode",
|
|
8459
|
-
"script-policy"
|
|
8625
|
+
"script-policy",
|
|
8626
|
+
"layout-mode"
|
|
8460
8627
|
];
|
|
8461
|
-
instanceId =
|
|
8628
|
+
instanceId = qe();
|
|
8462
8629
|
frame;
|
|
8463
8630
|
statusElement;
|
|
8464
8631
|
brandElement;
|
|
@@ -8467,6 +8634,8 @@ class _ extends HTMLElement {
|
|
|
8467
8634
|
clientValue;
|
|
8468
8635
|
requestController;
|
|
8469
8636
|
requestSequence = 0;
|
|
8637
|
+
renderSequence = 0;
|
|
8638
|
+
activeBridgeInstanceId;
|
|
8470
8639
|
responseValue;
|
|
8471
8640
|
themeValue = {};
|
|
8472
8641
|
stateValue = "idle";
|
|
@@ -8475,7 +8644,7 @@ class _ extends HTMLElement {
|
|
|
8475
8644
|
constructor() {
|
|
8476
8645
|
super();
|
|
8477
8646
|
const e = this.attachShadow({ mode: "open" });
|
|
8478
|
-
e.innerHTML = `<style>${
|
|
8647
|
+
e.innerHTML = `<style>${Ee}</style>
|
|
8479
8648
|
<section class="shell" part="container">
|
|
8480
8649
|
<div class="brand" part="brand" hidden>
|
|
8481
8650
|
<img alt="" hidden><span></span>
|
|
@@ -8483,7 +8652,7 @@ class _ extends HTMLElement {
|
|
|
8483
8652
|
<div class="status" part="status" role="status" aria-live="polite"></div>
|
|
8484
8653
|
<iframe part="article" title="Dictionary article" sandbox="allow-scripts"
|
|
8485
8654
|
referrerpolicy="no-referrer" hidden></iframe>
|
|
8486
|
-
</section>`, this.frame = e.querySelector("iframe"), this.statusElement = e.querySelector(".status"), this.brandElement = e.querySelector(".brand"), this.brandImage = this.brandElement.querySelector("img"), this.brandText = this.brandElement.querySelector("span"), this.clientValue = new v({ baseUrl: this.apiBase }), this.
|
|
8655
|
+
</section>`, this.frame = e.querySelector("iframe"), this.statusElement = e.querySelector(".status"), this.brandElement = e.querySelector(".brand"), this.brandImage = this.brandElement.querySelector("img"), this.brandText = this.brandElement.querySelector("span"), this.clientValue = new v({ baseUrl: this.apiBase }), this.updateBrand(), this.setState("idle");
|
|
8487
8656
|
}
|
|
8488
8657
|
connectedCallback() {
|
|
8489
8658
|
globalThis.addEventListener("message", this.handleBridgeMessage);
|
|
@@ -8500,7 +8669,7 @@ class _ extends HTMLElement {
|
|
|
8500
8669
|
} : e === "theme-mode" ? this.theme = {
|
|
8501
8670
|
...this.themeValue,
|
|
8502
8671
|
mode: t || "light"
|
|
8503
|
-
} : e === "script-policy" && this.responseValue && this.renderResponse(this.responseValue));
|
|
8672
|
+
} : (e === "script-policy" || e === "layout-mode") && this.responseValue && this.renderResponse(this.responseValue));
|
|
8504
8673
|
}
|
|
8505
8674
|
get apiBase() {
|
|
8506
8675
|
return this.getAttribute("api-base")?.trim() || "/api/v1";
|
|
@@ -8526,6 +8695,12 @@ class _ extends HTMLElement {
|
|
|
8526
8695
|
set scriptPolicy(e) {
|
|
8527
8696
|
this.setAttribute("script-policy", e);
|
|
8528
8697
|
}
|
|
8698
|
+
get layoutMode() {
|
|
8699
|
+
return this.getAttribute("layout-mode") === "fidelity" ? "fidelity" : "responsive";
|
|
8700
|
+
}
|
|
8701
|
+
set layoutMode(e) {
|
|
8702
|
+
this.setAttribute("layout-mode", e);
|
|
8703
|
+
}
|
|
8529
8704
|
get dictionaryIds() {
|
|
8530
8705
|
return this.dictionaryIdsValue;
|
|
8531
8706
|
}
|
|
@@ -8559,10 +8734,10 @@ class _ extends HTMLElement {
|
|
|
8559
8734
|
return;
|
|
8560
8735
|
this.setLookupResponse(r);
|
|
8561
8736
|
} catch (r) {
|
|
8562
|
-
if (n !== this.requestSequence ||
|
|
8737
|
+
if (n !== this.requestSequence || Le(r))
|
|
8563
8738
|
return;
|
|
8564
|
-
const
|
|
8565
|
-
this.responseValue = void 0, this.
|
|
8739
|
+
const l = r instanceof Error ? r : new Error(String(r));
|
|
8740
|
+
this.responseValue = void 0, this.resetFrame(), this.setState("error", { word: t, error: l });
|
|
8566
8741
|
} finally {
|
|
8567
8742
|
n === this.requestSequence && (this.requestController = void 0);
|
|
8568
8743
|
}
|
|
@@ -8571,21 +8746,38 @@ class _ extends HTMLElement {
|
|
|
8571
8746
|
this.responseValue = e, this.renderResponse(e);
|
|
8572
8747
|
}
|
|
8573
8748
|
abort() {
|
|
8574
|
-
this.requestController?.abort(), this.requestController = void 0;
|
|
8749
|
+
this.requestController?.abort(), this.requestController = void 0, this.renderSequence += 1, this.resetFrame();
|
|
8575
8750
|
}
|
|
8576
8751
|
clear() {
|
|
8577
|
-
this.abort(), this.requestSequence += 1, this.responseValue = void 0, this.
|
|
8752
|
+
this.abort(), this.requestSequence += 1, this.responseValue = void 0, this.setState("idle");
|
|
8578
8753
|
}
|
|
8579
8754
|
scrollToArticle(e) {
|
|
8580
8755
|
this.postCommand({ type: "scroll-article", dictionaryId: e });
|
|
8581
8756
|
}
|
|
8582
8757
|
renderResponse(e) {
|
|
8583
|
-
|
|
8758
|
+
const o = ++this.renderSequence, t = `${this.instanceId}-${o}`;
|
|
8759
|
+
this.activeBridgeInstanceId = t;
|
|
8760
|
+
const n = this.replaceFrame(!1);
|
|
8761
|
+
n.title = e.word ? `Dictionary results for ${e.word}` : "Dictionary article";
|
|
8762
|
+
const a = De(e, {
|
|
8584
8763
|
apiBaseUrl: this.clientValue.baseUrl,
|
|
8585
|
-
instanceId:
|
|
8764
|
+
instanceId: t,
|
|
8586
8765
|
scriptPolicy: this.scriptPolicy,
|
|
8766
|
+
layoutMode: this.layoutMode,
|
|
8587
8767
|
theme: this.themeValue
|
|
8588
|
-
})
|
|
8768
|
+
});
|
|
8769
|
+
requestAnimationFrame(() => {
|
|
8770
|
+
o !== this.renderSequence || n !== this.frame || (n.srcdoc = a, this.statusElement.hidden = !0);
|
|
8771
|
+
});
|
|
8772
|
+
}
|
|
8773
|
+
resetFrame() {
|
|
8774
|
+
this.activeBridgeInstanceId = void 0, this.replaceFrame(!0);
|
|
8775
|
+
}
|
|
8776
|
+
replaceFrame(e) {
|
|
8777
|
+
const o = this.frame, t = this.ownerDocument.createElement("iframe");
|
|
8778
|
+
return t.setAttribute("part", "article"), t.title = "Dictionary article", t.setAttribute("sandbox", "allow-scripts"), t.referrerPolicy = "no-referrer", t.style.height = "8rem", t.hidden = e, t.addEventListener("load", () => {
|
|
8779
|
+
this.frame === t && t.hasAttribute("srcdoc") && this.handleFrameLoaded();
|
|
8780
|
+
}), o.replaceWith(t), this.frame = t, t.offsetWidth, t;
|
|
8589
8781
|
}
|
|
8590
8782
|
handleFrameLoaded() {
|
|
8591
8783
|
this.responseValue && (this.setState(
|
|
@@ -8597,7 +8789,7 @@ class _ extends HTMLElement {
|
|
|
8597
8789
|
if (e.source !== this.frame.contentWindow)
|
|
8598
8790
|
return;
|
|
8599
8791
|
const o = e.data;
|
|
8600
|
-
if (o.namespace !== "goldendict-web" || o.instanceId !== this.
|
|
8792
|
+
if (o.namespace !== "goldendict-web" || o.instanceId !== this.activeBridgeInstanceId || !o.type)
|
|
8601
8793
|
return;
|
|
8602
8794
|
const t = o.detail ?? {};
|
|
8603
8795
|
switch (o.type) {
|
|
@@ -8606,7 +8798,7 @@ class _ extends HTMLElement {
|
|
|
8606
8798
|
break;
|
|
8607
8799
|
case "height": {
|
|
8608
8800
|
const n = Number(t.height);
|
|
8609
|
-
Number.isFinite(n) && n > 0 && (this.frame.style.height = `${Math.min(Math.max(n, 128), 1e5)}px
|
|
8801
|
+
Number.isFinite(n) && n > 0 && (this.frame.style.height = `${Math.min(Math.max(n, 128), 1e5)}px`, this.handleFrameLoaded());
|
|
8610
8802
|
break;
|
|
8611
8803
|
}
|
|
8612
8804
|
case "lookup":
|
|
@@ -8682,10 +8874,10 @@ class _ extends HTMLElement {
|
|
|
8682
8874
|
});
|
|
8683
8875
|
}
|
|
8684
8876
|
postCommand(e) {
|
|
8685
|
-
this.frame.contentWindow?.postMessage(
|
|
8877
|
+
this.activeBridgeInstanceId && this.frame.contentWindow?.postMessage(
|
|
8686
8878
|
{
|
|
8687
8879
|
namespace: "goldendict-web",
|
|
8688
|
-
instanceId: this.
|
|
8880
|
+
instanceId: this.activeBridgeInstanceId,
|
|
8689
8881
|
...e
|
|
8690
8882
|
},
|
|
8691
8883
|
"*"
|
|
@@ -8701,26 +8893,26 @@ class _ extends HTMLElement {
|
|
|
8701
8893
|
return this.dispatchEvent(n), n;
|
|
8702
8894
|
}
|
|
8703
8895
|
}
|
|
8704
|
-
function
|
|
8896
|
+
function Be(i = "goldendict-view") {
|
|
8705
8897
|
if (!globalThis.customElements)
|
|
8706
8898
|
return _;
|
|
8707
8899
|
const e = globalThis.customElements.get(i);
|
|
8708
8900
|
return e || (globalThis.customElements.define(i, _), _);
|
|
8709
8901
|
}
|
|
8710
|
-
|
|
8902
|
+
Be();
|
|
8711
8903
|
export {
|
|
8712
|
-
|
|
8713
|
-
|
|
8904
|
+
ye as DARK_THEME_TOKENS,
|
|
8905
|
+
q as DictionaryApiError,
|
|
8714
8906
|
v as DictionaryClient,
|
|
8715
8907
|
b as GOLDENDICT_EVENTS,
|
|
8716
|
-
|
|
8908
|
+
se as GOLDENDICT_SCHEME_SUPPORT,
|
|
8717
8909
|
_ as GoldenDictView,
|
|
8718
|
-
|
|
8910
|
+
xe as LIGHT_THEME_TOKENS,
|
|
8719
8911
|
D as classifyArticleLink,
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8912
|
+
Be as defineGoldendictView,
|
|
8913
|
+
k as escapeStyleText,
|
|
8914
|
+
p as resolveResourceUrl,
|
|
8915
|
+
E as resolveThemeMode,
|
|
8916
|
+
ve as themeToCss
|
|
8725
8917
|
};
|
|
8726
8918
|
//# sourceMappingURL=index.js.map
|