jpegxl 8.4.0 → 8.4.1

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.
Files changed (88) hide show
  1. package/README.md +294 -229
  2. package/dist/animation.browser.mjs +2 -2
  3. package/dist/animation.mjs +2 -2
  4. package/dist/capture-complete.browser.mjs +2 -2
  5. package/dist/capture-complete.mjs +2 -2
  6. package/dist/capture-groups.mjs +2 -2
  7. package/dist/capture.browser.mjs +2 -2
  8. package/dist/capture.mjs +2 -2
  9. package/dist/cli-add.mjs +2 -2
  10. package/dist/cli-astro.mjs +2 -2
  11. package/dist/cli-cloudflare.mjs +2 -2
  12. package/dist/cli-emdash.mjs +2 -2
  13. package/dist/cli-places.mjs +2 -2
  14. package/dist/cli-selftest.mjs +2 -2
  15. package/dist/cli-workers.mjs +2 -2
  16. package/dist/cli.mjs +2 -2
  17. package/dist/decode.browser.mjs +2 -2
  18. package/dist/decode.mjs +2 -2
  19. package/dist/decode.node.mjs +2 -2
  20. package/dist/format.browser.mjs +2 -2
  21. package/dist/format.mjs +2 -2
  22. package/dist/hdr.mjs +2 -2
  23. package/dist/helpers.mjs +2 -2
  24. package/dist/index.browser.mjs +2 -2
  25. package/dist/index.mjs +2 -2
  26. package/dist/jpeg.browser.mjs +2 -2
  27. package/dist/jpeg.mjs +2 -2
  28. package/dist/jpeg.node.mjs +2 -2
  29. package/dist/metadata.mjs +2 -2
  30. package/dist/polyfill.mjs +2 -2
  31. package/dist/resumable.mjs +2 -2
  32. package/dist/resumable.node.mjs +2 -2
  33. package/dist/serve.mjs +2 -2
  34. package/dist/serve.node.mjs +2 -2
  35. package/dist/upload.browser.mjs +2 -2
  36. package/dist/upload.mjs +2 -2
  37. package/dist/verify.mjs +2 -2
  38. package/dist/verify.node.mjs +2 -2
  39. package/dist/wasm-modules.mjs +2 -2
  40. package/examples/agents/jxl-tools.mjs +8 -8
  41. package/examples/android/prepare-assets.mjs +2 -2
  42. package/examples/capacitor/prepare-assets.mjs +2 -2
  43. package/examples/emdash/admin-work.mjs +1 -1
  44. package/examples/emdash/backfill.mjs +4 -4
  45. package/examples/emdash/background.mjs +5 -5
  46. package/examples/emdash/browser-candidate.mjs +1 -1
  47. package/examples/emdash/deliver.mjs +2 -2
  48. package/examples/emdash/host-policy.mjs +6 -6
  49. package/examples/emdash/index.mjs +3 -3
  50. package/examples/emdash/job-runner.mjs +31 -31
  51. package/examples/emdash/job-store.mjs +21 -21
  52. package/examples/emdash/jpeg-source.mjs +2 -2
  53. package/examples/emdash/library-jobs.mjs +21 -21
  54. package/examples/emdash/local-store.mjs +16 -16
  55. package/examples/emdash/media-admin.mjs +9 -9
  56. package/examples/emdash/media-plugin.mjs +62 -62
  57. package/examples/emdash/media-storage.mjs +55 -55
  58. package/examples/emdash/media-words.mjs +89 -89
  59. package/examples/emdash/media-worker.mjs +1 -1
  60. package/examples/emdash/original-envelope.mjs +2 -2
  61. package/examples/emdash/originals.mjs +77 -77
  62. package/examples/emdash/r2-store.mjs +3 -3
  63. package/examples/emdash/read-all.mjs +14 -14
  64. package/examples/emdash/server-only.mjs +1 -1
  65. package/examples/emdash/storage.mjs +1 -1
  66. package/examples/emdash/structural-delivery.mjs +42 -42
  67. package/examples/emdash/thread-driver.mjs +15 -15
  68. package/examples/emdash/thread-worker.mjs +3 -3
  69. package/examples/emdash/work-queue.mjs +11 -11
  70. package/examples/flutter/prepare-assets.mjs +3 -3
  71. package/examples/ios/prepare-assets.mjs +3 -3
  72. package/examples/page-rects.js +14 -14
  73. package/examples/react-native/src/JXLProvider.tsx +19 -9
  74. package/examples/snapdom/jxl.js +3 -2
  75. package/examples/svg-jxl.js +10 -10
  76. package/package.json +1 -1
  77. package/types/animation.d.mts +2 -2
  78. package/types/capture-complete.d.mts +5 -5
  79. package/types/capture.d.mts +1 -1
  80. package/types/format.d.mts +2 -2
  81. package/types/index.d.mts +6 -6
  82. package/types/jpeg.d.mts +1 -1
  83. package/types/result.d.mts +5 -4
  84. package/types/resumable.d.mts +7 -7
  85. package/types/serve.d.mts +1 -1
  86. package/types/types.d.mts +19 -18
  87. package/types/upload.d.mts +1 -1
  88. package/types/verify.d.mts +4 -4
@@ -1,28 +1,38 @@
1
- import React, {createContext, useContext, useMemo, useRef, useState, type ReactNode} from 'react';
1
+ import React, {createContext, useContext, useEffect, useState, type ReactNode} from 'react';
2
2
  import {WebView} from 'react-native-webview';
3
3
  import {createCodec, type JXLCodec} from './codec.ts';
4
4
  import {ORIGIN, PAGE, modules} from './generated/page.ts';
5
5
 
6
6
  const Context = createContext<JXLCodec | null>(null);
7
+ type Page = React.ComponentRef<typeof WebView>;
7
8
 
