Upload bridge.lua, default.lua and some Lua libs

base64
inspect
json.lua
Lua-hashings
Lua-nums
Moses
mt19937ar-lua
Penlight
Serpent
This commit is contained in:
Gnome Ann 2021-12-10 19:45:57 -05:00
parent cb384ce25b
commit 35966b2007
64 changed files with 1641 additions and 19 deletions

View File

@ -87,8 +87,10 @@ class vars:
andepth = 3 # How far back in history to append author's note
actions = structures.KoboldStoryRegister() # Actions submitted by user and AI
worldinfo = [] # List of World Info key/value objects
worldinfo_u = {} # Dictionary of World Info UID - key/value pairs
wifolders_d = {} # Dictionary of World Info folder UID-info pairs
wifolders_l = [] # List of World Info folder UIDs
wifolders_u = {} # Dictionary of pairs of folder UID - list of WI UID
# badwords = [] # Array of str/chr values that should be removed from output
badwordsids = [[13460], [6880], [50256], [42496], [4613], [17414], [22039], [16410], [27], [29], [38430], [37922], [15913], [24618], [28725], [58], [47175], [36937], [26700], [12878], [16471], [37981], [5218], [29795], [13412], [45160], [3693], [49778], [4211], [20598], [36475], [33409], [44167], [32406], [29847], [29342], [42669], [685], [25787], [7359], [3784], [5320], [33994], [33490], [34516], [43734], [17635], [24293], [9959], [23785], [21737], [28401], [18161], [26358], [32509], [1279], [38155], [18189], [26894], [6927], [14610], [23834], [11037], [14631], [26933], [46904], [22330], [25915], [47934], [38214], [1875], [14692], [41832], [13163], [25970], [29565], [44926], [19841], [37250], [49029], [9609], [44438], [16791], [17816], [30109], [41888], [47527], [42924], [23984], [49074], [33717], [31161], [49082], [30138], [31175], [12240], [14804], [7131], [26076], [33250], [3556], [38381], [36338], [32756], [46581], [17912], [49146]] # Tokenized array of badwords used to prevent AI artifacting
deletewi = -1 # Temporary storage for index to delete
@ -2157,6 +2159,12 @@ def addwiitem(folder_uid=None):
assert folder_uid is None or folder_uid in vars.wifolders_d
ob = {"key": "", "keysecondary": "", "content": "", "comment": "", "folder": folder_uid, "num": len(vars.worldinfo), "init": False, "selective": False, "constant": False}
vars.worldinfo.append(ob)
while(True):
uid = int.from_bytes(os.urandom(4), "little", signed=True)
if(uid not in vars.worldinfo_u):
break
vars.worldinfo_u[uid] = vars.worldinfo[-1]
vars.worldinfo[-1]["uid"] = uid
emit('from_server', {'cmd': 'addwiitem', 'data': ob}, broadcast=True)
#==================================================================#
@ -2170,6 +2178,7 @@ def addwifolder():
ob = {"name": "", "collapsed": False}
vars.wifolders_d[uid] = ob
vars.wifolders_l.append(uid)
vars.wifolders_u[uid] = []
emit('from_server', {'cmd': 'addwifolder', 'uid': uid, 'data': ob}, broadcast=True)
addwiitem(folder_uid=uid)
@ -2178,6 +2187,13 @@ def addwifolder():
# the WI entry with number dst
#==================================================================#
def movewiitem(dst, src):
if(vars.worldinfo[src]["folder"] is not None):
for i, e in enumerate(vars.wifolders_u[vars.worldinfo[src]["folder"]]):
if(e is vars.worldinfo[src]):
vars.wifolders_u[vars.worldinfo[src]["folder"]].pop(i)
if(vars.worldinfo[dst]["folder"] is not None):
vars.wifolders_u[vars.worldinfo[dst]["folder"]].append(vars.worldinfo[src])
vars.wifolders_u[vars.worldinfo[src]["folder"]]
vars.worldinfo[src]["folder"] = vars.worldinfo[dst]["folder"]
vars.worldinfo.insert(dst - (dst >= src), vars.worldinfo.pop(src))
sendwi()
@ -2213,7 +2229,6 @@ def sendwi():
addwiitem()
else:
# Send contents of WI array
organizewi()
last_folder = ...
for wi in vars.worldinfo:
if(wi["folder"] != last_folder):
@ -2242,7 +2257,8 @@ def stablesortwi():
vars.worldinfo.sort(key=lambda x: mapping[x["folder"]] if x["folder"] is not None else float("inf"))
last_folder = ...
last_wi = None
for wi in vars.worldinfo:
for i, wi in enumerate(vars.worldinfo):
wi["num"] = i
wi["init"] = True
if(wi["folder"] != last_folder):
if(last_wi is not None and last_folder is not ...):
@ -2251,17 +2267,8 @@ def stablesortwi():
last_wi = wi
if(last_wi is not None):
last_wi["init"] = False
#==================================================================#
# Renumber WI items consecutively
#==================================================================#
def organizewi():
if(len(vars.worldinfo) > 0):
count = 0
for wi in vars.worldinfo:
wi["num"] = count
count += 1
for folder in vars.wifolders_u:
folder.sort(key=lambda x: x["num"])
#==================================================================#
# Extract object from server and send it to WI objects
@ -2277,6 +2284,11 @@ def commitwi(ar):
vars.worldinfo[ob["num"]]["constant"] = ob.get("constant", False)
# Was this a deletion request? If so, remove the requested index
if(vars.deletewi >= 0):
if(vars.worldinfo[vars.deletewi]["folder"] is not None):
for i, e in enumerate(vars.wifolders_u[vars.worldinfo[vars.deletewi]["folder"]]):
if(e is vars.worldinfo[vars.deletewi]):
vars.wifolders_u[vars.worldinfo[vars.deletewi]["folder"]].pop(i)
del vars.worldinfo_d[vars.worldinfo[vars.deletewi]]
del vars.worldinfo[vars.deletewi]
# Send the new WI array structure
sendwi()
@ -2298,6 +2310,7 @@ def deletewi(num):
#==================================================================#
def deletewifolder(uid):
uid = int(uid)
del vars.wifolders_u[uid]
del vars.wifolders_d[uid]
del vars.wifolders_l[vars.wifolders_l.index(uid)]
# Delete uninitialized entries in the folder we're going to delete
@ -2717,8 +2730,10 @@ def loadRequest(loadpath, filename=None):
vars.prompt = js["prompt"]
vars.memory = js["memory"]
vars.worldinfo = []
vars.worldinfo_u = {}
vars.wifolders_d = {int(k): v for k, v in js.get("wifolders_d", {}).items()}
vars.wifolders_l = js.get("wifolders_l", [])
vars.wifolders_u = {uid: [] for uid in vars.wifolders_d}
vars.lastact = ""
vars.lastctx = ""
@ -2756,14 +2771,20 @@ def loadRequest(loadpath, filename=None):
"num": num,
"init": True,
"selective": wi.get("selective", False),
"constant": wi.get("constant", False)
"constant": wi.get("constant", False),
"uid": None,
})
while(True):
uid = int.from_bytes(os.urandom(4), "little", signed=True)
if(uid not in vars.worldinfo_u):
break
vars.worldinfo_u[uid] = vars.worldinfo[-1]
vars.worldinfo[-1]["uid"] = uid
num += 1
for uid in vars.wifolders_l + [None]:
vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False})
vars.worldinfo.append({"key": "", "keysecondary": "", "content": "", "comment": "", "folder": uid, "num": None, "init": False, "selective": False, "constant": False, "uid": None})
stablesortwi()
organizewi()
# Save path for save button
vars.savedir = loadpath
@ -2905,8 +2926,10 @@ def importgame():
vars.authornote = ref["authorsNote"] if type(ref["authorsNote"]) is str else ""
vars.actions = structures.KoboldStoryRegister()
vars.worldinfo = []
vars.worldinfo_u = {}
vars.wifolders_d = {}
vars.wifolders_l = []
vars.wifolders_u = {uid: [] for uid in vars.wifolders_d}
vars.lastact = ""
vars.lastctx = ""
@ -2934,8 +2957,15 @@ def importgame():
"num": num,
"init": True,
"selective": wi.get("selective", False),
"constant": wi.get("constant", False)
"constant": wi.get("constant", False),
"uid": None,
})
while(True):
uid = int.from_bytes(os.urandom(4), "little", signed=True)
if(uid not in vars.worldinfo_u):
break
vars.worldinfo_u[uid] = vars.worldinfo[-1]
vars.worldinfo[-1]["uid"] = uid
num += 1
# Clear import data
@ -2973,8 +3003,10 @@ def importAidgRequest(id):
vars.authornote = js["authorsNote"]
vars.actions = structures.KoboldStoryRegister()
vars.worldinfo = []
vars.worldinfo_u = {}
vars.wifolders_d = {}
vars.wifolders_l = []
vars.wifolders_u = {uid: [] for uid in vars.wifolders_d}
vars.lastact = ""
vars.lastctx = ""
@ -2989,8 +3021,15 @@ def importAidgRequest(id):
"num": num,
"init": True,
"selective": wi.get("selective", False),
"constant": wi.get("constant", False)
"constant": wi.get("constant", False),
"uid": None,
})
while(True):
uid = int.from_bytes(os.urandom(4), "little", signed=True)
if(uid not in vars.worldinfo_u):
break
vars.worldinfo_u[uid] = vars.worldinfo[-1]
vars.worldinfo[-1]["uid"] = uid
num += 1
# Reset current save
@ -3029,8 +3068,15 @@ def wiimportrequest():
"num": num,
"init": True,
"selective": wi.get("selective", False),
"constant": wi.get("constant", False)
"constant": wi.get("constant", False),
"uid": None,
})
while(True):
uid = int.from_bytes(os.urandom(4), "little", signed=True)
if(uid not in vars.worldinfo_u):
break
vars.worldinfo_u[uid] = vars.worldinfo[-1]
vars.worldinfo[-1]["uid"] = uid
num += 1
print("{0}".format(vars.worldinfo[0]))
@ -3053,6 +3099,7 @@ def newGameRequest():
vars.authornote = ""
vars.worldinfo = []
vars.worldinfo_u = {}
vars.wifolders_d = {}
vars.wifolders_l = []
vars.lastact = ""

1112
bridge.lua Normal file

File diff suppressed because it is too large Load Diff

4
extern/lualibs/base64.lua vendored Normal file
View File

@ -0,0 +1,4 @@
-- base64 1.5.3 | /base64.lua | https://github.com/iskolbin/lbase64 | License: Unlicense | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
local a={}local b=_G.bit32 and _G.bit32.extract;if not b then if _G.bit then local c,d,e=_G.bit.lshift,_G.bit.rshift,_G.bit.band;b=function(f,g,h)return e(d(f,g),c(1,h)-1)end elseif _G._VERSION=="Lua 5.1"then b=function(f,g,h)local i=0;local j=2^g;for k=0,h-1 do local l=j+j;if f%l>=j then i=i+2^k end;j=l end;return i end else b=load[[return function( v, from, width )
return ( v >> from ) & ((1 << width) - 1)
end]]()end end;function a.makeencoder(m,n,o)local p={}for q,r in pairs{[0]='A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9',m or'+',n or'/',o or'='}do p[q]=r:byte()end;return p end;function a.makedecoder(m,n,o)local s={}for q,t in pairs(a.makeencoder(m,n,o))do s[t]=q end;return s end;local u=a.makeencoder()local v=a.makedecoder()local r,w=string.char,table.concat;function a.encode(x,p,y)p=p or u;local z,A,B={},1,#x;local C=B%3;local D={}for k=1,B-C,3 do local E,F,G=x:byte(k,k+2)local f=E*0x10000+F*0x100+G;local H;if y then H=D[f]if not H then H=r(p[b(f,18,6)],p[b(f,12,6)],p[b(f,6,6)],p[b(f,0,6)])D[f]=H end else H=r(p[b(f,18,6)],p[b(f,12,6)],p[b(f,6,6)],p[b(f,0,6)])end;z[A]=H;A=A+1 end;if C==2 then local E,F=x:byte(B-1,B)local f=E*0x10000+F*0x100;z[A]=r(p[b(f,18,6)],p[b(f,12,6)],p[b(f,6,6)],p[64])elseif C==1 then local f=x:byte(B)*0x10000;z[A]=r(p[b(f,18,6)],p[b(f,12,6)],p[64],p[64])end;return w(z)end;function a.decode(I,s,y)s=s or v;local J='[^%w%+%/%=]'if s then local m,n;for t,q in pairs(s)do if q==62 then m=t elseif q==63 then n=t end end;J=('[^%%w%%%s%%%s%%=]'):format(r(m),r(n))end;I=I:gsub(J,'')local D=y and{}local z,A={},1;local B=#I;local K=I:sub(-2)=='=='and 2 or I:sub(-1)=='='and 1 or 0;for k=1,K>0 and B-4 or B,4 do local E,F,G,L=I:byte(k,k+3)local H;if y then local M=E*0x1000000+F*0x10000+G*0x100+L;H=D[M]if not H then local f=s[E]*0x40000+s[F]*0x1000+s[G]*0x40+s[L]H=r(b(f,16,8),b(f,8,8),b(f,0,8))D[M]=H end else local f=s[E]*0x40000+s[F]*0x1000+s[G]*0x40+s[L]H=r(b(f,16,8),b(f,8,8),b(f,0,8))end;z[A]=H;A=A+1 end;if K==1 then local E,F,G=I:byte(B-3,B-1)local f=s[E]*0x40000+s[F]*0x1000+s[G]*0x40;z[A]=r(b(f,16,8),b(f,8,8))elseif K==2 then local E,F=I:byte(B-3,B-2)local f=s[E]*0x40000+s[F]*0x1000;z[A]=r(b(f,16,8))end;return w(z)end;return a

6
extern/lualibs/hashings/adler32.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/adler32.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}local e=65521;c.digest_size=8;c.block_size=8;function c:new(f)if self~=c then return nil,"First argument must be self"end;local g=setmetatable({},d)g._b1=b(1)g._b2=b(0)if f~=nil then g:update(f)end;return g end;setmetatable(c,{__call=c.new})function c:copy()local g=c:new()g._b1=self._b1:copy()g._b2=self._b2:copy()return g end;function c:update(f)local h;if f==nil then f=""end;f=tostring(f)for i=1,#f do h=a.byte(f,i)self._b1=(self._b1+h)%e;self._b2=(self._b2+self._b1)%e end end;function c:digest()return(self._b2<<16|self._b1):asbytestring()end;function c:hexdigest()local j;local k={}j=self:digest()for i=1,#j do k[i]=a.format("%02X",a.byte(j,i))end;return table.concat(k)end;return c

6
extern/lualibs/hashings/blake2b.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/blake2b.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintb").u64;local c=require("nums.uintn").u8;local d={}local e={__metatable={},__index=d}d.digest_size=64;d.block_size=128;local f={b("0x6A09E667F3BCC908"),b("0xBB67AE8584CAA73B"),b("0x3C6EF372FE94F82B"),b("0xA54FF53A5F1D36F1"),b("0x510E527FADE682D1"),b("0x9B05688C2B3E6C1F"),b("0x1F83D9ABFB41BD6B"),b("0x5BE0CD19137E2179")}local g={{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},{15,11,5,9,10,16,14,7,2,13,1,3,12,8,6,4},{12,9,13,1,6,3,16,14,11,15,4,7,8,2,10,5},{8,10,4,2,14,13,12,15,3,7,6,11,5,1,16,9},{10,1,6,8,3,5,11,16,15,2,12,13,7,9,4,14},{3,13,7,11,1,12,9,4,5,14,8,6,16,15,2,10},{13,6,2,16,15,14,5,11,1,8,7,4,10,3,9,12},{14,12,8,15,13,2,4,10,6,1,16,5,9,7,3,11},{7,16,15,10,12,4,1,9,13,3,14,8,2,5,11,6},{11,3,9,5,8,7,2,6,16,12,10,15,4,13,14,1},{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},{15,11,5,9,10,16,14,7,2,13,1,3,12,8,6,4}}local function h(i,j)return i>>j|(i<<64-j)end;local function k(l,m)l._t0=l._t0+m;if l._t0<m then l._t1=l._t1+1 end end;local function n(o,p,q,r,s,t,u)r=r+s+q[g[o+1][2*p+1]]u=h(u~r,32)t=t+u;s=h(s~t,24)r=r+s+q[g[o+1][2*p+2]]u=h(u~r,16)t=t+u;s=h(s~t,63)return r,s,t,u end;local function v(o,q,w)w[1],w[5],w[9],w[13]=n(o,0,q,w[1],w[5],w[9],w[13])w[2],w[6],w[10],w[14]=n(o,1,q,w[2],w[6],w[10],w[14])w[3],w[7],w[11],w[15]=n(o,2,q,w[3],w[7],w[11],w[15])w[4],w[8],w[12],w[16]=n(o,3,q,w[4],w[8],w[12],w[16])w[1],w[6],w[11],w[16]=n(o,4,q,w[1],w[6],w[11],w[16])w[2],w[7],w[12],w[13]=n(o,5,q,w[2],w[7],w[12],w[13])w[3],w[8],w[9],w[14]=n(o,6,q,w[3],w[8],w[9],w[14])w[4],w[5],w[10],w[15]=n(o,7,q,w[4],w[5],w[10],w[15])end;local function x(l)local w={}local q={}if#l._data<128 then return end;for y=1,128,8 do q[#q+1]=b(a.byte(l._data,y+7))<<56|(b(a.byte(l._data,y+6))<<48)|(b(a.byte(l._data,y+5))<<40)|(b(a.byte(l._data,y+4))<<32)|(b(a.byte(l._data,y+3))<<24)|(b(a.byte(l._data,y+2))<<16)|(b(a.byte(l._data,y+1))<<8)|b(a.byte(l._data,y))end;l._data=l._data:sub(129,#l._data)for p=1,8 do w[p]=l._h[p]:copy()end;w[9]=f[1]:copy()w[10]=f[2]:copy()w[11]=f[3]:copy()w[12]=f[4]:copy()w[13]=l._t0~f[5]w[14]=l._t1~f[6]if l._last then w[15]=b("0xFFFFFFFFFFFFFFFF")~f[7]else w[15]=f[7]:copy()end;w[16]=f[8]:copy()v(0,q,w)v(1,q,w)v(2,q,w)v(3,q,w)v(4,q,w)v(5,q,w)v(6,q,w)v(7,q,w)v(8,q,w)v(9,q,w)v(10,q,w)v(11,q,w)for p=1,8 do l._h[p]=l._h[p]~w[p]~w[p+8]end end;function d:new(z)if self~=d then return nil,"First argument must be self"end;local A=setmetatable({},e)A._h={}for p=1,8 do A._h[p]=f[p]:copy()end;A._h[1]=A._h[1]~16842816;A._last=false;A._t0=b(0)A._t1=b(0)A._data=""if z~=nil then A:update(z)end;return A end;setmetatable(d,{__call=d.new})function d:copy()local A=d()for p=1,8 do A._h[p]=self._h[p]:copy()end;A._last=self._last;A._t0=self._t0:copy()A._t1=self._t1:copy()A._data=self._data;return A end;function d:update(z)if z==nil then z=""end;z=tostring(z)self._data=self._data..z;while#self._data>128 do k(self,128)x(self)end end;function d:digest()local B;local C={}local y;B=self:copy()k(B,#B._data)B._last=true;B._data=B._data..a.rep(a.char(0),128-#B._data)x(B)for p=1,#B._h do C[p]=B._h[p]:swape():asbytestring()end;return table.concat(C)end;function d:hexdigest()local D;local C={}D=self:digest()for p=1,#D do C[p]=a.format("%02X",a.byte(D,p))end;return table.concat(C)end;return d

