@mizchi/vlmkit-core 0.23.2 → 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.
- package/dist/a11y-semantic.d.mts +7 -9
- package/dist/a11y-semantic.mjs +2 -2
- package/dist/animated-image.d.mts +29 -0
- package/dist/animated-image.mjs +113 -0
- package/dist/apng.d.mts +6 -8
- package/dist/apng.mjs +5 -5
- package/dist/arg-reader.d.mts +10 -11
- package/dist/auth-state.d.mts +7 -8
- package/dist/authored-style-capture.d.mts +8 -9
- package/dist/authored-style-diff.d.mts +7 -9
- package/dist/bitmap-font.d.mts +8 -9
- package/dist/browser-launch.d.mts +8 -10
- package/dist/cli-args.d.mts +9 -10
- package/dist/cli-error.d.mts +10 -11
- package/dist/cli-error.mjs +1 -1
- package/dist/computed-style-capture.d.mts +21 -22
- package/dist/computed-style-capture.mjs +3 -3
- package/dist/computed-style-diff.d.mts +8 -9
- package/dist/computed-style-diff.mjs +1 -1
- package/dist/diff-regions.d.mts +4 -6
- package/dist/dom-equivalence.d.mts +6 -7
- package/dist/dom-position-styles.d.mts +15 -14
- package/dist/dom-position-styles.mjs +3 -3
- package/dist/element-compare.d.mts +9 -8
- package/dist/element-compare.mjs +3 -2
- package/dist/filmstrip.d.mts +61 -8
- package/dist/filmstrip.mjs +82 -10
- package/dist/gate-config.d.mts +19 -21
- package/dist/gate-exit.d.mts +6 -7
- package/dist/gif.d.mts +43 -0
- package/dist/gif.mjs +74 -0
- package/dist/heatmap-regions.d.mts +5 -6
- package/dist/heatmap.d.mts +21 -15
- package/dist/heatmap.mjs +11 -3
- package/dist/image-resize.d.mts +9 -10
- package/dist/image-timing.d.mts +59 -0
- package/dist/image-timing.mjs +167 -0
- package/dist/index.d.mts +2 -2
- package/dist/mask.d.mts +6 -8
- package/dist/navigation-redirect.d.mts +2 -3
- package/dist/page-load.d.mts +12 -13
- package/dist/page-open.d.mts +12 -14
- package/dist/plugin/args.d.mts +17 -11
- package/dist/plugin/args.mjs +12 -1
- package/dist/plugin/cli-entry.d.mts +2 -3
- package/dist/plugin/contract.d.mts +18 -20
- package/dist/plugin/index.d.mts +3 -4
- package/dist/plugin/index.mjs +2 -2
- package/dist/plugin/load.d.mts +7 -9
- package/dist/plugin/registry.d.mts +9 -11
- package/dist/plugin/rule-prose.d.mts +5 -7
- package/dist/plugin/rule-tier.d.mts +8 -10
- package/dist/plugin/rules.d.mts +19 -21
- package/dist/plugin/runner.d.mts +19 -20
- package/dist/plugin/runner.mjs +43 -2
- package/dist/png-decode.d.mts +19 -0
- package/dist/png-decode.mjs +161 -0
- package/dist/png-utils.d.mts +8 -9
- package/dist/png-utils.mjs +2 -1
- package/dist/project-config.d.mts +8 -9
- package/dist/rect-overlap.d.mts +4 -5
- package/dist/region-shift.d.mts +3 -5
- package/dist/run-ledger.d.mts +11 -12
- package/dist/run-ledger.mjs +3 -2
- package/dist/stable-selector.d.mts +2 -3
- package/dist/terminal-colors.d.mts +9 -10
- package/dist/text-rows.d.mts +11 -12
- package/dist/types.d.mts +87 -62
- package/dist/version.d.mts +2 -3
- package/dist/version.mjs +1 -1
- package/dist/video-decode.d.mts +146 -0
- package/dist/video-decode.mjs +936 -0
- package/dist/video-frames.d.mts +306 -0
- package/dist/video-frames.mjs +565 -0
- package/dist/webp.d.mts +8 -10
- package/dist/webp.mjs +2 -1
- package/package.json +4 -4
package/dist/plugin/index.d.mts
CHANGED
|
@@ -3,11 +3,10 @@ import { UsageError } from "../cli-error.mjs";
|
|
|
3
3
|
import { AnyGateDefinition, FINDING_SEVERITIES, Finding, FindingSeverity, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GateCategory, GateContext, GateDefinition, GateInput, RuleDefinition, RuleView, VlmkitPlugin, defineGate, definePlugin, gateCommandString, ruleRef } from "./contract.mjs";
|
|
4
4
|
import { AppliedRules, RULE_SETTINGS, RuleSetting, RuleSettingEntry, RuleSettings } from "./rules.mjs";
|
|
5
5
|
import { DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, PageLoadOptions, PageLoadWaitUntil, navigationOptions, parsePageLoad, pickPageLoad } from "../page-load.mjs";
|
|
6
|
-
import { firstPositional, firstPositionalOrUndefined, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue } from "./args.mjs";
|
|
6
|
+
import { firstPositional, firstPositionalOrUndefined, instantList, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue } from "./args.mjs";
|
|
7
7
|
import { isCliEntry } from "./cli-entry.mjs";
|
|
8
8
|
import { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW, hr } from "../terminal-colors.mjs";
|
|
9
9
|
import { CONFIG_CANDIDATES, CONFIG_FILE, STATE_DIR, debugEnabled, readEnv, resolveStatePath } from "../project-config.mjs";
|
|
10
|
-
|
|
11
10
|
//#region src/plugin/index.d.ts
|
|
12
11
|
/**
|
|
13
12
|
* `@mizchi/vlmkit-core/plugin` — the whole surface a gate plugin needs.
|
|
@@ -77,6 +76,6 @@ import { CONFIG_CANDIDATES, CONFIG_FILE, STATE_DIR, debugEnabled, readEnv, resol
|
|
|
77
76
|
* if (PLUGIN_API_VERSION !== 1) throw new Error("built for plugin API 1");
|
|
78
77
|
* ```
|
|
79
78
|
*/
|
|
80
|
-
declare const PLUGIN_API_VERSION: 1;
|
|
79
|
+
export declare const PLUGIN_API_VERSION: 1;
|
|
81
80
|
//#endregion
|
|
82
|
-
export { type AnyGateDefinition, type AppliedRules, BOLD, CONFIG_CANDIDATES, CONFIG_FILE, CYAN, DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, DIM, FINDING_SEVERITIES, type Finding, type FindingSeverity, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GREEN, type GateCategory, type GateContext, type GateDefinition, type GateInput, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL,
|
|
81
|
+
export { type AnyGateDefinition, type AppliedRules, BOLD, CONFIG_CANDIDATES, CONFIG_FILE, CYAN, DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, DIM, FINDING_SEVERITIES, type Finding, type FindingSeverity, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GREEN, type GateCategory, type GateContext, type GateDefinition, type GateInput, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, type PageLoadOptions, type PageLoadWaitUntil, RED, RESET, RULE_SETTINGS, type RuleDefinition, type RuleSetting, type RuleSettingEntry, type RuleSettings, type RuleView, STATE_DIR, UsageError, type VlmkitPlugin, YELLOW, debugEnabled, defineGate, definePlugin, firstPositional, firstPositionalOrUndefined, gateCommandString, hasFlag, hr, instantList, isCliEntry, navigationOptions, numberList, numberListFloat, optionalInt, parsePageLoad, pickPageLoad, readAll, readChoice, readEnv, readFlag, readInt, readNumber, readPositionals, resolveStatePath, ruleRef, runOutputDir, tokenizeCommand, viewportFlag, vlmFlag, withoutOptionalValue };
|
package/dist/plugin/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { FINDING_SEVERITIES, GATE_CATEGORIES, GATE_CATEGORY_ORDER, defineGate, d
|
|
|
6
6
|
import { RULE_SETTINGS } from "./rules.mjs";
|
|
7
7
|
import { DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, navigationOptions, parsePageLoad, pickPageLoad } from "../page-load.mjs";
|
|
8
8
|
import { CONFIG_CANDIDATES, CONFIG_FILE, STATE_DIR, debugEnabled, readEnv, resolveStatePath } from "../project-config.mjs";
|
|
9
|
-
import { firstPositional, firstPositionalOrUndefined, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue } from "./args.mjs";
|
|
9
|
+
import { firstPositional, firstPositionalOrUndefined, instantList, numberList, numberListFloat, optionalInt, runOutputDir, viewportFlag, vlmFlag, withoutOptionalValue } from "./args.mjs";
|
|
10
10
|
//#region src/plugin/index.ts
|
|
11
11
|
/**
|
|
12
12
|
* `@mizchi/vlmkit-core/plugin` — the whole surface a gate plugin needs.
|
|
@@ -78,4 +78,4 @@ import { firstPositional, firstPositionalOrUndefined, numberList, numberListFloa
|
|
|
78
78
|
*/
|
|
79
79
|
const PLUGIN_API_VERSION = 1;
|
|
80
80
|
//#endregion
|
|
81
|
-
export { BOLD, CONFIG_CANDIDATES, CONFIG_FILE, CYAN, DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, DIM, FINDING_SEVERITIES, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GREEN, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, PLUGIN_API_VERSION, RED, RESET, RULE_SETTINGS, STATE_DIR, UsageError, YELLOW, debugEnabled, defineGate, definePlugin, firstPositional, firstPositionalOrUndefined, gateCommandString, hasFlag, hr, isCliEntry, navigationOptions, numberList, numberListFloat, optionalInt, parsePageLoad, pickPageLoad, readAll, readChoice, readEnv, readFlag, readInt, readNumber, readPositionals, resolveStatePath, ruleRef, runOutputDir, tokenizeCommand, viewportFlag, vlmFlag, withoutOptionalValue };
|
|
81
|
+
export { BOLD, CONFIG_CANDIDATES, CONFIG_FILE, CYAN, DEFAULT_PAGE_LOAD_TIMEOUT_MS, DEFAULT_PAGE_LOAD_WAIT_UNTIL, DIM, FINDING_SEVERITIES, GATE_CATEGORIES, GATE_CATEGORY_ORDER, GREEN, PAGE_LOAD_INPUTS, PAGE_LOAD_VALUE_FLAGS, PAGE_LOAD_WAIT_UNTIL, PLUGIN_API_VERSION, RED, RESET, RULE_SETTINGS, STATE_DIR, UsageError, YELLOW, debugEnabled, defineGate, definePlugin, firstPositional, firstPositionalOrUndefined, gateCommandString, hasFlag, hr, instantList, isCliEntry, navigationOptions, numberList, numberListFloat, optionalInt, parsePageLoad, pickPageLoad, readAll, readChoice, readEnv, readFlag, readInt, readNumber, readPositionals, resolveStatePath, ruleRef, runOutputDir, tokenizeCommand, viewportFlag, vlmFlag, withoutOptionalValue };
|
package/dist/plugin/load.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { VlmkitPlugin } from "./contract.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/plugin/load.d.ts
|
|
4
|
-
interface LoadedPlugin {
|
|
3
|
+
export interface LoadedPlugin {
|
|
5
4
|
plugin: VlmkitPlugin;
|
|
6
5
|
/** Specifier as written in the config, for error messages. */
|
|
7
6
|
specifier: string;
|
|
@@ -9,28 +8,27 @@ interface LoadedPlugin {
|
|
|
9
8
|
resolved: string;
|
|
10
9
|
}
|
|
11
10
|
/** Injectable so tests do not need a module on disk. */
|
|
12
|
-
type PluginImporter = (specifier: string) => Promise<unknown>;
|
|
11
|
+
export type PluginImporter = (specifier: string) => Promise<unknown>;
|
|
13
12
|
/**
|
|
14
13
|
* Validate the imported shape before it reaches the registry. The registry's
|
|
15
14
|
* own validation covers ids and rule tables; this covers "is this even a
|
|
16
15
|
* plugin", where the useful error names the specifier and the missing member
|
|
17
16
|
* rather than surfacing as `gates is not iterable` three frames deeper.
|
|
18
17
|
*/
|
|
19
|
-
declare function asPlugin(moduleNamespace: unknown, specifier: string): VlmkitPlugin;
|
|
20
|
-
interface LoadPluginsOptions {
|
|
18
|
+
export declare function asPlugin(moduleNamespace: unknown, specifier: string): VlmkitPlugin;
|
|
19
|
+
export interface LoadPluginsOptions {
|
|
21
20
|
/** Directory relative specifiers resolve against. Defaults to cwd. */
|
|
22
21
|
baseDir?: string;
|
|
23
22
|
importer?: PluginImporter;
|
|
24
23
|
}
|
|
25
|
-
declare function loadPlugins(specifiers: readonly string[], options?: LoadPluginsOptions): Promise<LoadedPlugin[]>;
|
|
24
|
+
export declare function loadPlugins(specifiers: readonly string[], options?: LoadPluginsOptions): Promise<LoadedPlugin[]>;
|
|
26
25
|
/**
|
|
27
26
|
* Read the `plugins` array out of `vlmkit.config.json`. Absent config or
|
|
28
27
|
* absent key means no plugins — a project that declares none must not pay a
|
|
29
28
|
* config-file requirement.
|
|
30
29
|
*/
|
|
31
|
-
declare function readPluginSpecifiers(cwd?: string): {
|
|
30
|
+
export declare function readPluginSpecifiers(cwd?: string): {
|
|
32
31
|
specifiers: string[];
|
|
33
32
|
configPath: string | null;
|
|
34
33
|
};
|
|
35
|
-
//#endregion
|
|
36
|
-
export { LoadPluginsOptions, LoadedPlugin, PluginImporter, asPlugin, loadPlugins, readPluginSpecifiers };
|
|
34
|
+
//#endregion
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { AnyGateDefinition, GateCategory, VlmkitPlugin } from "./contract.mjs";
|
|
2
2
|
import { RuleSettings } from "./rules.mjs";
|
|
3
|
-
|
|
4
3
|
//#region src/plugin/registry.d.ts
|
|
5
|
-
interface RegisteredGate {
|
|
4
|
+
export interface RegisteredGate {
|
|
6
5
|
gate: AnyGateDefinition;
|
|
7
6
|
/** Plugin that supplied it — named in conflict errors and `--plugins` listings. */
|
|
8
7
|
plugin: string;
|
|
9
8
|
}
|
|
10
|
-
interface GateResolution {
|
|
9
|
+
export interface GateResolution {
|
|
11
10
|
gate: AnyGateDefinition;
|
|
12
11
|
/** Argv remaining after the matched command tokens. */
|
|
13
12
|
rest: string[];
|
|
14
13
|
}
|
|
15
|
-
interface GateRegistry {
|
|
14
|
+
export interface GateRegistry {
|
|
16
15
|
readonly plugins: readonly VlmkitPlugin[];
|
|
17
16
|
/** Every gate, in registration order. */
|
|
18
17
|
list(): readonly RegisteredGate[];
|
|
@@ -37,10 +36,10 @@ interface GateRegistry {
|
|
|
37
36
|
/** Near-miss command strings for a "did you mean" line. */
|
|
38
37
|
suggest(command: string | readonly string[], limit?: number): string[];
|
|
39
38
|
}
|
|
40
|
-
declare function createGateRegistry(plugins: readonly VlmkitPlugin[]): GateRegistry;
|
|
39
|
+
export declare function createGateRegistry(plugins: readonly VlmkitPlugin[]): GateRegistry;
|
|
41
40
|
/** Levenshtein, iterative single-row — only ever run on a failed lookup. */
|
|
42
|
-
declare function editDistance(a: string, b: string): number;
|
|
43
|
-
interface GateCommandProblem {
|
|
41
|
+
export declare function editDistance(a: string, b: string): number;
|
|
42
|
+
export interface GateCommandProblem {
|
|
44
43
|
command: string;
|
|
45
44
|
message: string;
|
|
46
45
|
}
|
|
@@ -49,12 +48,11 @@ interface GateCommandProblem {
|
|
|
49
48
|
* entry rather than throwing on the first, so a reviewer fixes the whole
|
|
50
49
|
* config in one pass.
|
|
51
50
|
*/
|
|
52
|
-
declare function validateGateCommands(registry: GateRegistry, commands: readonly string[]): GateCommandProblem[];
|
|
51
|
+
export declare function validateGateCommands(registry: GateRegistry, commands: readonly string[]): GateCommandProblem[];
|
|
53
52
|
/**
|
|
54
53
|
* Validate rule references. A bare `<ruleId>` key is only resolvable inside
|
|
55
54
|
* a gate-scoped block, so this checks the qualified forms and reports a bare
|
|
56
55
|
* key as needing a scope rather than guessing which gate it meant.
|
|
57
56
|
*/
|
|
58
|
-
declare function validateRuleSettings(registry: GateRegistry, settings: RuleSettings, scope?: AnyGateDefinition): string[];
|
|
59
|
-
//#endregion
|
|
60
|
-
export { GateCommandProblem, GateRegistry, GateResolution, RegisteredGate, createGateRegistry, editDistance, validateGateCommands, validateRuleSettings };
|
|
57
|
+
export declare function validateRuleSettings(registry: GateRegistry, settings: RuleSettings, scope?: AnyGateDefinition): string[];
|
|
58
|
+
//#endregion
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { FindingSeverity, RuleView } from "./contract.mjs";
|
|
2
2
|
import { TieredRow } from "./rule-tier.mjs";
|
|
3
|
-
|
|
4
3
|
//#region src/plugin/rule-prose.d.ts
|
|
5
4
|
/** The shape all seven reports' rows already have. */
|
|
6
|
-
interface IssueLike {
|
|
5
|
+
export interface IssueLike {
|
|
7
6
|
kind: string;
|
|
8
7
|
severity: FindingSeverity;
|
|
9
8
|
}
|
|
10
|
-
interface TieredIssues<T> {
|
|
9
|
+
export interface TieredIssues<T> {
|
|
11
10
|
/** Rows whose rule is still on, each carrying the severity to print it at. */
|
|
12
11
|
shown: TieredRow<T>[];
|
|
13
12
|
/**
|
|
@@ -28,7 +27,7 @@ interface TieredIssues<T> {
|
|
|
28
27
|
* per gate and are not worth unifying — but they must read `tier` from the returned rows rather
|
|
29
28
|
* than `severity` from their own, which is the point of routing through here.
|
|
30
29
|
*/
|
|
31
|
-
declare function tierIssues<T extends IssueLike>(issues: readonly T[], rules?: RuleView): TieredIssues<T>;
|
|
30
|
+
export declare function tierIssues<T extends IssueLike>(issues: readonly T[], rules?: RuleView): TieredIssues<T>;
|
|
32
31
|
/**
|
|
33
32
|
* ` [kind re-tuned to warn]`, or `""` when the row prints at the severity it was emitted at.
|
|
34
33
|
*
|
|
@@ -36,6 +35,5 @@ declare function tierIssues<T extends IssueLike>(issues: readonly T[], rules?: R
|
|
|
36
35
|
* the reader has no way to tell a measurement from a policy. The suffix names the rule id
|
|
37
36
|
* because that is the string they would edit to change it back.
|
|
38
37
|
*/
|
|
39
|
-
declare function retuneNote<T extends IssueLike>(entry: TieredRow<T>): string;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { IssueLike, TieredIssues, retuneNote, tierIssues };
|
|
38
|
+
export declare function retuneNote<T extends IssueLike>(entry: TieredRow<T>): string;
|
|
39
|
+
//#endregion
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FindingSeverity, RuleView } from "./contract.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/plugin/rule-tier.d.ts
|
|
4
3
|
/** A rule's effective setting: a severity, or `off` when the project turned it off. */
|
|
5
|
-
type RuleTier = "off" | FindingSeverity;
|
|
4
|
+
export type RuleTier = "off" | FindingSeverity;
|
|
6
5
|
/**
|
|
7
6
|
* What to print a row as: the explicit project setting, or the severity the finding was
|
|
8
7
|
* emitted at.
|
|
@@ -19,7 +18,7 @@ type RuleTier = "off" | FindingSeverity;
|
|
|
19
18
|
* `rules` is optional in `format`, and undefined means nobody applied settings — a direct
|
|
20
19
|
* library call or a test. The emitted severity is the honest answer there too.
|
|
21
20
|
*/
|
|
22
|
-
declare function ruleTier(rules: RuleView | undefined, ruleId: string, emitted: FindingSeverity): RuleTier;
|
|
21
|
+
export declare function ruleTier(rules: RuleView | undefined, ruleId: string, emitted: FindingSeverity): RuleTier;
|
|
23
22
|
/**
|
|
24
23
|
* A `RuleView` from a plain map of explicit settings — for tests, and for anything else that
|
|
25
24
|
* needs to render prose under a hypothetical configuration.
|
|
@@ -29,12 +28,12 @@ declare function ruleTier(rules: RuleView | undefined, ruleId: string, emitted:
|
|
|
29
28
|
* severity for EVERY rule and can never see "nobody set this one", so a test built on it
|
|
30
29
|
* cannot reproduce the case the real runner hits most often — no settings at all.
|
|
31
30
|
*/
|
|
32
|
-
declare function ruleViewFrom(settings: Readonly<Record<string, RuleTier>>, fallback?: FindingSeverity): RuleView;
|
|
33
|
-
interface TieredRow<T> {
|
|
31
|
+
export declare function ruleViewFrom(settings: Readonly<Record<string, RuleTier>>, fallback?: FindingSeverity): RuleView;
|
|
32
|
+
export interface TieredRow<T> {
|
|
34
33
|
row: T;
|
|
35
34
|
tier: FindingSeverity;
|
|
36
35
|
}
|
|
37
|
-
interface TieredRows<T> {
|
|
36
|
+
export interface TieredRows<T> {
|
|
38
37
|
/** Rows whose rule is still on, each carrying its effective severity. */
|
|
39
38
|
shown: TieredRow<T>[];
|
|
40
39
|
/** Rows dropped because their rule is `off`, keyed by rule id for the disclosure line. */
|
|
@@ -49,7 +48,7 @@ interface TieredRows<T> {
|
|
|
49
48
|
* uses this to keep its own body and counts consistent with that line instead of contradicting
|
|
50
49
|
* it.
|
|
51
50
|
*/
|
|
52
|
-
declare function applyRuleTiers<T>(rows: readonly T[], ruleOf: (row: T) => {
|
|
51
|
+
export declare function applyRuleTiers<T>(rows: readonly T[], ruleOf: (row: T) => {
|
|
53
52
|
rule: string;
|
|
54
53
|
emitted: FindingSeverity;
|
|
55
54
|
}, rules?: RuleView): TieredRows<T>;
|
|
@@ -60,6 +59,5 @@ declare function applyRuleTiers<T>(rows: readonly T[], ruleOf: (row: T) => {
|
|
|
60
59
|
* palettes, and they wrap this in their own `DIM`. Deliberately not silent when the count is
|
|
61
60
|
* zero either — it returns `undefined` so a formatter cannot print an empty bullet.
|
|
62
61
|
*/
|
|
63
|
-
declare function hiddenByRuleNote(hiddenByRule: Map<string, number>): string | undefined;
|
|
64
|
-
//#endregion
|
|
65
|
-
export { RuleTier, TieredRow, TieredRows, applyRuleTiers, hiddenByRuleNote, ruleTier, ruleViewFrom };
|
|
62
|
+
export declare function hiddenByRuleNote(hiddenByRule: Map<string, number>): string | undefined;
|
|
63
|
+
//#endregion
|
package/dist/plugin/rules.d.mts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { AnyGateDefinition, Finding, FindingSeverity } from "./contract.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/plugin/rules.d.ts
|
|
4
3
|
/** `"off"` drops the finding; a severity re-tunes it (usually `suspect` → `warn`). */
|
|
5
|
-
type RuleSetting = "off" | FindingSeverity;
|
|
6
|
-
declare const RULE_SETTINGS: readonly RuleSetting[];
|
|
4
|
+
export type RuleSetting = "off" | FindingSeverity;
|
|
5
|
+
export declare const RULE_SETTINGS: readonly RuleSetting[];
|
|
7
6
|
/**
|
|
8
7
|
* Keys are `<gateId>/<ruleId>`, `<gateId>` (every rule of that gate), or a
|
|
9
8
|
* bare `<ruleId>` when the settings block is already scoped to one gate.
|
|
10
9
|
*/
|
|
11
|
-
type RuleSettings = Readonly<Record<string, RuleSetting>>;
|
|
10
|
+
export type RuleSettings = Readonly<Record<string, RuleSetting>>;
|
|
12
11
|
/**
|
|
13
12
|
* The long form of a rule setting: the setting plus why it is there.
|
|
14
13
|
*
|
|
@@ -29,7 +28,7 @@ type RuleSettings = Readonly<Record<string, RuleSetting>>;
|
|
|
29
28
|
* cannot carry a reason, so requiring one everywhere would make the config
|
|
30
29
|
* unable to express what the CLI does.
|
|
31
30
|
*/
|
|
32
|
-
interface RuleSettingEntry {
|
|
31
|
+
export interface RuleSettingEntry {
|
|
33
32
|
setting: RuleSetting;
|
|
34
33
|
/** Why the tool is wrong here. Required in this form — that is the point of it. */
|
|
35
34
|
reason: string;
|
|
@@ -38,14 +37,14 @@ interface RuleSettingEntry {
|
|
|
38
37
|
/** `YYYY-MM-DD`. Past it, the setting is dropped and the rule bites again. */
|
|
39
38
|
expires?: string;
|
|
40
39
|
}
|
|
41
|
-
type RuleSettingValue = RuleSetting | RuleSettingEntry;
|
|
40
|
+
export type RuleSettingValue = RuleSetting | RuleSettingEntry;
|
|
42
41
|
/** Rule settings with their annotations kept, for the inventory and expiry. */
|
|
43
|
-
interface AnnotatedRuleSettings {
|
|
42
|
+
export interface AnnotatedRuleSettings {
|
|
44
43
|
settings: RuleSettings;
|
|
45
44
|
/** Keyed by rule reference; only the entries written in the long form. */
|
|
46
45
|
annotations: Readonly<Record<string, RuleSettingEntry>>;
|
|
47
46
|
}
|
|
48
|
-
interface RuleDecision {
|
|
47
|
+
export interface RuleDecision {
|
|
49
48
|
ruleId: string;
|
|
50
49
|
/** Effective severity, or `"off"`. */
|
|
51
50
|
effective: RuleSetting;
|
|
@@ -54,24 +53,24 @@ interface RuleDecision {
|
|
|
54
53
|
/** The settings key that decided this, when a setting applied. */
|
|
55
54
|
via?: string;
|
|
56
55
|
}
|
|
57
|
-
interface ResolvedRules {
|
|
56
|
+
export interface ResolvedRules {
|
|
58
57
|
gateId: string;
|
|
59
58
|
decisions: ReadonlyMap<string, RuleDecision>;
|
|
60
59
|
/** Settings keys that matched no rule of this gate — typos, or stale entries. */
|
|
61
60
|
unmatched: readonly string[];
|
|
62
61
|
}
|
|
63
|
-
interface SuppressedFinding {
|
|
62
|
+
export interface SuppressedFinding {
|
|
64
63
|
finding: Finding;
|
|
65
64
|
/** Settings key that silenced it. */
|
|
66
65
|
via: string;
|
|
67
66
|
}
|
|
68
|
-
interface RetunedFinding {
|
|
67
|
+
export interface RetunedFinding {
|
|
69
68
|
finding: Finding;
|
|
70
69
|
from: FindingSeverity;
|
|
71
70
|
to: FindingSeverity;
|
|
72
71
|
via: string;
|
|
73
72
|
}
|
|
74
|
-
interface AppliedRules {
|
|
73
|
+
export interface AppliedRules {
|
|
75
74
|
/** Findings that survived, with severities re-tuned in place. */
|
|
76
75
|
findings: readonly Finding[];
|
|
77
76
|
suppressed: readonly SuppressedFinding[];
|
|
@@ -89,24 +88,23 @@ interface AppliedRules {
|
|
|
89
88
|
* Errors name the JSON path, matching `parseGateConfig`'s convention so a bad
|
|
90
89
|
* rules block reads like any other config defect.
|
|
91
90
|
*/
|
|
92
|
-
declare function parseAnnotatedRuleSettings(raw: unknown, path: string): AnnotatedRuleSettings;
|
|
91
|
+
export declare function parseAnnotatedRuleSettings(raw: unknown, path: string): AnnotatedRuleSettings;
|
|
93
92
|
/** The settings alone, for the many callers that never needed the annotations. */
|
|
94
|
-
declare function parseRuleSettings(raw: unknown, path: string): RuleSettings;
|
|
95
|
-
declare function resolveRules(gate: AnyGateDefinition, settings?: RuleSettings): ResolvedRules;
|
|
93
|
+
export declare function parseRuleSettings(raw: unknown, path: string): RuleSettings;
|
|
94
|
+
export declare function resolveRules(gate: AnyGateDefinition, settings?: RuleSettings): ResolvedRules;
|
|
96
95
|
/** Apply resolved settings to a gate's findings. */
|
|
97
|
-
declare function applyRuleSettings(gate: AnyGateDefinition, findings: readonly Finding[], settings?: RuleSettings): AppliedRules;
|
|
98
|
-
interface FindingCounts {
|
|
96
|
+
export declare function applyRuleSettings(gate: AnyGateDefinition, findings: readonly Finding[], settings?: RuleSettings): AppliedRules;
|
|
97
|
+
export interface FindingCounts {
|
|
99
98
|
suspect: number;
|
|
100
99
|
warn: number;
|
|
101
100
|
info: number;
|
|
102
101
|
}
|
|
103
|
-
declare function countFindings(findings: readonly Finding[]): FindingCounts;
|
|
102
|
+
export declare function countFindings(findings: readonly Finding[]): FindingCounts;
|
|
104
103
|
/**
|
|
105
104
|
* Validate a definition before it is registered. Cheap invariants, but each
|
|
106
105
|
* one is a defect that used to be discoverable only by running the gate:
|
|
107
106
|
* duplicate rule ids make a setting ambiguous, a non-slug id breaks config
|
|
108
107
|
* keys, and an empty command cannot be dispatched.
|
|
109
108
|
*/
|
|
110
|
-
declare function validateGateDefinition(gate: AnyGateDefinition): string[];
|
|
111
|
-
//#endregion
|
|
112
|
-
export { AnnotatedRuleSettings, AppliedRules, FindingCounts, RULE_SETTINGS, ResolvedRules, RetunedFinding, RuleDecision, RuleSetting, RuleSettingEntry, RuleSettingValue, RuleSettings, SuppressedFinding, applyRuleSettings, countFindings, parseAnnotatedRuleSettings, parseRuleSettings, resolveRules, validateGateDefinition };
|
|
109
|
+
export declare function validateGateDefinition(gate: AnyGateDefinition): string[];
|
|
110
|
+
//#endregion
|
package/dist/plugin/runner.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { LedgerWrite } from "../run-ledger.mjs";
|
|
2
2
|
import { AnyGateDefinition, Finding, GateDefinition } from "./contract.mjs";
|
|
3
3
|
import { AppliedRules, FindingCounts, RuleSettings } from "./rules.mjs";
|
|
4
|
-
|
|
5
4
|
//#region src/plugin/runner.d.ts
|
|
6
5
|
/** Flags the runner owns. A gate's `parse` never sees these as its own. */
|
|
7
|
-
declare const SHARED_GATE_FLAGS: readonly ["--json", "--advisory", "--fail-on-suspect", "--rule", "--rules", "--timing", "--ledger", "--no-ledger", "--help", "-h"];
|
|
8
|
-
interface SharedFlags {
|
|
6
|
+
export declare const SHARED_GATE_FLAGS: readonly ["--json", "--advisory", "--fail-on-suspect", "--rule", "--rules", "--timing", "--ledger", "--no-ledger", "--help", "-h"];
|
|
7
|
+
export interface SharedFlags {
|
|
9
8
|
json: boolean;
|
|
10
9
|
advisory: boolean;
|
|
11
10
|
help: boolean;
|
|
@@ -35,9 +34,9 @@ interface SharedFlags {
|
|
|
35
34
|
* does nothing: it was the documented way to opt *into* failing before
|
|
36
35
|
* failing became the default, and scripts in the wild still pass it.
|
|
37
36
|
*/
|
|
38
|
-
declare function parseSharedFlags(argv: readonly string[]): SharedFlags;
|
|
37
|
+
export declare function parseSharedFlags(argv: readonly string[]): SharedFlags;
|
|
39
38
|
/** Drop the runner-owned flags so a gate's parser never has to know them. */
|
|
40
|
-
declare function stripSharedFlags(argv: readonly string[]): string[];
|
|
39
|
+
export declare function stripSharedFlags(argv: readonly string[]): string[];
|
|
41
40
|
/**
|
|
42
41
|
* Wall-clock ms per contract phase.
|
|
43
42
|
*
|
|
@@ -53,7 +52,7 @@ declare function stripSharedFlags(argv: readonly string[]): string[];
|
|
|
53
52
|
* floor of a browser launch. Reported only when asked, because a timing field
|
|
54
53
|
* is nondeterministic and `--json` has to stay byte-stable for equal inputs.
|
|
55
54
|
*/
|
|
56
|
-
interface GateTiming {
|
|
55
|
+
export interface GateTiming {
|
|
57
56
|
parseMs: number;
|
|
58
57
|
runMs: number;
|
|
59
58
|
/** `gate.findings` — the projection. Per-rule work lives here. */
|
|
@@ -66,7 +65,7 @@ interface GateTiming {
|
|
|
66
65
|
/** Everything above plus the runner's own overhead. */
|
|
67
66
|
totalMs: number;
|
|
68
67
|
}
|
|
69
|
-
interface GateOutcome<Report = unknown> {
|
|
68
|
+
export interface GateOutcome<Report = unknown> {
|
|
70
69
|
gateId: string;
|
|
71
70
|
command: string;
|
|
72
71
|
/** `fail` when a suspect survived rule settings; `--advisory` does not change it. */
|
|
@@ -87,7 +86,7 @@ interface GateOutcome<Report = unknown> {
|
|
|
87
86
|
*/
|
|
88
87
|
ledgerWrite: LedgerWrite | null;
|
|
89
88
|
}
|
|
90
|
-
interface RunGateOptions {
|
|
89
|
+
export interface RunGateOptions {
|
|
91
90
|
cwd?: string;
|
|
92
91
|
/** Project-level rule settings; `--rule` overrides win over these. */
|
|
93
92
|
rules?: RuleSettings;
|
|
@@ -99,7 +98,7 @@ interface RunGateOptions {
|
|
|
99
98
|
* print or set `process.exitCode` — `runGateCli` does that, and tests get to
|
|
100
99
|
* assert on an object instead of scraping stdout.
|
|
101
100
|
*/
|
|
102
|
-
declare function runGate<Report, Options>(gate: GateDefinition<Report, Options>, argv: readonly string[], options?: RunGateOptions): Promise<GateOutcome<Report>>;
|
|
101
|
+
export declare function runGate<Report, Options>(gate: GateDefinition<Report, Options>, argv: readonly string[], options?: RunGateOptions): Promise<GateOutcome<Report>>;
|
|
103
102
|
/**
|
|
104
103
|
* Suppression and re-tuning are reported, never silent — the same reason
|
|
105
104
|
* `check integrity` prints its exemptions and `gates suppressions` exists.
|
|
@@ -127,16 +126,16 @@ declare function runGate<Report, Options>(gate: GateDefinition<Report, Options>,
|
|
|
127
126
|
* deliberate: this one is the runner's accounting, tied to the exit code, and a formatter that
|
|
128
127
|
* forgets to render its own note must not be able to make the suppression invisible.
|
|
129
128
|
*/
|
|
130
|
-
declare function formatRuleNotes(gate: AnyGateDefinition, applied: AppliedRules): string;
|
|
129
|
+
export declare function formatRuleNotes(gate: AnyGateDefinition, applied: AppliedRules): string;
|
|
131
130
|
/** `vlmkit <gate> --rules` — the tunable surface, without measuring anything. */
|
|
132
|
-
declare function formatRuleTable(gate: AnyGateDefinition): string;
|
|
131
|
+
export declare function formatRuleTable(gate: AnyGateDefinition): string;
|
|
133
132
|
/**
|
|
134
133
|
* Help text, composed from the definition. The shared-flag block is appended
|
|
135
134
|
* here rather than copied into every gate's usage string, which is how the
|
|
136
135
|
* `--advisory` contract drifted out of `check integrity` in the first place.
|
|
137
136
|
*/
|
|
138
|
-
declare function formatGateHelp(gate: AnyGateDefinition): string;
|
|
139
|
-
interface GateCliIo {
|
|
137
|
+
export declare function formatGateHelp(gate: AnyGateDefinition): string;
|
|
138
|
+
export interface GateCliIo {
|
|
140
139
|
out?: (text: string) => void;
|
|
141
140
|
err?: (text: string) => void;
|
|
142
141
|
}
|
|
@@ -148,7 +147,7 @@ interface GateCliIo {
|
|
|
148
147
|
* the one place the runner touches gate-owned prose, which is why it is a single
|
|
149
148
|
* insertion at a documented anchor rather than a rewrite.
|
|
150
149
|
*/
|
|
151
|
-
declare function withExitIntent(text: string, line: string): string;
|
|
150
|
+
export declare function withExitIntent(text: string, line: string): string;
|
|
152
151
|
/**
|
|
153
152
|
* Is this run measuring a live URL that nothing has pinned?
|
|
154
153
|
*
|
|
@@ -163,7 +162,8 @@ declare function withExitIntent(text: string, line: string): string;
|
|
|
163
162
|
* but the question it was actually answering is "could this differ", and that is
|
|
164
163
|
* decidable without running anything twice.
|
|
165
164
|
*/
|
|
166
|
-
declare function unpinnedLiveInput(gate: AnyGateDefinition, argv: readonly string[]): string | null;
|
|
165
|
+
export declare function unpinnedLiveInput(gate: AnyGateDefinition, argv: readonly string[]): string | null;
|
|
166
|
+
export declare function unknownGateFlags(gate: AnyGateDefinition, argv: readonly string[]): string[];
|
|
167
167
|
/**
|
|
168
168
|
* Announce a file this run brought into existence in an un-ignored spot.
|
|
169
169
|
*
|
|
@@ -179,12 +179,12 @@ declare function unpinnedLiveInput(gate: AnyGateDefinition, argv: readonly strin
|
|
|
179
179
|
* every run would be noise on a file that gets one appended line per gate, and
|
|
180
180
|
* the moment worth reporting is the moment the repo changed shape.
|
|
181
181
|
*/
|
|
182
|
-
declare function newOutputNotice(write: LedgerWrite | null, cwd: string): string | null;
|
|
182
|
+
export declare function newOutputNotice(write: LedgerWrite | null, cwd: string): string | null;
|
|
183
183
|
/**
|
|
184
184
|
* CLI adapter: handle `--help` / `--rules`, run the gate, write the output,
|
|
185
185
|
* return the exit code. A migrated gate's whole `main()` becomes one call.
|
|
186
186
|
*/
|
|
187
|
-
declare function runGateCli<Report, Options>(gate: GateDefinition<Report, Options>, argv: readonly string[], options?: RunGateOptions & GateCliIo): Promise<0 | 1>;
|
|
187
|
+
export declare function runGateCli<Report, Options>(gate: GateDefinition<Report, Options>, argv: readonly string[], options?: RunGateOptions & GateCliIo): Promise<0 | 1>;
|
|
188
188
|
/**
|
|
189
189
|
* The phase breakdown as one block.
|
|
190
190
|
*
|
|
@@ -193,6 +193,5 @@ declare function runGateCli<Report, Options>(gate: GateDefinition<Report, Option
|
|
|
193
193
|
* but the page) or slow at everything else (a formatter doing real work — the
|
|
194
194
|
* defect `formatA11yTouchReport` had, where a "formatter" ran a policy).
|
|
195
195
|
*/
|
|
196
|
-
declare function formatGateTiming(outcome: GateOutcome): string;
|
|
197
|
-
//#endregion
|
|
198
|
-
export { GateCliIo, GateOutcome, GateTiming, RunGateOptions, SHARED_GATE_FLAGS, SharedFlags, formatGateHelp, formatGateTiming, formatRuleNotes, formatRuleTable, newOutputNotice, parseSharedFlags, runGate, runGateCli, stripSharedFlags, unpinnedLiveInput, withExitIntent };
|
|
196
|
+
export declare function formatGateTiming(outcome: GateOutcome): string;
|
|
197
|
+
//#endregion
|
package/dist/plugin/runner.mjs
CHANGED
|
@@ -355,6 +355,35 @@ function unpinnedLiveInput(gate, argv) {
|
|
|
355
355
|
return `${DIM} ${url} is live and not pinned — a re-run may measure different data. Pin it: vlmkit snapshot record-har ${url} --out app.har, then --har app.har${RESET}`;
|
|
356
356
|
}
|
|
357
357
|
/**
|
|
358
|
+
* Flags on the command line that neither the runner nor the gate declares. They were ignored
|
|
359
|
+
* without a word: an agent passed `verify markup --manifest copy.txt` and could not tell
|
|
360
|
+
* whether the copy was checked (it was not; `check copy --manifest` is the gate that does).
|
|
361
|
+
* Said, not refused: a gate whose `inputs` missed a flag it reads would otherwise break.
|
|
362
|
+
*/
|
|
363
|
+
/** Levenshtein distance, for "did you mean" on a mistyped option. */
|
|
364
|
+
function editDistance(a, b) {
|
|
365
|
+
const row = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
366
|
+
for (let i = 1; i <= a.length; i++) {
|
|
367
|
+
let prev = row[0];
|
|
368
|
+
row[0] = i;
|
|
369
|
+
for (let j = 1; j <= b.length; j++) {
|
|
370
|
+
const cur = row[j];
|
|
371
|
+
row[j] = Math.min(row[j] + 1, row[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
372
|
+
prev = cur;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return row[b.length];
|
|
376
|
+
}
|
|
377
|
+
function unknownGateFlags(gate, argv) {
|
|
378
|
+
const known = /* @__PURE__ */ new Set([...SHARED_GATE_FLAGS, "--har"]);
|
|
379
|
+
for (const input of gate.inputs ?? []) {
|
|
380
|
+
known.add(`--${input.name}`);
|
|
381
|
+
known.add(`--no-${input.name}`);
|
|
382
|
+
}
|
|
383
|
+
const unknown = argv.filter((arg) => arg.startsWith("--") && arg.length > 2).map((arg) => arg.split("=")[0]).filter((flag) => !known.has(flag));
|
|
384
|
+
return [...new Set(unknown)];
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
358
387
|
* Announce a file this run brought into existence in an un-ignored spot.
|
|
359
388
|
*
|
|
360
389
|
* The run ledger has always been written to `.vlmkit/run-ledger.jsonl` with no
|
|
@@ -371,8 +400,9 @@ function unpinnedLiveInput(gate, argv) {
|
|
|
371
400
|
*/
|
|
372
401
|
function newOutputNotice(write, cwd) {
|
|
373
402
|
if (!write?.created) return null;
|
|
374
|
-
if (!isGitRepo(cwd) || isGitIgnored(cwd, write.path)) return null;
|
|
375
403
|
const rel = relative(cwd, write.path).split("\\").join("/") || write.path;
|
|
404
|
+
if (!isGitRepo(cwd)) return `${DIM} created ${rel} — an append-only record of every gate run (--no-ledger turns it off)${RESET}`;
|
|
405
|
+
if (isGitIgnored(cwd, write.path)) return null;
|
|
376
406
|
const entries = rel === LEDGER_RELATIVE_PATH.split("\\").join("/") ? [...VLMKIT_IGNORE_ENTRIES] : [rel];
|
|
377
407
|
return [
|
|
378
408
|
`${DIM} created ${rel} — an append-only record of every gate run, one line each.${RESET}`,
|
|
@@ -396,6 +426,17 @@ async function runGateCli(gate, argv, options = {}) {
|
|
|
396
426
|
out(formatRuleTable(gate));
|
|
397
427
|
return 0;
|
|
398
428
|
}
|
|
429
|
+
const unknown = unknownGateFlags(gate, argv);
|
|
430
|
+
if (unknown.length > 0) {
|
|
431
|
+
const near = unknown.flatMap((flag) => {
|
|
432
|
+
const best = (gate.inputs ?? []).map((i) => `--${i.name}`).map((name) => ({
|
|
433
|
+
name,
|
|
434
|
+
d: editDistance(flag, name)
|
|
435
|
+
})).sort((x, y) => x.d - y.d)[0];
|
|
436
|
+
return best && best.d <= 2 ? [`${flag} → ${best.name}`] : [];
|
|
437
|
+
});
|
|
438
|
+
(options.err ?? ((text) => console.error(text)))(`warn: ${unknown.join(", ")} ${unknown.length === 1 ? "is not an option" : "are not options"} of vlmkit ${gateCommandString(gate)} and ${unknown.length === 1 ? "was" : "were"} ignored (--help lists its options)${near.length > 0 ? `; did you mean ${near.join(", ")}?` : ""}`);
|
|
439
|
+
}
|
|
399
440
|
const outcome = await runGate(gate, argv, options);
|
|
400
441
|
if (outcome.exitCode === 0 && outcome.counts.warn > 0 && !shared.json) {
|
|
401
442
|
const ids = [...new Set(outcome.findings.filter((f) => f.severity === "warn").map((f) => f.rule))];
|
|
@@ -437,4 +478,4 @@ function formatGateTiming(outcome) {
|
|
|
437
478
|
].join("\n");
|
|
438
479
|
}
|
|
439
480
|
//#endregion
|
|
440
|
-
export { SHARED_GATE_FLAGS, formatGateHelp, formatGateTiming, formatRuleNotes, formatRuleTable, newOutputNotice, parseSharedFlags, runGate, runGateCli, stripSharedFlags, unpinnedLiveInput, withExitIntent };
|
|
481
|
+
export { SHARED_GATE_FLAGS, formatGateHelp, formatGateTiming, formatRuleNotes, formatRuleTable, newOutputNotice, parseSharedFlags, runGate, runGateCli, stripSharedFlags, unknownGateFlags, unpinnedLiveInput, withExitIntent };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PngData } from "./png-utils.mjs";
|
|
2
|
+
//#region src/png-decode.d.ts
|
|
3
|
+
/** Decoded pixels as they were stored: 3 (RGB) or 4 (RGBA) bytes a pixel, rows packed. */
|
|
4
|
+
export interface PngPixels {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
channels: 3 | 4;
|
|
8
|
+
data: Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* CRC-32 (ISO 3309, the one PNG chunks carry), by a 256-entry table. Only for a Node without
|
|
12
|
+
* `zlib.crc32` (before 22.2 / 20.15); exported so a test holds it to zlib's.
|
|
13
|
+
*/
|
|
14
|
+
export declare function tableCrc32(bytes: Uint8Array): number;
|
|
15
|
+
/** A PNG as RGBA. */
|
|
16
|
+
export declare function decodePngBuffer(buffer: Uint8Array): PngData;
|
|
17
|
+
/** A PNG's pixels without widening RGB to RGBA: a screenshot is RGB, and the copy is a third of the decode. */
|
|
18
|
+
export declare function decodePngPixels(buffer: Uint8Array): PngPixels;
|
|
19
|
+
//#endregion
|