@build-qube/papyra 0.3.0 → 0.5.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/cells.d.ts +148 -0
  15. package/dist/cells.d.ts.map +1 -0
  16. package/dist/cells.js +144 -0
  17. package/dist/cells.js.map +1 -0
  18. package/dist/core.d.ts +53 -0
  19. package/dist/core.d.ts.map +1 -0
  20. package/dist/core.js +38 -0
  21. package/dist/core.js.map +1 -0
  22. package/dist/document.d.ts +28 -20
  23. package/dist/document.d.ts.map +1 -1
  24. package/dist/document.js +79 -360
  25. package/dist/document.js.map +1 -1
  26. package/dist/engine.d.ts +327 -0
  27. package/dist/engine.d.ts.map +1 -0
  28. package/dist/engine.js +485 -0
  29. package/dist/engine.js.map +1 -0
  30. package/dist/errors.d.ts +14 -1
  31. package/dist/errors.d.ts.map +1 -1
  32. package/dist/errors.js +19 -2
  33. package/dist/errors.js.map +1 -1
  34. package/dist/fingerprint.d.ts +2 -1
  35. package/dist/fingerprint.d.ts.map +1 -1
  36. package/dist/fingerprint.js +2 -1
  37. package/dist/fingerprint.js.map +1 -1
  38. package/dist/index.d.ts +10 -24
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +7 -11
  41. package/dist/index.js.map +1 -1
  42. package/dist/links.d.ts +6 -1
  43. package/dist/links.d.ts.map +1 -1
  44. package/dist/links.js +6 -1
  45. package/dist/links.js.map +1 -1
  46. package/dist/office.d.ts +85 -0
  47. package/dist/office.d.ts.map +1 -0
  48. package/dist/office.js +135 -0
  49. package/dist/office.js.map +1 -0
  50. package/dist/papyra-engine.d.ts +68 -0
  51. package/dist/papyra-engine.d.ts.map +1 -0
  52. package/dist/papyra-engine.js +173 -0
  53. package/dist/papyra-engine.js.map +1 -0
  54. package/dist/runtime.d.ts +7 -0
  55. package/dist/runtime.d.ts.map +1 -1
  56. package/dist/runtime.js +11 -0
  57. package/dist/runtime.js.map +1 -1
  58. package/dist/scheduler.d.ts +10 -2
  59. package/dist/scheduler.d.ts.map +1 -1
  60. package/dist/scheduler.js +26 -7
  61. package/dist/scheduler.js.map +1 -1
  62. package/dist/source.d.ts +1 -1
  63. package/dist/source.js +1 -1
  64. package/dist/styles.d.ts +96 -0
  65. package/dist/styles.d.ts.map +1 -0
  66. package/dist/styles.js +69 -0
  67. package/dist/styles.js.map +1 -0
  68. package/dist/text.d.ts +6 -1
  69. package/dist/text.d.ts.map +1 -1
  70. package/dist/text.js +6 -1
  71. package/dist/text.js.map +1 -1
  72. package/dist/tiff.d.ts +95 -0
  73. package/dist/tiff.d.ts.map +1 -0
  74. package/dist/tiff.js +78 -0
  75. package/dist/tiff.js.map +1 -0
  76. package/dist/types.d.ts +22 -2
  77. package/dist/types.d.ts.map +1 -1
  78. package/dist/workbook.d.ts +152 -0
  79. package/dist/workbook.d.ts.map +1 -0
  80. package/dist/workbook.js +158 -0
  81. package/dist/workbook.js.map +1 -0
  82. package/package.json +24 -3
package/README.md CHANGED
@@ -122,7 +122,7 @@ width on screen is the page's height, and `vp.dpi` carries the answer back.
122
122
  Renders draw annotations by default. Pass `{ annotations: false }` when you are drawing
123
123
  your own link or highlight layer, or they appear twice.
124
124
 
125
- ## Two things that will bite you
125
+ ## Three things that will bite you
126
126
 
127
127
  **Size with `fitWidth`, not `dpi`.** Page areas vary by two orders of magnitude. At a
128
128
  fixed 36 DPI, US Letter is a 216x279 thumbnail while a 42x30in drawing is a 1512x1080,
@@ -137,6 +137,17 @@ Cross-Origin-Opener-Policy: same-origin
137
137
  Cross-Origin-Embedder-Policy: require-corp
