reamkit 1.32.0 → 1.33.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 (157) hide show
  1. package/README.md +5 -4
  2. package/dist/esm/core/bidi/algorithm.js +2 -2
  3. package/dist/esm/core/bidi/char-types.js +1 -1
  4. package/dist/esm/core/bidi/index.js +3 -3
  5. package/dist/esm/core/bytes.js +1 -1
  6. package/dist/esm/core/converter/facade.js +3 -2
  7. package/dist/esm/core/converter/ream.js +12 -5
  8. package/dist/esm/core/crypto/asn1.js +2 -2
  9. package/dist/esm/core/crypto/cms.js +5 -3
  10. package/dist/esm/core/crypto/index.js +2 -1
  11. package/dist/esm/core/crypto/offcrypto.js +64 -19
  12. package/dist/esm/core/crypto/primitives.js +16 -16
  13. package/dist/esm/core/document-model/index.d.ts +1 -1
  14. package/dist/esm/core/document-model/types.d.ts +174 -2
  15. package/dist/esm/core/drawingml/chart-geometry.d.ts +45 -17
  16. package/dist/esm/core/drawingml/chart-geometry.js +1090 -257
  17. package/dist/esm/core/drawingml/chart-parser.d.ts +24 -1
  18. package/dist/esm/core/drawingml/chart-parser.js +334 -41
  19. package/dist/esm/core/drawingml/chart-text.d.ts +41 -0
  20. package/dist/esm/core/drawingml/chart-text.js +93 -0
  21. package/dist/esm/core/drawingml/colors.js +5 -5
  22. package/dist/esm/core/drawingml/diagram/layout-engine.js +1 -4
  23. package/dist/esm/core/drawingml/diagram/run.js +2 -1
  24. package/dist/esm/core/drawingml/preset-geometry.js +4 -6
  25. package/dist/esm/core/drawingml/shape-render.js +1 -1
  26. package/dist/esm/core/drawingml/text-warp.js +4 -16
  27. package/dist/esm/core/drawingml/theme-parser.js +14 -8
  28. package/dist/esm/core/font/arabic-joining.js +2 -2
  29. package/dist/esm/core/font/binary-reader.js +2 -0
  30. package/dist/esm/core/font/font-registry.js +1 -0
  31. package/dist/esm/core/font/ligatures.js +1 -1
  32. package/dist/esm/core/font/opentype-layout.js +11 -5
  33. package/dist/esm/core/font/ttf-build.js +6 -10
  34. package/dist/esm/core/font/ttf-parser.js +2 -1
  35. package/dist/esm/core/font/ttf-subset.js +8 -8
  36. package/dist/esm/core/fonts/families.js +1 -1
  37. package/dist/esm/core/fonts/remote-fonts.js +4 -4
  38. package/dist/esm/core/hyphenation/index.js +1 -1
  39. package/dist/esm/core/images.js +8 -8
  40. package/dist/esm/core/ir/loss.js +1 -0
  41. package/dist/esm/core/line-breaker/cjk.js +1 -1
  42. package/dist/esm/core/line-breaker/index.js +4 -3
  43. package/dist/esm/core/links.js +1 -1
  44. package/dist/esm/core/lzw.js +1 -1
  45. package/dist/esm/core/metafile/blit.js +1 -1
  46. package/dist/esm/core/metafile/emf.js +5 -7
  47. package/dist/esm/core/metafile/picture.js +1 -1
  48. package/dist/esm/core/metafile/symbol-fonts.js +7 -7
  49. package/dist/esm/core/metafile/wmf.js +5 -7
  50. package/dist/esm/core/number-format.d.ts +40 -15
  51. package/dist/esm/core/number-format.js +284 -79
  52. package/dist/esm/core/numbering/index.js +3 -2
  53. package/dist/esm/core/ole/cfb.js +4 -4
  54. package/dist/esm/core/ole/escher-blip.js +1 -1
  55. package/dist/esm/core/opc/index.js +5 -4
  56. package/dist/esm/core/opc/package.js +3 -1
  57. package/dist/esm/core/opc/tag-scan.d.ts +15 -0
  58. package/dist/esm/core/opc/tag-scan.js +41 -0
  59. package/dist/esm/core/opc/xml-entities.js +40 -3
  60. package/dist/esm/core/outline.js +1 -1
  61. package/dist/esm/core/png-encode.js +3 -3
  62. package/dist/esm/core/po-helpers.js +1 -1
  63. package/dist/esm/core/spreadsheet-model/types.d.ts +6 -0
  64. package/dist/esm/core/style-cascade/index.js +4 -3
  65. package/dist/esm/core/tiff.js +3 -1
  66. package/dist/esm/excel/activex-parser.js +1 -1
  67. package/dist/esm/excel/conditional-format.js +7 -7
  68. package/dist/esm/excel/formula/functions.js +45 -18
  69. package/dist/esm/excel/formula/index.js +3 -3
  70. package/dist/esm/excel/formula/lexer.js +2 -2
  71. package/dist/esm/excel/formula/parser.js +4 -3
  72. package/dist/esm/excel/formula/value.js +1 -1
  73. package/dist/esm/excel/index.js +7 -6
  74. package/dist/esm/excel/print-model.js +18 -7
  75. package/dist/esm/excel/printer-settings.js +6 -7
  76. package/dist/esm/excel/rich-value.js +1 -1
  77. package/dist/esm/excel/sheet-shape-parser.js +4 -2
  78. package/dist/esm/excel/sheet-to-flow.js +13 -11
  79. package/dist/esm/excel/styles-parser.js +5 -3
  80. package/dist/esm/excel/tint.js +5 -5
  81. package/dist/esm/excel/vml-drawing.js +3 -3
  82. package/dist/esm/excel/worksheet-parser.js +5 -5
  83. package/dist/esm/excel/xls/biff-chart.js +1 -3
  84. package/dist/esm/excel/xls/biff-reader.js +10 -11
  85. package/dist/esm/excel/xls/xls-reader.js +1 -1
  86. package/dist/esm/excel/xlsx-reader.js +56 -9
  87. package/dist/esm/excel/xlsx-to-pdf.js +1 -1
  88. package/dist/esm/excel/xlsx-writer.js +2 -2
  89. package/dist/esm/html/html-writer.js +18 -10
  90. package/dist/esm/layout/line-paint.js +1 -1
  91. package/dist/esm/layout/math-layout.js +5 -8
  92. package/dist/esm/layout/styled-layout.js +104 -32
  93. package/dist/esm/layout/turned-section.js +2 -2
  94. package/dist/esm/markdown/markdown-writer.js +59 -8
  95. package/dist/esm/pdf/encryption.js +9 -9
  96. package/dist/esm/pdf/icc-profile.js +2 -2
  97. package/dist/esm/pdf/index.js +3 -2
  98. package/dist/esm/pdf/objects.js +7 -0
  99. package/dist/esm/pdf/serialize.js +1 -1
  100. package/dist/esm/pdf/struct-tree.js +3 -1
  101. package/dist/esm/pdf/styled-page-emitter.js +23 -15
  102. package/dist/esm/pdf/styled-page-renderer.js +9 -5
  103. package/dist/esm/pdf-reader/annot-draw.js +5 -5
  104. package/dist/esm/pdf-reader/annots.js +3 -1
  105. package/dist/esm/pdf-reader/ccitt.js +2 -1
  106. package/dist/esm/pdf-reader/cff-outline.js +1 -4
  107. package/dist/esm/pdf-reader/content.js +13 -15
  108. package/dist/esm/pdf-reader/decrypt.js +5 -4
  109. package/dist/esm/pdf-reader/document.js +6 -2
  110. package/dist/esm/pdf-reader/encodings.js +1 -1
  111. package/dist/esm/pdf-reader/flow-build.js +4 -6
  112. package/dist/esm/pdf-reader/font.js +4 -4
  113. package/dist/esm/pdf-reader/function.js +8 -7
  114. package/dist/esm/pdf-reader/icc.js +1 -1
  115. package/dist/esm/pdf-reader/images.js +1 -1
  116. package/dist/esm/pdf-reader/jbig2.js +36 -38
  117. package/dist/esm/pdf-reader/jpeg.js +14 -13
  118. package/dist/esm/pdf-reader/layout.js +13 -10
  119. package/dist/esm/pdf-reader/lexer.js +2 -1
  120. package/dist/esm/pdf-reader/math-rows.js +2 -2
  121. package/dist/esm/pdf-reader/optional-content.js +1 -1
  122. package/dist/esm/pdf-reader/page-numbers.js +1 -1
  123. package/dist/esm/pdf-reader/pattern-tint.js +1 -2
  124. package/dist/esm/pdf-reader/reader.js +2 -2
  125. package/dist/esm/pdf-reader/struct-tree.js +1 -1
  126. package/dist/esm/pdf-reader/tagged.js +3 -2
  127. package/dist/esm/pdf-reader/text.js +2 -2
  128. package/dist/esm/pdf-reader/type1-outline.js +1 -3
  129. package/dist/esm/pptx/embedded-fonts.js +3 -5
  130. package/dist/esm/pptx/placeholder-cascade.js +1 -1
  131. package/dist/esm/pptx/ppt/ppt-reader.js +5 -4
  132. package/dist/esm/pptx/ppt/ppt-text.js +9 -10
  133. package/dist/esm/pptx/pptx-reader.js +6 -5
  134. package/dist/esm/pptx/preset-table-styles.js +1 -1
  135. package/dist/esm/pptx/slide-parser.js +6 -4
  136. package/dist/esm/pptx/sp-helpers.js +1 -1
  137. package/dist/esm/pptx/table-style.js +2 -1
  138. package/dist/esm/svg/svg-writer.js +1 -1
  139. package/dist/esm/word/doc/doc-reader.js +2 -2
  140. package/dist/esm/word/doc/doc-text.js +20 -22
  141. package/dist/esm/word/document-parser.js +27 -22
  142. package/dist/esm/word/docx-reader.js +15 -10
  143. package/dist/esm/word/docx-to-pdf.js +6 -6
  144. package/dist/esm/word/docx-writer.js +10 -6
  145. package/dist/esm/word/drawing-parser.js +18 -18
  146. package/dist/esm/word/font-table.js +90 -11
  147. package/dist/esm/word/index.js +6 -5
  148. package/dist/esm/word/numbering-parser.js +5 -4
  149. package/dist/esm/word/omml-parser.js +1 -1
  150. package/dist/esm/word/paragraph-properties.js +11 -10
  151. package/dist/esm/word/run-properties.js +4 -4
  152. package/dist/esm/word/settings-parser.js +2 -1
  153. package/dist/esm/word/shading.js +1 -1
  154. package/dist/esm/word/styles-parser.js +5 -4
  155. package/dist/esm/word/table-parser.js +4 -4
  156. package/dist/esm/word/theme-fonts.js +1 -1
  157. package/package.json +10 -4
