@gwigz/slua-types 1.0.0 → 1.0.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 +47 -18
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -291,6 +291,35 @@ declare type OsDateTime = {
291
291
  yday?: number
292
292
  isdst?: boolean
293
293
  }
294
+ /** Configuration options for lljson encoding */
295
+ declare type LLJsonEncodeOptions = {
296
+ tight?: boolean
297
+ skip_tojson?: boolean
298
+ allow_sparse?: boolean
299
+ replacer: ((this: void, key: any, value: any, parent: any[] | undefined) => any) | undefined
300
+ }
301
+ declare type LLJsonDecodeReviverWithoutPath = (
302
+ this: void,
303
+ key: string | number,
304
+ value: any,
305
+ parent: any[] | undefined,
306
+ ctx: any[],
307
+ ) => any
308
+ declare type LLJsonDecodeOptionsWithoutPath =
309
+ | { track_path?: false; reviver?: LLJsonDecodeReviverWithoutPath }
310
+ | LLJsonDecodeReviverWithoutPath
311
+ declare type LLJsonDecodeOptionsWithPath = {
312
+ track_path: true
313
+ reviver: (
314
+ this: void,
315
+ key: string | number,
316
+ value: any,
317
+ parent: any[] | undefined,
318
+ ctx: { path: (string | number)[] },
319
+ ) => any
320
+ }
321
+ /** Configuration options for lljson decoding */
322
+ declare type LLJsonDecodeOptions = LLJsonDecodeOptionsWithoutPath | LLJsonDecodeOptionsWithPath
294
323
 
295
324
  /** Event registration and management class for Second Life events */
296
325
  declare interface LLEvents {
@@ -300,9 +329,9 @@ declare interface LLEvents {
300
329
  off<E extends keyof LLEventMap>(event: E, callback: LLEventMap[E]): boolean
301
330
  /** Registers a one-time callback. Returns the wrapper function. */
302
331
  once<E extends keyof LLEventMap>(event: E, callback: LLEventMap[E]): LLEventMap[E]
303
- /** Returns a list of all listeners for a specific event. */
304
- listeners<E extends keyof LLEventMap>(event: E): LLEventMap[E][]
305
- /** Returns a list of all event names that have listeners. */
332
+ /** Returns a list of all handlers for a specific event. */
333
+ handlers<E extends keyof LLEventMap>(event: E): LLEventMap[E][]
334
+ /** Returns a list of all event names that have handlers. */
306
335
  eventNames(): (keyof LLEventMap)[]
307
336
  }
308
337
 
@@ -704,29 +733,29 @@ declare namespace llbase64 {
704
733
  /** @noSelf */
705
734
  declare namespace lljson {
706
735
  /** Encodes a Lua value as JSON. Raises an error if value contains unsupported types. */
707
- export function encode(value: any): string
736
+ export function encode(value: any, options?: LLJsonEncodeOptions): string
708
737
 
709
738
  /** Decodes a JSON string to a Lua value. Raises an error if JSON is invalid. */
710
- export function decode(json: string): any
739
+ export function decode(json: string, options?: LLJsonDecodeOptions): any
711
740
 
712
741
  /** Encodes a Lua value as JSON, preserving SL types. Use tight to encode more compactly. Raises an error if value contains unsupported types. */
713
- export function slencode(value: any, tight?: boolean): string
742
+ export function slencode(value: any, options?: LLJsonEncodeOptions): string
714
743
 
715
744
  /** Decodes a JSON string to a Lua value, preserving SL types. Raises an error if JSON is invalid. */
716
- export function sldecode(json: string): any
745
+ export function sldecode(json: string, options?: LLJsonDecodeOptions): any
717
746
 
718
- /** A constant to pass for null to json encode */
747
+ /** A constant to pass for null to json encode. */
719
748
  export const null_: any
720
- /** Metatable for declaring table as an empty array for json encode */
721
- export const empty_array_mt: Record<any, any>
722
- /** Metatable for declaring table as an array for json encode */
723
- export const array_mt: Record<any, any>
724
- /** A constant to pass for an empty array to json encode */
725
- export const empty_array: any
726
- /** Name of the lljson library */
727
- export const _NAME: string
728
- /** Version of the lljson library */
729
- export const _VERSION: string
749
+ /** A constant to return from a reviver/replacer replacer function to omit this item. */
750
+ export const remove: any
751
+ /** Metatable for declaring table as an array for json encode. */
752
+ export const array_mt: { __jsonhint: string }
753
+ /** Metatable for declaring table as an object for json encode. */
754
+ export const object_mt: { __jsonhint: string }
755
+ /** A constant to pass for an empty array to json encode. */
756
+ export const empty_array: any[]
757
+ /** A constant to pass for an empty object to json encode. */
758
+ export const empty_object: any[]
730
759
  }
731
760
 
732
761
  /** Mathematical functions library. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gwigz/slua-types",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "TypeScript type definitions for Second Life's SLua runtime",
5
5
  "license": "MIT",
6
6
  "repository": {