Create Component Library (#43)

* Move src under playlet-lib

* Update configuration

* Update script

* Update script

* Working version

* Vs code config WIP

* Package lock sync

* Lint fix

* Fix images

* Reuse config files

* Kind of a working setup

* Lock node version

* Rename scripts to tools

* Fix build scripts, lib url system

* Lint fix

* rale

* Fix args and web server

* Load fallbacks and build script cleanups

* Remove unused method

* no message

* no message

* Remove generic message field

* Lint fix

* no message

* Use loading indicator on main app

* Add playlet lib version to settings

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
Brahim Hadricheandgithub-action linter authored and GitHub committed 2023-01-29 16:50:28 -05:00
1 parent 90df81df4b
commit 9d8a3d1cea
156 files changed
+3341 -213

No files matched your search

@@ -0,0 +1,105 @@
import "pkg:/components/WebServer/WebSocket/WebSocketOpCode.bs"
namespace Web
class WebSocketFrame
public fin
public opcode
public is_masked
public payload_size
public mask
public payload
private index
private length
function new()
m.payload = CreateObject("roByteArray")
end function
function ReadFromBuffer(buffer as object, index as integer, length as integer) as boolean
m.buffer = buffer
m.index = index
m.length = length
firstByte = m.ReadByte()
m.fin = (firstByte and &h80) <> 0
m.opcode = firstByte and &hf
if not m.fin
return false
end if
if m.opcode <> Web.WebSocketOpCode.TEXT
return false
end if
secondByte = m.ReadByte()
m.is_masked = (secondByte and &h80) <> 0
m.payload_size = secondByte and &h7F
if not m.is_masked
return false
end if
if m.payload_size >= 126
return false
end if
m.mask = [m.ReadByte(), m.ReadByte(), m.ReadByte(), m.ReadByte()]
m.payload.Clear()
for i = 0 to m.payload_size - 1
m.payload[i] = m.Xor(m.ReadByte(), m.mask[i mod 4])
end for
return true
end function
function WriteToBuffer(buffer as object, index as integer, length as integer) as integer
m.buffer = buffer
m.index = index
m.length = length
m.WriteByte(m.fin or m.opcode)
m.WriteByte(m.payload_size)
for i = 0 to m.payload_size - 1
m.buffer[m.index] = m.payload[i]
m.index++
end for
return m.index - index
end function
function GetPayloadText() as string
return m.payload.ToAsciiString()
end function
function SetPayloadText(text as string)
m.fin = &h80
m.opcode = Web.WebSocketOpCode.TEXT
m.is_masked = false
m.mask = invalid
m.payload.FromAsciiString(text)
m.payload_size = m.payload.Count()
end function
function ReadByte() as integer
byte = m.buffer[m.index]
m.index++
return byte
end function
function WriteByte(byte as integer) as integer
m.buffer[m.index] = byte
m.index++
return byte
end function
function Xor(a as integer, b as integer) as integer
return (a or b) and not (a and b)
end function
end class
end namespace