mirror of
https://github.com/Septh/libwin32
synced 2026-08-09 12:19:58 +00:00
chore: Move some files.
This commit is contained in:
+2
-1
@@ -1,5 +1,6 @@
|
||||
node_modules/
|
||||
# dist/
|
||||
/dist
|
||||
/demos
|
||||
*.tsbuildinfo
|
||||
*.tgz
|
||||
zz*
|
||||
|
||||
@@ -16,23 +16,41 @@
|
||||
1. Install the lib in your project: `npm install libwin32`
|
||||
1. Import the functions, constants and types you need. You may either import from `libwin32` or from `libwin32/<dllname>` (without the `.dll` extension). Currently, only two dlls are available: `kernel32` and `user32`.
|
||||
1. Call the functions as instructed by the [Win32 API documentation](https://learn.microsoft.com/en-us/windows/win32/api/). All functions, constants and types are named accordingly.
|
||||
* Constants like `WM_DESTROY` are exported as `const enum`s, where the prefix is the name of the enum. Eg, `WM_DESTROY` and `WM_KEYDOWN` are exported as `WM.DESTROY` and `WM_KEYDOWN`.
|
||||
* ⚠️ *If you don't use TypeScript, then you'll have to search the numerical values in the docs and use that instead.*
|
||||
* Constants like `WM_DESTROY` are exported as `const enum`s, where the prefix is the name of the enum. Eg, `WM_DESTROY` and `WM_KEYDOWN` are exported as `WM.DESTROY` and `WM_KEYDOWN` (if you use TypeScript, you may want to set `preserveConstEnmums = false` in `tsconfig.json`).
|
||||
|
||||
#### > Build the lib
|
||||
* Clone the repo: `git clone https://github.com/Septh/libwin32.git`
|
||||
* Run `npm install` then `npm run build` at the repo's root.
|
||||
* The output goes to `/dist`.
|
||||
|
||||
#### > See the demo
|
||||
* Build the lib, then run `node dist/demos/window.js`.
|
||||
````shell
|
||||
$ git clone https://github.com/Septh/libwin32.git
|
||||
$ cd libwin32
|
||||
$ npm install
|
||||
$ npm run build
|
||||
````
|
||||
|
||||
The output goes to `/dist` for the library, and `/demos` for the demos.
|
||||
|
||||
#### > See the demos
|
||||
Build the lib, then:
|
||||
|
||||
* Without bundling:
|
||||
````shell
|
||||
$ node dist/demos/window.js
|
||||
$ node dist/demos/messagebox.js
|
||||
````
|
||||
|
||||
With bundling:
|
||||
* Build the lib, then:
|
||||
````shell
|
||||
$ npm run build:demos
|
||||
$ node demos/window/window.js
|
||||
$ node demos/messagebox/messagebox.js
|
||||
````
|
||||
|
||||
### Directories
|
||||
* `./source/win32`:
|
||||
* The main bindings source files.
|
||||
* `./source/demos`:
|
||||
* Some usage examples. (*only one at the time, more to come later*)
|
||||
* Some usage examples. (*only two at the time, more to come later*)
|
||||
* `./source/rollup`:
|
||||
* A [Rollup](https://rollup.org) plugin to ease the process of bundling this library with your code. This targets the *consumers* of the library, not the library itself. (*more info to come*).
|
||||
* `./source/stubs`:
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "libwin32",
|
||||
"version": "0.1.0",
|
||||
"version": "0.0.1",
|
||||
"description": "Node bindings to native Win32 DLLs through Koffi",
|
||||
"author": "Stephan 'Septh' Schreiber <septh@sfr.fr>",
|
||||
"license": "MIT",
|
||||
@@ -23,7 +23,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build:demos": "rollup -c source/demos/rollup.config.js",
|
||||
"build:demos": "rollup -c",
|
||||
"clean": "rimraf .tsbuildinfo dist"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* This config only bundles the demos. The library itself is published unbundled.
|
||||
*/
|
||||
// @ts-check
|
||||
import path from 'node:path'
|
||||
import { defineConfig } from 'rollup'
|
||||
@@ -7,12 +10,13 @@ import commonjs from '@rollup/plugin-commonjs'
|
||||
import typescript from '@rollup/plugin-typescript'
|
||||
import { koffi } from 'libwin32/rollup-plugin'
|
||||
|
||||
// Use distinct configs to prevent Rollup from code-splitting the library.
|
||||
export default [
|
||||
config('window'),
|
||||
config('messagebox')
|
||||
]
|
||||
|
||||
/** @param {string} which */
|
||||
/** @param { 'window' | 'messagebox' } which */
|
||||
function config(which) {
|
||||
const outDir = path.join('demos', which)
|
||||
return defineConfig({
|
||||
@@ -25,8 +29,7 @@ function config(which) {
|
||||
symbols: false
|
||||
},
|
||||
assetFileNames: 'assets/[name].[ext]',
|
||||
sourcemap: true,
|
||||
manualChunks: {}
|
||||
sourcemap: true
|
||||
},
|
||||
treeshake: {
|
||||
preset: 'smallest',
|
||||
Reference in New Issue
Block a user