koffi 3.0.1 → 3.0.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Fast and easy-to-use dynamic C FFI (foreign function interface) for Node.js",
5
5
  "keywords": [
6
6
  "foreign",
@@ -33,20 +33,20 @@
33
33
  },
34
34
  "funding": "https://liberapay.com/Koromix",
35
35
  "optionalDependencies": {
36
- "@koromix/koffi-linux-arm64": "3.0.1",
37
- "@koromix/koffi-linux-ia32": "3.0.1",
38
- "@koromix/koffi-linux-x64": "3.0.1",
39
- "@koromix/koffi-linux-riscv64": "3.0.1",
40
- "@koromix/koffi-freebsd-ia32": "3.0.1",
41
- "@koromix/koffi-freebsd-x64": "3.0.1",
42
- "@koromix/koffi-freebsd-arm64": "3.0.1",
43
- "@koromix/koffi-openbsd-ia32": "3.0.1",
44
- "@koromix/koffi-openbsd-x64": "3.0.1",
45
- "@koromix/koffi-win32-ia32": "3.0.1",
46
- "@koromix/koffi-win32-x64": "3.0.1",
47
- "@koromix/koffi-darwin-x64": "3.0.1",
48
- "@koromix/koffi-darwin-arm64": "3.0.1",
49
- "@koromix/koffi-linux-loong64": "3.0.1"
36
+ "@koromix/koffi-linux-arm64": "3.0.2",
37
+ "@koromix/koffi-linux-ia32": "3.0.2",
38
+ "@koromix/koffi-linux-x64": "3.0.2",
39
+ "@koromix/koffi-linux-riscv64": "3.0.2",
40
+ "@koromix/koffi-freebsd-ia32": "3.0.2",
41
+ "@koromix/koffi-freebsd-x64": "3.0.2",
42
+ "@koromix/koffi-freebsd-arm64": "3.0.2",
43
+ "@koromix/koffi-openbsd-ia32": "3.0.2",
44
+ "@koromix/koffi-openbsd-x64": "3.0.2",
45
+ "@koromix/koffi-win32-ia32": "3.0.2",
46
+ "@koromix/koffi-win32-x64": "3.0.2",
47
+ "@koromix/koffi-darwin-x64": "3.0.2",
48
+ "@koromix/koffi-darwin-arm64": "3.0.2",
49
+ "@koromix/koffi-linux-loong64": "3.0.2"
50
50
  },
51
51
  "type": "module",
52
52
  "main": "./index.cjs",
@@ -60,7 +60,7 @@
60
60
  "./indirect": {
61
61
  "import": "./indirect.js",
62
62
  "require": "./indirect.cjs",
63
- "types": "./indirect.d.ts"
63
+ "types": "./index.d.ts"
64
64
  }
65
65
  },
66
66
  "types": "./index.d.ts"
@@ -67,6 +67,7 @@ set(KOFFI_SRC
67
67
  src/call.cc
68
68
  src/ffi.cc
69
69
  src/parser.cc
70
+ src/type.cc
70
71
  src/util.cc
71
72
  src/uv.cc
72
73
  src/win32.cc
@@ -7,9 +7,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __esm = (fn, res) => function __init() {
8
8
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
9
  };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
10
  var __export = (target, all) => {
14
11
  for (var name in all)
15
12
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -32,7 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
29
  ));
33
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
31
 
