cvdl-ts 1.0.7 → 1.0.9

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/Layout.d.ts CHANGED
@@ -75,6 +75,16 @@ export declare class Row {
75
75
  scale_width(w: number): Row;
76
76
  break_lines(font_dict: FontDict): Row[];
77
77
  }
78
+ export type Color = "Transparent" | "Light Yellow" | "Light Brown" | "Light Green" | "Light Beige" | "Light Blue" | "Blue";
79
+ export declare const ColorMap: {
80
+ Transparent: string;
81
+ "Light Yellow": string;
82
+ "Light Brown": string;
83
+ "Light Green": string;
84
+ "Light Beige": string;
85
+ "Light Blue": string;
86
+ Blue: string;
87
+ };
78
88
  export declare class Elem {
79
89
  tag: "Elem";
80
90
  item: string;
@@ -86,8 +96,9 @@ export declare class Elem {
86
96
  margin: Margin;
87
97
  alignment: Alignment;
88
98
  width: Width;
89
- constructor(item: string, url: string | null, is_ref: boolean, is_fill: boolean, text_width: Width, font: Font, margin: Margin, alignment: Alignment, width: Width);
90
- static elem(item: string, url: string | null, is_ref: boolean, is_fill: boolean, text_width: Width, font: Font, margin: Margin, alignment: Alignment, width: Width): SectionLayout;
99
+ 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;
91
102
  copy(): Elem;
92
103
  static default_(): Elem;
93
104
  with_item(item: string): Elem;
package/dist/Layout.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Elem = exports.Row = exports.Stack = exports.SectionLayout = void 0;
4
+ exports.Elem = exports.ColorMap = exports.Row = exports.Stack = exports.SectionLayout = void 0;
5
5
  const Margin_1 = require("./Margin");
6
6
  const Alignment_1 = require("./Alignment");
7
7
  const Width_1 = require("./Width");
@@ -38,6 +38,7 @@ class SectionLayout {
38
38
  return new SectionLayout(Stack.default_());
39
39
  }
40
40
  static fromJson(json) {
41
+ var _a;
41
42
  const key = Object.keys(json)[0];
42
43
  switch (key) {
43
44
  case 'Stack':
@@ -60,6 +61,7 @@ class SectionLayout {
60
61
  inner.text_width = Width_1.Width.fromJson(json[key].text_width);
61
62
  inner.font = Font_1.Font.fromJson(json[key].font);
62
63
  inner.url = json[key].url;
64
+ inner.background_color = (_a = json[key].background_color) !== null && _a !== void 0 ? _a : "Transparent";
63
65
  return new SectionLayout(inner);
64
66
  }
65
67
  }
@@ -81,6 +83,7 @@ class SectionLayout {
81
83
  }
82
84
  case "Elem": {
83
85
  const elem = this.inner;
86
+ console.error(elem.background_color);
84
87
  return {
85
88
  [this.tag_()]: {
86
89
  item: elem.item,
@@ -90,6 +93,7 @@ class SectionLayout {
90
93
  text_width: Width_1.Width.toJson(elem.text_width),
91
94
  font: elem.font.toJson(),
92
95
  url: elem.url,
96
+ background_color: elem.background_color,
93
97
  },
94
98
  };
95
99
  }
@@ -447,8 +451,17 @@ class Row {
447
451
  }
448
452
  }
449
453
  exports.Row = Row;
454
+ exports.ColorMap = {
455
+ "Transparent": "transparent",
456
+ "Light Yellow": "#FFC96F",
457
+ "Light Brown": "#ECB176",
458
+ "Light Green": "#F6FAB9",
459
+ "Light Beige": "#F6EEC9",
460
+ "Light Blue": "#EEF7FF",
461
+ "Blue": "#4793AF",
462
+ };
450
463
  class Elem {
451
- constructor(item, url, is_ref, is_fill, text_width, font, margin, alignment, width) {
464
+ constructor(item, url, is_ref, is_fill, text_width, font, margin, alignment, width, background_color) {
452
465
  this.tag = "Elem";
453
466
  this.item = item;
454
467
  this.url = url;
@@ -459,42 +472,44 @@ class Elem {
459
472
  this.margin = margin;
460
473
  this.alignment = alignment;
461
474
  this.width = width;
475
+ this.background_color = background_color;
462
476
  }
463
- static elem(item, url, is_ref, is_fill, text_width, font, margin, alignment, width) {
464
- return new SectionLayout(new Elem(item, url, is_ref, is_fill, text_width, font, margin, alignment, width));
477
+ static elem(item, url, is_ref, is_fill, text_width, font, margin, alignment, width, background_color) {
478
+ return new SectionLayout(new Elem(item, url, is_ref, is_fill, text_width, font, margin, alignment, width, background_color));
465
479
  }
466
480
  copy() {
467
- return new Elem(this.item, this.url, this.is_ref, this.is_fill, Width_1.Width.copy(this.text_width), this.font, this.margin.copy(), this.alignment, Width_1.Width.copy(this.width));
481
+ console.error(this.background_color);
482
+ return new Elem(this.item, this.url, this.is_ref, this.is_fill, Width_1.Width.copy(this.text_width), this.font, this.margin.copy(), this.alignment, Width_1.Width.copy(this.width), this.background_color);
468
483
  }
469
484
  static default_() {
470
- return new Elem("", null, false, false, Width_1.Width.default_(), Font_1.Font.default_(), Margin_1.Margin.default_(), Alignment_1.Alignment.default_(), Width_1.Width.default_());
485
+ return new Elem("", null, false, false, Width_1.Width.default_(), Font_1.Font.default_(), Margin_1.Margin.default_(), Alignment_1.Alignment.default_(), Width_1.Width.default_(), "Transparent");
471
486
  }
472
487
  with_item(item) {
473
- return new Elem(item, this.url, this.is_ref, this.is_fill, this.text_width, this.font, this.margin, this.alignment, this.width);
488
+ return new Elem(item, this.url, this.is_ref, this.is_fill, this.text_width, this.font, this.margin, this.alignment, this.width, this.background_color);
474
489
  }
475
490
  as_ref() {
476
- return new Elem(this.item, this.url, true, this.is_fill, this.text_width, this.font, this.margin, this.alignment, this.width);
491
+ return new Elem(this.item, this.url, true, this.is_fill, this.text_width, this.font, this.margin, this.alignment, this.width, this.background_color);
477
492
  }
478
493
  with_font(font) {
479
- return new Elem(this.item, this.url, this.is_ref, this.is_fill, this.text_width, font, this.margin, this.alignment, this.width);
494
+ return new Elem(this.item, this.url, this.is_ref, this.is_fill, this.text_width, font, this.margin, this.alignment, this.width, this.background_color);
480
495
  }
481
496
  with_url(url) {
482
- return new Elem(this.item, url, this.is_ref, this.is_fill, this.text_width, this.font, this.margin, this.alignment, this.width);
497
+ return new Elem(this.item, url, this.is_ref, this.is_fill, this.text_width, this.font, this.margin, this.alignment, this.width, this.background_color);
483
498
  }
484
499
  with_margin(margin) {
485
- return new Elem(this.item, this.url, this.is_ref, this.is_fill, this.text_width, this.font, margin, this.alignment, this.width);
500
+ return new Elem(this.item, this.url, this.is_ref, this.is_fill, this.text_width, this.font, margin, this.alignment, this.width, this.background_color);
486
501
  }
487
502
  with_alignment(alignment) {
488
- return new Elem(this.item, this.url, this.is_ref, this.is_fill, this.text_width, this.font, this.margin, alignment, this.width);
503
+ return new Elem(this.item, this.url, this.is_ref, this.is_fill, this.text_width, this.font, this.margin, alignment, this.width, this.background_color);
489
504
  }
490
505
  with_width(width) {
491
- return new Elem(this.item, this.url, this.is_ref, this.is_fill, this.text_width, this.font, this.margin, this.alignment, width);
506
+ return new Elem(this.item, this.url, this.is_ref, this.is_fill, this.text_width, this.font, this.margin, this.alignment, width, this.background_color);
492
507
  }
493
508
  with_text_width(text_width) {
494
- return new Elem(this.item, this.url, this.is_ref, this.is_fill, text_width, this.font, this.margin, this.alignment, this.width);
509
+ return new Elem(this.item, this.url, this.is_ref, this.is_fill, text_width, this.font, this.margin, this.alignment, this.width, this.background_color);
495
510
  }
496
511
  with_is_fill(is_fill) {
497
- return new Elem(this.item, this.url, this.is_ref, is_fill, this.text_width, this.font, this.margin, this.alignment, this.width);
512
+ return new Elem(this.item, this.url, this.is_ref, is_fill, this.text_width, this.font, this.margin, this.alignment, this.width, this.background_color);
498
513
  }
499
514
  scale_width(w) {
500
515
  return this.with_width(Width_1.Width.scale(this.width, w));
@@ -516,7 +531,7 @@ class Elem {
516
531
  const row = new Row([], false, line.margin, line.alignment, line.width);
517
532
  words.forEach(word => {
518
533
  const word_width = this.font.get_width(word, font_dict);
519
- row.elements.push(new SectionLayout(new Elem(word, null, false, false, Width_1.Width.absolute(word_width), this.font, Margin_1.Margin.default_(), Alignment_1.Alignment.default_(), Width_1.Width.absolute(word_width))));
534
+ row.elements.push(new SectionLayout(new Elem(word, null, false, false, Width_1.Width.absolute(word_width), this.font, Margin_1.Margin.default_(), Alignment_1.Alignment.default_(), Width_1.Width.absolute(word_width), this.background_color)));
520
535
  });
521
536
  rowLines.push(row);
522
537
  }
package/dist/PdfLayout.js CHANGED
@@ -7,6 +7,7 @@ exports.render = void 0;
7
7
  const blob_stream_1 = __importDefault(require("blob-stream"));
8
8
  const AnyLayout_1 = require("./AnyLayout");
9
9
  const pdfkit_1 = __importDefault(require("pdfkit"));
10
+ const Layout_1 = require("./Layout");
10
11
  const render = async ({ resume_name, resume, data_schemas, layout_schemas, resume_layout, storage, fontDict, debug = false }) => {
11
12
  let start_time = Date.now();
12
13
  if (!resume && !resume_name) {
@@ -67,7 +68,11 @@ const render = async ({ resume_name, resume, data_schemas, layout_schemas, resum
67
68
  }
68
69
  for (const [box_, element] of elements) {
69
70
  console.log(`(${box_.top_left.x}, ${box_.top_left.y})(${box_.bottom_right.x}, ${box_.bottom_right.y}): ${element.item}`);
70
- console.log(element.font.full_name());
71
+ if (element.background_color !== "Transparent") {
72
+ doc.rect(box_.top_left.x, box_.top_left.y, box_.width(), box_.height()).fillAndStroke(Layout_1.ColorMap[element.background_color], Layout_1.ColorMap[element.background_color]);
73
+ }
74
+ // Make this more generic
75
+ doc.fillColor("black");
71
76
  doc.
72
77
  font(element.font.full_name()).
73
78
  fontSize(element.font.size).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cvdl-ts",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Typescript Implementation of CVDL Compiler",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",