kordoc 1.7.1 → 1.7.2

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/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  detectFormat,
5
5
  parse,
6
6
  toArrayBuffer
7
- } from "./chunk-VOMMXHNQ.js";
7
+ } from "./chunk-NJ3R7LNR.js";
8
8
 
9
9
  // src/cli.ts
10
10
  import { readFileSync, writeFileSync, mkdirSync, statSync } from "fs";
@@ -97,7 +97,7 @@ program.name("kordoc").description("\uBAA8\uB450 \uD30C\uC2F1\uD574\uBC84\uB9AC\
97
97
  }
98
98
  });
99
99
  program.command("watch <dir>").description("\uB514\uB809\uD1A0\uB9AC \uAC10\uC2DC \u2014 \uC0C8 \uBB38\uC11C \uC790\uB3D9 \uBCC0\uD658").option("--webhook <url>", "\uACB0\uACFC \uC804\uC1A1 \uC6F9\uD6C5 URL").option("-d, --out-dir <dir>", "\uBCC0\uD658 \uACB0\uACFC \uCD9C\uB825 \uB514\uB809\uD1A0\uB9AC").option("-p, --pages <range>", "\uD398\uC774\uC9C0/\uC139\uC158 \uBC94\uC704").option("--format <type>", "\uCD9C\uB825 \uD615\uC2DD: markdown \uB610\uB294 json", "markdown").option("--silent", "\uC9C4\uD589 \uBA54\uC2DC\uC9C0 \uC228\uAE30\uAE30").action(async (dir, opts) => {
100
- const { watchDirectory } = await import("./watch-YPR56MI6.js");
100
+ const { watchDirectory } = await import("./watch-AKTZTPVF.js");
101
101
  await watchDirectory({
102
102
  dir,
103
103
  outDir: opts.outDir,
package/dist/index.cjs CHANGED
@@ -294,7 +294,7 @@ function tableToMarkdown(table) {
294
294
  }
295
295
 
296
296
  // src/utils.ts
297
- var VERSION = true ? "1.7.1" : "0.0.0-dev";
297
+ var VERSION = true ? "1.7.2" : "0.0.0-dev";
298
298
  function toArrayBuffer(buf) {
299
299
  if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
300
300
  return buf.buffer;
@@ -1614,6 +1614,20 @@ function extractLines(fnArray, argsArray) {
1614
1614
  let currentPath = [];
1615
1615
  let pathStartX = 0, pathStartY = 0;
1616
1616
  let curX = 0, curY = 0;
1617
+ function pushRectangle(path, rx, ry, rw, rh) {
1618
+ if (Math.abs(rh) < ORIENTATION_TOL * 2) {
1619
+ path.push({ x1: rx, y1: ry + rh / 2, x2: rx + rw, y2: ry + rh / 2 });
1620
+ } else if (Math.abs(rw) < ORIENTATION_TOL * 2) {
1621
+ path.push({ x1: rx + rw / 2, y1: ry, x2: rx + rw / 2, y2: ry + rh });
1622
+ } else {
1623
+ path.push(
1624
+ { x1: rx, y1: ry, x2: rx + rw, y2: ry },
1625
+ { x1: rx + rw, y1: ry, x2: rx + rw, y2: ry + rh },
1626
+ { x1: rx + rw, y1: ry + rh, x2: rx, y2: ry + rh },
1627
+ { x1: rx, y1: ry + rh, x2: rx, y2: ry }
1628
+ );
1629
+ }
1630
+ }
1617
1631
  function flushPath(isStroke) {
1618
1632
  if (!isStroke) {
1619
1633
  currentPath = [];
@@ -1632,49 +1646,78 @@ function extractLines(fnArray, argsArray) {
1632
1646
  lineWidth = args[0] || 1;
1633
1647
  break;
1634
1648
  case import_pdf.OPS.constructPath: {
1635
- const subOps = args[0];
1636
- const coords = args[1];
1637
- let ci = 0;
1638
- for (const subOp of subOps) {
1639
- if (subOp === import_pdf.OPS.moveTo) {
1640
- curX = coords[ci++];
1641
- curY = coords[ci++];
1642
- pathStartX = curX;
1643
- pathStartY = curY;
1644
- } else if (subOp === import_pdf.OPS.lineTo) {
1645
- const x2 = coords[ci++], y2 = coords[ci++];
1646
- currentPath.push({ x1: curX, y1: curY, x2, y2 });
1647
- curX = x2;
1648
- curY = y2;
1649
- } else if (subOp === import_pdf.OPS.rectangle) {
1650
- const rx = coords[ci++], ry = coords[ci++];
1651
- const rw = coords[ci++], rh = coords[ci++];
1652
- if (Math.abs(rh) < ORIENTATION_TOL * 2) {
1653
- currentPath.push({ x1: rx, y1: ry + rh / 2, x2: rx + rw, y2: ry + rh / 2 });
1654
- } else if (Math.abs(rw) < ORIENTATION_TOL * 2) {
1655
- currentPath.push({ x1: rx + rw / 2, y1: ry, x2: rx + rw / 2, y2: ry + rh });
1656
- } else {
1657
- currentPath.push(
1658
- { x1: rx, y1: ry, x2: rx + rw, y2: ry },
1659
- // bottom
1660
- { x1: rx + rw, y1: ry, x2: rx + rw, y2: ry + rh },
1661
- // right
1662
- { x1: rx + rw, y1: ry + rh, x2: rx, y2: ry + rh },
1663
- // top
1664
- { x1: rx, y1: ry + rh, x2: rx, y2: ry }
1665
- // left
1666
- );
1649
+ const arg0 = args[0];
1650
+ if (Array.isArray(arg0)) {
1651
+ const subOps = arg0;
1652
+ const coords = args[1];
1653
+ let ci = 0;
1654
+ for (const subOp of subOps) {
1655
+ if (subOp === import_pdf.OPS.moveTo) {
1656
+ curX = coords[ci++];
1657
+ curY = coords[ci++];
1658
+ pathStartX = curX;
1659
+ pathStartY = curY;
1660
+ } else if (subOp === import_pdf.OPS.lineTo) {
1661
+ const x2 = coords[ci++], y2 = coords[ci++];
1662
+ currentPath.push({ x1: curX, y1: curY, x2, y2 });
1663
+ curX = x2;
1664
+ curY = y2;
1665
+ } else if (subOp === import_pdf.OPS.rectangle) {
1666
+ const rx = coords[ci++], ry = coords[ci++];
1667
+ const rw = coords[ci++], rh = coords[ci++];
1668
+ pushRectangle(currentPath, rx, ry, rw, rh);
1669
+ } else if (subOp === import_pdf.OPS.closePath) {
1670
+ if (curX !== pathStartX || curY !== pathStartY) {
1671
+ currentPath.push({ x1: curX, y1: curY, x2: pathStartX, y2: pathStartY });
1672
+ }
1673
+ curX = pathStartX;
1674
+ curY = pathStartY;
1675
+ } else if (subOp === import_pdf.OPS.curveTo) {
1676
+ ci += 6;
1677
+ } else if (subOp === import_pdf.OPS.curveTo2 || subOp === import_pdf.OPS.curveTo3) {
1678
+ ci += 4;
1667
1679
  }
1668
- } else if (subOp === import_pdf.OPS.closePath) {
1669
- if (curX !== pathStartX || curY !== pathStartY) {
1670
- currentPath.push({ x1: curX, y1: curY, x2: pathStartX, y2: pathStartY });
1680
+ }
1681
+ } else {
1682
+ const afterOp = arg0;
1683
+ const dataArr = args[1];
1684
+ const pathData = dataArr?.[0];
1685
+ if (pathData && typeof pathData === "object") {
1686
+ const len = Object.keys(pathData).length;
1687
+ let di = 0;
1688
+ while (di < len) {
1689
+ const drawOp = pathData[di++];
1690
+ if (drawOp === 0 /* moveTo */) {
1691
+ curX = pathData[di++];
1692
+ curY = pathData[di++];
1693
+ pathStartX = curX;
1694
+ pathStartY = curY;
1695
+ } else if (drawOp === 1 /* lineTo */) {
1696
+ const x2 = pathData[di++], y2 = pathData[di++];
1697
+ currentPath.push({ x1: curX, y1: curY, x2, y2 });
1698
+ curX = x2;
1699
+ curY = y2;
1700
+ } else if (drawOp === 2 /* curveTo */) {
1701
+ di += 6;
1702
+ } else if (drawOp === 3 /* quadraticCurveTo */) {
1703
+ di += 4;
1704
+ } else if (drawOp === 4 /* closePath */) {
1705
+ if (curX !== pathStartX || curY !== pathStartY) {
1706
+ currentPath.push({ x1: curX, y1: curY, x2: pathStartX, y2: pathStartY });
1707
+ }
1708
+ curX = pathStartX;
1709
+ curY = pathStartY;
1710
+ } else {
1711
+ break;
1712
+ }
1671
1713
  }
1672
- curX = pathStartX;
1673
- curY = pathStartY;
1674
- } else if (subOp === import_pdf.OPS.curveTo) {
1675
- ci += 6;
1676
- } else if (subOp === import_pdf.OPS.curveTo2 || subOp === import_pdf.OPS.curveTo3) {
1677
- ci += 4;
1714
+ }
1715
+ if (afterOp === import_pdf.OPS.stroke || afterOp === import_pdf.OPS.closeStroke) {
1716
+ flushPath(true);
1717
+ } else if (afterOp === import_pdf.OPS.fill || afterOp === import_pdf.OPS.eoFill || afterOp === import_pdf.OPS.fillStroke || afterOp === import_pdf.OPS.eoFillStroke || afterOp === import_pdf.OPS.closeFillStroke || afterOp === import_pdf.OPS.closeEOFillStroke) {
1718
+ flushPath(true);
1719
+ } else if (afterOp === import_pdf.OPS.endPath) {
1720
+ flushPath(false);
1678
1721
  }
1679
1722
  }
1680
1723
  break;