@tsukilabs/nil-ffi 0.7.19 → 0.7.21

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/def.d.ts CHANGED
@@ -176,6 +176,10 @@ export declare const definitions: {
176
176
  readonly arguments: readonly [ffi.types.UINT_32, ffi.types.POINTER];
177
177
  readonly return: ffi.types.VOID;
178
178
  };
179
+ readonly nil_cheat_get_influence: {
180
+ readonly arguments: readonly [ffi.types.UINT_32, ffi.types.POINTER];
181
+ readonly return: ffi.types.VOID;
182
+ };
179
183
  readonly nil_cheat_get_infrastructure: {
180
184
  readonly arguments: readonly [ffi.types.UINT_32, ffi.types.POINTER];
181
185
  readonly return: ffi.types.VOID;
@@ -232,6 +236,10 @@ export declare const definitions: {
232
236
  readonly arguments: readonly [ffi.types.UINT_32, ffi.types.POINTER];
233
237
  readonly return: ffi.types.VOID;
234
238
  };
239
+ readonly nil_cheat_set_influence: {
240
+ readonly arguments: readonly [ffi.types.UINT_32, ffi.types.POINTER];
241
+ readonly return: ffi.types.VOID;
242
+ };
235
243
  readonly nil_cheat_set_iron: {
236
244
  readonly arguments: readonly [ffi.types.UINT_32, ffi.types.POINTER];
237
245
  readonly return: ffi.types.VOID;
@@ -356,6 +364,10 @@ export declare const definitions: {
356
364
  readonly arguments: readonly [ffi.types.UINT_32, ffi.types.POINTER];
357
365
  readonly return: ffi.types.VOID;
358
366
  };
367
+ readonly nil_get_city_limit: {
368
+ readonly arguments: readonly [ffi.types.UINT_32, ffi.types.POINTER];
369
+ readonly return: ffi.types.VOID;
370
+ };
359
371
  readonly nil_get_city_score: {
360
372
  readonly arguments: readonly [ffi.types.UINT_32, ffi.types.POINTER];
361
373
  readonly return: ffi.types.VOID;
package/dist/index.js CHANGED
@@ -94,7 +94,9 @@ var Queue = class Queue {
94
94
  this.pendingRequests = /* @__PURE__ */ new Map();
95
95
  this.functions = handle.functions;
96
96
  this.errorHandler = options?.onError ?? console.error;
97
+ this.eventHandler = options?.onEvent ?? console.log;
97
98
  this.emitter.on("error", this.errorHandler);
99
+ this.emitter.on("event", this.eventHandler);
98
100
  this.emitter.on("response", this.onResponse.bind(this));
99
101
  this.timer = setTimeout(() => this.drain(), 0);
100
102
  }
@@ -148,6 +150,11 @@ var Queue = class Queue {
148
150
  }
149
151
  dispatch(entry) {
150
152
  switch (entry.kind) {
153
+ case "event": {
154
+ const event = JSON.parse(entry.jsonStr);
155
+ this.emitter.emit("event", event);
156
+ break;
157
+ }
151
158
  case "response": {
152
159
  const response = JSON.parse(entry.jsonStr);
153
160
  this.emitter.emit("response", response);
@@ -359,6 +366,10 @@ var definitions = {
359
366
  arguments: [ffi.types.UINT_32, ffi.types.POINTER],
360
367
  return: ffi.types.VOID
361
368
  },
369
+ nil_cheat_get_influence: {
370
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
371
+ return: ffi.types.VOID
372
+ },
362
373
  nil_cheat_get_infrastructure: {
363
374
  arguments: [ffi.types.UINT_32, ffi.types.POINTER],
364
375
  return: ffi.types.VOID
@@ -415,6 +426,10 @@ var definitions = {
415
426
  arguments: [ffi.types.UINT_32, ffi.types.POINTER],
416
427
  return: ffi.types.VOID
417
428
  },
429
+ nil_cheat_set_influence: {
430
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
431
+ return: ffi.types.VOID
432
+ },
418
433
  nil_cheat_set_iron: {
419
434
  arguments: [ffi.types.UINT_32, ffi.types.POINTER],
420
435
  return: ffi.types.VOID
@@ -539,6 +554,10 @@ var definitions = {
539
554
  arguments: [ffi.types.UINT_32, ffi.types.POINTER],
540
555
  return: ffi.types.VOID
541
556
  },
557
+ nil_get_city_limit: {
558
+ arguments: [ffi.types.UINT_32, ffi.types.POINTER],
559
+ return: ffi.types.VOID
560
+ },
542
561
  nil_get_city_score: {
543
562
  arguments: [ffi.types.UINT_32, ffi.types.POINTER],
544
563
  return: ffi.types.VOID
@@ -790,7 +809,7 @@ var definitions = {
790
809
  };
791
810
  //#endregion
792
811
  //#region package.json
793
- var version = "0.7.19";
812
+ var version = "0.7.21";
794
813
  //#endregion
795
814
  //#region \0@oxc-project+runtime@0.142.0/helpers/esm/decorate.js
796
815
  function __decorate(decorators, target, key, desc) {
@@ -846,7 +865,8 @@ var Nil = class Nil {
846
865
  const file = `libnil.${ffi.suffix}`;
847
866
  const filePath = path.resolve(options?.outDir ?? cwd(), file);
848
867
  if (!(options?.overwrite ?? true) && existsSync(filePath)) return filePath;
849
- const response = await fetch(`https://tsukilabs.dev.br/download/nil/${file}`, { headers: { "User-Agent": USER_AGENT } });
868
+ const url = `https://tsukilabs.dev.br/download/nil/${file}`;
869
+ const response = await fetch(new URL(url), { headers: { "User-Agent": USER_AGENT } });
850
870
  if (!response.ok) throw new Error(`failed to download ${file}: ${response.status} ${response.statusText}`);
851
871
  const bytes = await response.bytes();
852
872
  await fs.writeFile(filePath, bytes);
package/dist/queue.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare class Queue implements Disposable {
11
11
  private readonly pendingRequests;
12
12
  private timer;
13
13
  private readonly errorHandler;
14
+ private readonly eventHandler;
14
15
  constructor(handle: Handle, options?: QueueOptions);
15
16
  [Symbol.dispose](): void;
16
17
  request<T = nil>(start: RequestFn): Promise<T>;
package/dist/types.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import { definitions } from './def';
2
2
  import { Option } from '@tb-dev/utils';
3
+ import { Event } from '@tsukilabs/nil-bindings';
3
4
  import { DynamicLibraryResult } from 'node:ffi';
4
5
  export type Handle = DynamicLibraryResult<typeof definitions>;
5
6
  export type ErrorHandler = (error: unknown) => void;
7
+ export type EventHandler = (event: Event) => void;
6
8
  export interface QueueOptions {
7
9
  onError?: Option<ErrorHandler>;
10
+ onEvent?: Option<EventHandler>;
8
11
  }
9
12
  export interface NilOptions extends QueueOptions {
10
13
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@tsukilabs/nil-ffi",
3
- "version": "0.7.19",
3
+ "version": "0.7.21",
4
4
  "description": "FFI bindings for Call of Nil",
5
5
  "type": "module",
6
- "packageManager": "pnpm@11.20.0",
6
+ "packageManager": "pnpm@11.21.0",
7
7
  "license": "AGPL-3.0-only",
8
8
  "private": false,
9
9
  "homepage": "https://nil.dev.br",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@tb-dev/utils": "^8.1.3",
34
- "@tsukilabs/nil-bindings": "^0.7.18",
34
+ "@tsukilabs/nil-bindings": "^0.7.20",
35
35
  "es-toolkit": "^1.50.0"
36
36
  },
37
37
  "files": ["dist"],