@build-qube/papyra 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +12 -1
  2. package/dist/attachments.d.ts +6 -1
  3. package/dist/attachments.d.ts.map +1 -1
  4. package/dist/attachments.js +6 -1
  5. package/dist/attachments.js.map +1 -1
  6. package/dist/cache.d.ts +5 -0
  7. package/dist/cache.d.ts.map +1 -1
  8. package/dist/cache.js +8 -0
  9. package/dist/cache.js.map +1 -1
  10. package/dist/canvas.d.ts +2 -2
  11. package/dist/canvas.d.ts.map +1 -1
  12. package/dist/canvas.js +20 -7
  13. package/dist/canvas.js.map +1 -1
  14. package/dist/core.d.ts +57 -0
  15. package/dist/core.d.ts.map +1 -0
  16. package/dist/core.js +40 -0
  17. package/dist/core.js.map +1 -0
  18. package/dist/document.d.ts +28 -20
  19. package/dist/document.d.ts.map +1 -1
  20. package/dist/document.js +79 -360
  21. package/dist/document.js.map +1 -1
  22. package/dist/engine.d.ts +327 -0
  23. package/dist/engine.d.ts.map +1 -0
  24. package/dist/engine.js +485 -0
  25. package/dist/engine.js.map +1 -0
  26. package/dist/errors.d.ts +2 -1
  27. package/dist/errors.d.ts.map +1 -1
  28. package/dist/errors.js +2 -1
  29. package/dist/errors.js.map +1 -1
  30. package/dist/fingerprint.d.ts +2 -1
  31. package/dist/fingerprint.d.ts.map +1 -1
  32. package/dist/fingerprint.js +2 -1
  33. package/dist/fingerprint.js.map +1 -1
  34. package/dist/index.d.ts +6 -31
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +5 -14
  37. package/dist/index.js.map +1 -1
  38. package/dist/links.d.ts +6 -1
  39. package/dist/links.d.ts.map +1 -1
  40. package/dist/links.js +6 -1
  41. package/dist/links.js.map +1 -1
  42. package/dist/office.d.ts +85 -0
  43. package/dist/office.d.ts.map +1 -0
  44. package/dist/office.js +135 -0
  45. package/dist/office.js.map +1 -0
  46. package/dist/papyra-engine.d.ts +68 -0
  47. package/dist/papyra-engine.d.ts.map +1 -0
  48. package/dist/papyra-engine.js +173 -0
  49. package/dist/papyra-engine.js.map +1 -0
  50. package/dist/runtime.d.ts +7 -0
  51. package/dist/runtime.d.ts.map +1 -1
  52. package/dist/runtime.js +11 -0
  53. package/dist/runtime.js.map +1 -1
  54. package/dist/scheduler.d.ts +10 -2
  55. package/dist/scheduler.d.ts.map +1 -1
  56. package/dist/scheduler.js +26 -7
  57. package/dist/scheduler.js.map +1 -1
  58. package/dist/sheets.d.ts +160 -0
  59. package/dist/sheets.d.ts.map +1 -0
  60. package/dist/sheets.js +153 -0
  61. package/dist/sheets.js.map +1 -0
  62. package/dist/source.d.ts +1 -1
  63. package/dist/source.js +1 -1
  64. package/dist/text.d.ts +6 -1
  65. package/dist/text.d.ts.map +1 -1
  66. package/dist/text.js +6 -1
  67. package/dist/text.js.map +1 -1
  68. package/dist/tiff-image.d.ts +97 -0
  69. package/dist/tiff-image.d.ts.map +1 -0
  70. package/dist/tiff-image.js +65 -0
  71. package/dist/tiff-image.js.map +1 -0
  72. package/dist/tiff.d.ts +2 -73
  73. package/dist/tiff.d.ts.map +1 -1
  74. package/dist/tiff.js +4 -53
  75. package/dist/tiff.js.map +1 -1
  76. package/dist/types.d.ts +22 -2
  77. package/dist/types.d.ts.map +1 -1
  78. package/dist/workbook.d.ts +3 -134
  79. package/dist/workbook.d.ts.map +1 -1
  80. package/dist/workbook.js +6 -141
  81. package/dist/workbook.js.map +1 -1
  82. package/package.json +24 -3
package/dist/index.js CHANGED
@@ -14,20 +14,11 @@
14
14
  * onScroll(() => job.setPriority(0));
