@build-qube/papyra 0.0.4 → 0.1.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.
@@ -0,0 +1,49 @@
1
+ import { type PageImage as NativePageImage } from '@build-qube/papyra-native';
2
+ import { type EncodedImage, type EncodeOptions } from './encoded.js';
3
+ import type { RenderedPage } from './types.js';
4
+ export type { EncodedFormat, EncodedImage, EncodeOptions } from './encoded.js';
5
+ export { encodedImage, mimeType } from './encoded.js';
6
+ /**
7
+ * Encode a page you already hold — a cache hit, or one you have just painted.
8
+ *
9
+ * This copies the pixels back into Rust, because a `Uint8Array` points at the JS heap
10
+ * and cannot be held across the worker-thread boundary. When you do not also need the
11
+ * raw pixels, `doc.renderImage()` skips the round trip entirely.
12
+ */
13
+ export declare function encode(page: RenderedPage, options?: EncodeOptions): Promise<EncodedImage>;
14
+ /**
15
+ * A page held in Rust, encoded on demand.
16
+ *
17
+ * The pixels never cross into JS. A 42x30in drawing at 150 DPI is 6.5 MB raw and a
18
+ * fraction of that encoded, so for export the raw buffer is pure overhead. There is no
19
+ * accessor for it on purpose: use `renderPage` when you want pixels, this when you
20
+ * want a file.
21
+ */
22
+ export declare class PageImage {
23
+ #private;
24
+ constructor(inner: NativePageImage);
25
+ /** Output width in pixels. */
26
+ get width(): number;
27
+ /** Output height in pixels. */
28
+ get height(): number;
29
+ /** Size of the *raw* bitmap still held in Rust. Encoded output is much smaller. */
30
+ get byteLength(): number;
31
+ /** Encode to {@link EncodeOptions.format}, defaulting to WebP. */
32
+ encode(options?: EncodeOptions): Promise<EncodedImage>;
33
+ /** Lossless VP8L. The default, and ~3x smaller than PNG on page content. */
34
+ toWebp(options?: Omit<EncodeOptions, 'format' | 'quality'>): Promise<EncodedImage>;
35
+ /** Lossless PNG. Reach for it when the consumer cannot be trusted to read WebP. */
36
+ toPng(options?: Omit<EncodeOptions, 'format' | 'quality'>): Promise<EncodedImage>;
37
+ /**
38
+ * Lossy JPEG at `quality` (1-100, default 80).
39
+ *
40
+ * No alpha: transparent pixels composite onto white, matching how pages render.
41
+ */
42
+ toJpeg(quality?: number, options?: Omit<EncodeOptions, 'format'>): Promise<EncodedImage>;
43
+ /**
44
+ * Encode straight to a `data:` URL. Nothing but the finished string crosses the
45
+ * boundary — not the pixels, not the encoded bytes.
46
+ */
47
+ toDataUrl(options?: EncodeOptions): Promise<string>;
48
+ }
49
+ //# sourceMappingURL=encode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../src/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,IAAI,eAAe,EAClC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,aAAa,EAEnB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;;;GAMG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,YAAY,EAClB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAYvB;AAED;;;;;;;GAOG;AACH,qBAAa,SAAS;;IAGpB,YAAY,KAAK,EAAE,eAAe,EAEjC;IAED,8BAA8B;IAC9B,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,+BAA+B;IAC/B,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,mFAAmF;IACnF,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,kEAAkE;IAC5D,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAQ/D;IAED,4EAA4E;IAC5E,MAAM,CAAC,OAAO,GAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,SAAS,CAAM,yBAE7D;IAED,mFAAmF;IACnF,KAAK,CAAC,OAAO,GAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,SAAS,CAAM,yBAE5D;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAM,yBAEnE;IAED;;;OAGG;IACH,SAAS,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAMtD;CACF"}
package/dist/encode.js ADDED
@@ -0,0 +1,71 @@
1
+ import { encodeBitmap, } from '@build-qube/papyra-native';
2
+ import { encodedImage, } from './encoded.js';
3
+ export { encodedImage, mimeType } from './encoded.js';
4
+ /**
5
+ * Encode a page you already hold — a cache hit, or one you have just painted.
6
+ *
7
+ * This copies the pixels back into Rust, because a `Uint8Array` points at the JS heap
8
+ * and cannot be held across the worker-thread boundary. When you do not also need the
9
+ * raw pixels, `doc.renderImage()` skips the round trip entirely.
10
+ */
11
+ export async function encode(page, options = {}) {
12
+ const format = options.format ?? 'webp';
13
+ const bytes = await encodeBitmap(page.data, page.width, page.height, page.stride, format, options.quality, options.signal);
14
+ return encodedImage(bytes, format);
15
+ }
16
+ /**
17
+ * A page held in Rust, encoded on demand.
18
+ *
19
+ * The pixels never cross into JS. A 42x30in drawing at 150 DPI is 6.5 MB raw and a
20
+ * fraction of that encoded, so for export the raw buffer is pure overhead. There is no
21
+ * accessor for it on purpose: use `renderPage` when you want pixels, this when you
22
+ * want a file.
23
+ */
24
+ export class PageImage {
25
+ #inner;
26
+ constructor(inner) {
27
+ this.#inner = inner;
28
+ }
29
+ /** Output width in pixels. */
30
+ get width() {
31
+ return this.#inner.width;
32
+ }
33
+ /** Output height in pixels. */
34
+ get height() {
35
+ return this.#inner.height;
36
+ }
37
+ /** Size of the *raw* bitmap still held in Rust. Encoded output is much smaller. */
38
+ get byteLength() {
39
+ return this.#inner.byteLength;
40
+ }
41
+ /** Encode to {@link EncodeOptions.format}, defaulting to WebP. */
42
+ async encode(options = {}) {
43
+ const format = options.format ?? 'webp';
44
+ const bytes = await this.#inner.encode(format, options.quality, options.signal);
45
+ return encodedImage(bytes, format);
46
+ }
47
+ /** Lossless VP8L. The default, and ~3x smaller than PNG on page content. */
48
+ toWebp(options = {}) {
49
+ return this.encode({ ...options, format: 'webp' });
50
+ }
51
+ /** Lossless PNG. Reach for it when the consumer cannot be trusted to read WebP. */
52
+ toPng(options = {}) {
53
+ return this.encode({ ...options, format: 'png' });
54
+ }
55
+ /**
56
+ * Lossy JPEG at `quality` (1-100, default 80).
57
+ *
58
+ * No alpha: transparent pixels composite onto white, matching how pages render.
59
+ */
60
+ toJpeg(quality, options = {}) {
61
+ return this.encode({ ...options, format: 'jpeg', quality });
62
+ }
63
+ /**
64
+ * Encode straight to a `data:` URL. Nothing but the finished string crosses the
65
+ * boundary — not the pixels, not the encoded bytes.
66
+ */
67
+ toDataUrl(options = {}) {
68
+ return this.#inner.toDataUrl((options.format ?? 'webp'), options.quality, options.signal);
69
+ }
70
+ }
71
+ //# sourceMappingURL=encode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode.js","sourceRoot":"","sources":["../src/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAGb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,YAAY,GACb,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,IAAkB,EAClB,OAAO,GAAkB,EAAE;IAE3B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC;IACxC,MAAM,KAAK,GAAG,MAAM,YAAY,CAC9B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,EACX,MAAsB,EAC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E;QAClE,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,OAAO,GAAkB,EAAE;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAC1B,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAiB,EAC1C,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,MAAM,CACf,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The parts of encoding that touch no native code.
3
+ *
4
+ * Split from `encode.ts` because CI's `unit-test` job runs with no Rust toolchain and
5
+ * no build: anything `test/unit` imports must not pull in the addon, and `encode.ts`
6
+ * imports `encodeBitmap` as a value. See CLAUDE.md.
7
+ */
8
+ /**
9
+ * Containers papyra can write. All three encoders are pure Rust — that is what keeps
10
+ * the browser build free of a C toolchain — so there is no lossy WebP and no AVIF.
11
+ *
12
+ * - `webp` is lossless VP8L, and the default: on page content (line art, text, flat
13
+ * fills) it is ~3x smaller than PNG for roughly the same encode time.
14
+ * - `png` is the universal fallback.
15
+ * - `jpeg` is the only lossy option and the only one with a `quality` knob. It has no
16
+ * alpha channel; transparent pixels are composited onto white, matching how pages
17
+ * are rendered.
18
+ */
19
+ export type EncodedFormat = 'webp' | 'png' | 'jpeg';
20
+ /** MIME type for an encoded format, e.g. `'webp'` -> `'image/webp'`. */
21
+ export declare function mimeType(format: EncodedFormat): string;
22
+ /** Which container to write, and how hard to squeeze. */
23
+ export interface EncodeOptions {
24
+ /** Defaults to `'webp'`. */
25
+ format?: EncodedFormat;
26
+ /** JPEG only, 1-100. Defaults to 80. Ignored by the lossless formats. */
27
+ quality?: number;
28
+ /** Abort a request that has not started yet. */
29
+ signal?: AbortSignal;
30
+ }
31
+ /** Encoded bytes, plus the three ways you are likely to want to hand them to a browser. */
32
+ export interface EncodedImage {
33
+ /** The encoded file, ready to write to disk or upload. */
34
+ readonly bytes: Uint8Array;
35
+ /** The container {@link bytes} is written in. */
36
+ readonly format: EncodedFormat;
37
+ /** MIME type for {@link format}, so a caller never has to map it back. */
38
+ readonly mime: string;
39
+ /** Wrap as a `Blob`, ready for `URL.createObjectURL` or an upload. */
40
+ toBlob(): Blob;
41
+ /**
42
+ * An object URL for `<img src>`. Prefer this over {@link toDataUrl} in a browser:
43
+ * no base64 inflation, no multi-megabyte string on the heap, and the decoder reads
44
+ * straight from the blob.
45
+ *
46
+ * The caller owns the URL — `URL.revokeObjectURL` it when the image is gone.
47
+ */
48
+ toBlobUrl(): string;
49
+ /**
50
+ * A `data:` URL. For an `<img src>` this is the worse option; reach for it when the
51
+ * bytes must be embedded — CSS, serialised output, server-rendered HTML.
52
+ */
53
+ toDataUrl(): string;
54
+ }
55
+ /**
56
+ * Wrap already-encoded bytes as an {@link EncodedImage}.
57
+ *
58
+ * Exported for callers holding bytes from somewhere else — a cache, a fetch — that
59
+ * want the same `toBlob`/`toBlobUrl`/`toDataUrl` conveniences.
60
+ */
61
+ export declare function encodedImage(bytes: Uint8Array, format: EncodedFormat): EncodedImage;
62
+ //# sourceMappingURL=encoded.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoded.d.ts","sourceRoot":"","sources":["../src/encoded.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAQpD,wEAAwE;AACxE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAEtD;AAED,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,4BAA4B;IAC5B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,2FAA2F;AAC3F,MAAM,WAAW,YAAY;IAC3B,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,MAAM,IAAI,IAAI,CAAC;IACf;;;;;;OAMG;IACH,SAAS,IAAI,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,IAAI,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,aAAa,GACpB,YAAY,CAYd"}
@@ -0,0 +1,56 @@
1
+ const MIME = {
2
+ webp: 'image/webp',
3
+ png: 'image/png',
4
+ jpeg: 'image/jpeg',
5
+ };
6
+ /** MIME type for an encoded format, e.g. `'webp'` -> `'image/webp'`. */
7
+ export function mimeType(format) {
8
+ return MIME[format];
9
+ }
10
+ /**
11
+ * Wrap already-encoded bytes as an {@link EncodedImage}.
12
+ *
13
+ * Exported for callers holding bytes from somewhere else — a cache, a fetch — that
14
+ * want the same `toBlob`/`toBlobUrl`/`toDataUrl` conveniences.
15
+ */
16
+ export function encodedImage(bytes, format) {
17
+ const mime = MIME[format];
18
+ return {
19
+ bytes,
20
+ format,
21
+ mime,
22
+ toBlob: () => new Blob([detach(bytes)], { type: mime }),
23
+ toBlobUrl() {
24
+ return URL.createObjectURL(this.toBlob());
25
+ },
26
+ toDataUrl: () => `data:${mime};base64,${base64(bytes)}`,
27
+ };
28
+ }
29
+ /**
30
+ * Copy into a buffer `Blob` will accept.
31
+ *
32
+ * On the wasm build these bytes live in the module's shared linear memory, and
33
+ * `SharedArrayBuffer`-backed views are not valid `BlobPart`s. Copying unconditionally
34
+ * keeps both runtimes on one path; encoded output is small enough that it does not
35
+ * matter, which is exactly why `toImageData` cannot do the same trick cheaply.
36
+ */
37
+ function detach(bytes) {
38
+ const out = new Uint8Array(bytes.byteLength);
39
+ out.set(bytes);
40
+ return out;
41
+ }
42
+ function base64(bytes) {
43
+ const buf = globalThis.Buffer;
44
+ // Node's native base64 beats anything expressible in JS by a wide margin.
45
+ if (buf)
46
+ return buf.from(bytes).toString('base64');
47
+ // btoa wants a binary string, and spreading into fromCharCode overflows the stack
48
+ // somewhere north of 100k arguments. Chunk it.
49
+ let binary = '';
50
+ const chunk = 0x8000;
51
+ for (let i = 0; i < bytes.length; i += chunk) {
52
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
53
+ }
54
+ return btoa(binary);
55
+ }
56
+ //# sourceMappingURL=encoded.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoded.js","sourceRoot":"","sources":["../src/encoded.ts"],"names":[],"mappings":"AAoBA,MAAM,IAAI,GAAkC;IAC1C,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;CACnB,CAAC;AAEF,wEAAwE;AACxE,MAAM,UAAU,QAAQ,CAAC,MAAqB;IAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC;AAqCD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAiB,EACjB,MAAqB;IAErB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,OAAO;QACL,KAAK;QACL,MAAM;QACN,IAAI;QACJ,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACvD,SAAS;YACP,OAAO,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,IAAI,WAAW,MAAM,CAAC,KAAK,CAAC,EAAE;KACxD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,MAAM,CAAC,KAAiB;IAC/B,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC7C,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACf,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,MAAM,CAAC,KAAiB;IAC/B,MAAM,GAAG,GACP,UAGD,CAAC,MAAM,CAAC;IACT,0EAA0E;IAC1E,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEnD,kFAAkF;IAClF,+CAA+C;IAC/C,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,KAAK,GAAG,MAAM,CAAC;IACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;QAC7C,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -15,11 +15,19 @@
15
15
  */
