@mizchi/vlmkit-core 0.23.2 → 0.28.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 (112) hide show
  1. package/dist/a11y-semantic.d.mts +6 -10
  2. package/dist/a11y-semantic.mjs +3 -4
  3. package/dist/animated-image.d.mts +27 -0
  4. package/dist/animated-image.mjs +112 -0
  5. package/dist/apng.d.mts +5 -9
  6. package/dist/apng.mjs +6 -7
  7. package/dist/arg-reader.d.mts +9 -12
  8. package/dist/arg-reader.mjs +1 -2
  9. package/dist/auth-state.d.mts +6 -9
  10. package/dist/auth-state.mjs +1 -2
  11. package/dist/authored-style-capture.d.mts +7 -10
  12. package/dist/authored-style-capture.mjs +1 -2
  13. package/dist/authored-style-diff.d.mts +8 -12
  14. package/dist/authored-style-diff.mjs +1 -2
  15. package/dist/bitmap-font.d.mts +7 -10
  16. package/dist/bitmap-font.mjs +1 -2
  17. package/dist/browser-launch.d.mts +7 -11
  18. package/dist/browser-launch.mjs +1 -2
  19. package/dist/cli-args.d.mts +8 -11
  20. package/dist/cli-args.mjs +1 -2
  21. package/dist/cli-error.d.mts +10 -13
  22. package/dist/cli-error.mjs +2 -3
  23. package/dist/computed-style-capture.d.mts +20 -23
  24. package/dist/computed-style-capture.mjs +4 -5
  25. package/dist/computed-style-diff.d.mts +8 -11
  26. package/dist/computed-style-diff.mjs +2 -3
  27. package/dist/diff-regions.d.mts +3 -7
  28. package/dist/diff-regions.mjs +1 -2
  29. package/dist/dom-equivalence.d.mts +5 -8
  30. package/dist/dom-equivalence.mjs +1 -2
  31. package/dist/dom-position-styles.d.mts +14 -15
  32. package/dist/dom-position-styles.mjs +4 -5
  33. package/dist/element-compare.d.mts +8 -9
  34. package/dist/element-compare.mjs +5 -5
  35. package/dist/filmstrip.d.mts +60 -9
  36. package/dist/filmstrip.mjs +83 -12
  37. package/dist/gate-config.d.mts +18 -22
  38. package/dist/gate-config.mjs +8 -4
  39. package/dist/gate-exit.d.mts +5 -8
  40. package/dist/gate-exit.mjs +1 -2
  41. package/dist/gif.d.mts +41 -0
  42. package/dist/gif.mjs +73 -0
  43. package/dist/heatmap-regions.d.mts +4 -7
  44. package/dist/heatmap-regions.mjs +1 -2
  45. package/dist/heatmap.d.mts +21 -17
  46. package/dist/heatmap.mjs +23 -11
  47. package/dist/image-resize.d.mts +9 -12
  48. package/dist/image-resize.mjs +1 -2
  49. package/dist/image-timing.d.mts +57 -0
  50. package/dist/image-timing.mjs +166 -0
  51. package/dist/index.d.mts +14 -14
  52. package/dist/index.mjs +11 -11
  53. package/dist/mask.d.mts +5 -9
  54. package/dist/mask.mjs +1 -2
  55. package/dist/motion-spec.d.mts +97 -0
  56. package/dist/motion-spec.mjs +145 -0
  57. package/dist/navigation-redirect.d.mts +1 -4
  58. package/dist/navigation-redirect.mjs +1 -2
  59. package/dist/page-load.d.mts +40 -16
  60. package/dist/page-load.mjs +34 -5
  61. package/dist/page-open.d.mts +15 -15
  62. package/dist/page-open.mjs +4 -3
  63. package/dist/plugin/args.d.mts +16 -12
  64. package/dist/plugin/args.mjs +15 -4
  65. package/dist/plugin/browser.d.mts +3 -3
  66. package/dist/plugin/browser.mjs +2 -2
  67. package/dist/plugin/cli-entry.d.mts +1 -4
  68. package/dist/plugin/cli-entry.mjs +1 -2
  69. package/dist/plugin/contract.d.mts +17 -21
  70. package/dist/plugin/contract.mjs +1 -2
  71. package/dist/plugin/index.d.mts +6 -9
  72. package/dist/plugin/index.mjs +7 -8
  73. package/dist/plugin/load.d.mts +7 -11
  74. package/dist/plugin/load.mjs +1 -2
  75. package/dist/plugin/registry.d.mts +8 -12
  76. package/dist/plugin/registry.mjs +1 -2
  77. package/dist/plugin/rule-prose.d.mts +4 -8
  78. package/dist/plugin/rule-prose.mjs +1 -2
  79. package/dist/plugin/rule-tier.d.mts +7 -11
  80. package/dist/plugin/rule-tier.mjs +1 -2
  81. package/dist/plugin/rules.d.mts +18 -22
  82. package/dist/plugin/rules.mjs +1 -2
  83. package/dist/plugin/runner.d.mts +18 -21
  84. package/dist/plugin/runner.mjs +55 -6
  85. package/dist/png-decode.d.mts +17 -0
  86. package/dist/png-decode.mjs +160 -0
  87. package/dist/png-utils.d.mts +7 -10
  88. package/dist/png-utils.mjs +3 -3
  89. package/dist/project-config.d.mts +7 -10
  90. package/dist/project-config.mjs +1 -2
  91. package/dist/rect-overlap.d.mts +3 -6
  92. package/dist/rect-overlap.mjs +1 -2
  93. package/dist/region-shift.d.mts +3 -6
  94. package/dist/region-shift.mjs +1 -2
  95. package/dist/run-ledger.d.mts +10 -13
  96. package/dist/run-ledger.mjs +4 -4
  97. package/dist/stable-selector.d.mts +1 -4
  98. package/dist/stable-selector.mjs +1 -2
  99. package/dist/terminal-colors.d.mts +8 -11
  100. package/dist/terminal-colors.mjs +1 -2
  101. package/dist/text-rows.d.mts +10 -13
  102. package/dist/text-rows.mjs +1 -2
  103. package/dist/types.d.mts +87 -64
  104. package/dist/version.d.mts +1 -4
  105. package/dist/version.mjs +2 -3
  106. package/dist/video-decode.d.mts +144 -0
  107. package/dist/video-decode.mjs +939 -0
  108. package/dist/video-frames.d.mts +310 -0
  109. package/dist/video-frames.mjs +576 -0
  110. package/dist/webp.d.mts +7 -11
  111. package/dist/webp.mjs +3 -3
  112. package/package.json +7 -7
