@panda-lingo/goldendict 0.1.2 → 0.1.3

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/dist/index.js CHANGED
@@ -311,7 +311,7 @@ const M = `<?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
- `, 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"?>
314
+ `, R = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAATrAAAE6wHYKlsNAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAcRJREFUOI2lkztvE0EQgL8Z7/rB2T5fCixhQQc00FAjJCRkiTYV/JH0adIgfgJVGn4CKRBUSIjCHYiOBimK7KA4ORw/dofC3Ck2dhpGGu1r5pvZmV0xM/5HXDEZDAbf2u12BkiM0UIImBlmRoyxHBeLBaPRaNzv9++tAJIkyVS1673HzBCRUtfFzEo/d/VAVRERzvf2uDw6AqB6eMhlt1va9Hq9FWgJiDEiIqgqcTwmnp4CUPeearu9EmRjDYp7qiqVNEV3dgCYx8hlniMimBlZlm0GFN0QERoHB7j9/bIGVUDiHCrVfzLQqwDvPSLCZDIhz3MuLi6YTye4eY58fkOnUbkeUERMkoRWq0WaptRqDaYfXvPr3StmP75cX4PZbIb3HoDx6TmttImveZoPn9N+0KfWvbsdYGY45xARvn76zvu3H8m6GS/2dpnefLRsb4Bb2wAhBJxbLoc/hwCcDc9QqVCvuzLy+uPa2IUnu4+p36hz5/5tGkmdxWKBc45Op0MIYXsNClAzTXj28imquqKFzUbA8fHxbzMbi0glhKBmpsuEREQkqmpU1Sgi8eTkJC/8ZNN3FhEHNIHG360pkJvZdN32D0SOwDehr1HXAAAAAElFTkSuQmCC", G = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
315
315
  <!-- Created with Inkscape (http://www.inkscape.org/) -->
316
316
 
317
317
  <svg
@@ -357,7 +357,7 @@ const M = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
357
357
  sodipodi:nodetypes="cccc" />
358
358
  </g>
359
359
  </svg>
360
- `, G = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
360
+ `, N = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
361
361
  <!-- Created with Inkscape (http://www.inkscape.org/) -->
362
362
 
363
363
  <svg
@@ -731,9 +731,9 @@ const u = {
731
731
  "collapse_article_hovered.svg": s($),
732
732
  "collapse_opt.svg": s(P),
733
733
  "document.png": R,
734
- "downarrow.svg": s(N),
734
+ "downarrow.svg": s(G),
735
735
  "expand_article.svg": s(O),
736
- "expand_article_hovered.svg": s(G),
736
+ "expand_article_hovered.svg": s(N),
737
737
  "expand_opt.svg": s(V),
738
738
  "old-arrow.svg": s(H),
739
739
  "old-downarrow.svg": s(W),
@@ -8564,7 +8564,10 @@ function Ie(i, e) {
8564
8564
  "base-uri 'none'"
8565
8565
  ].join("; ");
8566
8566
  }
8567
- function De(i, e) {
8567
+ function De() {
8568
+ return 'globalThis.__DICT__={name:"GoldenDict",version:"web"};';
8569
+ }
8570
+ function Ee(i, e) {
8568
8571
  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
8572
  (d) => Se(d, e.apiBaseUrl, e.scriptPolicy)
8570
8573
  ).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;
@@ -8574,6 +8577,7 @@ function De(i, e) {
8574
8577
  <meta name="viewport" content="width=device-width,initial-scale=1">
8575
8578
  <meta http-equiv="Content-Security-Policy" content="${g(Ie(e.scriptPolicy, a))}">
8576
8579
  <title>${g(m)}</title>
8580
+ <script nonce="${a}" data-gd-runtime="compatibility">${De()}<\/script>
8577
8581
  <style>${k(re)}</style>
8578
8582
  <style>${k(de(o.preset))}</style>
8579
8583
  ${n === "responsive" ? `<style data-gd-style="responsive">${k(le)}</style>` : ""}
@@ -8592,7 +8596,7 @@ const b = {
8592
8596
  mediaRequest: "goldendict-media-request",
8593
8597
  externalLink: "goldendict-external-link",
8594
8598
  stateChange: "goldendict-state-change"
8595
- }, Ee = `
8599
+ }, qe = `
8596
8600
  :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
8601
  .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
8602
  .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}
@@ -8610,10 +8614,10 @@ const b = {
8610
8614
  @container goldendict-view (max-width:30rem){.brand{gap:.5rem;padding:.55rem .65rem}.status{padding:1rem .75rem}}
8611
8615
  @media (prefers-reduced-motion:reduce){.spinner{animation:none}}
8612
8616
  `;
