rendercv-ts 0.1.0

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.
Files changed (77) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +112 -0
  3. package/assets/fonts/EB Garamond/EBGaramond-Bold.ttf +0 -0
  4. package/assets/fonts/EB Garamond/EBGaramond-BoldItalic.ttf +0 -0
  5. package/assets/fonts/EB Garamond/EBGaramond-Italic.ttf +0 -0
  6. package/assets/fonts/EB Garamond/EBGaramond-Regular.ttf +0 -0
  7. package/assets/fonts/Fontin/Fontin-Bold.otf +0 -0
  8. package/assets/fonts/Fontin/Fontin-Italic.otf +0 -0
  9. package/assets/fonts/Fontin/Fontin-Regular.otf +0 -0
  10. package/assets/fonts/Gentium Book Plus/GentiumBookPlus-Bold.ttf +0 -0
  11. package/assets/fonts/Gentium Book Plus/GentiumBookPlus-BoldItalic.ttf +0 -0
  12. package/assets/fonts/Gentium Book Plus/GentiumBookPlus-Italic.ttf +0 -0
  13. package/assets/fonts/Gentium Book Plus/GentiumBookPlus-Regular.ttf +0 -0
  14. package/assets/fonts/Lato/Lato-Bold.ttf +0 -0
  15. package/assets/fonts/Lato/Lato-BoldItalic.ttf +0 -0
  16. package/assets/fonts/Lato/Lato-Italic.ttf +0 -0
  17. package/assets/fonts/Lato/Lato-Regular.ttf +0 -0
  18. package/assets/fonts/Raleway/Raleway-Bold.ttf +0 -0
  19. package/assets/fonts/Raleway/Raleway-BoldItalic.ttf +0 -0
  20. package/assets/fonts/Raleway/Raleway-Italic.ttf +0 -0
  21. package/assets/fonts/Raleway/Raleway-Regular.ttf +0 -0
  22. package/assets/fonts/Source Sans 3/SourceSans3-Bold.ttf +0 -0
  23. package/assets/fonts/Source Sans 3/SourceSans3-BoldItalic.ttf +0 -0
  24. package/assets/fonts/Source Sans 3/SourceSans3-Italic.ttf +0 -0
  25. package/assets/fonts/Source Sans 3/SourceSans3-Regular.ttf +0 -0
  26. package/assets/fonts/Ubuntu/Ubuntu-Bold.ttf +0 -0
  27. package/assets/fonts/Ubuntu/Ubuntu-BoldItalic.ttf +0 -0
  28. package/assets/fonts/Ubuntu/Ubuntu-Italic.ttf +0 -0
  29. package/assets/fonts/Ubuntu/Ubuntu-Regular.ttf +0 -0
  30. package/assets/fonts/Vazirmatn/Vazirmatn-Black.ttf +0 -0
  31. package/assets/fonts/Vazirmatn/Vazirmatn-Bold.ttf +0 -0
  32. package/assets/fonts/Vazirmatn/Vazirmatn-ExtraBold.ttf +0 -0
  33. package/assets/fonts/Vazirmatn/Vazirmatn-ExtraLight.ttf +0 -0
  34. package/assets/fonts/Vazirmatn/Vazirmatn-Light.ttf +0 -0
  35. package/assets/fonts/Vazirmatn/Vazirmatn-Medium.ttf +0 -0
  36. package/assets/fonts/Vazirmatn/Vazirmatn-Regular.ttf +0 -0
  37. package/assets/fonts/Vazirmatn/Vazirmatn-SemiBold.ttf +0 -0
  38. package/assets/fonts/Vazirmatn/Vazirmatn-Thin.ttf +0 -0
  39. package/assets/fonts/XCharter/XCharter-Bold.otf +0 -0
  40. package/assets/fonts/XCharter/XCharter-BoldItalic.otf +0 -0
  41. package/assets/fonts/XCharter/XCharter-Italic.otf +0 -0
  42. package/assets/fonts/XCharter/XCharter-Regular.otf +0 -0
  43. package/assets/wasm/typst_ts_renderer_bg.wasm +0 -0
  44. package/assets/wasm/typst_ts_web_compiler_bg.wasm +0 -0
  45. package/dist/asset_paths-Q3SHUESH.js +12 -0
  46. package/dist/asset_paths-Q3SHUESH.js.map +1 -0
  47. package/dist/chunk-CJBTP63L.js +94 -0
  48. package/dist/chunk-CJBTP63L.js.map +1 -0
  49. package/dist/chunk-EVM6BVMO.js +16 -0
  50. package/dist/chunk-EVM6BVMO.js.map +1 -0
  51. package/dist/chunk-QZVXUQ72.js +91 -0
  52. package/dist/chunk-QZVXUQ72.js.map +1 -0
  53. package/dist/chunk-VZSMPOAA.js +1012 -0
  54. package/dist/chunk-VZSMPOAA.js.map +1 -0
  55. package/dist/font_cache-BZENGUJA.js +84 -0
  56. package/dist/font_cache-BZENGUJA.js.map +1 -0
  57. package/dist/font_registry-TJ7PJJTJ.js +183 -0
  58. package/dist/font_registry-TJ7PJJTJ.js.map +1 -0
  59. package/dist/index.cjs +9979 -0
  60. package/dist/index.cjs.map +1 -0
  61. package/dist/index.d.cts +195 -0
  62. package/dist/index.d.ts +195 -0
  63. package/dist/index.js +8396 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/renderer/worker/pdf_worker.cjs +1518 -0
  66. package/dist/renderer/worker/pdf_worker.cjs.map +1 -0
  67. package/dist/renderer/worker/pdf_worker.d.cts +24 -0
  68. package/dist/renderer/worker/pdf_worker.d.ts +24 -0
  69. package/dist/renderer/worker/pdf_worker.js +51 -0
  70. package/dist/renderer/worker/pdf_worker.js.map +1 -0
  71. package/dist/typst_font_cache-LYHXH5UA.js +60 -0
  72. package/dist/typst_font_cache-LYHXH5UA.js.map +1 -0
  73. package/dist/typst_setup-SW3GQFSL.js +30 -0
  74. package/dist/typst_setup-SW3GQFSL.js.map +1 -0
  75. package/dist/typst_setup-WebjDI32.d.cts +266 -0
  76. package/dist/typst_setup-WebjDI32.d.ts +266 -0
  77. package/package.json +80 -0
