@projektemacher/vivliostyle-batch-cli 0.3.1 → 0.3.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/README.md +39 -32
- package/dist/index.d.ts +16 -1
- package/dist/vivliostyle-batch-cli.js +178 -27
- package/package.json +1 -1
- package/src/metadata.ts +103 -19
- package/src/render/pdf-postprocess.ts +6 -0
- package/src/render/pdf.ts +28 -3
- package/src/render/xmp.ts +12 -0
- package/src/vivliostyle-cli.ts +55 -6
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ It runs the [Vivliostyle viewer](https://www.npmjs.com/package/@vivliostyle/view
|
|
|
10
10
|
- Preview documents in the browser
|
|
11
11
|
- Render with the real browser engine, so canvas charts, WebGL scenes and cross-origin iframes end up in the PDF
|
|
12
12
|
- Stay sharp past 96dpi: `--pixel-ratio` redraws JS-painted content at higher backing resolution
|
|
13
|
-
- Stamp PDF metadata — title, author, subject, keywords, language — into the information dictionary and a matching XMP packet
|
|
13
|
+
- Stamp PDF metadata — title, author, subject, keywords, DOI/URL, language — into the information dictionary and a matching XMP packet
|
|
14
14
|
- Label the output as PDF/A or PDF/X with `--pdfa` / `--pdfx`, embedding an ICC output intent (`--icc-profile`, bundled sRGB default)
|
|
15
|
-
- Metadata comes from the flags, the publication manifest or the document itself (`<title>`, `<meta>` tags)
|
|
15
|
+
- Metadata comes from the flags, the publication manifest or the document itself (`<title>`, `<meta>` tags, `<link rel="canonical">`)
|
|
16
16
|
- Per-push showcase page (GitHub Pages) with the render fixtures next to their PDFs
|
|
17
17
|
- Automatic detection and mapping of static assets from HTML (`<link>`, `<script>`, `<img>`, etc.)
|
|
18
18
|
- Support for custom static asset mappings via `--static`
|
|
@@ -67,39 +67,46 @@ vivliostyle-cli -i index.html -o output.pdf -- --size A4 --viewer-param pixelRat
|
|
|
67
67
|
|
|
68
68
|
## Options
|
|
69
69
|
|
|
70
|
-
| Option | Description
|
|
71
|
-
| ----------------------------------- |
|
|
72
|
-
| `-i, --input <input>` | Input HTML or publication manifest file (required)
|
|
73
|
-
| `-o, --output <file>` | Output file path (default: `output.pdf`)
|
|
74
|
-
| `--title <title>` | Document title (overrides source)
|
|
75
|
-
| `--author <author>` | Document author
|
|
76
|
-
| `--subject <subject>` | Document subject (e.g. the page's description meta tag content)
|
|
77
|
-
| `--keywords <keywords>` | Document keywords, comma separated
|
|
78
|
-
| `--
|
|
79
|
-
| `--
|
|
80
|
-
| `--
|
|
81
|
-
| `--
|
|
82
|
-
| `--
|
|
83
|
-
| `--
|
|
84
|
-
| `--
|
|
85
|
-
| `--
|
|
86
|
-
| `--
|
|
87
|
-
| `--
|
|
88
|
-
| `--
|
|
89
|
-
| `--
|
|
90
|
-
| `--
|
|
91
|
-
| `--
|
|
92
|
-
| `--
|
|
93
|
-
| `--
|
|
94
|
-
| `--
|
|
95
|
-
| `--
|
|
96
|
-
| `--
|
|
97
|
-
| `--
|
|
98
|
-
|
|
|
70
|
+
| Option | Description |
|
|
71
|
+
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
72
|
+
| `-i, --input <input>` | Input HTML or publication manifest file (required) |
|
|
73
|
+
| `-o, --output <file>` | Output file path (default: `output.pdf`) |
|
|
74
|
+
| `--title <title>` | Document title (overrides source) |
|
|
75
|
+
| `--author <author>` | Document author |
|
|
76
|
+
| `--subject <subject>` | Document subject (e.g. the page's description meta tag content) |
|
|
77
|
+
| `--keywords <keywords>` | Document keywords, comma separated |
|
|
78
|
+
| `--doi <doi>` | Document DOI (bare `10.x/…`, `doi:` URI or doi.org URL); wins over `--url` and is written as the XMP `dc:identifier` (`doi:` prefix) |
|
|
79
|
+
| `--url <url>` | Document URL; XMP `dc:identifier` when no DOI is set, so reference managers can pick up the source |
|
|
80
|
+
| `--language <lang>` | Document language tag (e.g. `en`, `de`, `ja`); taken from the document or manifest when omitted, falling back to `de` |
|
|
81
|
+
| `--pdfa <level>` | Label the output as PDF/A: `1a`, `1b`, `2a`, `2b`, `2u`, `3a`, `3b`, `3u`, `4`. Embeds the sRGB output intent unless overridden |
|
|
82
|
+
| `--pdfx <version>` | Label the output as PDF/X: `X-4` or `X-1a:2003` (requires `--icc-profile`) |
|
|
83
|
+
| `--icc-profile <path>` | ICC profile embedded as the PDF output intent (required for `--pdfx`) |
|
|
84
|
+
| `--no-validate` | Skip the built-in compliance checks run for `--pdfa`/`--pdfx` output |
|
|
85
|
+
| `--verapdf` | Additionally run the verapdf binary (must be on the PATH) against the output and fail the build on full ISO rule-set violations |
|
|
86
|
+
| `--static <mapping>` | Map virtual path to local path: `/virtual/path:/local/path` (repeatable) |
|
|
87
|
+
| `--no-scripts` | Do not map `<script src>` tags as static assets |
|
|
88
|
+
| `--asset-base <urlBase=localBase>` | Map URLs starting with `urlBase` to files under `localBase` (repeatable) |
|
|
89
|
+
| `--ignore-asset <path>` | Skip specific virtual paths when deriving static mappings (repeatable) |
|
|
90
|
+
| `--allow-remote` | Keep subresource references that would be fetched from the network (default: drop) |
|
|
91
|
+
| `--executable-browser <path>` | Chrome/Chromium binary to render with (default: search puppeteer cache, then system) |
|
|
92
|
+
| `--dump-html <dir>` | Write the rewritten input HTML into `<dir>` and keep it (debugging aid) |
|
|
93
|
+
| `--fetch-missing` | Load references without a local file from the web (implies `--allow-remote`; drops gone remotes after a HEAD probe) |
|
|
94
|
+
| `--wait-for-content [ms]` --------- | Delay pagination until the page finished its own async work; pages with `<script>` wait automatically (10s default, `0` disables) |
|
|
95
|
+
| `--quiet-ms <ms>` ----------------- | Quiet period before the layout gate opens (default 400) --------------------------- |
|
|
96
|
+
| `--pixel-ratio <n>` --------------- | Render at `n` times the output resolution; redraws `__vivResize` pages at `n`× backing pixels |
|
|
97
|
+
| `--timeout <ms>` ------------------ | Give up on a page after `<ms>` (default: 300000) --------------------------------- |
|
|
98
|
+
| `--format <format>` | Output format: `pdf` (default: `pdf`) |
|
|
99
|
+
| `--log-level <level>` | Log level: `silent`, `info`, `verbose`, or `debug` (default: `info`) |
|
|
100
|
+
| `--mode <mode>` | Execution mode: `build` or `preview` (default: `build`) |
|
|
101
|
+
| `--preview` | Shorthand for `--mode preview` — open result in browser |
|
|
102
|
+
| `-d, --debug` | Enable debug mode (sets log level to `debug`) |
|
|
99
103
|
|
|
100
104
|
## Notes
|
|
101
105
|
|
|
102
|
-
- **PDF metadata and standards labeling**: every build stamps a producer/creator identity (`vivliostyle-batch-cli`) and a document language. Title, author, subject, keywords and language resolve with this precedence: CLI flags → publication manifest (`.json` input) → the document itself (`<title>`, `<meta name="author">`/`dc.creator`, `<meta name="description">`, `<meta name="keywords">`, `html[lang]`) → language fallback `de`. The values land in both the PDF information dictionary and an XMP metadata stream kept consistent with it, plus the catalog `/Lang` entry. `--pdfa <level>` and `--pdfx <version>` additionally write the standards identification (XMP `pdfaid`/`pdfxid` properties, an OutputIntent with an embedded ICC profile and a file identifier). This is a **label, not a conversion**: the rendered content is neither converted nor checked, so conformance of the content is the author's responsibility — verify with veraPDF when it matters. Chrome's output carries transparency, so `--pdfa 2b` (or newer) is the realistic level; PDF/A-1b will usually fail validation.
|
|
106
|
+
- **PDF metadata and standards labeling**: every build stamps a producer/creator identity (`vivliostyle-batch-cli`) and a document language. Title, author, subject, keywords, DOI/URL and language resolve with this precedence: CLI flags → publication manifest (`.json` input) → the document itself (`<title>`, `<meta name="author">`/`dc.creator`, `<meta name="description">`, `<meta name="keywords">`, `citation_doi`/`dc.doi`/`dc.identifier`, `<link rel="canonical">`/`og:url`, `html[lang]`) → language fallback `de`. The values land in both the PDF information dictionary and an XMP metadata stream kept consistent with it, plus the catalog `/Lang` entry. A DOI (flag, manifest, or meta — bare, `doi:` or doi.org URL forms all normalize) is written as XMP `dc:identifier` with a `doi:` prefix; when no DOI is known, the document URL is written there instead. Reference managers (Zotero, JabRef) pick the identifier up on PDF import. `--pdfa <level>` and `--pdfx <version>` additionally write the standards identification (XMP `pdfaid`/`pdfxid` properties, an OutputIntent with an embedded ICC profile and a file identifier). This is a **label, not a conversion**: the rendered content is neither converted nor checked, so conformance of the content is the author's responsibility — verify with veraPDF when it matters. Chrome's output carries transparency, so `--pdfa 2b` (or newer) is the realistic level; PDF/A-1b will usually fail validation.
|
|
107
|
+
|
|
108
|
+
Validation happens in two layers: every labeled build runs the built-in checks (a practical subset covering the PDF version of the labeled part, the XMP identification, the OutputIntent, the file identifier, embedded fonts and the absence of JavaScript; `--no-validate` skips them), and `--verapdf` additionally runs the [veraPDF](https://verapdf.org/) binary against the output for the full ISO rule set. `--verapdf` requires a veraPDF installation on the PATH (it needs a Java runtime) and makes the build fail if either the binary is missing or the output violates the labeled standard. For CI, the repository ships a reusable setup action (`.github/actions/setup-verapdf`) that installs veraPDF unattended.
|
|
109
|
+
|
|
103
110
|
- The bundled `src/render/srgb.icc` is the ICC's `sRGB_v4_ICC_preference.icc`, redistributed unchanged under its license ("permission to use, copy and distribute this file for any purpose… provided that the file is not changed"), see <https://www.color.org/srgbprofiles.xalter>. Pass `--icc-profile` to embed a print provider's profile instead.
|
|
104
111
|
- HTML input (`.html`/`.htm`) is auto-detected by file extension.
|
|
105
112
|
- For HTML input, `<link href>` and `<script src>` tags are parsed and automatically mapped.
|
package/dist/index.d.ts
CHANGED
|
@@ -63,6 +63,10 @@ type DocumentMetadata = {
|
|
|
63
63
|
author?: string;
|
|
64
64
|
subject?: string;
|
|
65
65
|
keywords?: string;
|
|
66
|
+
/** Normalized bare DOI (10.…/…); reference managers read it as dc:identifier. */
|
|
67
|
+
doi?: string;
|
|
68
|
+
/** Source URL of the document, used as dc:identifier when no DOI is known. */
|
|
69
|
+
url?: string;
|
|
66
70
|
language?: string;
|
|
67
71
|
/** ISO 8601 creation date (information dictionary and XMP CreateDate). */
|
|
68
72
|
created?: string;
|
|
@@ -77,6 +81,8 @@ type CliOptions = {
|
|
|
77
81
|
author?: string;
|
|
78
82
|
subject?: string;
|
|
79
83
|
keywords?: string;
|
|
84
|
+
doi?: string;
|
|
85
|
+
url?: string;
|
|
80
86
|
language?: string;
|
|
81
87
|
created?: string;
|
|
82
88
|
modified?: string;
|
|
@@ -113,6 +119,8 @@ type HtmlRewriteOptions = {
|
|
|
113
119
|
dumpDir?: string | null;
|
|
114
120
|
/** Let the browser load references without a local file from the web. */
|
|
115
121
|
fetchMissing?: boolean;
|
|
122
|
+
/** Origins mapped via --asset-base; page-script fetches route to the server. */
|
|
123
|
+
mappedOrigins?: string[];
|
|
116
124
|
/** Delay pagination until the page's own async work finished. */
|
|
117
125
|
settle?: SettleGate | null;
|
|
118
126
|
/** Origin that page-script requests are routed to. */
|
|
@@ -144,6 +152,13 @@ type RuntimeScriptOptions = {
|
|
|
144
152
|
origin: string;
|
|
145
153
|
documentBaseUrl: string;
|
|
146
154
|
gate: SettleGate | null;
|
|
155
|
+
/**
|
|
156
|
+
* Origins mapped via --asset-base. Page scripts fetch data from these
|
|
157
|
+
* (the blog's sparql/graph components fetch their datasets from the site
|
|
158
|
+
* origin); routing them to the static server keeps builds deterministic
|
|
159
|
+
* instead of silently depending on the live site.
|
|
160
|
+
*/
|
|
161
|
+
mappedOrigins?: string[];
|
|
147
162
|
/**
|
|
148
163
|
* Open every `<details>` element. Vivliostyle loads the page's scripts itself
|
|
149
164
|
* and only re-dispatches `DOMContentLoaded` on the window, so scripts that
|
|
@@ -358,7 +373,7 @@ declare function resolveIccProfile(options: Pick<CliOptions, "iccProfile">, labe
|
|
|
358
373
|
* input (HTML meta tags or a publication manifest); the language falls back
|
|
359
374
|
* to "de" when no source provides one.
|
|
360
375
|
*/
|
|
361
|
-
declare function resolvePdfMetadata(options: Pick<CliOptions, "title" | "author" | "subject" | "keywords" | "language" | "created" | "modified">, inputAbs: string, htmlMode: boolean): DocumentMetadata & {
|
|
376
|
+
declare function resolvePdfMetadata(options: Pick<CliOptions, "title" | "author" | "subject" | "keywords" | "doi" | "url" | "language" | "created" | "modified">, inputAbs: string, htmlMode: boolean): DocumentMetadata & {
|
|
362
377
|
language: string;
|
|
363
378
|
};
|
|
364
379
|
declare function execute(options: CliOptions, extraArgs?: string[]): Promise<void>;
|
|
@@ -415,6 +415,15 @@ function buildXmpPacket(fields, label) {
|
|
|
415
415
|
if (fields.keywords !== undefined) {
|
|
416
416
|
properties.push(`<pdf:Keywords>${xmlEscape(fields.keywords)}</pdf:Keywords>`);
|
|
417
417
|
}
|
|
418
|
+
// dc:identifier carries the DOI when one is known — Zotero and friends pick
|
|
419
|
+
// it up on PDF import — otherwise the source URL. The info dictionary has
|
|
420
|
+
// no entry for either, so this is the only place they appear.
|
|
421
|
+
if (fields.doi !== undefined) {
|
|
422
|
+
properties.push(`<dc:identifier>doi:${xmlEscape(fields.doi)}</dc:identifier>`);
|
|
423
|
+
}
|
|
424
|
+
else if (fields.url !== undefined) {
|
|
425
|
+
properties.push(`<dc:identifier>${xmlEscape(fields.url)}</dc:identifier>`);
|
|
426
|
+
}
|
|
418
427
|
if (fields.producer !== undefined) {
|
|
419
428
|
properties.push(`<pdf:Producer>${xmlEscape(fields.producer)}</pdf:Producer>`);
|
|
420
429
|
}
|
|
@@ -665,6 +674,8 @@ async function postProcessPdf(pdf, options) {
|
|
|
665
674
|
author: metadata.author,
|
|
666
675
|
subject: metadata.subject,
|
|
667
676
|
keywords: metadata.keywords,
|
|
677
|
+
doi: metadata.doi,
|
|
678
|
+
url: metadata.url,
|
|
668
679
|
producer: metadata.producer,
|
|
669
680
|
creatorTool: metadata.creator,
|
|
670
681
|
createDate: createDateXmp,
|
|
@@ -1017,6 +1028,8 @@ function pdfMetadata(request) {
|
|
|
1017
1028
|
...(request.author === undefined ? {} : { author: request.author }),
|
|
1018
1029
|
...(request.subject === undefined ? {} : { subject: request.subject }),
|
|
1019
1030
|
...(request.keywords === undefined ? {} : { keywords: request.keywords }),
|
|
1031
|
+
...(request.doi === undefined ? {} : { doi: request.doi }),
|
|
1032
|
+
...(request.url === undefined ? {} : { url: request.url }),
|
|
1020
1033
|
...(request.language === undefined ? {} : { language: request.language }),
|
|
1021
1034
|
...(request.created === undefined ? {} : { created: request.created }),
|
|
1022
1035
|
...(request.modified === undefined ? {} : { modified: request.modified }),
|
|
@@ -1330,14 +1343,33 @@ async function renderPdf(request) {
|
|
|
1330
1343
|
polling: 500
|
|
1331
1344
|
});
|
|
1332
1345
|
if (request.waitForSettle === true) {
|
|
1346
|
+
// The gate image keeps the viewer's document processing pending until
|
|
1347
|
+
// the settle fires; only then does vivliostyle drain the deferred and
|
|
1348
|
+
// module scripts it queued (end-of-document execution) and dispatch
|
|
1349
|
+
// DOMContentLoaded. Pages that depend on those late globals flip
|
|
1350
|
+
// __vivReady after the gate settled, so hold print briefly for them.
|
|
1351
|
+
const POST_SETTLE_READY_GRACE_MS = 2000;
|
|
1352
|
+
let settledAt = -1;
|
|
1333
1353
|
const handle = await page.waitForFunction(() => {
|
|
1334
1354
|
const settleState = window.__vivSettle;
|
|
1335
1355
|
// Pages with mocked/measured async work set __vivReady when painted;
|
|
1336
1356
|
// Vivliostyle re-runs document scripts in the viewer context, so both
|
|
1337
1357
|
// live on the same window the renderer polls here.
|
|
1338
|
-
const
|
|
1339
|
-
if (
|
|
1358
|
+
const readyState = window.__vivReady;
|
|
1359
|
+
if (readyState === true)
|
|
1340
1360
|
return { reason: "ready", at: 0 };
|
|
1361
|
+
// An explicit not-ready beats a settled gate: quietness alone must
|
|
1362
|
+
// not print the pre-paint DOM (async tails emit no network signal).
|
|
1363
|
+
if (readyState === false) {
|
|
1364
|
+
if (settleState?.done === true) {
|
|
1365
|
+
if (settledAt < 0)
|
|
1366
|
+
settledAt = Date.now();
|
|
1367
|
+
if (Date.now() - settledAt >= POST_SETTLE_READY_GRACE_MS) {
|
|
1368
|
+
return { reason: settleState.reason ?? "settled", at: settleState.at ?? 0 };
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
return false;
|
|
1372
|
+
}
|
|
1341
1373
|
return settleState?.done === true ? { reason: settleState.reason ?? "settled", at: settleState.at ?? 0 } : false;
|
|
1342
1374
|
}, { polling: 200, timeout: timeoutMs });
|
|
1343
1375
|
const state = (await handle.jsonValue());
|
|
@@ -1385,7 +1417,8 @@ async function renderPdf(request) {
|
|
|
1385
1417
|
if (request.verapdf === true && request.pdfLabel !== undefined) {
|
|
1386
1418
|
const vera = runVeraPdf(request.output, request.pdfLabel);
|
|
1387
1419
|
if (!vera.ran) {
|
|
1388
|
-
|
|
1420
|
+
throw new Error(`--verapdf was requested, but veraPDF could not be run: ${vera.reason}. ` +
|
|
1421
|
+
"Install veraPDF (https://verapdf.org/, requires Java) or drop --verapdf.");
|
|
1389
1422
|
}
|
|
1390
1423
|
else if (vera.passed !== true) {
|
|
1391
1424
|
throw new Error(`verapdf reports ${describeLabel(request.pdfLabel)} violations (exit ${vera.exitCode ?? "n/a"}):\n${vera.output}`);
|
|
@@ -1437,39 +1470,97 @@ function fileURLOfSelf() {
|
|
|
1437
1470
|
// src/metadata.ts
|
|
1438
1471
|
/** Language tag assumed when no source provides one (project contract). */
|
|
1439
1472
|
const DEFAULT_LANGUAGE = "de";
|
|
1473
|
+
// Bare DOI form (ISO 26324): a directory indicator plus a suffix. Accepts
|
|
1474
|
+
// variants authors hand over: bare, doi: URIs and resolver URLs.
|
|
1475
|
+
const DOI_PATTERN = /^10\.\d{4,9}\/\S+$/;
|
|
1476
|
+
/**
|
|
1477
|
+
* Normalizes a DOI the user supplied: resolver URLs (`https://doi.org/…`,
|
|
1478
|
+
* `http://dx.doi.org/…`, `https://hdl.handle.net/…` keeps `10.` handles) and
|
|
1479
|
+
* `doi:` URIs reduce to the bare form, which is validated against ISO 26324.
|
|
1480
|
+
* Returns undefined when the value is not a DOI at all.
|
|
1481
|
+
*/
|
|
1482
|
+
function normalizeDoi(value) {
|
|
1483
|
+
let doi = value.trim();
|
|
1484
|
+
for (const prefix of ["https://doi.org/", "http://doi.org/", "https://dx.doi.org/", "http://dx.doi.org/", "doi:"]) {
|
|
1485
|
+
if (doi.toLowerCase().startsWith(prefix.toLowerCase())) {
|
|
1486
|
+
doi = doi.slice(prefix.length);
|
|
1487
|
+
break;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
doi = doi.trim();
|
|
1491
|
+
if (!DOI_PATTERN.test(doi))
|
|
1492
|
+
return undefined;
|
|
1493
|
+
return doi;
|
|
1494
|
+
}
|
|
1495
|
+
/** Reads a DOI from a meta content, ignoring values that are not DOIs. */
|
|
1496
|
+
function doiMetaContent(names, document) {
|
|
1497
|
+
const content = metaContentOf(names, document);
|
|
1498
|
+
return content === undefined ? undefined : normalizeDoi(content);
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Extracts a document URL: the canonical link wins, then the usual
|
|
1502
|
+
* URL meta tags. Only absolute http(s) URLs are accepted.
|
|
1503
|
+
*/
|
|
1504
|
+
function extractDocumentUrl(document) {
|
|
1505
|
+
const candidates = [
|
|
1506
|
+
document.querySelector('link[rel="canonical" i]')?.getAttribute("href"),
|
|
1507
|
+
document.querySelector('meta[property="og:url" i]')?.getAttribute("content"),
|
|
1508
|
+
document.querySelector('meta[name="citation_url" i]')?.getAttribute("content"),
|
|
1509
|
+
document.querySelector('meta[name="dc.url" i]')?.getAttribute("content")
|
|
1510
|
+
];
|
|
1511
|
+
for (const candidate of candidates) {
|
|
1512
|
+
const url = candidate?.trim();
|
|
1513
|
+
if (url === undefined || url === "")
|
|
1514
|
+
continue;
|
|
1515
|
+
let parsed;
|
|
1516
|
+
try {
|
|
1517
|
+
parsed = new URL(url);
|
|
1518
|
+
}
|
|
1519
|
+
catch {
|
|
1520
|
+
continue;
|
|
1521
|
+
}
|
|
1522
|
+
if (parsed.protocol === "http:" || parsed.protocol === "https:")
|
|
1523
|
+
return url;
|
|
1524
|
+
}
|
|
1525
|
+
return undefined;
|
|
1526
|
+
}
|
|
1527
|
+
/** First non-empty `content` of the named meta tags (name or http-equiv). */
|
|
1528
|
+
function metaContentOf(names, document) {
|
|
1529
|
+
for (const name of names) {
|
|
1530
|
+
const element = document.querySelector(`meta[name="${name}" i]`) ?? document.querySelector(`meta[http-equiv="${name}" i]`);
|
|
1531
|
+
const content = element?.getAttribute("content")?.trim();
|
|
1532
|
+
if (content !== undefined && content !== "")
|
|
1533
|
+
return content;
|
|
1534
|
+
}
|
|
1535
|
+
return undefined;
|
|
1536
|
+
}
|
|
1440
1537
|
/**
|
|
1441
1538
|
* Extracts metadata from the input document: <title>, the usual
|
|
1442
|
-
* author/description/keywords meta tags, the
|
|
1443
|
-
*
|
|
1444
|
-
*
|
|
1539
|
+
* author/description/keywords meta tags, the DOI (citation_doi, dc.doi,
|
|
1540
|
+
* dc.identifier when it holds a DOI), the document URL (canonical link,
|
|
1541
|
+
* og:url), the creation/modification dates (dcterms, falling back to the
|
|
1542
|
+
* plain date meta tag) and the document language.
|
|
1445
1543
|
*/
|
|
1446
1544
|
function extractMetadataFromDocument(document) {
|
|
1447
1545
|
const title = document.querySelector("title")?.textContent?.trim();
|
|
1448
|
-
const metaContent = (names) => {
|
|
1449
|
-
for (const name of names) {
|
|
1450
|
-
const element = document.querySelector(`meta[name="${name}" i]`) ?? document.querySelector(`meta[http-equiv="${name}" i]`);
|
|
1451
|
-
const content = element?.getAttribute("content")?.trim();
|
|
1452
|
-
if (content !== undefined && content !== "")
|
|
1453
|
-
return content;
|
|
1454
|
-
}
|
|
1455
|
-
return undefined;
|
|
1456
|
-
};
|
|
1457
1546
|
return {
|
|
1458
1547
|
...(title === undefined || title === "" ? {} : { title }),
|
|
1459
|
-
...optional(
|
|
1460
|
-
...optional(
|
|
1461
|
-
...optional(
|
|
1462
|
-
...optional(
|
|
1463
|
-
...optional(
|
|
1464
|
-
...optional(
|
|
1548
|
+
...optional(metaContentOf(["author", "dc.creator", "dcterms.creator"], document), (value) => ({ author: value })),
|
|
1549
|
+
...optional(metaContentOf(["description", "dc.description"], document), (value) => ({ subject: value })),
|
|
1550
|
+
...optional(metaContentOf(["keywords"], document), (value) => ({ keywords: value })),
|
|
1551
|
+
...optional(doiMetaContent(["citation_doi", "dc.doi", "dc.identifier", "doi"], document), (value) => ({ doi: value })),
|
|
1552
|
+
...optional(extractDocumentUrl(document), (value) => ({ url: value })),
|
|
1553
|
+
...optional(metaContentOf(["dcterms.created", "dc.date", "date"], document), (value) => ({ created: value })),
|
|
1554
|
+
...optional(metaContentOf(["dcterms.modified", "dc.date.modified", "modified"], document), (value) => ({ modified: value })),
|
|
1555
|
+
...optional(document.documentElement.getAttribute("lang")?.trim() || metaContentOf(["content-language"], document), (value) => ({
|
|
1465
1556
|
language: value
|
|
1466
1557
|
}))
|
|
1467
1558
|
};
|
|
1468
1559
|
}
|
|
1469
1560
|
/**
|
|
1470
1561
|
* Extracts metadata from a publication manifest (W3C Web Publication
|
|
1471
|
-
* Manifest shape): title, author, description, keywords and
|
|
1472
|
-
* Returns undefined when the text is not a JSON object.
|
|
1562
|
+
* Manifest shape): title, author, description, keywords, DOI, URL and
|
|
1563
|
+
* language. Returns undefined when the text is not a JSON object.
|
|
1473
1564
|
*/
|
|
1474
1565
|
function extractMetadataFromManifest(text) {
|
|
1475
1566
|
let manifest;
|
|
@@ -1487,6 +1578,8 @@ function extractMetadataFromManifest(text) {
|
|
|
1487
1578
|
...optional(asAuthorList(record.author), (value) => ({ author: value })),
|
|
1488
1579
|
...optional(asString(record.description), (value) => ({ subject: value })),
|
|
1489
1580
|
...optional(asStringList(record.keywords, ", "), (value) => ({ keywords: value })),
|
|
1581
|
+
...optional(asDoi(record.doi ?? record.identifier), (value) => ({ doi: value })),
|
|
1582
|
+
...optional(asUrl(record.url), (value) => ({ url: value })),
|
|
1490
1583
|
...optional(asStringList(record.language ?? record.inLanguage, " "), (value) => ({ language: value }))
|
|
1491
1584
|
};
|
|
1492
1585
|
}
|
|
@@ -1543,6 +1636,27 @@ function optional(value, wrap) {
|
|
|
1543
1636
|
function asString(value) {
|
|
1544
1637
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
|
|
1545
1638
|
}
|
|
1639
|
+
/** Reads a DOI from a manifest value; non-DOI identifiers are ignored. */
|
|
1640
|
+
function asDoi(value) {
|
|
1641
|
+
if (typeof value !== "string")
|
|
1642
|
+
return undefined;
|
|
1643
|
+
return normalizeDoi(value);
|
|
1644
|
+
}
|
|
1645
|
+
/** Reads a http(s) URL from a manifest value; relative links are ignored. */
|
|
1646
|
+
function asUrl(value) {
|
|
1647
|
+
if (typeof value !== "string")
|
|
1648
|
+
return undefined;
|
|
1649
|
+
const url = value.trim();
|
|
1650
|
+
try {
|
|
1651
|
+
const parsed = new URL(url);
|
|
1652
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
1653
|
+
return undefined;
|
|
1654
|
+
}
|
|
1655
|
+
catch {
|
|
1656
|
+
return undefined;
|
|
1657
|
+
}
|
|
1658
|
+
return url;
|
|
1659
|
+
}
|
|
1546
1660
|
/** Flattens string | {name} | ({name} | string)[] into "a; b" form. */
|
|
1547
1661
|
function asAuthorList(value) {
|
|
1548
1662
|
const names = Array.isArray(value) ? value : [value];
|
|
@@ -1661,11 +1775,12 @@ function buildSettleGateImage(origin) {
|
|
|
1661
1775
|
function buildRuntimeScript(options) {
|
|
1662
1776
|
const { origin, documentBaseUrl, gate } = options;
|
|
1663
1777
|
const expandDetails = options.expandDetails === true ? EXPAND_DETAILS_SNIPPET : "";
|
|
1778
|
+
const mappedOrigins = JSON.stringify(options.mappedOrigins ?? []);
|
|
1664
1779
|
// Vivliostyle paginates incrementally, so collapsed content has to be opened
|
|
1665
1780
|
// again while it lays the document out, not just once up front.
|
|
1666
1781
|
const expandDetailsTick = options.expandDetails === true ? "expandDetails(document);" : "";
|
|
1667
1782
|
return `(function(){
|
|
1668
|
-
var ORIGIN=${JSON.stringify(origin)},BASE=${JSON.stringify(documentBaseUrl)};
|
|
1783
|
+
var ORIGIN=${JSON.stringify(origin)},BASE=${JSON.stringify(documentBaseUrl)},MAPPED_ORIGINS=${mappedOrigins};
|
|
1669
1784
|
var QUIET=${gate?.quietMs ?? 400},DEADLINE=${gate?.deadlineMs ?? 10000},FRAME_GRACE=3000;
|
|
1670
1785
|
var pending=0,frames=0,last=0,mutations=0,done=false,longtasks=0;
|
|
1671
1786
|
// Force preserveDrawingBuffer on every WebGL context the page creates:
|
|
@@ -1706,7 +1821,13 @@ var state=window.__vivSettle={done:false,reason:null,at:0,pending:0,frames:0,mut
|
|
|
1706
1821
|
function fix(u){
|
|
1707
1822
|
if(typeof u!=="string"||u==="")return u;
|
|
1708
1823
|
if(u.slice(0,2)==="//"||u.charAt(0)==="#"||u.charAt(0)==="?")return u;
|
|
1709
|
-
if(/^[a-z][a-z0-9+.-]*:/i.test(u))
|
|
1824
|
+
if(/^[a-z][a-z0-9+.-]*:/i.test(u)){
|
|
1825
|
+
try{
|
|
1826
|
+
var mu=new URL(u);
|
|
1827
|
+
if(MAPPED_ORIGINS.indexOf(mu.origin)>=0)return ORIGIN+mu.pathname+mu.search+mu.hash;
|
|
1828
|
+
}catch(e){}
|
|
1829
|
+
return u;
|
|
1830
|
+
}
|
|
1710
1831
|
return u.charAt(0)==="/"?ORIGIN+u:BASE+u;
|
|
1711
1832
|
}
|
|
1712
1833
|
|
|
@@ -1824,6 +1945,10 @@ last=performance.now();
|
|
|
1824
1945
|
// Deterministic pages (charts, WebGL, OSD fixtures) set __vivReady when
|
|
1825
1946
|
// painted instead of making the gate guess from network quietness. Shader
|
|
1826
1947
|
// compile and tile decode finish after the last fetch, so readiness wins.
|
|
1948
|
+
// An explicit __vivReady=false holds the quiet path too: async tails (module
|
|
1949
|
+
// imports, wasm, deferred timers) emit no network signal, so quietness alone
|
|
1950
|
+
// would settle on the pre-paint DOM. The deadline above still bounds it.
|
|
1951
|
+
if(window.__vivReady===false){setTimeout(check,50);return;}
|
|
1827
1952
|
if(window.__vivReady===true&&pending===0&&frames===0){signal("ready");return;}
|
|
1828
1953
|
if(pending===0&&frames===0&&now-last>=QUIET){signal("quiet");return;}
|
|
1829
1954
|
setTimeout(check,50);
|
|
@@ -2450,7 +2575,13 @@ function prepareInputHtmlForBuild(inputAbs, assetBases, staticMap, serverBaseUrl
|
|
|
2450
2575
|
const origin = options.shimOrigin ?? serverBaseUrl;
|
|
2451
2576
|
const documentBaseUrl = options.documentBaseUrl ?? `${origin}/`;
|
|
2452
2577
|
// Only the PDF run expands `<details>`; the preview stays interactive.
|
|
2453
|
-
injectRuntimeScriptInDom(document, {
|
|
2578
|
+
injectRuntimeScriptInDom(document, {
|
|
2579
|
+
origin,
|
|
2580
|
+
documentBaseUrl,
|
|
2581
|
+
gate: options.settle ?? null,
|
|
2582
|
+
mappedOrigins: options.mappedOrigins ?? [],
|
|
2583
|
+
expandDetails: true
|
|
2584
|
+
});
|
|
2454
2585
|
log.trace("prepareInputHtmlForBuild: injected runtime script", { origin, documentBaseUrl, gate: options.settle });
|
|
2455
2586
|
}
|
|
2456
2587
|
if (!absChanged &&
|
|
@@ -2718,6 +2849,8 @@ function buildProgram() {
|
|
|
2718
2849
|
.option("--author <author>", "Document author")
|
|
2719
2850
|
.option("--subject <subject>", "Document subject (e.g. the page's description meta tag content)")
|
|
2720
2851
|
.option("--keywords <keywords>", "Document keywords, comma separated")
|
|
2852
|
+
.option("--doi <doi>", "Document DOI (bare, doi: URI or doi.org URL). Wins over --url for the XMP identifier")
|
|
2853
|
+
.option("--url <url>", "Document URL; XMP dc:identifier when no DOI is set (reference managers read it)")
|
|
2721
2854
|
.option("--language <lang>", "Document language tag (e.g. en, de, ja). Taken from the document or manifest when omitted, falling back to 'de'")
|
|
2722
2855
|
.option("--created <date>", "Document creation date (ISO 8601, e.g. 2024-11-18T00:00:00+01:00). Taken from the document's dcterms.created meta tag when omitted")
|
|
2723
2856
|
.option("--modified <date>", "Document modification date (ISO 8601). Taken from the document's dcterms.modified meta tag when omitted")
|
|
@@ -2823,7 +2956,7 @@ function buildProgram() {
|
|
|
2823
2956
|
" • the browser prints that page to PDF, so canvases and iframes stay real content.",
|
|
2824
2957
|
" • Collapsed <details> content is opened for the PDF; the preview keeps the page as it is.",
|
|
2825
2958
|
" • --asset-base localBase is also a fallback root for CSS-referenced assets.",
|
|
2826
|
-
" • PDF metadata (--title/--author/--subject/--keywords/--language/--created/--modified)",
|
|
2959
|
+
" • PDF metadata (--title/--author/--subject/--keywords/--doi/--url/--language/--created/--modified)",
|
|
2827
2960
|
" • values read from the document or the publication manifest; language falls",
|
|
2828
2961
|
" • back to 'de'. --pdfa/--pdfx label the output; the built-in validation",
|
|
2829
2962
|
" • checks the practical subset (--no-validate skips it) and --verapdf runs",
|
|
@@ -2864,6 +2997,8 @@ async function runRender(params) {
|
|
|
2864
2997
|
...(params.metaFields.author === undefined ? {} : { author: params.metaFields.author }),
|
|
2865
2998
|
...(params.metaFields.subject === undefined ? {} : { subject: params.metaFields.subject }),
|
|
2866
2999
|
...(params.metaFields.keywords === undefined ? {} : { keywords: params.metaFields.keywords }),
|
|
3000
|
+
...(params.metaFields.doi === undefined ? {} : { doi: params.metaFields.doi }),
|
|
3001
|
+
...(params.metaFields.url === undefined ? {} : { url: params.metaFields.url }),
|
|
2867
3002
|
...(params.metaFields.language === undefined ? {} : { language: params.metaFields.language }),
|
|
2868
3003
|
...(params.metaFields.created === undefined ? {} : { created: params.metaFields.created }),
|
|
2869
3004
|
...(params.metaFields.modified === undefined ? {} : { modified: params.metaFields.modified }),
|
|
@@ -2981,10 +3116,19 @@ function resolvePdfMetadata(options, inputAbs, htmlMode) {
|
|
|
2981
3116
|
"author",
|
|
2982
3117
|
"subject",
|
|
2983
3118
|
"keywords",
|
|
3119
|
+
"doi",
|
|
3120
|
+
"url",
|
|
2984
3121
|
"language",
|
|
2985
3122
|
"created",
|
|
2986
3123
|
"modified"
|
|
2987
3124
|
]);
|
|
3125
|
+
if (cliFields.doi !== undefined) {
|
|
3126
|
+
const normalized = normalizeDoi(cliFields.doi);
|
|
3127
|
+
if (normalized === undefined) {
|
|
3128
|
+
throw new Error(`--doi is not a DOI: "${cliFields.doi}". Use the bare form (10.xxxx/…), a doi: URI or a doi.org URL`);
|
|
3129
|
+
}
|
|
3130
|
+
cliFields.doi = normalized;
|
|
3131
|
+
}
|
|
2988
3132
|
let derived;
|
|
2989
3133
|
if (htmlMode) {
|
|
2990
3134
|
derived = extractMetadataFromDocument(new JSDOM(readFileSync(inputAbs, "utf-8")).window.document);
|
|
@@ -3085,6 +3229,9 @@ async function execute(options, extraArgs = []) {
|
|
|
3085
3229
|
if (options.iccProfile !== undefined && pdfLabel === undefined) {
|
|
3086
3230
|
log.warn("[pdf] --icc-profile has no effect without --pdfa or --pdfx");
|
|
3087
3231
|
}
|
|
3232
|
+
if (options.verapdf === true && pdfLabel === undefined) {
|
|
3233
|
+
log.warn("[pdf] --verapdf has no effect without --pdfa or --pdfx");
|
|
3234
|
+
}
|
|
3088
3235
|
const iccProfile = resolveIccProfile(options, pdfLabel);
|
|
3089
3236
|
const fetchMissing = options.fetchMissing === true || options.allowRemote === true;
|
|
3090
3237
|
// The wait arms automatically on script-driven pages: without it, charts,
|
|
@@ -3098,6 +3245,10 @@ async function execute(options, extraArgs = []) {
|
|
|
3098
3245
|
fetchMissing,
|
|
3099
3246
|
dumpDir: options.dumpHtml ?? null,
|
|
3100
3247
|
settle,
|
|
3248
|
+
// Page scripts fetch their data from the mapped origins (the blog's
|
|
3249
|
+
// sparql/graph components); route those to the static server so builds
|
|
3250
|
+
// stay deterministic instead of hitting the live site.
|
|
3251
|
+
mappedOrigins: [...new Set(assetBases.map((base) => new URL(base.urlBase).origin))],
|
|
3101
3252
|
...(typeof extraConfig.css === "string" ? { css: extraConfig.css } : {}),
|
|
3102
3253
|
...(typeof extraConfig.userStyle === "string" ? { userStyle: extraConfig.userStyle } : {})
|
|
3103
3254
|
};
|
package/package.json
CHANGED
package/src/metadata.ts
CHANGED
|
@@ -21,6 +21,10 @@ export type DocumentMetadata = {
|
|
|
21
21
|
author?: string;
|
|
22
22
|
subject?: string;
|
|
23
23
|
keywords?: string;
|
|
24
|
+
/** Normalized bare DOI (10.…/…); reference managers read it as dc:identifier. */
|
|
25
|
+
doi?: string;
|
|
26
|
+
/** Source URL of the document, used as dc:identifier when no DOI is known. */
|
|
27
|
+
url?: string;
|
|
24
28
|
language?: string;
|
|
25
29
|
/** ISO 8601 creation date (information dictionary and XMP CreateDate). */
|
|
26
30
|
created?: string;
|
|
@@ -31,30 +35,89 @@ export type DocumentMetadata = {
|
|
|
31
35
|
/** Language tag assumed when no source provides one (project contract). */
|
|
32
36
|
export const DEFAULT_LANGUAGE = "de";
|
|
33
37
|
|
|
38
|
+
// Bare DOI form (ISO 26324): a directory indicator plus a suffix. Accepts
|
|
39
|
+
// variants authors hand over: bare, doi: URIs and resolver URLs.
|
|
40
|
+
export const DOI_PATTERN = /^10\.\d{4,9}\/\S+$/;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Normalizes a DOI the user supplied: resolver URLs (`https://doi.org/…`,
|
|
44
|
+
* `http://dx.doi.org/…`, `https://hdl.handle.net/…` keeps `10.` handles) and
|
|
45
|
+
* `doi:` URIs reduce to the bare form, which is validated against ISO 26324.
|
|
46
|
+
* Returns undefined when the value is not a DOI at all.
|
|
47
|
+
*/
|
|
48
|
+
export function normalizeDoi(value: string): string | undefined {
|
|
49
|
+
let doi = value.trim();
|
|
50
|
+
for (const prefix of ["https://doi.org/", "http://doi.org/", "https://dx.doi.org/", "http://dx.doi.org/", "doi:"]) {
|
|
51
|
+
if (doi.toLowerCase().startsWith(prefix.toLowerCase())) {
|
|
52
|
+
doi = doi.slice(prefix.length);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
doi = doi.trim();
|
|
57
|
+
if (!DOI_PATTERN.test(doi)) return undefined;
|
|
58
|
+
return doi;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Reads a DOI from a meta content, ignoring values that are not DOIs. */
|
|
62
|
+
function doiMetaContent(names: readonly string[], document: Document): string | undefined {
|
|
63
|
+
const content = metaContentOf(names, document);
|
|
64
|
+
return content === undefined ? undefined : normalizeDoi(content);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Extracts a document URL: the canonical link wins, then the usual
|
|
69
|
+
* URL meta tags. Only absolute http(s) URLs are accepted.
|
|
70
|
+
*/
|
|
71
|
+
function extractDocumentUrl(document: Document): string | undefined {
|
|
72
|
+
const candidates: Array<string | null | undefined> = [
|
|
73
|
+
document.querySelector('link[rel="canonical" i]')?.getAttribute("href"),
|
|
74
|
+
document.querySelector('meta[property="og:url" i]')?.getAttribute("content"),
|
|
75
|
+
document.querySelector('meta[name="citation_url" i]')?.getAttribute("content"),
|
|
76
|
+
document.querySelector('meta[name="dc.url" i]')?.getAttribute("content")
|
|
77
|
+
];
|
|
78
|
+
for (const candidate of candidates) {
|
|
79
|
+
const url = candidate?.trim();
|
|
80
|
+
if (url === undefined || url === "") continue;
|
|
81
|
+
let parsed: URL;
|
|
82
|
+
try {
|
|
83
|
+
parsed = new URL(url);
|
|
84
|
+
} catch {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (parsed.protocol === "http:" || parsed.protocol === "https:") return url;
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** First non-empty `content` of the named meta tags (name or http-equiv). */
|
|
93
|
+
function metaContentOf(names: readonly string[], document: Document): string | undefined {
|
|
94
|
+
for (const name of names) {
|
|
95
|
+
const element = document.querySelector(`meta[name="${name}" i]`) ?? document.querySelector(`meta[http-equiv="${name}" i]`);
|
|
96
|
+
const content = element?.getAttribute("content")?.trim();
|
|
97
|
+
if (content !== undefined && content !== "") return content;
|
|
98
|
+
}
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
|
|
34
102
|
/**
|
|
35
103
|
* Extracts metadata from the input document: <title>, the usual
|
|
36
|
-
* author/description/keywords meta tags, the
|
|
37
|
-
*
|
|
38
|
-
*
|
|
104
|
+
* author/description/keywords meta tags, the DOI (citation_doi, dc.doi,
|
|
105
|
+
* dc.identifier when it holds a DOI), the document URL (canonical link,
|
|
106
|
+
* og:url), the creation/modification dates (dcterms, falling back to the
|
|
107
|
+
* plain date meta tag) and the document language.
|
|
39
108
|
*/
|
|
40
109
|
export function extractMetadataFromDocument(document: Document): DocumentMetadata {
|
|
41
110
|
const title = document.querySelector("title")?.textContent?.trim();
|
|
42
|
-
const metaContent = (names: readonly string[]): string | undefined => {
|
|
43
|
-
for (const name of names) {
|
|
44
|
-
const element = document.querySelector(`meta[name="${name}" i]`) ?? document.querySelector(`meta[http-equiv="${name}" i]`);
|
|
45
|
-
const content = element?.getAttribute("content")?.trim();
|
|
46
|
-
if (content !== undefined && content !== "") return content;
|
|
47
|
-
}
|
|
48
|
-
return undefined;
|
|
49
|
-
};
|
|
50
111
|
return {
|
|
51
112
|
...(title === undefined || title === "" ? {} : { title }),
|
|
52
|
-
...optional(
|
|
53
|
-
...optional(
|
|
54
|
-
...optional(
|
|
55
|
-
...optional(
|
|
56
|
-
...optional(
|
|
57
|
-
...optional(
|
|
113
|
+
...optional(metaContentOf(["author", "dc.creator", "dcterms.creator"], document), (value) => ({ author: value })),
|
|
114
|
+
...optional(metaContentOf(["description", "dc.description"], document), (value) => ({ subject: value })),
|
|
115
|
+
...optional(metaContentOf(["keywords"], document), (value) => ({ keywords: value })),
|
|
116
|
+
...optional(doiMetaContent(["citation_doi", "dc.doi", "dc.identifier", "doi"], document), (value) => ({ doi: value })),
|
|
117
|
+
...optional(extractDocumentUrl(document), (value) => ({ url: value })),
|
|
118
|
+
...optional(metaContentOf(["dcterms.created", "dc.date", "date"], document), (value) => ({ created: value })),
|
|
119
|
+
...optional(metaContentOf(["dcterms.modified", "dc.date.modified", "modified"], document), (value) => ({ modified: value })),
|
|
120
|
+
...optional(document.documentElement.getAttribute("lang")?.trim() || metaContentOf(["content-language"], document), (value) => ({
|
|
58
121
|
language: value
|
|
59
122
|
}))
|
|
60
123
|
};
|
|
@@ -62,8 +125,8 @@ export function extractMetadataFromDocument(document: Document): DocumentMetadat
|
|
|
62
125
|
|
|
63
126
|
/**
|
|
64
127
|
* Extracts metadata from a publication manifest (W3C Web Publication
|
|
65
|
-
* Manifest shape): title, author, description, keywords and
|
|
66
|
-
* Returns undefined when the text is not a JSON object.
|
|
128
|
+
* Manifest shape): title, author, description, keywords, DOI, URL and
|
|
129
|
+
* language. Returns undefined when the text is not a JSON object.
|
|
67
130
|
*/
|
|
68
131
|
export function extractMetadataFromManifest(text: string): DocumentMetadata | undefined {
|
|
69
132
|
let manifest: unknown;
|
|
@@ -79,6 +142,8 @@ export function extractMetadataFromManifest(text: string): DocumentMetadata | un
|
|
|
79
142
|
...optional(asAuthorList(record.author), (value) => ({ author: value })),
|
|
80
143
|
...optional(asString(record.description), (value) => ({ subject: value })),
|
|
81
144
|
...optional(asStringList(record.keywords, ", "), (value) => ({ keywords: value })),
|
|
145
|
+
...optional(asDoi(record.doi ?? record.identifier), (value) => ({ doi: value })),
|
|
146
|
+
...optional(asUrl(record.url), (value) => ({ url: value })),
|
|
82
147
|
...optional(asStringList(record.language ?? record.inLanguage, " "), (value) => ({ language: value }))
|
|
83
148
|
};
|
|
84
149
|
}
|
|
@@ -140,6 +205,25 @@ function asString(value: unknown): string | undefined {
|
|
|
140
205
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
|
|
141
206
|
}
|
|
142
207
|
|
|
208
|
+
/** Reads a DOI from a manifest value; non-DOI identifiers are ignored. */
|
|
209
|
+
function asDoi(value: unknown): string | undefined {
|
|
210
|
+
if (typeof value !== "string") return undefined;
|
|
211
|
+
return normalizeDoi(value);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Reads a http(s) URL from a manifest value; relative links are ignored. */
|
|
215
|
+
function asUrl(value: unknown): string | undefined {
|
|
216
|
+
if (typeof value !== "string") return undefined;
|
|
217
|
+
const url = value.trim();
|
|
218
|
+
try {
|
|
219
|
+
const parsed = new URL(url);
|
|
220
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return undefined;
|
|
221
|
+
} catch {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
return url;
|
|
225
|
+
}
|
|
226
|
+
|
|
143
227
|
/** Flattens string | {name} | ({name} | string)[] into "a; b" form. */
|
|
144
228
|
function asAuthorList(value: unknown): string | undefined {
|
|
145
229
|
const names = Array.isArray(value) ? value : [value];
|
|
@@ -35,6 +35,10 @@ export type PdfMetadata = {
|
|
|
35
35
|
author?: string;
|
|
36
36
|
subject?: string;
|
|
37
37
|
keywords?: string;
|
|
38
|
+
/** Bare DOI; wins over url for the XMP dc:identifier. */
|
|
39
|
+
doi?: string;
|
|
40
|
+
/** Source URL; dc:identifier when no DOI is set. */
|
|
41
|
+
url?: string;
|
|
38
42
|
language?: string;
|
|
39
43
|
/** ISO 8601 or PDF date; overrides the creation date the print backend wrote. */
|
|
40
44
|
created?: string;
|
|
@@ -251,6 +255,8 @@ export async function postProcessPdf(pdf: Uint8Array, options: PostProcessOption
|
|
|
251
255
|
author: metadata.author,
|
|
252
256
|
subject: metadata.subject,
|
|
253
257
|
keywords: metadata.keywords,
|
|
258
|
+
doi: metadata.doi,
|
|
259
|
+
url: metadata.url,
|
|
254
260
|
producer: metadata.producer,
|
|
255
261
|
creatorTool: metadata.creator,
|
|
256
262
|
createDate: createDateXmp,
|
package/src/render/pdf.ts
CHANGED
|
@@ -53,6 +53,8 @@ export type RenderPdfRequest = {
|
|
|
53
53
|
author?: string;
|
|
54
54
|
subject?: string;
|
|
55
55
|
keywords?: string;
|
|
56
|
+
doi?: string;
|
|
57
|
+
url?: string;
|
|
56
58
|
language?: string;
|
|
57
59
|
/** ISO 8601 creation date; overrides the one the print backend wrote. */
|
|
58
60
|
created?: string;
|
|
@@ -101,6 +103,8 @@ function pdfMetadata(request: RenderPdfRequest) {
|
|
|
101
103
|
...(request.author === undefined ? {} : { author: request.author }),
|
|
102
104
|
...(request.subject === undefined ? {} : { subject: request.subject }),
|
|
103
105
|
...(request.keywords === undefined ? {} : { keywords: request.keywords }),
|
|
106
|
+
...(request.doi === undefined ? {} : { doi: request.doi }),
|
|
107
|
+
...(request.url === undefined ? {} : { url: request.url }),
|
|
104
108
|
...(request.language === undefined ? {} : { language: request.language }),
|
|
105
109
|
...(request.created === undefined ? {} : { created: request.created }),
|
|
106
110
|
...(request.modified === undefined ? {} : { modified: request.modified }),
|
|
@@ -458,14 +462,32 @@ export async function renderPdf(request: RenderPdfRequest): Promise<RenderPdfRes
|
|
|
458
462
|
});
|
|
459
463
|
|
|
460
464
|
if (request.waitForSettle === true) {
|
|
465
|
+
// The gate image keeps the viewer's document processing pending until
|
|
466
|
+
// the settle fires; only then does vivliostyle drain the deferred and
|
|
467
|
+
// module scripts it queued (end-of-document execution) and dispatch
|
|
468
|
+
// DOMContentLoaded. Pages that depend on those late globals flip
|
|
469
|
+
// __vivReady after the gate settled, so hold print briefly for them.
|
|
470
|
+
const POST_SETTLE_READY_GRACE_MS = 2000;
|
|
471
|
+
let settledAt = -1;
|
|
461
472
|
const handle = await page.waitForFunction(
|
|
462
473
|
() => {
|
|
463
474
|
const settleState = (window as { __vivSettle?: { done?: boolean; reason?: string; at?: number } }).__vivSettle;
|
|
464
475
|
// Pages with mocked/measured async work set __vivReady when painted;
|
|
465
476
|
// Vivliostyle re-runs document scripts in the viewer context, so both
|
|
466
477
|
// live on the same window the renderer polls here.
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
478
|
+
const readyState = (window as { __vivReady?: boolean }).__vivReady;
|
|
479
|
+
if (readyState === true) return { reason: "ready", at: 0 };
|
|
480
|
+
// An explicit not-ready beats a settled gate: quietness alone must
|
|
481
|
+
// not print the pre-paint DOM (async tails emit no network signal).
|
|
482
|
+
if (readyState === false) {
|
|
483
|
+
if (settleState?.done === true) {
|
|
484
|
+
if (settledAt < 0) settledAt = Date.now();
|
|
485
|
+
if (Date.now() - settledAt >= POST_SETTLE_READY_GRACE_MS) {
|
|
486
|
+
return { reason: settleState.reason ?? "settled", at: settleState.at ?? 0 };
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
469
491
|
return settleState?.done === true ? { reason: settleState.reason ?? "settled", at: settleState.at ?? 0 } : false;
|
|
470
492
|
},
|
|
471
493
|
{ polling: 200, timeout: timeoutMs }
|
|
@@ -520,7 +542,10 @@ export async function renderPdf(request: RenderPdfRequest): Promise<RenderPdfRes
|
|
|
520
542
|
if (request.verapdf === true && request.pdfLabel !== undefined) {
|
|
521
543
|
const vera = runVeraPdf(request.output, request.pdfLabel);
|
|
522
544
|
if (!vera.ran) {
|
|
523
|
-
|
|
545
|
+
throw new Error(
|
|
546
|
+
`--verapdf was requested, but veraPDF could not be run: ${vera.reason}. ` +
|
|
547
|
+
"Install veraPDF (https://verapdf.org/, requires Java) or drop --verapdf."
|
|
548
|
+
);
|
|
524
549
|
} else if (vera.passed !== true) {
|
|
525
550
|
throw new Error(`verapdf reports ${describeLabel(request.pdfLabel)} violations (exit ${vera.exitCode ?? "n/a"}):\n${vera.output}`);
|
|
526
551
|
} else {
|
package/src/render/xmp.ts
CHANGED
|
@@ -45,6 +45,10 @@ export type XmpFields = {
|
|
|
45
45
|
author?: string;
|
|
46
46
|
subject?: string;
|
|
47
47
|
keywords?: string;
|
|
48
|
+
/** Bare DOI; wins over url for dc:identifier (what reference managers read). */
|
|
49
|
+
doi?: string;
|
|
50
|
+
/** Source URL; used as dc:identifier only when no DOI is set. */
|
|
51
|
+
url?: string;
|
|
48
52
|
producer?: string;
|
|
49
53
|
creatorTool?: string;
|
|
50
54
|
/** XMP dates (YYYY-MM-DDThh:mm:ssTZD, XMP Part 1, 8.2.1.2). */
|
|
@@ -143,6 +147,14 @@ export function buildXmpPacket(fields: XmpFields, label?: PdfLabel): string {
|
|
|
143
147
|
if (fields.keywords !== undefined) {
|
|
144
148
|
properties.push(`<pdf:Keywords>${xmlEscape(fields.keywords)}</pdf:Keywords>`);
|
|
145
149
|
}
|
|
150
|
+
// dc:identifier carries the DOI when one is known — Zotero and friends pick
|
|
151
|
+
// it up on PDF import — otherwise the source URL. The info dictionary has
|
|
152
|
+
// no entry for either, so this is the only place they appear.
|
|
153
|
+
if (fields.doi !== undefined) {
|
|
154
|
+
properties.push(`<dc:identifier>doi:${xmlEscape(fields.doi)}</dc:identifier>`);
|
|
155
|
+
} else if (fields.url !== undefined) {
|
|
156
|
+
properties.push(`<dc:identifier>${xmlEscape(fields.url)}</dc:identifier>`);
|
|
157
|
+
}
|
|
146
158
|
if (fields.producer !== undefined) {
|
|
147
159
|
properties.push(`<pdf:Producer>${xmlEscape(fields.producer)}</pdf:Producer>`);
|
|
148
160
|
}
|
package/src/vivliostyle-cli.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { loadDefaultIccProfile } from "./render/pdf-postprocess.js";
|
|
|
17
17
|
import {
|
|
18
18
|
extractMetadataFromDocument,
|
|
19
19
|
extractMetadataFromManifest,
|
|
20
|
+
normalizeDoi,
|
|
20
21
|
parsePdfaLabel,
|
|
21
22
|
parsePdfxLabel,
|
|
22
23
|
resolveMetadata,
|
|
@@ -35,6 +36,8 @@ type CliOptions = {
|
|
|
35
36
|
author?: string;
|
|
36
37
|
subject?: string;
|
|
37
38
|
keywords?: string;
|
|
39
|
+
doi?: string;
|
|
40
|
+
url?: string;
|
|
38
41
|
language?: string;
|
|
39
42
|
created?: string;
|
|
40
43
|
modified?: string;
|
|
@@ -72,6 +75,8 @@ export type HtmlRewriteOptions = {
|
|
|
72
75
|
dumpDir?: string | null;
|
|
73
76
|
/** Let the browser load references without a local file from the web. */
|
|
74
77
|
fetchMissing?: boolean;
|
|
78
|
+
/** Origins mapped via --asset-base; page-script fetches route to the server. */
|
|
79
|
+
mappedOrigins?: string[];
|
|
75
80
|
/** Delay pagination until the page's own async work finished. */
|
|
76
81
|
settle?: SettleGate | null;
|
|
77
82
|
/** Origin that page-script requests are routed to. */
|
|
@@ -154,6 +159,13 @@ export type RuntimeScriptOptions = {
|
|
|
154
159
|
origin: string;
|
|
155
160
|
documentBaseUrl: string;
|
|
156
161
|
gate: SettleGate | null;
|
|
162
|
+
/**
|
|
163
|
+
* Origins mapped via --asset-base. Page scripts fetch data from these
|
|
164
|
+
* (the blog's sparql/graph components fetch their datasets from the site
|
|
165
|
+
* origin); routing them to the static server keeps builds deterministic
|
|
166
|
+
* instead of silently depending on the live site.
|
|
167
|
+
*/
|
|
168
|
+
mappedOrigins?: string[];
|
|
157
169
|
/**
|
|
158
170
|
* Open every `<details>` element. Vivliostyle loads the page's scripts itself
|
|
159
171
|
* and only re-dispatches `DOMContentLoaded` on the window, so scripts that
|
|
@@ -207,12 +219,13 @@ export function buildSettleGateImage(origin: string): string {
|
|
|
207
219
|
export function buildRuntimeScript(options: RuntimeScriptOptions): string {
|
|
208
220
|
const { origin, documentBaseUrl, gate } = options;
|
|
209
221
|
const expandDetails = options.expandDetails === true ? EXPAND_DETAILS_SNIPPET : "";
|
|
222
|
+
const mappedOrigins = JSON.stringify(options.mappedOrigins ?? []);
|
|
210
223
|
// Vivliostyle paginates incrementally, so collapsed content has to be opened
|
|
211
224
|
// again while it lays the document out, not just once up front.
|
|
212
225
|
const expandDetailsTick = options.expandDetails === true ? "expandDetails(document);" : "";
|
|
213
226
|
|
|
214
227
|
return `(function(){
|
|
215
|
-
var ORIGIN=${JSON.stringify(origin)},BASE=${JSON.stringify(documentBaseUrl)};
|
|
228
|
+
var ORIGIN=${JSON.stringify(origin)},BASE=${JSON.stringify(documentBaseUrl)},MAPPED_ORIGINS=${mappedOrigins};
|
|
216
229
|
var QUIET=${gate?.quietMs ?? 400},DEADLINE=${gate?.deadlineMs ?? 10000},FRAME_GRACE=3000;
|
|
217
230
|
var pending=0,frames=0,last=0,mutations=0,done=false,longtasks=0;
|
|
218
231
|
// Force preserveDrawingBuffer on every WebGL context the page creates:
|
|
@@ -253,7 +266,13 @@ var state=window.__vivSettle={done:false,reason:null,at:0,pending:0,frames:0,mut
|
|
|
253
266
|
function fix(u){
|
|
254
267
|
if(typeof u!=="string"||u==="")return u;
|
|
255
268
|
if(u.slice(0,2)==="//"||u.charAt(0)==="#"||u.charAt(0)==="?")return u;
|
|
256
|
-
if(/^[a-z][a-z0-9+.-]*:/i.test(u))
|
|
269
|
+
if(/^[a-z][a-z0-9+.-]*:/i.test(u)){
|
|
270
|
+
try{
|
|
271
|
+
var mu=new URL(u);
|
|
272
|
+
if(MAPPED_ORIGINS.indexOf(mu.origin)>=0)return ORIGIN+mu.pathname+mu.search+mu.hash;
|
|
273
|
+
}catch(e){}
|
|
274
|
+
return u;
|
|
275
|
+
}
|
|
257
276
|
return u.charAt(0)==="/"?ORIGIN+u:BASE+u;
|
|
258
277
|
}
|
|
259
278
|
|
|
@@ -371,6 +390,10 @@ last=performance.now();
|
|
|
371
390
|
// Deterministic pages (charts, WebGL, OSD fixtures) set __vivReady when
|
|
372
391
|
// painted instead of making the gate guess from network quietness. Shader
|
|
373
392
|
// compile and tile decode finish after the last fetch, so readiness wins.
|
|
393
|
+
// An explicit __vivReady=false holds the quiet path too: async tails (module
|
|
394
|
+
// imports, wasm, deferred timers) emit no network signal, so quietness alone
|
|
395
|
+
// would settle on the pre-paint DOM. The deadline above still bounds it.
|
|
396
|
+
if(window.__vivReady===false){setTimeout(check,50);return;}
|
|
374
397
|
if(window.__vivReady===true&&pending===0&&frames===0){signal("ready");return;}
|
|
375
398
|
if(pending===0&&frames===0&&now-last>=QUIET){signal("quiet");return;}
|
|
376
399
|
setTimeout(check,50);
|
|
@@ -1079,7 +1102,13 @@ export function prepareInputHtmlForBuild(
|
|
|
1079
1102
|
const origin = options.shimOrigin ?? serverBaseUrl;
|
|
1080
1103
|
const documentBaseUrl = options.documentBaseUrl ?? `${origin}/`;
|
|
1081
1104
|
// Only the PDF run expands `<details>`; the preview stays interactive.
|
|
1082
|
-
injectRuntimeScriptInDom(document, {
|
|
1105
|
+
injectRuntimeScriptInDom(document, {
|
|
1106
|
+
origin,
|
|
1107
|
+
documentBaseUrl,
|
|
1108
|
+
gate: options.settle ?? null,
|
|
1109
|
+
mappedOrigins: options.mappedOrigins ?? [],
|
|
1110
|
+
expandDetails: true
|
|
1111
|
+
});
|
|
1083
1112
|
log.trace("prepareInputHtmlForBuild: injected runtime script", { origin, documentBaseUrl, gate: options.settle });
|
|
1084
1113
|
}
|
|
1085
1114
|
|
|
@@ -1398,6 +1427,8 @@ function buildProgram(): Command {
|
|
|
1398
1427
|
.option("--author <author>", "Document author")
|
|
1399
1428
|
.option("--subject <subject>", "Document subject (e.g. the page's description meta tag content)")
|
|
1400
1429
|
.option("--keywords <keywords>", "Document keywords, comma separated")
|
|
1430
|
+
.option("--doi <doi>", "Document DOI (bare, doi: URI or doi.org URL). Wins over --url for the XMP identifier")
|
|
1431
|
+
.option("--url <url>", "Document URL; XMP dc:identifier when no DOI is set (reference managers read it)")
|
|
1401
1432
|
.option(
|
|
1402
1433
|
"--language <lang>",
|
|
1403
1434
|
"Document language tag (e.g. en, de, ja). Taken from the document or manifest when omitted, falling back to 'de'"
|
|
@@ -1564,7 +1595,7 @@ function buildProgram(): Command {
|
|
|
1564
1595
|
" • the browser prints that page to PDF, so canvases and iframes stay real content.",
|
|
1565
1596
|
" • Collapsed <details> content is opened for the PDF; the preview keeps the page as it is.",
|
|
1566
1597
|
" • --asset-base localBase is also a fallback root for CSS-referenced assets.",
|
|
1567
|
-
" • PDF metadata (--title/--author/--subject/--keywords/--language/--created/--modified)",
|
|
1598
|
+
" • PDF metadata (--title/--author/--subject/--keywords/--doi/--url/--language/--created/--modified)",
|
|
1568
1599
|
" • values read from the document or the publication manifest; language falls",
|
|
1569
1600
|
" • back to 'de'. --pdfa/--pdfx label the output; the built-in validation",
|
|
1570
1601
|
" • checks the practical subset (--no-validate skips it) and --verapdf runs",
|
|
@@ -1603,7 +1634,7 @@ export function parseArgs(argv: string[]): {
|
|
|
1603
1634
|
// ---------------------------------------------------------------------------
|
|
1604
1635
|
|
|
1605
1636
|
/** Metadata fields the CLI layer resolves before handing them to the renderer. */
|
|
1606
|
-
type MetadataFieldName = "title" | "author" | "subject" | "keywords" | "language" | "created" | "modified";
|
|
1637
|
+
type MetadataFieldName = "title" | "author" | "subject" | "keywords" | "doi" | "url" | "language" | "created" | "modified";
|
|
1607
1638
|
|
|
1608
1639
|
/** ICC profile bytes with the name they get in the PDF's OutputIntent. */
|
|
1609
1640
|
type IccProfile = { bytes: Uint8Array; name: string };
|
|
@@ -1640,6 +1671,8 @@ async function runRender(params: RenderParams): Promise<void> {
|
|
|
1640
1671
|
...(params.metaFields.author === undefined ? {} : { author: params.metaFields.author }),
|
|
1641
1672
|
...(params.metaFields.subject === undefined ? {} : { subject: params.metaFields.subject }),
|
|
1642
1673
|
...(params.metaFields.keywords === undefined ? {} : { keywords: params.metaFields.keywords }),
|
|
1674
|
+
...(params.metaFields.doi === undefined ? {} : { doi: params.metaFields.doi }),
|
|
1675
|
+
...(params.metaFields.url === undefined ? {} : { url: params.metaFields.url }),
|
|
1643
1676
|
...(params.metaFields.language === undefined ? {} : { language: params.metaFields.language }),
|
|
1644
1677
|
...(params.metaFields.created === undefined ? {} : { created: params.metaFields.created }),
|
|
1645
1678
|
...(params.metaFields.modified === undefined ? {} : { modified: params.metaFields.modified }),
|
|
@@ -1756,7 +1789,7 @@ export function resolveIccProfile(options: Pick<CliOptions, "iccProfile">, label
|
|
|
1756
1789
|
* to "de" when no source provides one.
|
|
1757
1790
|
*/
|
|
1758
1791
|
export function resolvePdfMetadata(
|
|
1759
|
-
options: Pick<CliOptions, "title" | "author" | "subject" | "keywords" | "language" | "created" | "modified">,
|
|
1792
|
+
options: Pick<CliOptions, "title" | "author" | "subject" | "keywords" | "doi" | "url" | "language" | "created" | "modified">,
|
|
1760
1793
|
inputAbs: string,
|
|
1761
1794
|
htmlMode: boolean
|
|
1762
1795
|
): DocumentMetadata & { language: string } {
|
|
@@ -1765,10 +1798,19 @@ export function resolvePdfMetadata(
|
|
|
1765
1798
|
"author",
|
|
1766
1799
|
"subject",
|
|
1767
1800
|
"keywords",
|
|
1801
|
+
"doi",
|
|
1802
|
+
"url",
|
|
1768
1803
|
"language",
|
|
1769
1804
|
"created",
|
|
1770
1805
|
"modified"
|
|
1771
1806
|
]) as DocumentMetadata;
|
|
1807
|
+
if (cliFields.doi !== undefined) {
|
|
1808
|
+
const normalized = normalizeDoi(cliFields.doi);
|
|
1809
|
+
if (normalized === undefined) {
|
|
1810
|
+
throw new Error(`--doi is not a DOI: "${cliFields.doi}". Use the bare form (10.xxxx/…), a doi: URI or a doi.org URL`);
|
|
1811
|
+
}
|
|
1812
|
+
cliFields.doi = normalized;
|
|
1813
|
+
}
|
|
1772
1814
|
let derived: DocumentMetadata | undefined;
|
|
1773
1815
|
if (htmlMode) {
|
|
1774
1816
|
derived = extractMetadataFromDocument(new JSDOM(readFileSync(inputAbs, "utf-8")).window.document);
|
|
@@ -1887,6 +1929,9 @@ export async function execute(options: CliOptions, extraArgs: string[] = []): Pr
|
|
|
1887
1929
|
if (options.iccProfile !== undefined && pdfLabel === undefined) {
|
|
1888
1930
|
log.warn("[pdf] --icc-profile has no effect without --pdfa or --pdfx");
|
|
1889
1931
|
}
|
|
1932
|
+
if (options.verapdf === true && pdfLabel === undefined) {
|
|
1933
|
+
log.warn("[pdf] --verapdf has no effect without --pdfa or --pdfx");
|
|
1934
|
+
}
|
|
1890
1935
|
const iccProfile = resolveIccProfile(options, pdfLabel);
|
|
1891
1936
|
|
|
1892
1937
|
const fetchMissing = options.fetchMissing === true || options.allowRemote === true;
|
|
@@ -1901,6 +1946,10 @@ export async function execute(options: CliOptions, extraArgs: string[] = []): Pr
|
|
|
1901
1946
|
fetchMissing,
|
|
1902
1947
|
dumpDir: options.dumpHtml ?? null,
|
|
1903
1948
|
settle,
|
|
1949
|
+
// Page scripts fetch their data from the mapped origins (the blog's
|
|
1950
|
+
// sparql/graph components); route those to the static server so builds
|
|
1951
|
+
// stay deterministic instead of hitting the live site.
|
|
1952
|
+
mappedOrigins: [...new Set(assetBases.map((base) => new URL(base.urlBase).origin))],
|
|
1904
1953
|
...(typeof extraConfig.css === "string" ? { css: extraConfig.css } : {}),
|
|
1905
1954
|
...(typeof extraConfig.userStyle === "string" ? { userStyle: extraConfig.userStyle } : {})
|
|
1906
1955
|
};
|