16
16
  export type { CacheStats } from './cache.js';
17
17
  export { paintToCanvas, toImageData } from './canvas.js';
18
- export type { RenderHandle } from './document.js';
18
+ export type { ImageHandle, RenderHandle } from './document.js';
19
19
  export { Document, open } from './document.js';
20
+ export type { EncodedFormat, EncodedImage, EncodeOptions, } from './encode.js';
21
+ export { encode, encodedImage, mimeType, PageImage } from './encode.js';
22
+ export type { DestinationKind, OutlineDestination, OutlineNode, } from './outline.js';
23
+ export { buildOutlineTree, walkOutline } from './outline.js';
20
24
  export type { Runtime } from './runtime.js';
21
25
  export { backend, currentRuntime, hardwareConcurrency, init, } from './runtime.js';
22
26
  export type { JobHandle, JobTiming } from './scheduler.js';
23
27
  export { AbortError, DEFAULT_PRIORITY } from './scheduler.js';
24
- export type { OpenOptions, PageSize, PdfSource, RenderedPage, RenderOptions, StreamedPage, StreamOptions, } from './types.js';
28
+ export type { MatchOptions, SearchMatch } from './search.js';
29
+ export { findRanges, searchPageText } from './search.js';
30
+ export type { PageText, Quad, Rect, TextLine } from './text.js';
31
+ export { lineQuad, pageString, quadBounds, scaleQuad, } from './text.js';
32
+ export type { OpenOptions, PageSize, PdfSource, RenderedPage, RenderOptions, SearchOptions, StreamedPage, StreamOptions, } from './types.js';
25
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/C,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,IAAI,GACL,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,YAAY,EACV,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,GACd,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,YAAY,EAAE,UAAU,EAAE,M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ImageData } from './canvas.js';
17
17
  export { Document, open } from './document.js';