6
extern/lualibs/hashings/blake2s.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/blake2s.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintn").u32;local c=require("nums.uintn").u8;local d={}local e={__metatable={},__index=d}d.digest_size=32;d.block_size=64;local f={b(0x6A09E667),b(0xBB67AE85),b(0x3C6EF372),b(0xA54FF53A),b(0x510E527F),b(0x9B05688C),b(0x1F83D9AB),b(0x5BE0CD19)}local g={{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},{15,11,5,9,10,16,14,7,2,13,1,3,12,8,6,4},{12,9,13,1,6,3,16,14,11,15,4,7,8,2,10,5},{8,10,4,2,14,13,12,15,3,7,6,11,5,1,16,9},{10,1,6,8,3,5,11,16,15,2,12,13,7,9,4,14},{3,13,7,11,1,12,9,4,5,14,8,6,16,15,2,10},{13,6,2,16,15,14,5,11,1,8,7,4,10,3,9,12},{14,12,8,15,13,2,4,10,6,1,16,5,9,7,3,11},{7,16,15,10,12,4,1,9,13,3,14,8,2,5,11,6},{11,3,9,5,8,7,2,6,16,12,10,15,4,13,14,1}}local function h(i,j)return i>>j|(i<<32-j)end;local function k(l,m)l._t0=l._t0+m;if l._t0<m then l._t1=l._t1+1 end end;local function n(o,p,q,r,s,t,u)r=r+s+q[g[o+1][2*p+1]]u=h(u~r,16)t=t+u;s=h(s~t,12)r=r+s+q[g[o+1][2*p+2]]u=h(u~r,8)t=t+u;s=h(s~t,7)return r,s,t,u end;local function v(o,q,w)w[1],w[5],w[9],w[13]=n(o,0,q,w[1],w[5],w[9],w[13])w[2],w[6],w[10],w[14]=n(o,1,q,w[2],w[6],w[10],w[14])w[3],w[7],w[11],w[15]=n(o,2,q,w[3],w[7],w[11],w[15])w[4],w[8],w[12],w[16]=n(o,3,q,w[4],w[8],w[12],w[16])w[1],w[6],w[11],w[16]=n(o,4,q,w[1],w[6],w[11],w[16])w[2],w[7],w[12],w[13]=n(o,5,q,w[2],w[7],w[12],w[13])w[3],w[8],w[9],w[14]=n(o,6,q,w[3],w[8],w[9],w[14])w[4],w[5],w[10],w[15]=n(o,7,q,w[4],w[5],w[10],w[15])end;local function x(l)local w={}local q={}if#l._data<64 then return end;for y=1,64,4 do q[#q+1]=b(a.byte(l._data,y+3)<<24|(a.byte(l._data,y+2)<<16)|(a.byte(l._data,y+1)<<8)|a.byte(l._data,y))end;l._data=l._data:sub(65,#l._data)for p=1,8 do w[p]=l._h[p]:copy()end;w[9]=f[1]:copy()w[10]=f[2]:copy()w[11]=f[3]:copy()w[12]=f[4]:copy()w[13]=l._t0~f[5]w[14]=l._t1~f[6]if l._last then w[15]=b(0xFFFFFFFF)~f[7]else w[15]=f[7]:copy()end;w[16]=f[8]:copy()v(0,q,w)v(1,q,w)v(2,q,w)v(3,q,w)v(4,q,w)v(5,q,w)v(6,q,w)v(7,q,w)v(8,q,w)v(9,q,w)for p=1,8 do l._h[p]=l._h[p]~w[p]~w[p+8]end end;function d:new(z)if self~=d then return nil,"First argument must be self"end;local A=setmetatable({},e)A._h={}for p=1,8 do A._h[p]=f[p]:copy()end;A._h[1]=A._h[1]~16842784;A._last=false;A._t0=b(0)A._t1=b(0)A._data=""if z~=nil then A:update(z)end;return A end;setmetatable(d,{__call=d.new})function d:copy()local A=d()for p=1,8 do A._h[p]=self._h[p]:copy()end;A._last=self._last;A._t0=self._t0:copy()A._t1=self._t1:copy()A._data=self._data;return A end;function d:update(z)if z==nil then z=""end;z=tostring(z)self._data=self._data..z;while#self._data>64 do k(self,64)x(self)end end;function d:digest()local B;local C={}B=self:copy()k(B,#B._data)B._last=true;B._data=B._data..a.rep(a.char(0),64-#B._data)x(B)for p=1,#B._h do C[p]=B._h[p]:swape():asbytestring()end;return table.concat(C)end;function d:hexdigest()local D;local C={}D=self:digest()for p=1,#D do C[p]=a.format("%02X",a.byte(D,p))end;return table.concat(C)end;return d

6
extern/lualibs/hashings/crc32.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/crc32.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}c.digest_size=8;c.block_size=8;local function e(f)end;function c:new(g)if self~=c then return nil,"First argument must be self"end;local h=setmetatable({},d)h._crc=b(0xFFFFFFFF)if g~=nil then h:update(g)end;return h end;setmetatable(c,{__call=c.new})function c:copy()local h=c:new()h._crc=self._crc:copy()return h end;function c:update(g)local i;local j;if g==nil then g=""end;g=tostring(g)for k=1,#g do i=a.byte(g,k)self._crc=self._crc~i;for l=1,8 do j=self._crc&1*-1;self._crc=self._crc>>1~(0xEDB88320&j)end end end;function c:digest()return~self._crc:asbytestring()end;function c:hexdigest()local m;local n={}m=self:digest()for k=1,#m do n[k]=a.format("%02X",a.byte(m,k))end;return table.concat(n)end;return c

6
extern/lualibs/hashings/hmac.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/hmac.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b={}local c={__metatable={},__index=b}function b:new(d,e,f)local g;local h={}local i={}if self~=b then return nil,"First argument must be self"end;local j=setmetatable({},c)j._hm=d;if#e>d.block_size then g=d(e)e=g:digest()end;for k=1,#e do h[#h+1]=a.byte(e,k)end;for k=#e+1,d.block_size do h[#h+1]=0 end;j._opad={}for k=1,#h do i[k]=a.char(h[k]~0x36)j._opad[k]=a.char(h[k]~0x5C)end;i=table.concat(i)j._opad=table.concat(j._opad)j._hash=j._hm(i)if f~=nil then j._hash:update(f)end;return j end;setmetatable(b,{__call=b.new})function b:copy()local j=setmetatable({},c)j._hm=self._hm;j._hash=self._hash:copy()j._opad=self._opad;return j end;function b:update(f)self._hash:update(f)end;function b:digest()local l;local m;local g;l=self:copy()m=l._hash:digest()g=l._hm(l._opad)g:update(m)return g:digest()end;function b:hexdigest()local n;local o={}n=self:digest()for k=1,#n do o[k]=a.format("%02X",a.byte(n,k))end;return table.concat(o)end;return b

6
extern/lualibs/hashings/init.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/init.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a={}a.adler32=require("hashings.adler32")a.blake2b=require("hashings.blake2b")a.blake2s=require("hashings.blake2s")a.crc32=require("hashings.crc32")a.md5=require("hashings.md5")a.ripemd160=require("hashings.ripemd160")a.sha1=require("hashings.sha1")a.sha256=require("hashings.sha256")a.sha3_256=require("hashings.sha3_256")a.sha3_512=require("hashings.sha3_512")a.sha512=require("hashings.sha512")a.whirlpool=require("hashings.whirlpool")a.hmac=require("hashings.hmac")a.pbkdf2=require("hashings.pbkdf2")a.algorithms={"adler32","blake2b","blake2s","crc32","md5","ripemd160","sha1","sha256","sha3_256","sha3_512","sha512","whirlpool"}local b={adler32=a.adler32,blake2b=a.blake2b,blake2s=a.blake2s,crc32=a.crc32,md5=a.md5,ripemd160=a.ripemd160,sha1=a.sha1,sha256=a.sha256,sha3_256=a.sha3_256,sha3_512=a.sha3_512,sha512=a.sha512,whirlpool=a.whirlpool}function a:new(c,d)local e;e=b[c]if e==nil then return nil end;return e:new(d)end;setmetatable(a,{__call=a.new})return a

6
extern/lualibs/hashings/keccak.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/keccak.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintb").u64;local c={}local d={__metatable={},__index=c}local e={{5,2},{1,3},{2,4},{3,5},{4,1}}local f={11,8,12,18,19,4,6,17,9,22,25,5,16,24,20,14,13,3,21,15,23,10,7,2}local g={1,3,6,10,15,21,28,36,45,55,2,14,27,41,56,8,25,43,62,18,39,61,20,44}local h={{2,3},{3,4},{4,5},{5,1},{1,2},{7,8},{8,9},{9,10},{10,6},{6,7},{12,13},{13,14},{14,15},{15,11},{11,12},{17,18},{18,19},{19,20},{20,16},{16,17},{22,23},{23,24},{24,25},{25,21},{21,22}}local i={b("0x1"),b("0x8082"),b("0x800000000000808A"),b("0x8000000080008000"),b("0x808B"),b("0x80000001"),b("0x8000000080008081"),b("0x8000000000008009"),b("0x8A"),b("0x88"),b("0x80008009"),b("0x8000000A"),b("0x8000808B"),b("0x800000000000008B"),b("0x8000000000008089"),b("0x8000000000008003"),b("0x8000000000008002"),b("0x8000000000000080"),b("0x800A"),b("0x800000008000000A"),b("0x8000000080008081"),b("0x8000000000008080"),b("0x80000001"),b("0x8000000080008008")}local function j(k,l)return k<<l|(k>>64-l)end;local function m(n)local o;local p;for q=1,n._block_size,8 do o=q//8+1;p=q//8*8+1;n._s[o]=n._s[o]~(b(a.byte(n._data,p))|(b(a.byte(n._data,p+1))<<8)|(b(a.byte(n._data,p+2))<<16)|(b(a.byte(n._data,p+3))<<24)|(b(a.byte(n._data,p+4))<<32)|(b(a.byte(n._data,p+5))<<40)|(b(a.byte(n._data,p+6))<<48)|(b(a.byte(n._data,p+7))<<56))end;n._data=n._data:sub(n._block_size+1)end;local function r(s)local t={}local u;for q=1,5 do t[q]=s[q]~s[q+5]~s[q+10]~s[q+15]~s[q+20]end;for q=1,5 do u=t[e[q][1]]~j(t[e[q][2]],1)for o=q,25,5 do s[o]=s[o]~u end end end;local function v(s)local w;local u;u=s[2]:copy()for q=1,24 do w=s[f[q]]s[f[q]]=j(u,g[q])u=w end end;local function x(s)local t={}for q=1,25 do t[q]=s[q]:copy()end;for q=1,25 do s[q]=s[q]~(~t[h[q][1]]&t[h[q][2]])end end;local function y(s,l)s[1]=s[1]~i[l]end;function c:new(z,A,B)if self~=c then return nil,"First argument must be self"end;if z>200 then return nil,"Invalid block size"end;local C=setmetatable({},d)C._block_size=z;C._digest_size=A;C._data=""C._s={}for q=1,25 do C._s[q]=b(0)end;if B~=nil then C:update(B)end;return C end;setmetatable(c,{__call=c.new})function c:copy()local C=setmetatable({},d)C._block_size=self._block_size;C._digest_size=self._digest_size;C._data=self._data;C._s={}for q=1,25 do C._s[q]=self._s[q]:copy()end;return C end;function c:update(B)if B==nil then B=""end;B=tostring(B)self._data=self._data..B;while#self._data>=self._block_size do m(self)for q=1,24 do r(self._s)v(self._s)x(self._s)y(self._s,q)end end end;function c:digest()local D;local B;local E={}D=self:copy()if#D._data==D._block_size-1 then B=a.char(0x06|0x80)else B=a.char(0x06)..a.rep(a.char(0),D._block_size-#D._data-2)..a.char(0x80)end;D:update(B)for q=1,D._digest_size//8 do E[q]=D._s[q]:swape():asbytestring()end;return table.concat(E)end;function c:hexdigest()local F;local E={}F=self:digest()for q=1,#F do E[q]=a.format("%02X",a.byte(F,q))end;return table.concat(E)end;return c

6
extern/lualibs/hashings/md5.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/md5.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}c.digest_size=16;c.block_size=64;local function e(f,g,h)return f&g|(~f&h)end;local function i(f,g,h)return f&h|(g&~h)end;local function j(f,g,h)return f~g~h end;local function k(f,g,h)return g~(f|~h)end;local function l(m,n)return m<<n|(m>>32-n)end;local function o(p,q,r,s,t,m,u,v)return l(q+p(r,s,t)+m+v,u)+r end;local function w(x,y,z,A,f)local q=x;local r=y;local s=z;local t=A;q=o(e,q,r,s,t,f[1],7,0xD76AA478)t=o(e,t,q,r,s,f[2],12,0xE8C7B756)s=o(e,s,t,q,r,f[3],17,0x242070DB)r=o(e,r,s,t,q,f[4],22,0xC1BDCEEE)q=o(e,q,r,s,t,f[5],7,0xF57C0FAF)t=o(e,t,q,r,s,f[6],12,0x4787C62A)s=o(e,s,t,q,r,f[7],17,0xA8304613)r=o(e,r,s,t,q,f[8],22,0xFD469501)q=o(e,q,r,s,t,f[9],7,0x698098D8)t=o(e,t,q,r,s,f[10],12,0x8B44F7AF)s=o(e,s,t,q,r,f[11],17,0xFFFF5BB1)r=o(e,r,s,t,q,f[12],22,0x895CD7BE)q=o(e,q,r,s,t,f[13],7,0x6B901122)t=o(e,t,q,r,s,f[14],12,0xFD987193)s=o(e,s,t,q,r,f[15],17,0xA679438E)r=o(e,r,s,t,q,f[16],22,0x49B40821)q=o(i,q,r,s,t,f[2],5,0xF61E2562)t=o(i,t,q,r,s,f[7],9,0xC040B340)s=o(i,s,t,q,r,f[12],14,0x265E5A51)r=o(i,r,s,t,q,f[1],20,0xE9B6C7AA)q=o(i,q,r,s,t,f[6],5,0xD62F105D)t=o(i,t,q,r,s,f[11],9,0x2441453)s=o(i,s,t,q,r,f[16],14,0xD8A1E681)r=o(i,r,s,t,q,f[5],20,0xE7D3FBC8)q=o(i,q,r,s,t,f[10],5,0x21E1CDE6)t=o(i,t,q,r,s,f[15],9,0xC33707D6)s=o(i,s,t,q,r,f[4],14,0xF4D50D87)r=o(i,r,s,t,q,f[9],20,0x455A14ED)q=o(i,q,r,s,t,f[14],5,0xA9E3E905)t=o(i,t,q,r,s,f[3],9,0xFCEFA3F8)s=o(i,s,t,q,r,f[8],14,0x676F02D9)r=o(i,r,s,t,q,f[13],20,0x8D2A4C8A)q=o(j,q,r,s,t,f[6],4,0xFFFA3942)t=o(j,t,q,r,s,f[9],11,0x8771F681)s=o(j,s,t,q,r,f[12],16,0x6D9D6122)r=o(j,r,s,t,q,f[15],23,0xFDE5380C)q=o(j,q,r,s,t,f[2],4,0xA4BEEA44)t=o(j,t,q,r,s,f[5],11,0x4BDECFA9)s=o(j,s,t,q,r,f[8],16,0xF6BB4B60)r=o(j,r,s,t,q,f[11],23,0xBEBFBC70)q=o(j,q,r,s,t,f[14],4,0x289B7EC6)t=o(j,t,q,r,s,f[1],11,0xEAA127FA)s=o(j,s,t,q,r,f[4],16,0xD4EF3085)r=o(j,r,s,t,q,f[7],23,0x4881D05)q=o(j,q,r,s,t,f[10],4,0xD9D4D039)t=o(j,t,q,r,s,f[13],11,0xE6DB99E5)s=o(j,s,t,q,r,f[16],16,0x1FA27CF8)r=o(j,r,s,t,q,f[3],23,0xC4AC5665)q=o(k,q,r,s,t,f[1],6,0xF4292244)t=o(k,t,q,r,s,f[8],10,0x432AFF97)s=o(k,s,t,q,r,f[15],15,0xAB9423A7)r=o(k,r,s,t,q,f[6],21,0xFC93A039)q=o(k,q,r,s,t,f[13],6,0x655B59C3)t=o(k,t,q,r,s,f[4],10,0x8F0CCC92)s=o(k,s,t,q,r,f[11],15,0xFFEFF47D)r=o(k,r,s,t,q,f[2],21,0x85845DD1)q=o(k,q,r,s,t,f[9],6,0x6FA87E4F)t=o(k,t,q,r,s,f[16],10,0xFE2CE6E0)s=o(k,s,t,q,r,f[7],15,0xA3014314)r=o(k,r,s,t,q,f[14],21,0x4E0811A1)q=o(k,q,r,s,t,f[5],6,0xF7537E82)t=o(k,t,q,r,s,f[12],10,0xBD3AF235)s=o(k,s,t,q,r,f[3],15,0x2AD7D2BB)r=o(k,r,s,t,q,f[10],21,0xEB86D391)return q+x,r+y,s+z,t+A end;function c:new(B)if self~=c then return nil,"First argument must be self"end;local C=setmetatable({},d)C._A=b(0x67452301)C._B=b(0xEFCDAB89)C._C=b(0x98BADCFE)C._D=b(0x10325476)C._len=0;C._data=""if B~=nil then C:update(B)end;return C end;setmetatable(c,{__call=c.new})function c:copy()local C=c()C._A=self._A:copy()C._B=self._B:copy()C._C=self._C:copy()C._D=self._D:copy()C._data=self._data;C._len=self._len;return C end;function c:update(B)local f;if B==nil then B=""end;B=tostring(B)self._len=self._len+#B;self._data=self._data..B;while#self._data>=64 do f={}for D=1,64,4 do f[#f+1]=a.byte(self._data,D+3)<<24|(a.byte(self._data,D+2)<<16)|(a.byte(self._data,D+1)<<8)|a.byte(self._data,D)end;self._data=self._data:sub(65,#self._data)self._A,self._B,self._C,self._D=w(self._A,self._B,self._C,self._D,f)end end;function c:digest()local E;local B;local F=0;local G=0;E=self:copy()G=E._len%64;if G<56 then G=56-G else G=120-G end;F=E._len*8;B=a.char(1<<7)..a.rep(a.char(0),G-1)..a.char(F&0xFF)..a.char(F>>8&0xFF)..a.char(F>>16&0xFF)..a.char(F>>24&0xFF)..a.char(F>>32&0xFF)..a.char(F>>40&0xFF)..a.char(F>>48&0xFF)..a.char(F>>56&0xFF)E:update(B)return E._A:swape():asbytestring()..E._B:swape():asbytestring()..E._C:swape():asbytestring()..E._D:swape():asbytestring()end;function c:hexdigest()local H;local I={}H=self:digest()for J=1,#H do I[J]=a.format("%02X",a.byte(H,J))end;return table.concat(I)end;return c

6
extern/lualibs/hashings/pbkdf2.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/pbkdf2.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintn").u32;local c=require("hashings.hmac")local d={}local function e(f,g)local h={}local i={}local j={}for k=1,#f do h[#h+1]=a.byte(f,k)end;for k=1,#g do i[#i+1]=a.byte(g,k)end;for k=1,#h do j[#j+1]=a.char(h[k]~i[k])end;return table.concat(j)end;local function l(m)local n={}for k=1,#m do n[k]=a.format("%02X",a.byte(m,k))end;return table.concat(n)end;function d:pbkdf2(o,p,q,r)local s;local t;s=c(o,p,q..b(1):asbytestring()):digest()t=s;for k=2,r do s=c(o,p,s):digest()t=e(t,s)end;return l(t)end;setmetatable(d,{__call=d.pbkdf2})return d

6
extern/lualibs/hashings/ripemd160.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/hashings/sha1.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/sha1.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}c.digest_size=20;c.block_size=64;local function e(f,g)return f<<g|(f>>32-g)end;function c:new(h)if self~=c then return nil,"First argument must be self"end;local i=setmetatable({},d)i._H0=b(0x67452301)i._H1=b(0xEFCDAB89)i._H2=b(0x98BADCFE)i._H3=b(0x10325476)i._H4=b(0xC3D2E1F0)i._len=0;i._data=""if h~=nil then i:update(h)end;return i end;setmetatable(c,{__call=c.new})function c:copy()local i=c:new()i._H0=self._H0:copy()i._H1=self._H1:copy()i._H2=self._H2:copy()i._H3=self._H3:copy()i._H4=self._H4:copy()i._data=self._data;i._len=self._len;return i end;function c:update(h)local j=b(0x5A827999)local k=b(0x6ED9EBA1)local l=b(0x8F1BBCDC)local m=b(0xCA62C1D6)local n;local o;local p;local q;local r;local s;local t;if h==nil then h=""end;h=tostring(h)self._len=self._len+#h;self._data=self._data..h;while#self._data>=64 do n={}for u=1,64,4 do local v=#n+1;n[v]=b(a.byte(self._data,u))<<24;n[v]=n[v]|(b(a.byte(self._data,u+1))<<16)n[v]=n[v]|(b(a.byte(self._data,u+2))<<8)n[v]=n[v]|b(a.byte(self._data,u+3))end;for u=17,80 do n[u]=e(n[u-3]~n[u-8]~n[u-14]~n[u-16],1)end;p=self._H0;q=self._H1;r=self._H2;s=self._H3;t=self._H4;for u=1,20 do o=e(p,5)+q&r|(~q&s)+t+n[u]+j;t=s;s=r;r=e(q,30)q=p;p=o end;for u=21,40 do o=e(p,5)+q~r~s+t+n[u]+k;t=s;s=r;r=e(q,30)q=p;p=o end;for u=41,60 do o=e(p,5)+q&r|(q&s)|(r&s)+t+n[u]+l;t=s;s=r;r=e(q,30)q=p;p=o end;for u=61,80 do o=e(p,5)+q~r~s+t+n[u]+m;t=s;s=r;r=e(q,30)q=p;p=o end;self._H0=self._H0+p;self._H1=self._H1+q;self._H2=self._H2+r;self._H3=self._H3+s;self._H4=self._H4+t;self._data=self._data:sub(65,#self._data)end end;function c:digest()local w;local h;local x=0;local y=0;w=self:copy()y=w._len%64;if y<56 then y=56-y else y=120-y end;x=w._len*8;h=a.char(1<<7)..a.rep(a.char(0),y-1)..a.char(x>>56&0xFF)..a.char(x>>48&0xFF)..a.char(x>>40&0xFF)..a.char(x>>32&0xFF)..a.char(x>>24&0xFF)..a.char(x>>16&0xFF)..a.char(x>>8&0xFF)..a.char(x&0xFF)w:update(h)return w._H0:asbytestring()..w._H1:asbytestring()..w._H2:asbytestring()..w._H3:asbytestring()..w._H4:asbytestring()end;function c:hexdigest()local z;local A={}z=self:digest()for u=1,#z do A[u]=a.format("%02X",a.byte(z,u))end;return table.concat(A)end;return c

