@gwigz/slua-types 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/index.d.ts +132 -48
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -212,12 +212,12 @@ declare type list = (string | number | vector | uuid | quaternion | boolean)[];
212
212
  declare type LLDetectedEventName = "collision" | "collision_end" | "collision_start" | "final_damage" | "on_damage" | "sensor" | "touch" | "touch_end" | "touch_start";
213
213
  declare type LLNonDetectedEventName = "at_rot_target" | "at_target" | "attach" | "changed" | "control" | "dataserver" | "email" | "experience_permissions" | "experience_permissions_denied" | "game_control" | "http_request" | "http_response" | "land_collision" | "land_collision_end" | "land_collision_start" | "link_message" | "linkset_data" | "listen" | "money" | "moving_end" | "moving_start" | "no_sensor" | "not_at_rot_target" | "not_at_target" | "object_rez" | "on_death" | "on_rez" | "path_update" | "remote_data" | "run_time_permissions" | "timer" | "transaction_result";
214
214
  declare type LLEventName = keyof LLEventMap;
215
- declare type LLEventHandler = (...args: any[]) => void;
216
- declare type LLDetectedEventHandler = (detected: DetectedEvent[]) => void;
215
+ declare type LLEventHandler = (this: void, ...args: any[]) => void;
216
+ declare type LLDetectedEventHandler = (this: void, detected: DetectedEvent[]) => void;
217
217
  /** Callback type for LLTimers.every() - receives scheduled time and interval */
218
- declare type LLTimerEveryCallback = (scheduled: number, interval: number) => void;
218
+ declare type LLTimerEveryCallback = (this: void, scheduled: number, interval: number) => void;
219
219
  /** Callback type for LLTimers.once() - receives scheduled time */
220
- declare type LLTimerOnceCallback = (scheduled: number) => void;
220
+ declare type LLTimerOnceCallback = (this: void, scheduled: number) => void;
221
221
  /** Union of timer callback types */
222
222
  declare type LLTimerCallback = LLTimerEveryCallback | LLTimerOnceCallback;
223
223
  /** Date/time table structure used by os.date and os.time */
@@ -254,59 +254,140 @@ declare const LLEvents: LLEvents;
254
254
  /** Timer management singleton for scheduling periodic and one-time callbacks. */
255
255
  declare const LLTimers: LLTimers;
256
256
 
257
- /** Dangerously executes a required module function */
258
- declare function dangerouslyexecuterequiredmodule(f: (...args: any[]) => any[]): any[];
259
- /** Creates a new uuid from a string, buffer, or existing uuid. Returns nil if the string is not a valid UUID, or the the buffer is shorter than 16 bytes. */
257
+ /**
258
+ * Dangerously executes a required module function
259
+ * @noSelf
260
+ */
261
+ declare function dangerouslyexecuterequiredmodule(f: (this: void, ...args: any[]) => any[]): any[];
262
+ /**
263
+ * Creates a new uuid from a string, buffer, or existing uuid. Returns nil if the string is not a valid UUID, or the the buffer is shorter than 16 bytes.
264
+ * @noSelf
265
+ */
260
266
  declare function touuid(val: string | undefined | buffer | uuid): uuid | undefined;
261
- /** Converts a string to a vector, returns nil if invalid */
267
+ /**
268
+ * Converts a string to a vector, returns nil if invalid
269
+ * @noSelf
270
+ */
262
271
  declare function tovector(val: string | undefined | vector): vector | undefined;
263
- /** Converts a string to a quaternion, returns nil if invalid */
272
+ /**
273
+ * Converts a string to a quaternion, returns nil if invalid
274
+ * @noSelf
275
+ */
264
276
  declare function toquaternion(val: string | undefined | quaternion): quaternion | undefined;
265
- /** Converts a string to a rotation (quaternion), returns nil if invalid */
277
+ /**
278
+ * Converts a string to a rotation (quaternion), returns nil if invalid
279
+ * @noSelf
280
+ */
266
281
  declare function torotation(val: string | undefined | quaternion): quaternion | undefined;
267
- /** Checks if the value is truthy; if not, raises an error with the optional message. */
282
+ /**
283
+ * Checks if the value is truthy; if not, raises an error with the optional message.
284
+ * @noSelf
285
+ */
268
286
  declare function assert<T>(value?: T, message?: string): T;
