koffi 2.5.8 → 2.5.10
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/CHANGELOG.md +15 -99
- package/build/{2.5.8 → koffi}/darwin_arm64/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/darwin_x64/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/freebsd_arm64/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/freebsd_ia32/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/freebsd_x64/koffi.node +0 -0
- package/build/koffi/linux_arm32hf/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/linux_arm64/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/linux_ia32/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/linux_riscv64hf64/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/linux_x64/koffi.node +0 -0
- package/build/koffi/openbsd_ia32/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/openbsd_x64/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/win32_arm64/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/win32_ia32/koffi.node +0 -0
- package/build/{2.5.8 → koffi}/win32_x64/koffi.node +0 -0
- package/doc/conf.py +2 -1
- package/doc/index.rst +1 -0
- package/doc/packaging.md +71 -0
- package/doc/start.md +1 -36
- package/package.json +2 -2
- package/src/cnoke/assets/FindCNoke.cmake +16 -0
- package/src/core/libcc/libcc.cc +13 -9
- package/src/core/libcc/libcc.hh +2 -1
- package/src/index.d.ts +4 -0
- package/src/index.js +53 -24
- package/src/koffi/CMakeLists.txt +10 -0
- package/src/koffi/examples/electron-builder/README.md +11 -0
- package/src/koffi/examples/electron-builder/package.json +21 -0
- package/src/koffi/examples/electron-builder/src/app.js +20 -0
- package/src/koffi/examples/electron-builder/src/index.html +143 -0
- package/src/koffi/examples/electron-builder/src/preload.js +5 -0
- package/src/koffi/examples/electron-forge/README.md +25 -0
- package/src/koffi/examples/electron-forge/forge.config.js +43 -0
- package/src/koffi/examples/electron-forge/package.json +37 -0
- package/src/koffi/examples/electron-forge/src/index.css +7 -0
- package/src/koffi/examples/electron-forge/src/index.html +143 -0
- package/src/koffi/examples/electron-forge/src/main.js +52 -0
- package/src/koffi/examples/electron-forge/src/preload.js +5 -0
- package/src/koffi/examples/electron-forge/src/renderer.js +31 -0
- package/src/koffi/examples/electron-forge/webpack.main.config.js +11 -0
- package/src/koffi/examples/electron-forge/webpack.renderer.config.js +13 -0
- package/src/koffi/examples/electron-forge/webpack.rules.js +35 -0
- package/src/koffi/examples/node-esbuild/README.md +19 -0
- package/src/koffi/examples/node-esbuild/index.js +2 -0
- package/src/koffi/examples/node-esbuild/package.json +16 -0
- package/src/koffi/examples/nwjs/README.md +20 -0
- package/src/koffi/examples/nwjs/package.json +11 -0
- package/src/koffi/examples/nwjs/src/index.html +145 -0
- package/src/koffi/examples/nwjs/src/package.json +10 -0
- package/src/koffi/src/ffi.cc +1 -0
- package/build/2.5.8/linux_arm32hf/koffi.node +0 -0
- package/build/2.5.8/openbsd_ia32/koffi.node +0 -0
- /package/build/{2.5.8 → koffi}/win32_arm64/koffi.exp +0 -0
- /package/build/{2.5.8 → koffi}/win32_arm64/koffi.lib +0 -0
- /package/build/{2.5.8 → koffi}/win32_ia32/koffi.exp +0 -0
- /package/build/{2.5.8 → koffi}/win32_ia32/koffi.lib +0 -0
- /package/build/{2.5.8 → koffi}/win32_x64/koffi.exp +0 -0
- /package/build/{2.5.8 → koffi}/win32_x64/koffi.lib +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
/**
|
|
3
|
+
* This is the main entry point for your application, it's the first file
|
|
4
|
+
* that runs in the main process.
|
|
5
|
+
*/
|
|
6
|
+
entry: './src/main.js',
|
|
7
|
+
// Put your normal webpack config below here
|
|
8
|
+
module: {
|
|
9
|
+
rules: require('./webpack.rules'),
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module.exports = [
|
|
2
|
+
// Add support for native node modules
|
|
3
|
+
{
|
|
4
|
+
// We're specifying native_modules in the test because the asset relocator loader generates a
|
|
5
|
+
// "fake" .node file which is really a cjs file.
|
|
6
|
+
test: /native_modules[/\\].+\.node$/,
|
|
7
|
+
use: 'node-loader',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
test: /[/\\]node_modules[/\\].+\.(m?js|node)$/,
|
|
11
|
+
parser: { amd: false },
|
|
12
|
+
use: {
|
|
13
|
+
loader: '@vercel/webpack-asset-relocator-loader',
|
|
14
|
+
options: {
|
|
15
|
+
outputAssetBase: 'native_modules',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
// Put your webpack loader rules in this array. This is where you would put
|
|
20
|
+
// your ts-loader configuration for instance:
|
|
21
|
+
/**
|
|
22
|
+
* Typescript Example:
|
|
23
|
+
*
|
|
24
|
+
* {
|
|
25
|
+
* test: /\.tsx?$/,
|
|
26
|
+
* exclude: /(node_modules|.webpack)/,
|
|
27
|
+
* loaders: [{
|
|
28
|
+
* loader: 'ts-loader',
|
|
29
|
+
* options: {
|
|
30
|
+
* transpileOnly: true
|
|
31
|
+
* }
|
|
32
|
+
* }]
|
|
33
|
+
* }
|
|
34
|
+
*/
|
|
35
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
This is a simple example to bundle a CLI node.js app that uses Koffi, using esbuild.
|
|
2
|
+
|
|
3
|
+
To run the app, execute the following:
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
cd examples/node-esbuild
|
|
7
|
+
npm install
|
|
8
|
+
npm start
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
You can bundle the script and the native modules with the following command
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
cd examples/node-esbuild
|
|
15
|
+
npm install
|
|
16
|
+
npm run bundle
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Internally, this uses the esbuild copy loader to handle the native `.node` modules.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "KoffiConfig",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node index.js",
|
|
8
|
+
"bundle": "esbuild index.js --platform=node --bundle --loader:.node=copy --outdir=dist/"
|
|
9
|
+
},
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"esbuild": "^0.18.17",
|
|
14
|
+
"koffi": "^2.5.9"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
This is a simple example shows:
|
|
2
|
+
|
|
3
|
+
- How to communicate with Koffi from a simple window (NW.js takes care of the annonying parts)
|
|
4
|
+
- How to use [nw-builder](https://nwutils.io/nw-builder/) to package it
|
|
5
|
+
|
|
6
|
+
To run this example, you need to install NW.js (SDK flavor) from https://nwjs.io/
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
cd examples/nwjs/src
|
|
10
|
+
npm install # Install Koffi
|
|
11
|
+
/path/to/nw .
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
You can also use nw-builder to package the app directly:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
cd examples/nwjs
|
|
18
|
+
npm install
|
|
19
|
+
npm run pack
|
|
20
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Koffi Config",
|
|
3
|
+
"author": "Niels Martignène <niels.martignene@protonmail.com>",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"pack": "cd src && npm install && cd .. && nwbuild --glob=false src"
|
|
7
|
+
},
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"nw-builder": "^4.3.3"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Koffi Configuration</title>
|
|
6
|
+
|
|
7
|
+
<style>
|
|
8
|
+
html {
|
|
9
|
+
height: 100%;
|
|
10
|
+
}
|
|
11
|
+
body {
|
|
12
|
+
font-family: 'Open Sans', sans-serif;
|
|
13
|
+
display: flex;
|
|
14
|
+
min-height: calc(100% - 17px);
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
font-size: 14px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#error {
|
|
21
|
+
position: fixed;
|
|
22
|
+
top: 50px;
|
|
23
|
+
left: calc(50% - 200px);
|
|
24
|
+
width: 400px;
|
|
25
|
+
padding: 8px;
|
|
26
|
+
background: #db0a0a;
|
|
27
|
+
color: white;
|
|
28
|
+
box-shadow: 1px 1px rgba(0, 0, 0, 0.5);
|
|
29
|
+
text-align: center;
|
|
30
|
+
}
|
|
31
|
+
#error:empty { display: none; }
|
|
32
|
+
|
|
33
|
+
#config {
|
|
34
|
+
background: #f8f8f8;
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
padding: 1em;
|
|
37
|
+
font-size: 1.2em;
|
|
38
|
+
}
|
|
39
|
+
form {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
gap: 0.5em;
|
|
43
|
+
}
|
|
44
|
+
label {
|
|
45
|
+
display: flex;
|
|
46
|
+
gap: 12px;
|
|
47
|
+
}
|
|
48
|
+
label > span { width: 200px; }
|
|
49
|
+
label > :not(span) { flex: 1; }
|
|
50
|
+
button {
|
|
51
|
+
margin-top: 1em;
|
|
52
|
+
background: white;
|
|
53
|
+
border: white;
|
|
54
|
+
border-radius: 6px;
|
|
55
|
+
padding: 6px;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
}
|
|
58
|
+
button:hover { background: #ededed; }
|
|
59
|
+
</style>
|
|
60
|
+
</head>
|
|
61
|
+
|
|
62
|
+
<body>
|
|
63
|
+
<div id="error"></div>
|
|
64
|
+
<div id="config"></div>
|
|
65
|
+
|
|
66
|
+
<script>
|
|
67
|
+
const koffi = require('koffi');
|
|
68
|
+
|
|
69
|
+
update();
|
|
70
|
+
|
|
71
|
+
function update() {
|
|
72
|
+
let config = koffi.config();
|
|
73
|
+
|
|
74
|
+
let container = document.querySelector('#config');
|
|
75
|
+
let form = document.createElement('form');
|
|
76
|
+
|
|
77
|
+
form.addEventListener('submit', e => { e.preventDefault(); apply(e.target.elements); });
|
|
78
|
+
|
|
79
|
+
for (let key in config) {
|
|
80
|
+
let value = config[key];
|
|
81
|
+
|
|
82
|
+
if (typeof value != 'number')
|
|
83
|
+
continue;
|
|
84
|
+
|
|
85
|
+
let label = document.createElement('label');
|
|
86
|
+
let span = document.createElement('span');
|
|
87
|
+
let input = document.createElement('input');
|
|
88
|
+
|
|
89
|
+
span.textContent = key;
|
|
90
|
+
input.name = key;
|
|
91
|
+
input.type = 'number';
|
|
92
|
+
input.value = config[key];
|
|
93
|
+
|
|
94
|
+
label.appendChild(span);
|
|
95
|
+
label.appendChild(input);
|
|
96
|
+
form.appendChild(label);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let button = document.createElement('button');
|
|
100
|
+
button.textContent = 'Modifier';
|
|
101
|
+
button.type = 'submit';
|
|
102
|
+
|
|
103
|
+
form.appendChild(button);
|
|
104
|
+
|
|
105
|
+
window.requestAnimationFrame(() => {
|
|
106
|
+
container.innerHTML = '';
|
|
107
|
+
container.appendChild(form);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function apply(elements) {
|
|
112
|
+
let config = koffi.config();
|
|
113
|
+
|
|
114
|
+
for (let key in elements) {
|
|
115
|
+
if (!config.hasOwnProperty(key))
|
|
116
|
+
continue;
|
|
117
|
+
|
|
118
|
+
let value = elements[key].valueAsNumber;
|
|
119
|
+
|
|
120
|
+
if (typeof value == 'number')
|
|
121
|
+
config[key] = value;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
koffi.config(config);
|
|
126
|
+
} catch (err) {
|
|
127
|
+
console.error(err);
|
|
128
|
+
flashError(err.message);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
update();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function flashError(msg) {
|
|
135
|
+
let div = document.querySelector('#error');
|
|
136
|
+
|
|
137
|
+
if (flashError.timer != null)
|
|
138
|
+
clearTimeout(flashError.timer);
|
|
139
|
+
flashError.timer = setTimeout(() => { div.textContent = '' }, 4000);
|
|
140
|
+
|
|
141
|
+
div.textContent = msg;
|
|
142
|
+
}
|
|
143
|
+
</script>
|
|
144
|
+
</body>
|
|
145
|
+
</html>
|
package/src/koffi/src/ffi.cc
CHANGED
|
@@ -2168,6 +2168,7 @@ static Napi::Object InitModule(Napi::Env env, Napi::Object exports)
|
|
|
2168
2168
|
exports.Set("types", types);
|
|
2169
2169
|
|
|
2170
2170
|
exports.Set("internal", Napi::Boolean::New(env, false));
|
|
2171
|
+
exports.Set("version", Napi::String::New(env, RG_STRINGIFY(VERSION)));
|
|
2171
2172
|
|
|
2172
2173
|
return exports;
|
|
2173
2174
|
}
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|