@@ -0,0 +1,93 @@
1
+ import { poAttr, poChildren, poIs } from "../po-helpers.js";
2
+ import { resolveThemeFont } from "./theme-parser.js";
3
+ /**
4
+ * Resolve a chart's text, role by role: the element's own run properties over
5
+ * the chart's over the host's defaults.
6
+ *
7
+ * @param nodes Where each role's properties hang.
8
+ * @param resolveColor Maps a colour reference to RRGGBB — the default text colour.
9
+ * @param readFill Reads a run's `a:solidFill`.
10
+ * @param defaults The host's defaults and theme fonts.
11
+ * @returns Every role, resolved.
12
+ */
13
+ function chartTextStyles(nodes, resolveColor, readFill, defaults) {
14
+ const ctx = {
15
+ readFill,
16
+ fonts: defaults.themeFonts
17
+ };
18
+ const space = {
19
+ ...defaults.family ? { family: defaults.family } : {},
20
+ sizePt: 10,
21
+ colorHex: resolveColor({ scheme: "tx1" }) ?? "000000",
22
+ ...bodyStyle(child(nodes.chartSpace, "c:txPr"), ctx)
23
+ };
24
+ const titled = {
25
+ ...space,
26
+ bold: space.bold ?? true
27
+ };
28
+ const ofTitle = (title) => ({
29
+ ...titled,
30
+ ...titleStyle(title, ctx)
31
+ });
32
+ const ofText = (node) => ({
33
+ ...space,
34
+ ...bodyStyle(child(node, "c:txPr"), ctx)
35
+ });
36
+ return {
37
+ title: ofTitle(nodes.title),
38
+ legend: ofText(nodes.legend),
39
+ catAxis: ofText(nodes.catAxis),
40
+ valAxis: ofText(nodes.valAxis),
41
+ secondaryValAxis: ofText(nodes.secondaryValAxis ?? nodes.valAxis),
42
+ catAxisTitle: ofTitle(child(nodes.catAxis, "c:title")),
43
+ valAxisTitle: ofTitle(child(nodes.valAxis, "c:title")),
44
+ secondaryValAxisTitle: ofTitle(child(nodes.secondaryValAxis, "c:title")),
45
+ dataLabels: ofText(nodes.dataLabels)
46
+ };
47
+ }
48
+ /**
49
+ * A title's text: its `c:txPr`, then the rich text's paragraph defaults, then
50
+ * the first run's own properties — Excel keeps one style for a whole title.
51
+ */
52
+ function titleStyle(title, ctx) {
53
+ if (!title) return {};
54
+ const rich = child(child(title, "c:tx"), "c:rich");
55
+ const firstRun = rich ? poChildren(rich).filter((c) => poIs(c, "a:p")).flatMap((p) => poChildren(p)).find((c) => poIs(c, "a:r")) : void 0;
56
+ return {
57
+ ...bodyStyle(child(title, "c:txPr"), ctx),
58
+ ...bodyStyle(rich, ctx),
59
+ ...runStyle(child(firstRun, "a:rPr"), ctx)
60
+ };
61
+ }
62
+ /** A text body's paragraph defaults — the first paragraph's `a:pPr/a:defRPr`. */
63
+ function bodyStyle(body, ctx) {
64
+ return runStyle(child(child(body ? poChildren(body).find((c) => poIs(c, "a:p")) : void 0, "a:pPr"), "a:defRPr"), ctx);
65
+ }
66
+ /** §21.1.2.3.2 — one run-property node, read for what it states. */
67
+ function runStyle(node, ctx) {
68
+ if (!node) return {};
69
+ const size = Number(poAttr(node, "sz") ?? NaN);
70
+ const bold = flag(poAttr(node, "b"));
71
+ const italic = flag(poAttr(node, "i"));
72
+ const typeface = poAttr(child(node, "a:latin"), "typeface")?.trim();
73
+ const family = typeface ? resolveThemeFont(typeface, ctx.fonts) : void 0;
74
+ const fill = child(node, "a:solidFill");
75
+ const colorHex = fill ? ctx.readFill(fill) : void 0;
76
+ return {
77
+ ...family ? { family } : {},
78
+ ...Number.isFinite(size) && size >= 100 ? { sizePt: size / 100 } : {},
79
+ ...bold !== void 0 ? { bold } : {},
80
+ ...italic !== void 0 ? { italic } : {},
81
+ ...colorHex ? { colorHex } : {}
82
+ };
83
+ }
84
+ /** xsd:boolean, as an attribute states it. */
85
+ function flag(value) {
86
+ if (value === "1" || value === "true") return true;
87
+ if (value === "0" || value === "false") return false;
88
+ }
89
+ function child(node, tag) {
90
+ return node ? poChildren(node).find((c) => poIs(c, tag)) : void 0;
91
+ }
92
+ //#endregion
93
+ export { chartTextStyles };
@@ -134,7 +134,7 @@ function applyColorMods(hex, mods) {
134
134
  * Office 2013 default theme palette — the colours Word assigns to the standard
135
135
  * scheme slots when a document carries no custom theme part.
136
136
  */
137
- var DEFAULT_THEME_PALETTE = new Map([
137
+ var DEFAULT_THEME_PALETTE = /* @__PURE__ */ new Map([
138
138
  ["dk1", "000000"],
139
139
  ["lt1", "FFFFFF"],
140
140
  ["dk2", "44546A"],
@@ -153,7 +153,7 @@ var DEFAULT_THEME_PALETTE = new Map([
153
153
  * no theme part with. Its own PDF of theme slots 0…9 in such a workbook
154
154
  * (2026-10-01) paints exactly these: accent1 is 156082, not 2013's 4472C4.
155
155
  */
156
- var OFFICE_2023_THEME_PALETTE = new Map([
156
+ var OFFICE_2023_THEME_PALETTE = /* @__PURE__ */ new Map([
157
157
  ["dk1", "000000"],
158
158
  ["lt1", "FFFFFF"],
159
159
  ["dk2", "0E2841"],
@@ -217,7 +217,7 @@ function placeholderColors(base, phHex) {
217
217
  }
218
218
  /** A {@link ColorResolver} backed by the {@link DEFAULT_THEME_PALETTE}. */
219
219
  var defaultColorResolver = makeColorResolver(DEFAULT_THEME_PALETTE);
220
- var PRESET_COLORS = new Map([
220
+ var PRESET_COLORS = /* @__PURE__ */ new Map([
221
221
  ["black", "000000"],
222
222
  ["white", "FFFFFF"],
223
223
  ["gray", "808080"],
@@ -280,7 +280,7 @@ function readColorMods(colorNode) {
280
280
  * what a reader uses; the two names that matter without one are the window
281
281
  * background and its text.
282
282
  */
283
- var SYSTEM_COLORS = new Map([
283
+ var SYSTEM_COLORS = /* @__PURE__ */ new Map([
284
284
  ["window", "FFFFFF"],
285
285
  ["windowText", "000000"],
286
286
  ["windowFrame", "000000"],
@@ -325,4 +325,4 @@ function resolveColorNode(c, resolveColor) {
325
325
  } : raw);
326
326
  }
327
327
  //#endregion
328
- export { DEFAULT_SCHEME_ALIAS, DEFAULT_THEME_PALETTE, OFFICE_2023_THEME_PALETTE, defaultColorResolver, makeColorResolver, placeholderColors, readColorMods, resolveColorNode };
328
+ export { DEFAULT_SCHEME_ALIAS, DEFAULT_THEME_PALETTE, OFFICE_2023_THEME_PALETTE, applyColorMods, defaultColorResolver, makeColorResolver, placeholderColors, readColorMods, resolveColorNode, resolveSchemeName };
@@ -376,10 +376,7 @@ function rectIn(constrs, name, box, placed, fontEmu = 0, outer = []) {
376
376
  case "ctrX":
377
377
  x = box.x + v - cx / 2;
378
378
  break;
379
- case "ctrY":
380
- y = box.y + v - cy / 2;
381
- break;
382
- default: break;
379
+ case "ctrY": y = box.y + v - cy / 2;
383
380
  }
384
381
  }
385
382
  return {
@@ -40,7 +40,8 @@ function laidOutDiagramTree(parts, frame, parse) {
40
40
  const data = new DiagramData(parse(parts.data));
41
41
  const nodes = layoutDiagram(parse(parts.layout), data, frame.cx, frame.cy);
42
42
  if (nodes.length === 0) return void 0;
43
- const xml = diagramDrawingXml(nodes, frame, parts.colors ? new DiagramColors(parse(parts.colors)) : void 0, data.background);
43
+ const colors = parts.colors ? new DiagramColors(parse(parts.colors)) : void 0;
44
+ const xml = diagramDrawingXml(nodes, frame, colors, data.background);
44
45
  for (const root of parse(new TextEncoder().encode(xml))) {
45
46
  const found = poFindDescendant(root, "dsp:spTree");
46
47
  if (found) return found;
@@ -499,9 +499,7 @@ function customPaths(geom, wPt, hPt) {
499
499
  curY = cyP + cmd.hR * Math.sin(st + sw);
500
500
  break;
501
501
  }
502
- case "close":
503
- b.close();
504
- break;
502
+ case "close": b.close();
505
503
  }
506
504
  return [b.build()];
507
505
  }
@@ -509,7 +507,7 @@ var SQUARE = {
509
507
  cut: 0,
510
508
  round: false
511
509
  };
512
- var CORNER_RECTS = new Map([
510
+ var CORNER_RECTS = /* @__PURE__ */ new Map([
513
511
  ["round1Rect", {
514
512
  defaults: [16667, 0],
515
513
  corners: [
@@ -637,7 +635,7 @@ function roundedCorners(w, h, [tl, tr, br, bl]) {
637
635
  });
638
636
  return b.close().build();
639
637
  }
640
- var STARS = new Map([
638
+ var STARS = /* @__PURE__ */ new Map([
641
639
  ["star4", {
642
640
  points: 4,
643
641
  adj: 12500,
@@ -806,4 +804,4 @@ function blockArrow(w, h, adjust, dir) {
806
804
  ]);
807
805
  }
808
806
  //#endregion
809
- export { customPaths, presetPaths, rectPath };
807
+ export { customPaths, presetPaths, rectPath, rectSegments };
@@ -275,4 +275,4 @@ function buildShapeTransform(pageX, pageY, widthPt, heightPt, rotation60k, flipH
275
275
  ];
276
276
  }
277
277
  //#endregion
278
- export { DEFAULT_INSET_LR_PT, DEFAULT_INSET_TB_PT, buildShapePaths, buildShapeTransform, buildStroke, gradientSvgDef, gradientToSolid, lineEndPaths };
278
+ export { DEFAULT_INSET_LR_PT, DEFAULT_INSET_TB_PT, EMU_PER_PT, buildShapePaths, buildShapeTransform, buildStroke, gradientSvgDef, gradientToSolid, lineEndPaths };
@@ -11,7 +11,7 @@ var band = (top, drop) => ({
11
11
  * name. `adj` arrives as the `a:avLst` adjustment in hundred-thousandths, or
12
12
  * the preset's own default when the file states none.
13
13
  */
14
- var ENVELOPES = new Map([
14
+ var ENVELOPES = /* @__PURE__ */ new Map([
15
15
  ["textPlain", {
16
16
  defaultAdj: 0,
17
17
  at: () => ({
@@ -196,19 +196,7 @@ var ENVELOPES = new Map([
196
196
  at: (u, adj) => curve(u, adj)
197
197
  }]
198
198
  ]);
199
- /**
200
- * The ring presets, which do not hang text between two edges at all: they wind
201
- * it once round an ellipse inscribed in the box. Both start at the box's left
202
- * edge; `Inside` climbs over the top with each letter's head pointing out of
203
- * the ring, `Outside` dips under the bottom with each letter's head pointing
204
- * into it — which is why half of either one reads upside down.
205
- *
206
- * The band the letters occupy is a fixed share of the ring whatever the text:
207
- * eight letters and thirty-two fill exactly the same annulus, so it is the
208
- * preset and not the string that fixes the inner radius.
209
- */
210
- var RING_INNER = .34;
211
- var RINGS = new Map([["textRingInside", {
199
+ var RINGS = /* @__PURE__ */ new Map([["textRingInside", {
212
200
  clockwise: true,
213
201
  headOut: true
214
202
  }], ["textRingOutside", {
@@ -323,7 +311,7 @@ function ringMatrix(frame, ring, _u, v, glyphX) {
323
311
  const inX = -turn * -ty;
324
312
  const inY = -turn * tx;
325
313
  const head = ring.headOut ? -1 : 1;
326
- const depth = (1 - RING_INNER) * b;
314
+ const depth = .6599999999999999 * b;
327
315
  const sT = 2 * Math.PI * speed / frame.srcWidth;
328
316
  const sN = depth / frame.srcHeight;
329
317
  const inset = (ring.headOut ? v : 1 - v) * depth;
@@ -352,4 +340,4 @@ function textWarpEdges(preset, u, adj) {
352
340
  return env.at(Math.min(1, Math.max(0, u)), a);
353
341
  }
354
342
  //#endregion
355
- export { isTextWarp, warpGlyphMatrix };
343
+ export { isTextWarp, textWarpEdges, warpGlyphMatrix };
@@ -11,7 +11,7 @@ var parser = new XMLParser({
11
11
  parseTagValue: false,
12
12
  trimValues: false
13
13
  });
14
- var SCHEME_SLOTS = new Set([
14
+ var SCHEME_SLOTS = /* @__PURE__ */ new Set([
15
15
  "dk1",
16
16
  "lt1",
17
17
  "dk2",
@@ -32,7 +32,8 @@ var SCHEME_SLOTS = new Set([
32
32
  * @returns The two fonts; slots the theme leaves empty are absent.
33
33
  */
34
34
  function parseThemeFonts(themeXml) {
35
- const scheme = poFindByPath(parser.parse(decoder.decode(themeXml)), [
35
+ const tree = parser.parse(decoder.decode(themeXml));
36
+ const scheme = poFindByPath(tree, [
36
37
  "a:theme",
37
38
  "a:themeElements",
38
39
  "a:fontScheme"
@@ -60,7 +61,7 @@ function parseThemeFonts(themeXml) {
60
61
  minor: read("a:minorFont")
61
62
  };
62
63
  }
63
- var THEME_FONT_TOKENS = new Map([
64
+ var THEME_FONT_TOKENS = /* @__PURE__ */ new Map([
64
65
  ["+mj-lt", ["major", "latin"]],
65
66
  ["+mn-lt", ["minor", "latin"]],
66
67
  ["+mj-ea", ["major", "ea"]],
@@ -101,7 +102,8 @@ function resolveThemeFont(typeface, fonts) {
101
102
  */
102
103
  function parseTheme(themeXml) {
103
104
  const out = /* @__PURE__ */ new Map();
104
- const clrScheme = poFindByPath(parser.parse(decoder.decode(themeXml)), [
105
+ const tree = parser.parse(decoder.decode(themeXml));
106
+ const clrScheme = poFindByPath(tree, [
105
107
  "a:theme",
106
108
  "a:themeElements",
107
109
  "a:clrScheme"
@@ -129,7 +131,8 @@ function parseTheme(themeXml) {
129
131
  * no `a:fmtScheme`.
130
132
  */
131
133
  function parseThemeLineWidths(themeXml) {
132
- const list = poFindByPath(parser.parse(decoder.decode(themeXml)), [
134
+ const tree = parser.parse(decoder.decode(themeXml));
135
+ const list = poFindByPath(tree, [
133
136
  "a:theme",
134
137
  "a:themeElements",
135
138
  "a:fmtScheme",
@@ -162,7 +165,8 @@ function parseThemeLineWidths(themeXml) {
162
165
  * declares no `a:fmtScheme`.
163
166
  */
164
167
  function parseThemeFillStyles(themeXml) {
165
- const list = poFindByPath(parser.parse(decoder.decode(themeXml)), [
168
+ const tree = parser.parse(decoder.decode(themeXml));
169
+ const list = poFindByPath(tree, [
166
170
  "a:theme",
167
171
  "a:themeElements",
168
172
  "a:fmtScheme",
@@ -186,7 +190,8 @@ function fillsOf(list) {
186
190
  * @returns The fill children in list order; empty when the theme declares none.
187
191
  */
188
192
  function parseThemeBgFillStyles(themeXml) {
189
- const list = poFindByPath(parser.parse(decoder.decode(themeXml)), [
193
+ const tree = parser.parse(decoder.decode(themeXml));
194
+ const list = poFindByPath(tree, [
190
195
  "a:theme",
191
196
  "a:themeElements",
192
197
  "a:fmtScheme",
@@ -204,7 +209,8 @@ function parseThemeBgFillStyles(themeXml) {
204
209
  * declares no `a:fmtScheme`.
205
210
  */
206
211
  function parseThemeEffectStyles(themeXml) {
207
- const list = poFindByPath(parser.parse(decoder.decode(themeXml)), [
212
+ const tree = parser.parse(decoder.decode(themeXml));
213
+ const list = poFindByPath(tree, [
208
214
  "a:theme",
209
215
  "a:themeElements",
210
216
  "a:fmtScheme",
@@ -1,5 +1,5 @@
1
1
  //#region src/core/font/arabic-joining.ts
2
- var RIGHT_JOINING = new Set([
2
+ var RIGHT_JOINING = /* @__PURE__ */ new Set([
3
3
  1570,
4
4
  1571,
5
5
  1572,
@@ -110,4 +110,4 @@ function assignArabicForms(cps) {
110
110
  return forms;
111
111
  }
112
112
  //#endregion
113
- export { assignArabicForms };
113
+ export { arabicJoiningType, assignArabicForms };
@@ -5,6 +5,8 @@
5
5
  * Each read advances {@link BigEndianReader.offset}.
6
6
  */
7
7
  var BigEndianReader = class {
8
+ data;
9
+ offset;
8
10
  /**
9
11
  * @param data The buffer to read from.
10
12
  * @param offset The starting byte offset (default 0).
@@ -24,6 +24,7 @@ function pickVariant(has, bold, italic) {
24
24
  * through `bold → italic → regular` when an exact match is missing.
25
25
  */
26
26
  var FontRegistry = class FontRegistry {
27
+ fonts;
27
28
  constructor(fonts) {
28
29
  this.fonts = fonts;
29
30
  }
@@ -30,7 +30,7 @@ function lettersForLigature(cp) {
30
30
  return LIGATURE_LETTERS.get(cp);
31
31
  }
32
32
  /** U+FB00..FB06 — `ſt` opens with a long s, which is an s. */
33
- var LIGATURE_LETTERS = new Map([
33
+ var LIGATURE_LETTERS = /* @__PURE__ */ new Map([
34
34
  [64256, "ff"],
35
35
  [64257, "fi"],
36
36
  [64258, "fl"],
@@ -110,7 +110,8 @@ function collectLookupOffsets(raw, table, wantedFeatures) {
110
110
  const tag = fr.tag();
111
111
  const featureOff = fr.u16();
112
112
  if (wantedFeatures.includes(tag)) {
113
- const fr2 = new BigEndianReader(raw, featureListBase + featureOff);
113
+ const featBase = featureListBase + featureOff;
114
+ const fr2 = new BigEndianReader(raw, featBase);
114
115
  fr2.u16();
115
116
  const lookupCount = fr2.u16();
116
117
  for (let k = 0; k < lookupCount; k++) featureWanted.add(fr2.u16());
@@ -191,7 +192,8 @@ function parsePairPosFormat1(raw, subtableOffset, out) {
191
192
  for (let i = 0; i < pairSetCount; i++) {
192
193
  const first = coverage[i];
193
194
  if (first === void 0) continue;
194
- const psr = new BigEndianReader(raw, subtableOffset + pairSetOffs[i]);
195
+ const psBase = subtableOffset + pairSetOffs[i];
196
+ const psr = new BigEndianReader(raw, psBase);
195
197
  const pairCount = psr.u16();
196
198
  for (let j = 0; j < pairCount; j++) {
197
199
  const second = psr.u16();
@@ -222,7 +224,8 @@ function parsePairPosFormat2(raw, subtableOffset, out) {
222
224
  const class2 = readClassDef(raw, subtableOffset + classDef2Off);
223
225
  const recordsBase = r.offset;
224
226
  for (let i = 0; i < class1Count; i++) for (let j = 0; j < class2Count; j++) {
225
- const pr = new BigEndianReader(raw, recordsBase + (i * class2Count + j) * pairRecordSize);
227
+ const recordOff = recordsBase + (i * class2Count + j) * pairRecordSize;
228
+ const pr = new BigEndianReader(raw, recordOff);
226
229
  const v1 = readValueRecordAdvance(pr, valueFormat1);
227
230
  pr.skip(value1Size - bytesRead(valueFormat1));
228
231
  const v2 = readValueRecordAdvance(pr, valueFormat2);
@@ -352,7 +355,10 @@ function shapeText(text, glyphForCodepoint, advanceWidths, ligatures, kerning, j
352
355
  i += bestLen;
353
356
  }
354
357
  const advances = new Array(ligated.length);
355
- for (let j = 0; j < ligated.length; j++) advances[j] = advanceWidths[ligated[j]] ?? 0;
358
+ for (let j = 0; j < ligated.length; j++) {
359
+ const gid = ligated[j];
360
+ advances[j] = advanceWidths[gid] ?? 0;
361
+ }
356
362
  for (let j = 1; j < ligated.length; j++) {
357
363
  const adj = kerning.get(`${ligated[j - 1]},${ligated[j]}`);
358
364
  if (adj !== void 0 && adj !== 0) advances[j - 1] += adj;
@@ -363,4 +369,4 @@ function shapeText(text, glyphForCodepoint, advanceWidths, ligatures, kerning, j
363
369
  };
364
370
  }
365
371
  //#endregion
366
- export { parseGposKerning, parseGsubArabicForms, parseGsubLigatures, shapeText };
372
+ export { EMPTY_JOINING_FORMS, parseGposKerning, parseGsubArabicForms, parseGsubLigatures, shapeText };
@@ -8,8 +8,6 @@ var MAX_KERN_PAIRS = Math.floor(65521 / 6);
8
8
  /** OS/2 `fsType` bits (ISO/IEC 14496-22, OS/2 table). */
9
9
  var USAGE_BITS = 14;
10
10
  var EDITABLE_EMBEDDING = 8;
11
- var NO_SUBSETTING = 256;
12
- var BITMAP_ONLY = 512;
13
11
  /**
14
12
  * Whether a face's licence lets it be embedded, as outlines and subset, in a
15
13
  * document that stays EDITABLE: OS/2 `fsType` states installable embedding (no
@@ -26,7 +24,7 @@ var BITMAP_ONLY = 512;
26
24
  */
27
25
  function editableEmbedding(fsType) {
28
26
  if (fsType === void 0) return true;
29
- if ((fsType & (NO_SUBSETTING | BITMAP_ONLY)) !== 0) return false;
27
+ if ((fsType & 768) !== 0) return false;
30
28
  const usage = fsType & USAGE_BITS;
31
29
  return usage === 0 || (usage & EDITABLE_EMBEDDING) !== 0;
32
30
  }
@@ -291,7 +289,7 @@ function area(points) {
291
289
  }
292
290
  function emptyGlyph() {
293
291
  return {
294
- bytes: new Uint8Array(0),
292
+ bytes: /* @__PURE__ */ new Uint8Array(0),
295
293
  contours: 0,
296
294
  points: 0,
297
295
  xMin: 0,
@@ -612,8 +610,7 @@ function ligatureTable(face, ligatures) {
612
610
  const substHeader = 6 + firsts.length * 2;
613
611
  const coverageSize = 4 + firsts.length * 2;
614
612
  const setSize = (set) => 2 + set.length * 2 + set.reduce((n, lig) => n + 4 + lig.rest.length * 2, 0);
615
- const SUBST_AT = 62;
616
- const out = new Writer(SUBST_AT + substHeader + coverageSize + sets.reduce((n, set) => n + setSize(set), 0));
613
+ const out = new Writer(62 + substHeader + coverageSize + sets.reduce((n, set) => n + setSize(set), 0));
617
614
  out.u16(1);
618
615
  out.u16(0);
619
616
  out.u16(10);
@@ -641,7 +638,7 @@ function ligatureTable(face, ligatures) {
641
638
  out.u16(4);
642
639
  out.u16(0);
643
640
  out.u16(1);
644
- out.u16(SUBST_AT - 54);
641
+ out.u16(8);
645
642
  out.u16(1);
646
643
  out.u16(substHeader);
647
644
  out.u16(firsts.length);
@@ -738,8 +735,7 @@ function gposTable(pairs) {
738
735
  const pairPosHeader = 10 + lefts.length * 2;
739
736
  const coverageSize = 4 + lefts.length * 2;
740
737
  const pairSetsSize = lefts.reduce((n, left) => n + 2 + byLeft.get(left).length * 4, 0);
741
- const PAIR_POS_AT = 62;
742
- const out = new Writer(PAIR_POS_AT + pairPosHeader + coverageSize + pairSetsSize);
738
+ const out = new Writer(62 + pairPosHeader + coverageSize + pairSetsSize);
743
739
  out.u16(1);
744
740
  out.u16(0);
745
741
  out.u16(10);
@@ -767,7 +763,7 @@ function gposTable(pairs) {
767
763
  out.u16(2);
768
764
  out.u16(0);
769
765
  out.u16(1);
770
- out.u16(PAIR_POS_AT - 54);
766
+ out.u16(8);
771
767
  out.u16(1);
772
768
  out.u16(pairPosHeader);
773
769
  out.u16(4);
@@ -263,7 +263,8 @@ function buildCmapFormat4(raw, offset) {
263
263
  if (seg < 0) return 0;
264
264
  if (startCode[seg] > cp) return 0;
265
265
  if (idRangeOffset[seg] === 0) return cp + idDelta[seg] & 65535;
266
- const glyphId = new BigEndianReader(raw, idRangeOffsetPos + seg * 2 + idRangeOffset[seg] + (cp - startCode[seg]) * 2).u16();
266
+ const glyphIdByteOffset = idRangeOffsetPos + seg * 2 + idRangeOffset[seg] + (cp - startCode[seg]) * 2;
267
+ const glyphId = new BigEndianReader(raw, glyphIdByteOffset).u16();
267
268
  if (glyphId === 0) return 0;
268
269
  return glyphId + idDelta[seg] & 65535;
269
270
  };
@@ -15,7 +15,7 @@ var MAGIC_HEAD_CHECKSUM = 2981146554;
15
15
  * 136 KB font program in 55906-MultiSheetRefs.xlsx. `OS/2` is kept because
16
16
  * viewers read its metrics when a descriptor is incomplete.
17
17
  */
18
- var EMBEDDABLE_TABLES = new Set([
18
+ var EMBEDDABLE_TABLES = /* @__PURE__ */ new Set([
19
19
  "glyf",
20
20
  "head",
21
21
  "hhea",
@@ -62,11 +62,11 @@ function subsetTtf(parsed, usedGids) {
62
62
  */
63
63
  function glyphClosure(parsed, usedGids) {
64
64
  const glyf = parsed.tables.get("glyf");
65
- if (!glyf) return new Set([0, ...usedGids]);
65
+ if (!glyf) return /* @__PURE__ */ new Set([0, ...usedGids]);
66
66
  return computeGlyphClosure(parsed, glyf, usedGids);
67
67
  }
68
68
  function computeGlyphClosure(parsed, glyf, seed) {
69
- const closure = new Set([0]);
69
+ const closure = /* @__PURE__ */ new Set([0]);
70
70
  for (const g of seed) closure.add(g);
71
71
  const stack = [...closure];
72
72
  while (stack.length > 0) {
@@ -117,7 +117,7 @@ function rewriteGlyfLoca(parsed, glyf, closure) {
117
117
  parts.push(data);
118
118
  cursor += data.length;
119
119
  if (cursor & 1) {
120
- parts.push(new Uint8Array(1));
120
+ parts.push(/* @__PURE__ */ new Uint8Array(1));
121
121
  cursor++;
122
122
  }
123
123
  }
@@ -135,11 +135,11 @@ function assembleSubsetTtf(parsed, newGlyf, newLoca) {
135
135
  const oldHead = parsed.raw.subarray(headInfo.offset, headInfo.offset + headInfo.length);
136
136
  const newHead = new Uint8Array(oldHead);
137
137
  newHead[HEAD_CHECKSUM_ADJUSTMENT_OFFSET] = 0;
138
- newHead[HEAD_CHECKSUM_ADJUSTMENT_OFFSET + 1] = 0;
139
- newHead[HEAD_CHECKSUM_ADJUSTMENT_OFFSET + 2] = 0;
140
- newHead[HEAD_CHECKSUM_ADJUSTMENT_OFFSET + 3] = 0;
138
+ newHead[9] = 0;
139
+ newHead[10] = 0;
140
+ newHead[11] = 0;
141
141
  newHead[HEAD_INDEX_TO_LOC_FORMAT_OFFSET] = 0;
142
- newHead[HEAD_INDEX_TO_LOC_FORMAT_OFFSET + 1] = 1;
142
+ newHead[51] = 1;
143
143
  const orderedTags = [...parsed.tables.keys()].filter((t) => EMBEDDABLE_TABLES.has(t));
144
144
  const tableData = /* @__PURE__ */ new Map();
145
145
  for (const tag of orderedTags) if (tag === "glyf") tableData.set(tag, newGlyf);
@@ -38,7 +38,7 @@ function familiesInFlow(flow) {
38
38
  for (const note of flow.footnotes?.values() ?? []) visit(note);
39
39
  for (const note of flow.endnotes?.values() ?? []) visit(note);
40
40
  for (const comment of flow.comments?.values() ?? []) visit(comment.content);
41
- const keys = new Set(["arimo"]);
41
+ const keys = /* @__PURE__ */ new Set(["arimo"]);
42
42
  for (const name of names) keys.add(resolveFamilyKey(name));
43
43
  return keys;
44
44
  }
@@ -89,7 +89,7 @@ var EXACT = {
89
89
  courier: "cousine",
90
90
  "liberation mono": "cousine"
91
91
  };
92
- var SERIF = new Set([
92
+ var SERIF = /* @__PURE__ */ new Set([
93
93
  "georgia",
94
94
  "garamond",
95
95
  "book antiqua",
@@ -98,7 +98,7 @@ var SERIF = new Set([
98
98
  "minion pro",
99
99
  "serif"
100
100
  ]);
101
- var SANS = new Set([
101
+ var SANS = /* @__PURE__ */ new Set([
102
102
  "roboto",
103
103
  "noto sans",
104
104
  "notosans",
@@ -113,7 +113,7 @@ var SANS = new Set([
113
113
  "sans",
114
114
  "sans serif"
115
115
  ]);
116
- var MONO = new Set([
116
+ var MONO = /* @__PURE__ */ new Set([
117
117
  "mono",
118
118
  "monospaced",
119
119
  "consolas",
@@ -209,7 +209,7 @@ function familyFromStem(name) {
209
209
  return key;
210
210
  }
211
211
  }
212
- var WEIGHT_WORDS = new Map([
212
+ var WEIGHT_WORDS = /* @__PURE__ */ new Map([
213
213
  ["black", "bold"],
214
214
  ["heavy", "bold"],
215
215
  ["bold", "bold"],
@@ -52,4 +52,4 @@ function createLanguageHyphenator(language, bundle) {
52
52
  });
53
53
  }
54
54
  //#endregion
55
- export { createLanguageHyphenator, getHyphenator };
55
+ export { createHyphenator, createLanguageHyphenator, getHyphenator, splitPatternBundle };
@@ -315,7 +315,7 @@ function decodeGif(bytes) {
315
315
  const screenH = u16(8);
316
316
  const packed = bytes[10] ?? 0;
317
317
  let pos = 13;
318
- let globalPalette = new Uint8Array(0);
318
+ let globalPalette = /* @__PURE__ */ new Uint8Array(0);
319
319
  if ((packed & 128) !== 0) {
320
320
  const size = 3 * (1 << (packed & 7) + 1);
321
321
  globalPalette = bytes.subarray(pos, pos + size);
@@ -367,13 +367,13 @@ function lzwDecode(data, minCodeSize, pixelCount) {
367
367
  const end = clear + 1;
368
368
  const out = new Uint8Array(pixelCount);
369
369
  let outPos = 0;
370
- let prefix = new Int32Array(4096);
371
- let suffix = new Uint8Array(4096);
372
- let length = new Int32Array(4096);
370
+ let prefix = /* @__PURE__ */ new Int32Array(4096);
371
+ let suffix = /* @__PURE__ */ new Uint8Array(4096);
372
+ let length = /* @__PURE__ */ new Int32Array(4096);
373
373
  const reset = () => {
374
- prefix = new Int32Array(4096);
375
- suffix = new Uint8Array(4096);
376
- length = new Int32Array(4096);
374
+ prefix = /* @__PURE__ */ new Int32Array(4096);
375
+ suffix = /* @__PURE__ */ new Uint8Array(4096);
376
+ length = /* @__PURE__ */ new Int32Array(4096);
377
377
  for (let i = 0; i < clear; i++) {
378
378
  prefix[i] = -1;
379
379
  suffix[i] = i;
@@ -386,7 +386,7 @@ function lzwDecode(data, minCodeSize, pixelCount) {
386
386
  let prev = -1;
387
387
  let bitBuf = 0;
388
388
  let bitCount = 0;
389
- const stack = new Uint8Array(4096);
389
+ const stack = /* @__PURE__ */ new Uint8Array(4096);
390
390
  for (let i = 0; i < data.length || bitCount >= codeSize;) {
391
391
  while (bitCount < codeSize && i < data.length) {
392
392
  bitBuf |= (data[i] & 255) << bitCount;
@@ -12,6 +12,7 @@ function formatLoss(loss) {
12
12
  }
13
13
  /** Thrown by strict-mode conversions on the first recorded loss. */
14
14
  var ConversionLossError = class extends Error {
15
+ loss;
15
16
  /** @param loss The first loss that tripped strict mode (retained on the error). */
16
17
  constructor(loss) {
17
18
  super(`strict conversion failed — ${formatLoss(loss)}`);
@@ -57,4 +57,4 @@ function cjkBreakBetween(left, right) {
57
57
  return true;
58
58
  }
59
59
  //#endregion
60
- export { cjkBreakBetween, isCjkWide, splitCjkSegment };
60
+ export { cjkBreakBetween, isCjkNoBreakAfter, isCjkNoBreakBefore, isCjkWide, splitCjkSegment };
@@ -1,3 +1,4 @@
1
- import "./knuth-plass.js";
2
- import "./greedy.js";
3
- import "./cjk.js";
1
+ import { FORCED_BREAK, breakLines } from "./knuth-plass.js";
2
+ import { greedyBreakLines } from "./greedy.js";
3
+ import { cjkBreakBetween, splitCjkSegment } from "./cjk.js";
4
+ export { FORCED_BREAK, breakLines, cjkBreakBetween, greedyBreakLines, splitCjkSegment };
@@ -1,5 +1,5 @@
1
1
  //#region src/core/links.ts
2
- var ALLOWED_SCHEMES = new Set([
2
+ var ALLOWED_SCHEMES = /* @__PURE__ */ new Set([
3
3
  "http",
4
4
  "https",
5
5
  "mailto"