@bun-win32/propsys 1.0.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/AI.md +71 -0
- package/README.md +73 -0
- package/index.ts +4 -0
- package/package.json +57 -0
- package/structs/Propsys.ts +1432 -0
- package/types/Propsys.ts +151 -0
package/AI.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# AI Guide for @bun-win32/propsys
|
|
2
|
+
|
|
3
|
+
How to use this package, not what the Win32 API does.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import Propsys, { SomeFlag } from '@bun-win32/propsys';
|
|
9
|
+
|
|
10
|
+
// Methods bind lazily on first call
|
|
11
|
+
const result = Propsys.SomeFunctionW(arg1, arg2);
|
|
12
|
+
|
|
13
|
+
// Preload: array, single string, or no args (all symbols)
|
|
14
|
+
Propsys.Preload(['SomeFunctionW', 'AnotherFunction']);
|
|
15
|
+
Propsys.Preload('SomeFunctionW');
|
|
16
|
+
Propsys.Preload();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Where To Look
|
|
20
|
+
|
|
21
|
+
| Need | Read |
|
|
22
|
+
| --------------------------------- | -------------------- |
|
|
23
|
+
| Find a method or its MS Docs link | `structs/Propsys.ts` |
|
|
24
|
+
| Find types, enums, constants | `types/Propsys.ts` |
|
|
25
|
+
| Quick examples | `README.md` |
|
|
26
|
+
|
|
27
|
+
`index.ts` re-exports the class and all types — import from `@bun-win32/propsys` directly.
|
|
28
|
+
|
|
29
|
+
## Calling Convention
|
|
30
|
+
|
|
31
|
+
All documented `propsys.dll` exports are bound. Each method maps 1:1 to its DLL export. Names, parameter names, and order match Microsoft Docs.
|
|
32
|
+
|
|
33
|
+
### Strings
|
|
34
|
+
|
|
35
|
+
`W` methods take UTF-16LE NUL-terminated buffers. `A` methods take ANSI strings.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const wide = Buffer.from('Hello\0', 'utf16le'); // LPCWSTR
|
|
39
|
+
Propsys.SomeFunctionW(wide.ptr);
|
|
40
|
+
|
|
41
|
+
// Reading a wide string back from a buffer:
|
|
42
|
+
const text = new TextDecoder('utf-16').decode(buf).replace(/\0.*$/, '');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Return types
|
|
46
|
+
|
|
47
|
+
- `HANDLE`, `HWND`, etc. → `bigint`
|
|
48
|
+
- `DWORD`, `UINT`, `BOOL`, `INT`, `LONG` → `number`
|
|
49
|
+
- `LPVOID`, `LPWSTR`, etc. → `Pointer`
|
|
50
|
+
- Win32 `BOOL` is `number` (0 or non-zero), **not** JS `boolean`. Do not compare with `=== true`.
|
|
51
|
+
|
|
52
|
+
### Pointers, handles, out-parameters
|
|
53
|
+
|
|
54
|
+
- **Pointer** params (`LP*`, `P*`, `Pointer`): pass `buffer.ptr` from a caller-allocated `Buffer`.
|
|
55
|
+
- **Handle** params (`HANDLE`, `HWND`, etc.): pass a `bigint` value.
|
|
56
|
+
- **Out-parameters**: allocate a `Buffer`, pass `.ptr`, read the result after the call.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const out = Buffer.alloc(4);
|
|
60
|
+
Propsys.SomeFunction(out.ptr);
|
|
61
|
+
const value = out.readUInt32LE(0);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Nullability
|
|
65
|
+
|
|
66
|
+
- `| NULL` in a signature → pass `null` (optional pointer).
|
|
67
|
+
- `| 0n` in a signature → pass `0n` (optional handle).
|
|
68
|
+
|
|
69
|
+
## Errors and Cleanup
|
|
70
|
+
|
|
71
|
+
Return values are raw. If the Win32 function uses last-error semantics, read via `GetLastError()`. Resource cleanup is your responsibility — same as raw Win32.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @bun-win32/propsys
|
|
2
|
+
|
|
3
|
+
Zero-dependency, zero-overhead Win32 Propsys bindings for [Bun](https://bun.sh) on Windows.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@bun-win32/propsys` exposes the `propsys.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `Propsys`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.
|
|
8
|
+
|
|
9
|
+
The bindings are strongly typed for a smooth DX in TypeScript.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.
|
|
14
|
+
- Direct FFI to `propsys.dll` (PROPVARIANT/VARIANT helpers, property keys, and property stores).
|
|
15
|
+
- In-source docs in `structs/Propsys.ts` with links to Microsoft Docs.
|
|
16
|
+
- Lazy binding on first call; optional eager preload (`Propsys.Preload()`).
|
|
17
|
+
- No wrapper overhead; calls map 1:1 to native APIs.
|
|
18
|
+
- Strongly-typed Win32 aliases (see `types/Propsys.ts`).
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- [Bun](https://bun.sh) runtime
|
|
23
|
+
- Windows 10 or later
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
bun add @bun-win32/propsys
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import Propsys from '@bun-win32/propsys';
|
|
35
|
+
|
|
36
|
+
// Resolve a canonical property name to its binary PROPERTYKEY
|
|
37
|
+
// (GUID fmtid + DWORD pid = 20 bytes), then format it back to a string.
|
|
38
|
+
const name = Buffer.from('System.Title\0', 'utf16le');
|
|
39
|
+
const key = Buffer.alloc(20);
|
|
40
|
+
|
|
41
|
+
if (Propsys.PSGetPropertyKeyFromName(name.ptr, key.ptr) === 0) {
|
|
42
|
+
const text = Buffer.alloc(256 * 2); // wide chars
|
|
43
|
+
Propsys.PSStringFromPropertyKey(key.ptr, text.ptr, 256);
|
|
44
|
+
console.log(text.toString('utf16le').replace(/\0.*$/, ''));
|
|
45
|
+
// {F29F85E0-4FF9-1068-AB91-08002B27B3D9} 2
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> [!NOTE]
|
|
50
|
+
> `PSGetPropertyKeyFromName` resolves names through the COM-based property
|
|
51
|
+
> schema, so call `CoInitialize`/`CoInitializeEx` on the thread first. The
|
|
52
|
+
> `PropVariant*`/`Variant*` value helpers and `PropVariantCompareEx` do not
|
|
53
|
+
> require COM.
|
|
54
|
+
|
|
55
|
+
> [!NOTE]
|
|
56
|
+
> AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.
|
|
57
|
+
|
|
58
|
+
## Examples
|
|
59
|
+
|
|
60
|
+
Run the included examples:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
# Thorough diagnostic: property-key dictionary + PROPVARIANT conversion matrix
|
|
64
|
+
bun run example/property-system-diagnostic.ts
|
|
65
|
+
|
|
66
|
+
# Animated: a deck sorted live by Windows' own PropVariantCompareEx, three ways
|
|
67
|
+
bun run example/windows-sort-visualizer.ts
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Notes
|
|
71
|
+
|
|
72
|
+
- Either rely on lazy binding or call `Propsys.Preload()`.
|
|
73
|
+
- Windows only. Bun runtime required.
|
package/index.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Stev Peifer <stev@bell.net>",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/ObscuritySRL/bun-win32/issues"
|
|
5
|
+
},
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@bun-win32/core": "1.1.2"
|
|
8
|
+
},
|
|
9
|
+
"description": "Zero-dependency, zero-overhead Win32 PROPSYS bindings for Bun (FFI) on Windows.",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/bun": "latest"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./index.ts"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"module": "index.ts",
|
|
18
|
+
"name": "@bun-win32/propsys",
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"typescript": "^5"
|
|
21
|
+
},
|
|
22
|
+
"private": false,
|
|
23
|
+
"homepage": "https://github.com/ObscuritySRL/bun-win32#readme",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git://github.com/ObscuritySRL/bun-win32.git",
|
|
27
|
+
"directory": "packages/propsys"
|
|
28
|
+
},
|
|
29
|
+
"type": "module",
|
|
30
|
+
"version": "1.0.0",
|
|
31
|
+
"main": "./index.ts",
|
|
32
|
+
"keywords": [
|
|
33
|
+
"bun",
|
|
34
|
+
"ffi",
|
|
35
|
+
"win32",
|
|
36
|
+
"windows",
|
|
37
|
+
"propsys",
|
|
38
|
+
"bindings",
|
|
39
|
+
"typescript",
|
|
40
|
+
"dll"
|
|
41
|
+
],
|
|
42
|
+
"files": [
|
|
43
|
+
"AI.md",
|
|
44
|
+
"README.md",
|
|
45
|
+
"index.ts",
|
|
46
|
+
"structs/*.ts",
|
|
47
|
+
"types/*.ts"
|
|
48
|
+
],
|
|
49
|
+
"sideEffects": false,
|
|
50
|
+
"engines": {
|
|
51
|
+
"bun": ">=1.1.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"example:property-system-diagnostic": "bun ./example/property-system-diagnostic.ts",
|
|
55
|
+
"example:windows-sort-visualizer": "bun ./example/windows-sort-visualizer.ts"
|
|
56
|
+
}
|
|
57
|
+
}
|