jsonresume-theme-graph-paper-grid 1.1.2 → 1.1.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # jsonresume-theme-graph-paper-grid
2
2
 
3
+ ## 1.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - c621133: use @jsonresume/core/ssr renderResumeDocument
8
+ - Updated dependencies [ff09f75]
9
+ - @jsonresume/core@0.3.1
10
+
3
11
  ## 1.1.2
4
12
 
5
13
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { renderToString } from "react-dom/server";
2
+ import { renderToStaticMarkup } from "react-dom/server";
3
3
  import o, { useRef, useContext, useState, useMemo, useEffect, useDebugValue, createElement, createContext } from "react";
4
4
  var __assign = function() {
5
5
  __assign = Object.assign || function __assign2(t) {
@@ -1300,6 +1300,66 @@ var vt = /^\s*<\/[a-z]/i, gt = (function() {
1300
1300
  "production" !== process.env.NODE_ENV && "undefined" != typeof navigator && "ReactNative" === navigator.product && console.warn("It looks like you've imported 'styled-components' on React Native.\nPerhaps you're looking to import 'styled-components/native'?\nRead more about this at https://www.styled-components.com/docs/basics#react-native");
1301
1301
  var wt = "__sc-".concat(f, "__");
1302
1302
  "production" !== process.env.NODE_ENV && "test" !== process.env.NODE_ENV && "undefined" != typeof window && (window[wt] || (window[wt] = 0), 1 === window[wt] && console.warn("It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.\n\nSee https://s-c.sh/2BAXzed for more info."), window[wt] += 1);
1303
+ const CSS_RESET = "<style>*,*::before,*::after{box-sizing:border-box}html,body{margin:0;padding:0}body{-webkit-font-smoothing:antialiased}</style>";
1304
+ const TOKENS_CSS_HREF = "https://unpkg.com/@jsonresume/core/dist/tokens.css";
1305
+ const FONTS_PRECONNECT = '<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>';
1306
+ function isHref(value) {
1307
+ return /^(https?:)?\/\//.test(value) || value.trim().startsWith("<link");
1308
+ }
1309
+ function familyParam(family) {
1310
+ const [name, ...rest] = String(family).split(":");
1311
+ const encodedName = name.trim().replace(/\s+/g, "+");
1312
+ return rest.length ? `${encodedName}:${rest.join(":")}` : encodedName;
1313
+ }
1314
+ function googleFontsLinks(families) {
1315
+ if (!Array.isArray(families) || families.length === 0) return "";
1316
+ const passthrough = [];
1317
+ const names = [];
1318
+ for (const entry of families) {
1319
+ if (entry == null || entry === "") continue;
1320
+ if (isHref(entry)) passthrough.push(entry);
1321
+ else names.push(entry);
1322
+ }
1323
+ const links = passthrough.map(
1324
+ (href) => href.trim().startsWith("<link") ? href : `<link href="${href}" rel="stylesheet">`
1325
+ );
1326
+ if (names.length > 0) {
1327
+ const query = names.map(familyParam).join("&family=");
1328
+ links.unshift(
1329
+ `<link href="https://fonts.googleapis.com/css2?family=${query}&display=swap" rel="stylesheet">`
1330
+ );
1331
+ }
1332
+ if (links.length === 0) return "";
1333
+ return FONTS_PRECONNECT + links.join("");
1334
+ }
1335
+ function renderResumeDocument(element, options = {}) {
1336
+ const {
1337
+ fonts,
1338
+ title,
1339
+ lang = "en",
1340
+ dir = "ltr",
1341
+ reset = false,
1342
+ head = "",
1343
+ headAfterStyles = "",
1344
+ includeTokensCss = true,
1345
+ bodyClass
1346
+ } = options;
1347
+ const sheet = new gt();
1348
+ let html;
1349
+ let styleTags;
1350
+ try {
1351
+ html = renderToStaticMarkup(sheet.collectStyles(element));
1352
+ styleTags = sheet.getStyleTags();
1353
+ } finally {
1354
+ sheet.seal();
1355
+ }
1356
+ const fontLinks = googleFontsLinks(fonts);
1357
+ const tokensLink = includeTokensCss ? `<link rel="stylesheet" href="${TOKENS_CSS_HREF}">` : "";
1358
+ const resetTag = reset ? CSS_RESET : "";
1359
+ const titleTag = title ? `<title>${title}</title>` : "";
1360
+ const bodyAttr = bodyClass ? ` class="${bodyClass}"` : "";
1361
+ return `<!DOCTYPE html><html lang="${lang}" dir="${dir}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">` + fontLinks + tokensLink + resetTag + head + styleTags + headAfterStyles + titleTag + `</head><body${bodyAttr}>${html}</body></html>`;
1362
+ }
1303
1363
  createContext({
1304
1364
  theme: "professional",
1305
1365
  setTheme: () => {
@@ -1466,7 +1526,9 @@ function formatDateRange({
1466
1526
  return formatter.format(date);
1467
1527
  };
1468
1528
  const start = formatDate(startDate);
1469
- if (endDate === void 0) return start;
1529
+ if (endDate === void 0) {
1530
+ return start;
1531
+ }
1470
1532
  const end = formatDate(endDate);
1471
1533
  return `${start} - ${end}`;
1472
1534
  }
@@ -1551,7 +1613,6 @@ function safeUrl(url) {
1551
1613
  const trimmed = url.trim();
1552
1614
  const dangerousProtocols = /^(javascript|data|vbscript|file|about):/i;
1553
1615
  if (dangerousProtocols.test(trimmed)) {
1554
- console.warn(`[Security] Blocked dangerous URL: ${trimmed.slice(0, 50)}`);
1555
1616
  return null;
1556
1617
  }
1557
1618
  const safeProtocols = /^(https?|mailto|tel|sms|ftp):/i;
@@ -1567,7 +1628,6 @@ function safeUrl(url) {
1567
1628
  if (/^[a-z0-9][a-z0-9.-]+\.[a-z]{2,}$/i.test(trimmed)) {
1568
1629
  return `https://${trimmed}`;
1569
1630
  }
1570
- console.warn(`[Security] Uncertain URL safety: ${trimmed.slice(0, 50)}`);
1571
1631
  return trimmed;
1572
1632
  }
1573
1633
  function isExternalUrl(url, currentOrigin = null) {
@@ -6495,27 +6555,12 @@ function Resume({ resume }) {
6495
6555
  ] });
6496
6556
  }
6497
6557
  function render(resume) {
6498
- const sheet = new gt();
6499
- try {
6500
- const html = renderToString(
6501
- sheet.collectStyles(/* @__PURE__ */ jsx(Resume, { resume }))
6502
- );
6503
- const styles = sheet.getStyleTags();
6504
- return `<!DOCTYPE html>
6505
- <html lang="en">
6506
- <head>
6507
- <meta charset="UTF-8">
6508
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6509
- <title>${resume.basics?.name || "Resume"} - Curriculum Vitae</title>
6510
-
6511
- <!-- Google Fonts -->
6512
- <link rel="preconnect" href="https://fonts.googleapis.com">
6513
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
6514
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Roboto+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
6515
-
6516
- ${styles}
6517
-
6518
- <style>
6558
+ return renderResumeDocument(/* @__PURE__ */ jsx(Resume, { resume }), {
6559
+ fonts: [
6560
+ "Inter:wght@400;500;600;700;800",
6561
+ "Roboto Mono:wght@400;500;600;700"
6562
+ ],
6563
+ headAfterStyles: `<style>
6519
6564
  * {
6520
6565
  box-sizing: border-box;
6521
6566
  }
@@ -6545,15 +6590,12 @@ function render(resume) {
6545
6590
  margin: 0.5cm;
6546
6591
  }
6547
6592
  }
6548
- </style>
6549
- </head>
6550
- <body>
6551
- ${html}
6552
- </body>
6553
- </html>`;
6554
- } finally {
6555
- sheet.seal();
6556
- }
6593
+ </style>`,
6594
+ lang: "en",
6595
+ dir: "ltr",
6596
+ title: `${resume.basics?.name || "Resume"} - Curriculum Vitae`,
6597
+ includeTokensCss: false
6598
+ });
6557
6599
  }
6558
6600
  export {
6559
6601
  render
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsonresume-theme-graph-paper-grid",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Technical design precision with subtle graph paper grid and monospace typography",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "react": "^19.2.0",
20
20
  "react-dom": "^19.2.0",
21
21
  "styled-components": "^6.1.19",
22
- "@jsonresume/core": "0.3.0"
22
+ "@jsonresume/core": "0.3.1"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": "^19.2.0",
package/src/index.jsx CHANGED
@@ -1,32 +1,13 @@
1
- import { renderToString } from 'react-dom/server';
2
- import { ServerStyleSheet } from 'styled-components';
1
+ import { renderResumeDocument } from '@jsonresume/core/ssr';
3
2
  import Resume from './Resume.jsx';
4
- import React from 'react';
5
3
 
6
4
  export function render(resume) {
7
- const sheet = new ServerStyleSheet();
8
-
9
- try {
10
- const html = renderToString(
11
- sheet.collectStyles(<Resume resume={resume} />)
12
- );
13
- const styles = sheet.getStyleTags();
14
-
15
- return `<!DOCTYPE html>
16
- <html lang="en">
17
- <head>
18
- <meta charset="UTF-8">
19
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
20
- <title>${resume.basics?.name || 'Resume'} - Curriculum Vitae</title>
21
-
22
- <!-- Google Fonts -->
23
- <link rel="preconnect" href="https://fonts.googleapis.com">
24
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
25
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Roboto+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
26
-
27
- ${styles}
28
-
29
- <style>
5
+ return renderResumeDocument(<Resume resume={resume} />, {
6
+ fonts: [
7
+ 'Inter:wght@400;500;600;700;800',
8
+ 'Roboto Mono:wght@400;500;600;700',
9
+ ],
10
+ headAfterStyles: `<style>
30
11
  * {
31
12
  box-sizing: border-box;
32
13
  }
@@ -56,13 +37,10 @@ export function render(resume) {
56
37
  margin: 0.5cm;
57
38
  }
58
39
  }
59
- </style>
60
- </head>
61
- <body>
62
- ${html}
63
- </body>
64
- </html>`;
65
- } finally {
66
- sheet.seal();
67
- }
40
+ </style>`,
41
+ lang: 'en',
42
+ dir: 'ltr',
43
+ title: `${resume.basics?.name || 'Resume'} - Curriculum Vitae`,
44
+ includeTokensCss: false,
45
+ });
68
46
  }