@tilua-types/sunc 4.1.0 → 5.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/index.d.tilua +95 -0
- package/lowering.mjs +1 -1
- package/package.json +2 -2
- package/runtime/sunc.luau +4 -0
package/index.d.tilua
CHANGED
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
-- different things between them. Where sUNC and UNC disagree, sUNC's shape is
|
|
16
16
|
-- the one written down; where only UNC has a name (`crypt`, the `rconsole`
|
|
17
17
|
-- family, mouse input), it is kept, since executors still expose it.
|
|
18
|
+
--
|
|
19
|
+
-- The other spellings UNC lists for a name (`http_request`, `getidentity`,
|
|
20
|
+
-- `queueonteleport`, ...) are declared beside it, and the names every executor
|
|
21
|
+
-- has that neither standard writes down — `decompile`, `saveinstance`, the
|
|
22
|
+
-- keyboard — are at the end.
|
|
18
23
|
|
|
19
24
|
-- ============================================================
|
|
20
25
|
-- Environment
|
|
@@ -75,6 +80,7 @@ declare function restorefunction(func: (...args: unknown[]) => unknown): nil
|
|
|
75
80
|
|
|
76
81
|
-- A copy of `func` that is a distinct function with the same behaviour.
|
|
77
82
|
declare function clonefunction<T>(func: T): T
|
|
83
|
+
declare function replaceclosure<T>(func: T, hook: (...args: unknown[]) => unknown): T
|
|
78
84
|
|
|
79
85
|
-- Wrap a Luau function so it looks and behaves like a C closure.
|
|
80
86
|
declare function newcclosure<T>(func: T): T
|
|
@@ -85,6 +91,8 @@ declare function checkcaller(): boolean
|
|
|
85
91
|
declare function iscclosure(func: (...args: unknown[]) => unknown): boolean
|
|
86
92
|
declare function islclosure(func: (...args: unknown[]) => unknown): boolean
|
|
87
93
|
declare function isexecutorclosure(func: (...args: unknown[]) => unknown): boolean
|
|
94
|
+
declare function isourclosure(func: (...args: unknown[]) => unknown): boolean
|
|
95
|
+
declare function checkclosure(func: (...args: unknown[]) => unknown): boolean
|
|
88
96
|
|
|
89
97
|
-- A hash of a function's bytecode: two functions that do the same thing have
|
|
90
98
|
-- the same hash, which is how a hook finds its target across updates.
|
|
@@ -118,10 +126,16 @@ declare function getsenv(script: LocalScript | ModuleScript): { [string]: unknow
|
|
|
118
126
|
declare function getscriptbytecode(script: LocalScript | ModuleScript): string
|
|
119
127
|
declare function getscriptclosure(script: LocalScript | ModuleScript): (...args: unknown[]) => unknown
|
|
120
128
|
declare function getscripthash(script: LocalScript | ModuleScript): string
|
|
129
|
+
declare function getscriptfunction(script: LocalScript | ModuleScript): (...args: unknown[]) => unknown
|
|
130
|
+
declare function dumpstring(script: LocalScript | ModuleScript): string
|
|
121
131
|
|
|
122
132
|
-- The current thread's permission level, and a way to change it.
|
|
123
133
|
declare function getthreadidentity(): number
|
|
124
134
|
declare function setthreadidentity(identity: number): nil
|
|
135
|
+
declare function getidentity(): number
|
|
136
|
+
declare function setidentity(identity: number): nil
|
|
137
|
+
declare function getthreadcontext(): number
|
|
138
|
+
declare function setthreadcontext(identity: number): nil
|
|
125
139
|
|
|
126
140
|
-- ============================================================
|
|
127
141
|
-- Instances
|
|
@@ -244,6 +258,10 @@ type HttpResponse = {
|
|
|
244
258
|
|
|
245
259
|
-- Yields until the response arrives.
|
|
246
260
|
declare function request(options: HttpRequest): HttpResponse
|
|
261
|
+
declare function http_request(options: HttpRequest): HttpResponse
|
|
262
|
+
declare http: {
|
|
263
|
+
request: (options: HttpRequest) => HttpResponse,
|
|
264
|
+
}
|
|
247
265
|
|
|
248
266
|
declare function base64encode(data: string): string
|
|
249
267
|
declare function base64decode(data: string): string
|
|
@@ -254,6 +272,9 @@ declare function lz4decompress(data: string, size: number): string
|
|
|
254
272
|
declare crypt: {
|
|
255
273
|
base64encode: (data: string) => string,
|
|
256
274
|
base64decode: (data: string) => string,
|
|
275
|
+
base64_encode: (data: string) => string,
|
|
276
|
+
base64_decode: (data: string) => string,
|
|
277
|
+
base64: { encode: (data: string) => string, decode: (data: string) => string },
|
|
257
278
|
encrypt: (data: string, key: string, iv?: string, mode?: string) => [string, string],
|
|
258
279
|
decrypt: (data: string, key: string, iv: string, mode: string) => string,
|
|
259
280
|
hash: (data: string, algorithm: string) => string,
|
|
@@ -261,6 +282,11 @@ declare crypt: {
|
|
|
261
282
|
generatekey: () => string,
|
|
262
283
|
}
|
|
263
284
|
|
|
285
|
+
declare base64: {
|
|
286
|
+
encode: (data: string) => string,
|
|
287
|
+
decode: (data: string) => string,
|
|
288
|
+
}
|
|
289
|
+
|
|
264
290
|
type WebSocketConnection = {
|
|
265
291
|
Send: (self: WebSocketConnection, message: string) => nil,
|
|
266
292
|
Close: (self: WebSocketConnection) => nil,
|
|
@@ -344,6 +370,15 @@ declare function rconsoleclear(): nil
|
|
|
344
370
|
declare function rconsoleprint(text: string): nil
|
|
345
371
|
declare function rconsolesettitle(title: string): nil
|
|
346
372
|
declare function rconsoleinput(): string
|
|
373
|
+
declare function rconsolename(title: string): nil
|
|
374
|
+
|
|
375
|
+
-- The same six without the `r`.
|
|
376
|
+
declare function consolecreate(): nil
|
|
377
|
+
declare function consoledestroy(): nil
|
|
378
|
+
declare function consoleclear(): nil
|
|
379
|
+
declare function consoleprint(text: string): nil
|
|
380
|
+
declare function consolesettitle(title: string): nil
|
|
381
|
+
declare function consoleinput(): string
|
|
347
382
|
|
|
348
383
|
-- ============================================================
|
|
349
384
|
-- Input
|
|
@@ -354,6 +389,7 @@ declare function rconsoleinput(): string
|
|
|
354
389
|
-- it is.
|
|
355
390
|
|
|
356
391
|
declare function isrbxactive(): boolean
|
|
392
|
+
declare function isgameactive(): boolean
|
|
357
393
|
declare function mouse1click(): nil
|
|
358
394
|
declare function mouse1press(): nil
|
|
359
395
|
declare function mouse1release(): nil
|
|
@@ -364,6 +400,11 @@ declare function mousemoveabs(x: number, y: number): nil
|
|
|
364
400
|
declare function mousemoverel(x: number, y: number): nil
|
|
365
401
|
declare function mousescroll(pixels: number): nil
|
|
366
402
|
|
|
403
|
+
-- Keys are Windows virtual-key codes (`0x57` is W), not `Enum.KeyCode`.
|
|
404
|
+
declare function keypress(key: number): nil
|
|
405
|
+
declare function keyrelease(key: number): nil
|
|
406
|
+
declare function keyclick(key: number): nil
|
|
407
|
+
|
|
367
408
|
-- ============================================================
|
|
368
409
|
-- Debug
|
|
369
410
|
-- ============================================================
|
|
@@ -372,7 +413,22 @@ declare function mousescroll(pixels: number): nil
|
|
|
372
413
|
-- reaches into a function's own bytecode. Each takes a function, or a stack
|
|
373
414
|
-- level counted from the caller.
|
|
374
415
|
|
|
416
|
+
-- What `debug.getinfo` knows about a function. Executors leave some of these
|
|
417
|
+
-- out.
|
|
418
|
+
type DebugInfo = {
|
|
419
|
+
source: string,
|
|
420
|
+
short_src: string,
|
|
421
|
+
func: (...args: unknown[]) => unknown,
|
|
422
|
+
what: "Lua" | "C",
|
|
423
|
+
currentline: number,
|
|
424
|
+
name: string,
|
|
425
|
+
nups: number,
|
|
426
|
+
numparams: number,
|
|
427
|
+
is_vararg: number,
|
|
428
|
+
}
|
|
429
|
+
|
|
375
430
|
declare debug: {
|
|
431
|
+
getinfo: (func: ((...args: unknown[]) => unknown) | number) => DebugInfo,
|
|
376
432
|
getconstant: (func: ((...args: unknown[]) => unknown) | number, index: number) => unknown,
|
|
377
433
|
getconstants: (func: ((...args: unknown[]) => unknown) | number) => unknown[],
|
|
378
434
|
setconstant: (func: ((...args: unknown[]) => unknown) | number, index: number, value: unknown) => nil,
|
|
@@ -392,10 +448,49 @@ declare debug: {
|
|
|
392
448
|
|
|
393
449
|
-- The executor's name and version.
|
|
394
450
|
declare function identifyexecutor(): [string, string]
|
|
451
|
+
declare function getexecutorname(): [string, string]
|
|
395
452
|
|
|
396
453
|
declare function setclipboard(text: string): nil
|
|
454
|
+
declare function toclipboard(text: string): nil
|
|
397
455
|
declare function setfpscap(fps: number): nil
|
|
456
|
+
declare function getfpscap(): number
|
|
398
457
|
declare function messagebox(text: string, caption: string, flags: number): number
|
|
399
458
|
|
|
400
459
|
-- Source to run after the next teleport, in the new place.
|
|
401
460
|
declare function queue_on_teleport(code: string): nil
|
|
461
|
+
declare function queueonteleport(code: string): nil
|
|
462
|
+
|
|
463
|
+
-- ============================================================
|
|
464
|
+
-- Beyond the standards
|
|
465
|
+
-- ============================================================
|
|
466
|
+
--
|
|
467
|
+
-- In neither sUNC nor UNC, and in nearly every executor all the same. With no
|
|
468
|
+
-- standard to follow, the shapes are the ones executors agree on.
|
|
469
|
+
|
|
470
|
+
-- A script's bytecode turned back into Luau source. What comes back is the
|
|
471
|
+
-- decompiler's reading of it — names of locals are gone — and on failure it is
|
|
472
|
+
-- a comment saying so rather than an error.
|
|
473
|
+
declare function decompile(script: LocalScript | ModuleScript | ((...args: unknown[]) => unknown)): string
|
|
474
|
+
|
|
475
|
+
-- A function's own bytecode, as `getscriptbytecode` gives a script's.
|
|
476
|
+
declare function getfunctionbytecode(func: (...args: unknown[]) => unknown): string
|
|
477
|
+
|
|
478
|
+
-- Write the place, or one instance and what is under it, to a file in the
|
|
479
|
+
-- workspace folder. The options are the executor's own (`mode`, `noscripts`,
|
|
480
|
+
-- `FilePath`, ...), so they are left open.
|
|
481
|
+
declare function saveinstance(target?: Instance | { [string]: unknown }, options?: { [string]: unknown }): nil
|
|
482
|
+
|
|
483
|
+
-- `game:GetObjects`, which a script may not call itself.
|
|
484
|
+
declare function getobjects(assetId: string): Instance[]
|
|
485
|
+
|
|
486
|
+
-- Does this client simulate the part's physics?
|
|
487
|
+
declare function isnetworkowner(part: BasePart): boolean
|
|
488
|
+
|
|
489
|
+
-- An id for the machine the executor runs on.
|
|
490
|
+
declare function gethwid(): string
|
|
491
|
+
|
|
492
|
+
-- Parallel Luau: the actors of the game, and code run inside one — each actor
|
|
493
|
+
-- is a Luau state of its own, which a script outside cannot reach.
|
|
494
|
+
declare function getactors(): Actor[]
|
|
495
|
+
declare function run_on_actor(actor: Actor, code: string, ...args: unknown[]): nil
|
|
496
|
+
declare function isparallel(): boolean
|
package/lowering.mjs
CHANGED
|
@@ -15,7 +15,7 @@ const here = dirname(fileURLToPath(import.meta.url))
|
|
|
15
15
|
const sunc = readFileSync(join(here, "runtime", "sunc.luau"), "utf8")
|
|
16
16
|
|
|
17
17
|
/** The globals the runtime answers for. */
|
|
18
|
-
const GATHERED = new Set(["gethiddenproperty", "loadfile", "identifyexecutor", "crypt.encrypt"])
|
|
18
|
+
const GATHERED = new Set(["gethiddenproperty", "loadfile", "identifyexecutor", "getexecutorname", "crypt.encrypt"])
|
|
19
19
|
|
|
20
20
|
/** @type {(runtime: string, name: string) => string} */
|
|
21
21
|
const member = (runtime, name) => `${runtime}.${name.replace(".", "_")}`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tilua-types/sunc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.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": "^
|
|
17
|
+
"@tilua-types/roblox": "^5.0.1"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"tilua",
|
package/runtime/sunc.luau
CHANGED