6
extern/lualibs/hashings/sha256.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/sha256.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintn").u32;local c={}local d={__metatable={},__index=c}c.digest_size=32;c.block_size=64;local e={b(0x428A2F98),b(0x71374491),b(0xB5C0FBCF),b(0xE9B5DBA5),b(0x3956C25B),b(0x59F111F1),b(0x923F82A4),b(0xAB1C5ED5),b(0xD807AA98),b(0x12835B01),b(0x243185BE),b(0x550C7DC3),b(0x72BE5D74),b(0x80DEB1FE),b(0x9BDC06A7),b(0xC19BF174),b(0xE49B69C1),b(0xEFBE4786),b(0x0FC19DC6),b(0x240CA1CC),b(0x2DE92C6F),b(0x4A7484AA),b(0x5CB0A9DC),b(0x76F988DA),b(0x983E5152),b(0xA831C66D),b(0xB00327C8),b(0xBF597FC7),b(0xC6E00BF3),b(0xD5A79147),b(0x06CA6351),b(0x14292967),b(0x27B70A85),b(0x2E1B2138),b(0x4D2C6DFC),b(0x53380D13),b(0x650A7354),b(0x766A0ABB),b(0x81C2C92E),b(0x92722C85),b(0xA2BFE8A1),b(0xA81A664B),b(0xC24B8B70),b(0xC76C51A3),b(0xD192E819),b(0xD6990624),b(0xF40E3585),b(0x106AA070),b(0x19A4C116),b(0x1E376C08),b(0x2748774C),b(0x34B0BCB5),b(0x391C0CB3),b(0x4ED8AA4A),b(0x5B9CCA4F),b(0x682E6FF3),b(0x748F82EE),b(0x78A5636F),b(0x84C87814),b(0x8CC70208),b(0x90BEFFFA),b(0xA4506CEB),b(0xBEF9A3F7),b(0xC67178F2)}local function f(g,h)return g>>h|(g<<32-h)end;local function i(g,j,k)return g&j~(~g&k)end;local function l(g,j,k)return g&j~(g&k)~(j&k)end;local function m(g)return f(g,2)~f(g,13)~f(g,22)end;local function n(g)return f(g,6)~f(g,11)~f(g,25)end;local function o(g)return f(g,7)~f(g,18)~(g>>3)end;local function p(g)return f(g,17)~f(g,19)~(g>>10)end;function c:new(q)if self~=c then return nil,"First argument must be self"end;local r=setmetatable({},d)r._H0=b(0x6A09E667)r._H1=b(0xBB67AE85)r._H2=b(0x3C6EF372)r._H3=b(0xA54FF53A)r._H4=b(0x510E527F)r._H5=b(0x9B05688C)r._H6=b(0x1F83D9AB)r._H7=b(0x5BE0CD19)r._len=0;r._data=""if q~=nil then r:update(q)end;return r end;setmetatable(c,{__call=c.new})function c:copy()local r=c:new()r._H0=self._H0:copy()r._H1=self._H1:copy()r._H2=self._H2:copy()r._H3=self._H3:copy()r._H4=self._H4:copy()r._H5=self._H5:copy()r._H6=self._H6:copy()r._H7=self._H7:copy()r._data=self._data;r._len=self._len;return r end;function c:update(q)local s;local t;local u;local v;local w;local x;local y;local z;local A;local B;local C;if q==nil then q=""end;q=tostring(q)self._len=self._len+#q;self._data=self._data..q;while#self._data>=64 do s={}for D=1,64,4 do local E=#s+1;s[E]=b(a.byte(self._data,D))<<24;s[E]=s[E]|(b(a.byte(self._data,D+1))<<16)s[E]=s[E]|(b(a.byte(self._data,D+2))<<8)s[E]=s[E]|b(a.byte(self._data,D+3))end;self._data=self._data:sub(65,#self._data)for D=17,64 do s[D]=p(s[D-2])+s[D-7]+o(s[D-15])+s[D-16]end;v=self._H0;w=self._H1;x=self._H2;y=self._H3;z=self._H4;A=self._H5;B=self._H6;C=self._H7;for D=1,64 do t=C+n(z)+i(z,A,B)+e[D]+s[D]u=m(v)+l(v,w,x)C=B;B=A;A=z;z=y+t;y=x;x=w;w=v;v=t+u end;self._H0=self._H0+v;self._H1=self._H1+w;self._H2=self._H2+x;self._H3=self._H3+y;self._H4=self._H4+z;self._H5=self._H5+A;self._H6=self._H6+B;self._H7=self._H7+C end end;function c:digest()local F;local q;local G=0;local H=0;F=self:copy()H=F._len%64;if H<56 then H=56-H else H=120-H end;G=F._len*8;q=a.char(1<<7)..a.rep(a.char(0),H-1)..a.char(G>>56&0xFF)..a.char(G>>48&0xFF)..a.char(G>>40&0xFF)..a.char(G>>32&0xFF)..a.char(G>>24&0xFF)..a.char(G>>16&0xFF)..a.char(G>>8&0xFF)..a.char(G&0xFF)F:update(q)return F._H0:asbytestring()..F._H1:asbytestring()..F._H2:asbytestring()..F._H3:asbytestring()..F._H4:asbytestring()..F._H5:asbytestring()..F._H6:asbytestring()..F._H7:asbytestring()end;function c:hexdigest()local C;local I={}C=self:digest()for D=1,#C do I[D]=a.format("%02X",a.byte(C,D))end;return table.concat(I)end;return c

6
extern/lualibs/hashings/sha3_256.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/sha3_256.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("hashings.keccak")local b={}local c={__metatable={},__index=b}b.digest_size=32;b.block_size=136;function b:new(d)return a:new(b.block_size,b.digest_size,d)end;setmetatable(b,{__call=b.new})return b

6
extern/lualibs/hashings/sha3_512.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/sha3_512.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("hashings.keccak")local b={}local c={__metatable={},__index=b}b.digest_size=64;b.block_size=72;function b:new(d)return a:new(b.block_size,b.digest_size,d)end;setmetatable(b,{__call=b.new})return b

6
extern/lualibs/hashings/sha512.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/sha512.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintb").u64;local c={}local d={__metatable={},__index=c}c.digest_size=64;c.block_size=128;local e={b("0x428A2F98D728AE22"),b("0x7137449123EF65CD"),b("0xB5C0FBCFEC4D3B2F"),b("0xE9B5DBA58189DBBC"),b("0x3956C25BF348B538"),b("0x59F111F1B605D019"),b("0x923F82A4AF194F9B"),b("0xAB1C5ED5DA6D8118"),b("0xD807AA98A3030242"),b("0x12835B0145706FBE"),b("0x243185BE4EE4B28C"),b("0x550C7DC3D5FFB4E2"),b("0x72BE5D74F27B896F"),b("0x80DEB1FE3B1696B1"),b("0x9BDC06A725C71235"),b("0xC19BF174CF692694"),b("0xE49B69C19EF14AD2"),b("0xEFBE4786384F25E3"),b("0x0FC19DC68B8CD5B5"),b("0x240CA1CC77AC9C65"),b("0x2DE92C6F592B0275"),b("0x4A7484AA6EA6E483"),b("0x5CB0A9DCBD41FBD4"),b("0x76F988DA831153B5"),b("0x983E5152EE66DFAB"),b("0xA831C66D2DB43210"),b("0xB00327C898FB213F"),b("0xBF597FC7BEEF0EE4"),b("0xC6E00BF33DA88FC2"),b("0xD5A79147930AA725"),b("0x06CA6351E003826F"),b("0x142929670A0E6E70"),b("0x27B70A8546D22FFC"),b("0x2E1B21385C26C926"),b("0x4D2C6DFC5AC42AED"),b("0x53380D139D95B3DF"),b("0x650A73548BAF63DE"),b("0x766A0ABB3C77B2A8"),b("0x81C2C92E47EDAEE6"),b("0x92722C851482353B"),b("0xA2BFE8A14CF10364"),b("0xA81A664BBC423001"),b("0xC24B8B70D0F89791"),b("0xC76C51A30654BE30"),b("0xD192E819D6EF5218"),b("0xD69906245565A910"),b("0xF40E35855771202A"),b("0x106AA07032BBD1B8"),b("0x19A4C116B8D2D0C8"),b("0x1E376C085141AB53"),b("0x2748774CDF8EEB99"),b("0x34B0BCB5E19B48A8"),b("0x391C0CB3C5C95A63"),b("0x4ED8AA4AE3418ACB"),b("0x5B9CCA4F7763E373"),b("0x682E6FF3D6B2B8A3"),b("0x748F82EE5DEFB2FC"),b("0x78A5636F43172F60"),b("0x84C87814A1F0AB72"),b("0x8CC702081A6439EC"),b("0x90BEFFFA23631E28"),b("0xA4506CEBDE82BDE9"),b("0xBEF9A3F7B2C67915"),b("0xC67178F2E372532B"),b("0xCA273ECEEA26619C"),b("0xD186B8C721C0C207"),b("0xEADA7DD6CDE0EB1E"),b("0xF57D4F7FEE6ED178"),b("0x06F067AA72176FBA"),b("0x0A637DC5A2C898A6"),b("0x113F9804BEF90DAE"),b("0x1B710B35131C471B"),b("0x28DB77F523047D84"),b("0x32CAAB7B40C72493"),b("0x3C9EBE0A15C9BEBC"),b("0x431D67C49C100D4C"),b("0x4CC5D4BECB3E42B6"),b("0x597F299CFC657E2A"),b("0x5FCB6FAB3AD6FAEC"),b("0x6C44198C4A475817")}local function f(g,h)return g>>h|(g<<64-h)end;local function i(g,j,k)return g&j~(~g&k)end;local function l(g,j,k)return g&j~(g&k)~(j&k)end;local function m(g)return f(g,28)~f(g,34)~f(g,39)end;local function n(g)return f(g,14)~f(g,18)~f(g,41)end;local function o(g)return f(g,1)~f(g,8)~(g>>7)end;local function p(g)return f(g,19)~f(g,61)~(g>>6)end;function c:new(q)if self~=c then return nil,"First argument must be self"end;local r=setmetatable({},d)r._H0=b(0x6A09E667F3BCC908)r._H1=b(0xBB67AE8584CAA73B)r._H2=b(0x3C6EF372FE94F82B)r._H3=b(0xA54FF53A5F1D36F1)r._H4=b(0x510E527FADE682D1)r._H5=b(0x9B05688C2B3E6C1F)r._H6=b(0x1F83D9ABFB41BD6B)r._H7=b(0x5BE0CD19137E2179)r._len=0;r._data=""if q~=nil then r:update(q)end;return r end;setmetatable(c,{__call=c.new})function c:copy()local r=c:new()r._H0=self._H0:copy()r._H1=self._H1:copy()r._H2=self._H2:copy()r._H3=self._H3:copy()r._H4=self._H4:copy()r._H5=self._H5:copy()r._H6=self._H6:copy()r._H7=self._H7:copy()r._data=self._data;r._len=self._len;return r end;function c:update(q)local s;local t;local u;local v;local w;local x;local y;local z;local A;local B;local C;if q==nil then q=""end;q=tostring(q)self._len=self._len+#q;self._data=self._data..q;while#self._data>=128 do s={}for D=1,128,8 do local E=#s+1;s[E]=b(a.byte(self._data,D))<<56;s[E]=s[E]|(b(a.byte(self._data,D+1))<<48)s[E]=s[E]|(b(a.byte(self._data,D+2))<<40)s[E]=s[E]|(b(a.byte(self._data,D+3))<<32)s[E]=s[E]|(b(a.byte(self._data,D+4))<<24)s[E]=s[E]|(b(a.byte(self._data,D+5))<<16)s[E]=s[E]|(b(a.byte(self._data,D+6))<<8)s[E]=s[E]|b(a.byte(self._data,D+7))end;self._data=self._data:sub(129,#self._data)for D=17,80 do s[D]=p(s[D-2])+s[D-7]+o(s[D-15])+s[D-16]end;v=self._H0;w=self._H1;x=self._H2;y=self._H3;z=self._H4;A=self._H5;B=self._H6;C=self._H7;for D=1,80 do t=C+n(z)+i(z,A,B)+e[D]+s[D]u=m(v)+l(v,w,x)C=B;B=A;A=z;z=y+t;y=x;x=w;w=v;v=t+u end;self._H0=self._H0+v;self._H1=self._H1+w;self._H2=self._H2+x;self._H3=self._H3+y;self._H4=self._H4+z;self._H5=self._H5+A;self._H6=self._H6+B;self._H7=self._H7+C end end;function c:digest()local F;local q;local G=0;local H=0;F=self:copy()H=F._len%128;if H<112 then H=112-H else H=240-H end;G=F._len*8;q=a.char(1<<7)..a.rep(a.char(0),H-1)..a.char(G>>120&0xFF)..a.char(G>>112&0xFF)..a.char(G>>104&0xFF)..a.char(G>>96&0xFF)..a.char(G>>88&0xFF)..a.char(G>>80&0xFF)..a.char(G>>72&0xFF)..a.char(G>>64&0xFF)..a.char(G>>56&0xFF)..a.char(G>>48&0xFF)..a.char(G>>40&0xFF)..a.char(G>>32&0xFF)..a.char(G>>24&0xFF)..a.char(G>>16&0xFF)..a.char(G>>8&0xFF)..a.char(G&0xFF)F:update(q)return F._H0:asbytestring()..F._H1:asbytestring()..F._H2:asbytestring()..F._H3:asbytestring()..F._H4:asbytestring()..F._H5:asbytestring()..F._H6:asbytestring()..F._H7:asbytestring()end;function c:hexdigest()local C;local I={}C=self:digest()for D=1,#C do I[D]=a.format("%02X",a.byte(C,D))end;return table.concat(I)end;return c

6
extern/lualibs/hashings/whirlpool.lua vendored Normal file

File diff suppressed because one or more lines are too long

25
extern/lualibs/inspect.lua vendored Normal file
View File