138
138
  ```
139
139
 
140
+ **A panic in the browser build is fatal.** It aborts that wasm instance, and papyra
141
+ fails until the page reloads; natively it is a rejected promise like any other error.
142
+
143
+ ## Engines
144
+
145
+ Other engines — pdf.js for pages that cannot be isolated, Tauri, and the experimental
146
+ Word and PowerPoint `@build-qube/papyra/office` — are covered in the
147
+ [Engines guide](https://buildqube.github.io/Papyra/docs/guides/engines).
148
+ Code that opens documents with another engine imports from `@build-qube/papyra/core`,
149
+ which never loads papyra's wasm.
150
+
140
151
  ## More
141
152
 
142
153
  The [full API reference](https://buildqube.github.io/Papyra/docs) is generated from
@@ -49,7 +49,12 @@ export interface Attachment {
49
49
  */
50
50
  readonly relationship: string | null;
51
51
  }
52
- /** @internal */
52
+ /**
53
+ * An attachment as the bindings report it, as an {@link Attachment} at `index`.
54
+ *
55
+ * Exported for engines whose host answers in the native bindings' shapes, as
56
+ * `tauri-plugin-papyra` does, so they normalise exactly as papyra's own engine does.
57
+ */
53
58
  export declare function toAttachment(native: NativeAttachment, index: number): Attachment;
54
59
  /**
55
60
  * The attachment's media type, falling back to its extension.
@@ -1 +1 @@
1
- {"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEhF;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC;;;;;;OAMG;IACH,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;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,MAAM,GACZ,UAAU,CAWZ;AAiBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAK5D;AAUD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAE7D"}
@@ -1,4 +1,9 @@
1
- /** @internal */
1
+ /**
2
+ * An attachment as the bindings report it, as an {@link Attachment} at `index`.
3
+ *
4
+ * Exported for engines whose host answers in the native bindings' shapes, as
5
+ * `tauri-plugin-papyra` does, so they normalise exactly as papyra's own engine does.
6
+ */
2
7
  export function toAttachment(native, index) {
3
8
  return {
4
9
  index,
@@ -1 +1 @@
1
- {"version":3,"file":"attachments.js","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAqDA,gBAAgB;AAChB,MAAM,UAAU,YAAY,CAC1B,MAAwB,EACxB,KAAa;IAEb,OAAO;QACL,KAAK;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,IAAI;QACvC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;QACnC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI;QACzB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI;QAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,IAAI;QACjC,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,IAAI;KAC1C,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,MAAM,YAAY,GAA2B;IAC3C,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,kBAAkB;IACxB,GAAG,EAAE,iBAAiB;IACtB,GA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ist/cache.d.ts CHANGED
@@ -31,6 +31,11 @@ export declare class RenderCache<T> {
31
31
  get(key: string): T | undefined;
32
32
  set(key: string, value: T): void;
33
33
  clear(): void;
34
+ /**
35
+ * Empty the cache and refuse every later `set`. For a closed document, whose
36
+ * in-flight work still resolves into it afterwards.
37
+ */
38
+ close(): void;
34
39
  get stats(): CacheStats;
35
40
  }
36
41
  //# sourceMappingURL=cache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,UAAU;IACzB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,WAAW,CAAC,CAAC;;IAUxB,YAAY,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,EAG5D;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAW9B;IAED,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAc/B;IAcD,KAAK,IAAI,IAAI,CAGZ;IAED,IAAI,KAAK,IAAI,UAAU,CAQtB;CACF"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,UAAU;IACzB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,WAAW,CAAC,CAAC;;IAUxB,YAAY,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,EAG5D;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAW9B;IAED,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAc/B;IAcD,KAAK,IAAI,IAAI,CAGZ;IAED;;;OAGG;IACH,KAAK,IAAI,IAAI,CAGZ;IAED,IAAI,KAAK,IAAI,UAAU,CAQtB;CACF"}
package/dist/cache.js CHANGED
@@ -73,6 +73,14 @@ export class RenderCache {
73
73
  this.#entries.clear();
74
74
  this.#bytes = 0;
75
75
  }
76
+ /**
77
+ * Empty the cache and refuse every later `set`. For a closed document, whose
78
+ * in-flight work still resolves into it afterwards.
79
+ */
80
+ close() {
81
+ this.#budget = 0;
82
+ this.clear();
83
+ }
76
84
  get stats() {
77
85
  return {
78
86
  bytes: this.#bytes,
package/dist/cache.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAeH,MAAM,OAAO,WAAW;IACb,OAAO,CAAS;IAChB,OAAO,CAAuB;IACvC,wFAAwF;IAC/E,QAAQ,GAAG,IAAI,GAAG,EAAa,CAAC;IACzC,MAAM,GAAG,CAAC,CAAC;IACX,KAAK,GAAG,CAAC,CAAC;IACV,OAAO,GAAG,CAAC,CAAC;IACZ,UAAU,GAAG,CAAC,CAAC;IAEf,YAAY,WAAmB,EAAE,MAA4B;QAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC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- import type { RenderedPage } from './types.js';
1
+ import type { PageBitmap, RenderedPage } from './types.js';
2
2
  import type { Rotation } from './viewport.js';
3
3
  /**
4
4
  * Wrap a rendered page as `ImageData`, ready for `putImageData`.
@@ -33,5 +33,5 @@ export interface PaintOptions {
33
33
  * });
34
34
  * ```
