@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.
- package/dist/compile/DocumentCompiler.d.ts +40 -0
- package/dist/index.browser.d.ts +28 -0
- package/dist/index.browser.js +18 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +11 -147930
- package/dist/layout/AutoFitEngine.d.ts +44 -0
- package/dist/layout/LineBoxValidator.d.ts +25 -0
- package/dist/layout/ParagraphLayoutEngine.d.ts +46 -0
- package/dist/layout/PositioningEngine.d.ts +68 -0
- package/dist/layout/TextFrameLayoutEngine.d.ts +50 -0
- package/{src/layout/estimateWidth.ts → dist/layout/estimateWidth.d.ts} +2 -40
- package/dist/measure/FontEngine.d.ts +47 -0
- package/dist/measure/FontMetricsProvider.d.ts +49 -0
- package/dist/measure/FontNotFoundError.d.ts +6 -0
- package/dist/measure/SystemFontRegistry.d.ts +46 -0
- package/dist/measure/canvas-polyfill.d.ts +30 -0
- package/dist/types/Document.d.ts +593 -0
- package/dist/types/FontTypes.d.ts +61 -0
- package/dist/types/LayoutTypes.d.ts +128 -0
- package/{src/utils/env.ts → dist/utils/env.d.ts} +1 -8
- package/{src/utils/font.ts → dist/utils/font.d.ts} +1 -13
- package/{src/utils/groupLinesByParagraph.ts → dist/utils/groupLinesByParagraph.d.ts} +7 -37
- package/dist/utils/list.d.ts +41 -0
- package/dist/utils/textTransform.d.ts +32 -0
- package/package.json +13 -13
- package/src/compile/DocumentCompiler.ts +0 -144
- package/src/index.browser.ts +0 -90
- package/src/index.ts +0 -97
- package/src/layout/AutoFitEngine.ts +0 -101
- package/src/layout/LineBoxValidator.ts +0 -162
- package/src/layout/ParagraphLayoutEngine.ts +0 -264
- package/src/layout/PositioningEngine.ts +0 -615
- package/src/layout/TextFrameLayoutEngine.ts +0 -363
- package/src/measure/FontEngine.ts +0 -144
- package/src/measure/FontMetricsProvider.ts +0 -224
- package/src/measure/FontNotFoundError.ts +0 -16
- package/src/measure/SystemFontRegistry.ts +0 -152
- package/src/measure/canvas-polyfill.d.ts +0 -6
- package/src/measure/canvas-polyfill.ts +0 -243
- package/src/measure/fontkit.d.ts +0 -44
- package/src/types/Document.ts +0 -666
- package/src/types/FontTypes.ts +0 -74
- package/src/types/LayoutTypes.ts +0 -158
- package/src/utils/list.ts +0 -107
- 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
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -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';
|