accessify-widget 0.3.1 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { d, i } from "./index-CFoky8Ty.js";
1
+ import { d, i } from "./index-B8sAE1Po.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-B66DnefL.js"),
6436
+ "keyboard-nav": () => import("./keyboard-nav-SGx_nXud.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-C76rueHv.js"),
6443
+ "page-structure": () => import("./page-structure-BfD6Mw28.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)
@@ -7953,17 +7953,16 @@ async function autoApplyCachedAltTexts(widgetConfig) {
7953
7953
  if (cache.size === 0) return 0;
7954
7954
  function applyToImg(img) {
7955
7955
  if (img.closest("#accessify-root") || img.closest("accessify-widget")) return false;
7956
- const alt = img.getAttribute("alt");
7957
- if (alt !== null && alt.trim() !== "") return false;
7958
7956
  const src = getImageSrc(img);
7959
7957
  const cached = cache.get(src) || cache.get(normalizeImageUrl(src)) || cache.get(img.src);
7960
- if (cached) {
7958
+ if (!cached) return false;
7959
+ const alt = img.getAttribute("alt");
7960
+ if (alt === null || alt.trim() === "") {
7961
7961
  img.setAttribute("alt", cached);
7962
- img.setAttribute("title", cached);
7963
7962
  img.setAttribute("data-accessify-alt", "auto");
7964
- return true;
7965
7963
  }
7966
- return false;
7964
+ img.setAttribute("title", cached);
7965
+ return true;
7967
7966
  }
7968
7967
  let applied = 0;
7969
7968
  document.querySelectorAll("img").forEach((img) => {
@@ -7986,7 +7985,6 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
7986
7985
  const proxyUrl = serverConfig?.proxyUrl || "";
7987
7986
  let enabled = false;
7988
7987
  let styleEl = null;
7989
- let badgeEl = null;
7990
7988
  let tooltipEl = null;
7991
7989
  let domObserver = null;
7992
7990
  let autoGenerating = false;
@@ -8002,38 +8000,8 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8002
8000
  return lang().startsWith("de");
8003
8001
  }
8004
8002
  const STYLE_ID = "accessify-alt-text-styles";
8005
- const HIGHLIGHT_CLASS = "accessify-alt-missing";
8006
8003
  function getStyles() {
8007
8004
  return `
8008
- .${HIGHLIGHT_CLASS} {
8009
- outline: 3px dashed #e63946 !important;
8010
- outline-offset: 3px !important;
8011
- position: relative !important;
8012
- }
8013
- .${HIGHLIGHT_CLASS}.accessify-alt-generating::after {
8014
- content: '\\2026';
8015
- position: absolute;
8016
- top: 4px;
8017
- left: 4px;
8018
- padding: 2px 6px;
8019
- background: #f77f00;
8020
- color: #fff;
8021
- font-family: system-ui, -apple-system, sans-serif;
8022
- font-size: 10px;
8023
- font-weight: 700;
8024
- border-radius: 3px;
8025
- line-height: 1.4;
8026
- pointer-events: none;
8027
- z-index: 1;
8028
- }
8029
- .${HIGHLIGHT_CLASS}.accessify-alt-done {
8030
- outline-color: #2a9d8f !important;
8031
- outline-style: solid !important;
8032
- }
8033
- .${HIGHLIGHT_CLASS}.accessify-alt-done::after {
8034
- content: none;
8035
- }
8036
-
8037
8005
  img[data-a11y-describable="true"]:not([data-a11y-is-link="true"]) {
8038
8006
  cursor: help !important;
8039
8007
  }
@@ -8048,8 +8016,8 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8048
8016
  padding: 0;
8049
8017
  border: none;
8050
8018
  border-radius: 50%;
8051
- background: rgba(26, 26, 46, 0.85);
8052
- color: #e0e0e0;
8019
+ background: rgba(0, 0, 0, 0.55);
8020
+ color: #fff;
8053
8021
  font-family: system-ui, -apple-system, sans-serif;
8054
8022
  font-size: 14px;
8055
8023
  font-weight: 700;
@@ -8059,60 +8027,44 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8059
8027
  opacity: 0;
8060
8028
  transition: opacity 0.15s ease;
8061
8029
  backdrop-filter: blur(4px);
8062
- box-shadow: 0 2px 8px rgba(0,0,0,0.3);
8063
8030
  }
8064
8031
  img[data-a11y-is-link="true"]:hover ~ .accessify-describe-btn,
8065
8032
  .accessify-describe-btn:hover {
8066
8033
  opacity: 1;
8067
8034
  }
8068
8035
  .accessify-describe-btn:hover {
8069
- background: rgba(26, 26, 46, 0.95);
8070
- color: #fff;
8036
+ background: rgba(0, 0, 0, 0.75);
8071
8037
  }
8072
8038
 
8073
8039
  .accessify-describe-tooltip {
8074
8040
  position: fixed;
8075
8041
  z-index: 2147483647;
8076
- max-width: 340px;
8077
- padding: 14px 18px;
8078
- background: #1a1a2e;
8079
- color: #e0e0e0;
8080
- border-radius: 10px;
8081
- box-shadow: 0 6px 24px rgba(0,0,0,0.45);
8042
+ max-width: 320px;
8043
+ padding: 10px 14px;
8044
+ background: rgba(0, 0, 0, 0.75);
8045
+ color: #fff;
8046
+ border-radius: 8px;
8047
+ backdrop-filter: blur(8px);
8082
8048
  font-family: system-ui, -apple-system, sans-serif;
8083
- font-size: 14px;
8084
- line-height: 1.6;
8049
+ font-size: 13px;
8050
+ line-height: 1.5;
8085
8051
  word-break: break-word;
8086
- animation: accessify-fade-in 0.15s ease;
8087
- }
8088
- .accessify-describe-tooltip .accessify-describe-close {
8089
- position: absolute;
8090
- top: 6px;
8091
- right: 8px;
8092
- background: none;
8093
- border: none;
8094
- color: #888;
8095
- font-size: 16px;
8096
- cursor: pointer;
8097
- padding: 2px 6px;
8098
- line-height: 1;
8099
- }
8100
- .accessify-describe-tooltip .accessify-describe-close:hover {
8101
- color: #fff;
8052
+ animation: accessify-fade-in 0.12s ease;
8053
+ pointer-events: auto;
8102
8054
  }
8103
8055
  .accessify-describe-loading {
8104
8056
  display: flex;
8105
8057
  align-items: center;
8106
8058
  gap: 8px;
8107
- color: #aaa;
8059
+ color: #ddd;
8108
8060
  font-style: italic;
8109
8061
  }
8110
8062
  .accessify-describe-loading::before {
8111
8063
  content: '';
8112
- width: 14px;
8113
- height: 14px;
8114
- border: 2px solid #555;
8115
- border-top-color: #aaa;
8064
+ width: 12px;
8065
+ height: 12px;
8066
+ border: 2px solid rgba(255,255,255,0.3);
8067
+ border-top-color: #fff;
8116
8068
  border-radius: 50%;
8117
8069
  animation: accessify-spin 0.8s linear infinite;
8118
8070
  }
@@ -8123,37 +8075,6 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8123
8075
  from { opacity: 0; transform: translateY(4px); }
8124
8076
  to { opacity: 1; transform: translateY(0); }
8125
8077
  }
8126
-
8127
- .accessify-alt-badge {
8128
- position: fixed;
8129
- top: 12px;
8130
- right: 12px;
8131
- z-index: 2147483646;
8132
- display: flex;
8133
- align-items: center;
8134
- gap: 6px;
8135
- padding: 8px 14px;
8136
- background: #1a1a2e;
8137
- color: #f0f0f0;
8138
- border-radius: 8px;
8139
- box-shadow: 0 4px 16px rgba(0,0,0,0.3);
8140
- font-family: system-ui, -apple-system, sans-serif;
8141
- font-size: 13px;
8142
- user-select: none;
8143
- }
8144
- .accessify-alt-badge-count {
8145
- display: inline-flex;
8146
- align-items: center;
8147
- justify-content: center;
8148
- min-width: 22px;
8149
- height: 22px;
8150
- padding: 0 6px;
8151
- background: #e63946;
8152
- color: #fff;
8153
- font-size: 12px;
8154
- font-weight: 700;
8155
- border-radius: 11px;
8156
- }
8157
8078
  `;
8158
8079
  }
8159
8080
  function injectStyles() {
@@ -8172,15 +8093,6 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8172
8093
  hideDescribeTooltip();
8173
8094
  const tip = document.createElement("div");
8174
8095
  tip.className = "accessify-describe-tooltip";
8175
- const closeBtn = document.createElement("button");
8176
- closeBtn.className = "accessify-describe-close";
8177
- closeBtn.textContent = "×";
8178
- closeBtn.setAttribute("aria-label", "Close");
8179
- closeBtn.addEventListener("click", (e) => {
8180
- e.stopPropagation();
8181
- hideDescribeTooltip();
8182
- });
8183
- tip.appendChild(closeBtn);
8184
8096
  if (loading) {
8185
8097
  const loadingEl = document.createElement("div");
8186
8098
  loadingEl.className = "accessify-describe-loading";
@@ -8384,10 +8296,6 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8384
8296
  img.setAttribute("alt", altText2);
8385
8297
  img.setAttribute("title", altText2);
8386
8298
  processedImages.set(img, { generatedAlt: altText2 });
8387
- if (enabled) {
8388
- img.classList.add("accessify-alt-done");
8389
- img.classList.remove("accessify-alt-generating");
8390
- }
8391
8299
  }
8392
8300
  async function generateAll() {
8393
8301
  if (autoGenerating || !enabled || !aiService) return;
@@ -8404,12 +8312,10 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8404
8312
  uncached.push(img);
8405
8313
  }
8406
8314
  }
8407
- updateBadge();
8408
8315
  if (!uncached.length) {
8409
8316
  autoGenerating = false;
8410
8317
  return;
8411
8318
  }
8412
- uncached.forEach((img) => img.classList.add("accessify-alt-generating"));
8413
8319
  for (let i = 0; i < uncached.length; i += CONCURRENCY) {
8414
8320
  if (!enabled) break;
8415
8321
  const batch = uncached.slice(i, i + CONCURRENCY);
@@ -8427,10 +8333,8 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8427
8333
  }
8428
8334
  } catch (err) {
8429
8335
  console.warn("[Accessify] Alt-text generation failed:", getImageSrc(img), err);
8430
- img.classList.remove("accessify-alt-generating");
8431
8336
  }
8432
8337
  }));
