@oh-my-pi/pi-natives 17.0.0 → 17.0.1
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 +12 -0
- package/native/loader-state.js +36 -1
- package/package.json +6 -6
package/native/index.d.ts
CHANGED
|
@@ -175,7 +175,7 @@ export declare function __ompInstallTokioRuntime(): void
|
|
|
175
175
|
* `packages/natives/native/index.js` (which derives the name from
|
|
176
176
|
* `package.json#version`).
|
|
177
177
|
*/
|
|
178
|
-
export declare function
|
|
178
|
+
export declare function __piNativesV17_0_1(): void
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* Apply ast-grep rewrite rules to matching files; honors `dryRun` and returns
|
package/native/index.js
CHANGED
|
@@ -24,7 +24,7 @@ export const Shell = nativeBindings.Shell;
|
|
|
24
24
|
|
|
25
25
|
// functions
|
|
26
26
|
export const __ompInstallTokioRuntime = nativeBindings.__ompInstallTokioRuntime;
|
|
27
|
-
export const
|
|
27
|
+
export const __piNativesV17_0_1 = nativeBindings.__piNativesV17_0_1;
|
|
28
28
|
export const astEdit = nativeBindings.astEdit;
|
|
29
29
|
export const astGrep = nativeBindings.astGrep;
|
|
30
30
|
export const astMatch = nativeBindings.astMatch;
|
package/native/loader-state.d.ts
CHANGED
|
@@ -86,4 +86,16 @@ export interface SelectCpuVariantResult {
|
|
|
86
86
|
|
|
87
87
|
export function selectCpuVariant(input: SelectCpuVariantInput): SelectCpuVariantResult;
|
|
88
88
|
|
|
89
|
+
export interface ValidateLoadedBindingsContext {
|
|
90
|
+
isWorkspaceLoad: boolean;
|
|
91
|
+
packageVersion: string;
|
|
92
|
+
versionSentinelExport: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function validateLoadedBindings(
|
|
96
|
+
ctx: ValidateLoadedBindingsContext,
|
|
97
|
+
bindings: Record<string, unknown>,
|
|
98
|
+
candidate: string,
|
|
99
|
+
): void;
|
|
100
|
+
|
|
89
101
|
export function loadNative(): Record<string, unknown>;
|
package/native/loader-state.js
CHANGED
|
@@ -583,7 +583,7 @@ function maybeStageNodeModulesAddon(ctx, errors) {
|
|
|
583
583
|
return stagedPath;
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
function validateLoadedBindings(ctx, bindings, candidate) {
|
|
586
|
+
export function validateLoadedBindings(ctx, bindings, candidate) {
|
|
587
587
|
// In workspace dev (running out of `packages/natives/native/` rather than a
|
|
588
588
|
// `node_modules` install or a compiled bundle) the local `.node` only gains
|
|
589
589
|
// the renamed sentinel after `bun --cwd=packages/natives run build`. Skip
|
|
@@ -591,6 +591,41 @@ function validateLoadedBindings(ctx, bindings, candidate) {
|
|
|
591
591
|
// completes; install and compiled-binary paths still validate.
|
|
592
592
|
if (ctx.isWorkspaceLoad) return;
|
|
593
593
|
if (typeof bindings[ctx.versionSentinelExport] === "function") return;
|
|
594
|
+
|
|
595
|
+
// The expected sentinel is missing. Distinguish two failure modes by the
|
|
596
|
+
// sentinel the bindings DO carry:
|
|
597
|
+
// - disk stale: the `.node` on disk predates this loader (its own build);
|
|
598
|
+
// reinstalling re-syncs the file.
|
|
599
|
+
// - process stale: an in-place upgrade landed a new release on disk while
|
|
600
|
+
// this process still holds the previous addon generation resident in the
|
|
601
|
+
// dynamic-loader's native-module cache. `require` returns those old
|
|
602
|
+
// exports, which carry the PRIOR sentinel — disk is already consistent,
|
|
603
|
+
// so reinstall is a no-op and only restarting the process re-syncs.
|
|
604
|
+
const residentSentinel = Object.keys(bindings).find(
|
|
605
|
+
key => key !== ctx.versionSentinelExport && /^__piNativesV[A-Za-z0-9_]+$/.test(key),
|
|
606
|
+
);
|
|
607
|
+
// A prior sentinel alone cannot distinguish a resident old module from an
|
|
608
|
+
// actually stale file: `require` returns the same exports in both cases.
|
|
609
|
+
// The restart diagnosis is valid only when the selected file itself carries
|
|
610
|
+
// the current sentinel; otherwise a restart would simply reload stale disk.
|
|
611
|
+
let diskHasExpectedSentinel = false;
|
|
612
|
+
try {
|
|
613
|
+
diskHasExpectedSentinel = fs.readFileSync(candidate).includes(ctx.versionSentinelExport);
|
|
614
|
+
} catch {
|
|
615
|
+
// The successful require above normally guarantees readability. If the
|
|
616
|
+
// file disappears concurrently, retain the safe reinstall diagnosis.
|
|
617
|
+
}
|
|
618
|
+
if (residentSentinel && diskHasExpectedSentinel) {
|
|
619
|
+
const residentVersion = residentSentinel.slice("__piNativesV".length).replace(/_/g, ".");
|
|
620
|
+
throw new Error(
|
|
621
|
+
`Loaded ${candidate}, which exposes the @oh-my-pi/pi-natives@${residentVersion} version ` +
|
|
622
|
+
`sentinel \`${residentSentinel}\` but not the @${ctx.packageVersion} sentinel ` +
|
|
623
|
+
`\`${ctx.versionSentinelExport}\` this loader expects. omp was upgraded to ` +
|
|
624
|
+
`${ctx.packageVersion} while this session was running; the ${residentVersion} addon is ` +
|
|
625
|
+
"still resident in this process. Disk is already consistent — restart omp to pick up " +
|
|
626
|
+
`${ctx.packageVersion} (reinstalling changes nothing).`,
|
|
627
|
+
);
|
|
628
|
+
}
|
|
594
629
|
throw new Error(
|
|
595
630
|
`Loaded ${candidate} but it does not expose the @oh-my-pi/pi-natives@${ctx.packageVersion} ` +
|
|
596
631
|
`version sentinel \`${ctx.versionSentinelExport}\`. The .node file on disk is from a different ` +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-natives",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.1",
|
|
4
4
|
"description": "Native Rust bindings for grep, clipboard, image processing, syntax highlighting, PTY, and shell operations via N-API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"@oh-my-pi/pi-natives-linux-x64": "17.0.
|
|
71
|
-
"@oh-my-pi/pi-natives-linux-arm64": "17.0.
|
|
72
|
-
"@oh-my-pi/pi-natives-darwin-x64": "17.0.
|
|
73
|
-
"@oh-my-pi/pi-natives-darwin-arm64": "17.0.
|
|
74
|
-
"@oh-my-pi/pi-natives-win32-x64": "17.0.
|
|
70
|
+
"@oh-my-pi/pi-natives-linux-x64": "17.0.1",
|
|
71
|
+
"@oh-my-pi/pi-natives-linux-arm64": "17.0.1",
|
|
72
|
+
"@oh-my-pi/pi-natives-darwin-x64": "17.0.1",
|
|
73
|
+
"@oh-my-pi/pi-natives-darwin-arm64": "17.0.1",
|
|
74
|
+
"@oh-my-pi/pi-natives-win32-x64": "17.0.1"
|
|
75
75
|
}
|
|
76
76
|
}
|