15
15
  * ```
16
16
  */
17
- export { attachmentMediaType, isInvoiceAttachment, } from './attachments.js';
18
- export { paintToCanvas, toImageData } from './canvas.js';
19
- export { CellWindow, columnName } from './cells.js';
17
+ export * from './core.js';
20
18
  export { Document, open } from './document.js';
21
- export { encode, encodedImage, mimeType, PageImage, svgPage, } from './encode.js';
22
- export { EncryptedWorkbookError, IncorrectPasswordError, PasswordError, PasswordRequiredError, } from './errors.js';
23
- export { buildOutlineTree, walkOutline } from './outline.js';
19
+ export { encode, PageImage } from './encode.js';
20
+ export { defaultPdfEngine, PapyraEngine } from './papyra-engine.js';
24
21
  export { backend, currentRuntime, hardwareConcurrency, init, } from './runtime.js';
25
- export { AbortError, DEFAULT_PRIORITY } from './scheduler.js';
26
- export { findRanges, searchPageText } from './search.js';
27
- export { buildStructTree, readingOrder, structuredPageString, walkStructTree, } from './structure.js';
28
- export { cssColor } from './styles.js';
29
- export { lineQuad, pageString, quadBounds, scaleQuad, scaleRect, } from './text.js';
30
- export { openTiff, TIFF_MAX_PIXELS, TiffImage } from './tiff.js';
31
- export { rotatePage, rotateSize, viewport, viewportQuad, viewportRect, } from './viewport.js';
32
- export { openWorkbook, Sheet, Workbook } from './workbook.js';
22
+ export { openTiff } from './tiff.js';
23
+ export { openWorkbook } from './workbook.js';
33
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;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAazD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAQ/C,OAAO,EACL,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAOrB,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;AAMzD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,cAAc,GACf,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,GACV,MAAM,WAAW,CAAC;AAMnB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAcjE,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC;AASvB,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAc,WAAW,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEpE,OAAO,EACL,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,IAAI,GACL,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
package/dist/links.d.ts CHANGED
@@ -48,6 +48,11 @@ export interface PageLink {
48
48
  /** The annotation's tooltip, when it has one. */
49
49
  readonly alt: string | null;
50
50
  }
51
- /** @internal */
51
+ /**
52
+ * A link as the bindings report it, as a {@link PageLink}; null when it has no target.
53
+ *
54
+ * Exported for engines whose host answers in the native bindings' shapes, as
55
+ * `tauri-plugin-papyra` does, so they normalise exactly as papyra's own engine does.
56
+ */
52
57
  export declare function toPageLink(native: NativePageLink): PageLink | null;
53
58
  //# sourceMappingURL=links.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,KAAK,kBAAkB,EAAiB,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,GAClB;IACE,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;CACnC,GACD;IACE;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,iDAAiD;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEN;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,gBAAgB;AAChB,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI,CAelE"}
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,KAAK,kBAAkB,EAAiB,MAAM,cAAc,CAAC;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,GAClB;IACE,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;CACnC,GACD;IACE;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,iDAAiD;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEN;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,GAAG,IAAI,CAelE"}
package/dist/links.js CHANGED
@@ -1,5 +1,10 @@
1
1
  import { toDestination } from './outline.js';
2
- /** @internal */
2
+ /**
3
+ * A link as the bindings report it, as a {@link PageLink}; null when it has no target.
4
+ *
5
+ * Exported for engines whose host answers in the native bindings' shapes, as
6
+ * `tauri-plugin-papyra` does, so they normalise exactly as papyra's own engine does.
7
+ */
3
8
  export function toPageLink(native) {
4
9
  const target = linkTarget(native);
5
10
  // The bindings only emit a link with one target or the other, so this is
package/dist/links.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"links.js","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,aAAa,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Z,CAAC,EAAE,MAAM,CAAC,EAAE;YACZ,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE;YAC5B,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE;SAC9B;QACD,MAAM;QACN,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,IAAI;KACxB,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,MAAsB;IACxC,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;IACtE,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC"}
@@ -0,0 +1,85 @@
1
+ import type { OfficeDocument as NativeOfficeDocument } from '@build-qube/papyra-office-native';
2
+ import { type Availability, type BackendRenderOptions, type PagedBackend, type PagedDoc, PagedEngine } from './engine.js';
3
+ import type { OpenOptions, PageSize, PdfSource, RenderedPage } from './types.js';
4
+ /** What an office file is: a Word document, or a PowerPoint deck. */
5
+ export type OfficeKind = 'word' | 'slides';
6
+ /** An open Word document or PowerPoint deck. Get one from {@link PapyraOfficeEngine.open}. */
7
+ export interface OfficeDoc extends PagedDoc {
8
+ /** `'word'` or `'slides'`. Pages in a document, slides in a deck — hidden ones too. */
9
+ readonly kind: OfficeKind;
10
+ }
11
+ /** The addon's document, as a {@link PagedBackend}. */
12
+ declare class OfficeBackend implements PagedBackend {
13
+ #private;
14
+ readonly kind: OfficeKind;
15
+ readonly pageCount: number;
16
+ readonly capabilities: import("./engine.js").Capabilities;
17
+ readonly concurrency = 4;
18
+ constructor(native: NativeOfficeDocument);
19
+ /**
20
+ * Page size in points (1/72 inch). Every slide in a deck shares one size; a Word
21
+ * document's sections may each set their own.
22
+ */
23
+ pageSize(index: number): PageSize;
24
+ /** `annotations` does not apply: an office page has none to switch off. */
25
+ renderPage(index: number, { dpi }: BackendRenderOptions): Promise<RenderedPage>;
26
+ /**
27
+ * Free the laid-out document in the wasm heap now, not whenever the wrapper is
28
+ * collected: a deck's model can be large, and growing a shared heap while workers
29
+ * run is the trap the addon pre-grows its heap to avoid.
30
+ */
31
+ close(): void;
32
+ }
33
+ /**
34
+ * Word documents (`.docx`, `.docm`, `.dotx`, `.dotm`) and PowerPoint decks (`.pptx`,
35
+ * `.potx`, `.ppsx` and their macro-enabled twins), laid out and drawn by papyra in
36
+ * Rust over WordCraft and DeckCraft.
37
+ *
38
+ * A {@link PagedEngine}, so renders get the same priority queue, coalescing,
39
+ * byte-bounded cache and `fitWidth` sizing a PDF's do, and a page column written for
40
+ * PDFs shows these unchanged. Pages only: no text, links or outline.
41
+ *
42
+ * A file is recognised by its declared main part, not its name, so a renamed
43
+ * workbook or plain zip is refused. A Word document is paginated once, while
44
+ * opening. The office addon is its own wasm module — about 5.7 MB gzipped — fetched
45
+ * by the first open or font, so importing `/office` costs nothing until then.
46
+ *
47
+ * Experimental: the engines are young, and a real-world file may lay out differently
48
+ * from Office.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * await officeEngine.addFont(await (await fetch('/fonts/Carlito-Regular.ttf')).bytes());
53
+ * const doc = await officeEngine.open(file);
54
+ * paintToCanvas(await officeEngine.render(doc, 0, { fitWidth: 1200 }).promise, canvas);
55
+ * ```
56
+ */
57
+ export declare class PapyraOfficeEngine extends PagedEngine<OfficeDoc, OfficeBackend> {
58
+ readonly id = "papyra-office";
59
+ /**
60
+ * Make a TrueType or OpenType font available to the Word and PowerPoint layout,
61
+ * for every document opened **after** this call.
62
+ *
63
+ * A document names fonts like Calibri that cannot be shipped, so each engine
64
+ * substitutes — and a substitute with different widths moves every line break after
65
+ * it. Carlito, Caladea and Liberation Sans/Serif are metric-compatible with Calibri,
66
+ * Cambria and Arial/Times New Roman, and both engines already prefer them by name. A
67
+ * browser has no system fonts at all, so without this, Word text falls back to
68
+ * Source Sans and slide text to Ubuntu Light.
69
+ *
70
+ * On the engine because fonts belong to whatever runs the layout: this wasm module
71
+ * here, a host process for another engine. Fetches the module if no document has
72
+ * yet. Resolves to how many faces were added: 0 when the bytes are not a font, or
73
+ * when every face in them was already registered.
74
+ */
75
+ addFont(source: PdfSource): Promise<number>;
76
+ availability(): Availability;
77
+ /** @internal Its backend type is private to this file, as is `handle`'s. */
78
+ protected load(source: PdfSource, _options: OpenOptions): Promise<OfficeBackend>;
79
+ /** @internal */
80
+ protected handle(backend: OfficeBackend): OfficeDoc;
81
+ }
82
+ /** The office engine, shared so every view opens into one queue per document. */
83
+ export declare const officeEngine: PapyraOfficeEngine;
84
+ export {};
85
+ //# sourceMappingURL=office.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"office.d.ts","sourceRoot":"","sources":["../src/office.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC/F,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,WAAW,EAEZ,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3C,8FAA8F;AAC9F,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,uFAAuF;IACvF,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B;AAuBD,uDAAuD;AACvD,cAAM,aAAc,YAAW,YAAY;;IACzC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,qCAAe;IACpC,QAAQ,CAAC,WAAW,KAAe;IAGnC,YAAY,MAAM,EAAE,oBAAoB,EAIvC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAEhC;IAED,2EAA2E;IAC3E,UAAU,CACR,KAAK,EAAE,MAAM,EACb,EAAE,GAAG,EAAE,EAAE,oBAAoB,GAC5B,OAAO,CAAC,YAAY,CAAC,CAEvB;IAED;;;;OAIG;IACH,KAAK,IAAI,IAAI,CAEZ;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,kBAAmB,SAAQ,WAAW,CAAC,SAAS,EAAE,aAAa,CAAC;IAC3E,QAAQ,CAAC,EAAE,mBAAmB;IAE9B;;;;;;;;;;;;;;;OAeG;IACG,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAMhD;IAED,YAAY,IAAI,YAAY,CAY3B;IAED,4EAA4E;IAC5E,UAAgB,IAAI,CAClB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,WAAW,GACpB,OAAO,CAAC,aAAa,CAAC,CAMxB;IAED,gBAAgB;IAChB,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,CAQlD;CACF;AAED,iFAAiF;AACjF,eAAO,MAAM,YAAY,EAAE,kBACe,CAAC"}
package/dist/office.js ADDED
@@ -0,0 +1,135 @@
1
+ import { PagedEngine, RENDER_ONLY, } from './engine.js';
2
+ import { toBytes } from './source.js';
3
+ /**
4
+ * Renders in flight at once. napi-rs runs an addon's async work on a pool of four in
5
+ * the browser, so more only queues inside the glue, where priority cannot reach it.
6
+ */
7
+ const CONCURRENCY = 4;
8
+ /** The addon once loaded. Process-wide, like the addon itself. */
9
+ let native;
10
+ function loadNative() {
11
+ native ??= import('@build-qube/papyra-office-native').catch((e) => {
12
+ // A failed fetch of a 5.7 MB module is often transient: let the next open retry
13
+ // rather than leave office disabled until a reload.
14
+ native = undefined;
15
+ throw e;
16
+ });
17
+ return native;
18
+ }
19
+ /** The addon's document, as a {@link PagedBackend}. */
20
+ class OfficeBackend {
21
+ kind;
22
+ pageCount;
23
+ capabilities = RENDER_ONLY;
24
+ concurrency = CONCURRENCY;
25
+ #native;
26
+ constructor(native) {
27
+ this.#native = native;
28
+ this.kind = native.kind;
29
+ this.pageCount = native.pageCount;
30
+ }
31
+ /**
32
+ * Page size in points (1/72 inch). Every slide in a deck shares one size; a Word
33
+ * document's sections may each set their own.
34
+ */
35
+ pageSize(index) {
36
+ return this.#native.pageSize(index);
37
+ }
38
+ /** `annotations` does not apply: an office page has none to switch off. */
39
+ renderPage(index, { dpi }) {
40
+ return this.#native.renderPage(index, dpi / 72);
41
+ }
42
+ /**
43
+ * Free the laid-out document in the wasm heap now, not whenever the wrapper is
44
+ * collected: a deck's model can be large, and growing a shared heap while workers
45
+ * run is the trap the addon pre-grows its heap to avoid.
46
+ */
47
+ close() {
48
+ this.#native.close();
49
+ }
50
+ }
51
+ /**
52
+ * Word documents (`.docx`, `.docm`, `.dotx`, `.dotm`) and PowerPoint decks (`.pptx`,
53
+ * `.potx`, `.ppsx` and their macro-enabled twins), laid out and drawn by papyra in
54
+ * Rust over WordCraft and DeckCraft.
55
+ *
56
+ * A {@link PagedEngine}, so renders get the same priority queue, coalescing,
57
+ * byte-bounded cache and `fitWidth` sizing a PDF's do, and a page column written for
58
+ * PDFs shows these unchanged. Pages only: no text, links or outline.
59
+ *
60
+ * A file is recognised by its declared main part, not its name, so a renamed
61
+ * workbook or plain zip is refused. A Word document is paginated once, while
62
+ * opening. The office addon is its own wasm module — about 5.7 MB gzipped — fetched
63
+ * by the first open or font, so importing `/office` costs nothing until then.
64
+ *
65
+ * Experimental: the engines are young, and a real-world file may lay out differently
66
+ * from Office.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * await officeEngine.addFont(await (await fetch('/fonts/Carlito-Regular.ttf')).bytes());
71
+ * const doc = await officeEngine.open(file);
72
+ * paintToCanvas(await officeEngine.render(doc, 0, { fitWidth: 1200 }).promise, canvas);
73
+ * ```
74
+ */
75
+ export class PapyraOfficeEngine extends PagedEngine {
76
+ id = 'papyra-office';
77
+ /**
78
+ * Make a TrueType or OpenType font available to the Word and PowerPoint layout,
79
+ * for every document opened **after** this call.
80
+ *
81
+ * A document names fonts like Calibri that cannot be shipped, so each engine
82
+ * substitutes — and a substitute with different widths moves every line break after
83
+ * it. Carlito, Caladea and Liberation Sans/Serif are metric-compatible with Calibri,
84
+ * Cambria and Arial/Times New Roman, and both engines already prefer them by name. A
85
+ * browser has no system fonts at all, so without this, Word text falls back to
86
+ * Source Sans and slide text to Ubuntu Light.
87
+ *
88
+ * On the engine because fonts belong to whatever runs the layout: this wasm module
89
+ * here, a host process for another engine. Fetches the module if no document has
90
+ * yet. Resolves to how many faces were added: 0 when the bytes are not a font, or
91
+ * when every face in them was already registered.
92
+ */
93
+ async addFont(source) {
94
+ const [{ addFont }, bytes] = await Promise.all([
95
+ loadNative(),
96
+ toBytes(source),
97
+ ]);
98
+ return addFont(bytes);
99
+ }
100
+ availability() {
101
+ // `undefined` outside a browser (Node, Bun), where the native addon needs nothing.
102
+ if (globalThis.crossOriginIsolated !== false)
103
+ return { ok: true };
104
+ return {
105
+ ok: false,
106
+ title: 'This page is not cross-origin isolated',
107
+ reason: 'papyra renders Word and PowerPoint in WebAssembly with shared memory, ' +
108
+ 'which needs SharedArrayBuffer. Serve this page with ' +
109
+ 'Cross-Origin-Opener-Policy: same-origin and ' +
110
+ 'Cross-Origin-Embedder-Policy: require-corp, then reload.',
111
+ };
112
+ }
113
+ /** @internal Its backend type is private to this file, as is `handle`'s. */
114
+ async load(source, _options) {
115
+ const [{ loadOffice }, bytes] = await Promise.all([
116
+ loadNative(),
117
+ toBytes(source),
118
+ ]);
119
+ return new OfficeBackend(await loadOffice(bytes));
120
+ }
121
+ /** @internal */
122
+ handle(backend) {
123
+ return {
124
+ engine: this.id,
125
+ kind: backend.kind,
126
+ pageCount: backend.pageCount,
127
+ pageSize: (index) => backend.pageSize(index),
128
+ capabilities: backend.capabilities,
129
+ };
130
+ }
131
+ }
132
+ /** The office engine, shared so every view opens into one queue per document. */
133
+ export const officeEngine =
134
+ /* @__PURE__ */ new PapyraOfficeEngine();
135
+ //# sourceMappingURL=office.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"office.js","sourceRoot":"","sources":["../src/office.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAiBtC;;;GAGG;AACH,MAAM,WAAW,GAAG,CAAC,CAAC;AAItB,kEAAkE;AAClE,IAAI,MAAmC,CAAC;AAExC,SAAS,UAAU;IACjB,MAAM,KAAK,MAAM,CAAC,kCAAkC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE;QACzE,gFAAgF;QAChF,oDAAoD;QACpD,MAAM,GAAG,SAAS,CAAC;QACnB,MAAM,CAAC,CAAC;IACV,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,uDAAuD;AACvD,MAAM,aAAa;IACR,IAAI,CAAa;IACjB,SAAS,CAAS;IAClB,YAAY,GAAG,WAAW,CAAC;IAC3B,WAAW,GAAG,WAAW,CAAC;IAC1B,OAAO,CAAuB;IAEvC,YAAY,MAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAkB,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,KAAa;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,2EAA2E;IAC3E,UAAU,CACR,KAAa,EACb,EA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,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC5C,YAAY,EAAE,OAAO,CAAC,YAAY;SACnC,CAAC;IACJ,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,CAAC,MAAM,YAAY;AACvB,eAAe,CAAC,IAAI,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { PdfDocument as NativeDocument } from '@build-qube/papyra-native';
2
+ import { type Attachment } from './attachments.js';
3
+ import type { Document } from './document.js';
4
+ import { type Availability, type BackendRenderOptions, type Capabilities, type PdfBackend, PdfEngine } from './engine.js';
5
+ import { type PageLink } from './links.js';
6
+ import { type OutlineNode } from './outline.js';
7
+ import { type StructNode } from './structure.js';
8
+ import { type PageText } from './text.js';
9
+ import type { DocumentMetadata, OpenOptions, PageSize, PdfSource, RenderedPage } from './types.js';
10
+ /**
11
+ * papyra's own engine: hayro, compiled into the native addon in Node and into wasm in
12
+ * a browser. Imported from `@build-qube/papyra/engine` (or the main entry), never from
13
+ * `/core`, so an app that never names it ships none of its wasm.
14
+ *
15
+ * Constructing one loads nothing. The addon — in a browser, a wasm module of about
16
+ * 2.5 MB — is fetched by the first {@link PagedEngine.open}, which is what lets a
17
+ * bundle that names this engine as a default still cost nothing until a PDF opens.
18
+ *
19
+ * In a browser it needs a cross-origin-isolated page: the wasm build uses shared
20
+ * memory, and so needs `SharedArrayBuffer`. {@link availability} says so.
21
+ */
22
+ export declare class PapyraEngine extends PdfEngine {
23
+ readonly id = "papyra";
24
+ availability(): Availability;
25
+ /**
26
+ * Opens to a `Document`, which is a `PdfDoc` like any engine's handle and
27
+ * also carries papyra's extras — `renderImage`, `renderSvg`, `cache` — so code that
28
+ * knows it has papyra's engine can reach them with an `instanceof` check.
29
+ */
30
+ open(source: PdfSource, options?: OpenOptions): Promise<Document>;
31
+ protected load(source: PdfSource, options: OpenOptions): Promise<PdfBackend>;
32
+ }
33
+ /**
34
+ * The engine `open()` and `Document` go through, and the one a viewer falls back
35
+ * to when the app names none. Being one instance is the point: a document belongs to
36
+ * the engine that opened it, so a `Document` from `open()` and a viewer's default
37
+ * engine have to be the same object for the viewer's commands to accept it.
38
+ *
39
+ * Costs nothing until a document opens, like any {@link PapyraEngine}.
40
+ */
41
+ export declare const defaultPdfEngine: PapyraEngine;
42
+ /**
43
+ * The addon's document, as a {@link PdfBackend}. Every napi shape is normalised
44
+ * here, so nothing past this class sees one.
45
+ *
46
+ * @internal Exported for `Document`, whose export-only methods call the addon
47
+ * directly.
48
+ */
49
+ export declare class PapyraBackend implements PdfBackend {
50
+ readonly native: NativeDocument;
51
+ readonly fingerprint: string;
52
+ readonly concurrency: number;
53
+ readonly capabilities: Capabilities;
54
+ constructor(native: NativeDocument, fingerprint: string, concurrency: number);
55
+ get pageCount(): number;
56
+ pageSize(index: number): PageSize;
57
+ renderPage(index: number, options: BackendRenderOptions): Promise<RenderedPage>;
58
+ metadata(): DocumentMetadata;
59
+ pdfVersion(): string | null;
60
+ pageText(index: number): Promise<PageText>;
61
+ outline(): Promise<OutlineNode[]>;
62
+ links(index: number): Promise<readonly PageLink[]>;
63
+ pageLabels(): Promise<readonly string[]>;
64
+ attachments(): Promise<readonly Attachment[]>;
65
+ attachmentData(index: number): Promise<Uint8Array>;
66
+ structTree(): Promise<StructNode[]>;
67
+ }
68
+ //# sourceMappingURL=papyra-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"papyra-engine.d.ts","sourceRoot":"","sources":["../src/papyra-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,IAAI,cAAc,EAE9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,Q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AM,GAAG,QAAQ,CAEhC;IAED,UAAU,CACR,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,YAAY,CAAC,CAMvB;IAED,QAAQ,IAAI,gBAAgB,CAE3B;IAED,UAAU,IAAI,MAAM,GAAG,IAAI,CAE1B;IAEK,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE/C;IAED,OAAO,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAEhC;IAED,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,QAAQ,EAAE,CAAC,CAWjD;IAED,UAAU,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAEvC;IAED,WAAW,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAE5C;IAED,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAEjD;IAED,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAElC;CACF"}
@@ -0,0 +1,173 @@
1
+ import { toAttachment } from './attachments.js';
2
+ import { PdfEngine, } from './engine.js';
3
+ import { rethrowLoadError } from './errors.js';
4
+ import { fingerprint } from './fingerprint.js';
5
+ import { toPageLink } from './links.js';
6
+ import { buildOutlineTree } from './outline.js';
7
+ import { toBytes } from './source.js';
8
+ import { buildStructTree } from './structure.js';
9
+ import { toPageText } from './text.js';
10
+ const EVERYTHING = {
11
+ text: true,
12
+ outline: true,
13
+ links: true,
14
+ attachments: true,
15
+ structure: true,
16
+ pageLabels: true,
17
+ annotationsToggle: true,
18
+ };
19
+ /** napi omits absent strings rather than nulling them; normalise to one shape. */
20
+ function toMetadata(info) {
21
+ return {
22
+ title: info.title ?? null,
23
+ author: info.author ?? null,
24
+ subject: info.subject ?? null,
25
+ keywords: info.keywords ?? null,
26
+ creator: info.creator ?? null,
27
+ producer: info.producer ?? null,
28
+ created: info.created ?? null,
29
+ modified: info.modified ?? null,
30
+ };
31
+ }
32
+ /** The addon once loaded. Process-wide, like the addon itself. */
33
+ let addon;
34
+ async function loadAddon() {
35
+ const [native, runtime, { Document }] = await Promise.all([
36
+ import('@build-qube/papyra-native'),
37
+ import('./runtime.js'),
38
+ // With the addon, not before: `Document`'s export methods call it directly.
39
+ import('./document.js'),
40
+ ]);
41
+ // Before any document loads: the wasm thread pool has to exist before rayon does.
42
+ runtime.init();
43
+ addon = { native, runtime, Document };
44
+ return addon;
45
+ }
46
+ /**
47
+ * papyra's own engine: hayro, compiled into the native addon in Node and into wasm in
48
+ * a browser. Imported from `@build-qube/papyra/engine` (or the main entry), never from
49
+ * `/core`, so an app that never names it ships none of its wasm.
50
+ *
51
+ * Constructing one loads nothing. The addon — in a browser, a wasm module of about
52
+ * 2.5 MB — is fetched by the first {@link PagedEngine.open}, which is what lets a
53
+ * bundle that names this engine as a default still cost nothing until a PDF opens.
54
+ *
55
+ * In a browser it needs a cross-origin-isolated page: the wasm build uses shared
56
+ * memory, and so needs `SharedArrayBuffer`. {@link availability} says so.
57
+ */
58
+ export class PapyraEngine extends PdfEngine {
59
+ id = 'papyra';
60
+ availability() {
61
+ // `undefined` outside a browser (Node, Bun), where the native addon needs nothing.
62
+ if (globalThis.crossOriginIsolated !== false)
63
+ return { ok: true };
64
+ return {
65
+ ok: false,
66
+ title: 'This page is not cross-origin isolated',
67
+ reason: 'papyra renders in WebAssembly with shared memory, which needs ' +
68
+ 'SharedArrayBuffer. Serve this page with ' +
69
+ 'Cross-Origin-Opener-Policy: same-origin and ' +
70
+ 'Cross-Origin-Embedder-Policy: require-corp, then reload.',
71
+ };
72
+ }
73
+ /**
74
+ * Opens to a `Document`, which is a `PdfDoc` like any engine's handle and
75
+ * also carries papyra's extras — `renderImage`, `renderSvg`, `cache` — so code that
76
+ * knows it has papyra's engine can reach them with an `instanceof` check.
77
+ */
78
+ async open(source, options = {}) {
79
+ const doc = await super.open(source, options);
80
+ // Loaded by now: `super.open` went through `load`.
81
+ const { Document } = addon ?? (await loadAddon());
82
+ return new Document(doc, this);
83
+ }
84
+ async load(source, options) {
85
+ // Only the first open waits on the import; after that `open` costs what it did
86
+ // before engines existed (measured: two `import()`s per open were +6µs).
87
+ const { native, runtime } = addon ?? (await loadAddon());
88
+ const bytes = await toBytes(source);
89
+ let inner;
90
+ try {
91
+ inner =
92
+ options.password === undefined
93
+ ? native.PdfDocument.load(bytes)
94
+ : native.PdfDocument.loadWithPassword(bytes, options.password);
95
+ }
96
+ catch (e) {
97
+ rethrowLoadError(e);
98
+ }
99
+ return new PapyraBackend(inner, fingerprint(bytes), runtime.defaultConcurrency());
100
+ }
101
+ }
102
+ /**
103
+ * The engine `open()` and `Document` go through, and the one a viewer falls back
104
+ * to when the app names none. Being one instance is the point: a document belongs to
105
+ * the engine that opened it, so a `Document` from `open()` and a viewer's default
106
+ * engine have to be the same object for the viewer's commands to accept it.
107
+ *
108
+ * Costs nothing until a document opens, like any {@link PapyraEngine}.
109
+ */
110
+ export const defaultPdfEngine =
111
+ /* @__PURE__ */ new PapyraEngine();
112
+ /**
113
+ * The addon's document, as a {@link PdfBackend}. Every napi shape is normalised
114
+ * here, so nothing past this class sees one.
115
+ *
116
+ * @internal Exported for `Document`, whose export-only methods call the addon
117
+ * directly.
118
+ */
119
+ export class PapyraBackend {
120
+ native;
121
+ fingerprint;
122
+ concurrency;
123
+ capabilities = EVERYTHING;
124
+ constructor(native, fingerprint, concurrency) {
125
+ this.native = native;
126
+ this.fingerprint = fingerprint;
127
+ this.concurrency = concurrency;
128
+ }
129
+ get pageCount() {
130
+ return this.native.pageCount;
131
+ }
132
+ pageSize(index) {
133
+ return this.native.pageSize(index);
134
+ }
135
+ renderPage(index, options) {
136
+ return this.native.renderPageAsync(index, options.dpi, options.annotations);
137
+ }
138
+ metadata() {
139
+ return toMetadata(this.native.info());
140
+ }
141
+ pdfVersion() {
142
+ return this.native.pdfVersion ?? null;
143
+ }
144
+ async pageText(index) {
145
+ return toPageText(index, await this.native.pageTextAsync(index));
146
+ }
147
+ outline() {
148
+ return this.native.outline().then(buildOutlineTree);
149
+ }
150
+ links(index) {
151
+ // `toPageLink` only returns null for a link with no resolvable target, which the
152
+ // bindings do not emit — the filter is here so a future one cannot leak a null
153
+ // into the array.
154
+ return this.native
155
+ .pageLinks(index)
156
+ .then((native) => native
157
+ .map(toPageLink)
158
+ .filter((link) => link !== null));
159
+ }
160
+ pageLabels() {
161
+ return this.native.pageLabels();
162
+ }
163
+ attachments() {
164
+ return this.native.attachments().then((files) => files.map(toAttachment));
165
+ }
166
+ attachmentData(index) {
167
+ return this.native.attachmentData(index);
168
+ }
169
+ structTree() {
170
+ return this.native.structTree().then(buildStructTree);
171
+ }
172
+ }
173
+ //# sourceMappingURL=papyra-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"papyra-engine.js","sourceRoot":"","sources":["../src/papyra-engine.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAKL,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAiB,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAoB,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,eAAe,EAAmB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAiB,UAAU,EAAE,MAAM,WAAW,CAAC;AAStD,MAAM,UAAU,GAAiB;IAC/B,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,IAAI;IAChB,iBAAiB,EAAE,IAAI;CACxB,CA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AI,CAAC,CACrD,CAAC;IACN,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,cAAc,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACxD,CAAC;CACF"}
package/dist/runtime.d.ts CHANGED
@@ -30,4 +30,11 @@ export declare function backend(): string;
30
30
  export declare function init(options?: {
31
31
  threads?: number;
32
32
  }): void;
