@vyaz/core 0.0.11 → 0.0.16

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 (47) hide show
  1. package/dist/compile/DocumentCompiler.d.ts +1 -0
  2. package/dist/compile/DocumentCompiler.d.ts.map +1 -0
  3. package/dist/index.browser.d.ts +19 -43
  4. package/dist/index.browser.d.ts.map +1 -0
  5. package/dist/index.browser.js +69 -39
  6. package/dist/index.d.ts +33 -48
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +43 -32
  9. package/dist/layout/AutoFitEngine.d.ts +1 -0
  10. package/dist/layout/AutoFitEngine.d.ts.map +1 -0
  11. package/dist/layout/LineBoxValidator.d.ts +1 -0
  12. package/dist/layout/LineBoxValidator.d.ts.map +1 -0
  13. package/dist/layout/ParagraphLayoutEngine.d.ts +1 -0
  14. package/dist/layout/ParagraphLayoutEngine.d.ts.map +1 -0
  15. package/dist/layout/PositioningEngine.d.ts +1 -0
  16. package/dist/layout/PositioningEngine.d.ts.map +1 -0
  17. package/dist/layout/TextFrameLayoutEngine.d.ts +1 -0
  18. package/dist/layout/TextFrameLayoutEngine.d.ts.map +1 -0
  19. package/dist/layout/estimateWidth.d.ts +1 -0
  20. package/dist/layout/estimateWidth.d.ts.map +1 -0
  21. package/dist/measure/FontEngine.d.ts +1 -0
  22. package/dist/measure/FontEngine.d.ts.map +1 -0
  23. package/dist/measure/FontMetricsProvider.d.ts +62 -9
  24. package/dist/measure/FontMetricsProvider.d.ts.map +1 -0
  25. package/dist/measure/FontNotFoundError.d.ts +1 -0
  26. package/dist/measure/FontNotFoundError.d.ts.map +1 -0
  27. package/dist/measure/SystemFontRegistry.d.ts +1 -0
  28. package/dist/measure/SystemFontRegistry.d.ts.map +1 -0
  29. package/dist/measure/canvas-polyfill.d.ts +8 -2
  30. package/dist/measure/canvas-polyfill.d.ts.map +1 -0
  31. package/dist/types/Document.d.ts +1 -0
  32. package/dist/types/Document.d.ts.map +1 -0
  33. package/dist/types/FontTypes.d.ts +1 -0
  34. package/dist/types/FontTypes.d.ts.map +1 -0
  35. package/dist/types/LayoutTypes.d.ts +1 -0
  36. package/dist/types/LayoutTypes.d.ts.map +1 -0
  37. package/dist/utils/env.d.ts +1 -0
  38. package/dist/utils/env.d.ts.map +1 -0
  39. package/dist/utils/font.d.ts +1 -0
  40. package/dist/utils/font.d.ts.map +1 -0
  41. package/dist/utils/groupLinesByParagraph.d.ts +1 -0
  42. package/dist/utils/groupLinesByParagraph.d.ts.map +1 -0
  43. package/dist/utils/list.d.ts +1 -0
  44. package/dist/utils/list.d.ts.map +1 -0
  45. package/dist/utils/textTransform.d.ts +1 -0
  46. package/dist/utils/textTransform.d.ts.map +1 -0
  47. package/package.json +3 -2
@@ -81,3 +81,4 @@ export declare function splitParagraphByHardBreaks(paragraph: Paragraph): Paragr
81
81
  * Get the full text of a paragraph (for INDEX_CONSIST checks).
82
82
  */
83
83
  export declare function getParagraphText(paragraph: Paragraph): string;
84
+ //# sourceMappingURL=DocumentCompiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentCompiler.d.ts","sourceRoot":"","sources":["../../src/compile/DocumentCompiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAiB,MAAM,sBAAsB,CAAC;AAM9E,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAe/C,CAAC;AAEF,gEAAgE;AAChE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAI/E;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAK7E;AAED,8CAA8C;AAC9C,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3B,wGAAwG;IACxG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE;QACR,gBAAgB,EAAE,MAAM,CAAC;QACzB,cAAc,EAAE,MAAM,CAAC;QACvB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,KAAK,EAAE,OAAO,CAAC;QACf,YAAY,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;KACxC,CAAC;CACH;AAcD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIjE;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAMnE;AAID;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,sBAAsB,EAAE,CA+D/E;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,CAoD5E;AAOD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAE7D"}
@@ -4,11 +4,20 @@
4
4
  * Re-exports all browser-safe APIs. Forces bundlers to inline the modules
5
5
  * by using a single `export *`/re-export style that bun build inlines.
6
6
  *
7
+ * ## Stability
8
+ *
9
+ * - **Stable**: types, layout engines, font metrics provider, compiler
10
+ * - **@beta** — may change with reasonable notice
11
+ * - **@internal** — implementation details, not for external use
12
+ *
7
13
  * ❌ NOT exported: SystemFontRegistry / systemFontRegistry — requires `node:fs`
8
14
  */
9
15
  export { ParagraphLayoutEngine, paragraphLayoutEngine } from './layout/ParagraphLayoutEngine.js';
16
+ /** @internal */
10
17
  export { positionLines } from './layout/PositioningEngine.js';
18
+ /** @internal */
11
19
  export { assertLineInvariants, linesToYAML } from './layout/LineBoxValidator.js';
20
+ export { groupLinesByParagraph } from './utils/groupLinesByParagraph.js';
12
21
  export { layoutTextFrame } from './layout/TextFrameLayoutEngine.js';
13
22
  export { applyScale, findScale } from './layout/AutoFitEngine.js';
14
23
  export { compileParagraph, getParagraphText, makeFontToken, collapseSegmentWhitespace, splitParagraphByHardBreaks } from './compile/DocumentCompiler.js';
@@ -16,48 +25,15 @@ export { FontMetricsProvider, fontMetricsProvider } from './measure/FontMetricsP
16
25
  export { createFontFace, getGlyphAdvance, computePixelMetrics, isFontEngineAvailable } from './measure/FontEngine.js';
17
26
  export { getFontBuffer } from './utils/font.js';
18
27
  export { FontNotFoundError } from './measure/FontNotFoundError.js';