18
+ export { encode, encodedImage, mimeType, PageImage } from './encode.js';
19
+ export { buildOutlineTree, walkOutline } from './outline.js';
18
20
  export { backend, currentRuntime, hardwareConcurrency, init, } from './runtime.js';
19
21
  export { AbortError, DEFAULT_PRIORITY } from './scheduler.js';
22
+ export { findRanges, searchPageText } from './search.js';
23
+ export { lineQuad, pageString, quadBounds, scaleQuad, } from './text.js';
20
24
  //# 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;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EACL,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,IAAI,GACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAM/C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EACL,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,IAAI,GACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,GACV,MAAM,WAAW,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { OutlineEntry as NativeEntry } from '@build-qube/papyra-native';
2
+ /** How a destination positions the page in the window (PDF 32000-1, 12.3.2.2). */
3
+ export type DestinationKind = 'XYZ' | 'Fit' | 'FitH' | 'FitV' | 'FitR' | 'FitB' | 'FitBH' | 'FitBV';
4
+ /**
5
+ * Where an outline entry points.
6
+ *
7
+ * Coordinates are PDF points measured from the page's bottom-left corner — the same
8
+ * space as {@link PageSize} — so converting to rendered pixels is
9
+ * `(pt / 72) * dpi`. `null` means "leave this axis as it is", which is how the spec
10
+ * spells a destination that scrolls vertically but not horizontally.
11
+ */
12
+ export interface OutlineDestination {
13
+ /** 0-based page index. */
14
+ readonly page: number;
15
+ /** Which of the eight positioning modes the destination uses. */
16
+ readonly kind: DestinationKind;
17
+ /** Left edge, for `'XYZ'`, `'FitV'`, `'FitBV'` and `'FitR'`. */
18
+ readonly left: number | null;
19
+ /** Top edge, for `'XYZ'`, `'FitH'`, `'FitBH'` and `'FitR'`. */
20
+ readonly top: number | null;
21
+ /** Right edge. Only ever set for `'FitR'`. */
22
+ readonly right: number | null;
23
+ /** Bottom edge. Only ever set for `'FitR'`. */
24
+ readonly bottom: number | null;
25
+ /** Only ever set for `'XYZ'`. A zoom of 0 means "unchanged" and reads as `null`. */
26
+ readonly zoom: number | null;
27
+ }
28
+ /** A node in the document outline. */
29
+ export interface OutlineNode {
30
+ /** The entry's label, already decoded from UTF-16, UTF-8 or PDFDocEncoding. */
31
+ readonly title: string;
32
+ /**
33
+ * `null` for a container that groups children without pointing anywhere itself, and
34
+ * for entries whose action leaves this document (a URL, or another file).
35
+ */
36
+ readonly dest: OutlineDestination | null;
37
+ /** `dest.page`, hoisted — the only field most viewers need. */
38
+ readonly page: number | null;
39
+ /** The document asks for this title to be drawn bold. */
40
+ readonly bold: boolean;
41
+ /** The document asks for this title to be drawn italic. */
42
+ readonly italic: boolean;
43
+ /** The document asks for this node to start expanded. */
44
+ readonly open: boolean;
45
+ /** Nested entries, empty for a leaf. */
46
+ readonly children: OutlineNode[];
47
+ }
48
+ /**
49
+ * Rebuild the tree from the flat pre-order list the bindings return.
50
+ *
51
+ * A stack indexed by level is enough because pre-order guarantees a node's parent is
52
+ * the most recent node one level shallower. Levels that skip a step cannot come from
53
+ * our own walker, but are clamped rather than trusted — a malformed document should
54
+ * produce a flatter outline, not a crash.
55
+ */
56
+ export declare function buildOutlineTree(entries: readonly NativeEntry[]): OutlineNode[];
57
+ /** Walk an outline depth-first, yielding each node with its depth. */
58
+ export declare function walkOutline(nodes: readonly OutlineNode[], depth?: number): Generator<{
59
+ /** The entry. */
60
+ node: OutlineNode;
61
+ /** How deep it sits, 0 for a root. Useful as an indent. */
62
+ depth: number;
63
+ }>;
64
+ //# sourceMappingURL=outline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../src/outline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,YAAY,IAAI,WAAW,EAC5B,MAAM,2BAA2B,CAAC;AAEnC,kFAAkF;AAClF,MAAM,MAAM,eAAe,GACvB,KAAK,GACL,KAAK,GACL,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,OAAO,GACP,OAAO,CAAC;AAEZ;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,sCAAsC;AACtC,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;CAClC;AA+BD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,WAAW,EAAE,GAC9B,WAAW,EAAE,CAyBf;AAED,sEAAsE;AACtE,wBAAiB,WAAW,CAC1B,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,KAAK,SAAI,GACR,SAAS,CAAC;IACX,iBAAiB;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAKD"}
@@ -0,0 +1,67 @@
1
+ const KINDS = new Set([
2
+ 'XYZ',
3
+ 'Fit',
4
+ 'FitH',
5
+ 'FitV',
6
+ 'FitR',
7
+ 'FitB',
8
+ 'FitBH',
9
+ 'FitBV',
10
+ ]);
11
+ /** napi omits absent numbers rather than nulling them; normalise to one shape. */
12
+ function destination(dest) {
13
+ if (!dest)
14
+ return null;
15
+ return {
16
+ page: dest.page,
17
+ // Unknown view kinds are read as `Fit` in Rust, so this only guards against a
18
+ // binding and a wrapper that have drifted apart.
19
+ kind: (KINDS.has(dest.kind) ? dest.kind : 'Fit'),
20
+ left: dest.left ?? null,
21
+ top: dest.top ?? null,
22
+ right: dest.right ?? null,
23
+ bottom: dest.bottom ?? null,
24
+ zoom: dest.zoom ?? null,
25
+ };
26
+ }
27
+ /**
28
+ * Rebuild the tree from the flat pre-order list the bindings return.
29
+ *
30
+ * A stack indexed by level is enough because pre-order guarantees a node's parent is
31
+ * the most recent node one level shallower. Levels that skip a step cannot come from
32
+ * our own walker, but are clamped rather than trusted — a malformed document should
33
+ * produce a flatter outline, not a crash.
34
+ */
35
+ export function buildOutlineTree(entries) {
36
+ const roots = [];
37
+ const stack = [];
38
+ for (const entry of entries) {
39
+ const dest = destination(entry.dest);
40
+ const node = {
41
+ title: entry.title,
42
+ dest,
43
+ page: dest?.page ?? null,
44
+ bold: entry.bold,
45
+ italic: entry.italic,
46
+ open: entry.open,
47
+ children: [],
48
+ };
49
+ const level = Math.min(entry.level, stack.length);
50
+ stack.length = level;
51
+ const parent = stack[level - 1];
52
+ if (parent)
53
+ parent.children.push(node);
54
+ else
55
+ roots.push(node);
56
+ stack.push(node);
57
+ }
58
+ return roots;
59
+ }
60
+ /** Walk an outline depth-first, yielding each node with its depth. */
61
+ export function* walkOutline(nodes, depth = 0) {
62
+ for (const node of nodes) {
63
+ yield { node, depth };
64
+ yield* walkOutline(node.children, depth + 1);
65
+ }
66
+ }
67
+ //# sourceMappingURL=outline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outline.js","sourceRoot":"","sources":["../src/outline.ts"],"names":[],"mappings":"AA8DA,MAAM,KAAK,GAAG,IAAI,GAAG,CAAS;IAC5B,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;CACR,CAAC,CAAC;AAEH,kFAAkF;AAClF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AM,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAChC,IAAI,MAAM;YAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;YAClC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,sEAAsE;AACtE,MAAM,SAAS,CAAC,CAAC,WAAW,CAC1B,KAA6B,EAC7B,KAAK,GAAG,CAAC;IAOT,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACtB,KAAK,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
package/dist/runtime.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Which build is loaded: the native addon, or wasm in a browser.
3
+ *
4
+ * Worth branching on only for concurrency and memory. The rendering API is identical
5
+ * on both, which is the point of the library.
6
+ */
1
7
  export type Runtime = 'native' | 'wasm';
