@flighthq/image 0.5.1-next.973.788d3d7 → 0.6.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/README.md +2 -2
- package/dist/.tsbuildinfo.contract +1 -0
- package/dist/.tsbuildinfo.runtime +1 -0
- package/dist/contract.d.ts +6 -6
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.image-types.d.ts +2 -0
- package/dist/contract.image-types.d.ts.map +1 -0
- package/dist/contract.image-types.js +5 -0
- package/dist/contract.image-types.js.map +1 -0
- package/dist/contract.js +6 -6
- package/dist/contract.js.map +1 -1
- package/dist/imageResource.d.ts +3 -1
- package/dist/imageResource.d.ts.map +1 -1
- package/dist/imageResource.js +21 -17
- package/dist/imageResource.js.map +1 -1
- package/dist/imageResourceFrom.d.ts +7 -12
- package/dist/imageResourceFrom.d.ts.map +1 -1
- package/dist/imageResourceFrom.js +10 -56
- package/dist/imageResourceFrom.js.map +1 -1
- package/dist/imageResourceReference.d.ts +6 -4
- package/dist/imageResourceReference.d.ts.map +1 -1
- package/dist/imageResourceReference.js +32 -45
- package/dist/imageResourceReference.js.map +1 -1
- package/dist/imageSourceDimensions.d.ts +6 -0
- package/dist/imageSourceDimensions.d.ts.map +1 -0
- package/dist/imageSourceDimensions.js +24 -0
- package/dist/imageSourceDimensions.js.map +1 -0
- package/dist/imageTestHelper.d.ts +5 -0
- package/dist/imageTestHelper.d.ts.map +1 -0
- package/dist/imageTestHelper.js +29 -0
- package/dist/imageTestHelper.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +93 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +11 -5
- package/src/imageResource.test.ts +16 -3
- package/src/imageResourceFrom.test.ts +52 -130
- package/src/imageResourceReference.test.ts +62 -114
- package/src/imageSourceDimensions.test.ts +86 -0
- package/src/imageTestHelper.test.ts +48 -0
|
@@ -1,41 +1,47 @@
|
|
|
1
|
-
import { allocateEntity
|
|
2
|
-
import { decodeImage, decodeImagePremultiplied
|
|
3
|
-
import {
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
2
|
+
import { decodeImage, decodeImagePremultiplied } from '@flighthq/image-codec/contract';
|
|
3
|
+
import { ResourceResolutionState } from '@flighthq/resource/contract';
|
|
4
|
+
import { BitmapTextureSourceKind } from '@flighthq/texture/contract';
|
|
5
|
+
import { ImageResourceFailureKind, ImageResourceReferenceKind } from './types.js';
|
|
4
6
|
export function createEmbeddedImageResourceReference(bytes, mimeType = null, alphaType = 'straight') {
|
|
5
7
|
const out = allocateEntity();
|
|
6
8
|
initializeEmbeddedImageResourceReference(out, bytes, mimeType, alphaType);
|
|
7
|
-
return
|
|
9
|
+
return out;
|
|
8
10
|
}
|
|
9
11
|
export function createExternalImageResourceReference(uri, basePath = null) {
|
|
10
12
|
const out = allocateEntity();
|
|
11
13
|
initializeExternalImageResourceReference(out, uri, basePath);
|
|
12
|
-
return
|
|
14
|
+
return out;
|
|
13
15
|
}
|
|
14
16
|
// The one encoded-byte producer for image resource references. A registered decoder owns format
|
|
15
17
|
// knowledge; this async resource layer turns its RGBA result into the live Bitmap entity renderers
|
|
16
18
|
// dispatch by kind. The reference's alpha request is carried onto the source verbatim, so bytes that
|
|
17
19
|
// are already premultiplied never get multiplied a second time at renderer upload.
|
|
18
|
-
async function decodeEmbeddedImageResourceReference(ref, signal) {
|
|
20
|
+
async function decodeEmbeddedImageResourceReference(imageDecode, ref, signal, fallbackDecode) {
|
|
19
21
|
if (ref.bitmapComposition !== undefined && _resolveImageBitmapComposition !== null) {
|
|
20
|
-
return _resolveImageBitmapComposition(ref, signal);
|
|
22
|
+
return _resolveImageBitmapComposition(imageDecode, ref, signal);
|
|
21
23
|
}
|
|
22
24
|
signal.throwIfAborted();
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const premultiplied = ref.alphaType === 'premultiplied';
|
|
26
|
+
let decoded = await (premultiplied
|
|
27
|
+
? decodeImagePremultiplied(imageDecode, ref.bytes, ref.mimeType ?? undefined)
|
|
28
|
+
: decodeImage(imageDecode, ref.bytes, ref.mimeType ?? undefined));
|
|
29
|
+
if (decoded === null && fallbackDecode !== undefined && ref.mimeType !== null) {
|
|
30
|
+
decoded = await fallbackDecode(ref.bytes, ref.mimeType, premultiplied ? { premultiplyAlpha: true } : undefined);
|
|
31
|
+
}
|
|
26
32
|
signal.throwIfAborted();
|
|
27
33
|
if (decoded === null)
|
|
28
34
|
return null;
|
|
29
35
|
const out = allocateEntity();
|
|
30
36
|
out.alphaType = ref.alphaType;
|
|
31
|
-
out.data = new
|
|
37
|
+
out.data = new Uint8Array(decoded.data);
|
|
32
38
|
out.format = 'rgba8unorm';
|
|
33
39
|
out.gamut = 'srgb';
|
|
34
40
|
out.height = decoded.height;
|
|
35
41
|
out.kind = BitmapTextureSourceKind;
|
|
36
42
|
out.version = 0;
|
|
37
43
|
out.width = decoded.width;
|
|
38
|
-
return
|
|
44
|
+
return out;
|
|
39
45
|
}
|
|
40
46
|
// Reduces a thrown value to the serialization-safe categories a reference retains. Raw Error objects and
|
|
41
47
|
// arbitrary thrown values stay inside the resolving operation; diagnostics get category, name, and message.
|
|
@@ -45,36 +51,14 @@ export function createImageResourceFailure(cause) {
|
|
|
45
51
|
out.kind = ImageResourceFailureKind.Error;
|
|
46
52
|
out.message = cause.message;
|
|
47
53
|
out.name = cause.name;
|
|
48
|
-
return
|
|
54
|
+
return out;
|
|
49
55
|
}
|
|
50
56
|
const out = allocateEntity();
|
|
51
57
|
out.kind = ImageResourceFailureKind.Error;
|
|
52
58
|
out.message = String(cause);
|
|
53
59
|
out.name = null;
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
export function disableImageBitmapComposition() {
|
|
57
|
-
_resolveImageBitmapComposition = null;
|
|
58
|
-
}
|
|
59
|
-
// Installs the optional decoded-pixel join without making an ordinary embedded-image consumer retain
|
|
60
|
-
// its registry lookup or straight-decode branch. A format package calls this beside its composer
|
|
61
|
-
// registrations; until then the nullable hook leaves the original hot path byte-for-byte tree-shakable.
|
|
62
|
-
export function enableImageBitmapComposition() {
|
|
63
|
-
_resolveImageBitmapComposition = resolveImageBitmapComposition;
|
|
64
|
-
}
|
|
65
|
-
async function resolveImageBitmapComposition(ref, signal) {
|
|
66
|
-
signal.throwIfAborted();
|
|
67
|
-
const composition = ref.bitmapComposition;
|
|
68
|
-
const composer = getImageBitmapComposer(composition.kind);
|
|
69
|
-
if (composer === null)
|
|
70
|
-
return null;
|
|
71
|
-
// A composer always receives straight decoded pixels. It may also own a raw raster with no MIME
|
|
72
|
-
// decoder, in which case decoded is null and its plain payload is the complete input.
|
|
73
|
-
const decoded = await decodeImage(ref.bytes, ref.mimeType ?? undefined);
|
|
74
|
-
signal.throwIfAborted();
|
|
75
|
-
return composer(decoded, composition.payload);
|
|
60
|
+
return out;
|
|
76
61
|
}
|
|
77
|
-
let _resolveImageBitmapComposition = null;
|
|
78
62
|
// Returns a detached plain-data explanation suitable for logs, tools, and serialization. It never throws
|
|
79
63
|
// and exposes no resolver runtime or raw thrown value.
|
|
80
64
|
export function explainImageResourceReferenceResolution(ref) {
|
|
@@ -85,6 +69,7 @@ export function explainImageResourceReferenceResolution(ref) {
|
|
|
85
69
|
state: ref.state,
|
|
86
70
|
};
|
|
87
71
|
}
|
|
72
|
+
let _resolveImageBitmapComposition = null;
|
|
88
73
|
// `bytes` is retained as the view the container handed over, not a copy: a parser carves an image payload
|
|
89
74
|
// out of its source and the reference borrows it, so a document that never resolves an image never pays for
|
|
90
75
|
// its pixels. `textures` starts empty and each waiting Texture subscribes itself.
|
|
@@ -106,6 +91,13 @@ export function initializeExternalImageResourceReference(out, uri, basePath = nu
|
|
|
106
91
|
out.textures = [];
|
|
107
92
|
out.uri = uri;
|
|
108
93
|
}
|
|
94
|
+
// The slot the optional decoded-pixel join installs into, so an ordinary embedded-image consumer keeps
|
|
95
|
+
// neither a composer registry nor a second decode branch. Whoever owns the composers — the web host
|
|
96
|
+
// today, through enableWebImageBitmapComposition — puts its resolver here and passes null to take it back;
|
|
97
|
+
// until something does, the nullable hook leaves the original hot path byte-for-byte tree-shakable.
|
|
98
|
+
export function registerImageBitmapCompositionResolver(resolver) {
|
|
99
|
+
_resolveImageBitmapComposition = resolver;
|
|
100
|
+
}
|
|
109
101
|
// Returns a failed reference to the requestable state. Loading/resolved/unresolved references are unchanged
|
|
110
102
|
// so this atom cannot invalidate live work or a successfully bound resource accidentally.
|
|
111
103
|
export function resetFailedImageResourceReference(ref) {
|
|
@@ -123,24 +115,19 @@ export function resetFailedImageResourceReference(ref) {
|
|
|
123
115
|
//
|
|
124
116
|
// This is the whole lifecycle for a document that resolves its images once. A caller needing concurrency
|
|
125
117
|
// limits, priority, or retry drives those around this atom rather than inside it.
|
|
126
|
-
export async function resolveImageResourceReference(ref, fetch, signal) {
|
|
118
|
+
export async function resolveImageResourceReference(imageDecode, ref, fetch, signal, fallbackDecode) {
|
|
127
119
|
ref.failure = null;
|
|
128
120
|
ref.state = ResourceResolutionState.Loading;
|
|
129
121
|
try {
|
|
130
|
-
const usesOrdinaryEmbeddedDecode = ref.kind === ImageResourceReferenceKind.Embedded &&
|
|
131
|
-
(ref.bitmapComposition === undefined || _resolveImageBitmapComposition === null);
|
|
132
122
|
const source = ref.kind === ImageResourceReferenceKind.Embedded
|
|
133
|
-
? await decodeEmbeddedImageResourceReference(ref, signal)
|
|
123
|
+
? await decodeEmbeddedImageResourceReference(imageDecode, ref, signal, fallbackDecode)
|
|
134
124
|
: await fetch(ref, signal);
|
|
135
125
|
if (source === null) {
|
|
136
|
-
const decodeFailure = usesOrdinaryEmbeddedDecode
|
|
137
|
-
? explainImageDecodeFailure(ref.bytes, ref.mimeType ?? undefined)
|
|
138
|
-
: null;
|
|
139
126
|
const out = allocateEntity();
|
|
140
127
|
out.kind = ImageResourceFailureKind.Unavailable;
|
|
141
|
-
out.message =
|
|
128
|
+
out.message = 'Image resource unavailable';
|
|
142
129
|
out.name = null;
|
|
143
|
-
ref.failure =
|
|
130
|
+
ref.failure = out;
|
|
144
131
|
ref.state = ResourceResolutionState.Failed;
|
|
145
132
|
return null;
|
|
146
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageResourceReference.js","sourceRoot":"","sources":["../src/imageResourceReference.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"imageResourceReference.js","sourceRoot":"","sources":["../src/imageResourceReference.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAEvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAWrE,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAElF,MAAM,UAAU,oCAAoC,CAClD,KAAiB,EACjB,QAAQ,GAAkB,IAAI,EAC9B,SAAS,GAAc,UAAU;IAEjC,MAAM,GAAG,GAAG,cAAc,EAAkC,CAAC;IAC7D,wCAAwC,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC1E,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,oCAAoC,CAClD,GAAW,EACX,QAAQ,GAAkB,IAAI;IAE9B,MAAM,GAAG,GAAG,cAAc,EAAkC,CAAC;IAC7D,wCAAwC,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC7D,OAAO,GAAG,CAAC;AACb,CAAC;AAED,gGAAgG;AAChG,mGAAmG;AACnG,qGAAqG;AACrG,mFAAmF;AACnF,KAAK,UAAU,oCAAoC,CACjD,WA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,UAAU,CAAC;YAC/C,MAAM,KAAK,CAAC;QACd,CAAC;QACD,GAAG,CAAC,OAAO,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC;QAChD,GAAG,CAAC,KAAK,GAAG,uBAAuB,CAAC,MAAM,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HostImageDimensionResolver, HostImageDimensions } from './types.ts';
|
|
2
|
+
export declare function getHostImageSourceDimensions(source: CanvasImageSource, out: HostImageDimensions): boolean;
|
|
3
|
+
export declare function hasHostImageDimensionResolver(): boolean;
|
|
4
|
+
export declare function registerHostImageDimensionResolver(resolver: HostImageDimensionResolver): void;
|
|
5
|
+
export declare function unregisterHostImageDimensionResolver(): void;
|
|
6
|
+
//# sourceMappingURL=imageSourceDimensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageSourceDimensions.d.ts","sourceRoot":"","sources":["../src/imageSourceDimensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAKlF,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAGzG;AAID,wBAAgB,6BAA6B,IAAI,OAAO,CAEvD;AAKD,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,0BAA0B,GAAG,IAAI,CAE7F;AAED,wBAAgB,oCAAoC,IAAI,IAAI,CAE3D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Reads the pixel size of a borrowed host handle through the registered host resolver, returning false
|
|
2
|
+
// when no resolver is registered or the registered one does not recognize this handle. `out` is left
|
|
3
|
+
// untouched in both cases, so a caller keeps whatever dimensions it already had.
|
|
4
|
+
export function getHostImageSourceDimensions(source, out) {
|
|
5
|
+
if (_resolver === null)
|
|
6
|
+
return false;
|
|
7
|
+
return _resolver(source, out);
|
|
8
|
+
}
|
|
9
|
+
// True once a host has installed its resolver. A caller that measures sources can require this rather
|
|
10
|
+
// than discovering silently-zero dimensions at draw time.
|
|
11
|
+
export function hasHostImageDimensionResolver() {
|
|
12
|
+
return _resolver !== null;
|
|
13
|
+
}
|
|
14
|
+
// Installs the host's measurer. Opt-in, like every other host capability: an application registers the
|
|
15
|
+
// one its platform provides (registerWebImageDimensionResolver for the browser) and nothing in this
|
|
16
|
+
// package reaches for a platform global. Last registration wins.
|
|
17
|
+
export function registerHostImageDimensionResolver(resolver) {
|
|
18
|
+
_resolver = resolver;
|
|
19
|
+
}
|
|
20
|
+
export function unregisterHostImageDimensionResolver() {
|
|
21
|
+
_resolver = null;
|
|
22
|
+
}
|
|
23
|
+
let _resolver = null;
|
|
24
|
+
//# sourceMappingURL=imageSourceDimensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageSourceDimensions.js","sourceRoot":"","sources":["../src/imageSourceDimensions.ts"],"names":[],"mappings":"AAEA,uGAAuG;AACvG,qGAAqG;AACrG,iFAAiF;AACjF,MAAM,UAAU,4BAA4B,CAAC,MAAyB,EAAE,GAAwB;IAC9F,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACrC,OAAO,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC;AAED,sGAAsG;AACtG,0DAA0D;AAC1D,MAAM,UAAU,6BAA6B;IAC3C,OAAO,SAAS,KAAK,IAAI,CAAC;AAC5B,CAAC;AAED,uGAAuG;AACvG,oGAAoG;AACpG,iEAAiE;AACjE,MAAM,UAAU,kCAAkC,CAAC,QAAoC;IACrF,SAAS,GAAG,QAAQ,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,oCAAoC;IAClD,SAAS,GAAG,IAAI,CAAC;AACnB,CAAC;AAED,IAAI,SAAS,GAAsC,IAAI,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HostImageDimensionResolver } from './types.ts';
|
|
2
|
+
export declare function registerTestImageDimensionResolver(): void;
|
|
3
|
+
export declare const testImageDimensionResolver: HostImageDimensionResolver;
|
|
4
|
+
export declare function unregisterTestImageDimensionResolver(): void;
|
|
5
|
+
//# sourceMappingURL=imageTestHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageTestHelper.d.ts","sourceRoot":"","sources":["../src/imageTestHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAY7D,wBAAgB,kCAAkC,IAAI,IAAI,CAEzD;AAID,eAAO,MAAM,0BAA0B,EAAE,0BAMxC,CAAC;AAGF,wBAAgB,oCAAoC,IAAI,IAAI,CAE3D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { registerHostImageDimensionResolver, unregisterHostImageDimensionResolver } from './imageSourceDimensions.js';
|
|
2
|
+
// Measuring a borrowed handle belongs to the host, which leaves every portable package's tests needing a
|
|
3
|
+
// host they must not depend on: pulling @flighthq/host-web into a renderer package's tests would invert
|
|
4
|
+
// the layering the seam cleanup established. This is the portable stand-in — the same structural read a
|
|
5
|
+
// browser host performs, owned by the package that owns the seam, so a test names one dependency instead
|
|
6
|
+
// of hand-rolling a resolver literal.
|
|
7
|
+
//
|
|
8
|
+
// Register in beforeEach and clear in afterEach. Clearing is not tidiness: the slot is module state
|
|
9
|
+
// shared by every test file in a Vitest process, so a file that registers and never clears can satisfy a
|
|
10
|
+
// LATER file's missing registration. That is not hypothetical — it hid a real defect, where
|
|
11
|
+
// scene2d-canvas passed in the broad suite and failed run on its own.
|
|
12
|
+
export function registerTestImageDimensionResolver() {
|
|
13
|
+
registerHostImageDimensionResolver(testImageDimensionResolver);
|
|
14
|
+
}
|
|
15
|
+
// Reads width and height off any handle that carries them, and declines one that does not, exactly as a
|
|
16
|
+
// host resolver must.
|
|
17
|
+
export const testImageDimensionResolver = (source, out) => {
|
|
18
|
+
const sized = source;
|
|
19
|
+
if (typeof sized.width !== 'number' || typeof sized.height !== 'number')
|
|
20
|
+
return false;
|
|
21
|
+
out.height = sized.height;
|
|
22
|
+
out.width = sized.width;
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
// Pairs with registerTestImageDimensionResolver so a suite leaves the slot as it found it.
|
|
26
|
+
export function unregisterTestImageDimensionResolver() {
|
|
27
|
+
unregisterHostImageDimensionResolver();
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=imageTestHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageTestHelper.js","sourceRoot":"","sources":["../src/imageTestHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,oCAAoC,EAAE,MAAM,4BAA4B,CAAC;AAGtH,yGAAyG;AACzG,wGAAwG;AACxG,wGAAwG;AACxG,yGAAyG;AACzG,sCAAsC;AACtC,EAAE;AACF,oGAAoG;AACpG,yGAAyG;AACzG,4FAA4F;AAC5F,sEAAsE;AACtE,MAAM,UAAU,kCAAkC;IAChD,kCAAkC,CAAC,0BAA0B,CAAC,CAAC;AACjE,CAAC;AAED,wGAAwG;AACxG,sBAAsB;AACtB,MAAM,CAAC,MAAM,0BAA0B,GAA+B,CAAC,MAAM,EAAE,GAAG,EAAW,EAAE;IAC7F,MAAM,KAAK,GAAG,MAA+D,CAAC;IAC9E,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtF,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC1B,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACxB,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,2FAA2F;AAC3F,MAAM,UAAU,oCAAoC;IAClD,oCAAoC,EAAE,CAAC;AACzC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export { cloneImageResource, createCompressedImageResource,
|
|
1
|
+
export { cloneImageResource, createCompressedImageResource, createImageResource, invalidateImageResource, isImageResourceEmpty, } from './imageResource.ts';
|
|
2
|
+
export * from './imageResourceFrom.ts';
|
|
3
|
+
export { createEmbeddedImageResourceReference, createExternalImageResourceReference, createImageResourceFailure, explainImageResourceReferenceResolution, resetFailedImageResourceReference, resolveImageResourceReference, } from './imageResourceReference.ts';
|
|
4
|
+
export { ImageResourceFailureKind, ImageResourceReferenceKind } from './types.ts';
|
|
5
|
+
export type { EmbeddedImageResourceReference, ExternalImageResourceReference, ImageResourceFailure, ImageResourceFetch, ImageResourceReference, ImageResourceReferenceResolutionExplanation, } from './types.ts';
|
|
2
6
|
//# 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,kBAAkB,EAClB,6BAA6B,EAC7B,oCAAoC,EACpC,oCAAoC,EACpC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,6BAA6B,EAC7B,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,OAAO,EACL,oCAAoC,EACpC,oCAAoC,EACpC,0BAA0B,EAC1B,uCAAuC,EACvC,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAClF,YAAY,EACV,8BAA8B,EAC9B,8BAA8B,EAC9B,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,2CAA2C,GAC5C,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export { cloneImageResource, createCompressedImageResource,
|
|
1
|
+
export { cloneImageResource, createCompressedImageResource, createImageResource, invalidateImageResource, isImageResourceEmpty, } from './imageResource.js';
|
|
2
|
+
export * from './imageResourceFrom.js';
|
|
3
|
+
export { createEmbeddedImageResourceReference, createExternalImageResourceReference, createImageResourceFailure, explainImageResourceReferenceResolution, resetFailedImageResourceReference, resolveImageResourceReference, } from './imageResourceReference.js';
|
|
4
|
+
export { ImageResourceFailureKind, ImageResourceReferenceKind } from './types.js';
|
|
2
5
|
//# 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,kBAAkB,EAClB,6BAA6B,EAC7B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,6BAA6B,EAC7B,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,OAAO,EACL,oCAAoC,EACpC,oCAAoC,EACpC,0BAA0B,EAC1B,uCAAuC,EACvC,iCAAiC,EACjC,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Bitmap } from '@flighthq/bitmap/contract';
|
|
2
|
+
import type { EntityRaw, EntityRuntime } from '@flighthq/entity/contract';
|
|
3
|
+
import type { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
4
|
+
import type { DecodedImage, HostImageDecodeCapabilities } from '@flighthq/image-codec/contract';
|
|
5
|
+
import type { ResourceResolutionState } from '@flighthq/resource/contract';
|
|
6
|
+
import type { Surface } from '@flighthq/surface/contract';
|
|
7
|
+
import type { TextureContainer } from '@flighthq/texture-formats/contract';
|
|
8
|
+
import type { AlphaType, CompressedImageTextureSourceKind, ImageTextureSourceKind, Texture, TextureSource } from '@flighthq/texture/contract';
|
|
9
|
+
interface ImageEntity extends EntityRaw {
|
|
10
|
+
[EntityRuntimeKey]: EntityRuntime | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface HostImageDimensions {
|
|
13
|
+
height: number;
|
|
14
|
+
width: number;
|
|
15
|
+
}
|
|
16
|
+
export type HostImageDimensionResolver = (source: CanvasImageSource, out: HostImageDimensions) => boolean;
|
|
17
|
+
export declare const ImageResourceReferenceKind: {
|
|
18
|
+
readonly Embedded: 'Embedded';
|
|
19
|
+
readonly External: 'External';
|
|
20
|
+
};
|
|
21
|
+
export type ImageResourceReferenceKind = (typeof ImageResourceReferenceKind)[keyof typeof ImageResourceReferenceKind];
|
|
22
|
+
export declare const ImageResourceFailureKind: {
|
|
23
|
+
readonly Error: 'Error';
|
|
24
|
+
readonly Unavailable: 'Unavailable';
|
|
25
|
+
};
|
|
26
|
+
export type ImageResourceFailureKind = (typeof ImageResourceFailureKind)[keyof typeof ImageResourceFailureKind];
|
|
27
|
+
/**
|
|
28
|
+
* A flat host-drawable image asset. ImageResource, Bitmap, and CompressedImageResource are sibling
|
|
29
|
+
* TextureSource variants; renderers dispatch them by `kind` and never inspect nullable alternate
|
|
30
|
+
* representations.
|
|
31
|
+
*/
|
|
32
|
+
export interface ImageResource extends TextureSource {
|
|
33
|
+
/** Image TextureSource registry key. */
|
|
34
|
+
readonly kind: typeof ImageTextureSourceKind;
|
|
35
|
+
/** Borrowed host representation uploaded or drawn directly (image, canvas, ImageBitmap, …). */
|
|
36
|
+
readonly source: CanvasImageSource;
|
|
37
|
+
}
|
|
38
|
+
export interface HostImageCapability {
|
|
39
|
+
createImageFromBitmap?(bitmap: Readonly<Bitmap>): ImageResource;
|
|
40
|
+
createImageFromSurface?(surface: Readonly<Surface>): ImageResource;
|
|
41
|
+
loadImageFromUrl(url: string, crossOrigin?: 'anonymous' | 'use-credentials', signal?: AbortSignal): Promise<ImageResource>;
|
|
42
|
+
}
|
|
43
|
+
export type ImageOperation = keyof HostImageCapability;
|
|
44
|
+
export interface ImageResourceFailure extends ImageEntity {
|
|
45
|
+
kind: ImageResourceFailureKind;
|
|
46
|
+
message: string;
|
|
47
|
+
name: string | null;
|
|
48
|
+
}
|
|
49
|
+
interface ImageResourceReferenceBase extends ImageEntity {
|
|
50
|
+
failure: ImageResourceFailure | null;
|
|
51
|
+
mimeType: string | null;
|
|
52
|
+
state: ResourceResolutionState;
|
|
53
|
+
textures?: Texture[];
|
|
54
|
+
}
|
|
55
|
+
export interface EmbeddedImageResourceReference extends ImageResourceReferenceBase {
|
|
56
|
+
kind: 'Embedded';
|
|
57
|
+
alphaType: AlphaType;
|
|
58
|
+
bitmapComposition?: ImageBitmapComposition;
|
|
59
|
+
bytes: Uint8Array;
|
|
60
|
+
}
|
|
61
|
+
export interface ExternalImageResourceReference extends ImageResourceReferenceBase {
|
|
62
|
+
kind: 'External';
|
|
63
|
+
uri: string;
|
|
64
|
+
basePath: string | null;
|
|
65
|
+
}
|
|
66
|
+
export type ImageResourceReference = EmbeddedImageResourceReference | ExternalImageResourceReference;
|
|
67
|
+
export type ImageResourceFetch = (ref: Readonly<ExternalImageResourceReference>, signal: AbortSignal) => Promise<ImageResource | null>;
|
|
68
|
+
export interface ImageResourceReferenceResolutionExplanation {
|
|
69
|
+
failure: ImageResourceFailure | null;
|
|
70
|
+
kind: ImageResourceReferenceKind;
|
|
71
|
+
retryable: boolean;
|
|
72
|
+
state: ResourceResolutionState;
|
|
73
|
+
}
|
|
74
|
+
export interface ImageBitmapComposition {
|
|
75
|
+
kind: string;
|
|
76
|
+
payload: Uint8Array;
|
|
77
|
+
}
|
|
78
|
+
export type ImageBitmapComposer = (decoded: Readonly<DecodedImage> | null, payload: Readonly<Uint8Array>) => Bitmap | null;
|
|
79
|
+
export type ImageBitmapCompositionResolver = (imageDecode: Readonly<HostImageDecodeCapabilities>, ref: Readonly<EmbeddedImageResourceReference>, signal: AbortSignal) => Promise<Bitmap | null>;
|
|
80
|
+
export interface CompressedImageData {
|
|
81
|
+
readonly container: TextureContainer;
|
|
82
|
+
readonly payload: Readonly<Uint8Array>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* GPU-only block-compressed image source. The payload remains in its container-native format; it is
|
|
86
|
+
* neither directly drawable by Canvas/DOM nor readable through the Bitmap pixel API.
|
|
87
|
+
*/
|
|
88
|
+
export interface CompressedImageResource extends TextureSource {
|
|
89
|
+
readonly compressed: CompressedImageData;
|
|
90
|
+
readonly kind: typeof CompressedImageTextureSourceKind;
|
|
91
|
+
}
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAChG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EACV,SAAS,EACT,gCAAgC,EAChC,sBAAsB,EACtB,OAAO,EACP,aAAa,EACd,MAAM,4BAA4B,CAAC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EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,IAAI,EACtC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,KAC1B,MAAM,GAAG,IAAI,CAAC;AAKnB,MAAM,MAAM,8BAA8B,GAAG,CAC3C,WAAW,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EAClD,GAAG,EAAE,QAAQ,CAAC,8BAA8B,CAAC,EAC7C,MAAM,EAAE,WAAW,KAChB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAK5B,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,aAAa;IAC5D,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,OAAO,gCAAgC,CAAC;CACxD"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA6BA,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAIX,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,KAAK,EAAE,OAAO;IACd,WAAW,EAAE,aAAa;CAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/image",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,18 +32,24 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsc -b",
|
|
34
34
|
"clean": "tsc -b --clean",
|
|
35
|
+
"generate": "tsx ../../scripts/generate-rust-package.ts --crate flight-image --package image",
|
|
36
|
+
"generate:check": "tsx ../../scripts/generate-rust-package.ts --crate flight-image --package image --check",
|
|
35
37
|
"test": "vitest run --config vitest.config.ts",
|
|
36
38
|
"test:watch": "vitest --watch --config vitest.config.ts",
|
|
37
39
|
"prepack": "npm run clean && npm run clean:dist && npm run build",
|
|
38
40
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@flighthq/
|
|
42
|
-
"@flighthq/
|
|
43
|
-
"@flighthq/
|
|
43
|
+
"@flighthq/bitmap": "0.6.0",
|
|
44
|
+
"@flighthq/entity": "0.6.0",
|
|
45
|
+
"@flighthq/image-codec": "0.6.0",
|
|
46
|
+
"@flighthq/resource": "0.6.0",
|
|
47
|
+
"@flighthq/surface": "0.6.0",
|
|
48
|
+
"@flighthq/texture": "0.6.0",
|
|
49
|
+
"@flighthq/texture-formats": "0.6.0"
|
|
44
50
|
},
|
|
45
51
|
"devDependencies": {
|
|
46
|
-
"typescript": "^
|
|
52
|
+
"typescript": "^7.0.2"
|
|
47
53
|
},
|
|
48
54
|
"description": "Image resources: pixel sources, MIME detection, and constructors from canvas/bitmap/element",
|
|
49
55
|
"sideEffects": false
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CompressedImageTextureSourceKind, ImageTextureSourceKind } from '@flighthq/types/contract';
|
|
1
|
+
import { CompressedImageTextureSourceKind, ImageTextureSourceKind } from '@flighthq/texture/contract';
|
|
3
2
|
|
|
4
3
|
import {
|
|
5
4
|
cloneImageResource,
|
|
@@ -8,7 +7,21 @@ import {
|
|
|
8
7
|
initializeCompressedImageResource,
|
|
9
8
|
invalidateImageResource,
|
|
10
9
|
isImageResourceEmpty,
|
|
11
|
-
} from './imageResource';
|
|
10
|
+
} from './imageResource.ts';
|
|
11
|
+
import { registerTestImageDimensionResolver, unregisterTestImageDimensionResolver } from './imageTestHelper.ts';
|
|
12
|
+
import type { CompressedImageData } from './types.ts';
|
|
13
|
+
|
|
14
|
+
// Measuring a borrowed handle is the host's job, so these tests install the portable stand-in. Without
|
|
15
|
+
// one a resource keeps whatever size it was constructed with, which is the behavior
|
|
16
|
+
// imageSourceDimensions.test.ts covers. Clearing after each test is what keeps this file from silently
|
|
17
|
+
// supplying a resolver to a later one.
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
registerTestImageDimensionResolver();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
unregisterTestImageDimensionResolver();
|
|
24
|
+
});
|
|
12
25
|
|
|
13
26
|
function makeCompressed(): CompressedImageData {
|
|
14
27
|
return {
|