cvdl-ts 1.0.9 → 1.0.11

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/README.md ADDED
@@ -0,0 +1,5 @@
1
+
2
+ # Todos
3
+
4
+ - Right elements should not become double columns when there is available space.
5
+ - Margins should affect the width of the element.
@@ -1,4 +1,4 @@
1
- export type Alignment = "Left" | "Center" | "Right" | "Justified";
2
- export declare namespace Alignment {
3
- function default_(): Alignment;
4
- }
1
+ export type t = "Left" | "Center" | "Right" | "Justified";
2
+ type Alignment = t;
3
+ export declare function default_(): Alignment;
4
+ export {};
package/dist/Alignment.js CHANGED
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Alignment = void 0;
4
- var Alignment;
5
- (function (Alignment) {
6
- function default_() {
7
- return "Left";
8
- }
9
- Alignment.default_ = default_;
10
- })(Alignment || (exports.Alignment = Alignment = {}));
3
+ exports.default_ = void 0;
4
+ function default_() {
5
+ return "Left";
6
+ }
7
+ exports.default_ = default_;
@@ -1,8 +1,8 @@
1
1
  import { Box } from "./Box";
2
2
  import { DataSchema } from "./DataSchema";
3
- import { Elem } from "./Layout";
3
+ import { Elem, SectionLayout } from "./Layout";
4
4
  import { LayoutSchema } from "./LayoutSchema";
5
- import { LocalStorage } from "./LocalStorage";
5
+ import { Storage } from "./Storage";
6
6
  import { Resume } from "./Resume";
7
7
  import { ResumeLayout } from "./ResumeLayout";
8
8
  import * as fontkit from 'fontkit';
@@ -34,13 +34,13 @@ export type RenderProps = {
34
34
  layout_schemas: LayoutSchema[];
35
35
  data_schemas: DataSchema[];
36
36
  resume_layout: ResumeLayout;
37
- storage: LocalStorage;
37
+ storage: Storage;
38
38
  fontDict?: FontDict;
39
39
  };
40
40
  export declare class FontDict {
41
41
  fonts: Map<string, fontkit.Font>;
42
42
  constructor();
43
- load_fonts_from_schema(schema: LayoutSchema, storage: LocalStorage): Promise<void>;
43
+ load_fonts_from_schema(schema: LayoutSchema, storage: Storage): Promise<void>;
44
44
  get_font(name: string): fontkit.Font;
45
45
  }
46
- export declare function render({ resume, layout_schemas, data_schemas, resume_layout, storage, fontDict }: RenderProps): Promise<[FontDict, ElementBox[][]]>;
46
+ export declare function render({ resume, layout_schemas, data_schemas, resume_layout, storage, fontDict }: RenderProps): Promise<[FontDict, ElementBox[][], SectionLayout[]]>;
package/dist/AnyLayout.js CHANGED
@@ -83,6 +83,7 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
83
83
  const column_width = resume_layout.column_type.tag === "SingleColumn"
84
84
  ? width
85
85
  : (width - (0, ResumeLayout_1.vertical_margin)(resume_layout.column_type) / 2.0);
86
+ const layouts = [];
86
87
  for (const section of resume.sections) {
87
88
  // Render Section Header
88
89
  // 1. Find the layout schema for the section
@@ -103,12 +104,14 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
103
104
  }
104
105
  start_time = Date.now();
105
106
  // 3. Render the header
106
- const result = layout_schema
107
+ const [result, layout] = layout_schema
107
108
  .header_layout_schema
108
- .copy()
109
+ // .copy()
109
110
  .instantiate(section.data)
110
111
  .normalize(column_width, font_dict)
111
112
  .compute_boxes(font_dict);
113
+ console.error("LSH: ", layout);
114
+ layouts.push(layout);
112
115
  end_time = Date.now();
113
116
  console.info(`Header rendering time: ${end_time - start_time}ms for section ${section.section_name}`);
114
117
  result.path = {
@@ -135,12 +138,14 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
135
138
  const _data_schema = data_schemas
136
139
  .find((s) => s.schema_name == section.data_schema);
137
140
  // 3. Render the item
138
- const result = layout_schema
141
+ const [result, layout] = layout_schema
139
142
  .item_layout_schema
140
- .copy()
143
+ // .copy()
141
144
  .instantiate(item.fields)
142
145
  .normalize(column_width, font_dict)
143
146
  .compute_boxes(font_dict);
147
+ console.error("LSS: ", layout);
148
+ layouts.push(layout);
144
149
  result.path = {
145
150
  tag: 'item',
146
151
  section: section.section_name,
@@ -168,6 +173,6 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
168
173
  current_y += box.bounding_box.height();
169
174
  }
170
175
  console.log("Position calculations are completed.");
171
- return [font_dict, pages];
176
+ return [font_dict, pages, layouts];
172
177
  }
