@tilua-types/sunc 8.0.0 → 10.0.0

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/README.md CHANGED
@@ -37,8 +37,14 @@ http.request({ Url: url })
37
37
  The namespaces are not the executor's — no executor has `fs` or `closure`.
38
38
  The compiler reads each from the library's runtime, which builds it as the
39
39
  script starts from whatever the executor has, under whichever spelling it
40
- has. A function the executor has under none of them raises "fs.read is not
41
- available in this executor" when called.
40
+ has. A function the executor has under none of them is `nil`, so every
41
+ member is optional and a script says what it needs before it calls it:
42
+
43
+ ```luau
44
+ if (fs.write) fs.write("log.txt", text)
45
+ const hui = instance.gethui
46
+ const parent = hui ? hui() : game:GetService("CoreGui")
47
+ ```
42
48
 
43
49
  | Namespace | Functions (what the executor calls them) |
44
50
  | --- | --- |
@@ -110,3 +116,14 @@ No executor implements all of this, and several names mean slightly different
110
116
  things between them — the types say what the standard says, not what any one
111
117
  executor does. Nothing here exists in a normal Roblox game: a script using
112
118
  these runs only under an executor.
119
+
120
+ <!-- compatibility:start -->
121
+ ## Compatibility
122
+
123
+ `@tilua-types/sunc@10.0.0` works with these tilua packages. *Released with* is the
124
+ version it was built and tested against.
125
+
126
+ | Package | Range | Released with | |
127
+ | --- | --- | --- | --- |
128
+ | `@tilua-types/roblox` | `^9.0.0` | 9.0.0 | dependency |
129
+ <!-- compatibility:end -->
package/index.d.tilua CHANGED
@@ -26,7 +26,8 @@
26
26
  -- from whatever the executor has. A function executors spell several ways is
27
27
  -- whichever spelling there is — `http.request` is `request`, `http_request`,
28
28
  -- `http.request` or `syn.request` — and one an executor has under none of them
29
- -- raises "... is not available in this executor" when called.
29
+ -- is `nil`, so every member is optional and `if (fs.write)` says whether the
30
+ -- executor has it.
30
31
  --
31
32
  -- No executor implements all of this, and several names mean slightly
32
33
  -- different things between them. Where sUNC and UNC disagree, sUNC's shape is
