@oh-my-pi/pi-natives 17.1.2 → 17.1.4

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,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
+ }
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 __piNativesV17_1_2(): void
249
+ export declare function __piNativesV17_1_4(): void
250
250
 
251
251
  /**
252
252
  * Apply ast-grep rewrite rules to matching files; honors `dryRun` and returns
@@ -440,7 +440,10 @@ export interface AstReplaceFileChange {
440
440
  export interface AstReplaceOptions {
441
441
  /** Map of pattern string to replacement template. */
442
442
  rewrites?: Record<string, string>
443
- /** Language override; otherwise inferred from discovered files. */
443
+ /**
444
+ * Language override applied to every file; otherwise inferred per file, so
445
+ * mixed-language paths rewrite each file in its own language.
446
+ */
444
447
  lang?: string
445
448
  /** Single file or directory to rewrite. */
446
449
  path?: string
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 __piNativesV17_1_2 = nativeBindings.__piNativesV17_1_2;
31
+ export const __piNativesV17_1_4 = nativeBindings.__piNativesV17_1_4;
32
32
  export const astEdit = nativeBindings.astEdit;
33
33
  export const astGrep = nativeBindings.astGrep;
34
34
  export const astMatch = nativeBindings.astMatch;
@@ -178,6 +178,23 @@ export function resolveLoaderCandidates({
178
178
 
179
179
  // =========================================================================
180
180
 
181
+ function parseReleaseVersion(version) {
182
+ const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
183
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
184
+ }
185
+
186
+ function isOlderReleaseVersion(candidate, current) {
187
+ const candidateParts = parseReleaseVersion(candidate);
188
+ const currentParts = parseReleaseVersion(current);
189
+ if (!candidateParts || !currentParts) return false;
190
+ for (let index = 0; index < candidateParts.length; index++) {
191
+ if (candidateParts[index] !== currentParts[index]) {
192
+ return candidateParts[index] < currentParts[index];
193
+ }
194
+ }
195
+ return false;
196
+ }
197
+
181
198
  /**
182
199
  * Remove version-pinned native cache directories older than the loaded package.
183
200
  * Best-effort by design: permission errors and concurrent processes must not
@@ -196,7 +213,7 @@ export function cleanupStaleNativeVersions({ nativesDir, currentVersion }) {
196
213
  }
197
214
 
198
215
  for (const entry of entries) {
199
- if (!entry.isDirectory() || entry.name === currentVersion) continue;
216
+ if (!entry.isDirectory() || !isOlderReleaseVersion(entry.name, currentVersion)) continue;
200
217
  const targetPath = path.join(nativesDir, entry.name);
201
218
  try {
202
219
  fs.rmSync(targetPath, { recursive: true, force: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-natives",
3
- "version": "17.1.2",
3
+ "version": "17.1.4",
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",
@@ -55,6 +55,8 @@
55
55
  "files": [
56
56
  "native/index.js",
57
57
  "native/index.d.ts",
58
+ "native/desktop.js",
59
+ "native/desktop.d.ts",
58
60
  "native/loader-state.js",
59
61
  "native/loader-state.d.ts",
60
62
  "native/embedded-addon.js",
@@ -64,13 +66,17 @@
64
66
  ".": {
65
67
  "types": "./native/index.d.ts",
66
68
  "import": "./native/index.js"
69
+ },
70
+ "./desktop": {
71
+ "types": "./native/desktop.d.ts",
72
+ "import": "./native/desktop.js"
67
73
  }
68
74
  },
69
75
  "optionalDependencies": {
70
- "@oh-my-pi/pi-natives-linux-x64": "17.1.2",
71
- "@oh-my-pi/pi-natives-linux-arm64": "17.1.2",
72
- "@oh-my-pi/pi-natives-darwin-x64": "17.1.2",
73
- "@oh-my-pi/pi-natives-darwin-arm64": "17.1.2",
74
- "@oh-my-pi/pi-natives-win32-x64": "17.1.2"
76
+ "@oh-my-pi/pi-natives-linux-x64": "17.1.4",
77
+ "@oh-my-pi/pi-natives-linux-arm64": "17.1.4",
78
+ "@oh-my-pi/pi-natives-darwin-x64": "17.1.4",
79
+ "@oh-my-pi/pi-natives-darwin-arm64": "17.1.4",
80
+ "@oh-my-pi/pi-natives-win32-x64": "17.1.4"
75
81
  }
76
82
  }