cvdl-ts 1.0.18 → 1.0.19
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.js +1 -2
- package/dist/AnyLayout.d.ts +6 -6
- package/dist/AnyLayout.js +21 -17
- package/dist/BrowserStorage.d.ts +22 -0
- package/dist/BrowserStorage.js +50 -0
- package/dist/DataSchema.js +17 -8
- package/dist/Elem.d.ts +1 -1
- package/dist/Elem.js +37 -27
- package/dist/FileStorage.d.ts +0 -1
- package/dist/FileStorage.js +1 -1
- package/dist/Font.d.ts +5 -1
- package/dist/Font.js +53 -8
- package/dist/IndexedDB.d.ts +22 -0
- package/dist/IndexedDB.js +225 -0
- package/dist/Layout.js +124 -68
- package/dist/LayoutSchema.js +1 -1
- package/dist/LocalStorage.d.ts +0 -1
- package/dist/LocalStorage.js +0 -1
- package/dist/Margin.js +9 -10
- package/dist/OldLayout.js +7 -7
- package/dist/PdfLayout.d.ts +1 -2
- package/dist/PdfLayout.js +59 -20
- package/dist/RemoteStorage.d.ts +0 -1
- package/dist/RemoteStorage.js +8 -12
- package/dist/Resume.js +32 -16
- package/dist/ResumeLayout.js +6 -6
- package/dist/Row.js +16 -13
- package/dist/Stack.js +17 -10
- package/dist/Storage.d.ts +0 -1
- package/dist/Utils.js +2 -3
- package/dist/Width.js +15 -16
- package/dist/cli.js +9 -1
- package/package.json +25 -34
package/dist/Alignment.js
CHANGED
package/dist/AnyLayout.d.ts
CHANGED
|
@@ -3,19 +3,19 @@ import { LayoutSchema } from "./LayoutSchema";
|
|
|
3
3
|
import { Storage } from "./Storage";
|
|
4
4
|
import { Resume } from "./Resume";
|
|
5
5
|
import { ResumeLayout } from "./ResumeLayout";
|
|
6
|
-
import * as fontkit from
|
|
6
|
+
import * as fontkit from "fontkit";
|
|
7
7
|
import { Layout } from ".";
|
|
8
8
|
export type ElementPath = {
|
|
9
|
-
tag:
|
|
9
|
+
tag: "none";
|
|
10
10
|
} | {
|
|
11
|
-
tag:
|
|
11
|
+
tag: "section";
|
|
12
12
|
section: string;
|
|
13
13
|
} | {
|
|
14
|
-
tag:
|
|
14
|
+
tag: "item";
|
|
15
15
|
section: string;
|
|
16
16
|
item: number;
|
|
17
17
|
} | {
|
|
18
|
-
tag:
|
|
18
|
+
tag: "field";
|
|
19
19
|
section: string;
|
|
20
20
|
item: number;
|
|
21
21
|
field: string;
|
|
@@ -34,4 +34,4 @@ export declare class FontDict {
|
|
|
34
34
|
load_fonts_from_schema(schema: LayoutSchema, storage: Storage): Promise<void>;
|
|
35
35
|
get_font(name: string): fontkit.Font;
|
|
36
36
|
}
|
|
37
|
-
export declare function render({ resume, layout_schemas, data_schemas, resume_layout, storage, fontDict }: RenderProps): Promise<Layout.RenderedLayout[]>;
|
|
37
|
+
export declare function render({ resume, layout_schemas, data_schemas, resume_layout, storage, fontDict, }: RenderProps): Promise<Layout.RenderedLayout[]>;
|
package/dist/AnyLayout.js
CHANGED
|
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.FontDict = void 0;
|
|
27
|
+
exports.render = render;
|
|
27
28
|
const ResumeLayout_1 = require("./ResumeLayout");
|
|
28
29
|
const fontkit = __importStar(require("fontkit"));
|
|
29
30
|
const _1 = require(".");
|
|
@@ -32,16 +33,21 @@ class FontDict {
|
|
|
32
33
|
this.fonts = new Map();
|
|
33
34
|
}
|
|
34
35
|
async load_fonts_from_schema(schema, storage) {
|
|
35
|
-
for (const font of schema.fonts()) {
|
|
36
|
+
for (const font of [...schema.fonts()]) {
|
|
36
37
|
const fontName = _1.Font.full_name(font);
|
|
37
|
-
console.
|
|
38
|
+
console.error(`Loading font ${fontName}`);
|
|
38
39
|
if (this.fonts.has(fontName)) {
|
|
39
|
-
console.
|
|
40
|
+
console.error(`Font ${fontName} is already loaded`);
|
|
40
41
|
continue;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
try {
|
|
44
|
+
const font_data = await storage.load_font(font);
|
|
45
|
+
const fontkit_font = fontkit.create(font_data);
|
|
46
|
+
this.fonts.set(fontName, fontkit_font);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
console.error(`Error loading font ${fontName}: ${e}`);
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
get_font(name) {
|
|
@@ -53,21 +59,20 @@ class FontDict {
|
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
exports.FontDict = FontDict;
|
|
56
|
-
async function render({ resume, layout_schemas, data_schemas, resume_layout, storage, fontDict }) {
|
|
62
|
+
async function render({ resume, layout_schemas, data_schemas, resume_layout, storage, fontDict, }) {
|
|
57
63
|
// Compute the total usable width by subtracting the margins from the document width
|
|
58
|
-
const width = resume_layout.width -
|
|
64
|
+
const width = resume_layout.width -
|
|
65
|
+
(resume_layout.margin.left + resume_layout.margin.right);
|
|
59
66
|
// If the resume is double column, then the usable width is halved
|
|
60
67
|
const column_width = resume_layout.column_type.tag === "SingleColumn"
|
|
61
68
|
? width
|
|
62
|
-
:
|
|
69
|
+
: width - (0, ResumeLayout_1.vertical_margin)(resume_layout.column_type) / 2.0;
|
|
63
70
|
const layouts = [];
|
|
64
|
-
console.error("Rendering sections...");
|
|
65
71
|
for (const section of resume.sections) {
|
|
66
72
|
// Render Section Header
|
|
67
73
|
// 1. Find the layout schema for the section
|
|
68
74
|
console.info("Computing section: ", section.section_name);
|
|
69
|
-
const layout_schema = layout_schemas
|
|
70
|
-
.find(s => s.schema_name === section.layout_schema);
|
|
75
|
+
const layout_schema = layout_schemas.find((s) => s.schema_name === section.layout_schema);
|
|
71
76
|
if (layout_schema === undefined) {
|
|
72
77
|
throw new Error(`Could not find layout schema ${section.layout_schema}`);
|
|
73
78
|
}
|
|
@@ -76,14 +81,14 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
|
|
|
76
81
|
let end_time = Date.now();
|
|
77
82
|
console.info(`Font loading time: ${end_time - start_time}ms for section ${section.section_name}`);
|
|
78
83
|
// 2. Find the data schema for the section
|
|
79
|
-
const data_schema = data_schemas.find(s => s.schema_name === section.data_schema);
|
|
84
|
+
const data_schema = data_schemas.find((s) => s.schema_name === section.data_schema);
|
|
80
85
|
if (data_schema === undefined) {
|
|
81
86
|
throw new Error(`Could not find data schema ${section.data_schema}`);
|
|
82
87
|
}
|
|
83
88
|
start_time = Date.now();
|
|
84
89
|
// 3. Render the header
|
|
85
90
|
const layout = _1.Layout.computeBoxes(_1.Layout.normalize(_1.Layout.instantiate(layout_schema.header_layout_schema, section.data, data_schema.header_schema), column_width, fontDict), fontDict);
|
|
86
|
-
layout.path = { tag:
|
|
91
|
+
layout.path = { tag: "section", section: section.section_name };
|
|
87
92
|
console.info("Header is computed");
|
|
88
93
|
layouts.push(layout);
|
|
89
94
|
end_time = Date.now();
|
|
@@ -93,7 +98,7 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
|
|
|
93
98
|
for (const [index, item] of section.items.entries()) {
|
|
94
99
|
// 3. Render the item
|
|
95
100
|
const layout = _1.Layout.computeBoxes(_1.Layout.normalize(_1.Layout.instantiate(layout_schema.item_layout_schema, item.fields, data_schema.item_schema), column_width, fontDict), fontDict);
|
|
96
|
-
layout.path = { tag:
|
|
101
|
+
layout.path = { tag: "item", section: section.section_name, item: index };
|
|
97
102
|
layouts.push(layout);
|
|
98
103
|
}
|
|
99
104
|
end_time = Date.now();
|
|
@@ -102,4 +107,3 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
|
|
|
102
107
|
console.log("Position calculations are completed.");
|
|
103
108
|
return layouts;
|
|
104
109
|
}
|
|
105
|
-
exports.render = render;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DataSchema } from "./DataSchema";
|
|
2
|
+
import * as Font from "./Font";
|
|
3
|
+
import { LayoutSchema } from "./LayoutSchema";
|
|
4
|
+
import { Resume } from "./Resume";
|
|
5
|
+
import { ResumeLayout } from "./ResumeLayout";
|
|
6
|
+
import { Storage } from "./Storage";
|
|
7
|
+
export declare class BrowserStorage implements Storage {
|
|
8
|
+
initiate_storage(): Promise<void>;
|
|
9
|
+
list_resumes(): Promise<string[]>;
|
|
10
|
+
list_data_schemas(): Promise<string[]>;
|
|
11
|
+
list_layout_schemas(): Promise<string[]>;
|
|
12
|
+
list_resume_layouts(): Promise<string[]>;
|
|
13
|
+
load_resume(resume_name: string): Promise<Resume>;
|
|
14
|
+
load_data_schema(schema_name: string): Promise<DataSchema>;
|
|
15
|
+
load_layout_schema(schema_name: string): Promise<LayoutSchema>;
|
|
16
|
+
load_resume_layout(schema_name: string): Promise<ResumeLayout>;
|
|
17
|
+
save_resume(resume_name: string, resume_data: Resume): Promise<void>;
|
|
18
|
+
save_data_schema(data_schema: DataSchema): Promise<void>;
|
|
19
|
+
save_layout_schema(layout_schema: LayoutSchema): Promise<void>;
|
|
20
|
+
save_resume_layout(resume_layout: ResumeLayout): Promise<void>;
|
|
21
|
+
load_font(font: Font.t): Promise<Buffer>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowserStorage = void 0;
|
|
4
|
+
const LocalStorage_1 = require("./LocalStorage");
|
|
5
|
+
const IndexedDB_1 = require("./IndexedDB");
|
|
6
|
+
class BrowserStorage {
|
|
7
|
+
async initiate_storage() {
|
|
8
|
+
new LocalStorage_1.LocalStorage().initiate_storage();
|
|
9
|
+
}
|
|
10
|
+
list_resumes() {
|
|
11
|
+
return new LocalStorage_1.LocalStorage().list_resumes();
|
|
12
|
+
}
|
|
13
|
+
list_data_schemas() {
|
|
14
|
+
return new LocalStorage_1.LocalStorage().list_data_schemas();
|
|
15
|
+
}
|
|
16
|
+
list_layout_schemas() {
|
|
17
|
+
return new LocalStorage_1.LocalStorage().list_layout_schemas();
|
|
18
|
+
}
|
|
19
|
+
list_resume_layouts() {
|
|
20
|
+
return new LocalStorage_1.LocalStorage().list_resume_layouts();
|
|
21
|
+
}
|
|
22
|
+
load_resume(resume_name) {
|
|
23
|
+
return new LocalStorage_1.LocalStorage().load_resume(resume_name);
|
|
24
|
+
}
|
|
25
|
+
load_data_schema(schema_name) {
|
|
26
|
+
return new LocalStorage_1.LocalStorage().load_data_schema(schema_name);
|
|
27
|
+
}
|
|
28
|
+
load_layout_schema(schema_name) {
|
|
29
|
+
return new LocalStorage_1.LocalStorage().load_layout_schema(schema_name);
|
|
30
|
+
}
|
|
31
|
+
load_resume_layout(schema_name) {
|
|
32
|
+
return new LocalStorage_1.LocalStorage().load_resume_layout(schema_name);
|
|
33
|
+
}
|
|
34
|
+
save_resume(resume_name, resume_data) {
|
|
35
|
+
return new LocalStorage_1.LocalStorage().save_resume(resume_name, resume_data);
|
|
36
|
+
}
|
|
37
|
+
save_data_schema(data_schema) {
|
|
38
|
+
return new LocalStorage_1.LocalStorage().save_data_schema(data_schema);
|
|
39
|
+
}
|
|
40
|
+
save_layout_schema(layout_schema) {
|
|
41
|
+
return new LocalStorage_1.LocalStorage().save_layout_schema(layout_schema);
|
|
42
|
+
}
|
|
43
|
+
save_resume_layout(resume_layout) {
|
|
44
|
+
throw new Error("Method not implemented.");
|
|
45
|
+
}
|
|
46
|
+
async load_font(font) {
|
|
47
|
+
return new IndexedDB_1.IndexedDB().load_font(font);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.BrowserStorage = BrowserStorage;
|
package/dist/DataSchema.js
CHANGED
|
@@ -16,10 +16,9 @@ var DateFormat;
|
|
|
16
16
|
"Mon YYYY",
|
|
17
17
|
"Mon DD, YYYY",
|
|
18
18
|
"YYYY",
|
|
19
|
-
"unknown"
|
|
19
|
+
"unknown",
|
|
20
20
|
];
|
|
21
21
|
DateFormat.print = (date, format) => {
|
|
22
|
-
console.error(date);
|
|
23
22
|
const d = new Date(date + "T00:00:00");
|
|
24
23
|
const year = d.getFullYear();
|
|
25
24
|
const month = d.getMonth() + 1;
|
|
@@ -29,13 +28,12 @@ var DateFormat;
|
|
|
29
28
|
result = result.replace("YY", year.toString().slice(-2));
|
|
30
29
|
result = result.replace("MM", month.toString().padStart(2, "0"));
|
|
31
30
|
result = result.replace("DD", day.toString().padStart(2, "0"));
|
|
32
|
-
result = result.replace("Month", d.toLocaleString(
|
|
33
|
-
result = result.replace("Mon", d.toLocaleString(
|
|
31
|
+
result = result.replace("Month", d.toLocaleString("default", { month: "long" }));
|
|
32
|
+
result = result.replace("Mon", d.toLocaleString("default", { month: "short" }));
|
|
34
33
|
return result;
|
|
35
34
|
};
|
|
36
35
|
DateFormat.parse = (date) => {
|
|
37
36
|
const d = new Date(date + "T00:00:00");
|
|
38
|
-
console.error(d);
|
|
39
37
|
if (isNaN(d.getTime())) {
|
|
40
38
|
return "";
|
|
41
39
|
}
|
|
@@ -46,7 +44,10 @@ var DocumentDataType;
|
|
|
46
44
|
(function (DocumentDataType) {
|
|
47
45
|
function parse(s) {
|
|
48
46
|
if (s === "Date") {
|
|
49
|
-
return {
|
|
47
|
+
return {
|
|
48
|
+
tag: "Date",
|
|
49
|
+
format: s.length > 4 ? s.slice(5, -1).trim() : "YYYY-MM-DD",
|
|
50
|
+
};
|
|
50
51
|
}
|
|
51
52
|
else if (s === "String") {
|
|
52
53
|
return { tag: "String" };
|
|
@@ -61,7 +62,13 @@ var DocumentDataType;
|
|
|
61
62
|
return { tag: "List", value: parse(s.slice(5, -1).trim()) };
|
|
62
63
|
}
|
|
63
64
|
else if (s.includes("|")) {
|
|
64
|
-
return {
|
|
65
|
+
return {
|
|
66
|
+
tag: "Types",
|
|
67
|
+
value: s
|
|
68
|
+
.split("|")
|
|
69
|
+
.map((s) => s.trim())
|
|
70
|
+
.map(parse),
|
|
71
|
+
};
|
|
65
72
|
}
|
|
66
73
|
else {
|
|
67
74
|
throw new Error("Invalid DocumentDataType: " + s);
|
|
@@ -127,7 +134,9 @@ class DataSchema {
|
|
|
127
134
|
if (typeof json !== "object" || json === null) {
|
|
128
135
|
throw new Error("DataSchema must be an object");
|
|
129
136
|
}
|
|
130
|
-
if (!("schema_name" in json) ||
|
|
137
|
+
if (!("schema_name" in json) ||
|
|
138
|
+
!("header_schema" in json) ||
|
|
139
|
+
!("item_schema" in json)) {
|
|
131
140
|
throw new Error("DataSchema must have a schema_name, header_schema, and item_schema");
|
|
132
141
|
}
|
|
133
142
|
return new DataSchema(json.schema_name, json.header_schema.map(Field.fromJson), json.item_schema.map(Field.fromJson));
|
package/dist/Elem.d.ts
CHANGED
package/dist/Elem.js
CHANGED
|
@@ -23,7 +23,26 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.elem = elem;
|
|
27
|
+
exports.copy = copy;
|
|
28
|
+
exports.default_ = default_;
|
|
29
|
+
exports.from = from;
|
|
30
|
+
exports.withItem = withItem;
|
|
31
|
+
exports.withUrl = withUrl;
|
|
32
|
+
exports.withIsRef = withIsRef;
|
|
33
|
+
exports.asRef = asRef;
|
|
34
|
+
exports.withIsFill = withIsFill;
|
|
35
|
+
exports.withTextWidth = withTextWidth;
|
|
36
|
+
exports.withFont = withFont;
|
|
37
|
+
exports.withMargin = withMargin;
|
|
38
|
+
exports.withAlignment = withAlignment;
|
|
39
|
+
exports.withWidth = withWidth;
|
|
40
|
+
exports.withBackgroundColor = withBackgroundColor;
|
|
41
|
+
exports.scaleWidth = scaleWidth;
|
|
42
|
+
exports.parseMarkdownItem = parseMarkdownItem;
|
|
43
|
+
exports.fillFonts = fillFonts;
|
|
44
|
+
exports.boundWidth = boundWidth;
|
|
45
|
+
exports.instantiate = instantiate;
|
|
27
46
|
const Font = __importStar(require("./Font"));
|
|
28
47
|
const _1 = require(".");
|
|
29
48
|
const Resume_1 = require("./Resume");
|
|
@@ -54,11 +73,9 @@ function elem(item, url, is_ref, is_fill, is_markdown, text_width, font, margin,
|
|
|
54
73
|
background_color,
|
|
55
74
|
};
|
|
56
75
|
}
|
|
57
|
-
exports.elem = elem;
|
|
58
76
|
function copy(e) {
|
|
59
77
|
return { ...e };
|
|
60
78
|
}
|
|
61
|
-
exports.copy = copy;
|
|
62
79
|
function default_() {
|
|
63
80
|
return {
|
|
64
81
|
tag: "Elem",
|
|
@@ -75,59 +92,45 @@ function default_() {
|
|
|
75
92
|
background_color: "Transparent",
|
|
76
93
|
};
|
|
77
94
|
}
|
|
78
|
-
exports.default_ = default_;
|
|
79
95
|
function from(w) {
|
|
80
96
|
return { ...default_(), ...w };
|
|
81
97
|
}
|
|
82
|
-
exports.from = from;
|
|
83
98
|
function withItem(e, item) {
|
|
84
99
|
return { ...e, item };
|
|
85
100
|
}
|
|
86
|
-
exports.withItem = withItem;
|
|
87
101
|
function withUrl(e, url) {
|
|
88
102
|
return { ...e, url };
|
|
89
103
|
}
|
|
90
|
-
exports.withUrl = withUrl;
|
|
91
104
|
function withIsRef(e, is_ref) {
|
|
92
105
|
return { ...e, is_ref };
|
|
93
106
|
}
|
|
94
|
-
exports.withIsRef = withIsRef;
|
|
95
107
|
function asRef(e) {
|
|
96
108
|
return withIsRef(e, true);
|
|
97
109
|
}
|
|
98
|
-
exports.asRef = asRef;
|
|
99
110
|
function withIsFill(e, is_fill) {
|
|
100
111
|
return { ...e, is_fill };
|
|
101
112
|
}
|
|
102
|
-
exports.withIsFill = withIsFill;
|
|
103
113
|
function withTextWidth(e, text_width) {
|
|
104
114
|
return { ...e, text_width };
|
|
105
115
|
}
|
|
106
|
-
exports.withTextWidth = withTextWidth;
|
|
107
116
|
function withFont(e, font) {
|
|
108
117
|
return { ...e, font };
|
|
109
118
|
}
|
|
110
|
-
exports.withFont = withFont;
|
|
111
119
|
function withMargin(e, margin) {
|
|
112
120
|
return { ...e, margin };
|
|
113
121
|
}
|
|
114
|
-
exports.withMargin = withMargin;
|
|
115
122
|
function withAlignment(e, alignment) {
|
|
116
123
|
return { ...e, alignment };
|
|
117
124
|
}
|
|
118
|
-
exports.withAlignment = withAlignment;
|
|
119
125
|
function withWidth(e, width) {
|
|
120
126
|
return { ...e, width };
|
|
121
127
|
}
|
|
122
|
-
exports.withWidth = withWidth;
|
|
123
128
|
function withBackgroundColor(e, background_color) {
|
|
124
129
|
return { ...e, background_color };
|
|
125
130
|
}
|
|
126
|
-
exports.withBackgroundColor = withBackgroundColor;
|
|
127
131
|
function scaleWidth(e, scale) {
|
|
128
132
|
return withWidth(e, _1.Width.scale(e.width, scale));
|
|
129
133
|
}
|
|
130
|
-
exports.scaleWidth = scaleWidth;
|
|
131
134
|
function flatten(ts, sp) {
|
|
132
135
|
const spans = [];
|
|
133
136
|
for (const t of ts) {
|
|
@@ -179,15 +182,16 @@ function parseMarkdownItem(item) {
|
|
|
179
182
|
}
|
|
180
183
|
return spans;
|
|
181
184
|
}
|
|
182
|
-
exports.parseMarkdownItem = parseMarkdownItem;
|
|
183
185
|
function fillFonts(e, fonts) {
|
|
184
186
|
const simpleSpans = e.is_markdown ? parseMarkdownItem(e.text) : [{ ...defaultSpanProps(), text: e.text, font: e.font, link: null }];
|
|
185
187
|
const spans = [];
|
|
186
188
|
for (const span of simpleSpans) {
|
|
187
189
|
const font = e.is_markdown ? (0, Utils_1.with_)(e.font, ({
|
|
188
|
-
|
|
189
|
-
weight: span.is_bold ? "Bold" :
|
|
190
|
+
style: span.is_italic ? "Italic" : e.font.style,
|
|
191
|
+
weight: span.is_bold ? "Bold" : e.font.weight,
|
|
192
|
+
name: span.is_code ? "JetBrainsMono" : e.font.name
|
|
190
193
|
})) : e.font;
|
|
194
|
+
console.log(`Font: ${JSON.stringify(font)}`, span.text);
|
|
191
195
|
if (span.text === " ") {
|
|
192
196
|
const width = Font.get_width(font, "-", fonts);
|
|
193
197
|
spans.push({ ...span, font, width });
|
|
@@ -202,7 +206,12 @@ function fillFonts(e, fonts) {
|
|
|
202
206
|
const width = Font.get_width(font, word, fonts);
|
|
203
207
|
spans.push({ ...span, text: word, font, width });
|
|
204
208
|
if (index < words.length - 1) {
|
|
205
|
-
spans.push({
|
|
209
|
+
spans.push({
|
|
210
|
+
...span,
|
|
211
|
+
text: " ",
|
|
212
|
+
font,
|
|
213
|
+
width: Font.get_width(font, " ", fonts),
|
|
214
|
+
});
|
|
206
215
|
}
|
|
207
216
|
});
|
|
208
217
|
}
|
|
@@ -211,14 +220,13 @@ function fillFonts(e, fonts) {
|
|
|
211
220
|
return (0, Utils_1.with_)(e, {
|
|
212
221
|
width: _1.Width.absolute(Math.min(_1.Width.get_fixed_unchecked(e.width), text_width)),
|
|
213
222
|
text_width: _1.Width.absolute(text_width),
|
|
214
|
-
spans
|
|
223
|
+
spans,
|
|
215
224
|
});
|
|
216
225
|
}
|
|
217
226
|
else {
|
|
218
227
|
return (0, Utils_1.with_)(e, { text_width: _1.Width.absolute(text_width), spans });
|
|
219
228
|
}
|
|
220
229
|
}
|
|
221
|
-
exports.fillFonts = fillFonts;
|
|
222
230
|
function boundWidth(e, width) {
|
|
223
231
|
if (!_1.Width.is_fill(e.width)) {
|
|
224
232
|
return withIsFill(withWidth(e, _1.Width.absolute(Math.min(_1.Width.get_fixed_unchecked(e.width), width))), false);
|
|
@@ -227,12 +235,11 @@ function boundWidth(e, width) {
|
|
|
227
235
|
return withIsFill(withWidth(e, _1.Width.absolute(width)), true);
|
|
228
236
|
}
|
|
229
237
|
}
|
|
230
|
-
exports.boundWidth = boundWidth;
|
|
231
238
|
function instantiate(e, section, fields) {
|
|
232
239
|
if (!e.is_ref) {
|
|
233
240
|
return e;
|
|
234
241
|
}
|
|
235
|
-
const itemType = fields.find(f => f.name === e.item);
|
|
242
|
+
const itemType = fields.find((f) => f.name === e.item);
|
|
236
243
|
if (itemType.type.tag === "MarkdownString") {
|
|
237
244
|
e.is_markdown = true;
|
|
238
245
|
}
|
|
@@ -243,11 +250,14 @@ function instantiate(e, section, fields) {
|
|
|
243
250
|
}
|
|
244
251
|
else {
|
|
245
252
|
if (text.tag === "Url") {
|
|
246
|
-
return (0, Utils_1.with_)(e, {
|
|
253
|
+
return (0, Utils_1.with_)(e, {
|
|
254
|
+
is_ref: false,
|
|
255
|
+
text: text.value.text,
|
|
256
|
+
url: text.value.url,
|
|
257
|
+
});
|
|
247
258
|
}
|
|
248
259
|
else {
|
|
249
260
|
return (0, Utils_1.with_)(e, { is_ref: false, text: Resume_1.ItemContent.toString(text) });
|
|
250
261
|
}
|
|
251
262
|
}
|
|
252
263
|
}
|
|
253
|
-
exports.instantiate = instantiate;
|
package/dist/FileStorage.d.ts
CHANGED
package/dist/FileStorage.js
CHANGED
|
@@ -81,7 +81,7 @@ class FileStorage {
|
|
|
81
81
|
}
|
|
82
82
|
async list_resumes() {
|
|
83
83
|
const files = fs_1.default.readdirSync(this.dir + "/resumes");
|
|
84
|
-
return Promise.resolve(files.map(file => file.replace(".json", "")));
|
|
84
|
+
return Promise.resolve(files.map((file) => file.replace(".json", "")));
|
|
85
85
|
}
|
|
86
86
|
async list_data_schemas() {
|
|
87
87
|
const data_schemas = fs_1.default.readFileSync(this.dir + "/data-schemas.json");
|
package/dist/Font.d.ts
CHANGED
|
@@ -10,10 +10,14 @@ type Font = t;
|
|
|
10
10
|
export declare function font(name: string, size: number, weight: FontWeight, style: FontStyle, source: FontSource): Font;
|
|
11
11
|
export declare function fromJson(json: unknown): Font;
|
|
12
12
|
export declare function default_(): Font;
|
|
13
|
+
export declare function variants(f: Font): Font[];
|
|
13
14
|
export declare function full_name(f: Font): string;
|
|
14
15
|
export declare function get_width(f: Font, text: string, fonts: FontDict): number;
|
|
15
16
|
export declare function get_height(f: Font, fonts: FontDict): number;
|
|
16
17
|
export type FontSource = "Local" | "System" | "Remote";
|
|
17
|
-
export type FontWeight = "Light" | "Medium" | "Bold";
|
|
18
|
+
export type FontWeight = "ExtraLight" | "Light" | "Thin" | "Medium" | "Regular" | "SemiBold" | "Bold" | "Black" | "ExtraBold";
|
|
19
|
+
export declare const FontWeights: readonly ["ExtraLight", "Light", "Thin", "Medium", "Regular", "SemiBold", "Bold", "Black", "ExtraBold"];
|
|
18
20
|
export type FontStyle = "Normal" | "Italic";
|
|
21
|
+
export declare const FontStyles: readonly ["Normal", "Italic"];
|
|
22
|
+
export declare const AvailableFonts: readonly ["EBGaramond", "Exo", "Inter", "JetBrainsMono", "Montserrat", "Merriweather", "NotoSerif", "OpenSans", "Roboto", "RobotoMono"];
|
|
19
23
|
export {};
|
package/dist/Font.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AvailableFonts = exports.FontStyles = exports.FontWeights = void 0;
|
|
4
|
+
exports.font = font;
|
|
5
|
+
exports.fromJson = fromJson;
|
|
6
|
+
exports.default_ = default_;
|
|
7
|
+
exports.variants = variants;
|
|
8
|
+
exports.full_name = full_name;
|
|
9
|
+
exports.get_width = get_width;
|
|
10
|
+
exports.get_height = get_height;
|
|
4
11
|
function font(name, size, weight, style, source) {
|
|
5
12
|
return {
|
|
6
13
|
name,
|
|
@@ -10,7 +17,6 @@ function font(name, size, weight, style, source) {
|
|
|
10
17
|
source,
|
|
11
18
|
};
|
|
12
19
|
}
|
|
13
|
-
exports.font = font;
|
|
14
20
|
function fromJson(json) {
|
|
15
21
|
return {
|
|
16
22
|
...default_(),
|
|
@@ -21,7 +27,6 @@ function fromJson(json) {
|
|
|
21
27
|
source: json["source"],
|
|
22
28
|
};
|
|
23
29
|
}
|
|
24
|
-
exports.fromJson = fromJson;
|
|
25
30
|
function default_() {
|
|
26
31
|
return {
|
|
27
32
|
name: "Exo",
|
|
@@ -31,18 +36,58 @@ function default_() {
|
|
|
31
36
|
source: "System",
|
|
32
37
|
};
|
|
33
38
|
}
|
|
34
|
-
|
|
39
|
+
function variants(f) {
|
|
40
|
+
const fonts = [];
|
|
41
|
+
for (const weight of exports.FontWeights) {
|
|
42
|
+
for (const style of exports.FontStyles) {
|
|
43
|
+
fonts.push({
|
|
44
|
+
...f,
|
|
45
|
+
weight,
|
|
46
|
+
style,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return fonts;
|
|
51
|
+
}
|
|
35
52
|
function full_name(f) {
|
|
36
53
|
return f.name + "-" + f.weight + (f.style === "Italic" ? "Italic" : "");
|
|
37
54
|
}
|
|
38
|
-
exports.full_name = full_name;
|
|
39
55
|
function get_width(f, text, fonts) {
|
|
40
56
|
const font = fonts.get_font(full_name(f));
|
|
41
|
-
return (
|
|
57
|
+
return ((font
|
|
58
|
+
.layout(text)
|
|
59
|
+
.glyphs.reduce((acc, glyph) => acc + glyph.advanceWidth, 0) /
|
|
60
|
+
font.unitsPerEm) *
|
|
61
|
+
f.size);
|
|
42
62
|
}
|
|
43
|
-
exports.get_width = get_width;
|
|
44
63
|
function get_height(f, fonts) {
|
|
45
64
|
const font = fonts.get_font(full_name(f));
|
|
46
65
|
return (font.bbox.height / font.unitsPerEm) * f.size;
|
|
47
66
|
}
|
|
48
|
-
exports.
|
|
67
|
+
exports.FontWeights = [
|
|
68
|
+
"ExtraLight",
|
|
69
|
+
"Light",
|
|
70
|
+
"Thin",
|
|
71
|
+
"Medium",
|
|
72
|
+
"Regular",
|
|
73
|
+
"SemiBold",
|
|
74
|
+
"Bold",
|
|
75
|
+
"Black",
|
|
76
|
+
"ExtraBold",
|
|
77
|
+
];
|
|
78
|
+
exports.FontStyles = [
|
|
79
|
+
"Normal",
|
|
80
|
+
"Italic",
|
|
81
|
+
];
|
|
82
|
+
exports.AvailableFonts = [
|
|
83
|
+
"EBGaramond",
|
|
84
|
+
"Exo",
|
|
85
|
+
"Inter",
|
|
86
|
+
"JetBrainsMono",
|
|
87
|
+
"Montserrat",
|
|
88
|
+
"Merriweather",
|
|
89
|
+
"NotoSerif",
|
|
90
|
+
"OpenSans",
|
|
91
|
+
"Roboto",
|
|
92
|
+
"RobotoMono",
|
|
93
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DataSchema } from "./DataSchema";
|
|
2
|
+
import * as Font from "./Font";
|
|
3
|
+
import { LayoutSchema } from "./LayoutSchema";
|
|
4
|
+
import { Resume } from "./Resume";
|
|
5
|
+
import { ResumeLayout } from "./ResumeLayout";
|
|
6
|
+
import { Storage } from "./Storage";
|
|
7
|
+
export declare class IndexedDB implements Storage {
|
|
8
|
+
initiate_storage(): Promise<void>;
|
|
9
|
+
list_resumes(): Promise<string[]>;
|
|
10
|
+
list_data_schemas(): Promise<string[]>;
|
|
11
|
+
list_layout_schemas(): Promise<string[]>;
|
|
12
|
+
list_resume_layouts(): Promise<string[]>;
|
|
13
|
+
load_resume(resume_name: string): Promise<Resume>;
|
|
14
|
+
load_data_schema(schema_name: string): Promise<DataSchema>;
|
|
15
|
+
load_layout_schema(schema_name: string): Promise<LayoutSchema>;
|
|
16
|
+
load_resume_layout(schema_name: string): Promise<ResumeLayout>;
|
|
17
|
+
save_resume(resume_name: string, resume_data: Resume): Promise<void>;
|
|
18
|
+
save_data_schema(data_schema: DataSchema): Promise<void>;
|
|
19
|
+
save_layout_schema(layout_schema: LayoutSchema): Promise<void>;
|
|
20
|
+
save_resume_layout(resume_layout: ResumeLayout): Promise<void>;
|
|
21
|
+
load_font(font: Font.t): Promise<Buffer>;
|
|
22
|
+
}
|