@@ -0,0 +1,144 @@
1
+ import { SelectionRequest, VideoStream } from "./video-frames.mjs";
2
+ import { FramesManifest } from "@mizchi/vlmkit-judge/frames.ts";
3
+ /** Frame files are named `NNNN-…`: past 9999 a glob no longer sorts them in order. */
4
+ export declare const MAX_SCAN_FRAMES = 9999;
5
+ /** Refused above this unless asked for: a minute at 60fps, already gigabytes of PNG at 1080p. */
6
+ export declare const DEFAULT_MAX_FRAMES = 3600;
7
+ /** File extensions `check flash` reads as a recording rather than a page. */
8
+ export declare const VIDEO_EXTENSIONS: ReadonlySet<string>;
9
+ /**
10
+ * Whether `check flash` reads a source as a recording: a local file with a video extension (a
11
+ * page's query or hash is not its extension: `player.html?clip=a.gif` is a page), or a `.png`
12
+ * that is an animated PNG — the APNG spec's own extension, which a page sweep would only report
13
+ * as an unmeasured animated image.
14
+ */
15
+ export declare function isVideoFile(path: string): boolean;
16
+ export declare function apngDeclaredFrames(file: string): number | null;
17
+ export interface DecoderPaths {
18
+ /** The user's ffmpeg; default `VLMKIT_FFMPEG`, else `ffmpeg` on PATH. */
19
+ ffmpeg?: string;
20
+ /** Default `VLMKIT_FFPROBE`, else the ffprobe beside `ffmpeg` when that is a path, else `ffprobe` on PATH. */
21
+ ffprobe?: string;
22
+ env?: Record<string, string | undefined>;
23
+ }
24
+ export interface Decoder {
25
+ ffmpeg: string;
26
+ ffprobe: string;
27
+ /** `ffmpeg 6.1.1-3ubuntu5`: what the frames say decoded them. */
28
+ name: string;
29
+ }
30
+ /**
31
+ * A bare name resolved on PATH, never in the working directory: Windows' own search tries the
32
+ * current directory first, so an `ffmpeg.exe` dropped beside a folder of recordings would run. Only
33
+ * absolute entries are searched (`.`, `./`, `bin` are the working directory), and only what a spawn
34
+ * without a shell can run: on POSIX an executable file (a non-executable one is skipped, as execvp
35
+ * skips it), on Windows the `.com` / `.exe` libuv runs (not an extensionless npm shim, not a
36
+ * `.bat`), with a quoted entry unquoted. The path returned is absolute, so nothing searches again.
37
+ */
38
+ export declare function onPath(name: string, env: Record<string, string | undefined>, platform?: NodeJS.Platform): string | null;
39
+ /** Find the user's ffmpeg and ffprobe and ask ffmpeg its version. Throws a UsageError naming the remedy. */
40
+ export declare function findDecoder(paths?: DecoderPaths): Promise<Decoder>;
41
+ export interface ScanVideoOptions extends DecoderPaths {
42
+ /** The recording. */
43
+ file: string;
44
+ /** Where frames and `frames.json` go; default `<recording>.frames/` beside it (`rec.mp4.frames/`). */
45
+ out?: string;
46
+ selection?: SelectionRequest;
47
+ /** The width the video plays at, in CSS px; default its own width (one frame pixel per CSS px). */
48
+ displayWidth?: number;
49
+ maxFrames?: number;
50
+ /** A video stream's index in the file; default the one marked default, else the largest, never cover art. */
51
+ stream?: number;
52
+ /** The YUV matrix to convert with, over the stream's tag or the BT.601 default (`COLOR_MATRICES`). */
53
+ colorMatrix?: string;
54
+ /** The range to convert with, over the stream's tag or the limited default. */
55
+ colorRange?: "tv" | "pc";
56
+ /** What transparent pixels are composited over (default white, a browser's default page). */
57
+ background?: "white" | "black";
58
+ }
59
+ export interface ScanVideoResult {
60
+ manifestPath: string;
61
+ manifest: FramesManifest;
62
+ stream: VideoStream;
63
+ /** Frames the recording decodes to. */
64
+ streamFrames: number;
65
+ timingMs: {
66
+ probe: number;
67
+ decode: number;
68
+ };
69
+ }
70
+ /** `rec.mp4.frames/` beside the recording: the extension stays, so `clip.mp4` and `clip.webm` do not share one. */
71
+ export declare const defaultFramesDir: (file: string) => string;
72
+ /** A lock or temporary directory whose owner cannot be seen is taken as abandoned only this old. */
73
+ export declare const STALE_UNKNOWN_MS: number;
74
+ /** Whether pid is a process this one can see. */
75
+ export declare const alive: (pid: number) => boolean;
76
+ /**
77
+ * Which pids `alive` can judge: this host and PID namespace. A pid from a container sharing the
78
+ * directory, or from `unshare`, reads as dead here (measured: a sandboxed run removed a live
79
+ * one's frames), so an owner of another identity is never taken as gone by its pid.
80
+ */
81
+ export declare function processIdentity(): string;
82
+ /**
83
+ * The lines ffmpeg logged at error level or worse (`-loglevel level+info` tags each line), from the
84
+ * input's side — the demuxer and the decoder — not the PNG writer's: it exits 0 on a truncated
85
+ * file. By level, not by wording: Matroska says `File ended prematurely` and HEVC `The cu_qp_delta
86
+ * 80 is outside the valid range`, which no keyword list held, and a title with "corrupt" in it is
87
+ * metadata at info level.
88
+ */
89
+ export declare function decodeErrors(lines: readonly string[]): string[];
90
+ /** A lost or damaged packet: frames may be missing between the ones decoded. */
91
+ export declare const CORRUPT_PACKET: RegExp;
92
+ /**
93
+ * Decode `file` with the user's ffmpeg into `out` (`NNNN-t<ms>.png` + `frames.json`). Refuses
94
+ * (UsageError) a file with no video stream, an HDR one, one that decodes to frames of more than one
95
+ * size, more frames than `maxFrames`, and anything the decoder itself cannot read — never a
96
+ * sequence of black frames standing for a picture that was not decoded.
97
+ */
98
+ export declare function scanVideo(options: ScanVideoOptions): Promise<ScanVideoResult>;
99
+ export interface ImportFramesOptions {
100
+ /** A directory of PNGs another decoder wrote, one per frame, named so they sort in order. */
101
+ dir: string;
102
+ /**
103
+ * One timestamp in seconds per line, in the frames' order (ffprobe's `best_effort_timestamp_time`)
104
+ * — or, as ffprobe prints `key_frame,best_effort_timestamp_time,pkt_pos`, the keyframe flag (0 or
105
+ * 1) before it and the packet's position after it, so the frames know where the codec re-quantizes.
106
+ */
107
+ pts?: string;
108
+ /** A constant rate instead of a timestamp file. */
109
+ fps?: number;
110
+ displayWidth?: number;
111
+ /** The frames are what was recorded, exactly (a lossless codec, or a renderer's own output). */
112
+ lossless?: boolean;
113
+ /**
114
+ * The directory holds every frame the recording shows (the recipe's `-fps_mode passthrough`
115
+ * writes them all). Without it nothing says another tool did not thin them (`-vf fps=5`), so the
116
+ * sequence is not claimed complete and a pass on it is not backed.
117
+ */
118
+ everyFrame?: boolean;
119
+ /**
120
+ * The frames are one pass of an animation that loops (a GIF / APNG another tool composited):
121
+ * how many times it plays, `null` forever. The timestamp file then ends with one more line, the
122
+ * pass's end, and the pass is repeated as a browser repeats it — to one pass and a second more
123
+ * for a loop that never ends. One pass alone holds none of the windows across the seam.
124
+ */
125
+ loop?: number | null;
126
+ }
127
+ /** Timestamps from a sidecar: one number of seconds per line; ffprobe's csv may end each with a comma. */
128
+ export declare function parsePtsFile(text: string, file: string): number[];
129
+ /**
130
+ * A timestamp file as ffprobe writes it with `-of csv=p=0`: a time per line (`best_effort_timestamp_time`),
131
+ * or `key_frame,best_effort_timestamp_time[,pkt_pos]` — ffprobe prints a section's fields in its own
132
+ * order, whatever order -show_entries names them in. Trailing commas (side data) are dropped. Every
133
+ * line has the same fields; without the flag there are no keyframes to know.
134
+ */
135
+ export declare function parsePtsTable(text: string, file: string): {
136
+ seconds: number[];
137
+ keys: boolean[] | null;
138
+ pos: (number | undefined)[] | null;
139
+ };
140
+ /** Turn a directory of decoded frames plus their timestamps into a `vlmkit-frames/1` sequence (`frames.json` in that directory). */
141
+ export declare function importFrames(options: ImportFramesOptions): Promise<{
142
+ manifestPath: string;
143
+ manifest: FramesManifest;
144
+ }>;