napi-windows-process-start-time 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +48 -2
- package/dist/index.d.ts +13 -0
- package/dist/index.js +27 -0
- package/native/process-start-time.win32-arm64.node +0 -0
- package/native/process-start-time.win32-x64.node +0 -0
- package/package.json +55 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 napi-windows-process-start-time contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# napi-windows-process-start-time
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A tiny Windows Node-API addon that reads a running process's creation time.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import { getProcessStartTime } from 'napi-windows-process-start-time'
|
|
7
|
+
|
|
8
|
+
const startTime = getProcessStartTime(process.pid)
|
|
9
|
+
// 'win32:639...' or null
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
`getProcessStartTime(pid: number): string | null`
|
|
15
|
+
|
|
16
|
+
Returns a stable `win32:<ticks>` token. Ticks are 100-nanosecond intervals since 0001-01-01 UTC, matching `(Get-Process -Id $pid).StartTime.ToUniversalTime().Ticks` in .NET. The value is kept as a string to preserve precision.
|
|
17
|
+
|
|
18
|
+
Returns `null` when the process has exited, does not exist, or cannot be queried with the current permissions. Invalid arguments throw `TypeError`: `pid` must be an integer between 0 and 4294967295. PID 0 is valid input but cannot be queried.
|
|
19
|
+
|
|
20
|
+
A process can exit immediately after a successful query. Callers must account for that race when using a timestamp to identify a process.
|
|
21
|
+
|
|
22
|
+
## Platform support
|
|
23
|
+
|
|
24
|
+
Windows x64 and ARM64 with Node.js 20+.
|
|
25
|
+
|
|
26
|
+
## Development
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
pnpm install --frozen-lockfile
|
|
30
|
+
pnpm run build
|
|
31
|
+
pnpm test
|
|
32
|
+
pnpm run check
|
|
33
|
+
pnpm run lint
|
|
34
|
+
pnpm run format
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Releases
|
|
38
|
+
|
|
39
|
+
From a clean checkout on `main`:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
git pull --ff-only
|
|
43
|
+
pnpm version patch -m "release: v%s" # or minor, major, explicit version
|
|
44
|
+
git push origin main --follow-tags
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Reads a running Windows process's creation time without spawning a subprocess.
|
|
4
|
+
*
|
|
5
|
+
* Returns `win32:<ticks>`, where ticks are 100-nanosecond intervals since
|
|
6
|
+
* 0001-01-01 UTC, matching .NET DateTime.Ticks. Returns null when the process
|
|
7
|
+
* has exited, does not exist, or cannot be queried with the current permissions.
|
|
8
|
+
*
|
|
9
|
+
* @throws {TypeError} If pid is not an integer between 0 and 4294967295.
|
|
10
|
+
*/
|
|
11
|
+
declare function getProcessStartTime(pid: number): `win32:${string}` | null;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { getProcessStartTime };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region index.ts
|
|
3
|
+
if (process.platform !== "win32" || !["x64", "arm64"].includes(process.arch)) throw new Error(`napi-windows-process-start-time supports Windows x64 and ARM64; received ${process.platform}/${process.arch}`);
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const filename = `../native/process-start-time.win32-${process.arch}.node`;
|
|
6
|
+
let binding;
|
|
7
|
+
try {
|
|
8
|
+
binding = require(filename);
|
|
9
|
+
} catch (cause) {
|
|
10
|
+
throw new Error(`Cannot load ${filename}. When using a source checkout, run pnpm run build with Rust and the MSVC build tools installed.`, { cause });
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Reads a running Windows process's creation time without spawning a subprocess.
|
|
14
|
+
*
|
|
15
|
+
* Returns `win32:<ticks>`, where ticks are 100-nanosecond intervals since
|
|
16
|
+
* 0001-01-01 UTC, matching .NET DateTime.Ticks. Returns null when the process
|
|
17
|
+
* has exited, does not exist, or cannot be queried with the current permissions.
|
|
18
|
+
*
|
|
19
|
+
* @throws {TypeError} If pid is not an integer between 0 and 4294967295.
|
|
20
|
+
*/
|
|
21
|
+
function getProcessStartTime(pid) {
|
|
22
|
+
if (!Number.isInteger(pid) || pid < 0 || pid > 4294967295) throw new TypeError("pid must be a uint32");
|
|
23
|
+
const ticks = binding.getProcessStartTime(pid);
|
|
24
|
+
return ticks === null ? null : `win32:${ticks}`;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { getProcessStartTime };
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "napi-windows-process-start-time",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tiny native addon for Windows process creation times",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"napi",
|
|
7
|
+
"node-api",
|
|
8
|
+
"process",
|
|
9
|
+
"start-time",
|
|
10
|
+
"windows"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/sapphi-red/napi-windows-process-start-time#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/sapphi-red/napi-windows-process-start-time/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/sapphi-red/napi-windows-process-start-time.git"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist/index.js",
|
|
23
|
+
"dist/index.d.ts",
|
|
24
|
+
"native/*.node"
|
|
25
|
+
],
|
|
26
|
+
"os": [
|
|
27
|
+
"win32"
|
|
28
|
+
],
|
|
29
|
+
"cpu": [
|
|
30
|
+
"x64",
|
|
31
|
+
"arm64"
|
|
32
|
+
],
|
|
33
|
+
"type": "module",
|
|
34
|
+
"exports": "./dist/index.js",
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^20.19.43",
|
|
37
|
+
"oxfmt": "^0.76.0",
|
|
38
|
+
"oxlint": "^1.91.0",
|
|
39
|
+
"oxlint-tsgolint": "^7.0.2006",
|
|
40
|
+
"pkg-pr-new": "0.0.93",
|
|
41
|
+
"tsdown": "^0.21.10",
|
|
42
|
+
"typescript": "^6.0.3",
|
|
43
|
+
"vitest": "^4.0.0"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsdown",
|
|
50
|
+
"build:js": "tsdown --on-success \"\"",
|
|
51
|
+
"typecheck": "pnpm run lint",
|
|
52
|
+
"test": "pnpm run build && vitest run",
|
|
53
|
+
"lint": "oxlint",
|
|
54
|
+
"format": "oxfmt",
|
|
55
|
+
"format:check": "oxfmt --check",
|
|
56
|
+
"check": "pnpm run format:check && pnpm run lint && cargo fmt --check && cargo clippy --lib --locked -- -D warnings"
|
|
57
|
+
}
|
|
6
58
|
}
|