@linxiraos/pi-natives 1.0.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/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @linxiraos/pi-natives
2
+
3
+ Native Rust functionality via N-API.
4
+
5
+ ## What's Inside
6
+
7
+ - **Grep**: Regex-based search powered by ripgrep's engine with native file walking and matching
8
+ - **Find**: Glob-based file/directory discovery with gitignore support (pure TypeScript via `globPaths`)
9
+ - **SIXEL**: Terminal image encoding for SIXEL-capable terminals (decode, resize, encode in one pass)
10
+ - **Audio**: Cross-platform low-latency microphone capture and gapless speaker playback
11
+ - **WebRTC**: Native Opus media, SDP offer/answer negotiation, and data-channel events for live sessions
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
+
14
+ General-purpose image processing (decode/resize/encode for files and buffers)
15
+ lives in [`Bun.Image`](https://bun.com/docs/runtime/image) on the JS side; this
16
+ crate only ships the SIXEL encoder because no built-in equivalent exists for
17
+ that terminal protocol.
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import { grep, find, encodeSixel } from "@linxiraos/pi-natives";
23
+
24
+ // Grep for a pattern
25
+ const results = await grep({
26
+ pattern: "TODO",
27
+ path: "/path/to/project",
28
+ glob: "*.ts",
29
+ context: 2,
30
+ });
31
+
32
+ // Find files
33
+ const files = await find({
34
+ pattern: "*.rs",
35
+ path: "/path/to/project",
36
+ fileType: "file",
37
+ });
38
+
39
+ // SIXEL encode for a terminal cell box (px)
40
+ const sequence = encodeSixel(pngBytes, widthPx, heightPx);
41
+ ```
42
+
43
+ ## Building
44
+
45
+ ```bash
46
+ # Build native addon from workspace root (requires Rust)
47
+ bun run build
48
+
49
+ # Type check
50
+ bun run check
51
+ ```
52
+
53
+ ## Architecture
54
+
55
+ `@linxiraos/pi-natives` publishes a small core package plus generated
56
+ platform-specific optional dependency packages:
57
+
58
+ ```
59
+ crates/pi-natives/ # Rust source (workspace member)
60
+ src/lib.rs # N-API exports
61
+ src/sixel.rs # SIXEL terminal-image encoding
62
+ Cargo.toml # Rust dependencies
63
+ native/ # Core loader files and local/CI native build outputs
64
+ index.js # Public native export surface
65
+ loader-state.js # Platform, ISA variant, and addon resolution
66
+ embedded-addon.js # Standalone binary embed stub/generated metadata
67
+ pi_natives.<platform>-<arch>-modern.node # x64 modern ISA (local/CI artifact)
68
+ pi_natives.<platform>-<arch>-baseline.node # x64 baseline ISA (local/CI artifact)
69
+ pi_natives.<platform>-<arch>.node # non-x64 build artifact
70
+ npm/<platform>-<arch>/ # Generated at publish time, not committed
71
+ package.json # @linxiraos/pi-natives-<platform>-<arch>
72
+ *.node # Only that platform's addon binary or x64 ISA variants
73
+ ```
74
+
75
+ The published core package contains only the JS loader, declarations, README,
76
+ and `package.json`. Release publishing generates one leaf package per supported
77
+ `os`/`cpu` pair and injects those leaves into the core manifest as pinned
78
+ `optionalDependencies`, so package managers install only the host platform's
79
+ native addon. x64 leaves include every built ISA variant, and the loader keeps
80
+ choosing between `baseline` and `modern` at runtime.
@@ -0,0 +1,9 @@
1
+ import type { ClipboardImage } from "./index.js";
2
+
3
+ export type { ClipboardImage } from "./index.js";
4
+
5
+ /** Copy text to the clipboard, loading the native addon on first use. */
6
+ export declare function copyToClipboard(text: string): void;
7
+
8
+ /** Read an image from the clipboard, loading the native addon on first use. */
9
+ export declare function readImageFromClipboard(): Promise<ClipboardImage | undefined | null>;
@@ -0,0 +1,11 @@
1
+ import { loadNative } from "./loader-state.js";
2
+
3
+ /** Copy text to the clipboard, loading the native addon on first use. */
4
+ export function copyToClipboard(text) {
5
+ return loadNative().copyToClipboard(text);
6
+ }
7
+
8
+ /** Read an image from the clipboard, loading the native addon on first use. */
9
+ export function readImageFromClipboard() {
10
+ return loadNative().readImageFromClipboard();
11
+ }
@@ -0,0 +1,4 @@
1
+ import type { DesktopSession, DesktopSessionOptions } from "./index.js";
2
+
3
+ /** Construct a desktop session, loading the native addon on first use. */
4
+ export declare function createDesktopSession(options: DesktopSessionOptions): DesktopSession;
@@ -0,0 +1,10 @@
1
+ import { loadNative } from "./loader-state.js";
2
+
3
+ /**
4
+ * Construct a desktop session without loading the native addon until the
5
+ * computer worker receives its initialization message.
6
+ */
7
+ export function createDesktopSession(options) {
8
+ const { DesktopSession } = loadNative();
9
+ return new DesktopSession(options);
10
+ }
@@ -0,0 +1,31 @@
1
+
2
+ // AUTOGENERATED FILE -- DO NOT EDIT DIRECTLY
3
+ // See scripts/embed-native.ts
4
+
5
+ /** @typedef {"modern" | "baseline" | "default"} EmbeddedAddonVariant */
6
+
7
+ /**
8
+ * @typedef {Object} EmbeddedAddonFile
9
+ * @property {EmbeddedAddonVariant} variant
10
+ * @property {string} filename
11
+ * @property {number} size
12
+ * @property {string=} filePath
13
+ */
14
+
15
+ /**
16
+ * @typedef {Object} EmbeddedAddonArchive
17
+ * @property {"tar.gz"} format
18
+ * @property {string} filename
19
+ * @property {string} filePath
20
+ */
21
+
22
+ /**
23
+ * @typedef {Object} EmbeddedAddon
24
+ * @property {string} platformTag
25
+ * @property {string} version
26
+ * @property {EmbeddedAddonFile[]} files
27
+ * @property {EmbeddedAddonArchive=} archive
28
+ */
29
+
30
+ /** @type {EmbeddedAddon|null} */
31
+ export const embeddedAddon = null;