@mizchi/vlmkit-core 0.8.0 → 0.8.1

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 (66) hide show
  1. package/dist/a11y-semantic.d.mts +34 -0
  2. package/dist/a11y-semantic.mjs +261 -0
  3. package/dist/authored-style-capture.d.mts +42 -0
  4. package/dist/authored-style-capture.mjs +117 -0
  5. package/dist/authored-style-diff.d.mts +15 -0
  6. package/dist/authored-style-diff.mjs +16 -0
  7. package/dist/cli-args.d.mts +11 -0
  8. package/dist/cli-args.mjs +21 -0
  9. package/dist/cli-error.d.mts +4 -0
  10. package/dist/cli-error.mjs +59 -0
  11. package/dist/computed-style-capture.d.mts +41 -0
  12. package/dist/computed-style-capture.mjs +589 -0
  13. package/dist/computed-style-diff.d.mts +83 -0
  14. package/dist/computed-style-diff.mjs +123 -0
  15. package/dist/diff-regions.d.mts +8 -0
  16. package/dist/diff-regions.mjs +52 -0
  17. package/dist/dom-equivalence.d.mts +51 -0
  18. package/dist/dom-equivalence.mjs +91 -0
  19. package/dist/dom-position-styles.d.mts +166 -0
  20. package/dist/dom-position-styles.mjs +296 -0
  21. package/dist/element-compare.d.mts +71 -0
  22. package/dist/element-compare.mjs +269 -0
  23. package/dist/heatmap-regions.d.mts +57 -0
  24. package/dist/heatmap-regions.mjs +158 -0
  25. package/dist/heatmap.d.mts +86 -0
  26. package/dist/heatmap.mjs +510 -0
  27. package/dist/image-resize.d.mts +34 -0
  28. package/dist/image-resize.mjs +92 -0
  29. package/dist/index.d.mts +15 -0
  30. package/dist/index.mjs +14 -0
  31. package/dist/mask.d.mts +18 -0
  32. package/dist/mask.mjs +27 -0
  33. package/dist/png-utils.d.mts +30 -0
  34. package/dist/png-utils.mjs +80 -0
  35. package/dist/region-shift.d.mts +20 -0
  36. package/dist/region-shift.mjs +128 -0
  37. package/dist/run-ledger.d.mts +14 -0
  38. package/dist/run-ledger.mjs +31 -0
  39. package/dist/terminal-colors.d.mts +12 -0
  40. package/dist/terminal-colors.mjs +14 -0
  41. package/dist/text-rows.d.mts +121 -0
  42. package/dist/text-rows.mjs +246 -0
  43. package/{src/types.ts → dist/types.d.mts} +88 -206
  44. package/dist/types.mjs +1 -0
  45. package/package.json +17 -5
  46. package/src/a11y-semantic.ts +0 -384
  47. package/src/authored-style-capture.ts +0 -185
  48. package/src/authored-style-diff.ts +0 -32
  49. package/src/cli-args.ts +0 -29
  50. package/src/cli-error.ts +0 -85
  51. package/src/computed-style-capture.ts +0 -717
  52. package/src/computed-style-diff.ts +0 -192
  53. package/src/diff-regions.ts +0 -70
  54. package/src/dom-equivalence.ts +0 -158
  55. package/src/dom-position-styles.ts +0 -457
  56. package/src/element-compare.ts +0 -354
  57. package/src/heatmap-regions.ts +0 -245
  58. package/src/heatmap.ts +0 -670
  59. package/src/image-resize.ts +0 -112
  60. package/src/index.ts +0 -105
  61. package/src/mask.ts +0 -41
  62. package/src/png-utils.ts +0 -86
  63. package/src/region-shift.ts +0 -173
  64. package/src/run-ledger.ts +0 -39
  65. package/src/terminal-colors.ts +0 -13
  66. package/src/text-rows.ts +0 -412
