@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.
@@ -0,0 +1,142 @@
1
+ import { loadNative } from "./loader-state.js";
2
+
3
+ /**
4
+ * Native addon entrypoint.
5
+ *
6
+ * Hand-written surface area: one `loadNative()` call. Everything else in
7
+ * this file (the surface-area `export const` block between MARKER_START
8
+ * and MARKER_END) is rewritten by `packages/natives/scripts/gen-enums.ts`
9
+ * after `napi build` regenerates `index.d.ts`.
10
+ *
11
+ * Loader logic lives in `./loader-state.js` so the pure helpers stay
12
+ * unit-testable without triggering AVX2 detection or filesystem probes on
13
+ * import. Types are auto-generated by napi-rs in `./index.d.ts`.
14
+ */
15
+
16
+ const nativeBindings = loadNative();
17
+ // --- generated native exports (do not edit) ---
18
+ // classes
19
+ export const AudioCapture = nativeBindings.AudioCapture;
20
+ export const AudioPlayback = nativeBindings.AudioPlayback;
21
+ export const DesktopSession = nativeBindings.DesktopSession;
22
+ export const FileLock = nativeBindings.FileLock;
23
+ export const LiveWebRtcPeer = nativeBindings.LiveWebRtcPeer;
24
+ export const MacAppearanceObserver = nativeBindings.MacAppearanceObserver;
25
+ export const MacOSPowerAssertion = nativeBindings.MacOSPowerAssertion;
26
+ export const Process = nativeBindings.Process;
27
+ export const PtySession = nativeBindings.PtySession;
28
+ export const Shell = nativeBindings.Shell;
29
+
30
+ // functions
31
+ export const __ompInstallTokioRuntime = nativeBindings.__ompInstallTokioRuntime;
32
+ export const __piNativesV1_0_0 = nativeBindings.__piNativesV1_0_0;
33
+ export const astEdit = nativeBindings.astEdit;
34
+ export const astGrep = nativeBindings.astGrep;
35
+ export const astMatch = nativeBindings.astMatch;
36
+ export const blockRangeAt = nativeBindings.blockRangeAt;
37
+ export const copyToClipboard = nativeBindings.copyToClipboard;
38
+ export const cosineSimilarityPairs = nativeBindings.cosineSimilarityPairs;
39
+ export const countTokens = nativeBindings.countTokens;
40
+ export const detectMacOSAppearance = nativeBindings.detectMacOSAppearance;
41
+ export const deviceCheckGenerateToken = nativeBindings.deviceCheckGenerateToken;
42
+ export const diffLineRuns = nativeBindings.diffLineRuns;
43
+ export const diffLines = nativeBindings.diffLines;
44
+ export const diffWords = nativeBindings.diffWords;
45
+ export const enclosingBlockBoundaries = nativeBindings.enclosingBlockBoundaries;
46
+ export const encodeSixel = nativeBindings.encodeSixel;
47
+ export const executeShell = nativeBindings.executeShell;
48
+ export const extractSegments = nativeBindings.extractSegments;
49
+ export const fuzzyFind = nativeBindings.fuzzyFind;
50
+ export const getSupportedLanguages = nativeBindings.getSupportedLanguages;
51
+ export const getWorkProfile = nativeBindings.getWorkProfile;
52
+ export const glob = nativeBindings.glob;
53
+ export const grep = nativeBindings.grep;
54
+ export const hasMatch = nativeBindings.hasMatch;
55
+ export const highlightCode = nativeBindings.highlightCode;
56
+ export const htmlToMarkdown = nativeBindings.htmlToMarkdown;
57
+ export const invalidateFsScanCache = nativeBindings.invalidateFsScanCache;
58
+ export const isoBackend = nativeBindings.isoBackend;
59
+ export const isoDiff = nativeBindings.isoDiff;
60
+ export const isoIsUnavailableError = nativeBindings.isoIsUnavailableError;
61
+ export const isoProbe = nativeBindings.isoProbe;
62
+ export const isoResolve = nativeBindings.isoResolve;
63
+ export const isoStart = nativeBindings.isoStart;
64
+ export const isoStop = nativeBindings.isoStop;
65
+ export const listWorkspace = nativeBindings.listWorkspace;
66
+ export const matchesKey = nativeBindings.matchesKey;
67
+ export const matchesKittySequence = nativeBindings.matchesKittySequence;
68
+ export const matchesLegacySequence = nativeBindings.matchesLegacySequence;
69
+ export const mmrRerankIndices = nativeBindings.mmrRerankIndices;
70
+ export const parseKey = nativeBindings.parseKey;
71
+ export const parseKittySequence = nativeBindings.parseKittySequence;
72
+ export const readImageFromClipboard = nativeBindings.readImageFromClipboard;
73
+ export const renderSnapcompactPng = nativeBindings.renderSnapcompactPng;
74
+ export const search = nativeBindings.search;
75
+ export const setHangulCompatJamoWidthOverride = nativeBindings.setHangulCompatJamoWidthOverride;
76
+ export const sliceWithWidth = nativeBindings.sliceWithWidth;
77
+ export const snapcompactSupportedChars = nativeBindings.snapcompactSupportedChars;
78
+ export const structuredPatchHunks = nativeBindings.structuredPatchHunks;
79
+ export const summarizeCode = nativeBindings.summarizeCode;
80
+ export const supportsLanguage = nativeBindings.supportsLanguage;
81
+ export const truncateToWidth = nativeBindings.truncateToWidth;
82
+ export const vectorIndexTopK = nativeBindings.vectorIndexTopK;
83
+ export const visibleWidth = nativeBindings.visibleWidth;
84
+ export const wrapTextWithAnsi = nativeBindings.wrapTextWithAnsi;
85
+
86
+ // string/numeric enums (napi-rs string_enum produces TS-only const enum)
87
+ export const AstMatchStrictness = {
88
+ Cst: "cst",
89
+ Smart: "smart",
90
+ Ast: "ast",
91
+ Relaxed: "relaxed",
92
+ Signature: "signature",
93
+ Template: "template",
94
+ };
95
+ export const Ellipsis = {
96
+ Unicode: 0,
97
+ Ascii: 1,
98
+ Omit: 2,
99
+ };
100
+ export const Encoding = {
101
+ O200kBase: "O200kBase",
102
+ Cl100kBase: "Cl100kBase",
103
+ };
104
+ export const FileType = {
105
+ File: 1,
106
+ Dir: 2,
107
+ Symlink: 3,
108
+ };
109
+ export const GrepOutputMode = {
110
+ Content: "content",
111
+ Count: "count",
112
+ FilesWithMatches: "filesWithMatches",
113
+ };
114
+ export const IsoBackendKind = {
115
+ Apfs: 0,
116
+ Btrfs: 1,
117
+ Zfs: 2,
118
+ LinuxReflink: 3,
119
+ Overlayfs: 4,
120
+ WindowsBlockClone: 5,
121
+ Projfs: 6,
122
+ Rcopy: 7,
123
+ };
124
+ export const IsoChangeKind = {
125
+ Added: 0,
126
+ Modified: 1,
127
+ Removed: 2,
128
+ };
129
+ export const KeyEventType = {
130
+ Press: 1,
131
+ Repeat: 2,
132
+ Release: 3,
133
+ };
134
+ export const MacOSAppearance = {
135
+ Dark: "dark",
136
+ Light: "light",
137
+ };
138
+ export const ProcessStatus = {
139
+ Running: "running",
140
+ Exited: "exited",
141
+ };
142
+ // --- end generated native exports ---
@@ -0,0 +1,129 @@
1
+ export interface EmbeddedAddonFile {
2
+ variant: "modern" | "baseline" | "default";
3
+ filename: string;
4
+ size?: number;
5
+ filePath?: string;
6
+ }
7
+
8
+ export interface EmbeddedAddonArchive {
9
+ format: "tar.gz";
10
+ filename: string;
11
+ filePath: string;
12
+ }
13
+
14
+ export interface EmbeddedAddon {
15
+ platformTag: string;
16
+ version: string;
17
+ files: EmbeddedAddonFile[];
18
+ archive?: EmbeddedAddonArchive;
19
+ }
20
+
21
+ export interface DetectCompiledBinaryInput {
22
+ embeddedAddon: EmbeddedAddon | null | undefined;
23
+ env: Record<string, string | undefined>;
24
+ importMetaUrl: string | null | undefined;
25
+ }
26
+
27
+ export function detectCompiledBinary(input: DetectCompiledBinaryInput): boolean;
28
+
29
+ export interface GetAddonFilenamesInput {
30
+ tag: string;
31
+ arch: string;
32
+ variant: "modern" | "baseline" | null | undefined;
33
+ }
34
+
35
+ export function getAddonFilenames(input: GetAddonFilenamesInput): string[];
36
+
37
+ export interface ShouldStageNodeModulesAddonInput {
38
+ platform: NodeJS.Platform | string;
39
+ isCompiledBinary: boolean;
40
+ nativeDir: string;
41
+ }
42
+
43
+ export function shouldStageNodeModulesAddon(input: ShouldStageNodeModulesAddonInput): boolean;
44
+
45
+ export interface ResolveLoaderCandidatesInput {
46
+ addonFilenames: string[];
47
+ isCompiledBinary: boolean;
48
+ stageFromNodeModules?: boolean;
49
+ nativeDir: string;
50
+ leafPackageDir?: string | null;
51
+ execDir: string;
52
+ versionedDir: string;
53
+ userDataDir: string;
54
+ }
55
+
56
+ export function resolveLoaderCandidates(input: ResolveLoaderCandidatesInput): string[];
57
+
58
+ export interface InitLoaderContextOverrides {
59
+ nativeDir?: string;
60
+ platform?: NodeJS.Platform | string;
61
+ isCompiledBinary?: boolean;
62
+ leafPackageDir?: string | null;
63
+ }
64
+
65
+ export interface NativeLoaderContext {
66
+ platformTag: string;
67
+ packageVersion: string;
68
+ nativeDir: string;
69
+ leafPackageDir: string | null;
70
+ versionedDir: string;
71
+ isCompiledBinary: boolean;
72
+ stageFromNodeModules: boolean;
73
+ selectedVariant: "modern" | "baseline" | null;
74
+ addonFilenames: string[];
75
+ addonLabel: string;
76
+ candidates: string[];
77
+ versionSentinelExport: string;
78
+ isWorkspaceLoad: boolean;
79
+ nativesDir: string;
80
+ }
81
+
82
+ export function initLoaderContext(overrides?: InitLoaderContextOverrides): NativeLoaderContext;
83
+
84
+ export interface CleanupStaleNativeVersionsInput {
85
+ nativesDir: string;
86
+ currentVersion: string;
87
+ }
88
+
89
+ export function cleanupStaleNativeVersions(input: CleanupStaleNativeVersionsInput): string[];
90
+
91
+ export function prepareNativeVersionDir(versionedDir: string): void;
92
+
93
+ export interface ExtractEmbeddedAddonArchiveInput {
94
+ archivePath: string;
95
+ files: EmbeddedAddonFile[];
96
+ targetDir: string;
97
+ }
98
+
99
+ export function extractEmbeddedAddonArchive(input: ExtractEmbeddedAddonArchiveInput): string[];
100
+
101
+ export interface SelectCpuVariantInput {
102
+ arch: string;
103
+ override: "modern" | "baseline" | null | undefined;
104
+ env: Record<string, string | undefined>;
105
+ detectAvx2: () => boolean;
106
+ }
107
+
108
+ export interface SelectCpuVariantResult {
109
+ variant: "modern" | "baseline" | null;
110
+ source: "non-x64" | "override" | "cache" | "detect";
111
+ cacheEnvKey?: string;
112
+ cacheEnvValue?: string;
113
+ }
114
+
115
+ export function selectCpuVariant(input: SelectCpuVariantInput): SelectCpuVariantResult;
116
+
117
+ export interface ValidateLoadedBindingsContext {
118
+ isWorkspaceLoad: boolean;
119
+ packageVersion: string;
120
+ versionSentinelExport: string;
121
+ }
122
+
123
+ export function validateLoadedBindings(
124
+ ctx: ValidateLoadedBindingsContext,
125
+ bindings: Record<string, unknown>,
126
+ candidate: string,
127
+ ): void;
128
+
129
+ export function loadNative(): Record<string, unknown>;