8
- /** Mounts the hidden page that runs the encoder. Put it once, high in the tree; calls made before the page is ready wait for it. */
9
- export function JXLProvider({children}: {children?: ReactNode}) {
10
- const web = useRef<React.ComponentRef<typeof WebView>>(null);
11
- const [page, setPage] = useState(0);
12
- const host = useMemo(() => createCodec(
13
- message => web.current?.injectJavaScript(`rapier.receive(${JSON.stringify(message)});true;`),
9
+ // The codec and the page it talks to. The provider hands it the mounted page from an effect, so rendering never reads
10
+ // it; a page the system ended is replaced and handed over again.
11
+ function startHost() {
12
+ let page: Page | null = null;
13
+ const host = createCodec(
14
+ message => page?.injectJavaScript(`rapier.receive(${JSON.stringify(message)});true;`),
14
15
  async name => {
15
16
  const load = modules[name];
16
17
  if (!load) throw new Error(`There is no ${name} module.`);
17
18
  return load();
18
- }), []);
19
+ });
20
+ return {...host, attach: (next: Page | null) => { page = next; }};
21
+ }
22
+
23
+ /** Mounts the hidden page that runs the encoder. Put it once, high in the tree; calls made before the page is ready wait for it. */
24
+ export function JXLProvider({children}: {children?: ReactNode}) {
25
+ const [host] = useState(startHost);
26
+ const [page, setPage] = useState(0);
27
+ const [view, setView] = useState<Page | null>(null);
28
+ useEffect(() => host.attach(view), [host, view]);
19
29
  const lost = (message: string) => { host.reset('JXL_WEBVIEW_STOPPED', message); setPage(n => n + 1); };
20
30
  return (
21
31
  <Context.Provider value={host.codec}>
22
32
  {children}
23
33
  <WebView
24
34
  key={page}
25
- ref={web}
35
+ ref={setView}
26
36
  source={{html: PAGE, baseUrl: ORIGIN}}
27
37
  style={{position: 'absolute', width: 1, height: 1, opacity: 0, pointerEvents: 'none'}}
28
38
  javaScriptEnabled
@@ -454,8 +454,9 @@ async function image(blob, drawn, own, dpr, signal, exact) {
454
454
 
455
455
  // A canvas holds its pixels until it is emptied, even once nothing reads it. Only the export's own
456
456
  // canvases are emptied, never one the app passed as `canvas`.
457
- // The capture's refusal of a canvas read back blank where its rectangles hold content (its words, which cross a worker).
458
- const blankCanvas = error => error?.code === 'JXL_PLATFORM' && /read back blank/.test(error?.message ?? '');
457
+ // The capture's refusal of a canvas that reads back blank where its rectangles hold content (JXL_PLATFORM; its words, which cross
458
+ // a worker, say "blank" in every version).
459
+ const blankCanvas = error => error?.code === 'JXL_PLATFORM' && /\bblank\b/.test(error?.message ?? '');
459
460
 
460
461
  function free(canvas) {
461
462
  if (typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement) canvas.width = canvas.height = 0;
@@ -12,23 +12,23 @@ const stillModule = () => still ??= import('jpegxl');
12
12
 
13
13
  const KEYS = ['fidelity', 'effort', 'webgpu', 'signal', 'onProgress', 'codec', 'cache'];
14
14
  export async function svgJxl(input, options = {}) {
15
- if (typeof input !== 'string' && !(typeof Blob === 'function' && input instanceof Blob)) throw Object.assign(new TypeError("Invalid input; use SVG text or a Blob."), { code: 'JXL_INPUT' });
16
- if (options === null || typeof options !== 'object' || Array.isArray(options)) throw Object.assign(new TypeError("Invalid options; pass an object."), { code: 'JXL_OPTIONS' });
15
+ if (typeof input !== 'string' && !(typeof Blob === 'function' && input instanceof Blob)) throw Object.assign(new TypeError("input: SVG string or Blob"), { code: 'JXL_INPUT' });
16
+ if (options === null || typeof options !== 'object' || Array.isArray(options)) throw Object.assign(new TypeError("options: object"), { code: 'JXL_OPTIONS' });
17
17
  const refuse = message => Object.assign(new TypeError(message), { code: 'JXL_OPTIONS' });
18
- for (const key of Object.keys(options)) if (!KEYS.includes(key)) throw refuse(`Unknown svgJxl option ${key}; remove it.`);
18
+ for (const key of Object.keys(options)) if (!KEYS.includes(key)) throw refuse(`unknown option: ${key}`);
19
19
  const { fidelity = { quality: 92 }, effort, webgpu, signal, onProgress, codec, cache = new Map() } = options;
20
20
  // fidelity as encode takes it: 'exact', or {quality} from 1 to 100 (100 is exact).
21
21
  const named = fidelity !== null && typeof fidelity === 'object' && !Array.isArray(fidelity) && Object.keys(fidelity).join() === 'quality';
22
22
  if (fidelity !== 'exact' && !(named && typeof fidelity.quality === 'number' && fidelity.quality >= 1 && fidelity.quality <= 100))
23
- throw refuse("Invalid fidelity; use 'exact' or {quality: 1 to 100}.");
23
+ throw refuse("fidelity: 'exact' or quality 1-100");
24
24
  const exact = fidelity === 'exact', quality = exact ? 1 : fidelity.quality / 100;
25
- if (effort !== undefined && !(Number.isInteger(effort) && effort >= 1 && effort <= 9)) throw refuse("Invalid effort; use an integer from 1 to 9.");
26
- if (webgpu !== undefined && webgpu !== 'required' && webgpu !== false) throw refuse("Invalid webgpu; use 'required', false, or omit it.");
27
- if (codec !== undefined && typeof codec?.capture !== 'function') throw refuse("Invalid codec; pass a capture module, such as import * as codec from 'jpegxl/capture-complete'.");
25
+ if (effort !== undefined && !(Number.isInteger(effort) && effort >= 1 && effort <= 9)) throw refuse("effort: integer 1-9");
26
+ if (webgpu !== undefined && webgpu !== 'required' && webgpu !== false) throw refuse("webgpu: 'required', false or omit");
27
+ if (codec !== undefined && typeof codec?.capture !== 'function') throw refuse("codec: capture module");
28
28
  if (signal !== undefined && (!signal || typeof signal !== 'object' || typeof signal.aborted !== 'boolean' ||
29
- ['throwIfAborted', 'addEventListener', 'removeEventListener'].some(key => typeof signal[key] !== 'function'))) throw refuse("Invalid signal; pass an AbortSignal.");
30
- if (onProgress !== undefined && typeof onProgress !== 'function') throw refuse("Invalid onProgress; pass a function.");
31
- if (cache === null || typeof cache !== 'object' || typeof cache.has !== 'function' || typeof cache.get !== 'function' || typeof cache.set !== 'function') throw refuse("Invalid cache; use a Map.");
29
+ ['throwIfAborted', 'addEventListener', 'removeEventListener'].some(key => typeof signal[key] !== 'function'))) throw refuse("signal: AbortSignal");
30
+ if (onProgress !== undefined && typeof onProgress !== 'function') throw refuse("onProgress: function");
31
+ if (cache === null || typeof cache !== 'object' || typeof cache.has !== 'function' || typeof cache.get !== 'function' || typeof cache.set !== 'function') throw refuse("cache: Map");
32
32
  signal?.throwIfAborted();
33
33
  // A Blob or File is scanned as one character per byte and written back unchanged, whatever its encoding.
34
34
  const text = typeof input === 'string', svg = text ? input : latin1(new Uint8Array(await abortable(input.arrayBuffer(), signal)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jpegxl",
3
- "version": "8.4.0",
3
+ "version": "8.4.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "JPEG XL encoder and decoder in WebAssembly for browsers, Node and Cloudflare Workers, with no native dependencies. Page captures with exact text, fast uploads, animation, lossless JPEG recompression.",
@@ -21,8 +21,8 @@ export function encode(input: AnimationInput | Blob | VideoSurface, options?: An
21
21
  export function encode(input: ImageInput, options?: EncodeOptions): Promise<EncodedResult>;
22
22
 
23
23
  /** Where the host reads no JPEG (Node, Deno, Bun), the one setup step for a JPEG input: `configureDecoder(decode, restore,
24
- * recompress)` with rapier-jxl/decode's decode and rapier-jxl/jpeg's recompress (restore may be null). Without it a JPEG
25
- * refuses JXL_PLATFORM. One call serves every rapier-jxl module in the realm; null alone clears it, while null with helpers keeps them. */
24
+ * recompress)` with jpegxl/decode's decode and jpegxl/jpeg's recompress (restore may be null). Without it a JPEG
25
+ * refuses JXL_PLATFORM. One call serves every jpegxl module in the realm; null alone clears it, while null with helpers keeps them. */
26
26
  export function configureDecoder(decode: PackageDecode | null, restore?: JpegRestore | null, recompress?: JpegRecompress | null): void;
27
27
 
28
28
  /** This module's settings for the calls that follow. In a browser they are its queue's: the module runs in its own file's
@@ -1,5 +1,5 @@
1
1
  import type {EncodedResult, ImageResult} from './result.mjs';
2
- // rapier-jxl/capture-complete: every capture effort, 1-9, exact, bounded and photographic
2
+ // jpegxl/capture-complete: every capture effort, 1-9, exact, bounded and photographic
3
3
  import type {CaptureInput, Effort, CapturePhotoOptions, CaptureDecoder, PackageDecode, JpegRestore, JpegRecompress} from './types.mjs';
4
4
  import type {ResumableFunction} from './resumable.mjs';
5
5
  import type {CodecConfig} from './types.mjs';
@@ -10,16 +10,16 @@ export type {CapturePhotoFidelity, CapturePhotoOptions, CaptureRect, ExactRect,
10
10
  export type CaptureCompleteOptions = Omit<CapturePhotoOptions, 'effort'> & {
11
11
  /** 1 (fastest) to 9 (smallest file); default 3. Efforts 1-5 predict the look, 6-9 measure it. */
12
12
  effort?: Effort};
13
- /** In one file: a page's calls run in its own worker; calls in a worker, Node and edge hosts run in place. Exact, bounded and photographic capture at efforts 1-9 (rapier-jxl/capture's exact files at 1-5), GPU textures, and
13
+ /** In one file: a page's calls run in its own worker; calls in a worker, Node and edge hosts run in place. Exact, bounded and photographic capture at efforts 1-9 (jpegxl/capture's exact files at 1-5), GPU textures, and
14
14
  * efforts 7-9's GPU stages on a device where one answers (the same file without one).
15
- * The root still encoder has no capture() export. rapier-jxl/upload carries photographic capture at 1-3. Invalid options refuse JXL_OPTIONS, oversized rectangle work JXL_LIMIT, required GPU failure JXL_WEBGPU, and unavailable decoding JXL_PLATFORM. */
15
+ * The root still encoder has no capture() export. jpegxl/upload carries photographic capture at 1-3. Invalid options refuse JXL_OPTIONS, oversized rectangle work JXL_LIMIT, required GPU failure JXL_WEBGPU, and unavailable decoding JXL_PLATFORM. */
16
16
  export const capture: ResumableFunction<(input: CaptureInput, options?: CaptureCompleteOptions) => Promise<EncodedResult>>;
17
17
  export function prepare(): Promise<void>;
18
18
  /** supported('webgpu'): this realm has a usable GPU for efforts 7-9. */
19
19
  export function supported(feature?: 'webgpu'): Promise<boolean>;
20
20
  /** The one setup step for measured capture (efforts 6-9) in Node, Deno, Bun and desktop apps: `configureDecoder(decode)`
21
- * with rapier-jxl/decode's decode (and rapier-jxl/jpeg's restore, which rapier-jxl/verify uses). One call serves every
22
- * rapier-jxl module in the realm. Browser-native decoding is preferred; null alone clears it, while null with helpers keeps them. */
21
+ * with jpegxl/decode's decode (and jpegxl/jpeg's restore, which jpegxl/verify uses). One call serves every
22
+ * jpegxl module in the realm. Browser-native decoding is preferred; null alone clears it, while null with helpers keeps them. */
23
23
  export function configureDecoder(decode: PackageDecode | CaptureDecoder | null, restore?: JpegRestore | null, recompress?: JpegRecompress | null): void;
24
24
 
25
25
  export type {ImageJob, ImageVerb, Digest, ResultSource, ResultReason, ResultTransform, ResultFidelity, ResultMeasurement, ImageResult, EncodedResult} from './result.mjs';
@@ -7,7 +7,7 @@ export type {CaptureOptions, CaptureFidelity, MaxError, ImageInput, CapturePixel
7
7
  export type CaptureInput = Exclude<FullCaptureInput, TextureInput>;
8
8
  export type {ImagePreview, PreviewOptions} from './types.mjs';
9
9
  /** The screenshot encoder in one file: a page's calls run in its own worker; calls in a worker, Node and edge hosts run in place. 8-bit sRGB or Display P3 RGBA, exact or within maxError.
10
- * Efforts 1-5. `rapier-jxl/capture-complete` adds photographic fidelity, efforts 6-9 and WebGPU. Invalid options refuse JXL_OPTIONS, unsupported efforts and textures JXL_UNSUPPORTED, and unreadable canvas data JXL_PLATFORM. */
10
+ * Efforts 1-5. `jpegxl/capture-complete` adds photographic fidelity, efforts 6-9 and WebGPU. Invalid options refuse JXL_OPTIONS, unsupported efforts and textures JXL_UNSUPPORTED, and unreadable canvas data JXL_PLATFORM. */
11
11
  export const capture: ResumableFunction<(input: CaptureInput, options?: CaptureOptions) => Promise<EncodedResult>>;
12
12
  /** Compiles the kernels and warms the coder, with no job. */
13
13
  export function prepare(): Promise<void>;
@@ -79,8 +79,8 @@ type FormatCall = {[K in FormatKind]: [input: Extract<FormatRequest, {kind: K}>,
79
79
  export function format(...args: FormatCall): Promise<import('./result.mjs').EncodedResult>;
80
80
 
81
81
  /** Where the host reads no JPEG (Node, Deno, Bun), the one setup step for a JPEG input: `configureDecoder(decode, restore,
82
- * recompress)` with rapier-jxl/decode's decode and rapier-jxl/jpeg's recompress (restore may be null). Without it a JPEG
83
- * refuses JXL_PLATFORM. One call serves every rapier-jxl module in the realm; null alone clears it, while null with helpers keeps them. */
82
+ * recompress)` with jpegxl/decode's decode and jpegxl/jpeg's recompress (restore may be null). Without it a JPEG
83
+ * refuses JXL_PLATFORM. One call serves every jpegxl module in the realm; null alone clears it, while null with helpers keeps them. */
84
84
  export function configureDecoder(decode: PackageDecode | null, restore?: JpegRestore | null, recompress?: JpegRecompress | null): void;
85
85
  export type {ImageJob, ImageVerb, Digest, ResultSource, ResultReason, ResultTransform, ResultFidelity, ResultMeasurement, ImageResult, EncodedResult} from './result.mjs';
86
86
 
package/types/index.d.mts CHANGED
@@ -4,15 +4,15 @@ import type {ImageInput, EncodeOptions, PreparationInput, FitOptions, VariantsOp
4
4
  import type {ResumableFunction} from './resumable.mjs';
5
5
  import type {CodecConfig} from './types.mjs';
6
6
  export type * from './types.mjs';
7
- // Types only: page capture's options; the function is rapier-jxl/capture-complete's.
7
+ // Types only: page capture's options; the function is jpegxl/capture-complete's.
8
8
  export type {CaptureCompleteOptions, CapturePhotoFidelity as CaptureFidelity} from './capture-complete.mjs';
9
- /** rapier-jxl: the full still encoder in one file: a page's calls run in its own worker; calls in a worker, Node and edge hosts run in place. Efforts 1-9, exact or lossy, measured fidelity, WebGPU
9
+ /** jpegxl: the full still encoder in one file: a page's calls run in its own worker; calls in a worker, Node and edge hosts run in place. Efforts 1-9, exact or lossy, measured fidelity, WebGPU
10
10
  * at lossy efforts 7-9, HDR and deeper samples, ICC and codestream features. An exact, unchanged JPEG File or Blob
11
11
  * preserves the original JPEG. At efforts 6-9, a JPEG look request compares the pixel result's size with reversible
12
12
  * recompression. jpeg: 'pixels' requires pixel encoding. A preserved JPEG reports fidelity: 'exact', kept: 'jpeg-bytes'
13
13
  * and measurements: [], with no measured score. An animation is
14
- * encoded by rapier-jxl/animation; a file's header and metadata are rapier-jxl/metadata's. In a browser each module's own name is
15
- * its worker queue (configure sets it). Page capture is rapier-jxl/capture and rapier-jxl/capture-complete.
14
+ * encoded by jpegxl/animation; a file's header and metadata are jpegxl/metadata's. In a browser each module's own name is
15
+ * its worker queue (configure sets it). Page capture is jpegxl/capture and jpegxl/capture-complete.
16
16
  * Invalid fidelity, effort or readAs refuses JXL_OPTIONS; a required WebGPU device or job that cannot run refuses JXL_WEBGPU. */
17
17
  export const encode: ResumableFunction<(input: ImageInput, options?: EncodeOptions) => Promise<EncodedResult>>;
18
18
  /** Fit the same oriented dimensions to maxBytes within explicit fidelity bounds. No fit is an ordinary result. */
@@ -26,8 +26,8 @@ export function prepare(): Promise<void>;
26
26
  export function supported(feature?: 'webgpu'): Promise<boolean>;
27
27
 
28
28
  /** Where the host reads no JPEG (Node, Deno, Bun), the one setup step for a JPEG input: `configureDecoder(decode, restore,
29
- * recompress)` with rapier-jxl/decode's decode and rapier-jxl/jpeg's recompress (restore may be null). Without it a JPEG
30
- * refuses JXL_PLATFORM. One call serves every rapier-jxl module in the realm; null alone clears it, while null with helpers keeps them. */
29
+ * recompress)` with jpegxl/decode's decode and jpegxl/jpeg's recompress (restore may be null). Without it a JPEG
30
+ * refuses JXL_PLATFORM. One call serves every jpegxl module in the realm; null alone clears it, while null with helpers keeps them. */
31
31
  export function configureDecoder(decode: PackageDecode | null, restore?: JpegRestore | null, recompress?: JpegRecompress | null): void;
32
32
 
33
33
  /** This module's settings for the calls that follow. In a browser they are its queue's: the module runs in its own file's
package/types/jpeg.d.mts CHANGED
@@ -15,7 +15,7 @@ export interface RecompressOptions extends JPEGOptions {
15
15
  gainMap?: boolean; }
16
16
  export const recompress: ResumableFunction<(input: Uint8Array | Blob, options?: RecompressOptions) => Promise<EncodedResult>>;
17
17
  /** The JPEG a recompressed file was made from, restored exactly. A file with no reconstruction data refuses
18
- * JXL_RECONSTRUCTION. rapier-jxl/metadata header(bytes).reconstruction says, without a decode, whether the bytes hold a
18
+ * JXL_RECONSTRUCTION. jpegxl/metadata header(bytes).reconstruction says, without a decode, whether the bytes hold a
19
19
  * reconstruction box; restore alone says whether the JPEG comes back.
20
20
  * Unknown restore options refuse JXL_OPTIONS. */
21
21
  export const restore: ResumableFunction<(input: Uint8Array | Blob, options?: JobOptions) => Promise<EncodedResult>>;
@@ -66,19 +66,20 @@ interface ResultDescription<F = ResultFidelity> {
66
66
  readonly originalBytes?: number;
67
67
  /** True exactly when the returned file exceeds originalBytes; omitted when no file was returned. */
68
68
  readonly largerThanOriginal?: boolean;
69
- /** rapier-jxl/jpeg's recompress, when another decoder returns less than the whole JPEG. */
69
+ /** jpegxl/jpeg's recompress, when another decoder returns less than the whole JPEG. */
70
70
  readonly otherDecoders?: ResultOtherDecoders;
71
71
  /** An animation's durations: 'rounded' when one was rounded to the file's tick (each frame still ends within half a tick). */
72
72
  readonly timing?: 'exact' | 'rounded';
73
73
  /** A capture: 'skipped' where the page held more marks of ink than the reader takes; the caller's boxes and the
74
74
  * repeated marks stayed exact, and unboxed text was not looked for. */
75
75
  readonly textMarks?: 'skipped';
76
- /** From the entries that can run stages on WebGPU (rapier-jxl's encode, fit and variants, animation, format's encode,
76
+ /** From the entries that can run stages on WebGPU (jpegxl's encode, fit and variants, animation, format's encode,
77
77
  * capture-complete): true when a stage of this call ran on the device. The file is the same either way. */
78
78
  readonly usedWebGPU?: boolean;
79
79
  }
80
- /** Another decoder (libjxl's djxl) returns this JPEG without its last `missing` bytes; rapier-jxl/jpeg's restore returns
81
- * all of it. 'past-jbrd': the data after the JPEG's end is longer than the 4,260,096 bytes the reconstruction box holds. */
80
+ /** Another decoder (libjxl's djxl) returns this JPEG without its last `missing` bytes; jpegxl/jpeg's restore returns
81
+ * all of it. 'past-jbrd': data after the JPEG's end travels outside the reconstruction box. This happens for tails
82
+ * longer than the 4,260,096 bytes the box holds, or when gainMap: true keeps the gain map in a jhgm bundle. */
82
83
  export interface ResultOtherDecoders {
83
84
  readonly missing: number;
84
85
  readonly reason: 'past-jbrd';
@@ -44,8 +44,8 @@ export interface ResumableFile extends ResumableInput {
44
44
  readonly kind: 'file';
45
45
  }
46
46
 
47
- /** A stored JPEG XL, such as a JPEG's lossless one, whose picture is its decode: rapier-jxl/decode's decode, set once with
48
- * configureDecoder(decode) from rapier-jxl/verify. The job encodes the decoded pixels, as encode() of them would. */
47
+ /** A stored JPEG XL, such as a JPEG's lossless one, whose picture is its decode: jpegxl/decode's decode, set once with
48
+ * configureDecoder(decode) from jpegxl/verify. The job encodes the decoded pixels, as encode() of them would. */
49
49
  export interface ResumableDecode extends ResumableInput {
50
50
  readonly kind: 'decode';
51
51
  }
@@ -80,8 +80,8 @@ export interface Checkpoint {
80
80
  }
81
81
 
82
82
  type Uploads = typeof root.encode | typeof root.fit | typeof root.variants | typeof upload.encode | typeof upload.fit | typeof upload.variants;
83
- /** Resumable verbs: encode/fit/variants from rapier-jxl or rapier-jxl/upload, capture from rapier-jxl/capture or
84
- * rapier-jxl/capture-complete (every effort), recompress/restore from rapier-jxl/jpeg, and verify from rapier-jxl/verify. */
83
+ /** Resumable verbs: encode/fit/variants from jpegxl or jpegxl/upload, capture from jpegxl/capture or
84
+ * jpegxl/capture-complete (every effort), recompress/restore from jpegxl/jpeg, and verify from jpegxl/verify. */
85
85
  export type ResumableOperation = typeof capture | typeof captureComplete | typeof recompress | typeof restore | typeof verify | Uploads;
86
86
 
87
87
  type OptionKeys = keyof CaptureOptions | keyof JPEGOptions;
@@ -141,7 +141,7 @@ interface OperationContext<Operation extends ResumableOperation = ResumableOpera
141
141
  /** The operation alone determines the admitted source and option shapes. */
142
142
  export type StartOptions<Operation extends ResumableOperation = ResumableOperation> = Operation extends unknown ? OperationContext<Operation> & {
143
143
  readonly input: InputOf<NoInfer<Operation>>;
144
- /** rapier-jxl/verify's verify: verify in the advances and return the whole-file verifier's receipt at
144
+ /** jpegxl/verify's verify: verify in the advances and return the whole-file verifier's receipt at
145
145
  * result.verification. The plan saves that verification was chosen; pass the same verify to every advance. The host
146
146
  * supplies a decoder through configureDecoder where needed. */
147
147
  readonly verify?: Operation extends typeof verify ? never : typeof verify;
@@ -158,7 +158,7 @@ export interface AdvanceOptions<Operation extends ResumableOperation = Resumable
158
158
  /** `ms`: positive milliseconds, at most 60000; defaults to {ms: 30}. A call advances at least one step. `reads`: the store
159
159
  * reads a call may make, for a host that allows few calls a request (none by default). */
160
160
  readonly budget?: {readonly ms: number; readonly reads?: number};
161
- /** rapier-jxl/verify's verify, for a job started with it (an advance without it refuses with JXL_OPTIONS). */
161
+ /** jpegxl/verify's verify, for a job started with it (an advance without it refuses with JXL_OPTIONS). */
162
162
  readonly verify?: typeof verify;
163
163
  }
164
164
  export interface AdvanceResult {
@@ -184,7 +184,7 @@ type VerifiedResult<Result> = Result extends readonly (infer Item)[] ? Array<Ver
184
184
  export function finish<Operation extends ResumableOperation>(checkpoint: Checkpoint, options: FinishOptions<Operation>): Promise<
185
185
  Operation extends typeof verify ? VerificationReceipt : VerifiedResult<Awaited<ReturnType<Operation>>>>;
186
186
 
187
- /** Whether a resumable job runs within a Cloudflare Workers isolate's 128 MB, from rapier-jxl's measured table: the
187
+ /** Whether a resumable job runs within a Cloudflare Workers isolate's 128 MB, from jpegxl's measured table: the
188
188
  * Node estimate (total peak minus bare runtime) x 1.1 <= 96,000,000 B, admitted only where every measured size up to the
189
189
  * first at least this large was admitted. Pass the imported operation function (encode, recompress, etc.), never
190
190
  * the operation name as a string. The answer rests on the next measured size bucket at least width x height pixels,
package/types/serve.d.mts CHANGED
@@ -12,7 +12,7 @@ export interface ServeOptions {
12
12
  /** The largest picture served, in pixels; none by default. A larger one refuses JXL_DIMENSIONS. */
13
13
  maxPixels?: number;
14
14
  /** To an image/jxl client, the smallest of the file's sizes (1:8, 1:4, 1:2, 1:1) at least this many pixels wide, cut
15
- * from the file without decoding (rapier-jxl/metadata slice). A file with no passes to cut is served whole. */
15
+ * from the file without decoding (jpegxl/metadata slice). A file with no passes to cut is served whole. */
16
16
  width?: number;
17
17
  /** To an image/jxl client, the largest of the file's sizes in at most this many bytes; none refuses JXL_LIMIT. */
18
18
  maxBytes?: number;
package/types/types.d.mts CHANGED
@@ -74,7 +74,7 @@ export interface GPUTextureLike {readonly width: number; readonly height: number
74
74
  /** An extra channel read from a texture of the input's device (a depth buffer: depth16unorm, depth32float, r16uint,
75
75
  * r16float or r32float), from the input's layer, at the picture's size or its 2^dimShift reduction. */
76
76
  export type TextureChannel = Omit<NonNullable<AdvancedPhotoOptions['extraChannels']>[number], 'data' | 'bitDepth' | 'sampleFormat' | 'exponentBits'> & {texture: GPUTextureLike; data?: never};
77
- /** A GPU texture read from its own device, at the encoder's size; rapier-jxl and capture-complete take it. */
77
+ /** A GPU texture read from its own device, at the encoder's size; jpegxl and capture-complete take it. */
78
78
  export interface TextureInput extends Omit<SampleDescription, 'extraChannels'> {
79
79
  texture: GPUTextureLike;
80
80
  /** Required to contain failed texture copies, including destroyed or invalid source textures. */
@@ -185,7 +185,7 @@ type Sole<K extends FidelityKey, V = number> = {[P in K]: V} & {[P in Exclude<Fi
185
185
  export interface SampleDescription {
186
186
  colorSpace?: CoreOptions['colorSpace'];
187
187
  /** The primaries and white point as a file states them, for a picture that is none of the named color spaces (what
188
- * `read()` from rapier-jxl/hdr returns); the picture's transferFunction names its curve. Instead of colorSpace, not beside it. */
188
+ * `read()` from jpegxl/hdr returns); the picture's transferFunction names its curve. Instead of colorSpace, not beside it. */
189
189
  colorEncoding?: ColorEncoding;
190
190
  transferFunction?: CoreOptions['transferFunction'];
191
191
  bitDepth?: CoreOptions['bitDepth'];
@@ -231,7 +231,7 @@ type EncodingExecution = JobOptions & PreviewOptions & Described & Handed & {
231
231
  /** 1 (fastest) to 9 (smallest file); default 7. Same fidelity, same file on every host. */
232
232
  effort?: Effort;
233
233
  /** Lossy pictures in three passes over the 1:8 image (1:4, 1:2, then the rest): a browser loading the file sharpens
234
- * it in steps, and rapier-jxl/metadata slice() cuts each size from it. The same picture in a file a few percent
234
+ * it in steps, and jpegxl/metadata slice() cuts each size from it. The same picture in a file a few percent
235
235
  * larger. A picture the encoder codes as graphics (Modular) keeps one pass. Exact fidelity refuses JXL_OPTIONS. */
236
236
  progressive?: boolean;
237
237
  /** Space a canvas, bitmap or Blob is read in: 'srgb' or 'display-p3'; omitted, sRGB or the source's own. Pixels you pass say their own. */
@@ -260,8 +260,8 @@ export type VariantRequest = OutputSize & {/** As encode's effort. */ effort?: E
260
260
  export type VariantsOptions = EncodeOptions & {
261
261
  /** One entry per file wanted: its size, and its own effort, fidelity, JPEG policy or maxBytes. */
262
262
  outputs: readonly VariantRequest[]};
263
- /** rapier-jxl/upload's options: efforts 1-3 (default 3), 'exact' or a quality, with the full encoder's meanings. Lossy
264
- * float (HDR) samples, a GPU texture and firstRegion are rapier-jxl's: refused JXL_UNSUPPORTED. Upload runs on
263
+ /** jpegxl/upload's options: efforts 1-3 (default 3), 'exact' or a quality, with the full encoder's meanings. Lossy
264
+ * float (HDR) samples, a GPU texture and firstRegion are jpegxl's: refused JXL_UNSUPPORTED. Upload runs on
265
265
  * WebAssembly: it takes no webgpu. */
266
266
  export type UploadOptions = JobOptions & PreviewOptions & Described & Handed & {
267
267
  /** Encode a JPEG's decoded pixels without reconstruction data. Omitted, an unchanged 'exact' JPEG preserves the original file. */
@@ -289,13 +289,13 @@ export type AnimationOptions = JobOptions & PreviewOptions & Described & Handed
289
289
  effort?: Effort;
290
290
  /** Left out: use WebGPU where it helps. 'required' fails with JXL_WEBGPU without a WebGPU device, and at efforts 1-6 or exact, which run on WebAssembly. */
291
291
  webgpu?: 'required' | false};
292
- /** A capture's effort in rapier-jxl/capture (1-5); rapier-jxl/upload takes 1-3, and
293
- * rapier-jxl/capture-complete takes every Effort, 1-9. The root still encoder has no capture() export. */
292
+ /** A capture's effort in jpegxl/capture (1-5); jpegxl/upload takes 1-3, and
293
+ * jpegxl/capture-complete takes every Effort, 1-9. The root still encoder has no capture() export. */
294
294
  export type CaptureEffort = 1 | 2 | 3 | 4 | 5;
295
295
  /** A capture runs on WebAssembly; the pixels say their colorSpace, readAs reads a canvas, bitmap or Blob in a chosen one.
296
296
  * effort: 3 by default; higher is slower and smaller, with the same pixels at the same quality, and each effort writes its
297
297
  * own file. A module refuses an effort it does not carry (JXL_UNSUPPORTED) and names the module that does; every module
298
- * that carries an effort writes the same file for the same call. rapier-jxl/capture and upload's capture run on
298
+ * that carries an effort writes the same file for the same call. jpegxl/capture and upload's capture run on
299
299
  * WebAssembly and take no webgpu; capture-complete's is CapturePhotoOptions.webgpu. */
300
300
  export type CaptureOptions = JobOptions & PreviewOptions & Described & Handed & {
301
301
  /** 'exact' (default), or {maxError} 0 to 8: every sample within that many levels of the input. */
@@ -304,7 +304,7 @@ export type CaptureOptions = JobOptions & PreviewOptions & Described & Handed &
304
304
  effort?: CaptureEffort;
305
305
  /** Space a canvas, bitmap or Blob is read in: 'srgb' or 'display-p3'; omitted, sRGB or the source's own. Pixels you pass say their own. */
306
306
  readAs?: ReadAs};
307
- /** Photographic capture's options (rapier-jxl/capture-complete, efforts 1-9; rapier-jxl/upload's are UploadCaptureOptions). */
307
+ /** Photographic capture's options (jpegxl/capture-complete, efforts 1-9; jpegxl/upload's are UploadCaptureOptions). */
308
308
  /** Exact by default. A maxError is integer 0–8; quality 1–100 offers photographic capture, with 100 normalized to exact:
309
309
  * each photo gets its own coding, aimed at the measured SSIMULACRA 2 look that number names.
310
310
  * Fidelity is one exclusive choice. The picture itself continues to describe its samples. */
@@ -340,7 +340,7 @@ export type CapturePhotoOptions = Omit<CaptureOptions, 'fidelity' | 'effort'> &
340
340
  * solidText box over a photo is coded with the photo. rects: the boxes whose text was made transparent for certain. */
341
341
  withoutText?: CapturePixels & {rects?: ReadonlyArray<CaptureRect>};
342
342
  };
343
- /** rapier-jxl/upload's capture: efforts 1-3, as its encode. */
343
+ /** jpegxl/upload's capture: efforts 1-3, as its encode. */
344
344
  export type UploadCaptureOptions = Omit<CapturePhotoOptions, 'effort' | 'webgpu'> & {
345
345
  /** 1 (fastest) to 3 (smallest file). */
346
346
  effort?: 1 | 2 | 3};
@@ -404,7 +404,7 @@ export interface ImageHeader {
404
404
  * read no profile. */
405
405
  icc?: Uint8Array;
406
406
  }
407
- /** The header alone, read synchronously (rapier-jxl/metadata header): no metadata is read, so no maxMetadataBytes. */
407
+ /** The header alone, read synchronously (jpegxl/metadata header): no metadata is read, so no maxMetadataBytes. */
408
408
  export type HeaderOptions = Omit<InspectOptions, 'details' | 'decompress' | 'maxMetadataBytes'>;
409
409
  /** edit's changes: the metadata (exif, xmp, jumb; null removes, undefined keeps; compression) first, then the
410
410
  * container's framing (chunkSize, fragmentOrder, ...); the codestream and every other box stay exact. Caller metadata
@@ -450,7 +450,7 @@ export type DecodedImageOf<F> = F extends 'uint8' ? DecodedImage & {format: 'uin
450
450
  * closed); a job canceled through its signal rejects with that signal's reason, an AbortError DOMException unless you
451
451
  * passed one. Not done by this version: JXL_UNSUPPORTED, a valid request or file asking for
452
452
  * something this version does not do. The setup commands: JXL_SETUP (`add` or `remove` cannot change a project's files
453
- * safely; its message names the step to do by hand). Ours: JXL_INTERNAL (a fault in rapier-jxl itself). A code keeps its meaning through 8.x; a later 8.x may add one.
453
+ * safely; its message names the step to do by hand). Ours: JXL_INTERNAL (a fault in jpegxl itself). A code keeps its meaning through 8.x; a later 8.x may add one.
454
454
  */
455
455
  export type ErrorCode =
456
456
  | 'JXL_OPTIONS' | 'JXL_INPUT' | 'JXL_DIMENSIONS' | 'JXL_JPEG' | 'JXL_DECODE' | 'JXL_RECONSTRUCTION' | 'JXL_TARGET' | 'JXL_PLATFORM'
@@ -473,8 +473,9 @@ export type WorkerLike = {
473
473
  on(type: string, listener: (...args: any[]) => void): unknown;
474
474
  off(type: string, listener: (...args: any[]) => void): unknown;
475
475
  });
476
- /** A module's settings. Inside a worker of your own the module runs there, in place, and takes only helpers, webgpu
477
- * and maxPixels; the queue's settings (workerFactory, maxPendingBytes, ...) are refused. */
476
+ /** A module's settings. When it runs in place it accepts the same keys and validates the queue settings.
477
+ * maxPendingJobs bounds calls pending at once. No worker starts and no input is copied for a queue, so
478
+ * workerFactory, workerStartupTimeout and maxPendingBytes have no effect there. */
478
479
  export interface CodecConfig {
479
480
  /** Returns a fresh worker running this module's own file as its worker each time it is called: in a browser
480
481
  * `new Worker(url, {type: 'module', name: '<module> worker'})` (such as `'rapier-jxl/upload worker'`), in Node a worker
@@ -519,7 +520,7 @@ export interface CodecConfig {
519
520
  webgpu?: 'required' | false;
520
521
  }
521
522
 
522
- /** A host's JPEG XL decoder for measured capture where no browser decodes JPEG XL: rapier-jxl/decode's decode, or any
523
+ /** A host's JPEG XL decoder for measured capture where no browser decodes JPEG XL: jpegxl/decode's decode, or any
523
524
  * function answering the whole file in the asked color space, straight alpha. An sRGB file is asked for floats (straight RGB
524
525
  * or RGBA, 0 to 1); a decoder that gives none throws an error with code 'JXL_UNSUPPORTED' and is asked for 8-bit RGBA.
525
526
  * Hooks receive owned bytes and supplied options. */
@@ -527,10 +528,10 @@ type CapturePicture = {data: Uint8Array | Uint8ClampedArray | Float32Array, widt
527
528
  /** (bytes, {colorSpace, format, signal}) returning 8-bit RGBA, or floats where format is 'float32', with width and height. */
528
529
  export type CaptureDecoder = (bytes: Bytes, options: {colorSpace: 'srgb' | 'display-p3', format: 'uint8' | 'float32', signal?: AbortSignal}) =>
529
530
  CapturePicture | PromiseLike<CapturePicture>;
530
- /** A full decoded description; configureDecoder accepts rapier-jxl/decode's decode as it is. */
531
+ /** A full decoded description; configureDecoder accepts jpegxl/decode's decode as it is. */
531
532
  export type PackageDecode = (input: Bytes, options: DecodeOptions) => DecodedImage | PromiseLike<DecodedImage>;
532
- /** rapier-jxl/jpeg's restore: the JPEG a recompressed file holds. */
533
+ /** jpegxl/jpeg's restore: the JPEG a recompressed file holds. */
533
534
  type RestoredJPEG = Uint8Array | {bytes: Uint8Array} | import('./result.mjs').ImageResult;
534
535
  export type JpegRestore = (file: Bytes, options: {maxPixels?: number, signal?: AbortSignal}) => RestoredJPEG | PromiseLike<RestoredJPEG>;
535
- /** rapier-jxl/jpeg's recompress: how an encoder reads a JPEG where the host has none (Node, Deno, Bun). */
536
+ /** jpegxl/jpeg's recompress: how an encoder reads a JPEG where the host has none (Node, Deno, Bun). */
536
537
  export type JpegRecompress = (file: Bytes, options: {effort?: Effort, maxPixels?: number, signal?: AbortSignal}) => {bytes: Uint8Array | null} | PromiseLike<{bytes: Uint8Array | null}>;
@@ -10,7 +10,7 @@ export type {UploadCaptureOptions, CapturePhotoFidelity as CaptureFidelity} from
10
10
  export type {UploadPreparationInput, UploadFitOptions, UploadVariantRequest, UploadVariantsOptions, UploadPreparation} from './preparation-upload.mjs';
11
11
  /** The upload encoder in one file: a page's calls run in its own worker; calls in a worker, Node and edge hosts run in place: a File, Blob, canvas or pixels in; efforts 1-3. An exact, unchanged
12
12
  * JPEG preserves the original file; jpeg: 'pixels' requires pixel encoding instead.
13
- * `encode` from `rapier-jxl` writes the same file at the same effort, and runs efforts 4-9 too.
13
+ * `encode` from `jpegxl` writes the same file at the same effort, and runs efforts 4-9 too.
14
14
  * For JPEG input in Node, Deno or Bun, the setup call is configureDecoder, exported here as from the root entry.
15
15
  * Efforts 4-9 refuse JXL_UNSUPPORTED; passing webgpu refuses JXL_OPTIONS. */
16
16
  export function configureDecoder(decode: PackageDecode | null, restore?: JpegRestore | null, recompress?: JpegRecompress | null): void;
@@ -2,10 +2,10 @@ import type {AnimationInput, CaptureRect, ErrorCode, ImageInput, JobOptions, Rea
2
2
  import type {Digest, ImageResult, ResultOtherDecoders, ResultSource, ResultTransform} from './result.mjs';
3
3
 
4
4
  /** In a browser, direct verify() reads 8-bit sRGB and Display P3 stills with the browser's own JPEG XL decode, and direct
5
- * verify() in Node, Deno and Bun needs nothing. Resumable verification (rapier-jxl/resumable with verify), and elsewhere
5
+ * verify() in Node, Deno and Bun needs nothing. Resumable verification (jpegxl/resumable with verify), and elsewhere
6
6
  * for recompressed JPEGs, row sources, animations, more than 8 bits, float samples or
7
- * other color, the one setup step is `configureDecoder(decode, restore)` with rapier-jxl/decode's decode and
8
- * rapier-jxl/jpeg's restore; without it those refuse JXL_PLATFORM, naming it. One call serves every rapier-jxl module. */
7
+ * other color, the one setup step is `configureDecoder(decode, restore)` with jpegxl/decode's decode and
8
+ * jpegxl/jpeg's restore; without it those refuse JXL_PLATFORM, naming it. One call serves every jpegxl module. */
9
9
  export function configureDecoder(decode: PackageDecode | null, restore?: JpegRestore | null, recompress?: JpegRecompress | null): void;
10
10
 
11
11
  /** Explicit exact-pixel obligations in output-canvas coordinates, snapshotted at verify().
@@ -53,7 +53,7 @@ interface VerificationDetails {
53
53
  /** The record's measurements this verification did not measure (another metric, or a region): not vouched for. */
54
54
  readonly unchecked?: readonly {readonly metric: 'ssimulacra2' | 'max-error'; readonly region?: {readonly x: number; readonly y: number; readonly width: number; readonly height: number}}[];
55
55
  /** 'without-noise': the record's look was searched with the noise off, and `score` is the file's noise-off reading
56
- * (rapier-jxl/decode's alone gives it); 'pu21': a high dynamic range file read through PU21. */
56
+ * (jpegxl/decode's alone gives it); 'pu21': a high dynamic range file read through PU21. */
57
57
  readonly view?: 'pu21' | 'without-noise';
58
58
  /** Beside a noise-off reading: the decoded reading, what every decoder shows. */
59
59
  readonly decodedScore?: number;