@evotecit/officeimo 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1222 -2
  3. package/bundles/officeimo-canopyx.js +11741 -0
  4. package/bundles/officeimo-canopyx.mjs +11639 -0
  5. package/bundles/officeimo-csv.js +1264 -0
  6. package/bundles/officeimo-csv.mjs +1239 -0
  7. package/bundles/officeimo-datatables.js +12018 -0
  8. package/bundles/officeimo-datatables.mjs +11915 -0
  9. package/bundles/officeimo-execution.js +1513 -0
  10. package/bundles/officeimo-execution.mjs +1489 -0
  11. package/bundles/officeimo-pdf.js +7009 -0
  12. package/bundles/officeimo-pdf.mjs +6946 -0
  13. package/bundles/officeimo-xlsx.js +5344 -0
  14. package/bundles/officeimo-xlsx.mjs +5290 -0
  15. package/bundles/officeimo.js +11468 -0
  16. package/bundles/officeimo.mjs +11369 -0
  17. package/dist/core/dates.d.ts +1 -0
  18. package/dist/core/dates.js +16 -0
  19. package/dist/core/errors.d.ts +12 -0
  20. package/dist/core/errors.js +31 -0
  21. package/dist/core/grouped-report.d.ts +87 -0
  22. package/dist/core/grouped-report.js +252 -0
  23. package/dist/core/index.d.ts +74 -0
  24. package/dist/core/index.js +37 -0
  25. package/dist/core/iteration.d.ts +7 -0
  26. package/dist/core/iteration.js +149 -0
  27. package/dist/core/limits.d.ts +7 -0
  28. package/dist/core/limits.js +56 -0
  29. package/dist/core/links.d.ts +5 -0
  30. package/dist/core/links.js +14 -0
  31. package/dist/core/presentation.d.ts +29 -0
  32. package/dist/core/presentation.js +59 -0
  33. package/dist/core/progress.d.ts +1 -0
  34. package/dist/core/progress.js +10 -0
  35. package/dist/core/sinks.d.ts +33 -0
  36. package/dist/core/sinks.js +102 -0
  37. package/dist/core/table.d.ts +8 -0
  38. package/dist/core/table.js +1 -0
  39. package/dist/core/value-text.d.ts +7 -0
  40. package/dist/core/value-text.js +13 -0
  41. package/dist/csv/index.d.ts +44 -0
  42. package/dist/csv/index.js +133 -0
  43. package/dist/csv/options.d.ts +1 -0
  44. package/dist/csv/options.js +8 -0
  45. package/dist/csv/structured-rows.d.ts +3 -0
  46. package/dist/csv/structured-rows.js +15 -0
  47. package/dist/execution/host.d.ts +5 -0
  48. package/dist/execution/host.js +164 -0
  49. package/dist/execution/index.d.ts +3 -0
  50. package/dist/execution/index.js +2 -0
  51. package/dist/execution/protocol.d.ts +48 -0
  52. package/dist/execution/protocol.js +173 -0
  53. package/dist/execution/types.d.ts +42 -0
  54. package/dist/execution/types.js +1 -0
  55. package/dist/execution/worker.d.ts +3 -0
  56. package/dist/execution/worker.js +147 -0
  57. package/dist/index.d.ts +32 -0
  58. package/dist/index.js +14 -0
  59. package/dist/integrations/canopyx/dates.d.ts +1 -0
  60. package/dist/integrations/canopyx/dates.js +34 -0
  61. package/dist/integrations/canopyx/index.d.ts +10 -0
  62. package/dist/integrations/canopyx/index.js +45 -0
  63. package/dist/integrations/canopyx/source.d.ts +3 -0
  64. package/dist/integrations/canopyx/source.js +122 -0
  65. package/dist/integrations/canopyx/types.d.ts +83 -0
  66. package/dist/integrations/canopyx/types.js +1 -0
  67. package/dist/integrations/datatables/api.d.ts +1 -0
  68. package/dist/integrations/datatables/api.js +27 -0
  69. package/dist/integrations/datatables/headings.d.ts +1 -0
  70. package/dist/integrations/datatables/headings.js +65 -0
  71. package/dist/integrations/datatables/index.d.ts +12 -0
  72. package/dist/integrations/datatables/index.js +167 -0
  73. package/dist/integrations/datatables/snapshot.d.ts +3 -0
  74. package/dist/integrations/datatables/snapshot.js +206 -0
  75. package/dist/integrations/datatables/types.d.ts +98 -0
  76. package/dist/integrations/datatables/types.js +1 -0
  77. package/dist/integrations/options.d.ts +13 -0
  78. package/dist/integrations/options.js +34 -0
  79. package/dist/internal/capture.d.ts +4 -0
  80. package/dist/internal/capture.js +14 -0
  81. package/dist/internal/columns.d.ts +27 -0
  82. package/dist/internal/columns.js +1 -0
  83. package/dist/internal/crc32.d.ts +6 -0
  84. package/dist/internal/crc32.js +17 -0
  85. package/dist/internal/export-values.d.ts +3 -0
  86. package/dist/internal/export-values.js +14 -0
  87. package/dist/internal/rows.d.ts +6 -0
  88. package/dist/internal/rows.js +77 -0
  89. package/dist/internal/table-spans.d.ts +11 -0
  90. package/dist/internal/table-spans.js +58 -0
  91. package/dist/internal/totals.d.ts +15 -0
  92. package/dist/internal/totals.js +42 -0
  93. package/dist/opc/index.d.ts +67 -0
  94. package/dist/opc/index.js +233 -0
  95. package/dist/opc/properties.d.ts +15 -0
  96. package/dist/opc/properties.js +18 -0
  97. package/dist/opc/uri.d.ts +5 -0
  98. package/dist/opc/uri.js +41 -0
  99. package/dist/pdf/annotations.d.ts +1 -0
  100. package/dist/pdf/annotations.js +38 -0
  101. package/dist/pdf/binary.d.ts +6 -0
  102. package/dist/pdf/binary.js +24 -0
  103. package/dist/pdf/document-drawings.d.ts +15 -0
  104. package/dist/pdf/document-drawings.js +237 -0
  105. package/dist/pdf/document-grouped.d.ts +1 -0
  106. package/dist/pdf/document-grouped.js +244 -0
  107. package/dist/pdf/document-images.d.ts +19 -0
  108. package/dist/pdf/document-images.js +125 -0
  109. package/dist/pdf/document-types.d.ts +160 -0
  110. package/dist/pdf/document-types.js +1 -0
  111. package/dist/pdf/document-vectors.d.ts +11 -0
  112. package/dist/pdf/document-vectors.js +77 -0
  113. package/dist/pdf/document.d.ts +9 -0
  114. package/dist/pdf/document.js +270 -0
  115. package/dist/pdf/drawing-types.d.ts +53 -0
  116. package/dist/pdf/drawing-types.js +1 -0
  117. package/dist/pdf/font-resources.d.ts +43 -0
  118. package/dist/pdf/font-resources.js +202 -0
  119. package/dist/pdf/font-support.d.ts +1 -0
  120. package/dist/pdf/font-support.js +60 -0
  121. package/dist/pdf/font.d.ts +17 -0
  122. package/dist/pdf/font.js +56 -0
  123. package/dist/pdf/grouped-table.d.ts +6 -0
  124. package/dist/pdf/grouped-table.js +40 -0
  125. package/dist/pdf/grouped-types.d.ts +34 -0
  126. package/dist/pdf/grouped-types.js +1 -0
  127. package/dist/pdf/grouped.d.ts +10 -0
  128. package/dist/pdf/grouped.js +37 -0
  129. package/dist/pdf/index.d.ts +22 -0
  130. package/dist/pdf/index.js +8 -0
  131. package/dist/pdf/inline-text.d.ts +30 -0
  132. package/dist/pdf/inline-text.js +183 -0
  133. package/dist/pdf/inline-types.d.ts +15 -0
  134. package/dist/pdf/inline-types.js +1 -0
  135. package/dist/pdf/list-layout.d.ts +6 -0
  136. package/dist/pdf/list-layout.js +49 -0
  137. package/dist/pdf/objects.d.ts +2 -0
  138. package/dist/pdf/objects.js +320 -0
  139. package/dist/pdf/outlines.d.ts +1 -0
  140. package/dist/pdf/outlines.js +55 -0
  141. package/dist/pdf/page-context.d.ts +1 -0
  142. package/dist/pdf/page-context.js +12 -0
  143. package/dist/pdf/pages.d.ts +1 -0
  144. package/dist/pdf/pages.js +678 -0
  145. package/dist/pdf/paragraph-layout.d.ts +21 -0
  146. package/dist/pdf/paragraph-layout.js +71 -0
  147. package/dist/pdf/paragraph-styles.d.ts +1 -0
  148. package/dist/pdf/paragraph-styles.js +66 -0
  149. package/dist/pdf/png.d.ts +9 -0
  150. package/dist/pdf/png.js +259 -0
  151. package/dist/pdf/preflight.d.ts +7 -0
  152. package/dist/pdf/preflight.js +32 -0
  153. package/dist/pdf/presentation-settings.d.ts +5 -0
  154. package/dist/pdf/presentation-settings.js +28 -0
  155. package/dist/pdf/providers/harfbuzz.d.ts +60 -0
  156. package/dist/pdf/providers/harfbuzz.js +112 -0
  157. package/dist/pdf/providers/unicode13-profile.d.ts +2 -0
  158. package/dist/pdf/providers/unicode13-profile.js +115 -0
  159. package/dist/pdf/section-types.d.ts +15 -0
  160. package/dist/pdf/section-types.js +40 -0
  161. package/dist/pdf/session.d.ts +25 -0
  162. package/dist/pdf/session.js +55 -0
  163. package/dist/pdf/settings.d.ts +17 -0
  164. package/dist/pdf/settings.js +196 -0
  165. package/dist/pdf/shaped-text.d.ts +5 -0
  166. package/dist/pdf/shaped-text.js +205 -0
  167. package/dist/pdf/standard-widths.d.ts +1 -0
  168. package/dist/pdf/standard-widths.js +317 -0
  169. package/dist/pdf/structure-parent-tree.d.ts +1 -0
  170. package/dist/pdf/structure-parent-tree.js +57 -0
  171. package/dist/pdf/structure.d.ts +6 -0
  172. package/dist/pdf/structure.js +302 -0
  173. package/dist/pdf/table-band-flow.d.ts +34 -0
  174. package/dist/pdf/table-band-flow.js +129 -0
  175. package/dist/pdf/table-band-plan.d.ts +10 -0
  176. package/dist/pdf/table-band-plan.js +83 -0
  177. package/dist/pdf/table-layout.d.ts +75 -0
  178. package/dist/pdf/table-layout.js +217 -0
  179. package/dist/pdf/table-structure.d.ts +1 -0
  180. package/dist/pdf/table-structure.js +108 -0
  181. package/dist/pdf/text-shaping-types.d.ts +39 -0
  182. package/dist/pdf/text-shaping-types.js +1 -0
  183. package/dist/pdf/text.d.ts +13 -0
  184. package/dist/pdf/text.js +101 -0
  185. package/dist/pdf/truetype-subset.d.ts +5 -0
  186. package/dist/pdf/truetype-subset.js +217 -0
  187. package/dist/pdf/truetype.d.ts +1 -0
  188. package/dist/pdf/truetype.js +235 -0
  189. package/dist/pdf/types.d.ts +171 -0
  190. package/dist/pdf/types.js +1 -0
  191. package/dist/pdf/write.d.ts +6 -0
  192. package/dist/pdf/write.js +57 -0
  193. package/dist/pdf/xref.d.ts +1 -0
  194. package/dist/pdf/xref.js +30 -0
  195. package/dist/xlsx/attachments.d.ts +30 -0
  196. package/dist/xlsx/attachments.js +67 -0
  197. package/dist/xlsx/chart-bindings.d.ts +1 -0
  198. package/dist/xlsx/chart-bindings.js +122 -0
  199. package/dist/xlsx/chart-types.d.ts +73 -0
  200. package/dist/xlsx/chart-types.js +1 -0
  201. package/dist/xlsx/chart-xml.d.ts +2 -0
  202. package/dist/xlsx/chart-xml.js +103 -0
  203. package/dist/xlsx/charts.d.ts +1 -0
  204. package/dist/xlsx/charts.js +159 -0
  205. package/dist/xlsx/conditional-formatting.d.ts +1 -0
  206. package/dist/xlsx/conditional-formatting.js +158 -0
  207. package/dist/xlsx/conditional-types.d.ts +64 -0
  208. package/dist/xlsx/conditional-types.js +1 -0
  209. package/dist/xlsx/data-row-ranges.d.ts +5 -0
  210. package/dist/xlsx/data-row-ranges.js +39 -0
  211. package/dist/xlsx/differential-styles.d.ts +1 -0
  212. package/dist/xlsx/differential-styles.js +102 -0
  213. package/dist/xlsx/formula.d.ts +8 -0
  214. package/dist/xlsx/formula.js +104 -0
  215. package/dist/xlsx/grouped-layout.d.ts +61 -0
  216. package/dist/xlsx/grouped-layout.js +79 -0
  217. package/dist/xlsx/grouped.d.ts +16 -0
  218. package/dist/xlsx/grouped.js +161 -0
  219. package/dist/xlsx/index.d.ts +24 -0
  220. package/dist/xlsx/index.js +10 -0
  221. package/dist/xlsx/layout.d.ts +1 -0
  222. package/dist/xlsx/layout.js +186 -0
  223. package/dist/xlsx/options.d.ts +1 -0
  224. package/dist/xlsx/options.js +16 -0
  225. package/dist/xlsx/portable.d.ts +27 -0
  226. package/dist/xlsx/portable.js +44 -0
  227. package/dist/xlsx/preservation.d.ts +1 -0
  228. package/dist/xlsx/preservation.js +60 -0
  229. package/dist/xlsx/ranges.d.ts +1 -0
  230. package/dist/xlsx/ranges.js +24 -0
  231. package/dist/xlsx/regions.d.ts +1 -0
  232. package/dist/xlsx/regions.js +97 -0
  233. package/dist/xlsx/structured-rows.d.ts +11 -0
  234. package/dist/xlsx/structured-rows.js +28 -0
  235. package/dist/xlsx/style-xml.d.ts +1 -0
  236. package/dist/xlsx/style-xml.js +6 -0
  237. package/dist/xlsx/styles.d.ts +70 -0
  238. package/dist/xlsx/styles.js +203 -0
  239. package/dist/xlsx/table.d.ts +12 -0
  240. package/dist/xlsx/table.js +35 -0
  241. package/dist/xlsx/types.d.ts +180 -0
  242. package/dist/xlsx/types.js +1 -0
  243. package/dist/xlsx/validation-types.d.ts +18 -0
  244. package/dist/xlsx/validation-types.js +1 -0
  245. package/dist/xlsx/validation.d.ts +1 -0
  246. package/dist/xlsx/validation.js +92 -0
  247. package/dist/xlsx/values.d.ts +13 -0
  248. package/dist/xlsx/values.js +87 -0
  249. package/dist/xlsx/workbook.d.ts +50 -0
  250. package/dist/xlsx/workbook.js +452 -0
  251. package/dist/xlsx/worksheet.d.ts +71 -0
  252. package/dist/xlsx/worksheet.js +700 -0
  253. package/dist/xlsx/write.d.ts +15 -0
  254. package/dist/xlsx/write.js +47 -0
  255. package/dist/xml/index.d.ts +24 -0
  256. package/dist/xml/index.js +74 -0
  257. package/dist/zip/entry.d.ts +39 -0
  258. package/dist/zip/entry.js +122 -0
  259. package/dist/zip/index.d.ts +44 -0
  260. package/dist/zip/index.js +248 -0
  261. package/package.json +104 -4
