{"_id":"@alankherron/kdp-cover-geometry","_rev":"2-a0d24d8b9337fb5d44eecbddcb05ad9b","name":"@alankherron/kdp-cover-geometry","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.1":{"name":"@alankherron/kdp-cover-geometry","version":"0.1.1","keywords":["kdp","amazon","kindle-direct-publishing","self-publishing","print-on-demand","book","cover","spine","trim","bleed","barcode","paperback"],"author":{"name":"alanherron"},"license":"MIT","_id":"@alankherron/kdp-cover-geometry@0.1.1","maintainers":[{"name":"alanherron","email":"alanherron@gmail.com"}],"homepage":"https://github.com/alanherron/kdp-cover-math#readme","bugs":{"url":"https://github.com/alanherron/kdp-cover-math/issues"},"dist":{"shasum":"3969371bef1753c665008ce2c7fd3486719920c6","tarball":"https://registry.npmjs.org/@alankherron/kdp-cover-geometry/-/kdp-cover-geometry-0.1.1.tgz","fileCount":9,"integrity":"sha512-/VrHSiFCs18cbn6omWuEurwt32pJkSes6s36uOm1Ls47S04H8xm0pEDBJEkUqHtFirJrkoeJDki14jiGvW3Ryw==","signatures":[{"sig":"MEUCIQCKqMK/M8NFHyzYYyRCDVNgey8JJq1uTXEd9EmPs8vP/wIgdI0xhBjFMbjj81BJg3zXbtR/+BkUFmvE1pi1oW2KapM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29874},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"708e3dcd67de612cefce78c23422fe93dc263777","scripts":{"lint":"tsc --noEmit","test":"vitest run","build":"tsup src/index.ts --format esm,cjs --dts --clean","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run typecheck && npm run test && npm run build"},"_npmUser":{"name":"alanherron","email":"alanherron@gmail.com"},"repository":{"url":"git+https://github.com/alanherron/kdp-cover-math.git","type":"git"},"_npmVersion":"10.8.2","description":"Pure-function Amazon KDP paperback cover-wrap and interior-page geometry. Trim sizes, bleed, spine width, full cover-wrap dimensions.","directories":{},"sideEffects":false,"_nodeVersion":"18.20.8","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.0","vitest":"^2.1.0","typescript":"^5.6.0"},"_npmOperationalInternal":{"tmp":"tmp/kdp-cover-geometry_0.1.1_1779152156322_0.9586925853529138","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@alankherron/kdp-cover-geometry","version":"0.2.0","description":"Pure-function Amazon KDP paperback cover-wrap and interior-page geometry. Trim sizes, bleed, spine width, full cover-wrap dimensions.","keywords":["kdp","amazon","kindle-direct-publishing","self-publishing","print-on-demand","book","cover","spine","trim","bleed","barcode","paperback"],"license":"MIT","author":{"name":"alanherron"},"homepage":"https://github.com/alanherron/kdp-cover-math#readme","repository":{"type":"git","url":"git+https://github.com/alanherron/kdp-cover-math.git"},"bugs":{"url":"https://github.com/alanherron/kdp-cover-math/issues"},"type":"module","sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup src/index.ts --format esm,cjs --dts --clean","test":"vitest run","test:watch":"vitest","typecheck":"tsc --noEmit","lint":"tsc --noEmit","prepublishOnly":"npm run typecheck && npm run test && npm run build"},"devDependencies":{"tsup":"^8.3.0","typescript":"^5.6.0","vitest":"^2.1.0"},"engines":{"node":">=18"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"gitHead":"50a4ce13b05b97eeaaf04c8002877e6e5cf3aeac","_id":"@alankherron/kdp-cover-geometry@0.2.0","_nodeVersion":"24.16.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-yMNzIqF++8OcA/t1g7fo2okyXmIhEXA5WbaMQwsLZvSIVRZfPz7TTmVrkRN1SwYyulhgJ41iroGpGDoaYJ+PXg==","shasum":"7d10f05d74dd0559230f82415895aef7abf85f25","tarball":"https://registry.npmjs.org/@alankherron/kdp-cover-geometry/-/kdp-cover-geometry-0.2.0.tgz","fileCount":9,"unpackedSize":30543,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@alankherron%2fkdp-cover-geometry@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGirQ+DFLDV1c23UhyTksGWcBcfy5NOZu9+1aObKu+EtAiAinXR6NQc1kRLx9raNN3O+bch6s+sztuQJrPpN05TaPA=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:998e7fcf-10b5-4469-9754-f0400d69d037"}},"directories":{},"maintainers":[{"name":"alanherron","email":"alanherron@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/kdp-cover-geometry_0.2.0_1781820513574_0.9800617049173086"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-19T00:55:56.208Z","modified":"2026-06-18T22:08:33.989Z","0.1.1":"2026-05-19T00:55:56.461Z","0.2.0":"2026-06-18T22:08:33.714Z"},"bugs":{"url":"https://github.com/alanherron/kdp-cover-math/issues"},"author":{"name":"alanherron"},"license":"MIT","homepage":"https://github.com/alanherron/kdp-cover-math#readme","keywords":["kdp","amazon","kindle-direct-publishing","self-publishing","print-on-demand","book","cover","spine","trim","bleed","barcode","paperback"],"repository":{"type":"git","url":"git+https://github.com/alanherron/kdp-cover-math.git"},"description":"Pure-function Amazon KDP paperback cover-wrap and interior-page geometry. Trim sizes, bleed, spine width, full cover-wrap dimensions.","maintainers":[{"name":"alanherron","email":"alanherron@gmail.com"}],"readme":"# @alankherron/kdp-cover-geometry\n\nPure-function Amazon KDP paperback **cover-wrap** and **interior-page** geometry. Returns the inch dimensions you need to lay out a print-ready cover or interior — trim, bleed, spine width, full wrap dimensions, safe areas, barcode box.\n\nZero dependencies. ESM + CJS + types. Works in Node, the browser, edge runtimes, and any TypeScript project.\n\n```\nnpm i @alankherron/kdp-cover-geometry\n```\n\n## Why this exists\n\nEvery KDP paperback designer rebuilds the same math. The official numbers are spread across [KDP docs](https://kdp.amazon.com/help/), most third-party tools hide the math behind paid services, and the only open-source equivalents are buried inside coupled application code (or licensed under restrictive non-commercial terms).\n\nThis package extracts the math as plain functions you can import anywhere — no UI, no opinions on rendering, no telemetry.\n\n## Quick start\n\n```ts\nimport {\n  coverDimensions,\n  interiorPageDimensions,\n  spineWidthInches,\n  spineSupportsText,\n  TRIM_SIZES,\n} from \"@alankherron/kdp-cover-geometry\";\n\n// Full cover wrap for a 40-page, 8.5\"x11\", white-paper paperback.\nconst cover = coverDimensions(\"8.5x11\", 40, \"white\");\n//          ^ trim id          ^ pages    ^ paper\n// → {\n//     trimWidthIn:  8.5,\n//     trimHeightIn: 11,\n//     spineIn:      0.09008,\n//     bleedIn:      0.125,\n//     fullWidthIn:  17.34008,        // 2 × 8.5 + spine + 2 × 0.125\n//     fullHeightIn: 11.25,           // 11 + 2 × 0.125\n//     safeInsetIn:  0.25,\n//     barcodeBoxIn: { widthIn: 2.0, heightIn: 1.2 },\n//   }\n\n// Interior page dimensions including bleed (or not).\nconst page = interiorPageDimensions(\"8.5x11\", \"bleed\");\n// → { trimWidthIn: 8.5, trimHeightIn: 11, pageWidthIn: 8.625, pageHeightIn: 11.25, bleedIn: 0.125, safeInsetIn: 0.25, gutterInsetIn: 0.375 }\n\n// Spine math.\nspineWidthInches(120, \"cream\");     // → 0.3 in\nspineSupportsText(60, \"white\");     // → false  (KDP requires ≥ 79 interior pages for spine text)\nspineSupportsText(120, \"cream\");    // → true\n\n// The four trim sizes this package knows about.\nTRIM_SIZES;\n// → [{ id: \"8.5x11\",  widthIn: 8.5, heightIn: 11,  label: '8.5\" × 11\"',  description: \"...\" },\n//    { id: \"8x10\",    widthIn: 8,   heightIn: 10,  ... },\n//    { id: \"9.5x9.5\", widthIn: 9.5, heightIn: 9.5, ... },\n//    { id: \"8.5x8.5\", widthIn: 8.5, heightIn: 8.5, ... }]\n```\n\n## API\n\n### Types\n\n- `TrimSizeId` — `\"8.5x11\" | \"8x10\" | \"9.5x9.5\" | \"8.5x8.5\"`.\n- `PaperType` — `\"white\" | \"cream\"`.\n- `BleedSetting` — `\"no-bleed\" | \"bleed\"`.\n\n### Constants\n\n| Constant | Value | What it represents |\n|---|---|---|\n| `BLEED_INCHES` | `0.125` | Outer-edge bleed for both interior pages and the cover wrap. |\n| `SAFE_AREA_INSET_IN` | `0.25` | Inset from trim where you should keep critical content. |\n| `GUTTER_INSET_IN` | `0.375` | Extra inset on the inside edge of interior pages. |\n| `SPINE_WHITE_PER_PAGE` | `0.002252` | Inches of spine thickness per page on white paper. |\n| `SPINE_CREAM_PER_PAGE` | `0.0025` | Inches of spine thickness per page on cream paper. |\n| `SPINE_TEXT_MIN_PAGES` | `79` | KDP's minimum interior page count for reliable printed spine text. |\n| `SPINE_TEXT_MIN_INCHES` | `0.06` | The thinnest spine KDP will print readable text on. |\n\n### Functions\n\n- `getTrim(id: TrimSizeId): TrimDimensions` — look up one trim record.\n- `interiorPageDimensions(trimId, bleed): InteriorPageDimensions` — page geometry for an interior layout.\n- `spineWidthInches(pageCount, paper): number` — spine width in inches.\n- `spineSupportsText(pageCount, paper): boolean` — whether KDP will print spine text on this book.\n- `coverDimensions(trimId, pageCount, paper): CoverDimensions` — full cover wrap geometry.\n\n### `TRIM_SIZES`\n\nRead-only catalogue of every trim this package supports. Each entry exposes `id`, `label`, `widthIn`, `heightIn`, and a short `description` suitable for UI.\n\n## Constraints and assumptions\n\n- Paperback-only. No hardcover, no PDF cover proofing, no Kindle eBook geometry.\n- Black-and-white interior assumption (the spine constants follow KDP's B&W price tier; color print uses different stocks and spine rates).\n- USD-agnostic; this package does not do pricing math. See [PRICING] for the conventional separate package if you need that.\n- Values are returned in **inches**. Convert to points or millimeters yourself if your renderer wants those.\n\n## Compatibility\n\nTested on Node 18+. Pure ECMAScript with no platform APIs — works in:\n- Node.js (ESM and CJS)\n- Browser bundlers (Webpack / Vite / esbuild / Turbopack / Bun)\n- Edge runtimes (Vercel Functions, Cloudflare Workers, Deno)\n- React / Vue / Svelte / SolidJS / vanilla\n\n## Sources\n\nAll formulas pulled from current KDP documentation:\n- [Print options for paperbacks](https://kdp.amazon.com/help/topic/G201834180)\n- [Cover sizing & bleed](https://kdp.amazon.com/help/topic/G201953020)\n- [Spine text requirements](https://kdp.amazon.com/help/topic/G201834180)\n- [Barcode safe area](https://kdp.amazon.com/help/topic/G201834200)\n\nKDP can and does update these from time to time — file an issue if you spot drift.\n\n## License\n\nMIT © alanherron — use freely in commercial work, no attribution required (but appreciated).\n\n## Related\n\nThis package was extracted from [starofthepage](https://starofthepage.com) — a coloring-book studio that turns photos into KDP-ready coloring books. The starofthepage app uses this package to compute every paperback wrap it lays out.\n","readmeFilename":"README.md"}