@oh-my-pi/pi-natives 17.2.0 → 17.2.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/native/index.d.ts +1 -1
- package/native/index.js +1 -1
- package/native/loader-state.d.ts +26 -0
- package/native/loader-state.js +30 -15
- package/package.json +6 -6
package/native/index.d.ts
CHANGED
|
@@ -246,7 +246,7 @@ export declare function __ompInstallTokioRuntime(): void
|
|
|
246
246
|
* `packages/natives/native/index.js` (which derives the name from
|
|
247
247
|
* `package.json#version`).
|
|
248
248
|
*/
|
|
249
|
-
export declare function
|
|
249
|
+
export declare function __piNativesV17_2_2(): void
|
|
250
250
|
|
|
251
251
|
/**
|
|
252
252
|
* Apply ast-grep rewrite rules to matching files; honors `dryRun` and returns
|
package/native/index.js
CHANGED
|
@@ -28,7 +28,7 @@ export const Shell = nativeBindings.Shell;
|
|
|
28
28
|
|
|
29
29
|
// functions
|
|
30
30
|
export const __ompInstallTokioRuntime = nativeBindings.__ompInstallTokioRuntime;
|
|
31
|
-
export const
|
|
31
|
+
export const __piNativesV17_2_2 = nativeBindings.__piNativesV17_2_2;
|
|
32
32
|
export const astEdit = nativeBindings.astEdit;
|
|
33
33
|
export const astGrep = nativeBindings.astGrep;
|
|
34
34
|
export const astMatch = nativeBindings.astMatch;
|
package/native/loader-state.d.ts
CHANGED
|
@@ -55,6 +55,32 @@ export interface ResolveLoaderCandidatesInput {
|
|
|
55
55
|
|
|
56
56
|
export function resolveLoaderCandidates(input: ResolveLoaderCandidatesInput): string[];
|
|
57
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
|
+
|
|
58
84
|
export interface CleanupStaleNativeVersionsInput {
|
|
59
85
|
nativesDir: string;
|
|
60
86
|
currentVersion: string;
|
package/native/loader-state.js
CHANGED
|
@@ -129,7 +129,8 @@ export function shouldStageNodeModulesAddon({ platform, isCompiledBinary, native
|
|
|
129
129
|
// Check both separators independently of the host's `path.sep`: this helper
|
|
130
130
|
// is shared by the loader (running on Windows with `\`) and the test suite
|
|
131
131
|
// (typically running on POSIX hosts when CI executes the regression test).
|
|
132
|
-
|
|
132
|
+
const normalizedNativeDir = nativeDir.toLowerCase();
|
|
133
|
+
return normalizedNativeDir.includes("\\node_modules\\") || normalizedNativeDir.includes("/node_modules/");
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/**
|
|
@@ -698,28 +699,44 @@ function buildHelpMessage(ctx) {
|
|
|
698
699
|
* Called from `loadNative()` rather than at module scope so importing pure
|
|
699
700
|
* helpers from this file doesn't trigger AVX2 detection or filesystem probes.
|
|
700
701
|
*/
|
|
701
|
-
|
|
702
|
-
|
|
702
|
+
/**
|
|
703
|
+
* @param {{ nativeDir?: string; platform?: NodeJS.Platform | string; isCompiledBinary?: boolean; leafPackageDir?: string | null }} [overrides]
|
|
704
|
+
*/
|
|
705
|
+
export function initLoaderContext(overrides = {}) {
|
|
706
|
+
const platform = overrides.platform ?? process.platform;
|
|
707
|
+
const platformTag = `${platform}-${process.arch}`;
|
|
703
708
|
const packageVersion = packageJson.version;
|
|
704
|
-
const nativeDir = path.join(import.meta.dir, "..", "native");
|
|
709
|
+
const nativeDir = overrides.nativeDir ?? path.join(import.meta.dir, "..", "native");
|
|
705
710
|
const execDir = path.dirname(process.execPath);
|
|
706
711
|
const nativesDir = getNativesDir();
|
|
707
712
|
const versionedDir = path.join(nativesDir, packageVersion);
|
|
708
713
|
const userDataDir =
|
|
709
|
-
|
|
714
|
+
platform === "win32"
|
|
710
715
|
? path.join(process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local"), "omp")
|
|
711
716
|
: path.join(os.homedir(), ".local", "bin");
|
|
712
717
|
|
|
713
|
-
const isCompiledBinary =
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
718
|
+
const isCompiledBinary =
|
|
719
|
+
overrides.isCompiledBinary ??
|
|
720
|
+
detectCompiledBinary({
|
|
721
|
+
embeddedAddon,
|
|
722
|
+
env: process.env,
|
|
723
|
+
importMetaUrl: import.meta.url,
|
|
724
|
+
});
|
|
725
|
+
const normalizedNativeDir = platform === "win32" ? nativeDir.toLowerCase() : nativeDir;
|
|
726
|
+
const isWorkspaceLoad =
|
|
727
|
+
!isCompiledBinary &&
|
|
728
|
+
!normalizedNativeDir.includes("\\node_modules\\") &&
|
|
729
|
+
!normalizedNativeDir.includes("/node_modules/");
|
|
730
|
+
const leafPackageDir =
|
|
731
|
+
isCompiledBinary || isWorkspaceLoad
|
|
732
|
+
? null
|
|
733
|
+
: overrides.leafPackageDir === undefined
|
|
734
|
+
? resolveLeafPackageDir(platformTag)
|
|
735
|
+
: overrides.leafPackageDir;
|
|
719
736
|
const stageFromNodeModules = shouldStageNodeModulesAddon({
|
|
720
|
-
platform
|
|
737
|
+
platform,
|
|
721
738
|
isCompiledBinary,
|
|
722
|
-
nativeDir,
|
|
739
|
+
nativeDir: normalizedNativeDir,
|
|
723
740
|
});
|
|
724
741
|
|
|
725
742
|
const selectedVariant = resolveCpuVariant(getVariantOverride());
|
|
@@ -745,8 +762,6 @@ function initLoaderContext() {
|
|
|
745
762
|
// turns the silent `<sym> is not a function` crash from a Windows
|
|
746
763
|
// locked-file update into an actionable load-time error.
|
|
747
764
|
const versionSentinelExport = `__piNativesV${packageVersion.replace(/[^A-Za-z0-9]/g, "_")}`;
|
|
748
|
-
const isWorkspaceLoad =
|
|
749
|
-
!isCompiledBinary && !nativeDir.includes("\\node_modules\\") && !nativeDir.includes("/node_modules/");
|
|
750
765
|
|
|
751
766
|
return {
|
|
752
767
|
platformTag,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-natives",
|
|
3
|
-
"version": "17.2.
|
|
3
|
+
"version": "17.2.2",
|
|
4
4
|
"description": "Native Rust bindings for 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",
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
"optionalDependencies": {
|
|
77
|
-
"@oh-my-pi/pi-natives-linux-x64": "17.2.
|
|
78
|
-
"@oh-my-pi/pi-natives-linux-arm64": "17.2.
|
|
79
|
-
"@oh-my-pi/pi-natives-darwin-x64": "17.2.
|
|
80
|
-
"@oh-my-pi/pi-natives-darwin-arm64": "17.2.
|
|
81
|
-
"@oh-my-pi/pi-natives-win32-x64": "17.2.
|
|
77
|
+
"@oh-my-pi/pi-natives-linux-x64": "17.2.2",
|
|
78
|
+
"@oh-my-pi/pi-natives-linux-arm64": "17.2.2",
|
|
79
|
+
"@oh-my-pi/pi-natives-darwin-x64": "17.2.2",
|
|
80
|
+
"@oh-my-pi/pi-natives-darwin-arm64": "17.2.2",
|
|
81
|
+
"@oh-my-pi/pi-natives-win32-x64": "17.2.2"
|
|
82
82
|
}
|
|
83
83
|
}
|