@oh-my-pi/pi-natives 17.3.2 → 17.3.4

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 CHANGED
@@ -10,6 +10,7 @@ Native Rust functionality via N-API.
10
10
  - **Audio**: Cross-platform low-latency microphone capture and gapless speaker playback
11
11
  - **WebRTC**: Native Opus media, SDP offer/answer negotiation, and data-channel events for live sessions
12
12
  - **File locking**: Process-owned cross-process locks with in-memory kernel names on Linux/Windows and `flock(2)` sidecars on other Unix platforms
13
+ - **PDF**: In-memory PDF-to-Markdown extraction with OCR-page classification via `pdf-inspector`
13
14
 
14
15
  General-purpose image processing (decode/resize/encode for files and buffers)
15
16
  lives in [`Bun.Image`](https://bun.com/docs/runtime/image) on the JS side; this
@@ -19,7 +20,7 @@ that terminal protocol.
19
20
  ## Usage
20
21
 
21
22
  ```typescript
22
- import { grep, find, encodeSixel } from "@oh-my-pi/pi-natives";
23
+ import { encodeSixel, grep, pdfToMarkdown } from "@oh-my-pi/pi-natives";
23
24
 
24
25
  // Grep for a pattern
25
26
  const results = await grep({
@@ -38,6 +39,10 @@ const files = await find({
38
39
 
39
40
  // SIXEL encode for a terminal cell box (px)
40
41
  const sequence = encodeSixel(pngBytes, widthPx, heightPx);
42
+
43
+ // Extract PDF text and identify pages that still need OCR
44
+ const pdf = await pdfToMarkdown(pdfBytes);
45
+ console.log(pdf.markdown, pdf.pagesNeedingOcr);
41
46
  ```
42
47
 
43
48
  ## Building
package/native/index.d.ts CHANGED
@@ -279,7 +279,7 @@ export declare function __ompInstallTokioRuntime(): void
279
279
  * `packages/natives/native/index.js` (which derives the name from
280
280
  * `package.json#version`).
281
281
  */
282
- export declare function __piNativesV17_3_2(): void
282
+ export declare function __piNativesV17_3_4(): void
283
283
 
284
284
  /**
285
285
  * Apply ast-grep rewrite rules to matching files; honors `dryRun` and returns
@@ -1578,6 +1578,32 @@ export interface PatchHunk {
1578
1578
  lines: Array<string>
1579
1579
  }
1580
1580
 
1581
+ /** Markdown and inspection metadata produced from a PDF document. */
1582
+ export interface PdfMarkdownResult {
1583
+ /** Extracted document content in Markdown format. */
1584
+ markdown: string
1585
+ /** Document title from PDF metadata, when present. */
1586
+ title?: string
1587
+ /** Total number of pages in the document. */
1588
+ pageCount: number
1589
+ /** One-indexed page numbers whose content requires OCR. */
1590
+ pagesNeedingOcr: Array<number>
1591
+ /** Whether the document contains text encoding problems. */
1592
+ hasEncodingIssues: boolean
1593
+ }
1594
+
1595
+ /**
1596
+ * Convert an in-memory PDF to Markdown and return its inspection metadata.
1597
+ *
1598
+ * Conversion copies the typed array before dispatch so JavaScript mutation
1599
+ * cannot race the native worker.
1600
+ *
1601
+ * # Errors
1602
+ * Returns an error prefixed with `PDF conversion failed:` when the PDF cannot
1603
+ * be parsed or converted.
1604
+ */
1605
+ export declare function pdfToMarkdown(input: Uint8Array): Promise<PdfMarkdownResult>
1606
+
1581
1607
  export interface PointerOptions {
1582
1608
  button?: string
1583
1609
  count?: number
package/native/index.js CHANGED
@@ -29,7 +29,7 @@ export const Shell = nativeBindings.Shell;
29
29
 
30
30
  // functions
31
31
  export const __ompInstallTokioRuntime = nativeBindings.__ompInstallTokioRuntime;
32
- export const __piNativesV17_3_2 = nativeBindings.__piNativesV17_3_2;
32
+ export const __piNativesV17_3_4 = nativeBindings.__piNativesV17_3_4;
33
33
  export const astEdit = nativeBindings.astEdit;
34
34
  export const astGrep = nativeBindings.astGrep;
35
35
  export const astMatch = nativeBindings.astMatch;
@@ -69,6 +69,7 @@ export const matchesLegacySequence = nativeBindings.matchesLegacySequence;
69
69
  export const mmrRerankIndices = nativeBindings.mmrRerankIndices;
70
70
  export const parseKey = nativeBindings.parseKey;
71
71
  export const parseKittySequence = nativeBindings.parseKittySequence;
72
+ export const pdfToMarkdown = nativeBindings.pdfToMarkdown;
72
73
  export const readImageFromClipboard = nativeBindings.readImageFromClipboard;
73
74
  export const renderSnapcompactPng = nativeBindings.renderSnapcompactPng;
74
75
  export const search = nativeBindings.search;
@@ -26,6 +26,7 @@ export interface DetectCompiledBinaryInput {
26
26
 
27
27
  export function detectCompiledBinary(input: DetectCompiledBinaryInput): boolean;
28
28
 
29
+
29
30
  export interface GetAddonFilenamesInput {
30
31
  tag: string;
31
32
  arch: string;
@@ -87,7 +87,6 @@ export function detectCompiledBinary({ embeddedAddon, env, importMetaUrl }) {
87
87
  }
88
88
  return false;
89
89
  }
90
-
91
90
  /**
92
91
  * @param {{ tag: string; arch: string; variant: "modern" | "baseline" | null | undefined }} input
93
92
  * @returns {string[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-natives",
3
- "version": "17.3.2",
4
- "description": "Native Rust bindings for audio, WebRTC, grep, clipboard, image processing, syntax highlighting, PTY, and shell operations via N-API",
3
+ "version": "17.3.4",
4
+ "description": "Native Rust bindings for PDF conversion, audio, WebRTC, grep, clipboard, image processing, syntax highlighting, PTY, and shell operations via N-API",
5
5
  "type": "module",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": "Can Boluk",
@@ -80,10 +80,10 @@
80
80
  }
81
81
  },
82
82
  "optionalDependencies": {
83
- "@oh-my-pi/pi-natives-linux-x64": "17.3.2",
84
- "@oh-my-pi/pi-natives-linux-arm64": "17.3.2",
85
- "@oh-my-pi/pi-natives-darwin-x64": "17.3.2",
86
- "@oh-my-pi/pi-natives-darwin-arm64": "17.3.2",
87
- "@oh-my-pi/pi-natives-win32-x64": "17.3.2"
83
+ "@oh-my-pi/pi-natives-linux-x64": "17.3.4",
84
+ "@oh-my-pi/pi-natives-linux-arm64": "17.3.4",
85
+ "@oh-my-pi/pi-natives-darwin-x64": "17.3.4",
86
+ "@oh-my-pi/pi-natives-darwin-arm64": "17.3.4",
87
+ "@oh-my-pi/pi-natives-win32-x64": "17.3.4"
88
88
  }
89
89
  }