@@ -0,0 +1,266 @@
1
+ import { z } from 'zod';
2
+ import { Document, LineCounter } from 'yaml';
3
+
4
+ /**
5
+ * Error types for the rendercv pipeline.
6
+ *
7
+ * Ported from src/rendercv/exception.py. We use classes (not dataclasses) and
8
+ * preserve the structured shape so callers can map errors to YAML positions.
9
+ */
10
+ type YamlSource = 'main_yaml_file' | 'design_yaml_file' | 'locale_yaml_file' | 'settings_yaml_file';
11
+ /** [[startLine, startCol], [endLine, endCol]] — 1-indexed, like ruamel.yaml. */
12
+ type YamlLocation = [[number, number], [number, number]];
13
+ /**
14
+ * Structured validation error paired with a YAML source location.
15
+ *
16
+ * Mirrors rendercv's `RenderCVValidationError` dataclass. The CLI / playground
17
+ * uses `yaml_location` to point at the offending YAML span.
18
+ */
19
+ declare class RenderCVValidationError {
20
+ readonly schemaLocation: readonly string[] | null;
21
+ readonly yamlLocation: YamlLocation | null;
22
+ readonly yamlSource: YamlSource;
23
+ readonly message: string;
24
+ readonly input: string;
25
+ constructor(schemaLocation: readonly string[] | null, yamlLocation: YamlLocation | null, yamlSource: YamlSource, message: string, input: string);
26
+ }
27
+ /** User-facing error carrying multiple structured validation errors. */
28
+ declare class RenderCVUserValidationError extends Error {
29
+ readonly validationErrors: RenderCVValidationError[];
30
+ constructor(validationErrors: RenderCVValidationError[]);
31
+ }
32
+ /** User-facing error for recoverable problems (invalid input, missing files). */
33
+ declare class RenderCVUserError extends Error {
34
+ constructor(message?: string);
35
+ }
36
+ /** Internal error indicating a bug in rendercv logic. Should never reach users. */
37
+ declare class RenderCVInternalError extends Error {
38
+ constructor(message: string);
39
+ }
40
+
41
+ /**
42
+ * Date helpers — ported from `entry_with_date.py` and `entry_with_complex_fields.py`.
43
+ *
44
+ * rendercv dates are unusual: they accept "free text" like "Fall 2023" for
45
+ * display, while strict dates (YYYY / YYYY-MM / YYYY-MM-DD) are validated and
46
+ * used for arithmetic (start ≤ end, duration calc). The literal `"present"`
47
+ * resolves to the rendering's "current date".
48
+ */
49
+
50
+ interface SimpleDate {
51
+ year: number;
52
+ month: number;
53
+ day: number;
54
+ }
55
+
56
+ /**
57
+ * Validation context threaded through model building — browser port of
58
+ * `validation_context.py`.
59
+ */
60
+
61
+ interface ValidationContext {
62
+ /** Relative-path assets supplied by the caller (path → URL or data URL). */
63
+ assets?: Record<string, string>;
64
+ /** Resolved reference date for entry validation. */
65
+ currentDate?: SimpleDate;
66
+ /** Header keys in YAML source order (from cv map). */
67
+ cvHeaderKeyOrder?: string[];
68
+ }
69
+
70
+ /**
71
+ * YAML parsing with source coordinates for error reporting.
72
+ */
73
+
74
+ interface YamlDocumentBundle {
75
+ value: Record<string, unknown>;
76
+ document: Document;
77
+ lineCounter: LineCounter;
78
+ source: YamlSource;
79
+ }
80
+ type OverlayDocuments = Partial<Record<'design' | 'locale' | 'settings', YamlDocumentBundle>>;
81
+
82
+ /**
83
+ * Cv — ported from `cv/cv.py`.
84
+ *
85
+ * The header / personal-information block. Holds name, headline, location,
86
+ * contact details (email/phone/website — each scalar-or-list), photo,
87
+ * social networks, custom connections, and the sections dict.
88
+ *
89
+ * Python-specific behaviors that need careful porting:
90
+ * - `capture_input_order` (model_validator wrap): preserve YAML key order so
91
+ * the header renders in user-defined order. In JS, object keys already
92
+ * preserve insertion order, so we just record which header keys were
93
+ * present in the input into `_keyOrder`.
94
+ * - `validate_list_or_scalar_fields`: email/phone/website accept a scalar OR
95
+ * a list. We model with a Zod union of single-or-array.
96
+ * - Private attrs (_plain_name, _connections, _top_note, _footer) are computed
97
+ * during the renderer's model-processor step, NOT here. We only carry
98
+ * `_keyOrder` (computed at parse time from input order).
99
+ *
100
+ * Like the entry schema, Cv needs a `currentDate` (passed through to sections),
101
+ * so we expose a factory `cvSchema(currentDate)`.
102
+ */
103
+
104
+ interface Cv {
105
+ name?: string | null;
106
+ headline?: string | null;
107
+ location?: string | null;
108
+ email?: string | string[];
109
+ photo?: string;
110
+ phone?: string | string[];
111
+ website?: string | string[];
112
+ social_networks?: unknown[];
113
+ custom_connections?: unknown[];
114
+ sections?: Record<string, unknown[]>;
115
+ /** Header keys in their original YAML order (for header rendering). */
116
+ _keyOrder: string[];
117
+ }
118
+ declare function cvSchema(currentDate: SimpleDate, validationContext?: ValidationContext): z.ZodEffects<z.ZodObject<z.ZodRawShape, "strict", z.ZodTypeAny, {
119
+ [x: string]: any;
120
+ }, {
121
+ [x: string]: any;
122
+ }>, Cv, {
123
+ [x: string]: any;
124
+ }>;
125
+
126
+ /**
127
+ * ClassicTheme — ported from `design/classic_theme.py`.
128
+ *
129
+ * This is the base schema for ALL themes. Other built-in themes inherit the
130
+ * same field structure; they differ only in defaults (stored as static
131
+ * override objects in `themes/*.ts` and deep-merged over classic defaults
132
+ * at schema-construction time — see `variant_generator.ts`).
133
+ *
134
+ * Field structure (matching Python field order):
135
+ * theme: Literal["classic"]
136
+ * page: Page
137
+ * colors: Colors
138
+ * typography: Typography
139
+ * links: Links
140
+ * header: Header
141
+ * section_titles: SectionTitles
142
+ * sections: Sections
143
+ * entries: Entries
144
+ * templates: Templates
145
+ *
146
+ * Each sub-object is exported individually so the variant generator can
147
+ * override their defaults.
148
+ */
149
+
150
+ /**
151
+ * The base theme schema shared by ALL themes. The `theme` field accepts any of
152
+ * the built-in theme names (the variant generator pins it to the right literal
153
+ * per-variant). `ClassicThemeSchema` below wraps this with `theme = 'classic'`.
154
+ */
155
+ declare const ThemeBaseSchema: z.ZodObject<z.ZodRawShape, "strict", z.ZodTypeAny, {
156
+ [x: string]: any;
157
+ }, {
158
+ [x: string]: any;
159
+ }>;
160
+ type ClassicTheme = z.infer<typeof ThemeBaseSchema>;
161
+
162
+ /**
163
+ * Locale — ported from `locale/locale.py` + `locale/english_locale.py`.
164
+ *
165
+ * Structure (matching Python field order):
166
+ * language: Literal["english"] (or one of 20 other names)
167
+ * last_updated, month, months, year, years, present: str
168
+ * phrases: { degree_with_area: str }
169
+ * month_abbreviations: string[12]
170
+ * month_names: string[12]
171
+ *
172
+ * Plus computed properties (ported as functions here, not class methods):
173
+ * languageIso6391(language) → ISO 639-1 2-letter code
174
+ * flagEmoji(language) → flag emoji string
175
+ * isRtl(language) → boolean
176
+ *
177
+ * Like the Design layer, locales use the variant-generator pattern: a single
178
+ * base schema + deep-merged YAML configs for each non-English locale. The 21
179
+ * YAMLs are loaded as raw strings and parsed via the `yaml` package at module
180
+ * load — keeping them byte-identical to the Python source.
181
+ */
182
+
183
+ /** Known language names (English + 20 others). */
184
+ declare const LOCALE_NAMES: readonly ["english", "arabic", "danish", "dutch", "french", "german", "hebrew", "hindi", "hungarian", "indonesian", "italian", "japanese", "korean", "mandarin_chinese", "norwegian_bokmål", "norwegian_nynorsk", "persian", "portuguese", "russian", "spanish", "turkish", "vietnamese"];
185
+ type LocaleName = (typeof LOCALE_NAMES)[number];
186
+ /**
187
+ * Base locale schema. The `language` field accepts any known locale name; the
188
+ * variant generator pins the literal per-locale.
189
+ */
190
+ declare const LocaleBaseSchema: z.ZodObject<z.ZodRawShape, "strict", z.ZodTypeAny, {
191
+ [x: string]: any;
192
+ }, {
193
+ [x: string]: any;
194
+ }>;
195
+ type Locale = z.infer<typeof LocaleBaseSchema>;
196
+
197
+ /**
198
+ * RenderCommand — ported from `settings/render_command.py`.
199
+ *
200
+ * Holds output paths (with placeholders like `OUTPUT_FOLDER/NAME_IN_SNAKE_CASE_CV.typ`)
201
+ * and per-format disable flags. The browser port treats paths as plain strings
202
+ * (the path-resolver expands placeholders at render time); the
203
+ * `ExistingPathRelativeToInput` / `PlannedPathRelativeToInput` custom types in
204
+ * Python are just strings with extra validation that we keep as `z.string()`.
205
+ */
206
+
207
+ declare const RenderCommandSchema: z.ZodObject<z.ZodRawShape, "strict", z.ZodTypeAny, {
208
+ [x: string]: any;
209
+ }, {
210
+ [x: string]: any;
211
+ }>;
212
+ type RenderCommand = z.infer<typeof RenderCommandSchema>;
213
+
214
+ /**
215
+ * Settings — ported from `settings/settings.py`.
216
+ *
217
+ * Holds the "current date" (literal "today" or a real date), bold keywords,
218
+ * the PDF title template, and the nested RenderCommand settings.
219
+ *
220
+ * The `current_date` field resolves at parse time:
221
+ * - "today" → today's date
222
+ * - YYYY-MM-DD → that date
223
+ * - YYYY-MM / YYYY → that date (day/month default to 1)
224
+ * The resolved date is attached as `_resolvedCurrentDate` for downstream use
225
+ * (entry date adjustment, time-span calculations).
226
+ */
227
+
228
+ interface Settings {
229
+ current_date: string;
230
+ render_command: RenderCommand;
231
+ bold_keywords: string[];
232
+ pdf_title: string;
233
+ /** Resolved at parse time — used by entry date adjustment and path resolution. */
234
+ _resolvedCurrentDate: SimpleDate;
235
+ }
236
+
237
+ /**
238
+ * RenderCVModel — ported from `models/rendercv_model.py` + the builder.
239
+ */
240
+
241
+ interface RenderCVModel {
242
+ cv: Cv;
243
+ design: ClassicTheme;
244
+ locale: Locale;
245
+ settings: Settings;
246
+ }
247
+ interface BuildRendercvModelOptions {
248
+ validationContext?: ValidationContext;
249
+ yamlDocuments?: {
250
+ main: YamlDocumentBundle;
251
+ overlays?: OverlayDocuments;
252
+ };
253
+ }
254
+ declare function buildRendercvModel(input: unknown, options?: BuildRendercvModelOptions): RenderCVModel;
255
+ declare const RenderCvModelSchema: z.ZodType<RenderCVModel>;
256
+
257
+ /**
258
+ * Bundled Typst package + font setup for the WASM compiler.
259
+ */
260
+
261
+ declare const MAIN_TYP_PATH = "/main.typ";
262
+ declare function configureBrowserWasm(baseUrl?: string): void;
263
+ declare function preloadTypst(): Promise<void>;
264
+ declare function clearFontCache(): Promise<void>;
265
+
266
+ export { type ClassicTheme as C, type Locale as L, MAIN_TYP_PATH as M, type OverlayDocuments as O, type RenderCVModel as R, type YamlDocumentBundle as Y, type YamlSource as a, RenderCVValidationError as b, type Cv as c, type LocaleName as d, RenderCVInternalError as e, RenderCVUserError as f, RenderCVUserValidationError as g, RenderCvModelSchema as h, buildRendercvModel as i, clearFontCache as j, configureBrowserWasm as k, cvSchema as l, preloadTypst as p };
@@ -0,0 +1,266 @@
1
+ import { z } from 'zod';
2
+ import { Document, LineCounter } from 'yaml';
3
+
4
+ /**
5
+ * Error types for the rendercv pipeline.
6
+ *
7
+ * Ported from src/rendercv/exception.py. We use classes (not dataclasses) and
8
+ * preserve the structured shape so callers can map errors to YAML positions.
9
+ */
10
+ type YamlSource = 'main_yaml_file' | 'design_yaml_file' | 'locale_yaml_file' | 'settings_yaml_file';
11
+ /** [[startLine, startCol], [endLine, endCol]] — 1-indexed, like ruamel.yaml. */
12
+ type YamlLocation = [[number, number], [number, number]];
13
+ /**
14
+ * Structured validation error paired with a YAML source location.
15
+ *
16
+ * Mirrors rendercv's `RenderCVValidationError` dataclass. The CLI / playground
17
+ * uses `yaml_location` to point at the offending YAML span.
18
+ */
19
+ declare class RenderCVValidationError {
20
+ readonly schemaLocation: readonly string[] | null;
21
+ readonly yamlLocation: YamlLocation | null;
22
+ readonly yamlSource: YamlSource;
23
+ readonly message: string;
24
+ readonly input: string;
25
+ constructor(schemaLocation: readonly string[] | null, yamlLocation: YamlLocation | null, yamlSource: YamlSource, message: string, input: string);
26
+ }
27
+ /** User-facing error carrying multiple structured validation errors. */
28
+ declare class RenderCVUserValidationError extends Error {
29
+ readonly validationErrors: RenderCVValidationError[];
30
+ constructor(validationErrors: RenderCVValidationError[]);
31
+ }
32
+ /** User-facing error for recoverable problems (invalid input, missing files). */
33
+ declare class RenderCVUserError extends Error {
34
+ constructor(message?: string);
35
+ }
36
+ /** Internal error indicating a bug in rendercv logic. Should never reach users. */
37
+ declare class RenderCVInternalError extends Error {
38
+ constructor(message: string);
39
+ }
40
+
41
+ /**
42
+ * Date helpers — ported from `entry_with_date.py` and `entry_with_complex_fields.py`.
43
+ *
44
+ * rendercv dates are unusual: they accept "free text" like "Fall 2023" for
45
+ * display, while strict dates (YYYY / YYYY-MM / YYYY-MM-DD) are validated and
46
+ * used for arithmetic (start ≤ end, duration calc). The literal `"present"`
47
+ * resolves to the rendering's "current date".
48
+ */
49
+
50
+ interface SimpleDate {
51
+ year: number;
52
+ month: number;
53
+ day: number;
54
+ }
55
+
56
+ /**
57
+ * Validation context threaded through model building — browser port of
58
+ * `validation_context.py`.
59
+ */
60
+
61
+ interface ValidationContext {
62
+ /** Relative-path assets supplied by the caller (path → URL or data URL). */
63
+ assets?: Record<string, string>;
64
+ /** Resolved reference date for entry validation. */
65
+ currentDate?: SimpleDate;
66
+ /** Header keys in YAML source order (from cv map). */
67
+ cvHeaderKeyOrder?: string[];
68
+ }
69
+
70
+ /**
71
+ * YAML parsing with source coordinates for error reporting.
72
+ */
73
+
74
+ interface YamlDocumentBundle {
75
+ value: Record<string, unknown>;
76
+ document: Document;
77
+ lineCounter: LineCounter;
78
+ source: YamlSource;
79
+ }
80
+ type OverlayDocuments = Partial<Record<'design' | 'locale' | 'settings', YamlDocumentBundle>>;
81
+
82
+ /**
83
+ * Cv — ported from `cv/cv.py`.
84
+ *
85
+ * The header / personal-information block. Holds name, headline, location,
86
+ * contact details (email/phone/website — each scalar-or-list), photo,
87
+ * social networks, custom connections, and the sections dict.
88
+ *
89
+ * Python-specific behaviors that need careful porting:
90
+ * - `capture_input_order` (model_validator wrap): preserve YAML key order so
91
+ * the header renders in user-defined order. In JS, object keys already
92
+ * preserve insertion order, so we just record which header keys were
93
+ * present in the input into `_keyOrder`.
94
+ * - `validate_list_or_scalar_fields`: email/phone/website accept a scalar OR
95
+ * a list. We model with a Zod union of single-or-array.
96
+ * - Private attrs (_plain_name, _connections, _top_note, _footer) are computed
97
+ * during the renderer's model-processor step, NOT here. We only carry
98
+ * `_keyOrder` (computed at parse time from input order).
99
+ *
100
+ * Like the entry schema, Cv needs a `currentDate` (passed through to sections),
101
+ * so we expose a factory `cvSchema(currentDate)`.
102
+ */
103
+
104
+ interface Cv {
105
+ name?: string | null;
106
+ headline?: string | null;
107
+ location?: string | null;
108
+ email?: string | string[];
109
+ photo?: string;
110
+ phone?: string | string[];
111
+ website?: string | string[];
112
+ social_networks?: unknown[];
113
+ custom_connections?: unknown[];
114
+ sections?: Record<string, unknown[]>;
115
+ /** Header keys in their original YAML order (for header rendering). */
116
+ _keyOrder: string[];
117
+ }
118
+ declare function cvSchema(currentDate: SimpleDate, validationContext?: ValidationContext): z.ZodEffects<z.ZodObject<z.ZodRawShape, "strict", z.ZodTypeAny, {
119
+ [x: string]: any;
120
+ }, {
121
+ [x: string]: any;
122
+ }>, Cv, {
123
+ [x: string]: any;
124
+ }>;
125
+
126
+ /**
127
+ * ClassicTheme — ported from `design/classic_theme.py`.
128
+ *
129
+ * This is the base schema for ALL themes. Other built-in themes inherit the
130
+ * same field structure; they differ only in defaults (stored as static
131
+ * override objects in `themes/*.ts` and deep-merged over classic defaults
132
+ * at schema-construction time — see `variant_generator.ts`).
133
+ *
134
+ * Field structure (matching Python field order):
135
+ * theme: Literal["classic"]
136
+ * page: Page
137
+ * colors: Colors
138
+ * typography: Typography
139
+ * links: Links
140
+ * header: Header
141
+ * section_titles: SectionTitles
142
+ * sections: Sections
143
+ * entries: Entries
144
+ * templates: Templates
145
+ *
146
+ * Each sub-object is exported individually so the variant generator can
147
+ * override their defaults.
148
+ */
149
+
150
+ /**
151
+ * The base theme schema shared by ALL themes. The `theme` field accepts any of
152
+ * the built-in theme names (the variant generator pins it to the right literal
153
+ * per-variant). `ClassicThemeSchema` below wraps this with `theme = 'classic'`.
154
+ */
155
+ declare const ThemeBaseSchema: z.ZodObject<z.ZodRawShape, "strict", z.ZodTypeAny, {
156
+ [x: string]: any;
157
+ }, {
158
+ [x: string]: any;
159
+ }>;
160
+ type ClassicTheme = z.infer<typeof ThemeBaseSchema>;
161
+
162
+ /**
163
+ * Locale — ported from `locale/locale.py` + `locale/english_locale.py`.
164
+ *
165
+ * Structure (matching Python field order):
166
+ * language: Literal["english"] (or one of 20 other names)
167
+ * last_updated, month, months, year, years, present: str
168
+ * phrases: { degree_with_area: str }
169
+ * month_abbreviations: string[12]
170
+ * month_names: string[12]
171
+ *
172
+ * Plus computed properties (ported as functions here, not class methods):
173
+ * languageIso6391(language) → ISO 639-1 2-letter code
174
+ * flagEmoji(language) → flag emoji string
175
+ * isRtl(language) → boolean
176
+ *
177
+ * Like the Design layer, locales use the variant-generator pattern: a single
178
+ * base schema + deep-merged YAML configs for each non-English locale. The 21
179
+ * YAMLs are loaded as raw strings and parsed via the `yaml` package at module
180
+ * load — keeping them byte-identical to the Python source.
181
+ */
182
+
183
+ /** Known language names (English + 20 others). */
184
+ declare const LOCALE_NAMES: readonly ["english", "arabic", "danish", "dutch", "french", "german", "hebrew", "hindi", "hungarian", "indonesian", "italian", "japanese", "korean", "mandarin_chinese", "norwegian_bokmål", "norwegian_nynorsk", "persian", "portuguese", "russian", "spanish", "turkish", "vietnamese"];
185
+ type LocaleName = (typeof LOCALE_NAMES)[number];
186
+ /**
187
+ * Base locale schema. The `language` field accepts any known locale name; the
188
+ * variant generator pins the literal per-locale.
189
+ */
190
+ declare const LocaleBaseSchema: z.ZodObject<z.ZodRawShape, "strict", z.ZodTypeAny, {
191
+ [x: string]: any;
192
+ }, {
193
+ [x: string]: any;
194
+ }>;
195
+ type Locale = z.infer<typeof LocaleBaseSchema>;
196
+
197
+ /**
198
+ * RenderCommand — ported from `settings/render_command.py`.
199
+ *
200
+ * Holds output paths (with placeholders like `OUTPUT_FOLDER/NAME_IN_SNAKE_CASE_CV.typ`)
201
+ * and per-format disable flags. The browser port treats paths as plain strings
202
+ * (the path-resolver expands placeholders at render time); the
203
+ * `ExistingPathRelativeToInput` / `PlannedPathRelativeToInput` custom types in
204
+ * Python are just strings with extra validation that we keep as `z.string()`.
205
+ */
206
+
207
+ declare const RenderCommandSchema: z.ZodObject<z.ZodRawShape, "strict", z.ZodTypeAny, {
208
+ [x: string]: any;
209
+ }, {
210
+ [x: string]: any;
211
+ }>;
212
+ type RenderCommand = z.infer<typeof RenderCommandSchema>;
213
+
214
+ /**
215
+ * Settings — ported from `settings/settings.py`.
216
+ *
217
+ * Holds the "current date" (literal "today" or a real date), bold keywords,
218
+ * the PDF title template, and the nested RenderCommand settings.
219
+ *
220
+ * The `current_date` field resolves at parse time:
221
+ * - "today" → today's date
222
+ * - YYYY-MM-DD → that date
223
+ * - YYYY-MM / YYYY → that date (day/month default to 1)
224
+ * The resolved date is attached as `_resolvedCurrentDate` for downstream use
225
+ * (entry date adjustment, time-span calculations).
226
+ */
227
+
228
+ interface Settings {
229
+ current_date: string;
230
+ render_command: RenderCommand;
231
+ bold_keywords: string[];
232
+ pdf_title: string;
233
+ /** Resolved at parse time — used by entry date adjustment and path resolution. */
234
+ _resolvedCurrentDate: SimpleDate;
235
+ }
236
+
237
+ /**
238
+ * RenderCVModel — ported from `models/rendercv_model.py` + the builder.
239
+ */
240
+
241
+ interface RenderCVModel {
242
+ cv: Cv;
243
+ design: ClassicTheme;
244
+ locale: Locale;
245
+ settings: Settings;
246
+ }
247
+ interface BuildRendercvModelOptions {
248
+ validationContext?: ValidationContext;
249
+ yamlDocuments?: {
250
+ main: YamlDocumentBundle;
251
+ overlays?: OverlayDocuments;
252
+ };
253
+ }
254
+ declare function buildRendercvModel(input: unknown, options?: BuildRendercvModelOptions): RenderCVModel;
255
+ declare const RenderCvModelSchema: z.ZodType<RenderCVModel>;
256
+
257
+ /**
258
+ * Bundled Typst package + font setup for the WASM compiler.
259
+ */
260
+
261
+ declare const MAIN_TYP_PATH = "/main.typ";
262
+ declare function configureBrowserWasm(baseUrl?: string): void;
263
+ declare function preloadTypst(): Promise<void>;
264
+ declare function clearFontCache(): Promise<void>;
265
+
266
+ export { type ClassicTheme as C, type Locale as L, MAIN_TYP_PATH as M, type OverlayDocuments as O, type RenderCVModel as R, type YamlDocumentBundle as Y, type YamlSource as a, RenderCVValidationError as b, type Cv as c, type LocaleName as d, RenderCVInternalError as e, RenderCVUserError as f, RenderCVUserValidationError as g, RenderCvModelSchema as h, buildRendercvModel as i, clearFontCache as j, configureBrowserWasm as k, cvSchema as l, preloadTypst as p };
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "rendercv-ts",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript port of rendercv — version-controlled CVs as code, validated and rendered to PDF/Markdown/HTML in the browser.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "files": [
9
+ "dist",
10
+ "assets"
11
+ ],
12
+ "main": "./dist/index.cjs",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js",
19
+ "require": "./dist/index.cjs"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "generate:fonts": "node scripts/generate-font-manifest.mjs",
24
+ "generate:icons": "node scripts/generate-connection-icons.mjs",
25
+ "prebuild": "node scripts/generate-font-manifest.mjs && node scripts/generate-connection-icons.mjs && node scripts/copy-publish-assets.mjs",
26
+ "build": "tsup",
27
+ "pretest": "node scripts/copy-publish-assets.mjs",
28
+ "test": "vitest run",
29
+ "test:watch": "vitest",
30
+ "typecheck": "tsc --noEmit",
31
+ "lint": "biome check src tests",
32
+ "format": "biome format --write src tests",
33
+ "bench": "node scripts/bench-render.mjs",
34
+ "prepublishOnly": "npm run build"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/alishirani1384/rendercv-ts.git"
39
+ },
40
+ "homepage": "https://github.com/alishirani1384/rendercv-ts#readme",
41
+ "bugs": {
42
+ "url": "https://github.com/alishirani1384/rendercv-ts/issues"
43
+ },
44
+ "keywords": [
45
+ "rendercv",
46
+ "cv",
47
+ "resume",
48
+ "typst",
49
+ "pdf",
50
+ "yaml"
51
+ ],
52
+ "dependencies": {
53
+ "@myriaddreamin/typst-ts-renderer": "^0.7.0",
54
+ "@myriaddreamin/typst-ts-web-compiler": "^0.7.0",
55
+ "@myriaddreamin/typst.ts": "^0.7.0",
56
+ "libphonenumber-js": "^1.13.7",
57
+ "marked": "^18.0.5",
58
+ "nunjucks": "^3.2.4",
59
+ "yaml": "^2.6.0"
60
+ },
61
+ "devDependencies": {
62
+ "@biomejs/biome": "^1.9.4",
63
+ "@fontsource-variable/vazirmatn": "^5.2.8",
64
+ "@fontsource/vazirmatn": "^5.2.8",
65
+ "@happy-dom/node-canvas-adapter": "^20.10.6",
66
+ "@resvg/resvg-js": "^2.6.2",
67
+ "@types/nunjucks": "^3.2.6",
68
+ "canvas": "^3.2.3",
69
+ "happy-dom": "^20.10.6",
70
+ "simple-icons": "^16.24.0",
71
+ "tsup": "^8.3.5",
72
+ "typescript": "^5.7.2",
73
+ "vazirmatn": "^33.0.3",
74
+ "vitest": "^2.1.8",
75
+ "zod": "^3.25.76"
76
+ },
77
+ "engines": {
78
+ "node": ">=20"
79
+ }
80
+ }