@vyaz/core 0.0.16 → 0.3.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 (53) hide show
  1. package/README.md +35 -0
  2. package/bin/vyaz.js +27 -0
  3. package/dist/cli/check.d.ts +12 -0
  4. package/dist/cli/check.d.ts.map +1 -0
  5. package/dist/cli/check.js +4077 -0
  6. package/dist/compile/ParagraphCompiler.d.ts +84 -0
  7. package/dist/compile/ParagraphCompiler.d.ts.map +1 -0
  8. package/dist/debug/lines-to-yaml.d.ts +14 -0
  9. package/dist/debug/lines-to-yaml.d.ts.map +1 -0
  10. package/dist/debug.d.ts +11 -0
  11. package/dist/debug.d.ts.map +1 -0
  12. package/dist/debug.js +4 -0
  13. package/dist/index.browser.d.ts +11 -4
  14. package/dist/index.browser.d.ts.map +1 -1
  15. package/dist/index.browser.js +3244 -4669
  16. package/dist/index.d.ts +15 -11
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +5133 -811
  19. package/dist/layout/AutoFitEngine.d.ts.map +1 -1
  20. package/dist/layout/LineBoxValidator.d.ts +5 -10
  21. package/dist/layout/LineBoxValidator.d.ts.map +1 -1
  22. package/dist/layout/ParagraphLayoutEngine.d.ts +13 -8
  23. package/dist/layout/ParagraphLayoutEngine.d.ts.map +1 -1
  24. package/dist/layout/PositioningEngine.d.ts +1 -1
  25. package/dist/layout/PositioningEngine.d.ts.map +1 -1
  26. package/dist/layout/TableLayoutEngine.d.ts +174 -0
  27. package/dist/layout/TableLayoutEngine.d.ts.map +1 -0
  28. package/dist/layout/TextFrameLayoutEngine.d.ts +115 -16
  29. package/dist/layout/TextFrameLayoutEngine.d.ts.map +1 -1
  30. package/dist/layout/create-engine.d.ts +32 -0
  31. package/dist/layout/create-engine.d.ts.map +1 -0
  32. package/dist/layout/resolve-font.d.ts +25 -0
  33. package/dist/layout/resolve-font.d.ts.map +1 -0
  34. package/dist/measure/FontEngine.d.ts +44 -1
  35. package/dist/measure/FontEngine.d.ts.map +1 -1
  36. package/dist/measure/FontMetricsProvider.d.ts +3 -10
  37. package/dist/measure/FontMetricsProvider.d.ts.map +1 -1
  38. package/dist/measure/FontkitMeasureContext.d.ts +109 -0
  39. package/dist/measure/FontkitMeasureContext.d.ts.map +1 -0
  40. package/dist/measure/canvas-polyfill.d.ts.map +1 -1
  41. package/dist/types/Document.d.ts +73 -28
  42. package/dist/types/Document.d.ts.map +1 -1
  43. package/dist/types/FontTypes.d.ts +1 -1
  44. package/dist/types/FontTypes.d.ts.map +1 -1
  45. package/dist/types/LayoutTypes.d.ts +19 -2
  46. package/dist/types/LayoutTypes.d.ts.map +1 -1
  47. package/dist/types/TableTypes.d.ts +198 -0
  48. package/dist/types/TableTypes.d.ts.map +1 -0
  49. package/dist/utils/sides.d.ts +26 -0
  50. package/dist/utils/sides.d.ts.map +1 -0
  51. package/dist/utils/widths.d.ts +16 -0
  52. package/dist/utils/widths.d.ts.map +1 -0
  53. package/package.json +25 -4
package/README.md CHANGED
@@ -46,6 +46,7 @@ console.log(result.lines);
46
46
  - **Writing modes** — `horizontal-tb`, `vertical-rl`, `vertical-lr` with text orientation
47
47
  - **Auto-fit** — scale text proportionally to fit the container (`AutofitConfig`)
