koffi 3.0.0 → 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.
@@ -1,12 +1,12 @@
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
- let abi = process.arch;
9
+ let abi = process.arch.toString();
10
10
  if (abi == "riscv32" || abi == "riscv64") {
11
11
  let buf = readFileHeader(process.execPath, 512);
12
12
  let header = decodeElfHeader(buf);
@@ -93,15 +93,15 @@ function decodeElfHeader(buf) {
93
93
  return header;
94
94
  }
95
95
 
96
- // package.json
97
- var package_default = { name: "koffi", version: "3.0.0", 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);
104
- throw new Error(`This engine is based on Node ${process.versions.node}, but ${package_default.name} does not support the Node ${major}.x branch (N-API < ${package_default.cnoke.napi})`);
104
+ throw new Error(`This engine is based on Node ${process.versions.node}, but ${package_default.name} does not support the Node ${major}.x branch (Node-API < ${package_default.cnoke.napi})`);
105
105
  }
106
106
  let abi = determineAbi();
107
107
  let pkg2 = `${process.platform}-${process.arch}`;
@@ -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
- if (process.resourcesPath != null) {
118
- roots.push(process.resourcesPath);
119
- roots.push(process.resourcesPath + "/node_modules/koffi");
119
+ if (process["resourcesPath"] != null) {
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,42 +133,43 @@ 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
- native2.sizeof = (spec) => native2.type(spec).size;
145
- native2.alignof = (spec) => native2.type(spec).alignment;
153
+ let introspect = native2.introspect ?? native2.type;
154
+ native2.sizeof = (spec) => introspect(spec).size;
155
+ native2.alignof = (spec) => introspect(spec).alignment;
146
156
  native2.offsetof = (spec, name) => {
147
- let type = native2.type(spec);
148
- if (type.primitive != "Record")
157
+ let info = introspect(spec);
158
+ if (info.primitive != "Record")
149
159
  throw new TypeError("The offsetof() function can only be used with record types");
150
- let member = type.members[name];
160
+ let member = info.members[name];
151
161
  if (member == null)
152
- throw new Error(`Record type ${type.name} does not have member '${name}'`);
162
+ throw new Error(`Record type ${info.name} does not have member '${name}'`);
153
163
  return member.offset;
154
164
  };
155
165
  native2.register = (...args) => {
156
166
  if (args.length >= 3 && typeof args[1] == "function") {
157
- process.emitWarning("Using koffi.register() with a custom this value was deprecated in Koffi 3.0, use function.bind() instead", "DeprecationWarning", "KOFFI009");
167
+ process.emitWarning("Using koffi.register() with a custom this value was deprecated in Koffi 2.17, use function.bind() instead", "DeprecationWarning", "KOFFI009");
158
168
  args[1] = args[1].bind(args[0]);
159
169
  args = args.slice(1);
160
170
  }
161
171
  return register(...args);
162
172
  };
163
- native2.resolve = util.deprecate(native2.type, "The koffi.resolve() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI007");
164
- native2.introspect = util.deprecate(native2.type, "The koffi.introspect() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI008");
165
173
  native2.load = (...args) => {
166
174
  let lib = load(...args);
167
175
  lib.cdecl = util.deprecate((...args2) => lib.func("__cdecl", ...args2), "The koffi.cdecl() function was deprecated in Koffi 2.7, use koffi.func(...) instead", "KOFFI003");
@@ -170,97 +178,104 @@ function wrapNative(native2) {
170
178
  lib.thiscall = util.deprecate((...args2) => lib.func("__thiscall", ...args2), 'The koffi.thiscall() function was deprecated in Koffi 2.7, use koffi.func("__thiscall", ...) instead', "KOFFI006");
171
179
  return lib;
172
180
  };
173
- }
174
-
175
- // src/static.js
176
- import { createRequire as createRequire2 } from "node:module";
177
- var requireNative2 = createRequire2(import.meta.url);
178
- var BINARY_ROOT = import.meta.dirname + "/../../build/koffi";
179
- function loadStatic(pkg2) {
180
- let native2 = null;
181
- try {
182
- if (pkg2 == "linux-arm64")
183
- native2 = requireNative2("../../../@koromix/koffi-linux-arm64");
184
- } catch (err) {
185
- }
186
- try {
187
- if (pkg2 == "linux-ia32")
188
- native2 = requireNative2("../../../@koromix/koffi-linux-ia32");
189
- } catch (err) {
190
- }
191
- try {
192
- if (pkg2 == "linux-x64")
193
- native2 = requireNative2("../../../@koromix/koffi-linux-x64");
194
- } catch (err) {
195
- }
196
- try {
197
- if (pkg2 == "linux-riscv64")
198
- native2 = requireNative2("../../../@koromix/koffi-linux-riscv64");
199
- } catch (err) {
200
- }
201
- try {
202
- if (pkg2 == "freebsd-ia32")
203
- native2 = requireNative2("../../../@koromix/koffi-freebsd-ia32");
204
- } catch (err) {
205
- }
206
- try {
207
- if (pkg2 == "freebsd-x64")
208
- native2 = requireNative2("../../../@koromix/koffi-freebsd-x64");
209
- } catch (err) {
210
- }
211
- try {
212
- if (pkg2 == "freebsd-arm64")
213
- native2 = requireNative2("../../../@koromix/koffi-freebsd-arm64");
214
- } catch (err) {
215
- }
216
- try {
217
- if (pkg2 == "openbsd-ia32")
218
- native2 = requireNative2("../../../@koromix/koffi-openbsd-ia32");
219
- } catch (err) {
220
- }
221
- try {
222
- if (pkg2 == "openbsd-x64")
223
- native2 = requireNative2("../../../@koromix/koffi-openbsd-x64");
224
- } catch (err) {
225
- }
226
- try {
227
- if (pkg2 == "win32-ia32")
228
- native2 = requireNative2("../../../@koromix/koffi-win32-ia32");
229
- } catch (err) {
230
- }
231
- try {
232
- if (pkg2 == "win32-x64")
233
- native2 = requireNative2("../../../@koromix/koffi-win32-x64");
234
- } catch (err) {
235
- }
236
- try {
237
- if (pkg2 == "darwin-x64")
238
- native2 = requireNative2("../../../@koromix/koffi-darwin-x64");
239
- } catch (err) {
240
- }
241
- try {
242
- if (pkg2 == "darwin-arm64")
243
- native2 = requireNative2("../../../@koromix/koffi-darwin-arm64");
244
- } catch (err) {
245
- }
246
- try {
247
- if (pkg2 == "linux-loong64")
248
- native2 = requireNative2("../../../@koromix/koffi-linux-loong64");
249
- } catch (err) {
181
+ if (native2.introspect == null) {
182
+ native2.resolve = util.deprecate(native2.type, "The koffi.resolve() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI007");
183
+ native2.introspect = util.deprecate(native2.type, "The koffi.introspect() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI008");
184
+ } else {
185
+ native2.resolve = native2.type;
250
186
  }
251
- return native2;
252
187
  }
253
188
 
254
- // index.js
189
+ // src/koffi/index.js
190
+ import { loadStatic } from "./src/static.js";
255
191
  var [version, pkg, triplets] = detectPlatform();
256
- var native = null;
257
- STATIC: native = loadStatic(pkg);
258
- if (native == null)
259
- native = loadDynamic(BINARY_ROOT, pkg, triplets);
260
- if (native.version != version)
261
- throw new Error("Mismatched native Koffi modules");
262
- wrapNative(native);
192
+ var native = loadStatic(pkg) ?? loadDynamic(import.meta.dirname, pkg, triplets);
193
+ wrapNative(native, version);
194
+ var mod_LibraryHandle = native.LibraryHandle;
195
+ var mod_TypeObject = native.TypeObject;
196
+ var mod_Union = native.Union;
197
+ var mod_address = native.address;
198
+ var mod_alias = native.alias;
199
+ var mod_alignof = native.alignof;
200
+ var mod_alloc = native.alloc;
201
+ var mod_array = native.array;
202
+ var mod_as = native.as;
203
+ var mod_call = native.call;
204
+ var mod_config = native.config;
205
+ var mod_decode = native.decode;
206
+ var mod_disposable = native.disposable;
207
+ var mod_encode = native.encode;
208
+ var mod_enumeration = native.enumeration;
209
+ var mod_errno = native.errno;
210
+ var mod_extension = native.extension;
211
+ var mod_free = native.free;
212
+ var mod_in = native.in;
213
+ var mod_inout = native.inout;
214
+ var mod_introspect = native.introspect;
215
+ var mod_load = native.load;
216
+ var mod_node = native.node;
217
+ var mod_offsetof = native.offsetof;
218
+ var mod_opaque = native.opaque;
219
+ var mod_os = native.os;
220
+ var mod_out = native.out;
221
+ var mod_pack = native.pack;
222
+ var mod_pointer = native.pointer;
223
+ var mod_proto = native.proto;
224
+ var mod_register = native.register;
225
+ var mod_reset = native.reset;
226
+ var mod_resolve = native.resolve;
227
+ var mod_sizeof = native.sizeof;
228
+ var mod_stats = native.stats;
229
+ var mod_struct = native.struct;
230
+ var mod_type = native.type;
231
+ var mod_types = native.types;
232
+ var mod_union = native.union;
233
+ var mod_unregister = native.unregister;
234
+ var mod_version = native.version;
235
+ var mod_view = native.view;
263
236
  var index_default = native;
264
237
  export {
265
- index_default as default
238
+ mod_LibraryHandle as LibraryHandle,
239
+ mod_TypeObject as TypeObject,
240
+ mod_Union as Union,
241
+ mod_address as address,
242
+ mod_alias as alias,
243
+ mod_alignof as alignof,
244
+ mod_alloc as alloc,
245
+ mod_array as array,
246
+ mod_as as as,
247
+ mod_call as call,
248
+ mod_config as config,
249
+ mod_decode as decode,
250
+ index_default as default,
251
+ mod_disposable as disposable,
252
+ mod_encode as encode,
253
+ mod_enumeration as enumeration,
254
+ mod_errno as errno,
255
+ mod_extension as extension,
256
+ mod_free as free,
257
+ mod_in as in,
258
+ mod_inout as inout,
259
+ mod_introspect as introspect,
260
+ mod_load as load,
261
+ mod_node as node,
262
+ mod_offsetof as offsetof,
263
+ mod_opaque as opaque,
264
+ mod_os as os,
265
+ mod_out as out,
266
+ mod_pack as pack,
267
+ mod_pointer as pointer,
268
+ mod_proto as proto,
269
+ mod_register as register,
270
+ mod_reset as reset,
271
+ mod_resolve as resolve,
272
+ mod_sizeof as sizeof,
273
+ mod_stats as stats,
274
+ mod_struct as struct,
275
+ mod_type as type,
276
+ mod_types as types,
277
+ mod_union as union,
278
+ mod_unregister as unregister,
279
+ mod_version as version,
280
+ mod_view as view
266
281
  };
@@ -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,9 +29,9 @@ 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
- let abi = process.arch;
34
+ let abi = process.arch.toString();
38
35
  if (abi == "riscv32" || abi == "riscv64") {
39
36
  let buf = readFileHeader(process.execPath, 512);
40
37
  let header = decodeElfHeader(buf);
@@ -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.0", 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,
@@ -145,7 +142,7 @@ __export(init_exports, {
145
142
  function detectPlatform() {
146
143
  if (process.versions.napi == null || process.versions.napi < package_default.cnoke.napi) {
147
144
  let major = parseInt(process.versions.node, 10);
148
- throw new Error(`This engine is based on Node ${process.versions.node}, but ${package_default.name} does not support the Node ${major}.x branch (N-API < ${package_default.cnoke.napi})`);
145
+ throw new Error(`This engine is based on Node ${process.versions.node}, but ${package_default.name} does not support the Node ${major}.x branch (Node-API < ${package_default.cnoke.napi})`);
149
146
  }
150
147
  let abi = determineAbi();
151
148
  let pkg2 = `${process.platform}-${process.arch}`;
@@ -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
- if (process.resourcesPath != null) {
162
- roots.push(process.resourcesPath);
163
- roots.push(process.resourcesPath + "/node_modules/koffi");
160
+ if (process["resourcesPath"] != null) {
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,42 +174,43 @@ 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
- native2.sizeof = (spec) => native2.type(spec).size;
189
- native2.alignof = (spec) => native2.type(spec).alignment;
194
+ let introspect = native2.introspect ?? native2.type;
195
+ native2.sizeof = (spec) => introspect(spec).size;
196
+ native2.alignof = (spec) => introspect(spec).alignment;
190
197
  native2.offsetof = (spec, name) => {
191
- let type = native2.type(spec);
192
- if (type.primitive != "Record")
198
+ let info = introspect(spec);
199
+ if (info.primitive != "Record")
193
200
  throw new TypeError("The offsetof() function can only be used with record types");
194
- let member = type.members[name];
201
+ let member = info.members[name];
195
202
  if (member == null)
196
- throw new Error(`Record type ${type.name} does not have member '${name}'`);
203
+ throw new Error(`Record type ${info.name} does not have member '${name}'`);
197
204
  return member.offset;
198
205
  };
199
206
  native2.register = (...args) => {
200
207
  if (args.length >= 3 && typeof args[1] == "function") {
201
- process.emitWarning("Using koffi.register() with a custom this value was deprecated in Koffi 3.0, use function.bind() instead", "DeprecationWarning", "KOFFI009");
208
+ process.emitWarning("Using koffi.register() with a custom this value was deprecated in Koffi 2.17, use function.bind() instead", "DeprecationWarning", "KOFFI009");
202
209
  args[1] = args[1].bind(args[0]);
203
210
  args = args.slice(1);
204
211
  }
205
212
  return register(...args);
206
213
  };
207
- native2.resolve = import_node_util.default.deprecate(native2.type, "The koffi.resolve() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI007");
208
- native2.introspect = import_node_util.default.deprecate(native2.type, "The koffi.introspect() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI008");
209
214
  native2.load = (...args) => {
210
215
  let lib = load(...args);
211
216
  lib.cdecl = import_node_util.default.deprecate((...args2) => lib.func("__cdecl", ...args2), "The koffi.cdecl() function was deprecated in Koffi 2.7, use koffi.func(...) instead", "KOFFI003");
@@ -214,114 +219,72 @@ function wrapNative(native2) {
214
219
  lib.thiscall = import_node_util.default.deprecate((...args2) => lib.func("__thiscall", ...args2), 'The koffi.thiscall() function was deprecated in Koffi 2.7, use koffi.func("__thiscall", ...) instead', "KOFFI006");
215
220
  return lib;
216
221
  };
222
+ if (native2.introspect == null) {
223
+ native2.resolve = import_node_util.default.deprecate(native2.type, "The koffi.resolve() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI007");
224
+ native2.introspect = import_node_util.default.deprecate(native2.type, "The koffi.introspect() function was deprecated in Koffi 3.0, use koffi.type() instead", "KOFFI008");
225
+ } else {
226
+ native2.resolve = native2.type;
227
+ }
217
228
  }
218
- var import_node_util, import_node_fs2, import_node_module, requireNative;
229
+ var import_node_util, import_node_fs2, import_node_module, require2;
219
230
  var init_init = __esm({
220
- "src/init.js"() {
231
+ "src/koffi/src/init.js"() {
221
232
  import_node_util = __toESM(require("node:util"));
222
233
  import_node_fs2 = __toESM(require("node:fs"));
223
234
  import_node_module = require("node:module");
224
235
  init_abi();
225
236
  init_package();
226
- requireNative = (0, import_node_module.createRequire)(__filename);
227
- }
228
- });
229
-
230
- // src/static.js
231
- var require_static = __commonJS({
232
- "src/static.js"(exports2, module2) {
233
- var { createRequire: createRequire2 } = require("node:module");
234
- var requireNative2 = createRequire2(__filename);
235
- var BINARY_ROOT2 = __dirname + "/../../build/koffi";
236
- function loadStatic2(pkg2) {
237
- let native2 = null;
238
- try {
239
- if (pkg2 == "linux-arm64")
240
- native2 = requireNative2("../../../@koromix/koffi-linux-arm64");
241
- } catch (err) {
242
- }
243
- try {
244
- if (pkg2 == "linux-ia32")
245
- native2 = requireNative2("../../../@koromix/koffi-linux-ia32");
246
- } catch (err) {
247
- }
248
- try {
249
- if (pkg2 == "linux-x64")
250
- native2 = requireNative2("../../../@koromix/koffi-linux-x64");
251
- } catch (err) {
252
- }
253
- try {
254
- if (pkg2 == "linux-riscv64")
255
- native2 = requireNative2("../../../@koromix/koffi-linux-riscv64");
256
- } catch (err) {
257
- }
258
- try {
259
- if (pkg2 == "freebsd-ia32")
260
- native2 = requireNative2("../../../@koromix/koffi-freebsd-ia32");
261
- } catch (err) {
262
- }
263
- try {
264
- if (pkg2 == "freebsd-x64")
265
- native2 = requireNative2("../../../@koromix/koffi-freebsd-x64");
266
- } catch (err) {
267
- }
268
- try {
269
- if (pkg2 == "freebsd-arm64")
270
- native2 = requireNative2("../../../@koromix/koffi-freebsd-arm64");
271
- } catch (err) {
272
- }
273
- try {
274
- if (pkg2 == "openbsd-ia32")
275
- native2 = requireNative2("../../../@koromix/koffi-openbsd-ia32");
276
- } catch (err) {
277
- }
278
- try {
279
- if (pkg2 == "openbsd-x64")
280
- native2 = requireNative2("../../../@koromix/koffi-openbsd-x64");
281
- } catch (err) {
282
- }
283
- try {
284
- if (pkg2 == "win32-ia32")
285
- native2 = requireNative2("../../../@koromix/koffi-win32-ia32");
286
- } catch (err) {
287
- }
288
- try {
289
- if (pkg2 == "win32-x64")
290
- native2 = requireNative2("../../../@koromix/koffi-win32-x64");
291
- } catch (err) {
292
- }
293
- try {
294
- if (pkg2 == "darwin-x64")
295
- native2 = requireNative2("../../../@koromix/koffi-darwin-x64");
296
- } catch (err) {
297
- }
298
- try {
299
- if (pkg2 == "darwin-arm64")
300
- native2 = requireNative2("../../../@koromix/koffi-darwin-arm64");
301
- } catch (err) {
302
- }
303
- try {
304
- if (pkg2 == "linux-loong64")
305
- native2 = requireNative2("../../../@koromix/koffi-linux-loong64");
306
- } catch (err) {
307
- }
308
- return native2;
309
- }
310
- module2.exports = {
311
- BINARY_ROOT: BINARY_ROOT2,
312
- loadStatic: loadStatic2
313
- };
237
+ require2 = (0, import_node_module.createRequire)(__filename);
314
238
  }
315
239
  });
316
240
 
317
- // index.cjs
241
+ // src/koffi/indirect.cjs
318
242
  var { detectPlatform: detectPlatform2, loadDynamic: loadDynamic2, wrapNative: wrapNative2 } = (init_init(), __toCommonJS(init_exports));
319
- var { BINARY_ROOT, loadStatic } = require_static();
320
243
  var [version, pkg, triplets] = detectPlatform2();
321
- var native = null;
322
- if (native == null)
323
- native = loadDynamic2(BINARY_ROOT, pkg, triplets);
324
- if (native.version != version)
325
- throw new Error("Mismatched native Koffi modules");
326
- wrapNative2(native);
327
- module.exports = native;
244
+ var native = loadDynamic2(__dirname, pkg, triplets);
245
+ wrapNative2(native, version);
246
+ module.exports = {
247
+ default: native,
248
+ "LibraryHandle": native["LibraryHandle"],
249
+ "TypeObject": native["TypeObject"],
250
+ "Union": native["Union"],
251
+ "address": native["address"],
252
+ "alias": native["alias"],
253
+ "alignof": native["alignof"],
254
+ "alloc": native["alloc"],
255
+ "array": native["array"],
256
+ "as": native["as"],
257
+ "call": native["call"],
258
+ "config": native["config"],
259
+ "decode": native["decode"],
260
+ "disposable": native["disposable"],
261
+ "encode": native["encode"],
262
+ "enumeration": native["enumeration"],
263
+ "errno": native["errno"],
264
+ "extension": native["extension"],
265
+ "free": native["free"],
266
+ "in": native["in"],
267
+ "inout": native["inout"],
268
+ "introspect": native["introspect"],
269
+ "load": native["load"],
270
+ "node": native["node"],
271
+ "offsetof": native["offsetof"],
272
+ "opaque": native["opaque"],
273
+ "os": native["os"],
274
+ "out": native["out"],
275
+ "pack": native["pack"],
276
+ "pointer": native["pointer"],
277
+ "proto": native["proto"],
278
+ "register": native["register"],
279
+ "reset": native["reset"],
280
+ "resolve": native["resolve"],
281
+ "sizeof": native["sizeof"],
282
+ "stats": native["stats"],
283
+ "struct": native["struct"],
284
+ "type": native["type"],
285
+ "types": native["types"],
286
+ "union": native["union"],
287
+ "unregister": native["unregister"],
288
+ "version": native["version"],
289
+ "view": native["view"]
290
+ };