2
8
  /**
3
9
  * Useful concurrency ceiling on wasm.
@@ -9,7 +15,9 @@ export type Runtime = 'native' | 'wasm';
9
15
  export declare const MAX_WASM_CONCURRENCY = 4;
10
16
  /** Best guess at how many renders this host can genuinely run at once. */
11
17
  export declare function hardwareConcurrency(): number;
18
+ /** Which build is loaded. See {@link Runtime}. */
12
19
  export declare function currentRuntime(): Runtime;
20
+ /** The rendering engine and version behind this build, for diagnostics and bug reports. */
13
21
  export declare function backend(): string;
14
22
  /**
15
23
  * Prepare the rendering thread pool. Idempotent, and called automatically by
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAItC,0EAA0E;AAC1E,wBAAgB,mBAAmB,IAAI,MAAM,CAY5C;AAED,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,IAAI,CAS7D"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAItC,0EAA0E;AAC1E,wBAAgB,mBAAmB,IAAI,MAAM,CAY5C;AAED,kDAAkD;AAClD,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED,2FAA2F;AAC3F,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,IAAI,CAS7D"}
package/dist/runtime.js CHANGED
@@ -22,9 +22,11 @@ export function hardwareConcurrency() {
22
22
  const fromEnv = Number(proc?.env?.PAPYRA_THREADS);
23
23
  return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : 4;
24
24
  }
25
+ /** Which build is loaded. See {@link Runtime}. */
25
26
  export function currentRuntime() {
26
27
  return runtime() === 'wasm' ? 'wasm' : 'native';
27
28
  }