33
+ /**
34
+ * Renders in flight at once when the caller does not say: the runtime's own
35
+ * concurrency natively, and {@link MAX_WASM_CONCURRENCY} on wasm.
36
+ *
37
+ * @internal
38
+ */
39
+ export declare function defaultConcurrency(): number;
33
40
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
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"}
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;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAI3C"}
package/dist/runtime.js CHANGED
@@ -51,4 +51,15 @@ export function init(options = {}) {
51
51
  // Already built (another copy of the library got there first). Harmless.
52
52
  }
53
53
  }
54
+ /**
55
+ * Renders in flight at once when the caller does not say: the runtime's own
56
+ * concurrency natively, and {@link MAX_WASM_CONCURRENCY} on wasm.
57
+ *
58
+ * @internal
59
+ */
60
+ export function defaultConcurrency() {
61
+ return currentRuntime() === 'wasm'
62
+ ? MAX_WASM_CONCURRENCY
63
+ : hardwareConcurrency();
64
+ }
54
65
  //# sourceMappingURL=runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,OAAO,GACR,MAAM,2BAA2B,CAAC;AAUnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB;IACjC,MAAM,GAAG,GAAI,UAA+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K,MAAM;QAChC,CAAC,CAAC,oBAAoB;QACtB,CAAC,CAAC,mBAAmB,EAAE,CAAC;AAC5B,CAAC"}
