@vyaz/core 0.0.5 → 0.0.6

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 (45) hide show
  1. package/dist/compile/DocumentCompiler.d.ts +40 -0
  2. package/dist/index.browser.d.ts +28 -0
  3. package/dist/index.browser.js +18 -0
  4. package/dist/index.d.ts +30 -0
  5. package/dist/index.js +11 -147930
  6. package/dist/layout/AutoFitEngine.d.ts +44 -0
  7. package/dist/layout/LineBoxValidator.d.ts +25 -0
  8. package/dist/layout/ParagraphLayoutEngine.d.ts +46 -0
  9. package/dist/layout/PositioningEngine.d.ts +68 -0
  10. package/dist/layout/TextFrameLayoutEngine.d.ts +50 -0
  11. package/{src/layout/estimateWidth.ts → dist/layout/estimateWidth.d.ts} +2 -40
  12. package/dist/measure/FontEngine.d.ts +47 -0
  13. package/dist/measure/FontMetricsProvider.d.ts +49 -0
  14. package/dist/measure/FontNotFoundError.d.ts +6 -0
  15. package/dist/measure/SystemFontRegistry.d.ts +46 -0
  16. package/dist/measure/canvas-polyfill.d.ts +30 -0
  17. package/dist/types/Document.d.ts +593 -0
  18. package/dist/types/FontTypes.d.ts +61 -0
  19. package/dist/types/LayoutTypes.d.ts +128 -0
  20. package/{src/utils/env.ts → dist/utils/env.d.ts} +1 -8
  21. package/{src/utils/font.ts → dist/utils/font.d.ts} +1 -13
  22. package/{src/utils/groupLinesByParagraph.ts → dist/utils/groupLinesByParagraph.d.ts} +7 -37
  23. package/dist/utils/list.d.ts +41 -0
  24. package/dist/utils/textTransform.d.ts +32 -0
  25. package/package.json +13 -13
  26. package/src/compile/DocumentCompiler.ts +0 -144
  27. package/src/index.browser.ts +0 -90
  28. package/src/index.ts +0 -97
  29. package/src/layout/AutoFitEngine.ts +0 -101
  30. package/src/layout/LineBoxValidator.ts +0 -162
  31. package/src/layout/ParagraphLayoutEngine.ts +0 -264
  32. package/src/layout/PositioningEngine.ts +0 -615
  33. package/src/layout/TextFrameLayoutEngine.ts +0 -363
  34. package/src/measure/FontEngine.ts +0 -144
  35. package/src/measure/FontMetricsProvider.ts +0 -224
  36. package/src/measure/FontNotFoundError.ts +0 -16
  37. package/src/measure/SystemFontRegistry.ts +0 -152
  38. package/src/measure/canvas-polyfill.d.ts +0 -6
  39. package/src/measure/canvas-polyfill.ts +0 -243
  40. package/src/measure/fontkit.d.ts +0 -44
  41. package/src/types/Document.ts +0 -666
  42. package/src/types/FontTypes.ts +0 -74
  43. package/src/types/LayoutTypes.ts +0 -158
  44. package/src/utils/list.ts +0 -107
  45. package/src/utils/textTransform.ts +0 -96
