Skip to content

Commit b4f70ae

Browse files
committed
docs: Update docs
1 parent bc931e8 commit b4f70ae

File tree

3 files changed

+38
-22
lines changed

3 files changed

+38
-22
lines changed

.github/README.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
# libwin32 (work in progress)
22
> Node bindings to native Win32 DLLs through [Koffi](https://koffi.dev).
33
4+
````js
5+
import { MessageBox } from 'libwin32'
6+
import { MB_ } from 'libwin32/consts'
7+
8+
const result = MessageBox(
9+
null,
10+
"Hello, world!",
11+
"libwin32",
12+
MB_.ICONINFORMATION | MB_.YESNO
13+
)
14+
````
15+
16+
![screenshot](../docs/snapshot.png)
17+
18+
419
### In a nutshell:
520
* Very simple and intuitive API (see [demos](./source//demos/)), with TypeScript definitions included.
621
* Bundler friendly, designed with tree-shakeability in mind.
@@ -19,22 +34,16 @@
1934
* All constants are available via the `libwin32/consts` import.
2035
* Logically grouped constants are exported as `enum`s, where the prefix is the name of the enum. For instance, `WM_DESTROY` and `WM_KEYDOWN` are members of the `WM_` enum and can be accessed as `WM_.DESTROY` and `WM_.KEYDOWN`, respectively.
2136
1. Call the functions as instructed by the [Win32 API documentation](https://learn.microsoft.com/en-us/windows/win32/api/).
22-
* All functions, constants and types are named accordingly.
23-
* There are a few cases where it made sense to transform the C prototype to something more JS-friendly. For instance, in C, `GetWindowText` fills in a buffer whose address is passed as the second parameter to the function; in JS/TS, the function takes only one parameter and returns a string.
37+
* All functions, constants and types are named accordingly and the lib is fully typed so you may rely on code hints from your editor.
38+
* Many Win32 C structures have a size member (often named `cbSize`) that must be set before they are used as a parameter. For these, the lib provide a JS class that automatically sets that field when instantiated. See `WNDCLASSEX` for an example.
39+
* There are a few cases where it made sense to transform the C prototype to something more JS-friendly. For instance, in C, `GetWindowText()` fills in a buffer whose address is passed as the second parameter to the function; in JS/TS, the function takes only one parameter and returns a string.
2440

25-
````js
26-
import { MessageBox } from 'libwin32'
27-
import { MB_ } from 'libwin32/consts'
41+
#### > Bundle the lib with your code
42+
The Win32 API has thousands of functions, structures and constants. While providing bindings for all of them is *not* a goal, the lib may eventually grow to something very, very big.
2843

29-
const result = MessageBox(
30-
null,
31-
"Hello, world!",
32-
"libwin32",
33-
MB_.ICONINFORMATION | MB_.YESNO
34-
)
35-
````
44+
To accommodate this, `libwin32` is "tree-shakeable by design". This feature relies on [Rollup's awesome tree-shaking capabilities](https://rollupjs.org/introduction/#tree-shaking).
3645

37-
![screenshot](../docs/snapshot.png)
46+
See [rollup.demos.js](../rollup.demos.js) to see how it's done, and build the demos (see below) to see the resulting code in the `/demos` directory.
3847

3948
#### > Build the lib
4049

@@ -146,7 +155,7 @@ None.
146155
* `./source/demos`:
147156
* Some usage examples.
148157
* `./source/rollup`:
149-
* Two [Rollup](https://rollup.org) plugins to ease the process of bundling this library with your own code and to boost its tree-shakeability. See [rollup.demos.js](./rollup.demos.js) to see how to use.
158+
* Two [Rollup](https://rollup.org) plugins to ease the process of bundling this library with your own code and to boost its tree-shakeability. See [rollup.demos.js](../rollup.demos.js) to see how to use.
150159

151160
### Licence
152161
MIT.

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,11 @@
4646
"user32",
4747
"shell32",
4848
"demos"
49+
],
50+
"cSpell.words": [
51+
"bundable",
52+
"Koffi",
53+
"libwin",
54+
"shakeability"
4955
]
5056
}

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
# libwin32 (work in progress)
22
> Node bindings to native Win32 DLLs through [Koffi](https://koffi.dev).
33
4-
### In a nutshell:
5-
* Very simple and intuitive API (see [demos](./source//demos/)), with TypeScript definitions included.
6-
* Bundler friendly, designed with tree-shakeability in mind.
7-
* Opinionated:
8-
* Only targets **64-bit** platforms (*Intel/AMD for now, ARM may be added later, no warranty though*).
9-
* Only exposes **Unicode** functions and data structures (those whose name ends in `W` in the Win32 API).
10-
* Very easy to extend with additional functions, data structures and constants. I will add some myself time permitting; any help would be *mucho* appreciated.
11-
124
````js
135
import { MessageBox } from 'libwin32'
146
import { MB_ } from 'libwin32/consts'
@@ -23,6 +15,15 @@ const result = MessageBox(
2315

2416
![screenshot](docs/snapshot.png)
2517

18+
19+
### In a nutshell:
20+
* Very simple and intuitive API (see [demos](./source//demos/)), with TypeScript definitions included.
21+
* Bundler friendly, designed with tree-shakeability in mind.
22+
* Opinionated:
23+
* Only targets **64-bit** platforms (*Intel/AMD for now, ARM may be added later, no warranty though*).
24+
* Only exposes **Unicode** functions and data structures (those whose name ends in `W` in the Win32 API).
25+
* Very easy to extend with additional functions, data structures and constants. I will add some myself time permitting; any help would be *mucho* appreciated.
26+
2627
See [the repo on Github](https://github.com/Septh/libwin32#readme) for full documentation.
2728

2829
### Licence

0 commit comments

Comments
 (0)