@@ -17,7 +17,14 @@ export interface SchedulerJob<T> {
17
17
  /** Identity for coalescing. Two live requests with the same key share one render. */
18
18
  key: string;
19
19
  priority: number;
20
- run: () => Promise<T>;
20
+ /** The work. `signal` aborts when an `abortable` job loses its last waiter. */
21
+ run: (signal?: AbortSignal) => Promise<T>;
22
+ /**
23
+ * Whether `run` stops early on its signal. Only then is a started job aborted when
24
+ * nobody waits on it any more; otherwise it runs to the end, and a new request for
25
+ * the same key joins it rather than starting a second.
26
+ */
27
+ abortable?: boolean;
21
28
  }
22
29
  /** Where a job's wall-clock time actually went. */
23
30
  export interface JobTiming {
@@ -44,7 +51,8 @@ export interface JobHandle<T> {
44
51
  readonly promise: Promise<T>;
45
52
  /**
46
53
  * Detach from this job. If nothing else is waiting on it and it has not started,
47
- * it is dropped from the queue; if it is already running it is left to finish.
54
+ * it is dropped from the queue; if it is already running it is left to finish,
55
+ * unless it was submitted `abortable`, in which case its signal aborts.
48
56
  */
49
57
  cancel(reason?: string): void;
50
58
  }
@@ -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,qFAAqF;AACrF,MAAM,WAAW,SAAS,CAAC,CAAC;IA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