luaut-parser 1.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 +129 -0
- package/dist/index.cjs +5582 -0
- package/dist/index.d.cts +1102 -0
- package/dist/index.d.ts +1102 -0
- package/dist/index.js +5489 -0
- package/dist/luau.d.luaut +244 -0
- package/dist/roblox.d.luaut +503 -0
- package/package.json +40 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
-- Roblox ambient definitions, written in luaut.
|
|
2
|
+
--
|
|
3
|
+
-- Layered on top of `luau.d.luaut`, which carries the core language (including
|
|
4
|
+
-- the `type` / `typeof` overloads that drive narrowing). This file adds the
|
|
5
|
+
-- Roblox data types, the Instance class hierarchy, and the globals.
|
|
6
|
+
--
|
|
7
|
+
-- Pass both: `analyzeTypes(program, scopes, { libs: defaultLibs })`.
|
|
8
|
+
--
|
|
9
|
+
-- Nothing here is special-cased in the analyzer. Three declaration-driven
|
|
10
|
+
-- mechanisms do all the work, and you extend them the same way:
|
|
11
|
+
--
|
|
12
|
+
-- * `typeof(v) == "Vector3"` narrows because `typeof` has one overload per
|
|
13
|
+
-- result string, returning that string as a *literal* type.
|
|
14
|
+
-- * `inst:IsA("Model")` narrows because `IsA` is one generic `self is
|
|
15
|
+
-- ClassMap[K]` guard over the class map, and `K` infers the string
|
|
16
|
+
-- literal that was passed.
|
|
17
|
+
-- * `Instance.new("Part")` and `game:GetService("ReplicatedStorage")` are
|
|
18
|
+
-- the same trick: a generic signature indexing a map of names to types.
|
|
19
|
+
-- Services are also plain properties, so `game.ReplicatedStorage` works.
|
|
20
|
+
--
|
|
21
|
+
-- Hand-written baseline, not the full API dump — extend it, or generate your
|
|
22
|
+
-- own from the Roblox API dump and parse it the same way.
|
|
23
|
+
|
|
24
|
+
-- ============================================================
|
|
25
|
+
-- Data types (value types, not Instances)
|
|
26
|
+
-- ============================================================
|
|
27
|
+
|
|
28
|
+
type Vector3 = {
|
|
29
|
+
X: number, Y: number, Z: number,
|
|
30
|
+
Magnitude: number, Unit: Vector3,
|
|
31
|
+
Cross: (self: Vector3, other: Vector3) -> Vector3,
|
|
32
|
+
Dot: (self: Vector3, other: Vector3) -> number,
|
|
33
|
+
Lerp: (self: Vector3, goal: Vector3, alpha: number) -> Vector3,
|
|
34
|
+
}
|
|
35
|
+
type Vector2 = { X: number, Y: number, Magnitude: number, Unit: Vector2 }
|
|
36
|
+
type Color3 = { R: number, G: number, B: number }
|
|
37
|
+
type CFrame = {
|
|
38
|
+
Position: Vector3, LookVector: Vector3, RightVector: Vector3, UpVector: Vector3,
|
|
39
|
+
Inverse: (self: CFrame) -> CFrame,
|
|
40
|
+
}
|
|
41
|
+
type UDim = { Scale: number, Offset: number }
|
|
42
|
+
type UDim2 = { X: UDim, Y: UDim }
|
|
43
|
+
type NumberRange = { Min: number, Max: number }
|
|
44
|
+
type Rect = { Min: Vector2, Max: Vector2, Width: number, Height: number }
|
|
45
|
+
type Ray = { Origin: Vector3, Direction: Vector3, Unit: Ray }
|
|
46
|
+
type Region3 = { CFrame: CFrame, Size: Vector3 }
|
|
47
|
+
type BrickColor = { Number: number, Name: string, Color: Color3 }
|
|
48
|
+
type EnumItem = { Name: string, Value: number, EnumType: unknown }
|
|
49
|
+
type TweenInfo = { Time: number, DelayTime: number, RepeatCount: number, Reverses: boolean }
|
|
50
|
+
type Random = {
|
|
51
|
+
NextNumber: (self: Random, min?: number, max?: number) -> number,
|
|
52
|
+
NextInteger: (self: Random, min: number, max: number) -> number,
|
|
53
|
+
Clone: (self: Random) -> Random,
|
|
54
|
+
}
|
|
55
|
+
type DateTime = {
|
|
56
|
+
UnixTimestamp: number,
|
|
57
|
+
UnixTimestampMillis: number,
|
|
58
|
+
ToIsoDate: (self: DateTime) -> string,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type RBXScriptConnection = { Connected: boolean, Disconnect: (self: RBXScriptConnection) -> () }
|
|
62
|
+
type RBXScriptSignal = {
|
|
63
|
+
Connect: (self: RBXScriptSignal, fn: (...unknown) -> ()) -> RBXScriptConnection,
|
|
64
|
+
Once: (self: RBXScriptSignal, fn: (...unknown) -> ()) -> RBXScriptConnection,
|
|
65
|
+
Wait: (self: RBXScriptSignal) -> ...unknown,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
-- ============================================================
|
|
69
|
+
-- Instance
|
|
70
|
+
-- ------------------------------------------------------------
|
|
71
|
+
-- luaut's type system is structural, so a subclass is written as the parent
|
|
72
|
+
-- intersected with what it adds: `type Model = PVInstance & { ... }`.
|
|
73
|
+
-- ============================================================
|
|
74
|
+
|
|
75
|
+
type Instance = {
|
|
76
|
+
Name: string,
|
|
77
|
+
ClassName: string,
|
|
78
|
+
Parent: Instance | nil,
|
|
79
|
+
Archivable: boolean,
|
|
80
|
+
ChildAdded: RBXScriptSignal,
|
|
81
|
+
ChildRemoved: RBXScriptSignal,
|
|
82
|
+
AncestryChanged: RBXScriptSignal,
|
|
83
|
+
Destroying: RBXScriptSignal,
|
|
84
|
+
|
|
85
|
+
-- One generic guard instead of one overload per class: `K` is inferred as
|
|
86
|
+
-- the string *literal* that was passed (its constraint is a union of
|
|
87
|
+
-- literals, so it is not widened to `string`), and `ClassMap[K]` looks the
|
|
88
|
+
-- class up. Adding a class to `ClassMap` is all it takes.
|
|
89
|
+
IsA: <K extends keyof ClassMap>(self: Instance, className: K) -> self is ClassMap[K],
|
|
90
|
+
|
|
91
|
+
FindFirstChild: (self: Instance, name: string, recursive?: boolean) -> Instance | nil,
|
|
92
|
+
FindFirstChildOfClass: (self: Instance, className: string) -> Instance | nil,
|
|
93
|
+
FindFirstChildWhichIsA: (self: Instance, className: string) -> Instance | nil,
|
|
94
|
+
FindFirstAncestor: (self: Instance, name: string) -> Instance | nil,
|
|
95
|
+
FindFirstAncestorOfClass: (self: Instance, className: string) -> Instance | nil,
|
|
96
|
+
WaitForChild: (self: Instance, name: string, timeout?: number) -> Instance,
|
|
97
|
+
GetChildren: (self: Instance) -> Instance[],
|
|
98
|
+
GetDescendants: (self: Instance) -> Instance[],
|
|
99
|
+
GetFullName: (self: Instance) -> string,
|
|
100
|
+
IsDescendantOf: (self: Instance, ancestor: Instance) -> boolean,
|
|
101
|
+
IsAncestorOf: (self: Instance, descendant: Instance) -> boolean,
|
|
102
|
+
Clone: (self: Instance) -> Instance,
|
|
103
|
+
Destroy: (self: Instance) -> (),
|
|
104
|
+
ClearAllChildren: (self: Instance) -> (),
|
|
105
|
+
GetAttribute: (self: Instance, name: string) -> unknown,
|
|
106
|
+
SetAttribute: (self: Instance, name: string, value: unknown) -> (),
|
|
107
|
+
GetPropertyChangedSignal: (self: Instance, property: string) -> RBXScriptSignal,
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
-- ============================================================
|
|
111
|
+
-- The class hierarchy
|
|
112
|
+
-- ============================================================
|
|
113
|
+
|
|
114
|
+
type PVInstance = Instance & {
|
|
115
|
+
GetPivot: (self: PVInstance) -> CFrame,
|
|
116
|
+
PivotTo: (self: PVInstance, target: CFrame) -> (),
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
type Model = PVInstance & {
|
|
120
|
+
PrimaryPart: BasePart | nil,
|
|
121
|
+
WorldPivot: CFrame,
|
|
122
|
+
GetBoundingBox: (self: Model) -> (CFrame, Vector3),
|
|
123
|
+
GetExtentsSize: (self: Model) -> Vector3,
|
|
124
|
+
MoveTo: (self: Model, position: Vector3) -> (),
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
type BasePart = PVInstance & {
|
|
128
|
+
Position: Vector3,
|
|
129
|
+
Size: Vector3,
|
|
130
|
+
CFrame: CFrame,
|
|
131
|
+
Anchored: boolean,
|
|
132
|
+
CanCollide: boolean,
|
|
133
|
+
CanTouch: boolean,
|
|
134
|
+
Transparency: number,
|
|
135
|
+
Color: Color3,
|
|
136
|
+
BrickColor: BrickColor,
|
|
137
|
+
Material: EnumItem,
|
|
138
|
+
Massless: boolean,
|
|
139
|
+
AssemblyLinearVelocity: Vector3,
|
|
140
|
+
Touched: RBXScriptSignal,
|
|
141
|
+
TouchEnded: RBXScriptSignal,
|
|
142
|
+
ApplyImpulse: (self: BasePart, impulse: Vector3) -> (),
|
|
143
|
+
GetTouchingParts: (self: BasePart) -> BasePart[],
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
type Part = BasePart & { Shape: EnumItem }
|
|
147
|
+
type MeshPart = BasePart & { MeshId: string, TextureID: string }
|
|
148
|
+
type UnionOperation = BasePart & { UsePartColor: boolean }
|
|
149
|
+
type SpawnLocation = BasePart & { TeamColor: BrickColor, Neutral: boolean }
|
|
150
|
+
|
|
151
|
+
type Folder = Instance & {}
|
|
152
|
+
type Configuration = Instance & {}
|
|
153
|
+
type Attachment = Instance & { Position: Vector3, WorldPosition: Vector3, WorldCFrame: CFrame }
|
|
154
|
+
|
|
155
|
+
type Humanoid = Instance & {
|
|
156
|
+
Health: number,
|
|
157
|
+
MaxHealth: number,
|
|
158
|
+
WalkSpeed: number,
|
|
159
|
+
JumpPower: number,
|
|
160
|
+
MoveDirection: Vector3,
|
|
161
|
+
RootPart: BasePart | nil,
|
|
162
|
+
Died: RBXScriptSignal,
|
|
163
|
+
HealthChanged: RBXScriptSignal,
|
|
164
|
+
TakeDamage: (self: Humanoid, amount: number) -> (),
|
|
165
|
+
MoveTo: (self: Humanoid, location: Vector3, part?: BasePart) -> (),
|
|
166
|
+
LoadAnimation: (self: Humanoid, animation: Instance) -> Instance,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
type Tool = Model & { Grip: CFrame, RequiresHandle: boolean, Activated: RBXScriptSignal }
|
|
170
|
+
type Accessory = Model & { AttachmentPoint: CFrame }
|
|
171
|
+
|
|
172
|
+
type Player = Instance & {
|
|
173
|
+
UserId: number,
|
|
174
|
+
DisplayName: string,
|
|
175
|
+
Character: Model | nil,
|
|
176
|
+
Team: Instance | nil,
|
|
177
|
+
CharacterAdded: RBXScriptSignal,
|
|
178
|
+
CharacterRemoving: RBXScriptSignal,
|
|
179
|
+
Kick: (self: Player, message?: string) -> (),
|
|
180
|
+
LoadCharacter: (self: Player) -> (),
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
type LuaSourceContainer = Instance & { Source: string }
|
|
184
|
+
type Script = LuaSourceContainer & { Enabled: boolean, RunContext: EnumItem }
|
|
185
|
+
type LocalScript = LuaSourceContainer & { Enabled: boolean }
|
|
186
|
+
type ModuleScript = LuaSourceContainer & {}
|
|
187
|
+
|
|
188
|
+
type Sound = Instance & {
|
|
189
|
+
SoundId: string,
|
|
190
|
+
Volume: number,
|
|
191
|
+
Playing: boolean,
|
|
192
|
+
Looped: boolean,
|
|
193
|
+
TimePosition: number,
|
|
194
|
+
Ended: RBXScriptSignal,
|
|
195
|
+
Play: (self: Sound) -> (),
|
|
196
|
+
Stop: (self: Sound) -> (),
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
type Camera = Instance & {
|
|
200
|
+
CFrame: CFrame,
|
|
201
|
+
FieldOfView: number,
|
|
202
|
+
CameraSubject: Instance | nil,
|
|
203
|
+
ViewportSize: Vector2,
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
type GuiObject = Instance & {
|
|
207
|
+
Visible: boolean,
|
|
208
|
+
Position: UDim2,
|
|
209
|
+
Size: UDim2,
|
|
210
|
+
AnchorPoint: Vector2,
|
|
211
|
+
ZIndex: number,
|
|
212
|
+
BackgroundColor3: Color3,
|
|
213
|
+
BackgroundTransparency: number,
|
|
214
|
+
InputBegan: RBXScriptSignal,
|
|
215
|
+
InputEnded: RBXScriptSignal,
|
|
216
|
+
}
|
|
217
|
+
type Frame = GuiObject & {}
|
|
218
|
+
type TextLabel = GuiObject & { Text: string, TextColor3: Color3, TextSize: number, Font: EnumItem }
|
|
219
|
+
type TextButton = GuiObject & { Text: string, TextColor3: Color3, Activated: RBXScriptSignal }
|
|
220
|
+
type TextBox = GuiObject & { Text: string, PlaceholderText: string, FocusLost: RBXScriptSignal }
|
|
221
|
+
type ImageLabel = GuiObject & { Image: string, ImageColor3: Color3 }
|
|
222
|
+
type ImageButton = GuiObject & { Image: string, Activated: RBXScriptSignal }
|
|
223
|
+
type ScrollingFrame = GuiObject & { CanvasSize: UDim2, CanvasPosition: Vector2 }
|
|
224
|
+
type ScreenGui = Instance & { Enabled: boolean, ResetOnSpawn: boolean, DisplayOrder: number }
|
|
225
|
+
type BillboardGui = Instance & { Adornee: Instance | nil, Size: UDim2, AlwaysOnTop: boolean }
|
|
226
|
+
|
|
227
|
+
type RemoteEvent = Instance & {
|
|
228
|
+
OnServerEvent: RBXScriptSignal,
|
|
229
|
+
OnClientEvent: RBXScriptSignal,
|
|
230
|
+
FireServer: (self: RemoteEvent, ...unknown) -> (),
|
|
231
|
+
FireClient: (self: RemoteEvent, player: Player, ...unknown) -> (),
|
|
232
|
+
FireAllClients: (self: RemoteEvent, ...unknown) -> (),
|
|
233
|
+
}
|
|
234
|
+
type RemoteFunction = Instance & {
|
|
235
|
+
InvokeServer: (self: RemoteFunction, ...unknown) -> ...unknown,
|
|
236
|
+
InvokeClient: (self: RemoteFunction, player: Player, ...unknown) -> ...unknown,
|
|
237
|
+
}
|
|
238
|
+
type BindableEvent = Instance & { Event: RBXScriptSignal, Fire: (self: BindableEvent, ...unknown) -> () }
|
|
239
|
+
|
|
240
|
+
-- ============================================================
|
|
241
|
+
-- Services
|
|
242
|
+
-- ============================================================
|
|
243
|
+
|
|
244
|
+
type Workspace = Model & {
|
|
245
|
+
CurrentCamera: Camera | nil,
|
|
246
|
+
Gravity: number,
|
|
247
|
+
Raycast: (self: Workspace, origin: Vector3, direction: Vector3, params?: unknown) -> unknown,
|
|
248
|
+
}
|
|
249
|
+
type Players = Instance & {
|
|
250
|
+
LocalPlayer: Player | nil,
|
|
251
|
+
PlayerAdded: RBXScriptSignal,
|
|
252
|
+
PlayerRemoving: RBXScriptSignal,
|
|
253
|
+
GetPlayers: (self: Players) -> Player[],
|
|
254
|
+
GetPlayerFromCharacter: (self: Players, character: Model) -> Player | nil,
|
|
255
|
+
}
|
|
256
|
+
type RunService = Instance & {
|
|
257
|
+
Heartbeat: RBXScriptSignal,
|
|
258
|
+
RenderStepped: RBXScriptSignal,
|
|
259
|
+
Stepped: RBXScriptSignal,
|
|
260
|
+
IsClient: (self: RunService) -> boolean,
|
|
261
|
+
IsServer: (self: RunService) -> boolean,
|
|
262
|
+
IsStudio: (self: RunService) -> boolean,
|
|
263
|
+
}
|
|
264
|
+
type UserInputService = Instance & {
|
|
265
|
+
InputBegan: RBXScriptSignal,
|
|
266
|
+
InputEnded: RBXScriptSignal,
|
|
267
|
+
TouchEnabled: boolean,
|
|
268
|
+
KeyboardEnabled: boolean,
|
|
269
|
+
IsKeyDown: (self: UserInputService, key: EnumItem) -> boolean,
|
|
270
|
+
}
|
|
271
|
+
type TweenService = Instance & {
|
|
272
|
+
Create: (self: TweenService, instance: Instance, info: TweenInfo, goals: { [string]: unknown }) -> Instance,
|
|
273
|
+
}
|
|
274
|
+
type Lighting = Instance & { Ambient: Color3, Brightness: number, ClockTime: number, FogEnd: number }
|
|
275
|
+
type ReplicatedStorage = Instance & {}
|
|
276
|
+
type ReplicatedFirst = Instance & {}
|
|
277
|
+
type TeleportService = Instance & {
|
|
278
|
+
Teleport: (self: TeleportService, placeId: number, player?: Player) -> (),
|
|
279
|
+
}
|
|
280
|
+
type MarketplaceService = Instance & {
|
|
281
|
+
PromptPurchase: (self: MarketplaceService, player: Player, assetId: number) -> (),
|
|
282
|
+
UserOwnsGamePassAsync: (self: MarketplaceService, userId: number, gamePassId: number) -> boolean,
|
|
283
|
+
}
|
|
284
|
+
type PhysicsService = Instance & {
|
|
285
|
+
RegisterCollisionGroup: (self: PhysicsService, name: string) -> (),
|
|
286
|
+
CollisionGroupSetCollidable: (self: PhysicsService, a: string, b: string, collidable: boolean) -> (),
|
|
287
|
+
}
|
|
288
|
+
type ContextActionService = Instance & {
|
|
289
|
+
BindAction: (self: ContextActionService, name: string, fn: (...unknown) -> (), touchButton: boolean, ...unknown) -> (),
|
|
290
|
+
UnbindAction: (self: ContextActionService, name: string) -> (),
|
|
291
|
+
}
|
|
292
|
+
type ServerStorage = Instance & {}
|
|
293
|
+
type ServerScriptService = Instance & {}
|
|
294
|
+
type StarterGui = Instance & {}
|
|
295
|
+
type StarterPlayer = Instance & {}
|
|
296
|
+
type Teams = Instance & {}
|
|
297
|
+
type SoundService = Instance & {}
|
|
298
|
+
type Debris = Instance & { AddItem: (self: Debris, item: Instance, lifetime?: number) -> () }
|
|
299
|
+
type CollectionService = Instance & {
|
|
300
|
+
AddTag: (self: CollectionService, instance: Instance, tag: string) -> (),
|
|
301
|
+
HasTag: (self: CollectionService, instance: Instance, tag: string) -> boolean,
|
|
302
|
+
GetTagged: (self: CollectionService, tag: string) -> Instance[],
|
|
303
|
+
GetInstanceAddedSignal: (self: CollectionService, tag: string) -> RBXScriptSignal,
|
|
304
|
+
}
|
|
305
|
+
type HttpService = Instance & {
|
|
306
|
+
JSONEncode: (self: HttpService, value: unknown) -> string,
|
|
307
|
+
JSONDecode: (self: HttpService, json: string) -> unknown,
|
|
308
|
+
GenerateGUID: (self: HttpService, wrapInCurlyBraces?: boolean) -> string,
|
|
309
|
+
}
|
|
310
|
+
type DataStoreService = Instance & {
|
|
311
|
+
GetDataStore: (self: DataStoreService, name: string, scope?: string) -> Instance,
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
-- Services are a map of their own, so the same map serves both spellings:
|
|
315
|
+
-- intersecting it into `DataModel` gives `game.ReplicatedStorage`, and
|
|
316
|
+
-- indexing it gives `game:GetService("ReplicatedStorage")`.
|
|
317
|
+
type Services = {
|
|
318
|
+
Workspace: Workspace,
|
|
319
|
+
Players: Players,
|
|
320
|
+
RunService: RunService,
|
|
321
|
+
UserInputService: UserInputService,
|
|
322
|
+
TweenService: TweenService,
|
|
323
|
+
Lighting: Lighting,
|
|
324
|
+
ReplicatedStorage: ReplicatedStorage,
|
|
325
|
+
ReplicatedFirst: ReplicatedFirst,
|
|
326
|
+
ServerStorage: ServerStorage,
|
|
327
|
+
ServerScriptService: ServerScriptService,
|
|
328
|
+
StarterGui: StarterGui,
|
|
329
|
+
StarterPlayer: StarterPlayer,
|
|
330
|
+
Teams: Teams,
|
|
331
|
+
SoundService: SoundService,
|
|
332
|
+
Debris: Debris,
|
|
333
|
+
CollectionService: CollectionService,
|
|
334
|
+
HttpService: HttpService,
|
|
335
|
+
DataStoreService: DataStoreService,
|
|
336
|
+
TeleportService: TeleportService,
|
|
337
|
+
MarketplaceService: MarketplaceService,
|
|
338
|
+
PhysicsService: PhysicsService,
|
|
339
|
+
ContextActionService: ContextActionService,
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
type DataModel = Instance & Services & {
|
|
343
|
+
PlaceId: number,
|
|
344
|
+
JobId: string,
|
|
345
|
+
BindToClose: (self: DataModel, callback: () -> ()) -> (),
|
|
346
|
+
|
|
347
|
+
-- `K` is constrained to the service names, which is both what makes the
|
|
348
|
+
-- argument infer as a string *literal* rather than widening to `string`,
|
|
349
|
+
-- and what catches a typo.
|
|
350
|
+
GetService: <K extends keyof Services>(self: DataModel, name: K) -> Services[K],
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
-- ============================================================
|
|
356
|
+
-- The class map
|
|
357
|
+
-- ------------------------------------------------------------
|
|
358
|
+
-- One place that names every class. `IsA` and `Instance.new` are both a
|
|
359
|
+
-- single generic signature over it, so adding a class is adding one line here
|
|
360
|
+
-- plus its type above.
|
|
361
|
+
-- ============================================================
|
|
362
|
+
|
|
363
|
+
type ClassMap = {
|
|
364
|
+
Instance: Instance,
|
|
365
|
+
PVInstance: PVInstance,
|
|
366
|
+
Model: Model,
|
|
367
|
+
BasePart: BasePart,
|
|
368
|
+
Part: Part,
|
|
369
|
+
MeshPart: MeshPart,
|
|
370
|
+
UnionOperation: UnionOperation,
|
|
371
|
+
SpawnLocation: SpawnLocation,
|
|
372
|
+
Folder: Folder,
|
|
373
|
+
Configuration: Configuration,
|
|
374
|
+
Attachment: Attachment,
|
|
375
|
+
Humanoid: Humanoid,
|
|
376
|
+
Tool: Tool,
|
|
377
|
+
Accessory: Accessory,
|
|
378
|
+
Player: Player,
|
|
379
|
+
LuaSourceContainer: LuaSourceContainer,
|
|
380
|
+
Script: Script,
|
|
381
|
+
LocalScript: LocalScript,
|
|
382
|
+
ModuleScript: ModuleScript,
|
|
383
|
+
Sound: Sound,
|
|
384
|
+
Camera: Camera,
|
|
385
|
+
GuiObject: GuiObject,
|
|
386
|
+
Frame: Frame,
|
|
387
|
+
TextLabel: TextLabel,
|
|
388
|
+
TextButton: TextButton,
|
|
389
|
+
TextBox: TextBox,
|
|
390
|
+
ImageLabel: ImageLabel,
|
|
391
|
+
ImageButton: ImageButton,
|
|
392
|
+
ScrollingFrame: ScrollingFrame,
|
|
393
|
+
ScreenGui: ScreenGui,
|
|
394
|
+
BillboardGui: BillboardGui,
|
|
395
|
+
RemoteEvent: RemoteEvent,
|
|
396
|
+
RemoteFunction: RemoteFunction,
|
|
397
|
+
BindableEvent: BindableEvent,
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
-- The abstract classes cannot be constructed, so `Instance.new` works over
|
|
401
|
+
-- everything else — written with `Omit` rather than a second hand-kept list.
|
|
402
|
+
type CreatableClassMap = Omit<ClassMap,
|
|
403
|
+
"Instance" | "PVInstance" | "BasePart" | "GuiObject" | "LuaSourceContainer">
|
|
404
|
+
|
|
405
|
+
-- ============================================================
|
|
406
|
+
-- `typeof()` for the Roblox data types
|
|
407
|
+
-- ------------------------------------------------------------
|
|
408
|
+
-- These extend the base overloads declared in `luau.d.luaut`. `typeof` reports
|
|
409
|
+
-- a Roblox data type by name rather than as `userdata`; every Instance reports
|
|
410
|
+
-- as `"Instance"`.
|
|
411
|
+
-- ============================================================
|
|
412
|
+
|
|
413
|
+
declare function typeof(value: Vector3): "Vector3"
|
|
414
|
+
declare function typeof(value: Vector2): "Vector2"
|
|
415
|
+
declare function typeof(value: CFrame): "CFrame"
|
|
416
|
+
declare function typeof(value: Color3): "Color3"
|
|
417
|
+
declare function typeof(value: UDim): "UDim"
|
|
418
|
+
declare function typeof(value: UDim2): "UDim2"
|
|
419
|
+
declare function typeof(value: NumberRange): "NumberRange"
|
|
420
|
+
declare function typeof(value: Rect): "Rect"
|
|
421
|
+
declare function typeof(value: Ray): "Ray"
|
|
422
|
+
declare function typeof(value: Region3): "Region3"
|
|
423
|
+
declare function typeof(value: BrickColor): "BrickColor"
|
|
424
|
+
declare function typeof(value: EnumItem): "EnumItem"
|
|
425
|
+
declare function typeof(value: TweenInfo): "TweenInfo"
|
|
426
|
+
declare function typeof(value: Random): "Random"
|
|
427
|
+
declare function typeof(value: DateTime): "DateTime"
|
|
428
|
+
declare function typeof(value: RBXScriptSignal): "RBXScriptSignal"
|
|
429
|
+
declare function typeof(value: RBXScriptConnection): "RBXScriptConnection"
|
|
430
|
+
declare function typeof(value: Instance): "Instance"
|
|
431
|
+
|
|
432
|
+
-- ============================================================
|
|
433
|
+
-- Globals
|
|
434
|
+
-- ============================================================
|
|
435
|
+
|
|
436
|
+
declare game: DataModel
|
|
437
|
+
declare workspace: Workspace
|
|
438
|
+
declare script: LuaSourceContainer
|
|
439
|
+
declare shared: { [string]: unknown }
|
|
440
|
+
|
|
441
|
+
-- `Instance.new(className)` returns the class it names, by the same
|
|
442
|
+
-- one-overload-per-class trick as `IsA`.
|
|
443
|
+
declare Instance: {
|
|
444
|
+
new: <K extends keyof CreatableClassMap>(className: K, parent?: Instance) -> CreatableClassMap[K],
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
declare Vector3: {
|
|
448
|
+
new: (x?: number, y?: number, z?: number) -> Vector3,
|
|
449
|
+
zero: Vector3,
|
|
450
|
+
one: Vector3,
|
|
451
|
+
xAxis: Vector3,
|
|
452
|
+
yAxis: Vector3,
|
|
453
|
+
zAxis: Vector3,
|
|
454
|
+
}
|
|
455
|
+
declare Vector2: { new: (x?: number, y?: number) -> Vector2, zero: Vector2, one: Vector2 }
|
|
456
|
+
declare Color3: {
|
|
457
|
+
new: (r?: number, g?: number, b?: number) -> Color3,
|
|
458
|
+
fromRGB: (r?: number, g?: number, b?: number) -> Color3,
|
|
459
|
+
fromHSV: (h: number, s: number, v: number) -> Color3,
|
|
460
|
+
}
|
|
461
|
+
declare CFrame: {
|
|
462
|
+
new: (x?: number, y?: number, z?: number) -> CFrame,
|
|
463
|
+
lookAt: (at: Vector3, target: Vector3, up?: Vector3) -> CFrame,
|
|
464
|
+
identity: CFrame,
|
|
465
|
+
}
|
|
466
|
+
declare UDim: { new: (scale?: number, offset?: number) -> UDim }
|
|
467
|
+
declare UDim2: {
|
|
468
|
+
new: (xScale?: number, xOffset?: number, yScale?: number, yOffset?: number) -> UDim2,
|
|
469
|
+
fromScale: (x: number, y: number) -> UDim2,
|
|
470
|
+
fromOffset: (x: number, y: number) -> UDim2,
|
|
471
|
+
}
|
|
472
|
+
declare NumberRange: { new: (min: number, max?: number) -> NumberRange }
|
|
473
|
+
declare Rect: { new: (min: Vector2, max: Vector2) -> Rect }
|
|
474
|
+
declare Ray: { new: (origin: Vector3, direction: Vector3) -> Ray }
|
|
475
|
+
declare Region3: { new: (min: Vector3, max: Vector3) -> Region3 }
|
|
476
|
+
declare BrickColor: { new: (name: string) -> BrickColor, random: () -> BrickColor }
|
|
477
|
+
declare TweenInfo: {
|
|
478
|
+
new: (time?: number, easingStyle?: EnumItem, easingDirection?: EnumItem,
|
|
479
|
+
repeatCount?: number, reverses?: boolean, delayTime?: number) -> TweenInfo,
|
|
480
|
+
}
|
|
481
|
+
declare Random: { new: (seed?: number) -> Random }
|
|
482
|
+
declare DateTime: {
|
|
483
|
+
now: () -> DateTime,
|
|
484
|
+
fromUnixTimestamp: (unixTimestamp: number) -> DateTime,
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
declare Enum: { [string]: { [string]: EnumItem } }
|
|
488
|
+
|
|
489
|
+
declare task: {
|
|
490
|
+
wait: (seconds?: number) -> number,
|
|
491
|
+
spawn: (fn: (...unknown) -> (), ...unknown) -> thread,
|
|
492
|
+
defer: (fn: (...unknown) -> (), ...unknown) -> thread,
|
|
493
|
+
delay: (seconds: number, fn: (...unknown) -> (), ...unknown) -> thread,
|
|
494
|
+
cancel: (thread: thread) -> (),
|
|
495
|
+
synchronize: () -> (),
|
|
496
|
+
desynchronize: () -> (),
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
declare function tick(): number
|
|
500
|
+
declare function time(): number
|
|
501
|
+
declare function wait(seconds?: number): number
|
|
502
|
+
declare function delay(seconds: number, fn: () -> ()): ()
|
|
503
|
+
declare function spawn(fn: () -> ()): ()
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "luaut-parser",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "luau parser for roblox",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/Uav3537/luaut-parser.git"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": {
|
|
18
|
+
"require": "./dist/index.d.cts",
|
|
19
|
+
"import": "./dist/index.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"test": "tsx scripts/test.ts",
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"typecheck": "tsc --noEmit"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [],
|
|
31
|
+
"author": "",
|
|
32
|
+
"license": "ISC",
|
|
33
|
+
"type": "module",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^22.0.0",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"tsx": "^4.19.0",
|
|
38
|
+
"typescript": "^5.0.4"
|
|
39
|
+
}
|
|
40
|
+
}
|