@markdy/renderer-dom 1.4.17 → 1.4.19

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.
Files changed (2) hide show
  1. package/dist/index.js +30 -11
  2. package/package.json +6 -7
package/dist/index.js CHANGED
@@ -6301,12 +6301,20 @@ function buildBeatCaptionAnimations(beats, layer) {
6301
6301
  function isDarkBgColor(colorStr) {
6302
6302
  if (!colorStr || colorStr === "transparent" || colorStr === "rgba(0, 0, 0, 0)") return null;
6303
6303
  const match = colorStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/i);
6304
- if (!match) return null;
6305
- const r = parseInt(match[1], 10);
6306
- const g = parseInt(match[2], 10);
6307
- const b = parseInt(match[3], 10);
6308
- const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
6309
- return luma < 128;
6304
+ if (match) {
6305
+ const r = parseInt(match[1], 10);
6306
+ const g = parseInt(match[2], 10);
6307
+ const b = parseInt(match[3], 10);
6308
+ const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
6309
+ return luma < 128;
6310
+ }
6311
+ const oklMatch = colorStr.match(/ok(?:lch|lab)\(\s*([\d.]+)(%?)/i);
6312
+ if (oklMatch) {
6313
+ let l = parseFloat(oklMatch[1]);
6314
+ if (oklMatch[2] === "%") l /= 100;
6315
+ return l < 0.5;
6316
+ }
6317
+ return null;
6310
6318
  }
6311
6319
  function checkElementTheme(el, lightTheme = "paper", darkTheme = "nebula") {
6312
6320
  const themeAttr = el.getAttribute("data-theme") || el.dataset.theme || el.getAttribute("data-mode") || el.getAttribute("data-bs-theme") || el.getAttribute("data-color-mode") || el.getAttribute("data-color-scheme");
@@ -6315,10 +6323,21 @@ function checkElementTheme(el, lightTheme = "paper", darkTheme = "nebula") {
6315
6323
  if (lower.includes("dark")) return darkTheme;
6316
6324
  if (lower.includes("light")) return lightTheme;
6317
6325
  }
6318
- const cls = el.className;
6319
- if (typeof cls === "string" && cls.length > 0) {
6320
- if (/\b(dark|dark-mode|dark-theme|theme-dark|vscode-dark)\b/i.test(cls)) return darkTheme;
6321
- if (/\b(light|light-mode|light-theme|theme-light|vscode-light)\b/i.test(cls)) return lightTheme;
6326
+ if (el.classList) {
6327
+ const darkClasses = ["dark", "dark-mode", "dark-theme", "theme-dark", "vscode-dark"];
6328
+ for (const c of darkClasses) {
6329
+ if (el.classList.contains(c)) return darkTheme;
6330
+ }
6331
+ const lightClasses = ["light", "light-mode", "light-theme", "theme-light", "vscode-light"];
6332
+ for (const c of lightClasses) {
6333
+ if (el.classList.contains(c)) return lightTheme;
6334
+ }
6335
+ } else {
6336
+ const cls = el.className;
6337
+ if (typeof cls === "string" && cls.length > 0) {
6338
+ if (/(?:^|\s)(dark|dark-mode|dark-theme|theme-dark|vscode-dark)(?:\s|$)/i.test(cls)) return darkTheme;
6339
+ if (/(?:^|\s)(light|light-mode|light-theme|theme-light|vscode-light)(?:\s|$)/i.test(cls)) return lightTheme;
6340
+ }
6322
6341
  }
6323
6342
  return null;
6324
6343
  }
@@ -6377,7 +6396,7 @@ function detectHostTheme(container, defaults) {
6377
6396
  if (bodyCheck) return bodyCheck;
6378
6397
  }
6379
6398
  if (typeof window !== "undefined" && typeof window.getComputedStyle === "function") {
6380
- let bgEl = container ?? document.body ?? null;
6399
+ let bgEl = (container ? container.parentElement : null) ?? document.body ?? null;
6381
6400
  while (bgEl) {
6382
6401
  try {
6383
6402
  const bg = window.getComputedStyle(bgEl).backgroundColor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markdy/renderer-dom",
3
- "version": "1.4.17",
3
+ "version": "1.4.19",
4
4
  "description": "Browser renderer for diagram-native animated MarkdyScript architecture diagrams, built on the Web Animations API.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,19 +41,18 @@
41
41
  "url": "https://github.com/HoangYell/markdy-com/issues"
42
42
  },
43
43
  "publishConfig": {
44
- "access": "public",
45
- "registry": "https://registry.npmjs.org"
44
+ "access": "public"
46
45
  },
47
46
  "dependencies": {
48
- "html2canvas": "^1.4.1",
49
- "@markdy/core": "1.4.17"
47
+ "@markdy/core": "^1.4.19",
48
+ "html2canvas": "^1.4.1"
50
49
  },
51
50
  "devDependencies": {
51
+ "@markdy/stdlib-systems": "^1.4.19",
52
52
  "jsdom": "^29.1.1",
53
53
  "tsup": "^8.5.1",
54
54
  "typescript": "^5.9.3",
55
- "vitest": "^4.1.7",
56
- "@markdy/stdlib-systems": "1.4.17"
55
+ "vitest": "^4.1.7"
57
56
  },
58
57
  "scripts": {
59
58
  "build": "tsup",