bun-shlwapi 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/index.ts +6 -0
- package/package.json +52 -0
- package/runtime/extensions.ts +210 -0
- package/structs/Shlwapi.ts +2383 -0
- package/types/Shlwapi.ts +315 -0
package/index.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Stev Peifer <stev@bell.net>",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/obscuritysrl/bun-shlwapi/issues"
|
|
5
|
+
},
|
|
6
|
+
"description": "Zero-dependency, zero-overhead Win32 SHLWAPI bindings for Bun (FFI) on Windows.",
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@types/bun": "latest"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./index.ts"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"module": "index.ts",
|
|
15
|
+
"name": "bun-shlwapi",
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"typescript": "^5"
|
|
18
|
+
},
|
|
19
|
+
"private": false,
|
|
20
|
+
"homepage": "https://github.com/obscuritysrl/bun-shlwapi#readme",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git://github.com/obscuritysrl/bun-shlwapi.git"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"version": "1.0.0",
|
|
27
|
+
"main": "./index.ts",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"bun",
|
|
30
|
+
"ffi",
|
|
31
|
+
"win32",
|
|
32
|
+
"windows",
|
|
33
|
+
"shlwapi",
|
|
34
|
+
"bindings",
|
|
35
|
+
"typescript",
|
|
36
|
+
"dll"
|
|
37
|
+
],
|
|
38
|
+
"files": [
|
|
39
|
+
"index.ts",
|
|
40
|
+
"runtime/*.ts",
|
|
41
|
+
"structs/*.ts",
|
|
42
|
+
"types/*.ts",
|
|
43
|
+
"README.md"
|
|
44
|
+
],
|
|
45
|
+
"sideEffects": false,
|
|
46
|
+
"engines": {
|
|
47
|
+
"bun": ">=1.1.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"example": "bun ./example/shlwapi.ts"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { type Pointer, ptr } from 'bun:ffi';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
/**
|
|
5
|
+
* Adds a native pointer property to all ArrayBuffer, Buffer, DataView, and TypedArray types.
|
|
6
|
+
*
|
|
7
|
+
* The `ptr` property returns a native pointer usable with Bun FFI.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const arr = new Uint8Array([1, 2, 3]);
|
|
12
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
interface ArrayBuffer {
|
|
16
|
+
/**
|
|
17
|
+
* Native pointer to ArrayBuffer memory for Bun FFI.
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const buf = new ArrayBuffer(8);
|
|
21
|
+
* nativeFunction(buf.ptr, buf.byteLength);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
readonly ptr: Pointer;
|
|
25
|
+
}
|
|
26
|
+
interface BigInt64Array {
|
|
27
|
+
/**
|
|
28
|
+
* Native pointer to BigInt64Array memory for Bun FFI.
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const arr = new BigInt64Array([1n, 2n]);
|
|
32
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
readonly ptr: Pointer;
|
|
36
|
+
}
|
|
37
|
+
interface BigUint64Array {
|
|
38
|
+
/**
|
|
39
|
+
* Native pointer to BigUint64Array memory for Bun FFI.
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* const arr = new BigUint64Array([1n, 2n]);
|
|
43
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
readonly ptr: Pointer;
|
|
47
|
+
}
|
|
48
|
+
interface Buffer {
|
|
49
|
+
/**
|
|
50
|
+
* Native pointer to Buffer memory for Bun FFI.
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const buf = Buffer.from([1, 2, 3]);
|
|
54
|
+
* nativeFunction(buf.ptr, buf.length);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
readonly ptr: Pointer;
|
|
58
|
+
}
|
|
59
|
+
interface DataView {
|
|
60
|
+
/**
|
|
61
|
+
* Native pointer to DataView memory for Bun FFI.
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const view = new DataView(new ArrayBuffer(4));
|
|
65
|
+
* nativeFunction(view.ptr, view.byteLength);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
readonly ptr: Pointer;
|
|
69
|
+
}
|
|
70
|
+
interface Float32Array {
|
|
71
|
+
/**
|
|
72
|
+
* Native pointer to Float32Array memory for Bun FFI.
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const arr = new Float32Array([1, 2, 3]);
|
|
76
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
readonly ptr: Pointer;
|
|
80
|
+
}
|
|
81
|
+
interface Float64Array {
|
|
82
|
+
/**
|
|
83
|
+
* Native pointer to Float64Array memory for Bun FFI.
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const arr = new Float64Array([1, 2, 3]);
|
|
87
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
readonly ptr: Pointer;
|
|
91
|
+
}
|
|
92
|
+
interface Int16Array {
|
|
93
|
+
/**
|
|
94
|
+
* Native pointer to Int16Array memory for Bun FFI.
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const arr = new Int16Array([1, 2, 3]);
|
|
98
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
readonly ptr: Pointer;
|
|
102
|
+
}
|
|
103
|
+
interface Int32Array {
|
|
104
|
+
/**
|
|
105
|
+
* Native pointer to Int32Array memory for Bun FFI.
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const arr = new Int32Array([1, 2, 3]);
|
|
109
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
readonly ptr: Pointer;
|
|
113
|
+
}
|
|
114
|
+
interface Int8Array {
|
|
115
|
+
/**
|
|
116
|
+
* Native pointer to Int8Array memory for Bun FFI.
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* const arr = new Int8Array([1, 2, 3]);
|
|
120
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
readonly ptr: Pointer;
|
|
124
|
+
}
|
|
125
|
+
interface SharedArrayBuffer {
|
|
126
|
+
/**
|
|
127
|
+
* Native pointer to SharedArrayBuffer memory for Bun FFI.
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* const buf = new SharedArrayBuffer(8);
|
|
131
|
+
* nativeFunction(buf.ptr, buf.byteLength);
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
readonly ptr: Pointer;
|
|
135
|
+
}
|
|
136
|
+
interface Uint16Array {
|
|
137
|
+
/**
|
|
138
|
+
* Native pointer to Uint16Array memory for Bun FFI.
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const arr = new Uint16Array([1, 2, 3]);
|
|
142
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
readonly ptr: Pointer;
|
|
146
|
+
}
|
|
147
|
+
interface Uint32Array {
|
|
148
|
+
/**
|
|
149
|
+
* Native pointer to Uint32Array memory for Bun FFI.
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* const arr = new Uint32Array([1, 2, 3]);
|
|
153
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
readonly ptr: Pointer;
|
|
157
|
+
}
|
|
158
|
+
interface Uint8Array {
|
|
159
|
+
/**
|
|
160
|
+
* Native pointer to Uint8Array memory for Bun FFI.
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const arr = new Uint8Array([1, 2, 3]);
|
|
164
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
readonly ptr: Pointer;
|
|
168
|
+
}
|
|
169
|
+
interface Uint8ClampedArray {
|
|
170
|
+
/**
|
|
171
|
+
* Native pointer to Uint8ClampedArray memory for Bun FFI.
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const arr = new Uint8ClampedArray([1, 2, 3]);
|
|
175
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
readonly ptr: Pointer;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Installs the `ptr` property on all supported binary view prototypes.
|
|
184
|
+
*
|
|
185
|
+
* The property is non-enumerable and non-configurable. The getter calls `ptr(this)`.
|
|
186
|
+
*/
|
|
187
|
+
const constructors = [ArrayBuffer, BigInt64Array, BigUint64Array, Buffer, DataView, Float32Array, Float64Array, Int16Array, Int32Array, Int8Array, SharedArrayBuffer, Uint16Array, Uint32Array, Uint8Array, Uint8ClampedArray] as const;
|
|
188
|
+
|
|
189
|
+
constructors.forEach(
|
|
190
|
+
({ prototype }) =>
|
|
191
|
+
!Object.getOwnPropertyDescriptor(prototype, 'ptr') &&
|
|
192
|
+
Object.defineProperty(prototype, 'ptr', {
|
|
193
|
+
configurable: false,
|
|
194
|
+
enumerable: false,
|
|
195
|
+
/**
|
|
196
|
+
* Returns a native pointer to the underlying memory.
|
|
197
|
+
* @returns Native pointer for Bun FFI.
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* const arr = new Uint8Array([1, 2, 3]);
|
|
201
|
+
* nativeFunction(arr.ptr, arr.length);
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
get(this): Pointer {
|
|
205
|
+
return ptr(this);
|
|
206
|
+
},
|
|
207
|
+
})
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
export {};
|