accessify-widget 0.3.6 → 0.3.8

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.
@@ -1,4 +1,4 @@
1
- import { d, i } from "./index-DDv0soH8.js";
1
+ import { d, i } from "./index-C3jQHPAw.js";
2
2
  export {
3
3
  d as destroy,
4
4
  i as init
@@ -6433,14 +6433,14 @@ function FeatureGrid($$anchor, $$props) {
6433
6433
  const FEATURE_LOADERS = {
6434
6434
  contrast: () => import("./contrast-CqsICAkU.js"),
6435
6435
  "text-size": () => import("./text-size-C6OFhCGi.js"),
6436
- "keyboard-nav": () => import("./keyboard-nav-DYBrrE4b.js"),
6436
+ "keyboard-nav": () => import("./keyboard-nav-CzeLetKR.js"),
6437
6437
  "link-highlight": () => import("./link-highlight-DBGm067Y.js"),
6438
6438
  "reading-guide": () => import("./reading-guide-VT8NciIL.js"),
6439
6439
  "reading-mask": () => import("./reading-mask-BABChuCz.js"),
6440
6440
  "animation-stop": () => import("./animation-stop-C0MwseK0.js"),
6441
6441
  "hide-images": () => import("./hide-images-B_LeCBcd.js"),
6442
6442
  "big-cursor": () => import("./big-cursor-B2UKu9dQ.js"),
6443
- "page-structure": () => import("./page-structure-BTemvR2X.js"),
6443
+ "page-structure": () => import("./page-structure-DFT1USJ1.js"),
6444
6444
  tts: () => import("./tts-CjszLRnb.js"),
6445
6445
  "text-simplify": () => import("./text-simplify-Cvhpio7g.js"),
6446
6446
  "alt-text": () => Promise.resolve().then(() => altText)
@@ -6811,16 +6811,28 @@ async function translateSingleText(text, sourceLang, targetLang) {
6811
6811
  }
6812
6812
  }
6813
6813
  async function translateTexts(texts, sourceLang, targetLang) {
6814
- const CONCURRENCY = 10;
6815
- const results = new Array(texts.length);
6816
- for (let start = 0; start < texts.length; start += CONCURRENCY) {
6817
- const batch = texts.slice(start, start + CONCURRENCY);
6818
- const translated = await Promise.all(
6819
- batch.map((text) => translateSingleText(text, sourceLang, targetLang))
6820
- );
6821
- for (let j = 0; j < translated.length; j++) {
6822
- results[start + j] = translated[j];
6823
- }
6814
+ const SEP = "\n\n";
6815
+ const BATCH_CHAR_LIMIT = 4e3;
6816
+ const results = new Array(texts.length).fill("");
6817
+ let batchStart = 0;
6818
+ while (batchStart < texts.length) {
6819
+ const batchTexts = [];
6820
+ let charCount = 0;
6821
+ let i = batchStart;
6822
+ while (i < texts.length) {
6823
+ const nextLen = texts[i].length + SEP.length;
6824
+ if (charCount + nextLen > BATCH_CHAR_LIMIT && batchTexts.length > 0) break;
6825
+ batchTexts.push(texts[i]);
6826
+ charCount += nextLen;
6827
+ i++;
6828
+ }
6829
+ const joined = batchTexts.join(SEP);
6830
+ const translated = await translateSingleText(joined, sourceLang, targetLang);
6831
+ const lines = translated.split(/\n\s*\n/);
6832
+ for (let j = 0; j < batchTexts.length; j++) {
6833
+ results[batchStart + j] = (lines[j] || "").trim() || batchTexts[j];
6834
+ }
6835
+ batchStart = i;
6824
6836
  }
6825
6837
  return results;
6826
6838
  }
@@ -8163,19 +8175,17 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8163
8175
  }
8164
8176
  function scanForBackgroundImages() {
8165
8177
  const found = [];
8166
- const candidates = document.querySelectorAll(
8167
- 'header, [class*="hero"], [class*="banner"], [class*="header"], [class*="bg-"], [class*="background"], [style*="background"]'
8168
- );
8169
- for (const el of candidates) {
8178
+ const allElements = document.querySelectorAll("*");
8179
+ for (const el of allElements) {
8170
8180
  if (el.closest("#accessify-root") || el.closest("accessify-widget")) continue;
8171
8181
  if (el.getAttribute("data-accessify-bg-alt")) continue;
8182
+ if (el.offsetWidth < 200 || el.offsetHeight < 150) continue;
8172
8183
  const style = getComputedStyle(el);
8173
8184
  const bg = style.backgroundImage;
8174
8185
  if (!bg || bg === "none") continue;
8175
8186
  const urlMatch = bg.match(/url\(["']?([^"')]+)["']?\)/);
8176
8187
  if (!urlMatch) continue;
8177
- const rect = el.getBoundingClientRect();
8178
- if (rect.width < 100 || rect.height < 100) continue;
8188
+ if (urlMatch[1].startsWith("data:image/svg")) continue;
8179
8189
  if (el.getAttribute("role") === "img" && el.getAttribute("aria-label")) continue;
8180
8190
  found.push(el);
8181
8191
  }
@@ -8570,4 +8580,4 @@ export {
8570
8580
  init as i,
8571
8581
  t
8572
8582
  };
8573
- //# sourceMappingURL=index-DDv0soH8.js.map
8583
+ //# sourceMappingURL=index-C3jQHPAw.js.map