269
- /** Raises an error with the specified object and optional call stack level. */
287
+ /**
288
+ * Raises an error with the specified object and optional call stack level.
289
+ * @noSelf
290
+ */
270
291
  declare function error(obj: any, level?: number): never;
271
- /** Returns the total heap size in kilobytes. */
292
+ /**
293
+ * Returns the total heap size in kilobytes.
294
+ * @noSelf
295
+ */
272
296
  declare function gcinfo(): number;
273
- /** Returns the metatable for the specified object. */
297
+ /**
298
+ * Returns the metatable for the specified object.
299
+ * @noSelf
300
+ */
274
301
  declare function getmetatable(obj: any): Record<any, any> | undefined;
275
- /** Returns the next key-value pair in the table traversal order. */
302
+ /**
303
+ * Returns the next key-value pair in the table traversal order.
304
+ * @noSelf
305
+ */
276
306
  declare function next<K, V>(t: Record<K, V>, i?: K): LuaMultiReturn<[K, V]> | undefined;
277
- /** Creates a new untyped userdata object with an optional metatable. */
307
+ /**
308
+ * Creates a new untyped userdata object with an optional metatable.
309
+ * @noSelf
310
+ */
278
311
  declare function newproxy(mt?: boolean): any;
279
- /** Prints all arguments to standard output using Tab as a separator. */
312
+ /**
313
+ * Prints all arguments to standard output using Tab as a separator.
314
+ * @noSelf
315
+ */
280
316
  declare function print(...args: any[]): void;
281
- /** Returns true if a and b have the same type and value. */
317
+ /**
318
+ * Returns true if a and b have the same type and value.
319
+ * @noSelf
320
+ */
282
321
  declare function rawequal(a: any, b: any): boolean;
283
- /** Performs a table lookup bypassing metatables. */
322
+ /**
323
+ * Performs a table lookup bypassing metatables.
324
+ * @noSelf
325
+ */
284
326
  declare function rawget<K, V>(t: Record<K, V>, k: K): V | undefined;
285
- /** Assigns a value to a table field bypassing metatables. */
327
+ /**
328
+ * Assigns a value to a table field bypassing metatables.
329
+ * @noSelf
330
+ */
286
331
  declare function rawset<K, V>(t: Record<K, V>, k: K, v: V): Record<K, V>;
287
- /** Returns the length of a table or string bypassing metatables. */
332
+ /**
333
+ * Returns the length of a table or string bypassing metatables.
334
+ * @noSelf
335
+ */
288
336
  declare function rawlen<K, V>(t: Record<any, any> | string): number;
289
- /** Returns a subset of arguments or the number of arguments. */
337
+ /**
338
+ * Returns a subset of arguments or the number of arguments.
339
+ * @noSelf
340
+ */
290
341
  declare function select(i: string | number, ...args: any[]): any;
291
- /** Changes the metatable for the given table. */
342
+ /**
343
+ * Changes the metatable for the given table.
344
+ * @noSelf
345
+ */
292
346
  declare function setmetatable(t: Record<any, any>, mt?: Record<any, any>): void;
293
- /** Converts the input string to a number in the specified base. */
347
+ /**
348
+ * Converts the input string to a number in the specified base.
349
+ * @noSelf
350
+ */
294
351
  declare function tonumber(s: string, base?: number): number | undefined;
295
- /** Converts the input object to a string. */
352
+ /**
353
+ * Converts the input object to a string.
354
+ * @noSelf
355
+ */
296
356
  declare function tostring(obj: any): string;
297
- /** Returns the type of the object as a string. */
357
+ /**
358
+ * Returns the type of the object as a string.
359
+ * @noSelf
360
+ */
298
361
  declare function type(obj: any): string;
