@mizchi/vlmkit-core 0.8.0 → 0.9.0

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 (81) hide show
  1. package/README.md +1 -1
  2. package/dist/a11y-semantic.d.mts +34 -0
  3. package/dist/a11y-semantic.mjs +261 -0
  4. package/dist/arg-reader.d.mts +52 -0
  5. package/dist/arg-reader.mjs +129 -0
  6. package/dist/auth-state.d.mts +30 -0
  7. package/dist/auth-state.mjs +82 -0
  8. package/dist/authored-style-capture.d.mts +42 -0
  9. package/dist/authored-style-capture.mjs +117 -0
  10. package/dist/authored-style-diff.d.mts +15 -0
  11. package/dist/authored-style-diff.mjs +16 -0
  12. package/dist/cli-args.d.mts +35 -0
  13. package/dist/cli-args.mjs +63 -0
  14. package/dist/cli-error.d.mts +12 -0
  15. package/dist/cli-error.mjs +71 -0
  16. package/dist/computed-style-capture.d.mts +41 -0
  17. package/dist/computed-style-capture.mjs +589 -0
  18. package/dist/computed-style-diff.d.mts +83 -0
  19. package/dist/computed-style-diff.mjs +123 -0
  20. package/dist/diff-regions.d.mts +8 -0
  21. package/dist/diff-regions.mjs +52 -0
  22. package/dist/dom-equivalence.d.mts +51 -0
  23. package/dist/dom-equivalence.mjs +91 -0
  24. package/dist/dom-position-styles.d.mts +166 -0
  25. package/dist/dom-position-styles.mjs +296 -0
  26. package/dist/element-compare.d.mts +71 -0
  27. package/dist/element-compare.mjs +269 -0
  28. package/dist/gate-config.d.mts +116 -0
  29. package/dist/gate-config.mjs +169 -0
  30. package/dist/gate-exit.d.mts +45 -0
  31. package/dist/gate-exit.mjs +25 -0
  32. package/dist/heatmap-regions.d.mts +57 -0
  33. package/dist/heatmap-regions.mjs +158 -0
  34. package/dist/heatmap.d.mts +86 -0
  35. package/dist/heatmap.mjs +510 -0
  36. package/dist/image-resize.d.mts +34 -0
  37. package/dist/image-resize.mjs +92 -0
  38. package/dist/index.d.mts +15 -0
  39. package/dist/index.mjs +14 -0
  40. package/dist/legacy-names.d.mts +48 -0
  41. package/dist/legacy-names.mjs +134 -0
  42. package/dist/mask.d.mts +18 -0
  43. package/dist/mask.mjs +27 -0
  44. package/dist/navigation-redirect.d.mts +28 -0
  45. package/dist/navigation-redirect.mjs +47 -0
  46. package/dist/page-open.d.mts +102 -0
  47. package/dist/page-open.mjs +133 -0
  48. package/dist/png-utils.d.mts +30 -0
  49. package/dist/png-utils.mjs +80 -0
  50. package/dist/region-shift.d.mts +20 -0
  51. package/dist/region-shift.mjs +128 -0
  52. package/dist/run-ledger.d.mts +14 -0
  53. package/dist/run-ledger.mjs +31 -0
  54. package/dist/terminal-colors.d.mts +12 -0
  55. package/dist/terminal-colors.mjs +14 -0
  56. package/dist/text-rows.d.mts +121 -0
  57. package/dist/text-rows.mjs +246 -0
  58. package/{src/types.ts → dist/types.d.mts} +88 -206
  59. package/dist/types.mjs +1 -0
  60. package/package.json +17 -5
  61. package/src/a11y-semantic.ts +0 -384
  62. package/src/authored-style-capture.ts +0 -185
  63. package/src/authored-style-diff.ts +0 -32
  64. package/src/cli-args.ts +0 -29
  65. package/src/cli-error.ts +0 -85
  66. package/src/computed-style-capture.ts +0 -717
  67. package/src/computed-style-diff.ts +0 -192
  68. package/src/diff-regions.ts +0 -70
  69. package/src/dom-equivalence.ts +0 -158
  70. package/src/dom-position-styles.ts +0 -457
  71. package/src/element-compare.ts +0 -354
  72. package/src/heatmap-regions.ts +0 -245
  73. package/src/heatmap.ts +0 -670
  74. package/src/image-resize.ts +0 -112
  75. package/src/index.ts +0 -105
  76. package/src/mask.ts +0 -41
  77. package/src/png-utils.ts +0 -86
  78. package/src/region-shift.ts +0 -173
  79. package/src/run-ledger.ts +0 -39
  80. package/src/terminal-colors.ts +0 -13
  81. 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
- }