accessify-widget 0.3.6 → 0.3.7

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-C_cEJXg7.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-BN8NOhTx.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-CK_agCbv.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
  }
@@ -8570,4 +8582,4 @@ export {
8570
8582
  init as i,
8571
8583
  t
8572
8584
  };
8573
- //# sourceMappingURL=index-DDv0soH8.js.map
8585
+ //# sourceMappingURL=index-C_cEJXg7.js.map