@blazediff/contract 0.0.0-oidc-seed → 0.0.0-stage

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Temporary Holding Version
2
+
3
+ This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
package/package.json CHANGED
@@ -1,42 +1,6 @@
1
1
  {
2
- "name": "@blazediff/contract",
3
- "version": "0.0.0-oidc-seed",
4
- "description": "Shared diff API of the BlazeDiff engines: types, errors and argument checks",
5
- "private": false,
6
- "publishConfig": {
7
- "access": "public"
8
- },
9
- "main": "dist/index.js",
10
- "module": "dist/index.mjs",
11
- "types": "dist/index.d.ts",
12
- "exports": {
13
- ".": {
14
- "types": "./dist/index.d.ts",
15
- "import": "./dist/index.mjs",
16
- "require": "./dist/index.js"
17
- }
18
- },
19
- "files": [
20
- "dist"
21
- ],
22
- "scripts": {
23
- "typecheck": "tsc --noEmit",
24
- "build": "tsup",
25
- "dev": "tsup --watch",
26
- "clean": "rm -rf dist"
27
- },
28
- "keywords": [
29
- "image",
30
- "comparison",
31
- "diff",
32
- "blazediff"
33
- ],
34
- "author": "Teimur Gasanov <me@teimurjan.dev> (https://github.com/teimurjan)",
35
- "repository": "https://github.com/teimurjan/blazediff",
36
- "homepage": "https://blazediff.dev",
37
- "license": "MIT",
38
- "devDependencies": {
39
- "tsup": "8.5.0",
40
- "typescript": "5.9.2"
41
- }
42
- }
2
+ "name": "@blazediff/contract",
3
+ "version": "0.0.0-stage",
4
+ "stub": true,
5
+ "description": "Temporary package placeholder for staged publishing"
6
+ }
package/dist/index.d.ts DELETED
@@ -1,93 +0,0 @@
1
- type BlazeDiffErrorCode = "invalid-image" | "invalid-output" | "invalid-mask" | "invalid-option";
2
- /** Thrown for invalid arguments. Comparable images never throw. */
3
- declare class BlazeDiffError extends Error {
4
- readonly code: BlazeDiffErrorCode;
5
- constructor(code: BlazeDiffErrorCode, message: string);
6
- }
7
-
8
- /** Pixel buffer accepted by every entry point (Node `Buffer` is a Uint8Array). */
9
- type PixelData = Uint8Array | Uint8ClampedArray;
10
- type Rgb = [number, number, number];
11
- /** RGBA8 pixels, `width * height * 4` bytes. Browser `ImageData` fits as is. */
12
- interface Image {
13
- data: PixelData;
14
- width: number;
15
- height: number;
16
- }
17
- /** `yiq`: the metric pixelmatch used before v8. `oklab`: pixelmatch 8's OKLab HyAB metric. */
18
- type Metric = "yiq" | "oklab";
19
- interface RenderOptions {
20
- /** Opacity of the unchanged image in the output (0-1). Default: 0.1 */
21
- alpha?: number;
22
- /** Default: [255, 0, 0] */
23
- diffColor?: Rgb;
24
- /** Color for pixels that get darker in `b`. Default: `diffColor` */
25
- diffColorAlt?: Rgb;
26
- /** Color for detected anti-aliased pixels. Default: [255, 255, 0] */
27
- aaColor?: Rgb;
28
- /** `faded`: a gray copy of `a` under the diff. `transparent`: the diff alone on a cleared buffer. Default: `faded` */
29
- background?: "faded" | "transparent";
30
- }
31
- interface DiffOptions {
32
- /**
33
- * Color difference threshold (0-1). Lower is stricter. Default: 0.1.
34
- * With `yiq` it scales a squared distance; with `oklab`, 1 is black vs white.
35
- */
36
- threshold?: number;
37
- /** Detect anti-aliased pixels and leave them out of the count. Default: true */
38
- antialiasing?: boolean;
39
- /** Default: `yiq` */
40
- metric?: Metric;
41
- /** One byte per pixel (`width * height`); pixels with a non-zero byte are skipped. */
42
- mask?: PixelData;
43
- /** Also report the N×N window with the most diff pixels. N is clamped to [1, min(width, height)]. */
44
- window?: number;
45
- /** Draw the diff here. Omit for a count-only comparison. */
46
- output?: Image;
47
- render?: RenderOptions;
48
- }
49
- interface Size {
50
- width: number;
51
- height: number;
52
- }
53
- /** Top-left corner and diff count of the busiest window. */
54
- interface WindowHit {
55
- x: number;
56
- y: number;
57
- count: number;
58
- }
59
- type DiffResult = {
60
- kind: "compared";
61
- /** Pixels that differ beyond `threshold`, after the mask and AA exclusion. */
62
- count: number;
63
- /** `count` as a percentage of all pixels. */
64
- percentage: number;
65
- /** True when `count` is 0. */
66
- identical: boolean;
67
- /** Present when the `window` option is set. */
68
- window?: WindowHit;
69
- } | {
70
- kind: "dimension-mismatch";
71
- a: Size;
72
- b: Size;
73
- };
74
-
75
- /**
76
- * Argument checks shared by `diff` in core, core-wasm and core-native, so all
77
- * three throw the same {@link BlazeDiffError} codes and messages.
78
- */
79
-
80
- declare function isValidImage(arr: unknown): arr is PixelData;
81
- declare function assertImage(image: Image, name: string, code: BlazeDiffErrorCode): void;
82
- /** Checks everything in `options` that does not depend on the image size. */
83
- declare function assertOptions(options: Pick<DiffOptions, "metric" | "mask" | "render">): void;
84
- /** Checks `output` and the mask length against a `width` × `height` comparison. */
85
- declare function assertTargets(options: Pick<DiffOptions, "mask" | "output">, width: number, height: number): void;
86
-
87
- /**
88
- * Window side for the `window` option, or 0 when windowing is off.
89
- * Floored and clamped to [1, min(width, height)] like pixelmatch.
90
- */
91
- declare function windowSide(window: number | undefined, width: number, height: number): number;
92
-
93
- export { BlazeDiffError, type BlazeDiffErrorCode, type DiffOptions, type DiffResult, type Image, type Metric, type PixelData, type RenderOptions, type Rgb, type Size, type WindowHit, assertImage, assertOptions, assertTargets, isValidImage, windowSide };
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- 'use strict';var o=class extends Error{constructor(e,t){super(t),this.name="BlazeDiffError",this.code=e;}};function f(r){return ArrayBuffer.isView(r)&&r.BYTES_PER_ELEMENT===1}function d(r,e,t){if(!f(r?.data))throw new o(t,`${e}.data must be a Uint8Array, Uint8ClampedArray or Buffer.`);let{width:n,height:i,data:s}=r;if(!Number.isInteger(n)||!Number.isInteger(i)||n<0||i<0)throw new o(t,`${e} has an invalid size: ${n}x${i}.`);if(s.length!==n*i*4)throw new o(t,`${e}.data is ${s.length} bytes, expected ${n*i*4} for ${n}x${i}.`)}function u(r){let{metric:e,mask:t,render:n}=r;if(e!==void 0&&e!=="yiq"&&e!=="oklab")throw new o("invalid-option",`Unknown metric: ${e}. Expected "yiq" or "oklab".`);let i=n?.background;if(i!==void 0&&i!=="faded"&&i!=="transparent")throw new o("invalid-option",`Unknown render.background: ${i}. Expected "faded" or "transparent".`);if(a(n?.diffColor,"diffColor"),a(n?.diffColorAlt,"diffColorAlt"),a(n?.aaColor,"aaColor"),t!==void 0&&!f(t))throw new o("invalid-mask","mask must be a byte array of width * height bytes.")}function p(r,e,t){let{mask:n,output:i}=r;if(i&&(d(i,"output","invalid-output"),i.width!==e||i.height!==t))throw new o("invalid-output",`output is ${i.width}x${i.height}, expected ${e}x${t}.`);if(n!==void 0&&n.length!==e*t)throw new o("invalid-mask",`mask must be a byte array of width * height = ${e*t} bytes.`)}function a(r,e){if(r!==void 0&&(r.length!==3||r.some(t=>!Number.isInteger(t)||t<0||t>255)))throw new o("invalid-option",`render.${e} must contain three integer RGB channels.`)}function m(r,e,t){return r===void 0||!Number.isFinite(r)?0:Math.min(Math.max(Math.floor(r),1),e,t)}exports.BlazeDiffError=o;exports.assertImage=d;exports.assertOptions=u;exports.assertTargets=p;exports.isValidImage=f;exports.windowSide=m;
package/dist/index.mjs DELETED
@@ -1 +0,0 @@
1
- var o=class extends Error{constructor(e,t){super(t),this.name="BlazeDiffError",this.code=e;}};function f(r){return ArrayBuffer.isView(r)&&r.BYTES_PER_ELEMENT===1}function d(r,e,t){if(!f(r?.data))throw new o(t,`${e}.data must be a Uint8Array, Uint8ClampedArray or Buffer.`);let{width:n,height:i,data:s}=r;if(!Number.isInteger(n)||!Number.isInteger(i)||n<0||i<0)throw new o(t,`${e} has an invalid size: ${n}x${i}.`);if(s.length!==n*i*4)throw new o(t,`${e}.data is ${s.length} bytes, expected ${n*i*4} for ${n}x${i}.`)}function u(r){let{metric:e,mask:t,render:n}=r;if(e!==void 0&&e!=="yiq"&&e!=="oklab")throw new o("invalid-option",`Unknown metric: ${e}. Expected "yiq" or "oklab".`);let i=n?.background;if(i!==void 0&&i!=="faded"&&i!=="transparent")throw new o("invalid-option",`Unknown render.background: ${i}. Expected "faded" or "transparent".`);if(a(n?.diffColor,"diffColor"),a(n?.diffColorAlt,"diffColorAlt"),a(n?.aaColor,"aaColor"),t!==void 0&&!f(t))throw new o("invalid-mask","mask must be a byte array of width * height bytes.")}function p(r,e,t){let{mask:n,output:i}=r;if(i&&(d(i,"output","invalid-output"),i.width!==e||i.height!==t))throw new o("invalid-output",`output is ${i.width}x${i.height}, expected ${e}x${t}.`);if(n!==void 0&&n.length!==e*t)throw new o("invalid-mask",`mask must be a byte array of width * height = ${e*t} bytes.`)}function a(r,e){if(r!==void 0&&(r.length!==3||r.some(t=>!Number.isInteger(t)||t<0||t>255)))throw new o("invalid-option",`render.${e} must contain three integer RGB channels.`)}function m(r,e,t){return r===void 0||!Number.isFinite(r)?0:Math.min(Math.max(Math.floor(r),1),e,t)}export{o as BlazeDiffError,d as assertImage,u as assertOptions,p as assertTargets,f as isValidImage,m as windowSide};