@oh-my-pi/pi-natives 18.10.3 → 18.11.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.
@@ -499,13 +499,11 @@ export function extractEmbeddedAddons({ files, targetDir }) {
499
499
  return writtenPaths;
500
500
  }
501
501
 
502
- function maybeExtractEmbeddedAddon(ctx, errors) {
502
+ function maybeExtractEmbeddedAddon(ctx, errors, file = selectEmbeddedAddonFile(ctx.selectedVariant)) {
503
503
  if (!ctx.isCompiledBinary || !embeddedAddon) return null;
504
504
  if (embeddedAddon.platformTag !== ctx.platformTag || embeddedAddon.version !== ctx.packageVersion) return null;
505
-
506
- const selectedEmbeddedFile = selectEmbeddedAddonFile(ctx.selectedVariant);
507
- if (!selectedEmbeddedFile) return null;
508
- const targetPath = path.join(ctx.versionedDir, selectedEmbeddedFile.filename);
505
+ if (!file) return null;
506
+ const targetPath = path.join(ctx.versionedDir, file.filename);
509
507
 
510
508
  startupMarker("native:extractEmbeddedAddon:start");
511
509
  try {
@@ -517,11 +515,11 @@ function maybeExtractEmbeddedAddon(ctx, errors) {
517
515
  }
518
516
 
519
517
  try {
520
- extractEmbeddedAddons({ files: embeddedAddon.files, targetDir: ctx.versionedDir });
518
+ extractEmbeddedAddons({ files: [file], targetDir: ctx.versionedDir });
521
519
  return targetPath;
522
520
  } catch (err) {
523
521
  const message = err instanceof Error ? err.message : String(err);
524
- errors.push(`embedded addon extraction (${selectedEmbeddedFile.filename}): ${message}`);
522
+ errors.push(`embedded addon extraction (${file.filename}): ${message}`);
525
523
  return null;
526
524
  }
527
525
  }
@@ -866,8 +864,16 @@ export function loadNative() {
866
864
  const stagedCandidate = embeddedCandidate ? null : maybeStageNodeModulesAddon(ctx, errors);
867
865
  const prepended = [embeddedCandidate, stagedCandidate].filter(c => typeof c === "string");
868
866
  const runtimeCandidates = prepended.length > 0 ? [...prepended, ...ctx.candidates] : ctx.candidates;
867
+ const fallbackEmbeddedFile =
868
+ ctx.selectedVariant === "modern" && embeddedAddon
869
+ ? embeddedAddon.files.find(file => file.variant === "baseline")
870
+ : null;
871
+ const fallbackEmbeddedPath = fallbackEmbeddedFile && path.join(ctx.versionedDir, fallbackEmbeddedFile.filename);
869
872
 
870
873
  for (const candidate of runtimeCandidates) {
874
+ if (fallbackEmbeddedFile && candidate === fallbackEmbeddedPath) {
875
+ maybeExtractEmbeddedAddon(ctx, errors, fallbackEmbeddedFile);
876
+ }
871
877
  try {
872
878
  startupMarker(`native:require:${path.basename(candidate)}`);
873
879
  const bindings = require_(candidate);
package/native/vcs.d.ts CHANGED
@@ -81,6 +81,9 @@ export declare function detachGitDir(
81
81
  signal?: AbortSignal,
82
82
  ): Promise<"no-git" | "independent" | "detached">;
83
83
 
84
+ /** Preserve isolation-local Git objects in the source without changing its refs or index. */
85
+ export declare function copyGitObjects(isolationRoot: string, sourceRoot: string): Promise<void>;
86
+
84
87
  /** Run Git's checkout hook in a new linked worktree and return its output and exit status. */
85
88
  export declare function runPostCheckoutHook(
86
89
  worktreeRoot: string,
package/native/vcs.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { $ } from "bun";
2
2
  import * as fs from "node:fs";
3
+ import * as path from "node:path";
3
4
  import { loadNative } from "./loader-state.js";
4
5
 
5
6
  let native;
@@ -96,6 +97,31 @@ export function detachGitDir(worktreeRoot, sourceCommonDir, signal) {
96
97
  return api().vcsDetachGitDir(worktreeRoot, sourceCommonDir, signal);
97
98
  }
98
99
 
100
+ /**
101
+ * Keep objects created in an isolated Git repository reachable after its
102
+ * worktree is removed, without changing the destination's refs or index.
103
+ */
104
+ export async function copyGitObjects(isolationRoot, sourceRoot) {
105
+ const from = path.join(requireGit(isolationRoot).info().commonDir, "objects");
106
+ const to = path.join(requireGit(sourceRoot).info().commonDir, "objects");
107
+ for (const entry of await fs.promises.readdir(from, { withFileTypes: true })) {
108
+ if (entry.isDirectory() && /^[0-9a-f]{2}$/.test(entry.name)) {
109
+ await fs.promises.cp(path.join(from, entry.name), path.join(to, entry.name), {
110
+ recursive: true,
111
+ force: false,
112
+ });
113
+ }
114
+ }
115
+ const packs = await fs.promises.readdir(path.join(from, "pack"));
116
+ // The index must only become visible after the pack it describes.
117
+ for (const name of packs.filter(name => name.endsWith(".pack"))) {
118
+ await fs.promises.cp(path.join(from, "pack", name), path.join(to, "pack", name), { force: false });
119
+ }
120
+ for (const name of packs.filter(name => /\.(?:idx|rev|keep|promisor|mtimes)$/.test(name))) {
121
+ await fs.promises.cp(path.join(from, "pack", name), path.join(to, "pack", name), { force: false });
122
+ }
123
+ }
124
+
99
125
  /**
100
126
  * Run Git's checkout hook in a newly created linked worktree, using the same
101
127
  * null old HEAD and branch-switch flag as `git worktree add`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-natives",
3
- "version": "18.10.3",
3
+ "version": "18.11.0",
4
4
  "description": "Native Rust bindings for PDF conversion, 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",
@@ -113,11 +113,11 @@
113
113
  }
114
114
  },
115
115
  "optionalDependencies": {
116
- "@oh-my-pi/pi-natives-linux-x64": "18.10.3",
117
- "@oh-my-pi/pi-natives-linux-arm64": "18.10.3",
118
- "@oh-my-pi/pi-natives-darwin-x64": "18.10.3",
119
- "@oh-my-pi/pi-natives-darwin-arm64": "18.10.3",
120
- "@oh-my-pi/pi-natives-win32-x64": "18.10.3",
121
- "@oh-my-pi/pi-natives-win32-arm64": "18.10.3"
116
+ "@oh-my-pi/pi-natives-linux-x64": "18.11.0",
117
+ "@oh-my-pi/pi-natives-linux-arm64": "18.11.0",
118
+ "@oh-my-pi/pi-natives-darwin-x64": "18.11.0",
119
+ "@oh-my-pi/pi-natives-darwin-arm64": "18.11.0",
120
+ "@oh-my-pi/pi-natives-win32-x64": "18.11.0",
121
+ "@oh-my-pi/pi-natives-win32-arm64": "18.11.0"
122
122
  }
123
123
  }