@ -0,0 +1,25 @@
-- inspect 3.1.2 | /inspect.lua | https://github.com/kikito/inspect.lua | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
local a={_VERSION='inspect.lua 3.1.0',_URL='http://github.com/kikito/inspect.lua',_DESCRIPTION='human-readable representations of tables',_LICENSE=[[
MIT LICENSE
Copyright (c) 2013 Enrique García Cota
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]}local tostring=tostring;a.KEY=setmetatable({},{__tostring=function()return'inspect.KEY'end})a.METATABLE=setmetatable({},{__tostring=function()return'inspect.METATABLE'end})local function b(c)return next,c,nil end;local function d(e)if e:match('"')and not e:match("'")then return"'"..e.."'"end;return'"'..e:gsub('"','\\"')..'"'end;local f={["\a"]="\\a",["\b"]="\\b",["\f"]="\\f",["\n"]="\\n",["\r"]="\\r",["\t"]="\\t",["\v"]="\\v",["\127"]="\\127"}local g={["\127"]="\127"}for h=0,31 do local i=string.char(h)if not f[i]then f[i]="\\"..h;g[i]=string.format("\\%03d",h)end end;local function j(e)return e:gsub("\\","\\\\"):gsub("(%c)%f[0-9]",g):gsub("%c",f)end;local function k(e)return type(e)=='string'and e:match("^[_%a][_%a%d]*$")end;local function l(m,n)return type(m)=='number'and 1<=m and m<=n and math.floor(m)==m end;local o={['number']=1,['boolean']=2,['string']=3,['table']=4,['function']=5,['userdata']=6,['thread']=7}local function p(q,r)local s,t=type(q),type(r)if s==t and(s=='string'or s=='number')then return q<r end;local u,v=o[s],o[t]if u and v then return o[s]<o[t]elseif u then return true elseif v then return false end;return s<t end;local function w(c)local x=1;local y=rawget(c,x)while y~=nil do x=x+1;y=rawget(c,x)end;return x-1 end;local function z(c)local A,B={},0;local n=w(c)for m,C in b(c)do if not l(m,n)then B=B+1;A[B]=m end end;table.sort(A,p)return A,B,n end;local function D(c,E)E=E or{}if type(c)=='table'then if not E[c]then E[c]=1;for m,y in b(c)do D(m,E)D(y,E)end;D(getmetatable(c),E)else E[c]=E[c]+1 end end;return E end;local F=function(G)local H,x={},#G;for h=1,x do H[h]=G[h]end;return H,x end;local function I(J,...)local A={...}local K,x=F(J)for h=1,#A do K[x+h]=A[h]end;return K end;local function L(M,N,J,O)if N==nil then return nil end;if O[N]then return O[N]end;local P=M(N,J)if type(P)=='table'then local Q={}O[N]=Q;local R;for m,y in b(P)do R=L(M,m,I(J,m,a.KEY),O)if R~=nil then Q[R]=L(M,y,I(J,R),O)end end;local S=L(M,getmetatable(P),I(J,a.METATABLE),O)if type(S)~='table'then S=nil end;setmetatable(Q,S)P=Q end;return P end;local T={}local U={__index=T}function T:puts(...)local V={...}local W=self.buffer;local x=#W;for h=1,#V do x=x+1;W[x]=V[h]end end;function T:down(X)self.level=self.level+1;X()self.level=self.level-1 end;function T:tabify()self:puts(self.newline,string.rep(self.indent,self.level))end;function T:alreadyVisited(y)return self.ids[y]~=nil end;function T:getId(y)local Y=self.ids[y]if not Y then local Z=type(y)Y=(self.maxIds[Z]or 0)+1;self.maxIds[Z]=Y;self.ids[y]=Y end;return tostring(Y)end;function T:putKey(m)if k(m)then return self:puts(m)end;self:puts("[")self:putValue(m)self:puts("]")end;function T:putTable(c)if c==a.KEY or c==a.METATABLE then self:puts(tostring(c))elseif self:alreadyVisited(c)then self:puts('<table ',self:getId(c),'>')elseif self.level>=self.depth then self:puts('{...}')else if self.tableAppearances[c]>1 then self:puts('<',self:getId(c),'>')end;local _,a0,n=z(c)local S=getmetatable(c)self:puts('{')self:down(function()local a1=0;for h=1,n do if a1>0 then self:puts(',')end;self:puts(' ')self:putValue(c[h])a1=a1+1 end;for h=1,a0 do local m=_[h]if a1>0 then self:puts(',')end;self:tabify()self:putKey(m)self:puts(' = ')self:putValue(c[m])a1=a1+1 end;if type(S)=='table'then if a1>0 then self:puts(',')end;self:tabify()self:puts('<metatable> = ')self:putValue(S)end end)if a0>0 or type(S)=='table'then self:tabify()elseif n>0 then self:puts(' ')end;self:puts('}')end end;function T:putValue(y)local Z=type(y)if Z=='string'then self:puts(d(j(y)))elseif Z=='number'or Z=='boolean'or Z=='nil'or Z=='cdata'or Z=='ctype'then self:puts(tostring(y))elseif Z=='table'then self:putTable(y)else self:puts('<',Z,' ',self:getId(y),'>')end end;function a.inspect(a2,a3)a3=a3 or{}local a4=a3.depth or math.huge;local a5=a3.newline or'\n'local a6=a3.indent or' 'local M=a3.process;if M then a2=L(M,a2,{},{})end;local a7=setmetatable({depth=a4,level=0,buffer={},ids={},maxIds={},newline=a5,indent=a6,tableAppearances=D(a2)},U)a7:putValue(a2)return table.concat(a7.buffer)end;setmetatable(a,{__call=function(C,...)return a.inspect(...)end})return a

6
extern/lualibs/json.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- json.lua @dbf4b2dd2eb7c23be2773c89eb059dadd6436f94 | /json.lua | https://github.com/rxi/json.lua | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2020 rxi
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a={_version="0.1.2"}local b;local c={["\\"]="\\",["\""]="\"",["\b"]="b",["\f"]="f",["\n"]="n",["\r"]="r",["\t"]="t"}local d={["/"]="/"}for e,f in pairs(c)do d[f]=e end;local function g(h)return"\\"..(c[h]or string.format("u%04x",h:byte()))end;local function i(j)return"null"end;local function k(j,l)local m={}l=l or{}if l[j]then error("circular reference")end;l[j]=true;if rawget(j,1)~=nil or next(j)==nil then local n=0;for e in pairs(j)do if type(e)~="number"then error("invalid table: mixed or invalid key types")end;n=n+1 end;if n~=#j then error("invalid table: sparse array")end;for o,f in ipairs(j)do table.insert(m,b(f,l))end;l[j]=nil;return"["..table.concat(m,",").."]"else for e,f in pairs(j)do if type(e)~="string"then error("invalid table: mixed or invalid key types")end;table.insert(m,b(e,l)..":"..b(f,l))end;l[j]=nil;return"{"..table.concat(m,",").."}"end end;local function p(j)return'"'..j:gsub('[%z\1-\31\\"]',g)..'"'end;local function q(j)if j~=j or j<=-math.huge or j>=math.huge then error("unexpected number value '"..tostring(j).."'")end;return string.format("%.14g",j)end;local r={["nil"]=i,["table"]=k,["string"]=p,["number"]=q,["boolean"]=tostring}b=function(j,l)local s=type(j)local t=r[s]if t then return t(j,l)end;error("unexpected type '"..s.."'")end;function a.encode(j)return b(j)end;local u;local function v(...)local m={}for o=1,select("#",...)do m[select(o,...)]=true end;return m end;local w=v(" ","\t","\r","\n")local x=v(" ","\t","\r","\n","]","}",",")local y=v("\\","/",'"',"b","f","n","r","t","u")local z=v("true","false","null")local A={["true"]=true,["false"]=false,["null"]=nil}local function B(C,D,E,F)for o=D,#C do if E[C:sub(o,o)]~=F then return o end end;return#C+1 end;local function G(C,D,H)local I=1;local J=1;for o=1,D-1 do J=J+1;if C:sub(o,o)=="\n"then I=I+1;J=1 end end;error(string.format("%s at line %d col %d",H,I,J))end;local function K(n)local t=math.floor;if n<=0x7f then return string.char(n)elseif n<=0x7ff then return string.char(t(n/64)+192,n%64+128)elseif n<=0xffff then return string.char(t(n/4096)+224,t(n%4096/64)+128,n%64+128)elseif n<=0x10ffff then return string.char(t(n/262144)+240,t(n%262144/4096)+128,t(n%4096/64)+128,n%64+128)end;error(string.format("invalid unicode codepoint '%x'",n))end;local function L(M)local N=tonumber(M:sub(1,4),16)local O=tonumber(M:sub(7,10),16)if O then return K((N-0xd800)*0x400+O-0xdc00+0x10000)else return K(N)end end;local function P(C,o)local m=""local Q=o+1;local e=Q;while Q<=#C do local R=C:byte(Q)if R<32 then G(C,Q,"control character in string")elseif R==92 then m=m..C:sub(e,Q-1)Q=Q+1;local h=C:sub(Q,Q)if h=="u"then local S=C:match("^[dD][89aAbB]%x%x\\u%x%x%x%x",Q+1)or C:match("^%x%x%x%x",Q+1)or G(C,Q-1,"invalid unicode escape in string")m=m..L(S)Q=Q+#S else if not y[h]then G(C,Q-1,"invalid escape char '"..h.."' in string")end;m=m..d[h]end;e=Q+1 elseif R==34 then m=m..C:sub(e,Q-1)return m,Q+1 end;Q=Q+1 end;G(C,o,"expected closing quote for string")end;local function T(C,o)local R=B(C,o,x)local M=C:sub(o,R-1)local n=tonumber(M)if not n then G(C,o,"invalid number '"..M.."'")end;return n,R end;local function U(C,o)local R=B(C,o,x)local V=C:sub(o,R-1)if not z[V]then G(C,o,"invalid literal '"..V.."'")end;return A[V],R end;local function W(C,o)local m={}local n=1;o=o+1;while 1 do local R;o=B(C,o,w,true)if C:sub(o,o)=="]"then o=o+1;break end;R,o=u(C,o)m[n]=R;n=n+1;o=B(C,o,w,true)local X=C:sub(o,o)o=o+1;if X=="]"then break end;if X~=","then G(C,o,"expected ']' or ','")end end;return m,o end;local function Y(C,o)local m={}o=o+1;while 1 do local Z,j;o=B(C,o,w,true)if C:sub(o,o)=="}"then o=o+1;break end;if C:sub(o,o)~='"'then G(C,o,"expected string for key")end;Z,o=u(C,o)o=B(C,o,w,true)if C:sub(o,o)~=":"then G(C,o,"expected ':' after key")end;o=B(C,o+1,w,true)j,o=u(C,o)m[Z]=j;o=B(C,o,w,true)local X=C:sub(o,o)o=o+1;if X=="}"then break end;if X~=","then G(C,o,"expected '}' or ','")end end;return m,o end;local _={['"']=P,["0"]=T,["1"]=T,["2"]=T,["3"]=T,["4"]=T,["5"]=T,["6"]=T,["7"]=T,["8"]=T,["9"]=T,["-"]=T,["t"]=U,["f"]=U,["n"]=U,["["]=W,["{"]=Y}u=function(C,D)local X=C:sub(D,D)local t=_[X]if t then return t(C,D)end;G(C,D,"unexpected character '"..X.."'")end;function a.decode(C)if type(C)~="string"then error("expected argument of type string, got "..type(C))end;local m,D=u(C,B(C,1,w,true))D=B(C,D,w,true)if D<=#C then G(C,D,"trailing garbage")end;return m end;return a

6
extern/lualibs/moses.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/mt19937ar.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- mt19937ar-lua @9e110f2d1c8a981c1d4ffccb93e25aef9e8b5f17 | /mt19937ar.lua | https://github.com/davebollinger/mt19937ar-lua | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 David Bollinger (davebollinger at gmail dot com)
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=math.floor;local function b(c,d)local e=a(c%65536)local f=a(c/65536)%65536;local g=a(d%65536)local h=a(d/65536)%65536;local i=e*g;local j=e*h;local k=f*g;local l=j+k;return a((l*65536+i)%4294967296)end;local function m(c,d)local n,o=0,1;for p=0,31 do local q=c%2;local r=d%2;if q>0 and r>0 then n=n+o end;if q>0 then c=c-1 end;if r>0 then d=d-1 end;c=c/2;d=d/2;o=o*2 end;return n end;local function s(c,d)local n,o=0,1;for p=0,31 do local q=c%2;local r=d%2;if q>0 or r>0 then n=n+o end;if q>0 then c=c-1 end;if r>0 then d=d-1 end;c=c/2;d=d/2;o=o*2 end;return n end;local function t(c,d)local n,o=0,1;for p=0,31 do local q=c%2;local r=d%2;if q~=r then n=n+o end;if q>0 then c=c-1 end;if r>0 then d=d-1 end;c=c/2;d=d/2;o=o*2 end;return n end;local u=function(v)return a(v/2)end;local w=function(v)return a(v/1073741824)end;local x=function(v)return a(v/2048)end;local y=function(v)return v*128 end;local z=function(v)return v*32768 end;local A=function(v)return a(v/262144)end;local B=function(v)return v%2 end;local C=624;local D=397;local E=0x9908B0DF;local F=0x80000000;local G=0x7FFFFFFF;local H={}function H.new()local I={}local J={}local K=C+1;function I:init_genrand(L)J[0]=m(L,0xFFFFFFFF)for p=1,C-1 do J[p]=b(1812433253,t(J[p-1],w(J[p-1])))+p;J[p]=m(J[p],0xFFFFFFFF)end;K=C end;function I:init_by_array(M,N)self:init_genrand(19650218)if not N then N=#M end;local p,O,P=1,0,C>N and C or N;while P>0 do J[p]=t(J[p],b(t(J[p-1],w(J[p-1])),1664525))+M[O+1]+O;J[p]=m(J[p],0xFFFFFFFF)p,O=p+1,O+1;if p>=C then J[0]=J[C-1]p=1 end;if O>=N then O=0 end;P=P-1 end;for P=C-1,1,-1 do J[p]=t(J[p],b(t(J[p-1],w(J[p-1])),1566083941))-p;J[p]=m(J[p],0xFFFFFFFF)p=p+1;if p>=C then J[0]=J[C-1]p=1 end end;J[0]=0x80000000 end;function I:genrand_int32()local v;if K>=C then if K==C+1 then self:init_genrand(5489)end;for Q=0,C-D-1 do v=s(m(J[Q],F),m(J[Q+1],G))J[Q]=t(J[Q+D],t(u(v),B(v)*E))Q=Q+1 end;for Q=C-D,C-2 do v=s(m(J[Q],F),m(J[Q+1],G))J[Q]=t(J[Q+D-C],t(u(v),B(v)*E))Q=Q+1 end;v=s(m(J[C-1],F),m(J[0],G))J[C-1]=t(J[D-1],t(u(v),B(v)*E))K=0 end;v=J[K]K=K+1;v=t(v,x(v))v=t(v,m(y(v),0x9D2C5680))v=t(v,m(z(v),0xEFC60000))v=t(v,A(v))return v end;function I:genrand_int31()return a(self:genrand_int32()/2)end;function I:genrand_real1()return self:genrand_int32()*1.0/4294967295.0 end;function I:genrand_real2()return self:genrand_int32()*1.0/4294967296.0 end;function I:genrand_real3()return(self:genrand_int32()+0.5)*1.0/4294967296.0 end;function I:genrand_res53()local c=a(self:genrand_int32()/32)local d=a(self:genrand_int32()/64)return(c*67108864.0+d)*1.0/9007199254740992.0 end;I.randomseed=I.init_genrand;function I:random(R,S)if not R then return self:genrand_real2()else if not S then return self:genrand_int32()%R+1 else return R+self:genrand_int32()%(S-R+1)end end end;function I:getState()local n={}n.mti=K;n.mt={}for p=0,C-1 do n.mt[p]=J[p]end;return n end;function I:setState(L)if L==nil then return end;if type(L.mti)=="number"then K=a(L.mti)end;if type(L.mt)=="table"then for p=0,C-1 do if type(L.mt[p])=="number"then J[p]=a(L.mt[p])end end end end;function I:createValidationOutput()local T="mt19937ar.lua.out"local U=io.open(T,"wb")self:init_by_array({291,564,837,1110})U:write("1000 outputs of genrand_int32()\n")for p=0,999 do U:write(string.format("%10.0f ",self:genrand_int32()))if p%5==4 then U:write("\n")end end;U:write("\n1000 outputs of genrand_real2()\n")for p=0,999 do U:write(string.format("%10.8f ",self:genrand_real2()))if p%5==4 then U:write("\n")end end;U:close()end;return I end;return H

6
extern/lualibs/nums/bn.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/nums/init.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-nums @fef161a940aaafdbb8d9c75fe073b8bb43152474 | /nums/init.lua | https://github.com/user-none/lua-nums | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a={}a.bn=require("nums.bn")a.uintb=require("nums.uintb")a.uintn=require("nums.uintn")return a

6
extern/lualibs/nums/uintb.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-nums @fef161a940aaafdbb8d9c75fe073b8bb43152474 | /nums/uintb.lua | https://github.com/user-none/lua-nums | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("nums.bn")local b={}local c={}local function d(e,f)local g=false;if not b.isuint(e)then e,f=f,e;g=true end;return e:copy(),a(f),g end;local function h(i)if i._bn==i._max then i._bn:set(0)elseif i._bn<0 or i._bn>i._max then i._bn=i._bn%i._max end end;c.__index=b;c.__add=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f+e._bn else e._bn=e._bn+f end;h(e)return e end;c.__sub=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f-e._bn else e._bn=e._bn-f end;h(e)return e end;c.__mul=function(e,f)e,f=d(e,f)e._bn=e._bn*f;h(e)return e end;c.__div=function(e,f)return e//f end;c.__mod=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f%e._bn else e._bn=e._bn%f end;h(e)return e end;c.__pow=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f^e._bn else e._bn=e._bn^f end;h(e)return e end;c.__unm=function(e)e=e:copy()e._bn=-e._bn;h(e)return e end;c.__idiv=function(e,f)local j;e,f,j=d(e,f)if j and f==0 then e._val=0;return e end;if j then e._bn=f//e._bn else e._bn=e._bn//f end;h(e)return e end;c.__band=function(e,f)e,f=d(e,f)e._bn=e._bn&f;h(e)return e end;c.__bor=function(e,f)e,f=d(e,f)e._bn=e._bn|f;h(e)return e end;c.__bxor=function(e,f)e,f=d(e,f)e._bn=e._bn~f;h(e)return e end;c.__bnot=function(e)e=e:copy()e._bn=~e._bn;h(e)return e end;c.__shl=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f<<e._bn else e._bn=e._bn<<f end;h(e)return e end;c.__shr=function(e,f)local j;e,f,j=d(e,f)if j then e._bn=f>>e._bn else e._bn=e._bn>>f end;h(e)return e end;c.__concat=function(e,f)if b.isuint(e)and b.isuint(f)then return e._bn..f._bn elseif b.isuint(e)and not b.isuint(f)then return e._bn..f end;return e..f._bn end;c.__len=function(e)return e._bits end;c.__eq=function(e,f)e,f=d(e,f)return e._bn==f end;c.__lt=function(e,f)local j;e,f,j=d(e,f)if j then return e._bn>f end;return e._bn<f end;c.__le=function(e,f)if e<f or e==f then return true end;return false end;c.__tostring=function(e)return tostring(e._bn)end;function b:new(k,l)local i=setmetatable({},c)if self~=b then return nil,"first argument must be self"end;if k==nil then return nil,"bits required"end;if b.isuint(k)then i._bits=k._bits;i._max=k._max;if l~=nil then i._bn=a(l)else i._bn=a(k._bn)end else i._bits=k;i._max=a(1)<<i._bits;if l~=nil then i._bn=a(l)else i._bn=a()end end;h(i)return i end;function b.isuint(m)if type(m)=="table"and getmetatable(m)==c then return true end;return false end;function b.u8(l)return b:new(8,l)end;function b.u16(l)return b:new(16,l)end;function b.u32(l)return b:new(32,l)end;function b.u64(l)return b:new(64,l)end;function b.u128(l)return b:new(128,l)end;function b.u256(l)return b:new(256,l)end;function b.u512(l)return b:new(512,l)end;function b:copy()return b:new(self._bits,self._bn)end;function b:set(l)if b.isuint(l)then self._bn=l._val else self._bn:set(l)end;h(self)end;function b:swape()local n;local l=a()local m;n=self:asbytearray()for o=1,#n//2 do m=n[o]n[o]=n[#n-o+1]n[#n-o+1]=m end;m={}for o=#n,1,-1 do m[#m+1]=n[o]end;for o=1,#m do l=l|(a(m[o])<<o*8-8)end;return b:new(self._bits,l)end;function b:asnumber()return self._bn:asnumber()end;function b:asbn()return self._bn:copy()end;function b:ashex(p)return self._bn:ashex(p)end;function b:asbytearray()local q;q=self._bn:asbytearray()for o=1,self._bits//8-#q do table.insert(q,1,0)end;return q end;function b:asbytestring()local f;f=self:asbytearray()for o=1,#f do f[o]=string.char(f[o])end;return table.concat(f)end;return b

6
extern/lualibs/nums/uintn.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Lua-nums @fef161a940aaafdbb8d9c75fe073b8bb43152474 | /nums/uintn.lua | https://github.com/user-none/lua-nums | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a={}local b={}local function c(d,e)local f=false;if not a.isuint(d)then d,e=e,d;f=true end;if a.isuint(e)then e=e._val else e=tonumber(e)end;return d:copy(),e,f end;local function g(h)if h._val==h._max then h._val=0 elseif h._val<0 or h._val>h._max then h._val=h._val%h._max end end;b.__index=a;b.__add=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e+d._val else d._val=d._val+e end;g(d)return d end;b.__sub=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e-d._val else d._val=d._val-e end;g(d)return d end;b.__mul=function(d,e)d,e=c(d,e)d._val=d._val*e;g(d)return d end;b.__div=function(d,e)return d//e end;b.__mod=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e%d._val else d._val=d._val%e end;g(d)return d end;b.__pow=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e^d._val else d._val=d._val^e end;g(d)return d end;b.__unm=function(d)d=d:copy()d._val=-d._val;g(d)return d end;b.__idiv=function(d,e)local i;d,e,i=c(d,e)if i and e==0 then d._val=0;return d end;if i then d._val=e//d._val else d._val=d._val//e end;g(d)return d end;b.__band=function(d,e)d,e=c(d,e)d._val=d._val&e;g(d)return d end;b.__bor=function(d,e)d,e=c(d,e)d._val=d._val|e;g(d)return d end;b.__bxor=function(d,e)d,e=c(d,e)d._val=d._val~e;g(d)return d end;b.__bnot=function(d)d=d:copy()d._val=~d._val;g(d)return d end;b.__shl=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e<<d._val else d._val=d._val<<e end;g(d)return d end;b.__shr=function(d,e)local i;d,e,i=c(d,e)if i then d._val=e>>d._val else d._val=d._val>>e end;g(d)return d end;b.__concat=function(d,e)if a.isuint(d)and a.isuint(e)then return d._val..e._val elseif a.isuint(d)and not a.isuint(e)then return d._val..e end;return d..e._val end;b.__len=function(d)return d._bits end;b.__eq=function(d,e)d,e=c(d,e)return d._val==e end;b.__lt=function(d,e)local i;d,e,i=c(d,e)if i then return d._val>e end;return d._val<e end;b.__le=function(d,e)if d<e or d==e then return true end;return false end;b.__tostring=function(d)return tostring(d._val)end;local function j(k,l)local h=setmetatable({},b)h._bits=k;h._max=1<<h._bits;if l==nil then l=0 end;if a.isuint(l)then h._val=l._val else h._val=tonumber(l)end;g(h)return h end;function a.isuint(m)if type(m)=="table"and getmetatable(m)==b then return true end;return false end;function a.u8(n)return j(8,n)end;function a.u16(n)return j(16,n)end;function a.u32(n)return j(32,n)end;function a:copy()return j(self._bits,self._val)end;function a:set(l)if a.isuint(l)then self._val=l._val else self._val=tonumber(l)end;g(self)end;function a:swape()local n;local l=0;local m;n=self:asbytearray()for o=1,#n//2 do m=n[o]n[o]=n[#n-o+1]n[#n-o+1]=m end;m={}for o=#n,1,-1 do m[#m+1]=n[o]end;for o=1,#m do l=l|(m[o]<<o*8-8)end;return j(self._bits,l)end;function a:asnumber()return self._val end;function a:ashex(p)local q="%"if p~=nil then q=q.."0"..tostring(p)end;q=q.."X"return q:format(self._val)end;function a:asbytearray()local m={}for o=self._bits-8,0,-8 do m[#m+1]=self._val>>o&0xFF end;return m end;function a:asbytestring()local e;e=self:asbytearray()for o=1,#e do e[o]=string.char(e[o])end;return table.concat(e)end;return a

6
extern/lualibs/pl/Date.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/pl/List.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/List.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a,b,c,d=table.insert,table.remove,table.concat,table.sort;local setmetatable,getmetatable,type,tostring,string=setmetatable,getmetatable,type,tostring,string;local e=require'pl.tablex'local f,g,h,i,j,k=e.filter,e.imap,e.imap2,e.reduce,e.transform,e.removevalues;local l=e.sub;local m=require'pl.utils'local n=require'pl.class'local o,p,q,r=m.array_tostring,m.split,m.assert_arg,m.function_arg;local s=e._normalize_slice;local t=m.stdmt.MultiMap;local u=m.stdmt.List;local v;n(nil,nil,u)local function w(x,y)local z=u;if y then z=getmetatable(y)end;return setmetatable(x,z)end;local function A(x)return type(x)=='table'and not getmetatable(x)and#x>0 end;function u._create(B)if A(B)then return B end end;function u:_init(B)if self==B then return end;if B then for C in v(B)do a(self,C)end end end;u.new=u;function u:clone()local D=w({},self)D:extend(self)return D end;function u:append(E)a(self,E)return self end;u.push=a;function u:extend(F)q(1,F,'table')for E=1,#F do a(self,F[E])end;return self end;function u:insert(E,G)q(1,E,'number')a(self,E,G)return self end;function u:put(G)return self:insert(1,G)end;function u:remove(E)q(1,E,'number')b(self,E)return self end;function u:remove_value(G)for E=1,#self do if self[E]==G then b(self,E)return self end end;return self end;function u:pop(E)if not E then E=#self end;q(1,E,'number')return b(self,E)end;u.get=u.pop;local H=e.find;u.index=H;function u:contains(G)return H(self,G)and true or false end;function u:count(G)local I=0;for E=1,#self do if self[E]==G then I=I+1 end end;return I end;function u:sort(J)if J then J=r(1,J)end;d(self,J)return self end;function u:sorted(J)return u(self):sort(J)end;function u:reverse()local x=self;local K=#x;for E=1,K/2 do x[E],x[K]=x[K],x[E]K=K-1 end;return self end;function u:minmax()local L,M=1e70,-1e70;for E=1,#self do local C=self[E]if C<L then L=C end;if C>M then M=C end end;return L,M end;function u:slice(N,O)return l(self,N,O)end;function u:clear()for E=1,#self do b(self)end;return self end;local P=1.0e-10;function u.range(Q,R,S)if not R then R=Q;Q=1 end;if S then q(3,S,'number')if math.ceil(S)~=S then R=R+P end else S=1 end;q(1,Q,'number')q(2,R,'number')local x=u()for E=Q,R,S do a(x,E)end;return x end;function u:len()return#self end;function u:chop(T,U)return k(self,T,U)end;function u:splice(V,W)q(1,V,'number')V=V-1;local E=1;for C in v(W)do a(self,E+V,C)E=E+1 end;return self end;function u:slice_assign(T,U,X)q(1,T,'number')q(1,U,'number')T,U=s(self,T,U)if U>=T then self:chop(T,U)end;self:splice(T,X)return self end;function u:__concat(F)q(1,F,'table')local D=self:clone()D:extend(F)return D end;function u:__eq(F)if#self~=#F then return false end;for E=1,#self do if self[E]~=F[E]then return false end end;return true end;function u:join(Y)Y=Y or''q(1,Y,'string')return c(o(self),Y)end;u.concat=c;local function Z(_)local a0=tostring(_)if type(_)=='string'then a0='"'..a0 ..'"'end;return a0 end;function u:__tostring()return'{'..self:join(',',Z)..'}'end;function u:foreach(a1,...)a1=r(1,a1)for E=1,#self do a1(self[E],...)end end;local function a2(y,a3)local a4=y[a3]if not a4 then error(type(y).." does not have method "..a3,3)end;return a4 end;function u:foreachm(a3,...)for E=1,#self do local y=self[E]local a4=a2(y,a3)a4(y,...)end end;function u:filter(a1,a5)return w(f(self,a1,a5),self)end;function u.split(a0,Y)q(1,a0,'string')return w(p(a0,Y))end;function u:map(a1,...)return w(g(a1,self,...),self)end;function u:transform(a1,...)j(a1,self,...)return self end;function u:map2(a1,D,...)return w(h(a1,self,D,...),self)end;function u:mapm(a3,...)local a6={}for E=1,#self do local _=self[E]local a7=a2(_,a3)a6[E]=a7(_,...)end;return w(a6,self)end;local function a8(a9,a4)return function(self,...)return self[a9](self,a4,...)end end;function u.default_map_with(aa)return function(self,a3)local ab;if aa then local a4=a2(aa,a3)ab=a8('map',a4)else ab=a8('mapn',a3)end;getmetatable(self)[a3]=ab;return ab end end;u.default_map=u.default_map_with;function u:reduce(a1)return i(a1,self)end;function u:partition(a1,...)a1=r(1,a1)local a6={}for E=1,#self do local _=self[E]local z=a1(_,...)if z==nil then z='<nil>'end;if not a6[z]then a6[z]=u()end;a6[z]:append(_)end;return setmetatable(a6,t)end;function u:iter()return v(self)end;function u.iterate(X)if type(X)=='string'then local V=0;local K=#X;local ac=string.sub;return function()V=V+1;if V>K then return nil else return ac(X,V,V)end end elseif type(X)=='table'then local V=0;local K=#X;return function()V=V+1;if V>K then return nil else return X[V]end end elseif type(X)=='function'then return X elseif type(X)=='userdata'and io.type(X)=='file'then return X:lines()end end;v=u.iterate;return u

6
extern/lualibs/pl/Map.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/Map.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.tablex'local b=require'pl.utils'local c=b.stdmt;local d=a.deepcompare;local e=require'pl.pretty'.write;local f=c.Map;local g=c.Set;local h=require'pl.class'h(nil,nil,f)function f:_init(i)local j=getmetatable(i)if j==g or j==f then self:update(i)else return i end end;local function k(i)return setmetatable(i,require('pl.List'))end;f.keys=a.keys;f.values=a.values;function f:iter()return pairs(self)end;function f:items()local l=k(a.pairmap(function(m,n)return k{m,n}end,self))l:sort(function(o,p)return o[1]<p[1]end)return l end;function f:setdefault(q,r)local s=self[q]if s~=nil then return s end;self:set(q,r)return r end;f.len=a.size;function f:set(q,s)self[q]=s end;function f:get(q)return rawget(self,q)end;local t=a.index_by;function f:getvalues(u)return k(t(self,u))end;f.update=a.update;function f:__eq(v)return d(self,v,true)end;function f:__tostring()return e(self,'')end;return f

6
extern/lualibs/pl/MultiMap.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/MultiMap.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.utils'local b=require'pl.class'local c=require'pl.List'local d=require'pl.Map'local e=a.stdmt.MultiMap;b(d,nil,e)e._name='MultiMap'function e:_init(f)if not f then return end;self:update(f)end;function e:update(f)a.assert_arg(1,f,'table')if d:class_of(f)then for g,h in pairs(f)do self[g]=c()self[g]:append(h)end else for g,h in pairs(f)do self[g]=c(h)end end end;function e:set(i,j)if j==nil then self[i]=nil else if not self[i]then self[i]=c()end;self[i]:append(j)end end;return e

6
extern/lualibs/pl/OrderedMap.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/OrderedMap.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.tablex'local b=require'pl.utils'local c=require'pl.List'local d,e,f=a.index_by,table.sort,table.concat;local g=require'pl.class'local h=require'pl.Map'local i=g(h)i._name='OrderedMap'local rawset=rawset;function i:_init(j)rawset(self,'_keys',c())if j then local k,l=self:update(j)if not k then error(l,2)end end end;local m,n=b.assert_arg,b.raise;function i:update(j)m(1,j,'table')if i:class_of(j)then for o,p in j:iter()do self:set(o,p)end elseif#j>0 then if type(j[1])=='table'then for q,r in ipairs(j)do local s,t=next(r)if not s then return n'empty pair initialization table'end;self:set(s,t)end else return n'cannot use an array to initialize an OrderedMap'end else for o,p in pairs(j)do self:set(o,p)end end;return self end;function i:set(s,u)if rawget(self,s)==nil and u~=nil then self._keys:append(s)rawset(self,s,u)else if u==nil then self._keys:remove_value(s)rawset(self,s,nil)else self[s]=u end end;return self end;i.__newindex=i.set;function i:insert(v,s,u)local w=self[s]u=u or w;if w then self._keys:remove_value(s)end;if u then self._keys:insert(v,s)rawset(self,s,u)end;return self end;function i:keys()return self._keys end;function i:values()return c(d(self,self._keys))end;function i:sort(x)e(self._keys,x)return self end;function i:iter()local y=0;local z=self._keys;local A;return function()y=y+1;if y>#z then return nil end;A=z[y]return A,self[A]end end;i.__pairs=i.iter;function i:__tostring()local B={}for y,p in ipairs(self._keys)do local u=self[p]local C=tostring(u)if type(u)~='number'then C='"'..C..'"'end;B[y]=tostring(p)..'='..C end;return'{'..f(B,',')..'}'end;return i

6
extern/lualibs/pl/Set.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/Set.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.tablex'local b=require'pl.utils'local c,d=b.array_tostring,table.concat;local e,f=a.merge,a.difference;local g=require'pl.Map'local h=require'pl.class'local i=b.stdmt;local j=i.Set;h(g,nil,j)j.__index=nil;local function k(l)return setmetatable(l,j)end;function j:_init(l)l=l or{}local m=getmetatable(l)if m==j or m==g then for n in pairs(l)do self[n]=true end else for o,p in ipairs(l)do self[p]=true end end end;function j:__tostring()return'['..d(c(j.values(self)),',')..']'end;j.values=g.keys;function j.map(self,q,...)q=b.function_arg(1,q)local r={}for n in pairs(self)do r[q(n,...)]=true end;return k(r)end;function j.union(self,s)return e(self,s,true)end;local function t(self,u)local m=getmetatable(u)if m==j or m==g then return j.union(self,u)else local v=j(self)v[u]=true;return v end end;j.__add=t;function j.intersection(self,s)return e(self,s,false)end;j.__mul=j.intersection;function j.difference(self,s)return f(self,s,false)end;local function w(self,u)local m=getmetatable(u)if m==j or m==g then return j.difference(self,u)else local v=j(self)v[u]=nil;return v end end;j.__sub=w;function j.symmetric_difference(self,s)return f(self,s,true)end;j.__pow=j.symmetric_difference;function j.issubset(self,s)for n in pairs(self)do if not s[n]then return false end end;return true end;j.__lt=j.issubset;function j.isempty(self)return next(self)==nil end;function j.isdisjoint(x,y)return j.isempty(j.intersection(x,y))end;j.len=a.size;j.__len=j.len;function j.__eq(x,y)return j.issubset(x,y)and j.issubset(y,x)end;return j

6
extern/lualibs/pl/array2d.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/pl/class.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/class.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a,b,c,d,e,f,g,h,i=_G.error,_G.getmetatable,_G.io,_G.pairs,_G.rawget,_G.rawset,_G.setmetatable,_G.tostring,_G.type;local j;local function k(l,m,...)local n=e(l,'_init')local o=e(l,'_parent_with_init')if o then if not n then n=e(o,'_init')o=e(o,'_parent_with_init')end;if o then f(m,'super',function(m,...)k(o,m,...)end)end else f(m,'super',nil)end;local p=n(m,...)if o then f(m,'super',nil)end;return p end;local function q(self,r)if r==nil then return b(self)end;local s=b(self)if not s then return false end;while s do if s==r then return true end;s=e(s,'_base')end;return false end;local function t(r,m)if i(r)~='table'or not e(r,'is_a')then return false end;return r.is_a(m,r)end;local function u(r,m)return g(m,r)end;local function v(m)local w=m._class;local x=e(w,'_name')g(m,nil)local y=h(m)g(m,w)if x then y=x..y:gsub('table','')end;return y end;local function z(A,B,C)for D,E in d(B)do if not C or A[D]==nil then A[D]=E end end end;local function F(G,H,l)local w={}local I=i(G)=='table'and not b(G)if I then l=G;G=l._base else l=l or{}end;if i(G)=='table'then z(l,G,I)l._base=G;if e(l,'_handler')then w.__index=l._handler end elseif G~=nil then a("must derive from a table type",3)end;l.__index=l;g(l,w)if not I then if G and e(G,'_init')then l._parent_with_init=G end;l._init=nil end;if G and e(G,'_class_init')then G._class_init(l,H)end;w.__call=function(J,...)local m;if e(l,'_create')then m=l._create(...)end;if not m then m={}end;g(m,l)if e(l,'_init')or e(l,'_parent_with_init')then local p=k(l,m,...)if p then m=p;g(m,l)end end;if G and e(G,'_post_init')then G._post_init(m)end;return m end;l.catch=function(self,K)if i(self)=="function"then K=self end;l._handler=K;w.__index=K end;l.is_a=q;l.class_of=t;l.cast=u;l._class=l;if not e(l,'__tostring')then l.__tostring=v end;return l end;local L;L=g({},{__call=function(M,...)return F(...)end,__index=function(N,O)if O=='class'then c.stderr:write('require("pl.class").class is deprecated. Use require("pl.class")\n')return L end;j=j or require'pl.compat'local P=j.getfenv(2)return function(...)local l=F(...)l._name=O;f(P,O,l)return l end end})L.properties=L()function L.properties._class_init(r)r.__index=function(Q,O)local E=r[O]if E then return E end;E=e(r,'get_'..O)if E then return E(Q)end;return e(Q,'_'..O)end;r.__newindex=function(Q,O,R)local S='set_'..O;local T=r[S]if T then T(Q,R)else f(Q,O,R)end end end;return L

6
extern/lualibs/pl/compat.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/compat.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a={}a.lua51=_VERSION=='Lua 5.1'a.jit=tostring(assert):match('builtin')~=nil;if a.jit then a.jit52=not loadstring("local goto = 1")end;a.dir_separator=_G.package.config:sub(1,1)a.is_windows=a.dir_separator=='\\'function a.execute(b)local c,d,e=os.execute(b)if d=="No error"and e==0 and a.is_windows then e=-1 end;if a.lua51 and not a.jit52 then if a.is_windows then return c==0,c else c=c>255 and c/256 or c;return c==0,c end else if a.is_windows then return e==0,e else return not not c,e end end end;if a.lua51 then if not a.jit then local f=load;function a.load(g,h,i,j)local k,l;if type(g)=='string'then if g:byte(1)==27 and not(i or'bt'):find'b'then return nil,"attempt to load a binary chunk"end;k,l=loadstring(g,h)else k,l=f(g,h)end;if k and j then setfenv(k,j)end;return k,l end else a.load=load end;a.setfenv,a.getfenv=setfenv,getfenv else a.load=load;function a.setfenv(m,n)m=type(m)=='function'and m or debug.getinfo(m+1,'f').func;local o;local p=0;repeat p=p+1;o=debug.getupvalue(m,p)until o=='_ENV'or o==nil;if o then debug.upvaluejoin(m,p,function()return o end,1)debug.setupvalue(m,p,n)end;if m~=0 then return m end end;function a.getfenv(m)local m=m or 0;m=type(m)=='function'and m or debug.getinfo(m+1,'f').func;local o,q;local p=0;repeat p=p+1;o,q=debug.getupvalue(m,p)until o=='_ENV'or o==nil;return q end end;if not table.pack then function table.pack(...)return{n=select('#',...),...}end end;if not table.unpack then table.unpack=unpack end;if not package.searchpath then function package.searchpath(o,r,s,t)if type(o)~="string"then error(("bad argument #1 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;if type(r)~="string"then error(("bad argument #2 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;if s~=nil and type(s)~="string"then error(("bad argument #3 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;if t~=nil and type(t)~="string"then error(("bad argument #4 to 'searchpath' (string expected, got %s)"):format(type(r)),2)end;s=s or"."t=t or a.dir_separator;do local u,v=o:find(s,nil,true)while u do o=o:sub(1,u-1)..t..o:sub(v+1,-1)u,v=o:find(s,u+#t+1,true)end end;local w={}for x in r:gmatch('[^;]+')do local y=x:gsub('?',o)w[#w+1]=y;local m=io.open(y,'r')if m then m:close()return y end end;return nil,"\tno file '"..table.concat(w,"'\n\tno file '").."'"end end;if not warn then local z=false;function warn(A,...)if type(A)=="string"and A:sub(1,1)=="@"then if A=="@on"then z=true;return end;if A=="@off"then z=false;return end;return end;if z then io.stderr:write("Lua warning: ",A,...)io.stderr:write("\n")end end end;return a

6
extern/lualibs/pl/comprehension.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/comprehension.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.utils'local b,c=pcall(require,"pl.luabalanced")if not b then c=require'luabalanced'end;local d=math.max;local e=table.concat;local f={list={init=' {} ',accum=' __result[#__result+1] = (%s) '},table={init=' {} ',accum=' local __k, __v = %s __result[__k] = __v '},sum={init=' 0 ',accum=' __result = __result + (%s) '},min={init=' nil ',accum=' local __tmp = %s '..' if __result then if __tmp < __result then '..'__result = __tmp end else __result = __tmp end '},max={init=' nil ',accum=' local __tmp = %s '..' if __result then if __tmp > __result then '..'__result = __tmp end else __result = __tmp end '}}local function g(h)local i=1;local j;local k,l=h:match('^%s*([%a_][%w_]*)%s*%(()',i)local m=#h+1;if k then local n,o=c.match_bracketed(h,l-1)assert(n,'syntax error')if h:match('^%s*$',o)then j=k;m=o-1;i=l end end;j=j or"list"local p;p,i=c.match_explist(h,i)assert(p,"syntax error: missing expression list")p=e(p,', ')local q={}local r={}local s={}while 1 do local l=h:match('^%s*for%s+()',i)if not l then break end;i=l;local t;t,i=c.match_namelist(h,i)assert(#t>0,'syntax error: zero variables')for u,v in ipairs(t)do assert(not v:match'^__',"identifier "..v.." may not contain __ prefix")end;r[#r+1]=t;local w,l=h:match('^(=)%s*()',i)if not w then w,l=h:match('^(in)%s+()',i)end;if w then i=l;local x;x,i=c.match_explist(h,i)assert(#x>0,'syntax error: zero expressions')assert(w~='='or#x==2 or#x==3,'syntax error: numeric for requires 2 or three expressions')q[#r]=w;s[#r]=x else q[#r]=false;s[#r]=false end end;assert(#r>0,'syntax error: missing "for" clause')local y={}while 1 do local l=h:match('^%s*if%s+()',i)if not l then break end;i=l;local z;z,i=c.match_expression(h,i)assert(z,'syntax error: predicated expression not found')y[#y+1]=z end;local A=''c.gsub(h,function(B,C)if B=='e'then A=A..' '..C..' 'end end)local D=0;A:gsub('[%a_][%w_]*',function(E)local E=E:match('^_(%d+)$')if E then D=d(D,tonumber(E))end end)if i~=m then assert(false,"syntax error: unrecognized "..h:sub(i))end;return p,q,r,s,y,j,D end;local function F(p,q,r,s,y,j,D)local G=assert(f[j])local H=G.accum:gsub('%%s',p)for I=#y,1,-1 do local z=y[I]H=' if '..z..' then '..H..' end 'end;for I=#r,1,-1 do if not q[I]then local J='__in'..I;local K='__idx'..I;H=' for '..K..' = 1, #'..J..' do '..' local '..r[I][1]..' = '..J..'['..K..'] '..H..' end 'else H=' for '..e(r[I],', ')..' '..q[I]..' '..e(s[I],', ')..' do '..H..' end 'end end;H=' local __result = ( '..G.init..' ) '..H;return H end;local function L(H,M,D,s,N)assert(M>0)local O={}for I=1,D do O[#O+1]='_'..I end;for I=1,M do if not s[I]then local P='__in'..I;O[#O+1]=P end end;if#O>0 then H=' local '..e(O,', ')..' = ... '..H end;H=H..' return __result 'local Q,R=a.load(H,'tmp','t',N)if not Q then assert(false,R..' with generated code '..H)end;return Q end;local function S(h,N)local p,q,r,s,y,j,D=g(h)local H=F(p,q,r,s,y,j,D)local Q=L(H,#r,D,s,N)return Q end;local function T(N)if not N then N=a.getfenv(2)end;local U={}local V=setmetatable({},U)function U:__index(h)local Q=S(h,N)self[h]=Q;return Q end;U.__call=U.__index;V.new=T;return V end;local W={}W.new=T;return W

6
extern/lualibs/pl/config.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/config.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a,b,c,d,e=_G.type,_G.tonumber,_G.ipairs,_G.io,_G.table;local function f(g,h)local i={}local j=e.insert;h='[^'..h..']+'for k in g:gmatch(h)do j(i,k)end;return i end;local function l(g)return g:gsub('^%s+',''):gsub('%s+$','')end;local function m(g)return g:gsub("['\"](.*)['\"]",'%1')end;local n={}function n.lines(o)local p,q,r;local s=''if a(o)=='string'then p,r=d.open(o,'r')if not p then return nil,r end;q=true else p=o or d.stdin;if not o.read then return nil,'not a file-like object'end end;if not p then return nil,'file is nil'end;return function()local t=p:read()while t do if t:match'%S'and not t:match'^%s*[;#]'then local u=t:find'\\%s*$'if u then s=s..t:sub(1,u-1)elseif s==''then return t else t=s..t;s=''return t end end;t=p:read()end;if q then p:close()end end end;function n.read(o,v)local w;local x,r=n.lines(o)if not x then return nil,r end;local s=x()v=v or{}if v.smart then w=true;if s:match'^[^=]+='then v.keysep='='elseif s:match'^[^:]+:'then v.keysep=':'v.list_delim=':'elseif s:match'^%S+%s+'then v.keysep=' 'if s:match'^%S+%s+%S+%s+%S+'then v.list_delim=' 'end;v.variabilize=false end end;local function y(z,A)local B=v[z]if B==nil then return A else return B end end;local C='^[%d%+%-]'local D={}local E=D;local F=y('variabilize',true)local G=y('list_delim',',')local H=y('convert_numbers',true)local I=y('convert_boolean',false)local J=y('trim_space',true)local K=y('trim_quotes',false)local L=y('ignore_assign',false)local M=y('keysep','=')local N=M==' 'and'%s+'or'%s*'..M..'%s*'if G==' 'then G='%s+'end;local function O(P)if F then P=P:gsub('[^%w]','_')end;return P end;local function Q(R)if G and R:find(G)then R=f(R,G)for u,S in c(R)do R[u]=Q(S)end elseif H and R:find(C)then local B=b(R)if not B and R:match' kB$'then R=R:gsub(' kB','')B=b(R)end;if B then R=B end elseif I and R=='true'then return true elseif I and R=='false'then return false end;if a(R)=='string'then if J then R=l(R)end;if not K and w and R:match'^"'then K=true end;if K then R=m(R)end end;return R end;while s do if s:find('^%[')then local T=O(s:match('%[([^%]]+)%]'))D=E;D[T]={}D=D[T]else s=s:gsub('^%s*','')local U,V=s:find(N)if U and not L then local P=O(s:sub(1,U-1))local R=Q(s:sub(V+1))D[P]=R else D[#D+1]=Q(s)end end;s=x()end;return E end;return n

41
extern/lualibs/pl/data.lua vendored Normal file
View File

@ -0,0 +1,41 @@
-- Penlight 1.11.0-1 | /lua/pl/data.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.utils'local b=rawget(_G,'_DEBUG')local c,d,e,f=a.patterns,a.function_arg,a.split,a.array_tostring;local g,h=table.insert,table.concat;local i=string.gsub;local io=io;local _G,print,type,tonumber,ipairs,setmetatable=_G,print,type,tonumber,ipairs,setmetatable;local j={}local k;local function l(m)return m:gsub('%s+$','')end;local function n(m)return l(m):gsub('^%s*','')end;local function o(p)return setmetatable(p,require('pl.List'))end;local function q(r,s)local t={}for u=1,#s do t[u]=r(s[u])end;return t end;local function v(w,x,y,z)local A;if y and w:match'"'then w=w:gsub('"([^"]+)"',function(B)local m,C=B:gsub(',','\001')if C>0 then A=true end;return m end)if A then A=function(m)return m:gsub('\001',',')end end end;local t=e(w,x,false,z)if y then if A then t=q(A,t)end;if w:match',$'then g(t,'')end end;return o(t)end;local function D(s,E)for u=1,#s do if E==s[u]then return u end end end;local F={column_by_name=function(self,G)if type(G)=='number'then G='$'..G end;local H={}for t in j.query(self,G)do g(H,t)end;return o(H)end,copy_select=function(self,I)I=k(I,self)local J=j.query(self,I)local t={}local K=o{J()}while#K>0 do g(t,K)K=o{J()}end;t.delim=self.delim;return j.new(t,v(I.fields,','))end,column_names=function(self)return self.fieldnames end}local L;F.__index=function(self,G)local M=F[G]if M then return M end;if not L then L=require'pl.array2d'end;return L[G]end;local N={',','\t',' ',';'}local function O(w)if w==''then return' 'end;for P,x in ipairs(N)do if w:find(x)then return x==' 'and'%s+'or x end end;return' 'end;local function Q(M,R)local S,T;local U=R=='r'if type(M)=='string'then if M=='stdin'then M=io.stdin elseif M=='stdout'then M=io.stdout else M,T=io.open(M,R)if not M then return nil,T end;S=true end end;if M and(U and not M.read or not U and not M.write)then return nil,"not a file-like object"end;return M,nil,S end;function j.read(V,W)local X,w;local Y={}if not W then W={}end;local M,T,S=Q(V,'r')if not M then return nil,T end;local Z=W.thousands_dot;local y=W.csv;if y then W.delim=','end;local tonumber=tonumber;local function _(a0)if Z then a0=a0:gsub('%.(...)','%1')end;if y and a0==''then a0='0'end;local E=tonumber(a0)if E==nil then return nil,"not a number"end;return E end;X=1;w=M:read()if not w then return nil,"empty file"end;Y.delim=W.delim and W.delim or O(w)local x=Y.delim;local a1;local a2={}local function a3(a4,a5)a1=a1 or{}g(a2,a4)g(a1,a5)end;if W.numfields then for P,z in ipairs(W.numfields)do a3(z,_)end end;local a6;if x=='%s+'and w:find(x)==1 then a6=function(m)return m:gsub('^%s+','')end;w=a6(w)end;if not W.fieldnames then local a7,a8;a7=v(w,x,y)if not W.convert then a8=q(tonumber,a7)if#a8==#a7 then g(Y,a8)for u=1,#a8 do a3(u,_)end else a8=nil end else for a4,a5 in pairs(W.convert)do a3(a4,a5)end end;if a8==nil then W.fieldnames=a7 end;w=M:read()X=X+1;if a6 then w=a6(w)end elseif type(W.fieldnames)=='string'then W.fieldnames=v(W.fieldnames,x,y)end;local a9;if W.fieldnames then Y.fieldnames=W.fieldnames;if W.last_field_collect then a9=#Y.fieldnames end;if not W.no_convert then local a7=v(w,Y.delim,y,a9)for u=1,#a7 do if not D(a2,u)and _(a7[u])then a3(u,_)end end end end;while w do if not w:find('^%s*$')then if a6 then w=a6(w)end;local a7=v(w,x,y,a9)if a1 then for aa=1,#a2 do local u,a5=a2[aa],a1[aa]local ab,T=a5(a7[u])if ab==nil then return nil,T..": "..a7[u].." at line "..X else a7[u]=ab end end end;g(Y,a7)end;w=M:read()X=X+1 end;if S then M:close()end;if x=='%s+'then Y.delim=' 'end;if not Y.fieldnames then Y.fieldnames={}end;return j.new(Y)end;local function ac(j,M,K,x)j.temp=f(K,j.temp)M:write(h(j.temp,x),'\n')end;function F:write_row(M,K)ac(self,M,K,self.delim)end;function j.write(j,V,ad,x)local M,T,S=Q(V,'w')if not M then return nil,T end;if not ad then ad=j.fieldnames end;x=x or'\t'if ad and#ad>0 then M:write(h(ad,x),'\n')end;for u=1,#j do ac(j,M,j[u],x)end;if S then M:close()end;return true end;function F:write(V)j.write(self,V,self.fieldnames,self.delim)end;local function ae(a7,af)for u=1,#a7 do local M=n(a7[u])af[u]=M;a7[u]=M:gsub('%W','_')end end;function j.new(ag,ad)ag.fieldnames=ag.fieldnames or ad or''if not ag.delim and type(ag.fieldnames)=='string'then ag.delim=O(ag.fieldnames)ag.fieldnames=v(ag.fieldnames,ag.delim)end;ag.fieldnames=o(ag.fieldnames)ag.original_fieldnames={}ae(ag.fieldnames,ag.original_fieldnames)setmetatable(ag,F)return ag end;local ah=[[
return function (t)
local i = 0
local v
local ls = {}
for i,v in ipairs(t) do
if CONDITION then
ls[#ls+1] = v
end
end
table.sort(ls,function(v1,v2)
return SORT_EXPR
end)
local n = #ls
return function()
i = i + 1
v = ls[i]
if i > n then return end
return FIELDLIST
end
end
]]local ai=[[
return function (t)
local n = #t
local i = 0
local v
return function()
repeat
i = i + 1
v = t[i]
until i > n or CONDITION
if i > n then return end
return FIELDLIST
end
end
]]local function aj(m)return type(m)=='string'end;local ak;local function al(j)return h(j.fieldnames,',')end;local function am(j,M)local a4;if M:find'^%d+$'then a4=tonumber(M)else a4=D(j.fieldnames,M)end;if a4 then return'v['..a4 ..']'else ak=M..' not found in '..al(j)return M end end;local function an(j,ao)ak=nil;local a7=ao.fields;local a2=a7:find'%$'or#j.fieldnames==0;if a7:find'^%s*%*%s*'then if not a2 then a7=al(j)else local ap=#j[1]a7={}for u=1,ap do g(a7,'$'..u)end;a7=h(a7,',')end end;local aq=c.IDEN;if a2 then aq='%$(%d+)'else a7=l(a7):gsub('[^,%w]','_')end;local am=a.bind1(am,j)local ar=i(a7,aq,am)if ak then return nil,ak end;ao.fields=a7;ao.proc_fields=ar;ao.where=ao.where or'true'if aj(ao.where)then ao.where=i(ao.where,aq,am)ak=nil end;return true end;k=function(m,j)local as;local ao={}local at,au=m:find('where ')local av,aw=m:find('sort by ')if at then as=(av or 0)-1;ao.where=m:sub(au+1,as)end;if av then ao.sort_by=m:sub(aw+1)end;as=(at or av or 0)-1;ao.fields=m:sub(1,as)local ax,T=an(j,ao)if not ax then return nil,T else return ao end end;function j.query(j,I,ay,az)local T;if aj(I)then I,T=k(I,j)if not I then return nil,T end elseif type(I)=='table'then if type(I.fields)=='table'then I.fields=h(I.fields,',')end;if not I.proc_fields then local ax,T=an(j,I)if not ax then return nil,T end end else return nil,"condition must be a string or a table"end;local aA;if I.sort_by then aA=ah else aA=ai end;local a7=I.proc_fields or I.fields;if az then a7='{'..a7 ..'}'end;aA=aA:gsub('FIELDLIST',a7)if aj(I.where)then aA=aA:gsub('CONDITION',I.where)I.where=nil else aA=aA:gsub('CONDITION','_condn(v)')I.where=d(0,I.where,'condition.where must be callable')end;if I.sort_by then local aB,aC,aD;local aE=I.sort_by;local aF,aG=aE:find('%s+')if aF then aC,aD=aE:sub(1,aF-1),aE:sub(aG+1)else aC=aE;aD='asc'end;if aC:match'^%$'then aC=aC:sub(2)end;aC=am(j,aC)if ak then return nil,ak end;if aD=='asc'then aD='<'else aD='>'end;aB=('%s %s %s'):format(aC:gsub('v','v1'),aD,aC:gsub('v','v2'))aA=aA:gsub('SORT_EXPR',aB)end;if I.where then aA='return function(_condn) '..aA..' end'end;if b then print(aA)end;local aH,T=a.load(aA,'tmp')if not aH then return nil,T end;aH=aH()if I.where then aH=aH(I.where)end;local aI=aH(j)if ay then g(ay,_G)local aJ={}a.setfenv(aI,aJ)setmetatable(aJ,{__index=function(aK,aL)for aa,s in ipairs(ay)do if s[aL]then return s[aL]end end end})end;return aI end;F.select=j.query;F.select_row=function(ag,I,ay)return j.query(ag,I,ay,true)end;function j.filter(aM,aN,aO,aP)local ag=j.read(aN or'stdin')local aQ=Q(aO or'stdout')local J,T=ag:select(aM)local x=ag.delim;if not J then T='error: '..T;if aP then return nil,T else a.quit(1,T)end end;while true do local t={J()}if#t==0 then break end;aQ:write(h(t,x),'\n')end end;return j

10
extern/lualibs/pl/func.lua vendored Normal file
View File

@ -0,0 +1,10 @@
-- Penlight 1.11.0-1 | /lua/pl/func.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local type,setmetatable,getmetatable,rawset=type,setmetatable,getmetatable,rawset;local a,b=table.concat,table.insert;local tostring=tostring;local c=require'pl.utils'local pairs,rawget,d,e=pairs,rawget,c.unpack,c.pack;local f=require'pl.tablex'local g=f.map;local h=rawget(_G,'_DEBUG')local i=c.assert_arg;local j={}local k={}local function l(m)setmetatable(m,k)return m end;j.PE=l;local function n(o)return getmetatable(o)==k end;j.isPE=n;local function p(q)return l{op='X',repr='_'..q,index=q}end;local function r(q)return l{op='X',repr='_C'..q,index=q}end;j._1,j._2,j._3,j._4,j._5=p(1),p(2),p(3),p(4),p(5)j._0=l{op='X',repr='...',index=0}function j.Var(s)local t=c.split(s,'[%s,]+')local u={}for v=1,#t do b(u,l{op='X',repr=t[v],index=0})end;return d(u)end;function j._(w)return l{op='X',repr=w,index='wrap'}end;local x;j.Nil=j.Var'nil'function k.__index(o,y)return l{op='[]',o,y}end;function k.__call(z,...)return l{op='()',z,...}end;function k.__tostring(A)return x(A)end;function k.__unm(B)return l{op='unm',B}end;function j.Not(B)return l{op='not',B}end;function j.Len(B)return l{op='#',B}end;local function C(D,m)for s,E in pairs(m)do rawset(D,s,function(F,G)return l{op=E,F,G}end)end end;local function H(s,z,D)rawset(D,s,function(...)return l{op='()',z,...}end)end;local I={}local function J(K)return type(_G[K])=='table'end;function j.import(L,D)i(1,L,'string',J,'arg# 1: not a name of a global table')local m=_G[L]D=D or _G;for s,z in pairs(m)do H(s,z,D)I[z]=s end end;function j.register(z,s)i(1,z,'function')if s then i(2,s,'string')I[z]=s end;return function(...)return l{op='()',z,...}end end;function j.lookup_imported_name(z)return I[z]end;local function M(...)return...end;function j.Args(...)return l{op='()',M,...}end;local N={['or']=0,['and']=2,['==']=4,['~=']=4,['<']=4,['>']=4,['<=']=4,['>=']=4,['..']=6,['+']=8,['-']=8,['*']=10,['/']=10,['%']=10,['^']=14}local O={['not']=12,['#']=12,['unm']=12}C(j,{And='and',Or='or',Eq='==',Lt='<',Gt='>',Le='<=',Ge='>='})C(k,{__add='+',__sub='-',__mul='*',__div='/',__mod='%',__pow='^',__concat='..'})C(k,{__eq='=='})function j.tail(t)i(1,t,'table')local u={}for v=2,#t do b(u,t[v])end;return u end;function x(A,P)local Q=j.tail;if n(A)then local R=N[A.op]or O[A.op]if R then local S;if N[A.op]then local T=R;local U=R;if A.op=='..'or A.op=='^'then T=T+1 else U=U+1 end;local V=x(A[1],T)local W=x(A[2],U)S=V..' '..A.op..' '..W else local E=A.op=='unm'and'-'or A.op;S=E..' '..x(A[1],R)end;if P and P>R then S='('..S..')'end;return S else local t=g(x,A)if A.op=='[]'then return t[1]..'['..t[2]..']'elseif A.op=='()'then local X;if t[1]~=nil then X=t[1]else X=''end;return X..'('..a(Q(t),',')..')'else return A.repr end end elseif type(A)=='string'then return'"'..A..'"'elseif type(A)=='function'then local s=j.lookup_imported_name(A)if s then return s else return tostring(A)end else return tostring(A)end end;j.repr=x;local Y;function Y(A,Z)if n(A)then if A.op~='X'then local _=0;for v=1,#A do local a0=A[v]local a1=n(a0)if a1 then if a0.op=='X'and a0.index=='wrap'then a0=a0.repr;a1=false else _=math.max(_,Y(a0,Z))end end;if not a1 then b(Z,a0)A[v]=r(#Z)end end;return _ else return A.index end else return 0 end end;j.collect_values=Y;function j.instantiate(A)local a2,a3,a4={},{},{}local a5,a6,z;local K=j.collect_values(A,a3)for v=1,#a3 do b(a2,'_C'..v)if h then print(v,a3[v])end end;for v=1,K do b(a4,'_'..v)end;a2=a(a2,',')a4=a(a4,',')a5=x(A)local a7=('return function(%s) return function(%s) return %s end end'):format(a2,a4,a5)if h then print(a7)end;z,a6=c.load(a7,'fun')if not z then return nil,a6 end;z=z()z=z(d(a3))A.__PE_function=z;return z end;function j.I(A)if rawget(A,'__PE_function')then return A.__PE_function else return j.instantiate(A)end end;c.add_function_factory(k,j.I)j.bind1=c.bind1;j.curry=j.bind1;function j.compose(a8,a9)return function(...)return a8(a9(...))end end;function j.bind(X,...)local aa=e(...)local ab,a4,ac,a3={},{},{'fn'},{}local ad,ae,af=1,0,false;for v=1,aa.n do local ag=aa[v]if n(ag)and ag.op=='X'then b(ab,ag.repr)ae=math.max(ae,ag.index)if ag.index==0 then af=true end else local ah='_v'..ad;b(ac,ah)b(ab,ah)b(a3,ag)ad=ad+1 end end;for ai=1,ae do b(a4,'_'..ai)end;if af then b(a4,'...')end;ac=a(ac,',')a4=a(a4,',')ab=a(ab,',')local a7=([[
return function (%s)
return function(%s) return fn(%s) end
end
]]):format(ac,a4,ab)if h then print(a7)end;local u=c.load(a7)u=u()return u(X,d(a3))end;return j

6
extern/lualibs/pl/import_into.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/import_into.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return function(a)local b;if a==true then b={}a={}end;local a=a or{}local c={utils=true,path=true,dir=true,tablex=true,stringio=true,sip=true,input=true,seq=true,lexer=true,stringx=true,config=true,pretty=true,data=true,func=true,text=true,operator=true,lapp=true,array2d=true,comprehension=true,xml=true,types=true,test=true,app=true,file=true,class=true,luabalanced=true,permute=true,template=true,url=true,compat=true,List=true,Map=true,Set=true,OrderedMap=true,MultiMap=true,Date=true}rawset(a,'utils',require'pl.utils')for d,e in pairs(a.utils.stdmt)do e.__index=function(f,g)return require('pl.'..d)[g]end end;local h,i;local j={}local k=getmetatable(a)if k then i=k.__index;if k.__newindex then j.__index=k.__newindex end end;function j.hook(l)h=l end;function j.__index(f,d)local m=c[d]if m then rawset(a,d,require('pl.'..d))return a[d]else local n;if h then n=h(f,d)if n then return n end end;if i then return i(f,d)end end end;if b then function j.__newindex(f,d,o)b[d]=o;rawset(f,d,o)end end;setmetatable(a,j)return a,b or a end

6
extern/lualibs/pl/init.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/init.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require'pl.import_into'(_G)if rawget(_G,'PENLIGHT_STRICT')then require'pl.strict'end

6
extern/lualibs/pl/input.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/input.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=string.find;local b=string.sub;local c=string.match;local d=require'pl.utils'local e=d.unpack;local pairs,type,tonumber=pairs,type,tonumber;local f=d.patterns;local io=io;local g={}function g.alltokens(h,i,j)local k=h()local l=1;return function()while k do local m,n=a(k,i,l)if m then l=n+1;local o=b(k,m,n)if j then o=j(o)end;return o else k=h()l=1 end end;return nil end end;local p=g.alltokens;function g.create_getter(q)if q then if type(q)=='string'then local r=d.split(q,'\n')local s,t=0,#r;return function()s=s+1;if s>t then return nil end;return r[s]end else if not q.read then error('not a file-like object')end;return function()return q:read()end end else return io.read end end;function g.numbers(q)return p(g.create_getter(q),'('..f.FLOAT..')',tonumber)end;function g.words(q)return p(g.create_getter(q),"%w+")end;local function u(v,...)local w={...}for s=1,#w do local t=tonumber(w[s])if t==nil then if not v then return nil,w[s]end else w[s]=t end end;return w end;function g.fields(x,y,q,z)local A;local m;local h=g.create_getter(q)local v=z and z.no_fail;local B=z and z.no_convert;if not y or y==' 'then y='%s'A='%s+'m='%s*'else A=y;m=''end;local C=0;if type(x)=='table'then for s,D in pairs(x)do if D>C then C=D end end else C=x;x={}for s=1,C do x[#x+1]=s end end;local E='[^'..y..']*'local F=1;for s=1,C do if x[F]==s then F=F+1;m=m..'('..E..')'else m=m..E end;if s<C then m=m..A end end;local G=1;return function()local k,H,I;repeat k=h()G=G+1;if not k then return nil end;if B then H={c(k,m)}else H,I=u(v,c(k,m))if not H then d.quit("line "..G-1 ..": cannot convert '"..I.."' to number")end end until#H>0;return e(H)end end;return g

6
extern/lualibs/pl/lapp.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/pl/lexer.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/pl/luabalanced.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/luabalanced.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a={}local assert=assert;local b={['(']=')',['{']='}',['[']=']'}local c={}for d,e in pairs(b)do c[e]=d end;local function f(g,h)h=h or 1;local i=h;local j=g:sub(h,h)if j=='"'or j=="'"then h=h+1;while 1 do h=assert(g:find("["..j.."\\]",h),'syntax error')if g:sub(h,h)==j then local k=g:sub(i,h)return k,h+1 else h=h+2 end end else local l=g:match("^%[(=*)%[",h)if l then local m;m,h=g:find("%]"..l.."%]",h)assert(h)local k=g:sub(i,h)return k,h+1 else return nil,h end end end;a.match_string=f;local function n(g,h)h=h or 1;local i=h;local o=g:sub(h,h)if not b[o]then return nil,h end;local p={}while 1 do h=g:find('[%(%{%[%)%}%]\"\']',h)assert(h,'syntax error: unbalanced')local j=g:sub(h,h)if j=='"'or j=="'"then local k;k,h=f(g,h)assert(k)elseif b[j]then local q,r;if j=='['then q,r=g:match('^%[(=*)%[()',h)end;if q then h=g:match('%]'..q..'%]()',r)assert(h,'syntax error: long string not terminated')if#p==0 then local k=g:sub(i,h-1)return k,h end else p[#p+1]=j;h=h+1 end else assert(p[#p]==assert(c[j]),'syntax error: unbalanced')p[#p]=nil;if#p==0 then local k=g:sub(i,h)return k,h+1 end;h=h+1 end end end;a.match_bracketed=n;local function s(g,h)h=h or 1;if g:sub(h,h+1)~='--'then return nil,h end;h=h+2;local t,u=f(g,h)if t then return'--'..t,u end;local k;k,h=g:match('^([^\n]*\n?)()',h)return'--'..k,h end;local v={['and']=true,['or']=true,['not']=true}local w={['>']=true,['<']=true,['~']=true}local function x(g,h)h=h or 1;local m;local i=h;local y;local z,A;while h do local j=g:sub(h,h)if j=='"'or j=="'"or j=='['and g:find('^[=%[]',h+1)then local k;k,h=f(g,h)assert(k,'syntax error')elseif j=='-'and g:sub(h+1,h+1)=='-'then z=h;while g:sub(h,h+1)=='--'do local k;k,h=s(g,h)assert(k)h=g:match('^%s*()',h)A=h end elseif j=='('or j=='{'or j=='['then m,h=n(g,h)elseif j=='='and g:sub(h+1,h+1)=='='then h=h+2 elseif j=='='and w[g:sub(h-1,h-1)]then h=h+1 elseif j:match'^[%)%}%];,=]'then local k=g:sub(i,h-1)return k,h elseif j:match'^[%w_]'then local B,C=g:match('^([%w_]+)()',h)if h~=i and not v[B]then local D=(A==h and z or h)-1;while g:match('^%s',D)do D=D-1 end;local E=g:sub(D,D)if E:match'[%)%}\'\"%]]'or E:match'[%w_]'and not v[y]then local k=g:sub(i,h-1)return k,h end end;y,h=B,C else h=h+1 end;h=g:find('[%(%{%[%)%}%]\"\';,=%w_%-]',h)end;local k=g:sub(i,#g)return k,#g+1 end;a.match_expression=x;local function F(g,h)h=h or 1;local G={}while 1 do local j=#G==0 and'^'or'^%s*,%s*'local H,u=g:match(j..'([%a_][%w_]*)%s*()',h)if H then h=u else break end;G[#G+1]=H end;return G,h end;a.match_namelist=F;local function I(g,h)h=h or 1;local G={}while 1 do if#G~=0 then local u=g:match('^%s*,%s*()',h)if u then h=u else break end end;local H;H,h=x(g,h)assert(H,'syntax error')G[#G+1]=H end;return G,h end;a.match_explist=I;local function J(g,K)local h=1;local i=1;local L=''while 1 do h=g:find('[%-\'\"%[]',h)if not h then break end;if g:match('^%-%-',h)then local M=g:sub(i,h-1)if#M>0 then L=L..(K('e',M)or M)end;local N;N,h=s(g,h)L=L..(K('c',assert(N))or N)i=h else local r=g:find('^[\'\"%[]',h)local O;if r then O,h=f(g,r)end;if O then local M=g:sub(i,r-1)if#M>0 then L=L..(K('e',M)or M)end;L=L..(K('s',O)or O)i=h else h=h+1 end end end;local M=g:sub(i)if#M>0 then L=L..(K('e',M)or M)end;return L end;a.gsub=J;return a

6
extern/lualibs/pl/operator.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/operator.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=string.find;local b={}function b.call(c,...)return c(...)end;function b.index(d,e)return d[e]end;function b.eq(f,g)return f==g end;function b.neq(f,g)return f~=g end;function b.lt(f,g)return f<g end;function b.le(f,g)return f<=g end;function b.gt(f,g)return f>g end;function b.ge(f,g)return f>=g end;function b.len(f)return#f end;function b.add(f,g)return f+g end;function b.sub(f,g)return f-g end;function b.mul(f,g)return f*g end;function b.div(f,g)return f/g end;function b.pow(f,g)return f^g end;function b.mod(f,g)return f%g end;function b.concat(f,g)return f..g end;function b.unm(f)return-f end;function b.lnot(f)return not f end;function b.land(f,g)return f and g end;function b.lor(f,g)return f or g end;function b.table(...)return{...}end;function b.match(f,g)return a(f,g)~=nil end;function b.nop(...)return...end;b.optable={['+']=b.add,['-']=b.sub,['*']=b.mul,['/']=b.div,['%']=b.mod,['^']=b.pow,['..']=b.concat,['()']=b.call,['[]']=b.index,['<']=b.lt,['<=']=b.le,['>']=b.gt,['>=']=b.ge,['==']=b.eq,['~=']=b.neq,['#']=b.len,['and']=b.land,['or']=b.lor,['{}']=b.table,['~']=b.match,['']=b.nop}return b

6
extern/lualibs/pl/permute.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/permute.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.tablex'local b=require'pl.utils'local c=a.deepcopy;local d=table.insert;local e=b.assert_arg;local f={}function f.order_iter(g)e(1,g,'table')local h=#g;local i={1}local function j()local k=#i;local l=h-k+1;local m=i[k]if m>h then return end;if l==0 then table.remove(i)k=k-1;i[k]=i[k]+1;return g elseif m<=l then g[l],g[m]=g[m],g[l]table.insert(i,1)else table.remove(i)k=k-1;l=l+1;m=i[k]g[l],g[m]=g[m],g[l]i[k]=i[k]+1 end;return j()end;return j end;function f.order_table(g)e(1,g,'table')local n={}for h in f.iter(g)do d(n,c(h))end;return n end;function f.list_iter(...)local o={...}local p={}local q={}local r=#o;for m,s in ipairs(o)do e(m,s,'table')p[m]=1;q[m]=s.n or#s end;local t=0;return function()if p[r]>q[r]then return end;t=t+1;local u={n=#o}local v=true;for m=1,r do u[m]=o[m][p[m]]if v then p[m]=p[m]+1;if p[m]<=q[m]then v=false else if m~=r then p[m]=1 end end end end;return t,b.unpack(u)end end;function f.list_table(...)local j=f.list_iter(...)local w={}local m=1;while true do local x=b.pack(j())if x[1]==nil then return w end;for m=1,x.n do x[m]=x[m+1]end;x.n=x.n-1;w[m]=x;m=m+1 end end;function f.iter(...)b.raise_deprecation{source="Penlight "..b._VERSION,message="function 'iter' was renamed to 'order_iter'",version_removed="2.0.0",deprecated_after="1.9.2"}return f.order_iter(...)end;function f.table(...)b.raise_deprecation{source="Penlight "..b._VERSION,message="function 'table' was renamed to 'order_table'",version_removed="2.0.0",deprecated_after="1.9.2"}return f.order_table(...)end;return f

6
extern/lualibs/pl/pretty.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/pretty.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=table.insert;local b=table.concat;local c,d=math.floor,math.huge;local e=math.type;local f=require'pl.utils'local g=require'pl.lexer'local h=require'debug'local i=require'pl.stringx'.quote_string;local j=f.assert_arg;local k=tostring;local function tostring(l)if type(l)~="number"then return k(l)elseif l~=l then return"NaN"elseif l==d then return"Inf"elseif l==-d then return"-Inf"elseif(_VERSION~="Lua 5.3"or e(l)=="integer")and c(l)==l then return("%d"):format(l)else local m=("%.14g"):format(l)if _VERSION=="Lua 5.3"and e(l)=="float"and not m:find("%.")then m=m:gsub("%d+","%0.0",1)end;return m end end;local n={}local function o()local p={}p.hook,p.mask,p.count=h.gethook()if p.hook~="external hook"then h.sethook()end;p.string_mt=getmetatable("")h.setmetatable("",nil)return p end;local function q(p)if p then h.setmetatable("",p.string_mt)if p.hook~="external hook"then h.sethook(p.hook,p.mask,p.count)end end end;function n.read(r)j(1,r,'string')if r:find'^%s*%-%-'then r=r:gsub('%-%-.-\n','')end;if not r:find'^%s*{'then return nil,"not a Lua table"end;if r:find'[^\'"%w_]function[^\'"%w_]'then local s=g.lua(r)for t,u in s do if t=='keyword'and u=='function'then return nil,"cannot have functions in table definition"end end end;r='return '..r;local v,w=f.load(r,'tbl','t',{})if not v then return nil,w end;local x=o()local y,z=pcall(v)q(x)if y then return z else return nil,z end end;function n.load(r,p,A)p=p or{}if A then local s=g.lua(r)for t,u in s do if t=='keyword'and(u=='for'or u=='repeat'or u=='function'or u=='goto')then return nil,"looping not allowed"end end end;local v,w=f.load(r,'tbl','t',p)if not v then return nil,w end;local x=A and o()local y,w=pcall(v)q(x)if not y then return nil,w end;return p end;local function B(u)if not u then return''else if u:find' 'then u=i(u)end end;return u end;local C;local function D(r)return type(r)=='string'and r:find('^[%a_][%w_]*$')and not C[r]end;local function E(r)if type(r)=='table'then return n.write(r,'')else return i(r)end end;local function F(G,H)if not G then H=E(H)H=H:find("^%[")and" "..H.." "or H end;return'['..H..']'end;function n.write(I,J,K)if type(I)~='table'then local m=tostring(I)if type(I)=='string'then return E(I)end;return m,'not a table'end;if not C then C=g.get_keywords()end;local L=' = 'if J==''then L='='end;J=J or' 'local M={}local N=''local O={}local function P(r)if#r>0 then N=N..r end end;local function Q(r)if#N>0 then N=N..r;a(M,N)N=''else a(M,r)end end;local function R()local S=#M;local T=M[S]:sub(-1,-1)if T==','then M[S]=M[S]:sub(1,-2)end end;local U=function(t)local V=0;local y,u;local W=function()return t[V]end;return function()V=V+1;y,u=pcall(W)if u==nil or not y then return end;return V,t[V]end end;local X=function(t)local Y,u,y;local W=function()return next(t,Y)end;return function()y,Y,u=pcall(W)if not y then return end;return Y,u end end;local Z;Z=function(t,_,a0)local a1=type(t)if a1~='string'and a1~='table'then Q(B(tostring(t))..',')elseif a1=='string'then Q(i(t)..",")elseif a1=='table'then if O[t]then Q('<cycle>,')return end;O[t]=true;local a2=a0 ..J;Q('{')local a3={}if not K then for V,a4 in U(t)do P(a0)Z(a4,a0,a2)a3[V]=true end end;local a5={}for Y,u in X(t)do if type(Y)~='number'then a5[#a5+1]=Y end end;table.sort(a5,function(a6,a7)if type(a6)==type(a7)and type(a6)=='string'then return a6<a7 end;return type(a6)=='boolean'or type(a7)~='boolean'and type(a6)=='table'end)local function a8(H,a4)local a9=type(H)local G=a9=='number'if K then H=tostring(H)P(a0 ..F(G,H)..L)Z(a4,a0,a2)else if not G or not a3[H]then if a9~='string'then H=tostring(H)end;if G or not D(H)then H=F(G,H)end;P(a0 ..H..L)Z(a4,a0,a2)end end end;for V=1,#a5 do local H=a5[V]local a4=t[H]a8(H,a4)end;for H,a4 in X(t)do if type(H)=='number'then a8(H,a4)end end;O[t]=nil;R()Q(_..'},')else Q(tostring(t)..',')end end;Z(I,'',J)R()return b(M,#J>0 and'\n'or'')end;function n.dump(t,aa)if not aa then print(n.write(t))return true else return f.writefile(aa,n.write(t))end end;function n.debug(...)local S=select("#",...)local t={...}for V=1,S do local l=t[V]if l==nil then l="<nil>"end;t[V]=nil;t["arg "..V]=l end;print(n.write(t))return true end;local ab,ac={'B','KiB','MiB','GiB'},{'','K','M','B'}local function ad(a4)local ae=math.floor(a4/1000)if ae>0 then return ad(ae)..','..tostring(a4%1000)else return tostring(a4)end end;function n.number(af,ag,ah)local ai='%.'..(ah or 1)..'f%s'if ag=='T'then return ad(af)else local aj,ak;if ag=='M'then ak=1024;aj=ab else ak=1000;aj=ac end;local al=ak;local Y=1;while af>=al and Y<=#aj do al=al*ak;Y=Y+1 end;al=al/ak;if Y>#aj then Y=Y-1;al=al/ak end;if Y>1 then return ai:format(af/al,aj[Y]or'duh')else return af..aj[1]end end end;return setmetatable(n,{__call=function(self,...)return self.debug(...)end})

6
extern/lualibs/pl/seq.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/pl/sip.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/sip.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=rawget(_G,'loadstring')or load;local b=rawget(_G,'unpack')or rawget(table,'unpack')local c,d=table.insert,table.concat;local ipairs,type=ipairs,type;local io,_G=io,_G;local print,rawget=print,rawget;local e={FLOAT='[%+%-%d]%d*%.?%d*[eE]?[%+%-]?%d*',INTEGER='[+%-%d]%d*',IDEN='[%a_][%w_]*',OPTION='[%a_][%w_%-]*'}local function f(g,h,i)if type(h)~=i then error("argument "..g.." must be "..i,2)end end;local j={}local k={['<']='>',['(']=')',['{']='}',['[']=']'}local l={a=1,c=0,d=1,l=1,p=0,u=1,w=1,x=1,s=0}local function m(n)return'('..n..')'end;local function o(p)return p:gsub('[%-%.%+%[%]%(%)%^%%%?%*]','%%%0'):gsub('%$%%(%S)','$%1')end;local function q(r)return r:gsub("()%s+()",function(s,t)local u=r:sub(s-2,s-1)if u:match('%$[vifadxlu]')or u:match('^[^%$]?[%w_]$')then local v=r:sub(t,t+1)if v:match('%$[vifadxlu]')or v:match('^[%w_]')then return'%s+'end end;return'%s*'end)end;local w={v=m(e.IDEN),i=m(e.INTEGER),f=m(e.FLOAT),o=m(e.OPTION),r='(%S.*)',p='([%a]?[:]?[\\/%.%w_]+)'}function j.custom_pattern(x,r)w[x]=r end;function j.create_pattern(p,y)f(1,p,'string')local z,A={},{}if type(p)=='string'then p=o(p)else local B={}for C,n in ipairs(p)do B[C]=o(n)end;p=d(B,'.-')end;local D=1;local function E(F,type)F=F or D;c(z,F)A[F]=type;D=D+1 end;local G=p:find('{%a+}')if y and y.at_start then p='^'..p end;if p:sub(-1,-1)=='$'then p=p:sub(1,-2)..'$r'if G then p=p..'{rest}'end end;local H;if G then H={}p=p:gsub('{(%a+)}',function(F)c(H,F)return''end)end;p=q(p)local I=1;local J;local K=p:gsub('%$%S',function(n)local type,F;type=n:sub(2,2)if H then F=H[I]I=I+1 end;if not H and type=='q'then E(nil,'Q')else E(F,type)end;local B;if w[type]then B=w[type]elseif type=='q'then E(F,type)B='(["\'])(.-)%'..D-2 else local L=k[type]if L then B='(%b'..type..L..')'elseif l[type]or l[type:lower()]then B='(%'..type..'+)'else J="unknown format type or character class"end end;return B end)if J then return nil,J else return K,z,A end end;local function M(n)return n=='d'or n=='i'or n=='f'end;function j.create_spec_fun(p,y)local A,z;local N={}p,z,A=j.create_pattern(p,y)if not p then return p,z end;local G=type(z[1])=='string'for C=1,#z do c(N,'mm'..C)end;N[1]=N[1]or"mm1"local O=('return (function(s,res)\n\tlocal %s = s:match(%q)\n'):format(d(N,','),p)O=O..'\tif not mm1 then return false end\n'local I=1;for C,P in ipairs(z)do if P~='_'then local Q='mm'..C;if M(A[P])then Q='tonumber('..Q..')'elseif k[A[P]]then Q=Q..':sub(2,-2)'end;if G then O=('%s\tres.%s = %s\n'):format(O,P,Q)else if A[P]~='Q'then O=('%s\tres[%d] = %s\n'):format(O,I,Q)I=I+1 end end end end;return O..'\treturn true\nend)\n',G end;function j.compile(p,y)f(1,p,'string')local O,H=j.create_spec_fun(p,y)if not O then return nil,H end;if rawget(_G,'_DEBUG')then print(O)end;local R,J=a(O,'tmp')if J then return nil,J end;return R(),H end;local S={}function j.match(p,T,B,y)f(1,p,'string')f(2,T,'string')f(3,B,'table')if not S[p]then S[p]=j.compile(p,y)end;return S[p](T,B)end;function j.match_at_start(p,T,B)return j.match(p,T,B,{at_start=true})end;function j.fields(p,P)f(1,p,'string')if not P then return nil,"no file object"end;local O,J=j.compile(p)if not O then return nil,J end;local B={}return function()while true do local T=P:read()if not T then return end;if O(T,B)then local U=B;B={}return b(U)end end end end;local V={}function j.pattern(p,O)f(1,p,'string')local W,X=j.compile(p)c(V,{pat=W,named=X,callback=O})end;function j.read(P,Y)local Z,J;if not P then return nil,"no file object"end;if type(P)=='string'then P,J=io.open(P)if not P then return nil,J end;Z=true end;if Y then for _,a0 in ipairs(Y)do j.pattern(a0[1],a0[2])end end;local B={}for T in P:lines()do for _,a1 in ipairs(V)do if a1.pat(T,B)then if a1.callback then if a1.named then a1.callback(B)else a1.callback(b(B))end end;B={}break end end end;if Z then P:close()end end;return j

6
extern/lualibs/pl/strict.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/strict.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require'debug'local a,error,rawset,rawget=debug.getinfo,error,rawset,rawget;local b={}local function c()local d=a(3,"S")return d and d.what or"C"end;function b.module(e,f,g)local h,i,j,k,l;if g then l=g.__global end;if type(f)=='table'then h=getmetatable(f)if h and rawget(h,'__declared')then return end else f={}end;if h==nil then h={}setmetatable(f,h)else i=h.__newindex;j=h.__index;k=type(j)end;h.__declared=g or{}h.__newindex=function(m,n,o)if i then i(m,n,o)if rawget(m,n)~=nil then return end end;if not h.__declared[n]then if l then local p=c()if p~="main"and p~="C"then error("assign to undeclared global '"..n.."'",2)end end;h.__declared[n]=true end;rawset(m,n,o)end;h.__index=function(m,n)if not h.__declared[n]and c()~="C"then if j then if k=="table"then local q=j[n]if q~=nil then return q end else local r=j(m,n)if r~=nil then return r end end end;local s="variable '"..n.."' is not declared"if e then s=s.." in '"..tostring(e).."'"end;error(s,2)end;return rawget(m,n)end;return f end;function b.make_all_strict(t)for u,o in pairs(t)do if type(o)=='table'and o~=t then b.module(u,o)end end end;function b.closed_module(f,e)local v={}f=f or{}local h=getmetatable(f)if not h then h={}setmetatable(f,h)end;h.__newindex=function(m,u,o)v[u]=o end;return b.module(e,v)end;if not rawget(_G,'PENLIGHT_NO_GLOBAL_STRICT')then b.module(nil,_G,{_PROMPT=true,_PROMPT2=true,__global=true})end;return b

6
extern/lualibs/pl/stringio.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/stringio.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=rawget(_G,'unpack')or rawget(table,'unpack')local tonumber=tonumber;local b,c=table.concat,table.insert;local d={}local e={}e.__index=e;local function f(self,...)local g={...}for h=1,#g do c(self.tbl,g[h])end end;function e:write(i,j,...)if j then f(self,i,j,...)else c(self.tbl,i)end end;function e:writef(k,...)self:write(k:format(...))end;function e:value()return b(self.tbl)end;function e:__tostring()return self:value()end;function e:close()end;function e:seek()end;local l={}l.__index=l;function l:_read(k)local h,m=self.i,self.str;local n=#m;if h>n then return nil end;local o;if k=='*l'or k=='*L'then local p=m:find('\n',h)or n+1;o=m:sub(h,k=='*l'and p-1 or p)self.i=p+1 elseif k=='*a'then o=m:sub(h)self.i=n elseif k=='*n'then local q,r,p;q,p=m:find('%s*%d+',h)q,r=m:find('^%.%d+',p+1)if r then p=r end;q,r=m:find('^[eE][%+%-]*%d+',p+1)if r then p=r end;local s=m:sub(h,p)o=tonumber(s)self.i=p+1 elseif type(k)=='number'then o=m:sub(h,h+k-1)self.i=h+k else error("bad read format",2)end;return o end;function l:read(...)if select('#',...)==0 then return self:_read('*l')else local o,t={},{...}for h=1,#t do o[h]=self:_read(t[h])end;return a(o)end end;function l:seek(u,v)local w;u=u or'cur'v=v or 0;if u=='set'then w=1 elseif u=='cur'then w=self.i elseif u=='end'then w=#self.str end;self.i=w+v;return self.i end;function l:lines(...)local x,g=select('#',...)if x>0 then g={...}end;return function()if x==0 then return self:_read'*l'else return self:read(a(g))end end end;function l:close()end;function d.create()return setmetatable({tbl={}},e)end;function d.open(y)return setmetatable({str=y,i=1},l)end;function d.lines(y,...)return d.open(y):lines(...)end;return d

6
extern/lualibs/pl/stringx.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/stringx.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.utils'local string=string;local b=string.find;local type,setmetatable,ipairs=type,setmetatable,ipairs;local error=error;local c=string.gsub;local d=string.rep;local e=string.sub;local f=string.reverse;local g=table.concat;local h=table.insert;local i=a.escape;local j,k=math.ceil,math.max;local l,m=a.assert_arg,a.split;local n;local function o(p,q)l(p,q,'string')end;local function r(q)return#q>0 end;local function s(p,q)l(p,q,'string',r,'must be a non-empty string')end;local function t(u)return setmetatable(u,require('pl.List'))end;local v={}function v.isalpha(q)o(1,q)return b(q,'^%a+$')==1 end;function v.isdigit(q)o(1,q)return b(q,'^%d+$')==1 end;function v.isalnum(q)o(1,q)return b(q,'^%w+$')==1 end;function v.isspace(q)o(1,q)return b(q,'^%s+$')==1 end;function v.islower(q)o(1,q)return b(q,'^[%l%s]+$')==1 end;function v.isupper(q)o(1,q)return b(q,'^[%u%s]+$')==1 end;local function w(q,x)return b(q,x,1,true)==1 end;local function y(q,z)return#q>=#z and b(q,z,#q-#z+1,true)and true or false end;local function A(q,B,C)if type(B)=='string'then return C(q,B)elseif type(B)=='table'then for D,E in ipairs(B)do if C(q,E)then return true end end;return false else error(("argument #2 expected a 'string' or a 'table', got a '%s'"):format(type(B)))end end;function v.startswith(q,x)o(1,q)return A(q,x,w)end;function v.endswith(q,z)o(1,q)return A(q,z,y)end;function v.join(q,F)o(1,q)return g(F,q)end;function v.splitlines(q,G)o(1,q)local H={}local I=1;while true do local J=b(q,'[\r\n]',I)if not J then break end;local K=e(q,J,J)if K=='\r'and e(q,J+1,J+1)=='\n'then K='\r\n'end;local L=e(q,I,J-1)if G then L=L..K end;h(H,L)I=J+#K end;if I<=#q then h(H,e(q,I))end;return t(H)end;function v.split(q,M,p)o(1,q)local N=true;if not M then q=n(q)N=false end;local H=m(q,M,N,p)if M and M~=''and b(q,M,-#M,true)and(p or math.huge)>#H then H[#H+1]=""end;return t(H)end;function v.expandtabs(q,O)o(1,q)O=O or 8;return q:gsub("([^\t\r\n]*)\t",function(P)return P..(" "):rep(O-#P%O)end)end;local function Q(q,e,R,S,T)R=R or 1;S=S or#q;if e==''then return S+1,S-R+1 end;local U,V=b(q,e,R,true)local H;local W=0;while U do if S and V>S then break end;H=U;W=W+1;if T then U,V=b(q,e,U+1,true)else U,V=b(q,e,V+1,true)end end;return H,W end;function v.lfind(q,e,R,S)o(1,q)o(2,e)local U,V=b(q,e,R,true)if U and(not S or V<=S)then return U else return nil end end;function v.rfind(q,e,R,S)o(1,q)o(2,e)return Q(q,e,R,S,true)end;function v.replace(q,X,Y,p)o(1,q)o(2,X)o(3,Y)return c(q,i(X),Y:gsub('%%','%%%%'),p)end;function v.count(q,e,T)o(1,q)local D,W=Q(q,e,1,false,T)return W end;local function Z(q,_,a0,a1,a2)local p=#q;if _>p then if not a0 then a0=' 'end;local a3,a4;if a1 and a2 then local a5=j((_-p)/2)local a6=_-p-a5;a3=d(a0,a6)a4=d(a0,a5)elseif a2 then a3=d(a0,_-p)a4=''else a4=d(a0,_-p)a3=''end;return a3 ..q..a4 else return q end end;function v.ljust(q,_,a0)o(1,q)l(2,_,'number')return Z(q,_,a0,true,false)end;function v.rjust(q,_,a0)o(1,q)l(2,_,'number')return Z(q,_,a0,false,true)end;function v.center(q,_,a0)o(1,q)l(2,_,'number')return Z(q,_,a0,true,true)end;local function a7(q,a1,a2,a8)if not a8 then a8='%s'else a8='['..i(a8)..']'end;local a9=1;local aa;if a1 then local U,V=b(q,'^'..a8 ..'*')if V>=U then a9=V+1 end end;if a2 then if#q<200 then local U,V=b(q,a8 ..'*$',a9)if V>=U then aa=U-1 end else local ab=f(q)local U,V=b(ab,'^'..a8 ..'*')if V>=U then aa=-V-1 end end end;return e(q,a9,aa)end;function v.lstrip(q,a8)o(1,q)return a7(q,true,false,a8)end;n=v.lstrip;function v.rstrip(q,a8)o(1,q)return a7(q,false,true,a8)end;function v.strip(q,a8)o(1,q)return a7(q,true,true,a8)end;function v.splitv(q,M)o(1,q)return a.splitv(q,M)end;local function ac(ad,ae,C)local U,V=C(ad,ae)if not U or U==-1 then return ad,'',''else if not V then V=U end;return e(ad,1,U-1),e(ad,U,V),e(ad,V+1)end end;function v.partition(q,a0)o(1,q)s(2,a0)return ac(q,a0,v.lfind)end;function v.rpartition(q,a0)o(1,q)s(2,a0)local af,ag,ah=ac(q,a0,v.rfind)if af==q then return ah,ag,af end;return af,ag,ah end;function v.at(q,ai)o(1,q)l(2,ai,'number')return e(q,ai,ai)end;function v.lines(q)o(1,q)if not q:find'\n$'then q=q..'\n'end;return q:gmatch('([^\n]*)\n')end;function v.title(q)o(1,q)return q:gsub('(%S)(%S*)',function(a9,aj)return a9:upper()..aj:lower()end)end;v.capitalize=v.title;local ak='...'local al=#ak;function v.shorten(q,_,am)o(1,q)if#q>_ then if _<al then return ak:sub(1,_)end;if am then local an=#q-_+1+al;return ak..q:sub(an)else return q:sub(1,_-al)..ak end end;return q end;local function ao(q)local ap='([%[%]])(=*)%1'local aq,ar,D;local as=1;repeat D,as,D,ar=q:find(ap,as)if ar then aq=k(aq or 0,#ar)end until not ar;return aq end;function v.quote_string(q)o(1,q)local at=ao(q.."]")if(q:find("\n")or at)and not q:find("\r")then at=("="):rep((at or-1)+1)if q:find("^\n")then q="\n"..q end;local au,av="["..at.."[","]"..at.."]"q=au..q..av else q=("%q"):format(q):gsub("\r","\\r")end;return q end;function v.import()a.import(v,string)end;return v

6
extern/lualibs/pl/tablex.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/pl/template.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/template.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.utils'local b,c,d,e,f=table.insert,string.format,string.sub,string.find,string.gsub;local g="\n__R_size = __R_size + 1; __R_table[__R_size] = "local function h(i,j,k,l)local m=1;for n,o,p in j:gmatch(k)do o='('..d(o,2,-2)..')'b(i,g..c("%q",d(j,m,n-1)))b(i,g..c("__tostring(%s or '')",o))m=p end;local q;if l then q=c("%q",f(d(j,m),"\n",""))else q=c("%q",d(j,m))end;if q~='""'then b(i,g..q)end end;local function r(j,s,t,u,l)local k="()"..s.."(%b"..t..")()"local v=u.."+([^\n]*\n?)"local w,x="^"..v,"\n"..v;local i,m={"return function()\nlocal __R_size, __R_table, __tostring = 0, {}, __tostring",n=1},1;while true do local y,p,z=e(j,w,m)if not p then local A;A,p,z=e(j,x,m)h(i,d(j,m,A),k,l)if not p then break end end;if d(z,-1,-1)=="\n"then z=d(z,1,-2)end;b(i,"\n"..z)m=p+1 end;b(i,"\nreturn __R_table\nend")local B=false;if#i==3 and i[2]:find(g,1,true)==1 then i={"return "..i[2]:sub(#g+1,-1)}B=true end;return table.concat(i),B end;local C={}function C.substitute(D,E)E=E or{}local F,G=C.compile(D,{chunk_name=rawget(E,"_chunk_name"),escape=rawget(E,"_escape"),inline_escape=rawget(E,"_inline_escape"),inline_brackets=rawget(E,"_brackets"),newline=nil,debug=rawget(E,"_debug")})if not F then return F,G end;return F:render(E,rawget(E,"_parent"),rawget(E,"_debug"))end;local H=function(self,E,I,J)E=E or{}if I then setmetatable(E,{__index=I})end;setmetatable(self.env,{__index=E})local K,L=xpcall(self.fn,debug.traceback)if not K then if self.code and J then print(self.code)end;return nil,L,self.code end;return table.concat(L),nil,self.code end;function C.compile(D,M)M=M or{}local N=M.chunk_name or'TMP'local O=M.escape or'#'local s=M.inline_escape or'$'local P=M.inline_brackets or'()'local Q,B=r(D,s,P,O,M.newline)local E={__tostring=tostring}local R,G=a.load(Q,N,'t',E)if not R then return nil,G,Q end;if B then local S=R()return{fn=R(),env=E,render=function(self)return S,nil,self.code end,code=M.debug and Q or nil}end;return{fn=R(),env=E,render=H,code=M.debug and Q or nil}end;return C

6
extern/lualibs/pl/test.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/test.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.tablex'local b=require'pl.utils'local c=require'pl.pretty'local d=require'pl.path'local type,e,f=type,b.unpack,b.pack;local g=os.clock;local h=require'debug'local io=io;local function i(j)if type(j)=='table'and not(getmetatable(j)and getmetatable(j).__tostring)then return c.write(j,' ',true)elseif type(j)=='string'then return'"'..j..'"'else return tostring(j)end end;local k={}function k.error_handler(l,m,n,o,p)local q=io.stderr;q:write(d.basename(l)..':'..m..': assertion failed\n')q:write("got:\t",n,'\n')q:write("needed:\t",o,'\n')b.quit(1,p or"these values were not equal")end;local function r(j,s,p,t)local u=h.getinfo(3+(t or 0))k.error_handler(u.short_src,u.currentline,i(j),i(s),p)end;k.complain=r;function k.asserteq(j,s,v,t)local w=j==s;if not w then w=a.deepcompare(j,s,true,v)end;if not w then r(j,s,nil,t)end end;function k.assertmatch(x,y,t)if not x:match(y)then r(x,y,"these strings did not match",t)end end;function k.assertraise(z,A,t)local B,q;if type(z)=='table'then B,q=pcall(e(z))else B,q=pcall(z)end;if B or q:match(A)==nil then r(q,A,"these errors did not match",t)end end;function k.asserteq2(C,D,E,F,t)if C~=E then r(C,E,nil,t)end;if D~=F then r(D,F,nil,t)end end;local G={unpack=e}G.__index=G;function G.__tostring(self)local H={}for u=1,self.n do local I=self[u]H[u]=type(I)=='string'and('%q'):format(I)or tostring(I)end;return'tuple('..table.concat(H,', ')..')'end;function G.__eq(J,K)if J.n~=K.n then return false end;for u=1,J.n do if J[u]~=K[u]then return false end end;return true end;function G.__len(self)return self.n end;function k.tuple(...)return setmetatable(f(...),G)end;function k.timer(p,L,M,...)local N=g()for u=1,L do M(...)end;b.printf("%s: took %7.2f sec\n",p,g()-N)end;return k

6
extern/lualibs/pl/text.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/text.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=string.gsub;local b,c=table.concat,table.insert;local d=require'pl.utils'local e,f,g=d.bind1,d.split,d.assert_arg;local h=require'pl.types'.is_callable;local i=d.unpack;local j={}local function k(l)return setmetatable(l,require('pl.List'))end;local function m(n)return n:gsub('^%s+','')end;local function o(n)return m(n):gsub('%s+$','')end;local function p(q,r)return k(f(q,r))end;local function s(t,u,...)local v={}for w=1,#u do v[w]=t(u[w],...)end;return v end;local function x(q,y)local z=p(q,'\n')return b(s(e('..',y),z),'\n')..'\n'end;function j.indent(q,A,B)g(1,q,'string')g(2,A,'number')return x(q,string.rep(B or' ',A))end;function j.dedent(q)g(1,q,'string')local z=p(q,'\n')local C,D=(#z>0 and z[1]or''):find('^%s*')z=s(string.sub,z,D+1)return b(z,'\n')..'\n'end;function j.wrap(q,E)g(1,q,'string')E=E or 70;q=q:gsub('\n',' ')local w,F=1;local G,H={}while w<#q do F=w+E;if q:find("[%w']",F)then F=q:find('%W',F+1)end;H=q:sub(w,F)w=w+#H;c(G,o(H))end;return k(G)end;function j.fill(q,E)return b(j.wrap(q,E),'\n')..'\n'end;local I={}j.Template=I;I.__index=I;setmetatable(I,{__call=function(J,K)return I.new(K)end})function I.new(K)g(1,K,'string')local v={}v.tmpl=K;setmetatable(v,I)return v end;local function L(q,M,N)local O;if h(M)then O=M else function O(t)local q=M[t]if not q then if N then return t else error("not present in table "..t)end else return q end end end;local v=a(q,'%${([%w_]+)}',O)return a(v,'%$([%w_]+)',O)end;function I:substitute(M)g(1,M,'table')return L(self.tmpl,M,false)end;function I:safe_substitute(M)g(1,M,'table')return L(self.tmpl,M,true)end;function I:indent_substitute(M)g(1,M,'table')if not self.strings then self.strings=p(self.tmpl,'\n')end;local function O(H)return H:gsub('(%s*)%$([%w_]+)',function(y,t)local P;local q=M[t]if not q then error("not present in table "..t)end;if getmetatable(q)==I then P=q;q=q.tmpl else q=tostring(q)end;if q:find'\n'then q=x(q,y)end;if P then return L(q,M)else return q end end)end;local G=s(O,self.strings)return b(G,'\n')..'\n'end;function j.format_operator()local Q=string.format;local function R(S,...)local T={...}local w=1;for U in S:gmatch('%%.')do if U=='%s'and type(T[w])~='string'then T[w]=tostring(T[w])end;w=w+1 end;return Q(S,i(T))end;local function V(q,u)return q:gsub('%$([%w_]+)',u)end;getmetatable("").__mod=function(W,X)if X==nil then return W elseif type(X)=="table"and getmetatable(X)==nil then if#X==0 then return L(W,X,true)else return R(W,i(X))end elseif type(X)=='function'then return V(W,X)else return R(W,X)end end end;return j

6
extern/lualibs/pl/types.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/types.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require'pl.utils'local b=math.ceil;local c=a.assert_arg;local d={}function d.is_callable(e)return type(e)=='function'or getmetatable(e)and getmetatable(e).__call and true end;d.is_type=a.is_type;local f=getmetatable(io.stdout)function d.type(e)local g=type(e)if g=='table'or g=='userdata'then local h=getmetatable(e)if h==f then return'file'elseif h==nil then return g else return h._name or"unknown "..g end else return g end end;function d.is_integer(i)return b(i)==i end;function d.is_empty(j,k)if j==nil then return true elseif type(j)=="table"then return next(j)==nil elseif type(j)=="string"then return j==""or not not k and not not j:find("^%s+$")else return true end end;local function l(m)if type(m)=='table'then return true end;return getmetatable(m)end;function d.is_indexable(m)local h=l(m)if h==true then return true end;return h and h.__len and h.__index and true end;function d.is_iterable(m)local h=l(m)if h==true then return true end;return h and h.__pairs and true end;function d.is_writeable(m)local h=l(m)if h==true then return true end;return h and h.__newindex and true end;local n={yes=true,y=true,["true"]=true,t=true,["1"]=true}local o={boolean=function(j,p,q)return j end,string=function(j,p,q)j=j:lower()if n[j]then return true end;for r,s in ipairs(p or{})do if type(s)=="string"and j==s:lower()then return true end end;return false end,number=function(j,p,q)return j~=0 end,table=function(j,p,q)if q and next(j)~=nil then return true end;return false end}function d.to_bool(j,p,q)local t;if p then c(2,p,"table")end;t=o[type(j)]if t then return t(j,p,q)elseif q and j~=nil then return true end;return false end;return d

6
extern/lualibs/pl/url.lua vendored Normal file
View File

@ -0,0 +1,6 @@
-- Penlight 1.11.0-1 | /lua/pl/url.lua | https://github.com/lunarmodules/Penlight | License: MIT | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (C) 2009-2016 Steve Donovan, David Manura.
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a={}local function b(c)return string.format("%%%02X",string.byte(c))end;function a.quote(d,e)if type(d)~="string"then return d end;d=d:gsub("\n","\r\n")d=d:gsub("([^A-Za-z0-9 %-_%./])",b)if e then d=d:gsub(" ","+")d=d:gsub("/",b)else d=d:gsub(" ","%%20")end;return d end;local function f(g)return string.char(tonumber(g,16))end;function a.unquote(d)if type(d)~="string"then return d end;d=d:gsub("+"," ")d=d:gsub("%%(%x%x)",f)d=d:gsub("\r\n","\n")return d end;return a

6
extern/lualibs/pl/utils.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/pl/xml.lua vendored Normal file

File diff suppressed because one or more lines are too long

6
extern/lualibs/serpent.lua vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,41 @@
-- Default core script
-- Runs all input modifiers and generation modifiers in forward order, and
-- runs all output modifiers in reverse order
kobold, koboldcore = require("bridge")() -- This line is optional and is only for EmmyLua type annotations
---@class KoboldCoreScript
local corescript = {}
-- Run all the input modifiers from top to bottom
function corescript.inmod()
for i, userscript in ipairs(koboldcore.userscripts) do
if userscript.inmod ~= nil then
userscript.inmod()
end
end
end
-- Run all the generation modifiers from top to bottom
function corescript.genmod()
for i, userscript in ipairs(koboldcore.userscripts) do
if userscript.genmod ~= nil then
userscript.genmod()
end
end
end
-- Run all the generation modifiers from bottom to top
function corescript.outmod()
local userscript
for i = #koboldcore.userscripts, 1, -1 do
userscript = koboldcore.userscripts[i]
if userscript.outmod ~= nil then
userscript.outmod()
end
end
end
return corescript