@mizchi/vlmkit-core 0.23.1 → 0.24.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 (77) hide show
  1. package/dist/a11y-semantic.d.mts +7 -9
  2. package/dist/a11y-semantic.mjs +2 -2
  3. package/dist/animated-image.d.mts +29 -0
  4. package/dist/animated-image.mjs +113 -0
  5. package/dist/apng.d.mts +6 -8
  6. package/dist/apng.mjs +5 -5
  7. package/dist/arg-reader.d.mts +10 -11
  8. package/dist/auth-state.d.mts +7 -8
  9. package/dist/authored-style-capture.d.mts +8 -9
  10. package/dist/authored-style-diff.d.mts +7 -9
  11. package/dist/bitmap-font.d.mts +8 -9
  12. package/dist/browser-launch.d.mts +8 -10
  13. package/dist/cli-args.d.mts +9 -10
  14. package/dist/cli-error.d.mts +10 -11
  15. package/dist/cli-error.mjs +1 -1
  16. package/dist/computed-style-capture.d.mts +21 -22
  17. package/dist/computed-style-capture.mjs +3 -3
  18. package/dist/computed-style-diff.d.mts +8 -9
  19. package/dist/computed-style-diff.mjs +1 -1
  20. package/dist/diff-regions.d.mts +4 -6
  21. package/dist/dom-equivalence.d.mts +6 -7
  22. package/dist/dom-position-styles.d.mts +15 -14
  23. package/dist/dom-position-styles.mjs +3 -3
  24. package/dist/element-compare.d.mts +9 -8
  25. package/dist/element-compare.mjs +3 -2
  26. package/dist/filmstrip.d.mts +61 -8
  27. package/dist/filmstrip.mjs +82 -10
  28. package/dist/gate-config.d.mts +19 -21
  29. package/dist/gate-exit.d.mts +6 -7
  30. package/dist/gif.d.mts +43 -0
  31. package/dist/gif.mjs +74 -0
  32. package/dist/heatmap-regions.d.mts +5 -6
  33. package/dist/heatmap.d.mts +21 -15
  34. package/dist/heatmap.mjs +11 -3
  35. package/dist/image-resize.d.mts +9 -10
  36. package/dist/image-timing.d.mts +59 -0
  37. package/dist/image-timing.mjs +167 -0
  38. package/dist/index.d.mts +2 -2
  39. package/dist/mask.d.mts +6 -8
  40. package/dist/navigation-redirect.d.mts +2 -3
  41. package/dist/page-load.d.mts +12 -13
  42. package/dist/page-open.d.mts +12 -14
  43. package/dist/plugin/args.d.mts +17 -11
  44. package/dist/plugin/args.mjs +12 -1
  45. package/dist/plugin/cli-entry.d.mts +2 -3
  46. package/dist/plugin/contract.d.mts +18 -20
  47. package/dist/plugin/index.d.mts +3 -4
  48. package/dist/plugin/index.mjs +2 -2
  49. package/dist/plugin/load.d.mts +7 -9
  50. package/dist/plugin/registry.d.mts +9 -11
  51. package/dist/plugin/rule-prose.d.mts +5 -7
  52. package/dist/plugin/rule-tier.d.mts +8 -10
  53. package/dist/plugin/rules.d.mts +19 -21
  54. package/dist/plugin/runner.d.mts +19 -20
  55. package/dist/plugin/runner.mjs +43 -2
  56. package/dist/png-decode.d.mts +19 -0
  57. package/dist/png-decode.mjs +161 -0
  58. package/dist/png-utils.d.mts +8 -9
  59. package/dist/png-utils.mjs +2 -1
  60. package/dist/project-config.d.mts +8 -9
  61. package/dist/rect-overlap.d.mts +4 -5
  62. package/dist/region-shift.d.mts +3 -5
  63. package/dist/run-ledger.d.mts +11 -12
  64. package/dist/run-ledger.mjs +3 -2
  65. package/dist/stable-selector.d.mts +2 -3
  66. package/dist/terminal-colors.d.mts +9 -10
  67. package/dist/text-rows.d.mts +11 -12
  68. package/dist/types.d.mts +87 -62
  69. package/dist/version.d.mts +2 -3
  70. package/dist/version.mjs +1 -1
  71. package/dist/video-decode.d.mts +146 -0
  72. package/dist/video-decode.mjs +936 -0
  73. package/dist/video-frames.d.mts +306 -0
  74. package/dist/video-frames.mjs +565 -0
  75. package/dist/webp.d.mts +8 -10
  76. package/dist/webp.mjs +2 -1
  77. package/package.json +4 -4