@@ -60,15 +61,15 @@ type TableFilter = {
60
61
 
61
62
  declare env: {
62
63
  -- The executor's own global table — shared by every script it runs.
63
- getgenv: () => { [string]: unknown },
64
+ getgenv?: () => { [string]: unknown },
64
65
  -- The game's global environment: the `_G` LocalScripts and ModuleScripts see.
65
- getrenv: () => { [string]: unknown },
66
+ getrenv?: () => { [string]: unknown },
66
67
  -- The Luau registry.
67
- getreg: () => { [unknown]: unknown },
68
+ getreg?: () => { [unknown]: unknown },
68
69
  -- Everything the garbage collector is holding. Tables are left out unless
69
70
  -- `includeTables` is true.
70
- getgc: (includeTables?: boolean) => (AnyFunction | { [unknown]: unknown })[],
71
- filtergc: ((kind: "function", filter: FunctionFilter, returnOne: true) => AnyFunction | nil)
71
+ getgc?: (includeTables?: boolean) => (AnyFunction | { [unknown]: unknown })[],
72
+ filtergc?: ((kind: "function", filter: FunctionFilter, returnOne: true) => AnyFunction | nil)
72
73
  & ((kind: "function", filter: FunctionFilter, returnOne?: false) => AnyFunction[])
73
74
  & ((kind: "table", filter: TableFilter, returnOne: true) => { [unknown]: unknown } | nil)
74
75
  & ((kind: "table", filter: TableFilter, returnOne?: false) => { [unknown]: unknown }[]),
@@ -82,32 +83,32 @@ declare closure: {
82
83
  -- Replace what `func` does with `hook`, and give back a callable copy of
83
84
  -- the original. The hook keeps the original's type, so a hooked function
84
85
  -- is still called the way it was. (`hookfunction`, `replaceclosure`)
85
- hook: <T>(func: T, hook: AnyFunction) => T,
86
+ hook?: <T>(func: T, hook: AnyFunction) => T,
86
87
  -- Undo every hook on a function, back to the one it started as. Errors if
87
88
  -- the function was never hooked. (`restorefunction`)
88
- restore: (func: AnyFunction) => void,
89
+ restore?: (func: AnyFunction) => void,
89
90
  -- A copy of `func` that is a distinct function with the same behaviour.
90
91
  -- (`clonefunction`)
91
- clone: <T>(func: T) => T,
92
+ clone?: <T>(func: T) => T,
92
93
  -- Wrap a Luau function so it looks and behaves like a C closure.
93
94
  -- (`newcclosure`)
94
- newcclosure: <T>(func: T) => T,
95
+ newcclosure?: <T>(func: T) => T,
95
96
  -- (`iscclosure`, `islclosure`)
96
- iscclosure: (func: AnyFunction) => boolean,
97
- islclosure: (func: AnyFunction) => boolean,
97
+ iscclosure?: (func: AnyFunction) => boolean,
98
+ islclosure?: (func: AnyFunction) => boolean,
98
99
  -- Was the function made by the executor, rather than the game?
99
100
  -- (`isexecutorclosure`, `isourclosure`, `checkclosure`)
100
- isexecutorclosure: (func: AnyFunction) => boolean,
101
+ isexecutorclosure?: (func: AnyFunction) => boolean,
101
102
  -- Was the caller of the current function the executor, rather than the
102
103
  -- game? (`checkcaller`)
103
- checkcaller: () => boolean,
104
+ checkcaller?: () => boolean,
104
105
  -- A hash of a function's bytecode: two functions that do the same thing
105
106
  -- have the same hash, which is how a hook finds its target across
106
107
  -- updates. (`getfunctionhash`)
107
- hash: (func: AnyFunction) => string,
108
+ hash?: (func: AnyFunction) => string,
108
109
  -- A function's own bytecode, as `scripts.bytecode` gives a script's.
109
110
  -- (`getfunctionbytecode`)
110
- bytecode: (func: AnyFunction) => string,
111
+ bytecode?: (func: AnyFunction) => string,
111
112
  }
112
113
 
113
114
  -- ============================================================
@@ -116,17 +117,17 @@ declare closure: {
116
117
 
117
118
  declare metatable: {
118
119
  -- (`getrawmetatable`, `setrawmetatable`)
119
- getraw: <T>(object: T) => { [unknown]: unknown } | nil,
120
- setraw: <T>(object: T, metatable: { [unknown]: unknown } | nil) => T,
120
+ getraw?: <T>(object: T) => { [unknown]: unknown } | nil,
121
+ setraw?: <T>(object: T, metatable: { [unknown]: unknown } | nil) => T,
121
122
  -- (`isreadonly`, `setreadonly`)
122
- isreadonly: (object: unknown) => boolean,
123
- setreadonly: (object: unknown, readonly: boolean) => void,
123
+ isreadonly?: (object: unknown) => boolean,
124
+ setreadonly?: (object: unknown, readonly: boolean) => void,
124
125
  -- Replace one metamethod of `object`'s metatable, returning the original.
125
126
  -- (`hookmetamethod`)
126
- hook: <T>(object: T, method: string, hook: AnyFunction) => AnyFunction,
127
+ hook?: <T>(object: T, method: string, hook: AnyFunction) => AnyFunction,
127
128
  -- Inside a `__namecall` hook: which method was called.
128
129
  -- (`getnamecallmethod`)
129
- getnamecallmethod: () => string,
130
+ getnamecallmethod?: () => string,
130
131
  }
131
132
 
132
133
  -- ============================================================
@@ -135,25 +136,25 @@ declare metatable: {
135
136
 
136
137
  declare scripts: {
137
138
  -- (`getcallingscript`)
138
- calling: () => BaseScript | nil,
139
+ calling?: () => BaseScript | nil,
139
140
  -- (`getscripts`, `getrunningscripts`, `getloadedmodules`)
140
- all: () => (LocalScript | ModuleScript)[],
141
- running: () => (LocalScript | ModuleScript)[],
142
- loadedmodules: (excludeCore?: boolean) => ModuleScript[],
141
+ all?: () => (LocalScript | ModuleScript)[],
142
+ running?: () => (LocalScript | ModuleScript)[],
143
+ loadedmodules?: (excludeCore?: boolean) => ModuleScript[],
143
144
  -- (`getscriptfromthread`)
144
- fromthread: (thread: thread) => BaseScript | nil,
145
+ fromthread?: (thread: thread) => BaseScript | nil,
145
146
  -- A script's globals, the way the script itself sees them. (`getsenv`)
146
- env: (script: LocalScript | ModuleScript) => { [string]: unknown },
147
+ env?: (script: LocalScript | ModuleScript) => { [string]: unknown },
147
148
  -- (`getscriptbytecode`, `dumpstring`)
148
- bytecode: (script: LocalScript | ModuleScript) => string,
149
+ bytecode?: (script: LocalScript | ModuleScript) => string,
149
150
  -- (`getscriptclosure`, `getscriptfunction`)
150
- closure: (script: LocalScript | ModuleScript) => AnyFunction,
151
+ closure?: (script: LocalScript | ModuleScript) => AnyFunction,
151
152
  -- (`getscripthash`)
152
- hash: (script: LocalScript | ModuleScript) => string,
153
+ hash?: (script: LocalScript | ModuleScript) => string,
153
154
  -- A script's bytecode turned back into Luau source. What comes back is
154
155
  -- the decompiler's reading of it — names of locals are gone — and on
155
156
  -- failure it is a comment saying so rather than an error. (`decompile`)
156
- decompile: (script: LocalScript | ModuleScript | AnyFunction) => string,
157
+ decompile?: (script: LocalScript | ModuleScript | AnyFunction) => string,
157
158
  }
158
159
 
159
160
  -- ============================================================
@@ -162,9 +163,9 @@ declare scripts: {
162
163
 
163
164
  declare identity: {
164
165
  -- (`getthreadidentity`, `getidentity`, `getthreadcontext`)
165
- get: () => number,
166
+ get?: () => number,
166
167
  -- (`setthreadidentity`, `setidentity`, `setthreadcontext`)
167
- set: (identity: number) => void,
168
+ set?: (identity: number) => void,
168
169
  }
169
170
 
170
171
  -- ============================================================
@@ -175,50 +176,50 @@ declare instance: {
175
176
  -- A reference to the same instance that the game's own code cannot
176
177
  -- recognise as yours — what keeps a detection hook from seeing the
177
178
  -- instance you hold. (`cloneref`)
178
- cloneref: <T>(object: T) => T,
179
+ cloneref?: <T>(object: T) => T,
179
180
  -- Two references, one instance? (`compareinstances`)
180
- compare: (a: Instance, b: Instance) => boolean,
181
+ compare?: (a: Instance, b: Instance) => boolean,
181
182
  -- Every instance in the data model, and those parented to nil.
182
183
  -- (`getinstances`, `getnilinstances`)
183
- all: () => Instance[],
184
- nilparented: () => Instance[],
184
+ all?: () => Instance[],
185
+ nilparented?: () => Instance[],
185
186
  -- A hidden container for the executor's own UI, which the game cannot
186
187
  -- see. (`gethui`)
187
- gethui: () => Folder,
188
+ gethui?: () => Folder,
188
189
  -- Properties the engine hides from scripts: `Instance.Archivable`-style
189
190
  -- flags, and anything marked not scriptable. `gethidden` answers the value
190
191
  -- and whether it was hidden. (`gethiddenproperty`, `sethiddenproperty`,
191
192
  -- `isscriptable`, `setscriptable`)
192
- gethidden: (object: Instance, property: string) => [unknown, boolean],
193
- sethidden: (object: Instance, property: string, value: unknown) => boolean,
194
- isscriptable: (object: Instance, property: string) => boolean,
195
- setscriptable: (object: Instance, property: string, scriptable: boolean) => boolean,
193
+ gethidden?: (object: Instance, property: string) => [unknown, boolean],
194
+ sethidden?: (object: Instance, property: string, value: unknown) => boolean,
195
+ isscriptable?: (object: Instance, property: string) => boolean,
196
+ setscriptable?: (object: Instance, property: string, scriptable: boolean) => boolean,
196
197
  -- The function assigned to a callback property (`OnServerInvoke`, ...).
197
198
  -- (`getcallbackvalue`)
198
- getcallback: (object: Instance, property: string) => AnyFunction | nil,
199
+ getcallback?: (object: Instance, property: string) => AnyFunction | nil,
199
200
  -- (`fireclickdetector`, `fireproximityprompt`)
200
- fireclickdetector: (object: ClickDetector, distance?: number, event?: string) => void,
201
- fireproximityprompt: (prompt: ProximityPrompt) => void,
201
+ fireclickdetector?: (object: ClickDetector, distance?: number, event?: string) => void,
202
+ fireproximityprompt?: (prompt: ProximityPrompt) => void,
202
203
  -- `toggle` is true (or 0) to begin the touch and false (or 1) to end it.
203
204
  -- (`firetouchinterest`)
204
- firetouch: (part: BasePart, other: BasePart, toggle: boolean | number) => void,
205
+ firetouch?: (part: BasePart, other: BasePart, toggle: boolean | number) => void,
205
206
  -- `game:GetObjects`, which a script may not call itself. (`getobjects`)
206
- getobjects: (assetId: string) => Instance[],
207
+ getobjects?: (assetId: string) => Instance[],
207
208
  -- Does this client simulate the part's physics? (`isnetworkowner`)
208
- isnetworkowner: (part: BasePart) => boolean,
209
+ isnetworkowner?: (part: BasePart) => boolean,
209
210
  -- Write the place, or one instance and what is under it, to a file in the
210
211
  -- workspace folder. The options are the executor's own (`mode`,
211
212
  -- `noscripts`, `FilePath`, ...), so they are left open. (`saveinstance`)
212
- save: (target?: Instance | { [string]: unknown }, options?: { [string]: unknown }) => void,
213
+ save?: (target?: Instance | { [string]: unknown }, options?: { [string]: unknown }) => void,
213
214
  }
214
215
 
215
216
  declare cache: {
216
217
  -- Forget an instance, so the next reference to it is a new one.
217
- invalidate: (object: Instance) => void,
218
+ invalidate?: (object: Instance) => void,
218
219
  -- Point every future reference to `object` at `newObject` instead.
219
- replace: (object: Instance, newObject: Instance) => void,
220
+ replace?: (object: Instance, newObject: Instance) => void,
220
221
  -- (`cache.iscached`)
221
- iscached: (object: Instance) => boolean,
222
+ iscached?: (object: Instance) => boolean,
222
223
  }
223
224
 
224
225
  -- ============================================================
@@ -247,12 +248,12 @@ type AnySignal = { Connect: (self: unknown, callback: (...args: unknown[]) => vo
247
248
 
248
249
  declare signal: {
249
250
  -- (`getconnections`)
250
- connections: (signal: AnySignal) => Connection[],
251
+ connections?: (signal: AnySignal) => Connection[],
251
252
  -- Run every Luau connection of a signal now. (`firesignal`)
252
- fire: (signal: AnySignal, ...args: unknown[]) => void,
253
+ fire?: (signal: AnySignal, ...args: unknown[]) => void,
253
254
  -- Send a signal to the server, for the signals that replicate.
254
255
  -- (`replicatesignal`)
255
- replicate: (signal: AnySignal, ...args: unknown[]) => void,
256
+ replicate?: (signal: AnySignal, ...args: unknown[]) => void,
256
257
  }
257
258
 
258
259
  -- ============================================================
@@ -263,24 +264,24 @@ declare signal: {
263
264
 
264
265
  declare fs: {
265
266
  -- (`readfile`, `writefile`, `appendfile`, `delfile`, `isfile`, `listfiles`)
266
- read: (path: string) => string,
267
- write: (path: string, data: string) => void,
268
- append: (path: string, data: string) => void,
269
- delete: (path: string) => void,
270
- isfile: (path: string) => boolean,
271
- list: (path: string) => string[],
267
+ read?: (path: string) => string,
268
+ write?: (path: string, data: string) => void,
269
+ append?: (path: string, data: string) => void,
270
+ delete?: (path: string) => void,
271
+ isfile?: (path: string) => boolean,
272
+ list?: (path: string) => string[],
272
273
  -- (`makefolder`, `delfolder`, `isfolder`)
273
- makefolder: (path: string) => void,
274
- deletefolder: (path: string) => void,
275
- isfolder: (path: string) => boolean,
274
+ makefolder?: (path: string) => void,
275
+ deletefolder?: (path: string) => void,
276
+ isfolder?: (path: string) => boolean,
276
277
  -- Run a file. (`dofile`)
277
- dofile: (path: string) => void,
278
+ dofile?: (path: string) => void,
278
279
  -- Compile a file without running it, as `loadstring` does a string.
279
280
  -- (`loadfile`)
280
- loadfile: (path: string, chunkname?: string) => [AnyFunction | nil, string | nil],
281
+ loadfile?: (path: string, chunkname?: string) => [AnyFunction | nil, string | nil],
281
282
  -- A `rbxasset://` id for a file on disk, usable wherever the engine takes
282
283
  -- a content id (images, sounds, meshes). (`getcustomasset`)
283
- getcustomasset: (path: string, noCache?: boolean) => string,
284
+ getcustomasset?: (path: string, noCache?: boolean) => string,
284
285
  }
285
286
 
286
287
  -- ============================================================
@@ -337,7 +338,7 @@ declare http: {
337
338
  -- }))
338
339
  --
339
340
  -- (`request`, `http_request`, `http.request`, `syn.request`, `fluxus.request`)
340
- request: ((options: HttpRequest) => HttpResponse)
341
+ request?: ((options: HttpRequest) => HttpResponse)
341
342
  & ((build: (types: HttpTypes) => HttpBuiltRequest) => HttpResponse),
342
343
  }
343
344
 
@@ -350,7 +351,7 @@ type WebSocketConnection = {
350
351
 
351
352
  declare websocket: {
352
353
  -- (`WebSocket.connect`)
353
- connect: (url: string) => WebSocketConnection,
354
+ connect?: (url: string) => WebSocketConnection,
354
355
  }
355
356
 
356
357
  -- ============================================================
@@ -360,21 +361,21 @@ declare websocket: {
360
361
  declare encoding: {
361
362
  -- (`base64encode`, `crypt.base64encode`, `crypt.base64_encode`,
362
363
  -- `crypt.base64.encode`, `base64.encode`, and the same for decode)
363
- base64encode: (data: string) => string,
364
- base64decode: (data: string) => string,
364
+ base64encode?: (data: string) => string,
365
+ base64decode?: (data: string) => string,
365
366
  -- (`lz4compress`, `lz4decompress`)
366
- lz4compress: (data: string) => string,
367
- lz4decompress: (data: string, size: number) => string,
367
+ lz4compress?: (data: string) => string,
368
+ lz4decompress?: (data: string, size: number) => string,
368
369
  }
369
370
 
370
371
  declare crypt: {
371
372
  -- The ciphertext and the iv it used.
372
- encrypt: (data: string, key: string, iv?: string, mode?: string) => [string, string],
373
- decrypt: (data: string, key: string, iv: string, mode: string) => string,
374
- hash: (data: string, algorithm: string) => string,
373
+ encrypt?: (data: string, key: string, iv?: string, mode?: string) => [string, string],
374
+ decrypt?: (data: string, key: string, iv: string, mode: string) => string,
375
+ hash?: (data: string, algorithm: string) => string,
375
376
  -- (`crypt.generatebytes`, `crypt.generatekey`)
376
- generatebytes: (size: number) => string,
377
- generatekey: () => string,
377
+ generatebytes?: (size: number) => string,
378
+ generatekey?: () => string,
378
379
  }
379
380
 
380
381
  -- ============================================================
@@ -423,7 +424,7 @@ type Drawing = DrawingLine | DrawingText | DrawingImage | DrawingCircle
423
424
 
424
425
  declare drawing: {
425
426
  -- (`Drawing.new`)
426
- new: ((kind: "Line") => DrawingLine)
427
+ new?: ((kind: "Line") => DrawingLine)
427
428
  & ((kind: "Text") => DrawingText)
428
429
  & ((kind: "Image") => DrawingImage)
429
430
  & ((kind: "Circle") => DrawingCircle)
@@ -431,14 +432,14 @@ declare drawing: {
431
432
  & ((kind: "Quad") => DrawingQuad)
432
433
  & ((kind: "Triangle") => DrawingTriangle),
433
434
  -- (`Drawing.Fonts`)
434
- fonts: { UI: number, System: number, Plex: number, Monospace: number },
435
+ fonts?: { UI: number, System: number, Plex: number, Monospace: number },
435
436
  -- Destroy every drawing at once; references to them stop working.
436
437
  -- (`cleardrawcache`)
437
- clear: () => void,
438
+ clear?: () => void,
438
439
  -- (`getrenderproperty`, `setrenderproperty`, `isrenderobj`)
439
- getproperty: (drawing: Drawing, property: string) => unknown,
440
- setproperty: (drawing: Drawing, property: string, value: unknown) => void,
441
- isdrawing: (object: unknown) => boolean,
440
+ getproperty?: (drawing: Drawing, property: string) => unknown,
441
+ setproperty?: (drawing: Drawing, property: string, value: unknown) => void,
442
+ isdrawing?: (object: unknown) => boolean,
442
443
  }
443
444
 
444
445
  -- ============================================================
@@ -448,12 +449,12 @@ declare drawing: {
448
449
  declare rconsole: {
449
450
  -- (`rconsolecreate` ... `rconsoleinput`, and the same without the `r`;
450
451
  -- `rconsolename` for `settitle`)
451
- create: () => void,
452
- destroy: () => void,
453
- clear: () => void,
454
- print: (text: string) => void,
455
- settitle: (title: string) => void,
456
- input: () => string,
452
+ create?: () => void,
453
+ destroy?: () => void,
454
+ clear?: () => void,
455
+ print?: (text: string) => void,
456
+ settitle?: (title: string) => void,
457
+ input?: () => string,
457
458
  }
458
459
 
459
460
  -- ============================================================
@@ -465,23 +466,23 @@ declare rconsole: {
465
466
 
466
467
  declare input: {
467
468
  -- (`isrbxactive`, `isgameactive`)
468
- isactive: () => boolean,
469
+ isactive?: () => boolean,
469
470
  -- (`mouse1click`, `mouse1press`, ...)
470
- mouse1click: () => void,
471
- mouse1press: () => void,
472
- mouse1release: () => void,
473
- mouse2click: () => void,
474
- mouse2press: () => void,
475
- mouse2release: () => void,
471
+ mouse1click?: () => void,
472
+ mouse1press?: () => void,
473
+ mouse1release?: () => void,
474
+ mouse2click?: () => void,
475
+ mouse2press?: () => void,
476
+ mouse2release?: () => void,
476
477
  -- (`mousemoveabs`, `mousemoverel`, `mousescroll`)
477
- mousemoveabs: (x: number, y: number) => void,
478
- mousemoverel: (x: number, y: number) => void,
479
- mousescroll: (pixels: number) => void,
478
+ mousemoveabs?: (x: number, y: number) => void,
479
+ mousemoverel?: (x: number, y: number) => void,
480
+ mousescroll?: (pixels: number) => void,
480
481
  -- Keys are Windows virtual-key codes (`0x57` is W), not `Enum.KeyCode`.
481
482
  -- (`keypress`, `keyrelease`, `keyclick`)
482
- keypress: (key: number) => void,
483
- keyrelease: (key: number) => void,
484
- keyclick: (key: number) => void,
483
+ keypress?: (key: number) => void,
484
+ keyrelease?: (key: number) => void,
485
+ keyclick?: (key: number) => void,
485
486
  }
486
487
 
487
488
  -- ============================================================
@@ -526,34 +527,34 @@ declare debug: {
526
527
 
527
528
  declare executor: {
528
529
  -- The executor's name and version. (`identifyexecutor`, `getexecutorname`)
529
- identify: () => [string, string],
530
+ identify?: () => [string, string],
530
531
  -- An id for the machine the executor runs on. (`gethwid`)
531
- hwid: () => string,
532
+ hwid?: () => string,
532
533
  -- (`setfpscap`, `getfpscap`)
533
- setfpscap: (fps: number) => void,
534
- getfpscap: () => number,
534
+ setfpscap?: (fps: number) => void,
535
+ getfpscap?: () => number,
535
536
  -- (`messagebox`)
536
- messagebox: (text: string, caption: string, flags: number) => number,
537
+ messagebox?: (text: string, caption: string, flags: number) => number,
537
538
  }
538
539
 
539
540
  declare clipboard: {
540
541
  -- (`setclipboard`, `toclipboard`)
541
- set: (text: string) => void,
542
+ set?: (text: string) => void,
542
543
  -- Roblox Studio's clipboard, of instances. (`setrbxclipboard`)
543
- setrbx: (data: string) => boolean,
544
+ setrbx?: (data: string) => boolean,
544
545
  }
545
546
 
546
547
  declare teleport: {
547
548
  -- Source to run after the next teleport, in the new place.
548
549
  -- (`queue_on_teleport`, `queueonteleport`, `queueteleport`)
549
- queue: (code: string) => void,
550
+ queue?: (code: string) => void,
550
551
  }
551
552
 
552
553
  -- Parallel Luau: the actors of the game, and code run inside one — each actor
553
554
  -- is a Luau state of its own, which a script outside cannot reach.
554
555
  declare actor: {
555
556
  -- (`getactors`, `run_on_actor`, `isparallel`)
556
- all: () => Actor[],
557
- run: (actor: Actor, code: string, ...args: unknown[]) => void,
558
- isparallel: () => boolean,
557
+ all?: () => Actor[],
558
+ run?: (actor: Actor, code: string, ...args: unknown[]) => void,
559
+ isparallel?: () => boolean,
559
560
  }
package/lowering.mjs CHANGED
@@ -10,6 +10,9 @@
10
10
  * fs.read("a.txt") -> tilua_sunc.fs.read("a.txt")
11
11
  * const files = fs -> local files = tilua_sunc.fs
12
12
  *
13
+ * A function the executor has under none of its spellings is `nil` in its
14
+ * namespace, as it would be in a script looking for it by hand.
15
+ *
13
16
  * The runtime's functions also answer several Luau values as tilua has them
14
17
  * (`executor.identify()` is one array), and `http.request(types => ...)` builds
15
18
  * a body that holds what a Luau table cannot.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tilua-types/sunc",
3
- "version": "8.0.0",
3
+ "version": "10.0.0",
4
4
  "description": "The script-executor environment as tilua types: sUNC and UNC names (getgenv, writefile, hookfunction, Drawing, ...)",
5
5
  "license": "ISC",
6
6
  "files": [
@@ -14,7 +14,7 @@
14
14
  "lowering": "lowering.mjs"
15
15
  },
16
16
  "dependencies": {
17
- "@tilua-types/roblox": "^8.0.0"
17
+ "@tilua-types/roblox": "^9.0.0"
18
18
  },
19
19
  "keywords": [
20
20
  "tilua",
package/runtime/sunc.luau CHANGED
@@ -1,278 +1,277 @@
1
- local __NAME__ = {}
2
-
3
- -- The namespaces of index.d.tilua — `env`, `file`, `closure`, ... — built from
4
- -- whatever the executor has. The compiler reads each namespace from here: none
5
- -- of them is the executor's own global, and most executors have none of them.
6
- --
7
- -- Each function is looked up once, as the script starts, under every spelling
8
- -- executors use for it; the first one there is the one called. With none of
9
- -- them, calling it says so, rather than "attempt to call a nil value".
10
-
11
- local function missing(name)
12
- return function()
13
- error(name .. " is not available in this executor", 2)
14
- end
15
- end
16
-
17
- local function pick(name, ...)
18
- for i = 1, select("#", ...) do
19
- local found = select(i, ...)
20
- if found ~= nil then
21
- return found
22
- end
23
- end
24
- return missing(name)
25
- end
26
-
27
- -- `t[key]`, where `t` may not be a table at all — `syn.request` in an
28
- -- executor with no `syn`.
29
- local function field(t, key)
30
- if type(t) == "table" then
31
- return t[key]
32
- end
33
- return nil
34
- end
35
-
36
- -- A function whose Luau answer is several values, answering them as tilua
37
- -- has them: one array.
38
- local function gathered(f)
39
- return function(...)
40
- return { f(...) }
41
- end
42
- end
43
-
44
- -- ============================================================
45
- -- Namespaces
46
- -- ============================================================
47
-
48
- __NAME__.env = {
49
- getgenv = pick("env.getgenv", getgenv),
50
- getrenv = pick("env.getrenv", getrenv),
51
- getreg = pick("env.getreg", getreg),
52
- getgc = pick("env.getgc", getgc),
53
- filtergc = pick("env.filtergc", filtergc),
54
- }
55
-
56
- __NAME__.closure = {
57
- hook = pick("closure.hook", hookfunction, replaceclosure),
58
- restore = pick("closure.restore", restorefunction),
59
- clone = pick("closure.clone", clonefunction),
60
- newcclosure = pick("closure.newcclosure", newcclosure),
61
- iscclosure = pick("closure.iscclosure", iscclosure),
62
- islclosure = pick("closure.islclosure", islclosure),
63
- isexecutorclosure = pick("closure.isexecutorclosure", isexecutorclosure, isourclosure, checkclosure),
64
- checkcaller = pick("closure.checkcaller", checkcaller),
65
- hash = pick("closure.hash", getfunctionhash),
66
- bytecode = pick("closure.bytecode", getfunctionbytecode),
67
- }
68
-
69
- __NAME__.metatable = {
70
- getraw = pick("metatable.getraw", getrawmetatable),
71
- setraw = pick("metatable.setraw", setrawmetatable),
72
- isreadonly = pick("metatable.isreadonly", isreadonly),
73
- setreadonly = pick("metatable.setreadonly", setreadonly),
74
- hook = pick("metatable.hook", hookmetamethod),
75
- getnamecallmethod = pick("metatable.getnamecallmethod", getnamecallmethod),
76
- }
77
-
78
- __NAME__.scripts = {
79
- calling = pick("scripts.calling", getcallingscript),
80
- all = pick("scripts.all", getscripts),
81
- running = pick("scripts.running", getrunningscripts),
82
- loadedmodules = pick("scripts.loadedmodules", getloadedmodules),
83
- fromthread = pick("scripts.fromthread", getscriptfromthread),
84
- env = pick("scripts.env", getsenv),
85
- bytecode = pick("scripts.bytecode", getscriptbytecode, dumpstring),
86
- closure = pick("scripts.closure", getscriptclosure, getscriptfunction),
87
- hash = pick("scripts.hash", getscripthash),
88
- decompile = pick("scripts.decompile", decompile),
89
- }
90
-
91
- __NAME__.identity = {
92
- get = pick("identity.get", getthreadidentity, getidentity, getthreadcontext),
93
- set = pick("identity.set", setthreadidentity, setidentity, setthreadcontext),
94
- }
95
-
96
- local gethidden = pick("instance.gethidden", gethiddenproperty)
97
-
98
- __NAME__.instance = {
99
- cloneref = pick("instance.cloneref", cloneref),
100
- compare = pick("instance.compare", compareinstances),
101
- all = pick("instance.all", getinstances),
102
- nilparented = pick("instance.nilparented", getnilinstances),
103
- gethui = pick("instance.gethui", gethui),
104
- gethidden = gathered(gethidden),
105
- sethidden = pick("instance.sethidden", sethiddenproperty),
106
- isscriptable = pick("instance.isscriptable", isscriptable),
107
- setscriptable = pick("instance.setscriptable", setscriptable),
108
- getcallback = pick("instance.getcallback", getcallbackvalue),
109
- fireclickdetector = pick("instance.fireclickdetector", fireclickdetector),
110
- fireproximityprompt = pick("instance.fireproximityprompt", fireproximityprompt),
111
- firetouch = pick("instance.firetouch", firetouchinterest),
112
- getobjects = pick("instance.getobjects", getobjects),
113
- isnetworkowner = pick("instance.isnetworkowner", isnetworkowner),
114
- save = pick("instance.save", saveinstance),
115
- }
116
-
117
- __NAME__.cache = {
118
- invalidate = pick("cache.invalidate", field(cache, "invalidate")),
119
- replace = pick("cache.replace", field(cache, "replace")),
120
- iscached = pick("cache.iscached", field(cache, "iscached")),
121
- }
122
-
123
- __NAME__.signal = {
124
- connections = pick("signal.connections", getconnections),
125
- fire = pick("signal.fire", firesignal),
126
- replicate = pick("signal.replicate", replicatesignal),
127
- }
128
-
129
- local loadfileOf = pick("fs.loadfile", loadfile)
130
-
131
- __NAME__.fs = {
132
- read = pick("fs.read", readfile),
133
- write = pick("fs.write", writefile),
134
- append = pick("fs.append", appendfile),
135
- delete = pick("fs.delete", delfile),
136
- isfile = pick("fs.isfile", isfile),
137
- list = pick("fs.list", listfiles),
138
- makefolder = pick("fs.makefolder", makefolder),
139
- deletefolder = pick("fs.deletefolder", delfolder),
140
- isfolder = pick("fs.isfolder", isfolder),
141
- dofile = pick("fs.dofile", dofile),
142
- loadfile = function(path, chunkname)
143
- local f, message = loadfileOf(path, chunkname)
144
- return { f, message }
145
- end,
146
- getcustomasset = pick("fs.getcustomasset", getcustomasset),
147
- }
148
-
149
- __NAME__.websocket = {
150
- connect = pick("websocket.connect", field(WebSocket, "connect"), field(WebSocket, "Connect")),
151
- }
152
-
153
- __NAME__.encoding = {
154
- base64encode = pick("encoding.base64encode", base64encode, field(crypt, "base64encode"), field(crypt, "base64_encode"),
155
- field(field(crypt, "base64"), "encode"), field(base64, "encode"), base64_encode),
156
- base64decode = pick("encoding.base64decode", base64decode, field(crypt, "base64decode"), field(crypt, "base64_decode"),
157
- field(field(crypt, "base64"), "decode"), field(base64, "decode"), base64_decode),
158
- lz4compress = pick("encoding.lz4compress", lz4compress),
159
- lz4decompress = pick("encoding.lz4decompress", lz4decompress),
160
- }
161
-
162
- __NAME__.crypt = {
163
- encrypt = gathered(pick("crypt.encrypt", field(crypt, "encrypt"))),
164
- decrypt = pick("crypt.decrypt", field(crypt, "decrypt")),
165
- hash = pick("crypt.hash", field(crypt, "hash")),
166
- generatebytes = pick("crypt.generatebytes", field(crypt, "generatebytes")),
167
- generatekey = pick("crypt.generatekey", field(crypt, "generatekey")),
168
- }
169
-
170
- __NAME__.drawing = {
171
- new = pick("drawing.new", field(Drawing, "new")),
172
- fonts = field(Drawing, "Fonts"),
173
- clear = pick("drawing.clear", cleardrawcache),
174
- getproperty = pick("drawing.getproperty", getrenderproperty),
175
- setproperty = pick("drawing.setproperty", setrenderproperty),
176
- isdrawing = pick("drawing.isdrawing", isrenderobj),
177
- }
178
-
179
- __NAME__.rconsole = {
180
- create = pick("rconsole.create", rconsolecreate, consolecreate),
181
- destroy = pick("rconsole.destroy", rconsoledestroy, consoledestroy),
182
- clear = pick("rconsole.clear", rconsoleclear, consoleclear),
183
- print = pick("rconsole.print", rconsoleprint, consoleprint),
184
- settitle = pick("rconsole.settitle", rconsolesettitle, rconsolename, consolesettitle),
185
- input = pick("rconsole.input", rconsoleinput, consoleinput),
186
- }
187
-
188
- __NAME__.input = {
189
- isactive = pick("input.isactive", isrbxactive, isgameactive),
190
- mouse1click = pick("input.mouse1click", mouse1click),
191
- mouse1press = pick("input.mouse1press", mouse1press),
192
- mouse1release = pick("input.mouse1release", mouse1release),
193
- mouse2click = pick("input.mouse2click", mouse2click),
194
- mouse2press = pick("input.mouse2press", mouse2press),
195
- mouse2release = pick("input.mouse2release", mouse2release),
196
- mousemoveabs = pick("input.mousemoveabs", mousemoveabs),
197
- mousemoverel = pick("input.mousemoverel", mousemoverel),
198
- mousescroll = pick("input.mousescroll", mousescroll),
199
- keypress = pick("input.keypress", keypress),
200
- keyrelease = pick("input.keyrelease", keyrelease),
201
- keyclick = pick("input.keyclick", keyclick),
202
- }
203
-
204
- __NAME__.executor = {
205
- identify = gathered(pick("executor.identify", identifyexecutor, getexecutorname)),
206
- hwid = pick("executor.hwid", gethwid),
207
- setfpscap = pick("executor.setfpscap", setfpscap),
208
- getfpscap = pick("executor.getfpscap", getfpscap),
209
- messagebox = pick("executor.messagebox", messagebox),
210
- }
211
-
212
- __NAME__.clipboard = {
213
- set = pick("clipboard.set", setclipboard, toclipboard),
214
- setrbx = pick("clipboard.setrbx", setrbxclipboard),
215
- }
216
-
217
- __NAME__.teleport = {
218
- queue = pick("teleport.queue", queue_on_teleport, queueonteleport, queueteleport, field(syn, "queue_on_teleport")),
219
- }
220
-
221
- __NAME__.actor = {
222
- all = pick("actor.all", getactors),
223
- run = pick("actor.run", run_on_actor),
224
- isparallel = pick("actor.isparallel", isparallel),
225
- }
226
-
227
- -- ============================================================
228
- -- http.request(types => ...)
229
- -- ============================================================
230
- --
231
- -- What a request body can hold that a Luau table cannot: a key whose value
232
- -- is nil. A body built by a function may hold `types.null` and
233
- -- `types.undefined` for it, and a body that is a table is sent as JSON —
234
- -- the language's (`__JSON__`), which writes them as what they say, and
235
- -- `[]` and `{}` as what they are.
236
-
237
- local send = pick("http.request", request, http_request, field(http, "request"), field(syn, "request"), field(fluxus, "request"))
238
-
239
- local types = { null = __JSON__.null, undefined = __JSON__.undefined }
240
-
241
- local function hasHeader(headers, name)
242
- for key in pairs(headers) do
243
- if type(key) == "string" and key:lower() == name then
244
- return true
245
- end
246
- end
247
- return false
248
- end
249
-
250
- -- The request a function built, as the executor's `request` takes it.
251
- local function built(options)
252
- if options.Body == nil or type(options.Body) == "string" then
253
- return options
254
- end
255
- local copy = {}
256
- for key, value in pairs(options) do
257
- copy[key] = value
258
- end
259
- copy.Body = __JSON__.encode(options.Body)
260
- local headers = {}
261
- for key, value in pairs(options.Headers or {}) do
262
- headers[key] = value
263
- end
264
- if not hasHeader(headers, "content-type") then
265
- headers["Content-Type"] = "application/json"
266
- end
267
- copy.Headers = headers
268
- return copy
269
- end
270
-
271
- __NAME__.http = {
272
- request = function(options)
273
- if type(options) == "function" then
274
- return send(built(options(types)))
275
- end
276
- return send(options)
277
- end,
278
- }
1
+ local __NAME__ = {}
2
+
3
+ -- The namespaces of index.d.tilua — `env`, `file`, `closure`, ... — built from
4
+ -- whatever the executor has. The compiler reads each namespace from here: none
5
+ -- of them is the executor's own global, and most executors have none of them.
6
+ --
7
+ -- Each function is looked up once, as the script starts, under every spelling
8
+ -- executors use for it; the first one there is the one called. With none of
9
+ -- them it is nil — and a name that is there but is not a function (a table, a
10
+ -- stub value) counts as not there. The namespace holds no function the executor
11
+ -- does not have, so `if (fs.write)` says whether it does.
12
+
13
+ local function pick(...)
14
+ for i = 1, select("#", ...) do
15
+ local found = select(i, ...)
16
+ if type(found) == "function" then
17
+ return found
18
+ end
19
+ end
20
+ return nil
21
+ end
22
+
23
+ -- `t[key]`, where `t` may not be a table at all — `syn.request` in an
24
+ -- executor with no `syn`.
25
+ local function field(t, key)
26
+ if type(t) == "table" then
27
+ return t[key]
28
+ end
29
+ return nil
30
+ end
31
+
32
+ -- A function whose Luau answer is several values, answering them as tilua
33
+ -- has them: one array.
34
+ local function gathered(f)
35
+ if f == nil then
36
+ return nil
37
+ end
38
+ return function(...)
39
+ return { f(...) }
40
+ end
41
+ end
42
+
43
+ -- ============================================================
44
+ -- Namespaces
45
+ -- ============================================================
46
+
47
+ __NAME__.env = {
48
+ getgenv = pick(getgenv),
49
+ getrenv = pick(getrenv),
50
+ getreg = pick(getreg),
51
+ getgc = pick(getgc),
52
+ filtergc = pick(filtergc),
53
+ }
54
+
55
+ __NAME__.closure = {
56
+ hook = pick(hookfunction, replaceclosure),
57
+ restore = pick(restorefunction),
58
+ clone = pick(clonefunction),
59
+ newcclosure = pick(newcclosure),
60
+ iscclosure = pick(iscclosure),
61
+ islclosure = pick(islclosure),
62
+ isexecutorclosure = pick(isexecutorclosure, isourclosure, checkclosure),
63
+ checkcaller = pick(checkcaller),
64
+ hash = pick(getfunctionhash),
65
+ bytecode = pick(getfunctionbytecode),
66
+ }
67
+
68
+ __NAME__.metatable = {
69
+ getraw = pick(getrawmetatable),
70
+ setraw = pick(setrawmetatable),
71
+ isreadonly = pick(isreadonly),
72
+ setreadonly = pick(setreadonly),
73
+ hook = pick(hookmetamethod),
74
+ getnamecallmethod = pick(getnamecallmethod),
75
+ }
76
+
77
+ __NAME__.scripts = {
78
+ calling = pick(getcallingscript),
79
+ all = pick(getscripts),
80
+ running = pick(getrunningscripts),
81
+ loadedmodules = pick(getloadedmodules),
82
+ fromthread = pick(getscriptfromthread),
83
+ env = pick(getsenv),
84
+ bytecode = pick(getscriptbytecode, dumpstring),
85
+ closure = pick(getscriptclosure, getscriptfunction),
86
+ hash = pick(getscripthash),
87
+ decompile = pick(decompile),
88
+ }
89
+
90
+ __NAME__.identity = {
91
+ get = pick(getthreadidentity, getidentity, getthreadcontext),
92
+ set = pick(setthreadidentity, setidentity, setthreadcontext),
93
+ }
94
+
95
+ local gethidden = pick(gethiddenproperty)
96
+
97
+ __NAME__.instance = {
98
+ cloneref = pick(cloneref),
99
+ compare = pick(compareinstances),
100
+ all = pick(getinstances),
101
+ nilparented = pick(getnilinstances),
102
+ gethui = pick(gethui),
103
+ gethidden = gathered(gethidden),
104
+ sethidden = pick(sethiddenproperty),
105
+ isscriptable = pick(isscriptable),
106
+ setscriptable = pick(setscriptable),
107
+ getcallback = pick(getcallbackvalue),
108
+ fireclickdetector = pick(fireclickdetector),
109
+ fireproximityprompt = pick(fireproximityprompt),
110
+ firetouch = pick(firetouchinterest),
111
+ getobjects = pick(getobjects),
112
+ isnetworkowner = pick(isnetworkowner),
113
+ save = pick(saveinstance),
114
+ }
115
+
116
+ __NAME__.cache = {
117
+ invalidate = pick(field(cache, "invalidate")),
118
+ replace = pick(field(cache, "replace")),
119
+ iscached = pick(field(cache, "iscached")),
120
+ }
121
+
122
+ __NAME__.signal = {
123
+ connections = pick(getconnections),
124
+ fire = pick(firesignal),
125
+ replicate = pick(replicatesignal),
126
+ }
127
+
128
+ local loadfileOf = pick(loadfile)
129
+
130
+ __NAME__.fs = {
131
+ read = pick(readfile),
132
+ write = pick(writefile),
133
+ append = pick(appendfile),
134
+ delete = pick(delfile),
135
+ isfile = pick(isfile),
136
+ list = pick(listfiles),
137
+ makefolder = pick(makefolder),
138
+ deletefolder = pick(delfolder),
139
+ isfolder = pick(isfolder),
140
+ dofile = pick(dofile),
141
+ loadfile = loadfileOf and function(path, chunkname)
142
+ local f, message = loadfileOf(path, chunkname)
143
+ return { f, message }
144
+ end or nil,
145
+ getcustomasset = pick(getcustomasset),
146
+ }
147
+
148
+ __NAME__.websocket = {
149
+ connect = pick(field(WebSocket, "connect"), field(WebSocket, "Connect")),
150
+ }
151
+
152
+ __NAME__.encoding = {
153
+ base64encode = pick(base64encode, field(crypt, "base64encode"), field(crypt, "base64_encode"),
154
+ field(field(crypt, "base64"), "encode"), field(base64, "encode"), base64_encode),
155
+ base64decode = pick(base64decode, field(crypt, "base64decode"), field(crypt, "base64_decode"),
156
+ field(field(crypt, "base64"), "decode"), field(base64, "decode"), base64_decode),
157
+ lz4compress = pick(lz4compress),
158
+ lz4decompress = pick(lz4decompress),
159
+ }
160
+
161
+ __NAME__.crypt = {
162
+ encrypt = gathered(pick(field(crypt, "encrypt"))),
163
+ decrypt = pick(field(crypt, "decrypt")),
164
+ hash = pick(field(crypt, "hash")),
165
+ generatebytes = pick(field(crypt, "generatebytes")),
166
+ generatekey = pick(field(crypt, "generatekey")),
167
+ }
168
+
169
+ __NAME__.drawing = {
170
+ new = pick(field(Drawing, "new")),
171
+ fonts = field(Drawing, "Fonts"),
172
+ clear = pick(cleardrawcache),
173
+ getproperty = pick(getrenderproperty),
174
+ setproperty = pick(setrenderproperty),
175
+ isdrawing = pick(isrenderobj),
176
+ }
177
+
178
+ __NAME__.rconsole = {
179
+ create = pick(rconsolecreate, consolecreate),
180
+ destroy = pick(rconsoledestroy, consoledestroy),
181
+ clear = pick(rconsoleclear, consoleclear),
182
+ print = pick(rconsoleprint, consoleprint),
183
+ settitle = pick(rconsolesettitle, rconsolename, consolesettitle),
184
+ input = pick(rconsoleinput, consoleinput),
185
+ }
186
+
187
+ __NAME__.input = {
188
+ isactive = pick(isrbxactive, isgameactive),
189
+ mouse1click = pick(mouse1click),
190
+ mouse1press = pick(mouse1press),
191
+ mouse1release = pick(mouse1release),
192
+ mouse2click = pick(mouse2click),
193
+ mouse2press = pick(mouse2press),
194
+ mouse2release = pick(mouse2release),
195
+ mousemoveabs = pick(mousemoveabs),
196
+ mousemoverel = pick(mousemoverel),
197
+ mousescroll = pick(mousescroll),
198
+ keypress = pick(keypress),
199
+ keyrelease = pick(keyrelease),
200
+ keyclick = pick(keyclick),
201
+ }
202
+
203
+ __NAME__.executor = {
204
+ identify = gathered(pick(identifyexecutor, getexecutorname)),
205
+ hwid = pick(gethwid),
206
+ setfpscap = pick(setfpscap),
207
+ getfpscap = pick(getfpscap),
208
+ messagebox = pick(messagebox),
209
+ }
210
+
211
+ __NAME__.clipboard = {
212
+ set = pick(setclipboard, toclipboard),
213
+ setrbx = pick(setrbxclipboard),
214
+ }
215
+
216
+ __NAME__.teleport = {
217
+ queue = pick(queue_on_teleport, queueonteleport, queueteleport, field(syn, "queue_on_teleport")),
218
+ }
219
+
220
+ __NAME__.actor = {
221
+ all = pick(getactors),
222
+ run = pick(run_on_actor),
223
+ isparallel = pick(isparallel),
224
+ }
225
+
226
+ -- ============================================================
227
+ -- http.request(types => ...)
228
+ -- ============================================================
229
+ --
230
+ -- What a request body can hold that a Luau table cannot: a key whose value
231
+ -- is nil. A body built by a function may hold `types.null` and
232
+ -- `types.undefined` for it, and a body that is a table is sent as JSON —
233
+ -- the language's (`__JSON__`), which writes them as what they say, and
234
+ -- `[]` and `{}` as what they are.
235
+
236
+ local send = pick(request, http_request, field(http, "request"), field(syn, "request"), field(fluxus, "request"))
237
+
238
+ local types = { null = __JSON__.null, undefined = __JSON__.undefined }
239
+
240
+ local function hasHeader(headers, name)
241
+ for key in pairs(headers) do
242
+ if type(key) == "string" and key:lower() == name then
243
+ return true
244
+ end
245
+ end
246
+ return false
247
+ end
248
+
249
+ -- The request a function built, as the executor's `request` takes it.
250
+ local function built(options)
251
+ if options.Body == nil or type(options.Body) == "string" then
252
+ return options
253
+ end
254
+ local copy = {}
255
+ for key, value in pairs(options) do
256
+ copy[key] = value
257
+ end
258
+ copy.Body = __JSON__.encode(options.Body)
259
+ local headers = {}
260
+ for key, value in pairs(options.Headers or {}) do
261
+ headers[key] = value
262
+ end
263
+ if not hasHeader(headers, "content-type") then
264
+ headers["Content-Type"] = "application/json"
265
+ end
266
+ copy.Headers = headers
267
+ return copy
268
+ end
269
+
270
+ __NAME__.http = {
271
+ request = send and function(options)
272
+ if type(options) == "function" then
273
+ return send(built(options(types)))
274
+ end
275
+ return send(options)
276
+ end or nil,
277
+ }