cvdl-ts 1.0.19 → 1.0.20
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/AnyLayout.d.ts +7 -6
- package/dist/AnyLayout.js +18 -19
- package/dist/Bindings.d.ts +0 -0
- package/dist/Bindings.js +0 -0
- package/dist/DataSchema.d.ts +8 -19
- package/dist/DataSchema.js +7 -110
- package/dist/Defaults.d.ts +35 -0
- package/dist/Defaults.js +714 -0
- package/dist/Elem.d.ts +12 -6
- package/dist/Elem.js +50 -23
- package/dist/FileStorage.d.ts +8 -7
- package/dist/FileStorage.js +27 -30
- package/dist/Font.d.ts +2 -9
- package/dist/Font.js +1 -56
- package/dist/Layout.d.ts +22 -4
- package/dist/Layout.js +3 -67
- package/dist/LayoutSchema.d.ts +5 -6
- package/dist/LayoutSchema.js +3 -9
- package/dist/LocalStorage.d.ts +8 -7
- package/dist/LocalStorage.js +35 -33
- package/dist/Margin.d.ts +0 -2
- package/dist/Margin.js +0 -17
- package/dist/PdfLayout.d.ts +5 -4
- package/dist/PdfLayout.js +34 -5
- package/dist/RemoteStorage.d.ts +8 -7
- package/dist/RemoteStorage.js +10 -26
- package/dist/Resume.d.ts +40 -47
- package/dist/Resume.js +49 -177
- package/dist/ResumeLayout.d.ts +0 -3
- package/dist/ResumeLayout.js +2 -45
- package/dist/Row.d.ts +3 -1
- package/dist/Row.js +9 -7
- package/dist/Stack.d.ts +4 -1
- package/dist/Stack.js +34 -8
- package/dist/Storage.d.ts +8 -7
- package/dist/Utils.d.ts +1 -0
- package/dist/Utils.js +4 -0
- package/dist/cli.js +55 -20
- package/package.json +1 -1
- package/dist/BrowserStorage.d.ts +0 -22
- package/dist/BrowserStorage.js +0 -50
- package/dist/IndexedDB.d.ts +0 -22
- package/dist/IndexedDB.js +0 -225
package/dist/AnyLayout.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DataSchema } from "./DataSchema";
|
|
2
2
|
import { LayoutSchema } from "./LayoutSchema";
|
|
3
3
|
import { Storage } from "./Storage";
|
|
4
|
-
import { Resume } from "./Resume";
|
|
5
4
|
import { ResumeLayout } from "./ResumeLayout";
|
|
6
5
|
import * as fontkit from "fontkit";
|
|
7
|
-
import
|
|
6
|
+
import * as Layout from "./Layout";
|
|
7
|
+
import * as Resume from "./Resume";
|
|
8
8
|
export type ElementPath = {
|
|
9
9
|
tag: "none";
|
|
10
10
|
} | {
|
|
@@ -21,17 +21,18 @@ export type ElementPath = {
|
|
|
21
21
|
field: string;
|
|
22
22
|
};
|
|
23
23
|
export type RenderProps = {
|
|
24
|
-
resume: Resume;
|
|
24
|
+
resume: Resume.t;
|
|
25
25
|
layout_schemas: LayoutSchema[];
|
|
26
|
-
data_schemas: DataSchema[];
|
|
26
|
+
data_schemas: DataSchema.t[];
|
|
27
27
|
resume_layout: ResumeLayout;
|
|
28
|
+
bindings: Map<string, unknown>;
|
|
28
29
|
storage: Storage;
|
|
29
30
|
fontDict?: FontDict;
|
|
30
31
|
};
|
|
31
32
|
export declare class FontDict {
|
|
32
33
|
fonts: Map<string, fontkit.Font>;
|
|
33
34
|
constructor();
|
|
34
|
-
|
|
35
|
+
load_fonts(storage: Storage): Promise<this>;
|
|
35
36
|
get_font(name: string): fontkit.Font;
|
|
36
37
|
}
|
|
37
|
-
export declare function render({ resume, layout_schemas, data_schemas, resume_layout,
|
|
38
|
+
export declare function render({ resume, layout_schemas, data_schemas, resume_layout, bindings, fontDict, }: RenderProps): Promise<Layout.RenderedLayout[]>;
|
package/dist/AnyLayout.js
CHANGED
|
@@ -27,28 +27,26 @@ exports.FontDict = void 0;
|
|
|
27
27
|
exports.render = render;
|
|
28
28
|
const ResumeLayout_1 = require("./ResumeLayout");
|
|
29
29
|
const fontkit = __importStar(require("fontkit"));
|
|
30
|
-
const
|
|
30
|
+
const Layout = __importStar(require("./Layout"));
|
|
31
|
+
const cartesian = (...a) => a.reduce((a, b) => a.flatMap(d => b.map(e => [d, e].flat())));
|
|
31
32
|
class FontDict {
|
|
32
33
|
constructor() {
|
|
33
34
|
this.fonts = new Map();
|
|
34
35
|
}
|
|
35
|
-
async
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
async load_fonts(storage) {
|
|
37
|
+
const variants = cartesian(["Exo", "OpenSans", "SourceCodePro"], ["Medium", "Bold"], ["", "Italic"]);
|
|
38
|
+
await Promise.all(variants.map(async ([name, weight, style]) => {
|
|
39
|
+
const fontName = `${name}-${weight}${style}`;
|
|
38
40
|
console.error(`Loading font ${fontName}`);
|
|
39
41
|
if (this.fonts.has(fontName)) {
|
|
40
|
-
console.
|
|
41
|
-
|
|
42
|
+
console.log(`Font ${fontName} is already loaded`);
|
|
43
|
+
return;
|
|
42
44
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
catch (e) {
|
|
49
|
-
console.error(`Error loading font ${fontName}: ${e}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
45
|
+
const font_data = await storage.load_font(fontName);
|
|
46
|
+
const fontkit_font = fontkit.create(font_data);
|
|
47
|
+
this.fonts.set(fontName, fontkit_font);
|
|
48
|
+
}));
|
|
49
|
+
return this;
|
|
52
50
|
}
|
|
53
51
|
get_font(name) {
|
|
54
52
|
const font = this.fonts.get(name);
|
|
@@ -59,7 +57,7 @@ class FontDict {
|
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
exports.FontDict = FontDict;
|
|
62
|
-
async function render({ resume, layout_schemas, data_schemas, resume_layout,
|
|
60
|
+
async function render({ resume, layout_schemas, data_schemas, resume_layout, bindings, fontDict, }) {
|
|
63
61
|
// Compute the total usable width by subtracting the margins from the document width
|
|
64
62
|
const width = resume_layout.width -
|
|
65
63
|
(resume_layout.margin.left + resume_layout.margin.right);
|
|
@@ -68,6 +66,7 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
|
|
|
68
66
|
? width
|
|
69
67
|
: width - (0, ResumeLayout_1.vertical_margin)(resume_layout.column_type) / 2.0;
|
|
70
68
|
const layouts = [];
|
|
69
|
+
console.error("Rendering sections...");
|
|
71
70
|
for (const section of resume.sections) {
|
|
72
71
|
// Render Section Header
|
|
73
72
|
// 1. Find the layout schema for the section
|
|
@@ -77,7 +76,7 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
|
|
|
77
76
|
throw new Error(`Could not find layout schema ${section.layout_schema}`);
|
|
78
77
|
}
|
|
79
78
|
let start_time = Date.now();
|
|
80
|
-
await fontDict.load_fonts_from_schema(layout_schema, storage);
|
|
79
|
+
// await fontDict.load_fonts_from_schema(layout_schema, storage);
|
|
81
80
|
let end_time = Date.now();
|
|
82
81
|
console.info(`Font loading time: ${end_time - start_time}ms for section ${section.section_name}`);
|
|
83
82
|
// 2. Find the data schema for the section
|
|
@@ -87,7 +86,7 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
|
|
|
87
86
|
}
|
|
88
87
|
start_time = Date.now();
|
|
89
88
|
// 3. Render the header
|
|
90
|
-
const layout =
|
|
89
|
+
const layout = Layout.computeBoxes(Layout.normalize(Layout.instantiate(layout_schema.header_layout_schema, section.data, data_schema.header_schema, bindings), column_width, fontDict), fontDict);
|
|
91
90
|
layout.path = { tag: "section", section: section.section_name };
|
|
92
91
|
console.info("Header is computed");
|
|
93
92
|
layouts.push(layout);
|
|
@@ -97,7 +96,7 @@ async function render({ resume, layout_schemas, data_schemas, resume_layout, sto
|
|
|
97
96
|
// Render Section Items
|
|
98
97
|
for (const [index, item] of section.items.entries()) {
|
|
99
98
|
// 3. Render the item
|
|
100
|
-
const layout =
|
|
99
|
+
const layout = Layout.computeBoxes(Layout.normalize(Layout.instantiate(layout_schema.item_layout_schema, item, data_schema.item_schema, bindings), column_width, fontDict), fontDict);
|
|
101
100
|
layout.path = { tag: "item", section: section.section_name, item: index };
|
|
102
101
|
layouts.push(layout);
|
|
103
102
|
}
|
|
File without changes
|
package/dist/Bindings.js
ADDED
|
File without changes
|
package/dist/DataSchema.d.ts
CHANGED
|
@@ -32,27 +32,16 @@ export declare namespace DocumentDataType {
|
|
|
32
32
|
};
|
|
33
33
|
type t = Date | PureString | MarkdownString | PureNumber | Type | List | Types;
|
|
34
34
|
type DocumentDataType = t;
|
|
35
|
-
function parse(s: string): DocumentDataType;
|
|
36
|
-
function print(d: DocumentDataType): string;
|
|
37
35
|
}
|
|
38
|
-
export
|
|
36
|
+
export type Field = {
|
|
37
|
+
name: string;
|
|
38
|
+
type: DocumentDataType.t;
|
|
39
|
+
};
|
|
40
|
+
export declare namespace DataSchema {
|
|
39
41
|
type t = {
|
|
40
|
-
name: string;
|
|
41
|
-
type: DocumentDataType.t;
|
|
42
|
-
};
|
|
43
|
-
type Field = t;
|
|
44
|
-
function fromJson(json: unknown): Field;
|
|
45
|
-
function toJson(f: Field): unknown;
|
|
46
|
-
}
|
|
47
|
-
export declare class DataSchema {
|
|
48
|
-
schema_name: string;
|
|
49
|
-
header_schema: Field.t[];
|
|
50
|
-
item_schema: Field.t[];
|
|
51
|
-
constructor(schema_name: string, header_schema: Field.t[], item_schema: Field.t[]);
|
|
52
|
-
static fromJson(json: unknown): DataSchema;
|
|
53
|
-
toJson(): {
|
|
54
42
|
schema_name: string;
|
|
55
|
-
header_schema:
|
|
56
|
-
item_schema:
|
|
43
|
+
header_schema: Field[];
|
|
44
|
+
item_schema: Field[];
|
|
57
45
|
};
|
|
46
|
+
function dataSchema(schema_name: string, header_schema: Field[], item_schema: Field[]): t;
|
|
58
47
|
}
|
package/dist/DataSchema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataSchema = exports.
|
|
3
|
+
exports.DataSchema = exports.DateFormat = void 0;
|
|
4
4
|
var DateFormat;
|
|
5
5
|
(function (DateFormat) {
|
|
6
6
|
DateFormat.formats = [
|
|
@@ -40,113 +40,10 @@ var DateFormat;
|
|
|
40
40
|
return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
|
|
41
41
|
};
|
|
42
42
|
})(DateFormat || (exports.DateFormat = DateFormat = {}));
|
|
43
|
-
var
|
|
44
|
-
(function (
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
tag: "Date",
|
|
49
|
-
format: s.length > 4 ? s.slice(5, -1).trim() : "YYYY-MM-DD",
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
else if (s === "String") {
|
|
53
|
-
return { tag: "String" };
|
|
54
|
-
}
|
|
55
|
-
else if (s === "MarkdownString") {
|
|
56
|
-
return { tag: "MarkdownString" };
|
|
57
|
-
}
|
|
58
|
-
else if (s === "Number") {
|
|
59
|
-
return { tag: "Number" };
|
|
60
|
-
}
|
|
61
|
-
else if (s.startsWith("List")) {
|
|
62
|
-
return { tag: "List", value: parse(s.slice(5, -1).trim()) };
|
|
63
|
-
}
|
|
64
|
-
else if (s.includes("|")) {
|
|
65
|
-
return {
|
|
66
|
-
tag: "Types",
|
|
67
|
-
value: s
|
|
68
|
-
.split("|")
|
|
69
|
-
.map((s) => s.trim())
|
|
70
|
-
.map(parse),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
throw new Error("Invalid DocumentDataType: " + s);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
DocumentDataType.parse = parse;
|
|
78
|
-
function print(d) {
|
|
79
|
-
switch (d.tag) {
|
|
80
|
-
case "Date":
|
|
81
|
-
return "Date";
|
|
82
|
-
case "String":
|
|
83
|
-
return "String";
|
|
84
|
-
case "MarkdownString":
|
|
85
|
-
return "MarkdownString";
|
|
86
|
-
case "Number":
|
|
87
|
-
return "Number";
|
|
88
|
-
case "Type":
|
|
89
|
-
return d.value;
|
|
90
|
-
case "List":
|
|
91
|
-
return "List<" + print(d.value) + ">";
|
|
92
|
-
case "Types":
|
|
93
|
-
return d.value.map(print).join(" | ");
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
DocumentDataType.print = print;
|
|
97
|
-
})(DocumentDataType || (exports.DocumentDataType = DocumentDataType = {}));
|
|
98
|
-
var Field;
|
|
99
|
-
(function (Field) {
|
|
100
|
-
function fromJson(json) {
|
|
101
|
-
if (typeof json !== "object" || json === null) {
|
|
102
|
-
throw new Error("Field must be an object");
|
|
103
|
-
}
|
|
104
|
-
if (!("name" in json) || !("type" in json)) {
|
|
105
|
-
throw new Error("Field must have a name and type");
|
|
106
|
-
}
|
|
107
|
-
if (typeof json.name !== "string") {
|
|
108
|
-
throw new Error("Field name must be a string");
|
|
109
|
-
}
|
|
110
|
-
if (typeof json.type !== "string") {
|
|
111
|
-
throw new Error("Field type must be a string");
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
name: json.name,
|
|
115
|
-
type: DocumentDataType.parse(json.type),
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
Field.fromJson = fromJson;
|
|
119
|
-
function toJson(f) {
|
|
120
|
-
return {
|
|
121
|
-
name: f.name,
|
|
122
|
-
type: DocumentDataType.print(f.type),
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
Field.toJson = toJson;
|
|
126
|
-
})(Field || (exports.Field = Field = {}));
|
|
127
|
-
class DataSchema {
|
|
128
|
-
constructor(schema_name, header_schema, item_schema) {
|
|
129
|
-
this.schema_name = schema_name;
|
|
130
|
-
this.header_schema = header_schema;
|
|
131
|
-
this.item_schema = item_schema;
|
|
132
|
-
}
|
|
133
|
-
static fromJson(json) {
|
|
134
|
-
if (typeof json !== "object" || json === null) {
|
|
135
|
-
throw new Error("DataSchema must be an object");
|
|
136
|
-
}
|
|
137
|
-
if (!("schema_name" in json) ||
|
|
138
|
-
!("header_schema" in json) ||
|
|
139
|
-
!("item_schema" in json)) {
|
|
140
|
-
throw new Error("DataSchema must have a schema_name, header_schema, and item_schema");
|
|
141
|
-
}
|
|
142
|
-
return new DataSchema(json.schema_name, json.header_schema.map(Field.fromJson), json.item_schema.map(Field.fromJson));
|
|
143
|
-
}
|
|
144
|
-
toJson() {
|
|
145
|
-
return {
|
|
146
|
-
schema_name: this.schema_name,
|
|
147
|
-
header_schema: this.header_schema.map(Field.toJson),
|
|
148
|
-
item_schema: this.item_schema.map(Field.toJson),
|
|
149
|
-
};
|
|
43
|
+
var DataSchema;
|
|
44
|
+
(function (DataSchema) {
|
|
45
|
+
function dataSchema(schema_name, header_schema, item_schema) {
|
|
46
|
+
return { schema_name, header_schema, item_schema };
|
|
150
47
|
}
|
|
151
|
-
|
|
152
|
-
exports.DataSchema = DataSchema;
|
|
48
|
+
DataSchema.dataSchema = dataSchema;
|
|
49
|
+
})(DataSchema || (exports.DataSchema = DataSchema = {}));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DataSchema } from "./DataSchema";
|
|
2
|
+
import { LayoutSchema } from "./LayoutSchema";
|
|
3
|
+
import { ResumeLayout } from "./ResumeLayout";
|
|
4
|
+
import * as Resume from "./Resume";
|
|
5
|
+
import { ResumeSection } from "./Resume";
|
|
6
|
+
export declare const Basics: DataSchema.t;
|
|
7
|
+
export declare const BasicsLayout: LayoutSchema;
|
|
8
|
+
export declare const Work: DataSchema.t;
|
|
9
|
+
export declare const WorkLayout: LayoutSchema;
|
|
10
|
+
export declare const Volunteer: DataSchema.t;
|
|
11
|
+
export declare const VolunteerLayout: LayoutSchema;
|
|
12
|
+
export declare const Education: DataSchema.t;
|
|
13
|
+
export declare const EducationLayout: LayoutSchema;
|
|
14
|
+
export declare const Awards: DataSchema.t;
|
|
15
|
+
export declare const AwardsLayout: LayoutSchema;
|
|
16
|
+
export declare const Certificates: DataSchema.t;
|
|
17
|
+
export declare const CertificatesLayout: LayoutSchema;
|
|
18
|
+
export declare const Publications: DataSchema.t;
|
|
19
|
+
export declare const PublicationsLayout: LayoutSchema;
|
|
20
|
+
export declare const Skills: DataSchema.t;
|
|
21
|
+
export declare const SkillsLayout: LayoutSchema;
|
|
22
|
+
export declare const Languages: DataSchema.t;
|
|
23
|
+
export declare const LanguagesLayout: LayoutSchema;
|
|
24
|
+
export declare const Interests: DataSchema.t;
|
|
25
|
+
export declare const InterestsLayout: LayoutSchema;
|
|
26
|
+
export declare const References: DataSchema.t;
|
|
27
|
+
export declare const ReferencesLayout: LayoutSchema;
|
|
28
|
+
export declare const Projects: DataSchema.t;
|
|
29
|
+
export declare const ProjectsLayout: LayoutSchema;
|
|
30
|
+
export declare const DefaultDataSchemas: DataSchema.t[];
|
|
31
|
+
export declare const DefaultLayoutSchemas: LayoutSchema[];
|
|
32
|
+
export declare const DefaultBindings: Map<string, unknown>;
|
|
33
|
+
export declare const DefaultResumeLayout: ResumeLayout;
|
|
34
|
+
export declare const DefaultSections: ResumeSection.t[];
|
|
35
|
+
export declare const DefaultResume: Resume.t;
|