299
- /** Returns an iterator for numeric key-value pairs in the table. */
300
- declare function ipairs<V>(t: V[]): LuaMultiReturn<[(arg0: V[], arg1: number) => LuaMultiReturn<[number | undefined, V]>, V[], number]>;
301
- /** Returns an iterator for all key-value pairs in the table. */
302
- declare function pairs<K, V>(t: Record<K, V>): LuaMultiReturn<[(arg0: Record<K, V>, arg1: K) => LuaMultiReturn<[K | undefined, V]>, Record<K, V>, K]>;
303
- /** Calls function f with parameters args, returning success and function results or an error. */
362
+ /**
363
+ * Returns an iterator for numeric key-value pairs in the table.
364
+ * @noSelf
365
+ */
366
+ declare function ipairs<V>(t: V[]): LuaMultiReturn<[(this: void, arg0: V[], arg1: number) => LuaMultiReturn<[number | undefined, V]>, V[], number]>;
367
+ /**
368
+ * Returns an iterator for all key-value pairs in the table.
369
+ * @noSelf
370
+ */
371
+ declare function pairs<K, V>(t: Record<K, V>): LuaMultiReturn<[(this: void, arg0: Record<K, V>, arg1: K) => LuaMultiReturn<[K | undefined, V]>, Record<K, V>, K]>;
372
+ /**
373
+ * Calls function f with parameters args, returning success and function results or an error.
374
+ * @noSelf
375
+ */
304
376
  declare function pcall(f: (...args: any[]) => any, ...args: any[][]): any;
305
- /** Calls function f with parameters args, handling errors with e if they occur. */
377
+ /**
378
+ * Calls function f with parameters args, handling errors with e if they occur.
379
+ * @noSelf
380
+ */
306
381
  declare function xpcall<E>(f: (...args: any[]) => any, e: (...args: any[]) => any, ...args: any[][]): any;
307
- /** Execute the named external module. */
382
+ /**
383
+ * Execute the named external module.
384
+ * @noSelf
385
+ */
308
386
  declare function require(target: string): any;
309
- /** Returns values from an array in the specified index range. */
387
+ /**
388
+ * Returns values from an array in the specified index range.
389
+ * @noSelf
390
+ */
310
391
  declare function unpack<V>(a: V[], f?: number, t?: number): V[];
311
392
 
312
393
  /** Bitwise operations library. */
