@tsukilabs/nil-ffi 0.7.0 → 0.7.1

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/dist/index.js CHANGED
@@ -1,6 +1,16 @@
1
1
  import * as ffi from "node:ffi";
2
2
  import { isNil } from "es-toolkit/predicate";
3
3
  import * as process from "node:process";
4
+ import { ffi_Status } from "@tsukilabs/nil-bindings";
5
+ //#region src/request.ts
6
+ var RequestId = class {
7
+ #current = 0;
8
+ next() {
9
+ if (this.#current >= 4294967295) this.#current = 0;
10
+ return ++this.#current;
11
+ }
12
+ };
13
+ //#endregion
4
14
  //#region src/ptr.ts
5
15
  function allocBuffer(size) {
6
16
  return Buffer.alloc(size ?? pointerSize());
@@ -14,18 +24,6 @@ function pointerSize() {
14
24
  else return 4;
15
25
  }
16
26
  //#endregion
17
- //#region ../bindings/dist/index.js
18
- var ffi_Status = /* @__PURE__ */ function(ffi_Status) {
19
- ffi_Status[ffi_Status["OK"] = 0] = "OK";
20
- ffi_Status[ffi_Status["ERR_NULL_POINTER"] = 1] = "ERR_NULL_POINTER";
21
- ffi_Status[ffi_Status["ERR_NOTHING_TO_POLL"] = 2] = "ERR_NOTHING_TO_POLL";
22
- ffi_Status[ffi_Status["ERR_SERIALIZATION"] = 3] = "ERR_SERIALIZATION";
23
- ffi_Status[ffi_Status["ERR_UNKNOWN"] = 2147483647] = "ERR_UNKNOWN";
24
- return ffi_Status;
25
- }({});
26
- //! Copyright (C) Call of Nil contributors
27
- //! SPDX-License-Identifier: AGPL-3.0-only
28
- //#endregion
29
27
  //#region src/error.ts
30
28
  var FfiError = class FfiError extends Error {
31
29
  constructor(message, options) {
@@ -63,6 +61,7 @@ var Queue = class Queue {
63
61
  constructor(handle) {
64
62
  this.pending = /* @__PURE__ */ new Map();
65
63
  this.disposed = false;
64
+ this.requestId = new RequestId();
66
65
  this.functions = handle.functions;
67
66
  }
68
67
  [Symbol.dispose]() {
@@ -72,18 +71,19 @@ var Queue = class Queue {
72
71
  }
73
72
  request(start) {
74
73
  if (this.disposed) return Promise.reject(new HandleClosedError());
74
+ const requestId = this.requestId.next();
75
75
  return new Promise((resolve, reject) => {
76
- let id;
76
+ this.pending.set(requestId, {
77
+ resolve,
78
+ reject
79
+ });
77
80
  try {
78
- id = start();
81
+ start(requestId);
79
82
  } catch (err) {
83
+ this.pending.delete(requestId);
80
84
  reject(err);
81
85
  return;
82
86
  }
83
- this.pending.set(id, {
84
- resolve,
85
- reject
86
- });
87
87
  this.startPolling();
88
88
  });
89
89
  }
@@ -147,543 +147,544 @@ var definitions = {
147
147
  return: ffi.types.VOID
148
148
  },
149
149
  nil_ffi_version: {
150
- arguments: [],
151
- return: ffi.types.UINT_32
150
+ arguments: [ffi.types.UINT_32],
151
+ return: ffi.types.VOID
152
152
  },
153
153
  nil_client_version: {
154
- arguments: [],
155
- return: ffi.types.UINT_32
154
+ arguments: [ffi.types.UINT_32],
155
+ return: ffi.types.VOID
156
156
  },
157
157
  nil_is_local: {
158
- arguments: [],
159
- return: ffi.types.UINT_32
158
+ arguments: [ffi.types.UINT_32],
159
+ return: ffi.types.VOID
160
160
  },
161
161
  nil_is_ready: {
162
- arguments: [],
163
- return: ffi.types.UINT_32
162
+ arguments: [ffi.types.UINT_32],
163
+ return: ffi.types.VOID
164
164
  },
165
165
  nil_is_remote: {
166
- arguments: [],
167
- return: ffi.types.UINT_32
166
+ arguments: [ffi.types.UINT_32],
167
+ return: ffi.types.VOID
168
168
  },
169
169
  nil_server_addr: {
170
- arguments: [],
171
- return: ffi.types.UINT_32
170
+ arguments: [ffi.types.UINT_32],
171
+ return: ffi.types.VOID
172
172
  },
173
173
  nil_set_user_agent: {
174
- arguments: [ffi.types.POINTER],
175
- return: ffi.types.UINT_32
174
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
175
+ return: ffi.types.VOID
176
176
  },
177
177
  nil_stop_client: {
178
- arguments: [],
179
- return: ffi.types.UINT_32
178
+ arguments: [ffi.types.UINT_32],
179
+ return: ffi.types.VOID
180
180
  },
181
181
  nil_update_client: {
182
- arguments: [ffi.types.POINTER],
183
- return: ffi.types.UINT_32
182
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
183
+ return: ffi.types.VOID
184
184
  },
185
185
  nil_user_agent: {
186
- arguments: [],
187
- return: ffi.types.UINT_32
186
+ arguments: [ffi.types.UINT_32],
187
+ return: ffi.types.VOID
188
188
  },
189
189
  nil_world: {
190
- arguments: [],
191
- return: ffi.types.UINT_32
190
+ arguments: [ffi.types.UINT_32],
191
+ return: ffi.types.VOID
192
192
  },
193
193
  nil_add_academy_recruit_order: {
194
- arguments: [ffi.types.POINTER],
195
- return: ffi.types.UINT_32
194
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
195
+ return: ffi.types.VOID
196
196
  },
197
197
  nil_add_prefecture_build_order: {
198
- arguments: [ffi.types.POINTER],
199
- return: ffi.types.UINT_32
198
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
199
+ return: ffi.types.VOID
200
200
  },
201
201
  nil_add_stable_recruit_order: {
202
- arguments: [ffi.types.POINTER],
203
- return: ffi.types.UINT_32
202
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
203
+ return: ffi.types.VOID
204
204
  },
205
205
  nil_add_workshop_recruit_order: {
206
- arguments: [ffi.types.POINTER],
207
- return: ffi.types.UINT_32
206
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
207
+ return: ffi.types.VOID
208
208
  },
209
209
  nil_authorize: {
210
- arguments: [ffi.types.POINTER],
211
- return: ffi.types.UINT_32
210
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
211
+ return: ffi.types.VOID
212
212
  },
213
213
  nil_cancel_academy_recruit_order: {
214
- arguments: [ffi.types.POINTER],
215
- return: ffi.types.UINT_32
214
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
215
+ return: ffi.types.VOID
216
216
  },
217
217
  nil_cancel_maneuver: {
218
- arguments: [ffi.types.POINTER],
219
- return: ffi.types.UINT_32
218
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
219
+ return: ffi.types.VOID
220
220
  },
221
221
  nil_cancel_prefecture_build_order: {
222
- arguments: [ffi.types.POINTER],
223
- return: ffi.types.UINT_32
222
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
223
+ return: ffi.types.VOID
224
224
  },
225
225
  nil_cancel_stable_recruit_order: {
226
- arguments: [ffi.types.POINTER],
227
- return: ffi.types.UINT_32
226
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
227
+ return: ffi.types.VOID
228
228
  },
229
229
  nil_cancel_workshop_recruit_order: {
230
- arguments: [ffi.types.POINTER],
231
- return: ffi.types.UINT_32
230
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
231
+ return: ffi.types.VOID
232
232
  },
233
233
  nil_cheat_fill_world: {
234
- arguments: [ffi.types.POINTER],
235
- return: ffi.types.UINT_32
234
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
235
+ return: ffi.types.VOID
236
236
  },
237
237
  nil_cheat_get_academy_recruit_queue: {
238
- arguments: [ffi.types.POINTER],
239
- return: ffi.types.UINT_32
238
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
239
+ return: ffi.types.VOID
240
240
  },
241
241
  nil_cheat_get_academy_recruit_queues: {
242
- arguments: [ffi.types.POINTER],
243
- return: ffi.types.UINT_32
242
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
243
+ return: ffi.types.VOID
244
244
  },
245
245
  nil_cheat_get_all_academy_recruit_queues: {
246
- arguments: [ffi.types.POINTER],
247
- return: ffi.types.UINT_32
246
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
247
+ return: ffi.types.VOID
248
248
  },
249
249
  nil_cheat_get_all_prefecture_build_queues: {
250
- arguments: [ffi.types.POINTER],
251
- return: ffi.types.UINT_32
250
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
251
+ return: ffi.types.VOID
252
252
  },
253
253
  nil_cheat_get_all_stable_recruit_queues: {
254
- arguments: [ffi.types.POINTER],
255
- return: ffi.types.UINT_32
254
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
255
+ return: ffi.types.VOID
256
256
  },
257
257
  nil_cheat_get_build_steps: {
258
- arguments: [ffi.types.POINTER],
259
- return: ffi.types.UINT_32
258
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
259
+ return: ffi.types.VOID
260
260
  },
261
261
  nil_cheat_get_cities: {
262
- arguments: [ffi.types.POINTER],
263
- return: ffi.types.UINT_32
262
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
263
+ return: ffi.types.VOID
264
264
  },
265
265
  nil_cheat_get_city: {
266
- arguments: [ffi.types.POINTER],
267
- return: ffi.types.UINT_32
266
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
267
+ return: ffi.types.VOID
268
268
  },
269
269
  nil_cheat_get_ethics: {
270
- arguments: [ffi.types.POINTER],
271
- return: ffi.types.UINT_32
270
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
271
+ return: ffi.types.VOID
272
272
  },
273
273
  nil_cheat_get_idle_armies_at: {
274
- arguments: [ffi.types.POINTER],
275
- return: ffi.types.UINT_32
274
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
275
+ return: ffi.types.VOID
276
276
  },
277
277
  nil_cheat_get_idle_personnel_at: {
278
- arguments: [ffi.types.POINTER],
279
- return: ffi.types.UINT_32
278
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
279
+ return: ffi.types.VOID
280
280
  },
281
281
  nil_cheat_get_infrastructure: {
282
- arguments: [ffi.types.POINTER],
283
- return: ffi.types.UINT_32
282
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
283
+ return: ffi.types.VOID
284
284
  },
285
285
  nil_cheat_get_maneuvers: {
286
- arguments: [ffi.types.POINTER],
287
- return: ffi.types.UINT_32
286
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
287
+ return: ffi.types.VOID
288
288
  },
289
289
  nil_cheat_get_maneuvers_of: {
290
- arguments: [ffi.types.POINTER],
291
- return: ffi.types.UINT_32
290
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
291
+ return: ffi.types.VOID
292
292
  },
293
293
  nil_cheat_get_player: {
294
- arguments: [ffi.types.POINTER],
295
- return: ffi.types.UINT_32
294
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
295
+ return: ffi.types.VOID
296
296
  },
297
297
  nil_cheat_get_players: {
298
- arguments: [ffi.types.POINTER],
299
- return: ffi.types.UINT_32
298
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
299
+ return: ffi.types.VOID
300
300
  },
301
301
  nil_cheat_get_prefecture_build_queue: {
302
- arguments: [ffi.types.POINTER],
303
- return: ffi.types.UINT_32
302
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
303
+ return: ffi.types.VOID
304
304
  },
305
305
  nil_cheat_get_prefecture_build_queues: {
306
- arguments: [ffi.types.POINTER],
307
- return: ffi.types.UINT_32
306
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
307
+ return: ffi.types.VOID
308
308
  },
309
309
  nil_cheat_get_resources: {
310
- arguments: [ffi.types.POINTER],
311
- return: ffi.types.UINT_32
310
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
311
+ return: ffi.types.VOID
312
312
  },
313
313
  nil_cheat_get_stable_recruit_queue: {
314
- arguments: [ffi.types.POINTER],
315
- return: ffi.types.UINT_32
314
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
315
+ return: ffi.types.VOID
316
316
  },
317
317
  nil_cheat_get_stable_recruit_queues: {
318
- arguments: [ffi.types.POINTER],
319
- return: ffi.types.UINT_32
318
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
319
+ return: ffi.types.VOID
320
320
  },
321
321
  nil_cheat_get_storage_capacity: {
322
- arguments: [ffi.types.POINTER],
323
- return: ffi.types.UINT_32
322
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
323
+ return: ffi.types.VOID
324
324
  },
325
325
  nil_cheat_set_bot_ethics: {
326
- arguments: [ffi.types.POINTER],
327
- return: ffi.types.UINT_32
326
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
327
+ return: ffi.types.VOID
328
328
  },
329
329
  nil_cheat_set_building_level: {
330
- arguments: [ffi.types.POINTER],
331
- return: ffi.types.UINT_32
330
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
331
+ return: ffi.types.VOID
332
332
  },
333
333
  nil_cheat_set_food: {
334
- arguments: [ffi.types.POINTER],
335
- return: ffi.types.UINT_32
334
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
335
+ return: ffi.types.VOID
336
336
  },
337
337
  nil_cheat_set_iron: {
338
- arguments: [ffi.types.POINTER],
339
- return: ffi.types.UINT_32
338
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
339
+ return: ffi.types.VOID
340
340
  },
341
341
  nil_cheat_set_max_food: {
342
- arguments: [ffi.types.POINTER],
343
- return: ffi.types.UINT_32
342
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
343
+ return: ffi.types.VOID
344
344
  },
345
345
  nil_cheat_set_max_infrastructure: {
346
- arguments: [ffi.types.POINTER],
347
- return: ffi.types.UINT_32
346
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
347
+ return: ffi.types.VOID
348
348
  },
349
349
  nil_cheat_set_max_iron: {
350
- arguments: [ffi.types.POINTER],
351
- return: ffi.types.UINT_32
350
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
351
+ return: ffi.types.VOID
352
352
  },
353
353
  nil_cheat_set_max_resources: {
354
- arguments: [ffi.types.POINTER],
355
- return: ffi.types.UINT_32
354
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
355
+ return: ffi.types.VOID
356
356
  },
357
357
  nil_cheat_set_max_silo_resources: {
358
- arguments: [ffi.types.POINTER],
359
- return: ffi.types.UINT_32
358
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
359
+ return: ffi.types.VOID
360
360
  },
361
361
  nil_cheat_set_max_stone: {
362
- arguments: [ffi.types.POINTER],
363
- return: ffi.types.UINT_32
362
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
363
+ return: ffi.types.VOID
364
364
  },
365
365
  nil_cheat_set_max_warehouse_resources: {
366
- arguments: [ffi.types.POINTER],
367
- return: ffi.types.UINT_32
366
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
367
+ return: ffi.types.VOID
368
368
  },
369
369
  nil_cheat_set_max_wood: {
370
- arguments: [ffi.types.POINTER],
371
- return: ffi.types.UINT_32
370
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
371
+ return: ffi.types.VOID
372
372
  },
373
373
  nil_cheat_set_resources: {
374
- arguments: [ffi.types.POINTER],
375
- return: ffi.types.UINT_32
374
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
375
+ return: ffi.types.VOID
376
376
  },
377
377
  nil_cheat_set_stability: {
378
- arguments: [ffi.types.POINTER],
379
- return: ffi.types.UINT_32
378
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
379
+ return: ffi.types.VOID
380
380
  },
381
381
  nil_cheat_set_stone: {
382
- arguments: [ffi.types.POINTER],
383
- return: ffi.types.UINT_32
382
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
383
+ return: ffi.types.VOID
384
384
  },
385
385
  nil_cheat_set_wood: {
386
- arguments: [ffi.types.POINTER],
387
- return: ffi.types.UINT_32
386
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
387
+ return: ffi.types.VOID
388
388
  },
389
389
  nil_cheat_skip_round: {
390
- arguments: [ffi.types.POINTER],
391
- return: ffi.types.UINT_32
390
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
391
+ return: ffi.types.VOID
392
392
  },
393
393
  nil_cheat_spawn_bot: {
394
- arguments: [ffi.types.POINTER],
395
- return: ffi.types.UINT_32
394
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
395
+ return: ffi.types.VOID
396
396
  },
397
397
  nil_cheat_spawn_city: {
398
- arguments: [ffi.types.POINTER],
399
- return: ffi.types.UINT_32
398
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
399
+ return: ffi.types.VOID
400
400
  },
401
401
  nil_cheat_spawn_personnel: {
402
- arguments: [ffi.types.POINTER],
403
- return: ffi.types.UINT_32
402
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
403
+ return: ffi.types.VOID
404
404
  },
405
405
  nil_create_remote_world: {
406
- arguments: [ffi.types.POINTER],
407
- return: ffi.types.UINT_32
406
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
407
+ return: ffi.types.VOID
408
408
  },
409
409
  nil_create_user: {
410
- arguments: [ffi.types.POINTER],
411
- return: ffi.types.UINT_32
410
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
411
+ return: ffi.types.VOID
412
412
  },
413
413
  nil_delete_remote_world: {
414
- arguments: [ffi.types.POINTER],
415
- return: ffi.types.UINT_32
414
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
415
+ return: ffi.types.VOID
416
416
  },
417
417
  nil_forward_report: {
418
- arguments: [ffi.types.POINTER],
419
- return: ffi.types.UINT_32
418
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
419
+ return: ffi.types.VOID
420
420
  },
421
421
  nil_get_academy_recruit_catalog: {
422
- arguments: [ffi.types.POINTER],
423
- return: ffi.types.UINT_32
422
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
423
+ return: ffi.types.VOID
424
424
  },
425
425
  nil_get_armies: {
426
- arguments: [ffi.types.POINTER],
427
- return: ffi.types.UINT_32
426
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
427
+ return: ffi.types.VOID
428
428
  },
429
429
  nil_get_army: {
430
- arguments: [ffi.types.POINTER],
431
- return: ffi.types.UINT_32
430
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
431
+ return: ffi.types.VOID
432
432
  },
433
433
  nil_get_army_owner: {
434
- arguments: [ffi.types.POINTER],
435
- return: ffi.types.UINT_32
434
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
435
+ return: ffi.types.VOID
436
436
  },
437
437
  nil_get_bot_coords: {
438
- arguments: [ffi.types.POINTER],
439
- return: ffi.types.UINT_32
438
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
439
+ return: ffi.types.VOID
440
440
  },
441
441
  nil_get_chat_history: {
442
- arguments: [ffi.types.POINTER],
443
- return: ffi.types.UINT_32
442
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
443
+ return: ffi.types.VOID
444
444
  },
445
445
  nil_get_cities: {
446
- arguments: [ffi.types.POINTER],
447
- return: ffi.types.UINT_32
446
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
447
+ return: ffi.types.VOID
448
448
  },
449
449
  nil_get_city: {
450
- arguments: [ffi.types.POINTER],
451
- return: ffi.types.UINT_32
450
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
451
+ return: ffi.types.VOID
452
452
  },
453
453
  nil_get_city_score: {
454
- arguments: [ffi.types.POINTER],
455
- return: ffi.types.UINT_32
454
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
455
+ return: ffi.types.VOID
456
456
  },
457
457
  nil_get_continent_size: {
458
- arguments: [ffi.types.POINTER],
459
- return: ffi.types.UINT_32
458
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
459
+ return: ffi.types.VOID
460
460
  },
461
461
  nil_get_idle_armies_at: {
462
- arguments: [ffi.types.POINTER],
463
- return: ffi.types.UINT_32
462
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
463
+ return: ffi.types.VOID
464
464
  },
465
465
  nil_get_idle_armies_coords: {
466
- arguments: [ffi.types.POINTER],
467
- return: ffi.types.UINT_32
466
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
467
+ return: ffi.types.VOID
468
468
  },
469
469
  nil_get_maneuver: {
470
- arguments: [ffi.types.POINTER],
471
- return: ffi.types.UINT_32
470
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
471
+ return: ffi.types.VOID
472
472
  },
473
473
  nil_get_player: {
474
- arguments: [ffi.types.POINTER],
475
- return: ffi.types.UINT_32
474
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
475
+ return: ffi.types.VOID
476
476
  },
477
477
  nil_get_player_coords: {
478
- arguments: [ffi.types.POINTER],
479
- return: ffi.types.UINT_32
478
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
479
+ return: ffi.types.VOID
480
480
  },
481
481
  nil_get_player_ids: {
482
- arguments: [ffi.types.POINTER],
483
- return: ffi.types.UINT_32
482
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
483
+ return: ffi.types.VOID
484
484
  },
485
485
  nil_get_player_maintenance: {
486
- arguments: [ffi.types.POINTER],
487
- return: ffi.types.UINT_32
486
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
487
+ return: ffi.types.VOID
488
488
  },
489
489
  nil_get_player_military: {
490
- arguments: [ffi.types.POINTER],
491
- return: ffi.types.UINT_32
490
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
491
+ return: ffi.types.VOID
492
492
  },
493
493
  nil_get_player_status: {
494
- arguments: [ffi.types.POINTER],
495
- return: ffi.types.UINT_32
494
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
495
+ return: ffi.types.VOID
496
496
  },
497
497
  nil_get_player_storage_capacity: {
498
- arguments: [ffi.types.POINTER],
499
- return: ffi.types.UINT_32
498
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
499
+ return: ffi.types.VOID
500
500
  },
501
501
  nil_get_player_worlds: {
502
- arguments: [ffi.types.POINTER],
503
- return: ffi.types.UINT_32
502
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
503
+ return: ffi.types.VOID
504
504
  },
505
505
  nil_get_precursor_coords: {
506
- arguments: [ffi.types.POINTER],
507
- return: ffi.types.UINT_32
506
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
507
+ return: ffi.types.VOID
508
508
  },
509
509
  nil_get_prefecture_build_catalog: {
510
- arguments: [ffi.types.POINTER],
511
- return: ffi.types.UINT_32
510
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
511
+ return: ffi.types.VOID
512
512
  },
513
513
  nil_get_public_bot: {
514
- arguments: [ffi.types.POINTER],
515
- return: ffi.types.UINT_32
514
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
515
+ return: ffi.types.VOID
516
516
  },
517
517
  nil_get_public_bots: {
518
- arguments: [ffi.types.POINTER],
519
- return: ffi.types.UINT_32
518
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
519
+ return: ffi.types.VOID
520
520
  },
521
521
  nil_get_public_cities: {
522
- arguments: [ffi.types.POINTER],
523
- return: ffi.types.UINT_32
522
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
523
+ return: ffi.types.VOID
524
524
  },
525
525
  nil_get_public_city: {
526
- arguments: [ffi.types.POINTER],
527
- return: ffi.types.UINT_32
526
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
527
+ return: ffi.types.VOID
528
528
  },
529
529
  nil_get_public_field: {
530
- arguments: [ffi.types.POINTER],
531
- return: ffi.types.UINT_32
530
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
531
+ return: ffi.types.VOID
532
532
  },
533
533
  nil_get_public_fields: {
534
- arguments: [ffi.types.POINTER],
535
- return: ffi.types.UINT_32
534
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
535
+ return: ffi.types.VOID
536
536
  },
537
537
  nil_get_public_player: {
538
- arguments: [ffi.types.POINTER],
539
- return: ffi.types.UINT_32
538
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
539
+ return: ffi.types.VOID
540
540
  },
541
541
  nil_get_public_players: {
542
- arguments: [ffi.types.POINTER],
543
- return: ffi.types.UINT_32
542
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
543
+ return: ffi.types.VOID
544
544
  },
545
545
  nil_get_public_precursor: {
546
- arguments: [ffi.types.POINTER],
547
- return: ffi.types.UINT_32
546
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
547
+ return: ffi.types.VOID
548
548
  },
549
549
  nil_get_public_precursors: {
550
- arguments: [ffi.types.POINTER],
551
- return: ffi.types.UINT_32
550
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
551
+ return: ffi.types.VOID
552
552
  },
553
553
  nil_get_rank: {
554
- arguments: [ffi.types.POINTER],
555
- return: ffi.types.UINT_32
554
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
555
+ return: ffi.types.VOID
556
556
  },
557
557
  nil_get_ranking: {
558
- arguments: [ffi.types.POINTER],
559
- return: ffi.types.UINT_32
558
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
559
+ return: ffi.types.VOID
560
560
  },
561
561
  nil_get_remote_world: {
562
- arguments: [ffi.types.POINTER],
563
- return: ffi.types.UINT_32
562
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
563
+ return: ffi.types.VOID
564
564
  },
565
565
  nil_get_remote_world_limit: {
566
- arguments: [],
567
- return: ffi.types.UINT_32
566
+ arguments: [ffi.types.UINT_32],
567
+ return: ffi.types.VOID
568
568
  },
569
569
  nil_get_remote_world_limit_per_user: {
570
- arguments: [],
571
- return: ffi.types.UINT_32
570
+ arguments: [ffi.types.UINT_32],
571
+ return: ffi.types.VOID
572
572
  },
573
573
  nil_get_remote_worlds: {
574
- arguments: [],
575
- return: ffi.types.UINT_32
574
+ arguments: [ffi.types.UINT_32],
575
+ return: ffi.types.VOID
576
576
  },
577
577
  nil_get_round: {
578
- arguments: [ffi.types.POINTER],
579
- return: ffi.types.UINT_32
578
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
579
+ return: ffi.types.VOID
580
580
  },
581
581
  nil_get_server_kind: {
582
- arguments: [],
583
- return: ffi.types.UINT_32
582
+ arguments: [ffi.types.UINT_32],
583
+ return: ffi.types.VOID
584
584
  },
585
585
  nil_get_stable_recruit_catalog: {
586
- arguments: [ffi.types.POINTER],
587
- return: ffi.types.UINT_32
586
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
587
+ return: ffi.types.VOID
588
588
  },
589
589
  nil_get_workshop_recruit_catalog: {
590
- arguments: [ffi.types.POINTER],
591
- return: ffi.types.UINT_32
590
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
591
+ return: ffi.types.VOID
592
592
  },
593
593
  nil_get_world_bots: {
594
- arguments: [ffi.types.POINTER],
595
- return: ffi.types.UINT_32
594
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
595
+ return: ffi.types.VOID
596
596
  },
597
597
  nil_get_world_config: {
598
- arguments: [ffi.types.POINTER],
599
- return: ffi.types.UINT_32
598
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
599
+ return: ffi.types.VOID
600
600
  },
601
601
  nil_get_world_personnel: {
602
- arguments: [ffi.types.POINTER],
603
- return: ffi.types.UINT_32
602
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
603
+ return: ffi.types.VOID
604
604
  },
605
605
  nil_get_world_players: {
606
- arguments: [ffi.types.POINTER],
607
- return: ffi.types.UINT_32
606
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
607
+ return: ffi.types.VOID
608
608
  },
609
609
  nil_get_world_precursors: {
610
- arguments: [ffi.types.POINTER],
611
- return: ffi.types.UINT_32
610
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
611
+ return: ffi.types.VOID
612
612
  },
613
613
  nil_get_world_stats: {
614
- arguments: [ffi.types.POINTER],
615
- return: ffi.types.UINT_32
614
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
615
+ return: ffi.types.VOID
616
616
  },
617
617
  nil_player_exists: {
618
- arguments: [ffi.types.POINTER],
619
- return: ffi.types.UINT_32
618
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
619
+ return: ffi.types.VOID
620
620
  },
621
621
  nil_push_chat_message: {
622
- arguments: [ffi.types.POINTER],
623
- return: ffi.types.UINT_32
622
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
623
+ return: ffi.types.VOID
624
624
  },
625
625
  nil_rename_city: {
626
- arguments: [ffi.types.POINTER],
627
- return: ffi.types.UINT_32
626
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
627
+ return: ffi.types.VOID
628
628
  },
629
629
  nil_request_maneuver: {
630
- arguments: [ffi.types.POINTER],
631
- return: ffi.types.UINT_32
630
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
631
+ return: ffi.types.VOID
632
632
  },
633
633
  nil_save_local_world: {
634
- arguments: [ffi.types.POINTER],
635
- return: ffi.types.UINT_32
634
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
635
+ return: ffi.types.VOID
636
636
  },
637
637
  nil_search_city: {
638
- arguments: [ffi.types.POINTER],
639
- return: ffi.types.UINT_32
638
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
639
+ return: ffi.types.VOID
640
640
  },
641
641
  nil_search_public_city: {
642
- arguments: [ffi.types.POINTER],
643
- return: ffi.types.UINT_32
642
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
643
+ return: ffi.types.VOID
644
644
  },
645
645
  nil_server_version: {
646
- arguments: [],
647
- return: ffi.types.UINT_32
646
+ arguments: [ffi.types.UINT_32],
647
+ return: ffi.types.VOID
648
648
  },
649
649
  nil_set_player_ready: {
650
- arguments: [ffi.types.POINTER],
651
- return: ffi.types.UINT_32
650
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
651
+ return: ffi.types.VOID
652
652
  },
653
653
  nil_set_player_status: {
654
- arguments: [ffi.types.POINTER],
655
- return: ffi.types.UINT_32
654
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
655
+ return: ffi.types.VOID
656
656
  },
657
657
  nil_simulate_battle: {
658
- arguments: [ffi.types.POINTER],
659
- return: ffi.types.UINT_32
658
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
659
+ return: ffi.types.VOID
660
660
  },
661
661
  nil_spawn_player: {
662
- arguments: [ffi.types.POINTER],
663
- return: ffi.types.UINT_32
662
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
663
+ return: ffi.types.VOID
664
664
  },
665
665
  nil_start_round: {
666
- arguments: [ffi.types.POINTER],
667
- return: ffi.types.UINT_32
666
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
667
+ return: ffi.types.VOID
668
668
  },
669
669
  nil_toggle_building: {
670
- arguments: [ffi.types.POINTER],
671
- return: ffi.types.UINT_32
670
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
671
+ return: ffi.types.VOID
672
672
  },
673
673
  nil_user_exists: {
674
- arguments: [ffi.types.POINTER],
675
- return: ffi.types.UINT_32
674
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
675
+ return: ffi.types.VOID
676
676
  },
677
677
  nil_validate_token: {
678
- arguments: [ffi.types.POINTER],
679
- return: ffi.types.UINT_32
678
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
679
+ return: ffi.types.VOID
680
680
  }
681
681
  };
682
682
  //#endregion
683
683
  //#region package.json
684
- var version = "0.7.0";
684
+ var version = "0.7.1";
685
685
  //#endregion
686
686
  //#region src/index.ts
687
+ var VERSION = version;
687
688
  var Nil = class {
688
689
  constructor(dll) {
689
690
  this.disposed = false;
@@ -691,7 +692,7 @@ var Nil = class {
691
692
  this.handle = ffi.dlopen(dll, definitions);
692
693
  this.functions = this.handle.functions;
693
694
  this.queue = new Queue(this.handle);
694
- this.setUserAgent(`nil-ffi-node/${version}`);
695
+ this.setUserAgent(`nil-ffi-node/${version}`).catch(console.error);
695
696
  }
696
697
  [Symbol.dispose]() {
697
698
  this.close();
@@ -705,32 +706,51 @@ var Nil = class {
705
706
  }
706
707
  async getClientVersion() {
707
708
  this.throwIfClosed();
708
- return this.queue.request(() => {
709
- return this.functions.nil_client_version();
709
+ return this.queue.request((requestId) => {
710
+ this.functions.nil_client_version(requestId);
710
711
  });
711
712
  }
712
713
  async getFfiVersion() {
713
714
  this.throwIfClosed();
714
- return this.queue.request(() => {
715
- return this.functions.nil_ffi_version();
715
+ return this.queue.request((requestId) => {
716
+ this.functions.nil_ffi_version(requestId);
717
+ });
718
+ }
719
+ async getRemoteWorldLimit() {
720
+ this.throwIfClosed();
721
+ return this.queue.request((requestId) => {
722
+ this.functions.nil_get_remote_world_limit(requestId);
723
+ });
724
+ }
725
+ async getRemoteWorldLimitPerUser() {
726
+ this.throwIfClosed();
727
+ return this.queue.request((requestId) => {
728
+ this.functions.nil_get_remote_world_limit_per_user(requestId);
729
+ });
730
+ }
731
+ async getRemoteWorlds() {
732
+ this.throwIfClosed();
733
+ return this.queue.request((requestId) => {
734
+ this.functions.nil_get_remote_worlds(requestId);
716
735
  });
717
736
  }
718
737
  async getUserAgent() {
719
738
  this.throwIfClosed();
720
- return this.queue.request(() => {
721
- return this.functions.nil_user_agent();
739
+ return this.queue.request((requestId) => {
740
+ this.functions.nil_user_agent(requestId);
722
741
  });
723
742
  }
724
743
  async getWorld() {
725
744
  this.throwIfClosed();
726
- return this.queue.request(() => {
727
- return this.functions.nil_world();
745
+ return this.queue.request((requestId) => {
746
+ this.functions.nil_world(requestId);
728
747
  });
729
748
  }
730
749
  async setUserAgent(userAgent) {
731
750
  this.throwIfClosed();
732
- await this.queue.request(() => {
733
- return this.functions.nil_set_user_agent(userAgent);
751
+ await this.queue.request((requestId) => {
752
+ const arg1 = JSON.stringify(userAgent);
753
+ this.functions.nil_set_user_agent(requestId, arg1);
734
754
  });
735
755
  }
736
756
  throwIfClosed() {
@@ -738,4 +758,4 @@ var Nil = class {
738
758
  }
739
759
  };
740
760
  //#endregion
741
- export { FfiError, HandleClosedError, Nil, definitions };
761
+ export { FfiError, HandleClosedError, Nil, VERSION, definitions };