cvdl-ts 1.0.23 → 1.0.24

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,6 @@
1
+
2
+ # CVDL-TS
3
+
4
+ CVDL is a prototype for Tail focusing on resume documents. `cvdl-ts` is the Typescript implementation of the rendering engine for CVDL.
5
+
6
+ Although we expect most users to use the [web-based editor](../cvdl-ts/), we provide a CLI for rendering CVDL documents locally.
package/dist/Elem.js CHANGED
@@ -211,6 +211,13 @@ function fillFonts(e, fonts) {
211
211
  }
212
212
  const words = span.text.split(/\s+/);
213
213
  words.forEach((word, index) => {
214
+ // Fix html escape characters
215
+ word = word.replace(/&/g, "&");
216
+ word = word.replace(/&lt;/g, "<");
217
+ word = word.replace(/&gt;/g, ">");
218
+ word = word.replace(/&quot;/g, '"');
219
+ word = word.replace(/&apos;/g, "'");
220
+ word = word.replace(/&#39;/g, "'");
214
221
  const width = Font.get_width(font, word, fonts);
215
222
  spans.push({ ...span, text: word, font, width });
216
223
  if (index < words.length - 1) {
@@ -40,9 +40,9 @@ class LocalStorage {
40
40
  return Promise.resolve();
41
41
  }
42
42
  async initiate_storage() {
43
- if (localStorage.getItem("version") !== "0.1.2") {
43
+ if (localStorage.getItem("version") !== "0.1.3") {
44
44
  localStorage.clear();
45
- localStorage.setItem("version", "0.1.2");
45
+ localStorage.setItem("version", "0.1.3");
46
46
  }
47
47
  if (!localStorage.getItem("resumes")) {
48
48
  localStorage.setItem("resumes", JSON.stringify([Defaults.DefaultResume]));
File without changes
@@ -0,0 +1,204 @@
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 class LocalStorage implements Storage {
8
+ // prefix: string;
9
+ // constructor() {
10
+ // this.prefix = "https://d2bnplhbawocbk.cloudfront.net/data/";
11
+ // }
12
+ // save_bindings(bindings: Map<string, unknown>): Promise<void> {
13
+ // const bindingsObject: any = {};
14
+ // for (const [key, value] of bindings) {
15
+ // bindingsObject[key] = value;
16
+ // }
17
+ // localStorage.setItem("bindings", JSON.stringify(bindingsObject));
18
+ // return Promise.resolve();
19
+ // }
20
+ // async initiate_storage(): Promise<void> {
21
+ // if (!localStorage.getItem("resumes")) {
22
+ // fetch(
23
+ // "https://d2bnplhbawocbk.cloudfront.net/data/resumes/resume5.json",
24
+ // ).then((response) => {
25
+ // response.json().then((resume) => {
26
+ // localStorage.setItem(
27
+ // "resumes",
28
+ // JSON.stringify([{ name: "Default", data: resume }]),
29
+ // );
30
+ // });
31
+ // });
32
+ // }
33
+ // if (!localStorage.getItem("data_schemas")) {
34
+ // fetch(
35
+ // "https://d2bnplhbawocbk.cloudfront.net/data/data-schemas.json",
36
+ // ).then((response) => {
37
+ // response.json().then((data_schemas) => {
38
+ // localStorage.setItem("data_schemas", JSON.stringify(data_schemas));
39
+ // });
40
+ // });
41
+ // }
42
+ // if (!localStorage.getItem("section_layouts")) {
43
+ // fetch(
44
+ // "https://d2bnplhbawocbk.cloudfront.net/data/layout-schemas3.json",
45
+ // ).then((response) => {
46
+ // response.json().then((section_layouts) => {
47
+ // localStorage.setItem(
48
+ // "section_layouts",
49
+ // JSON.stringify(section_layouts),
50
+ // );
51
+ // });
52
+ // });
53
+ // }
54
+ // if (!localStorage.getItem("resume_layouts")) {
55
+ // const response = await fetch(
56
+ // "https://d2bnplhbawocbk.cloudfront.net/data/resume-layouts.json",
57
+ // );
58
+ // const resume_layouts = await response.json();
59
+ // localStorage.setItem("resume_layouts", JSON.stringify(resume_layouts));
60
+ // return Promise.resolve();
61
+ // }
62
+ // }
63
+ // list_resumes(): Promise<string[]> {
64
+ // const resumes = JSON.parse(localStorage.getItem("resumes") || "[]").map(
65
+ // (resume: any) => resume.name,
66
+ // );
67
+ // return Promise.resolve(resumes);
68
+ // }
69
+ // list_data_schemas(): Promise<string[]> {
70
+ // const schemas = JSON.parse(
71
+ // localStorage.getItem("data_schemas") || "[]",
72
+ // ).map((schema: any) => schema.schema_name);
73
+ // return Promise.resolve(schemas);
74
+ // }
75
+ // list_layout_schemas(): Promise<string[]> {
76
+ // const schemas = JSON.parse(
77
+ // localStorage.getItem("section_layouts") || "[]",
78
+ // ).map((schema: any) => schema.schema_name);
79
+ // return Promise.resolve(schemas);
80
+ // }
81
+ // list_resume_layouts(): Promise<string[]> {
82
+ // const schemas = JSON.parse(
83
+ // localStorage.getItem("resume_layouts") || "[]",
84
+ // ).map((schema: any) => schema.schema_name);
85
+ // return Promise.resolve(schemas);
86
+ // }
87
+ // load_resume(resume_name: string): Promise<Resume> {
88
+ // const resume = JSON.parse(localStorage.getItem("resumes") || "[]").find(
89
+ // (resume: any) => resume.name === resume_name,
90
+ // );
91
+ // if (!resume) {
92
+ // throw new Error(`Resume(${resume_name}) not found`);
93
+ // }
94
+ // return Promise.resolve(Resume.fromJson(resume.data));
95
+ // }
96
+ // load_data_schema(schema_name: string): Promise<DataSchema> {
97
+ // const schema = JSON.parse(
98
+ // localStorage.getItem("data_schemas") || "[]",
99
+ // ).find((schema: any) => schema.schema_name === schema_name);
100
+ // if (!schema) {
101
+ // throw new Error(`Data Schema(${schema_name}) not found`);
102
+ // }
103
+ // return Promise.resolve(DataSchema.fromJson(schema));
104
+ // }
105
+ // load_bindings(): Promise<Map<string, unknown>> {
106
+ // if (!localStorage.getItem("bindings")) {
107
+ // localStorage.setItem("bindings", JSON.stringify({}));
108
+ // }
109
+ // const bindingsObject = JSON.parse(localStorage.getItem("bindings") || "{}");
110
+ // const bindings = new Map<string, unknown>();
111
+ // for (const [key, value] of Object.entries(bindingsObject)) {
112
+ // bindings.set(key, value);
113
+ // }
114
+ // return Promise.resolve(bindings);
115
+ // }
116
+ // load_layout_schema(schema_name: string): Promise<LayoutSchema> {
117
+ // const schema = JSON.parse(
118
+ // localStorage.getItem("section_layouts") || "[]",
119
+ // ).find((schema: any) => schema.schema_name === schema_name);
120
+ // if (!schema) {
121
+ // throw new Error(`Layout Schema(${schema_name}) not found`);
122
+ // }
123
+ // return Promise.resolve(LayoutSchema.fromJson(schema));
124
+ // }
125
+ // load_resume_layout(schema_name: string): Promise<ResumeLayout> {
126
+ // const schema = JSON.parse(
127
+ // localStorage.getItem("resume_layouts") || "[]",
128
+ // ).find((schema: any) => schema.schema_name === schema_name);
129
+ // if (!schema) {
130
+ // throw new Error(`Resume Layout(${schema_name}) not found`);
131
+ // }
132
+ // return Promise.resolve(ResumeLayout.fromJson(schema));
133
+ // }
134
+ // save_resume(resume_name: string, resume_data: Resume): Promise<void> {
135
+ // const resumes = JSON.parse(localStorage.getItem("resumes") || "[]");
136
+ // const resume = resumes.find((resume: any) => resume.name === resume_name);
137
+ // if (!resume) {
138
+ // resumes.push({ name: resume_name, data: resume_data.toJson() });
139
+ // } else {
140
+ // resume.data = resume_data.toJson();
141
+ // }
142
+ // localStorage.setItem("resumes", JSON.stringify(resumes));
143
+ // return Promise.resolve();
144
+ // }
145
+ // save_data_schema(data_schema: DataSchema): Promise<void> {
146
+ // const schemasDirectMapped = JSON.parse(
147
+ // localStorage.getItem("data_schemas") || "[]",
148
+ // );
149
+ // const schemas = schemasDirectMapped.map((schema: any) =>
150
+ // DataSchema.fromJson(schema),
151
+ // );
152
+ // const schema = schemas.find(
153
+ // (schema: DataSchema) => schema.schema_name === data_schema.schema_name,
154
+ // );
155
+ // if (!schema) {
156
+ // schemas.push(data_schema);
157
+ // } else {
158
+ // schema.header_schema = data_schema.header_schema;
159
+ // schema.item_schema = data_schema.item_schema;
160
+ // }
161
+ // localStorage.setItem(
162
+ // "data_schemas",
163
+ // JSON.stringify(schemas.map((schema: DataSchema) => schema.toJson())),
164
+ // );
165
+ // return Promise.resolve();
166
+ // }
167
+ // save_layout_schema(layout_schema: LayoutSchema): Promise<void> {
168
+ // const schemasDirectMapped = JSON.parse(
169
+ // localStorage.getItem("section_layouts") || "[]",
170
+ // );
171
+ // const schemas = schemasDirectMapped.map((schema: any) =>
172
+ // LayoutSchema.fromJson(schema),
173
+ // );
174
+ // const schema = schemas.find(
175
+ // (schema: LayoutSchema) =>
176
+ // schema.schema_name === layout_schema.schema_name,
177
+ // );
178
+ // if (!schema) {
179
+ // schemas.push(layout_schema);
180
+ // } else {
181
+ // schema.header_layout_schema = layout_schema.header_layout_schema;
182
+ // schema.item_layout_schema = layout_schema.item_layout_schema;
183
+ // }
184
+ // localStorage.setItem(
185
+ // "section_layouts",
186
+ // JSON.stringify(schemas.map((schema: LayoutSchema) => schema.toJson())),
187
+ // );
188
+ // return Promise.resolve();
189
+ // }
190
+ // save_resume_layout(resume_layout: ResumeLayout): Promise<void> {
191
+ // throw new Error("Method not implemented.");
192
+ // }
193
+ // async load_font(fontName: string): Promise<Buffer> {
194
+ // const path = `fonts/${fontName}.ttf`;
195
+ // if (!localStorage.getItem(path)) {
196
+ // const response = await fetch(
197
+ // `https://d2bnplhbawocbk.cloudfront.net/data/${path}`,
198
+ // );
199
+ // const font_data = await response.arrayBuffer();
200
+ // return Buffer.from(font_data);
201
+ // }
202
+ // throw new Error("Font not found");
203
+ // }
204
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cvdl-ts",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "Typescript Implementation of CVDL Compiler",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,21 +0,0 @@
1
- import * as Font from "./Font";
2
- import { LayoutSchema } from "./LayoutSchema";
3
- import { Resume } from "./Resume";
4
- import { ResumeLayout } from "./ResumeLayout";
5
- import { Storage } from "./Storage";
6
- export declare class IndexedDB implements Storage {
7
- initiate_storage(): Promise<void>;
8
- list_resumes(): Promise<string[]>;
9
- list_data_schemas(): Promise<string[]>;
10
- list_layout_schemas(): Promise<string[]>;
11
- list_resume_layouts(): Promise<string[]>;
12
- load_resume(resume_name: string): Promise<Resume>;
13
- load_data_schema(schema_name: string): Promise<DataSchema>;
14
- load_layout_schema(schema_name: string): Promise<LayoutSchema>;
15
- load_resume_layout(schema_name: string): Promise<ResumeLayout>;
16
- save_resume(resume_name: string, resume_data: Resume): Promise<void>;
17
- save_data_schema(data_schema: DataSchema): Promise<void>;
18
- save_layout_schema(layout_schema: LayoutSchema): Promise<void>;
19
- save_resume_layout(resume_layout: ResumeLayout): Promise<void>;
20
- load_font(font: Font.t): Promise<Buffer>;
21
- }
package/dist/IndexedDB.js DELETED
@@ -1,282 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.IndexedDB = void 0;
27
- const DataSchema_1 = require("./DataSchema");
28
- const Font = __importStar(require("./Font"));
29
- const LayoutSchema_1 = require("./LayoutSchema");
30
- const Resume_1 = require("./Resume");
31
- const ResumeLayout_1 = require("./ResumeLayout");
32
- class IndexedDB {
33
- async initiate_storage() {
34
- const resumes = indexedDB.open("resumes", 1);
35
- resumes.onupgradeneeded = () => {
36
- const db = resumes.result;
37
- db.createObjectStore("resumes", { keyPath: "name" });
38
- };
39
- resumes.onsuccess = () => {
40
- const db = resumes.result;
41
- const transaction = db.transaction("resumes", "readwrite");
42
- const store = transaction.objectStore("resumes");
43
- if (!store.get("Default")) {
44
- fetch("https://d2bnplhbawocbk.cloudfront.net/data/resumes/resume5.json").then((response) => {
45
- response.json().then((resume) => {
46
- store.add({ name: "Default", data: resume });
47
- });
48
- });
49
- }
50
- };
51
- const data_schemas = indexedDB.open("data_schemas", 1);
52
- data_schemas.onupgradeneeded = () => {
53
- const db = data_schemas.result;
54
- db.createObjectStore("data_schemas", { keyPath: "schema_name" });
55
- };
56
- data_schemas.onsuccess = () => {
57
- const db = data_schemas.result;
58
- const transaction = db.transaction("data_schemas", "readwrite");
59
- const store = transaction.objectStore("data_schemas");
60
- if (!store.get("Default")) {
61
- fetch("https://d2bnplhbawocbk.cloudfront.net/data/data-schemas.json").then((response) => {
62
- response.json().then((data_schemas) => {
63
- store.add(data_schemas);
64
- });
65
- });
66
- }
67
- };
68
- const section_layouts = indexedDB.open("section_layouts", 1);
69
- section_layouts.onupgradeneeded = () => {
70
- const db = section_layouts.result;
71
- db.createObjectStore("section_layouts", { keyPath: "schema_name" });
72
- };
73
- section_layouts.onsuccess = () => {
74
- const db = section_layouts.result;
75
- const transaction = db.transaction("section_layouts", "readwrite");
76
- const store = transaction.objectStore("section_layouts");
77
- if (!store.get("Default")) {
78
- fetch("https://d2bnplhbawocbk.cloudfront.net/data/layout-schemas3.json").then((response) => {
79
- response.json().then((section_layouts) => {
80
- store.add(section_layouts);
81
- });
82
- });
83
- }
84
- };
85
- const resume_layouts = indexedDB.open("resume_layouts", 1);
86
- resume_layouts.onupgradeneeded = () => {
87
- const db = resume_layouts.result;
88
- db.createObjectStore("resume_layouts", { keyPath: "schema_name" });
89
- };
90
- resume_layouts.onsuccess = () => {
91
- const db = resume_layouts.result;
92
- const transaction = db.transaction("resume_layouts", "readwrite");
93
- const store = transaction.objectStore("resume_layouts");
94
- if (!store.get("Default")) {
95
- fetch("https://d2bnplhbawocbk.cloudfront.net/data/resume-layouts.json").then((response) => {
96
- response.json().then((resume_layouts) => {
97
- store.add(resume_layouts);
98
- });
99
- });
100
- }
101
- };
102
- }
103
- list_resumes() {
104
- const resumes = indexedDB.open("resumes", 1);
105
- resumes.onsuccess = () => {
106
- const db = resumes.result;
107
- const transaction = db.transaction("resumes", "readwrite");
108
- const store = transaction.objectStore("resumes");
109
- const request = store.getAll();
110
- request.onsuccess = () => {
111
- return request.result.map((resume) => resume.name);
112
- };
113
- };
114
- return Promise.resolve([]);
115
- }
116
- list_data_schemas() {
117
- const data_schemas = indexedDB.open("data_schemas", 1);
118
- data_schemas.onsuccess = () => {
119
- const db = data_schemas.result;
120
- const transaction = db.transaction("data_schemas", "readwrite");
121
- const store = transaction.objectStore("data_schemas");
122
- const request = store.getAll();
123
- request.onsuccess = () => {
124
- return request.result.map((schema) => schema.schema_name);
125
- };
126
- };
127
- return Promise.resolve([]);
128
- }
129
- list_layout_schemas() {
130
- const section_layouts = indexedDB.open("section_layouts", 1);
131
- section_layouts.onsuccess = () => {
132
- const db = section_layouts.result;
133
- const transaction = db.transaction("section_layouts", "readwrite");
134
- const store = transaction.objectStore("section_layouts");
135
- const request = store.getAll();
136
- request.onsuccess = () => {
137
- return request.result.map((schema) => schema.schema_name);
138
- };
139
- };
140
- return Promise.resolve([]);
141
- }
142
- list_resume_layouts() {
143
- const resume_layouts = indexedDB.open("resume_layouts", 1);
144
- resume_layouts.onsuccess = () => {
145
- const db = resume_layouts.result;
146
- const transaction = db.transaction("resume_layouts", "readwrite");
147
- const store = transaction.objectStore("resume_layouts");
148
- const request = store.getAll();
149
- request.onsuccess = () => {
150
- return request.result.map((schema) => schema.schema_name);
151
- };
152
- };
153
- return Promise.resolve([]);
154
- }
155
- load_resume(resume_name) {
156
- const resumes = indexedDB.open("resumes", 1);
157
- resumes.onsuccess = () => {
158
- const db = resumes.result;
159
- const transaction = db.transaction("resumes", "readwrite");
160
- const store = transaction.objectStore("resumes");
161
- const request = store.get(resume_name);
162
- request.onsuccess = () => {
163
- return Resume_1.Resume.fromJson(request.result.data);
164
- };
165
- };
166
- return Promise.resolve(Resume_1.Resume.fromJson({}));
167
- }
168
- load_data_schema(schema_name) {
169
- const data_schemas = indexedDB.open("data_schemas", 1);
170
- data_schemas.onsuccess = () => {
171
- const db = data_schemas.result;
172
- const transaction = db.transaction("data_schemas", "readwrite");
173
- const store = transaction.objectStore("data_schemas");
174
- const request = store.get(schema_name);
175
- request.onsuccess = () => {
176
- return DataSchema_1.DataSchema.fromJson(request.result);
177
- };
178
- };
179
- return Promise.resolve(DataSchema_1.DataSchema.fromJson({}));
180
- }
181
- load_layout_schema(schema_name) {
182
- const section_layouts = indexedDB.open("section_layouts", 1);
183
- section_layouts.onsuccess = () => {
184
- const db = section_layouts.result;
185
- const transaction = db.transaction("section_layouts", "readwrite");
186
- const store = transaction.objectStore("section_layouts");
187
- const request = store.get(schema_name);
188
- request.onsuccess = () => {
189
- return LayoutSchema_1.LayoutSchema.fromJson(request.result);
190
- };
191
- };
192
- return Promise.resolve(LayoutSchema_1.LayoutSchema.fromJson({}));
193
- }
194
- load_resume_layout(schema_name) {
195
- const resume_layouts = indexedDB.open("resume_layouts", 1);
196
- resume_layouts.onsuccess = () => {
197
- const db = resume_layouts.result;
198
- const transaction = db.transaction("resume_layouts", "readwrite");
199
- const store = transaction.objectStore("resume_layouts");
200
- const request = store.get(schema_name);
201
- request.onsuccess = () => {
202
- return ResumeLayout_1.ResumeLayout.fromJson(request.result);
203
- };
204
- };
205
- return Promise.resolve(ResumeLayout_1.ResumeLayout.fromJson({}));
206
- }
207
- save_resume(resume_name, resume_data) {
208
- const resumes = indexedDB.open("resumes", 1);
209
- resumes.onsuccess = () => {
210
- const db = resumes.result;
211
- const transaction = db.transaction("resumes", "readwrite");
212
- const store = transaction.objectStore("resumes");
213
- const request = store.put({ name: resume_name, data: resume_data.toJson() });
214
- request.onsuccess = () => {
215
- return;
216
- };
217
- };
218
- return Promise.resolve();
219
- }
220
- save_data_schema(data_schema) {
221
- const data_schemas = indexedDB.open("data_schemas", 1);
222
- data_schemas.onsuccess = () => {
223
- const db = data_schemas.result;
224
- const transaction = db.transaction("data_schemas", "readwrite");
225
- const store = transaction.objectStore("data_schemas");
226
- const request = store.put(data_schema);
227
- request.onsuccess = () => {
228
- return;
229
- };
230
- };
231
- return Promise.resolve();
232
- }
233
- save_layout_schema(layout_schema) {
234
- const section_layouts = indexedDB.open("section_layouts", 1);
235
- section_layouts.onsuccess = () => {
236
- const db = section_layouts.result;
237
- const transaction = db.transaction("section_layouts", "readwrite");
238
- const store = transaction.objectStore("section_layouts");
239
- const request = store.put(layout_schema);
240
- request.onsuccess = () => {
241
- return;
242
- };
243
- };
244
- return Promise.resolve();
245
- }
246
- save_resume_layout(resume_layout) {
247
- const resume_layouts = indexedDB.open("resume_layouts", 1);
248
- resume_layouts.onsuccess = () => {
249
- const db = resume_layouts.result;
250
- const transaction = db.transaction("resume_layouts", "readwrite");
251
- const store = transaction.objectStore("resume_layouts");
252
- const request = store.put(resume_layout);
253
- request.onsuccess = () => {
254
- return;
255
- };
256
- };
257
- return Promise.resolve();
258
- }
259
- async load_font(font) {
260
- const path = `fonts/${Font.full_name(font)}.ttf`;
261
- const fonts = indexedDB.open("fonts", 1);
262
- fonts.onsuccess = () => {
263
- const db = fonts.result;
264
- const transaction = db.transaction("fonts", "readwrite");
265
- const store = transaction.objectStore("fonts");
266
- const request = store.get(path);
267
- request.onsuccess = () => {
268
- return Buffer.from(request.result);
269
- };
270
- request.onerror = () => {
271
- const response = fetch(`https://d2bnplhbawocbk.cloudfront.net/data/${path}`);
272
- response.then((response) => {
273
- response.arrayBuffer().then((font_data) => {
274
- store.add(font_data, path);
275
- });
276
- });
277
- };
278
- };
279
- return Promise.resolve(Buffer.from([]));
280
- }
281
- }
282
- exports.IndexedDB = IndexedDB;