8433
- updateBadge();
8434
8338
  }
8435
8339
  autoGenerating = false;
8436
8340
  }
@@ -8443,7 +8347,6 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8443
8347
  updateBadge();
8444
8348
  return;
8445
8349
  }
8446
- img.classList.add("accessify-alt-generating");
8447
8350
  try {
8448
8351
  const ctx = gatherImageContext(img);
8449
8352
  const alt = await aiService.generateAltText(src, ctx, lang());
@@ -8452,60 +8355,11 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8452
8355
  setCachedAltText(src, alt, lang()).catch(() => {
8453
8356
  });
8454
8357
  if (siteKey) persistAltTextToServer(siteKey, proxyUrl, src, alt, lang());
8455
- updateBadge();
8456
8358
  }
8457
8359
  } catch (err) {
8458
8360
  console.warn("[Accessify] Alt-text generation failed:", src, err);
8459
- img.classList.remove("accessify-alt-generating");
8460
8361
  }
8461
8362
  }
8462
- function updateBadge() {
8463
- removeBadge();
8464
- const remaining = missingAltImages.filter((img) => !processedImages.has(img)).length;
8465
- const generating = missingAltImages.filter((img) => img.classList.contains("accessify-alt-generating")).length;
8466
- if (generating > 0) {
8467
- showBadge(isDE() ? `${generating} Bilder werden analysiert…` : `Analyzing ${generating} images…`, "#f77f00", generating);
8468
- return;
8469
- }
8470
- if (remaining === 0 && processedImages.size > 0) {
8471
- showBadge(
8472
- isDE() ? `✓ ${processedImages.size} Bildbeschreibungen erstellt` : `✓ ${processedImages.size} descriptions generated`,
8473
- "#2a9d8f",
8474
- 0
8475
- );
8476
- setTimeout(() => removeBadge(), 6e3);
8477
- return;
8478
- }
8479
- if (remaining > 0) {
8480
- showBadge(
8481
- isDE() ? `${remaining} Bilder ohne Beschreibung` : `${remaining} images without description`,
8482
- "#e63946",
8483
- remaining
8484
- );
8485
- }
8486
- }
8487
- function showBadge(text, color, count) {
8488
- const badge = document.createElement("div");
8489
- badge.className = "accessify-alt-badge";
8490
- badge.setAttribute("role", "status");
8491
- badge.setAttribute("aria-live", "polite");
8492
- if (count > 0) {
8493
- const c = document.createElement("span");
8494
- c.className = "accessify-alt-badge-count";
8495
- c.style.background = color;
8496
- c.textContent = String(count);
8497
- badge.appendChild(c);
8498
- }
8499
- const label = document.createElement("span");
8500
- label.textContent = text;
8501
- badge.appendChild(label);
8502
- document.body.appendChild(badge);
8503
- badgeEl = badge;
8504
- }
8505
- function removeBadge() {
8506
- badgeEl?.remove();
8507
- badgeEl = null;
8508
- }
8509
8363
  function tryRegisterImage(img) {
8510
8364
  if (!enabled) return;
8511
8365
  if (img.closest("#accessify-root")) return;
@@ -8515,9 +8369,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8515
8369
  if (img.naturalWidth < 20 || img.naturalHeight < 20) return;
8516
8370
  markImageDescribable(img);
8517
8371
  if (needsAltText(img)) {
8518
- img.classList.add(HIGHLIGHT_CLASS);
8519
8372
  missingAltImages.push(img);
8520
- updateBadge();
8521
8373
  generateSingle(img);
8522
8374
  }
8523
8375
  }