8613
- function qe() {
8617
+ function Le() {
8614
8618
  return globalThis.crypto?.randomUUID?.() ?? `gd-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
8615
8619
  }
8616
- function Le(i) {
8620
+ function Be(i) {
8617
8621
  return (i instanceof DOMException || i instanceof Error) && i.name === "AbortError";
8618
8622
  }
8619
8623
  class _ extends HTMLElement {
@@ -8625,7 +8629,7 @@ class _ extends HTMLElement {
8625
8629
  "script-policy",
8626
8630
  "layout-mode"
8627
8631
  ];
8628
- instanceId = qe();
8632
+ instanceId = Le();
8629
8633
  frame;
8630
8634
  statusElement;
8631
8635
  brandElement;
@@ -8644,7 +8648,7 @@ class _ extends HTMLElement {
8644
8648
  constructor() {
8645
8649
  super();
8646
8650
  const e = this.attachShadow({ mode: "open" });
8647
- e.innerHTML = `<style>${Ee}</style>
8651
+ e.innerHTML = `<style>${qe}</style>
8648
8652
  <section class="shell" part="container">
8649
8653
  <div class="brand" part="brand" hidden>
8650
8654
  <img alt="" hidden><span></span>
@@ -8734,7 +8738,7 @@ class _ extends HTMLElement {
8734
8738
  return;
8735
8739
  this.setLookupResponse(r);
8736
8740
  } catch (r) {
8737
- if (n !== this.requestSequence || Le(r))
8741
+ if (n !== this.requestSequence || Be(r))
8738
8742
  return;
8739
8743
  const l = r instanceof Error ? r : new Error(String(r));
8740
8744
  this.responseValue = void 0, this.resetFrame(), this.setState("error", { word: t, error: l });
@@ -8759,7 +8763,7 @@ class _ extends HTMLElement {
8759
8763
  this.activeBridgeInstanceId = t;
8760
8764
  const n = this.replaceFrame(!1);
8761
8765
  n.title = e.word ? `Dictionary results for ${e.word}` : "Dictionary article";
8762
- const a = De(e, {
8766
+ const a = Ee(e, {
8763
8767
  apiBaseUrl: this.clientValue.baseUrl,
8764
8768
  instanceId: t,
8765
8769
  scriptPolicy: this.scriptPolicy,
@@ -8893,13 +8897,13 @@ class _ extends HTMLElement {
8893
8897
  return this.dispatchEvent(n), n;
8894
8898
  }
8895
8899
  }
8896
- function Be(i = "goldendict-view") {
8900
+ function Me(i = "goldendict-view") {
8897
8901
  if (!globalThis.customElements)
8898
8902
  return _;
8899
8903
  const e = globalThis.customElements.get(i);
8900
8904
  return e || (globalThis.customElements.define(i, _), _);
8901
8905
  }
8902
- Be();
8906
+ Me();
8903
8907
  export {
8904
8908
  ye as DARK_THEME_TOKENS,
8905
8909
  q as DictionaryApiError,
@@ -8909,7 +8913,7 @@ export {
8909
8913
  _ as GoldenDictView,
8910
8914
  xe as LIGHT_THEME_TOKENS,
8911
8915
  D as classifyArticleLink,
8912
- Be as defineGoldendictView,
8916
+ Me as defineGoldendictView,
8913
8917
  k as escapeStyleText,
8914
8918
  p as resolveResourceUrl,
8915
8919
  E as resolveThemeMode,