pagyra-js 0.0.21 → 0.0.22

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.
Files changed (37) hide show
  1. package/README.md +283 -264
  2. package/dist/browser/pagyra.min.js +18 -18
  3. package/dist/browser/pagyra.min.js.map +3 -3
  4. package/dist/src/layout/inline/run-placer.js +1 -1
  5. package/dist/src/layout/strategies/grid.js +0 -3
  6. package/dist/src/pdf/font/embedder.js +3 -3
  7. package/dist/src/pdf/font/font-subset.js +1 -3
  8. package/dist/src/pdf/font/to-unicode.js +16 -16
  9. package/dist/src/pdf/utils/node-text-run-factory.js +1 -27
  10. package/dist/tests/environment/path-resolution.spec.js +2 -1
  11. package/dist/tests/helpers/ai-layout-diagnostics.js +6 -6
  12. package/dist/tests/layout/container-query-units.spec.js +0 -7
  13. package/dist/tests/layout/inline-background-alignment.spec.js +6 -6
  14. package/dist/tests/pdf/alignments.spec.js +12 -12
  15. package/dist/tests/pdf/svg-stroke-dash.spec.js +8 -8
  16. package/dist/tests/pdf/text-transform-matrix.spec.js +1 -1
  17. package/dist/tests/pdf/xref-integrity.spec.js +1 -1
  18. package/dist/tests/verify-subset-multi.spec.js +14 -14
  19. package/dist/tests/verify-subset.spec.js +12 -12
  20. package/package.json +89 -71
  21. package/dist/src/image/js-png-backend.d.ts +0 -7
  22. package/dist/src/image/js-png-backend.js +0 -9
  23. package/dist/src/image/png-backend.d.ts +0 -5
  24. package/dist/src/image/png-backend.js +0 -1
  25. package/dist/src/image/png-wasm-loader.d.ts +0 -5
  26. package/dist/src/image/png-wasm-loader.js +0 -59
  27. package/dist/src/image/wasm/png_decoder_wasm.d.ts +0 -8
  28. package/dist/src/image/wasm/png_decoder_wasm.js +0 -24
  29. package/dist/src/image/wasm/png_decoder_wasm_bg.js +0 -16
  30. package/dist/src/image/wasm-png-backend.d.ts +0 -6
  31. package/dist/src/image/wasm-png-backend.js +0 -17
  32. package/dist/tests/image/png-backend.spec.d.ts +0 -1
  33. package/dist/tests/image/png-backend.spec.js +0 -34
  34. package/dist/tests/pdf/font-subset-registry-key.spec.d.ts +0 -1
  35. package/dist/tests/pdf/font-subset-registry-key.spec.js +0 -66
  36. package/dist/tests/pdf/header-footer.spec.d.ts +0 -1
  37. package/dist/tests/pdf/header-footer.spec.js +0 -46
