cvdl-ts 1.0.10 → 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/dist/Alignment.d.ts +4 -4
- package/dist/Alignment.js +5 -8
- package/dist/AnyLayout.d.ts +5 -5
- package/dist/AnyLayout.js +10 -5
- package/dist/FileStorage.js +1 -1
- package/dist/Layout.d.ts +36 -35
- package/dist/Layout.js +91 -84
- package/dist/LocalStorage.d.ts +16 -13
- package/dist/LocalStorage.js +10 -7
- package/dist/Margin.d.ts +9 -12
- package/dist/Margin.js +32 -29
- package/dist/PdfLayout.d.ts +5 -2
- package/dist/PdfLayout.js +64 -29
- package/dist/ResumeLayout.d.ts +3 -3
- package/dist/ResumeLayout.js +25 -2
- package/dist/Width.d.ts +13 -13
- package/dist/Width.js +71 -74
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +23 -0
- package/package.json +3 -2
package/dist/Alignment.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
2
|
-
|
|
3
|
-
|
|
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.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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_;
|
package/dist/AnyLayout.d.ts
CHANGED
|
@@ -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 {
|
|
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:
|
|
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:
|
|
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;
|
package/dist/FileStorage.js
CHANGED
|
@@ -36,7 +36,7 @@ class FileStorage {
|
|
|
36
36
|
this.dir = dir;
|
|
37
37
|
}
|
|
38
38
|
load_font(font) {
|
|
39
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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,22 +10,23 @@ 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:
|
|
18
|
+
static fromJson(json: unknown): SectionLayout;
|
|
18
19
|
toJson(): any;
|
|
19
|
-
width(): Width;
|
|
20
|
+
width(): Width.t;
|
|
20
21
|
is_container(): boolean;
|
|
21
22
|
is_fill(): boolean;
|
|
22
23
|
is_ref(): boolean;
|
|
23
24
|
type_(): "Stack" | "Row" | "Elem";
|
|
24
25
|
tag_(): "Stack" | "FlexRow" | "FrozenRow" | "Ref" | "Text";
|
|
25
26
|
fonts(): Font[];
|
|
26
|
-
with_margin(margin: Margin): SectionLayout;
|
|
27
|
-
with_alignment(alignment: Alignment): SectionLayout;
|
|
28
|
-
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;
|
|
29
30
|
total_elements_width(): number;
|
|
30
31
|
is_instantiated(): boolean;
|
|
31
32
|
instantiate(section: Map<string, ItemContent>): SectionLayout;
|
|
@@ -35,45 +36,45 @@ export declare class SectionLayout {
|
|
|
35
36
|
normalize(width: number, font_dict: FontDict): SectionLayout;
|
|
36
37
|
fill_fonts(font_dict: FontDict): SectionLayout;
|
|
37
38
|
break_lines(font_dict: FontDict): SectionLayout;
|
|
38
|
-
compute_boxes(font_dict: FontDict): ElementBox;
|
|
39
|
+
compute_boxes(font_dict: FontDict): [ElementBox, SectionLayout];
|
|
39
40
|
compute_textbox_positions(textbox_positions: [Box, Elem][], top_left: Point, font_dict: FontDict): number;
|
|
40
41
|
}
|
|
41
42
|
export declare class Stack {
|
|
42
43
|
tag: "Stack";
|
|
43
44
|
elements: SectionLayout[];
|
|
44
|
-
margin: Margin;
|
|
45
|
-
alignment: Alignment;
|
|
46
|
-
width: Width;
|
|
45
|
+
margin: Margin.t;
|
|
46
|
+
alignment: Alignment.t;
|
|
47
|
+
width: Width.t;
|
|
47
48
|
is_fill: boolean;
|
|
48
|
-
constructor(elements: SectionLayout[], margin?: Margin, alignment?: Alignment, width?: Width, is_fill?: boolean);
|
|
49
|
-
static stack(elements: SectionLayout[], margin?: Margin, alignment?: Alignment, width?: Width, is_fill?: boolean): SectionLayout;
|
|
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;
|
|
50
51
|
copy(): Stack;
|
|
51
52
|
static default_(): Stack;
|
|
52
53
|
instantiate(section: Map<string, ItemContent>): Stack;
|
|
53
54
|
with_elements(elements: SectionLayout[]): Stack;
|
|
54
|
-
with_margin(margin: Margin): Stack;
|
|
55
|
-
with_alignment(alignment: Alignment): Stack;
|
|
56
|
-
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;
|
|
57
58
|
bound_width(width: number): Stack;
|
|
58
59
|
scale_width(w: number): Stack;
|
|
59
60
|
}
|
|
60
61
|
export declare class Row {
|
|
61
62
|
tag: "Row";
|
|
62
63
|
elements: SectionLayout[];
|
|
63
|
-
margin: Margin;
|
|
64
|
-
alignment: Alignment;
|
|
65
|
-
width: Width;
|
|
64
|
+
margin: Margin.t;
|
|
65
|
+
alignment: Alignment.t;
|
|
66
|
+
width: Width.t;
|
|
66
67
|
is_frozen: boolean;
|
|
67
68
|
is_fill: boolean;
|
|
68
|
-
constructor(elements: SectionLayout[], is_frozen?: boolean, margin?: Margin, alignment?: Alignment, width?: Width, is_fill?: boolean);
|
|
69
|
-
static row(elements: SectionLayout[], is_frozen?: boolean, margin?: Margin, alignment?: Alignment, width?: Width, is_fill?: boolean): SectionLayout;
|
|
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;
|
|
70
71
|
copy(): Row;
|
|
71
72
|
static default_(): Row;
|
|
72
73
|
instantiate(section: Map<string, ItemContent>): Row;
|
|
73
74
|
with_elements(elements: SectionLayout[]): Row;
|
|
74
|
-
with_margin(margin: Margin): Row;
|
|
75
|
-
with_alignment(alignment: Alignment): Row;
|
|
76
|
-
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;
|
|
77
78
|
elements_width(): number;
|
|
78
79
|
bound_width(width: number): Row;
|
|
79
80
|
scale_width(w: number): Row;
|
|
@@ -95,24 +96,24 @@ export declare class Elem {
|
|
|
95
96
|
url: string | null;
|
|
96
97
|
is_ref: boolean;
|
|
97
98
|
is_fill: boolean;
|
|
98
|
-
text_width: Width;
|
|
99
|
+
text_width: Width.t;
|
|
99
100
|
font: Font;
|
|
100
|
-
margin: Margin;
|
|
101
|
-
alignment: Alignment;
|
|
102
|
-
width: Width;
|
|
101
|
+
margin: Margin.t;
|
|
102
|
+
alignment: Alignment.t;
|
|
103
|
+
width: Width.t;
|
|
103
104
|
background_color: Color;
|
|
104
|
-
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);
|
|
105
|
-
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;
|
|
106
107
|
copy(): Elem;
|
|
107
108
|
static default_(): Elem;
|
|
108
109
|
with_item(item: string): Elem;
|
|
109
110
|
as_ref(): Elem;
|
|
110
111
|
with_font(font: Font): Elem;
|
|
111
112
|
with_url(url: string): Elem;
|
|
112
|
-
with_margin(margin: Margin): Elem;
|
|
113
|
-
with_alignment(alignment: Alignment): Elem;
|
|
114
|
-
with_width(width: Width): Elem;
|
|
115
|
-
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;
|
|
116
117
|
with_is_fill(is_fill: boolean): Elem;
|
|
117
118
|
scale_width(w: number): Elem;
|
|
118
119
|
fill_fonts(fonts: FontDict): Elem;
|