Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types for baton, flux, log.lua. Change rxi-json-lua to be more specific #43

Merged
merged 3 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions types/baton/baton.d.tl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- Depends on love definition from https://github.com/MikuAuahDark/love2d-tl

local record baton
record Configuration
controls: {string:{string}}
pairs: {string:{string, string, string, string}}
joystick: love.joystick.Joystick
deadzone: number
squareDeadzone: boolean
end

enum ActiveDevice
"kbm"
"joy"
"none"
end

record Player
config: Configuration

update: function(self: Player)
getRaw: function(self: Player, name: string): number
get: function(self: Player, name: string): number
get: function(self: Player, name: string): number, number
down: function(self: Player, name: string): boolean
pressed: function(self: Player, name: string): boolean
released: function(self: Player, name: string): boolean

getActiveDevice: function(self: Player): ActiveDevice
_activeDevice: ActiveDevice
end

new: function(config: Configuration): Player
end

return baton
57 changes: 57 additions & 0 deletions types/flux/flux.d.tl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
local record flux
enum Easing
"linear"
"quadin"
"quadout"
"quadinout"
"cubicin"
"cubicout"
"cubicinout"
"quartin"
"quartout"
"quartinout"
"quintin"
"quintout"
"quintinout"
"expoin"
"expoout"
"expoinout"
"sinein"
"sineout"
"sineinout"
"circin"
"circout"
"circinout"
"backin"
"backout"
"backinout"
"elasticin"
"elasticout"
"elasticinout"
end

record Tween<T>
ease: function(self: Tween<T>, type: Easing): Tween<T>
delay: function(self: Tween<T>, time: number): Tween<T>
onstart: function(self: Tween<T>, function()): Tween<T>
onupdate: function(self: Tween<T>, function()): Tween<T>
oncomplete: function(self: Tween<T>, function()): Tween<T>
after: function<U>(self: Tween<U>, time: number, vars: U): Tween<U>
after: function<U>(self: Tween<T>, obj: U, time: number, vars: U): Tween<T>
stop: function(self: Tween<T>)
end

record Group
update: function(self: Group, deltatime: number)
to: function<K, V>(self: Group, obj: {K:V}, time: number, vars: {K:V}): Tween<{K:V}>
to: function<T>(self: Group, obj: T, time: number, vars: T): Tween<T>
-- group: function(self: Group): Group
end

update: function(deltatime: number)
to: function<K, V>(obj: {K:V}, time: number, vars: {K:V}): Tween<{K:V}>
to: function<T>(obj: T, time: number, vars: T): Tween<T>
group: function(): Group
end

return flux
26 changes: 20 additions & 6 deletions types/rxi-json-lua/json.d.tl
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
local record json
-- Returns a string representing value encoded in JSON.
encode: function(value: any): string

-- Returns a value representing the decoded JSON string.
decode: function(str: string): any
type Array = {Value}
type Object = {string:Value}

-- Workaround for not being able to union Array and Object
type Mixed = {string|integer:Value}

type Value = number | string | boolean | Mixed

-- For convenience, encode takes any type and may throw an error at runtime.
-- You can enforce correctness yourself by specifying types on variables or records.
--
-- For example:
-- local obj: json.Object = {value = 'data'}
-- local encoded = json.encode(obj)

encode: function(value: any): string
-- encode: function(value: Value): string

decode: function(str: string): Value
end

return json
return json
24 changes: 24 additions & 0 deletions types/rxi-log-lua/log.d.tl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local record log
enum Level
"trace"
"debug"
"info"
"warn"
"error"
"fatal"
end
type LogFunction = function(...: any)

usecolor: boolean
outfile: string
level: Level

trace: LogFunction
debug: LogFunction
info: LogFunction
warn: LogFunction
error: LogFunction
fatal: LogFunction
end

return log