@notedge/panduck 0.0.1 → 0.0.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/package.json +8 -7
- package/readme.md +86 -2
- package/src/index.ts +1 -1
- package/src/wasm/index.ts +12 -0
- package/src/wasm/load.ts +10 -8
- package/src/wasm/panduck_wasm.d.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notedge/panduck",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Panduck document conversion bindings (Node-API + TypeScript)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"bin",
|
|
21
21
|
"locales",
|
|
22
|
+
"readme.md",
|
|
22
23
|
"src"
|
|
23
24
|
],
|
|
24
25
|
"engines": {
|
|
@@ -29,16 +30,16 @@
|
|
|
29
30
|
"test:e2e": "tsx --test tests/**/*.test.ts"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
33
|
+
"@notedge/panduck-unknown-wasm32": "0.0.2",
|
|
32
34
|
"@vmz/commander": "^0.2.0",
|
|
33
35
|
"jiti": "^2.4.2"
|
|
34
36
|
},
|
|
35
37
|
"optionalDependencies": {
|
|
36
|
-
"@notedge/panduck-darwin-arm64": "0.0.
|
|
37
|
-
"@notedge/panduck-darwin-x64": "0.0.
|
|
38
|
-
"@notedge/panduck-linux-arm64": "0.0.
|
|
39
|
-
"@notedge/panduck-linux-x64": "0.0.
|
|
40
|
-
"@notedge/panduck-win32-x64": "0.0.
|
|
41
|
-
"@notedge/panduck-unknown-wasm32": "0.0.1"
|
|
38
|
+
"@notedge/panduck-darwin-arm64": "0.0.2",
|
|
39
|
+
"@notedge/panduck-darwin-x64": "0.0.2",
|
|
40
|
+
"@notedge/panduck-linux-arm64": "0.0.2",
|
|
41
|
+
"@notedge/panduck-linux-x64": "0.0.2",
|
|
42
|
+
"@notedge/panduck-win32-x64": "0.0.2"
|
|
42
43
|
},
|
|
43
44
|
"repository": {
|
|
44
45
|
"type": "git",
|
package/readme.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# @notedge/panduck
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Node 20+ package for Panduck: CLI commands, `loadPanduckNode()`, and WASM format discovery. Use it when you need to convert a local file between supported formats and read a `panduck.report/v1` JSON result.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
File conversion runs through the native binding on Node. The WASM export lists formats and version metadata only—do not expect `convertDocument` in the browser build for this release.
|
|
6
|
+
|
|
7
|
+
## 🤖 Agent instructions
|
|
8
|
+
|
|
9
|
+
`@notedge/panduck-skills` teaches coding agents to check routes before converting. It installs instructions, not this runtime.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx @notedge/panduck-skills
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 📦 Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @notedge/panduck
|
|
19
|
+
npx panduck doctor
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Platform `.node` binaries install through optional dependencies (`@notedge/panduck-win32-x64`, `@notedge/panduck-linux-x64`, `@notedge/panduck-darwin-arm64`, and siblings).
|
|
23
|
+
|
|
24
|
+
## 🔄 Convert one file
|
|
25
|
+
|
|
26
|
+
Always write to a **new** path and keep the source unchanged:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx panduck plan ./draft.docx --to markdown
|
|
30
|
+
npx panduck convert ./draft.docx --to markdown -o ./draft.md --report ./draft.report.json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Check what the binding actually supports:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx panduck formats --json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 🔌 Node API
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { loadPanduckNode } from "@notedge/panduck/node";
|
|
43
|
+
|
|
44
|
+
const panduck = loadPanduckNode();
|
|
45
|
+
if (!panduck.supportsConversion?.("docx", "markdown")) {
|
|
46
|
+
throw new Error("route not available on this build");
|
|
47
|
+
}
|
|
48
|
+
const result = panduck.convertDocument!("docx", "markdown", "./draft.docx");
|
|
49
|
+
console.log(result.reportJson);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Exports:
|
|
53
|
+
|
|
54
|
+
- `@notedge/panduck` — package metadata
|
|
55
|
+
- `@notedge/panduck/node` — `loadPanduckNode()`
|
|
56
|
+
- `@notedge/panduck/wasm` — format discovery (no file conversion here)
|
|
57
|
+
- `@notedge/panduck/cli` — programmatic CLI builder
|
|
58
|
+
|
|
59
|
+
## 📊 Read the report
|
|
60
|
+
|
|
61
|
+
Open `panduck.report/v1` JSON for `status`, `coverage`, `losses`, `diagnostics`, and `outputs`. A successful exit can still be `success_with_loss`—read losses before publishing converted content.
|
|
62
|
+
|
|
63
|
+
`panduck inspect` helps audit container structure (for example DOCX package index) without promising a full semantic read.
|
|
64
|
+
|
|
65
|
+
## ✅ Verified routes (native)
|
|
66
|
+
|
|
67
|
+
When `supportsConversion(from, to)` is true:
|
|
68
|
+
|
|
69
|
+
| From | To |
|
|
70
|
+
|------|-----|
|
|
71
|
+
| `docx` | `markdown`, `docx` |
|
|
72
|
+
| `markdown` | `markdown`, `docx` |
|
|
73
|
+
| `notedown` | `markdown` |
|
|
74
|
+
| `epub` | `markdown` |
|
|
75
|
+
|
|
76
|
+
Registered format names beyond these pairs may read or list without a working writer. Plan before batch jobs.
|
|
77
|
+
|
|
78
|
+
## 🔧 Troubleshooting
|
|
79
|
+
|
|
80
|
+
| Symptom | Check |
|
|
81
|
+
|---------|-------|
|
|
82
|
+
| `Unsupported platform for Panduck native bindings` | OS/CPU mismatch or missing optional platform package |
|
|
83
|
+
| `conversion pipeline is not wired yet` | Route not implemented—use `plan` / `supportsConversion` |
|
|
84
|
+
| Output exists but quality is wrong | Report `losses` for tables, footnotes, images |
|
|
85
|
+
| Browser bundle cannot convert | Use Node native path for file conversion |
|
|
86
|
+
|
|
87
|
+
Repository: https://github.com/notedge/panduck
|
|
88
|
+
|
|
89
|
+
License: MPL-2.0
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { PanduckBindings, PanduckWasmOptions } from "./types.js";
|
|
2
2
|
export { loadPanduckNative, loadPanduckNode } from "./node/index.js";
|
|
3
|
-
export { loadPanduckWasm } from "./wasm/index.js";
|
|
3
|
+
export { loadPanduckWeb, loadPanduckWasm } from "./wasm/index.js";
|
|
4
4
|
export { buildPanduckCli, runCli, getFormatRegistry, ExitCode, REPORT_SCHEMA_VERSION } from "./cli/index.js";
|
|
5
5
|
export type { FormatRecord, PanduckReport, CapabilityState } from "./cli/index.js";
|
|
6
6
|
|
package/src/wasm/index.ts
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
import { loadPanduckWasm } from "./load.js";
|
|
2
|
+
|
|
1
3
|
export type { PanduckBindings, PanduckWasmOptions } from "../types.js";
|
|
2
4
|
export { loadPanduckWasm } from "./load.js";
|
|
5
|
+
|
|
6
|
+
let cached: Promise<import("../types.js").PanduckBindings> | undefined;
|
|
7
|
+
|
|
8
|
+
/** Cached WASM binding loader. */
|
|
9
|
+
export function loadPanduckWeb(): Promise<import("../types.js").PanduckBindings> {
|
|
10
|
+
if (!cached) {
|
|
11
|
+
cached = loadPanduckWasm();
|
|
12
|
+
}
|
|
13
|
+
return cached;
|
|
14
|
+
}
|
package/src/wasm/load.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import type { PanduckBindings, PanduckWasmOptions } from "../types.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const ARTIFACT_PACKAGE = "@notedge/panduck-unknown-wasm32";
|
|
4
|
+
|
|
5
|
+
type WasmBinding = {
|
|
4
6
|
default: (input?: { module_or_path?: string | URL }) => Promise<unknown>;
|
|
5
7
|
panduckVersion: () => string;
|
|
6
8
|
supportedFormats: () => string[];
|
|
7
9
|
isSupportedFormat: (name: string) => boolean;
|
|
8
10
|
};
|
|
9
11
|
|
|
10
|
-
/** Load `@notedge/panduck-unknown-wasm32
|
|
12
|
+
/** Load the WASM artifact from `@notedge/panduck-unknown-wasm32`. */
|
|
11
13
|
export async function loadPanduckWasm(options: PanduckWasmOptions = {}): Promise<PanduckBindings> {
|
|
12
|
-
const
|
|
14
|
+
const binding = (await import(ARTIFACT_PACKAGE)) as WasmBinding;
|
|
13
15
|
if (options.url) {
|
|
14
|
-
await
|
|
16
|
+
await binding.default({ module_or_path: options.url });
|
|
15
17
|
} else {
|
|
16
|
-
await
|
|
18
|
+
await binding.default();
|
|
17
19
|
}
|
|
18
20
|
return {
|
|
19
|
-
panduckVersion: () =>
|
|
20
|
-
supportedFormats: () =>
|
|
21
|
-
isSupportedFormat: (name) =>
|
|
21
|
+
panduckVersion: () => binding.panduckVersion(),
|
|
22
|
+
supportedFormats: () => binding.supportedFormats(),
|
|
23
|
+
isSupportedFormat: (name) => binding.isSupportedFormat(name),
|
|
22
24
|
};
|
|
23
25
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
declare module '@notedge/panduck-unknown-wasm32' {
|
|
2
|
-
export default function init(input?: { module_or_path?: string | URL }): Promise<unknown>;
|
|
3
|
-
export function panduckVersion(): string;
|
|
4
|
-
export function supportedFormats(): string[];
|
|
5
|
-
export function isSupportedFormat(name: string): boolean;
|
|
6
|
-
}
|