kumiori 0.3.0 → 0.4.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/CHANGELOG.en.md +104 -0
- package/CHANGELOG.md +104 -0
- package/README.en.md +10 -6
- package/README.md +10 -6
- package/dist-browser/chunks/{UTIF-D5qoainF.js → UTIF-Br536cfi.js} +4 -4
- package/dist-browser/chunks/{ccitt-7WmwG6OA.js → ccitt-DuYpUkox.js} +5 -5
- package/dist-browser/chunks/{cgm-DUIP-hbA.js → cgm-Blvzv6Sp.js} +5 -5
- package/dist-browser/chunks/{el-monoton-BVsCvfmZ.js → el-monoton-vcesHl--.js} +4 -4
- package/dist-browser/chunks/{en-gb-Cjtf0A6r.js → en-gb-DAIgCw5-.js} +4 -4
- package/dist-browser/chunks/{en-us-B_UiZPbu.js → en-us-BzUSGdOw.js} +4 -4
- package/dist-browser/chunks/{eps-_CPowVcQ.js → eps-BFOW93N0.js} +6 -6
- package/dist-browser/chunks/{epsInfo-BUAZ97F-.js → epsInfo-D7b8OFlX.js} +3 -3
- package/dist-browser/chunks/{export-contract-OHP-GNO0.js → export-contract-J-x2aLjv.js} +3 -3
- package/dist-browser/chunks/{la-7qtmi2aU.js → la-DRKqnbhl.js} +4 -4
- package/dist-browser/chunks/{load-BRpJTflg.js → load-ftVKpJYM.js} +11 -11
- package/dist-browser/chunks/{matrix-BcBTRcOc.js → matrix-DxjvN-4S.js} +2 -2
- package/dist-browser/chunks/{metafile-BikFmcYd.js → metafile-CdWE2Vpy.js} +4 -4
- package/dist-browser/chunks/{pako-Dl02IHsa.js → pako-BwlM3ygd.js} +3 -3
- package/{dist-lib/pixels-ByXzkjlj.js → dist-browser/chunks/pixels-BvYSA32R.js} +2 -2
- package/dist-browser/chunks/{rolldown-runtime-Bra2mvh4.js → rolldown-runtime-BV67vctc.js} +2 -2
- package/dist-browser/chunks/{ru-BMiVc5Ts.js → ru-C-K8QVC6.js} +4 -4
- package/dist-browser/chunks/{sniff-B_ueafAB.js → sniff-CqYWlxhA.js} +1367 -1367
- package/dist-browser/chunks/{strokeOutline-DA-aSg5C.js → strokeOutline-yLvGVz8Y.js} +4 -4
- package/dist-browser/chunks/{uk-ChOFgYc8.js → uk-DsJ1E5t7.js} +4 -4
- package/dist-browser/kumiori.js +39082 -34193
- package/dist-cli/assets/{cgm-CVN2h83E.js → cgm-DNhYr9YE.js} +2 -2
- package/dist-cli/assets/{drawioStencil-Bzai2moR.js → drawioStencil-FTgn0IEy.js} +2 -2
- package/dist-cli/assets/{eps-BK1bEizE.js → eps-L8amQ51W.js} +2 -2
- package/dist-cli/assets/{load-BwlOZ5Bc.js → load-O0H7f7JT.js} +3 -3
- package/dist-cli/assets/{metafile-DmYDB8sR.js → metafile-xjD5AdL9.js} +2 -2
- package/dist-cli/cli.js +9405 -1763
- package/dist-lib/{api-DB-5PKHp.js → api-DG-iGARW.js} +36826 -31937
- package/dist-lib/{cgm-CkwJobkQ.js → cgm-CAP3l6Ps.js} +19 -19
- package/dist-lib/{eps-D9WVND82.js → eps-BVpP3M6Z.js} +219 -219
- package/dist-lib/{epsInfo-BUAZ97F-.js → epsInfo-D7b8OFlX.js} +3 -3
- package/dist-lib/index.js +11 -11
- package/dist-lib/{load-plWCtVUv.js → load-WPgVW8G9.js} +3 -3
- package/dist-lib/{metafile-BOfMQbwN.js → metafile-DIpYelkX.js} +16 -16
- package/dist-lib/node.js +4 -4
- package/{dist-browser/chunks/pixels-ByXzkjlj.js → dist-lib/pixels-BvYSA32R.js} +2 -2
- package/dist-lib/types/api.d.ts +35 -1
- package/dist-lib/types/areaResources.d.ts +9 -1
- package/dist-lib/types/assets.d.ts +21 -0
- package/dist-lib/types/color.d.ts +4 -1
- package/dist-lib/types/colorGlyphPdf.d.ts +7 -1
- package/dist-lib/types/compat.d.ts +12 -0
- package/dist-lib/types/cssCascade.d.ts +35 -1
- package/dist-lib/types/cssSelector.d.ts +42 -3
- package/dist-lib/types/cssText.d.ts +23 -0
- package/dist-lib/types/foContext.d.ts +19 -0
- package/dist-lib/types/foExpr.d.ts +7 -0
- package/dist-lib/types/footnotes.d.ts +17 -1
- package/dist-lib/types/geometry.d.ts +5 -0
- package/dist-lib/types/gridTracks.d.ts +51 -0
- package/dist-lib/types/htmlImport.d.ts +62 -15
- package/dist-lib/types/htmlPaged.d.ts +5 -0
- package/dist-lib/types/htmlPrepare.d.ts +8 -1
- package/dist-lib/types/index.d.ts +3 -2
- package/dist-lib/types/inlineLayout.d.ts +18 -1
- package/dist-lib/types/layoutEngine.d.ts +157 -4
- package/dist-lib/types/lnode.d.ts +26 -0
- package/dist-lib/types/pageFlow.d.ts +34 -0
- package/dist-lib/types/paint.d.ts +3 -1
- package/dist-lib/types/pdfFlatten.d.ts +165 -0
- package/dist-lib/types/pdfLibPatches.d.ts +28 -4
- package/dist-lib/types/pdfRenderer.d.ts +23 -0
- package/dist-lib/types/pdfStandard.d.ts +17 -7
- package/dist-lib/types/pdfxVerify.d.ts +4 -0
- package/dist-lib/types/sourceRef.d.ts +20 -1
- package/dist-lib/types/svgFilterRaster.d.ts +61 -1
- package/dist-lib/types/types.d.ts +332 -7
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -23,7 +23,7 @@ Kumiori is developed with an AI coding assistant ([Claude Code](https://claude.c
|
|
|
23
23
|
- **Japanese typesetting**: vertical and horizontal writing, ruby, tate-chu-yoko, emphasis marks (kenten), line-breaking rules (kinsoku), hanging punctuation and pushing out, punctuation compression, spacing between Japanese and Latin text
|
|
24
24
|
- **Other scripts**: right-to-left scripts such as Arabic and Hebrew (reordered with the Unicode Bidirectional Algorithm, UAX #9; Arabic letters take their joined forms. CSS `direction: rtl`, XSL-FO `writing-mode="rl-tb"`), Thai (wrapped at word boundaries found with the dictionary of the runtime's `Intl.Segmenter`), Devanagari (Hindi and others; conjuncts and other shaping by the font), Korean (Hangul), other Indic scripts (Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Sinhala), Lao, Khmer, Burmese (Myanmar script) and Tibetan, Mongolian script (horizontal and vertical), Chinese (Simplified and Traditional), Vietnamese, Greek and Cyrillic, hyphenation (English, Latin, Russian, Ukrainian, Modern Greek), and mixed Japanese and Latin text. Fonts for Arabic, Thai, Devanagari, Hangul, Simplified and Traditional Chinese, emoji and other scripts are passed with `--font` or `fonts` (the default fonts do not include them; color emoji fonts are typeset in color; Hebrew, Greek, Cyrillic and Vietnamese letters can be set with the default Latin fonts). A table of the font each language and script needs, how it wraps, vertical writing and limitations is in the section "Supported languages and scripts" of the Conformance Guide ([`docs/en/conformance.md`](docs/en/conformance.md); section 5.6 of the XSL-FO 1.1 volume, section 5.8 of the HTML and CSS volume). The same section has typeset samples for each script (Article 1 of the Universal Declaration of Human Rights set in the font of each script), and samples of variable fonts and emoji are in sections 5.6 and 5.7 of the HTML and CSS volume
|
|
25
25
|
- **Pages**: page masters, running heads and page numbers (folios), footnotes, multi-column layout, floats, tables (splitting across rows and pages, repeated headers, automatic column width), page number references
|
|
26
|
-
- **Output**: Canvas preview, PDF (subset font embedding, bookmarks, links, annotations, forms, trim marks, PDF/X-3 and PDF/X-4 marking with conversion of RGB colors and images to CMYK)
|
|
26
|
+
- **Output**: Canvas preview, PDF (subset font embedding, bookmarks, links, annotations, forms, trim marks, PDF/X-1a, PDF/X-3 and PDF/X-4 marking with conversion of RGB colors and images to CMYK)
|
|
27
27
|
- The PDF/X marking (`pdfx` in the API, `--pdfx` on the command line) has been verified only for the parts defined by the PDF specification ISO 32000-2 (such as the form of the output intent dictionary and the XMP metadata). It has not been verified against the text of the PDF/X standard ISO 15930, so conformance to that standard is not guaranteed. Check the output with a preflight tool (such as Acrobat Pro) before submitting it
|
|
28
28
|
- **Environments**: browser (Vite) and the Node CLI (`dist-cli/cli.js`)
|
|
29
29
|
|
|
@@ -86,9 +86,11 @@ cat book.html | node dist-cli/cli.js - -o - --base . > book.pdf
|
|
|
86
86
|
- Images the document references via `http(s):` are fetched from the network by default. `--no-fetch-images` disables this (e.g. when typesetting documents written by others on a server; they are typeset as unreadable images). Network images are fetched up to 8 at a time, and fetching the images of a document also has an overall time limit (10 times the limit of a single fetch, 5 minutes by default; images not fetched by then are typeset as unreadable images)
|
|
87
87
|
- Stylesheets the document references via `http(s):` (`<link rel="stylesheet">`, `@import`) and the fonts of their `@font-face` rules (only those whose `unicode-range` overlaps the characters of the document) are also fetched by default. `--no-fetch-styles` disables this
|
|
88
88
|
- Image sizes are limited (so that a small file cannot consume large amounts of memory and time; the values and their rationale are in `src/imageLimits.ts`). One image may have up to 100 million pixels. The images inside a WMF, EMF or CGM file (DIBs, cell arrays, tile arrays, patterns) may total up to 64 million pixels per file, and also no more than "260 thousand pixels (512 × 512) + 1,024 pixels per byte of the file" (a file of a few hundred bytes cannot produce a huge image; a file larger than about 61 KB may use the full 64 million pixels). Images beyond the limits are not drawn, and the rest of the document is typeset. GIF, WebP, JPEG, CCITT TIFF and RLE BMP images also have their pixel count bounded by the file size (per format, a value derived from the densest coding a legitimate file can have; a large, almost single-colour lossless WebP, a blank CCITT image wider than 16,384 pixels, or a large, almost blank RLE BMP is not drawn when it exceeds the limit), and a PNG whose decompressed size exceeds 1,032 times its compressed data (the deflate limit) is not drawn. A font unpacked from WOFF or WOFF2 may be up to 128 MB, and no more than 100 times the file size + 1 MB
|
|
89
|
+
- Documents of thousands of pages use memory in proportion to the number of pages. The command and the API's `typesetToPdf` write the PDF page by page and release the layout results of each page once it is written, so the most memory is used when layout has finished, by the intermediate layout results (about 0.7MB per text-heavy page). `typeset`, which also returns the layout results (`areaTree`, `toPdf`, `renderPage`), holds the area tree of the whole document and uses correspondingly more (for the FO of the PostgreSQL documentation, 3,231 pages, the command peaks at about 2.3GB of live heap, and typesetting with `typeset` and calling `toPdf` at about 2.8GB). If Node stops at its heap limit (`JavaScript heap out of memory`; by default the limit depends on the machine's memory and is at most about 4GB), add `--low-memory` (see below) or raise the limit, as in `node --max-old-space-size=8192 dist-cli/cli.js book.fo -o book.pdf` (in MB). Image bytes are kept outside the V8 heap, so they do not count towards `--max-old-space-size`, but they use the machine's memory. When only the PDF is made (the command, `typesetToPdf`), the original bytes of each image are released once it has been embedded in the PDF, so a document with many images uses about 3 times the amount of image data (the size of the image files read; the embedded copies, the finished PDF and so on. With `typeset` the original bytes are also kept, about 3.5 times)
|
|
89
90
|
- When typesetting documents written by others on a server, also put a time limit and a memory limit on the typesetting of each document, separately from the limits above (typeset each document in a separate process or worker and stop it when the time is up; use `node --max-old-space-size=…` or a container memory limit, and so on). The limits above apply to one image or font at a time: a single image at the limit can still take several seconds to over ten seconds and about 2 GB, and a document that references many images and fonts costs correspondingly more
|
|
90
91
|
- Of the links that leave the document (HTML `<a href>`, and `external-destination` of XSL-FO `fo:basic-link` and `fo:bookmark`), by default only URLs whose scheme is `http`, `https`, `mailto` or `tel`, and relative references to a PDF (the action that opens another PDF), get an action in the PDF. Other schemes (`javascript:`, `data:`, `file:` and so on) and actions that open a file (relative non-PDF files, absolute paths, scheme-less `//host/…`) are typeset as plain text and counted in a "warning:" (to protect whoever opens a PDF made from a document written by someone else). `--link-schemes http,https,ftp` chooses the allowed schemes (`*` means all), and `--link-launch` also writes the actions that open a file (`--link-schemes '*' --link-launch` writes everything). `--link-relative uri` writes scheme-less relative links (`x.pdf`, `a.mp3`) as a URI action with the reference as written (`/S /URI /URI (x.pdf)`; `%xx` is not decoded) instead of the actions that open a file (GoToR, Launch): many PDF viewers inside browsers do not handle GoToR and Launch. Relative non-PDF files are then written without `--link-launch`; absolute paths and `//host/…` still need `--link-launch`. In the API it is `links: { relative: 'uri' }`
|
|
91
92
|
- Files the document or the CSS references with a `file:` URL (`file:///…/style.css` etc.) are read from that file, even outside the input's directory. Relative references that point outside the input's directory (`url(../fonts/a.ttf)` in `sub/a.html` etc.) are read the same way (as when a browser opens a local HTML file). `--no-outside-files` stops reading files outside the input's directory (for documents written by others: an image, font or SVG the document points at is drawn into the PDF when it can be read, so this keeps other files of the machine from being copied out; files inside the input's directory are still read). When none of the files in the `src` of an `@font-face` is found, a warning is reported
|
|
93
|
+
- `--low-memory`: typeset with less memory. The re-layouts that settle page number references (tables of contents and so on) do not reuse the pages of the previous pass, and the intermediate layout results of each page-sequence (for HTML, the document) are released once it has been laid out. The document is therefore laid out once more after the re-layouts to write the PDF. The PDF is the same. For the FO of the PostgreSQL documentation (3,231 pages), the maximum live heap goes from about 2.3GB to about 0.9GB (the most is used while reading the FO; it can be typeset with a 1GB heap limit), and the time from 160 s to 231 s. In the API, `lowMemory` of `typesetToPdf`
|
|
92
94
|
- `--watch`: re-typesets whenever the HTML, FO, CSS, images or fonts in the input's directory change
|
|
93
95
|
- `--help` (`-h`) prints the usage, `--version` (`-v`) prints the version
|
|
94
96
|
- Unsupported CSS properties and values (listed in chapter 16 of the Conformance Guide), properties unknown to Kumiori (misspelled or unsupported), XSL-FO elements and properties that cannot be read, unreadable images and so on are not silently ignored but reported as `警告:` ("warning:") messages (in the library, `result.warnings`)
|
|
@@ -107,7 +109,7 @@ cat book.html | node dist-cli/cli.js - -o - --base . > book.pdf
|
|
|
107
109
|
- `--plugin <module>`: loads a plugin (the API's `plugins`): a file path or a package name, searched in this order: (1) a spec starting with `./` or `../`, an absolute path or a `file:` URL is a file path (`./plugin.js` and so on); (2) any other spec is first resolved as a package name, as `import()` does (from the current directory with the same conditions as `import()`: the `import`, `node` and `default` conditions of `exports`; `@scope/name`, `name/sub` and specs ending in an extension, such as `kp/dist/plugin.js` or `chart.js`, work too; a directory of the same name in the current directory does not make it a path); (3) if it cannot be loaded as a package (no such package, and also when the package does not export that subpath in `exports` or its entry file is missing), the file of that name in the current directory is loaded (`--plugin myplugin.js`). Whenever it can be loaded as a package, the package is loaded, so write `./` to be sure the file is loaded. When nothing is found, the error message says what was searched, in order. Repeatable. The module's `default` export is a plugin or a function returning one (`(options, { cacheDir, lang }) => plugin`; `lang` is the message language chosen by `--lang` or the environment). `--plugin-option <name>=<value>` passes an option to the function of the preceding `--plugin` (repeatable). A plugin is a program that runs with the same rights as Kumiori, so give only ones you trust
|
|
108
110
|
- `--print`: trim marks and bleed (3mm)
|
|
109
111
|
- `--image-max-dpi <dpi>`: JPEG photos finer than this relative to the size they are placed at are downscaled to this resolution and re-encoded (makes the PDF smaller; by default they are left as they are)
|
|
110
|
-
- `--pdfx x3|x4`: write PDF/X-3:2003 or PDF/X-4 markers for print submission. RGB colors and images are converted to CMYK, gray text, lines and fills become K-only CMYK, K-only black body text under 12pt (including text in the page margins) and lines and rules under 2pt are overprinted (as recommended by the Ghent Workgroup submission specification GWG 2022; text and lines inside images such as SVG and EPS are not), pages get a TrimBox only, and links, annotations and form fields on the pages are left out, with their number reported in a warning (anything that overlaps the area up to the bleed (BleedBox) even slightly is left out; the BleedBox encloses the whole artwork of the page, so practically all links are lost, both internal ones such as those of a table of contents and those to external URLs; bookmarks are kept; write PDFs for reading on screen without `--pdfx`). Of the GWG 2022 requirements, differing finished page sizes, spot colors and coarse images (149ppi or less, and 224ppi or less) are also reported as warnings (with the values of the sheet-fed commercial variant).
|
|
112
|
+
- `--pdfx x1a|x1a:2003|x3|x4`: write PDF/X-1a:2001, PDF/X-1a:2003, PDF/X-3:2003 or PDF/X-4 markers for print submission. RGB colors and images are converted to CMYK, gray text, lines and fills become K-only CMYK, K-only black body text under 12pt (including text in the page margins) and lines and rules under 2pt are overprinted (as recommended by the Ghent Workgroup submission specification GWG 2022; text and lines inside images such as SVG and EPS are not), pages get a TrimBox only, and links, annotations and form fields on the pages are left out, with their number reported in a warning (anything that overlaps the area up to the bleed (BleedBox) even slightly is left out; the BleedBox encloses the whole artwork of the page, so practically all links are lost, both internal ones such as those of a table of contents and those to external URLs; bookmarks are kept; write PDFs for reading on screen without `--pdfx`). Of the GWG 2022 requirements, differing finished page sizes, spot colors and coarse images (149ppi or less, and 224ppi or less) are also reported as warnings (with the values of the sheet-fed commercial variant). PDF/X-4 keeps transparency as is and writes the version marker in the XMP metadata. For PDF/X-1a (CMYK and spot colors only, no transparency; :2001 is PDF 1.3, :2003 is PDF 1.4) and PDF/X-3 (no transparency; device-independent color (ICC, Lab) is allowed; PDF 1.4), the written PDF is read back and checked against the rules (version, markers, color spaces, transparency, font embedding, boxes, annotations), and writing fails if it does not meet them. Transparency is flattened: when only a single-color fill (a box background or the white page) lies under a transparent object (opacity, colors with alpha, images with alpha, translucency and masks in SVG), it is drawn as an opaque vector object in the composited CMYK color; otherwise that area is rasterized together with what lies under it into a CMYK image (300ppi; 600ppi where text under 12pt is involved), with a warning (also warning that text within rasterized areas loses quality and can no longer be selected as text). Writing fails if transparency that cannot be flattened remains (such as the transparency of color glyphs). Overlapping areas are composited in CMYK (as in printing), so they look slightly different from screen viewers that composite in RGB. Japanese printers mainly use PDF/X-4 and PDF/X-1a
|
|
111
113
|
- `--output-profile <ICC file>`: the output CMYK ICC profile (the one the printer specifies, such as Japan Color 2001 Coated). It is embedded in the PDF, and RGB colors and images are converted to CMYK with its tables. Required with `--pdfx x4` (an error if missing or not a CMYK profile). `--output-condition <name>` gives the printing condition name (default: the ICC registry name JC200103)
|
|
112
114
|
- `--spot-colors <JSON file>`: the names of spot colors and the alternate CMYK at 100% tint (`{"name": "cmyk(20%,40%,60%,80%)"}` or `{"name": [0.2,0.4,0.6,0.8]}`; the array holds numbers from 0 to 1, and a value over 1 is an error). Among `rgb-icc(r,g,b,#Separation,'name',tint)` colors, those whose name is listed here are written as a PDF Separation (the alternate color space is DeviceCMYK, and the tint transform is linear). `rgb-icc()` is read with either `--compat` in XSL-FO, and only with `--style ah` in HTML (it is an Antenna House form, not a CSS color function; with the other styles the declaration is ignored as an invalid value and reported in a warning). Those whose name is not listed are written with the alternate RGB as before. Names are written in UTF-8 (ISO 32000-2 §7.3.5). Spot color values (such as those of swatch books) are not included in Kumiori; the user supplies them
|
|
113
115
|
- HTML is read with linkedom, and the CSS computed values come from the own cascade (the same as "CSS interpretation: Kumiori" in the web app)
|
|
@@ -125,7 +127,7 @@ npm install kumiori
|
|
|
125
127
|
When building in this repository, `npm run build:lib` (dist-lib/; ES modules and type declarations).
|
|
126
128
|
|
|
127
129
|
```ts
|
|
128
|
-
import { typeset, walkAreaTree } from 'kumiori';
|
|
130
|
+
import { typeset, typesetToPdf, walkAreaTree } from 'kumiori';
|
|
129
131
|
|
|
130
132
|
// HTML+CSS (XSL-FO is typeset with the same function; the kind is detected from the extension of name or from the content)
|
|
131
133
|
const result = await typeset(html, {
|
|
@@ -139,6 +141,7 @@ const result = await typeset(html, {
|
|
|
139
141
|
console.log(result.pageCount, result.warnings);
|
|
140
142
|
walkAreaTree(result.areaTree, (area) => { /* walk the typeset result (Area Tree) */ });
|
|
141
143
|
const pdf = await result.toPdf(); // Uint8Array
|
|
144
|
+
const { pdf: bytes } = await typesetToPdf(html, { name: 'book.html' }); // when only the PDF is needed (it keeps no layout result, so large documents use less memory)
|
|
142
145
|
result.renderPage(canvas, 0); // draw page 1 onto a canvas (browser)
|
|
143
146
|
```
|
|
144
147
|
|
|
@@ -146,7 +149,8 @@ result.renderPage(canvas, 0); // draw page 1 on
|
|
|
146
149
|
- `text` is a string. When reading from a file, converting it to a string with `decodeDocumentText(bytes)` decodes it according to the BOM, the XML declaration's `encoding` and `<meta charset>` (reading as fixed UTF-8 garbles Shift_JIS FO and the like)
|
|
147
150
|
- Main `options`: `kind` (`html`, `xhtml`, `fo`; if omitted, determined from `name` and the content), `name` (the input file name), `files` (CSS, images, fonts; fonts may be TTF, OTF, TTC, WOFF or WOFF2), `fonts` (fonts to add), `genericFonts` (fonts for the generic font families; the names are the same as for `--generic-font`: `serif`, `sans-serif`, `monospace`, `serif-cjk`, `sans-serif-cjk`), `style` (the default style for HTML), `pageSize` (the default paper for HTML: the paper of a document that does not specify `size` in `@page`, written like the CSS `size` property: `"A5"`, `"A5 landscape"`, `"148mm 210mm"`; the default is A4; a `@page { size }` in the document wins; `width` and `height` in `@media` are also evaluated against this paper), `compat` (the XSL-FO default-value convention), `print` (bleed and trim marks), `spotColors` (alternate CMYK for spot colors), `loadFont`, `fetchTimeoutMs` (timeout for fetching fonts and images; default 30 seconds), `fetchImages` (whether to fetch the images the document references via `http(s):`; default `true`; `false`, or a function that takes a URL and returns a boolean; when typesetting others' documents on a server, disable it or allow only certain URLs), `fetchStyles` (whether to fetch the stylesheets the document references via `http(s):` and the fonts of their `@font-face` rules; the same form as `fetchImages`), `resolveResource` (a function that returns the content of files the document or the CSS references that are not in `files`; see below), `links` (which links that leave the document get an action in the PDF: `{ schemes?: string[]; launch?: boolean; relative?: 'file' | 'uri' }`; by default only URLs whose scheme is `http`, `https`, `mailto` or `tel` and relative references to a PDF are written, and the rest are typeset as plain text and reported in `warnings`; `schemes` is the list of allowed schemes (it replaces the default; `'*'` means all), and `launch: true` also writes the actions that open a file (relative non-PDF files, absolute paths, `//host/…`); `{ schemes: ['*'], launch: true }` writes everything), `svgLanguages` (an array of language tags to match SVG `systemLanguage` against; the same as `--svg-lang`), `lang` (language of `warnings` and error messages: `ja` or `en`; default Japanese), `deflate` (in Node, passing `zlib.deflateSync` speeds up PDF output)
|
|
148
151
|
- The function passed to `fetchImages` / `fetchStyles` is asked not only about the URL written in the document but also about every redirect target. On Node, redirects are followed one hop at a time (up to 20), and no request is sent to a target the function refuses. Redirects from `https:` to `http:` and redirects to non-`http(s):` targets are refused without asking the function (also when the option is `true`). In browsers, scripts cannot read a redirect target in advance, so the function is asked about the final URL after the browser has followed the redirects, and the response is discarded if it is refused (the request itself has already reached the redirect target). The function only sees the URL string: a host name that resolves to an internal address (including DNS rebinding) cannot be stopped by it. To protect an internal network when typesetting documents written by others on a server, also restrict the runtime itself (egress rules, an outbound proxy). Resources fetched from the network have size limits (images 256 MB, CSS 16 MB, fonts 128 MB); anything larger is abandoned mid-read and treated as an unreadable resource, even when the response has no `Content-Length`. The `fetchTimeoutMs` time limit applies until the body has been read completely
|
|
149
|
-
- `result.toPdf({ title, pdfx, imageMaxDpi })`: the PDF title, the PDF/X marking (`pdfx: { version: 'X-3' | 'X-4', condition, info, profile, warnings }`; RGB colors and images are converted to CMYK; X-3 by default; X-4 needs a CMYK ICC profile in `profile`; as with `--pdfx` on the command line, links, annotations and form fields on the pages are not written, and their number is added to `warnings`; bookmarks are kept), the upper limit of JPEG resolution. Warnings raised while writing the PDF (characters that cannot be drawn, color glyphs that cannot be drawn in color, etc.) are added to `result.warnings`. `result.renderPage(canvas, i, { scale, devicePixelRatio, guides })`: the scale, the device pixel density, and guide lines for the trim box and bleed
|
|
152
|
+
- `result.toPdf({ title, pdfx, imageMaxDpi })`: the PDF title, the PDF/X marking (`pdfx: { version: 'X-1a' | 'X-1a:2003' | 'X-3' | 'X-4', condition, info, profile, warnings }`; RGB colors and images are converted to CMYK; X-3 by default; X-4 needs a CMYK ICC profile in `profile`; X-1a and X-3 flatten transparency and check the written PDF against their rules (see `--pdfx` on the command line); as with `--pdfx` on the command line, links, annotations and form fields on the pages are not written, and their number is added to `warnings`; bookmarks are kept), the upper limit of JPEG resolution. Warnings raised while writing the PDF (characters that cannot be drawn, color glyphs that cannot be drawn in color, etc.) are added to `result.warnings`. `result.renderPage(canvas, i, { scale, devicePixelRatio, guides })`: the scale, the device pixel density, and guide lines for the trim box and bleed
|
|
153
|
+
- `typesetToPdf(text, options, pdfOptions)`: makes only the PDF (the same PDF, warnings and page count as calling `toPdf(pdfOptions)` after `typeset`). The result is `{ pdf, pageCount, warnings, layoutMs }` (type `TypesetPdfResult`; `pdfOptions` has the type `PdfOptions`, the same as for `toPdf`). It turns the pages into the layout result (Area Tree) one at a time, writes each to the PDF and releases it, so it never holds the layout result of the whole document, and documents of thousands of pages use less memory (the layout result of a page is built twice, once to collect the fonts and images used and once to draw it). There is no `areaTree` or `renderPage`. `layoutMs` does not include the time to turn the pages into layout results (it is part of writing the PDF). The Node command also makes PDFs with it. With `lowMemory: true` in `pdfOptions`, it typesets with less memory (type `TypesetPdfOptions`; the same as the command's `--low-memory`). The container from `createTypesetter()` also has `typesetter.typesetToPdf(text, options, pdfOptions)`
|
|
150
154
|
- Internal entities declared in the internal subset of the FO's DOCTYPE (such as `<!ENTITY nbsp " ">`) are expanded before import (external entities are not read)
|
|
151
155
|
- Exceptions: `typeset` throws when the FO's XML cannot be parsed (`XML の解析に失敗しました: …`, "failed to parse XML: …") and when the default fonts cannot be read (`書体を読めません: …`, "cannot read font: …"). A corrupt font file passed in `fonts` does not throw but goes into `warnings`. A nonexistent page number for `renderPage` is a `RangeError`. Typesetting warnings (unreadable images, overflow, etc.) do not throw but go into `result.warnings` (an array of strings)
|
|
152
156
|
- `resolveResource(url)`: asked for each file the document or the CSS references (`<link rel="stylesheet">`, `@import`, `url()`, `<img src>`, etc.) that is not in `files`. `url` is the reference as written (`file:///…/a.css`, `img/a.png`, `https://…`); relative references inside a CSS file are resolved against that CSS file's URL. If it returns content (a string, `Uint8Array` or `ArrayBuffer`), that is used; if it returns `undefined`, things work as before (`http(s):` images and stylesheets are fetched from the network). There is no need to rewrite the references and put the files into `files`. An image is recognized from the leading bytes of the returned content, even when its URL has no extension (such as `https://example.com/img?id=1`)
|
|
@@ -166,7 +170,7 @@ result.renderPage(canvas, 0); // draw page 1 on
|
|
|
166
170
|
|
|
167
171
|
```html
|
|
168
172
|
<script type="module">
|
|
169
|
-
import { typesetHtml } from 'https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
173
|
+
import { typesetHtml } from 'https://cdn.jsdelivr.net/npm/kumiori@0.4.0/dist-browser/kumiori.js';
|
|
170
174
|
const result = await typesetHtml(html, { name: 'a.html' });
|
|
171
175
|
result.renderPage(document.querySelector('canvas'), 0);
|
|
172
176
|
</script>
|
|
@@ -235,7 +239,7 @@ async function showPreview(bodyHtml: string, container: HTMLElement) {
|
|
|
235
239
|
| `src/fontMapping.ts`, `src/compat.ts`, `src/documentResources.ts`, `src/documentText.ts`, `src/cli.ts` | Font assignment, compatibility mode settings, fetching the math font and images, character encoding detection (shared by the web app and Node); the Node CLI |
|
|
236
240
|
| `src/webFont.ts`, `src/fontLoader.ts`, `src/userFonts.ts` | Converting WOFF and WOFF2 back to TTF and OTF, splitting the user's font files (including TTC) into single fonts and reading their names, storing the fonts loaded in the web app |
|
|
237
241
|
| `src/colorGlyph.ts`, `src/colorGlyphPdf.ts`, `src/colorGlyphCanvas.ts`, `src/colorGlyphSvg.ts` | Reading color glyphs (color emoji and the like) from the font tables and drawing them to PDF and Canvas (including glyphs in the OpenType SVG table) |
|
|
238
|
-
| `src/color.ts`, `src/cssColorFunctions.ts`, `src/cssGradient.ts`, `src/icc.ts`, `src/pdfStandard.ts` | Parsing color values, the CSS Color 4 and 5 color functions, CSS gradients, conversion to CMYK with an ICC profile, the policies for PDF/X-3 and PDF/X-4 |
|
|
242
|
+
| `src/color.ts`, `src/cssColorFunctions.ts`, `src/cssGradient.ts`, `src/icc.ts`, `src/pdfStandard.ts` | Parsing color values, the CSS Color 4 and 5 color functions, CSS gradients, conversion to CMYK with an ICC profile, the policies for PDF/X-1a, PDF/X-3 and PDF/X-4 |
|
|
239
243
|
| `src/assets.ts`, `src/linkPolicy.ts`, `src/messages.ts` | The image registry (shared by layout, Canvas and PDF), the policy for which PDF action a link leaving the document becomes, the user-facing messages (Japanese and English) |
|
|
240
244
|
| `src/drawio/` | Reads draw.io diagrams (`.drawio`, `.dio`) and converts them to SVG (shape and edge drawing ported from the source of draw.io and mxGraph; loaded only when a diagram appears; [`docs/en/drawio.md`](docs/en/drawio.md)) |
|
|
241
245
|
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Kumiori は、AI のコーディング支援 ([Claude Code](https://claude.com/c
|
|
|
23
23
|
- **日本語組版**: 縦書き・横書き、ルビ、縦中横、圏点、禁則、ぶら下げ・追い出し、約物の詰め、和欧間のアキ
|
|
24
24
|
- **多言語**: アラビア語・ヘブライ語などの右から左の文字 (Unicode の双方向アルゴリズム UAX #9 で並べ替え、アラビア文字は前後につながる字形にする。CSS の `direction: rtl`、XSL-FO の `writing-mode="rl-tb"`)、タイ語 (語の境目は実行環境の `Intl.Segmenter` の辞書で決めて折り返す)・デーヴァナーガリー (ヒンディー語など。結合子音などの書体の整形)・韓国語 (ハングル)、ほかのインド系の文字 (ベンガル・グルムキー・グジャラート・オリヤー・タミル・テルグ・カンナダ・マラヤーラム・シンハラ)、ラオ語・クメール語・ビルマ語 (ミャンマー文字)・チベット語、モンゴル文字 (横書きと縦書き)、中国語 (簡体字・繁体字)、ベトナム語・ギリシャ文字・キリル文字、欧文のハイフネーション (英語・ラテン語・ロシア語・ウクライナ語・現代ギリシャ語)、欧文と和文の混在。アラビア文字・タイ文字・デーヴァナーガリー・ハングル・簡体字と繁体字・絵文字などの書体は `--font` や `fonts` で渡す (既定の書体には無い。カラーの絵文字の書体は、色の付いたまま組める。ヘブライ文字・ギリシャ文字・キリル文字・ベトナム語の字は、既定の欧文の書体で組める)。言語と文字ごとの、要る書体・折り返し・縦書き・制限の一覧は、対応仕様説明書 ([`docs/conformance/`](docs/conformance/README.md)) の「対応している言語と文字」の節 (XSL-FO 1.1 編の 5.6 節、HTML と CSS 編の 5.8 節) にある。同じ節に、文字ごとの組版の見本 (世界人権宣言の第 1 条を、それぞれの文字の書体で組んだもの) があり、可変フォントと絵文字の見本は、HTML と CSS 編の 5.6 節・5.7 節にある
|
|
25
25
|
- **ページ**: ページマスター、柱・ノンブル、脚注、段組、回り込み、表 (行・ページをまたぐ分割、ヘッダーの繰り返し、列の幅の自動決定)、ページ番号の参照
|
|
26
|
-
- **出力**: Canvas のプレビュー、PDF (書体のサブセット埋め込み、しおり、リンク、注釈、フォーム、トンボ、PDF/X-3・PDF/X-4 の印と、RGB の色・画像の CMYK への変換)
|
|
26
|
+
- **出力**: Canvas のプレビュー、PDF (書体のサブセット埋め込み、しおり、リンク、注釈、フォーム、トンボ、PDF/X-1a・PDF/X-3・PDF/X-4 の印と、RGB の色・画像の CMYK への変換)
|
|
27
27
|
- PDF/X の印 (API の `pdfx`、コマンドの `--pdfx`) は、PDF の仕様 ISO 32000-2 で決まっている部分 (出力意図の辞書の形、XMP のメタデータなど) だけを確かめています。PDF/X の規格 ISO 15930 の本文では確かめていないので、規格への適合は保証しません。入稿の前に、プリフライト (Acrobat Pro など) で確かめてください
|
|
28
28
|
- **環境**: ブラウザ (Vite) と Node のコマンド (`dist-cli/cli.js`)
|
|
29
29
|
|
|
@@ -86,9 +86,11 @@ cat book.html | node dist-cli/cli.js - -o - --base . > book.pdf
|
|
|
86
86
|
- 文書が `http(s):` で参照する画像は、既定ではネットワークから取る。`--no-fetch-images` で取らない (他人の書いた文書をサーバーで組むときなど。読めない画像として組む)。ネットワークの画像は同時に 8 個まで取り、文書の画像の取得の全体にも時限がある (1 つの取得の時限の 10 倍。既定では 5 分。過ぎたら、残りは読めない画像として組む)
|
|
87
87
|
- 文書が `http(s):` で参照する CSS (`<link rel="stylesheet">`・`@import`) と、その `@font-face` の書体 (`unicode-range` が文書の字と重なるものだけ) も、既定ではネットワークから取る。`--no-fetch-styles` で取らない
|
|
88
88
|
- 画像の大きさには上限がある (小さなファイルで大量のメモリ・時間を使わせないため。値と根拠は `src/imageLimits.ts`)。1 枚の画像は 1 億画素まで。WMF・EMF・CGM の中の画像 (DIB・セルの並び・タイルの並び・模様) は、1 つのファイルで合計 6,400 万画素までで、かつ「26 万画素 (512 × 512) + ファイルの 1 バイトあたり 1,024 画素」まで (数百バイトのファイルから巨大な画像を作らせない。約 61KB より大きなファイルなら 6,400 万画素まで使える)。超えた画像は描かず、文書の残りを組む。GIF・WebP・JPEG・CCITT の TIFF・RLE の BMP も、画素の数をファイルの大きさで縛り (形式ごとに、正当なファイルの符号の密度の上限から決めた値。ほぼ 1 色の大きな可逆の WebP、幅 16,384 画素より広い白紙の CCITT、ほぼ白紙の大きな RLE の BMP は、上限を超えれば描かない)、PNG は展開した大きさが圧縮したデータの 1,032 倍 (deflate の上限) を超えるものを描かない。WOFF・WOFF2 を戻した書体は 128MB まで、かつファイルの 100 倍 + 1MB まで。WMF・EMF・CGM を図にした長さ (2MB + ファイルの 1 バイトあたり 128 字) と、1 つの文書の EPS の実行時間の合計 (60 秒) にも上限がある
|
|
89
|
+
- 数千ページの文書は、ページの数に比例してメモリを使う。コマンドと API の `typesetToPdf` は、PDF をページごとに書き、書いたページの組版の結果を手放すので、組み終えた時点の組版の途中の結果 (字の多いページで 1 ページあたり約 0.7MB) がいちばん多い。組んだ結果も返す `typeset` (`areaTree`・`toPdf`・`renderPage`) は、文書全体の領域の木を持つので、その分多く使う (PostgreSQL の文書の FO (3,231 ページ) で、コマンドは生きている量が最大約 2.3GB、`typeset` で組んで `toPdf` を呼ぶと約 2.8GB)。Node のヒープの上限 (既定では機械のメモリによって決まり、多くても約 4GB) で止まるときは (`JavaScript heap out of memory`)、`--low-memory` (下を見てください) を付けるか、`node --max-old-space-size=8192 dist-cli/cli.js book.fo -o book.pdf` のように上限を上げる (単位は MB)。画像のバイト列は V8 のヒープの外に置くので、`--max-old-space-size` の上限には入らないが、機械のメモリを使う。PDF だけを作るとき (コマンド・`typesetToPdf`) は、画像を PDF に埋め込むごとに元のバイト列を手放すので、画像の多い文書で使うメモリは、画像の量 (読み込んだファイルの大きさ) の約 3 倍 (埋め込んだ写しと、出来上がりの PDF など。`typeset` で組むと、元のバイト列も持つので約 3.5 倍)
|
|
89
90
|
- 他人の書いた文書をサーバーで組むときは、上の上限とは別に、1 つの文書を組む処理にも時間とメモリの上限をかけてください (文書ごとに別のプロセスかワーカーで組み、時限を過ぎたら止める。`node --max-old-space-size=…` やコンテナのメモリの上限を付ける、など)。上の上限は 1 つの画像・書体ごとのもので、上限いっぱいの画像 1 枚でも数秒〜十数秒と 2GB ほどを使い、文書が多くの画像・書体を参照すれば、その数だけ手間が増える
|
|
90
91
|
- 文書の外へのリンク (HTML の `<a href>`・XSL-FO の `fo:basic-link`・`fo:bookmark` の `external-destination`) のうち、PDF に動作を書くのは、既定では、スキームが `http`・`https`・`mailto`・`tel` の URL と、相対参照の PDF (別の PDF を開く動作) だけ。ほかのスキーム (`javascript:`・`data:`・`file:` など) と、ファイルを開く動作 (PDF でない相対のファイル・絶対パス・スキームの無い `//host/…`) は、字だけを組み、「警告:」に件数を出す (他人の書いた文書から作った PDF を、別の人が開くときのため)。`--link-schemes http,https,ftp` で許すスキームを選び (`*` はすべて)、`--link-launch` でファイルを開く動作も書く (`--link-schemes '*' --link-launch` で、すべて書く)。`--link-relative uri` で、スキームの無い相対のリンク (`x.pdf`・`a.mp3`) を、ファイルを開く動作 (GoToR・Launch) ではなく、書かれた参照のままの URI の動作 (`/S /URI /URI (x.pdf)`。`%xx` は解かない) に書く (ブラウザの中の PDF ビューアは GoToR・Launch を扱わないものが多い。PDF でない相対のファイルも `--link-launch` 無しで書く。絶対パスと `//host/…` は `--link-launch` のときだけ)。API では `links: { relative: 'uri' }`
|
|
91
92
|
- 文書・CSS が `file:` の URL で参照するファイル (`file:///…/style.css` など) は、入力のディレクトリの外でも、そのファイルを読む。相対参照が入力のディレクトリの外を指すもの (`sub/a.html` の `url(../fonts/a.ttf)` など) も同じく読む (ブラウザで手元の HTML を開いたときと同じ)。`--no-outside-files` で、入力のディレクトリの外のファイルを読まない (他人の書いた文書を組むとき。文書が指した画像・書体・SVG は、読めた中身が PDF に描かれるので、組む側の機械のほかのファイルを写し取られないようにする。入力のディレクトリの中のファイルは、これまでどおり読む)。`@font-face` の `src` のどのファイルも見つからないときは、警告で知らせる
|
|
93
|
+
- `--low-memory`: メモリを節約して組む。ページ番号の参照 (目次など) を決めるための組み直しで、前の回のページを使い回さず、組み終えた page-sequence (HTML は文書) の組版の途中の結果を手放す。そのため、組み直しの回を終えた後で、もう 1 度組んで PDF に書く。PDF は同じ。PostgreSQL の文書の FO (3,231 ページ) で、生きているヒープの最大が約 2.3GB → 約 0.9GB (いちばん多いのは FO の読み込みの所。ヒープの上限 1GB で組める)、時間は 160 秒 → 231 秒。API では `typesetToPdf` の `lowMemory`
|
|
92
94
|
- `--watch`: 入力のディレクトリの HTML・FO・CSS・画像・書体が変わるたびに組み直す
|
|
93
95
|
- `--help` (`-h`) で使い方、`--version` (`-v`) で版を出す
|
|
94
96
|
- 未対応の CSS のプロパティ・値 (対応仕様説明書の 16 章の一覧) と、Kumiori の知らないプロパティ (綴りの誤りか未対応)、XSL-FO の読めない要素・プロパティ、読めない画像などは、黙って無視せずに「警告:」として知らせる (ライブラリでは `result.warnings`)
|
|
@@ -107,7 +109,7 @@ cat book.html | node dist-cli/cli.js - -o - --base . > book.pdf
|
|
|
107
109
|
- `--plugin <モジュール>`: プラグイン (API の `plugins`) を読み込む。ファイルの道か、パッケージの名前。探す順は、(1) `./`・`../` で始まるもの、絶対の道、`file:` の URL は、ファイルの道 (`./plugin.js` など)。(2) それ以外は、`import()` と同じに、まずパッケージの名前として探す (`import()` と同じ条件 (`exports` の `import`・`node`・`default`) で、今のディレクトリから。`@scope/name`・`name/sub` も、`kp/dist/plugin.js`・`chart.js` のような拡張子で終わるものも書ける。今のディレクトリに同じ名前のディレクトリがあっても、パッケージとして探す)。(3) パッケージとして読めなければ (パッケージが無いときのほか、指したサブパスをそのパッケージが `exports` で出していないときや、パッケージの入口のファイルが無いときも)、今のディレクトリのその名前のファイルを読む (`--plugin myplugin.js`)。パッケージとして読めるときはパッケージを読むので、確実にファイルを読ませたいときは `./` を付ける。見つからないときは、何をどの順に探したかを誤りの文に書く。何度でも書ける。モジュールの `default` は、プラグインか、プラグインを返す関数 (`(選択肢, { cacheDir, lang }) => プラグイン`。`lang` は `--lang`・環境で決めた文言の言語)。`--plugin-option <名前>=<値>` は、その前の `--plugin` の関数に渡す選択肢 (何度でも)。プラグインはプログラムそのもので、Kumiori と同じ権限で動くので、信頼できるものだけを書く
|
|
108
110
|
- `--print`: トンボと塗り足し (3mm)
|
|
109
111
|
- `--image-max-dpi <dpi>`: 置かれる大きさに対してこれより細かい JPEG の写真を、この解像度に縮めて符号化し直す (PDF を小さくする。既定は元のまま)
|
|
110
|
-
- `--pdfx x3|x4`: 入稿用の PDF/X-3:2003・PDF/X-4 の印を付ける。RGB の色・画像は CMYK に、灰色の字・線・塗りは K だけの CMYK にし、本文 (ページの余白の字も) の K だけの黒の 12pt 未満の字と、2pt 未満の線・罫線にはノセ (overprint) を付け (Ghent Workgroup の入稿の仕様 GWG 2022 の推奨。図 (SVG・EPS など) の中の字・線には付けない)、ページには TrimBox だけを書き、ページの中のリンク・注釈・フォームの欄は書かずに、件数を警告に出す (塗り足しまでの範囲 (BleedBox) と少しでも重なるものを書かない。BleedBox はページの絵柄の全体を囲むので、目次などの内部のリンクも外の URL へのリンクも、ほぼ全部が無くなる。しおりは残る。画面で読むための PDF は、`--pdfx` を付けずに書き出す)。GWG 2022 の要件のうち、ページの仕上がりの大きさの違い・特色・画像の粗さ (149ppi 以下、と 224ppi 以下) も警告に出す (商業印刷の枚葉の用途の値)。PDF/X-3
|
|
112
|
+
- `--pdfx x1a|x1a:2003|x3|x4`: 入稿用の PDF/X-1a:2001・PDF/X-1a:2003・PDF/X-3:2003・PDF/X-4 の印を付ける。RGB の色・画像は CMYK に、灰色の字・線・塗りは K だけの CMYK にし、本文 (ページの余白の字も) の K だけの黒の 12pt 未満の字と、2pt 未満の線・罫線にはノセ (overprint) を付け (Ghent Workgroup の入稿の仕様 GWG 2022 の推奨。図 (SVG・EPS など) の中の字・線には付けない)、ページには TrimBox だけを書き、ページの中のリンク・注釈・フォームの欄は書かずに、件数を警告に出す (塗り足しまでの範囲 (BleedBox) と少しでも重なるものを書かない。BleedBox はページの絵柄の全体を囲むので、目次などの内部のリンクも外の URL へのリンクも、ほぼ全部が無くなる。しおりは残る。画面で読むための PDF は、`--pdfx` を付けずに書き出す)。GWG 2022 の要件のうち、ページの仕上がりの大きさの違い・特色・画像の粗さ (149ppi 以下、と 224ppi 以下) も警告に出す (商業印刷の枚葉の用途の値)。PDF/X-4 は透明をそのまま出し、XMP のメタデータに版の印を書く。PDF/X-1a (CMYK と特色だけ、透明は使えない。:2001 は PDF 1.3、:2003 は PDF 1.4) と PDF/X-3 (透明は使えない。機器によらない色 (ICC・Lab) は使える。PDF 1.4) は、書き出した PDF を読み直して決まり (版・印・色空間・透明・書体の埋め込み・ボックス・注釈) に合うかを調べ、合わなければ誤りで止める。透明は平らにする: 透明な物 (不透明度・透明度つきの色・透明度つきの画像・SVG の半透明やマスク) の下が 1 色の塗り (箱の背景・ページの白) だけなら、ベクタのまま、合成した CMYK の色の不透明な物で描き、ほかは、その範囲を下の物と合わせて CMYK の画像 (300ppi。12pt 未満の字が掛かる所は 600ppi) にして置き、警告に出す (画像にした所に字が掛かれば、字の質が落ちて文字として選べなくなることも警告に出す)。平らにできない透明 (色つきの字形の透明など) が残れば誤りで止める。重なった所の色は CMYK で合成するので (印刷と同じ)、RGB で合成する画面のビューアの見た目とは少し違う。日本の印刷所で主に使われているのは PDF/X-4 と PDF/X-1a
|
|
111
113
|
- `--output-profile <ICC ファイル>`: 出力の CMYK の ICC プロファイル (印刷所の指定するもの。Japan Color 2001 Coated など)。PDF に埋め込み、RGB の色・画像はこの表で CMYK にする。`--pdfx x4` では必須 (無いか CMYK のものでなければ誤り)。`--output-condition <名前>` で印刷条件の名前 (既定は ICC の登録名 JC200103) を渡す
|
|
112
114
|
- `--spot-colors <JSON ファイル>`: 特色の名前と、濃度 100% のときの代わりの CMYK (`{"名前": "cmyk(20%,40%,60%,80%)"}` か `{"名前": [0.2,0.4,0.6,0.8]}`。配列は 0〜1 の数で、1 を超える値は誤り)。`rgb-icc(r,g,b,#Separation,'名前',濃度)` の色のうち、ここに名前のあるものを PDF の Separation (代わりの色空間は DeviceCMYK、濃度の変換は線形) で書く。`rgb-icc()` は、XSL-FO ではどちらの `--compat` でも読み、HTML では `--style ah` のときだけ読む (CSS の色の関数に無い、アンテナハウスの書き方のため。ほかのスタイルでは、読めない値として宣言ごと無視し、警告に出す)。名前の無いものは、これまでどおり代わりの RGB で書く。名前の字は UTF-8 で書く (ISO 32000-2 §7.3.5)。特色の値 (色見本帳の値など) は Kumiori には入っていないので、使う人が渡す
|
|
113
115
|
- HTML は linkedom で読み、CSS の計算値は自前のカスケード (画面の「CSS の解釈: Kumiori」と同じ)
|
|
@@ -125,7 +127,7 @@ npm install kumiori
|
|
|
125
127
|
このリポジトリで作るときは `npm run build:lib` (dist-lib/。ES モジュールと型の宣言)。
|
|
126
128
|
|
|
127
129
|
```ts
|
|
128
|
-
import { typeset, walkAreaTree } from 'kumiori';
|
|
130
|
+
import { typeset, typesetToPdf, walkAreaTree } from 'kumiori';
|
|
129
131
|
|
|
130
132
|
// HTML+CSS (XSL-FO も同じ関数で組める。種類は name の拡張子か中身で見分ける)
|
|
131
133
|
const result = await typeset(html, {
|
|
@@ -139,6 +141,7 @@ const result = await typeset(html, {
|
|
|
139
141
|
console.log(result.pageCount, result.warnings);
|
|
140
142
|
walkAreaTree(result.areaTree, (area) => { /* 組んだ結果 (Area Tree) をたどる */ });
|
|
141
143
|
const pdf = await result.toPdf(); // Uint8Array
|
|
144
|
+
const { pdf: bytes } = await typesetToPdf(html, { name: 'book.html' }); // PDF だけが要るとき (組んだ結果を持たないので、大きな文書で使うメモリが少ない)
|
|
142
145
|
result.renderPage(canvas, 0); // 1 ページ目を canvas に描く (ブラウザ)
|
|
143
146
|
```
|
|
144
147
|
|
|
@@ -146,7 +149,8 @@ result.renderPage(canvas, 0); // 1 ページ目
|
|
|
146
149
|
- `text` は文字列です。ファイルから読むときは `decodeDocumentText(bytes)` で文字列にすると、BOM・XML 宣言の `encoding`・`<meta charset>` に従って復号します (UTF-8 固定で読むと、Shift_JIS の FO などが化けます)
|
|
147
150
|
- 主な `options`: `kind` (`html`・`xhtml`・`fo`。省略すれば `name` と中身で決める)、`name` (入力のファイル名)、`files` (CSS・画像・書体。書体は TTF・OTF・TTC・WOFF・WOFF2)、`fonts` (足す書体)、`genericFonts` (総称の書体に使う書体。名前は `--generic-font` と同じ `serif`・`sans-serif`・`monospace`・`serif-cjk`・`sans-serif-cjk`)、`style` (HTML の既定のスタイル)、`pageSize` (HTML の既定の用紙。`@page` で `size` を指定していない文書の用紙を、CSS の `size` の書き方で: `"A5"`・`"A5 landscape"`・`"148mm 210mm"`。既定は A4。文書の `@page { size }` が勝つ。`@media` の `width`・`height` もこの用紙で評価する)、`compat` (XSL-FO の既定値の流儀)、`print` (塗り足しとトンボ)、`spotColors` (特色の代わりの CMYK)、`loadFont`、`fetchTimeoutMs` (書体・画像の取得の時限。既定 30 秒)、`fetchImages` (文書が `http(s):` で参照する画像を取るか。既定 `true`。`false` か、URL を受けて真偽を返す関数。他人の文書をサーバーで組むときは止めるか、許す URL だけにする)、`fetchStyles` (文書が `http(s):` で参照する CSS と、その `@font-face` の書体を取るか。`fetchImages` と同じ形)、`resolveResource` (文書・CSS が参照するファイルのうち `files` に無いものの中身を返す関数。下を見てください)、`links` (文書の外へのリンクのうち、PDF に動作を書くもの。`{ schemes?: string[]; launch?: boolean; relative?: 'file' | 'uri' }`。既定では、スキームが `http`・`https`・`mailto`・`tel` の URL と相対参照の PDF だけを書き、ほかは字だけを組んで `warnings` に知らせる。`schemes` は許すスキームの一覧 (既定と置き換わる。`'*'` はすべて)、`launch: true` はファイルを開く動作 (PDF でない相対のファイル・絶対パス・`//host/…`) も書く。すべて書くには `{ schemes: ['*'], launch: true }`)、`svgLanguages` (SVG の `systemLanguage` を照らす言語タグの配列。`--svg-lang` と同じ)、`lang` (`warnings` と誤りの文の言語。`ja` か `en`。既定は日本語)、`deflate` (Node なら `zlib.deflateSync` を渡すと PDF の書き出しが速い)
|
|
148
151
|
- `fetchImages`・`fetchStyles` に渡す関数には、文書に書かれた URL のほか、転送 (redirect) の先の URL も聞きます。Node では、転送を 1 つずつ確かめてたどり (20 回まで)、許されない先へは要求を出しません。`https:` から `http:` への転送と、`http(s):` でない先への転送は、関数に聞かずに断ります (真偽の `true` のときも同じ)。ブラウザでは、転送の先をスクリプトから前もって読めないので、たどった後の最後の URL を関数に聞き、許されなければ応答を使いません (このとき、要求そのものは転送の先に届いています)。関数が見るのは URL の文字列だけです。内部のアドレスに解決されるホスト名 (DNS rebinding を含む) は、関数では防げません。他人の書いた文書をサーバーで組むときに内部の網を守るには、実行環境の側 (外向きの通信の制限・外向きのプロキシ) でも絞ってください。ネットワークから取るものの大きさには上限があります (画像 256MB・CSS 16MB・書体 128MB)。超えたものは、読むのを途中でやめて、読めない資源として扱います (`Content-Length` の無い応答でも同じ)。`fetchTimeoutMs` の時限は、本体を読み終えるまで効きます
|
|
149
|
-
- `result.toPdf({ title, pdfx, imageMaxDpi })`: PDF の題名、PDF/X の印 (`pdfx: { version: 'X-3' | 'X-4', condition, info, profile, warnings }`。RGB の色・画像を CMYK にする。既定は X-3。X-4 は CMYK の ICC プロファイル `profile`
|
|
152
|
+
- `result.toPdf({ title, pdfx, imageMaxDpi })`: PDF の題名、PDF/X の印 (`pdfx: { version: 'X-1a' | 'X-1a:2003' | 'X-3' | 'X-4', condition, info, profile, warnings }`。RGB の色・画像を CMYK にする。既定は X-3。X-4 は CMYK の ICC プロファイル `profile` が要る。X-1a・X-3 は透明を平らにし、書き出した PDF を決まりに照らして調べる (コマンドの `--pdfx` の説明)。コマンドの `--pdfx` と同じく、ページの中のリンク・注釈・フォームの欄は書かずに、件数を `warnings` に足す。しおりは残る)、JPEG の解像度の上限。PDF を書く途中の警告 (描けない字・色つきの字形を色つきで描けないことなど) は、`result.warnings` に足す。`result.renderPage(canvas, i, { scale, devicePixelRatio, guides })`: 倍率、画面の画素の細かさ、仕上がり・塗り足しのガイド線
|
|
153
|
+
- `typesetToPdf(text, options, pdfOptions)`: PDF だけを作ります (`typeset` の後に `toPdf(pdfOptions)` を呼ぶのと同じ PDF・警告・ページ数)。結果は `{ pdf, pageCount, warnings, layoutMs }` (型は `TypesetPdfResult`。`pdfOptions` の型は `PdfOptions` で、`toPdf` と同じ)。ページを 1 枚ずつ組んだ結果 (Area Tree) にして PDF に書き、書いたページを手放すので、文書全体の組んだ結果を持たず、数千ページの文書で使うメモリが少なくなります (ページの組んだ結果を、使う書体・画像を集めるときと描くときの 2 度作ります)。`areaTree`・`renderPage` はありません。`layoutMs` は、ページを組んだ結果にする時間を含みません (PDF を書く時間に入る)。Node のコマンドも、これで PDF を作ります。`pdfOptions` に `lowMemory: true` を付けると、メモリを節約して組みます (型は `TypesetPdfOptions`。コマンドの `--low-memory` と同じ)。`createTypesetter()` の器にも `typesetter.typesetToPdf(text, options, pdfOptions)` があります
|
|
150
154
|
- FO の DOCTYPE の内部サブセットに宣言した内部実体 (`<!ENTITY nbsp " ">` など) は、読み込みの前に展開します (外部実体は読みません)
|
|
151
155
|
- 例外: FO の XML が読めない (`XML の解析に失敗しました: …`)、既定の書体が読めない (`書体を読めません: …`) は `typeset` が投げる。`fonts` に渡した壊れた書体ファイルは投げずに `warnings` に入る。`renderPage` の無いページ番号は `RangeError`。組版の警告 (読めない画像・溢れなど) は投げずに `result.warnings` (文字列の配列) に入る
|
|
152
156
|
- `resolveResource(url)`: 文書・CSS が参照するファイル (`<link rel="stylesheet">`・`@import`・`url()`・`<img src>` など) のうち、`files` に無いものを問い合わせます。`url` は書かれた参照 (`file:///…/a.css`・`img/a.png`・`https://…`) で、CSS の中の相対参照は、その CSS の URL を基準に解決したものです。中身 (文字列・`Uint8Array`・`ArrayBuffer`) を返せばそれを使い、`undefined` ならこれまでどおり (`http(s):` の画像・CSS はネットワークから取る) です。参照を書き換えて `files` に入れ直す手間が要りません。画像は、URL に拡張子が無くても (`https://example.com/img?id=1` など)、返した中身の先頭のバイト列で画像と見分けて使います
|
|
@@ -166,7 +170,7 @@ result.renderPage(canvas, 0); // 1 ページ目
|
|
|
166
170
|
|
|
167
171
|
```html
|
|
168
172
|
<script type="module">
|
|
169
|
-
import { typesetHtml } from 'https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
173
|
+
import { typesetHtml } from 'https://cdn.jsdelivr.net/npm/kumiori@0.4.0/dist-browser/kumiori.js';
|
|
170
174
|
const result = await typesetHtml(html, { name: 'a.html' });
|
|
171
175
|
result.renderPage(document.querySelector('canvas'), 0);
|
|
172
176
|
</script>
|
|
@@ -235,7 +239,7 @@ async function showPreview(bodyHtml: string, container: HTMLElement) {
|
|
|
235
239
|
| `src/fontMapping.ts`, `src/compat.ts`, `src/documentResources.ts`, `src/documentText.ts`, `src/cli.ts` | 書体の割り当て・互換モードの設定・数式書体と画像の取得・文字の符号化の判定 (画面と Node で共通)、Node のコマンド |
|
|
236
240
|
| `src/webFont.ts`, `src/fontLoader.ts`, `src/userFonts.ts` | WOFF・WOFF2 を TTF・OTF に戻す、利用者の書体のファイル (TTC を含む) を書体ごとに分けて名前を読む、画面で読み込んだ書体の保存 |
|
|
237
241
|
| `src/colorGlyph.ts`, `src/colorGlyphPdf.ts`, `src/colorGlyphCanvas.ts`, `src/colorGlyphSvg.ts` | 色つきの字形 (カラーの絵文字など) を書体の表から読み、PDF と Canvas に描く (OpenType の SVG の表の字形を含む) |
|
|
238
|
-
| `src/color.ts`, `src/cssColorFunctions.ts`, `src/cssGradient.ts`, `src/icc.ts`, `src/pdfStandard.ts` | 色の指定の読み取り、CSS Color 4・5 の色の関数、CSS のグラデーション、ICC プロファイルでの CMYK への変換、PDF/X-3・PDF/X-4 の方針 |
|
|
242
|
+
| `src/color.ts`, `src/cssColorFunctions.ts`, `src/cssGradient.ts`, `src/icc.ts`, `src/pdfStandard.ts` | 色の指定の読み取り、CSS Color 4・5 の色の関数、CSS のグラデーション、ICC プロファイルでの CMYK への変換、PDF/X-1a・PDF/X-3・PDF/X-4 の方針 |
|
|
239
243
|
| `src/assets.ts`, `src/linkPolicy.ts`, `src/messages.ts` | 画像の登録所 (組版・Canvas・PDF で共有)、文書の外へのリンクを PDF のどの動作にするかの方針、利用者に見せる文言 (日本語・英語) |
|
|
240
244
|
| `src/drawio/` | draw.io の図 (`.drawio`・`.dio`) を読んで SVG にする (draw.io と mxGraph のソースから移した形・線の描き方。図が出てきたときだけ読み込む。[`docs/drawio.md`](docs/drawio.md)) |
|
|
241
245
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
4
|
-
import { n as e, t } from "./rolldown-runtime-
|
|
5
|
-
import { t as n } from "./pako-
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
|
+
import { n as e, t } from "./rolldown-runtime-BV67vctc.js";
|
|
5
|
+
import { t as n } from "./pako-BwlM3ygd.js";
|
|
6
6
|
// node_modules/utif/UTIF.js
|
|
7
7
|
var r = /* @__PURE__ */ t(((t, r) => {
|
|
8
8
|
(function() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
4
|
-
import { F as e, g as t, h as n, j as r } from "./pixels-
|
|
5
|
-
import { r as i } from "./epsInfo-
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
|
+
import { F as e, g as t, h as n, j as r } from "./pixels-BvYSA32R.js";
|
|
5
|
+
import { r as i } from "./epsInfo-D7b8OFlX.js";
|
|
6
6
|
// src/jpegTables.ts
|
|
7
7
|
var a = [
|
|
8
8
|
0,
|
|
@@ -1292,7 +1292,7 @@ function ne(e) {
|
|
|
1292
1292
|
if (i && a) return e.subarray(i, i + a);
|
|
1293
1293
|
}
|
|
1294
1294
|
async function re(e) {
|
|
1295
|
-
let { cgmPictureSize: t } = await import("./cgm-
|
|
1295
|
+
let { cgmPictureSize: t } = await import("./cgm-Blvzv6Sp.js"), n = t(e);
|
|
1296
1296
|
return n && {
|
|
1297
1297
|
mime: "image/cgm",
|
|
1298
1298
|
width: n.width,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
4
|
-
import { N as e, P as t, a as n, l as r, p as i } from "./pixels-
|
|
5
|
-
import { a, n as o, s } from "./ccitt-
|
|
6
|
-
import { a as c, l, u } from "./epsInfo-
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
|
+
import { N as e, P as t, a as n, l as r, p as i } from "./pixels-BvYSA32R.js";
|
|
5
|
+
import { a, n as o, s } from "./ccitt-DuYpUkox.js";
|
|
6
|
+
import { a as c, l, u } from "./epsInfo-D7b8OFlX.js";
|
|
7
7
|
// src/cgm.ts
|
|
8
8
|
var d = 96 / 25.4, f = 400, p = [
|
|
9
9
|
1,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
4
|
/*!
|
|
5
5
|
* Hyphenation patterns for Modern Greek, monotonic (hyph-el-monoton.tex of the hyph-utf8 package), converted to JavaScript by the npm package "hyphen".
|
|
6
6
|
* Copyright (C) 2008-2011 Dimitrios Filippou
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
18
|
* SOFTWARE.
|
|
19
19
|
* See THIRD_PARTY_NOTICES.md, section 1.4. */
|
|
20
|
-
import { t as e } from "./rolldown-runtime-
|
|
21
|
-
import { t } from "./export-contract-
|
|
20
|
+
import { t as e } from "./rolldown-runtime-BV67vctc.js";
|
|
21
|
+
import { t } from "./export-contract-J-x2aLjv.js";
|
|
22
22
|
// node_modules/hyphen/patterns/el-monoton.js
|
|
23
23
|
var n = /* @__PURE__ */ e(((e, t, n) => {
|
|
24
24
|
(function(e, n) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
4
|
/*!
|
|
5
5
|
* Hyphenation patterns for British English (hyph-en-gb.tex of the hyph-utf8 package), converted to JavaScript by the npm package "hyphen".
|
|
6
6
|
* Copyright (C) 1992, 1996, 2005, 2016 Dominik Wujastyk, Graham Toal
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
18
|
* SOFTWARE.
|
|
19
19
|
* See THIRD_PARTY_NOTICES.md, section 1.4. */
|
|
20
|
-
import { t as e } from "./rolldown-runtime-
|
|
21
|
-
import { t } from "./export-contract-
|
|
20
|
+
import { t as e } from "./rolldown-runtime-BV67vctc.js";
|
|
21
|
+
import { t } from "./export-contract-J-x2aLjv.js";
|
|
22
22
|
// node_modules/hyphen/patterns/en-gb.js
|
|
23
23
|
var n = /* @__PURE__ */ e(((e, t, n) => {
|
|
24
24
|
(function(e, n) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
4
|
/*!
|
|
5
5
|
* Hyphenation patterns for American English (hyph-en-us.tex of the hyph-utf8 package), converted to JavaScript by the npm package "hyphen".
|
|
6
6
|
* Copyright (C) 1990, 2004, 2005 Gerard D.C. Kuiken
|
|
7
7
|
* Copying and distribution of this file, with or without modification, are permitted in any medium without royalty
|
|
8
8
|
* provided the copyright notice and this notice are preserved.
|
|
9
9
|
* See THIRD_PARTY_NOTICES.md, section 1.4. */
|
|
10
|
-
import { t as e } from "./rolldown-runtime-
|
|
11
|
-
import { t } from "./export-contract-
|
|
10
|
+
import { t as e } from "./rolldown-runtime-BV67vctc.js";
|
|
11
|
+
import { t } from "./export-contract-J-x2aLjv.js";
|
|
12
12
|
// node_modules/hyphen/patterns/en-us.js
|
|
13
13
|
var n = /* @__PURE__ */ e(((e, t, n) => {
|
|
14
14
|
(function(e, n) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
4
|
-
import { a as e, c as t, o as n, r, s as i } from "./epsInfo-
|
|
5
|
-
import { i as a, l as o, p as s } from "./pixels-
|
|
6
|
-
import { i as c, n as l, o as u, r as d, s as f, t as p } from "./matrix-
|
|
7
|
-
import { c as m, l as h, n as g, r as _, s as v, t as y } from "./strokeOutline-
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
|
+
import { a as e, c as t, o as n, r, s as i } from "./epsInfo-D7b8OFlX.js";
|
|
5
|
+
import { i as a, l as o, p as s } from "./pixels-BvYSA32R.js";
|
|
6
|
+
import { i as c, n as l, o as u, r as d, s as f, t as p } from "./matrix-DxjvN-4S.js";
|
|
7
|
+
import { c as m, l as h, n as g, r as _, s as v, t as y } from "./strokeOutline-yLvGVz8Y.js";
|
|
8
8
|
// src/psInterp.ts
|
|
9
9
|
var b = { t: "null" }, x = { t: "mark" }, S = {
|
|
10
10
|
t: "bool",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
4
|
-
import { L as e } from "./pixels-
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
|
+
import { L as e } from "./pixels-BvYSA32R.js";
|
|
5
5
|
// src/psFilters.ts
|
|
6
6
|
var t = class extends Error {}, n = 4096;
|
|
7
7
|
function r(e, t) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
4
|
-
import { t as e } from "./rolldown-runtime-
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
|
+
import { t as e } from "./rolldown-runtime-BV67vctc.js";
|
|
5
5
|
// node_modules/hyphen/hyphen.js
|
|
6
6
|
var t = /* @__PURE__ */ e(((e, t, n) => {
|
|
7
7
|
(function(e, n) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
4
|
/*!
|
|
5
5
|
* Hyphenation patterns for modern and medieval Latin (hyph-la.tex of the hyph-utf8 package), converted to JavaScript by the npm package "hyphen".
|
|
6
6
|
* Copyright (C) 1999-2016 Claudio Beccari
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
18
|
* SOFTWARE.
|
|
19
19
|
* See THIRD_PARTY_NOTICES.md, section 1.4. */
|
|
20
|
-
import { t as e } from "./rolldown-runtime-
|
|
21
|
-
import { t } from "./export-contract-
|
|
20
|
+
import { t as e } from "./rolldown-runtime-BV67vctc.js";
|
|
21
|
+
import { t } from "./export-contract-J-x2aLjv.js";
|
|
22
22
|
// node_modules/hyphen/patterns/la.js
|
|
23
23
|
var n = /* @__PURE__ */ e(((e, t, n) => {
|
|
24
24
|
(function(e, n) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
4
|
/*! Includes code ported from draw.io and mxGraph (https://github.com/jgraph/drawio), licensed under the Apache License 2.0:
|
|
5
5
|
* Copyright (c) 2006-2026, JGraph Holdings Ltd; Copyright (c) 2006-2026, draw.io AG; Copyright (c) 2006-2020, JGraph Ltd.
|
|
6
6
|
* The shapes from draw.io's src/main/webapp/shapes/ are ported from draw.io v24.7.5 (Apache License 2.0 only).
|
|
7
7
|
* See section 13 of THIRD_PARTY_NOTICES.md. */
|
|
8
|
-
import { r as e } from "./rolldown-runtime-
|
|
9
|
-
import {
|
|
10
|
-
import { t as a } from "./pako-
|
|
8
|
+
import { r as e } from "./rolldown-runtime-BV67vctc.js";
|
|
9
|
+
import { A as t, n, o as r, r as i } from "./sniff-CqYWlxhA.js";
|
|
10
|
+
import { t as a } from "./pako-BwlM3ygd.js";
|
|
11
11
|
// src/drawio/drawioText.ts
|
|
12
12
|
var o;
|
|
13
13
|
function s(e, t) {
|
|
@@ -47,19 +47,19 @@ function l(e, t, n = "Helvetica", r = !1, i = !1) {
|
|
|
47
47
|
return a * t;
|
|
48
48
|
}
|
|
49
49
|
var u, d = /* @__PURE__ */ new Map();
|
|
50
|
-
function f(e,
|
|
51
|
-
let i = (
|
|
50
|
+
function f(e, n) {
|
|
51
|
+
let i = (n ? "b" : "r") + e, a = d.get(i);
|
|
52
52
|
if (a !== void 0) return a;
|
|
53
53
|
let o = e.codePointAt(0), s;
|
|
54
54
|
if (p(o)) s = 1;
|
|
55
55
|
else if (o < 8192) {
|
|
56
56
|
let i = (e) => t.for(e);
|
|
57
57
|
u ??= {
|
|
58
|
-
r: i(
|
|
59
|
-
b: i(
|
|
58
|
+
r: i(r.Helvetica),
|
|
59
|
+
b: i(r.HelveticaBold)
|
|
60
60
|
};
|
|
61
61
|
try {
|
|
62
|
-
s = (
|
|
62
|
+
s = (n ? u.b : u.r).widthOfTextAtSize(o === 160 ? " " : e, 1e3) / 1e3;
|
|
63
63
|
} catch {
|
|
64
64
|
s = .6;
|
|
65
65
|
}
|
|
@@ -2236,7 +2236,7 @@ var Ut = class e {
|
|
|
2236
2236
|
function Gt(e) {
|
|
2237
2237
|
return e.length > 8 && e[0] === 137 && e[1] === 80 && e[2] === 78 && e[3] === 71 ? "image/png" : e.length > 3 && e[0] === 255 && e[1] === 216 && e[2] === 255 ? "image/jpeg" : Jt(new TextDecoder().decode(e.subarray(0, 4096)).replace(/^\ufeff/, "").trimStart()) ? "image/svg+xml" : void 0;
|
|
2238
2238
|
}
|
|
2239
|
-
var Kt = (e) => /^https?:\/\//i.test(e), qt = new RegExp(String.raw`^(?:<\?xml[^>]*\?>\s*)?(?:${
|
|
2239
|
+
var Kt = (e) => /^https?:\/\//i.test(e), qt = new RegExp(String.raw`^(?:<\?xml[^>]*\?>\s*)?(?:${n}\s*|<!DOCTYPE[^>]*>\s*)*<svg[\s>]`, "i"), Jt = (e) => qt.test(e.slice(0, 4096)), Yt = (e) => /^img\/(?:[A-Za-z0-9_,()-]+\/){1,4}[^/\\?#%]+\.(?:svg|png|jpe?g)$/i.test(e) && !e.split("/").some((e) => e === ".." || e === "."), Xt = (e, t = At) => new URL(`../${e.split("/").map(encodeURIComponent).join("/")}`, t).href, Zt = (e) => /^#[0-9a-f]{3,8}$/i.test(e) || /^(?:rgb|rgba|hsl|hsla)\([\d\s.,%]+\)$/i.test(e), Qt = (e) => /^#[0-9a-f]{3,8}$/i.test(e) || /^(?:rgb|rgba|hsl|hsla)\([\d\s.,%]+\)$/i.test(e) || /^[a-z]+$/i.test(e);
|
|
2240
2240
|
function $t(e, t, n, r, i = 0) {
|
|
2241
2241
|
if (t.w <= 0 || t.h <= 0 || i > Mt.depth) return "";
|
|
2242
2242
|
let a = e.attrs, o = N(a.get("w"), 100) || 100, s = N(a.get("h"), 100) || 100, c = t.w / o, l = t.h / s, u = t.x, d = t.y;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
4
|
// src/matrix.ts
|
|
5
5
|
var e = [
|
|
6
6
|
1,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
4
|
-
import { N as e, P as t, a as n, b as r, l as i, o as a, p as o, t as s, x as c } from "./pixels-
|
|
5
|
-
import { a as l, n as u, o as d } from "./matrix-
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
|
+
import { N as e, P as t, a as n, b as r, l as i, o as a, p as o, t as s, x as c } from "./pixels-BvYSA32R.js";
|
|
5
|
+
import { a as l, n as u, o as d } from "./matrix-DxjvN-4S.js";
|
|
6
6
|
// src/regionBool.ts
|
|
7
7
|
var f = 25e-5;
|
|
8
8
|
function p(e, t) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
4
|
-
import { t as e } from "./rolldown-runtime-
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
|
+
import { t as e } from "./rolldown-runtime-BV67vctc.js";
|
|
5
5
|
// node_modules/pako/lib/utils/common.js
|
|
6
6
|
var t = /* @__PURE__ */ e(((e) => {
|
|
7
7
|
var t = typeof Uint8Array < "u" && typeof Uint16Array < "u" && typeof Int32Array < "u";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
4
|
// src/inflateFast.ts
|
|
5
5
|
var e = Uint16Array.from([
|
|
6
6
|
3,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
4
|
// \0rolldown/runtime.js
|
|
5
5
|
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), s = (e, i, o, s) => {
|
|
6
6
|
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! Kumiori (組み織り) 0.
|
|
1
|
+
/*! Kumiori (組み織り) 0.4.0 | Apache License 2.0 | Copyright 2026 Northern Lights Co.
|
|
2
2
|
* Third-party notices (第三者のソフトウェアの表示): THIRD_PARTY_NOTICES.md
|
|
3
|
-
* https://cdn.jsdelivr.net/npm/kumiori@0.
|
|
3
|
+
* https://cdn.jsdelivr.net/npm/kumiori@0.4.0/THIRD_PARTY_NOTICES.md */
|
|
4
4
|
/*!
|
|
5
5
|
* Hyphenation patterns for Russian. Copyright (C) 1999-2003 Alexander I. Lebedev.
|
|
6
6
|
* License: LaTeX Project Public License (LPPL), version 1.2 or later; distributed here under LPPL 1.3c
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* The author and maintainers of the original patterns do not provide any support for this modified version;
|
|
16
16
|
* report problems to the Kumiori project.
|
|
17
17
|
* See THIRD_PARTY_NOTICES.md, section 1.4. */
|
|
18
|
-
import { t as e } from "./rolldown-runtime-
|
|
19
|
-
import { t } from "./export-contract-
|
|
18
|
+
import { t as e } from "./rolldown-runtime-BV67vctc.js";
|
|
19
|
+
import { t } from "./export-contract-J-x2aLjv.js";
|
|
20
20
|
// node_modules/hyphen/patterns/ru.js
|
|
21
21
|
var n = /* @__PURE__ */ e(((e, t, n) => {
|
|
22
22
|
(function(e, n) {
|