pi-win-notify 1.0.11 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-win-notify",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "description": "A Windows notification tool for pi — fast focus, response preview, elapsed time, mute, multi-language",
6
6
  "keywords": [
@@ -24,10 +24,14 @@
24
24
  "files": [
25
25
  "extensions/desktop-notify.ts",
26
26
  "extensions/host.ps1",
27
+ "scripts/postinstall.js",
27
28
  "README.md",
28
29
  "README.zh.md",
29
30
  "package.json"
30
31
  ],
32
+ "scripts": {
33
+ "postinstall": "node scripts/postinstall.js"
34
+ },
31
35
  "dependencies": {
32
36
  "koffi": "^3.0.2"
33
37
  },
@@ -0,0 +1,31 @@
1
+ // Postinstall: ensure koffi's native module is findable despite npm hoisting
2
+ import { existsSync, mkdirSync } from "node:fs";
3
+ import { join, dirname } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { execSync } from "node:child_process";
6
+ import { platform } from "node:os";
7
+
8
+ if (platform() !== "win32") process.exit(0);
9
+
10
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
+ const pkgDir = dirname(__dirname); // pi-win-notify root
12
+
13
+ // Source: where npm hoisted the native module (top-level node_modules)
14
+ const src = join(pkgDir, "..", "..", "node_modules", "@koromix", "koffi-win32-x64");
15
+ // Dest: where koffi expects it (inside pi-win-notify/node_modules)
16
+ const destDir = join(pkgDir, "node_modules", "@koromix");
17
+ const dest = join(destDir, "koffi-win32-x64");
18
+
19
+ if (existsSync(dest)) {
20
+ console.log("[pi-win-notify] koffi native module already linked, skip");
21
+ process.exit(0);
22
+ }
23
+
24
+ if (!existsSync(src)) {
25
+ console.log("[pi-win-notify] koffi native module not found at top level, skip");
26
+ process.exit(0);
27
+ }
28
+
29
+ mkdirSync(destDir, { recursive: true });
30
+ execSync(`mklink /J "${dest}" "${src}"`, { stdio: "pipe" });
31
+ console.log("[pi-win-notify] linked koffi native module");