@@ -0,0 +1,40 @@
1
+ /**
2
+ * DocumentCompiler.ts — compile Paragraph → PreparedRichInlineItem[].
3
+ *
4
+ * Each TextRun becomes a RichInlineItem for pretext.
5
+ * inline-box: text → \uFFFC, dimensions in metadata.inlineWidget.
6
+ * super/sub: fontSize *= 0.65, baselineOffset in metadata.
7
+ *
8
+ * Simple JSON-serialisable format — does not depend on pretext directly.
9
+ */
10
+ import type { Paragraph, TextRun } from '../types/Document.js';
11
+ export declare const FONT_WEIGHTS: Record<string, number>;
12
+ /** Normalize fontWeight to a numeric value (400 by default). */
13
+ export declare function normalizeFontWeight(weight: number | string | undefined): number;
14
+ /** Font token for pretext: "${style}_${weight}_${fontSize}_${family}" */
15
+ export declare function makeFontToken(run: TextRun, effectiveFontSize: number): string;
16
+ /** Compilation context (passed to pretext) */
17
+ export interface PreparedRichInlineItem {
18
+ text: string;
19
+ font: string;
20
+ letterSpacing?: number;
21
+ extraWidth?: number;
22
+ break?: 'normal' | 'never';
23
+ /** Original text before text-transform (if transform was applied). Used for copy-paste / round-trip. */
24
+ originalText?: string;
25
+ metadata: {
26
+ originalRunIndex: number;
27
+ baselineOffset: number;
28
+ effectiveFontSize: number;
29
+ style: TextRun;
30
+ inlineWidget?: TextRun['inlineWidget'];
31
+ };
32
+ }
33
+ /**
34
+ * Compile a paragraph into PreparedRichInlineItem[].
35
+ */
36
+ export declare function compileParagraph(paragraph: Paragraph): PreparedRichInlineItem[];
37
+ /**
38
+ * Get the full text of a paragraph (for INDEX_CONSIST checks).
39
+ */
40
+ export declare function getParagraphText(paragraph: Paragraph): string;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @vyaz/core — Browser entry point.
3
+ *
4
+ * Re-exports everything from the main index **except** `SystemFontRegistry`
5
+ * and `systemFontRegistry`, which require Node.js built-in modules
6
+ * (`node:fs`, `get-system-fonts`).
7
+ *
8
+ * All server-only code paths are guarded by runtime checks (`isNodeLike`)
9
+ * so tree-shakers can safely eliminate dead branches.
10
+ *
11
+ * ✅ Safe for Vite / webpack / Rollup / esbuild browser builds.
12
+ */
13
+ 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';
14
+ export { DEFAULT_PARAGRAPH_STYLE, DEFAULT_TEXT_STYLE, } from './types/Document.js';
15
+ export type { ParagraphLayoutResult, Line, Span, SpanFontMetrics, SemanticParagraph, SemanticLine, SemanticFragment, } from './types/LayoutTypes.js';
16
+ export type { FontMetrics, IFontMetricsProvider, GlyphData, } from './types/FontTypes.js';
17
+ export { ParagraphLayoutEngine, paragraphLayoutEngine } from './layout/ParagraphLayoutEngine.js';
18
+ export { positionLines } from './layout/PositioningEngine.js';
19
+ export { assertLineInvariants, linesToYAML } from './layout/LineBoxValidator.js';
20
+ export type { InvariantError } from './layout/LineBoxValidator.js';
21
+ export { layoutTextFrame } from './layout/TextFrameLayoutEngine.js';
22
+ export type { TextFrameLayoutResult } from './layout/TextFrameLayoutEngine.js';
23
+ export { applyScale, findScale } from './layout/AutoFitEngine.js';
24
+ export type { AutoFitOptions, AutoFitResult } from './layout/AutoFitEngine.js';
25
+ export { compileParagraph, getParagraphText, makeFontToken } from './compile/DocumentCompiler.js';
26
+ export type { PreparedRichInlineItem } from './compile/DocumentCompiler.js';
27
+ export { FontMetricsProvider, fontMetricsProvider } from './measure/FontMetricsProvider.js';
28
+ export { FontNotFoundError } from './measure/FontNotFoundError.js';
@@ -0,0 +1,18 @@
1
+ export {
2
+ positionLines,
3
+ paragraphLayoutEngine,
4
+ makeFontToken,
5
+ linesToYAML,
6
+ layoutTextFrame,
7
+ getParagraphText,
8
+ fontMetricsProvider,
9
+ findScale,
10
+ compileParagraph,
11
+ assertLineInvariants,
12
+ applyScale,
13
+ ParagraphLayoutEngine,
14
+ FontNotFoundError,
15
+ FontMetricsProvider,
16
+ DEFAULT_TEXT_STYLE,
17
+ DEFAULT_PARAGRAPH_STYLE
18
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @vyaz/core — Public API.
3
+ *
4
+ * Exports input types (Logical level), output types (Physical Box Model),
5
+ * layout engines, font metric providers, renderers, and utilities.
6
+ */
7
+ 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 { DEFAULT_PARAGRAPH_STYLE, DEFAULT_TEXT_STYLE, } from './types/Document.js';
9
+ export type { ParagraphLayoutResult, Line, Span, SpanFontMetrics, SemanticParagraph, SemanticLine, SemanticFragment, } from './types/LayoutTypes.js';
10
+ export type { FontMetrics, IFontMetricsProvider, GlyphData, } from './types/FontTypes.js';
11
+ export { ParagraphLayoutEngine, paragraphLayoutEngine } from './layout/ParagraphLayoutEngine.js';
12
+ export { positionLines } from './layout/PositioningEngine.js';
13
+ export { assertLineInvariants, linesToYAML } from './layout/LineBoxValidator.js';
14
+ export type { InvariantError } from './layout/LineBoxValidator.js';
15
+ export { layoutTextFrame } from './layout/TextFrameLayoutEngine.js';
16
+ export type { TextFrameLayoutResult } from './layout/TextFrameLayoutEngine.js';
17
+ export { applyScale, findScale } from './layout/AutoFitEngine.js';
18
+ export type { AutoFitOptions, AutoFitResult } from './layout/AutoFitEngine.js';
19
+ export { groupLinesByParagraph } from './utils/groupLinesByParagraph.js';
20
+ export type { ParagraphGroup } from './utils/groupLinesByParagraph.js';
21
+ export { transformText } from './utils/textTransform.js';
22
+ export { formatListNumber, defaultBulletChar, BULLET_CHARACTERS } from './utils/list.js';
23
+ export { compileParagraph, getParagraphText, makeFontToken } from './compile/DocumentCompiler.js';
24
+ export type { PreparedRichInlineItem } from './compile/DocumentCompiler.js';
25
+ export type { FontFace } from './measure/FontEngine.js';
26
+ export { createFontFace, getGlyphAdvance, computePixelMetrics, isFontEngineAvailable } from './measure/FontEngine.js';
27
+ export { FontMetricsProvider, fontMetricsProvider } from './measure/FontMetricsProvider.js';
28
+ export { SystemFontRegistry, systemFontRegistry } from './measure/SystemFontRegistry.js';
29
+ export { getFontBuffer } from './utils/font.js';
30
+ export { FontNotFoundError } from './measure/FontNotFoundError.js';