@flighthq/bitmap 0.5.1-next.1069.554a2ac → 0.5.1-next.1197.6a425ce
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 +2 -2
- package/dist/bitmapEncode.d.ts +3 -3
- package/dist/bitmapEncode.d.ts.map +1 -1
- package/dist/bitmapEncode.js +6 -6
- package/dist/bitmapEncode.js.map +1 -1
- package/dist/bitmapFrom.d.ts +3 -5
- package/dist/bitmapFrom.d.ts.map +1 -1
- package/dist/bitmapFrom.js +4 -25
- package/dist/bitmapFrom.js.map +1 -1
- package/dist/bitmapReadbackResolver.d.ts +2 -2
- package/dist/bitmapReadbackResolver.d.ts.map +1 -1
- package/dist/bitmapReadbackResolver.js +2 -2
- package/dist/bitmapReadbackResolver.js.map +1 -1
- package/dist/contract.d.ts +0 -2
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +0 -2
- package/dist/contract.js.map +1 -1
- package/dist/explainBitmapReadback.d.ts +2 -2
- package/dist/explainBitmapReadback.d.ts.map +1 -1
- package/dist/explainBitmapReadback.js +2 -2
- package/dist/explainBitmapReadback.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/bitmapEncode.test.ts +18 -15
- package/src/bitmapFrom.test.ts +26 -58
- package/src/bitmapReadbackResolver.test.ts +16 -6
- package/src/explainBitmapReadback.test.ts +27 -18
- package/dist/bitmapDraw.d.ts +0 -8
- package/dist/bitmapDraw.d.ts.map +0 -1
- package/dist/bitmapDraw.js +0 -15
- package/dist/bitmapDraw.js.map +0 -1
- package/src/bitmapDraw.test.ts +0 -163
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/bitmap`. The `@fligh
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/bitmap@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/bitmap@0.5.1-next.1197.6a425ce](https://github.com/flighthq/flight/tree/6a425ce64e6d501dac8218fe625e73d58da88639/packages/bitmap)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/6a425ce64e6d501dac8218fe625e73d58da88639/LICENSE.md)
|
package/dist/bitmapEncode.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Bitmap, BitmapEncodeFailureExplanation,
|
|
2
|
-
export declare function encodeBitmap(
|
|
3
|
-
export declare function explainBitmapEncodeFailure(
|
|
1
|
+
import type { Bitmap, BitmapEncodeFailureExplanation, HostBitmapEncodeProvider, ImageFormat } from '@flighthq/types/contract';
|
|
2
|
+
export declare function encodeBitmap(hostBitmapEncode: Readonly<HostBitmapEncodeProvider>, source: Readonly<Bitmap>, format?: ImageFormat, quality?: number): Uint8Array | null;
|
|
3
|
+
export declare function explainBitmapEncodeFailure(hostBitmapEncode: Readonly<HostBitmapEncodeProvider>, format: ImageFormat): BitmapEncodeFailureExplanation | null;
|
|
4
4
|
//# sourceMappingURL=bitmapEncode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmapEncode.d.ts","sourceRoot":"","sources":["../src/bitmapEncode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,8BAA8B,EAC9B,
|
|
1
|
+
{"version":3,"file":"bitmapEncode.d.ts","sourceRoot":"","sources":["../src/bitmapEncode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,8BAA8B,EAC9B,wBAAwB,EACxB,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAElC,wBAAgB,YAAY,CAC1B,gBAAgB,EAAE,QAAQ,CAAC,wBAAwB,CAAC,EACpD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EACxB,MAAM,GAAE,WAAmB,EAC3B,OAAO,GAAE,MAAY,GACpB,UAAU,GAAG,IAAI,CAInB;AAED,wBAAgB,0BAA0B,CACxC,gBAAgB,EAAE,QAAQ,CAAC,wBAAwB,CAAC,EACpD,MAAM,EAAE,WAAW,GAClB,8BAA8B,GAAG,IAAI,CAGvC"}
|
package/dist/bitmapEncode.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export function encodeBitmap(
|
|
2
|
-
const resolution = resolveBitmapEncode(
|
|
1
|
+
export function encodeBitmap(hostBitmapEncode, source, format = 'png', quality = 0.9) {
|
|
2
|
+
const resolution = resolveBitmapEncode(hostBitmapEncode, format);
|
|
3
3
|
if (resolution.reason !== null)
|
|
4
4
|
return null;
|
|
5
5
|
return resolution.backend.encodeBitmap(source, resolution.format, quality);
|
|
6
6
|
}
|
|
7
|
-
export function explainBitmapEncodeFailure(
|
|
8
|
-
const resolution = resolveBitmapEncode(
|
|
7
|
+
export function explainBitmapEncodeFailure(hostBitmapEncode, format) {
|
|
8
|
+
const resolution = resolveBitmapEncode(hostBitmapEncode, format);
|
|
9
9
|
return resolution.reason === null ? null : { format: resolution.format, reason: resolution.reason };
|
|
10
10
|
}
|
|
11
|
-
function resolveBitmapEncode(
|
|
11
|
+
function resolveBitmapEncode(hostBitmapEncode, format) {
|
|
12
12
|
const normalizedFormat = format === 'jpeg' ? 'jpeg' : 'png';
|
|
13
|
-
const backend =
|
|
13
|
+
const backend = hostBitmapEncode;
|
|
14
14
|
if (!backend.supportedFormats.includes(normalizedFormat)) {
|
|
15
15
|
return { backend, format: normalizedFormat, reason: 'format-unsupported' };
|
|
16
16
|
}
|
package/dist/bitmapEncode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmapEncode.js","sourceRoot":"","sources":["../src/bitmapEncode.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,YAAY,CAC1B,
|
|
1
|
+
{"version":3,"file":"bitmapEncode.js","sourceRoot":"","sources":["../src/bitmapEncode.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,YAAY,CAC1B,gBAAoD,EACpD,MAAwB,EACxB,SAAsB,KAAK,EAC3B,UAAkB,GAAG;IAErB,MAAM,UAAU,GAAG,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACjE,IAAI,UAAU,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,gBAAoD,EACpD,MAAmB;IAEnB,MAAM,UAAU,GAAG,mBAAmB,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACjE,OAAO,UAAU,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;AACtG,CAAC;AAcD,SAAS,mBAAmB,CAC1B,gBAAoD,EACpD,MAAmB;IAEnB,MAAM,gBAAgB,GAAgB,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IACzE,MAAM,OAAO,GAAG,gBAAgB,CAAC;IACjC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACzD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC7E,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC7D,CAAC"}
|
package/dist/bitmapFrom.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { Bitmap,
|
|
2
|
-
export declare function captureBitmapFromImageResource(
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function createBitmapFromImageSource(host: Readonly<HasGraphicsBitmapReadback>, source: CanvasImageSource, width: number, height: number): Bitmap | null;
|
|
5
|
-
export declare function initializeBitmapFromCanvas(out: EntityConstruction<Bitmap>, canvas: HTMLCanvasElement, x?: number, y?: number, width?: number, height?: number): void;
|
|
1
|
+
import type { Bitmap, HostBitmapReadbackProvider, HostImageSource, ImageResource } from '@flighthq/types/contract';
|
|
2
|
+
export declare function captureBitmapFromImageResource(hostBitmapReadback: Readonly<HostBitmapReadbackProvider>, resource: Readonly<ImageResource>): Bitmap | null;
|
|
3
|
+
export declare function createBitmapFromImageSource(hostBitmapReadback: Readonly<HostBitmapReadbackProvider>, source: HostImageSource, width: number, height: number): Bitmap | null;
|
|
6
4
|
//# sourceMappingURL=bitmapFrom.d.ts.map
|
package/dist/bitmapFrom.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmapFrom.d.ts","sourceRoot":"","sources":["../src/bitmapFrom.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bitmapFrom.d.ts","sourceRoot":"","sources":["../src/bitmapFrom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,0BAA0B,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAInH,wBAAgB,8BAA8B,CAC5C,kBAAkB,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EACxD,QAAQ,EAAE,QAAQ,CAAC,aAAa,CAAC,GAChC,MAAM,GAAG,IAAI,CAEf;AAED,wBAAgB,2BAA2B,CACzC,kBAAkB,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EACxD,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,IAAI,CAEf"}
|
package/dist/bitmapFrom.js
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
|
-
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
-
import { BitmapTextureSourceKind } from '@flighthq/types/contract';
|
|
3
1
|
import { resolveBitmapReadback } from './bitmapReadbackResolver';
|
|
4
|
-
export function captureBitmapFromImageResource(
|
|
5
|
-
return createBitmapFromImageSource(
|
|
2
|
+
export function captureBitmapFromImageResource(hostBitmapReadback, resource) {
|
|
3
|
+
return createBitmapFromImageSource(hostBitmapReadback, resource.source, resource.width, resource.height);
|
|
6
4
|
}
|
|
7
|
-
export function
|
|
8
|
-
|
|
9
|
-
initializeBitmapFromCanvas(out, canvas, x, y, width, height);
|
|
10
|
-
return finishEntity(out);
|
|
11
|
-
}
|
|
12
|
-
export function createBitmapFromImageSource(host, source, width, height) {
|
|
13
|
-
return resolveBitmapReadback(host, source, width, height, 'bitmap').bitmap;
|
|
14
|
-
}
|
|
15
|
-
export function initializeBitmapFromCanvas(out, canvas, x = 0, y = 0, width, height) {
|
|
16
|
-
const w = width ?? canvas.width;
|
|
17
|
-
const h = height ?? canvas.height;
|
|
18
|
-
const ctx = canvas.getContext('2d');
|
|
19
|
-
const raw = ctx.getImageData(x, y, w, h);
|
|
20
|
-
out.alphaType = 'straight';
|
|
21
|
-
out.gamut = raw.colorSpace;
|
|
22
|
-
out.data = raw.data;
|
|
23
|
-
out.format = 'rgba8unorm';
|
|
24
|
-
out.height = raw.height;
|
|
25
|
-
out.kind = BitmapTextureSourceKind;
|
|
26
|
-
out.version = 0;
|
|
27
|
-
out.width = raw.width;
|
|
5
|
+
export function createBitmapFromImageSource(hostBitmapReadback, source, width, height) {
|
|
6
|
+
return resolveBitmapReadback(hostBitmapReadback, source, width, height, 'bitmap').bitmap;
|
|
28
7
|
}
|
|
29
8
|
//# sourceMappingURL=bitmapFrom.js.map
|
package/dist/bitmapFrom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmapFrom.js","sourceRoot":"","sources":["../src/bitmapFrom.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bitmapFrom.js","sourceRoot":"","sources":["../src/bitmapFrom.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,UAAU,8BAA8B,CAC5C,kBAAwD,EACxD,QAAiC;IAEjC,OAAO,2BAA2B,CAAC,kBAAkB,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC3G,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,kBAAwD,EACxD,MAAuB,EACvB,KAAa,EACb,MAAc;IAEd,OAAO,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC;AAC3F,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Bitmap, BitmapReadbackBlockReason, BitmapReadbackMode,
|
|
1
|
+
import type { Bitmap, BitmapReadbackBlockReason, BitmapReadbackMode, HostBitmapReadbackProvider, HostImageSource } from '@flighthq/types/contract';
|
|
2
2
|
interface BitmapReadbackResolution {
|
|
3
3
|
readonly bitmap: Bitmap | null;
|
|
4
4
|
readonly reason: BitmapReadbackBlockReason;
|
|
5
5
|
}
|
|
6
|
-
export declare function resolveBitmapReadback(
|
|
6
|
+
export declare function resolveBitmapReadback(hostBitmapReadback: Readonly<HostBitmapReadbackProvider>, source: HostImageSource, width: number, height: number, mode: BitmapReadbackMode): BitmapReadbackResolution;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=bitmapReadbackResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmapReadbackResolver.d.ts","sourceRoot":"","sources":["../src/bitmapReadbackResolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,yBAAyB,EACzB,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"bitmapReadbackResolver.d.ts","sourceRoot":"","sources":["../src/bitmapReadbackResolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,yBAAyB,EACzB,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAElC,UAAU,wBAAwB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC;CAC5C;AAED,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EACxD,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,kBAAkB,GACvB,wBAAwB,CAG1B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function resolveBitmapReadback(
|
|
1
|
+
export function resolveBitmapReadback(hostBitmapReadback, source, width, height, mode) {
|
|
2
2
|
if (width <= 0 || height <= 0)
|
|
3
3
|
return { bitmap: null, reason: 'empty-size' };
|
|
4
|
-
return
|
|
4
|
+
return hostBitmapReadback.readBitmap(source, width, height, mode);
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=bitmapReadbackResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmapReadbackResolver.js","sourceRoot":"","sources":["../src/bitmapReadbackResolver.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,qBAAqB,CACnC,
|
|
1
|
+
{"version":3,"file":"bitmapReadbackResolver.js","sourceRoot":"","sources":["../src/bitmapReadbackResolver.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,qBAAqB,CACnC,kBAAwD,EACxD,MAAuB,EACvB,KAAa,EACb,MAAc,EACd,IAAwB;IAExB,IAAI,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAC7E,OAAO,kBAAkB,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AACpE,CAAC"}
|
package/dist/contract.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ export * from './bitmapCoverage';
|
|
|
13
13
|
export * from './bitmapCrop';
|
|
14
14
|
export * from './bitmapDisplacement';
|
|
15
15
|
export * from './bitmapDissolve';
|
|
16
|
-
export * from './bitmapDraw';
|
|
17
16
|
export * from './bitmapEncode';
|
|
18
17
|
export * from './bitmapFill';
|
|
19
18
|
export * from './bitmapFingerprint';
|
|
@@ -40,6 +39,5 @@ export * from './bitmapTone';
|
|
|
40
39
|
export * from './bitmapTransform';
|
|
41
40
|
export * from './bitmapWarp';
|
|
42
41
|
export * from './explainBitmapReadback';
|
|
43
|
-
export { initializeBitmapFromCanvas } from './bitmapFrom';
|
|
44
42
|
export { initializeBitmap } from './bitmap';
|
|
45
43
|
//# sourceMappingURL=contract.d.ts.map
|
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/contract.js
CHANGED
|
@@ -13,7 +13,6 @@ export * from './bitmapCoverage';
|
|
|
13
13
|
export * from './bitmapCrop';
|
|
14
14
|
export * from './bitmapDisplacement';
|
|
15
15
|
export * from './bitmapDissolve';
|
|
16
|
-
export * from './bitmapDraw';
|
|
17
16
|
export * from './bitmapEncode';
|
|
18
17
|
export * from './bitmapFill';
|
|
19
18
|
export * from './bitmapFingerprint';
|
|
@@ -40,6 +39,5 @@ export * from './bitmapTone';
|
|
|
40
39
|
export * from './bitmapTransform';
|
|
41
40
|
export * from './bitmapWarp';
|
|
42
41
|
export * from './explainBitmapReadback';
|
|
43
|
-
export { initializeBitmapFromCanvas } from './bitmapFrom';
|
|
44
42
|
export { initializeBitmap } from './bitmap';
|
|
45
43
|
//# sourceMappingURL=contract.js.map
|
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { BitmapReadbackExplanation,
|
|
2
|
-
export declare function explainBitmapReadback(
|
|
1
|
+
import type { BitmapReadbackExplanation, HostBitmapReadbackProvider, HostImageSource } from '@flighthq/types/contract';
|
|
2
|
+
export declare function explainBitmapReadback(hostBitmapReadback: Readonly<HostBitmapReadbackProvider>, source: HostImageSource, width: number, height: number): BitmapReadbackExplanation;
|
|
3
3
|
//# sourceMappingURL=explainBitmapReadback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explainBitmapReadback.d.ts","sourceRoot":"","sources":["../src/explainBitmapReadback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"explainBitmapReadback.d.ts","sourceRoot":"","sources":["../src/explainBitmapReadback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAIvH,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,QAAQ,CAAC,0BAA0B,CAAC,EACxD,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,yBAAyB,CAG3B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveBitmapReadback } from './bitmapReadbackResolver';
|
|
2
|
-
export function explainBitmapReadback(
|
|
3
|
-
const outcome = resolveBitmapReadback(
|
|
2
|
+
export function explainBitmapReadback(hostBitmapReadback, source, width, height) {
|
|
3
|
+
const outcome = resolveBitmapReadback(hostBitmapReadback, source, width, height, 'probe');
|
|
4
4
|
return { readable: outcome.reason === 'ok', reason: outcome.reason };
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=explainBitmapReadback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explainBitmapReadback.js","sourceRoot":"","sources":["../src/explainBitmapReadback.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,UAAU,qBAAqB,CACnC,
|
|
1
|
+
{"version":3,"file":"explainBitmapReadback.js","sourceRoot":"","sources":["../src/explainBitmapReadback.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,UAAU,qBAAqB,CACnC,kBAAwD,EACxD,MAAuB,EACvB,KAAa,EACb,MAAc;IAEd,MAAM,OAAO,GAAG,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1F,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;AACvE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ImageChannel, BITMAP_FINGERPRINT_COMPUTATION_ID, BITMAP_NOISE_CHANNEL_A, BITMAP_NOISE_CHANNEL_B, BITMAP_NOISE_CHANNEL_G, BITMAP_NOISE_CHANNEL_R, applyBitmapColorScaleBias, applyBitmapCurve, applyBitmapLevels, applyBitmapPaletteMap, applyBitmapThreshold, bevelBitmap, blurBitmapPixelsHorizontal, blurBitmapPixelsHorizontalWeighted, blurBitmapPixelsVertical, blurBitmapPixelsVerticalWeighted, boxBlurBitmap, buildBitmapBrightnessColorMatrix, buildBitmapContrastColorMatrix, buildBitmapGradientRamp, buildBitmapGrayscaleColorMatrix, buildBitmapHueRotationColorMatrix, buildBitmapInvertColorMatrix, buildBitmapSaturationColorMatrix, buildBitmapSepiaColorMatrix, cloneBitmap, colorMatrixBitmap, compareBitmap, compareBitmapFingerprints, compositeBitmapPixels, compositeBitmapRegion, computeGaussianKernel, concatBitmapColorMatrix, convertBitmapAlphaType, convertBitmapPixelOrder, convolveBitmap, copyBitmapAlpha, copyBitmapChannel, copyBitmapPixels, createBitmap, createBitmapFingerprint,
|
|
1
|
+
export { ImageChannel, BITMAP_FINGERPRINT_COMPUTATION_ID, BITMAP_NOISE_CHANNEL_A, BITMAP_NOISE_CHANNEL_B, BITMAP_NOISE_CHANNEL_G, BITMAP_NOISE_CHANNEL_R, applyBitmapColorScaleBias, applyBitmapCurve, applyBitmapLevels, applyBitmapPaletteMap, applyBitmapThreshold, bevelBitmap, blurBitmapPixelsHorizontal, blurBitmapPixelsHorizontalWeighted, blurBitmapPixelsVertical, blurBitmapPixelsVerticalWeighted, boxBlurBitmap, buildBitmapBrightnessColorMatrix, buildBitmapContrastColorMatrix, buildBitmapGradientRamp, buildBitmapGrayscaleColorMatrix, buildBitmapHueRotationColorMatrix, buildBitmapInvertColorMatrix, buildBitmapSaturationColorMatrix, buildBitmapSepiaColorMatrix, cloneBitmap, colorMatrixBitmap, compareBitmap, compareBitmapFingerprints, compositeBitmapPixels, compositeBitmapRegion, computeGaussianKernel, concatBitmapColorMatrix, convertBitmapAlphaType, convertBitmapPixelOrder, convolveBitmap, copyBitmapAlpha, copyBitmapChannel, copyBitmapPixels, createBitmap, createBitmapFingerprint, captureBitmapFromImageResource, createBitmapFromImageSource, explainBitmapReadback, createBitmapRegion, cropBitmap, dilateBitmap, displaceBitmap, dissolveBitmapPixels, dropShadowBitmap, encodeBitmap, explainBitmapEncodeFailure, equalizeBitmapHistogram, erodeBitmap, extendBitmap, extractBitmapPixels, extractBitmapPixels32, fillBitmapLinearGradient, fillBitmapNoise, fillBitmapPerlinNoise, fillBitmapRadialGradient, fillBitmapRectangle, fillBitmapTurbulence, flipBitmapHorizontal, flipBitmapVertical, floodFillBitmap, formatBitmapFingerprint, gaussianBlurBitmap, getBitmapColorBoundsRectangle, getBitmapCoverage, getBitmapHistogram, getBitmapMismatch, getBitmapPixel, getBitmapPixelChannel, getBitmapPixelLuminance, getBitmapPixelRgb, glowBitmap, gradientBevelBitmap, gradientGlowBitmap, innerGlowBitmap, innerShadowBitmap, invalidateBitmap, medianBitmap, mergeBitmap, mergeBitmapChannels, multiplyBitmapAlpha, parseBitmapFingerprint, pixelateBitmap, premultiplyBitmapPixels, resizeBitmap, rotateBitmap, rotateBitmap180, rotateBitmapClockwise, rotateBitmapCounterClockwise, scrollBitmap, setBitmapAlpha, setBitmapColorMatrixIdentity, setBitmapPixel, setBitmapPixelRgb, setBitmapRegion, sharpenBitmap, splitBitmapChannels, transformBitmap, trimBitmap, unpremultiplyBitmapPixels, warpBitmap, warpBitmapQuad, writeBitmapPixels, writeBitmapPixels32, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iCAAiC,EACjC,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,0BAA0B,EAC1B,kCAAkC,EAClC,wBAAwB,EACxB,gCAAgC,EAChC,aAAa,EACb,gCAAgC,EAChC,8BAA8B,EAC9B,uBAAuB,EACvB,+BAA+B,EAC/B,iCAAiC,EACjC,4BAA4B,EAC5B,gCAAgC,EAChC,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iCAAiC,EACjC,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,0BAA0B,EAC1B,kCAAkC,EAClC,wBAAwB,EACxB,gCAAgC,EAChC,aAAa,EACb,gCAAgC,EAChC,8BAA8B,EAC9B,uBAAuB,EACvB,+BAA+B,EAC/B,iCAAiC,EACjC,4BAA4B,EAC5B,gCAAgC,EAChC,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,0BAA0B,EAC1B,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC7B,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,4BAA4B,EAC5B,YAAY,EACZ,cAAc,EACd,4BAA4B,EAC5B,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,yBAAyB,EACzB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ImageChannel, BITMAP_FINGERPRINT_COMPUTATION_ID, BITMAP_NOISE_CHANNEL_A, BITMAP_NOISE_CHANNEL_B, BITMAP_NOISE_CHANNEL_G, BITMAP_NOISE_CHANNEL_R, applyBitmapColorScaleBias, applyBitmapCurve, applyBitmapLevels, applyBitmapPaletteMap, applyBitmapThreshold, bevelBitmap, blurBitmapPixelsHorizontal, blurBitmapPixelsHorizontalWeighted, blurBitmapPixelsVertical, blurBitmapPixelsVerticalWeighted, boxBlurBitmap, buildBitmapBrightnessColorMatrix, buildBitmapContrastColorMatrix, buildBitmapGradientRamp, buildBitmapGrayscaleColorMatrix, buildBitmapHueRotationColorMatrix, buildBitmapInvertColorMatrix, buildBitmapSaturationColorMatrix, buildBitmapSepiaColorMatrix, cloneBitmap, colorMatrixBitmap, compareBitmap, compareBitmapFingerprints, compositeBitmapPixels, compositeBitmapRegion, computeGaussianKernel, concatBitmapColorMatrix, convertBitmapAlphaType, convertBitmapPixelOrder, convolveBitmap, copyBitmapAlpha, copyBitmapChannel, copyBitmapPixels, createBitmap, createBitmapFingerprint,
|
|
1
|
+
export { ImageChannel, BITMAP_FINGERPRINT_COMPUTATION_ID, BITMAP_NOISE_CHANNEL_A, BITMAP_NOISE_CHANNEL_B, BITMAP_NOISE_CHANNEL_G, BITMAP_NOISE_CHANNEL_R, applyBitmapColorScaleBias, applyBitmapCurve, applyBitmapLevels, applyBitmapPaletteMap, applyBitmapThreshold, bevelBitmap, blurBitmapPixelsHorizontal, blurBitmapPixelsHorizontalWeighted, blurBitmapPixelsVertical, blurBitmapPixelsVerticalWeighted, boxBlurBitmap, buildBitmapBrightnessColorMatrix, buildBitmapContrastColorMatrix, buildBitmapGradientRamp, buildBitmapGrayscaleColorMatrix, buildBitmapHueRotationColorMatrix, buildBitmapInvertColorMatrix, buildBitmapSaturationColorMatrix, buildBitmapSepiaColorMatrix, cloneBitmap, colorMatrixBitmap, compareBitmap, compareBitmapFingerprints, compositeBitmapPixels, compositeBitmapRegion, computeGaussianKernel, concatBitmapColorMatrix, convertBitmapAlphaType, convertBitmapPixelOrder, convolveBitmap, copyBitmapAlpha, copyBitmapChannel, copyBitmapPixels, createBitmap, createBitmapFingerprint, captureBitmapFromImageResource, createBitmapFromImageSource, explainBitmapReadback, createBitmapRegion, cropBitmap, dilateBitmap, displaceBitmap, dissolveBitmapPixels, dropShadowBitmap, encodeBitmap, explainBitmapEncodeFailure, equalizeBitmapHistogram, erodeBitmap, extendBitmap, extractBitmapPixels, extractBitmapPixels32, fillBitmapLinearGradient, fillBitmapNoise, fillBitmapPerlinNoise, fillBitmapRadialGradient, fillBitmapRectangle, fillBitmapTurbulence, flipBitmapHorizontal, flipBitmapVertical, floodFillBitmap, formatBitmapFingerprint, gaussianBlurBitmap, getBitmapColorBoundsRectangle, getBitmapCoverage, getBitmapHistogram, getBitmapMismatch, getBitmapPixel, getBitmapPixelChannel, getBitmapPixelLuminance, getBitmapPixelRgb, glowBitmap, gradientBevelBitmap, gradientGlowBitmap, innerGlowBitmap, innerShadowBitmap, invalidateBitmap, medianBitmap, mergeBitmap, mergeBitmapChannels, multiplyBitmapAlpha, parseBitmapFingerprint, pixelateBitmap, premultiplyBitmapPixels, resizeBitmap, rotateBitmap, rotateBitmap180, rotateBitmapClockwise, rotateBitmapCounterClockwise, scrollBitmap, setBitmapAlpha, setBitmapColorMatrixIdentity, setBitmapPixel, setBitmapPixelRgb, setBitmapRegion, sharpenBitmap, splitBitmapChannels, transformBitmap, trimBitmap, unpremultiplyBitmapPixels, warpBitmap, warpBitmapQuad, writeBitmapPixels, writeBitmapPixels32, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iCAAiC,EACjC,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,0BAA0B,EAC1B,kCAAkC,EAClC,wBAAwB,EACxB,gCAAgC,EAChC,aAAa,EACb,gCAAgC,EAChC,8BAA8B,EAC9B,uBAAuB,EACvB,+BAA+B,EAC/B,iCAAiC,EACjC,4BAA4B,EAC5B,gCAAgC,EAChC,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iCAAiC,EACjC,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,0BAA0B,EAC1B,kCAAkC,EAClC,wBAAwB,EACxB,gCAAgC,EAChC,aAAa,EACb,gCAAgC,EAChC,8BAA8B,EAC9B,uBAAuB,EACvB,+BAA+B,EAC/B,iCAAiC,EACjC,4BAA4B,EAC5B,gCAAgC,EAChC,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,0BAA0B,EAC1B,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC7B,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,4BAA4B,EAC5B,YAAY,EACZ,cAAc,EACd,4BAA4B,EAC5B,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,UAAU,EACV,yBAAyB,EACzB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/bitmap",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.1197.6a425ce",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/image": "0.5.1-next.
|
|
42
|
-
"@flighthq/entity": "0.5.1-next.
|
|
43
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/image": "0.5.1-next.1197.6a425ce",
|
|
42
|
+
"@flighthq/entity": "0.5.1-next.1197.6a425ce",
|
|
43
|
+
"@flighthq/types": "0.5.1-next.1197.6a425ce"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "^5.3.0"
|
package/src/bitmapEncode.test.ts
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostBitmapEncodeProvider, ImageFormat } from '@flighthq/types/contract';
|
|
2
2
|
|
|
3
3
|
import { createBitmap } from './bitmap';
|
|
4
4
|
import { encodeBitmap, explainBitmapEncodeFailure } from './bitmapEncode';
|
|
5
5
|
|
|
6
6
|
function hostWith(
|
|
7
|
-
supportedFormats:
|
|
7
|
+
supportedFormats: HostBitmapEncodeProvider['supportedFormats'] = ['jpeg', 'png'],
|
|
8
8
|
bytes: Uint8Array = new Uint8Array([9, 8, 7]),
|
|
9
|
-
):
|
|
9
|
+
): { readonly graphics: { readonly bitmapEncode: HostBitmapEncodeProvider } } {
|
|
10
10
|
return {
|
|
11
11
|
graphics: {
|
|
12
12
|
bitmapEncode: {
|
|
13
13
|
encodeBitmap: vi.fn(() => bytes),
|
|
14
14
|
supportedFormats,
|
|
15
|
-
} satisfies
|
|
15
|
+
} satisfies HostBitmapEncodeProvider,
|
|
16
16
|
},
|
|
17
|
-
} as
|
|
17
|
+
} as { readonly graphics: { readonly bitmapEncode: HostBitmapEncodeProvider } };
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
describe('encodeBitmap', () => {
|
|
21
21
|
it('dispatches the default png format and quality to the host backend', () => {
|
|
22
22
|
const host = hostWith();
|
|
23
23
|
const source = createBitmap(2, 2, 0x112233ff);
|
|
24
|
-
expect(encodeBitmap(host, source)).toEqual(new Uint8Array([9, 8, 7]));
|
|
24
|
+
expect(encodeBitmap(host.graphics.bitmapEncode, source)).toEqual(new Uint8Array([9, 8, 7]));
|
|
25
25
|
expect(host.graphics.bitmapEncode.encodeBitmap).toHaveBeenCalledWith(source, 'png', 0.9);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it('forwards jpeg and caller quality unchanged', () => {
|
|
29
29
|
const host = hostWith();
|
|
30
30
|
const source = createBitmap(1, 1);
|
|
31
|
-
encodeBitmap(host, source, 'jpeg', 1.25);
|
|
31
|
+
encodeBitmap(host.graphics.bitmapEncode, source, 'jpeg', 1.25);
|
|
32
32
|
expect(host.graphics.bitmapEncode.encodeBitmap).toHaveBeenCalledWith(source, 'jpeg', 1.25);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it('preserves the legacy runtime fallback from every non-jpeg value to png', () => {
|
|
36
36
|
const host = hostWith();
|
|
37
37
|
const source = createBitmap(1, 1);
|
|
38
|
-
encodeBitmap(host, source, 'webp' as ImageFormat);
|
|
38
|
+
encodeBitmap(host.graphics.bitmapEncode, source, 'webp' as ImageFormat);
|
|
39
39
|
expect(host.graphics.bitmapEncode.encodeBitmap).toHaveBeenCalledWith(source, 'png', 0.9);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
it('returns null when the backend does not support the format', () => {
|
|
43
43
|
const host = hostWith(['png']);
|
|
44
|
-
expect(encodeBitmap(host, createBitmap(1, 1), 'jpeg')).toBeNull();
|
|
44
|
+
expect(encodeBitmap(host.graphics.bitmapEncode, createBitmap(1, 1), 'jpeg')).toBeNull();
|
|
45
45
|
expect(host.graphics.bitmapEncode.encodeBitmap).not.toHaveBeenCalled();
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -54,27 +54,30 @@ describe('encodeBitmap', () => {
|
|
|
54
54
|
throw failure;
|
|
55
55
|
},
|
|
56
56
|
supportedFormats: ['png'],
|
|
57
|
-
} satisfies
|
|
57
|
+
} satisfies HostBitmapEncodeProvider,
|
|
58
58
|
},
|
|
59
|
-
} as
|
|
60
|
-
expect(() => encodeBitmap(host, createBitmap(1, 1))).toThrow(failure);
|
|
59
|
+
} as { readonly graphics: { readonly bitmapEncode: HostBitmapEncodeProvider } };
|
|
60
|
+
expect(() => encodeBitmap(host.graphics.bitmapEncode, createBitmap(1, 1))).toThrow(failure);
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
describe('explainBitmapEncodeFailure', () => {
|
|
65
65
|
it('reports an unsupported format from the host backend', () => {
|
|
66
66
|
const host = hostWith(['png']);
|
|
67
|
-
expect(explainBitmapEncodeFailure(host, 'jpeg')).toEqual({
|
|
67
|
+
expect(explainBitmapEncodeFailure(host.graphics.bitmapEncode, 'jpeg')).toEqual({
|
|
68
|
+
format: 'jpeg',
|
|
69
|
+
reason: 'format-unsupported',
|
|
70
|
+
});
|
|
68
71
|
});
|
|
69
72
|
|
|
70
73
|
it('returns null for webp because it normalizes to png which is supported', () => {
|
|
71
74
|
const host = hostWith(['png']);
|
|
72
|
-
expect(explainBitmapEncodeFailure(host, 'webp' as ImageFormat)).toBeNull();
|
|
75
|
+
expect(explainBitmapEncodeFailure(host.graphics.bitmapEncode, 'webp' as ImageFormat)).toBeNull();
|
|
73
76
|
});
|
|
74
77
|
|
|
75
78
|
it('returns null for a supported format without invoking the encoder', () => {
|
|
76
79
|
const host = hostWith(['png']);
|
|
77
|
-
expect(explainBitmapEncodeFailure(host, 'png')).toBeNull();
|
|
80
|
+
expect(explainBitmapEncodeFailure(host.graphics.bitmapEncode, 'png')).toBeNull();
|
|
78
81
|
expect(host.graphics.bitmapEncode.encodeBitmap).not.toHaveBeenCalled();
|
|
79
82
|
});
|
|
80
83
|
});
|
package/src/bitmapFrom.test.ts
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
createImageResource,
|
|
3
|
+
registerTestImageDimensionResolver,
|
|
4
|
+
unregisterTestImageDimensionResolver,
|
|
5
|
+
} from '@flighthq/image/contract';
|
|
6
|
+
import type { HostBitmapReadbackProvider } from '@flighthq/types/contract';
|
|
3
7
|
import { vi } from 'vitest';
|
|
4
8
|
|
|
5
9
|
import { createBitmap } from './bitmap';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from './bitmapFrom';
|
|
10
|
+
import { captureBitmapFromImageResource, createBitmapFromImageSource } from './bitmapFrom';
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
registerTestImageDimensionResolver();
|
|
14
|
+
});
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
unregisterTestImageDimensionResolver();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function hostWith(backend: HostBitmapReadbackProvider): {
|
|
21
|
+
readonly graphics: { readonly bitmapReadback: HostBitmapReadbackProvider };
|
|
22
|
+
} {
|
|
23
|
+
return { graphics: { bitmapReadback: backend } } as {
|
|
24
|
+
readonly graphics: { readonly bitmapReadback: HostBitmapReadbackProvider };
|
|
25
|
+
};
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
describe('captureBitmapFromImageResource', () => {
|
|
@@ -23,7 +34,7 @@ describe('captureBitmapFromImageResource', () => {
|
|
|
23
34
|
const readBitmap = vi.fn(() => ({ bitmap, reason: 'ok' as const }));
|
|
24
35
|
const host = hostWith({ readBitmap });
|
|
25
36
|
|
|
26
|
-
expect(captureBitmapFromImageResource(host, createImageResource(canvas))).toBe(bitmap);
|
|
37
|
+
expect(captureBitmapFromImageResource(host.graphics.bitmapReadback, createImageResource(canvas))).toBe(bitmap);
|
|
27
38
|
expect(readBitmap).toHaveBeenCalledOnce();
|
|
28
39
|
expect(readBitmap).toHaveBeenCalledWith(canvas, 3, 2, 'bitmap');
|
|
29
40
|
});
|
|
@@ -36,47 +47,7 @@ describe('captureBitmapFromImageResource', () => {
|
|
|
36
47
|
canvas.width = 4;
|
|
37
48
|
canvas.height = 4;
|
|
38
49
|
|
|
39
|
-
expect(captureBitmapFromImageResource(host, createImageResource(canvas))).toBeNull();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('createBitmapFromCanvas', () => {
|
|
44
|
-
it('returns Bitmap matching the canvas size', () => {
|
|
45
|
-
const canvas = document.createElement('canvas');
|
|
46
|
-
canvas.width = 4;
|
|
47
|
-
canvas.height = 4;
|
|
48
|
-
const data = createBitmapFromCanvas(canvas);
|
|
49
|
-
expect(data.width).toBe(4);
|
|
50
|
-
expect(data.height).toBe(4);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('returns a Bitmap with data length matching canvas pixels', () => {
|
|
54
|
-
const canvas = document.createElement('canvas');
|
|
55
|
-
canvas.width = 8;
|
|
56
|
-
canvas.height = 8;
|
|
57
|
-
const data = createBitmapFromCanvas(canvas);
|
|
58
|
-
expect(data.data.length).toBe(8 * 8 * 4);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('returns only the requested subrectangle', () => {
|
|
62
|
-
const canvas = document.createElement('canvas');
|
|
63
|
-
canvas.width = 8;
|
|
64
|
-
canvas.height = 8;
|
|
65
|
-
|
|
66
|
-
const data = createBitmapFromCanvas(canvas, 2, 1, 2, 3);
|
|
67
|
-
|
|
68
|
-
expect(data.width).toBe(2);
|
|
69
|
-
expect(data.height).toBe(3);
|
|
70
|
-
expect(data.data).toHaveLength(2 * 3 * 4);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('rejects a zero-area read like a browser canvas', () => {
|
|
74
|
-
const context = document.createElement('canvas').getContext('2d')!;
|
|
75
|
-
const callWithTooFewArguments = context.getImageData as unknown as (...args: number[]) => ImageData;
|
|
76
|
-
|
|
77
|
-
expect(() => callWithTooFewArguments(0, 0, 1)).toThrowError(TypeError);
|
|
78
|
-
expect(() => context.getImageData(0, 0, 0, 1)).toThrowError(DOMException);
|
|
79
|
-
expect(() => context.getImageData(0, 0, 1, 0)).toThrowError(DOMException);
|
|
50
|
+
expect(captureBitmapFromImageResource(host.graphics.bitmapReadback, createImageResource(canvas))).toBeNull();
|
|
80
51
|
});
|
|
81
52
|
});
|
|
82
53
|
|
|
@@ -87,11 +58,8 @@ describe('createBitmapFromImageSource', () => {
|
|
|
87
58
|
readBitmap: vi.fn(() => ({ bitmap: expected, reason: 'ok' as const })),
|
|
88
59
|
});
|
|
89
60
|
|
|
90
|
-
expect(createBitmapFromImageSource(host, document.createElement('canvas'), 8, 4)).toBe(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
describe('initializeBitmapFromCanvas', () => {
|
|
94
|
-
it('is the construction initializer of createBitmapFromCanvas', () => {
|
|
95
|
-
expect(typeof initializeBitmapFromCanvas).toBe('function');
|
|
61
|
+
expect(createBitmapFromImageSource(host.graphics.bitmapReadback, document.createElement('canvas'), 8, 4)).toBe(
|
|
62
|
+
expected,
|
|
63
|
+
);
|
|
96
64
|
});
|
|
97
65
|
});
|
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostBitmapReadbackProvider, HostImageSource } from '@flighthq/types/contract';
|
|
2
2
|
import { vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import { resolveBitmapReadback } from './bitmapReadbackResolver';
|
|
5
5
|
|
|
6
6
|
function hostWith(
|
|
7
|
-
readBitmap:
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
readBitmap: {
|
|
8
|
+
readonly graphics: { readonly bitmapReadback: HostBitmapReadbackProvider };
|
|
9
|
+
}['graphics']['bitmapReadback']['readBitmap'],
|
|
10
|
+
): { readonly graphics: { readonly bitmapReadback: HostBitmapReadbackProvider } } {
|
|
11
|
+
return { graphics: { bitmapReadback: { readBitmap } } } as {
|
|
12
|
+
readonly graphics: { readonly bitmapReadback: HostBitmapReadbackProvider };
|
|
13
|
+
};
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
describe('resolveBitmapReadback', () => {
|
|
13
17
|
it('rejects empty dimensions before backend selection', () => {
|
|
14
18
|
const host = hostWith(() => ({ bitmap: null, reason: 'ok' }));
|
|
15
|
-
expect(resolveBitmapReadback(host, source, 0, 1, 'bitmap')).toEqual({
|
|
19
|
+
expect(resolveBitmapReadback(host.graphics.bitmapReadback, source, 0, 1, 'bitmap')).toEqual({
|
|
20
|
+
bitmap: null,
|
|
21
|
+
reason: 'empty-size',
|
|
22
|
+
});
|
|
16
23
|
});
|
|
17
24
|
|
|
18
25
|
it('forwards source, dimensions, and mode to the host backend', () => {
|
|
19
26
|
const readBitmap = vi.fn(() => ({ bitmap: null, reason: 'ok' as const }));
|
|
20
27
|
const host = hostWith(readBitmap);
|
|
21
28
|
|
|
22
|
-
expect(resolveBitmapReadback(host, source, 3, 5, 'probe')).toEqual({
|
|
29
|
+
expect(resolveBitmapReadback(host.graphics.bitmapReadback, source, 3, 5, 'probe')).toEqual({
|
|
30
|
+
bitmap: null,
|
|
31
|
+
reason: 'ok',
|
|
32
|
+
});
|
|
23
33
|
expect(readBitmap).toHaveBeenCalledWith(source, 3, 5, 'probe');
|
|
24
34
|
});
|
|
25
35
|
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
BitmapReadbackBackend,
|
|
3
|
-
BitmapReadbackBackendReason,
|
|
4
|
-
HasGraphicsBitmapReadback,
|
|
5
|
-
} from '@flighthq/types/contract';
|
|
1
|
+
import type { HostBitmapReadbackProvider, BitmapReadbackBackendReason } from '@flighthq/types/contract';
|
|
6
2
|
import { describe, expect, it, vi } from 'vitest';
|
|
7
3
|
|
|
8
4
|
import { createBitmap } from './bitmap';
|
|
9
5
|
import { createBitmapFromImageSource } from './bitmapFrom';
|
|
10
6
|
import { explainBitmapReadback } from './explainBitmapReadback';
|
|
11
7
|
|
|
12
|
-
function hostWith(backend:
|
|
13
|
-
|
|
8
|
+
function hostWith(backend: HostBitmapReadbackProvider): {
|
|
9
|
+
readonly graphics: { readonly bitmapReadback: HostBitmapReadbackProvider };
|
|
10
|
+
} {
|
|
11
|
+
return { graphics: { bitmapReadback: backend } } as {
|
|
12
|
+
readonly graphics: { readonly bitmapReadback: HostBitmapReadbackProvider };
|
|
13
|
+
};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function makeCanvas(width = 8, height = 4): HTMLCanvasElement {
|
|
@@ -25,24 +25,33 @@ describe('explainBitmapReadback', () => {
|
|
|
25
25
|
const readBitmap = vi.fn(() => ({ bitmap: null, reason: 'tainted-source' as const }));
|
|
26
26
|
const host = hostWith({ readBitmap });
|
|
27
27
|
|
|
28
|
-
expect(explainBitmapReadback(host, makeCanvas(), 0, 4)).toEqual({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
expect(explainBitmapReadback(host.graphics.bitmapReadback, makeCanvas(), 0, 4)).toEqual({
|
|
29
|
+
readable: false,
|
|
30
|
+
reason: 'empty-size',
|
|
31
|
+
});
|
|
32
|
+
expect(explainBitmapReadback(host.graphics.bitmapReadback, makeCanvas(), 8, 0)).toEqual({
|
|
33
|
+
readable: false,
|
|
34
|
+
reason: 'empty-size',
|
|
35
|
+
});
|
|
36
|
+
expect(explainBitmapReadback(host.graphics.bitmapReadback, makeCanvas(), -1, 4)).toEqual({
|
|
37
|
+
readable: false,
|
|
38
|
+
reason: 'empty-size',
|
|
39
|
+
});
|
|
40
|
+
expect(createBitmapFromImageSource(host.graphics.bitmapReadback, makeCanvas(), 8, -1)).toBeNull();
|
|
32
41
|
expect(readBitmap).not.toHaveBeenCalled();
|
|
33
42
|
});
|
|
34
43
|
|
|
35
44
|
it('returns the exact success outcome and keeps constructor/explainer parity', () => {
|
|
36
45
|
const bitmap = createBitmap(8, 4);
|
|
37
|
-
const readBitmap:
|
|
46
|
+
const readBitmap: HostBitmapReadbackProvider['readBitmap'] = vi.fn((_source, _width, _height, mode) => ({
|
|
38
47
|
bitmap: mode === 'bitmap' ? bitmap : null,
|
|
39
48
|
reason: 'ok' as const,
|
|
40
49
|
}));
|
|
41
50
|
const host = hostWith({ readBitmap });
|
|
42
51
|
const source = makeCanvas();
|
|
43
52
|
|
|
44
|
-
expect(createBitmapFromImageSource(host, source, 8, 4)).toBe(bitmap);
|
|
45
|
-
expect(explainBitmapReadback(host, source, 8, 4)).toEqual({ readable: true, reason: 'ok' });
|
|
53
|
+
expect(createBitmapFromImageSource(host.graphics.bitmapReadback, source, 8, 4)).toBe(bitmap);
|
|
54
|
+
expect(explainBitmapReadback(host.graphics.bitmapReadback, source, 8, 4)).toEqual({ readable: true, reason: 'ok' });
|
|
46
55
|
expect(readBitmap).toHaveBeenNthCalledWith(1, source, 8, 4, 'bitmap');
|
|
47
56
|
expect(readBitmap).toHaveBeenNthCalledWith(2, source, 8, 4, 'probe');
|
|
48
57
|
});
|
|
@@ -53,8 +62,8 @@ describe('explainBitmapReadback', () => {
|
|
|
53
62
|
const host = hostWith({ readBitmap: () => ({ bitmap: null, reason }) });
|
|
54
63
|
const source = makeCanvas();
|
|
55
64
|
|
|
56
|
-
expect(createBitmapFromImageSource(host, source, 8, 4)).toBeNull();
|
|
57
|
-
expect(explainBitmapReadback(host, source, 8, 4)).toEqual({ readable: false, reason });
|
|
65
|
+
expect(createBitmapFromImageSource(host.graphics.bitmapReadback, source, 8, 4)).toBeNull();
|
|
66
|
+
expect(explainBitmapReadback(host.graphics.bitmapReadback, source, 8, 4)).toEqual({ readable: false, reason });
|
|
58
67
|
},
|
|
59
68
|
);
|
|
60
69
|
|
|
@@ -68,7 +77,7 @@ describe('explainBitmapReadback', () => {
|
|
|
68
77
|
});
|
|
69
78
|
const source = makeCanvas();
|
|
70
79
|
|
|
71
|
-
expect(explainBitmapReadback(host, source, 8, 4)).toEqual({ readable: true, reason: 'ok' });
|
|
72
|
-
expect(() => createBitmapFromImageSource(host, source, 8, 4)).toThrow(fault);
|
|
80
|
+
expect(explainBitmapReadback(host.graphics.bitmapReadback, source, 8, 4)).toEqual({ readable: true, reason: 'ok' });
|
|
81
|
+
expect(() => createBitmapFromImageSource(host.graphics.bitmapReadback, source, 8, 4)).toThrow(fault);
|
|
73
82
|
});
|
|
74
83
|
});
|
package/dist/bitmapDraw.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { BitmapRegion } from '@flighthq/types/contract';
|
|
2
|
-
/**
|
|
3
|
-
* Draws the `source` region onto a 2D canvas at `(x, y)` via `putImageData`.
|
|
4
|
-
* A region with a zero dimension is a no-op (`ImageData` requires positive
|
|
5
|
-
* dimensions).
|
|
6
|
-
*/
|
|
7
|
-
export declare function drawBitmap(dest: HTMLCanvasElement, source: Readonly<BitmapRegion>, x: number, y: number): void;
|
|
8
|
-
//# sourceMappingURL=bitmapDraw.d.ts.map
|
package/dist/bitmapDraw.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bitmapDraw.d.ts","sourceRoot":"","sources":["../src/bitmapDraw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7D;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM9G"}
|
package/dist/bitmapDraw.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { extractBitmapPixels } from './bitmapComposite';
|
|
2
|
-
/**
|
|
3
|
-
* Draws the `source` region onto a 2D canvas at `(x, y)` via `putImageData`.
|
|
4
|
-
* A region with a zero dimension is a no-op (`ImageData` requires positive
|
|
5
|
-
* dimensions).
|
|
6
|
-
*/
|
|
7
|
-
export function drawBitmap(dest, source, x, y) {
|
|
8
|
-
if (source.width <= 0 || source.height <= 0)
|
|
9
|
-
return;
|
|
10
|
-
const context = dest.getContext('2d');
|
|
11
|
-
const domImageData = context.createImageData(source.width, source.height);
|
|
12
|
-
extractBitmapPixels(domImageData.data, source);
|
|
13
|
-
context.putImageData(domImageData, x, y);
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=bitmapDraw.js.map
|
package/dist/bitmapDraw.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bitmapDraw.js","sourceRoot":"","sources":["../src/bitmapDraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAuB,EAAE,MAA8B,EAAE,CAAS,EAAE,CAAS;IACtG,IAAI,MAAM,CAAC,KAAK,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO;IACpD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAE,CAAC;IACvC,MAAM,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1E,mBAAmB,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/C,OAAO,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
package/src/bitmapDraw.test.ts
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { createBitmap } from './bitmap';
|
|
2
|
-
import { extractBitmapPixels } from './bitmapComposite';
|
|
3
|
-
import { drawBitmap } from './bitmapDraw';
|
|
4
|
-
import { setBitmapPixel } from './bitmapPixel';
|
|
5
|
-
|
|
6
|
-
function region(bitmap: ReturnType<typeof createBitmap>, x = 0, y = 0, width = bitmap.width, height = bitmap.height) {
|
|
7
|
-
return { bitmap, x, y, width, height };
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function readExtractedPixel(buf: Uint8ClampedArray, regionWidth: number, x: number, y: number): number {
|
|
11
|
-
const i = (y * regionWidth + x) * 4;
|
|
12
|
-
return ((buf[i] << 24) | (buf[i + 1] << 16) | (buf[i + 2] << 8) | buf[i + 3]) >>> 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function guardGlobalImageDataAccess() {
|
|
16
|
-
const descriptor = Object.getOwnPropertyDescriptor(globalThis, 'ImageData');
|
|
17
|
-
let accesses = 0;
|
|
18
|
-
Object.defineProperty(globalThis, 'ImageData', {
|
|
19
|
-
configurable: true,
|
|
20
|
-
get() {
|
|
21
|
-
accesses++;
|
|
22
|
-
throw new Error('global ImageData must not be accessed');
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
return {
|
|
26
|
-
get accesses() {
|
|
27
|
-
return accesses;
|
|
28
|
-
},
|
|
29
|
-
restore() {
|
|
30
|
-
if (descriptor === undefined) Reflect.deleteProperty(globalThis, 'ImageData');
|
|
31
|
-
else Object.defineProperty(globalThis, 'ImageData', descriptor);
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
describe('drawBitmap', () => {
|
|
37
|
-
it('allocates through one destination context and puts the exact extracted pixels at the caller coordinates', () => {
|
|
38
|
-
const src = createBitmap(2, 1);
|
|
39
|
-
setBitmapPixel(src, 0, 0, 0x112233ff);
|
|
40
|
-
setBitmapPixel(src, 1, 0, 0xaabbccdd);
|
|
41
|
-
const imageData = {
|
|
42
|
-
colorSpace: 'srgb',
|
|
43
|
-
data: new Uint8ClampedArray(8),
|
|
44
|
-
height: 1,
|
|
45
|
-
width: 2,
|
|
46
|
-
} as ImageData;
|
|
47
|
-
const createImageData = vi.fn(() => imageData);
|
|
48
|
-
const putImageData = vi.fn();
|
|
49
|
-
const getContext = vi.fn(() => ({ createImageData, putImageData }));
|
|
50
|
-
const canvas = document.createElement('canvas');
|
|
51
|
-
Object.defineProperty(canvas, 'getContext', { configurable: true, value: getContext });
|
|
52
|
-
const globalImageData = guardGlobalImageDataAccess();
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
drawBitmap(canvas, region(src), 7, -3);
|
|
56
|
-
expect(getContext).toHaveBeenCalledOnce();
|
|
57
|
-
expect(getContext).toHaveBeenCalledWith('2d');
|
|
58
|
-
expect(createImageData).toHaveBeenCalledOnce();
|
|
59
|
-
expect(createImageData).toHaveBeenCalledWith(2, 1);
|
|
60
|
-
expect(Array.from(imageData.data)).toEqual([17, 34, 51, 255, 170, 187, 204, 221]);
|
|
61
|
-
expect(putImageData).toHaveBeenCalledOnce();
|
|
62
|
-
expect(putImageData).toHaveBeenCalledWith(imageData, 7, -3);
|
|
63
|
-
expect(globalImageData.accesses).toBe(0);
|
|
64
|
-
} finally {
|
|
65
|
-
globalImageData.restore();
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('extracts correct pixels from a filled source', () => {
|
|
70
|
-
const src = createBitmap(4, 4, 0xff0000ff);
|
|
71
|
-
const r = region(src);
|
|
72
|
-
const buf = new Uint8ClampedArray(r.width * r.height * 4);
|
|
73
|
-
extractBitmapPixels(buf, r);
|
|
74
|
-
expect(readExtractedPixel(buf, r.width, 0, 0)).toBe(0xff0000ff);
|
|
75
|
-
expect(readExtractedPixel(buf, r.width, 3, 3)).toBe(0xff0000ff);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('extracts correct pixels from a sub-region', () => {
|
|
79
|
-
const src = createBitmap(4, 4);
|
|
80
|
-
setBitmapPixel(src, 1, 1, 0xaabbccdd);
|
|
81
|
-
setBitmapPixel(src, 2, 2, 0x11223344);
|
|
82
|
-
const r = region(src, 1, 1, 2, 2);
|
|
83
|
-
const buf = new Uint8ClampedArray(r.width * r.height * 4);
|
|
84
|
-
extractBitmapPixels(buf, r);
|
|
85
|
-
expect(readExtractedPixel(buf, r.width, 0, 0)).toBe(0xaabbccdd);
|
|
86
|
-
expect(readExtractedPixel(buf, r.width, 1, 1)).toBe(0x11223344);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('extracts zeroes from an empty bitmap', () => {
|
|
90
|
-
const src = createBitmap(2, 2);
|
|
91
|
-
const r = region(src);
|
|
92
|
-
const buf = new Uint8ClampedArray(r.width * r.height * 4);
|
|
93
|
-
extractBitmapPixels(buf, r);
|
|
94
|
-
expect(readExtractedPixel(buf, r.width, 0, 0)).toBe(0x00000000);
|
|
95
|
-
expect(readExtractedPixel(buf, r.width, 1, 1)).toBe(0x00000000);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it.each([
|
|
99
|
-
['width', 0, 1],
|
|
100
|
-
['height', 1, 0],
|
|
101
|
-
] as const)('is a no-op for a zero %s before context, allocation, extraction, or put', (_axis, width, height) => {
|
|
102
|
-
const src = createBitmap(2, 2, 0x112233ff);
|
|
103
|
-
const sourceData = src.data;
|
|
104
|
-
let sourceDataAccesses = 0;
|
|
105
|
-
Object.defineProperty(src, 'data', {
|
|
106
|
-
configurable: true,
|
|
107
|
-
get() {
|
|
108
|
-
sourceDataAccesses++;
|
|
109
|
-
return sourceData;
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
const createImageData = vi.fn();
|
|
113
|
-
const putImageData = vi.fn();
|
|
114
|
-
const getContext = vi.fn(() => ({ createImageData, putImageData }));
|
|
115
|
-
const canvas = document.createElement('canvas');
|
|
116
|
-
Object.defineProperty(canvas, 'getContext', { configurable: true, value: getContext });
|
|
117
|
-
const globalImageData = guardGlobalImageDataAccess();
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
expect(() => drawBitmap(canvas, region(src, 0, 0, width, height), 0, 0)).not.toThrow();
|
|
121
|
-
expect(getContext).not.toHaveBeenCalled();
|
|
122
|
-
expect(createImageData).not.toHaveBeenCalled();
|
|
123
|
-
expect(putImageData).not.toHaveBeenCalled();
|
|
124
|
-
expect(sourceDataAccesses).toBe(0);
|
|
125
|
-
expect(globalImageData.accesses).toBe(0);
|
|
126
|
-
} finally {
|
|
127
|
-
globalImageData.restore();
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('throws from a null positive-size context before allocation, extraction, or put', () => {
|
|
132
|
-
const src = createBitmap(1, 1, 0x112233ff);
|
|
133
|
-
const sourceData = src.data;
|
|
134
|
-
let sourceDataAccesses = 0;
|
|
135
|
-
Object.defineProperty(src, 'data', {
|
|
136
|
-
configurable: true,
|
|
137
|
-
get() {
|
|
138
|
-
sourceDataAccesses++;
|
|
139
|
-
return sourceData;
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
const getContext = vi.fn(() => null);
|
|
143
|
-
const canvas = document.createElement('canvas');
|
|
144
|
-
Object.defineProperty(canvas, 'getContext', { configurable: true, value: getContext });
|
|
145
|
-
const globalImageData = guardGlobalImageDataAccess();
|
|
146
|
-
const createImageData = vi.spyOn(CanvasRenderingContext2D.prototype, 'createImageData');
|
|
147
|
-
const putImageData = vi.spyOn(CanvasRenderingContext2D.prototype, 'putImageData');
|
|
148
|
-
|
|
149
|
-
try {
|
|
150
|
-
expect(() => drawBitmap(canvas, region(src), 0, 0)).toThrow();
|
|
151
|
-
expect(getContext).toHaveBeenCalledOnce();
|
|
152
|
-
expect(getContext).toHaveBeenCalledWith('2d');
|
|
153
|
-
expect(createImageData).not.toHaveBeenCalled();
|
|
154
|
-
expect(putImageData).not.toHaveBeenCalled();
|
|
155
|
-
expect(sourceDataAccesses).toBe(0);
|
|
156
|
-
expect(globalImageData.accesses).toBe(0);
|
|
157
|
-
} finally {
|
|
158
|
-
createImageData.mockRestore();
|
|
159
|
-
putImageData.mockRestore();
|
|
160
|
-
globalImageData.restore();
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
});
|