@workglow/util 0.2.19 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +81 -16
- package/dist/browser.js.map +4 -4
- package/dist/bun.js +81 -16
- package/dist/bun.js.map +4 -4
- package/dist/json-schema/SchemaUtils.d.ts.map +1 -1
- package/dist/json-schema/SchemaValidation.d.ts +6 -0
- package/dist/json-schema/SchemaValidation.d.ts.map +1 -1
- package/dist/media/cpuImage.d.ts +15 -16
- package/dist/media/cpuImage.d.ts.map +1 -1
- package/dist/media/encode.d.ts +3 -5
- package/dist/media/encode.d.ts.map +1 -1
- package/dist/media/gpuImage.d.ts +21 -30
- package/dist/media/gpuImage.d.ts.map +1 -1
- package/dist/media/imageCacheCodec.d.ts +19 -7
- package/dist/media/imageCacheCodec.d.ts.map +1 -1
- package/dist/media/imageRasterCodecRegistry.d.ts +3 -3
- package/dist/media/imageRasterCodecRegistry.d.ts.map +1 -1
- package/dist/media/imageTypes.d.ts +0 -16
- package/dist/media/imageTypes.d.ts.map +1 -1
- package/dist/media/imageValue.d.ts +44 -0
- package/dist/media/imageValue.d.ts.map +1 -0
- package/dist/media/imageValue.test.d.ts +7 -0
- package/dist/media/imageValue.test.d.ts.map +1 -0
- package/dist/media/imageValueSchema.d.ts +15 -0
- package/dist/media/imageValueSchema.d.ts.map +1 -0
- package/dist/media/previewBudget.d.ts +10 -13
- package/dist/media/previewBudget.d.ts.map +1 -1
- package/dist/media/rawPixelBuffer.d.ts +20 -0
- package/dist/media/rawPixelBuffer.d.ts.map +1 -0
- package/dist/media/{sharpImage.node.d.ts → sharpImage.server.d.ts} +42 -14
- package/dist/media/sharpImage.server.d.ts.map +1 -0
- package/dist/media/webGpuImage.browser.d.ts +11 -14
- package/dist/media/webGpuImage.browser.d.ts.map +1 -1
- package/dist/media-browser.d.ts +9 -3
- package/dist/media-browser.d.ts.map +1 -1
- package/dist/media-browser.js +429 -342
- package/dist/media-browser.js.map +14 -14
- package/dist/media-node.d.ts +8 -6
- package/dist/media-node.d.ts.map +1 -1
- package/dist/media-node.js +479 -254
- package/dist/media-node.js.map +14 -14
- package/dist/node.js +81 -16
- package/dist/node.js.map +4 -4
- package/dist/schema-entry.js +166 -165
- package/dist/schema-entry.js.map +5 -5
- package/dist/utilities/Misc.d.ts +1 -1
- package/dist/utilities/Misc.d.ts.map +1 -1
- package/dist/worker/WorkerManager.d.ts.map +1 -1
- package/dist/worker-browser.js +5 -2
- package/dist/worker-browser.js.map +3 -3
- package/dist/worker-bun.js +5 -2
- package/dist/worker-bun.js.map +3 -3
- package/dist/worker-node.js +5 -2
- package/dist/worker-node.js.map +3 -3
- package/package.json +1 -1
- package/dist/media/gpuImageSchema.d.ts +0 -8
- package/dist/media/gpuImageSchema.d.ts.map +0 -1
- package/dist/media/sharpImage.bun.d.ts +0 -7
- package/dist/media/sharpImage.bun.d.ts.map +0 -1
- package/dist/media/sharpImage.node.d.ts.map +0 -1
|
@@ -14,6 +14,12 @@ export interface SchemaValidationResult {
|
|
|
14
14
|
readonly valid: boolean;
|
|
15
15
|
readonly errors: readonly SchemaValidationError[];
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Pattern for format annotations used in dataflow compatibility checking.
|
|
19
|
+
* Format: /\w+(:\w+)?/ where first part is the "name" and optional second part narrows the type.
|
|
20
|
+
* Reused from SchemaUtils.ts areFormatStringsCompatible().
|
|
21
|
+
*/
|
|
22
|
+
export declare const FORMAT_PATTERN: RegExp;
|
|
17
23
|
/**
|
|
18
24
|
* Validates that a schema is a well-formed DataPortSchema.
|
|
19
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaValidation.d.ts","sourceRoot":"","sources":["../../src/json-schema/SchemaValidation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,YAAY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOvD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACnD;
|
|
1
|
+
{"version":3,"file":"SchemaValidation.d.ts","sourceRoot":"","sources":["../../src/json-schema/SchemaValidation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,YAAY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOvD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACnD;AAOD;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAA4D,CAAC;AAgBxF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,sBAAsB,CAyCrF;AAgFD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,cAAc,GAAG,sBAAsB,CAexF;AAqDD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,sBAAsB,CAU7E"}
|
package/dist/media/cpuImage.d.ts
CHANGED
|
@@ -3,27 +3,26 @@
|
|
|
3
3
|
* Copyright 2026 Steven Roussey
|
|
4
4
|
* All Rights Reserved
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
6
|
+
import type { ImageChannels } from "./imageTypes";
|
|
7
|
+
import type { GpuImage as IGpuImage, GpuImageEncodeFormat } from "./gpuImage";
|
|
8
|
+
import type { ImageValue } from "./imageValue";
|
|
9
|
+
import type { RawPixelBuffer } from "./rawPixelBuffer";
|
|
10
|
+
export type { RawPixelBuffer } from "./rawPixelBuffer";
|
|
8
11
|
export declare class CpuImage implements IGpuImage {
|
|
9
|
-
private
|
|
12
|
+
private bin;
|
|
10
13
|
readonly backend: "cpu";
|
|
11
|
-
private _previewScale;
|
|
12
14
|
private constructor();
|
|
13
15
|
get width(): number;
|
|
14
16
|
get height(): number;
|
|
15
|
-
get channels():
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
toCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): Promise<void>;
|
|
17
|
+
get channels(): ImageChannels;
|
|
18
|
+
/** @internal — used by CPU filter ops to read the raw pixel buffer. */
|
|
19
|
+
getBinary(): RawPixelBuffer;
|
|
20
|
+
static from(value: ImageValue): Promise<CpuImage>;
|
|
21
|
+
/** @internal — synchronous factory for backends that already have a raw buffer
|
|
22
|
+
* in hand (used by the WGSL CPU fallback). */
|
|
23
|
+
static fromRaw(bin: RawPixelBuffer): CpuImage;
|
|
24
|
+
toImageValue(previewScale: number): Promise<ImageValue>;
|
|
24
25
|
encode(format: GpuImageEncodeFormat, _quality?: number): Promise<Uint8Array>;
|
|
25
|
-
|
|
26
|
-
release(): void;
|
|
27
|
-
static fromImageBinary(bin: ImageBinary, previewScale?: number): CpuImage;
|
|
26
|
+
dispose(): void;
|
|
28
27
|
}
|
|
29
28
|
//# sourceMappingURL=cpuImage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpuImage.d.ts","sourceRoot":"","sources":["../../src/media/cpuImage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"cpuImage.d.ts","sourceRoot":"","sources":["../../src/media/cpuImage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,QAAQ,IAAI,SAAS,EACrB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAG/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQvD,qBAAa,QAAS,YAAW,SAAS;IAGpB,OAAO,CAAC,GAAG;IAF/B,QAAQ,CAAC,OAAO,EAAG,KAAK,CAAU;IAElC,OAAO,eAAmD;IAE1D,IAAI,KAAK,IAAI,MAAM,CAGlB;IACD,IAAI,MAAM,IAAI,MAAM,CAGnB;IACD,IAAI,QAAQ,IAAI,aAAa,CAG5B;IAED,uEAAuE;IACvE,SAAS,IAAI,cAAc,CAG1B;IAED,OAAa,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiBtD;IAED;mDAC+C;IAC/C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,QAAQ,CAE5C;IAEK,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAkC5D;IAEK,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAKjF;IAED,OAAO,IAAI,IAAI,CAEd;CACF"}
|
package/dist/media/encode.d.ts
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
* Copyright 2026 Steven Roussey
|
|
4
4
|
* All Rights Reserved
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function imageBinaryToDataUri(bin: ImageBinary, mimeType?: string): Promise<string>;
|
|
10
|
-
export declare function imageBinaryToBlob(bin: ImageBinary, mimeType?: string): Promise<Blob>;
|
|
6
|
+
import type { RawPixelBuffer } from "./rawPixelBuffer";
|
|
7
|
+
export declare function rawPixelBufferToDataUri(bin: RawPixelBuffer, mimeType?: string): Promise<string>;
|
|
8
|
+
export declare function rawPixelBufferToBlob(bin: RawPixelBuffer, mimeType?: string): Promise<Blob>;
|
|
11
9
|
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/media/encode.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/media/encode.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAYvD,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,cAAc,EACnB,QAAQ,SAAc,GACrB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,cAAc,EACnB,QAAQ,SAAc,GACrB,OAAO,CAAC,IAAI,CAAC,CAGf"}
|
package/dist/media/gpuImage.d.ts
CHANGED
|
@@ -3,48 +3,39 @@
|
|
|
3
3
|
* Copyright 2026 Steven Roussey
|
|
4
4
|
* All Rights Reserved
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { ImageChannels } from "./imageTypes";
|
|
7
|
+
import type { ImageValue } from "./imageValue";
|
|
7
8
|
export type GpuImageBackend = "webgpu" | "sharp" | "cpu";
|
|
8
9
|
export type GpuImageEncodeFormat = "png" | "jpeg" | "webp";
|
|
10
|
+
/**
|
|
11
|
+
* `GpuImage` is a private implementation detail of image tasks: it never
|
|
12
|
+
* crosses a task/engine/worker boundary. Lives only inside an
|
|
13
|
+
* `ImageFilterTask.execute` method body. Cross-boundary currency is
|
|
14
|
+
* `ImageValue`. Use `GpuImage.from(value)` at task entry and
|
|
15
|
+
* `imageValueFromGpu(out, scale)` (or `transferToImageBitmap()` /
|
|
16
|
+
* `toBuffer()` directly) at task exit.
|
|
17
|
+
*/
|
|
9
18
|
export interface GpuImage {
|
|
10
19
|
readonly width: number;
|
|
11
20
|
readonly height: number;
|
|
12
21
|
readonly channels: ImageChannels;
|
|
13
22
|
readonly backend: GpuImageBackend;
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
materialize(): Promise<ImageBinary>;
|
|
20
|
-
toCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): Promise<void>;
|
|
23
|
+
/** Materialize back into a wire-form `ImageValue`. Always returns a fresh
|
|
24
|
+
* ImageValue; the caller is the new owner. */
|
|
25
|
+
toImageValue(previewScale: number): Promise<ImageValue>;
|
|
26
|
+
/** Encode to a compressed image format (png/jpeg/webp). Implementations MAY
|
|
27
|
+
* consume the underlying resource — treat as single-use. */
|
|
21
28
|
encode(format: GpuImageEncodeFormat, quality?: number): Promise<Uint8Array>;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
*/
|
|
27
|
-
retain(n?: number): this;
|
|
28
|
-
/**
|
|
29
|
-
* Decrement the refcount by 1. When it hits 0, reclaim the underlying resource
|
|
30
|
-
* (e.g., return the GPU texture to the pool). Throws on release-after-reclaim.
|
|
31
|
-
* No-op for backends without external resource lifetime.
|
|
32
|
-
*/
|
|
33
|
-
release(): void;
|
|
29
|
+
/** Early cleanup on error paths only. Required because GPU/native resources
|
|
30
|
+
* are not held by GC. The happy path uses `toImageValue()` which transfers
|
|
31
|
+
* ownership; this is the abort/error case. */
|
|
32
|
+
dispose(): void;
|
|
34
33
|
}
|
|
35
34
|
export interface GpuImageStatic {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
fromDataUri(dataUri: string): Promise<GpuImage>;
|
|
39
|
-
fromBlob(blob: Blob): Promise<GpuImage>;
|
|
40
|
-
fromImageBitmap?(bitmap: ImageBitmap): Promise<GpuImage>;
|
|
35
|
+
/** Bridge from the cross-boundary `ImageValue` to a backend-private GpuImage. */
|
|
36
|
+
from(value: ImageValue): Promise<GpuImage>;
|
|
41
37
|
}
|
|
42
38
|
export declare function registerGpuImageFactory<K extends keyof GpuImageStatic>(key: K, fn: GpuImageStatic[K]): void;
|
|
43
|
-
/**
|
|
44
|
-
* Returns the registered factory function for `key`, or `undefined` if it
|
|
45
|
-
* has not been registered. Prefer this over accessing `GpuImage[key]` directly
|
|
46
|
-
* when the factory is optional — the Proxy throws on missing registrations.
|
|
47
|
-
*/
|
|
48
39
|
export declare function getGpuImageFactory<K extends keyof GpuImageStatic>(key: K): GpuImageStatic[K] | undefined;
|
|
49
40
|
export declare const GpuImage: GpuImageStatic;
|
|
50
41
|
//# sourceMappingURL=gpuImage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpuImage.d.ts","sourceRoot":"","sources":["../../src/media/gpuImage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"gpuImage.d.ts","sourceRoot":"","sources":["../../src/media/gpuImage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC;mDAC+C;IAC/C,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACxD;iEAC6D;IAC7D,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5E;;mDAE+C;IAC/C,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC5C;AASD,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,cAAc,EACpE,GAAG,EAAE,CAAC,EACN,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,GACpB,IAAI,CAEN;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,cAAc,EAC/D,GAAG,EAAE,CAAC,GACL,cAAc,CAAC,CAAC,CAAC,GAAG,SAAS,CAG/B;AAED,eAAO,MAAM,QAAQ,EAAE,cASrB,CAAC"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import type { NodeImageFormat } from "./imageValue";
|
|
2
|
+
/**
|
|
3
|
+
* Cache codec for `format: "image"` ports.
|
|
4
|
+
*
|
|
5
|
+
* Produces a JSON-safe wire form so persistent caches (e.g. `TaskOutputTabularRepository`,
|
|
6
|
+
* which stringifies before writing to disk) can round-trip image outputs. The wire form
|
|
7
|
+
* carries encoded bytes plus dimensions and `previewScale`; the decoded shape is the
|
|
8
|
+
* platform-native `ImageValue` (browser → `BrowserImageValue`, node/bun → `NodeImageValue`).
|
|
9
|
+
*
|
|
10
|
+
* Cross-platform read is supported: a node-written cache entry decodes to a
|
|
11
|
+
* `BrowserImageValue` when read in the browser (via `createImageBitmap`), and vice versa.
|
|
12
|
+
*/
|
|
13
|
+
export interface ImageValueWire {
|
|
14
|
+
readonly __imageValueWire: 1;
|
|
15
|
+
readonly format: NodeImageFormat;
|
|
16
|
+
readonly base64: string;
|
|
17
|
+
readonly width: number;
|
|
18
|
+
readonly height: number;
|
|
19
|
+
readonly previewScale: number;
|
|
8
20
|
}
|
|
9
21
|
//# sourceMappingURL=imageCacheCodec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageCacheCodec.d.ts","sourceRoot":"","sources":["../../src/media/imageCacheCodec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"imageCacheCodec.d.ts","sourceRoot":"","sources":["../../src/media/imageCacheCodec.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAiC,eAAe,EAAE,MAAM,cAAc,CAAC;AAGnF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B"}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { RawPixelBuffer } from "./rawPixelBuffer";
|
|
7
7
|
export interface ImageRasterCodec {
|
|
8
|
-
decodeDataUri(dataUri: string): Promise<
|
|
9
|
-
encodeDataUri(image:
|
|
8
|
+
decodeDataUri(dataUri: string): Promise<RawPixelBuffer>;
|
|
9
|
+
encodeDataUri(image: RawPixelBuffer, mimeType: string): Promise<string>;
|
|
10
10
|
}
|
|
11
11
|
export declare function registerImageRasterCodec(next: ImageRasterCodec): void;
|
|
12
12
|
export declare function getImageRasterCodec(): ImageRasterCodec;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageRasterCodecRegistry.d.ts","sourceRoot":"","sources":["../../src/media/imageRasterCodecRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"imageRasterCodecRegistry.d.ts","sourceRoot":"","sources":["../../src/media/imageRasterCodecRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACxD,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACzE;AAeD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAErE;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAOtD"}
|
|
@@ -4,20 +4,4 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
export type ImageChannels = 1 | 3 | 4;
|
|
7
|
-
export type ImageDataSupport = "Blob" | "ImageBinary" | "ImageBitmap" | "OffscreenCanvas" | "VideoFrame" | "RawImage" | "DataUri" | "Sharp";
|
|
8
|
-
export interface ImageBinary {
|
|
9
|
-
data: Uint8ClampedArray;
|
|
10
|
-
width: number;
|
|
11
|
-
height: number;
|
|
12
|
-
channels: ImageChannels;
|
|
13
|
-
rawChannels?: number | undefined;
|
|
14
|
-
}
|
|
15
|
-
/** RGBA pixel buffer (`channels` is always 4). */
|
|
16
|
-
export type RgbaImageBinary = Readonly<Omit<ImageBinary, "channels" | "rawChannels"> & {
|
|
17
|
-
readonly channels: 4;
|
|
18
|
-
}>;
|
|
19
|
-
export declare function parseDataUri(dataUri: string): {
|
|
20
|
-
mimeType: string;
|
|
21
|
-
base64: string;
|
|
22
|
-
};
|
|
23
7
|
//# sourceMappingURL=imageTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageTypes.d.ts","sourceRoot":"","sources":["../../src/media/imageTypes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"imageTypes.d.ts","sourceRoot":"","sources":["../../src/media/imageTypes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export type NodeImageFormat = "png" | "jpeg" | "raw-rgba";
|
|
7
|
+
export interface ImageValueBase {
|
|
8
|
+
readonly width: number;
|
|
9
|
+
readonly height: number;
|
|
10
|
+
readonly previewScale: number;
|
|
11
|
+
}
|
|
12
|
+
export interface BrowserImageValue extends ImageValueBase {
|
|
13
|
+
readonly bitmap: ImageBitmap;
|
|
14
|
+
}
|
|
15
|
+
export interface NodeImageValue extends ImageValueBase {
|
|
16
|
+
readonly buffer: Buffer;
|
|
17
|
+
readonly format: NodeImageFormat;
|
|
18
|
+
}
|
|
19
|
+
export type ImageValue = BrowserImageValue | NodeImageValue;
|
|
20
|
+
export declare function imageValueFromBitmap(bitmap: ImageBitmap, width: number, height: number, previewScale?: number): BrowserImageValue;
|
|
21
|
+
export declare function imageValueFromBuffer(buffer: Buffer, format: NodeImageFormat, width: number, height: number, previewScale?: number): NodeImageValue;
|
|
22
|
+
export declare function isImageValue(v: unknown): v is ImageValue;
|
|
23
|
+
export declare function isBrowserImageValue(v: unknown): v is BrowserImageValue;
|
|
24
|
+
export declare function isNodeImageValue(v: unknown): v is NodeImageValue;
|
|
25
|
+
/**
|
|
26
|
+
* Best-effort normalization at boundaries (input resolver, builder hook).
|
|
27
|
+
* Accepts the wire forms an `ImageValue` port may receive:
|
|
28
|
+
* - an existing `ImageValue` (passthrough)
|
|
29
|
+
* - a `data:` URI (browser: decoded via `createImageBitmap`; node: encoded
|
|
30
|
+
* bytes wrapped in a `NodeImageValue`, with dimensions probed via the
|
|
31
|
+
* registered raster codec)
|
|
32
|
+
* - a `Blob` (browser only)
|
|
33
|
+
* - an `ImageBitmap` (browser only)
|
|
34
|
+
* Returns `undefined` for unrecognized shapes.
|
|
35
|
+
*
|
|
36
|
+
* Note: a raw `Buffer` is intentionally not handled here — callers with
|
|
37
|
+
* encoded bytes plus a format hint should construct one via
|
|
38
|
+
* `imageValueFromBuffer(...)` directly.
|
|
39
|
+
*
|
|
40
|
+
* String dispatch is platform-agnostic; non-string platform-specific shapes
|
|
41
|
+
* are tested via `typeof` guards so the same module loads on browser and node.
|
|
42
|
+
*/
|
|
43
|
+
export declare function normalizeToImageValue(value: unknown): Promise<ImageValue | undefined>;
|
|
44
|
+
//# sourceMappingURL=imageValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageValue.d.ts","sourceRoot":"","sources":["../../src/media/imageValue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,MAAM,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.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright
|
|
3
|
+
* Copyright 2026 Steven Roussey
|
|
4
|
+
* All Rights Reserved
|
|
5
|
+
*/
|
|
6
|
+
import type { DataPortSchema } from "../json-schema/DataPortSchema";
|
|
7
|
+
/**
|
|
8
|
+
* Schema annotation for `ImageValue` ports. Multi-type form so the
|
|
9
|
+
* validator accepts the wire forms an `ImageValue` port may receive
|
|
10
|
+
* before hydration: `string` (data: URI), `object` (Blob, ImageBitmap, an
|
|
11
|
+
* ImageValue, or a `Buffer`-like). The `format: "image"` annotation drives
|
|
12
|
+
* the input resolver.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ImageValueSchema(annotations?: Record<string, unknown>): DataPortSchema;
|
|
15
|
+
//# sourceMappingURL=imageValueSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageValueSchema.d.ts","sourceRoot":"","sources":["../../src/media/imageValueSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,cAAc,CAS1F"}
|
|
@@ -3,21 +3,18 @@
|
|
|
3
3
|
* Copyright 2026 Steven Roussey
|
|
4
4
|
* All Rights Reserved
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
7
|
-
export type PreviewResizeFn = (image:
|
|
8
|
-
export declare function registerPreviewResizeFn(fn: PreviewResizeFn): void;
|
|
6
|
+
import type { ImageValue } from "./imageValue";
|
|
7
|
+
export type PreviewResizeFn = (image: ImageValue, width: number, height: number) => Promise<ImageValue>;
|
|
8
|
+
export declare function registerPreviewResizeFn(fn: PreviewResizeFn | undefined): void;
|
|
9
9
|
export declare function getPreviewBudget(): number;
|
|
10
10
|
export declare function setPreviewBudget(px: number): void;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* (
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* startup with a callback that performs the resize (typically routed through
|
|
19
|
-
* @workglow/tasks's applyFilter). Without registration, previewSource is
|
|
20
|
-
* a no-op even on webgpu inputs.
|
|
12
|
+
* Engine-applied chain-head downscale for `runPreview`. Idempotent: when
|
|
13
|
+
* the input is already within budget, returns the input unchanged
|
|
14
|
+
* (referential equality is the no-op signal). When over budget, calls the
|
|
15
|
+
* registered resize fn (typically routed through Sharp on node and an
|
|
16
|
+
* OffscreenCanvas/WebGPU resize on browser) and composes `previewScale`:
|
|
17
|
+
* `out.previewScale = in.previewScale × downscaleRatio`.
|
|
21
18
|
*/
|
|
22
|
-
export declare function previewSource(image:
|
|
19
|
+
export declare function previewSource(image: ImageValue): Promise<ImageValue>;
|
|
23
20
|
//# sourceMappingURL=previewBudget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"previewBudget.d.ts","sourceRoot":"","sources":["../../src/media/previewBudget.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"previewBudget.d.ts","sourceRoot":"","sources":["../../src/media/previewBudget.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAc/C,MAAM,MAAM,eAAe,GAAG,CAC5B,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,UAAU,CAAC,CAAC;AAQzB,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAE7E;AAMD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAKjD;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAe1E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { ImageChannels } from "./imageTypes";
|
|
7
|
+
/** Internal pixel-buffer shape used by CPU filter ops and codec helpers.
|
|
8
|
+
* Replaces the old `ImageBinary` export — the boundary type is now `ImageValue`. */
|
|
9
|
+
export interface RawPixelBuffer {
|
|
10
|
+
data: Uint8ClampedArray;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
channels: ImageChannels;
|
|
14
|
+
rawChannels?: number | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** RGBA-only variant. */
|
|
17
|
+
export type RgbaPixelBuffer = Readonly<Omit<RawPixelBuffer, "channels" | "rawChannels"> & {
|
|
18
|
+
readonly channels: 4;
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=rawPixelBuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rawPixelBuffer.d.ts","sourceRoot":"","sources":["../../src/media/rawPixelBuffer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD;qFACqF;AACrF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,aAAa,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED,yBAAyB;AACzB,MAAM,MAAM,eAAe,GAAG,QAAQ,CACpC,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,aAAa,CAAC,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;CAAE,CAC5E,CAAC"}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Copyright 2026 Steven Roussey
|
|
4
4
|
* All Rights Reserved
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { ImageChannels } from "./imageTypes";
|
|
7
7
|
import type { GpuImage as IGpuImage, GpuImageEncodeFormat } from "./gpuImage";
|
|
8
|
+
import type { ImageValue } from "./imageValue";
|
|
8
9
|
type Sharp = {
|
|
9
10
|
clone(): Sharp;
|
|
10
11
|
flip(): Sharp;
|
|
@@ -15,7 +16,7 @@ type Sharp = {
|
|
|
15
16
|
alpha?: boolean;
|
|
16
17
|
}): Sharp;
|
|
17
18
|
recomb(matrix: number[][]): Sharp;
|
|
18
|
-
linear(a: number, b: number): Sharp;
|
|
19
|
+
linear(a: number | number[], b: number | number[]): Sharp;
|
|
19
20
|
threshold(threshold: number, options?: {
|
|
20
21
|
grayscale?: boolean;
|
|
21
22
|
}): Sharp;
|
|
@@ -70,24 +71,51 @@ export declare class SharpImage implements IGpuImage {
|
|
|
70
71
|
readonly height: number;
|
|
71
72
|
readonly channels: ImageChannels;
|
|
72
73
|
readonly backend: "sharp";
|
|
73
|
-
private _previewScale;
|
|
74
74
|
private constructor();
|
|
75
|
-
|
|
76
|
-
/** @internal — only previewSource and ImageTextTask.executePreview (without-
|
|
77
|
-
* background source case) may call this. */
|
|
78
|
-
_setPreviewScale(scale: number): this;
|
|
79
|
-
static fromImageBinary(bin: ImageBinary, previewScale?: number): Promise<SharpImage>;
|
|
80
|
-
static fromBuffer(buf: Buffer): Promise<SharpImage>;
|
|
75
|
+
static from(value: ImageValue): Promise<SharpImage>;
|
|
81
76
|
apply(op: (p: Sharp) => Sharp, outSize?: {
|
|
82
77
|
width: number;
|
|
83
78
|
height: number;
|
|
84
79
|
channels?: ImageChannels;
|
|
85
80
|
}): SharpImage;
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
toBuffer(format: "png" | "jpeg" | "raw-rgba"): Promise<Buffer>;
|
|
82
|
+
toImageValue(previewScale: number): Promise<ImageValue>;
|
|
88
83
|
encode(format: GpuImageEncodeFormat, quality?: number): Promise<Uint8Array>;
|
|
89
|
-
|
|
90
|
-
release(): void;
|
|
84
|
+
dispose(): void;
|
|
91
85
|
}
|
|
86
|
+
export interface DecodeBufferToRawOptions {
|
|
87
|
+
readonly limitInputPixels?: number;
|
|
88
|
+
readonly sequentialRead?: boolean;
|
|
89
|
+
readonly ensureAlpha?: boolean;
|
|
90
|
+
}
|
|
91
|
+
export interface RawPixelInput {
|
|
92
|
+
readonly data: Buffer | Uint8ClampedArray;
|
|
93
|
+
readonly width: number;
|
|
94
|
+
readonly height: number;
|
|
95
|
+
readonly channels: 1 | 2 | 3 | 4;
|
|
96
|
+
}
|
|
97
|
+
export type EncodeRawPixelsOptions = {
|
|
98
|
+
readonly format: "png";
|
|
99
|
+
readonly compressionLevel?: number;
|
|
100
|
+
} | {
|
|
101
|
+
readonly format: "jpeg";
|
|
102
|
+
readonly quality?: number;
|
|
103
|
+
readonly mozjpeg?: boolean;
|
|
104
|
+
} | {
|
|
105
|
+
readonly format: "webp";
|
|
106
|
+
readonly quality?: number;
|
|
107
|
+
};
|
|
108
|
+
export declare function probeImageDimensions(buffer: Buffer): Promise<{
|
|
109
|
+
width: number;
|
|
110
|
+
height: number;
|
|
111
|
+
channels: number | undefined;
|
|
112
|
+
}>;
|
|
113
|
+
export declare function decodeBufferToRaw(buffer: Buffer, options?: DecodeBufferToRawOptions): Promise<{
|
|
114
|
+
data: Buffer;
|
|
115
|
+
width: number;
|
|
116
|
+
height: number;
|
|
117
|
+
channels: number;
|
|
118
|
+
}>;
|
|
119
|
+
export declare function encodeRawPixels(raw: RawPixelInput, options: EncodeRawPixelsOptions): Promise<Buffer>;
|
|
92
120
|
export {};
|
|
93
|
-
//# sourceMappingURL=sharpImage.
|
|
121
|
+
//# sourceMappingURL=sharpImage.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharpImage.server.d.ts","sourceRoot":"","sources":["../../src/media/sharpImage.server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAG/D,KAAK,KAAK,GAAG;IACX,KAAK,IAAI,KAAK,CAAC;IACf,IAAI,IAAI,KAAK,CAAC;IACd,IAAI,IAAI,KAAK,CAAC;IACd,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;IAC3B,SAAS,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACtC,MAAM,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,KAAK,CAAC;IAC7C,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,KAAK,CAAC;IAClC,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC;IAC1D,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,KAAK,CAAC;IACvE,IAAI,CAAC,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,CAAC;IACtD,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACnC,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Rights Reserved
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { ImageChannels } from "./imageTypes";
|
|
7
7
|
import type { GpuImage as IGpuImage, GpuImageEncodeFormat } from "./gpuImage";
|
|
8
|
+
import type { ImageValue } from "./imageValue";
|
|
8
9
|
export interface ApplyParams {
|
|
9
10
|
shader: string;
|
|
10
11
|
uniforms: ArrayBuffer | undefined;
|
|
@@ -20,21 +21,17 @@ export declare class WebGpuImage implements IGpuImage {
|
|
|
20
21
|
readonly height: number;
|
|
21
22
|
readonly backend: "webgpu";
|
|
22
23
|
readonly channels: ImageChannels;
|
|
23
|
-
/** Internal refcount. Initialized to 1 in fromImageBinary/apply. Reclaim at 0. */
|
|
24
|
-
private refcount;
|
|
25
|
-
private _previewScale;
|
|
26
24
|
private constructor();
|
|
27
|
-
|
|
28
|
-
/** @internal — only previewSource and ImageTextTask.executePreview (without-
|
|
29
|
-
* background source case) may call this. Mutates previewScale on this
|
|
30
|
-
* instance and returns this for chaining. */
|
|
31
|
-
_setPreviewScale(scale: number): this;
|
|
32
|
-
static fromImageBinary(bin: ImageBinary): Promise<WebGpuImage>;
|
|
25
|
+
static from(value: ImageValue): Promise<WebGpuImage>;
|
|
33
26
|
apply(params: ApplyParams): WebGpuImage;
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
/** Synchronous transfer to ImageBitmap via OffscreenCanvas. The transfer
|
|
28
|
+
* drains the texture; this image is disposed afterward. */
|
|
29
|
+
transferToImageBitmap(): Promise<ImageBitmap>;
|
|
30
|
+
toImageValue(previewScale: number): Promise<ImageValue>;
|
|
31
|
+
/** Encode the image to a compressed format. Single-use: the underlying
|
|
32
|
+
* texture is disposed during encoding (via `transferToImageBitmap`); a
|
|
33
|
+
* second call on the same instance throws. */
|
|
36
34
|
encode(format: GpuImageEncodeFormat, quality?: number): Promise<Uint8Array>;
|
|
37
|
-
|
|
38
|
-
release(): void;
|
|
35
|
+
dispose(): void;
|
|
39
36
|
}
|
|
40
37
|
//# sourceMappingURL=webGpuImage.browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webGpuImage.browser.d.ts","sourceRoot":"","sources":["../../src/media/webGpuImage.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"webGpuImage.browser.d.ts","sourceRoot":"","sources":["../../src/media/webGpuImage.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ/C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,WAAW,GAAG,SAAS,CAAC;IAClC,OAAO,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C;AAED,qBAAa,WAAY,YAAW,SAAS;IAKzC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IACf,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM;IAPzB,QAAQ,CAAC,OAAO,EAAG,QAAQ,CAAU;IACrC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAK;IAErC,OAAO,eAKH;IAEJ,OAAa,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAiBzD;IAED,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CA4CtC;IAED;gEAC4D;IACtD,qBAAqB,IAAI,OAAO,CAAC,WAAW,CAAC,CA0ClD;IAEK,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAG5D;IAED;;mDAE+C;IACzC,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAShF;IAED,OAAO,IAAI,IAAI,CASd;CACF"}
|
package/dist/media-browser.d.ts
CHANGED
|
@@ -7,15 +7,18 @@ import "./media/imageCacheCodec";
|
|
|
7
7
|
import "./media/imageHydrationResolver";
|
|
8
8
|
export * from "./media/color";
|
|
9
9
|
export { CpuImage } from "./media/cpuImage";
|
|
10
|
-
export {
|
|
10
|
+
export { rawPixelBufferToBlob, rawPixelBufferToDataUri } from "./media/encode";
|
|
11
11
|
export { _resetFilterRegistryForTests, applyFilter, hasFilterOp, registerFilterOp, } from "./media/filterRegistry";
|
|
12
12
|
export type { FilterOpFn } from "./media/filterRegistry";
|
|
13
13
|
export { getGpuDevice, resetGpuDeviceForTests } from "./media/gpuDevice.browser";
|
|
14
14
|
export { getGpuImageFactory, GpuImage as GpuImageFactory, registerGpuImageFactory, } from "./media/gpuImage";
|
|
15
15
|
export type { GpuImage, GpuImageBackend, GpuImageEncodeFormat, GpuImageStatic, } from "./media/gpuImage";
|
|
16
|
-
export {
|
|
16
|
+
export { ImageValueSchema } from "./media/imageValueSchema";
|
|
17
17
|
export * from "./media/imageRasterCodecRegistry";
|
|
18
|
-
export
|
|
18
|
+
export type { ImageChannels } from "./media/imageTypes";
|
|
19
|
+
export type { RawPixelBuffer, RgbaPixelBuffer } from "./media/rawPixelBuffer";
|
|
20
|
+
export { imageValueFromBitmap, imageValueFromBuffer, isBrowserImageValue, isImageValue, isNodeImageValue, normalizeToImageValue, } from "./media/imageValue";
|
|
21
|
+
export type { BrowserImageValue, ImageValue, ImageValueBase, NodeImageFormat, NodeImageValue, } from "./media/imageValue";
|
|
19
22
|
export * from "./media/MediaRawImage";
|
|
20
23
|
export { getPreviewBudget, previewSource, registerPreviewResizeFn, setPreviewBudget, } from "./media/previewBudget";
|
|
21
24
|
export { createShaderCache, getShaderCache, PASSTHROUGH_SHADER_SRC, VERTEX_PRELUDE, } from "./media/shaderRegistry.browser";
|
|
@@ -24,4 +27,7 @@ export { createTexturePool, getTexturePool, resetTexturePoolForTests, } from "./
|
|
|
24
27
|
export type { TexturePool, TexturePoolOptions } from "./media/texturePool.browser";
|
|
25
28
|
export { WebGpuImage } from "./media/webGpuImage.browser";
|
|
26
29
|
export type { ApplyParams } from "./media/webGpuImage.browser";
|
|
30
|
+
export declare function probeImageDimensions(): Promise<never>;
|
|
31
|
+
export declare function decodeBufferToRaw(): Promise<never>;
|
|
32
|
+
export declare function encodeRawPixels(): Promise<never>;
|
|
27
33
|
//# sourceMappingURL=media-browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-browser.d.ts","sourceRoot":"","sources":["../src/media-browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,gCAAgC,CAAC;AAExC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"media-browser.d.ts","sourceRoot":"","sources":["../src/media-browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,yBAAyB,CAAC;AACjC,OAAO,gCAAgC,CAAC;AAExC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EACL,4BAA4B,EAC5B,WAAW,EACX,WAAW,EACX,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EACL,kBAAkB,EAClB,QAAQ,IAAI,eAAe,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