@@ -450,7 +531,7 @@ declare namespace buffer {
450
531
  /** @noSelf */
451
532
  declare namespace coroutine {
452
533
  /** Returns a new coroutine that, when resumed, will run function f. */
453
- export function create(f: (...args: any[]) => any[]): LuaThread;
534
+ export function create(f: (this: void, ...args: any[]) => any[]): LuaThread;
454
535
 
455
536
  /** Resumes a coroutine, returning true and results if successful, or false and an error. */
456
537
  export function resume(co: LuaThread, ...args: any[]): LuaMultiReturn<[boolean, ...args: any[]]>;
@@ -462,7 +543,7 @@ declare namespace coroutine {
462
543
  export function status(co: LuaThread): "running" | "suspended" | "normal" | "dead";
463
544
 
464
545
  /** Creates a coroutine and returns a function that resumes it. */
465
- export function wrap(f: (...args: any[]) => any[]): (...args: any[]) => any[];
546
+ export function wrap(f: (this: void, ...args: any[]) => any[]): (this: void, ...args: any[]) => any[];
466
547
 
467
548
  /** Yields the current coroutine, passing arguments to the resuming code. */
468
549
  export function yield(...args: any[]): any[];
@@ -478,13 +559,13 @@ declare namespace coroutine {
478
559
  /** @noSelf */
479
560
  declare namespace debug {
480
561
  /** Returns information about a stack frame or function based on specified format. */
481
- export function info(co: LuaThread | ((...args: any[]) => any[]) | number, level: number, s: string): any[];
562
+ export function info(co: LuaThread | ((this: void, ...args: any[]) => any[]) | number, level: number, s: string): any[];
482
563
 
483
564
  /** Returns a human-readable call stack starting from the specified level. */
484
565
  export function traceback(co: LuaThread, msg?: string, level?: number): string;
485
566
 
486
567
  /** Returns a table containing debug information about a function or stack frame. */
487
- export function getinfo(thread: LuaThread, function_: ((...args: any[]) => any[]) | number, what: string): Record<any, any>;
568
+ export function getinfo(thread: LuaThread, function_: ((this: void, ...args: any[]) => any[]) | number, what: string): Record<any, any>;
488
569
 
489
570
  /** Returns the name and value of a local variable at the specified stack level. */
490
571
  export function getlocal(level: number, index: number): string | any;
@@ -493,10 +574,10 @@ declare namespace debug {
493
574
  export function setlocal(level: number, index: number, value: any): boolean;
494
575
 
495
576
  /** Returns the name and value of an upvalue for a given function. */
496
- export function getupvalue(function_: (...args: any[]) => any[], index: number): string | any;
577
+ export function getupvalue(function_: (this: void, ...args: any[]) => any[], index: number): string | any;
497
578
 
498
579
  /** Sets the value of an upvalue for a given function. */
499
- export function setupvalue(function_: (...args: any[]) => any[], index: number, value: any): string;
580
+ export function setupvalue(function_: (this: void, ...args: any[]) => any[], index: number, value: any): string;
500
581
 
501
582
  /** Returns the metatable of the given value, if any. */
502
583
  export function getmetatable(value: any): Record<any, any> | undefined;
@@ -720,8 +801,11 @@ declare namespace Quaternion {
720
801
  /** String manipulation library. */
721
802
  /** @noSelf */
722
803
  declare namespace string {
723
- /** Returns the numeric code of every byte in the input string within the given range. */
724
- export function byte(s: string, i?: number, j?: number): number[];
804
+ /** Returns the numeric code of the byte at position i (default 1) in the input string. */
805
+ export function byte(s: string, i?: number): number;
806
+
807
+ /** Returns the numeric codes of every byte in the input string within the range [i, j]. */
808
+ export function byte(s: string, i: number, j: number): number[];
725
809
 
726
810
  /** Returns a string containing characters for the given byte values. */
727
811
  export function char(...args: number[]): string;
@@ -733,10 +817,10 @@ declare namespace string {
733
817
  export function format(formatstring: string, ...args: any[]): string;
734
818
 
735
819
  /** Returns an iterator function for pattern matches */
736
- export function gmatch(s: string, pattern: string): () => string[];
820
+ export function gmatch(s: string, pattern: string): (this: void) => string[];
737
821
 
738
822
  /** Performs pattern-based substitution in a string. */
739
- export function gsub(s: string, pattern: string, repl: string | Record<string, string> | ((...args: string[]) => string), maxn?: number): LuaMultiReturn<[string, number]>;
823
+ export function gsub(s: string, pattern: string, repl: string | Record<string, string> | ((this: void, ...args: string[]) => string), maxn?: number): LuaMultiReturn<[string, number]>;
740
824
 
741
825
  /** Returns the number of bytes in the string. Identical to #s */
742
826
  export function len(s: string): number;
@@ -782,13 +866,13 @@ declare namespace table {
782
866
  * Iterates over all key-value pairs in the table (deprecated).
783
867
  * @deprecated Use a for loop instead
784
868
  */
785
- export function foreach<K, V, R>(t: Record<K, V>, f?: (key: K, value: V) => R): R | undefined;
869
+ export function foreach<K, V, R>(t: Record<K, V>, f?: (this: void, key: K, value: V) => R): R | undefined;
786
870
 
787
871
  /**
788
872
  * Iterates over all index-value pairs in the array (deprecated).
789
873
  * @deprecated Use a for loop instead
790
874
  */
791
- export function foreachi<V, R>(a: V[], f?: (index: number, value: V) => R): R | undefined;
875
+ export function foreachi<V, R>(a: V[], f?: (this: void, index: number, value: V) => R): R | undefined;
792
876
 
793
877
  /**
794
878
  * Returns the length of an array (deprecated; use # instead).
@@ -812,7 +896,7 @@ declare namespace table {
812
896
  export function remove<V>(a: V[], i?: number): V | undefined;
813
897
 
814
898
  /** Sorts an array in place. */
815
- export function sort<V>(a: V[], f?: (a: V, b: V) => boolean): void;
899
+ export function sort<V>(a: V[], f?: (this: void, a: V, b: V) => boolean): void;
816
900
 
817
901
  /** Packs multiple arguments into a new array with length field n. */
818
902
  export function pack<V>(...args: V[]): { n: number; [index: number]: V };
@@ -852,7 +936,7 @@ declare namespace utf8 {
852
936
  export function char(...args: number[]): string;
853
937
 
854
938
  /** Returns an iterator that produces the byte offset and Unicode codepoint for each character in the string. */
855
- export function codes(s: string): LuaMultiReturn<[(arg0: string, arg1: number) => LuaMultiReturn<[number, number]>, string, number]>;
939
+ export function codes(s: string): LuaMultiReturn<[(this: void, arg0: string, arg1: number) => LuaMultiReturn<[number, number]>, string, number]>;
856
940
 
857
941
  /** Returns the Unicode codepoints in the specified range of the string. */
858
942
  export function codepoint(s: string, i?: number, j?: number): number[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gwigz/slua-types",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "TypeScript type definitions for Second Life's SLua runtime",
5
5
  "license": "MIT",
6
6
  "repository": {