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.
- package/LICENSE +26 -0
- package/README.md +112 -0
- package/assets/fonts/EB Garamond/EBGaramond-Bold.ttf +0 -0
- package/assets/fonts/EB Garamond/EBGaramond-BoldItalic.ttf +0 -0
- package/assets/fonts/EB Garamond/EBGaramond-Italic.ttf +0 -0
- package/assets/fonts/EB Garamond/EBGaramond-Regular.ttf +0 -0
- package/assets/fonts/Fontin/Fontin-Bold.otf +0 -0
- package/assets/fonts/Fontin/Fontin-Italic.otf +0 -0
- package/assets/fonts/Fontin/Fontin-Regular.otf +0 -0
- package/assets/fonts/Gentium Book Plus/GentiumBookPlus-Bold.ttf +0 -0
- package/assets/fonts/Gentium Book Plus/GentiumBookPlus-BoldItalic.ttf +0 -0
- package/assets/fonts/Gentium Book Plus/GentiumBookPlus-Italic.ttf +0 -0
- package/assets/fonts/Gentium Book Plus/GentiumBookPlus-Regular.ttf +0 -0
- package/assets/fonts/Lato/Lato-Bold.ttf +0 -0
- package/assets/fonts/Lato/Lato-BoldItalic.ttf +0 -0
- package/assets/fonts/Lato/Lato-Italic.ttf +0 -0
- package/assets/fonts/Lato/Lato-Regular.ttf +0 -0
- package/assets/fonts/Raleway/Raleway-Bold.ttf +0 -0
- package/assets/fonts/Raleway/Raleway-BoldItalic.ttf +0 -0
- package/assets/fonts/Raleway/Raleway-Italic.ttf +0 -0
- package/assets/fonts/Raleway/Raleway-Regular.ttf +0 -0
- package/assets/fonts/Source Sans 3/SourceSans3-Bold.ttf +0 -0
- package/assets/fonts/Source Sans 3/SourceSans3-BoldItalic.ttf +0 -0
- package/assets/fonts/Source Sans 3/SourceSans3-Italic.ttf +0 -0
- package/assets/fonts/Source Sans 3/SourceSans3-Regular.ttf +0 -0
- package/assets/fonts/Ubuntu/Ubuntu-Bold.ttf +0 -0
- package/assets/fonts/Ubuntu/Ubuntu-BoldItalic.ttf +0 -0
- package/assets/fonts/Ubuntu/Ubuntu-Italic.ttf +0 -0
- package/assets/fonts/Ubuntu/Ubuntu-Regular.ttf +0 -0
- package/assets/fonts/Vazirmatn/Vazirmatn-Black.ttf +0 -0
- package/assets/fonts/Vazirmatn/Vazirmatn-Bold.ttf +0 -0
- package/assets/fonts/Vazirmatn/Vazirmatn-ExtraBold.ttf +0 -0
- package/assets/fonts/Vazirmatn/Vazirmatn-ExtraLight.ttf +0 -0
- package/assets/fonts/Vazirmatn/Vazirmatn-Light.ttf +0 -0
- package/assets/fonts/Vazirmatn/Vazirmatn-Medium.ttf +0 -0
- package/assets/fonts/Vazirmatn/Vazirmatn-Regular.ttf +0 -0
- package/assets/fonts/Vazirmatn/Vazirmatn-SemiBold.ttf +0 -0
- package/assets/fonts/Vazirmatn/Vazirmatn-Thin.ttf +0 -0
- package/assets/fonts/XCharter/XCharter-Bold.otf +0 -0
- package/assets/fonts/XCharter/XCharter-BoldItalic.otf +0 -0
- package/assets/fonts/XCharter/XCharter-Italic.otf +0 -0
- package/assets/fonts/XCharter/XCharter-Regular.otf +0 -0
- package/assets/wasm/typst_ts_renderer_bg.wasm +0 -0
- package/assets/wasm/typst_ts_web_compiler_bg.wasm +0 -0
- package/dist/asset_paths-Q3SHUESH.js +12 -0
- package/dist/asset_paths-Q3SHUESH.js.map +1 -0
- package/dist/chunk-CJBTP63L.js +94 -0
- package/dist/chunk-CJBTP63L.js.map +1 -0
- package/dist/chunk-EVM6BVMO.js +16 -0
- package/dist/chunk-EVM6BVMO.js.map +1 -0
- package/dist/chunk-QZVXUQ72.js +91 -0
- package/dist/chunk-QZVXUQ72.js.map +1 -0
- package/dist/chunk-VZSMPOAA.js +1012 -0
- package/dist/chunk-VZSMPOAA.js.map +1 -0
- package/dist/font_cache-BZENGUJA.js +84 -0
- package/dist/font_cache-BZENGUJA.js.map +1 -0
- package/dist/font_registry-TJ7PJJTJ.js +183 -0
- package/dist/font_registry-TJ7PJJTJ.js.map +1 -0
- package/dist/index.cjs +9979 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +195 -0
- package/dist/index.d.ts +195 -0
- package/dist/index.js +8396 -0
- package/dist/index.js.map +1 -0
- package/dist/renderer/worker/pdf_worker.cjs +1518 -0
- package/dist/renderer/worker/pdf_worker.cjs.map +1 -0
- package/dist/renderer/worker/pdf_worker.d.cts +24 -0
- package/dist/renderer/worker/pdf_worker.d.ts +24 -0
- package/dist/renderer/worker/pdf_worker.js +51 -0
- package/dist/renderer/worker/pdf_worker.js.map +1 -0
- package/dist/typst_font_cache-LYHXH5UA.js +60 -0
- package/dist/typst_font_cache-LYHXH5UA.js.map +1 -0
- package/dist/typst_setup-SW3GQFSL.js +30 -0
- package/dist/typst_setup-SW3GQFSL.js.map +1 -0
- package/dist/typst_setup-WebjDI32.d.cts +266 -0
- package/dist/typst_setup-WebjDI32.d.ts +266 -0
- package/package.json +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rendercv-ts contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
This project is a TypeScript port of RenderCV (https://github.com/rendercv/rendercv),
|
|
26
|
+
which is also licensed under the MIT License.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# rendercv (TypeScript)
|
|
2
|
+
|
|
3
|
+
Browser-only TypeScript port of [RenderCV](https://github.com/rendercv/rendercv). Validate CV YAML and render to Typst, Markdown, HTML, PDF, and PNG without a CLI.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install rendercv-ts
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import {
|
|
15
|
+
buildRendercvModelFromYaml,
|
|
16
|
+
generateTypst,
|
|
17
|
+
generateMarkdown,
|
|
18
|
+
generateHtml,
|
|
19
|
+
generatePdf,
|
|
20
|
+
generatePng,
|
|
21
|
+
preloadTypst,
|
|
22
|
+
} from 'rendercv-ts';
|
|
23
|
+
|
|
24
|
+
const { model } = buildRendercvModelFromYaml(yamlText, {
|
|
25
|
+
assets: {
|
|
26
|
+
'images/photo.jpg': 'data:image/jpeg;base64,...',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const typst = generateTypst(model);
|
|
31
|
+
const markdown = generateMarkdown(model);
|
|
32
|
+
const html = generateHtml(model);
|
|
33
|
+
|
|
34
|
+
// PDF/PNG use Typst WASM — warm up once, then render
|
|
35
|
+
await preloadTypst();
|
|
36
|
+
const pdf = await generatePdf(model); // Uint8Array | null
|
|
37
|
+
const pngPages = await generatePng(model); // Uint8Array[] | null
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Relative asset paths (for example a CV photo) must be supplied through the `assets` map as URLs or data URLs.
|
|
41
|
+
|
|
42
|
+
## Browser setup (PDF / PNG)
|
|
43
|
+
|
|
44
|
+
The npm package ships bundled **fonts** and **Typst WASM** under `node_modules/rendercv-ts/assets/`. Your app must serve them as static files (typically under `/fonts` and `/wasm`).
|
|
45
|
+
|
|
46
|
+
### Next.js / Vite
|
|
47
|
+
|
|
48
|
+
Copy assets into your public folder before dev/build:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Example: copy from node_modules into public/
|
|
52
|
+
cp -r node_modules/rendercv-ts/assets/fonts public/fonts
|
|
53
|
+
cp -r node_modules/rendercv-ts/assets/wasm public/wasm
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Then call `preloadTypst()` — it auto-configures URLs from `window.location.origin` when you haven't set paths manually:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
await preloadTypst();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Manual path override
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { configureBrowserWasm, configureBrowserFonts, preloadTypst } from 'rendercv-ts';
|
|
66
|
+
|
|
67
|
+
configureBrowserWasm('https://cdn.example.com/wasm');
|
|
68
|
+
configureBrowserFonts('https://cdn.example.com/fonts');
|
|
69
|
+
await preloadTypst();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Or use `configureDefaultAssets({ origin: 'https://my-app.com' })` before `preloadTypst()`.
|
|
73
|
+
|
|
74
|
+
## Bundled fonts
|
|
75
|
+
|
|
76
|
+
Theme fonts are **bundled locally** — no Google Fonts network requests at render time.
|
|
77
|
+
|
|
78
|
+
| Family | Used by |
|
|
79
|
+
|--------|---------|
|
|
80
|
+
| Source Sans 3 | classic (default) |
|
|
81
|
+
| Raleway | engineeringclassic |
|
|
82
|
+
| XCharter | engineeringresumes, harvard |
|
|
83
|
+
| EB Garamond | ink |
|
|
84
|
+
| Fontin | moderncv |
|
|
85
|
+
| Lato | opal |
|
|
86
|
+
| Ubuntu, Gentium Book Plus | ember |
|
|
87
|
+
| Vazirmatn | RTL / Persian / Arabic (user override) |
|
|
88
|
+
|
|
89
|
+
`sb2nov` uses **New Computer Modern**, loaded from the Typst CDN (not bundled).
|
|
90
|
+
|
|
91
|
+
Run `npm run generate:fonts` after `npm install` (requires `pip` to fetch `rendercv-fonts`, or install it with `pip install rendercv-fonts`).
|
|
92
|
+
|
|
93
|
+
PDF header icons use lightweight inline SVG presets (~22 icons).
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm install
|
|
99
|
+
npm run typecheck
|
|
100
|
+
npm test
|
|
101
|
+
npm run build
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
PDF golden fixtures are produced by Typst WASM and may differ from Python `typst-cli` output. Regenerate them with:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
UPDATE_TESTDATA=1 npm test -- tests/renderer/pdf-png.test.ts
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configureDefaultAssets,
|
|
3
|
+
resolveBundledAssetPaths
|
|
4
|
+
} from "./chunk-QZVXUQ72.js";
|
|
5
|
+
import "./chunk-CJBTP63L.js";
|
|
6
|
+
import "./chunk-VZSMPOAA.js";
|
|
7
|
+
import "./chunk-EVM6BVMO.js";
|
|
8
|
+
export {
|
|
9
|
+
configureDefaultAssets,
|
|
10
|
+
resolveBundledAssetPaths
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=asset_paths-Q3SHUESH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__glob
|
|
3
|
+
} from "./chunk-EVM6BVMO.js";
|
|
4
|
+
|
|
5
|
+
// import("../assets/fonts/**/*?binary") in src/renderer/fonts/load_bundled_font.ts
|
|
6
|
+
var globImport_assets_fonts_binary = __glob({});
|
|
7
|
+
|
|
8
|
+
// src/renderer/fonts/load_bundled_font.ts
|
|
9
|
+
var fontFileCache = /* @__PURE__ */ new Map();
|
|
10
|
+
var nodeFontsRoot;
|
|
11
|
+
var browserFontsBaseUrl = "/fonts";
|
|
12
|
+
var fontsUrlConfigured = false;
|
|
13
|
+
function configureBrowserFonts(baseUrl = "/fonts") {
|
|
14
|
+
fontsUrlConfigured = true;
|
|
15
|
+
browserFontsBaseUrl = baseUrl.replace(/\/$/, "");
|
|
16
|
+
}
|
|
17
|
+
function isFontsUrlConfigured() {
|
|
18
|
+
return fontsUrlConfigured;
|
|
19
|
+
}
|
|
20
|
+
function isNodeRuntime() {
|
|
21
|
+
return typeof process !== "undefined" && Boolean(process.versions?.node);
|
|
22
|
+
}
|
|
23
|
+
async function resolveNodeFontsRoot() {
|
|
24
|
+
if (nodeFontsRoot !== void 0) {
|
|
25
|
+
return nodeFontsRoot;
|
|
26
|
+
}
|
|
27
|
+
if (!isNodeRuntime()) {
|
|
28
|
+
nodeFontsRoot = null;
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const [{ existsSync }, path, { fileURLToPath }] = await Promise.all([
|
|
32
|
+
import("fs"),
|
|
33
|
+
import("path"),
|
|
34
|
+
import("url")
|
|
35
|
+
]);
|
|
36
|
+
const cwd = process.cwd();
|
|
37
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
38
|
+
const candidates = [
|
|
39
|
+
path.resolve(moduleDir, "../assets/fonts"),
|
|
40
|
+
path.resolve(moduleDir, "../../assets/fonts"),
|
|
41
|
+
path.resolve(moduleDir, "../../../assets/fonts"),
|
|
42
|
+
path.join(cwd, "assets/fonts"),
|
|
43
|
+
path.join(cwd, "node_modules/rendercv-ts/assets/fonts"),
|
|
44
|
+
path.join(cwd, "rendercv-ts/assets/fonts"),
|
|
45
|
+
path.join(cwd, "src/renderer/assets/fonts"),
|
|
46
|
+
path.join(cwd, "rendercv-ts/src/renderer/assets/fonts")
|
|
47
|
+
];
|
|
48
|
+
for (const candidate of candidates) {
|
|
49
|
+
if (existsSync(candidate)) {
|
|
50
|
+
nodeFontsRoot = candidate;
|
|
51
|
+
return candidate;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
nodeFontsRoot = null;
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
async function loadBundledFontPath(relativePath) {
|
|
58
|
+
const cached = fontFileCache.get(relativePath);
|
|
59
|
+
if (cached) {
|
|
60
|
+
return cached;
|
|
61
|
+
}
|
|
62
|
+
const fontsRoot = await resolveNodeFontsRoot();
|
|
63
|
+
let bytes;
|
|
64
|
+
if (fontsRoot) {
|
|
65
|
+
const [{ readFile }, path] = await Promise.all([
|
|
66
|
+
import("fs/promises"),
|
|
67
|
+
import("path")
|
|
68
|
+
]);
|
|
69
|
+
bytes = new Uint8Array(await readFile(path.join(fontsRoot, relativePath)));
|
|
70
|
+
} else if (typeof window !== "undefined") {
|
|
71
|
+
const response = await fetch(
|
|
72
|
+
`${browserFontsBaseUrl}/${relativePath.split("/").map(encodeURIComponent).join("/")}`
|
|
73
|
+
);
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
throw new Error(`Failed to load font: ${relativePath} (${response.status})`);
|
|
76
|
+
}
|
|
77
|
+
bytes = new Uint8Array(await response.arrayBuffer());
|
|
78
|
+
} else {
|
|
79
|
+
const mod = await globImport_assets_fonts_binary(`../assets/fonts/${relativePath}?binary`);
|
|
80
|
+
bytes = mod.default;
|
|
81
|
+
}
|
|
82
|
+
fontFileCache.set(relativePath, bytes);
|
|
83
|
+
return bytes;
|
|
84
|
+
}
|
|
85
|
+
async function loadBundledFontPaths(paths) {
|
|
86
|
+
return Promise.all(paths.map((relativePath) => loadBundledFontPath(relativePath)));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
configureBrowserFonts,
|
|
91
|
+
isFontsUrlConfigured,
|
|
92
|
+
loadBundledFontPaths
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=chunk-CJBTP63L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/renderer/fonts/load_bundled_font.ts"],"sourcesContent":["/**\n * Load a single bundled font file with in-memory cache.\n * Node: reads from src/renderer/assets/fonts on disk (fast, no bundler chunks).\n * Browser: dynamic import of the binary asset.\n */\nconst fontFileCache = new Map<string, Uint8Array>();\nlet nodeFontsRoot: string | null | undefined;\nlet browserFontsBaseUrl = '/fonts';\nlet fontsUrlConfigured = false;\n\nexport function configureBrowserFonts(baseUrl = '/fonts'): void {\n fontsUrlConfigured = true;\n browserFontsBaseUrl = baseUrl.replace(/\\/$/, '');\n}\n\nexport function isFontsUrlConfigured(): boolean {\n return fontsUrlConfigured;\n}\n\nfunction isNodeRuntime(): boolean {\n return typeof process !== 'undefined' && Boolean(process.versions?.node);\n}\n\nasync function resolveNodeFontsRoot(): Promise<string | null> {\n if (nodeFontsRoot !== undefined) {\n return nodeFontsRoot;\n }\n if (!isNodeRuntime()) {\n nodeFontsRoot = null;\n return null;\n }\n\n const [{ existsSync }, path, { fileURLToPath }] = await Promise.all([\n import('node:fs'),\n import('node:path'),\n import('node:url'),\n ]);\n\n const cwd = process.cwd();\n const moduleDir = path.dirname(fileURLToPath(import.meta.url));\n const candidates = [\n path.resolve(moduleDir, '../assets/fonts'),\n path.resolve(moduleDir, '../../assets/fonts'),\n path.resolve(moduleDir, '../../../assets/fonts'),\n path.join(cwd, 'assets/fonts'),\n path.join(cwd, 'node_modules/rendercv-ts/assets/fonts'),\n path.join(cwd, 'rendercv-ts/assets/fonts'),\n path.join(cwd, 'src/renderer/assets/fonts'),\n path.join(cwd, 'rendercv-ts/src/renderer/assets/fonts'),\n ];\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n nodeFontsRoot = candidate;\n return candidate;\n }\n }\n\n nodeFontsRoot = null;\n return null;\n}\n\nasync function loadBundledFontPath(relativePath: string): Promise<Uint8Array> {\n const cached = fontFileCache.get(relativePath);\n if (cached) {\n return cached;\n }\n\n const fontsRoot = await resolveNodeFontsRoot();\n let bytes: Uint8Array;\n\n if (fontsRoot) {\n const [{ readFile }, path] = await Promise.all([\n import('node:fs/promises'),\n import('node:path'),\n ]);\n bytes = new Uint8Array(await readFile(path.join(fontsRoot, relativePath)));\n } else if (typeof window !== 'undefined') {\n const response = await fetch(\n `${browserFontsBaseUrl}/${relativePath.split('/').map(encodeURIComponent).join('/')}`,\n );\n if (!response.ok) {\n throw new Error(`Failed to load font: ${relativePath} (${response.status})`);\n }\n bytes = new Uint8Array(await response.arrayBuffer());\n } else {\n const mod = await import(`../assets/fonts/${relativePath}?binary`);\n bytes = mod.default as Uint8Array;\n }\n\n fontFileCache.set(relativePath, bytes);\n return bytes;\n}\n\nexport async function loadBundledFontPaths(paths: readonly string[]): Promise<Uint8Array[]> {\n return Promise.all(paths.map((relativePath) => loadBund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Ae,oBAAoB,cAA2C;AAC5E,QAAM,SAAS,cAAc,IAAI,YAAY;AAC7C,MAAI,QAAQ;AACV,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,MAAM,qBAAqB;AAC7C,MAAI;AAEJ,MAAI,WAAW;AACb,UAAM,CAAC,EAAE,SAAS,GAAG,IAAI,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC7C,OAAO,aAAkB;AAAA,MACzB,OAAO,MAAW;AAAA,IACpB,CAAC;AACD,YAAQ,IAAI,WAAW,MAAM,SAAS,KAAK,KAAK,WAAW,YAAY,CAAC,CAAC;AAAA,EAC3E,WAAW,OAAO,WAAW,aAAa;AACxC,UAAM,WAAW,MAAM;AAAA,MACrB,GAAG,mBAAmB,IAAI,aAAa,MAAM,GAAG,EAAE,IAAI,kBAAkB,EAAE,KAAK,GAAG,CAAC;AAAA,IACrF;AACA,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,MAAM,wBAAwB,YAAY,KAAK,SAAS,MAAM,GAAG;AAAA,IAC7E;AACA,YAAQ,IAAI,WAAW,MAAM,SAAS,YAAY,CAAC;AAAA,EACrD,OAAO;AACL,UAAM,MAAM,MAAa,kDAAmB,YAAY;AACxD,YAAQ,IAAI;AAAA,EACd;AAEA,gBAAc,IAAI,cAAc,KAAK;AACrC,SAAO;AACT;AAEA,eAAsB,qBAAqB,OAAiD;AAC1F,SAAO,QAAQ,IAAI,MAAM,IAAI,CAAC,iBAAiB,oBAAoB,YAAY,CAAC,CAAC;AACnF;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __glob = (map) => (path) => {
|
|
3
|
+
var fn = map[path];
|
|
4
|
+
if (fn) return fn();
|
|
5
|
+
throw new Error("Module not found in bundle: " + path);
|
|
6
|
+
};
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
__glob,
|
|
14
|
+
__export
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-EVM6BVMO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configureBrowserFonts,
|
|
3
|
+
isFontsUrlConfigured
|
|
4
|
+
} from "./chunk-CJBTP63L.js";
|
|
5
|
+
import {
|
|
6
|
+
configureBrowserWasm,
|
|
7
|
+
isWasmUrlConfigured,
|
|
8
|
+
setBrowserWasmBytes
|
|
9
|
+
} from "./chunk-VZSMPOAA.js";
|
|
10
|
+
|
|
11
|
+
// src/renderer/asset_paths.ts
|
|
12
|
+
var assetsConfigured = false;
|
|
13
|
+
function resolveBundledAssetPaths(origin = "") {
|
|
14
|
+
const base = origin.replace(/\/$/, "");
|
|
15
|
+
return {
|
|
16
|
+
wasmBaseUrl: `${base}/wasm`,
|
|
17
|
+
fontsBaseUrl: `${base}/fonts`
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function isNodeRuntime() {
|
|
21
|
+
return typeof process !== "undefined" && Boolean(process.versions?.node);
|
|
22
|
+
}
|
|
23
|
+
async function resolvePublishAssetsRoot() {
|
|
24
|
+
if (!isNodeRuntime()) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const [{ existsSync }, path, { fileURLToPath }] = await Promise.all([
|
|
28
|
+
import("fs"),
|
|
29
|
+
import("path"),
|
|
30
|
+
import("url")
|
|
31
|
+
]);
|
|
32
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
33
|
+
const cwd = process.cwd();
|
|
34
|
+
const candidates = [
|
|
35
|
+
path.resolve(moduleDir, "../../assets"),
|
|
36
|
+
path.resolve(moduleDir, "../assets"),
|
|
37
|
+
path.join(cwd, "assets"),
|
|
38
|
+
path.join(cwd, "node_modules/rendercv-ts/assets"),
|
|
39
|
+
path.join(cwd, "rendercv-ts/assets")
|
|
40
|
+
];
|
|
41
|
+
for (const candidate of candidates) {
|
|
42
|
+
if (existsSync(path.join(candidate, "wasm")) && existsSync(path.join(candidate, "fonts"))) {
|
|
43
|
+
return candidate;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
async function injectWasmFromDisk(assetsRoot) {
|
|
49
|
+
const [{ readFile }, path] = await Promise.all([import("fs/promises"), import("path")]);
|
|
50
|
+
const wasmDir = path.join(assetsRoot, "wasm");
|
|
51
|
+
const [compiler, renderer] = await Promise.all([
|
|
52
|
+
readFile(path.join(wasmDir, "typst_ts_web_compiler_bg.wasm")),
|
|
53
|
+
readFile(path.join(wasmDir, "typst_ts_renderer_bg.wasm"))
|
|
54
|
+
]);
|
|
55
|
+
setBrowserWasmBytes(compiler.buffer, renderer.buffer);
|
|
56
|
+
}
|
|
57
|
+
async function configureDefaultAssets(options) {
|
|
58
|
+
if (assetsConfigured) {
|
|
59
|
+
return resolveBundledAssetPaths(options?.origin ?? getBrowserOrigin());
|
|
60
|
+
}
|
|
61
|
+
const assetsRoot = await resolvePublishAssetsRoot();
|
|
62
|
+
let wasmLoadedFromDisk = false;
|
|
63
|
+
if (assetsRoot && isNodeRuntime()) {
|
|
64
|
+
await injectWasmFromDisk(assetsRoot);
|
|
65
|
+
wasmLoadedFromDisk = true;
|
|
66
|
+
}
|
|
67
|
+
const origin = options?.origin ?? getBrowserOrigin();
|
|
68
|
+
const paths = resolveBundledAssetPaths(origin);
|
|
69
|
+
if (typeof window !== "undefined" && origin) {
|
|
70
|
+
if (!isWasmUrlConfigured() && !wasmLoadedFromDisk) {
|
|
71
|
+
configureBrowserWasm(paths.wasmBaseUrl);
|
|
72
|
+
}
|
|
73
|
+
if (!isFontsUrlConfigured() && !assetsRoot) {
|
|
74
|
+
configureBrowserFonts(paths.fontsBaseUrl);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
assetsConfigured = true;
|
|
78
|
+
return paths;
|
|
79
|
+
}
|
|
80
|
+
function getBrowserOrigin() {
|
|
81
|
+
if (typeof window === "undefined") {
|
|
82
|
+
return "";
|
|
83
|
+
}
|
|
84
|
+
return window.location?.origin ?? "";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
resolveBundledAssetPaths,
|
|
89
|
+
configureDefaultAssets
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=chunk-QZVXUQ72.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/renderer/asset_paths.ts"],"sourcesContent":["/**\n * Resolve bundled runtime asset locations (fonts + Typst WASM).\n */\nimport { configureBrowserFonts, isFontsUrlConfigured } from './fonts/load_bundled_font';\nimport { configureBrowserWasm, isWasmUrlConfigured, setBrowserWasmBytes } from './typst_setup';\n\nexport interface RendercvAssetPaths {\n wasmBaseUrl: string;\n fontsBaseUrl: string;\n}\n\nlet assetsConfigured = false;\n\n/** Default browser URLs when assets are served from the app origin (e.g. /wasm, /fonts). */\nexport function resolveBundledAssetPaths(origin = ''): RendercvAssetPaths {\n const base = origin.replace(/\\/$/, '');\n return {\n wasmBaseUrl: `${base}/wasm`,\n fontsBaseUrl: `${base}/fonts`,\n };\n}\n\nfunction isNodeRuntime(): boolean {\n return typeof process !== 'undefined' && Boolean(process.versions?.node);\n}\n\nasync function resolvePublishAssetsRoot(): Promise<string | null> {\n if (!isNodeRuntime()) {\n return null;\n }\n\n const [{ existsSync }, path, { fileURLToPath }] = await Promise.all([\n import('node:fs'),\n import('node:path'),\n import('node:url'),\n ]);\n\n const moduleDir = path.dirname(fileURLToPath(import.meta.url));\n const cwd = process.cwd();\n const candidates = [\n path.resolve(moduleDir, '../../assets'),\n path.resolve(moduleDir, '../assets'),\n path.join(cwd, 'assets'),\n path.join(cwd, 'node_modules/rendercv-ts/assets'),\n path.join(cwd, 'rendercv-ts/assets'),\n ];\n\n for (const candidate of candidates) {\n if (existsSync(path.join(candidate, 'wasm')) && existsSync(path.join(candidate, 'fonts'))) {\n return candidate;\n }\n }\n\n return null;\n}\n\nasync function injectWasmFromDisk(assetsRoot: string): Promise<void> {\n const [{ readFile }, path] = await Promise.all([import('node:fs/promises'), import('node:path')]);\n const wasmDir = path.join(assetsRoot, 'wasm');\n const [compiler, renderer] = await Promise.all([\n readFile(path.join(wasmDir, 'typst_ts_web_compiler_bg.wasm')),\n readFile(path.join(wasmDir, 'typst_ts_renderer_bg.wasm')),\n ]);\n setBrowserWasmBytes(compiler.buffer, renderer.buffer);\n}\n\n/**\n * Configure font/WASM loading. In the browser, defaults to `{origin}/wasm` and `{origin}/fonts`.\n * In Node (tests), loads WASM bytes from the bundled assets/ directory on disk.\n */\nexport async function configureDefaultAssets(options?: {\n origin?: string;\n}): Promise<RendercvAssetPaths> {\n if (assetsConfigured) {\n return resolveBundledAssetPaths(options?.origin ?? getBrowserOrigin());\n }\n\n const assetsRoot = await resolvePublishAssetsRoot();\n let wasmLoadedFromDisk = false;\n\n if (assetsRoot && isNodeRuntime()) {\n await injectWasmFromDisk(assetsRoot);\n wasmLoadedFromDisk = true;\n }\n\n const origin = options?.origin ?? getBrowserOrigin();\n const paths = resolveBundledAssetPaths(origin);\n\n if (typeof window !== 'undefined' && origin) {\n if (!isWasmUrlConfigured() && !wasmLoadedFromDisk) {\n configureBrowserWasm(paths.wasmBaseUrl);\n }\n if (!isFontsUrlConfigured() && !assetsRoot) {\n configureBrowserFonts(paths.fontsBaseUrl);\n }\n }\n\n assetsConfigured = true;\n return paths;\n}\n\nfunction getBrowserOrigin(): string {\n if (typeof window === 'undefined') {\n return '';\n }\n return window.location?.origin ?? '';\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAI,mBAAmB;AAGhB,SAAS,yBAAyB,SAAS,IAAwB;AACxE,QAAM,OAAO,OAAO,QAAQ,OAAO,EAAE;AACrC,SAAO;AAAA,IACL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