@nxgt/material-core 0.1.1 → 0.3.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/README.md +178 -5
- package/dist/file-preview/describe-file.d.ts +30 -0
- package/dist/file-preview/describe-file.d.ts.map +1 -0
- package/dist/file-preview/file-kind.d.ts +41 -0
- package/dist/file-preview/file-kind.d.ts.map +1 -0
- package/dist/file-preview/index.d.ts +10 -0
- package/dist/file-preview/index.d.ts.map +1 -0
- package/dist/file-preview/index.js +260 -0
- package/dist/file-preview/index.js.map +13 -0
- package/dist/file-preview/safe-url.d.ts +22 -0
- package/dist/file-preview/safe-url.d.ts.map +1 -0
- package/dist/file-preview/text-preview.d.ts +32 -0
- package/dist/file-preview/text-preview.d.ts.map +1 -0
- package/dist/lib/date-range.d.ts +84 -0
- package/dist/lib/date-range.d.ts.map +1 -0
- package/dist/lib/date-range.js +105 -0
- package/dist/lib/date-range.js.map +10 -0
- package/dist/lib/format-file-size.d.ts +10 -0
- package/dist/lib/format-file-size.d.ts.map +1 -0
- package/dist/lib/format-file-size.js +17 -0
- package/dist/lib/format-file-size.js.map +10 -0
- package/dist/lib/slider-ticks.d.ts +7 -0
- package/dist/lib/slider-ticks.d.ts.map +1 -0
- package/dist/lib/slider-ticks.js +16 -0
- package/dist/lib/slider-ticks.js.map +10 -0
- package/dist/pdf-viewer/index.d.ts +1 -0
- package/dist/pdf-viewer/index.d.ts.map +1 -1
- package/dist/pdf-viewer/index.js +68 -33
- package/dist/pdf-viewer/index.js.map +6 -4
- package/dist/pdf-viewer/pdf-pin-page.d.ts +16 -0
- package/dist/pdf-viewer/pdf-pin-page.d.ts.map +1 -0
- package/dist/pdf-viewer/pdf-scroll-spy.d.ts +2 -8
- package/dist/pdf-viewer/pdf-scroll-spy.d.ts.map +1 -1
- package/dist/pdf-viewer/pdf-user-input.d.ts +7 -0
- package/dist/pdf-viewer/pdf-user-input.d.ts.map +1 -0
- package/dist/pdfkit-fonts/index.d.ts +61 -0
- package/dist/pdfkit-fonts/index.d.ts.map +1 -0
- package/dist/pdfkit-fonts/index.js +80 -0
- package/dist/pdfkit-fonts/index.js.map +10 -0
- package/docs/roadmap.md +12 -1
- package/docs/troubleshooting.md +65 -0
- package/package.json +33 -3
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/pdf-viewer/pdf-escape.ts", "../src/pdf-viewer/pdf-text-search.ts", "../src/pdf-viewer/pdf-document-search.ts", "../src/pdf-viewer/pdf-page-geometry.ts", "../src/pdf-viewer/pdf-page-sizes.ts", "../src/pdf-viewer/pdf-scroll-spy.ts"],
|
|
3
|
+
"sources": ["../src/pdf-viewer/pdf-escape.ts", "../src/pdf-viewer/pdf-text-search.ts", "../src/pdf-viewer/pdf-document-search.ts", "../src/pdf-viewer/pdf-page-geometry.ts", "../src/pdf-viewer/pdf-page-sizes.ts", "../src/pdf-viewer/pdf-user-input.ts", "../src/pdf-viewer/pdf-scroll-spy.ts", "../src/pdf-viewer/pdf-pin-page.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"export function escapeHtml(text: string): string {\n\treturn text\n\t\t.replace(/&/g, '&')\n\t\t.replace(/</g, '<')\n\t\t.replace(/>/g, '>')\n\t\t.replace(/\"/g, '"')\n\t\t.replace(/'/g, ''');\n}\n\nexport function mapPdfOutline(items: unknown): {\n\ttitle: string;\n\tdest: unknown;\n\titems: ReturnType<typeof mapPdfOutline>;\n}[] {\n\tif (!Array.isArray(items)) return [];\n\treturn items.map((item) => {\n\t\tconst node = item as {\n\t\t\ttitle?: string;\n\t\t\tdest?: unknown;\n\t\t\titems?: unknown;\n\t\t};\n\t\treturn {\n\t\t\ttitle: String(node.title ?? ''),\n\t\t\tdest: node.dest ?? null,\n\t\t\titems: mapPdfOutline(node.items),\n\t\t};\n\t});\n}\n",
|
|
6
6
|
"import { escapeHtml } from './pdf-escape';\n\n/** One item of `page.getTextContent()`: marked-content items have no `str`. */\nexport type PdfTextItem = { str?: string; hasEOL?: boolean };\n\n/** A page's text, and where each text item starts in it. */\nexport type PdfPageText = { text: string; starts: number[] };\n\n/** A match in a page's text: `end` is exclusive. */\nexport type PdfTextRange = { start: number; end: number };\n\n/** Joins the items' text, a line break after each item that ends a line. */\nexport function pageTextFromItems(items: readonly PdfTextItem[]): PdfPageText {\n\tlet text = '';\n\tconst starts: number[] = [];\n\tfor (const item of items) {\n\t\tstarts.push(text.length);\n\t\ttext += item.str ?? '';\n\t\tif (item.hasEOL) text += '\\n';\n\t}\n\treturn { text, starts };\n}\n\n/**\n * Lower case, accents and ligatures dropped (`Café` and `fi` match `cafe` and\n * `fi`), every run of white space one space; `origin` maps each folded\n * character back to its index in `text`.\n */\nfunction fold(text: string) {\n\tlet folded = '';\n\tconst origin: number[] = [];\n\tlet space = false;\n\tfor (let index = 0; index < text.length; index += 1) {\n\t\tconst char = text.charAt(index);\n\t\tif (/\\s/.test(char)) {\n\t\t\tif (!space) {\n\t\t\t\tfolded += ' ';\n\t\t\t\torigin.push(index);\n\t\t\t}\n\t\t\tspace = true;\n\t\t\tcontinue;\n\t\t}\n\t\tspace = false;\n\t\tfor (const part of char\n\t\t\t.normalize('NFKD')\n\t\t\t.replace(/\\p{M}/gu, '')\n\t\t\t.toLowerCase()) {\n\t\t\tfolded += part;\n\t\t\torigin.push(index);\n\t\t}\n\t}\n\treturn { folded, origin };\n}\n\n/** Every match of `query` in `text`, ignoring case, accents and spacing. */\nexport function findTextMatches(text: string, query: string): PdfTextRange[] {\n\tconst needle = fold(query.trim()).folded;\n\tif (!needle) return [];\n\tconst { folded, origin } = fold(text);\n\tconst matches: PdfTextRange[] = [];\n\tlet from = 0;\n\tfor (;;) {\n\t\tconst at = folded.indexOf(needle, from);\n\t\tif (at < 0) return matches;\n\t\tconst last = origin[at + needle.length - 1] ?? 0;\n\t\tmatches.push({ start: origin[at] ?? 0, end: last + 1 });\n\t\tfrom = at + needle.length;\n\t}\n}\n\n/**\n * One text item's HTML, its part of each match wrapped in\n * `<mark class=\"pdf-highlight\" data-hit=\"…\">`. A match across items gets a\n * mark in each; the current one also carries `data-current`.\n */\nexport function highlightItemHtml(\n\tstr: string,\n\titemStart: number,\n\tmatches: readonly PdfTextRange[],\n\tcurrent = -1,\n) {\n\tconst itemEnd = itemStart + str.length;\n\tlet html = '';\n\tlet at = itemStart;\n\tmatches.forEach((match, hit) => {\n\t\tif (match.end <= at || match.start >= itemEnd) return;\n\t\tconst start = Math.max(match.start, at);\n\t\tconst end = Math.min(match.end, itemEnd);\n\t\tconst mark = hit === current ? ' data-current=\"true\"' : '';\n\t\thtml += escapeHtml(str.slice(at - itemStart, start - itemStart));\n\t\thtml += `<mark class=\"pdf-highlight\" data-hit=\"${hit}\"${mark}>`;\n\t\thtml += `${escapeHtml(str.slice(start - itemStart, end - itemStart))}</mark>`;\n\t\tat = end;\n\t});\n\treturn html + escapeHtml(str.slice(at - itemStart));\n}\n",
|
|
7
7
|
"import {\n\tfindTextMatches,\n\ttype PdfPageText,\n\ttype PdfTextItem,\n\ttype PdfTextRange,\n\tpageTextFromItems,\n} from './pdf-text-search';\n\n/** Where a match sits: its page, and its rank among that page's matches. */\nexport type PdfSearchHit = { page: number; hit: number };\n\nexport type PdfTextSource = {\n\tnumPages: number;\n\tgetPage: (pageNumber: number) => Promise<{\n\t\tgetTextContent: () => Promise<{ items: readonly unknown[] }>;\n\t}>;\n};\n\nconst texts = new WeakMap<object, Map<number, Promise<PdfPageText>>>();\n\n/** A page's text, read once per document. */\nexport function loadPageText(pdf: PdfTextSource, pageNumber: number) {\n\tlet pages = texts.get(pdf);\n\tif (!pages) {\n\t\tpages = new Map();\n\t\ttexts.set(pdf, pages);\n\t}\n\tlet text = pages.get(pageNumber);\n\tif (!text) {\n\t\tconst cache = pages;\n\t\t// Without marked content, like the text layer: item i is span i.\n\t\ttext = pdf\n\t\t\t.getPage(pageNumber)\n\t\t\t.then((page) => page.getTextContent())\n\t\t\t.then(({ items }) => pageTextFromItems(items as PdfTextItem[]));\n\t\t// A failed read is tried again by the next search.\n\t\ttext.catch(() => cache.delete(pageNumber));\n\t\tpages.set(pageNumber, text);\n\t}\n\treturn text;\n}\n\n/** A page the search has read: its text and the matches in it. */\nexport type PdfPageMatches = {\n\tpage: number;\n\ttext: PdfPageText;\n\tmatches: PdfTextRange[];\n};\n\n/**\n * Searches every page in order, drawn or not, and reports the pages read: the\n * first one at once, then `chunk` at a time. A report per page would have the\n * reader draw every page again after each one read, a quadratic first search.\n * Stops once `isCancelled` says so.\n */\nexport async function searchDocument(\n\tpdf: PdfTextSource,\n\tquery: string,\n\tonPages: (pages: PdfPageMatches[]) => void,\n\tisCancelled: () => boolean = () => false,\n\tchunk = 25,\n) {\n\tlet found: PdfPageMatches[] = [];\n\tfor (let page = 1; page <= pdf.numPages; page += 1) {\n\t\tconst text = await loadPageText(pdf, page);\n\t\tif (isCancelled()) return;\n\t\tfound.push({ page, text, matches: findTextMatches(text.text, query) });\n\t\tif (page === 1 || found.length >= chunk || page === pdf.numPages) {\n\t\t\tonPages(found);\n\t\t\tfound = [];\n\t\t}\n\t}\n}\n\n/** Each page's text and matches, as far as the search has read. */\nexport type PdfDocumentMatches = {\n\ttexts: (PdfPageText | undefined)[];\n\tmatches: PdfTextRange[][];\n};\n\n/** `found` with a batch of pages read, copied once for the whole batch. */\nexport function withPageMatches(\n\tfound: PdfDocumentMatches,\n\tpages: readonly PdfPageMatches[],\n): PdfDocumentMatches {\n\tconst texts = [...found.texts];\n\tconst matches = [...found.matches];\n\tfor (const { page, text, matches: inPage } of pages) {\n\t\ttexts[page - 1] = text;\n\t\tmatches[page - 1] = inPage;\n\t}\n\treturn { texts, matches };\n}\n\n/**\n * The rank `delta` away from `from`, wrapping; from none (-1), the first\n * match forward or the last one back.\n */\nexport function stepHit(from: number, delta: number, count: number) {\n\tif (count <= 0) return -1;\n\tif (from < 0) return delta > 0 ? 0 : count - 1;\n\treturn (((from + delta) % count) + count) % count;\n}\n\n/** The hit at a document-wide rank, from each page's match count. */\nexport function hitAt(\n\tcounts: readonly (number | undefined)[],\n\tindex: number,\n): PdfSearchHit | null {\n\tlet rest = index;\n\tfor (let page = 0; page < counts.length; page += 1) {\n\t\tconst count = counts[page] ?? 0;\n\t\tif (rest < count) return { page: page + 1, hit: rest };\n\t\trest -= count;\n\t}\n\treturn null;\n}\n",
|
|
8
8
|
"/**\n * How the reader sizes a page: to the viewport's width, to the whole page, or\n * at a zoom the user chose.\n */\nexport type FitMode = 'width' | 'page' | 'custom';\n\n/**\n * A page's size in PDF points (1/72 inch), before any rotation, and the\n * rotation the page asks for itself (its `/Rotate`, in degrees clockwise).\n */\nexport type PdfPageSize = { width: number; height: number; rotate?: number };\n\n/** Used until a page's own size is known: US Letter. */\nexport const DEFAULT_PAGE_SIZE: PdfPageSize = { width: 612, height: 792 };\n\n/**\n * The fit zoom fits the first pages only, the ones read when the document\n * opens: pages read later never move it. A wider page further on is shown at\n * that zoom (and scrolls sideways in fit width).\n */\nexport const FIT_PAGES = 25;\n\n/** Room kept around the pages: the list's padding on each side. */\nexport const PAGE_PADDING = 32;\n\n// The reader's own MIN_SCALE and MAX_SCALE; kept here so this file stays\n// shared.\nconst MIN_FIT_SCALE = 0.25;\nconst MAX_FIT_SCALE = 5;\n\n/**\n * The rotation a page is drawn at: its own `/Rotate` plus the reader's, from\n * 0 to 270. `undefined` while the page's own is not known and the reader adds\n * none, so the renderer keeps the page's. Once the reader turns the pages, a\n * page whose size is not read yet (past the first chunk) is drawn at the\n * reader's rotation alone until its size arrives, then drawn again.\n */\nexport function pageRotation(\n\tsize: PdfPageSize | undefined,\n\trotation: number,\n): number | undefined {\n\tif (!size && !rotation) return undefined;\n\tconst turn = (size?.rotate ?? 0) + rotation;\n\treturn ((turn % 360) + 360) % 360;\n}\n\n/** The page's size on screen: turned by its own `/Rotate` and `rotation`. */\nexport function rotatedSize(size: PdfPageSize, rotation: number): PdfPageSize {\n\tconst turn = (size.rotate ?? 0) + rotation;\n\tconst quarter = ((turn % 180) + 180) % 180 === 90;\n\treturn quarter\n\t\t? { width: size.height, height: size.width }\n\t\t: { width: size.width, height: size.height };\n}\n\n/**\n * The widest and the tallest of the known pages, rotated. Fitting on it keeps\n * every page inside the box with one scale, so the zoom does not jump while\n * scrolling from an A4 page to a landscape one.\n */\nexport function largestPage(\n\tsizes: readonly (PdfPageSize | undefined)[],\n\trotation: number,\n): PdfPageSize {\n\tlet width = 0;\n\tlet height = 0;\n\tfor (const size of sizes) {\n\t\tif (!size) continue;\n\t\tconst turned = rotatedSize(size, rotation);\n\t\twidth = Math.max(width, turned.width);\n\t\theight = Math.max(height, turned.height);\n\t}\n\treturn width && height\n\t\t? { width, height }\n\t\t: rotatedSize(DEFAULT_PAGE_SIZE, rotation);\n}\n\n/**\n * The scale at which the largest page fits the box's width, or all of it,\n * within the reader's zoom range: a tiny page does not fit to 4000%.\n */\nexport function fitScale(\n\tmode: Exclude<FitMode, 'custom'>,\n\tlargest: PdfPageSize,\n\tbox: { width: number; height: number },\n\tpadding = PAGE_PADDING,\n) {\n\tconst byWidth = (box.width - padding) / largest.width;\n\tconst scale =\n\t\tmode === 'width'\n\t\t\t? byWidth\n\t\t\t: Math.min(byWidth, (box.height - padding) / largest.height);\n\treturn Math.min(MAX_FIT_SCALE, Math.max(MIN_FIT_SCALE, scale));\n}\n\n/**\n * The reader's zoom in fit width or fit page: the largest of the first\n * `FIT_PAGES` pages, rotated, fitted to the box.\n */\nexport function readerFitScale(\n\tmode: Exclude<FitMode, 'custom'>,\n\tsizes: readonly (PdfPageSize | undefined)[],\n\trotation: number,\n\tbox: { width: number; height: number },\n) {\n\treturn fitScale(mode, largestPage(sizes.slice(0, FIT_PAGES), rotation), box);\n}\n\n/** Pixel size of a page's placeholder before it renders. */\nexport function placeholderSize(\n\tsize: PdfPageSize | undefined,\n\tscale: number,\n\trotation: number,\n) {\n\tconst turned = rotatedSize(size ?? DEFAULT_PAGE_SIZE, rotation);\n\treturn {\n\t\twidth: Math.round(turned.width * scale),\n\t\theight: Math.round(turned.height * scale),\n\t};\n}\n",
|
|
9
9
|
"import { FIT_PAGES, type PdfPageSize } from './pdf-page-geometry';\n\ntype SizedPage = {\n\t/** The page's own `/Rotate`, in degrees (pdf.js `PDFPageProxy.rotate`). */\n\trotate?: number;\n\tgetViewport: (options: { scale: number; rotation: number }) => {\n\t\twidth: number;\n\t\theight: number;\n\t};\n};\n\nexport type PdfSizedDocument = {\n\tnumPages: number;\n\tgetPage: (pageNumber: number) => Promise<SizedPage>;\n};\n\n/** What a load handler receives: `getPage` is optional for older callers. */\nexport type PdfLoadedDocument = Pick<PdfSizedDocument, 'numPages'> &\n\tPartial<Pick<PdfSizedDocument, 'getPage'>>;\n\n/**\n * Reads every page's size, unrotated, and its own `/Rotate`, `chunk` pages\n * at a time (at most `chunk` page objects asked for at once): the first chunk\n * at once, the rest in the background. `onSizes` gets the list known so far\n * after each chunk; the first report holds the pages the fit zoom is computed\n * from (`FIT_PAGES`), so later chunks never move it. `isCancelled` stops the\n * reading when the document changed.\n */\nexport async function readPageSizes(\n\tpdf: PdfSizedDocument,\n\tonSizes: (sizes: PdfPageSize[]) => void,\n\tisCancelled: () => boolean = () => false,\n\tchunk = FIT_PAGES,\n) {\n\tconst sizes: PdfPageSize[] = [];\n\tfor (let next = 1; next <= pdf.numPages; next += chunk) {\n\t\tconst last = Math.min(pdf.numPages, next + chunk - 1);\n\t\tconst pages = await Promise.all(\n\t\t\tArray.from({ length: last - next + 1 }, (_, index) =>\n\t\t\t\tpdf.getPage(next + index),\n\t\t\t),\n\t\t);\n\t\tif (isCancelled()) return;\n\t\tfor (const page of pages) {\n\t\t\tconst { width, height } = page.getViewport({ scale: 1, rotation: 0 });\n\t\t\tconst rotate = (((page.rotate ?? 0) % 360) + 360) % 360;\n\t\t\tsizes.push(rotate ? { width, height, rotate } : { width, height });\n\t\t}\n\t\tonSizes([...sizes]);\n\t}\n}\n\n/**\n * Reads the sizes of the document last loaded. `reset` forgets it when the\n * file changes, so sizes still arriving for it never land. A document\n * without `getPage` keeps the fallback size.\n */\nexport function createPageSizesLoader(onSizes: (sizes: PdfPageSize[]) => void) {\n\tlet generation = 0;\n\treturn {\n\t\treset() {\n\t\t\tgeneration += 1;\n\t\t},\n\t\tload(pdf: PdfLoadedDocument) {\n\t\t\tgeneration += 1;\n\t\t\tif (!pdf.getPage) return Promise.resolve();\n\t\t\tconst current = generation;\n\t\t\t// pdf.js reads `this` in getPage: pass the document itself.\n\t\t\treturn readPageSizes(\n\t\t\t\tpdf as PdfSizedDocument,\n\t\t\t\tonSizes,\n\t\t\t\t() => current !== generation,\n\t\t\t).catch(() => {\n\t\t\t\t/* a page failed or the document was destroyed: the rest keep the\n\t\t\t\t fallback size */\n\t\t\t});\n\t\t},\n\t};\n}\n",
|
|
10
|
-
"/**
|
|
10
|
+
"/** What the user does to scroll a page area themselves. */\nconst USER_SCROLL_EVENTS = [\n\t'wheel',\n\t'touchstart',\n\t'pointerdown',\n\t'keydown',\n] as const;\n\n/**\n * Runs `run` on each wheel, touch, pointer or key event that reaches\n * `target`, in the capture phase. Returns a function that stops listening.\n * Internal: not re-exported from the subpath.\n */\nexport function listenForUserInput(\n\ttarget: EventTarget,\n\trun: (event: Event) => void,\n) {\n\tfor (const type of USER_SCROLL_EVENTS) {\n\t\ttarget.addEventListener(type, run, { capture: true, passive: true });\n\t}\n\treturn () => {\n\t\tfor (const type of USER_SCROLL_EVENTS) {\n\t\t\ttarget.removeEventListener(type, run, { capture: true });\n\t\t}\n\t};\n}\n",
|
|
11
|
+
"import { listenForUserInput } from './pdf-user-input';\n\n/** A vertical extent on screen, as `getBoundingClientRect` gives it. */\nexport type PdfBox = { top: number; bottom: number };\n\n/**\n * The page with the most of itself on screen, the first one on a tie; once\n * scrolled to the end, the last page on screen, however little of it shows.\n */\nexport function mostVisiblePage(\n\tview: PdfBox & { atEnd: boolean },\n\tpages: Iterable<readonly [number, PdfBox]>,\n): number | null {\n\tlet best: number | null = null;\n\tlet bestSeen = 0;\n\tlet last: number | null = null;\n\tfor (const [page, box] of pages) {\n\t\tconst seen =\n\t\t\tMath.min(box.bottom, view.bottom) - Math.max(box.top, view.top);\n\t\tif (seen <= 0) continue;\n\t\tif (last === null || page > last) last = page;\n\t\tif (\n\t\t\tseen > bestSeen ||\n\t\t\t(seen === bestSeen && best !== null && page < best)\n\t\t) {\n\t\t\tbest = page;\n\t\t\tbestSeen = seen;\n\t\t}\n\t}\n\treturn view.atEnd && last !== null ? last : best;\n}\n\n/**\n * Scrolls the page area around `node`, and nothing else: `scrollIntoView`\n * would scroll the host page too. `block` puts `node` at the area's top or\n * centre.\n */\nexport function scrollIntoArea(\n\tnode: Element,\n\tblock: 'start' | 'center',\n\tbehavior: ScrollBehavior = 'smooth',\n) {\n\tconst area = node.closest<HTMLElement>('[data-slot=\"scroll-area-viewport\"]');\n\tif (!area) return;\n\tconst box = node.getBoundingClientRect();\n\tconst view = area.getBoundingClientRect();\n\tlet top = area.scrollTop + box.top - view.top;\n\tif (block === 'center') top -= (view.height - box.height) / 2;\n\tarea.scrollTo({ top: Math.max(0, top), behavior });\n}\n\n/**\n * Reports the page most on screen as the reader's page area (`root`)\n * scrolls. `hold`\n * ignores scrolling until it has stopped for `idleMs`: the reader calls it\n * before scrolling to a page itself, so the pages it passes on the way are\n * not reported. What the user does in the page area (wheel, touch, pointer,\n * key) ends a hold: the scrolling after it is theirs.\n */\nexport function createScrollSpy(\n\troot: () => HTMLElement | null | undefined,\n\tpages: () => ReadonlyMap<number, HTMLElement>,\n\tonPage: (page: number) => void,\n\tidleMs = 150,\n) {\n\tlet frame = 0;\n\tlet held = false;\n\tlet idle: ReturnType<typeof setTimeout> | undefined;\n\tlet scroller: HTMLElement | null = null;\n\n\tconst release = () => {\n\t\tclearTimeout(idle);\n\t\tidle = setTimeout(() => {\n\t\t\theld = false;\n\t\t}, idleMs);\n\t};\n\n\tconst measure = () => {\n\t\tframe = 0;\n\t\tif (!scroller) return;\n\t\tconst view = scroller.getBoundingClientRect();\n\t\tconst atEnd =\n\t\t\tscroller.scrollTop + scroller.clientHeight >= scroller.scrollHeight - 2;\n\t\tconst boxes = Array.from(pages(), ([page, node]) => {\n\t\t\tconst { top, bottom } = node.getBoundingClientRect();\n\t\t\treturn [page, { top, bottom }] as const;\n\t\t});\n\t\tconst page = mostVisiblePage(\n\t\t\t{ top: view.top, bottom: view.bottom, atEnd },\n\t\t\tboxes,\n\t\t);\n\t\tif (page !== null) onPage(page);\n\t};\n\n\tconst onScroll = (event: Event) => {\n\t\tconst target = event.target;\n\t\tif (!(target instanceof HTMLElement) || !root()?.contains(target)) return;\n\t\t// Scrolling during a hold is not measured again on release: that would\n\t\t// report the page a jump near the end scrolled past.\n\t\tif (held) {\n\t\t\trelease();\n\t\t\treturn;\n\t\t}\n\t\tscroller = target;\n\t\tif (!frame) frame = requestAnimationFrame(measure);\n\t};\n\n\tconst onUserInput = (event: Event) => {\n\t\t// Input on the document lands on a node (an SVG icon too).\n\t\tconst target = event.target as Node | null;\n\t\tif (!target || !root()?.contains(target)) return;\n\t\theld = false;\n\t\tclearTimeout(idle);\n\t};\n\n\t// Scroll events do not bubble: listen in the capture phase, on the\n\t// document, as the page area may be rendered again under the reader.\n\t// Plain DOM rather than react-use or VueUse: this file is shared.\n\tdocument.addEventListener('scroll', onScroll, {\n\t\tcapture: true,\n\t\tpassive: true,\n\t});\n\tconst stopInput = listenForUserInput(document, onUserInput);\n\n\treturn {\n\t\thold() {\n\t\t\theld = true;\n\t\t\tcancelAnimationFrame(frame);\n\t\t\tframe = 0;\n\t\t\trelease();\n\t\t},\n\t\tstop() {\n\t\t\tdocument.removeEventListener('scroll', onScroll, { capture: true });\n\t\t\tstopInput();\n\t\t\tcancelAnimationFrame(frame);\n\t\t\tclearTimeout(idle);\n\t\t},\n\t};\n}\n\n/**\n * Scrolls a page's match to the middle of the page area once the page has\n * drawn its mark, polling each frame for up to `timeout` ms; `beforeScroll`\n * runs first. Returns a function that stops waiting.\n */\nexport function revealHit(\n\tfindPage: () => ParentNode | null | undefined,\n\thit: number,\n\tbeforeScroll: () => void = () => {},\n\ttimeout = 5000,\n) {\n\tconst until = Date.now() + timeout;\n\tlet frame = 0;\n\tconst look = () => {\n\t\tconst mark = findPage()?.querySelector(`mark[data-hit=\"${hit}\"]`);\n\t\tif (mark) {\n\t\t\tbeforeScroll();\n\t\t\tscrollIntoArea(mark, 'center');\n\t\t\treturn;\n\t\t}\n\t\tif (Date.now() < until) frame = requestAnimationFrame(look);\n\t};\n\t// The page marks the match on its next render, not now.\n\tframe = requestAnimationFrame(look);\n\treturn () => cancelAnimationFrame(frame);\n}\n",
|
|
12
|
+
"import { scrollIntoArea } from './pdf-scroll-spy';\nimport { listenForUserInput } from './pdf-user-input';\n\nconst VIEWPORT = '[data-slot=\"scroll-area-viewport\"]';\n\n/**\n * Keeps `node` at the top of the page area while the pages above it change\n * size (the zoom fitting to page sizes still arriving), until the user\n * scrolls, taps, clicks or types in the page area, or the returned function\n * is called. `beforeScroll` runs before each correction; `onRelease` once,\n * when the pin lets go (at once when there is nothing to pin).\n */\nexport function pinToPage(\n\tnode: () => Element | null | undefined,\n\tbeforeScroll: () => void,\n\tonRelease: () => void = () => {},\n) {\n\tconst area = node()?.closest(VIEWPORT);\n\tconst content = area?.firstElementChild;\n\tif (!area || !content || typeof ResizeObserver === 'undefined') {\n\t\tonRelease();\n\t\treturn () => {};\n\t}\n\t// The scroll area, not only its viewport: dragging the scrollbar counts.\n\tconst surface = area.closest('[data-slot=\"scroll-area\"]') ?? area;\n\tconst observer = new ResizeObserver(() => {\n\t\tconst target = node();\n\t\tif (!target) return;\n\t\tbeforeScroll();\n\t\tscrollIntoArea(target, 'start', 'auto');\n\t});\n\tobserver.observe(content);\n\tlet pinned = true;\n\t// A scroll event cannot tell the user's scroll from a correction; what\n\t// the user does first can.\n\tconst unpin = () => {\n\t\tif (!pinned) return;\n\t\tpinned = false;\n\t\tobserver.disconnect();\n\t\tstopListening();\n\t\tonRelease();\n\t};\n\tconst stopListening = listenForUserInput(surface, unpin);\n\treturn unpin;\n}\n\n/**\n * Whether the page area still shows `node` where a pin puts it: at the top,\n * or as near as the area can scroll (at its end). A scroll that leaves it\n * elsewhere came with no input the pin hears (find in page, a screen\n * reader's cursor, your own `scrollTop`): it is not the reader's.\n */\nexport function pinHolds(node: Element | null | undefined) {\n\tconst area = node?.closest<HTMLElement>(VIEWPORT);\n\tif (!node || !area) return false;\n\tconst atEnd = area.scrollTop + area.clientHeight >= area.scrollHeight - 2;\n\tconst offset =\n\t\tnode.getBoundingClientRect().top - area.getBoundingClientRect().top;\n\t// At the end, the pinned page may sit below the top (the area can\n\t// scroll no further), never above it: a jump to the last page left it.\n\treturn (atEnd && offset >= -2) || Math.abs(offset) <= 2;\n}\n"
|
|
11
13
|
],
|
|
12
|
-
"mappings": ";AAAO,SAAS,UAAU,CAAC,MAAsB;AAAA,EAChD,OAAO,KACL,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,OAAO;AAAA;AAGjB,SAAS,aAAa,CAAC,OAI1B;AAAA,EACH,IAAI,CAAC,MAAM,QAAQ,KAAK;AAAA,IAAG,OAAO,CAAC;AAAA,EACnC,OAAO,MAAM,IAAI,CAAC,SAAS;AAAA,IAC1B,MAAM,OAAO;AAAA,IAKb,OAAO;AAAA,MACN,OAAO,OAAO,KAAK,SAAS,EAAE;AAAA,MAC9B,MAAM,KAAK,QAAQ;AAAA,MACnB,OAAO,cAAc,KAAK,KAAK;AAAA,IAChC;AAAA,GACA;AAAA;;;ACdK,SAAS,iBAAiB,CAAC,OAA4C;AAAA,EAC7E,IAAI,OAAO;AAAA,EACX,MAAM,SAAmB,CAAC;AAAA,EAC1B,WAAW,QAAQ,OAAO;AAAA,IACzB,OAAO,KAAK,KAAK,MAAM;AAAA,IACvB,QAAQ,KAAK,OAAO;AAAA,IACpB,IAAI,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;AAAA,IAC/D,UAAU;AAAA,IACV,OAAO,MAAM;AAAA,EACd;AAAA,EAEA,MAAM,UAAU,KAAK,QAAQ,2BAA2B,KAAK;AAAA,EAC7D,MAAM,WAAW,IAAI,eAAe,MAAM;AAAA,IACzC,MAAM,SAAS,KAAK;AAAA,IACpB,IAAI,CAAC;AAAA,MAAQ;AAAA,IACb,aAAa;AAAA,IACb,eAAe,QAAQ,SAAS,MAAM;AAAA,GACtC;AAAA,EACD,SAAS,QAAQ,OAAO;AAAA,EACxB,IAAI,SAAS;AAAA,EAGb,MAAM,QAAQ,MAAM;AAAA,IACnB,IAAI,CAAC;AAAA,MAAQ;AAAA,IACb,SAAS;AAAA,IACT,SAAS,WAAW;AAAA,IACpB,cAAc;AAAA,IACd,UAAU;AAAA;AAAA,EAEX,MAAM,gBAAgB,mBAAmB,SAAS,KAAK;AAAA,EACvD,OAAO;AAAA;AASD,SAAS,QAAQ,CAAC,MAAkC;AAAA,EAC1D,MAAM,OAAO,MAAM,QAAqB,QAAQ;AAAA,EAChD,IAAI,CAAC,QAAQ,CAAC;AAAA,IAAM,OAAO;AAAA,EAC3B,MAAM,QAAQ,KAAK,YAAY,KAAK,gBAAgB,KAAK,eAAe;AAAA,EACxE,MAAM,SACL,KAAK,sBAAsB,EAAE,MAAM,KAAK,sBAAsB,EAAE;AAAA,EAGjE,OAAQ,SAAS,UAAU,MAAO,KAAK,IAAI,MAAM,KAAK;AAAA;",
|
|
15
|
+
"debugId": "71863DCA45A690D164756E2164756E21",
|
|
14
16
|
"names": []
|
|
15
17
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps `node` at the top of the page area while the pages above it change
|
|
3
|
+
* size (the zoom fitting to page sizes still arriving), until the user
|
|
4
|
+
* scrolls, taps, clicks or types in the page area, or the returned function
|
|
5
|
+
* is called. `beforeScroll` runs before each correction; `onRelease` once,
|
|
6
|
+
* when the pin lets go (at once when there is nothing to pin).
|
|
7
|
+
*/
|
|
8
|
+
export declare function pinToPage(node: () => Element | null | undefined, beforeScroll: () => void, onRelease?: () => void): () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the page area still shows `node` where a pin puts it: at the top,
|
|
11
|
+
* or as near as the area can scroll (at its end). A scroll that leaves it
|
|
12
|
+
* elsewhere came with no input the pin hears (find in page, a screen
|
|
13
|
+
* reader's cursor, your own `scrollTop`): it is not the reader's.
|
|
14
|
+
*/
|
|
15
|
+
export declare function pinHolds(node: Element | null | undefined): boolean;
|
|
16
|
+
//# sourceMappingURL=pdf-pin-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-pin-page.d.ts","sourceRoot":"","sources":["../../src/pdf-viewer/pdf-pin-page.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,SAAS,CACxB,IAAI,EAAE,MAAM,OAAO,GAAG,IAAI,GAAG,SAAS,EACtC,YAAY,EAAE,MAAM,IAAI,EACxB,SAAS,GAAE,MAAM,IAAe,cA6BhC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,WASxD"}
|
|
@@ -16,19 +16,13 @@ export declare function mostVisiblePage(view: PdfBox & {
|
|
|
16
16
|
* centre.
|
|
17
17
|
*/
|
|
18
18
|
export declare function scrollIntoArea(node: Element, block: 'start' | 'center', behavior?: ScrollBehavior): void;
|
|
19
|
-
/**
|
|
20
|
-
* Keeps `node` at the top of the page area while the pages above it change
|
|
21
|
-
* size (the zoom fitting to page sizes still arriving), until the user
|
|
22
|
-
* scrolls, taps, clicks or types in the page area, or the returned function
|
|
23
|
-
* is called. `beforeScroll` runs before each correction.
|
|
24
|
-
*/
|
|
25
|
-
export declare function pinToPage(node: () => Element | null | undefined, beforeScroll: () => void): () => void;
|
|
26
19
|
/**
|
|
27
20
|
* Reports the page most on screen as the reader's page area (`root`)
|
|
28
21
|
* scrolls. `hold`
|
|
29
22
|
* ignores scrolling until it has stopped for `idleMs`: the reader calls it
|
|
30
23
|
* before scrolling to a page itself, so the pages it passes on the way are
|
|
31
|
-
* not reported.
|
|
24
|
+
* not reported. What the user does in the page area (wheel, touch, pointer,
|
|
25
|
+
* key) ends a hold: the scrolling after it is theirs.
|
|
32
26
|
*/
|
|
33
27
|
export declare function createScrollSpy(root: () => HTMLElement | null | undefined, pages: () => ReadonlyMap<number, HTMLElement>, onPage: (page: number) => void, idleMs?: number): {
|
|
34
28
|
hold(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf-scroll-spy.d.ts","sourceRoot":"","sources":["../../src/pdf-viewer/pdf-scroll-spy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pdf-scroll-spy.d.ts","sourceRoot":"","sources":["../../src/pdf-viewer/pdf-scroll-spy.ts"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,MAAM,MAAM,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,EACjC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACxC,MAAM,GAAG,IAAI,CAkBf;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,OAAO,GAAG,QAAQ,EACzB,QAAQ,GAAE,cAAyB,QASnC;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,EAC1C,KAAK,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,EAC7C,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAC9B,MAAM,SAAM;;;EA2EZ;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACxB,QAAQ,EAAE,MAAM,UAAU,GAAG,IAAI,GAAG,SAAS,EAC7C,GAAG,EAAE,MAAM,EACX,YAAY,GAAE,MAAM,IAAe,EACnC,OAAO,SAAO,cAgBd"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs `run` on each wheel, touch, pointer or key event that reaches
|
|
3
|
+
* `target`, in the capture phase. Returns a function that stops listening.
|
|
4
|
+
* Internal: not re-exported from the subpath.
|
|
5
|
+
*/
|
|
6
|
+
export declare function listenForUserInput(target: EventTarget, run: (event: Event) => void): () => void;
|
|
7
|
+
//# sourceMappingURL=pdf-user-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf-user-input.d.ts","sourceRoot":"","sources":["../../src/pdf-viewer/pdf-user-input.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,cAU3B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where an app's pdfkit keeps its fourteen standard fonts, resolved the way
|
|
3
|
+
* that app loads them. Build-time code for a framework's config: the Next.js
|
|
4
|
+
* helper of `@nxgt/material` (`@nxgt/material/next`, which turns the
|
|
5
|
+
* directories into `outputFileTracingIncludes` globs) and the Nuxt module of
|
|
6
|
+
* `@nxgt/material-vue` (which adds the files to Nitro's `traceInclude`).
|
|
7
|
+
*
|
|
8
|
+
* **Node only.** This is the one subpath of `@nxgt/material-core` that
|
|
9
|
+
* imports `node:*` built-ins (`node:module`, `node:path`); `verify:ssr` fails
|
|
10
|
+
* the build if any other reaches one. Never import it from code that can end
|
|
11
|
+
* up in a browser bundle.
|
|
12
|
+
*
|
|
13
|
+
* Why it exists: pdfkit registers its fonts with a runtime
|
|
14
|
+
* `require('#standard-fonts/<Name>')`, a package-`imports` specifier private
|
|
15
|
+
* to pdfkit. A server tracer (Next.js's, Nitro's) does not follow a runtime
|
|
16
|
+
* `require`, so a traced server output has pdfkit but not its `.cjs` fonts,
|
|
17
|
+
* and every PDF rendered there fails with
|
|
18
|
+
* `Cannot find module '…/pdfkit/js/standard-fonts/Helvetica.cjs'`.
|
|
19
|
+
*
|
|
20
|
+
* pdfkit is found through `@react-pdf/renderer` and through
|
|
21
|
+
* `@react-pdf/font` (resolved from the renderer), since each can nest a
|
|
22
|
+
* pdfkit of its own. Resolving `pdfkit/standard-fonts/<Name>` from them
|
|
23
|
+
* under the `require` condition lands on the `.cjs` file pdfkit's runtime
|
|
24
|
+
* `require` reads, as a real path, under npm, pnpm and bun alike.
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { pdfkitStandardFontDirs } from '@nxgt/material-core/pdfkit-fonts';
|
|
28
|
+
*
|
|
29
|
+
* pdfkitStandardFontDirs(process.cwd(), (message) => console.warn(message));
|
|
30
|
+
* // ['/app/node_modules/pdfkit/js/standard-fonts']
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
/** The fourteen standard PDF fonts, as pdfkit exports them. */
|
|
34
|
+
export declare const PDFKIT_STANDARD_FONTS: readonly ["Courier", "CourierBold", "CourierBoldOblique", "CourierOblique", "Helvetica", "HelveticaBold", "HelveticaBoldOblique", "HelveticaOblique", "Symbol", "TimesBold", "TimesBoldItalic", "TimesItalic", "TimesRoman", "ZapfDingbats"];
|
|
35
|
+
export type PdfkitStandardFont = (typeof PDFKIT_STANDARD_FONTS)[number];
|
|
36
|
+
/** Receives the one warning a call can give. */
|
|
37
|
+
export type PdfkitFontsWarn = (message: string) => void;
|
|
38
|
+
/**
|
|
39
|
+
* pdfkit's `js/standard-fonts` directories, real paths, as the app at
|
|
40
|
+
* `projectDir` loads them: the one of the pdfkit `@react-pdf/renderer`
|
|
41
|
+
* depends on and the one of `@react-pdf/font`'s, without duplicates (one
|
|
42
|
+
* directory when both share a pdfkit, as they usually do). Each directory
|
|
43
|
+
* also holds the `chunks/` the fonts `require`.
|
|
44
|
+
*
|
|
45
|
+
* `[]`, silently, when `@react-pdf/renderer` is not installed. Anything else
|
|
46
|
+
* that fails is passed to `warn`, once per call: a font that cannot be traced
|
|
47
|
+
* is a PDF route that fails in production.
|
|
48
|
+
*/
|
|
49
|
+
export declare function pdfkitStandardFontDirs(projectDir: string, warn?: PdfkitFontsWarn): string[];
|
|
50
|
+
/**
|
|
51
|
+
* pdfkit's fourteen standard-font modules (`.cjs`, real paths), as the app
|
|
52
|
+
* at `projectDir` loads them: through pdfkit's own `standard-fonts/<Name>`
|
|
53
|
+
* exports under the `require` condition, for the pdfkit
|
|
54
|
+
* `@react-pdf/renderer` depends on and the one `@react-pdf/font` depends on,
|
|
55
|
+
* without duplicates.
|
|
56
|
+
*
|
|
57
|
+
* `[]`, silently, when `@react-pdf/renderer` is not installed. Anything else
|
|
58
|
+
* that fails is passed to `warn`, once per call.
|
|
59
|
+
*/
|
|
60
|
+
export declare function pdfkitStandardFontFiles(projectDir: string, warn?: PdfkitFontsWarn): string[];
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pdfkit-fonts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,+DAA+D;AAC/D,eAAO,MAAM,qBAAqB,8OAexB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE,gDAAgD;AAChD,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAyDxD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,eAA0B,GAC9B,MAAM,EAAE,CAYV;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,eAA0B,GAC9B,MAAM,EAAE,CAcV"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/pdfkit-fonts/index.ts
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
var PDFKIT_STANDARD_FONTS = [
|
|
5
|
+
"Courier",
|
|
6
|
+
"CourierBold",
|
|
7
|
+
"CourierBoldOblique",
|
|
8
|
+
"CourierOblique",
|
|
9
|
+
"Helvetica",
|
|
10
|
+
"HelveticaBold",
|
|
11
|
+
"HelveticaBoldOblique",
|
|
12
|
+
"HelveticaOblique",
|
|
13
|
+
"Symbol",
|
|
14
|
+
"TimesBold",
|
|
15
|
+
"TimesBoldItalic",
|
|
16
|
+
"TimesItalic",
|
|
17
|
+
"TimesRoman",
|
|
18
|
+
"ZapfDingbats"
|
|
19
|
+
];
|
|
20
|
+
var isNotFound = (error) => error?.code === "MODULE_NOT_FOUND";
|
|
21
|
+
var firstLine = (error) => String(error).split(`
|
|
22
|
+
`, 1)[0] ?? "";
|
|
23
|
+
function fromEachPdfkit(projectDir, warn, collect) {
|
|
24
|
+
const problems = [];
|
|
25
|
+
let renderer;
|
|
26
|
+
try {
|
|
27
|
+
renderer = createRequire(join(resolve(projectDir), "package.json")).resolve("@react-pdf/renderer");
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (!isNotFound(error)) {
|
|
30
|
+
warn(`could not resolve @react-pdf/renderer: ${firstLine(error)}`);
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const fromRenderer = createRequire(renderer);
|
|
35
|
+
const owners = [["@react-pdf/renderer", fromRenderer]];
|
|
36
|
+
try {
|
|
37
|
+
owners.push([
|
|
38
|
+
"@react-pdf/font",
|
|
39
|
+
createRequire(fromRenderer.resolve("@react-pdf/font"))
|
|
40
|
+
]);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
problems.push(`could not resolve @react-pdf/font: ${firstLine(error)}`);
|
|
43
|
+
}
|
|
44
|
+
for (const [owner, from] of owners)
|
|
45
|
+
collect(owner, from, problems);
|
|
46
|
+
if (problems.length > 0)
|
|
47
|
+
warn(problems.join("; "));
|
|
48
|
+
}
|
|
49
|
+
function pdfkitStandardFontDirs(projectDir, warn = () => {}) {
|
|
50
|
+
const dirs = new Set;
|
|
51
|
+
fromEachPdfkit(projectDir, warn, (owner, from, problems) => {
|
|
52
|
+
try {
|
|
53
|
+
dirs.add(dirname(from.resolve("pdfkit/standard-fonts/Helvetica")));
|
|
54
|
+
} catch (error) {
|
|
55
|
+
problems.push(`could not resolve pdfkit's fonts for ${owner}: ${firstLine(error)}`);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return [...dirs];
|
|
59
|
+
}
|
|
60
|
+
function pdfkitStandardFontFiles(projectDir, warn = () => {}) {
|
|
61
|
+
const files = new Set;
|
|
62
|
+
fromEachPdfkit(projectDir, warn, (owner, from, problems) => {
|
|
63
|
+
for (const font of PDFKIT_STANDARD_FONTS) {
|
|
64
|
+
try {
|
|
65
|
+
files.add(from.resolve(`pdfkit/standard-fonts/${font}`));
|
|
66
|
+
} catch (error) {
|
|
67
|
+
problems.push(`could not resolve pdfkit's ${font} font for ${owner}: ${firstLine(error)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return [...files];
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
PDFKIT_STANDARD_FONTS,
|
|
75
|
+
pdfkitStandardFontDirs,
|
|
76
|
+
pdfkitStandardFontFiles
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
//# debugId=D12CCCD8FE08400864756E2164756E21
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/pdfkit-fonts/index.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Where an app's pdfkit keeps its fourteen standard fonts, resolved the way\n * that app loads them. Build-time code for a framework's config: the Next.js\n * helper of `@nxgt/material` (`@nxgt/material/next`, which turns the\n * directories into `outputFileTracingIncludes` globs) and the Nuxt module of\n * `@nxgt/material-vue` (which adds the files to Nitro's `traceInclude`).\n *\n * **Node only.** This is the one subpath of `@nxgt/material-core` that\n * imports `node:*` built-ins (`node:module`, `node:path`); `verify:ssr` fails\n * the build if any other reaches one. Never import it from code that can end\n * up in a browser bundle.\n *\n * Why it exists: pdfkit registers its fonts with a runtime\n * `require('#standard-fonts/<Name>')`, a package-`imports` specifier private\n * to pdfkit. A server tracer (Next.js's, Nitro's) does not follow a runtime\n * `require`, so a traced server output has pdfkit but not its `.cjs` fonts,\n * and every PDF rendered there fails with\n * `Cannot find module '…/pdfkit/js/standard-fonts/Helvetica.cjs'`.\n *\n * pdfkit is found through `@react-pdf/renderer` and through\n * `@react-pdf/font` (resolved from the renderer), since each can nest a\n * pdfkit of its own. Resolving `pdfkit/standard-fonts/<Name>` from them\n * under the `require` condition lands on the `.cjs` file pdfkit's runtime\n * `require` reads, as a real path, under npm, pnpm and bun alike.\n *\n * ```ts\n * import { pdfkitStandardFontDirs } from '@nxgt/material-core/pdfkit-fonts';\n *\n * pdfkitStandardFontDirs(process.cwd(), (message) => console.warn(message));\n * // ['/app/node_modules/pdfkit/js/standard-fonts']\n * ```\n */\n\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\n\n/** The fourteen standard PDF fonts, as pdfkit exports them. */\nexport const PDFKIT_STANDARD_FONTS = [\n\t'Courier',\n\t'CourierBold',\n\t'CourierBoldOblique',\n\t'CourierOblique',\n\t'Helvetica',\n\t'HelveticaBold',\n\t'HelveticaBoldOblique',\n\t'HelveticaOblique',\n\t'Symbol',\n\t'TimesBold',\n\t'TimesBoldItalic',\n\t'TimesItalic',\n\t'TimesRoman',\n\t'ZapfDingbats',\n] as const;\n\nexport type PdfkitStandardFont = (typeof PDFKIT_STANDARD_FONTS)[number];\n\n/** Receives the one warning a call can give. */\nexport type PdfkitFontsWarn = (message: string) => void;\n\ntype Require = ReturnType<typeof createRequire>;\n\nconst isNotFound = (error: unknown) =>\n\t(error as { code?: string } | null)?.code === 'MODULE_NOT_FOUND';\n\n/**\n * An error as one line: its text up to the first newline. Node's\n * `Cannot find module` error appends a multi-line `Require stack:`, and the\n * warning joins every problem into ONE line: kept whole, a single failure\n * buried the others under a dozen stack paths.\n */\nconst firstLine = (error: unknown): string =>\n\tString(error).split('\\n', 1)[0] ?? '';\n\n/**\n * Runs `collect` with the `require` of each package that depends on pdfkit\n * (`@react-pdf/renderer`, then `@react-pdf/font`), and hands every problem\n * met on the way to `warn` as ONE message, joined by `; `, each error cut\n * to its first line (`firstLine`). None, silently,\n * when the app does not install `@react-pdf/renderer`: it is an optional\n * peer, and an app that does not print has no fonts to find.\n */\nfunction fromEachPdfkit(\n\tprojectDir: string,\n\twarn: PdfkitFontsWarn,\n\tcollect: (owner: string, from: Require, problems: string[]) => void,\n): void {\n\tconst problems: string[] = [];\n\tlet renderer: string;\n\ttry {\n\t\t// createRequire takes an absolute path only: a relative `projectDir`\n\t\t// is taken from the working directory.\n\t\trenderer = createRequire(join(resolve(projectDir), 'package.json')).resolve(\n\t\t\t'@react-pdf/renderer',\n\t\t);\n\t} catch (error) {\n\t\tif (!isNotFound(error)) {\n\t\t\twarn(`could not resolve @react-pdf/renderer: ${firstLine(error)}`);\n\t\t}\n\t\treturn;\n\t}\n\tconst fromRenderer = createRequire(renderer);\n\tconst owners: [string, Require][] = [['@react-pdf/renderer', fromRenderer]];\n\ttry {\n\t\towners.push([\n\t\t\t'@react-pdf/font',\n\t\t\tcreateRequire(fromRenderer.resolve('@react-pdf/font')),\n\t\t]);\n\t} catch (error) {\n\t\tproblems.push(`could not resolve @react-pdf/font: ${firstLine(error)}`);\n\t}\n\tfor (const [owner, from] of owners) collect(owner, from, problems);\n\tif (problems.length > 0) warn(problems.join('; '));\n}\n\n/**\n * pdfkit's `js/standard-fonts` directories, real paths, as the app at\n * `projectDir` loads them: the one of the pdfkit `@react-pdf/renderer`\n * depends on and the one of `@react-pdf/font`'s, without duplicates (one\n * directory when both share a pdfkit, as they usually do). Each directory\n * also holds the `chunks/` the fonts `require`.\n *\n * `[]`, silently, when `@react-pdf/renderer` is not installed. Anything else\n * that fails is passed to `warn`, once per call: a font that cannot be traced\n * is a PDF route that fails in production.\n */\nexport function pdfkitStandardFontDirs(\n\tprojectDir: string,\n\twarn: PdfkitFontsWarn = () => {},\n): string[] {\n\tconst dirs = new Set<string>();\n\tfromEachPdfkit(projectDir, warn, (owner, from, problems) => {\n\t\ttry {\n\t\t\tdirs.add(dirname(from.resolve('pdfkit/standard-fonts/Helvetica')));\n\t\t} catch (error) {\n\t\t\tproblems.push(\n\t\t\t\t`could not resolve pdfkit's fonts for ${owner}: ${firstLine(error)}`,\n\t\t\t);\n\t\t}\n\t});\n\treturn [...dirs];\n}\n\n/**\n * pdfkit's fourteen standard-font modules (`.cjs`, real paths), as the app\n * at `projectDir` loads them: through pdfkit's own `standard-fonts/<Name>`\n * exports under the `require` condition, for the pdfkit\n * `@react-pdf/renderer` depends on and the one `@react-pdf/font` depends on,\n * without duplicates.\n *\n * `[]`, silently, when `@react-pdf/renderer` is not installed. Anything else\n * that fails is passed to `warn`, once per call.\n */\nexport function pdfkitStandardFontFiles(\n\tprojectDir: string,\n\twarn: PdfkitFontsWarn = () => {},\n): string[] {\n\tconst files = new Set<string>();\n\tfromEachPdfkit(projectDir, warn, (owner, from, problems) => {\n\t\tfor (const font of PDFKIT_STANDARD_FONTS) {\n\t\t\ttry {\n\t\t\t\tfiles.add(from.resolve(`pdfkit/standard-fonts/${font}`));\n\t\t\t} catch (error) {\n\t\t\t\tproblems.push(\n\t\t\t\t\t`could not resolve pdfkit's ${font} font for ${ow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MAAM,IACnB;AAAA,EACX,MAAM,OAAO,IAAI;AAAA,EACjB,eAAe,YAAY,MAAM,CAAC,OAAO,MAAM,aAAa;AAAA,IAC3D,IAAI;AAAA,MACH,KAAK,IAAI,QAAQ,KAAK,QAAQ,iCAAiC,CAAC,CAAC;AAAA,MAChE,OAAO,OAAO;AAAA,MACf,SAAS,KACR,wCAAwC,UAAU,UAAU,KAAK,GAClE;AAAA;AAAA,GAED;AAAA,EACD,OAAO,CAAC,GAAG,IAAI;AAAA;AAaT,SAAS,uBAAuB,CACtC,YACA,OAAwB,MAAM,IACnB;AAAA,EACX,MAAM,QAAQ,IAAI;AAAA,EAClB,eAAe,YAAY,MAAM,CAAC,OAAO,MAAM,aAAa;AAAA,IAC3D,WAAW,QAAQ,uBAAuB;AAAA,MACzC,IAAI;AAAA,QACH,MAAM,IAAI,KAAK,QAAQ,yBAAyB,MAAM,CAAC;AAAA,QACtD,OAAO,OAAO;AAAA,QACf,SAAS,KACR,8BAA8B,iBAAiB,UAAU,UAAU,KAAK,GACzE;AAAA;AAAA,IAEF;AAAA,GACA;AAAA,EACD,OAAO,CAAC,GAAG,KAAK;AAAA;",
|
|
8
|
+
"debugId": "D12CCCD8FE08400864756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/docs/roadmap.md
CHANGED
|
@@ -5,7 +5,13 @@ version an item shipped in is the only number on this page.
|
|
|
5
5
|
|
|
6
6
|
## Now
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
- **Date range presets and times** (`/date-range`) — the built-in presets'
|
|
9
|
+
ranges, whether a field's rules rule a range out, and the time of day on
|
|
10
|
+
each end, for both libraries' `DateRangeField`.
|
|
11
|
+
- **File preview** (`/file-preview`) — which kind of preview a file gets from
|
|
12
|
+
its MIME type or extension, which URLs it may link to or load, and the
|
|
13
|
+
first bytes of a text file read with a size cap in its own charset, for
|
|
14
|
+
both libraries' `FilePreview`.
|
|
9
15
|
|
|
10
16
|
## Next
|
|
11
17
|
|
|
@@ -37,3 +43,8 @@ Nothing in progress right now; see Next.
|
|
|
37
43
|
digits, the fields' blur layers and the fonts plugin, which
|
|
38
44
|
`@nxgt/material` and `@nxgt/material-vue` shared file by file, are this one
|
|
39
45
|
package, and both libraries depend on it. 0.1.0.
|
|
46
|
+
- **`formatFileSize` and the pdfkit fonts resolution** — the byte-count
|
|
47
|
+
formatter both libraries' file list and upload field use
|
|
48
|
+
(`/format-file-size`), and the Node-only resolution of pdfkit's standard
|
|
49
|
+
fonts behind `@nxgt/material/next` and `@nxgt/material-vue`'s Nuxt module
|
|
50
|
+
(`/pdfkit-fonts`), each kept once instead of in both libraries. 0.2.0.
|
package/docs/troubleshooting.md
CHANGED
|
@@ -21,6 +21,9 @@ file) is an example — search for the words around it.
|
|
|
21
21
|
|
|
22
22
|
- [`… still references '#standard-fonts/' after the transform — …`](#-still-references-standard-fonts-after-the-transform--)
|
|
23
23
|
- [`Cannot find module '#standard-fonts/Helvetica' from '…'`](#cannot-find-module-standard-fontshelvetica-from-)
|
|
24
|
+
- [`Cannot find module '…/pdfkit/js/standard-fonts/Helvetica.cjs'`](#cannot-find-module-pdfkitjsstandard-fontshelveticacjs)
|
|
25
|
+
- [`could not resolve …` (`@react-pdf/renderer`, `@react-pdf/font`, pdfkit's fonts)](#could-not-resolve-)
|
|
26
|
+
- [`Module "node:module" has been externalized for browser compatibility`](#module-nodemodule-has-been-externalized-for-browser-compatibility)
|
|
24
27
|
|
|
25
28
|
## Install
|
|
26
29
|
|
|
@@ -103,3 +106,65 @@ rather than the server at its first request. Pin the previous
|
|
|
103
106
|
A server bundle that contains pdfkit, run without `node_modules`. Add
|
|
104
107
|
`pdfkitStandardFonts()` to that build (see the README's `/vite` section), or
|
|
105
108
|
keep the library external so pdfkit loads from `node_modules`.
|
|
109
|
+
|
|
110
|
+
### `Cannot find module '…/pdfkit/js/standard-fonts/Helvetica.cjs'`
|
|
111
|
+
|
|
112
|
+
**When:** on every PDF a traced server output renders — `.next/standalone`
|
|
113
|
+
(`output: 'standalone'`), Nitro's `.output/server` — while the dev server
|
|
114
|
+
renders fine. The path points into the output's own `node_modules/pdfkit/`.
|
|
115
|
+
**Why:** the tracer copies pdfkit, but pdfkit loads its fonts with a runtime
|
|
116
|
+
`require('#standard-fonts/<Name>')` it never follows, so the `.cjs` fonts
|
|
117
|
+
(and the `chunks/` they `require`) are left behind.
|
|
118
|
+
**Fix:** hand the tracer the files. With `@nxgt/material`, wrap the Next.js
|
|
119
|
+
config in `withNxgtPrint` (`@nxgt/material/next`); with
|
|
120
|
+
`@nxgt/material-vue`, use its Nuxt module. Anything else calls
|
|
121
|
+
`/pdfkit-fonts` in its config:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { pdfkitStandardFontDirs } from '@nxgt/material-core/pdfkit-fonts';
|
|
125
|
+
|
|
126
|
+
// every .cjs under each directory, chunks/ included
|
|
127
|
+
const include = pdfkitStandardFontDirs(process.cwd(), console.warn).map(
|
|
128
|
+
(dir) => `${dir}/**/*.cjs`,
|
|
129
|
+
);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### `could not resolve …`
|
|
133
|
+
|
|
134
|
+
**When:** at build, from `pdfkitStandardFontDirs` or
|
|
135
|
+
`pdfkitStandardFontFiles` — through `withNxgtPrint`
|
|
136
|
+
(`[@nxgt/material/next] …`), the Nuxt module (`pdf fonts: …`) or your own
|
|
137
|
+
`warn`. Every problem goes into one line, joined by `; `, each error cut to
|
|
138
|
+
its first line (Node's `Require stack:` is left out):
|
|
139
|
+
`could not resolve @react-pdf/renderer: …`,
|
|
140
|
+
`could not resolve @react-pdf/font: …`,
|
|
141
|
+
`could not resolve pdfkit's fonts for @react-pdf/renderer: …`,
|
|
142
|
+
`could not resolve pdfkit's Courier font for …`.
|
|
143
|
+
Without `@react-pdf/renderer` installed at all, nothing is printed.
|
|
144
|
+
**Why:** `@react-pdf/renderer` is installed, but resolving it, the
|
|
145
|
+
`@react-pdf/font` it uses or the pdfkit either depends on fails: a broken or
|
|
146
|
+
partial install, or a layout that hides them from the renderer.
|
|
147
|
+
**Fix:** reinstall (`rm -rf node_modules && <your package manager> install`),
|
|
148
|
+
and check that `node -e "require.resolve('pdfkit/standard-fonts/Helvetica', { paths: [require.resolve('@react-pdf/renderer')] })"`
|
|
149
|
+
prints a `.cjs` path. What could be resolved is still returned: the warning
|
|
150
|
+
names only what a PDF route will miss.
|
|
151
|
+
|
|
152
|
+
### `Module "node:module" has been externalized for browser compatibility`
|
|
153
|
+
|
|
154
|
+
**When:** Vite (or a similar bundler) prints this, or a browser console shows
|
|
155
|
+
`createRequire is not a function`, in an app that imports
|
|
156
|
+
`@nxgt/material-core/pdfkit-fonts`.
|
|
157
|
+
**Why:** `/pdfkit-fonts` is Node-only: it resolves files on disk with
|
|
158
|
+
`node:module` and `node:path`. Imported from code that reaches the browser, the
|
|
159
|
+
bundler swaps those built-ins for empty shims.
|
|
160
|
+
**Fix:** import it only from build-time Node code — `next.config.ts`, a Nuxt
|
|
161
|
+
module, a Vite config, a script. In a Next.js app use `withNxgtPrint` from
|
|
162
|
+
`@nxgt/material/next`; in Nuxt the `@nxgt/material-vue` module already calls
|
|
163
|
+
it.
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
// next.config.ts: runs in Node, never in the browser
|
|
167
|
+
import { withNxgtPrint } from '@nxgt/material/next';
|
|
168
|
+
|
|
169
|
+
export default withNxgtPrint({ output: 'standalone' });
|
|
170
|
+
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxgt/material-core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The framework-free core of @nxgt/material and @nxgt/material-vue: the PDF document model and its react-pdf renderer, print formatters, PDF file helpers, the PDF viewer's pure modules, the currency digits, the field-blur layers and the pdfkit fonts Vite plugin",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "The framework-free core of @nxgt/material and @nxgt/material-vue: the PDF document model and its react-pdf renderer, print formatters, PDF file helpers, the PDF viewer's pure modules, the currency digits, the file-size formatter, the field-blur layers, the date range presets, the file preview's kind detection and text reader, the pdfkit fonts Vite plugin and the Node-only pdfkit fonts resolution for Next.js and Nuxt builds",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"email": "stevegires@gmail.com"
|
|
@@ -92,6 +92,26 @@
|
|
|
92
92
|
"import": "./dist/lib/field-blur-layers.js",
|
|
93
93
|
"default": "./dist/lib/field-blur-layers.js"
|
|
94
94
|
},
|
|
95
|
+
"./format-file-size": {
|
|
96
|
+
"types": "./dist/lib/format-file-size.d.ts",
|
|
97
|
+
"import": "./dist/lib/format-file-size.js",
|
|
98
|
+
"default": "./dist/lib/format-file-size.js"
|
|
99
|
+
},
|
|
100
|
+
"./slider-ticks": {
|
|
101
|
+
"types": "./dist/lib/slider-ticks.d.ts",
|
|
102
|
+
"import": "./dist/lib/slider-ticks.js",
|
|
103
|
+
"default": "./dist/lib/slider-ticks.js"
|
|
104
|
+
},
|
|
105
|
+
"./date-range": {
|
|
106
|
+
"types": "./dist/lib/date-range.d.ts",
|
|
107
|
+
"import": "./dist/lib/date-range.js",
|
|
108
|
+
"default": "./dist/lib/date-range.js"
|
|
109
|
+
},
|
|
110
|
+
"./file-preview": {
|
|
111
|
+
"types": "./dist/file-preview/index.d.ts",
|
|
112
|
+
"import": "./dist/file-preview/index.js",
|
|
113
|
+
"default": "./dist/file-preview/index.js"
|
|
114
|
+
},
|
|
95
115
|
"./pdf-viewer": {
|
|
96
116
|
"types": "./dist/pdf-viewer/index.d.ts",
|
|
97
117
|
"import": "./dist/pdf-viewer/index.js",
|
|
@@ -102,6 +122,11 @@
|
|
|
102
122
|
"import": "./dist/vite/index.js",
|
|
103
123
|
"default": "./dist/vite/index.js"
|
|
104
124
|
},
|
|
125
|
+
"./pdfkit-fonts": {
|
|
126
|
+
"types": "./dist/pdfkit-fonts/index.d.ts",
|
|
127
|
+
"import": "./dist/pdfkit-fonts/index.js",
|
|
128
|
+
"default": "./dist/pdfkit-fonts/index.js"
|
|
129
|
+
},
|
|
105
130
|
"./package.json": "./package.json"
|
|
106
131
|
},
|
|
107
132
|
"sideEffects": false,
|
|
@@ -146,8 +171,13 @@
|
|
|
146
171
|
"src/lib/pdf-download.ts",
|
|
147
172
|
"src/lib/currency-digits.ts",
|
|
148
173
|
"src/lib/field-blur-layers.ts",
|
|
174
|
+
"src/lib/format-file-size.ts",
|
|
175
|
+
"src/lib/slider-ticks.ts",
|
|
176
|
+
"src/lib/date-range.ts",
|
|
177
|
+
"src/file-preview/index.ts",
|
|
149
178
|
"src/pdf-viewer/index.ts",
|
|
150
|
-
"src/vite/index.ts"
|
|
179
|
+
"src/vite/index.ts",
|
|
180
|
+
"src/pdfkit-fonts/index.ts"
|
|
151
181
|
]
|
|
152
182
|
},
|
|
153
183
|
"dependencies": {
|