48
48
  - **Inline widgets** — embedded objects (icons, images) inside the text flow
49
+ - **Tables** — `TableFrame` grid layout: measured column widths/row heights, `colSpan`/`rowSpan`, per-side borders (solid, dashed, rounded corners), `before`/`after` decorative slots, nested tables
49
50
  - **Office-compatible mode** — `mode: 'office'` for PowerPoint/DrawingML rendering
50
51
  - **Font metrics** — system font registry with fontkit-based metric extraction
51
52
  - **Compiler** — paragraph compilation with token preparation for external renderers
@@ -78,6 +79,40 @@ const result: TextFrameLayoutResult = layoutTextFrame(frame);
78
79
  // → { lines: Line[], frameWidth?, frameHeight?, contentWidth, contentHeight, fitHorizontal, fitVertical }
79
80
  ```
80
81
 
82
+ ### Tables
83
+
84
+ ```ts
85
+ import { layoutTableFrame } from '@vyaz/core';
86
+ import type { TableFrame, TableLayoutResult } from '@vyaz/core';
87
+
88
+ const cell = (text: string) => ({
89
+ content: {
90
+ wrap: true,
91
+ paragraphs: [{
92
+ style: { alignment: 'left', lineHeight: 1.3, spaceBefore: 0, spaceAfter: 0 },
93
+ children: [{ type: 'text', text, fontFamily: 'Arial', fontSize: 14, fontWeight: 'normal', fontStyle: 'normal', color: '#000' }],
94
+ }],
95
+ },
96
+ });
97
+
98
+ const table: TableFrame = {
99
+ defaultCellStyle: { paddings: 8, borderWidths: 1, borderColors: '#ccc' },
100
+ rows: [
101
+ { style: { bgColor: '#eee' }, cells: [cell('Name'), cell('Qty')] },
102
+ { cells: [cell('Widget'), cell('3')] },
103
+ ],
104
+ };
105
+
106
+ const result: TableLayoutResult = layoutTableFrame(table);
107
+ // → { width, height, contentBox, rows: [{ y, height, cells: [{ x, y, width, height, content, ... }] }] }
108
+ ```
109
+
110
+ Column widths and row heights are *measured* from cell content unless
111
+ `columnWidths`/`rowHeights`/`width`/`height` override them. A cell's
112
+ `content` can itself be a `TableFrame` (nested tables). `@vyaz/renderer`'s
113
+ `renderTableToSVG` paints the result — see its README, or the
114
+ [Tables guide](https://sedrew.github.io/vyaz/guide/tables).
115
+
81
116
  ### Autofit
82
117
 
83
118
  ```ts
package/bin/vyaz.js ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+
3
+ const args = process.argv.slice(2);
4
+
5
+ if (args.includes('--check') || args.includes('check')) {
6
+ import('../dist/cli/check.js')
7
+ .then(mod => mod.run())
8
+ .catch(err => {
9
+ console.error('Failed to load check module:', err.message);
10
+ process.exit(1);
11
+ });
12
+ } else if (args.includes('--help') || args.includes('-h') || args.length === 0) {
13
+ printHelp();
14
+ } else {
15
+ printHelp();
16
+ process.exit(1);
17
+ }
18
+
19
+ function printHelp() {
20
+ console.log(`
21
+ vyaz CLI — environment diagnostics
22
+
23
+ Usage:
24
+ vyaz --check Check environment (napi-rs/canvas, fontkit, fontconfig, pretext)
25
+ vyaz --help Show this help
26
+ `);
27
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * vyaz --check CLI
3
+ *
4
+ * Environment diagnostics: verifies that all optional dependencies
5
+ * (napi-rs/canvas, fontkit, pretext, get-system-fonts) are available
6
+ * and that fontconfig is properly installed (measureText returns > 0).
7
+ *
8
+ * Usage:
9
+ * vyaz --check
10
+ */
11
+ export declare function run(): Promise<void>;
12
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/cli/check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA6IH,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CA8BzC"}