package/dist/types.d.mts CHANGED
@@ -1,49 +1,49 @@
1
1
  //#region src/types.d.ts
2
- interface PlaywrightReport {
2
+ export interface PlaywrightReport {
3
3
  config: {
4
4
  rootDir: string;
5
5
  projects: ProjectConfig[];
6
6
  };
7
7
  suites: TestSuite[];
8
8
  }
9
- interface ProjectConfig {
9
+ export interface ProjectConfig {
10
10
  name: string;
11
11
  use: Record<string, unknown>;
12
12
  }
13
- interface TestSuite {
13
+ export interface TestSuite {
14
14
  title: string;
15
15
  file: string;
16
16
  suites?: TestSuite[];
17
17
  specs: TestSpec[];
18
18
  }
19
- interface TestSpec {
19
+ export interface TestSpec {
20
20
  title: string;
21
21
  ok: boolean;
22
22
  tests: TestResult[];
23
23
  }
24
- interface TestResult {
24
+ export interface TestResult {
25
25
  projectName: string;
26
26
  status: "expected" | "unexpected" | "flaky" | "skipped";
27
27
  duration: number;
28
28
  results: TestAttempt[];
29
29
  }
30
- interface TestAttempt {
30
+ export interface TestAttempt {
31
31
  status: "passed" | "failed" | "timedOut" | "skipped";
32
32
  duration: number;
33
33
  attachments: Attachment[];
34
34
  errors: TestError[];
35
35
  }
36
- interface Attachment {
36
+ export interface Attachment {
37
37
  name: string;
38
38
  contentType: string;
39
39
  path?: string;
40
40
  body?: string;
41
41
  }
42
- interface TestError {
42
+ export interface TestError {
43
43
  message: string;
44
44
  stack?: string;
45
45
  }
46
- interface VrtSnapshot {
46
+ export interface VrtSnapshot {
47
47
  testId: string;
48
48
  testTitle: string;
49
49
  projectName: string;
@@ -51,7 +51,7 @@ interface VrtSnapshot {
51
51
  baselinePath?: string;
52
52
  status: "new" | "unchanged" | "changed" | "missing";
53
53
  }
54
- interface VrtDiff {
54
+ export interface VrtDiff {
55
55
  snapshot: VrtSnapshot;
56
56
  diffPixels: number;
57
57
  /**
@@ -67,13 +67,13 @@ interface VrtDiff {
67
67
  mask?: DiffMaskSummary;
68
68
  }
69
69
  /** A rectangle the caller declared permanently non-deterministic. */
70
- interface DiffIgnoreRegion {
70
+ export interface DiffIgnoreRegion {
71
71
  x: number;
72
72
  y: number;
73
73
  width: number;
74
74
  height: number;
75
75
  }
76
- interface DiffIgnoredRegionReport extends DiffIgnoreRegion {
76
+ export interface DiffIgnoredRegionReport extends DiffIgnoreRegion {
77
77
  /**
78
78
  * Pixels this rect actually covered inside the compared area — less than
79
79
  * `width * height` when the rect hangs off the edge, and 0 when it misses the
@@ -97,7 +97,7 @@ interface DiffIgnoredRegionReport extends DiffIgnoreRegion {
97
97
  * 0.1%. `imagePixels - ignoredPixels === totalPixels` is the arithmetic a
98
98
  * reader can check.
99
99
  */
100
- interface DiffMaskSummary {
100
+ export interface DiffMaskSummary {
101
101
  regions: DiffIgnoredRegionReport[];
102
102
  /** De-duplicated count of pixels inside at least one ignore region. */
103
103
  ignoredPixels: number;
@@ -106,8 +106,8 @@ interface DiffMaskSummary {
106
106
  /** The compared area before masking (excludes size-mismatch overflow). */
107
107
  imagePixels: number;
108
108
  }
109
- type DiffRegionType = "shift" | "content" | "edge";
110
- interface DiffRegion {
109
+ export type DiffRegionType = "shift" | "content" | "edge";
110
+ export interface DiffRegion {
111
111
  x: number;
112
112
  y: number;
113
113
  width: number;
@@ -119,15 +119,41 @@ interface DiffRegion {
119
119
  shift?: DiffRegionShift;
120
120
  /** Deterministic DOM hit-test result for this region's bbox (diff png --elements-*). */
121
121
  selectorCandidate?: DiffRegionSelectorCandidate;
122
+ /**
123
+ * What changed, named by a model on this region's magnified crop (diff png --kind). The
124
+ * region, shift and colours stay the pixels'; this is the one field that is not measured.
125
+ */
126
+ kind?: DiffRegionKind;
127
+ /** Why --kind left this region unlabelled (over --kind-limit, a size Jev rejects, an API error). */
128
+ kindSkipped?: string;
129
+ /**
130
+ * The largest per-channel difference of any pixel in the region (0-255). A few levels is
131
+ * antialiasing or compositing, not a change of content.
132
+ */
133
+ maxChannelDelta?: number;
134
+ /**
135
+ * Only glyph and edge rendering differs: a 5x5 average removes most of the difference and it
136
+ * lightens as much as it darkens (antialiasing, a layer composited differently), with no
137
+ * measured shift. Not a change of content.
138
+ */
139
+ edgeOnly?: boolean;
140
+ }
141
+ export interface DiffRegionKind {
142
+ label: "text" | "color" | "position" | "presence";
143
+ confidence: number;
144
+ /** Below the measured threshold (0.6): every wrong label in the 2026-10-16 round was below it. */
145
+ uncertain: boolean;
146
+ /** The model that answered, as served (e.g. `jev-1.14.0`). */
147
+ model: string;
122
148
  }
123
- interface DiffRegionShift {
149
+ export interface DiffRegionShift {
124
150
  /** Content moved by +dx px horizontally in current (vs baseline). */
125
151
  dx: number;
126
152
  /** Content moved by +dy px vertically in current (vs baseline). */
127
153
  dy: number;
128
154
  confidence: number;
129
155
  }
130
- interface DiffRegionSelectorCandidate {
156
+ export interface DiffRegionSelectorCandidate {
131
157
  selector: string;
132
158
  confidence: "high" | "medium" | "low";
133
159
  path: string;
@@ -144,19 +170,19 @@ interface DiffRegionSelectorCandidate {
144
170
  */
145
171
  alternates?: Omit<DiffRegionSelectorCandidate, "alternates">[];
146
172
  }
147
- interface DiffRegionColor {
173
+ export interface DiffRegionColor {
148
174
  r: number;
149
175
  g: number;
150
176
  b: number;
151
177
  hex: string;
152
178
  }
153
- interface DiffRegionColorPair {
179
+ export interface DiffRegionColorPair {
154
180
  baseline: DiffRegionColor;
155
181
  current: DiffRegionColor;
156
182
  /** Euclidean RGB distance between baseline and current. */
157
183
  distance: number;
158
184
  }
159
- interface DiffRegionColorSample extends DiffRegionColorPair {
185
+ export interface DiffRegionColorSample extends DiffRegionColorPair {
160
186
  /**
161
187
  * The single differing pixel with the largest baseline↔current channel
162
188
  * delta, attached when the differing pixels are sparse (thin glyphs, a
@@ -166,14 +192,14 @@ interface DiffRegionColorSample extends DiffRegionColorPair {
166
192
  */
167
193
  peak?: DiffRegionColorPair;
168
194
  }
169
- interface ShiftRegion {
195
+ export interface ShiftRegion {
170
196
  yStart: number;
171
197
  yEnd: number;
172
198
  shift: number;
173
199
  /** Correlation strength of the chosen offset (0..1). Higher = more confident. */
174
200
  confidence?: number;
175
201
  }
176
- interface DiffReport {
202
+ export interface DiffReport {
177
203
  diffPixels: number;
178
204
  /** Measured pixels — see `VrtDiff.totalPixels`. */
179
205
  totalPixels: number;
@@ -188,45 +214,45 @@ interface DiffReport {
188
214
  compensatedDiffCount: number;
189
215
  compact: string;
190
216
  }
191
- type Language = "typescript" | "moonbit" | "rust";
192
- interface DepNode {
217
+ export type Language = "typescript" | "moonbit" | "rust";
218
+ export interface DepNode {
193
219
  id: string;
194
220
  filePath: string;
195
221
  language: Language;
196
222
  exports: string[];
197
223
  isComponent: boolean;
198
224
  }
199
- interface DepEdge {
225
+ export interface DepEdge {
200
226
  from: string;
201
227
  to: string;
202
228
  specifiers: string[];
203
229
  }
204
- interface DepGraph {
230
+ export interface DepGraph {
205
231
  nodes: Map<string, DepNode>;
206
232
  edges: DepEdge[];
207
233
  }
208
- interface AffectedComponent {
234
+ export interface AffectedComponent {
209
235
  node: DepNode;
210
236
  depth: number;
211
237
  changedDependencies: string[];
212
238
  }
213
- interface ChangeIntent {
239
+ export interface ChangeIntent {
214
240
  summary: string;
215
241
  expectedVisualChanges: VisualExpectation[];
216
242
  expectedA11yChanges: A11yExpectation[];
217
243
  affectedComponents: string[];
218
244
  changeType: "feature" | "bugfix" | "refactor" | "style" | "deps" | "a11y" | "unknown";
219
245
  }
220
- interface VisualExpectation {
246
+ export interface VisualExpectation {
221
247
  component: string;
222
248
  description: string;
223
249
  confidence: number;
224
250
  }
225
- interface A11yExpectation {
251
+ export interface A11yExpectation {
226
252
  testId: string;
227
253
  expectedChanges: ExpectedA11yChange[];
228
254
  }
229
- interface ExpectedA11yChange {
255
+ export interface ExpectedA11yChange {
230
256
  /** NL description (primary). Works standalone */
231
257
  description: string;
232
258
  /** Structured hint (optional). Used for heuristic matching */
@@ -235,14 +261,14 @@ interface ExpectedA11yChange {
235
261
  role?: string;
236
262
  name?: string;
237
263
  }
238
- interface VrtExpectation {
264
+ export interface VrtExpectation {
239
265
  /** NL description of the change intent (primary) */
240
266
  description: string;
241
267
  /** Structured intent (optional). Inferred from description if omitted */
242
268
  intent?: Partial<ChangeIntent>;
243
269
  pages: PageExpectation[];
244
270
  }
245
- interface PageExpectation {
271
+ export interface PageExpectation {
246
272
  testId: string;
247
273
  /** Expected state in NL (alternative to structured fields) */
248
274
  expect?: string;
@@ -252,7 +278,7 @@ interface PageExpectation {
252
278
  expectedA11yChanges?: ExpectedA11yChange[];
253
279
  expectedVisualChanges?: VisualExpectation[];
254
280
  }
255
- interface UiSpec {
281
+ export interface UiSpec {
256
282
  /** Description of this spec */
257
283
  description: string;
258
284
  /** Per-page invariants */
@@ -260,14 +286,14 @@ interface UiSpec {
260
286
  /** Global invariants (applied to all pages) */
261
287
  global?: SpecInvariant[];
262
288
  }
263
- interface PageSpec {
289
+ export interface PageSpec {
264
290
  testId: string;
265
291
  /** Purpose of this page */
266
292
  purpose?: string;
267
293
  /** Invariant list */
268
294
  invariants: SpecInvariant[];
269
295
  }
270
- interface SpecInvariant {
296
+ export interface SpecInvariant {
271
297
  /** NL description of the invariant (primary) */
272
298
  description: string;
273
299
  /** Structured hint (optional) */
@@ -279,12 +305,12 @@ interface SpecInvariant {
279
305
  /** Verification cost. "low" = heuristics, "high" = LLM/Vision */
280
306
  cost?: "low" | "high";
281
307
  }
282
- type SpecCheckType = "landmark-exists" | "label-present" | "no-whiteout" | "no-error-state" | "text-visible" | "element-count" | "heading-hierarchy" | "aria-relationships" | "color-contrast" | "responsive-layout" | "nl-assertion";
283
- interface IntrospectResult {
308
+ export type SpecCheckType = "landmark-exists" | "label-present" | "no-whiteout" | "no-error-state" | "text-visible" | "element-count" | "heading-hierarchy" | "aria-relationships" | "color-contrast" | "responsive-layout" | "nl-assertion";
309
+ export interface IntrospectResult {
284
310
  generatedAt: string;
285
311
  pages: PageIntrospection[];
286
312
  }
287
- interface PageIntrospection {
313
+ export interface PageIntrospection {
288
314
  testId: string;
289
315
  /** Auto-generated page description */
290
316
  description: string;
@@ -314,7 +340,7 @@ interface PageIntrospection {
314
340
  /** Auto-inferred invariants */
315
341
  suggestedInvariants: SpecInvariant[];
316
342
  }
317
- interface NlAssertion {
343
+ export interface NlAssertion {
318
344
  /** Assertion text */
319
345
  assert: string;
320
346
  /** Target page */
@@ -328,7 +354,7 @@ interface NlAssertion {
328
354
  checkedAt: string;
329
355
  };
330
356
  }
331
- interface LoopScore {
357
+ export interface LoopScore {
332
358
  usability: number;
333
359
  practicality: number;
334
360
  fixSteps: number;
@@ -337,43 +363,43 @@ interface LoopScore {
337
363
  summary: string;
338
364
  details: ScoreDetail[];
339
365
  }
340
- interface ScoreDetail {
366
+ export interface ScoreDetail {
341
367
  category: string;
342
368
  score: number;
343
369
  maxScore: number;
344
370
  reasoning: string;
345
371
  }
346
- interface DiffSemantics {
372
+ export interface DiffSemantics {
347
373
  filesChanged: FileChange[];
348
374
  commitMessage: string;
349
375
  intent: ChangeIntent;
350
376
  }
351
- interface FileChange {
377
+ export interface FileChange {
352
378
  path: string;
353
379
  additions: number;
354
380
  deletions: number;
355
381
  hunks: DiffHunk[];
356
382
  }
357
- interface DiffHunk {
383
+ export interface DiffHunk {
358
384
  header: string;
359
385
  content: string;
360
386
  startLine: number;
361
387
  endLine: number;
362
388
  }
363
- interface VrtVerdict {
389
+ export interface VrtVerdict {
364
390
  snapshotId: string;
365
391
  decision: "approve" | "reject" | "escalate";
366
392
  reasoning: string;
367
393
  matchedIntent?: VisualExpectation;
368
394
  confidence: number;
369
395
  }
370
- interface AgentContext {
396
+ export interface AgentContext {
371
397
  intent: ChangeIntent;
372
398
  diffs: VrtDiff[];
373
399
  verdicts: VrtVerdict[];
374
400
  qualityChecks: QualityCheckResult[];
375
401
  }
376
- interface A11yNode {
402
+ export interface A11yNode {
377
403
  role: string;
378
404
  name: string;
379
405
  id?: string;
@@ -395,13 +421,13 @@ interface A11yNode {
395
421
  ariaActiveDescendant?: string | string[];
396
422
  children?: A11yNode[];
397
423
  }
398
- interface A11ySnapshot {
424
+ export interface A11ySnapshot {
399
425
  testId: string;
400
426
  testTitle: string;
401
427
  tree: A11yNode;
402
428
  }
403
- type A11yChangeType = "node-added" | "node-removed" | "role-changed" | "name-changed" | "state-changed" | "structure-changed" | "landmark-changed";
404
- interface A11yChange {
429
+ export type A11yChangeType = "node-added" | "node-removed" | "role-changed" | "name-changed" | "state-changed" | "structure-changed" | "landmark-changed";
430
+ export interface A11yChange {
405
431
  type: A11yChangeType;
406
432
  path: string;
407
433
  before?: Partial<A11yNode>;
@@ -409,7 +435,7 @@ interface A11yChange {
409
435
  severity: "error" | "warning" | "info";
410
436
  description: string;
411
437
  }
412
- interface A11yDiff {
438
+ export interface A11yDiff {
413
439
  testId: string;
414
440
  changes: A11yChange[];
415
441
  hasRegression: boolean;
@@ -420,19 +446,19 @@ interface A11yDiff {
420
446
  modified: number;
421
447
  };
422
448
  }
423
- type VisualChangeType = "text-change" | "color-change" | "layout-shift" | "reflow" | "element-added" | "element-removed" | "icon-change";
424
- interface VisualSemanticChange {
449
+ export type VisualChangeType = "text-change" | "color-change" | "layout-shift" | "reflow" | "element-added" | "element-removed" | "icon-change" | "render-noise";
450
+ export interface VisualSemanticChange {
425
451
  type: VisualChangeType;
426
452
  region: DiffRegion;
427
453
  confidence: number;
428
454
  description: string;
429
455
  }
430
- interface VisualSemanticDiff {
456
+ export interface VisualSemanticDiff {
431
457
  testId: string;
432
458
  changes: VisualSemanticChange[];
433
459
  summary: string;
434
460
  }
435
- interface CrossValidationResult {
461
+ export interface CrossValidationResult {
436
462
  testId: string;
437
463
  visualDiff?: VisualSemanticDiff;
438
464
  a11yDiff?: A11yDiff;
@@ -441,7 +467,7 @@ interface CrossValidationResult {
441
467
  recommendation: "approve" | "reject" | "escalate";
442
468
  reasoning: string;
443
469
  }
444
- interface UnifiedAgentContext {
470
+ export interface UnifiedAgentContext {
445
471
  intent: ChangeIntent;
446
472
  vrtDiffs: VrtDiff[];
447
473
  a11yDiffs: A11yDiff[];
@@ -450,19 +476,19 @@ interface UnifiedAgentContext {
450
476
  verdicts: VrtVerdict[];
451
477
  qualityChecks: QualityCheckResult[];
452
478
  }
453
- interface QualityCheckResult {
479
+ export interface QualityCheckResult {
454
480
  check: QualityCheckType;
455
481
  passed: boolean;
456
482
  details: string;
457
483
  severity: "error" | "warning" | "info";
458
484
  }
459
- type QualityCheckType = "whiteout" | "error-state" | "coverage" | "layout-shift" | "empty-content" | "a11y-regression" | "a11y-coverage" | "landmark-missing" | "label-missing";
485
+ export type QualityCheckType = "whiteout" | "error-state" | "coverage" | "layout-shift" | "empty-content" | "a11y-regression" | "a11y-coverage" | "landmark-missing" | "label-missing";
460
486
  /**
461
487
  * A targetable HTML source: either an inline HTML string or a URL the
462
488
  * server fetches on the client's behalf. Shared by both the HTTP API
463
489
  * (`api-types`) and the smoke runner (`vrt-markup/inspect`).
464
490
  */
465
- interface HtmlSource {
491
+ export interface HtmlSource {
466
492
  /** Inline HTML */
467
493
  html?: string;
468
494
  /** URL (fetched server-side) */
@@ -470,5 +496,4 @@ interface HtmlSource {
470
496
  /** Label (for reports) */
471
497
  label?: string;
472
498
  }
473
- //#endregion
474
- export { A11yChange, A11yChangeType, A11yDiff, A11yExpectation, A11yNode, A11ySnapshot, AffectedComponent, AgentContext, Attachment, ChangeIntent, CrossValidationResult, DepEdge, DepGraph, DepNode, DiffHunk, DiffIgnoreRegion, DiffIgnoredRegionReport, DiffMaskSummary, DiffRegion, DiffRegionColor, DiffRegionColorPair, DiffRegionColorSample, DiffRegionSelectorCandidate, DiffRegionShift, DiffRegionType, DiffReport, DiffSemantics, ExpectedA11yChange, FileChange, HtmlSource, IntrospectResult, Language, LoopScore, NlAssertion, PageExpectation, PageIntrospection, PageSpec, PlaywrightReport, ProjectConfig, QualityCheckResult, QualityCheckType, ScoreDetail, ShiftRegion, SpecCheckType, SpecInvariant, TestAttempt, TestError, TestResult, TestSpec, TestSuite, UiSpec, UnifiedAgentContext, VisualChangeType, VisualExpectation, VisualSemanticChange, VisualSemanticDiff, VrtDiff, VrtExpectation, VrtSnapshot, VrtVerdict };
499
+ //#endregion
@@ -15,6 +15,5 @@
15
15
  * every `package.json` and that the CHANGELOG has a section for it, so the literal cannot drift
16
16
  * from the release either.
17
17
  */
18
- declare const VLMKIT_VERSION = "0.23.1";
19
- //#endregion
20
- export { VLMKIT_VERSION };
18
+ export declare const VLMKIT_VERSION = "0.24.0";
19
+ //#endregion
package/dist/version.mjs CHANGED
@@ -15,6 +15,6 @@
15
15
  * every `package.json` and that the CHANGELOG has a section for it, so the literal cannot drift
16
16
  * from the release either.
17
17
  */
18
- const VLMKIT_VERSION = "0.23.1";
18
+ const VLMKIT_VERSION = "0.24.0";
19
19
  //#endregion
20
20
  export { VLMKIT_VERSION };
@@ -0,0 +1,146 @@
1
+ import { SelectionRequest, VideoStream } from "./video-frames.mjs";
2
+ import { FramesManifest } from "@mizchi/vlmkit-judge/frames.ts";
3
+ //#region src/video-decode.d.ts
4
+ /** Frame files are named `NNNN-…`: past 9999 a glob no longer sorts them in order. */
5
+ export declare const MAX_SCAN_FRAMES = 9999;
6
+ /** Refused above this unless asked for: a minute at 60fps, already gigabytes of PNG at 1080p. */
7
+ export declare const DEFAULT_MAX_FRAMES = 3600;
8
+ /** File extensions `check flash` reads as a recording rather than a page. */
9
+ export declare const VIDEO_EXTENSIONS: ReadonlySet<string>;
10
+ /**
11
+ * Whether `check flash` reads a source as a recording: a local file with a video extension (a
12
+ * page's query or hash is not its extension: `player.html?clip=a.gif` is a page), or a `.png`
13
+ * that is an animated PNG — the APNG spec's own extension, which a page sweep would only report
14
+ * as an unmeasured animated image.
15
+ */
16
+ export declare function isVideoFile(path: string): boolean;
17
+ export declare function apngDeclaredFrames(file: string): number | null;
18
+ export interface DecoderPaths {
19
+ /** The user's ffmpeg; default `VLMKIT_FFMPEG`, else `ffmpeg` on PATH. */
20
+ ffmpeg?: string;
21
+ /** Default `VLMKIT_FFPROBE`, else the ffprobe beside `ffmpeg` when that is a path, else `ffprobe` on PATH. */
22
+ ffprobe?: string;
23
+ env?: Record<string, string | undefined>;
24
+ }
25
+ export interface Decoder {
26
+ ffmpeg: string;
27
+ ffprobe: string;
28
+ /** `ffmpeg 6.1.1-3ubuntu5`: what the frames say decoded them. */
29
+ name: string;
30
+ }
31
+ /**
32
+ * A bare name resolved on PATH, never in the working directory: Windows' own search tries the
33
+ * current directory first, so an `ffmpeg.exe` dropped beside a folder of recordings would run. Only
34
+ * absolute entries are searched (`.`, `./`, `bin` are the working directory), and only what a spawn
35
+ * without a shell can run: on POSIX an executable file (a non-executable one is skipped, as execvp
36
+ * skips it), on Windows the `.com` / `.exe` libuv runs (not an extensionless npm shim, not a
37
+ * `.bat`), with a quoted entry unquoted. The path returned is absolute, so nothing searches again.
38
+ */
39
+ export declare function onPath(name: string, env: Record<string, string | undefined>, platform?: NodeJS.Platform): string | null;
40
+ /** Find the user's ffmpeg and ffprobe and ask ffmpeg its version. Throws a UsageError naming the remedy. */
41
+ export declare function findDecoder(paths?: DecoderPaths): Promise<Decoder>;
42
+ export interface ScanVideoOptions extends DecoderPaths {
43
+ /** The recording. */
44
+ file: string;
45
+ /** Where frames and `frames.json` go; default `<recording>.frames/` beside it (`rec.mp4.frames/`). */
46
+ out?: string;
47
+ selection?: SelectionRequest;
48
+ /** The width the video plays at, in CSS px; default its own width (one frame pixel per CSS px). */
49
+ displayWidth?: number;
50
+ maxFrames?: number;
51
+ /** A video stream's index in the file; default the one marked default, else the largest, never cover art. */
52
+ stream?: number;
53
+ /** The YUV matrix to convert with, over the stream's tag or the BT.601 default (`COLOR_MATRICES`). */
54
+ colorMatrix?: string;
55
+ /** The range to convert with, over the stream's tag or the limited default. */
56
+ colorRange?: "tv" | "pc";
57
+ /** What transparent pixels are composited over (default white, a browser's default page). */
58
+ background?: "white" | "black";
59
+ }
60
+ export interface ScanVideoResult {
61
+ manifestPath: string;
62
+ manifest: FramesManifest;
63
+ stream: VideoStream;
64
+ /** Frames the recording decodes to. */
65
+ streamFrames: number;
66
+ timingMs: {
67
+ probe: number;
68
+ decode: number;
69
+ };
70
+ }
71
+ /** `rec.mp4.frames/` beside the recording: the extension stays, so `clip.mp4` and `clip.webm` do not share one. */
72
+ export declare const defaultFramesDir: (file: string) => string;
73
+ /** A lock or temporary directory whose owner cannot be seen is taken as abandoned only this old. */
74
+ export declare const STALE_UNKNOWN_MS: number;
75
+ /** Whether pid is a process this one can see. */
76
+ export declare const alive: (pid: number) => boolean;
77
+ /**
78
+ * Which pids `alive` can judge: this host and PID namespace. A pid from a container sharing the
79
+ * directory, or from `unshare`, reads as dead here (measured: a sandboxed run removed a live
80
+ * one's frames), so an owner of another identity is never taken as gone by its pid.
81
+ */
82
+ export declare function processIdentity(): string;
83
+ /**
84
+ * The lines ffmpeg logged at error level or worse (`-loglevel level+info` tags each line), from the
85
+ * input's side — the demuxer and the decoder — not the PNG writer's: it exits 0 on a truncated
86
+ * file. By level, not by wording: Matroska says `File ended prematurely` and HEVC `The cu_qp_delta
87
+ * 80 is outside the valid range`, which no keyword list held, and a title with "corrupt" in it is
88
+ * metadata at info level.
89
+ */
90
+ export declare function decodeErrors(lines: readonly string[]): string[];
91
+ /** A lost or damaged packet: frames may be missing between the ones decoded. */
92
+ export declare const CORRUPT_PACKET: RegExp;
93
+ /**
94
+ * Decode `file` with the user's ffmpeg into `out` (`NNNN-t<ms>.png` + `frames.json`). Refuses
95
+ * (UsageError) a file with no video stream, an HDR one, one that decodes to frames of more than one
96
+ * size, more frames than `maxFrames`, and anything the decoder itself cannot read — never a
97
+ * sequence of black frames standing for a picture that was not decoded.
98
+ */
99
+ export declare function scanVideo(options: ScanVideoOptions): Promise<ScanVideoResult>;
100
+ export interface ImportFramesOptions {
101
+ /** A directory of PNGs another decoder wrote, one per frame, named so they sort in order. */
102
+ dir: string;
103
+ /**
104
+ * One timestamp in seconds per line, in the frames' order (ffprobe's `best_effort_timestamp_time`)
105
+ * — or, as ffprobe prints `key_frame,best_effort_timestamp_time,pkt_pos`, the keyframe flag (0 or
106
+ * 1) before it and the packet's position after it, so the frames know where the codec re-quantizes.
107
+ */
108
+ pts?: string;
109
+ /** A constant rate instead of a timestamp file. */
110
+ fps?: number;
111
+ displayWidth?: number;
112
+ /** The frames are what was recorded, exactly (a lossless codec, or a renderer's own output). */
113
+ lossless?: boolean;
114
+ /**
115
+ * The directory holds every frame the recording shows (the recipe's `-fps_mode passthrough`
116
+ * writes them all). Without it nothing says another tool did not thin them (`-vf fps=5`), so the
117
+ * sequence is not claimed complete and a pass on it is not backed.
118
+ */
119
+ everyFrame?: boolean;
120
+ /**
121
+ * The frames are one pass of an animation that loops (a GIF / APNG another tool composited):
122
+ * how many times it plays, `null` forever. The timestamp file then ends with one more line, the
123
+ * pass's end, and the pass is repeated as a browser repeats it — to one pass and a second more
124
+ * for a loop that never ends. One pass alone holds none of the windows across the seam.
125
+ */
126
+ loop?: number | null;
127
+ }
128
+ /** Timestamps from a sidecar: one number of seconds per line; ffprobe's csv may end each with a comma. */
129
+ export declare function parsePtsFile(text: string, file: string): number[];
130
+ /**
131
+ * A timestamp file as ffprobe writes it with `-of csv=p=0`: a time per line (`best_effort_timestamp_time`),
132
+ * or `key_frame,best_effort_timestamp_time[,pkt_pos]` — ffprobe prints a section's fields in its own
133
+ * order, whatever order -show_entries names them in. Trailing commas (side data) are dropped. Every
134
+ * line has the same fields; without the flag there are no keyframes to know.
135
+ */
136
+ export declare function parsePtsTable(text: string, file: string): {
137
+ seconds: number[];
138
+ keys: boolean[] | null;
139
+ pos: (number | undefined)[] | null;
140
+ };
141
+ /** Turn a directory of decoded frames plus their timestamps into a `vlmkit-frames/1` sequence (`frames.json` in that directory). */
142
+ export declare function importFrames(options: ImportFramesOptions): Promise<{
143
+ manifestPath: string;
144
+ manifest: FramesManifest;
145
+ }>;
146
+ //#endregion