35
35
  */
36
- export declare function paintToCanvas(page: RenderedPage, canvas: HTMLCanvasElement | OffscreenCanvas, options?: PaintOptions): void;
36
+ export declare function paintToCanvas(page: PageBitmap, canvas: HTMLCanvasElement | OffscreenCanvas, options?: PaintOptions): void;
37
37
  //# sourceMappingURL=canvas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../src/canvas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAU9C;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,CAMzD;AAED,oBAAoB;AACpB,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,iBAAiB,GAAG,eAAe,EAC3C,OAAO,GAAE,YAAiB,GACzB,IAAI,CA+BN"}
1
+ {"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../src/canvas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAU9C;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,CAMzD;AAED,oBAAoB;AACpB,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,iBAAiB,GAAG,eAAe,EAC3C,OAAO,GAAE,YAAiB,GACzB,IAAI,CA2CN"}
package/dist/canvas.js CHANGED
@@ -30,19 +30,32 @@ export function paintToCanvas(page, canvas, options = {}) {
30
30
  const ctx = canvas.getContext('2d');
31
31
  if (!ctx)
32
32
  throw new Error('papyra: could not get a 2d canvas context');
33
+ // An `ImageBitmap` is already a drawable surface: no copy, no scratch canvas.
34
+ const pixels = 'data' in page;
33
35
  if (rotation === 0) {
34
- ctx.putImageData(toImageData(page), 0, 0);
36
+ if (pixels)
37
+ ctx.putImageData(toImageData(page), 0, 0);
38
+ else
39
+ ctx.drawImage(page, 0, 0);
35
40
  return;
36
41
  }
37
42
  // `putImageData` writes straight to the backing store and ignores the transform, so
38
43
  // a rotation cannot go through it. The pixels land on a scratch surface first and
39
44
  // are then blitted under a transform, which is one extra copy — against rotating
40
45
  // the buffer ourselves, which is a copy plus a per-pixel loop in JS.
41
- const scratch = scratchCanvas(page.width, page.height);
42
- const scratchCtx = scratch.getContext('2d');
43
- if (!scratchCtx)
44
- throw new Error('papyra: could not get a 2d canvas context');
45
- scratchCtx.putImageData(toImageData(page), 0, 0);
46
+ let source;
47
+ if (pixels) {
48
+ const scratch = scratchCanvas(page.width, page.height);
49
+ const scratchCtx = scratch.getContext('2d');
50
+ if (!scratchCtx) {
51
+ throw new Error('papyra: could not get a 2d canvas context');
52
+ }
53
+ scratchCtx.putImageData(toImageData(page), 0, 0);
54
+ source = scratch;
55
+ }
56
+ else {
57
+ source = page;
58
+ }
46
59
  // Each pair puts the rotated page's origin back at the canvas corner: at 90° the
47
60
  // page's top-left corner ends up top-right, so the axes move there first.
48
61
  if (rotation === 90)
@@ -52,7 +65,7 @@ export function paintToCanvas(page, canvas, options = {}) {
52
65
  else
53
66
  ctx.translate(0, canvas.height);
54
67
  ctx.rotate((rotation * Math.PI) / 180);
55
- ctx.drawImage(scratch, 0, 0);
68
+ ctx.drawImage(source, 0, 0);
56
69
  ctx.setTransform(1, 0, 0, 1, 0, 0);
57
70
  }
58
71
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"canvas.js","sourceRoot":"","sources":["../src/canvas.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,IAAkB;IAC5C,OAAO,IAAI,SAAS,CAClB,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EACjC,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,CACZ,CAAC;AACJ,CAAC;AAcD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAkB,EAClB,MAA2C,EAC3C,OAAO,GAAiB,EAAE;IAE1B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,QAAQ,KAAK,EAAE,IAAI,QAAQ,KAAK,GAAG,CAAC;IACnD,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;IACjD,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IAElD,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAsB,CAAC;IACzD,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAEvE,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,GAAG,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1C,OAAO;IACT,CAAC;IAED,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AAE,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAa,EAAE,MAAc;IAClD,IAAI,OAAO,eAAe,KAAK,WAAW,EAAE,CAAC;QAC3C,OAAO,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IACD,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC5C,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC;IACjB,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,148 @@
1
+ import type { CellWindow as NativeCellWindow } from '@build-qube/papyra-native';
2
+ /** What a cell holds. A formula cell reports the result Excel last computed. */
3
+ export type CellKind = 'empty' | 'number' | 'text' | 'bool' | 'date' | 'duration' | 'error';
4
+ /** A cell with nothing in it, or outside the sheet's used range. */
5
+ export interface EmptyCell {
6
+ /** Always `'empty'`. */
7
+ kind: 'empty';
8
+ /** Always `''`. */
9
+ text: '';
10
+ }
11
+ /** A number, or in CSV a field that is unambiguously one. */
12
+ export interface NumberCell {
13
+ /** Always `'number'`. */
14
+ kind: 'number';
15
+ /** The value. */
16
+ value: number;
17
+ /**
18
+ * Excel's General rendering for a workbook. For CSV, the field exactly as
19
+ * written: `2.50` stays `2.50`.
20
+ */
21
+ text: string;
22
+ }
23
+ /** A string. Every CSV field that is not a plain number is one. */
24
+ export interface TextCell {
25
+ /** Always `'text'`. */
26
+ kind: 'text';
27
+ /** The string. */
28
+ text: string;
29
+ }
30
+ /** A boolean. */
31
+ export interface BoolCell {
32
+ /** Always `'bool'`. */
33
+ kind: 'bool';
34
+ /** The value. */
35
+ value: boolean;
36
+ /** Excel's spelling, which is also what a CSV export of the cell contains. */
37
+ text: 'TRUE' | 'FALSE';
38
+ }
39
+ /** A date, a time, or both. */
40
+ export interface DateCell {
41
+ /** Always `'date'`. */
42
+ kind: 'date';
43
+ /**
44
+ * The Excel date serial: days since 1899-12-30, time as the fraction. NaN for
45
+ * OpenDocument, which stores only the ISO form.
46
+ */
47
+ serial: number;
48
+ /** `2024-03-15`, `2024-03-15T13:30:00`, or `13:30:00` for a time alone. */
49
+ text: string;
50
+ }
51
+ /** A length of time. */
52
+ export interface DurationCell {
53
+ /** Always `'duration'`. */
54
+ kind: 'duration';
55
+ /** Length in days. NaN for OpenDocument, which stores only the text form. */
56
+ days: number;
57
+ /** `[h]:mm:ss` — hours do not wrap at 24. */
58
+ text: string;
59
+ }
60
+ /** An error a formula evaluated to. */
61
+ export interface ErrorCell {
62
+ /** Always `'error'`. */
63
+ kind: 'error';
64
+ /** Excel's code for it, e.g. `#DIV/0!`. */
65
+ text: string;
66
+ }
67
+ /**
68
+ * One cell's value, discriminated on `kind`.
69
+ *
70
+ * `text` is always what to display. Number formats are not applied yet, so a
71
+ * currency cell reads `1234.5` rather than `$1,234.50` and a date reads as ISO 8601
72
+ * — the raw value is beside it for anything that needs to compute.
73
+ */
74
+ export type Cell = EmptyCell | NumberCell | TextCell | BoolCell | DateCell | DurationCell | ErrorCell;
75
+ /**
76
+ * Cells merged into one, as a sheet reports them. Inclusive at both ends, like the
77
+ * `A4:B4` Excel would write — hence `lastRow` rather than an exclusive `rowEnd`.
78
+ */
79
+ export interface MergedRange {
80
+ /** 0-based row of the top-left cell, which holds the value. */
81
+ row: number;
82
+ /** 0-based column of the top-left cell. */
83
+ col: number;
84
+ /** Last row covered, inclusive. */
85
+ lastRow: number;
86
+ /** Last column covered, inclusive. */
87
+ lastCol: number;
88
+ }
89
+ /**
90
+ * A rectangle of a sheet, read in one call and decoded on access.
91
+ *
92
+ * Cells cross from Rust as four flat buffers rather than an object each, because
93
+ * building thousands of objects costs more than parsing them did. Nothing is
94
+ * decoded until asked for, so a grid that only draws text never builds a {@link Cell}.
95
+ *
96
+ * Coordinates are the sheet's, not the window's: `text(10, 2)` is row 10 of the
97
+ * sheet whichever row the window starts on. Anything outside the window is empty.
98
+ */
99
+ export declare class CellWindow {
100
+ #private;
101
+ /** First row held. */
102
+ readonly rowStart: number;
103
+ /** First column held. */
104
+ readonly colStart: number;
105
+ /** Rows held, which may be fewer than asked for at the sheet's edge. */
106
+ readonly rows: number;
107
+ /** Columns held. */
108
+ readonly cols: number;
109
+ /** @internal Use `Sheet.window`. */
110
+ constructor(native: NativeCellWindow);
111
+ /** One past the last row held. */
112
+ get rowEnd(): number;
113
+ /** One past the last column held. */
114
+ get colEnd(): number;
115
+ /** What the cell at `(row, col)` holds. Cheaper than {@link cell}. */
116
+ kind(row: number, col: number): CellKind;
117
+ /** The display text at `(row, col)` — all a plain grid needs. */
118
+ text(row: number, col: number): string;
119
+ /**
120
+ * The numeric value at `(row, col)`: a number, a bool as 0 or 1, a date's serial,
121
+ * a duration in days. NaN for anything else.
122
+ */
123
+ number(row: number, col: number): number;
124
+ /**
125
+ * The index of the cell's style in `Sheet.styles`. 0, the default, for a cell
126
+ * with none — and for every cell of a format that carries no styles.
127
+ */
128
+ style(row: number, col: number): number;
129
+ /**
130
+ * The colour the cell's number format chose, as `0xRRGGBB` — the `[Red]` in
131
+ * `#,##0;[Red](#,##0)`. It overrides the style's text colour, as in Excel.
132
+ */
133
+ color(row: number, col: number): number | undefined;
134
+ /** The cell at `(row, col)`, fully decoded. */
135
+ cell(row: number, col: number): Cell;
136
+ }
137
+ /** Unpack the bindings' flat merge quads. @internal */
138
+ export declare function toMergedRanges(quads: Uint32Array): MergedRange[];
139
+ /**
140
+ * The letters Excel heads a column with: 0 is `A`, 25 is `Z`, 26 is `AA`.
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * columnName(27); // 'AB'
145
+ * ```
146
+ */
147
+ export declare function columnName(index: number): string;
148
+ //# sourceMappingURL=cells.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cells.d.ts","sourceRoot":"","sources":["../src/cells.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAA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EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIlD;IAED,+CAA+C;IAC/C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAqBnC;CACF;AAED,uDAAuD;AACvD,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,EAAE,CAWhE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD"}
package/dist/cells.js ADDED
@@ -0,0 +1,144 @@
1
+ /** Indexed by the tag byte the bindings write. Keep in step with `CellKind` in Rust. */
2
+ const KINDS = [
3
+ 'empty',
4
+ 'number',
5
+ 'text',
6
+ 'bool',
7
+ 'date',
8
+ 'duration',
9
+ 'error',
10
+ ];
11
+ /**
12
+ * A rectangle of a sheet, read in one call and decoded on access.
13
+ *
14
+ * Cells cross from Rust as four flat buffers rather than an object each, because
15
+ * building thousands of objects costs more than parsing them did. Nothing is
16
+ * decoded until asked for, so a grid that only draws text never builds a {@link Cell}.
17
+ *
18
+ * Coordinates are the sheet's, not the window's: `text(10, 2)` is row 10 of the
19
+ * sheet whichever row the window starts on. Anything outside the window is empty.
20
+ */
21
+ export class CellWindow {
22
+ /** First row held. */
23
+ rowStart;
24
+ /** First column held. */
25
+ colStart;
26
+ /** Rows held, which may be fewer than asked for at the sheet's edge. */
27
+ rows;
28
+ /** Columns held. */
29
+ cols;
30
+ #native;
31
+ /** @internal Use `Sheet.window`. */
32
+ constructor(native) {
33
+ this.#native = native;
34
+ this.rowStart = native.rowStart;
35
+ this.colStart = native.colStart;
36
+ this.rows = native.rows;
37
+ this.cols = native.cols;
38
+ }
39
+ /** One past the last row held. */
40
+ get rowEnd() {
41
+ return this.rowStart + this.rows;
42
+ }
43
+ /** One past the last column held. */
44
+ get colEnd() {
45
+ return this.colStart + this.cols;
46
+ }
47
+ #index(row, col) {
48
+ const r = row - this.rowStart;
49
+ const c = col - this.colStart;
50
+ if (r < 0 || c < 0 || r >= this.rows || c >= this.cols)
51
+ return -1;
52
+ return r * this.cols + c;
53
+ }
54
+ /** What the cell at `(row, col)` holds. Cheaper than {@link cell}. */
55
+ kind(row, col) {
56
+ const i = this.#index(row, col);
57
+ return i < 0 ? 'empty' : (KINDS[this.#native.kinds[i] ?? 0] ?? 'empty');
58
+ }
59
+ /** The display text at `(row, col)` — all a plain grid needs. */
60
+ text(row, col) {
61
+ const i = this.#index(row, col);
62
+ if (i < 0)
63
+ return '';
64
+ const { offsets, text } = this.#native;
65
+ return text.slice(offsets[i], offsets[i + 1]);
66
+ }
67
+ /**
68
+ * The numeric value at `(row, col)`: a number, a bool as 0 or 1, a date's serial,
69
+ * a duration in days. NaN for anything else.
70
+ */
71
+ number(row, col) {
72
+ const i = this.#index(row, col);
73
+ return i < 0 ? Number.NaN : (this.#native.numbers[i] ?? Number.NaN);
74
+ }
75
+ /**
76
+ * The index of the cell's style in `Sheet.styles`. 0, the default, for a cell
77
+ * with none — and for every cell of a format that carries no styles.
78
+ */
79
+ style(row, col) {
80
+ const i = this.#index(row, col);
81
+ return i < 0 ? 0 : (this.#native.styles[i] ?? 0);
82
+ }
83
+ /**
84
+ * The colour the cell's number format chose, as `0xRRGGBB` — the `[Red]` in
85
+ * `#,##0;[Red](#,##0)`. It overrides the style's text colour, as in Excel.
86
+ */
87
+ color(row, col) {
88
+ const i = this.#index(row, col);
89
+ const c = i < 0 ? 0 : (this.#native.colors[i] ?? 0);
90
+ return c === 0 ? undefined : c & 0xffffff;
91
+ }
92
+ /** The cell at `(row, col)`, fully decoded. */
93
+ cell(row, col) {
94
+ const kind = this.kind(row, col);
95
+ const text = this.text(row, col);
96
+ const n = this.number(row, col);
97
+ switch (kind) {
98
+ case 'empty':
99
+ return { kind, text: '' };
100
+ case 'number':
101
+ return { kind, value: n, text };
102
+ case 'bool':
103
+ return n === 1
104
+ ? { kind, value: true, text: 'TRUE' }
105
+ : { kind, value: false, text: 'FALSE' };
106
+ case 'date':
107
+ return { kind, serial: n, text };
108
+ case 'duration':
109
+ return { kind, days: n, text };
110
+ case 'text':
111
+ case 'error':
112
+ return { kind, text };
113
+ }
114
+ }
115
+ }
116
+ /** Unpack the bindings' flat merge quads. @internal */
117
+ export function toMergedRanges(quads) {
118
+ const out = [];
119
+ for (let i = 0; i + 3 < quads.length; i += 4) {
120
+ out.push({
121
+ row: quads[i] ?? 0,
122
+ col: quads[i + 1] ?? 0,
123
+ lastRow: quads[i + 2] ?? 0,
124
+ lastCol: quads[i + 3] ?? 0,
125
+ });
126
+ }
127
+ return out;
128
+ }
129
+ /**
130
+ * The letters Excel heads a column with: 0 is `A`, 25 is `Z`, 26 is `AA`.
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * columnName(27); // 'AB'
135
+ * ```
136
+ */
137
+ export function columnName(index) {
138
+ let name = '';
139
+ for (let n = Math.floor(index) + 1; n > 0; n = Math.floor((n - 1) / 26)) {
140
+ name = String.fromCharCode(65 + ((n - 1) % 26)) + name;
141
+ }
142
+ return name;
143
+ }
144
+ //# sourceMappingURL=cells.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cells.js","sourceRoot":"","sources":["../src/cells.ts"],"names":[],"mappings":"AAYA,wFAAwF;AACxF,MAAM,KAAK,GAAwB;IACjC,OAAO;IACP,QAAQ;IACR,MAAM;IACN,MAAM;IACN,MAAM;IACN,UAAU;IACV,OAAO;CACR,CAAC;AAuGF;;;;;;;;;GASG;AACH,MAAM,OAAO,UAAU;IACrB,sBAAsB;IACb,QAAQ,CAAS;IAC1B,yBAAyB;IAChB,QAAQ,CAAS;IAC1B,wEAAwE;IAC/D,IAAI,CAAS;IACtB,oBAAoB;IACX,IAAI,CAAS;IACb,OAAO,CAAmB;IAEnC,oCAAoC;IACpC,YAAY,MAAwB;QAClC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;Q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AAE,CAAC;QAC7C,GAAG,CAAC,IAAI,CAAC;YACP,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;YAClB,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACtB,OAAO,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YAC1B,OAAO,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;QACxE,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;IACzD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/core.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Everything in papyra that runs without its engine.
3
+ *
4
+ * Painting a rendered bitmap, page geometry, search over extracted text, outline and
5
+ * structure trees, the priority queue, the error types, and {@link PagedEngine} and
6
+ * {@link PdfEngine} to build an engine on. papyra's own engine is not here but in
7
+ * `@build-qube/papyra/engine`.
8
+ *
9
+ * The main entry exports all of it too, but importing that loads the engine — on a
10
+ * browser, a wasm module of about 2.5 MB that needs a cross-origin-isolated page to
11
+ * start. Code that only draws pages, or that will hand the opening to another engine,
12
+ * imports from here.
13
+ *
14
+ * Nothing in this module's graph may reach `@build-qube/papyra-native` at all, not
15
+ * even through `import()`: a bundler emits the 6 MB wasm as soon as its graph reaches
16
+ * the loader, whether or not tree-shaking later drops the code that would fetch it.
17
+ * So an app whose viewer runs on another engine ships no wasm. `test/unit/core.test.ts`
18
+ * walks the graph and fails if anything does.
19
+ *
20
+ * @module
21
+ */
22
+ export type { Attachment } from './attachments.js';
23
+ export { attachmentMediaType, isInvoiceAttachment, toAttachment, } from './attachments.js';
24
+ export type { CacheStats } from './cache.js';
25
+ export type { PaintOptions } from './canvas.js';
26
+ export { paintToCanvas, toImageData } from './canvas.js';
27
+ export type { BoolCell, Cell, CellKind, DateCell, DurationCell, EmptyCell, ErrorCell, MergedRange, NumberCell, TextCell, } from './cells.js';
28
+ export { CellWindow, columnName } from './cells.js';
29
+ export type { EncodedFormat, EncodedImage, EncodeOptions, RasterFormat, SvgPage, } from './encoded.js';
30
+ export { encodedImage, mimeType, svgPage } from './encoded.js';
31
+ export type { Availability, BackendRenderOptions, Capabilities, PagedBackend, PagedDoc, PdfBackend, PdfDoc, } from './engine.js';
32
+ export { PagedEngine, PdfEngine, RENDER_ONLY } from './engine.js';
33
+ export { EncryptedWorkbookError, IncorrectPasswordError, PasswordError, PasswordRequiredError, rethrowLoadError, } from './errors.js';
34
+ export { fingerprint } from './fingerprint.js';
35
+ export type { LinkTarget, PageLink } from './links.js';
36
+ export { toPageLink } from './links.js';
37
+ export type { DestinationKind, OutlineDestination, OutlineNode, } from './outline.js';
38
+ export { buildOutlineTree, walkOutline } from './outline.js';
39
+ export type { JobHandle, JobTiming } from './scheduler.js';
40
+ export { AbortError, DEFAULT_PRIORITY } from './scheduler.js';
41
+ export type { MatchOptions, SearchMatch } from './search.js';
42
+ export { findRanges, searchPageText } from './search.js';
43
+ export { toBytes } from './source.js';
44
+ export type { MarkedContent, OrderedLine, StructNode, } from './structure.js';
45
+ export { buildStructTree, readingOrder, structuredPageString, walkStructTree, } from './structure.js';
46
+ export type { BorderEdge, BorderStyle, CellStyle, ColumnSpan, HorizontalAlign, RowSize, SheetLayout, VerticalAlign, } from './styles.js';
47
+ export { cssColor } from './styles.js';
48
+ export type { PageText, Quad, Rect, TextLine } from './text.js';
49
+ export { lineQuad, pageString, quadBounds, scaleQuad, scaleRect, toPageText, } from './text.js';
50
+ export type { DocumentMetadata, OpenOptions, PageBitmap, PageSize, PdfSource, RenderedPage, RenderHandle, RenderOptions, SearchOptions, StreamedPage, StreamOptions, SvgOptions, } from './types.js';
51
+ export type { Rotation, Viewport, ViewportOptions } from './viewport.js';
52
+ export { rotatePage, rotateSize, viewport, viewportQuad, viewportRect, } from './viewport.js';
53
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EACV,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,SAAS,EACT,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC/D,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,YAAY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EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC"}
package/dist/core.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Everything in papyra that runs without its engine.
3
+ *
4
+ * Painting a rendered bitmap, page geometry, search over extracted text, outline and
5
+ * structure trees, the priority queue, the error types, and {@link PagedEngine} and
6
+ * {@link PdfEngine} to build an engine on. papyra's own engine is not here but in
7
+ * `@build-qube/papyra/engine`.
8
+ *
9
+ * The main entry exports all of it too, but importing that loads the engine — on a
10
+ * browser, a wasm module of about 2.5 MB that needs a cross-origin-isolated page to
11
+ * start. Code that only draws pages, or that will hand the opening to another engine,
12
+ * imports from here.
13
+ *
14
+ * Nothing in this module's graph may reach `@build-qube/papyra-native` at all, not
15
+ * even through `import()`: a bundler emits the 6 MB wasm as soon as its graph reaches
16
+ * the loader, whether or not tree-shaking later drops the code that would fetch it.
17
+ * So an app whose viewer runs on another engine ships no wasm. `test/unit/core.test.ts`
18
+ * walks the graph and fails if anything does.
19
+ *
20
+ * @module
21
+ */
22
+ export { attachmentMediaType, isInvoiceAttachment, toAttachment, } from './attachments.js';
23
+ export { paintToCanvas, toImageData } from './canvas.js';
24
+ export { CellWindow, columnName } from './cells.js';
25
+ export { encodedImage, mimeType, svgPage } from './encoded.js';
26
+ export { PagedEngine, PdfEngine, RENDER_ONLY } from './engine.js';
27
+ export { EncryptedWorkbookError, IncorrectPasswordError, PasswordError, PasswordRequiredError, rethrowLoadError, } from './errors.js';
28
+ export { fingerprint } from './fingerprint.js';
29
+ export { toPageLink } from './links.js';
30
+ export { buildOutlineTree, walkOutline } from './outline.js';
31
+ export { AbortError, DEFAULT_PRIORITY } from './scheduler.js';
32
+ export { findRanges, searchPageText } from './search.js';
33
+ export { toBytes } from './source.js';
34
+ export { buildStructTree, readingOrder, structuredPageString, walkStructTree, } from './structure.js';
35
+ export { cssColor } from './styles.js';
36
+ export { lineQuad, pageString, quadBounds, scaleQuad, scaleRect, toPageText, } from './text.js';
37
+ export { rotatePage, rotateSize, viewport, viewportQuad, viewportRect, } from './viewport.js';
38
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,GACb,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAazD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAQpD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAU/D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,aAAa,EACb,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAMxC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,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