173
178
  exports.render = render;
@@ -36,7 +36,7 @@ class FileStorage {
36
36
  this.dir = dir;
37
37
  }
38
38
  load_font(font) {
39
- throw new Error("Method not implemented.");
39
+ return Promise.resolve(fs_1.default.readFileSync(this.dir + font.full_name() + ".ttf"));
40
40
  }
41
41
  initiate_storage() {
42
42
  // Create data_dir/resumes if it does not exist
package/dist/Layout.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Margin } from "./Margin";
2
- import { Alignment } from "./Alignment";
3
- import { Width } from "./Width";
1
+ import * as Margin from "./Margin";
2
+ import * as Alignment from "./Alignment";
3
+ import * as Width from "./Width";
4
4
  import { Font } from "./Font";
5
5
  import { ItemContent } from "./Resume";
6
6
  import { Box } from "./Box";
@@ -10,21 +10,24 @@ export type ContainerType = Stack | Row;
10
10
  export type LayoutType = Stack | Row | Elem;
11
11
  export declare class SectionLayout {
12
12
  inner: Stack | Row | Elem;
13
+ bounding_box: Box | null;
13
14
  constructor(inner: Stack | Row | Elem);
14
15
  copy(): SectionLayout;
15
16
  static constrMap(tag: string): Stack | Row | Elem;
16
17
  static empty(): SectionLayout;
17
- static fromJson(json: any): SectionLayout;
18
+ static fromJson(json: unknown): SectionLayout;
18
19
  toJson(): any;
19
- width(): Width;
20
+ width(): Width.t;
20
21
  is_container(): boolean;
22
+ is_fill(): boolean;
21
23
  is_ref(): boolean;
22
24
  type_(): "Stack" | "Row" | "Elem";
23
25
  tag_(): "Stack" | "FlexRow" | "FrozenRow" | "Ref" | "Text";
24
26
  fonts(): Font[];
25
- with_margin(margin: Margin): SectionLayout;
26
- with_alignment(alignment: Alignment): SectionLayout;
27
- with_width(width: Width): SectionLayout;
27
+ with_margin(margin: Margin.t): SectionLayout;
28
+ with_alignment(alignment: Alignment.t): SectionLayout;
29
+ with_width(width: Width.t): SectionLayout;
30
+ total_elements_width(): number;
28
31
  is_instantiated(): boolean;
29
32
  instantiate(section: Map<string, ItemContent>): SectionLayout;
30
33
  static instantiate_ref_element(element: Elem, section: Map<string, ItemContent>): SectionLayout;
@@ -33,43 +36,45 @@ export declare class SectionLayout {
33
36
  normalize(width: number, font_dict: FontDict): SectionLayout;
34
37
  fill_fonts(font_dict: FontDict): SectionLayout;
35
38
  break_lines(font_dict: FontDict): SectionLayout;
36
- compute_boxes(font_dict: FontDict): ElementBox;
39
+ compute_boxes(font_dict: FontDict): [ElementBox, SectionLayout];
37
40
  compute_textbox_positions(textbox_positions: [Box, Elem][], top_left: Point, font_dict: FontDict): number;
38
41
  }
39
42
  export declare class Stack {
40
43
  tag: "Stack";
41
44
  elements: SectionLayout[];
42
- margin: Margin;
43
- alignment: Alignment;
44
- width: Width;
45
- constructor(elements: SectionLayout[], margin?: Margin, alignment?: Alignment, width?: Width);
46
- static stack(elements: SectionLayout[], margin?: Margin, alignment?: Alignment, width?: Width): SectionLayout;
45
+ margin: Margin.t;
46
+ alignment: Alignment.t;
47
+ width: Width.t;
48
+ is_fill: boolean;
49
+ constructor(elements: SectionLayout[], margin?: Margin.t, alignment?: Alignment.t, width?: Width.t, is_fill?: boolean);
50
+ static stack(elements: SectionLayout[], margin?: Margin.t, alignment?: Alignment.t, width?: Width.t, is_fill?: boolean): SectionLayout;
47
51
  copy(): Stack;
48
52
  static default_(): Stack;
49
53
  instantiate(section: Map<string, ItemContent>): Stack;
50
54
  with_elements(elements: SectionLayout[]): Stack;
51
- with_margin(margin: Margin): Stack;
52
- with_alignment(alignment: Alignment): Stack;
53
- with_width(width: Width): Stack;
55
+ with_margin(margin: Margin.t): Stack;
56
+ with_alignment(alignment: Alignment.t): Stack;
57
+ with_width(width: Width.t): Stack;
54
58
  bound_width(width: number): Stack;
55
59
  scale_width(w: number): Stack;
56
60
  }
57
61
  export declare class Row {
58
62
  tag: "Row";
59
63
  elements: SectionLayout[];
60
- margin: Margin;
61
- alignment: Alignment;
62
- width: Width;
64
+ margin: Margin.t;
65
+ alignment: Alignment.t;
66
+ width: Width.t;
63
67
  is_frozen: boolean;
64
- constructor(elements: SectionLayout[], is_frozen?: boolean, margin?: Margin, alignment?: Alignment, width?: Width);
65
- static row(elements: SectionLayout[], is_frozen?: boolean, margin?: Margin, alignment?: Alignment, width?: Width): SectionLayout;
68
+ is_fill: boolean;
69
+ constructor(elements: SectionLayout[], is_frozen?: boolean, margin?: Margin.t, alignment?: Alignment.t, width?: Width.t, is_fill?: boolean);
70
+ static row(elements: SectionLayout[], is_frozen?: boolean, margin?: Margin.t, alignment?: Alignment.t, width?: Width.t, is_fill?: boolean): SectionLayout;
66
71
  copy(): Row;
67
72
  static default_(): Row;
68
73
  instantiate(section: Map<string, ItemContent>): Row;
69
74
  with_elements(elements: SectionLayout[]): Row;
70
- with_margin(margin: Margin): Row;
71
- with_alignment(alignment: Alignment): Row;
72
- with_width(width: Width): Row;
75
+ with_margin(margin: Margin.t): Row;
76
+ with_alignment(alignment: Alignment.t): Row;
77
+ with_width(width: Width.t): Row;
73
78
  elements_width(): number;
74
79
  bound_width(width: number): Row;
75
80
  scale_width(w: number): Row;
@@ -91,24 +96,24 @@ export declare class Elem {
91
96
  url: string | null;
92
97
  is_ref: boolean;
93
98
  is_fill: boolean;
94
- text_width: Width;
99
+ text_width: Width.t;
95
100
  font: Font;
96
- margin: Margin;
97
- alignment: Alignment;
98
- width: Width;
101
+ margin: Margin.t;
102
+ alignment: Alignment.t;
103
+ width: Width.t;
99
104
  background_color: Color;
100
- constructor(item: string, url: string | null, is_ref: boolean, is_fill: boolean, text_width: Width, font: Font, margin: Margin, alignment: Alignment, width: Width, background_color: Color);
101
- static elem(item: string, url: string | null, is_ref: boolean, is_fill: boolean, text_width: Width, font: Font, margin: Margin, alignment: Alignment, width: Width, background_color: Color): SectionLayout;
105
+ constructor(item: string, url: string | null, is_ref: boolean, is_fill: boolean, text_width: Width.t, font: Font, margin: Margin.t, alignment: Alignment.t, width: Width.t, background_color: Color);
106
+ static elem(item: string, url: string | null, is_ref: boolean, is_fill: boolean, text_width: Width.t, font: Font, margin: Margin.t, alignment: Alignment.t, width: Width.t, background_color: Color): SectionLayout;
102
107
  copy(): Elem;
103
108
  static default_(): Elem;
104
109
  with_item(item: string): Elem;
105
110
  as_ref(): Elem;
106
111
  with_font(font: Font): Elem;
107
112
  with_url(url: string): Elem;
108
- with_margin(margin: Margin): Elem;
109
- with_alignment(alignment: Alignment): Elem;
110
- with_width(width: Width): Elem;
111
- with_text_width(text_width: Width): Elem;
113
+ with_margin(margin: Margin.t): Elem;
114
+ with_alignment(alignment: Alignment.t): Elem;
115
+ with_width(width: Width.t): Elem;
116
+ with_text_width(text_width: Width.t): Elem;
112
117
  with_is_fill(is_fill: boolean): Elem;
113
118
  scale_width(w: number): Elem;
114
119
  fill_fonts(fonts: FontDict): Elem;