@@ -18,7 +18,7 @@ export class RunPlacer {
18
18
  if (parts.length === 0) {
19
19
  return;
20
20
  }
21
- const { lineTop, lineHeight, lineStartX, lineIndex, availableWidth, offsetShift, isLastLine, contentX, inlineOffsetStart } = lineContext;
21
+ const { lineTop, lineStartX, lineIndex, availableWidth, offsetShift, isLastLine, contentX, inlineOffsetStart } = lineContext;
22
22
  const lineWidth = parts.reduce((max, part) => Math.max(max, part.offset + part.item.width), 0);
23
23
  const currentAvailableWidth = Math.max(availableWidth, 0);
24
24
  const spaceCount = parts.reduce((count, part) => {
@@ -161,7 +161,6 @@ export class GridLayoutStrategy {
161
161
  node.box.marginBoxWidth = node.box.borderBoxWidth + horizontalMargin(node, resolvedContentWidth, cb.height);
162
162
  const columnOffsets = calculateTrackOffsets(columnWidths, columnGap);
163
163
  const rows = [];
164
- let currentRowTop = contentOriginY;
165
164
  let currentRowHeight = 0;
166
165
  let columnIndex = 0;
167
166
  let currentRowItems = [];
@@ -174,7 +173,6 @@ export class GridLayoutStrategy {
174
173
  if (columnIndex + span > columnWidths.length) {
175
174
  if (currentRowItems.length > 0) {
176
175
  rows.push({ items: currentRowItems, height: currentRowHeight });
177
- currentRowTop += currentRowHeight + rowGap;
178
176
  currentRowHeight = 0;
179
177
  currentRowItems = [];
180
178
  }
@@ -203,7 +201,6 @@ export class GridLayoutStrategy {
203
201
  columnIndex += span;
204
202
  if (columnIndex >= columnWidths.length) {
205
203
  rows.push({ items: currentRowItems, height: currentRowHeight });
206
- currentRowTop += currentRowHeight + rowGap;
207
204
  currentRowHeight = 0;
208
205
  columnIndex = 0;
209
206
  currentRowItems = [];
@@ -90,7 +90,7 @@ export class FontEmbedder {
90
90
  const fullFontData = new Uint8Array(face.data);
91
91
  const resourceName = `F${this.embeddedFonts.size + 1}`;
92
92
  let realizedRef;
93
- const self = this;
93
+ const realizeFont = this.realizeFont.bind(this);
94
94
  const embedded = {
95
95
  resourceName,
96
96
  baseFont: face.name,
@@ -98,14 +98,14 @@ export class FontEmbedder {
98
98
  subset: fullFontData,
99
99
  get ref() {
100
100
  if (!realizedRef) {
101
- realizedRef = self.realizeFont(face, metrics, resourceName);
101
+ realizedRef = realizeFont(face, metrics);
102
102
  }
103
103
  return realizedRef;
104
104
  }
105
105
  };
106
106
  return embedded;
107
107
  }
108
- realizeFont(face, metrics, resourceName) {
108
+ realizeFont(face, metrics) {
109
109
  const unitsPerEm = metrics.metrics.unitsPerEm;
110
110
  const scaleTo1000 = (v) => Math.round((v / unitsPerEm) * 1000);
111
111
  let fontBBox;
@@ -16,7 +16,6 @@ export function createPdfFontSubset(options) {
16
16
  const { glyphIds, gidMap } = computeSubsetClosure(fontProgram, initialGids);
17
17
  const unitsPerEm = fontMetrics.metrics.unitsPerEm;
18
18
  const widths = [];
19
- const usedGidSet = new Set(glyphIds);
20
19
  let firstChar;
21
20
  let lastChar;
22
21
  if (encoding === "sequential") {
@@ -174,7 +173,6 @@ function subsetFont(fontProgram, glyphIds, encoding) {
174
173
  }
175
174
  const headView = new DataView(head.buffer, head.byteOffset, head.byteLength);
176
175
  const locaView = new DataView(loca.buffer, loca.byteOffset, loca.byteLength);
177
- const glyfView = new DataView(glyf.buffer, glyf.byteOffset, glyf.byteLength);
178
176
  const hmtxView = new DataView(hmtx.buffer, hmtx.byteOffset, hmtx.byteLength);
179
177
  const hheaView = new DataView(hhea.buffer, hhea.byteOffset, hhea.byteLength);
180
178
  const indexToLocFormat = reader.getUint16(headView, 50);
@@ -352,7 +350,7 @@ function subsetFont(fontProgram, glyphIds, encoding) {
352
350
  paddedLength += 4 - (data.length % 4);
353
351
  offset += paddedLength;
354
352
  }
355
- for (const [_, data] of tables) {
353
+ for (const [, data] of tables) {
356
354
  fullTtf.writeBytes(data);
357
355
  const padding = (4 - (data.length % 4)) % 4;
358
356
  for (let k = 0; k < padding; k++)
@@ -4,22 +4,22 @@
4
4
  */
5
5
  export function createToUnicodeCMapText(entries) {
6
6
  if (!entries || entries.length === 0) {
7
- return `/CIDInit /ProcSet findresource begin
8
- 12 dict begin
9
- begincmap
10
- /CIDSystemInfo <<
11
- /Registry (Adobe)
12
- /Ordering (UCS)
13
- /Supplement 0
14
- >> def
15
- /CMapName /Adobe-Identity-UCS def
16
- /CMapType 2 def
17
- 1 begincodespacerange
18
- <0000> <FFFF>
19
- endcodespacerange
20
- endcmap
21
- CMapName currentdict /CMap defineresource pop
22
- end
7
+ return `/CIDInit /ProcSet findresource begin
8
+ 12 dict begin
9
+ begincmap
10
+ /CIDSystemInfo <<
11
+ /Registry (Adobe)
12
+ /Ordering (UCS)
13
+ /Supplement 0
14
+ >> def
15
+ /CMapName /Adobe-Identity-UCS def
16
+ /CMapType 2 def
17
+ 1 begincodespacerange
18
+ <0000> <FFFF>
19
+ endcodespacerange
20
+ endcmap
21
+ CMapName currentdict /CMap defineresource pop
22
+ end
23
23
  end`;
24
24
  }
25
25
  const es = entries.slice().sort((a, b) => a.gid - b.gid);
@@ -1,8 +1,7 @@
1
1
  import { createTextRuns } from "./text-utils.js";
2
2
  import { createListMarkerRun } from "./list-utils.js";
3
- import { multiplyMatrices } from "../../geometry/matrix.js";
4
3
  export function buildNodeTextRuns(context) {
5
- const { node, children, borderBox, contentBox, textColor, decorations, transform, fallbackColor, fontResolver, textGradient } = context;
4
+ const { node, children, contentBox, textColor, decorations, fallbackColor, fontResolver, textGradient } = context;
6
5
  const textRuns = createTextRuns(node, textColor, decorations);
7
6
  // If we have a fontResolver, enhance text runs with GlyphRun data
8
7
  if (fontResolver) {
@@ -19,33 +18,8 @@ export function buildNodeTextRuns(context) {
19
18
  run.textGradient = textGradient;
20
19
  }
21
20
  }
22
- if (transform && textRuns.length > 0) {
23
- // applyTransformToTextRuns(textRuns, transform, borderBox);
24
- }
25
21
  return textRuns;
26
22
  }
27
- function applyTransformToTextRuns(runs, cssMatrix, originBox) {
28
- if (runs.length === 0) {
29
- return;
30
- }
31
- const baseOriginX = Number.isFinite(originBox.x) ? originBox.x : 0;
32
- const baseOriginY = Number.isFinite(originBox.y) ? originBox.y : 0;
33
- const originWidth = Number.isFinite(originBox.width) ? originBox.width : 0;
34
- const originHeight = Number.isFinite(originBox.height) ? originBox.height : 0;
35
- const originX = baseOriginX + originWidth / 2;
36
- const originY = baseOriginY + originHeight / 2;
37
- const toOrigin = translationMatrix(-originX, -originY);
38
- const fromOrigin = translationMatrix(originX, originY);
39
- for (const run of runs) {
40
- const baseMatrix = run.lineMatrix ?? { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
41
- const localMatrix = multiplyMatrices(toOrigin, baseMatrix);
42
- const transformedLocal = multiplyMatrices(cssMatrix, localMatrix);
43
- run.lineMatrix = multiplyMatrices(fromOrigin, transformedLocal);
44
- }
45
- }
46
- function translationMatrix(tx, ty) {
47
- return { a: 1, b: 0, c: 0, d: 1, e: tx, f: ty };
48
- }
49
23
  /**
50
24
  * Enriches text runs with GlyphRun data for TTF-based rendering.
51
25
  * For each run, resolves the font, maps text to glyph IDs, and computes positions.
@@ -1,9 +1,10 @@
1
1
  import { NodeEnvironment } from '../../src/environment/node-environment.js';
2
2
  import { BrowserEnvironment } from '../../src/environment/browser-environment.js';
3
3
  import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
4
5
  describe('Path Resolution', () => {
5
6
  describe('NodeEnvironment', () => {
6
- const toPath = (p) => p.startsWith('file:') ? require('node:url').fileURLToPath(p) : p;
7
+ const toPath = (p) => p.startsWith('file:') ? fileURLToPath(p) : p;
7
8
  it('resolves leading-slash paths relative to base', () => {
8
9
  const env = new NodeEnvironment();
9
10
  const base = path.resolve('/var/www/public');
@@ -51,12 +51,12 @@ export function renderAsciiLayout() {
51
51
  const contentH = Math.round(contentBox.height);
52
52
  const spanW = Math.round(spanBox.width);
53
53
  const spanH = Math.round(spanBox.height);
54
- const ascii = `Border Box (W:${borderW}, H:${borderH}) |#########################|
55
- Content Box at (${Math.round(contentX)}, ${Math.round(contentY)}) (W:${contentW}, H:${contentH}) | +---+ |
56
- | |###| |
57
- | +---+ |
58
- Span Box at (${Math.round(spanX)}, ${Math.round(spanY)}) (W:${spanW}, H:${spanH}) | [xxx] |
59
- Padding: T:${padding.top}, R:${padding.right}, B:${padding.bottom}, L:${padding.left}
54
+ const ascii = `Border Box (W:${borderW}, H:${borderH}) |#########################|
55
+ Content Box at (${Math.round(contentX)}, ${Math.round(contentY)}) (W:${contentW}, H:${contentH}) | +---+ |
56
+ | |###| |
57
+ | +---+ |
58
+ Span Box at (${Math.round(spanX)}, ${Math.round(spanY)}) (W:${spanW}, H:${spanH}) | [xxx] |
59
+ Padding: T:${padding.top}, R:${padding.right}, B:${padding.bottom}, L:${padding.left}
60
60
  Border: T:${border.top}, R:${border.right}, B:${border.bottom}, L:${border.left}`;
61
61
  context.ascii = ascii;
62
62
  return ascii;
@@ -1,11 +1,4 @@
1
1
  import { collectBoxes, renderTreeForHtml } from "../helpers/render-utils.js";
2
- function findByTag(boxes, tagName) {
3
- const found = boxes.find((b) => b.tagName === tagName);
4
- if (!found) {
5
- throw new Error(`Expected to find <${tagName}> in render tree`);
6
- }
7
- return found;
8
- }
9
2
  describe("container query unit layout", () => {
10
3
  it("resolves cqw/cqh/cqmin/cqmax against containing block dimensions", async () => {
11
4
  const html = "<!DOCTYPE html><html><body style=\"margin:0;\"><section style=\"width:400px;height:300px;\"><div id=\"a\" style=\"width:50cqw;height:25cqh;\"></div><div id=\"b\" style=\"width:10cqmin;height:10cqmax;\"></div></section></body></html>";
@@ -5,8 +5,8 @@ const POSITION_TOLERANCE_PX = 10;
5
5
  const WIDTH_TOLERANCE_RATIO = 0.9;
6
6
  describe("inline background alignment", () => {
7
7
  it("aligns background with text for inline span elements", async () => {
8
- const html = `
9
- <p>Normal text <span style="background-color: yellow">highlighted text</span> after.</p>
8
+ const html = `
9
+ <p>Normal text <span style="background-color: yellow">highlighted text</span> after.</p>
10
10
  `;
11
11
  const renderTree = await renderTreeForHtml(html);
12
12
  const boxes = collectBoxes(renderTree.root);
@@ -28,8 +28,8 @@ describe("inline background alignment", () => {
28
28
  }
29
29
  });
30
30
  it("calculates correct width for inline span with multiple text fragments", async () => {
31
- const html = `
32
- <p>Before <span style="background-color: lightblue">text one two three</span> after.</p>
31
+ const html = `
32
+ <p>Before <span style="background-color: lightblue">text one two three</span> after.</p>
33
33
  `;
34
34
  const renderTree = await renderTreeForHtml(html);
35
35
  const boxes = collectBoxes(renderTree.root);
@@ -56,8 +56,8 @@ describe("inline background alignment", () => {
56
56
  }
57
57
  });
58
58
  it("positions background correctly when span follows other content", async () => {
59
- const html = `
60
- <p>Some initial text <span style="background-color: pink">highlighted</span> end.</p>
59
+ const html = `
60
+ <p>Some initial text <span style="background-color: pink">highlighted</span> end.</p>
61
61
  `;
62
62
  const renderTree = await renderTreeForHtml(html);
63
63
  const boxes = collectBoxes(renderTree.root);
@@ -1,18 +1,18 @@
1
1
  import { renderRuns } from "../helpers/render-utils.js";
2
2
  describe("PDF text alignment (non-justify)", () => {
3
3
  it("does not apply justification to left/center/right alignments", async () => {
4
- const html = `
5
- <div>
6
- <p style="width: 260px; text-align: left;">
7
- Some sample text that wraps into multiple lines for left.
8
- </p>
9
- <p style="width: 260px; text-align: center;">
10
- Some sample text that wraps into multiple lines for center.
11
- </p>
12
- <p style="width: 260px; text-align: right;">
13
- Some sample text that wraps into multiple lines for right.
14
- </p>
15
- </div>
4
+ const html = `
5
+ <div>
6
+ <p style="width: 260px; text-align: left;">
7
+ Some sample text that wraps into multiple lines for left.
8
+ </p>
9
+ <p style="width: 260px; text-align: center;">
10
+ Some sample text that wraps into multiple lines for center.
11
+ </p>
12
+ <p style="width: 260px; text-align: right;">
13
+ Some sample text that wraps into multiple lines for right.
14
+ </p>
15
+ </div>
16
16
  `;
17
17
  const runs = await renderRuns(html);
18
18
  // no positive wordSpacing anywhere
@@ -7,10 +7,10 @@ import { GraphicsStateManager } from "../../src/pdf/renderers/graphics-state-man
7
7
  import { parseHTML } from "linkedom";
8
8
  describe("SVG Stroke Dash Support", () => {
9
9
  it("should render path with stroke-dasharray", async () => {
10
- const { document } = parseHTML(`
11
- <svg>
12
- <path d="M10 10 L90 10" stroke="black" stroke-width="2" stroke-dasharray="5,5" />
13
- </svg>
10
+ const { document } = parseHTML(`
11
+ <svg>
12
+ <path d="M10 10 L90 10" stroke="black" stroke-width="2" stroke-dasharray="5,5" />
13
+ </svg>
14
14
  `);
15
15
  const pathElement = document.querySelector("path");
16
16
  const context = { warn: () => { } };
@@ -36,10 +36,10 @@ describe("SVG Stroke Dash Support", () => {
36
36
  expect(commands).toContain("[3.75 3.75] 0 d");
37
37
  });
38
38
  it("should render path with stroke-dasharray and stroke-dashoffset", async () => {
39
- const { document } = parseHTML(`
40
- <svg>
41
- <path d="M10 30 L90 30" stroke="black" stroke-width="2" stroke-dasharray="10 5" stroke-dashoffset="5" />
42
- </svg>
39
+ const { document } = parseHTML(`
40
+ <svg>
41
+ <path d="M10 30 L90 30" stroke="black" stroke-width="2" stroke-dasharray="10 5" stroke-dashoffset="5" />
42
+ </svg>
43
43
  `);
44
44
  const pathElement = document.querySelector("path");
45
45
  const context = { warn: () => { } };
@@ -1,4 +1,4 @@
1
- import { renderRuns, renderTreeForHtml, collectBoxes, collectRuns } from "../helpers/render-utils.js";
1
+ import { renderTreeForHtml, collectBoxes, collectRuns } from "../helpers/render-utils.js";
2
2
  const TAN_20 = Math.tan((20 * Math.PI) / 180);
3
3
  describe("PDF text transforms", () => {
4
4
  it("applies skewX to text runs (keeps linear components in CSS space)", async () => {
@@ -82,7 +82,7 @@ describe("xref table integrity", () => {
82
82
  const streamData = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
83
83
  const streamRef = doc.registerStream(streamData);
84
84
  const patternRef = doc.registerPattern("P0", "<< /PatternType 2 /Shading null >>");
85
- const customRef = doc.register({ Type: "/Custom", Value: 42 });
85
+ doc.register({ Type: "/Custom", Value: 42 });
86
86
  const fontRef = doc.registerStandardFont("Courier");
87
87
  const shadingRef = doc.registerShading("S0", "<< /ShadingType 2 /ColorSpace /DeviceRGB /Coords [0 0 1 1] /Function null >>");
88
88
  doc.addPage({
@@ -5,20 +5,20 @@ import fs from 'node:fs';
5
5
  describe('Multi-Font Subsetting Verification', () => {
6
6
  it('should generate a small PDF with Tinos and Arimo fonts', async () => {
7
7
  process.env.PAGYRA_FONTS_DIR = path.resolve(process.cwd(), 'assets/fonts');
8
- const html = `
9
- <!DOCTYPE html>
10
- <html>
11
- <head>
12
- <style>
13
- .serif { font-family: 'Tinos', serif; font-size: 24px; }
14
- .sans { font-family: 'Arimo', sans-serif; font-size: 24px; }
15
- </style>
16
- </head>
17
- <body>
18
- <div class="serif">Serif Text: Hello World with Tinos! - ação, acentuação, coração</div>
19
- <div class="sans">Sans-Serif Text: Hello World with Arimo! - ação, acentuação, coração</div>
20
- </body>
21
- </html>
8
+ const html = `
9
+ <!DOCTYPE html>
10
+ <html>
11
+ <head>
12
+ <style>
13
+ .serif { font-family: 'Tinos', serif; font-size: 24px; }
14
+ .sans { font-family: 'Arimo', sans-serif; font-size: 24px; }
15
+ </style>
16
+ </head>
17
+ <body>
18
+ <div class="serif">Serif Text: Hello World with Tinos! - ação, acentuação, coração</div>
19
+ <div class="sans">Sans-Serif Text: Hello World with Arimo! - ação, acentuação, coração</div>
20
+ </body>
21
+ </html>
22
22
  `;
23
23
  const pdfBuffer = await renderHtmlToPdf({
24
24
  html,
@@ -6,18 +6,18 @@ describe('Font Subsetting Verification', () => {
6
6
  it('should generate a small PDF with Tinos font', async () => {
7
7
  // Point to assets relative to CWD (project root)
8
8
  process.env.PAGYRA_FONTS_DIR = path.resolve(process.cwd(), 'assets/fonts');
9
- const html = `
10
- <!DOCTYPE html>
11
- <html>
12
- <head>
13
- <style>
14
- body { font-family: 'Tinos', serif; font-size: 24px; }
15
- </style>
16
- </head>
17
- <body>
18
- Hello World with Tinos!
19
- </body>
20
- </html>
9
+ const html = `
10
+ <!DOCTYPE html>
11
+ <html>
12
+ <head>
13
+ <style>
14
+ body { font-family: 'Tinos', serif; font-size: 24px; }
15
+ </style>
16
+ </head>
17
+ <body>
18
+ Hello World with Tinos!
19
+ </body>
20
+ </html>
21
21
  `;
22
22
  const pdfBuffer = await renderHtmlToPdf({
23
23
  html,
package/package.json CHANGED
@@ -1,71 +1,89 @@
1
- {
2
- "name": "pagyra-js",
3
- "version": "0.0.21",
4
- "type": "module",
5
- "files": [
6
- "dist"
7
- ],
8
- "main": "./dist/src/index.js",
9
- "types": "./dist/src/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./dist/src/index.d.ts",
13
- "import": "./dist/src/index.js",
14
- "default": "./dist/src/index.js"
15
- },
16
- "./browser": {
17
- "types": "./dist/src/browser-entry.d.ts",
18
- "import": "./dist/src/browser-entry.js",
19
- "default": "./dist/browser/pagyra.min.js"
20
- },
21
- "./package.json": "./package.json"
22
- },
23
- "browser": {
24
- "node:path": false,
25
- "node:url": false,
26
- "node:fs/promises": false,
27
- "node:zlib": false,
28
- "node:util": false,
29
- "zlib": false,
30
- "fs": false,
31
- "path": false,
32
- "url": false,
33
- "util": false,
34
- "./src/pdf/font/builtin-fonts.js": "./src/pdf/font/builtin-fonts.browser.js",
35
- "./src/environment/node-environment.js": "./src/environment/node-environment.browser.js",
36
- "./dist/src/pdf/font/builtin-fonts.js": "./dist/src/pdf/font/builtin-fonts.browser.js",
37
- "./dist/src/environment/node-environment.js": "./dist/src/environment/node-environment.browser.js"
38
- },
39
- "scripts": {
40
- "build": "tsc && tsx scripts/copy-brotli-vendor.ts && tsx scripts/copy-font-assets.ts && tsx scripts/build-browser-bundle.ts --target dist --sourcemap --minify",
41
- "check": "tsc --noEmit",
42
- "start": "npm run playground",
43
- "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
44
- "test": "vitest run",
45
- "lint": "eslint src tests --ext .ts,.js",
46
- "playground": "tsx playground/server.ts",
47
- "playground:browser": "tsx scripts/playground-browser-server.ts",
48
- "playground:render": "tsx scripts/render-playground-example.ts --debug-level debug --debug-cats 'layout,paint,pdf'",
49
- "build:browser": "tsx scripts/build-browser-bundle.ts --target dist --sourcemap --minify",
50
- "playground:pages": "tsx scripts/playground-pages-preview.ts"
51
- },
52
- "devDependencies": {
53
- "@types/css": "^0.0.36",
54
- "@types/express": "^4.17.23",
55
- "@types/node": "^22.7.4",
56
- "@typescript-eslint/eslint-plugin": "^8.46.4",
57
- "@typescript-eslint/parser": "^8.46.4",
58
- "esbuild": "^0.21.5",
59
- "eslint": "^9.39.1",
60
- "express": "^4.21.2",
61
- "pdf-parse": "^2.4.5",
62
- "playwright": "^1.57.0",
63
- "tsx": "^4.7.1",
64
- "typescript": "^5.9.0",
65
- "vitest": "^1.6.0"
66
- },
67
- "dependencies": {
68
- "css": "^3.0.0",
69
- "linkedom": "^0.18.12"
70
- }
71
- }
1
+ {
2
+ "name": "pagyra-js",
3
+ "version": "0.0.22",
4
+ "type": "module",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/celsowm/pagyra-js.git"
8
+ },
9
+ "homepage": "https://github.com/celsowm/pagyra-js#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/celsowm/pagyra-js/issues"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "main": "./dist/src/index.js",
20
+ "types": "./dist/src/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/src/index.d.ts",
24
+ "import": "./dist/src/index.js",
25
+ "default": "./dist/src/index.js"
26
+ },
27
+ "./browser": {
28
+ "types": "./dist/src/browser-entry.d.ts",
29
+ "import": "./dist/browser/pagyra.min.js",
30
+ "default": "./dist/browser/pagyra.min.js"
31
+ },
32
+ "./browser-entry": {
33
+ "types": "./dist/src/browser-entry.d.ts",
34
+ "import": "./dist/src/browser-entry.js",
35
+ "default": "./dist/src/browser-entry.js"
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
39
+ "browser": {
40
+ "node:path": false,
41
+ "node:url": false,
42
+ "node:fs/promises": false,
43
+ "node:zlib": false,
44
+ "node:util": false,
45
+ "zlib": false,
46
+ "fs": false,
47
+ "path": false,
48
+ "url": false,
49
+ "util": false,
50
+ "./src/pdf/font/builtin-fonts.js": "./src/pdf/font/builtin-fonts.browser.js",
51
+ "./src/environment/node-environment.js": "./src/environment/node-environment.browser.js",
52
+ "./dist/src/pdf/font/builtin-fonts.js": "./dist/src/pdf/font/builtin-fonts.browser.js",
53
+ "./dist/src/environment/node-environment.js": "./dist/src/environment/node-environment.browser.js"
54
+ },
55
+ "scripts": {
56
+ "build": "tsc && tsx scripts/copy-brotli-vendor.ts && tsx scripts/copy-font-assets.ts && tsx scripts/build-browser-bundle.ts --target dist --sourcemap --minify",
57
+ "check": "tsc --noEmit",
58
+ "start": "npm run playground",
59
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
60
+ "validate": "npm run lint && npm test",
61
+ "publish:npm": "npm publish --provenance",
62
+ "test": "vitest run",
63
+ "lint": "eslint src tests --ext .ts,.js",
64
+ "playground": "tsx playground/server.ts",
65
+ "playground:browser": "tsx scripts/playground-browser-server.ts",
66
+ "playground:render": "tsx scripts/render-playground-example.ts --debug-level debug --debug-cats 'layout,paint,pdf'",
67
+ "build:browser": "tsx scripts/build-browser-bundle.ts --target dist --sourcemap --minify",
68
+ "playground:pages": "tsx scripts/playground-pages-preview.ts"
69
+ },
70
+ "devDependencies": {
71
+ "@types/css": "^0.0.36",
72
+ "@types/express": "^4.17.23",
73
+ "@types/node": "^22.7.4",
74
+ "@typescript-eslint/eslint-plugin": "^8.46.4",
75
+ "@typescript-eslint/parser": "^8.46.4",
76
+ "esbuild": "^0.21.5",
77
+ "eslint": "^9.39.1",
78
+ "express": "^4.21.2",
79
+ "pdf-parse": "^2.4.5",
80
+ "playwright": "^1.57.0",
81
+ "tsx": "^4.7.1",
82
+ "typescript": "^5.9.0",
83
+ "vitest": "^1.6.0"
84
+ },
85
+ "dependencies": {
86
+ "css": "^3.0.0",
87
+ "linkedom": "^0.18.12"
88
+ }
89
+ }
@@ -1,7 +0,0 @@
1
- import type { ImageInfo } from "./types.js";
2
- import type { ImageDecodeOptions } from "./types.js";
3
- import type { PngBackend } from "./png-backend.js";
4
- export declare class JsPngBackend implements PngBackend {
5
- private readonly pngDecoder;
6
- decode(buffer: ArrayBuffer, options?: ImageDecodeOptions): Promise<ImageInfo>;
7
- }
@@ -1,9 +0,0 @@
1
- import { PngDecoder } from "./png-decoder.js";
2
- export class JsPngBackend {
3
- constructor() {
4
- this.pngDecoder = new PngDecoder();
5
- }
6
- async decode(buffer, options) {
7
- return this.pngDecoder.decode(buffer, options);
8
- }
9
- }
@@ -1,5 +0,0 @@
1
- import type { ImageInfo } from "./types.js";
2
- import type { ImageDecodeOptions } from "./types.js";
3
- export interface PngBackend {
4
- decode(buffer: ArrayBuffer, options?: ImageDecodeOptions): Promise<ImageInfo>;
5
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- export declare class PngWasmLoader {
2
- static getOrInit(): Promise<any>;
3
- static isAvailable(): Promise<boolean>;
4
- static reset(): void;
5
- }