35
- // ../cnoke/src/abi.js
32
+ // src/cnoke/src/abi.js
36
33
  function determineAbi() {
37
34
  let abi = process.arch.toString();
38
35
  if (abi == "riscv32" || abi == "riscv64") {
@@ -122,20 +119,20 @@ function decodeElfHeader(buf) {
122
119
  }
123
120
  var import_node_fs;
124
121
  var init_abi = __esm({
125
- "../cnoke/src/abi.js"() {
122
+ "src/cnoke/src/abi.js"() {
126
123
  import_node_fs = __toESM(require("node:fs"), 1);
127
124
  }
128
125
  });
129
126
 
130
- // package.json
127
+ // src/koffi/package.json
131
128
  var package_default;
132
129
  var init_package = __esm({
133
- "package.json"() {
134
- package_default = { name: "koffi", version: "3.0.1", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
130
+ "src/koffi/package.json"() {
131
+ package_default = { name: "koffi", version: "3.0.2", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
135
132
  }
136
133
  });
137
134
 
138
- // src/init.js
135
+ // src/koffi/src/init.js
139
136
  var init_exports = {};
140
137
  __export(init_exports, {
141
138
  detectPlatform: () => detectPlatform,
@@ -154,13 +151,20 @@ function detectPlatform() {
154
151
  triplets2.push(`musl_${abi}`);
155
152
  return [package_default.version, pkg2, triplets2];
156
153
  }
157
- function loadDynamic(root, pkg2, triplets2) {
154
+ function loadDynamic(dirname, pkg2, triplets2) {
155
+ let suffix = "/../../build/koffi";
156
+ let root = dirname + suffix;
158
157
  let roots = [root];
159
158
  let native2 = null;
160
159
  let err = null;
161
160
  if (process["resourcesPath"] != null) {
162
- roots.push(process["resourcesPath"]);
163
- roots.push(process["resourcesPath"] + "/node_modules/koffi");
161
+ let suffixes = [
162
+ "/koffi",
163
+ "/koffi/build",
164
+ "/node_modules/koffi/build"
165
+ ];
166
+ for (let suffix2 of suffixes)
167
+ roots.push(process["resourcesPath"] + suffix2);
164
168
  }
165
169
  let names = [
166
170
  `${__dirname}/../../../@koromix/koffi-${pkg2}`,
@@ -170,19 +174,21 @@ function loadDynamic(root, pkg2, triplets2) {
170
174
  if (!import_node_fs2.default.existsSync(name))
171
175
  continue;
172
176
  try {
173
- native2 = requireNative(name);
177
+ native2 = require2(name);
174
178
  break;
175
179
  } catch (e) {
176
180
  err ??= e;
177
181
  }
178
182
  }
179
- if (native2 == null) {
180
- err ??= new Error("Cannot find the native Koffi module; did you bundle it correctly?");
183
+ if (native2 == null && err != null)
181
184
  throw err;
182
- }
183
185
  return native2;
184
186
  }
185
- function wrapNative(native2) {
187
+ function wrapNative(native2, version2) {
188
+ if (native2 == null)
189
+ throw new Error("Cannot find the native Koffi module; did you bundle it correctly?");
190
+ if (native2.version != version2)
191
+ throw new Error("Mismatched native Koffi modules");
186
192
  let load = native2.load;
187
193
  let register = native2.register;
188
194
  let introspect = native2.introspect ?? native2.type;
@@ -220,116 +226,24 @@ function wrapNative(native2) {
220
226
  native2.resolve = native2.type;
221
227
  }
222
228
  }
223
- var import_node_util, import_node_fs2, import_node_module, requireNative;
229
+ var import_node_util, import_node_fs2, import_node_module, require2;
224
230
  var init_init = __esm({
225
- "src/init.js"() {
231
+ "src/koffi/src/init.js"() {
226
232
  import_node_util = __toESM(require("node:util"));
227
233
  import_node_fs2 = __toESM(require("node:fs"));
228
234
  import_node_module = require("node:module");
229
235
  init_abi();
230
236
  init_package();
231
- requireNative = (0, import_node_module.createRequire)(__filename);
232
- }
233
- });
234
-
235
- // src/static.js
236
- var require_static = __commonJS({
237
- "src/static.js"(exports2, module2) {
238
- var { createRequire: createRequire2 } = require("node:module");
239
- var requireNative2 = createRequire2(__filename);
240
- var BINARY_ROOT2 = __dirname + "/../../build/koffi";
241
- function loadStatic2(pkg2) {
242
- let native2 = null;
243
- try {
244
- if (pkg2 == "linux-arm64")
245
- native2 = requireNative2("../../../@koromix/koffi-linux-arm64");
246
- } catch (err) {
247
- }
248
- try {
249
- if (pkg2 == "linux-ia32")
250
- native2 = requireNative2("../../../@koromix/koffi-linux-ia32");
251
- } catch (err) {
252
- }
253
- try {
254
- if (pkg2 == "linux-x64")
255
- native2 = requireNative2("../../../@koromix/koffi-linux-x64");
256
- } catch (err) {
257
- }
258
- try {
259
- if (pkg2 == "linux-riscv64")
260
- native2 = requireNative2("../../../@koromix/koffi-linux-riscv64");
261
- } catch (err) {
262
- }
263
- try {
264
- if (pkg2 == "freebsd-ia32")
265
- native2 = requireNative2("../../../@koromix/koffi-freebsd-ia32");
266
- } catch (err) {
267
- }
268
- try {
269
- if (pkg2 == "freebsd-x64")
270
- native2 = requireNative2("../../../@koromix/koffi-freebsd-x64");
271
- } catch (err) {
272
- }
273
- try {
274
- if (pkg2 == "freebsd-arm64")
275
- native2 = requireNative2("../../../@koromix/koffi-freebsd-arm64");
276
- } catch (err) {
277
- }
278
- try {
279
- if (pkg2 == "openbsd-ia32")
280
- native2 = requireNative2("../../../@koromix/koffi-openbsd-ia32");
281
- } catch (err) {
282
- }
283
- try {
284
- if (pkg2 == "openbsd-x64")
285
- native2 = requireNative2("../../../@koromix/koffi-openbsd-x64");
286
- } catch (err) {
287
- }
288
- try {
289
- if (pkg2 == "win32-ia32")
290
- native2 = requireNative2("../../../@koromix/koffi-win32-ia32");
291
- } catch (err) {
292
- }
293
- try {
294
- if (pkg2 == "win32-x64")
295
- native2 = requireNative2("../../../@koromix/koffi-win32-x64");
296
- } catch (err) {
297
- }
298
- try {
299
- if (pkg2 == "darwin-x64")
300
- native2 = requireNative2("../../../@koromix/koffi-darwin-x64");
301
- } catch (err) {
302
- }
303
- try {
304
- if (pkg2 == "darwin-arm64")
305
- native2 = requireNative2("../../../@koromix/koffi-darwin-arm64");
306
- } catch (err) {
307
- }
308
- try {
309
- if (pkg2 == "linux-loong64")
310
- native2 = requireNative2("../../../@koromix/koffi-linux-loong64");
311
- } catch (err) {
312
- }
313
- return native2;
314
- }
315
- module2.exports = {
316
- BINARY_ROOT: BINARY_ROOT2,
317
- loadStatic: loadStatic2
318
- };
237
+ require2 = (0, import_node_module.createRequire)(__filename);
319
238
  }
320
239
  });
321
240
 
322
- // index.cjs
241
+ // src/koffi/index.cjs
323
242
  var { detectPlatform: detectPlatform2, loadDynamic: loadDynamic2, wrapNative: wrapNative2 } = (init_init(), __toCommonJS(init_exports));
324
- var { BINARY_ROOT, loadStatic } = require_static();
243
+ var { loadStatic } = require("./src/static.cjs");
325
244
  var [version, pkg, triplets] = detectPlatform2();
326
- var native = null;
327
- STATIC: native = loadStatic(pkg);
328
- if (native == null)
329
- native = loadDynamic2(BINARY_ROOT, pkg, triplets);
330
- if (native.version != version)
331
- throw new Error("Mismatched native Koffi modules");
332
- wrapNative2(native);
245
+ var native = loadStatic(pkg) ?? loadDynamic2(__dirname, pkg, triplets);
246
+ wrapNative2(native, version);
333
247
  module.exports = {
334
248
  default: native,
335
249
  "LibraryHandle": native["LibraryHandle"],
@@ -1,9 +1,9 @@
1
- // src/init.js
1
+ // src/koffi/src/init.js
2
2
  import util from "node:util";
3
3
  import fs2 from "node:fs";
4
4
  import { createRequire } from "node:module";
5
5
 
6
- // ../cnoke/src/abi.js
6
+ // src/cnoke/src/abi.js
7
7
  import fs from "node:fs";
8
8
  function determineAbi() {
9
9
  let abi = process.arch.toString();
@@ -93,11 +93,11 @@ function decodeElfHeader(buf) {
93
93
  return header;
94
94
  }
95
95
 
96
- // package.json
97
- var package_default = { name: "koffi", version: "3.0.1", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
96
+ // src/koffi/package.json
97
+ var package_default = { name: "koffi", version: "3.0.2", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
98
98
 
99
- // src/init.js
100
- var requireNative = createRequire(import.meta.url);
99
+ // src/koffi/src/init.js
100
+ var require2 = createRequire(import.meta.url);
101
101
  function detectPlatform() {
102
102
  if (process.versions.napi == null || process.versions.napi < package_default.cnoke.napi) {
103
103
  let major = parseInt(process.versions.node, 10);
@@ -110,13 +110,20 @@ function detectPlatform() {
110
110
  triplets2.push(`musl_${abi}`);
111
111
  return [package_default.version, pkg2, triplets2];
112
112
  }
113
- function loadDynamic(root, pkg2, triplets2) {
113
+ function loadDynamic(dirname, pkg2, triplets2) {
114
+ let suffix = "/../../build/koffi";
115
+ let root = dirname + suffix;
114
116
  let roots = [root];
115
117
  let native2 = null;
116
118
  let err = null;
117
119
  if (process["resourcesPath"] != null) {
118
- roots.push(process["resourcesPath"]);
119
- roots.push(process["resourcesPath"] + "/node_modules/koffi");
120
+ let suffixes = [
121
+ "/koffi",
122
+ "/koffi/build",
123
+ "/node_modules/koffi/build"
124
+ ];
125
+ for (let suffix2 of suffixes)
126
+ roots.push(process["resourcesPath"] + suffix2);
120
127
  }
121
128
  let names = [
122
129
  `${import.meta.dirname}/../../../@koromix/koffi-${pkg2}`,
@@ -126,19 +133,21 @@ function loadDynamic(root, pkg2, triplets2) {
126
133
  if (!fs2.existsSync(name))
127
134
  continue;
128
135
  try {
129
- native2 = requireNative(name);
136
+ native2 = require2(name);
130
137
  break;
131
138
  } catch (e) {
132
139
  err ??= e;
133
140
  }
134
141
  }
135
- if (native2 == null) {
136
- err ??= new Error("Cannot find the native Koffi module; did you bundle it correctly?");
142
+ if (native2 == null && err != null)
137
143
  throw err;
138
- }
139
144
  return native2;
140
145
  }
141
- function wrapNative(native2) {
146
+ function wrapNative(native2, version2) {
147
+ if (native2 == null)
148
+ throw new Error("Cannot find the native Koffi module; did you bundle it correctly?");
149
+ if (native2.version != version2)
150
+ throw new Error("Mismatched native Koffi modules");
142
151
  let load = native2.load;
143
152
  let register = native2.register;
144
153
  let introspect = native2.introspect ?? native2.type;
@@ -177,94 +186,11 @@ function wrapNative(native2) {
177
186
  }
178
187
  }
179
188
 
180
- // src/static.js
181
- import { createRequire as createRequire2 } from "node:module";
182
- var requireNative2 = createRequire2(import.meta.url);
183
- var BINARY_ROOT = import.meta.dirname + "/../../build/koffi";
184
- function loadStatic(pkg2) {
185
- let native2 = null;
186
- try {
187
- if (pkg2 == "linux-arm64")
188
- native2 = requireNative2("../../../@koromix/koffi-linux-arm64");
189
- } catch (err) {
190
- }
191
- try {
192
- if (pkg2 == "linux-ia32")
193
- native2 = requireNative2("../../../@koromix/koffi-linux-ia32");
194
- } catch (err) {
195
- }
196
- try {
197
- if (pkg2 == "linux-x64")
198
- native2 = requireNative2("../../../@koromix/koffi-linux-x64");
199
- } catch (err) {
200
- }
201
- try {
202
- if (pkg2 == "linux-riscv64")
203
- native2 = requireNative2("../../../@koromix/koffi-linux-riscv64");
204
- } catch (err) {
205
- }
206
- try {
207
- if (pkg2 == "freebsd-ia32")
208
- native2 = requireNative2("../../../@koromix/koffi-freebsd-ia32");
209
- } catch (err) {
210
- }
211
- try {
212
- if (pkg2 == "freebsd-x64")
213
- native2 = requireNative2("../../../@koromix/koffi-freebsd-x64");
214
- } catch (err) {
215
- }
216
- try {
217
- if (pkg2 == "freebsd-arm64")
218
- native2 = requireNative2("../../../@koromix/koffi-freebsd-arm64");
219
- } catch (err) {
220
- }
221
- try {
222
- if (pkg2 == "openbsd-ia32")
223
- native2 = requireNative2("../../../@koromix/koffi-openbsd-ia32");
224
- } catch (err) {
225
- }
226
- try {
227
- if (pkg2 == "openbsd-x64")
228
- native2 = requireNative2("../../../@koromix/koffi-openbsd-x64");
229
- } catch (err) {
230
- }
231
- try {
232
- if (pkg2 == "win32-ia32")
233
- native2 = requireNative2("../../../@koromix/koffi-win32-ia32");
234
- } catch (err) {
235
- }
236
- try {
237
- if (pkg2 == "win32-x64")
238
- native2 = requireNative2("../../../@koromix/koffi-win32-x64");
239
- } catch (err) {
240
- }
241
- try {
242
- if (pkg2 == "darwin-x64")
243
- native2 = requireNative2("../../../@koromix/koffi-darwin-x64");
244
- } catch (err) {
245
- }
246
- try {
247
- if (pkg2 == "darwin-arm64")
248
- native2 = requireNative2("../../../@koromix/koffi-darwin-arm64");
249
- } catch (err) {
250
- }
251
- try {
252
- if (pkg2 == "linux-loong64")
253
- native2 = requireNative2("../../../@koromix/koffi-linux-loong64");
254
- } catch (err) {
255
- }
256
- return native2;
257
- }
258
-
259
- // index.js
189
+ // src/koffi/index.js
190
+ import { loadStatic } from "./src/static.js";
260
191
  var [version, pkg, triplets] = detectPlatform();
261
- var native = null;
262
- STATIC: native = loadStatic(pkg);
263
- if (native == null)
264
- native = loadDynamic(BINARY_ROOT, pkg, triplets);
265
- if (native.version != version)
266
- throw new Error("Mismatched native Koffi modules");
267
- wrapNative(native);
192
+ var native = loadStatic(pkg) ?? loadDynamic(import.meta.dirname, pkg, triplets);
193
+ wrapNative(native, version);
268
194
  var mod_LibraryHandle = native.LibraryHandle;
269
195
  var mod_TypeObject = native.TypeObject;
270
196
  var mod_Union = native.Union;
@@ -7,9 +7,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __esm = (fn, res) => function __init() {
8
8
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
9
  };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
10
  var __export = (target, all) => {
14
11
  for (var name in all)
15
12
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -32,7 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
29
  ));
33
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
31
 
35
- // ../cnoke/src/abi.js
32
+ // src/cnoke/src/abi.js
36
33
  function determineAbi() {
37
34
  let abi = process.arch.toString();
38
35
  if (abi == "riscv32" || abi == "riscv64") {
@@ -122,20 +119,20 @@ function decodeElfHeader(buf) {
122
119
  }
123
120
  var import_node_fs;
124
121
  var init_abi = __esm({
125
- "../cnoke/src/abi.js"() {
122
+ "src/cnoke/src/abi.js"() {
126
123
  import_node_fs = __toESM(require("node:fs"), 1);
127
124
  }
128
125
  });
129
126
 
130
- // package.json
127
+ // src/koffi/package.json
131
128
  var package_default;
132
129
  var init_package = __esm({
133
- "package.json"() {
134
- package_default = { name: "koffi", version: "3.0.1", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
130
+ "src/koffi/package.json"() {
131
+ package_default = { name: "koffi", version: "3.0.2", cnoke: { api: "../../vendor/node-api-headers", output: "../../bin/Koffi/{{ toolchain }}", node: 16, napi: 8 } };
135
132
  }
136
133
  });
137
134
 
138
- // src/init.js
135
+ // src/koffi/src/init.js
139
136
  var init_exports = {};
140
137
  __export(init_exports, {
141
138
  detectPlatform: () => detectPlatform,
@@ -154,13 +151,20 @@ function detectPlatform() {
154
151
  triplets2.push(`musl_${abi}`);
155
152
  return [package_default.version, pkg2, triplets2];
156
153
  }
157
- function loadDynamic(root, pkg2, triplets2) {
154
+ function loadDynamic(dirname, pkg2, triplets2) {
155
+ let suffix = "/../../build/koffi";
156
+ let root = dirname + suffix;
158
157
  let roots = [root];
159
158
  let native2 = null;
160
159
  let err = null;
161
160
  if (process["resourcesPath"] != null) {
162
- roots.push(process["resourcesPath"]);
163
- roots.push(process["resourcesPath"] + "/node_modules/koffi");
161
+ let suffixes = [
162
+ "/koffi",
163
+ "/koffi/build",
164
+ "/node_modules/koffi/build"
165
+ ];
166
+ for (let suffix2 of suffixes)
167
+ roots.push(process["resourcesPath"] + suffix2);
164
168
  }
165
169
  let names = [
166
170
  `${__dirname}/../../../@koromix/koffi-${pkg2}`,
@@ -170,19 +174,21 @@ function loadDynamic(root, pkg2, triplets2) {
170
174
  if (!import_node_fs2.default.existsSync(name))
171
175
  continue;
172
176
  try {
173
- native2 = requireNative(name);
177
+ native2 = require2(name);
174
178
  break;
175
179
  } catch (e) {
176
180
  err ??= e;
177
181
  }
178
182
  }
179
- if (native2 == null) {
180
- err ??= new Error("Cannot find the native Koffi module; did you bundle it correctly?");
183
+ if (native2 == null && err != null)
181
184
  throw err;
182
- }
183
185
  return native2;
184
186
  }
185
- function wrapNative(native2) {
187
+ function wrapNative(native2, version2) {
188
+ if (native2 == null)
189
+ throw new Error("Cannot find the native Koffi module; did you bundle it correctly?");
190
+ if (native2.version != version2)
191
+ throw new Error("Mismatched native Koffi modules");
186
192
  let load = native2.load;
187
193
  let register = native2.register;
188
194
  let introspect = native2.introspect ?? native2.type;
@@ -220,115 +226,23 @@ function wrapNative(native2) {
220
226
  native2.resolve = native2.type;
221
227
  }
222
228
  }
223
- var import_node_util, import_node_fs2, import_node_module, requireNative;
229
+ var import_node_util, import_node_fs2, import_node_module, require2;
224
230
  var init_init = __esm({
225
- "src/init.js"() {
231
+ "src/koffi/src/init.js"() {
226
232
  import_node_util = __toESM(require("node:util"));
227
233
  import_node_fs2 = __toESM(require("node:fs"));
228
234
  import_node_module = require("node:module");
229
235
  init_abi();
230
236
  init_package();
231
- requireNative = (0, import_node_module.createRequire)(__filename);
232
- }
233
- });
234
-
235
- // src/static.js
236
- var require_static = __commonJS({
237
- "src/static.js"(exports2, module2) {
238
- var { createRequire: createRequire2 } = require("node:module");
239
- var requireNative2 = createRequire2(__filename);
240
- var BINARY_ROOT2 = __dirname + "/../../build/koffi";
241
- function loadStatic2(pkg2) {
242
- let native2 = null;
243
- try {
244
- if (pkg2 == "linux-arm64")
245
- native2 = requireNative2("../../../@koromix/koffi-linux-arm64");
246
- } catch (err) {
247
- }
248
- try {
249
- if (pkg2 == "linux-ia32")
250
- native2 = requireNative2("../../../@koromix/koffi-linux-ia32");
251
- } catch (err) {
252
- }
253
- try {
254
- if (pkg2 == "linux-x64")
255
- native2 = requireNative2("../../../@koromix/koffi-linux-x64");
256
- } catch (err) {
257
- }
258
- try {
259
- if (pkg2 == "linux-riscv64")
260
- native2 = requireNative2("../../../@koromix/koffi-linux-riscv64");
261
- } catch (err) {
262
- }
263
- try {
264
- if (pkg2 == "freebsd-ia32")
265
- native2 = requireNative2("../../../@koromix/koffi-freebsd-ia32");
266
- } catch (err) {
267
- }
268
- try {
269
- if (pkg2 == "freebsd-x64")
270
- native2 = requireNative2("../../../@koromix/koffi-freebsd-x64");
271
- } catch (err) {
272
- }
273
- try {
274
- if (pkg2 == "freebsd-arm64")
275
- native2 = requireNative2("../../../@koromix/koffi-freebsd-arm64");
276
- } catch (err) {
277
- }
278
- try {
279
- if (pkg2 == "openbsd-ia32")
280
- native2 = requireNative2("../../../@koromix/koffi-openbsd-ia32");
281
- } catch (err) {
282
- }
283
- try {
284
- if (pkg2 == "openbsd-x64")
285
- native2 = requireNative2("../../../@koromix/koffi-openbsd-x64");
286
- } catch (err) {
287
- }
288
- try {
289
- if (pkg2 == "win32-ia32")
290
- native2 = requireNative2("../../../@koromix/koffi-win32-ia32");
291
- } catch (err) {
292
- }
293
- try {
294
- if (pkg2 == "win32-x64")
295
- native2 = requireNative2("../../../@koromix/koffi-win32-x64");
296
- } catch (err) {
297
- }
298
- try {
299
- if (pkg2 == "darwin-x64")
300
- native2 = requireNative2("../../../@koromix/koffi-darwin-x64");
301
- } catch (err) {
302
- }
303
- try {
304
- if (pkg2 == "darwin-arm64")
305
- native2 = requireNative2("../../../@koromix/koffi-darwin-arm64");
306
- } catch (err) {
307
- }
308
- try {
309
- if (pkg2 == "linux-loong64")
310
- native2 = requireNative2("../../../@koromix/koffi-linux-loong64");
311
- } catch (err) {
312
- }
313
- return native2;
314
- }
315
- module2.exports = {
316
- BINARY_ROOT: BINARY_ROOT2,
317
- loadStatic: loadStatic2
318
- };
237
+ require2 = (0, import_node_module.createRequire)(__filename);
319
238
  }
320
239
  });
321
240
 
322
- // index.cjs
241
+ // src/koffi/indirect.cjs
323
242
  var { detectPlatform: detectPlatform2, loadDynamic: loadDynamic2, wrapNative: wrapNative2 } = (init_init(), __toCommonJS(init_exports));
324
- var { BINARY_ROOT, loadStatic } = require_static();
325
243
  var [version, pkg, triplets] = detectPlatform2();
326
- var native = null;
327
- if (native == null)
328
- native = loadDynamic2(BINARY_ROOT, pkg, triplets);
329
- if (native.version != version)
330
- throw new Error("Mismatched native Koffi modules");
331
- wrapNative2(native);
244
+ var native = loadDynamic2(__dirname, pkg, triplets);
245
+ wrapNative2(native, version);
332
246
  module.exports = {
333
247
  default: native,
334
248
  "LibraryHandle": native["LibraryHandle"],