19
- export declare const DEFAULT_PARAGRAPH_STYLE: {
20
- alignment: import("./index.js").TextAlignment;
21
- lineHeight: number;
22
- spaceBefore: number;
23
- spaceAfter: number;
24
- indent?: number;
25
- leftIndent?: number;
26
- rightIndent?: number;
27
- textIndent?: number;
28
- letterSpacing?: number;
29
- textAlignLast?: import("./index.js").TextAlignLast;
30
- wordBreak?: import("./index.js").WordBreak;
31
- lineBreak?: import("./index.js").LineBreak;
32
- overflowWrap?: import("./index.js").OverflowWrap;
33
- hyphens?: boolean;
34
- whiteSpace?: import("./index.js").WhiteSpace;
35
- listStyle?: import("./index.js").ListStyle;
36
- listRestart?: boolean;
37
- };
38
- export declare const DEFAULT_TEXT_STYLE: {
39
- type?: "text" | "inline-box" | undefined;
40
- text?: string | undefined;
41
- inlineWidget?: import("./index.js").InlineWidget | undefined;
42
- fontFamily?: string | undefined;
43
- fontSize?: number | undefined;
44
- fontWeight?: number | "bold" | "normal" | undefined;
45
- fontStyle?: "normal" | "italic" | undefined;
46
- color?: string | undefined;
47
- backgroundColor?: string | undefined;
48
- letterSpacing?: number | undefined;
49
- script?: import("./index.js").ScriptType | undefined;
50
- underline?: boolean | undefined;
51
- strikethrough?: boolean | undefined;
52
- overline?: boolean | undefined;
53
- textDecorationStyle?: import("./index.js").TextDecorationStyle | undefined;
54
- textDecorationColor?: string | undefined;
55
- textTransform?: import("./index.js").TextTransform | undefined;
56
- fullWidth?: boolean | undefined;
57
- fullSizeKana?: boolean | undefined;
58
- };
28
+ import type { ParagraphStyle, TextRun } from './types/Document.js';
29
+ /** @internal */
30
+ export declare const DEFAULT_PARAGRAPH_STYLE: ParagraphStyle;
31
+ /** @internal */
32
+ export declare const DEFAULT_TEXT_STYLE: Partial<TextRun>;
33
+ /** @internal */
59
34
  export { transformText } from './utils/textTransform.js';
60
- export declare const BULLET_CHARACTERS: {
61
- [x: number]: string;
62
- };
35
+ /** @internal */
36
+ export declare const BULLET_CHARACTERS: Record<number, string>;
37
+ /** @internal */
63
38
  export { formatListNumber, defaultBulletChar } from './utils/list.js';
39
+ //# sourceMappingURL=index.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAEjG,gBAAgB;AAChB,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,gBAAgB;AAChB,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAGzJ,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAOnE,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnE,gBAAgB;AAChB,eAAO,MAAM,uBAAuB,EAAE,cAA4B,CAAC;AACnE,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAAe,CAAC;AAEhE,gBAAgB;AAChB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAc,CAAC;AACpE,gBAAgB;AAChB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -43,13 +43,6 @@ var __export = (target, all) => {
43
43
  });
44
44
  };
45
45
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
46
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
47
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
48
- }) : x)(function(x) {
49
- if (typeof require !== "undefined")
50
- return require.apply(this, arguments);
51
- throw Error('Dynamic require of "' + x + '" is not supported');
52
- });
53
46
 
54
47
  // src/measure/canvas-polyfill.ts
55
48
  var exports_canvas_polyfill = {};
@@ -58,13 +51,26 @@ __export(exports_canvas_polyfill, {
58
51
  enableOfficeTextMeasure: () => enableOfficeTextMeasure,
59
52
  disableOfficeTextMeasure: () => disableOfficeTextMeasure
60
53
  });
61
- async function _initNodeDeps() {
54
+ function _initNodeDepsSync() {
62
55
  try {
63
- const m = await import("module");
64
- _require = m.createRequire(import.meta.url);
65
- const canvas = _require("@napi-rs/canvas");
66
- _createCanvas = canvas.createCanvas;
56
+ let moduleBuiltin = null;
57
+ if (typeof _process?.getBuiltinModule === "function") {
58
+ moduleBuiltin = _process.getBuiltinModule("module");
59
+ }
60
+ if (moduleBuiltin) {
61
+ _require = moduleBuiltin.createRequire(import.meta.url);
62
+ } else {
63
+ const cjsRequire = globalThis["require"];
64
+ if (typeof cjsRequire === "function") {
65
+ _require = cjsRequire;
66
+ }
67
+ }
68
+ if (_require) {
69
+ const canvas = _require("@napi-rs/canvas");
70
+ _createCanvas = canvas.createCanvas;
71
+ }
67
72
  } catch {
73
+ _require = null;
68
74
  _createCanvas = null;
69
75
  }
70
76
  }
@@ -170,10 +176,10 @@ function disableOfficeTextMeasure() {
170
176
  }
171
177
  }
172
178
  var _process, _require = null, _createCanvas = null, originalMeasureText, officeFontCache = null, officeEnabled = false;