package/src/cli-error.ts DELETED
@@ -1,85 +0,0 @@
1
- /**
2
- * Shared CLI error-prettifier. Recognizes common error shapes that
3
- * make `vrt` look user-hostile (ENOENT stack traces, Playwright
4
- * navigation errors with absolute source paths) and rewrites them
5
- * to a one-line message.
6
- *
7
- * Use:
8
- * main().catch(handleCliError);
9
- */
10
- import { statSync } from "node:fs";
11
-
12
- export function handleCliError(e: unknown): never {
13
- // Node fs errors carry the offending path on `.path`; that's more
14
- // reliable than parsing it out of `.message` (which sometimes
15
- // doesn't include the path at all, e.g. EISDIR from readFile).
16
- const err = e as { code?: string; message?: string; name?: string; path?: string };
17
- const msg = String(err?.message ?? e);
18
-
19
- // ENOENT — missing local file path.
20
- if (err?.code === "ENOENT") {
21
- const path = err.path ?? msg.match(/ENOENT: no such file or directory[^']*'([^']+)'/)?.[1] ?? "?";
22
- process.stderr.write(`error: file not found: ${path}\n`);
23
- process.exit(1);
24
- }
25
- // EISDIR — caller passed a directory where an HTML file (or other
26
- // single-file artifact) was expected. Surfaced repeatedly in
27
- // back-to-back cold-start dogfoods (2026-05-15) as the worst raw-
28
- // stack-trace first impression in the toolkit. Almost every vrt
29
- // subcommand accepts `<html-or-url>` as its first positional, so
30
- // catching the directory case here covers all of them at once.
31
- // Node's fsPromises.readFile drops `err.path`, so we fall back to
32
- // scanning argv for any positional that exists as a directory.
33
- if (err?.code === "EISDIR") {
34
- const argvDir = findDirectoryArg();
35
- const path = err.path ?? msg.match(/EISDIR:[^']*'([^']+)'/)?.[1] ?? argvDir ?? "?";
36
- const hint = path === "?"
37
- ? " hint: pass the path to a specific .html file."
38
- : ` hint: pass the path to a specific .html file inside it (e.g. ${path}/page.html).`;
39
- process.stderr.write(`error: expected an HTML file, got a directory: ${path}\n${hint}\n`);
40
- process.exit(1);
41
- }
42
- // Playwright navigation failure (DNS / connection refused / SSL).
43
- if (
44
- /net::ERR_NAME_NOT_RESOLVED/i.test(msg)
45
- || /net::ERR_CONNECTION_REFUSED/i.test(msg)
46
- || /Cannot navigate to invalid URL/i.test(msg)
47
- ) {
48
- const url = msg.match(/Navigating to ([^,]+)/i)?.[1]
49
- ?? msg.match(/(https?:\/\/[^\s"]+)/)?.[1]
50
- ?? "the URL";
51
- let reason = "failed to load";
52
- if (/ERR_NAME_NOT_RESOLVED/i.test(msg)) reason = "host could not be resolved (check the URL)";
53
- else if (/ERR_CONNECTION_REFUSED/i.test(msg)) reason = "connection refused (is the server running?)";
54
- else if (/invalid URL/i.test(msg)) reason = "not a valid URL";
55
- process.stderr.write(`error: cannot load ${url}: ${reason}\n`);
56
- process.exit(1);
57
- }
58
- // Playwright timeout.
59
- if (/Timeout \d+ms exceeded/i.test(msg)) {
60
- process.stderr.write(`error: page load timed out (${msg.match(/Timeout \d+ms exceeded[^.]*/i)?.[0] ?? msg})\n`);
61
- process.exit(1);
62
- }
63
- // Default: full error for the developer.
64
- console.error(e);
65
- process.exit(1);
66
- }
67
-
68
- /**
69
- * EISDIR fallback: Node's `fsPromises.readFile` doesn't attach `.path`
70
- * to the error, and the message string doesn't include the path
71
- * either. Scan argv for the first positional that exists as a
72
- * directory — close enough since most vrt subcommands take exactly
73
- * one path argument and the failure happens during the initial read.
74
- */
75
- function findDirectoryArg(): string | undefined {
76
- for (const arg of process.argv.slice(2)) {
77
- if (arg.startsWith("-")) continue;
78
- try {
79
- if (statSync(arg).isDirectory()) return arg;
80
- } catch {
81
- // arg doesn't exist as a path; keep scanning.
82
- }
83
- }
84
- return undefined;
85
- }