From b554d73eeabb96f23385b7b093d5609ff6105e99 Mon Sep 17 00:00:00 2001 From: amelia squires Date: Mon, 31 Mar 2025 13:21:27 -0500 Subject: type definitions --- library/lullaby.lua | 18 +++ library/lullaby/crypto.lua | 266 +++++++++++++++++++++++++++++++++++++++++++++ library/lullaby/error.lua | 3 + library/lullaby/io.lua | 40 +++++++ library/lullaby/math.lua | 10 ++ library/lullaby/net.lua | 166 ++++++++++++++++++++++++++++ library/lullaby/sort.lua | 54 +++++++++ library/lullaby/table.lua | 8 ++ library/lullaby/test.lua | 11 ++ library/lullaby/thread.lua | 67 ++++++++++++ 10 files changed, 643 insertions(+) create mode 100644 library/lullaby.lua create mode 100644 library/lullaby/crypto.lua create mode 100644 library/lullaby/error.lua create mode 100644 library/lullaby/io.lua create mode 100644 library/lullaby/math.lua create mode 100644 library/lullaby/net.lua create mode 100644 library/lullaby/sort.lua create mode 100644 library/lullaby/table.lua create mode 100644 library/lullaby/test.lua create mode 100644 library/lullaby/thread.lua (limited to 'library') diff --git a/library/lullaby.lua b/library/lullaby.lua new file mode 100644 index 0000000..675b14c --- /dev/null +++ b/library/lullaby.lua @@ -0,0 +1,18 @@ +---@meta + +---@class lullaby +local lullaby = {} + +function lullaby.version() end + +lullaby.crypto = require("library.lullaby.crypto") +lullaby.error = require("library.lullaby.error") +lullaby.io = require("library.lullaby.io") +lullaby.math = require("library.lullaby.math") +lullaby.net = require("library.lullaby.net") +lullaby.sort = require("library.lullaby.sort") +lullaby.table = require("library.lullaby.table") +lullaby.test = require("library.lullaby.test") +lullaby.thread = require("library.lullaby.thread") + +return lullaby diff --git a/library/lullaby/crypto.lua b/library/lullaby/crypto.lua new file mode 100644 index 0000000..307619b --- /dev/null +++ b/library/lullaby/crypto.lua @@ -0,0 +1,266 @@ +---@meta + +---@class crypto +local crypto = {} + +---@class hash +---@operator add(string): hash +local hash = {} + +---@param T hash +---@param value string +function hash.update(T, value) end + +---@param T hash +function hash.final(T) end + +---@return hash +---@overload fun(value: string): string +function crypto.adler32() end + +---@return hash +---@overload fun(value: string): string +function crypto.bsdchecksum() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha0() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha1() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha256() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha224() end + +---@return hash +---@overload fun(value: string): string +function crypto.pearson() end + +---@param T integer[] +function crypto.setpearson(T) end + +---@param input string +---@return string +function crypto.xxh64(input) end + +---@param input string +---@return string +function crypto.xxh32(input) end + +---@return hash +---@overload fun(value: string): string +function crypto.crc8() end + +---@return hash +---@overload fun(value: string): string +function crypto.crc16() end + +---@return hash +---@overload fun(value: string): string +function crypto.crc32() end + +---@return hash +---@overload fun(value: string): string +function crypto.fletcher8() end + +---@return hash +---@overload fun(value: string): string +function crypto.fletcher16() end + +---@return hash +---@overload fun(value: string): string +function crypto.fletcher32() end + +---@return hash +---@overload fun(value: string): string +function crypto.sysvchecksum() end + +---@return hash +---@overload fun(value: string): string +function crypto.xor8() end + +---@param input string +---@return string +function crypto.buzhash8(input) end + +---@param input string +---@return string +function crypto.buzhash16(input) end + +---@param T integer[] +function crypto.setbuzhasah(T) end + +---@param input string +---@return string +function crypto.cityhash32(input) end + +---@param input string +---@return string +function crypto.cityhash64(input) end + +---@param input string +---@return string +function crypto.cityhash128(input) end + +---@return hash +---@overload fun(value: string): string +function crypto.md5() end + +---@return hash +---@overload fun(value: string): string +function crypto.djb2() end + +---@param input string +---@return string +function crypto.farmhash32(input) end + +---@param input string +---@return string +function crypto.farmhash64(input) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.fasthash32(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.fasthash64(input, seed) end + +---@return hash +---@overload fun(value: string): string +function crypto.fnv_0() end + +---@return hash +---@overload fun(value: string): string +function crypto.fnv_1() end + +---@return hash +---@overload fun(value: string): string +function crypto.fnv_a() end + +---@return hash +---@overload fun(value: string): string +function crypto.oaat() end + +---@return hash +---@overload fun(value: string): string +function crypto.loselose() end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.metrohash64_v1(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.metrohash64_v2(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.metrohash128_v1(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.metrohash128_v2(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.murmur1_32(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.murmur2_32(input, seed) end + +---@return hash +---@overload fun(value: string): string +function crypto.pjw() end + +---@return hash +---@overload fun(value: string): string +function crypto.sdbm() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha512() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha384() end + +---@param t integer 0 < t <= 512 +---@return hash +---@overload fun(t, value: string): string +function crypto.sha512_t(t) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash128_v1(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash128_v2(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash64_v1(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash64_v2(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash32_v1(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash32_v2(input, seed) end + +---@return hash +---@overload fun(value: string): string +---@overload fun(value: string, length: integer, key: string): string +---@overload fun(length: integer, key: string): hash +function crypto.blake2b() end + +---@return hash +---@overload fun(value: string): string +---@overload fun(value: string, length: integer, key: string): string +---@overload fun(length: integer, key: string): hash +function crypto.blake2s() end + +---@return hash +---@overload fun(value: string): string +function crypto.blake256() end + +---@return hash +---@overload fun(value: string): string +function crypto.blake224() end + +---@return hash +---@overload fun(value: string): string +function crypto.blake512() end + +---@return hash +---@overload fun(value: string): string +function crypto.blake384() end + +return crypto diff --git a/library/lullaby/error.lua b/library/lullaby/error.lua new file mode 100644 index 0000000..1903746 --- /dev/null +++ b/library/lullaby/error.lua @@ -0,0 +1,3 @@ +---@meta + +---@alias error nil, any diff --git a/library/lullaby/io.lua b/library/lullaby/io.lua new file mode 100644 index 0000000..4fb7768 --- /dev/null +++ b/library/lullaby/io.lua @@ -0,0 +1,40 @@ +---@meta + +---@class io +local io = {} + +---print a string with a "pretty" log header +---@param value string value to print +---@return nil +function io.log(value) end + +---print a string with a "pretty" warning header +---@param value string value to print +---@return nil +function io.warn(value) end + +---print a string with a "pretty" error header +---@param value string value to print +---@return nil +function io.error(value) end + +---print a string with a "pretty" debug header +---@param value string value to print +---@return nil +function io.debug(value) end + +---prints any value, expanding tables +---@param value any value to print +---@return nil +function io.pprint(value) end + +---@deprecated +function io.readfile() end + +---@deprecated +function io.json_parse() end + +---@deprecated +function io.arg_handle() end + +return io diff --git a/library/lullaby/math.lua b/library/lullaby/math.lua new file mode 100644 index 0000000..2914a56 --- /dev/null +++ b/library/lullaby/math.lua @@ -0,0 +1,10 @@ +---@meta + +---@class math +local math = {} + +---@param N number[] +---@return integer +function math.lcm(N) end + +return math diff --git a/library/lullaby/net.lua b/library/lullaby/net.lua new file mode 100644 index 0000000..3f9abdc --- /dev/null +++ b/library/lullaby/net.lua @@ -0,0 +1,166 @@ +---@meta + +---@class net +local net = {} + +---@class server-table +local server_table = {} + +---@class res-table +local res_table = {} + +---sends value to client and closes socket +---@param T res-table +---@param value string +function res_table.send(T, value) end + +---autosets Content-Type and sends contents of file to client and closes socket +---@param T res-table +---@param value string +function res_table.sendfile(T, value) end + +---sends value to client and doesn't close the socket +---@param T res-table +---@param value string +function res_table.write(T, value) end + +---closes socket +---@param T res-table +function res_table.close(T) end + +---prevents calling any other selected routes +---@param T res-table +function res_table.stop(T) end + +---key value table containing header values to be sent +res_table.header = {} + +---@class req-table +local req_table = {} + +---"roll" the request forward +---@param T req-table +---@param bytes integer | nil +function req_table.roll(T, bytes) end + +---list of parameters in route +req_table.parameters = {} + +---@deprecated +req_table.client_fd = 0 + +---@deprecated +req_table._bytes = 0 + +---@type integer +req_table.ip = 0 + +---@type string +req_table.Body = "" + +---@type any|nil +req_table.files = {} + +---@type any|nil +req_table.cookies = {} + + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.GET(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.HEAD(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.POST(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.PUT(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.DELETE(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.CONNECT(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.OPTIONS(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.TRACE(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.PATCH(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.all(T, route, callback) end + +---@param server server-table +local function listen_callback(server) end + +---@param callback fun(server: server-table) +---@param port integer +function net.listen(callback, port) end + +---creates an https request +---@param url string +---@param value string | nil +---@param header table | nil +---@param request string | nil +---@return table | error +function net.srequest(url, value, header, request) end + +---@class wss-table +local wss = {} + +---@class wss-read +local wss_read = {} + +---@type string +wss_read.content = "" + +---@type integer +wss_read.opcode = 0 + +---reads oldest unread frame from server +---@param T wss-table +---@return wss-read | error +function wss.read(T) end + +---sents data frame to server +---@param T wss-table +---@param data string +---@return nil | error +function wss.write(T, data) end + +---calls gc early +---@param T wss-table +---@return nil +function wss.close(T) end + +---creates a wss connection +---@param url string +---@return wss-table | error +function net.wss(url) end + +return net diff --git a/library/lullaby/sort.lua b/library/lullaby/sort.lua new file mode 100644 index 0000000..c7d9f4d --- /dev/null +++ b/library/lullaby/sort.lua @@ -0,0 +1,54 @@ +---@meta + +---@class sort +local sort = {} + +---greatest, least +---@param array number[] +function sort.quicksort(array) end + +---greatest, least +---@param array number[] +function sort.mergesort(array) end + +---greatest, least +---@param array number[] +function sort.shellsort(array) end + +---greatest, least +---@param array number[] +function sort.bubblesort(array) end + +---greatest, least +---@param array number[] +function sort.heapsort(array) end + +---least, greatest +---@param array integer[] +function sort.countintsort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function sort.miraclesort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function sort.stalinsort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function sort.slowsort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function sort.bogosort(array) end + +return sort diff --git a/library/lullaby/table.lua b/library/lullaby/table.lua new file mode 100644 index 0000000..f02c21e --- /dev/null +++ b/library/lullaby/table.lua @@ -0,0 +1,8 @@ +---@meta + +---to be rewritten +---@deprecated +---@class lullaby.table +local table = {} + +return table diff --git a/library/lullaby/test.lua b/library/lullaby/test.lua new file mode 100644 index 0000000..3bc7151 --- /dev/null +++ b/library/lullaby/test.lua @@ -0,0 +1,11 @@ +---@meta + +---not meant for normal usage +---@deprecated +---@class test +local test = {} + +function test._match() end +function test.stack_dump() end + +return test diff --git a/library/lullaby/thread.lua b/library/lullaby/thread.lua new file mode 100644 index 0000000..1b0e89d --- /dev/null +++ b/library/lullaby/thread.lua @@ -0,0 +1,67 @@ +---@meta + +---@class thread +local thread = {} + +---@class async-table +local async = {} + +---waits for thread to exit, returns the value of res +---@param T async-table +---@return ... +function async.await(T) end + +---calls thread __gc early +---@param T async-table +---@return nil +function async.clean(T) end + +---contains data for the thread +---@deprecated +---@type lightuserdata +async._ = nil + +---@async +---@param fun fun(res: fun(...)): nil function to call, parameter will set a return value for the thread +---@return async-table +function thread.async(fun) end + +---@class buffer-table +local buffer = {} + +---gets the value of the buffer +---@param T buffer-table +---@return any +function buffer.get(T) end + +---sets the value of the buffer +---@param T buffer-table +---@param value any +---@return nil +function buffer.set(T, value) end + +---calls a function with a parameter that is the value of the buffer, return the new value of the buffer +---@param T buffer-table +---@param fun fun(any): nil +---@return nil +function buffer.mod(T, fun) end + +---puts a value into a atomic thread-safe buffer +---@param value any +---@return buffer-table +function thread.buffer(value) end + +---locks any thread reaching this lock id until a corresponding unlock is met +---@param tid integer +---@return nil +function thread.lock(tid) end + +---unlocks a lock id +---@param tid integer +---@return nil +function thread.unlock(tid) end + +---@deprecated +function thread.testcopy() end + +return thread -- cgit v1.2.3 From dc7e4527e88ed0c59e17c0ff04c01e1c92136e42 Mon Sep 17 00:00:00 2001 From: amelia squires Date: Mon, 14 Apr 2025 14:03:08 -0500 Subject: config change, local support, overall fixes --- library/lullaby.lua | 6 ++--- library/lullaby/array.lua | 56 +++++++++++++++++++++++++++++++++++++++++++++++ library/lullaby/io.lua | 7 ++++++ library/lullaby/sort.lua | 54 --------------------------------------------- library/lullaby/table.lua | 8 ------- 5 files changed, 65 insertions(+), 66 deletions(-) create mode 100644 library/lullaby/array.lua delete mode 100644 library/lullaby/sort.lua delete mode 100644 library/lullaby/table.lua (limited to 'library') diff --git a/library/lullaby.lua b/library/lullaby.lua index 675b14c..9f66530 100644 --- a/library/lullaby.lua +++ b/library/lullaby.lua @@ -1,17 +1,15 @@ ---@meta ---@class lullaby +---@field version string local lullaby = {} -function lullaby.version() end - lullaby.crypto = require("library.lullaby.crypto") lullaby.error = require("library.lullaby.error") lullaby.io = require("library.lullaby.io") lullaby.math = require("library.lullaby.math") lullaby.net = require("library.lullaby.net") -lullaby.sort = require("library.lullaby.sort") -lullaby.table = require("library.lullaby.table") +lullaby.array = require("library.lullaby.array") lullaby.test = require("library.lullaby.test") lullaby.thread = require("library.lullaby.thread") diff --git a/library/lullaby/array.lua b/library/lullaby/array.lua new file mode 100644 index 0000000..ebc23af --- /dev/null +++ b/library/lullaby/array.lua @@ -0,0 +1,56 @@ +---@meta + +---to be rewritten +---@deprecated +---@class lullaby.array +local table = {} + +---greatest, least +---@param array number[] +function table.quicksort(array) end + +---greatest, least +---@param array number[] +function table.mergesort(array) end + +---greatest, least +---@param array number[] +function table.shellsort(array) end + +---greatest, least +---@param array number[] +function table.bubblesort(array) end + +---greatest, least +---@param array number[] +function table.heapsort(array) end + +---least, greatest +---@param array integer[] +function table.countintsort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function table.miraclesort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function table.stalinsort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function table.slowsort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function table.bogosort(array) end + +return table diff --git a/library/lullaby/io.lua b/library/lullaby/io.lua index 4fb7768..6e7eb9d 100644 --- a/library/lullaby/io.lua +++ b/library/lullaby/io.lua @@ -1,6 +1,13 @@ ---@meta ---@class io +---@field filemallocchunk integer default chunk size for readfile +---@field print_type integer print the type next to the value +---@field max_depth integer max print depth before collapsing +---@field start_nl_at integer when to start new line while printing +---@field collapse_all integer whether or not to collapse everything +---@field collapse_to_memory integer when collapsing, print memory address +---@field print_meta integer print metatable local io = {} ---print a string with a "pretty" log header diff --git a/library/lullaby/sort.lua b/library/lullaby/sort.lua deleted file mode 100644 index c7d9f4d..0000000 --- a/library/lullaby/sort.lua +++ /dev/null @@ -1,54 +0,0 @@ ----@meta - ----@class sort -local sort = {} - ----greatest, least ----@param array number[] -function sort.quicksort(array) end - ----greatest, least ----@param array number[] -function sort.mergesort(array) end - ----greatest, least ----@param array number[] -function sort.shellsort(array) end - ----greatest, least ----@param array number[] -function sort.bubblesort(array) end - ----greatest, least ----@param array number[] -function sort.heapsort(array) end - ----least, greatest ----@param array integer[] -function sort.countintsort(array) end - ----dont use this lol ----@deprecated ----greatest, least ----@param array number[] -function sort.miraclesort(array) end - ----dont use this lol ----@deprecated ----greatest, least ----@param array number[] -function sort.stalinsort(array) end - ----dont use this lol ----@deprecated ----greatest, least ----@param array number[] -function sort.slowsort(array) end - ----dont use this lol ----@deprecated ----greatest, least ----@param array number[] -function sort.bogosort(array) end - -return sort diff --git a/library/lullaby/table.lua b/library/lullaby/table.lua deleted file mode 100644 index f02c21e..0000000 --- a/library/lullaby/table.lua +++ /dev/null @@ -1,8 +0,0 @@ ----@meta - ----to be rewritten ----@deprecated ----@class lullaby.table -local table = {} - -return table -- cgit v1.2.3