173
- var init_canvas_polyfill = __esm(async () => {
179
+ var init_canvas_polyfill = __esm(() => {
174
180
  _process = typeof globalThis !== "undefined" ? globalThis.process : undefined;
175
181
  if (_process && (_process.versions?.node || _process.versions?.bun)) {
176
- await _initNodeDeps();
182
+ _initNodeDepsSync();
177
183
  }
178
184
  if (needsCanvasPolyfill()) {
179
185
  globalThis.document = {
@@ -18124,33 +18130,31 @@ function splitParagraphByHardBreaks(paragraph) {
18124
18130
  const result = [];
18125
18131
  let currentRuns = [];
18126
18132
  for (const run of paragraph.children) {
18127
- const nlIndex = run.text.indexOf(`
18133
+ const segments = run.text.split(`
18128
18134
  `);
18129
- if (nlIndex === -1) {
18135
+ if (segments.length === 1) {
18130
18136
  currentRuns.push({ ...run });
18131
18137
  continue;
18132
18138
  }
18133
- const before = run.text.slice(0, nlIndex);
18134
- const after = run.text.slice(nlIndex + 1);
18135
- const textTransform = run.textTransform;
18136
- const effectiveFontSize = computeEffFs(run);
18137
- if (before.length > 0) {
18138
- const text = ws === "pre-line" ? collapseSegmentWhitespace(before) : before;
18139
- currentRuns.push({ ...run, text: transformText(text, textTransform) });
18140
- }
18141
- result.push({ style: paragraph.style, children: currentRuns });
18142
- let afterIdx = nlIndex + 1;
18143
- while (afterIdx < run.text.length && run.text[afterIdx] === `
18144
- `) {
18145
- result.push({ style: paragraph.style, children: [] });
18146
- afterIdx++;
18147
- }
18148
- const remaining = run.text.slice(afterIdx);
18149
- if (remaining.length > 0) {
18150
- const text = ws === "pre-line" ? collapseSegmentWhitespace(remaining) : remaining;
18151
- currentRuns = [{ ...run, text: transformText(text, textTransform) }];
18152
- } else {
18153
- currentRuns = [];
18139
+ for (let i = 0;i < segments.length; i++) {
18140
+ const seg = segments[i];
18141
+ const textTransform = run.textTransform;
18142
+ const effectiveFontSize = computeEffFs(run);
18143
+ if (i === 0) {
18144
+ if (seg.length > 0) {
18145
+ const text = ws === "pre-line" ? collapseSegmentWhitespace(seg) : seg;
18146
+ currentRuns.push({ ...run, text: transformText(text, textTransform) });
18147
+ }
18148
+ } else {
18149
+ result.push({ style: paragraph.style, children: currentRuns });
18150
+ if (seg.length > 0) {
18151
+ const text = ws === "pre-line" ? collapseSegmentWhitespace(seg) : seg;
18152
+ currentRuns = [{ ...run, text: transformText(text, textTransform) }];
18153
+ } else {
18154
+ result.push({ style: paragraph.style, children: [] });
18155
+ currentRuns = [];
18156
+ }
18157
+ }
18154
18158
  }
18155
18159
  }
18156
18160
  result.push({ style: paragraph.style, children: currentRuns });
@@ -18165,7 +18169,7 @@ function getParagraphText(paragraph) {
18165
18169
  }
18166
18170
 
18167
18171
  // src/measure/FontMetricsProvider.ts
18168
- await init_canvas_polyfill();
18172
+ init_canvas_polyfill();
18169
18173
 
18170
18174
  // src/measure/FontNotFoundError.ts
18171
18175
  class FontNotFoundError extends Error {
@@ -18276,7 +18280,7 @@ class FontMetricsProvider {
18276
18280
  }
18277
18281
  async _registerFontInternal(family, options, source, sourcePath) {
18278
18282
  const { createFontFace: createFontFace2 } = await Promise.resolve().then(() => exports_FontEngine);
18279
- const { registerCanvasFont: registerCanvasFont2 } = await init_canvas_polyfill().then(() => exports_canvas_polyfill);
18283
+ const { registerCanvasFont: registerCanvasFont2 } = await Promise.resolve().then(() => (init_canvas_polyfill(), exports_canvas_polyfill));
18280
18284
  if (typeof source === "string") {
18281
18285
  const { getFontBuffer: getFontBuffer2 } = await Promise.resolve().then(() => exports_font);
18282
18286
  source = await getFontBuffer2(source);
@@ -24804,6 +24808,31 @@ class ParagraphLayoutEngine {
24804
24808
  }
24805
24809
  }
24806
24810
  var paragraphLayoutEngine = new ParagraphLayoutEngine;
24811
+ // src/utils/groupLinesByParagraph.ts
24812
+ function groupLinesByParagraph(lines) {
24813
+ const map = new Map;
24814
+ for (const line of lines) {
24815
+ const idx = line.spans[0]?.pIdx ?? -1;
24816
+ let entry = map.get(idx);
24817
+ if (!entry) {
24818
+ entry = { lines: [] };
24819
+ map.set(idx, entry);
24820
+ }
24821
+ entry.lines.push(line);
24822
+ if (!entry.tag) {
24823
+ entry.tag = line.spans[0]?.tag;
24824
+ }
24825
+ }
24826
+ const groups = [];
24827
+ const sortedKeys = Array.from(map.keys()).sort((a, b) => a - b);
24828
+ for (const key of sortedKeys) {
24829
+ if (key === -1)
24830
+ continue;
24831
+ const entry = map.get(key);
24832
+ groups.push({ lines: entry.lines, pIdx: key, tag: entry.tag });
24833
+ }
24834
+ return groups;
24835
+ }
24807
24836
  // src/layout/TextFrameLayoutEngine.ts
24808
24837
  function getMarkerTextHelper(listStyle, listIndex) {
24809
24838
  if (listStyle.type === "bullet") {
@@ -25092,6 +25121,7 @@ export {
25092
25121
  linesToYAML,
25093
25122
  layoutTextFrame,
25094
25123
  isFontEngineAvailable,
25124
+ groupLinesByParagraph,
25095
25125
  getParagraphText,
25096
25126
  getGlyphAdvance,
25097
25127
  getFontBuffer,
package/dist/index.d.ts CHANGED
@@ -1,54 +1,34 @@
1
1
  /**
2
2
  * @vyaz/core — Public API.
3
3
  *
4
- * Exports input types (Logical level), output types (Physical Box Model),
5
- * layout engines, font metric providers, renderers, and utilities.
4
+ * ## Stability
5
+ *
6
+ * - **Stable**: types, layout engines, font metrics provider, compiler
7
+ * - **@beta** — may change with reasonable notice
8
+ * - **@internal** — implementation details, not for external use
9
+ *
10
+ * ## Environments
11
+ *
12
+ * - `index.ts` (Node.js / Bun) — full API including SystemFontRegistry
13
+ * - `index.browser.ts` (browser) — browser-safe subset (no node:fs)
6
14
  */
7
15
  export type { TextFrame, Paragraph, ParagraphStyle, TextRun, InlineWidget, AutofitConfig, TextAlignment, WritingMode, TextOrientation, VerticalAlignment, ScriptType, WhiteSpace, MultiColumnConfig, DominantBaseline, LineFitEdge, TextAlignLast, WordBreak, LineBreak, OverflowWrap, TextDecorationStyle, TextTransform, ListType, NumberFormat, ListStylePosition, ListStyle, } from './types/Document.js';
8
- export declare const DEFAULT_PARAGRAPH_STYLE: {
9
- alignment: import("./index.js").TextAlignment;
10
- lineHeight: number;
11
- spaceBefore: number;
12
- spaceAfter: number;
13
- indent?: number;
14
- leftIndent?: number;
15
- rightIndent?: number;
16
- textIndent?: number;
17
- letterSpacing?: number;
18
- textAlignLast?: import("./index.js").TextAlignLast;
19
- wordBreak?: import("./index.js").WordBreak;
20
- lineBreak?: import("./index.js").LineBreak;
21
- overflowWrap?: import("./index.js").OverflowWrap;
22
- hyphens?: boolean;
23
- whiteSpace?: import("./index.js").WhiteSpace;
24
- listStyle?: import("./index.js").ListStyle;
25
- listRestart?: boolean;
26
- };
27
- export declare const DEFAULT_TEXT_STYLE: {
28
- type?: "text" | "inline-box" | undefined;
29
- text?: string | undefined;
30
- inlineWidget?: import("./index.js").InlineWidget | undefined;
31
- fontFamily?: string | undefined;
32
- fontSize?: number | undefined;
33
- fontWeight?: number | "bold" | "normal" | undefined;
34
- fontStyle?: "normal" | "italic" | undefined;
35
- color?: string | undefined;
36
- backgroundColor?: string | undefined;
37
- letterSpacing?: number | undefined;
38
- script?: import("./index.js").ScriptType | undefined;
39
- underline?: boolean | undefined;
40
- strikethrough?: boolean | undefined;
41
- overline?: boolean | undefined;
42
- textDecorationStyle?: import("./index.js").TextDecorationStyle | undefined;
43
- textDecorationColor?: string | undefined;
44
- textTransform?: import("./index.js").TextTransform | undefined;
45
- fullWidth?: boolean | undefined;
46
- fullSizeKana?: boolean | undefined;
47
- };
16
+ import type { ParagraphStyle } from './types/Document.js';
17
+ /** @internal */
18
+ export declare const DEFAULT_PARAGRAPH_STYLE: ParagraphStyle;
19
+ /** @internal */
20
+ export declare const DEFAULT_TEXT_STYLE: Partial<import('./types/Document.js').TextRun>;
48
21
  export type { ParagraphLayoutResult, Line, Span, SpanFontMetrics, SemanticParagraph, SemanticLine, SemanticFragment, } from './types/LayoutTypes.js';
49
22
  export type { FontMetrics, IFontMetricsProvider, GlyphData, } from './types/FontTypes.js';
50
23
  export { ParagraphLayoutEngine, paragraphLayoutEngine } from './layout/ParagraphLayoutEngine.js';
24
+ /**
25
+ * @internal List layout positions lines within a paragraph box.
26
+ * Used internally by ParagraphLayoutEngine.
27
+ */
51
28
  export { positionLines } from './layout/PositioningEngine.js';
29
+ /**
30
+ * @internal Line box invariant checks for debugging.
31
+ */
52
32
  export { assertLineInvariants, linesToYAML } from './layout/LineBoxValidator.js';
53
33
  export type { InvariantError } from './layout/LineBoxValidator.js';
54
34
  export { layoutTextFrame } from './layout/TextFrameLayoutEngine.js';
@@ -57,13 +37,17 @@ export { applyScale, findScale } from './layout/AutoFitEngine.js';
57
37
  export type { AutoFitOptions, AutoFitResult } from './layout/AutoFitEngine.js';
58
38
  export { groupLinesByParagraph } from './utils/groupLinesByParagraph.js';
59
39
  export type { ParagraphGroup } from './utils/groupLinesByParagraph.js';
40
+ /**
41
+ * @internal Text transformation (uppercase, lowercase, capitalize).
42
+ */
60
43
  export { transformText } from './utils/textTransform.js';
61
- import { formatListNumber as _fln, defaultBulletChar as _dbc } from './utils/list.js';
62
- export declare const formatListNumber: typeof _fln;
63
- export declare const defaultBulletChar: typeof _dbc;
64
- export declare const BULLET_CHARACTERS: {
65
- [x: number]: string;
66
- };
44
+ import type { NumberFormat } from './types/Document.js';
45
+ /** @internal */
46
+ export declare const formatListNumber: (n: number, format: NumberFormat) => string;
47
+ /** @internal */
48
+ export declare const defaultBulletChar: (level: number) => string;
49
+ /** @internal */
50
+ export declare const BULLET_CHARACTERS: Record<number, string>;
67
51
  export { compileParagraph, getParagraphText, makeFontToken, splitParagraphByHardBreaks, collapseSegmentWhitespace } from './compile/DocumentCompiler.js';
68
52
  export type { PreparedRichInlineItem } from './compile/DocumentCompiler.js';
69
53
  export type { FontFace } from './measure/FontEngine.js';
@@ -72,3 +56,4 @@ export { FontMetricsProvider, fontMetricsProvider } from './measure/FontMetricsP
72
56
  export { SystemFontRegistry, systemFontRegistry } from './measure/SystemFontRegistry.js';
73
57
  export { getFontBuffer } from './utils/font.js';
74
58
  export { FontNotFoundError } from './measure/FontNotFoundError.js';
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,YAAY,EACV,SAAS,EACT,SAAS,EACT,cAAc,EACd,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,SAAS,GACV,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,gBAAgB;AAChB,eAAO,MAAM,uBAAuB,EAAE,cAA6B,CAAC;AACpE,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,OAAO,qBAAqB,EAAE,OAAO,CAAgB,CAAC;AAG/F,YAAY,EACV,qBAAqB,EACrB,IAAI,EACJ,IAAI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,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AACzJ,YAAY,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAG5E,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGtH,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAG5F,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGzF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC"}
package/dist/index.js CHANGED
@@ -23,13 +23,26 @@ __export(exports_canvas_polyfill, {
23
23
  enableOfficeTextMeasure: () => enableOfficeTextMeasure,
24
24
  disableOfficeTextMeasure: () => disableOfficeTextMeasure
25
25
  });
26
- async function _initNodeDeps() {
26
+ function _initNodeDepsSync() {
27
27
  try {
28
- const m = await import("module");
29
- _require = m.createRequire(import.meta.url);
30
- const canvas = _require("@napi-rs/canvas");
31
- _createCanvas = canvas.createCanvas;
28
+ let moduleBuiltin = null;
29
+ if (typeof _process?.getBuiltinModule === "function") {
30
+ moduleBuiltin = _process.getBuiltinModule("module");
31
+ }
32
+ if (moduleBuiltin) {
33
+ _require = moduleBuiltin.createRequire(import.meta.url);
34
+ } else {
35
+ const cjsRequire = globalThis["require"];
36
+ if (typeof cjsRequire === "function") {
37
+ _require = cjsRequire;
38
+ }
39
+ }
40
+ if (_require) {
41
+ const canvas = _require("@napi-rs/canvas");
42
+ _createCanvas = canvas.createCanvas;
43
+ }
32
44
  } catch {
45
+ _require = null;
33
46
  _createCanvas = null;
34
47
  }
35
48
  }
@@ -135,10 +148,10 @@ function disableOfficeTextMeasure() {
135
148
  }
136
149
  }
137
150
  var _process, _require = null, _createCanvas = null, originalMeasureText, officeFontCache = null, officeEnabled = false;
138
- var init_canvas_polyfill = __esm(async () => {
151
+ var init_canvas_polyfill = __esm(() => {
139
152
  _process = typeof globalThis !== "undefined" ? globalThis.process : undefined;
140
153
  if (_process && (_process.versions?.node || _process.versions?.bun)) {
141
- await _initNodeDeps();
154
+ _initNodeDepsSync();
142
155
  }
143
156
  if (needsCanvasPolyfill()) {
144
157
  globalThis.document = {
@@ -421,33 +434,31 @@ function splitParagraphByHardBreaks(paragraph) {
421
434
  const result = [];
422
435
  let currentRuns = [];
423
436
  for (const run of paragraph.children) {
424
- const nlIndex = run.text.indexOf(`
437
+ const segments = run.text.split(`
425
438
  `);
426
- if (nlIndex === -1) {
439
+ if (segments.length === 1) {
427
440
  currentRuns.push({ ...run });
428
441
  continue;
429
442
  }
430
- const before = run.text.slice(0, nlIndex);
431
- const after = run.text.slice(nlIndex + 1);
432
- const textTransform = run.textTransform;
433
- const effectiveFontSize = computeEffFs(run);
434
- if (before.length > 0) {
435
- const text = ws === "pre-line" ? collapseSegmentWhitespace(before) : before;
436
- currentRuns.push({ ...run, text: transformText(text, textTransform) });
437
- }
438
- result.push({ style: paragraph.style, children: currentRuns });
439
- let afterIdx = nlIndex + 1;
440
- while (afterIdx < run.text.length && run.text[afterIdx] === `
441
- `) {
442
- result.push({ style: paragraph.style, children: [] });
443
- afterIdx++;
444
- }
445
- const remaining = run.text.slice(afterIdx);
446
- if (remaining.length > 0) {
447
- const text = ws === "pre-line" ? collapseSegmentWhitespace(remaining) : remaining;
448
- currentRuns = [{ ...run, text: transformText(text, textTransform) }];
449
- } else {
450
- currentRuns = [];
443
+ for (let i = 0;i < segments.length; i++) {
444
+ const seg = segments[i];
445
+ const textTransform = run.textTransform;
446
+ const effectiveFontSize = computeEffFs(run);
447
+ if (i === 0) {
448
+ if (seg.length > 0) {
449
+ const text = ws === "pre-line" ? collapseSegmentWhitespace(seg) : seg;
450
+ currentRuns.push({ ...run, text: transformText(text, textTransform) });
451
+ }
452
+ } else {
453
+ result.push({ style: paragraph.style, children: currentRuns });
454
+ if (seg.length > 0) {
455
+ const text = ws === "pre-line" ? collapseSegmentWhitespace(seg) : seg;
456
+ currentRuns = [{ ...run, text: transformText(text, textTransform) }];
457
+ } else {
458
+ result.push({ style: paragraph.style, children: [] });
459
+ currentRuns = [];
460
+ }
461
+ }
451
462
  }
452
463
  }
453
464
  result.push({ style: paragraph.style, children: currentRuns });
@@ -462,7 +473,7 @@ function getParagraphText(paragraph) {
462
473
  }
463
474
 
464
475
  // src/measure/FontMetricsProvider.ts
465
- await init_canvas_polyfill();
476
+ init_canvas_polyfill();
466
477
 
467
478
  // src/measure/FontNotFoundError.ts
468
479
  class FontNotFoundError extends Error {
@@ -573,7 +584,7 @@ class FontMetricsProvider {
573
584
  }
574
585
  async _registerFontInternal(family, options, source, sourcePath) {
575
586
  const { createFontFace: createFontFace2 } = await Promise.resolve().then(() => exports_FontEngine);
576
- const { registerCanvasFont: registerCanvasFont2 } = await init_canvas_polyfill().then(() => exports_canvas_polyfill);
587
+ const { registerCanvasFont: registerCanvasFont2 } = await Promise.resolve().then(() => (init_canvas_polyfill(), exports_canvas_polyfill));
577
588
  if (typeof source === "string") {
578
589
  const { getFontBuffer: getFontBuffer2 } = await Promise.resolve().then(() => exports_font);
579
590
  source = await getFontBuffer2(source);
@@ -42,3 +42,4 @@ export declare function findScale(doc: TextFrame, layoutFn: (scaledDoc: TextFram
42
42
  maxWidth: number;
43
43
  maxHeight: number;
44
44
  }, options?: AutoFitOptions): AutoFitResult;
45
+ //# sourceMappingURL=AutoFitEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoFitEngine.d.ts","sourceRoot":"","sources":["../../src/layout/AutoFitEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,sBAAsB;AACtB,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAqB;AACrB,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,MAAM,GACZ,SAAS,CAcX;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EACrE,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAC/C,OAAO,CAAC,EAAE,cAAc,GACvB,aAAa,CAoCf"}
@@ -23,3 +23,4 @@ export declare function assertLineInvariants(lines: Line[], originalText: string
23
23
  * No glyphAdvances, fontMetrics (noise), inlineWidget.
24
24
  */
25
25
  export declare function linesToYAML(lines: Line[], paragraphWidth: number, paragraphHeight: number): string;
26
+ //# sourceMappingURL=LineBoxValidator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineBoxValidator.d.ts","sourceRoot":"","sources":["../../src/layout/LineBoxValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,IAAI,EAA2B,MAAM,yBAAyB,CAAC;AAM7E,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,IAAI,EAAE,EACb,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,IAAI,CAqFN;AAYD;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,IAAI,EAAE,EACb,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,GACtB,MAAM,CAwBR"}
@@ -44,3 +44,4 @@ export declare class ParagraphLayoutEngine {
44
44
  }
45
45
  /** Singleton */
46
46
  export declare const paragraphLayoutEngine: ParagraphLayoutEngine;
47
+ //# sourceMappingURL=ParagraphLayoutEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParagraphLayoutEngine.d.ts","sourceRoot":"","sources":["../../src/layout/ParagraphLayoutEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAqCrE,qBAAa,qBAAqB;IAChC,OAAO,CAAC,aAAa,CAAyC;IAE9D;;;;;;;OAOG;IACH,MAAM,CACJ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAU,EACnB,YAAY,CAAC,EAAE,oBAAoB,EACnC,SAAS,CAAC,EAAE,SAAS,EACrB,SAAS,CAAC,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,GACvB,qBAAqB;IA+HxB;;;;;OAKG;IACH,WAAW,CACT,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAU,GAClB,qBAAqB;IAIxB;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;CAoC7B;AAED,gBAAgB;AAChB,eAAO,MAAM,qBAAqB,EAAE,qBAAmD,CAAC"}
@@ -66,3 +66,4 @@ export declare function positionLines(pretextLines: PretextLine[], items: Prepar
66
66
  contentWidth: number;
67
67
  };
68
68
  export {};
69
+ //# sourceMappingURL=PositioningEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PositioningEngine.d.ts","sourceRoot":"","sources":["../../src/layout/PositioningEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAgB,MAAM,sBAAsB,CAAC;AACpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAyB,MAAM,yBAAyB,CAAC;AAC3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAO7E,UAAU,eAAe;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,GAAG,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;CACtD;AAED,UAAU,WAAW;IACnB,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;CACtD;AA8CD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAC3B,YAAY,EAAE,WAAW,EAAE,EAC3B,KAAK,EAAE,sBAAsB,EAAE,EAC/B,aAAa,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,WAAW,EAC5D,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,YAAI,EAClB,IAAI,EAAE,SAAS,GAAG,QAAQ,YAAY,EACtC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,MAAM,EACrH,GAAG,CAAC,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,SAAS,EACrB,SAAS,CAAC,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,GACvB;IAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CA8ezC"}
@@ -48,3 +48,4 @@ export interface TextFrameLayoutResult {
48
48
  * Layout a full TextFrame by stacking paragraphs with Y offset accumulation.
49
49
  */
50
50
  export declare function layoutTextFrame(frame: TextFrame): TextFrameLayoutResult;
51
+ //# sourceMappingURL=TextFrameLayoutEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextFrameLayoutEngine.d.ts","sourceRoot":"","sources":["../../src/layout/TextFrameLayoutEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,SAAS,EAA2C,MAAM,sBAAsB,CAAC;AAC/F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAKpD;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,aAAa,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,mEAAmE;IACnE,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;CAClC;AAmED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,qBAAqB,CAoRvE"}
@@ -34,3 +34,4 @@ export type MeasureFn = (text: string) => number;
34
34
  * @returns widths that sum to occupiedWidth (within floating point tolerance)
35
35
  */
36
36
  export declare function resolveFragmentWidths(fragments: string[], fullText: string, occupiedWidth: number, measureFn: MeasureFn): number[];
37
+ //# sourceMappingURL=estimateWidth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimateWidth.d.ts","sourceRoot":"","sources":["../../src/layout/estimateWidth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,aAAa,EAAE,MAAM,GACpB,MAAM,EAAE,CAUV;AAID,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EAAE,EACnB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,SAAS,GACnB,MAAM,EAAE,CAaV"}
@@ -45,3 +45,4 @@ export declare function computePixelMetrics(font: FontFace, fontSize: number, mo
45
45
  * Useful for tests to verify the bundler isn't blocking fontkit.
46
46
  */
47
47
  export declare function isFontEngineAvailable(): Promise<boolean>;
48
+ //# sourceMappingURL=FontEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontEngine.d.ts","sourceRoot":"","sources":["../../src/measure/FontEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKzD,8DAA8D;AAC9D,MAAM,WAAW,QAAQ;IACvB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC;IACnB,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAkDD;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAQxF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIhF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAqB7G;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO9D"}
@@ -19,40 +19,83 @@ import type { FontFace } from './FontEngine.js';
19
19
  * Multiplied by fontSize to estimate the missing glyph width.
20
20
  */
21
21
  export declare const MISSING_GLYPH_FACTOR = 0.5;
22
+ /**
23
+ * Font metrics provider — registers, resolves, and measures fonts.
24
+ *
25
+ * Public API (stable):
26
+ * - `registerFont()`
27
+ * - `getMetrics()`
28
+ * - `getFont()`
29
+ * - `setMode()` / `getMode()`
30
+ *
31
+ * Semi-stable (@beta — may change with notice):
32
+ * - `waitForPendingRegistrations()`
33
+ * - `getRegisteredFamilies()`
34
+ * - `getFamilyVariants()`
35
+ *
36
+ * Everything else is internal.
37
+ */
22
38
  export declare class FontMetricsProvider implements IFontMetricsProvider {
23
- /**
24
- * Nested registry: family → variantKey → FontFace.
25
- * Example:
26
- * "Roboto" → { "400_normal": FontFace, "700_normal": FontFace, "400_italic": FontFace }
27
- */
39
+ /** @internal Nested registry: family → variantKey → FontFace */
28
40
  private registry;
29
- /** Metrics cache keyed by variantKey_fontSize_mode */
41
+ /** @internal Metrics cache keyed by variantKey_fontSize_mode */
30
42
  private metricsCache;
43
+ /** @internal */
31
44
  private mode;
45
+ /** @internal Set of in-flight registerFont() promises for race-condition guarding */
32
46
  private pendingRegistrations;
47
+ /** @internal Reusable off-screen canvas for Canvas TextMetrics fallback */
33
48
  private _measureCanvas;
49
+ /** @internal */
34
50
  private _measureCtx;
51
+ /** @internal Get or create a reusable canvas context */
35
52
  private _getMeasureContext;
53
+ /**
54
+ * Set measurement mode.
55
+ * - `'browser'` — hhea.ascender/descender (default)
56
+ * - `'office'` — OS/2.usWinAscent/usWinDescent
57
+ */
36
58
  setMode(mode: 'browser' | 'office'): void;
59
+ /** Get current measurement mode. */
37
60
  getMode(): 'browser' | 'office';
38
61
  /**
39
- * Flatten the nested registry into a single map for office mode.
40
- * Office mode needs key → FontFace lookup by family_weight_style.
62
+ * @internal Flatten the nested registry for office mode.
41
63
  */
42
64
  private _flattenCache;
65
+ /**
66
+ * Register a binary font for use with fontkit.
67
+ *
68
+ * In both Node.js and browser the font is loaded via FontEngine.
69
+ * In the browser the caller must provide font bytes (e.g. fetched via
70
+ * `getFontBuffer()` from `../utils/font.js`).
71
+ *
72
+ * @param source Font file bytes (ArrayBuffer / Uint8Array), or a URL string
73
+ * @param sourcePath Optional filesystem path (used for @napi-rs/canvas in Node.js)
74
+ */
43
75
  registerFont(family: string, options: {
44
76
  weight?: string;
45
77
  style?: string;
46
78
  }, source: string | ArrayBuffer | Uint8Array, sourcePath?: string): Promise<void>;
79
+ /** @internal Internal registration logic */
47
80
  private _registerFontInternal;
81
+ /**
82
+ * Wait for all in-flight font registrations to complete.
83
+ * Useful after a batch of registerFont() calls before layout.
84
+ *
85
+ * @beta — may change with notice
86
+ */
48
87
  waitForPendingRegistrations(): Promise<void>;
49
88
  /**
50
89
  * List all families registered in the provider.
90
+ *
91
+ * @beta — may change with notice
51
92
  */
52
93
  getRegisteredFamilies(): string[];
53
94
  /**
54
95
  * Get all variant keys registered for a given family.
55
96
  * Returns empty array if family not found.
97
+ *
98
+ * @beta — may change with notice
56
99
  */
57
100
  getFamilyVariants(family: string): string[];
58
101
  /**
@@ -61,11 +104,21 @@ export declare class FontMetricsProvider implements IFontMetricsProvider {
61
104
  */
62
105
  getFont(family: string, weight?: string, style?: string): FontFace | undefined;
63
106
  /**
64
- * Resolve a font request with fallback.
107
+ * @internal Resolve a font request with fallback.
65
108
  * Returns { font, resolvedWeight, resolvedStyle } or null.
66
109
  */
67
110
  private _resolveFont;
111
+ /**
112
+ * Get pixel-scale metrics for a given font family, size, weight, and style.
113
+ *
114
+ * Resolution order:
115
+ * 1. FontEngine (fontkit) from registry — with smart weight/style fallback
116
+ * 2. Canvas TextMetrics (browser fallback when fontkit unavailable)
117
+ *
118
+ * @throws FontNotFoundError when font is neither registered nor available via Canvas
119
+ */
68
120
  getMetrics(fontFamily: string, fontSize: number, weight?: string, style?: string): FontMetrics;
69
121
  }
70
122
  /** Singleton */
71
123
  export declare const fontMetricsProvider: FontMetricsProvider;
124
+ //# sourceMappingURL=FontMetricsProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontMetricsProvider.d.ts","sourceRoot":"","sources":["../../src/measure/FontMetricsProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAMhD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAyExC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAoB,YAAW,oBAAoB;IAC9D,gEAAgE;IAChE,OAAO,CAAC,QAAQ,CAA4C;IAE5D,gEAAgE;IAChE,OAAO,CAAC,YAAY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@ -4,3 +4,4 @@
4
4
  export declare class FontNotFoundError extends Error {
5
5
  constructor(family: string, weight?: string, style?: string);
6
6
  }
7
+ //# sourceMappingURL=FontNotFoundError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontNotFoundError.d.ts","sourceRoot":"","sources":["../../src/measure/FontNotFoundError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAExC,MAAM,EAAE,MAAM,EACd,MAAM,SAAW,EACjB,KAAK,SAAW;CAQnB"}
@@ -44,3 +44,4 @@ export declare class SystemFontRegistry {
44
44
  /** Singleton instance */
45
45
  export declare const systemFontRegistry: SystemFontRegistry;
46
46
  export {};
47
+ //# sourceMappingURL=SystemFontRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SystemFontRegistry.d.ts","sourceRoot":"","sources":["../../src/measure/SystemFontRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,UAAU,UAAU;IAClB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;CACpB;AA4CD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAqB;IAE7C,4CAA4C;IAC5C,OAAO,CAAC,UAAU,CAA2B;IAE7C,OAAO;IAEP,MAAM,KAAK,QAAQ,IAAI,kBAAkB,CAKxC;IAED;;;;;;;;OAQG;IACG,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IA8CjC;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAIrC;;OAEG;IACH,qBAAqB,IAAI,MAAM,EAAE;CAGlC;AAED,yBAAyB;AACzB,eAAO,MAAM,kBAAkB,EAAE,kBAAgD,CAAC"}
@@ -11,8 +11,13 @@
11
11
  * Exports enableOfficeTextMeasure / disableOfficeTextMeasure —
12
12
  * ctx.measureText override for FontEngine-based measurements in Office mode.
13
13
  *
14
- * ⚠️ All Node.js built-in module imports are dynamic (lazy) to avoid
15
- * Vite/Webpack externalization errors in browser builds.
14
+ * ⚠️ Node.js built-in module access is synchronous via process.getBuiltinModule
15
+ * (Node ≥20.16 / ≥22, Bun ≥1.1) to avoid top-level await race conditions
16
+ * in worker threads (e.g. Piscina). The previous implementation used
17
+ * `await import('module')` which created a race window where layoutTextFrame
18
+ * could be called before the polyfill initialised, returning 0×0.
19
+ *
20
+ * @see https://nodejs.org/api/process.html#processgetbuiltinmoduleid
16
21
  */
17
22
  /**
18
23
  * Register a font with @napi-rs/canvas so ctx.measureText() works in Node.js.
@@ -28,3 +33,4 @@ export declare function enableOfficeTextMeasure(fontCache: Map<string, any>): vo
28
33
  * Restore original ctx.measureText.
29
34
  */
30
35
  export declare function disableOfficeTextMeasure(): void;
36
+ //# sourceMappingURL=canvas-polyfill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-polyfill.d.ts","sourceRoot":"","sources":["../../src/measure/canvas-polyfill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAkNH;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAUzE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CASzE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAS/C"}
@@ -597,3 +597,4 @@ export declare const DEFAULT_PARAGRAPH_STYLE: ParagraphStyle;
597
597
  * and no `defaultStyle` is set on the `TextFrame`.
598
598
  */
599
599
  export declare const DEFAULT_TEXT_STYLE: Partial<TextRun>;
600
+ //# sourceMappingURL=Document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../../src/types/Document.ts"],"names":[],"mappings":"A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AMrC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAM/C,CAAC"}
@@ -59,3 +59,4 @@ export interface GlyphData {
59
59
  advance: number;
60
60
  x: number;
61
61
  }
62
+ //# sourceMappingURL=FontTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontTypes.d.ts","sourceRoot":"","sources":["../../src/types/FontTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,6DAA6D;AAC7D,MAAM,WAAW,WAAW;IAC1B,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;CACvD;AAED,8CAA8C;AAC9C,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAC;IAE1C;;OAEG;IACH,OAAO,IAAI,SAAS,GAAG,QAAQ,CAAC;IAEhC;;;;;OAKG;IACH,YAAY,CACV,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAC5C,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,UAAU,CAAC,EAAE,MAAM,GAClB,IAAI,CAAC;IAER;;OAEG;IACH,UAAU,CACR,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,WAAW,CAAC;CAChB;AAED,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,EAAE,MAAM,CAAC;CACX"}
@@ -135,3 +135,4 @@ export interface SemanticParagraph {
135
135
  height: number;
136
136
  lines: SemanticLine[];
137
137
  }
138
+ //# sourceMappingURL=LayoutTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LayoutTypes.d.ts","sourceRoot":"","sources":["../../src/types/LayoutTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI1E,MAAM,WAAW,IAAI;IACnB,yBAAyB;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,0CAA0C;IAC1C,WAAW,EAAE,eAAe,CAAC;IAE7B;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf,mDAAmD;IACnD,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC;IAExC;;;;;OAKG;IACH,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAElC;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB;;qDAEi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CAAC;IACjB,SAAS,EAAE,gBAAgB,EAAE,CAAC;CAC/B;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB"}
@@ -9,3 +9,4 @@
9
9
  */
10
10
  /** `true` when running on Node.js or Bun (has `process.versions.node`) */
11
11
  export declare const isNodeLike: boolean;
12
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,0EAA0E;AAC1E,eAAO,MAAM,UAAU,EAAE,OAGmB,CAAC"}
@@ -14,3 +14,4 @@
14
14
  * @returns Font file bytes as an ArrayBuffer
15
15
  */
16
16
  export declare function getFontBuffer(fontUrl: string): Promise<ArrayBuffer>;
17
+ //# sourceMappingURL=font.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../src/utils/font.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAWzE"}
@@ -42,3 +42,4 @@ export interface ParagraphGroup {
42
42
  * ```
43
43
  */
44
44
  export declare function groupLinesByParagraph(lines: Line[]): ParagraphGroup[];
45
+ //# sourceMappingURL=groupLinesByParagraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groupLinesByParagraph.d.ts","sourceRoot":"","sources":["../../src/utils/groupLinesByParagraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,+BAA+B;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,CA2BrE"}
@@ -39,3 +39,4 @@ export declare function defaultBulletChar(level: number): string;
39
39
  * @see {@link https://www.w3.org/TR/css-counter-styles-3/ | CSS Counter Styles Level 3}
40
40
  */
41
41
  export declare function formatListNumber(n: number, format: NumberFormat): string;
42
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/utils/list.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAIpD,CAAC;AAKF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAexE"}
@@ -30,3 +30,4 @@ import type { TextTransform } from '../types/Document.js';
30
30
  * ```
31
31
  */
32
32
  export declare function transformText(text: string, transform?: TextTransform): string;
33
+ //# sourceMappingURL=textTransform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textTransform.d.ts","sourceRoot":"","sources":["../../src/utils/textTransform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,MAAM,CA8D7E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vyaz/core",
3
- "version": "0.0.11",
3
+ "version": "0.0.16",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -28,7 +28,8 @@
28
28
  "child_process": false
29
29
  },
30
30
  "scripts": {
31
- "build": "bun build ./src/index.ts --outdir ./dist --target bun --external @chenglou/pretext --external js-yaml --external @napi-rs/canvas --external fontkit --external get-system-fonts && bun build ./src/index.browser.ts --outdir ./dist --outfile ./dist/index.browser.js --target browser && tsc --project tsconfig.json --emitDeclarationOnly",
31
+ "build": "bun build ./src/index.ts --outdir ./dist --target bun --external @chenglou/pretext --external js-yaml --external @napi-rs/canvas --external fontkit --external get-system-fonts && bun build ./src/index.browser.ts --outdir ./dist --outfile ./dist/index.browser.js --target browser && tsc -b",
32
+ "prepublishOnly": "bun run build",
32
33
  "test": "bun test"
33
34
  },
34
35
  "dependencies": {