@flighthq/image 0.5.1-next.1350.8ce488b → 0.5.1-next.1404.457d1da
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
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/image`. The `@flight
|
|
|
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/image@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/image@0.5.1-next.1404.457d1da](https://github.com/flighthq/flight/tree/457d1da918a60be5853b84eb6c25530a66662cef/packages/image)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/457d1da918a60be5853b84eb6c25530a66662cef/LICENSE.md)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Bitmap,
|
|
2
|
-
export declare function createImageResourceFromBitmap(hostImage: Readonly<
|
|
1
|
+
import type { Bitmap, HostImageCapability, ImageResource } from '@flighthq/types/contract';
|
|
2
|
+
export declare function createImageResourceFromBitmap(hostImage: Readonly<HostImageCapability>, bitmap: Readonly<Bitmap>): ImageResource | null;
|
|
3
3
|
export declare function isImageUrlSameOrigin(url: string): boolean;
|
|
4
|
-
export declare function loadImageResourceFromBase64(hostImage: Readonly<
|
|
5
|
-
export declare function loadImageResourceFromBlob(hostImage: Readonly<
|
|
6
|
-
export declare function loadImageResourceFromBytes(hostImage: Readonly<
|
|
7
|
-
export declare function loadImageResourceFromUrl(hostImage: Readonly<
|
|
4
|
+
export declare function loadImageResourceFromBase64(hostImage: Readonly<HostImageCapability>, base64: string, mimeType: string, signal?: AbortSignal): Promise<ImageResource>;
|
|
5
|
+
export declare function loadImageResourceFromBlob(hostImage: Readonly<HostImageCapability>, blob: Blob, signal?: AbortSignal): Promise<ImageResource>;
|
|
6
|
+
export declare function loadImageResourceFromBytes(hostImage: Readonly<HostImageCapability>, bytes: Uint8Array, mimeType?: string, signal?: AbortSignal): Promise<ImageResource>;
|
|
7
|
+
export declare function loadImageResourceFromUrl(hostImage: Readonly<HostImageCapability>, url: string, crossOrigin?: 'anonymous' | 'use-credentials', signal?: AbortSignal): Promise<ImageResource>;
|
|
8
8
|
//# sourceMappingURL=imageResourceFrom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageResourceFrom.d.ts","sourceRoot":"","sources":["../src/imageResourceFrom.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"imageResourceFrom.d.ts","sourceRoot":"","sources":["../src/imageResourceFrom.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE3F,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACxC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GACvB,aAAa,GAAG,IAAI,CAItB;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOzD;AAED,wBAAsB,2BAA2B,CAC/C,SAAS,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACxC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC,CAExB;AAED,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACxC,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC,CAOxB;AAED,wBAAsB,0BAA0B,CAC9C,SAAS,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACxC,KAAK,EAAE,UAAU,EACjB,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC,CAOxB;AAED,wBAAsB,wBAAwB,CAC5C,SAAS,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACxC,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,WAAW,GAAG,iBAAiB,EAC7C,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC,CAExB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageResourceFrom.js","sourceRoot":"","sources":["../src/imageResourceFrom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE,MAAM,UAAU,6BAA6B,CAC3C,
|
|
1
|
+
{"version":3,"file":"imageResourceFrom.js","sourceRoot":"","sources":["../src/imageResourceFrom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE,MAAM,UAAU,6BAA6B,CAC3C,SAAwC,EACxC,MAAwB;IAExB,MAAM,OAAO,GAAG,SAAS,CAAC;IAC1B,IAAI,OAAO,CAAC,qBAAqB,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC7D,OAAO,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACpE,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CA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,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;AAC9D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/image",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.1404.457d1da",
|
|
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/entity": "0.5.1-next.
|
|
42
|
-
"@flighthq/image-codec": "0.5.1-next.
|
|
43
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.1404.457d1da",
|
|
42
|
+
"@flighthq/image-codec": "0.5.1-next.1404.457d1da",
|
|
43
|
+
"@flighthq/types": "0.5.1-next.1404.457d1da"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "^5.3.0"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
-
import type { Bitmap,
|
|
2
|
+
import type { Bitmap, HostImageCapability, ImageResource } from '@flighthq/types/contract';
|
|
3
3
|
import { BitmapTextureSourceKind, EntityRuntimeKey } from '@flighthq/types/contract';
|
|
4
4
|
|
|
5
5
|
import { createImageResource } from './imageResource';
|
|
@@ -21,7 +21,7 @@ afterEach(() => {
|
|
|
21
21
|
unregisterTestImageDimensionResolver();
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
function webHost(): { readonly graphics: { readonly image:
|
|
24
|
+
function webHost(): { readonly graphics: { readonly image: HostImageCapability } } {
|
|
25
25
|
return {
|
|
26
26
|
graphics: {
|
|
27
27
|
image: {
|
|
@@ -66,10 +66,10 @@ function webHost(): { readonly graphics: { readonly image: HostImageProvider } }
|
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
|
-
} as { readonly graphics: { readonly image:
|
|
69
|
+
} as { readonly graphics: { readonly image: HostImageCapability } };
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
let host: { readonly graphics: { readonly image:
|
|
72
|
+
let host: { readonly graphics: { readonly image: HostImageCapability } };
|
|
73
73
|
|
|
74
74
|
beforeEach(() => {
|
|
75
75
|
host = webHost();
|
|
@@ -87,12 +87,14 @@ describe('createImageResourceFromBitmap', () => {
|
|
|
87
87
|
const bitmap = createTestBitmap(3, 2);
|
|
88
88
|
const expected = {} as ImageResource;
|
|
89
89
|
const createImageFromBitmap = vi.fn((_bitmap: Readonly<Bitmap>) => expected);
|
|
90
|
-
const backend:
|
|
90
|
+
const backend: HostImageCapability = {
|
|
91
91
|
[EntityRuntimeKey]: undefined,
|
|
92
92
|
createImageFromBitmap,
|
|
93
93
|
loadImageFromUrl: vi.fn(),
|
|
94
94
|
};
|
|
95
|
-
const customHost = { graphics: { image: backend } } as {
|
|
95
|
+
const customHost = { graphics: { image: backend } } as {
|
|
96
|
+
readonly graphics: { readonly image: HostImageCapability };
|
|
97
|
+
};
|
|
96
98
|
vi.stubGlobal('document', undefined);
|
|
97
99
|
|
|
98
100
|
expect(createImageResourceFromBitmap(customHost.graphics.image, bitmap)).toBe(expected);
|
|
@@ -101,8 +103,10 @@ describe('createImageResourceFromBitmap', () => {
|
|
|
101
103
|
|
|
102
104
|
it('returns null for backend absence without throwing or falling back to DOM', () => {
|
|
103
105
|
const createElement = vi.spyOn(document, 'createElement');
|
|
104
|
-
const backend:
|
|
105
|
-
const customHost = { graphics: { image: backend } } as {
|
|
106
|
+
const backend: HostImageCapability = { [EntityRuntimeKey]: undefined, loadImageFromUrl: vi.fn() };
|
|
107
|
+
const customHost = { graphics: { image: backend } } as {
|
|
108
|
+
readonly graphics: { readonly image: HostImageCapability };
|
|
109
|
+
};
|
|
106
110
|
|
|
107
111
|
expect(() => createImageResourceFromBitmap(customHost.graphics.image, createTestBitmap(1, 1))).not.toThrow();
|
|
108
112
|
expect(createImageResourceFromBitmap(customHost.graphics.image, createTestBitmap(1, 1))).toBeNull();
|