@@ -8534,18 +8386,23 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8534
8386
  if (!processedImages.has(img)) {
8535
8387
  processedImages.set(img, { generatedAlt: img.getAttribute("alt") || "" });
8536
8388
  missingAltImages.push(img);
8537
- img.classList.add(HIGHLIGHT_CLASS, "accessify-alt-done");
8538
8389
  }
8539
8390
  });
8540
8391
  const missing = scanForMissingAlt();
8541
8392
  for (const img of missing) {
8542
8393
  if (!missingAltImages.includes(img)) {
8543
8394
  missingAltImages.push(img);
8544
- img.classList.add(HIGHLIGHT_CLASS);
8545
8395
  }
8546
8396
  }
8547
- updateBadge();
8548
8397
  generateAll();
8398
+ document.querySelectorAll("img").forEach((img) => {
8399
+ if (img.closest("#accessify-root") || img.closest("accessify-widget")) return;
8400
+ const alt = img.getAttribute("alt");
8401
+ if (alt && alt.trim() && !img.getAttribute("title")) {
8402
+ img.setAttribute("title", alt);
8403
+ img.setAttribute("data-accessify-title", "auto");
8404
+ }
8405
+ });
8549
8406
  enableClickToDescribe();
8550
8407
  document.querySelectorAll("img").forEach((img) => {
8551
8408
  if (!img.complete) tryRegisterImage(img);
@@ -8578,9 +8435,9 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8578
8435
  domObserver?.disconnect();
8579
8436
  domObserver = null;
8580
8437
  disableClickToDescribe();
8581
- removeBadge();
8582
- missingAltImages.forEach((img) => {
8583
- img.classList.remove(HIGHLIGHT_CLASS, "accessify-alt-done", "accessify-alt-generating");
8438
+ document.querySelectorAll('img[data-accessify-title="auto"]').forEach((img) => {
8439
+ img.removeAttribute("title");
8440
+ img.removeAttribute("data-accessify-title");
8584
8441
  });
8585
8442
  missingAltImages = [];
8586
8443
  removeStyles();
@@ -8796,4 +8653,4 @@ export {
8796
8653
  init as i,
8797
8654
  t
8798
8655
  };
8799
- //# sourceMappingURL=index-CFoky8Ty.js.map
8656
+ //# sourceMappingURL=index-B8sAE1Po.js.map