29
+ /** The rendering engine and version behind this build, for diagnostics and bug reports. */
28
30
  export function backend() {
29
31
  return backendName();
30
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAC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CAAC,OAAO,IAAI,mBAAmB,EAAE,EAAE,SAAS,CAAC,CAAC;IAC3E,CAAC;IAAC,MAAM,CAAC;QACP,yEAAyE;IAC3E,CAAC;AACH,CAAC"}
@@ -26,7 +26,9 @@ export interface JobTiming {
26
26
  /** Started until it finished. */
27
27
  runMs: number;
28
28
  }
29
+ /** A submitted job: its result, its timings, and the two ways to change its fate. */
29
30
  export interface JobHandle<T> {
31
+ /** The coalescing key. Two live requests sharing one render share this. */
30
32
  readonly key: string;
31
33
  /**
32
34
  * Populated once the job settles, `null` before that.
@@ -38,6 +40,7 @@ export interface JobHandle<T> {
38
40
  readonly timing: JobTiming | null;
39
41
  /** Reassign urgency while the job is still pending. A no-op once it is running. */
40
42
  setPriority(priority: number): void;
43
+ /** Resolves with the result, or rejects with {@link AbortError} if cancelled first. */
41
44
  readonly promise: Promise<T>;
42
45
  /**
43
46
  * Detach from this job. If nothing else is waiting on it and it has not started,
@@ -45,7 +48,14 @@ export interface JobHandle<T> {
45
48
  */
46
49
  cancel(reason?: string): void;
47
50
  }
51
+ /**
52
+ * Rejection reason for a job dropped before it started.
53
+ *
54
+ * Named `'AbortError'` to match `DOMException`, so existing `err.name === 'AbortError'`
55
+ * checks keep working across the two runtimes without a papyra-specific branch.
56
+ */
48
57
  export declare class AbortError extends Error {
58
+ /** Always `'AbortError'`. */
49
59
  readonly name = "AbortError";
50
60
  constructor(reason?: string);
51
61
  }
@@ -63,13 +73,21 @@ export interface SchedulerOptions {
63
73
  */
64
74
  yieldToUrgent?: boolean;
65
75
  }
66
- export declare class Scheduler<T> {
76
+ /**
77
+ * One queue for every kind of work a document does.
78
+ *
79
+ * Deliberately not parameterised by payload: renders and text extraction compete for
80
+ * the same cores, so they have to share a queue for priority to mean anything. Entries
81
+ * are stored opaquely and `submit` recovers the type — sound because coalescing is by
82
+ * key, and two jobs with the same key are by construction the same job.
83
+ */
84
+ export declare class Scheduler {
67
85
  #private;
68
86
  constructor(limit: number, options?: SchedulerOptions);
69
87
  get pendingCount(): number;
70
88
  get runningCount(): number;
71
89
  /** How long the longest-waiting pending job has been queued. */
72
90
  get oldestWaitMs(): number;
73
- submit(job: SchedulerJob<T>): JobHandle<T>;
91
+ submit<T>(job: SchedulerJob<T>): JobHandle<T>;
74
92
  }
75
93
  //# sourceMappingURL=scheduler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,qFAAqF;IACrF,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;CACvB;AAED,mDAAmD;AACnD,MAAM,WAAW,SAAS;IACxB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IAClC,mFAAmF;IACnF,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7B;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAkBD,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAkB,IAAI,gBAAgB;IACtC,YAAY,MAAM,SAAc,EAE/B;CACF;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,qBA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BAA6B;IAC7B,SAAkB,IAAI,gBAAgB;IACtC,YAAY,MAAM,SAAc,EAE/B;CACF;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,qBAAa,SAAS;;IAOpB,YAAY,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,EAGxD;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IASD,gEAAgE;IAChE,IAAI,YAAY,IAAI,MAAM,CAOzB;IAED,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAkC5C;CAgFF"}
package/dist/scheduler.js CHANGED
@@ -13,12 +13,27 @@
13
13
  */
14
14
  /** Runs first. Lower is more urgent; the default is the most urgent tier. */
15
15
  export const DEFAULT_PRIORITY = 0;
16
+ /**
17
+ * Rejection reason for a job dropped before it started.
18
+ *
19
+ * Named `'AbortError'` to match `DOMException`, so existing `err.name === 'AbortError'`
20
+ * checks keep working across the two runtimes without a papyra-specific branch.
21
+ */
16
22
  export class AbortError extends Error {
23
+ /** Always `'AbortError'`. */
17
24
  name = 'AbortError';
18
25
  constructor(reason = 'cancelled') {
19
26
  super(reason);
20
27
  }
21
28
  }
29
+ /**
30
+ * One queue for every kind of work a document does.
31
+ *
32
+ * Deliberately not parameterised by payload: renders and text extraction compete for
33
+ * the same cores, so they have to share a queue for priority to mean anything. Entries
34
+ * are stored opaquely and `submit` recovers the type — sound because coalescing is by
35
+ * key, and two jobs with the same key are by construction the same job.
36
+ */
22
37
  export class Scheduler {
23
38
  #limit;
24
39
  #yieldToUrgent;
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,6EAA6E;AAC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