@d0paminedriven/pdfdown 0.1.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/LICENSE +21 -0
- package/README.md +157 -0
- package/browser.js +1 -0
- package/index.d.ts +31 -0
- package/index.js +563 -0
- package/package.json +133 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 N-API for Rust
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# `@d0paminedriven/pdfdown`
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Rust-powered PDF extraction for Node.js via [napi-rs](https://napi.rs). Extracts per-page text, images (as PNG), and metadata from PDF buffers.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @d0paminedriven/pdfdown
|
|
11
|
+
# or
|
|
12
|
+
yarn add @d0paminedriven/pdfdown
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @d0paminedriven/pdfdown
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## API
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
export declare function extractTextPerPage(buffer: Buffer): Array<PageText>
|
|
21
|
+
export declare function extractImagesPerPage(buffer: Buffer): Array<PageImage>
|
|
22
|
+
export declare function pdfMetadata(buffer: Buffer): PdfMeta
|
|
23
|
+
|
|
24
|
+
export interface PageText {
|
|
25
|
+
page: number
|
|
26
|
+
text: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface PageImage {
|
|
30
|
+
page: number
|
|
31
|
+
imageIndex: number
|
|
32
|
+
width: number
|
|
33
|
+
height: number
|
|
34
|
+
data: Buffer // PNG-encoded bytes
|
|
35
|
+
colorSpace: string
|
|
36
|
+
bitsPerComponent: number
|
|
37
|
+
filter: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface PdfMeta {
|
|
41
|
+
pageCount: number
|
|
42
|
+
version: string
|
|
43
|
+
isLinearized: boolean
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
### Extract text per page
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { readFileSync } from "fs";
|
|
53
|
+
import { extractTextPerPage } from "@d0paminedriven/pdfdown";
|
|
54
|
+
|
|
55
|
+
const pdf = readFileSync("document.pdf");
|
|
56
|
+
const pages = extractTextPerPage(pdf);
|
|
57
|
+
|
|
58
|
+
for (const { page, text } of pages) {
|
|
59
|
+
console.log(`Page ${page}: ${text.slice(0, 100)}...`);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Extract images as PNG
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { readFileSync } from "fs";
|
|
67
|
+
import { extractImagesPerPage } from "@d0paminedriven/pdfdown";
|
|
68
|
+
|
|
69
|
+
const pdf = readFileSync("document.pdf");
|
|
70
|
+
const images = extractImagesPerPage(pdf);
|
|
71
|
+
|
|
72
|
+
for (const img of images) {
|
|
73
|
+
// Base64 data URL for embedding or API consumption
|
|
74
|
+
const dataUrl = `data:image/png;base64,${img.data.toString("base64")}`;
|
|
75
|
+
console.log(`Page ${img.page} image ${img.imageIndex}: ${img.width}x${img.height} ${img.colorSpace}`);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Get PDF metadata
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { readFileSync } from "fs";
|
|
83
|
+
import { pdfMetadata } from "@d0paminedriven/pdfdown";
|
|
84
|
+
|
|
85
|
+
const pdf = readFileSync("document.pdf");
|
|
86
|
+
const meta = pdfMetadata(pdf);
|
|
87
|
+
|
|
88
|
+
console.log(`v${meta.version}, ${meta.pageCount} pages, linearized: ${meta.isLinearized}`);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Combined: text + images + annotations for embeddings
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { readFileSync } from "fs";
|
|
95
|
+
import { extractTextPerPage, extractImagesPerPage } from "@d0paminedriven/pdfdown";
|
|
96
|
+
|
|
97
|
+
const pdf = readFileSync("document.pdf");
|
|
98
|
+
|
|
99
|
+
const text = extractTextPerPage(pdf);
|
|
100
|
+
const images = extractImagesPerPage(pdf);
|
|
101
|
+
|
|
102
|
+
// Group images by page
|
|
103
|
+
const imagesByPage = new Map<number, typeof images>();
|
|
104
|
+
for (const img of images) {
|
|
105
|
+
const arr = imagesByPage.get(img.page) ?? [];
|
|
106
|
+
arr.push(img);
|
|
107
|
+
imagesByPage.set(img.page, arr);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Build per-page payloads for multimodal embeddings
|
|
111
|
+
for (const { page, text: pageText } of text) {
|
|
112
|
+
const pageImages = imagesByPage.get(page) ?? [];
|
|
113
|
+
const payload = {
|
|
114
|
+
page,
|
|
115
|
+
text: pageText,
|
|
116
|
+
images: pageImages.map((img) => ({
|
|
117
|
+
dataUrl: `data:image/png;base64,${img.data.toString("base64")}`,
|
|
118
|
+
width: img.width,
|
|
119
|
+
height: img.height,
|
|
120
|
+
})),
|
|
121
|
+
};
|
|
122
|
+
// Send payload to Voyage AI, pgvector, etc.
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Supported formats
|
|
127
|
+
|
|
128
|
+
| Filter | Description | Handling |
|
|
129
|
+
|--------|-------------|----------|
|
|
130
|
+
| DCTDecode | JPEG-compressed images | Decoded and re-encoded as PNG |
|
|
131
|
+
| FlateDecode | Zlib-compressed raw pixels | Decompressed, reconstructed as PNG |
|
|
132
|
+
| None | Uncompressed raw pixels | Reconstructed as PNG |
|
|
133
|
+
|
|
134
|
+
| ColorSpace | Channels |
|
|
135
|
+
|------------|----------|
|
|
136
|
+
| DeviceRGB | 3 |
|
|
137
|
+
| DeviceGray | 1 |
|
|
138
|
+
| DeviceCMYK | 4 (converted to RGB) |
|
|
139
|
+
| ICCBased | Inferred from /N parameter |
|
|
140
|
+
|
|
141
|
+
8-bit and 16-bit BitsPerComponent are both supported (16-bit downscaled to 8-bit for PNG output).
|
|
142
|
+
|
|
143
|
+
## How it works
|
|
144
|
+
|
|
145
|
+
Built with [lopdf](https://github.com/J-F-Liu/lopdf) (pure Rust PDF parser) and [image](https://github.com/image-rs/image) (PNG/JPEG encoding). Compiled to a native Node.js addon via [napi-rs](https://napi.rs) with prebuilt binaries for:
|
|
146
|
+
|
|
147
|
+
- macOS (x64, ARM64)
|
|
148
|
+
- Windows (x64, ia32, ARM64)
|
|
149
|
+
- Linux glibc (x64, ARM64, ARMv7)
|
|
150
|
+
- Linux musl (x64, ARM64)
|
|
151
|
+
- FreeBSD (x64)
|
|
152
|
+
- Android (ARM64, ARMv7)
|
|
153
|
+
- WASI
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT
|
package/browser.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@d0paminedriven/pdfdown-wasm32-wasi'
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export declare function extractImagesPerPage(buffer: Buffer): Array<PageImage>
|
|
4
|
+
|
|
5
|
+
export declare function extractTextPerPage(buffer: Buffer): Array<PageText>
|
|
6
|
+
|
|
7
|
+
export interface PageImage {
|
|
8
|
+
page: number
|
|
9
|
+
imageIndex: number
|
|
10
|
+
width: number
|
|
11
|
+
height: number
|
|
12
|
+
data: Buffer
|
|
13
|
+
colorSpace: string
|
|
14
|
+
bitsPerComponent: number
|
|
15
|
+
filter: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface PageText {
|
|
19
|
+
page: number
|
|
20
|
+
text: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface PdfMeta {
|
|
24
|
+
pageCount: number
|
|
25
|
+
version: string
|
|
26
|
+
isLinearized: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare function pdfMetadata(buffer: Buffer): PdfMeta
|
|
30
|
+
|
|
31
|
+
export declare function plus100(input: number): number
|
package/index.js
ADDED
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
const { createRequire } = require('node:module')
|
|
7
|
+
require = createRequire(__filename)
|
|
8
|
+
|
|
9
|
+
const { readFileSync } = require('node:fs')
|
|
10
|
+
let nativeBinding = null
|
|
11
|
+
const loadErrors = []
|
|
12
|
+
|
|
13
|
+
const isMusl = () => {
|
|
14
|
+
let musl = false
|
|
15
|
+
if (process.platform === 'linux') {
|
|
16
|
+
musl = isMuslFromFilesystem()
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromReport()
|
|
19
|
+
}
|
|
20
|
+
if (musl === null) {
|
|
21
|
+
musl = isMuslFromChildProcess()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return musl
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
28
|
+
|
|
29
|
+
const isMuslFromFilesystem = () => {
|
|
30
|
+
try {
|
|
31
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
32
|
+
} catch {
|
|
33
|
+
return null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const isMuslFromReport = () => {
|
|
38
|
+
let report = null
|
|
39
|
+
if (typeof process.report?.getReport === 'function') {
|
|
40
|
+
process.report.excludeNetwork = true
|
|
41
|
+
report = process.report.getReport()
|
|
42
|
+
}
|
|
43
|
+
if (!report) {
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
50
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
51
|
+
return true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const isMuslFromChildProcess = () => {
|
|
58
|
+
try {
|
|
59
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
60
|
+
} catch (e) {
|
|
61
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function requireNative() {
|
|
67
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
68
|
+
try {
|
|
69
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
loadErrors.push(err)
|
|
72
|
+
}
|
|
73
|
+
} else if (process.platform === 'android') {
|
|
74
|
+
if (process.arch === 'arm64') {
|
|
75
|
+
try {
|
|
76
|
+
return require('./pdfdown.android-arm64.node')
|
|
77
|
+
} catch (e) {
|
|
78
|
+
loadErrors.push(e)
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const binding = require('@d0paminedriven/pdfdown-android-arm64')
|
|
82
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-android-arm64/package.json').version
|
|
83
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
84
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
85
|
+
}
|
|
86
|
+
return binding
|
|
87
|
+
} catch (e) {
|
|
88
|
+
loadErrors.push(e)
|
|
89
|
+
}
|
|
90
|
+
} else if (process.arch === 'arm') {
|
|
91
|
+
try {
|
|
92
|
+
return require('./pdfdown.android-arm-eabi.node')
|
|
93
|
+
} catch (e) {
|
|
94
|
+
loadErrors.push(e)
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const binding = require('@d0paminedriven/pdfdown-android-arm-eabi')
|
|
98
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-android-arm-eabi/package.json').version
|
|
99
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
100
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
101
|
+
}
|
|
102
|
+
return binding
|
|
103
|
+
} catch (e) {
|
|
104
|
+
loadErrors.push(e)
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
108
|
+
}
|
|
109
|
+
} else if (process.platform === 'win32') {
|
|
110
|
+
if (process.arch === 'x64') {
|
|
111
|
+
try {
|
|
112
|
+
return require('./pdfdown.win32-x64-msvc.node')
|
|
113
|
+
} catch (e) {
|
|
114
|
+
loadErrors.push(e)
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const binding = require('@d0paminedriven/pdfdown-win32-x64-msvc')
|
|
118
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-win32-x64-msvc/package.json').version
|
|
119
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
120
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
121
|
+
}
|
|
122
|
+
return binding
|
|
123
|
+
} catch (e) {
|
|
124
|
+
loadErrors.push(e)
|
|
125
|
+
}
|
|
126
|
+
} else if (process.arch === 'ia32') {
|
|
127
|
+
try {
|
|
128
|
+
return require('./pdfdown.win32-ia32-msvc.node')
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadErrors.push(e)
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const binding = require('@d0paminedriven/pdfdown-win32-ia32-msvc')
|
|
134
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-win32-ia32-msvc/package.json').version
|
|
135
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
136
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
137
|
+
}
|
|
138
|
+
return binding
|
|
139
|
+
} catch (e) {
|
|
140
|
+
loadErrors.push(e)
|
|
141
|
+
}
|
|
142
|
+
} else if (process.arch === 'arm64') {
|
|
143
|
+
try {
|
|
144
|
+
return require('./pdfdown.win32-arm64-msvc.node')
|
|
145
|
+
} catch (e) {
|
|
146
|
+
loadErrors.push(e)
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const binding = require('@d0paminedriven/pdfdown-win32-arm64-msvc')
|
|
150
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-win32-arm64-msvc/package.json').version
|
|
151
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
152
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
153
|
+
}
|
|
154
|
+
return binding
|
|
155
|
+
} catch (e) {
|
|
156
|
+
loadErrors.push(e)
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
160
|
+
}
|
|
161
|
+
} else if (process.platform === 'darwin') {
|
|
162
|
+
try {
|
|
163
|
+
return require('./pdfdown.darwin-universal.node')
|
|
164
|
+
} catch (e) {
|
|
165
|
+
loadErrors.push(e)
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const binding = require('@d0paminedriven/pdfdown-darwin-universal')
|
|
169
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-darwin-universal/package.json').version
|
|
170
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
171
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
|
+
}
|
|
173
|
+
return binding
|
|
174
|
+
} catch (e) {
|
|
175
|
+
loadErrors.push(e)
|
|
176
|
+
}
|
|
177
|
+
if (process.arch === 'x64') {
|
|
178
|
+
try {
|
|
179
|
+
return require('./pdfdown.darwin-x64.node')
|
|
180
|
+
} catch (e) {
|
|
181
|
+
loadErrors.push(e)
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const binding = require('@d0paminedriven/pdfdown-darwin-x64')
|
|
185
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-darwin-x64/package.json').version
|
|
186
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
187
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
188
|
+
}
|
|
189
|
+
return binding
|
|
190
|
+
} catch (e) {
|
|
191
|
+
loadErrors.push(e)
|
|
192
|
+
}
|
|
193
|
+
} else if (process.arch === 'arm64') {
|
|
194
|
+
try {
|
|
195
|
+
return require('./pdfdown.darwin-arm64.node')
|
|
196
|
+
} catch (e) {
|
|
197
|
+
loadErrors.push(e)
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const binding = require('@d0paminedriven/pdfdown-darwin-arm64')
|
|
201
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-darwin-arm64/package.json').version
|
|
202
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
203
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
204
|
+
}
|
|
205
|
+
return binding
|
|
206
|
+
} catch (e) {
|
|
207
|
+
loadErrors.push(e)
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
211
|
+
}
|
|
212
|
+
} else if (process.platform === 'freebsd') {
|
|
213
|
+
if (process.arch === 'x64') {
|
|
214
|
+
try {
|
|
215
|
+
return require('./pdfdown.freebsd-x64.node')
|
|
216
|
+
} catch (e) {
|
|
217
|
+
loadErrors.push(e)
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
const binding = require('@d0paminedriven/pdfdown-freebsd-x64')
|
|
221
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-freebsd-x64/package.json').version
|
|
222
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
223
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
224
|
+
}
|
|
225
|
+
return binding
|
|
226
|
+
} catch (e) {
|
|
227
|
+
loadErrors.push(e)
|
|
228
|
+
}
|
|
229
|
+
} else if (process.arch === 'arm64') {
|
|
230
|
+
try {
|
|
231
|
+
return require('./pdfdown.freebsd-arm64.node')
|
|
232
|
+
} catch (e) {
|
|
233
|
+
loadErrors.push(e)
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
const binding = require('@d0paminedriven/pdfdown-freebsd-arm64')
|
|
237
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-freebsd-arm64/package.json').version
|
|
238
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
239
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
240
|
+
}
|
|
241
|
+
return binding
|
|
242
|
+
} catch (e) {
|
|
243
|
+
loadErrors.push(e)
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
247
|
+
}
|
|
248
|
+
} else if (process.platform === 'linux') {
|
|
249
|
+
if (process.arch === 'x64') {
|
|
250
|
+
if (isMusl()) {
|
|
251
|
+
try {
|
|
252
|
+
return require('./pdfdown.linux-x64-musl.node')
|
|
253
|
+
} catch (e) {
|
|
254
|
+
loadErrors.push(e)
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
const binding = require('@d0paminedriven/pdfdown-linux-x64-musl')
|
|
258
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-x64-musl/package.json').version
|
|
259
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
260
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
261
|
+
}
|
|
262
|
+
return binding
|
|
263
|
+
} catch (e) {
|
|
264
|
+
loadErrors.push(e)
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
try {
|
|
268
|
+
return require('./pdfdown.linux-x64-gnu.node')
|
|
269
|
+
} catch (e) {
|
|
270
|
+
loadErrors.push(e)
|
|
271
|
+
}
|
|
272
|
+
try {
|
|
273
|
+
const binding = require('@d0paminedriven/pdfdown-linux-x64-gnu')
|
|
274
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-x64-gnu/package.json').version
|
|
275
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
276
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
277
|
+
}
|
|
278
|
+
return binding
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadErrors.push(e)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
} else if (process.arch === 'arm64') {
|
|
284
|
+
if (isMusl()) {
|
|
285
|
+
try {
|
|
286
|
+
return require('./pdfdown.linux-arm64-musl.node')
|
|
287
|
+
} catch (e) {
|
|
288
|
+
loadErrors.push(e)
|
|
289
|
+
}
|
|
290
|
+
try {
|
|
291
|
+
const binding = require('@d0paminedriven/pdfdown-linux-arm64-musl')
|
|
292
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-arm64-musl/package.json').version
|
|
293
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
294
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
295
|
+
}
|
|
296
|
+
return binding
|
|
297
|
+
} catch (e) {
|
|
298
|
+
loadErrors.push(e)
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
try {
|
|
302
|
+
return require('./pdfdown.linux-arm64-gnu.node')
|
|
303
|
+
} catch (e) {
|
|
304
|
+
loadErrors.push(e)
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
const binding = require('@d0paminedriven/pdfdown-linux-arm64-gnu')
|
|
308
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-arm64-gnu/package.json').version
|
|
309
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
310
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
311
|
+
}
|
|
312
|
+
return binding
|
|
313
|
+
} catch (e) {
|
|
314
|
+
loadErrors.push(e)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} else if (process.arch === 'arm') {
|
|
318
|
+
if (isMusl()) {
|
|
319
|
+
try {
|
|
320
|
+
return require('./pdfdown.linux-arm-musleabihf.node')
|
|
321
|
+
} catch (e) {
|
|
322
|
+
loadErrors.push(e)
|
|
323
|
+
}
|
|
324
|
+
try {
|
|
325
|
+
const binding = require('@d0paminedriven/pdfdown-linux-arm-musleabihf')
|
|
326
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-arm-musleabihf/package.json').version
|
|
327
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
328
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
329
|
+
}
|
|
330
|
+
return binding
|
|
331
|
+
} catch (e) {
|
|
332
|
+
loadErrors.push(e)
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
try {
|
|
336
|
+
return require('./pdfdown.linux-arm-gnueabihf.node')
|
|
337
|
+
} catch (e) {
|
|
338
|
+
loadErrors.push(e)
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
const binding = require('@d0paminedriven/pdfdown-linux-arm-gnueabihf')
|
|
342
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-arm-gnueabihf/package.json').version
|
|
343
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
344
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
345
|
+
}
|
|
346
|
+
return binding
|
|
347
|
+
} catch (e) {
|
|
348
|
+
loadErrors.push(e)
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
} else if (process.arch === 'loong64') {
|
|
352
|
+
if (isMusl()) {
|
|
353
|
+
try {
|
|
354
|
+
return require('./pdfdown.linux-loong64-musl.node')
|
|
355
|
+
} catch (e) {
|
|
356
|
+
loadErrors.push(e)
|
|
357
|
+
}
|
|
358
|
+
try {
|
|
359
|
+
const binding = require('@d0paminedriven/pdfdown-linux-loong64-musl')
|
|
360
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-loong64-musl/package.json').version
|
|
361
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
362
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
363
|
+
}
|
|
364
|
+
return binding
|
|
365
|
+
} catch (e) {
|
|
366
|
+
loadErrors.push(e)
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
try {
|
|
370
|
+
return require('./pdfdown.linux-loong64-gnu.node')
|
|
371
|
+
} catch (e) {
|
|
372
|
+
loadErrors.push(e)
|
|
373
|
+
}
|
|
374
|
+
try {
|
|
375
|
+
const binding = require('@d0paminedriven/pdfdown-linux-loong64-gnu')
|
|
376
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-loong64-gnu/package.json').version
|
|
377
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
378
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
379
|
+
}
|
|
380
|
+
return binding
|
|
381
|
+
} catch (e) {
|
|
382
|
+
loadErrors.push(e)
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
} else if (process.arch === 'riscv64') {
|
|
386
|
+
if (isMusl()) {
|
|
387
|
+
try {
|
|
388
|
+
return require('./pdfdown.linux-riscv64-musl.node')
|
|
389
|
+
} catch (e) {
|
|
390
|
+
loadErrors.push(e)
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
const binding = require('@d0paminedriven/pdfdown-linux-riscv64-musl')
|
|
394
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-riscv64-musl/package.json').version
|
|
395
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
396
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
397
|
+
}
|
|
398
|
+
return binding
|
|
399
|
+
} catch (e) {
|
|
400
|
+
loadErrors.push(e)
|
|
401
|
+
}
|
|
402
|
+
} else {
|
|
403
|
+
try {
|
|
404
|
+
return require('./pdfdown.linux-riscv64-gnu.node')
|
|
405
|
+
} catch (e) {
|
|
406
|
+
loadErrors.push(e)
|
|
407
|
+
}
|
|
408
|
+
try {
|
|
409
|
+
const binding = require('@d0paminedriven/pdfdown-linux-riscv64-gnu')
|
|
410
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-riscv64-gnu/package.json').version
|
|
411
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
412
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
413
|
+
}
|
|
414
|
+
return binding
|
|
415
|
+
} catch (e) {
|
|
416
|
+
loadErrors.push(e)
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
} else if (process.arch === 'ppc64') {
|
|
420
|
+
try {
|
|
421
|
+
return require('./pdfdown.linux-ppc64-gnu.node')
|
|
422
|
+
} catch (e) {
|
|
423
|
+
loadErrors.push(e)
|
|
424
|
+
}
|
|
425
|
+
try {
|
|
426
|
+
const binding = require('@d0paminedriven/pdfdown-linux-ppc64-gnu')
|
|
427
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-ppc64-gnu/package.json').version
|
|
428
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
429
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
430
|
+
}
|
|
431
|
+
return binding
|
|
432
|
+
} catch (e) {
|
|
433
|
+
loadErrors.push(e)
|
|
434
|
+
}
|
|
435
|
+
} else if (process.arch === 's390x') {
|
|
436
|
+
try {
|
|
437
|
+
return require('./pdfdown.linux-s390x-gnu.node')
|
|
438
|
+
} catch (e) {
|
|
439
|
+
loadErrors.push(e)
|
|
440
|
+
}
|
|
441
|
+
try {
|
|
442
|
+
const binding = require('@d0paminedriven/pdfdown-linux-s390x-gnu')
|
|
443
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-linux-s390x-gnu/package.json').version
|
|
444
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
445
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
446
|
+
}
|
|
447
|
+
return binding
|
|
448
|
+
} catch (e) {
|
|
449
|
+
loadErrors.push(e)
|
|
450
|
+
}
|
|
451
|
+
} else {
|
|
452
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
453
|
+
}
|
|
454
|
+
} else if (process.platform === 'openharmony') {
|
|
455
|
+
if (process.arch === 'arm64') {
|
|
456
|
+
try {
|
|
457
|
+
return require('./pdfdown.openharmony-arm64.node')
|
|
458
|
+
} catch (e) {
|
|
459
|
+
loadErrors.push(e)
|
|
460
|
+
}
|
|
461
|
+
try {
|
|
462
|
+
const binding = require('@d0paminedriven/pdfdown-openharmony-arm64')
|
|
463
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-openharmony-arm64/package.json').version
|
|
464
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
465
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
466
|
+
}
|
|
467
|
+
return binding
|
|
468
|
+
} catch (e) {
|
|
469
|
+
loadErrors.push(e)
|
|
470
|
+
}
|
|
471
|
+
} else if (process.arch === 'x64') {
|
|
472
|
+
try {
|
|
473
|
+
return require('./pdfdown.openharmony-x64.node')
|
|
474
|
+
} catch (e) {
|
|
475
|
+
loadErrors.push(e)
|
|
476
|
+
}
|
|
477
|
+
try {
|
|
478
|
+
const binding = require('@d0paminedriven/pdfdown-openharmony-x64')
|
|
479
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-openharmony-x64/package.json').version
|
|
480
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
481
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
482
|
+
}
|
|
483
|
+
return binding
|
|
484
|
+
} catch (e) {
|
|
485
|
+
loadErrors.push(e)
|
|
486
|
+
}
|
|
487
|
+
} else if (process.arch === 'arm') {
|
|
488
|
+
try {
|
|
489
|
+
return require('./pdfdown.openharmony-arm.node')
|
|
490
|
+
} catch (e) {
|
|
491
|
+
loadErrors.push(e)
|
|
492
|
+
}
|
|
493
|
+
try {
|
|
494
|
+
const binding = require('@d0paminedriven/pdfdown-openharmony-arm')
|
|
495
|
+
const bindingPackageVersion = require('@d0paminedriven/pdfdown-openharmony-arm/package.json').version
|
|
496
|
+
if (bindingPackageVersion !== '1.0.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
497
|
+
throw new Error(`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
498
|
+
}
|
|
499
|
+
return binding
|
|
500
|
+
} catch (e) {
|
|
501
|
+
loadErrors.push(e)
|
|
502
|
+
}
|
|
503
|
+
} else {
|
|
504
|
+
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
505
|
+
}
|
|
506
|
+
} else {
|
|
507
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
nativeBinding = requireNative()
|
|
512
|
+
|
|
513
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
514
|
+
let wasiBinding = null
|
|
515
|
+
let wasiBindingError = null
|
|
516
|
+
try {
|
|
517
|
+
wasiBinding = require('./pdfdown.wasi.cjs')
|
|
518
|
+
nativeBinding = wasiBinding
|
|
519
|
+
} catch (err) {
|
|
520
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
521
|
+
wasiBindingError = err
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (!nativeBinding) {
|
|
525
|
+
try {
|
|
526
|
+
wasiBinding = require('@d0paminedriven/pdfdown-wasm32-wasi')
|
|
527
|
+
nativeBinding = wasiBinding
|
|
528
|
+
} catch (err) {
|
|
529
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
530
|
+
wasiBindingError.cause = err
|
|
531
|
+
loadErrors.push(err)
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
536
|
+
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
537
|
+
error.cause = wasiBindingError
|
|
538
|
+
throw error
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (!nativeBinding) {
|
|
543
|
+
if (loadErrors.length > 0) {
|
|
544
|
+
throw new Error(
|
|
545
|
+
`Cannot find native binding. ` +
|
|
546
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
547
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
548
|
+
{
|
|
549
|
+
cause: loadErrors.reduce((err, cur) => {
|
|
550
|
+
cur.cause = err
|
|
551
|
+
return cur
|
|
552
|
+
}),
|
|
553
|
+
},
|
|
554
|
+
)
|
|
555
|
+
}
|
|
556
|
+
throw new Error(`Failed to load native binding`)
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
module.exports = nativeBinding
|
|
560
|
+
module.exports.extractImagesPerPage = nativeBinding.extractImagesPerPage
|
|
561
|
+
module.exports.extractTextPerPage = nativeBinding.extractTextPerPage
|
|
562
|
+
module.exports.pdfMetadata = nativeBinding.pdfMetadata
|
|
563
|
+
module.exports.plus100 = nativeBinding.plus100
|
package/package.json
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@d0paminedriven/pdfdown",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Template project for writing node package with napi-rs",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/DopamineDriven/pdfdown"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"browser": "browser.js",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"napi-rs",
|
|
14
|
+
"NAPI",
|
|
15
|
+
"N-API",
|
|
16
|
+
"Rust",
|
|
17
|
+
"node-addon",
|
|
18
|
+
"node-addon-api"
|
|
19
|
+
],
|
|
20
|
+
"files": [
|
|
21
|
+
"index.d.ts",
|
|
22
|
+
"index.js",
|
|
23
|
+
"browser.js"
|
|
24
|
+
],
|
|
25
|
+
"napi": {
|
|
26
|
+
"binaryName": "pdfdown",
|
|
27
|
+
"targets": [
|
|
28
|
+
"x86_64-pc-windows-msvc",
|
|
29
|
+
"x86_64-apple-darwin",
|
|
30
|
+
"x86_64-unknown-linux-gnu",
|
|
31
|
+
"x86_64-unknown-linux-musl",
|
|
32
|
+
"aarch64-unknown-linux-gnu",
|
|
33
|
+
"i686-pc-windows-msvc",
|
|
34
|
+
"armv7-unknown-linux-gnueabihf",
|
|
35
|
+
"aarch64-apple-darwin",
|
|
36
|
+
"aarch64-linux-android",
|
|
37
|
+
"x86_64-unknown-freebsd",
|
|
38
|
+
"aarch64-unknown-linux-musl",
|
|
39
|
+
"aarch64-pc-windows-msvc",
|
|
40
|
+
"armv7-linux-androideabi",
|
|
41
|
+
"wasm32-wasip1-threads"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org/",
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"artifacts": "napi artifacts",
|
|
53
|
+
"bench": "node --import @oxc-node/core/register benchmark/bench.ts",
|
|
54
|
+
"build": "napi build --platform --release",
|
|
55
|
+
"build:debug": "napi build --platform",
|
|
56
|
+
"format": "run-p format:prettier format:rs format:toml",
|
|
57
|
+
"format:prettier": "prettier . -w",
|
|
58
|
+
"format:toml": "taplo format",
|
|
59
|
+
"format:rs": "cargo fmt",
|
|
60
|
+
"lint": "oxlint .",
|
|
61
|
+
"prepublishOnly": "napi prepublish -t npm",
|
|
62
|
+
"test": "ava",
|
|
63
|
+
"preversion": "napi build --platform && git add .",
|
|
64
|
+
"version": "napi version",
|
|
65
|
+
"prepare": "husky"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@emnapi/core": "^1.5.0",
|
|
69
|
+
"@emnapi/runtime": "^1.5.0",
|
|
70
|
+
"@napi-rs/cli": "^3.2.0",
|
|
71
|
+
"@oxc-node/core": "^0.0.35",
|
|
72
|
+
"@taplo/cli": "^0.7.0",
|
|
73
|
+
"@tybys/wasm-util": "^0.10.0",
|
|
74
|
+
"ava": "^6.4.1",
|
|
75
|
+
"chalk": "^5.6.2",
|
|
76
|
+
"husky": "^9.1.7",
|
|
77
|
+
"lint-staged": "^16.1.6",
|
|
78
|
+
"npm-run-all2": "^8.0.4",
|
|
79
|
+
"oxlint": "^1.14.0",
|
|
80
|
+
"prettier": "^3.6.2",
|
|
81
|
+
"tinybench": "^6.0.0",
|
|
82
|
+
"typescript": "^5.9.2"
|
|
83
|
+
},
|
|
84
|
+
"lint-staged": {
|
|
85
|
+
"*.@(js|ts|tsx)": [
|
|
86
|
+
"oxlint --fix"
|
|
87
|
+
],
|
|
88
|
+
"*.@(js|ts|tsx|yml|yaml|md|json)": [
|
|
89
|
+
"prettier --write"
|
|
90
|
+
],
|
|
91
|
+
"*.toml": [
|
|
92
|
+
"taplo format"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"ava": {
|
|
96
|
+
"extensions": {
|
|
97
|
+
"ts": "module"
|
|
98
|
+
},
|
|
99
|
+
"timeout": "2m",
|
|
100
|
+
"workerThreads": false,
|
|
101
|
+
"environmentVariables": {
|
|
102
|
+
"OXC_TSCONFIG_PATH": "./__test__/tsconfig.json"
|
|
103
|
+
},
|
|
104
|
+
"nodeArguments": [
|
|
105
|
+
"--import",
|
|
106
|
+
"@oxc-node/core/register"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"prettier": {
|
|
110
|
+
"printWidth": 120,
|
|
111
|
+
"semi": false,
|
|
112
|
+
"trailingComma": "all",
|
|
113
|
+
"singleQuote": true,
|
|
114
|
+
"arrowParens": "always"
|
|
115
|
+
},
|
|
116
|
+
"packageManager": "yarn@4.12.0",
|
|
117
|
+
"optionalDependencies": {
|
|
118
|
+
"@d0paminedriven/pdfdown-win32-x64-msvc": "0.1.0",
|
|
119
|
+
"@d0paminedriven/pdfdown-darwin-x64": "0.1.0",
|
|
120
|
+
"@d0paminedriven/pdfdown-linux-x64-gnu": "0.1.0",
|
|
121
|
+
"@d0paminedriven/pdfdown-linux-x64-musl": "0.1.0",
|
|
122
|
+
"@d0paminedriven/pdfdown-linux-arm64-gnu": "0.1.0",
|
|
123
|
+
"@d0paminedriven/pdfdown-win32-ia32-msvc": "0.1.0",
|
|
124
|
+
"@d0paminedriven/pdfdown-linux-arm-gnueabihf": "0.1.0",
|
|
125
|
+
"@d0paminedriven/pdfdown-darwin-arm64": "0.1.0",
|
|
126
|
+
"@d0paminedriven/pdfdown-android-arm64": "0.1.0",
|
|
127
|
+
"@d0paminedriven/pdfdown-freebsd-x64": "0.1.0",
|
|
128
|
+
"@d0paminedriven/pdfdown-linux-arm64-musl": "0.1.0",
|
|
129
|
+
"@d0paminedriven/pdfdown-win32-arm64-msvc": "0.1.0",
|
|
130
|
+
"@d0paminedriven/pdfdown-android-arm-eabi": "0.1.0",
|
|
131
|
+
"@d0paminedriven/pdfdown-wasm32-wasi": "0.1.0"
|
|
132
|
+
}
|
|
133
|
+
}
|