@axpecter/lync 2.3.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +302 -299
- package/Types.luau +215 -0
- package/api/Define.luau +154 -0
- package/api/Lifecycle.luau +119 -0
- package/api/Packet.luau +108 -0
- package/api/Query.luau +149 -0
- package/api/Set.luau +189 -0
- package/channel/Blocks.luau +124 -0
- package/channel/Group.luau +118 -0
- package/channel/Link.luau +135 -0
- package/channel/Outbox.luau +261 -0
- package/channel/Recipients.luau +129 -0
- package/channel/Transport.luau +138 -0
- package/codec/Base.luau +236 -0
- package/codec/Composites.luau +128 -0
- package/codec/Datatypes.luau +162 -0
- package/codec/Legality.luau +61 -0
- package/codec/Scalars.luau +72 -0
- package/codec/Text.luau +89 -0
- package/codec/init.luau +39 -0
- package/index.d.ts +285 -0
- package/init.luau +91 -0
- package/kernel/Bits.luau +16 -0
- package/kernel/Catalog.luau +121 -0
- package/kernel/Heap.luau +80 -0
- package/kernel/Listeners.luau +95 -0
- package/kernel/Log.luau +197 -0
- package/kernel/Tally.luau +128 -0
- package/kernel/Threads.luau +44 -0
- package/kernel/Wide.luau +267 -0
- package/package.json +15 -32
- package/runtime/Boundary.luau +180 -0
- package/runtime/Dispatch.luau +91 -0
- package/runtime/Handles.luau +114 -0
- package/runtime/Handshake.luau +90 -0
- package/runtime/Pending.luau +196 -0
- package/runtime/Router.luau +379 -0
- package/runtime/Session.luau +731 -0
- package/shape/Compile.luau +340 -0
- package/shape/Folds.luau +332 -0
- package/shape/Frames.luau +170 -0
- package/shape/Grid.luau +169 -0
- package/shape/Ir.luau +540 -0
- package/shape/Joins.luau +125 -0
- package/shape/Legality.luau +273 -0
- package/shape/Lower.luau +419 -0
- package/shape/Order.luau +64 -0
- package/shape/Regions.luau +113 -0
- package/shape/Rotation.luau +472 -0
- package/shape/Serial.luau +258 -0
- package/shape/Words.luau +89 -0
- package/shape/emit/Block.luau +453 -0
- package/shape/emit/Column.luau +338 -0
- package/shape/emit/Leaf.luau +462 -0
- package/shape/emit/Word.luau +234 -0
- package/shape/emit/init.luau +222 -0
- package/shape/init.luau +78 -0
- package/state/Apply.luau +330 -0
- package/state/Audience.luau +126 -0
- package/state/Catchup.luau +218 -0
- package/state/Coalesce.luau +43 -0
- package/state/Fieldset.luau +177 -0
- package/state/Newest.luau +339 -0
- package/state/Plan.luau +441 -0
- package/state/Sections.luau +468 -0
- package/state/Store.luau +188 -0
- package/state/Sync.luau +762 -0
- package/wire/Bytes.luau +118 -0
- package/wire/Clock.luau +37 -0
- package/wire/Protocol.luau +110 -0
- package/wire/Sequence.luau +40 -0
- package/wire/Varint.luau +124 -0
- package/src/Types.luau +0 -180
- package/src/api/Group.luau +0 -156
- package/src/api/Packet.luau +0 -317
- package/src/api/Query.luau +0 -338
- package/src/api/Scope.luau +0 -90
- package/src/api/Signal.luau +0 -193
- package/src/codec/Base.luau +0 -136
- package/src/codec/composite/Array.luau +0 -473
- package/src/codec/composite/Map.luau +0 -485
- package/src/codec/composite/Optional.luau +0 -54
- package/src/codec/composite/Shared.luau +0 -311
- package/src/codec/composite/Struct.luau +0 -494
- package/src/codec/composite/Tagged.luau +0 -103
- package/src/codec/composite/Tuple.luau +0 -143
- package/src/codec/datatype/Buffer.luau +0 -66
- package/src/codec/datatype/CFrame.luau +0 -109
- package/src/codec/datatype/Color.luau +0 -32
- package/src/codec/datatype/Instance.luau +0 -52
- package/src/codec/datatype/IntVector.luau +0 -39
- package/src/codec/datatype/NumberRange.luau +0 -39
- package/src/codec/datatype/Ray.luau +0 -36
- package/src/codec/datatype/Rect.luau +0 -31
- package/src/codec/datatype/Region.luau +0 -62
- package/src/codec/datatype/Sequence.luau +0 -184
- package/src/codec/datatype/String.luau +0 -94
- package/src/codec/datatype/UDim.luau +0 -46
- package/src/codec/datatype/Vector.luau +0 -130
- package/src/codec/meta/Auto.luau +0 -318
- package/src/codec/meta/Bitfield.luau +0 -160
- package/src/codec/meta/Custom.luau +0 -33
- package/src/codec/meta/DeltaScalar.luau +0 -390
- package/src/codec/meta/Enum.luau +0 -50
- package/src/codec/meta/Float.luau +0 -38
- package/src/codec/meta/Nothing.luau +0 -13
- package/src/codec/meta/Unknown.luau +0 -41
- package/src/codec/primitive/Bool.luau +0 -26
- package/src/codec/primitive/Float16.luau +0 -99
- package/src/codec/primitive/Int.luau +0 -59
- package/src/codec/primitive/Number.luau +0 -24
- package/src/codec/primitive/Signed.luau +0 -32
- package/src/codec/primitive/Varint.luau +0 -165
- package/src/codec/primitive/Zint.luau +0 -99
- package/src/index.d.ts +0 -423
- package/src/init.luau +0 -362
- package/src/internal/Baseline.luau +0 -57
- package/src/internal/Channel.luau +0 -484
- package/src/internal/Middleware.luau +0 -100
- package/src/internal/Pool.luau +0 -66
- package/src/internal/Registry.luau +0 -119
- package/src/internal/Transport.luau +0 -28
- package/src/transport/Bridge.luau +0 -110
- package/src/transport/Client.luau +0 -97
- package/src/transport/Gate.luau +0 -488
- package/src/transport/Reader.luau +0 -331
- package/src/transport/Server.luau +0 -233
- package/src/util/Array.luau +0 -18
- package/src/util/Buffer.luau +0 -90
- package/src/util/Constants.luau +0 -30
- package/src/util/Log.luau +0 -68
- package/src/util/Player.luau +0 -14
- package/src/util/Quantize.luau +0 -84
- package/src/util/Quat.luau +0 -124
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!native
|
|
3
|
-
-- Positional ordered codec. Like struct but indexed.
|
|
4
|
-
|
|
5
|
-
local Base = require(script.Parent.Parent.Base)
|
|
6
|
-
local Log = require(script.Parent.Parent.Parent.util.Log)
|
|
7
|
-
local Shared = require(script.Parent.Parent.composite.Shared)
|
|
8
|
-
local Types = require(script.Parent.Parent.Parent.Types)
|
|
9
|
-
|
|
10
|
-
-- Private ----------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
local alloc = Base.alloc
|
|
13
|
-
|
|
14
|
-
-- Public -----------------------------------------------------------------
|
|
15
|
-
|
|
16
|
-
local Tuple = {}
|
|
17
|
-
|
|
18
|
-
function Tuple.define(...: Types.InternalCodec<any>): Types.InternalCodec<any>
|
|
19
|
-
local codecs = { ... }
|
|
20
|
-
local count = #codecs
|
|
21
|
-
Log.assert(count > 0, "requires at least one codec")
|
|
22
|
-
|
|
23
|
-
-- Single pass: detect all-direct fast path + propagate _hasUnknown / _hasDelta.
|
|
24
|
-
local allDirect, totalSize, hasUnknown = true, 0, false
|
|
25
|
-
local hasDelta = false
|
|
26
|
-
for i = 1, count do
|
|
27
|
-
local c = codecs[i]
|
|
28
|
-
if c._hasUnknown then
|
|
29
|
-
hasUnknown = true
|
|
30
|
-
end
|
|
31
|
-
if Shared.containsDelta(c) then
|
|
32
|
-
hasDelta = true
|
|
33
|
-
end
|
|
34
|
-
if allDirect then
|
|
35
|
-
if c._size and c._directWrite and c._directRead then
|
|
36
|
-
totalSize += c._size
|
|
37
|
-
else
|
|
38
|
-
allDirect = false
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
table.freeze(codecs)
|
|
43
|
-
|
|
44
|
-
-- All-direct: pre-compute offsets so write/read avoids the cursor dance per element.
|
|
45
|
-
if allDirect then
|
|
46
|
-
local offsets = table.create(count)
|
|
47
|
-
local directWrites = table.create(count)
|
|
48
|
-
local directReads = table.create(count)
|
|
49
|
-
local runningOffset = 0
|
|
50
|
-
|
|
51
|
-
for i = 1, count do
|
|
52
|
-
local c = codecs[i]
|
|
53
|
-
offsets[i] = runningOffset
|
|
54
|
-
directWrites[i] = c._directWrite
|
|
55
|
-
directReads[i] = c._directRead
|
|
56
|
-
runningOffset += c._size :: number
|
|
57
|
-
end
|
|
58
|
-
table.freeze(offsets)
|
|
59
|
-
table.freeze(directWrites)
|
|
60
|
-
table.freeze(directReads)
|
|
61
|
-
|
|
62
|
-
local codec: Types.InternalCodec<any> = {
|
|
63
|
-
_size = totalSize,
|
|
64
|
-
_isTuple = true,
|
|
65
|
-
_elements = codecs,
|
|
66
|
-
|
|
67
|
-
_directWrite = function(b: buffer, off: number, value: any): ()
|
|
68
|
-
for i = 1, count do
|
|
69
|
-
directWrites[i](b, off + offsets[i], value[i])
|
|
70
|
-
end
|
|
71
|
-
end,
|
|
72
|
-
|
|
73
|
-
_directRead = function(b: buffer, off: number): any
|
|
74
|
-
local result = table.create(count)
|
|
75
|
-
for i = 1, count do
|
|
76
|
-
result[i] = directReads[i](b, off + offsets[i])
|
|
77
|
-
end
|
|
78
|
-
return result
|
|
79
|
-
end,
|
|
80
|
-
|
|
81
|
-
write = function(ch: Types.ChannelState, value: any): ()
|
|
82
|
-
local cursor = ch.cursor
|
|
83
|
-
if cursor + totalSize > ch.size then
|
|
84
|
-
alloc(ch, totalSize)
|
|
85
|
-
end
|
|
86
|
-
local b = ch.buff
|
|
87
|
-
for i = 1, count do
|
|
88
|
-
directWrites[i](b, cursor + offsets[i], value[i])
|
|
89
|
-
end
|
|
90
|
-
ch.cursor = cursor + totalSize
|
|
91
|
-
end,
|
|
92
|
-
|
|
93
|
-
read = function(src: buffer, pos: number, _refs: { Instance }?): (any, number)
|
|
94
|
-
local result = table.create(count)
|
|
95
|
-
for i = 1, count do
|
|
96
|
-
result[i] = directReads[i](src, pos + offsets[i])
|
|
97
|
-
end
|
|
98
|
-
return result, totalSize
|
|
99
|
-
end,
|
|
100
|
-
}
|
|
101
|
-
if hasUnknown then
|
|
102
|
-
codec._hasUnknown = true
|
|
103
|
-
end
|
|
104
|
-
if hasDelta then
|
|
105
|
-
codec._hasDelta = true
|
|
106
|
-
end
|
|
107
|
-
return table.freeze(codec)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
local codec: Types.InternalCodec<any> = {
|
|
111
|
-
_isTuple = true,
|
|
112
|
-
_elements = codecs,
|
|
113
|
-
|
|
114
|
-
write = function(ch: Types.ChannelState, value: any): ()
|
|
115
|
-
for i = 1, count do
|
|
116
|
-
codecs[i].write(ch, value[i])
|
|
117
|
-
end
|
|
118
|
-
end,
|
|
119
|
-
|
|
120
|
-
read = function(src: buffer, pos: number, refs: { Instance }?): (any, number)
|
|
121
|
-
local result = table.create(count)
|
|
122
|
-
local total = 0
|
|
123
|
-
for i = 1, count do
|
|
124
|
-
local v, consumed = codecs[i].read(src, pos + total, refs)
|
|
125
|
-
if consumed == 0 then
|
|
126
|
-
Log.error(`element codec consumed 0 bytes at index {i}`)
|
|
127
|
-
end
|
|
128
|
-
result[i] = v
|
|
129
|
-
total += consumed
|
|
130
|
-
end
|
|
131
|
-
return result, total
|
|
132
|
-
end,
|
|
133
|
-
}
|
|
134
|
-
if hasUnknown then
|
|
135
|
-
codec._hasUnknown = true
|
|
136
|
-
end
|
|
137
|
-
if hasDelta then
|
|
138
|
-
codec._hasDelta = true
|
|
139
|
-
end
|
|
140
|
-
return table.freeze(codec)
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
return table.freeze(Tuple)
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!native
|
|
3
|
-
-- Raw buffer codec with dense-prefix-varint length prefix.
|
|
4
|
-
|
|
5
|
-
local Base = require(script.Parent.Parent.Base)
|
|
6
|
-
local Log = require(script.Parent.Parent.Parent.util.Log)
|
|
7
|
-
local Types = require(script.Parent.Parent.Parent.Types)
|
|
8
|
-
local Varint = require(script.Parent.Parent.primitive.Varint)
|
|
9
|
-
|
|
10
|
-
-- Private ----------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
local alloc = Base.alloc
|
|
13
|
-
local INLINE_MAX = Varint.INLINE_MAX
|
|
14
|
-
|
|
15
|
-
local function writeBuffer(ch: Types.ChannelState, value: buffer): ()
|
|
16
|
-
local len = buffer.len(value)
|
|
17
|
-
local cursor = ch.cursor
|
|
18
|
-
|
|
19
|
-
-- Single-byte length fast path skips the full varint encode.
|
|
20
|
-
if len <= INLINE_MAX then
|
|
21
|
-
if cursor + 1 + len > ch.size then
|
|
22
|
-
alloc(ch, 1 + len)
|
|
23
|
-
end
|
|
24
|
-
local b = ch.buff
|
|
25
|
-
buffer.writeu8(b, cursor, len)
|
|
26
|
-
buffer.copy(b, cursor + 1, value, 0, len)
|
|
27
|
-
ch.cursor = cursor + 1 + len
|
|
28
|
-
return
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
Varint.write(ch, len)
|
|
32
|
-
cursor = ch.cursor
|
|
33
|
-
if cursor + len > ch.size then
|
|
34
|
-
alloc(ch, len)
|
|
35
|
-
end
|
|
36
|
-
buffer.copy(ch.buff, cursor, value, 0, len)
|
|
37
|
-
ch.cursor = cursor + len
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
local function readBuffer(src: buffer, pos: number, _refs: { Instance }?): (buffer, number)
|
|
41
|
-
local len, lenBytes = Varint.readLengthPrefix(src, pos)
|
|
42
|
-
if len == 0 then
|
|
43
|
-
return buffer.create(0), lenBytes
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
local dataStart = pos + lenBytes
|
|
47
|
-
if dataStart + len > buffer.len(src) then
|
|
48
|
-
Log.error(`length {len}B exceeds remaining buffer`)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
local out = buffer.create(len)
|
|
52
|
-
buffer.copy(out, 0, src, dataStart, len)
|
|
53
|
-
return out, lenBytes + len
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
-- Public -----------------------------------------------------------------
|
|
57
|
-
|
|
58
|
-
local BufferCodec = {}
|
|
59
|
-
|
|
60
|
-
BufferCodec.buff = table.freeze({
|
|
61
|
-
_typeCheck = "buffer",
|
|
62
|
-
write = writeBuffer,
|
|
63
|
-
read = readBuffer,
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
return table.freeze(BufferCodec)
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!native
|
|
3
|
-
-- CFrame codec. Default lossless (24B); __call yields smallest-three quat (16B).
|
|
4
|
-
|
|
5
|
-
local Base = require(script.Parent.Parent.Base)
|
|
6
|
-
local Quat = require(script.Parent.Parent.Parent.util.Quat)
|
|
7
|
-
local Types = require(script.Parent.Parent.Parent.Types)
|
|
8
|
-
|
|
9
|
-
-- Constants --------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
local EPSILON = 2.4e-7
|
|
12
|
-
local EPSILON_SQ = EPSILON * EPSILON
|
|
13
|
-
|
|
14
|
-
-- Private ----------------------------------------------------------------
|
|
15
|
-
|
|
16
|
-
local alloc = Base.alloc
|
|
17
|
-
local writef32 = buffer.writef32
|
|
18
|
-
local readf32 = buffer.readf32
|
|
19
|
-
local writeu32 = buffer.writeu32
|
|
20
|
-
local readu32 = buffer.readu32
|
|
21
|
-
local sqrt = math.sqrt
|
|
22
|
-
local quatPack = Quat.pack
|
|
23
|
-
local quatUnpack = Quat.unpack
|
|
24
|
-
local quatFromCFrame = Quat.fromCFrame
|
|
25
|
-
|
|
26
|
-
local function writeLossless(b: buffer, off: number, value: CFrame): ()
|
|
27
|
-
local pos = value.Position
|
|
28
|
-
writef32(b, off, pos.X)
|
|
29
|
-
writef32(b, off + 4, pos.Y)
|
|
30
|
-
writef32(b, off + 8, pos.Z)
|
|
31
|
-
|
|
32
|
-
local axis, angle = value:ToAxisAngle()
|
|
33
|
-
if angle < EPSILON then
|
|
34
|
-
writef32(b, off + 12, 0)
|
|
35
|
-
writef32(b, off + 16, 0)
|
|
36
|
-
writef32(b, off + 20, 0)
|
|
37
|
-
return
|
|
38
|
-
end
|
|
39
|
-
writef32(b, off + 12, axis.X * angle)
|
|
40
|
-
writef32(b, off + 16, axis.Y * angle)
|
|
41
|
-
writef32(b, off + 20, axis.Z * angle)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
local function readLossless(b: buffer, off: number): CFrame
|
|
45
|
-
local px = readf32(b, off)
|
|
46
|
-
local py = readf32(b, off + 4)
|
|
47
|
-
local pz = readf32(b, off + 8)
|
|
48
|
-
local rx = readf32(b, off + 12)
|
|
49
|
-
local ry = readf32(b, off + 16)
|
|
50
|
-
local rz = readf32(b, off + 20)
|
|
51
|
-
|
|
52
|
-
local sqLen = rx * rx + ry * ry + rz * rz
|
|
53
|
-
if sqLen < EPSILON_SQ then
|
|
54
|
-
return CFrame.new(px, py, pz)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
local angle = sqrt(sqLen)
|
|
58
|
-
local inv = 1 / angle
|
|
59
|
-
return CFrame.new(px, py, pz)
|
|
60
|
-
* CFrame.fromAxisAngle(Vector3.new(rx * inv, ry * inv, rz * inv), angle)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
--[[
|
|
64
|
-
Compressed wire (16B):
|
|
65
|
-
[0..11] position 3x f32
|
|
66
|
-
[12..15] packed [largest:2][a:10][b:10][c:10] (smallest-three quat)
|
|
67
|
-
]]
|
|
68
|
-
local function writeCompressed(b: buffer, off: number, value: CFrame): ()
|
|
69
|
-
local pos = value.Position
|
|
70
|
-
writef32(b, off, pos.X)
|
|
71
|
-
writef32(b, off + 4, pos.Y)
|
|
72
|
-
writef32(b, off + 8, pos.Z)
|
|
73
|
-
writeu32(b, off + 12, quatPack(quatFromCFrame(value)))
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
local function readCompressed(b: buffer, off: number): CFrame
|
|
77
|
-
local px = readf32(b, off)
|
|
78
|
-
local py = readf32(b, off + 4)
|
|
79
|
-
local pz = readf32(b, off + 8)
|
|
80
|
-
return CFrame.new(px, py, pz) * quatUnpack(readu32(b, off + 12))
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
local function compressedFactory(_self): Types.InternalCodec<CFrame>
|
|
84
|
-
return Base.define(16, writeCompressed, readCompressed, { _typeCheck = "CFrame" })
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
-- Public -----------------------------------------------------------------
|
|
88
|
-
|
|
89
|
-
local CFrameCodec = {}
|
|
90
|
-
|
|
91
|
-
CFrameCodec.cframe = table.freeze(setmetatable({
|
|
92
|
-
_size = 24,
|
|
93
|
-
_directWrite = writeLossless,
|
|
94
|
-
_directRead = readLossless,
|
|
95
|
-
_typeCheck = "CFrame",
|
|
96
|
-
write = function(ch: Types.ChannelState, value: CFrame): ()
|
|
97
|
-
local cursor = ch.cursor
|
|
98
|
-
if cursor + 24 > ch.size then
|
|
99
|
-
alloc(ch, 24)
|
|
100
|
-
end
|
|
101
|
-
writeLossless(ch.buff, cursor, value)
|
|
102
|
-
ch.cursor = cursor + 24
|
|
103
|
-
end,
|
|
104
|
-
read = function(src: buffer, pos: number, _refs: { Instance }?): (CFrame, number)
|
|
105
|
-
return readLossless(src, pos), 24
|
|
106
|
-
end,
|
|
107
|
-
}, table.freeze({ __call = compressedFactory })))
|
|
108
|
-
|
|
109
|
-
return table.freeze(CFrameCodec)
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!native
|
|
3
|
-
-- Color3 codec. 3 bytes (R/G/B u8 per channel), clamped to [0, 1].
|
|
4
|
-
|
|
5
|
-
local Base = require(script.Parent.Parent.Base)
|
|
6
|
-
local Constants = require(script.Parent.Parent.Parent.util.Constants)
|
|
7
|
-
|
|
8
|
-
-- Private ----------------------------------------------------------------
|
|
9
|
-
|
|
10
|
-
local U8_MAX = Constants.U8_MAX
|
|
11
|
-
local writeu8 = buffer.writeu8
|
|
12
|
-
local readu8 = buffer.readu8
|
|
13
|
-
local round = math.round
|
|
14
|
-
local clamp = math.clamp
|
|
15
|
-
|
|
16
|
-
local function writeColor3(b: buffer, off: number, value: Color3): ()
|
|
17
|
-
writeu8(b, off, round(clamp(value.R, 0, 1) * U8_MAX))
|
|
18
|
-
writeu8(b, off + 1, round(clamp(value.G, 0, 1) * U8_MAX))
|
|
19
|
-
writeu8(b, off + 2, round(clamp(value.B, 0, 1) * U8_MAX))
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
local function readColor3(b: buffer, off: number): Color3
|
|
23
|
-
return Color3.fromRGB(readu8(b, off), readu8(b, off + 1), readu8(b, off + 2))
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
-- Public -----------------------------------------------------------------
|
|
27
|
-
|
|
28
|
-
local Color = {}
|
|
29
|
-
|
|
30
|
-
Color.color3 = Base.define(3, writeColor3, readColor3, { _typeCheck = "Color3" })
|
|
31
|
-
|
|
32
|
-
return table.freeze(Color)
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!native
|
|
3
|
-
-- Instance codec via the channel's sidecar reference array.
|
|
4
|
-
|
|
5
|
-
local Channel = require(script.Parent.Parent.Parent.internal.Channel)
|
|
6
|
-
local Log = require(script.Parent.Parent.Parent.util.Log)
|
|
7
|
-
local Types = require(script.Parent.Parent.Parent.Types)
|
|
8
|
-
|
|
9
|
-
-- Private ----------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
local pushRef = Channel.pushRef
|
|
12
|
-
local readu16 = buffer.readu16
|
|
13
|
-
|
|
14
|
-
local function writeInstance(ch: Types.ChannelState, value: Instance): ()
|
|
15
|
-
pushRef(ch, value)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
local function readInstance(src: buffer, pos: number, refs: { Instance }?): (Instance, number)
|
|
19
|
-
local r = refs
|
|
20
|
-
if not r then
|
|
21
|
-
Log.error("refs array is required")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
local idx = readu16(src, pos)
|
|
25
|
-
if idx < 1 or idx > #r then
|
|
26
|
-
Log.error(`ref index {idx} out of bounds`)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
--[[
|
|
30
|
-
Crafted clients can name a slot we never wrote; reject non-Instances.
|
|
31
|
-
Unknown codec skips this since it can legitimately hold any sidecar value.
|
|
32
|
-
]]
|
|
33
|
-
local inst = r[idx]
|
|
34
|
-
if typeof(inst) ~= "Instance" then
|
|
35
|
-
Log.error("ref is not an Instance")
|
|
36
|
-
end
|
|
37
|
-
return inst, 2
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
-- Public -----------------------------------------------------------------
|
|
41
|
-
|
|
42
|
-
local InstanceCodec = {}
|
|
43
|
-
|
|
44
|
-
-- No _directWrite/_directRead: write needs ch.refs (no fast path).
|
|
45
|
-
InstanceCodec.inst = table.freeze({
|
|
46
|
-
_size = 2,
|
|
47
|
-
_typeCheck = "Instance",
|
|
48
|
-
write = writeInstance,
|
|
49
|
-
read = readInstance,
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
return table.freeze(InstanceCodec)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!native
|
|
3
|
-
-- Vector2int16 (4B) and Vector3int16 (6B) codecs.
|
|
4
|
-
|
|
5
|
-
local Base = require(script.Parent.Parent.Base)
|
|
6
|
-
local Signed = require(script.Parent.Parent.primitive.Signed)
|
|
7
|
-
|
|
8
|
-
-- Private ----------------------------------------------------------------
|
|
9
|
-
|
|
10
|
-
local writeI16 = Signed.writeI16
|
|
11
|
-
local readi16 = buffer.readi16
|
|
12
|
-
|
|
13
|
-
local function writeVec2I16(b: buffer, off: number, value: Vector2int16): ()
|
|
14
|
-
writeI16(b, off, value.X)
|
|
15
|
-
writeI16(b, off + 2, value.Y)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
local function readVec2I16(b: buffer, off: number): Vector2int16
|
|
19
|
-
return Vector2int16.new(readi16(b, off), readi16(b, off + 2))
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
local function writeVec3I16(b: buffer, off: number, value: Vector3int16): ()
|
|
23
|
-
writeI16(b, off, value.X)
|
|
24
|
-
writeI16(b, off + 2, value.Y)
|
|
25
|
-
writeI16(b, off + 4, value.Z)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
local function readVec3I16(b: buffer, off: number): Vector3int16
|
|
29
|
-
return Vector3int16.new(readi16(b, off), readi16(b, off + 2), readi16(b, off + 4))
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
-- Public -----------------------------------------------------------------
|
|
33
|
-
|
|
34
|
-
local IntVector = {}
|
|
35
|
-
|
|
36
|
-
IntVector.vec2int16 = Base.define(4, writeVec2I16, readVec2I16, { _typeCheck = "Vector2int16" })
|
|
37
|
-
IntVector.vec3int16 = Base.define(6, writeVec3I16, readVec3I16, { _typeCheck = "Vector3int16" })
|
|
38
|
-
|
|
39
|
-
return table.freeze(IntVector)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!native
|
|
3
|
-
-- NumberRange codec. 8B: Min f32 + Max f32.
|
|
4
|
-
|
|
5
|
-
local Base = require(script.Parent.Parent.Base)
|
|
6
|
-
local Log = require(script.Parent.Parent.Parent.util.Log)
|
|
7
|
-
|
|
8
|
-
-- Private ----------------------------------------------------------------
|
|
9
|
-
|
|
10
|
-
local writef32 = buffer.writef32
|
|
11
|
-
local readf32 = buffer.readf32
|
|
12
|
-
|
|
13
|
-
local function writeNumberRange(b: buffer, off: number, value: NumberRange): ()
|
|
14
|
-
writef32(b, off, value.Min)
|
|
15
|
-
writef32(b, off + 4, value.Max)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
--[[
|
|
19
|
-
Reject min > max instead of silently swapping. A swap masks a desync;
|
|
20
|
-
erroring aborts the frame so the transport can reset its baseline.
|
|
21
|
-
]]
|
|
22
|
-
local function readNumberRange(b: buffer, off: number): NumberRange
|
|
23
|
-
local minV = readf32(b, off)
|
|
24
|
-
local maxV = readf32(b, off + 4)
|
|
25
|
-
if minV > maxV then
|
|
26
|
-
Log.error(`min ({minV}) > max ({maxV})`)
|
|
27
|
-
end
|
|
28
|
-
return NumberRange.new(minV, maxV)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
-- Public -----------------------------------------------------------------
|
|
32
|
-
|
|
33
|
-
local NumberRangeCodec = {}
|
|
34
|
-
|
|
35
|
-
NumberRangeCodec.numberRange = Base.define(8, writeNumberRange, readNumberRange, {
|
|
36
|
-
_typeCheck = "NumberRange",
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
return table.freeze(NumberRangeCodec)
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!native
|
|
3
|
-
-- Ray codec. 24B: Origin (3x f32) + Direction (3x f32).
|
|
4
|
-
|
|
5
|
-
local Base = require(script.Parent.Parent.Base)
|
|
6
|
-
|
|
7
|
-
-- Private ----------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
local writef32 = buffer.writef32
|
|
10
|
-
local readf32 = buffer.readf32
|
|
11
|
-
|
|
12
|
-
local function writeRay(b: buffer, off: number, value: Ray): ()
|
|
13
|
-
local o = value.Origin
|
|
14
|
-
local d = value.Direction
|
|
15
|
-
writef32(b, off, o.X)
|
|
16
|
-
writef32(b, off + 4, o.Y)
|
|
17
|
-
writef32(b, off + 8, o.Z)
|
|
18
|
-
writef32(b, off + 12, d.X)
|
|
19
|
-
writef32(b, off + 16, d.Y)
|
|
20
|
-
writef32(b, off + 20, d.Z)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
local function readRay(b: buffer, off: number): Ray
|
|
24
|
-
return Ray.new(
|
|
25
|
-
Vector3.new(readf32(b, off), readf32(b, off + 4), readf32(b, off + 8)),
|
|
26
|
-
Vector3.new(readf32(b, off + 12), readf32(b, off + 16), readf32(b, off + 20))
|
|
27
|
-
)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
-- Public -----------------------------------------------------------------
|
|
31
|
-
|
|
32
|
-
local RayCodec = {}
|
|
33
|
-
|
|
34
|
-
RayCodec.ray = Base.define(24, writeRay, readRay, { _typeCheck = "Ray" })
|
|
35
|
-
|
|
36
|
-
return table.freeze(RayCodec)
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!native
|
|
3
|
-
-- Rect codec. 16B: 4x f32 (Min.X, Min.Y, Max.X, Max.Y).
|
|
4
|
-
|
|
5
|
-
local Base = require(script.Parent.Parent.Base)
|
|
6
|
-
|
|
7
|
-
-- Private ----------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
local writef32 = buffer.writef32
|
|
10
|
-
local readf32 = buffer.readf32
|
|
11
|
-
|
|
12
|
-
local function writeRect(b: buffer, off: number, value: Rect): ()
|
|
13
|
-
local minV = value.Min
|
|
14
|
-
local maxV = value.Max
|
|
15
|
-
writef32(b, off, minV.X)
|
|
16
|
-
writef32(b, off + 4, minV.Y)
|
|
17
|
-
writef32(b, off + 8, maxV.X)
|
|
18
|
-
writef32(b, off + 12, maxV.Y)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
local function readRect(b: buffer, off: number): Rect
|
|
22
|
-
return Rect.new(readf32(b, off), readf32(b, off + 4), readf32(b, off + 8), readf32(b, off + 12))
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
-- Public -----------------------------------------------------------------
|
|
26
|
-
|
|
27
|
-
local RectCodec = {}
|
|
28
|
-
|
|
29
|
-
RectCodec.rect = Base.define(16, writeRect, readRect, { _typeCheck = "Rect" })
|
|
30
|
-
|
|
31
|
-
return table.freeze(RectCodec)
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--!native
|
|
3
|
-
-- Region3 (24B) and Region3int16 (12B) codecs.
|
|
4
|
-
|
|
5
|
-
local Base = require(script.Parent.Parent.Base)
|
|
6
|
-
local Signed = require(script.Parent.Parent.primitive.Signed)
|
|
7
|
-
|
|
8
|
-
-- Private ----------------------------------------------------------------
|
|
9
|
-
|
|
10
|
-
local writef32 = buffer.writef32
|
|
11
|
-
local readf32 = buffer.readf32
|
|
12
|
-
local writeI16 = Signed.writeI16
|
|
13
|
-
local readi16 = buffer.readi16
|
|
14
|
-
|
|
15
|
-
-- Region3 has no Min/Max accessors; reconstruct from CFrame.Position +/- Size/2.
|
|
16
|
-
local function writeRegion3(b: buffer, off: number, value: Region3): ()
|
|
17
|
-
local pos = value.CFrame.Position
|
|
18
|
-
local half = value.Size * 0.5
|
|
19
|
-
local minV = pos - half
|
|
20
|
-
local maxV = pos + half
|
|
21
|
-
writef32(b, off, minV.X)
|
|
22
|
-
writef32(b, off + 4, minV.Y)
|
|
23
|
-
writef32(b, off + 8, minV.Z)
|
|
24
|
-
writef32(b, off + 12, maxV.X)
|
|
25
|
-
writef32(b, off + 16, maxV.Y)
|
|
26
|
-
writef32(b, off + 20, maxV.Z)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
local function readRegion3(b: buffer, off: number): Region3
|
|
30
|
-
return Region3.new(
|
|
31
|
-
Vector3.new(readf32(b, off), readf32(b, off + 4), readf32(b, off + 8)),
|
|
32
|
-
Vector3.new(readf32(b, off + 12), readf32(b, off + 16), readf32(b, off + 20))
|
|
33
|
-
)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
local function writeRegion3I16(b: buffer, off: number, value: Region3int16): ()
|
|
37
|
-
local minV = value.Min
|
|
38
|
-
local maxV = value.Max
|
|
39
|
-
writeI16(b, off, minV.X)
|
|
40
|
-
writeI16(b, off + 2, minV.Y)
|
|
41
|
-
writeI16(b, off + 4, minV.Z)
|
|
42
|
-
writeI16(b, off + 6, maxV.X)
|
|
43
|
-
writeI16(b, off + 8, maxV.Y)
|
|
44
|
-
writeI16(b, off + 10, maxV.Z)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
local function readRegion3I16(b: buffer, off: number): Region3int16
|
|
48
|
-
return Region3int16.new(
|
|
49
|
-
Vector3int16.new(readi16(b, off), readi16(b, off + 2), readi16(b, off + 4)),
|
|
50
|
-
Vector3int16.new(readi16(b, off + 6), readi16(b, off + 8), readi16(b, off + 10))
|
|
51
|
-
)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
-- Public -----------------------------------------------------------------
|
|
55
|
-
|
|
56
|
-
local Region = {}
|
|
57
|
-
|
|
58
|
-
Region.region3 = Base.define(24, writeRegion3, readRegion3, { _typeCheck = "Region3" })
|
|
59
|
-
Region.region3int16 =
|
|
60
|
-
Base.define(12, writeRegion3I16, readRegion3I16, { _typeCheck = "Region3int16" })
|
|
61
|
-
|
|
62
|
-
return table.freeze(Region)
|