@@ -0,0 +1,6 @@
1
+ import type { ProjectionColumn } from "./columns.js";
2
+ export declare function createRowProjector(columns: readonly ProjectionColumn[], worksheet?: {
3
+ readonly sheetName: string;
4
+ readonly firstDataRow: number;
5
+ }, signal?: AbortSignal, validate?: (value: unknown) => void): (row: unknown, rowIndex?: number) => readonly unknown[];
6
+ export declare function copyColumns<C extends ProjectionColumn>(columns: readonly C[], workbookStyles?: boolean): C[];
@@ -0,0 +1,77 @@
1
+ import { assertExportValue } from "../core/presentation.js";
2
+ import { checkAbort } from "../core/iteration.js";
3
+ import { isDate } from "../core/dates.js";
4
+ import { captureFields } from "./capture.js";
5
+ export function createRowProjector(columns, worksheet, signal, validate = assertExportValue) {
6
+ const getters = columns.some(column => column.value);
7
+ return (row, rowIndex = 0) => {
8
+ if (Array.isArray(row) && !getters) {
9
+ const length = row.length;
10
+ if (length > columns.length)
11
+ throw new RangeError("Row has more values than declared columns.");
12
+ // Resolve each positional value once, just like key/value projections. Returning the
13
+ // source array would let an accessor change a value after the portable-value check.
14
+ const values = new Array(length);
15
+ for (let index = 0; index < length; index++) {
16
+ const value = row[index];
17
+ validate(value);
18
+ values[index] = value;
19
+ }
20
+ return values;
21
+ }
22
+ if (!row || typeof row !== "object" || isDate(row))
23
+ throw new TypeError("A row must be an array or object.");
24
+ if (Array.isArray(row) && row.length > columns.length && !columns.every(column => column.value))
25
+ throw new RangeError("Project every column explicitly when selecting from a wider array row.");
26
+ return columns.map((c, columnIndex) => {
27
+ if (c.value) {
28
+ checkAbort(signal);
29
+ const context = { rowIndex, columnIndex, column: c,
30
+ ...(worksheet ? { sheetName: worksheet.sheetName, worksheetRow: worksheet.firstDataRow + rowIndex } : {}) };
31
+ const result = c.value(row, context);
32
+ validate(result);
33
+ checkAbort(signal);
34
+ return result;
35
+ }
36
+ if (Array.isArray(row)) {
37
+ const result = row[columnIndex];
38
+ validate(result);
39
+ return result;
40
+ }
41
+ const key = c.key ?? c.header;
42
+ const result = Object.prototype.hasOwnProperty.call(row, key) ? row[key] : undefined;
43
+ validate(result);
44
+ return result;
45
+ });
46
+ };
47
+ }
48
+ /** @internal Shared metadata fields for full columns and adapter-owned partial overrides. */
49
+ export const columnOptionFields = ["header", "key", "value", "width", "type", "format", "wrapText", "alignment", "rowHeader", "groups", "style", "valueFormatter"];
50
+ export function copyColumns(columns, workbookStyles = false) {
51
+ if (!Array.isArray(columns))
52
+ throw new TypeError("Declare the columns in export order.");
53
+ return columns.map(c => {
54
+ if (!c || typeof c !== "object" && typeof c !== "function")
55
+ throw new TypeError("Each column needs a string header and an optional string key.");
56
+ // Own extension metadata remains available to its format owner. Capture the
57
+ // supported structural fields even when a class exposes prototype getters.
58
+ const captured = captureFields(c, columnOptionFields);
59
+ if (!workbookStyles && captured.style !== undefined)
60
+ throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");
61
+ if (typeof captured.header !== "string" || (captured.key !== undefined && typeof captured.key !== "string"))
62
+ throw new TypeError("Each column needs a string header and an optional string key.");
63
+ if (captured.value !== undefined && typeof captured.value !== "function")
64
+ throw new TypeError("Column value getters must be functions.");
65
+ if (captured.rowHeader !== undefined && typeof captured.rowHeader !== "boolean")
66
+ throw new TypeError("Column rowHeader must be boolean.");
67
+ if (captured.groups !== undefined) {
68
+ if (!Array.isArray(captured.groups))
69
+ throw new TypeError("Column groups must be an array of strings.");
70
+ const groups = Array.from(captured.groups);
71
+ if (groups.some(group => typeof group !== "string"))
72
+ throw new TypeError("Column groups must be an array of strings.");
73
+ return { ...captured, groups: Object.freeze(groups) };
74
+ }
75
+ return captured;
76
+ });
77
+ }
@@ -0,0 +1,11 @@
1
+ import type { TableSpanRows, ExportValue } from "../core/index.js";
2
+ export interface SpanAnchor {
3
+ readonly first: number;
4
+ readonly span: number;
5
+ readonly rowSpan: number;
6
+ readonly value: ExportValue;
7
+ }
8
+ /** Capture a bounded public matrix before validation or asynchronous report production can revisit its fields. */
9
+ export declare function captureTableSpans(rows: TableSpanRows, columns: number): TableSpanRows;
10
+ /** Validate one small, rectangular heading/footer matrix before any drawing. */
11
+ export declare function tableSpans(rows: TableSpanRows, columns: number): readonly (readonly SpanAnchor[])[];
@@ -0,0 +1,58 @@
1
+ import { assertExportValue } from "../core/presentation.js";
2
+ import { copyExportValue } from "./export-values.js";
3
+ /** Capture a bounded public matrix before validation or asynchronous report production can revisit its fields. */
4
+ export function captureTableSpans(rows, columns) {
5
+ if (!Array.isArray(rows) || !rows.length || rows.length > 16)
6
+ throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");
7
+ const captured = rows.map(row => {
8
+ if (!Array.isArray(row) || row.length !== columns)
9
+ throw new TypeError("Spanned rows must have the declared column count.");
10
+ return Object.freeze(row.map(cell => {
11
+ if (cell === null)
12
+ return null;
13
+ if (!cell || typeof cell !== "object")
14
+ throw new TypeError("Uncovered heading/footer cells need an anchor value.");
15
+ const { value, columnSpan, rowSpan } = cell;
16
+ return Object.freeze({ value: copyExportValue(value), ...(columnSpan === undefined ? {} : { columnSpan }),
17
+ ...(rowSpan === undefined ? {} : { rowSpan }) });
18
+ }));
19
+ });
20
+ tableSpans(captured, columns);
21
+ return Object.freeze(captured);
22
+ }
23
+ /** Validate one small, rectangular heading/footer matrix before any drawing. */
24
+ export function tableSpans(rows, columns) {
25
+ if (!Array.isArray(rows) || !rows.length || rows.length > 16)
26
+ throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");
27
+ const covered = Array.from({ length: rows.length }, () => new Uint8Array(columns));
28
+ return rows.map((row, level) => {
29
+ if (!Array.isArray(row) || row.length !== columns)
30
+ throw new TypeError("Spanned rows must have the declared column count.");
31
+ const anchors = [];
32
+ for (let first = 0; first < columns; first++) {
33
+ const cell = row[first];
34
+ if (covered[level][first]) {
35
+ if (cell !== null)
36
+ throw new TypeError("Covered heading/footer cells must be null.");
37
+ continue;
38
+ }
39
+ if (!cell || typeof cell !== "object")
40
+ throw new TypeError("Uncovered heading/footer cells need an anchor value.");
41
+ const span = cell.columnSpan ?? 1, rowSpan = cell.rowSpan ?? 1;
42
+ if (!Number.isInteger(span) || !Number.isInteger(rowSpan) || span < 1 || rowSpan < 1 || first + span > columns || level + rowSpan > rows.length)
43
+ throw new RangeError("Heading/footer spans must stay inside the declared matrix.");
44
+ const value = cell.value;
45
+ assertExportValue(value);
46
+ for (let r = level; r < level + rowSpan; r++)
47
+ for (let c = first; c < first + span; c++) {
48
+ if (covered[r][c])
49
+ throw new TypeError("Heading/footer spans overlap.");
50
+ if ((r !== level || c !== first) && rows[r]?.[c] !== null)
51
+ throw new TypeError("Covered heading/footer cells must be null.");
52
+ covered[r][c] = 1;
53
+ }
54
+ anchors.push(Object.freeze({ first, span, rowSpan, value }));
55
+ }
56
+ return Object.freeze(anchors);
57
+ });
58
+ }
@@ -0,0 +1,15 @@
1
+ import type { ProjectionColumn } from "./columns.js";
2
+ /** Shared numeric report totals. Count follows spreadsheet COUNT and ignores nonnumeric cells. */
3
+ export type TotalOperation = "sum" | "count" | "average" | "min" | "max";
4
+ export declare class NumericAggregate {
5
+ readonly operation: TotalOperation | undefined;
6
+ count: number;
7
+ private sum;
8
+ private mean;
9
+ private min;
10
+ private max;
11
+ constructor(operation: TotalOperation | undefined);
12
+ accept(value: unknown): void;
13
+ value(): number | null;
14
+ }
15
+ export declare function createTotals(columns: readonly ProjectionColumn[], totals?: Readonly<Record<string, TotalOperation>>): NumericAggregate[];
@@ -0,0 +1,42 @@
1
+ export class NumericAggregate {
2
+ operation;
3
+ count = 0;
4
+ sum = 0;
5
+ mean = 0;
6
+ min = Infinity;
7
+ max = -Infinity;
8
+ constructor(operation) {
9
+ this.operation = operation;
10
+ }
11
+ accept(value) {
12
+ if (!this.operation || typeof value !== "number" || !Number.isFinite(value))
13
+ return;
14
+ this.count++;
15
+ if (this.operation === "sum") {
16
+ this.sum += value;
17
+ if (!Number.isFinite(this.sum))
18
+ throw new RangeError("Numeric total exceeds finite number range.");
19
+ }
20
+ else if (this.operation === "average") {
21
+ const delta = value - this.mean;
22
+ this.mean = this.count === 1 ? value : Number.isFinite(delta) ? this.mean + delta / this.count : this.mean * ((this.count - 1) / this.count) + value / this.count;
23
+ }
24
+ else if (this.operation === "min")
25
+ this.min = Math.min(this.min, value);
26
+ else if (this.operation === "max")
27
+ this.max = Math.max(this.max, value);
28
+ }
29
+ value() {
30
+ return this.operation === "count" ? this.count : this.operation === "sum" ? this.sum : !this.count ? null : this.operation === "average" ? this.mean : this.operation === "min" ? this.min : this.max;
31
+ }
32
+ }
33
+ export function createTotals(columns, totals = {}) {
34
+ const keys = columns.map(c => c.key ?? c.header);
35
+ for (const [key, operation] of Object.entries(totals)) {
36
+ if (keys.filter(k => k === key).length !== 1)
37
+ throw new TypeError("Totals need an unambiguous declared column key: " + key);
38
+ if (!["sum", "count", "average", "min", "max"].includes(operation))
39
+ throw new TypeError("Invalid total operation.");
40
+ }
41
+ return keys.map(key => new NumericAggregate(Object.prototype.hasOwnProperty.call(totals, key) ? totals[key] : undefined));
42
+ }
@@ -0,0 +1,67 @@
1
+ export { partUri, relationshipPartUri, relativePartTarget } from "./uri.js";
2
+ export { corePropertiesXml, appPropertiesXml } from "./properties.js";
3
+ export type { CoreProperties, AppProperties } from "./properties.js";
4
+ import type { CoreProperties, AppProperties } from "./properties.js";
5
+ import type { ZipWriterOptions, ZipEntrySource, ZipEntry } from "../zip/index.js";
6
+ import type { ByteSink } from "../core/sinks.js";
7
+ import type { InvalidCharacterPolicy } from "../xml/index.js";
8
+ export declare const relationshipsNamespace = "http://schemas.openxmlformats.org/package/2006/relationships";
9
+ export declare const officeRelationshipsNamespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
10
+ export declare const contentTypesNamespace = "http://schemas.openxmlformats.org/package/2006/content-types";
11
+ export declare const relationshipTypes: {
12
+ readonly officeDocument: string;
13
+ readonly worksheet: string;
14
+ readonly styles: string;
15
+ readonly theme: string;
16
+ readonly customXml: string;
17
+ readonly coreProperties: string;
18
+ readonly appProperties: string;
19
+ };
20
+ export type PartSource = string | Blob | ZipEntrySource;
21
+ export interface PackagePart {
22
+ readonly uri: string;
23
+ readonly contentType: string;
24
+ readonly data: PartSource;
25
+ }
26
+ export interface Relationship {
27
+ readonly id: string;
28
+ readonly type: string;
29
+ /** Internal targets are absolute part URIs; serialized relative to the source part. */
30
+ readonly target: string;
31
+ readonly external?: boolean;
32
+ }
33
+ export interface OpcPackageOptions extends ZipWriterOptions {
34
+ readonly invalidCharacterPolicy?: InvalidCharacterPolicy;
35
+ readonly sink?: ByteSink;
36
+ }
37
+ /** Content-type catalog usable by every OPC format. Duplicate overrides are rejected. */
38
+ export declare class ContentTypes {
39
+ private readonly defaults;
40
+ private readonly overrides;
41
+ addDefault(extension: string, type: string): void;
42
+ addOverride(uri: string, type: string): void;
43
+ toXml(): string;
44
+ }
45
+ /** Format-neutral part and relationship owner. A source iterable is consumed once at finalization. */
46
+ export declare class OpcPackage {
47
+ private readonly types;
48
+ private readonly parts;
49
+ private readonly directories;
50
+ private readonly relationships;
51
+ private state;
52
+ private result;
53
+ private readonly zip;
54
+ private readonly options;
55
+ constructor(options?: OpcPackageOptions);
56
+ private open;
57
+ private reserve;
58
+ addPart(part: PackagePart): void;
59
+ /** Write a part directly to the configured sink. Close it before opening the next part. */
60
+ openPart(uri: string, type: string): Promise<ZipEntry>;
61
+ addRelationship(source: string, relationship: Relationship): void;
62
+ setProperties(core?: CoreProperties, app?: AppProperties): void;
63
+ private source;
64
+ /** Complete pending parts and metadata without closing a caller-owned sink. */
65
+ finish(): Promise<number>;
66
+ toBlob(type?: string): Promise<Blob>;
67
+ }
@@ -0,0 +1,233 @@
1
+ export { partUri, relationshipPartUri, relativePartTarget } from "./uri.js";
2
+ export { corePropertiesXml, appPropertiesXml } from "./properties.js";
3
+ import { partUri, relationshipPartUri, relativePartTarget } from "./uri.js";
4
+ import { corePropertiesXml, appPropertiesXml } from "./properties.js";
5
+ import { ZipWriter } from "../zip/index.js";
6
+ import { ChunkedTextSink } from "../core/sinks.js";
7
+ import { OfficeIMOError } from "../core/errors.js";
8
+ import { escapeXml, xmlDeclaration } from "../xml/index.js";
9
+ import { checkAbort, pause, taskYieldDue } from "../core/iteration.js";
10
+ import { captureFields } from "../internal/capture.js";
11
+ export const relationshipsNamespace = "http://schemas.openxmlformats.org/package/2006/relationships";
12
+ export const officeRelationshipsNamespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
13
+ export const contentTypesNamespace = "http://schemas.openxmlformats.org/package/2006/content-types";
14
+ export const relationshipTypes = {
15
+ officeDocument: officeRelationshipsNamespace + "/officeDocument",
16
+ worksheet: officeRelationshipsNamespace + "/worksheet",
17
+ styles: officeRelationshipsNamespace + "/styles",
18
+ theme: officeRelationshipsNamespace + "/theme",
19
+ customXml: officeRelationshipsNamespace + "/customXml",
20
+ coreProperties: relationshipsNamespace + "/metadata/core-properties",
21
+ appProperties: officeRelationshipsNamespace + "/extended-properties"
22
+ };
23
+ function contentType(value) {
24
+ if (typeof value !== "string" || !/^[\w!#$&^.+-]+\/[\w!#$&^.+-]+$/.test(value))
25
+ throw new TypeError("Invalid content type.");
26
+ return value;
27
+ }
28
+ /** Content-type catalog usable by every OPC format. Duplicate overrides are rejected. */
29
+ export class ContentTypes {
30
+ defaults = new Map([["rels", "application/vnd.openxmlformats-package.relationships+xml"], ["xml", "application/xml"]]);
31
+ overrides = new Map();
32
+ addDefault(extension, type) {
33
+ if (!/^[A-Za-z0-9]+$/.test(extension))
34
+ throw new TypeError("Invalid part extension.");
35
+ const key = extension.toLowerCase(), previous = this.defaults.get(key);
36
+ if (previous !== undefined && previous !== type)
37
+ throw new TypeError("Conflicting default content type.");
38
+ this.defaults.set(key, contentType(type));
39
+ }
40
+ addOverride(uri, type) {
41
+ uri = partUri(uri);
42
+ if (this.overrides.has(uri.toLowerCase()))
43
+ throw new TypeError("Duplicate content-type override.");
44
+ this.overrides.set(uri.toLowerCase(), { uri, type: contentType(type) });
45
+ }
46
+ toXml() {
47
+ return xmlDeclaration + '<Types xmlns="' + contentTypesNamespace + '">' + [...this.defaults].map(([ext, type]) => '<Default Extension="' + escapeXml(ext) + '" ContentType="' + escapeXml(type) + '"/>').join("") + [...this.overrides.values()].map(({ uri, type }) => '<Override PartName="' + escapeXml(uri) + '" ContentType="' + escapeXml(type) + '"/>').join("") + '</Types>';
48
+ }
49
+ }
50
+ /** Format-neutral part and relationship owner. A source iterable is consumed once at finalization. */
51
+ export class OpcPackage {
52
+ types = new ContentTypes();
53
+ parts = new Map();
54
+ directories = new Set();
55
+ relationships = new Map();
56
+ state = "open";
57
+ result;
58
+ zip;
59
+ options;
60
+ constructor(options = {}) {
61
+ this.options = Object.freeze(captureFields(options, ["compression", "signal", "maxOutputBytes", "invalidCharacterPolicy", "sink"]));
62
+ this.zip = new ZipWriter(this.options.sink, this.options);
63
+ }
64
+ open() { if (this.state !== "open")
65
+ throw new OfficeIMOError("INVALID_STATE", "OPC package is finalized."); }
66
+ reserve(uri, type) {
67
+ this.open();
68
+ uri = partUri(uri);
69
+ if (/\/_rels(?:\/|$)/i.test(uri) || uri.toLowerCase() === "/[content_types].xml")
70
+ throw new TypeError("Package metadata part names are reserved.");
71
+ const key = uri.toLowerCase();
72
+ if (this.parts.has(key))
73
+ throw new TypeError("Duplicate OPC part: " + uri);
74
+ if (this.directories.has(key))
75
+ throw new TypeError("OPC part-name prefix collision: " + uri + " is an ancestor of an existing part.");
76
+ const ancestors = [];
77
+ for (let slash = key.lastIndexOf("/"); slash > 0; slash = key.lastIndexOf("/", slash - 1)) {
78
+ const ancestor = key.slice(0, slash);
79
+ if (this.parts.has(ancestor))
80
+ throw new TypeError("OPC part-name prefix collision: " + uri + " descends from " + this.parts.get(ancestor).uri);
81
+ ancestors.push(ancestor);
82
+ }
83
+ this.types.addOverride(uri, type);
84
+ for (const ancestor of ancestors)
85
+ this.directories.add(ancestor);
86
+ return uri;
87
+ }
88
+ addPart(part) {
89
+ const uri = this.reserve(part.uri, part.contentType);
90
+ this.parts.set(uri.toLowerCase(), { ...part, uri, data: part.data instanceof Uint8Array ? new Uint8Array(part.data) : part.data });
91
+ }
92
+ /** @internal */
93
+ addPrepared(uri, type, prepared) {
94
+ uri = this.reserve(uri, type);
95
+ this.parts.set(uri.toLowerCase(), { uri, prepared });
96
+ }
97
+ /** Write a part directly to the configured sink. Close it before opening the next part. */
98
+ async openPart(uri, type) {
99
+ if (!this.options.sink)
100
+ throw new OfficeIMOError("INVALID_STATE", "openPart requires a caller-owned package sink.");
101
+ uri = this.reserve(uri, type);
102
+ this.parts.set(uri.toLowerCase(), { uri, written: true });
103
+ try {
104
+ return await this.zip.openEntry(uri.slice(1));
105
+ }
106
+ catch (error) {
107
+ await this.discard(error);
108
+ throw error;
109
+ }
110
+ }
111
+ addRelationship(source, relationship) {
112
+ checkAbort(this.options.signal);
113
+ this.open();
114
+ source = source === "/" ? source : partUri(source);
115
+ if (!/^[A-Za-z_][A-Za-z0-9_.-]*$/.test(relationship.id))
116
+ throw new TypeError("Relationship id must be an XML ID.");
117
+ if (!/^[A-Za-z][A-Za-z0-9+.-]*:[^\s<>"']+$/.test(relationship.type))
118
+ throw new TypeError("Relationship type must be an absolute URI.");
119
+ const target = relationship.external ? relationship.target : partUri(relationship.target);
120
+ if (relationship.external && (!target || /[\u0000-\u0020]/.test(target)))
121
+ throw new TypeError("Invalid external relationship target.");
122
+ const key = source.toLowerCase(), list = this.relationships.get(key) ?? new Map();
123
+ if (list.has(relationship.id))
124
+ throw new TypeError("Duplicate relationship id: " + relationship.id);
125
+ list.set(relationship.id, { ...relationship, target });
126
+ this.relationships.set(key, list);
127
+ }
128
+ setProperties(core = {}, app = {}) {
129
+ // Build and validate both documents before reserving any parts.
130
+ const coreXml = corePropertiesXml(core, this.options.invalidCharacterPolicy), appXml = appPropertiesXml(app, this.options.invalidCharacterPolicy);
131
+ this.addPart({ uri: "/docProps/core.xml", contentType: "application/vnd.openxmlformats-package.core-properties+xml", data: coreXml });
132
+ this.addPart({ uri: "/docProps/app.xml", contentType: "application/vnd.openxmlformats-officedocument.extended-properties+xml", data: appXml });
133
+ this.addRelationship("/", { id: "core", type: relationshipTypes.coreProperties, target: "/docProps/core.xml" });
134
+ this.addRelationship("/", { id: "app", type: relationshipTypes.appProperties, target: "/docProps/app.xml" });
135
+ }
136
+ source(data) {
137
+ if (typeof data === "string")
138
+ return async (sink) => { const text = new ChunkedTextSink(sink, this.options.signal); await text.write(data); await text.close(); };
139
+ if (data instanceof Blob)
140
+ return (async function* () {
141
+ for (let i = 0; i < data.size; i += 65536) {
142
+ let buffer;
143
+ try {
144
+ buffer = await data.slice(i, i + 65536).arrayBuffer();
145
+ }
146
+ catch (error) {
147
+ if (error?.name !== "NotReadableError")
148
+ throw error;
149
+ throw new OfficeIMOError("PLATFORM_UNAVAILABLE", "This environment cannot read Blob part data. Supply text or byte chunks; read Blobs before sending data to a worker.", { cause: error });
150
+ }
151
+ yield new Uint8Array(buffer);
152
+ }
153
+ })();
154
+ return data;
155
+ }
156
+ /** Complete pending parts and metadata without closing a caller-owned sink. */
157
+ finish() {
158
+ if (this.result)
159
+ return this.result;
160
+ this.open();
161
+ this.state = "finalizing";
162
+ this.result = (async () => {
163
+ const zip = this.zip;
164
+ try {
165
+ for (const [source, list] of this.relationships) {
166
+ if (source !== "/" && !this.parts.has(source))
167
+ throw new TypeError("Missing relationship source part: " + source);
168
+ let checked = 0;
169
+ for (const rel of list.values()) {
170
+ checkAbort(this.options.signal);
171
+ if (!rel.external && !this.parts.has(rel.target.toLowerCase()))
172
+ throw new TypeError("Missing relationship target: " + rel.target);
173
+ if ((++checked & 255) === 0 && taskYieldDue()) {
174
+ await pause();
175
+ checkAbort(this.options.signal);
176
+ }
177
+ }
178
+ }
179
+ for (const part of this.parts.values()) {
180
+ if ("written" in part)
181
+ continue;
182
+ if ("prepared" in part)
183
+ await zip.addPrepared(part.uri.slice(1), part.prepared);
184
+ else
185
+ await zip.add(part.uri.slice(1), this.source(part.data));
186
+ }
187
+ for (const [key, list] of this.relationships) {
188
+ const source = key === "/" ? "/" : this.parts.get(key).uri;
189
+ await zip.add(relationshipPartUri(source).slice(1), async (sink) => {
190
+ const text = new ChunkedTextSink(sink, this.options.signal);
191
+ await text.write(xmlDeclaration + '<Relationships xmlns="' + relationshipsNamespace + '">');
192
+ for (const r of list.values()) {
193
+ const xml = '<Relationship Id="' + escapeXml(r.id) + '" Type="' + escapeXml(r.type) + '" Target="' +
194
+ escapeXml(r.external ? r.target : relativePartTarget(source, r.target)) + '"' + (r.external ? ' TargetMode="External"' : "") + '/>';
195
+ if (text.append(xml))
196
+ await text.flush();
197
+ }
198
+ await text.write('</Relationships>');
199
+ await text.close();
200
+ });
201
+ }
202
+ await zip.add("[Content_Types].xml", this.source(this.types.toXml()));
203
+ await zip.finish();
204
+ this.state = "complete";
205
+ return zip.bytesWritten;
206
+ }
207
+ catch (error) {
208
+ await this.discard(error);
209
+ throw error;
210
+ }
211
+ finally {
212
+ this.parts.clear();
213
+ this.directories.clear();
214
+ this.relationships.clear();
215
+ }
216
+ })();
217
+ return this.result;
218
+ }
219
+ async toBlob(type = "application/zip") {
220
+ if (this.options.sink)
221
+ throw new OfficeIMOError("INVALID_STATE", "This package uses a caller-owned sink; use finish().");
222
+ await this.finish();
223
+ return this.zip.toBlob(type);
224
+ }
225
+ /** @internal Drop metadata and owned output after an export fails. */
226
+ async discard(error) {
227
+ this.state = "failed";
228
+ this.parts.clear();
229
+ this.directories.clear();
230
+ this.relationships.clear();
231
+ await this.zip.discard(error);
232
+ }
233
+ }
@@ -0,0 +1,15 @@
1
+ import type { InvalidCharacterPolicy } from "../xml/index.js";
2
+ export interface CoreProperties {
3
+ readonly creator?: string;
4
+ readonly title?: string;
5
+ readonly subject?: string;
6
+ readonly description?: string;
7
+ readonly created?: Date;
8
+ readonly modified?: Date;
9
+ }
10
+ export interface AppProperties {
11
+ readonly application?: string;
12
+ readonly company?: string;
13
+ }
14
+ export declare function corePropertiesXml(properties?: CoreProperties, policy?: InvalidCharacterPolicy): string;
15
+ export declare function appPropertiesXml(properties?: AppProperties, policy?: InvalidCharacterPolicy): string;
@@ -0,0 +1,18 @@
1
+ import { escapeXml, xmlDeclaration } from "../xml/index.js";
2
+ import { isDate } from "../core/dates.js";
3
+ export function corePropertiesXml(properties = {}, policy = "strip") {
4
+ const created = properties.created ?? new Date(), modified = properties.modified ?? created;
5
+ if (!isDate(created) || !isDate(modified) || !Number.isFinite(created.getTime()) || !Number.isFinite(modified.getTime()))
6
+ throw new TypeError("Invalid workbook property date.");
7
+ return xmlDeclaration + '<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"' +
8
+ ' xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' +
9
+ '<dc:creator>' + escapeXml(properties.creator ?? "", policy) + '</dc:creator><dc:title>' + escapeXml(properties.title ?? "", policy) + '</dc:title>' +
10
+ (properties.subject === undefined ? "" : '<dc:subject>' + escapeXml(properties.subject, policy) + '</dc:subject>') +
11
+ (properties.description === undefined ? "" : '<dc:description>' + escapeXml(properties.description, policy) + '</dc:description>') +
12
+ '<dcterms:created xsi:type="dcterms:W3CDTF">' + created.toISOString() + '</dcterms:created>' +
13
+ '<dcterms:modified xsi:type="dcterms:W3CDTF">' + modified.toISOString() + '</dcterms:modified></cp:coreProperties>';
14
+ }
15
+ export function appPropertiesXml(properties = {}, policy = "strip") {
16
+ return xmlDeclaration + '<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">' +
17
+ '<Application>' + escapeXml(properties.application ?? "OfficeIMO", policy) + '</Application><Company>' + escapeXml(properties.company ?? "", policy) + '</Company></Properties>';
18
+ }
@@ -0,0 +1,5 @@
1
+ /** Canonical absolute OPC part URI. ASCII URI spelling; Unicode must be UTF-8 percent encoded. */
2
+ export declare function partUri(value: string): string;
3
+ export declare function relationshipPartUri(source: string): string;
4
+ /** Relative target, derived from validated part URIs rather than caller-provided traversal. */
5
+ export declare function relativePartTarget(source: string, target: string): string;
@@ -0,0 +1,41 @@
1
+ import { OfficeIMOError } from "../core/errors.js";
2
+ /** Canonical absolute OPC part URI. ASCII URI spelling; Unicode must be UTF-8 percent encoded. */
3
+ export function partUri(value) {
4
+ const bad = () => new OfficeIMOError("INVALID_PART_URI", "Invalid OPC part URI: " + value);
5
+ if (typeof value !== "string" || !value.startsWith("/") || /[^A-Za-z0-9\-._~!$&'()*+,;=:@%/]/.test(value))
6
+ throw bad();
7
+ if (value.split("/").slice(1).some(s => !s || s.endsWith(".") || /^\.+$/.test(s)))
8
+ throw bad();
9
+ if (/%(?![\da-f]{2})/i.test(value))
10
+ throw bad();
11
+ for (const match of value.matchAll(/%([\da-f]{2})/gi)) {
12
+ const char = String.fromCharCode(parseInt(match[1], 16));
13
+ if (/[A-Za-z0-9_.~\-/\\]/.test(char))
14
+ throw bad();
15
+ }
16
+ try {
17
+ decodeURIComponent(value);
18
+ }
19
+ catch {
20
+ throw bad();
21
+ }
22
+ return value.replace(/%[\da-f]{2}/gi, s => s.toUpperCase());
23
+ }
24
+ export function relationshipPartUri(source) {
25
+ if (source === "/")
26
+ return "/_rels/.rels";
27
+ const uri = partUri(source), slash = uri.lastIndexOf("/");
28
+ return uri.slice(0, slash + 1) + "_rels/" + uri.slice(slash + 1) + ".rels";
29
+ }
30
+ /** Relative target, derived from validated part URIs rather than caller-provided traversal. */
31
+ export function relativePartTarget(source, target) {
32
+ const to = partUri(target).slice(1).split("/");
33
+ const from = source === "/" ? [] : partUri(source).slice(1).split("/").slice(0, -1);
34
+ while (from.length && from[0] === to[0]) {
35
+ from.shift();
36
+ to.shift();
37
+ }
38
+ const relative = "../".repeat(from.length) + to.join("/");
39
+ // RFC 3986 section 4.2 forbids a colon in a relative reference's first segment.
40
+ return relative.split("/", 1)[0].includes(":") ? "./" + relative : relative;
41
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import { OfficeIMOError } from "../core/errors.js";
2
+ import { pdfNumber, unicodeHex } from "./objects.js";
3
+ const encoder = new TextEncoder();
4
+ /** @internal URI actions are byte strings; tooltips are Unicode PDF text strings. */
5
+ export function linkAnnotation(link, x, bottom, width, height, maxBytes, structParent, page) {
6
+ const prefix = "<< /Type /Annot /Subtype /Link /F 4 /Border [0 0 0] /Rect [" +
7
+ [x, bottom, x + width, bottom + height].map(pdfNumber).join(" ") + "]" +
8
+ (structParent === undefined ? "" : " /StructParent " + structParent) + (page === undefined ? "" : " /P " + page + " 0 R") + " /A << /S /URI /URI <";
9
+ const suffix = "> >>" + (link.tooltip === undefined ? "" : " /Contents <feff") + " >>";
10
+ const fixedBytes = prefix.length + suffix.length + (link.tooltip === undefined ? 0 : link.tooltip.length * 4 + 1);
11
+ const limit = () => { throw new OfficeIMOError("RESOURCE_LIMIT", "maxPageBytes exceeded."); };
12
+ if (fixedBytes + link.target.length * 2 > maxBytes)
13
+ limit();
14
+ // Count before allocating the UTF-8 bytes or their hex representation. Lone
15
+ // surrogates become U+FFFD, matching TextEncoder's replacement behavior.
16
+ let uriBytes = 0;
17
+ for (let i = 0; i < link.target.length; i++) {
18
+ const code = link.target.charCodeAt(i);
19
+ if (code < 0x80)
20
+ uriBytes++;
21
+ else if (code < 0x800)
22
+ uriBytes += 2;
23
+ else if (code >= 0xd800 && code <= 0xdbff && i + 1 < link.target.length &&
24
+ link.target.charCodeAt(i + 1) >= 0xdc00 && link.target.charCodeAt(i + 1) <= 0xdfff) {
25
+ uriBytes += 4;
26
+ i++;
27
+ }
28
+ else
29
+ uriBytes += 3;
30
+ if (fixedBytes + uriBytes * 2 > maxBytes)
31
+ limit();
32
+ }
33
+ let uri = "";
34
+ for (const byte of encoder.encode(link.target))
35
+ uri += byte.toString(16).padStart(2, "0");
36
+ return prefix + uri + "> >>" +
37
+ (link.tooltip === undefined ? "" : " /Contents <feff" + unicodeHex(link.tooltip) + ">") + " >>";
38
+ }
@@ -0,0 +1,6 @@
1
+ export interface FontTable {
2
+ readonly offset: number;
3
+ readonly length: number;
4
+ }
5
+ export declare function checksum(bytes: Uint8Array): number;
6
+ export declare const align4: (value: number) => number;