@axpecter/lync 1.4.0 → 1.4.1
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/README.md +24 -24
- package/package.json +1 -1
- package/src/Types.luau +13 -2
- package/src/api/Group.luau +3 -5
- package/src/api/Namespace.luau +6 -6
- package/src/api/Packet.luau +9 -8
- package/src/api/Query.luau +11 -9
- package/src/api/Scope.luau +2 -2
- package/src/api/Signal.luau +10 -4
- package/src/codec/Base.luau +7 -3
- package/src/codec/composite/Array.luau +18 -15
- package/src/codec/composite/Map.luau +45 -31
- package/src/codec/composite/Optional.luau +3 -2
- package/src/codec/composite/Shared.luau +7 -5
- package/src/codec/composite/Struct.luau +6 -4
- package/src/codec/composite/Tagged.luau +6 -6
- package/src/codec/composite/Tuple.luau +9 -7
- package/src/codec/datatype/Buffer.luau +3 -2
- package/src/codec/datatype/CFrame.luau +2 -1
- package/src/codec/datatype/Instance.luau +3 -2
- package/src/codec/datatype/Sequence.luau +3 -4
- package/src/codec/datatype/String.luau +3 -6
- package/src/codec/meta/Auto.luau +77 -72
- package/src/codec/meta/Bitfield.luau +5 -4
- package/src/codec/meta/Enum.luau +6 -5
- package/src/codec/meta/Quantized.luau +5 -4
- package/src/codec/meta/Unknown.luau +5 -1
- package/src/codec/primitive/Float16.luau +5 -4
- package/src/codec/primitive/Varint.luau +2 -2
- package/src/init.luau +39 -37
- package/src/internal/Baseline.luau +6 -2
- package/src/internal/Channel.luau +11 -6
- package/src/internal/Middleware.luau +13 -12
- package/src/internal/Pool.luau +5 -5
- package/src/internal/Registry.luau +4 -4
- package/src/transport/Bridge.luau +4 -3
- package/src/transport/Client.luau +4 -3
- package/src/transport/Gate.luau +5 -5
- package/src/transport/Reader.luau +3 -3
- package/src/transport/Server.luau +7 -8
package/src/codec/meta/Auto.luau
CHANGED
|
@@ -2,29 +2,32 @@
|
|
|
2
2
|
--!native
|
|
3
3
|
-- Auto (self-describing) codec. Writes a u8 type tag then the value.
|
|
4
4
|
|
|
5
|
-
local
|
|
5
|
+
local BoolCodec = require (script.Parent.Parent.primitive.Bool)
|
|
6
|
+
local BufferCodec = require (script.Parent.Parent.datatype.Buffer)
|
|
6
7
|
local CFrameCodec = require (script.Parent.Parent.datatype.CFrame)
|
|
7
8
|
local Channel = require (script.Parent.Parent.Parent.internal.Channel)
|
|
8
|
-
local
|
|
9
|
-
local
|
|
10
|
-
local
|
|
11
|
-
local IntVector = require (script.Parent.Parent.datatype.IntVector)
|
|
12
|
-
local Number = require (script.Parent.Parent.primitive.Number)
|
|
9
|
+
local ColorCodec = require (script.Parent.Parent.datatype.Color)
|
|
10
|
+
local IntVectorCodec = require (script.Parent.Parent.datatype.IntVector)
|
|
11
|
+
local NumberCodec = require (script.Parent.Parent.primitive.Number)
|
|
13
12
|
local NumberRangeCodec = require (script.Parent.Parent.datatype.NumberRange)
|
|
14
13
|
local RayCodec = require (script.Parent.Parent.datatype.Ray)
|
|
15
14
|
local RectCodec = require (script.Parent.Parent.datatype.Rect)
|
|
16
|
-
local
|
|
17
|
-
local
|
|
18
|
-
local
|
|
15
|
+
local RegionCodec = require (script.Parent.Parent.datatype.Region)
|
|
16
|
+
local SequenceCodec = require (script.Parent.Parent.datatype.Sequence)
|
|
17
|
+
local StringCodec = require (script.Parent.Parent.datatype.String)
|
|
19
18
|
local Types = require (script.Parent.Parent.Parent.Types)
|
|
20
19
|
local UDimCodec = require (script.Parent.Parent.datatype.UDim)
|
|
21
20
|
local Varint = require (script.Parent.Parent.primitive.Varint)
|
|
22
|
-
local
|
|
21
|
+
local VectorCodec = require (script.Parent.Parent.datatype.Vector)
|
|
23
22
|
|
|
24
23
|
type ChannelState = Types.ChannelState
|
|
25
24
|
type Codec<T> = Types.Codec<T>
|
|
25
|
+
type InternalCodec<T> = Types.InternalCodec<T>
|
|
26
|
+
|
|
27
|
+
local alloc = Channel.alloc
|
|
28
|
+
local floor = math.floor
|
|
26
29
|
|
|
27
|
-
-- Constants
|
|
30
|
+
-- Constants ----------------------------------------------------------
|
|
28
31
|
|
|
29
32
|
local TAG_NIL = 0
|
|
30
33
|
local TAG_BOOL = 1
|
|
@@ -54,128 +57,130 @@ local TAG_RAY = 24
|
|
|
54
57
|
local TAG_NUMBERSEQUENCE = 25
|
|
55
58
|
local TAG_COLORSEQUENCE = 26
|
|
56
59
|
|
|
57
|
-
local floor = math.floor
|
|
58
|
-
|
|
59
60
|
local READ_DISPATCH = table.freeze ({
|
|
60
61
|
[TAG_BOOL] = BoolCodec.bool,
|
|
61
|
-
[TAG_U8] =
|
|
62
|
-
[TAG_U16] =
|
|
63
|
-
[TAG_U32] =
|
|
64
|
-
[TAG_I8] =
|
|
65
|
-
[TAG_I16] =
|
|
66
|
-
[TAG_I32] =
|
|
67
|
-
[TAG_F32] =
|
|
68
|
-
[TAG_F64] =
|
|
69
|
-
[TAG_STRING] =
|
|
70
|
-
[TAG_VEC2] =
|
|
71
|
-
[TAG_VEC3] =
|
|
72
|
-
[TAG_COLOR3] =
|
|
62
|
+
[TAG_U8] = NumberCodec.u8,
|
|
63
|
+
[TAG_U16] = NumberCodec.u16,
|
|
64
|
+
[TAG_U32] = NumberCodec.u32,
|
|
65
|
+
[TAG_I8] = NumberCodec.i8,
|
|
66
|
+
[TAG_I16] = NumberCodec.i16,
|
|
67
|
+
[TAG_I32] = NumberCodec.i32,
|
|
68
|
+
[TAG_F32] = NumberCodec.f32,
|
|
69
|
+
[TAG_F64] = NumberCodec.f64,
|
|
70
|
+
[TAG_STRING] = StringCodec.string,
|
|
71
|
+
[TAG_VEC2] = VectorCodec.vec2,
|
|
72
|
+
[TAG_VEC3] = VectorCodec.vec3,
|
|
73
|
+
[TAG_COLOR3] = ColorCodec.color3,
|
|
73
74
|
[TAG_CFRAME] = CFrameCodec.cframe,
|
|
74
|
-
[TAG_BUFFER] =
|
|
75
|
+
[TAG_BUFFER] = BufferCodec.buff,
|
|
75
76
|
[TAG_UDIM] = UDimCodec.udim,
|
|
76
77
|
[TAG_UDIM2] = UDimCodec.udim2,
|
|
77
78
|
[TAG_NUMBERRANGE] = NumberRangeCodec.numberRange,
|
|
78
79
|
[TAG_RECT] = RectCodec.rect,
|
|
79
|
-
[TAG_VEC2INT16] =
|
|
80
|
-
[TAG_VEC3INT16] =
|
|
81
|
-
[TAG_REGION3] =
|
|
82
|
-
[TAG_REGION3INT16] =
|
|
80
|
+
[TAG_VEC2INT16] = IntVectorCodec.vec2int16,
|
|
81
|
+
[TAG_VEC3INT16] = IntVectorCodec.vec3int16,
|
|
82
|
+
[TAG_REGION3] = RegionCodec.region3,
|
|
83
|
+
[TAG_REGION3INT16] = RegionCodec.region3int16,
|
|
83
84
|
[TAG_RAY] = RayCodec.ray,
|
|
84
|
-
[TAG_NUMBERSEQUENCE] =
|
|
85
|
-
[TAG_COLORSEQUENCE] =
|
|
85
|
+
[TAG_NUMBERSEQUENCE] = SequenceCodec.numberSequence,
|
|
86
|
+
[TAG_COLORSEQUENCE] = SequenceCodec.colorSequence,
|
|
86
87
|
})
|
|
87
88
|
|
|
89
|
+
local function extractDw (codec: any): any
|
|
90
|
+
return (codec :: InternalCodec<any>)._directWrite
|
|
91
|
+
end
|
|
92
|
+
|
|
88
93
|
local TYPE_DISPATCH = table.freeze ({
|
|
89
94
|
boolean = { tag = TAG_BOOL, codec = BoolCodec.bool, size = 1, dw = nil },
|
|
90
|
-
string = { tag = TAG_STRING, codec =
|
|
95
|
+
string = { tag = TAG_STRING, codec = StringCodec.string, size = nil, dw = nil },
|
|
96
|
+
buffer = { tag = TAG_BUFFER, codec = BufferCodec.buff, size = nil, dw = nil },
|
|
91
97
|
Vector2 = {
|
|
92
98
|
tag = TAG_VEC2,
|
|
93
|
-
codec =
|
|
99
|
+
codec = VectorCodec.vec2,
|
|
94
100
|
size = 8,
|
|
95
|
-
dw = (
|
|
101
|
+
dw = extractDw (VectorCodec.vec2),
|
|
96
102
|
},
|
|
97
103
|
Vector3 = {
|
|
98
104
|
tag = TAG_VEC3,
|
|
99
|
-
codec =
|
|
105
|
+
codec = VectorCodec.vec3,
|
|
100
106
|
size = 12,
|
|
101
|
-
dw = (
|
|
107
|
+
dw = extractDw (VectorCodec.vec3),
|
|
102
108
|
},
|
|
103
109
|
Color3 = {
|
|
104
110
|
tag = TAG_COLOR3,
|
|
105
|
-
codec =
|
|
111
|
+
codec = ColorCodec.color3,
|
|
106
112
|
size = 3,
|
|
107
|
-
dw = (
|
|
113
|
+
dw = extractDw (ColorCodec.color3),
|
|
108
114
|
},
|
|
109
115
|
CFrame = {
|
|
110
116
|
tag = TAG_CFRAME,
|
|
111
117
|
codec = CFrameCodec.cframe,
|
|
112
118
|
size = 24,
|
|
113
|
-
dw = (CFrameCodec.cframe
|
|
119
|
+
dw = extractDw (CFrameCodec.cframe),
|
|
114
120
|
},
|
|
115
|
-
buffer = { tag = TAG_BUFFER, codec = Buffer.buff, size = nil, dw = nil },
|
|
116
121
|
UDim = {
|
|
117
122
|
tag = TAG_UDIM,
|
|
118
123
|
codec = UDimCodec.udim,
|
|
119
124
|
size = 8,
|
|
120
|
-
dw = (UDimCodec.udim
|
|
125
|
+
dw = extractDw (UDimCodec.udim),
|
|
121
126
|
},
|
|
122
127
|
UDim2 = {
|
|
123
128
|
tag = TAG_UDIM2,
|
|
124
129
|
codec = UDimCodec.udim2,
|
|
125
130
|
size = 16,
|
|
126
|
-
dw = (UDimCodec.udim2
|
|
131
|
+
dw = extractDw (UDimCodec.udim2),
|
|
127
132
|
},
|
|
128
133
|
NumberRange = {
|
|
129
134
|
tag = TAG_NUMBERRANGE,
|
|
130
135
|
codec = NumberRangeCodec.numberRange,
|
|
131
136
|
size = 8,
|
|
132
|
-
dw = (NumberRangeCodec.numberRange
|
|
137
|
+
dw = extractDw (NumberRangeCodec.numberRange),
|
|
133
138
|
},
|
|
134
139
|
Rect = {
|
|
135
140
|
tag = TAG_RECT,
|
|
136
141
|
codec = RectCodec.rect,
|
|
137
142
|
size = 16,
|
|
138
|
-
dw = (RectCodec.rect
|
|
143
|
+
dw = extractDw (RectCodec.rect),
|
|
139
144
|
},
|
|
140
145
|
Vector2int16 = {
|
|
141
146
|
tag = TAG_VEC2INT16,
|
|
142
|
-
codec =
|
|
147
|
+
codec = IntVectorCodec.vec2int16,
|
|
143
148
|
size = 4,
|
|
144
|
-
dw = (
|
|
149
|
+
dw = extractDw (IntVectorCodec.vec2int16),
|
|
145
150
|
},
|
|
146
151
|
Vector3int16 = {
|
|
147
152
|
tag = TAG_VEC3INT16,
|
|
148
|
-
codec =
|
|
153
|
+
codec = IntVectorCodec.vec3int16,
|
|
149
154
|
size = 6,
|
|
150
|
-
dw = (
|
|
155
|
+
dw = extractDw (IntVectorCodec.vec3int16),
|
|
151
156
|
},
|
|
152
157
|
Region3 = {
|
|
153
158
|
tag = TAG_REGION3,
|
|
154
|
-
codec =
|
|
159
|
+
codec = RegionCodec.region3,
|
|
155
160
|
size = 24,
|
|
156
|
-
dw = (
|
|
161
|
+
dw = extractDw (RegionCodec.region3),
|
|
157
162
|
},
|
|
158
163
|
Region3int16 = {
|
|
159
164
|
tag = TAG_REGION3INT16,
|
|
160
|
-
codec =
|
|
165
|
+
codec = RegionCodec.region3int16,
|
|
161
166
|
size = 12,
|
|
162
|
-
dw = (
|
|
167
|
+
dw = extractDw (RegionCodec.region3int16),
|
|
163
168
|
},
|
|
164
169
|
Ray = {
|
|
165
170
|
tag = TAG_RAY,
|
|
166
171
|
codec = RayCodec.ray,
|
|
167
172
|
size = 24,
|
|
168
|
-
dw = (RayCodec.ray
|
|
173
|
+
dw = extractDw (RayCodec.ray),
|
|
169
174
|
},
|
|
170
175
|
NumberSequence = {
|
|
171
176
|
tag = TAG_NUMBERSEQUENCE,
|
|
172
|
-
codec =
|
|
177
|
+
codec = SequenceCodec.numberSequence,
|
|
173
178
|
size = nil,
|
|
174
179
|
dw = nil,
|
|
175
180
|
},
|
|
176
181
|
ColorSequence = {
|
|
177
182
|
tag = TAG_COLORSEQUENCE,
|
|
178
|
-
codec =
|
|
183
|
+
codec = SequenceCodec.colorSequence,
|
|
179
184
|
size = nil,
|
|
180
185
|
dw = nil,
|
|
181
186
|
},
|
|
@@ -187,24 +192,24 @@ local NUM_DWRITES = {} :: { [number]: any }
|
|
|
187
192
|
|
|
188
193
|
for _, pair in
|
|
189
194
|
{
|
|
190
|
-
{ TAG_U8,
|
|
191
|
-
{ TAG_U16,
|
|
192
|
-
{ TAG_U32,
|
|
193
|
-
{ TAG_I8,
|
|
194
|
-
{ TAG_I16,
|
|
195
|
-
{ TAG_I32,
|
|
196
|
-
{ TAG_F32,
|
|
197
|
-
{ TAG_F64,
|
|
195
|
+
{ TAG_U8, NumberCodec.u8, 1 },
|
|
196
|
+
{ TAG_U16, NumberCodec.u16, 2 },
|
|
197
|
+
{ TAG_U32, NumberCodec.u32, 4 },
|
|
198
|
+
{ TAG_I8, NumberCodec.i8, 1 },
|
|
199
|
+
{ TAG_I16, NumberCodec.i16, 2 },
|
|
200
|
+
{ TAG_I32, NumberCodec.i32, 4 },
|
|
201
|
+
{ TAG_F32, NumberCodec.f32, 4 },
|
|
202
|
+
{ TAG_F64, NumberCodec.f64, 8 },
|
|
198
203
|
}
|
|
199
204
|
do
|
|
200
205
|
NUM_SIZES[pair[1]] = pair[3]
|
|
201
|
-
NUM_DWRITES[pair[1]] = (pair[2] ::
|
|
206
|
+
NUM_DWRITES[pair[1]] = (pair[2] :: InternalCodec<number>)._directWrite
|
|
202
207
|
end
|
|
203
208
|
|
|
204
209
|
table.freeze (NUM_SIZES)
|
|
205
210
|
table.freeze (NUM_DWRITES)
|
|
206
211
|
|
|
207
|
-
-- Private
|
|
212
|
+
-- Private ------------------------------------------------------------
|
|
208
213
|
|
|
209
214
|
local _f32Temp = buffer.create (4)
|
|
210
215
|
|
|
@@ -246,7 +251,7 @@ local function selectNumberTag (value: number): number
|
|
|
246
251
|
return TAG_F64
|
|
247
252
|
end
|
|
248
253
|
|
|
249
|
-
-- Public
|
|
254
|
+
-- Public -------------------------------------------------------------
|
|
250
255
|
|
|
251
256
|
local auto = table.freeze ({
|
|
252
257
|
write = function (ch: ChannelState, value: any): ()
|
|
@@ -312,17 +317,17 @@ local auto = table.freeze ({
|
|
|
312
317
|
error (`[Lync] Auto unsupported type: {valueType}`)
|
|
313
318
|
end
|
|
314
319
|
|
|
315
|
-
local
|
|
316
|
-
local
|
|
317
|
-
if
|
|
318
|
-
local totalSize = 1 +
|
|
320
|
+
local entryDw = entry.dw
|
|
321
|
+
local entrySize = entry.size
|
|
322
|
+
if entryDw and entrySize then
|
|
323
|
+
local totalSize = 1 + entrySize
|
|
319
324
|
local c = ch.cursor
|
|
320
325
|
if c + totalSize > ch.size then
|
|
321
326
|
alloc (ch, totalSize)
|
|
322
327
|
end
|
|
323
328
|
local b = ch.buff
|
|
324
329
|
buffer.writeu8 (b, c, entry.tag)
|
|
325
|
-
|
|
330
|
+
entryDw (b, c + 1, value)
|
|
326
331
|
ch.cursor = c + totalSize
|
|
327
332
|
else
|
|
328
333
|
local c = ch.cursor
|
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
-- Pack booleans, unsigned and signed integers at the bit level.
|
|
4
4
|
|
|
5
5
|
local Channel = require (script.Parent.Parent.Parent.internal.Channel)
|
|
6
|
-
local alloc = Channel.alloc
|
|
7
6
|
local Types = require (script.Parent.Parent.Parent.Types)
|
|
8
7
|
|
|
9
8
|
type ChannelState = Types.ChannelState
|
|
10
9
|
type Codec<T> = Types.Codec<T>
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
local alloc = Channel.alloc
|
|
12
|
+
|
|
13
|
+
-- Constants ----------------------------------------------------------
|
|
13
14
|
|
|
14
15
|
local band = bit32.band
|
|
15
16
|
local bor = bit32.bor
|
|
16
17
|
local lshift = bit32.lshift
|
|
17
18
|
local rshift = bit32.rshift
|
|
18
19
|
|
|
19
|
-
-- Private
|
|
20
|
+
-- Private ------------------------------------------------------------
|
|
20
21
|
|
|
21
22
|
type FieldSpec = {
|
|
22
23
|
type: "bool" | "uint" | "int",
|
|
@@ -36,7 +37,7 @@ local function selectIO (bytes: number): ((b: buffer, offset: number, v: number)
|
|
|
36
37
|
return buffer.writeu32, buffer.readu32
|
|
37
38
|
end
|
|
38
39
|
|
|
39
|
-
-- Public
|
|
40
|
+
-- Public -------------------------------------------------------------
|
|
40
41
|
|
|
41
42
|
local Bitfield = {}
|
|
42
43
|
|
package/src/codec/meta/Enum.luau
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
-- String enum codec. Maps values to u8 indices at definition time.
|
|
4
4
|
|
|
5
5
|
local Channel = require (script.Parent.Parent.Parent.internal.Channel)
|
|
6
|
-
local alloc = Channel.alloc
|
|
7
6
|
local Types = require (script.Parent.Parent.Parent.Types)
|
|
8
7
|
|
|
9
8
|
type ChannelState = Types.ChannelState
|
|
10
9
|
type Codec<T> = Types.Codec<T>
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
local alloc = Channel.alloc
|
|
12
|
+
|
|
13
|
+
-- Public -------------------------------------------------------------
|
|
13
14
|
|
|
14
15
|
local EnumCodec = {}
|
|
15
16
|
|
|
@@ -28,7 +29,7 @@ function EnumCodec.define (...: string): Codec<string>
|
|
|
28
29
|
|
|
29
30
|
for i, value in values do
|
|
30
31
|
if toIndex[value] ~= nil then
|
|
31
|
-
error (`[Lync] Duplicate enum value:
|
|
32
|
+
error (`[Lync] Duplicate enum value: "{value}"`)
|
|
32
33
|
end
|
|
33
34
|
toIndex[value] = i - 1
|
|
34
35
|
toValue[i] = value
|
|
@@ -42,7 +43,7 @@ function EnumCodec.define (...: string): Codec<string>
|
|
|
42
43
|
_directWrite = function (b: buffer, offset: number, value: string): ()
|
|
43
44
|
local idx = toIndex[value]
|
|
44
45
|
if idx == nil then
|
|
45
|
-
error (`[Lync] Invalid enum value:
|
|
46
|
+
error (`[Lync] Invalid enum value: "{value}"`)
|
|
46
47
|
end
|
|
47
48
|
buffer.writeu8 (b, offset, idx)
|
|
48
49
|
end,
|
|
@@ -57,7 +58,7 @@ function EnumCodec.define (...: string): Codec<string>
|
|
|
57
58
|
write = function (ch: ChannelState, value: string): ()
|
|
58
59
|
local idx = toIndex[value]
|
|
59
60
|
if idx == nil then
|
|
60
|
-
error (`[Lync] Invalid enum value:
|
|
61
|
+
error (`[Lync] Invalid enum value: "{value}"`)
|
|
61
62
|
end
|
|
62
63
|
local c = ch.cursor
|
|
63
64
|
if c + 1 > ch.size then
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
-- Fixed-point compression. Maps float ranges to integer ranges.
|
|
4
4
|
|
|
5
5
|
local Channel = require (script.Parent.Parent.Parent.internal.Channel)
|
|
6
|
-
local alloc = Channel.alloc
|
|
7
6
|
local Types = require (script.Parent.Parent.Parent.Types)
|
|
8
7
|
|
|
9
8
|
type ChannelState = Types.ChannelState
|
|
10
9
|
type Codec<T> = Types.Codec<T>
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
local alloc = Channel.alloc
|
|
12
|
+
|
|
13
|
+
-- Constants ----------------------------------------------------------
|
|
13
14
|
|
|
14
15
|
local clamp = math.clamp
|
|
15
16
|
local round = math.round
|
|
@@ -19,7 +20,7 @@ local max = math.max
|
|
|
19
20
|
|
|
20
21
|
local U32_MAX = 4294967295
|
|
21
22
|
|
|
22
|
-
-- Private
|
|
23
|
+
-- Private ------------------------------------------------------------
|
|
23
24
|
|
|
24
25
|
local function selectIO (bytes: number): ((b: buffer, offset: number, v: number) -> (), (
|
|
25
26
|
b: buffer,
|
|
@@ -44,7 +45,7 @@ local function selectWidth (maxInt: number): number
|
|
|
44
45
|
return 4
|
|
45
46
|
end
|
|
46
47
|
|
|
47
|
-
-- Public
|
|
48
|
+
-- Public -------------------------------------------------------------
|
|
48
49
|
|
|
49
50
|
local Quantized = {}
|
|
50
51
|
|
|
@@ -3,11 +3,15 @@
|
|
|
3
3
|
-- Sidecar codec. Bypasses buffer serialization, uses Roblox remote refs.
|
|
4
4
|
|
|
5
5
|
local Channel = require (script.Parent.Parent.Parent.internal.Channel)
|
|
6
|
+
local Types = require (script.Parent.Parent.Parent.Types)
|
|
7
|
+
|
|
8
|
+
type ChannelState = Types.ChannelState
|
|
9
|
+
|
|
6
10
|
local alloc = Channel.alloc
|
|
7
11
|
|
|
8
12
|
return table.freeze ({
|
|
9
13
|
unknown = table.freeze ({
|
|
10
|
-
write = function (ch:
|
|
14
|
+
write = function (ch: ChannelState, value: any): ()
|
|
11
15
|
local refs = ch.refs
|
|
12
16
|
local idx = #refs + 1
|
|
13
17
|
if idx > 65535 then
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
-- Half-precision float codec. 2 bytes, ±65504, ~3 decimal digits.
|
|
4
4
|
|
|
5
5
|
local Channel = require (script.Parent.Parent.Parent.internal.Channel)
|
|
6
|
-
local alloc = Channel.alloc
|
|
7
6
|
local Types = require (script.Parent.Parent.Parent.Types)
|
|
8
7
|
|
|
8
|
+
local alloc = Channel.alloc
|
|
9
|
+
|
|
9
10
|
type ChannelState = Types.ChannelState
|
|
10
11
|
|
|
11
|
-
-- Constants
|
|
12
|
+
-- Constants ----------------------------------------------------------
|
|
12
13
|
|
|
13
14
|
local MAX_HALF = 65504
|
|
14
15
|
local BIAS = 15
|
|
@@ -28,7 +29,7 @@ local ldexp = math.ldexp
|
|
|
28
29
|
local round = math.round
|
|
29
30
|
local huge = math.huge
|
|
30
31
|
|
|
31
|
-
-- Private
|
|
32
|
+
-- Private ------------------------------------------------------------
|
|
32
33
|
|
|
33
34
|
local function encode (value: number): number
|
|
34
35
|
if value ~= value then
|
|
@@ -83,7 +84,7 @@ local function decode (packed: number): number
|
|
|
83
84
|
return if band (packed, SIGN_BIT) ~= 0 then -result else result
|
|
84
85
|
end
|
|
85
86
|
|
|
86
|
-
-- Public
|
|
87
|
+
-- Public -------------------------------------------------------------
|
|
87
88
|
|
|
88
89
|
local Float16 = {}
|
|
89
90
|
|
|
@@ -9,7 +9,7 @@ type ChannelState = Types.ChannelState
|
|
|
9
9
|
|
|
10
10
|
local alloc = Channel.alloc
|
|
11
11
|
|
|
12
|
-
-- Constants
|
|
12
|
+
-- Constants ----------------------------------------------------------
|
|
13
13
|
|
|
14
14
|
local CONT = 0x80
|
|
15
15
|
local MASK = 0x7F
|
|
@@ -21,7 +21,7 @@ local bor = bit32.bor
|
|
|
21
21
|
local rshift = bit32.rshift
|
|
22
22
|
local lshift = bit32.lshift
|
|
23
23
|
|
|
24
|
-
-- Public
|
|
24
|
+
-- Public -------------------------------------------------------------
|
|
25
25
|
|
|
26
26
|
local Varint = {}
|
|
27
27
|
|
package/src/init.luau
CHANGED
|
@@ -7,22 +7,22 @@ local RunService = game:GetService ("RunService")
|
|
|
7
7
|
-- Codec: primitive
|
|
8
8
|
local BoolCodec = require (script.codec.primitive.Bool)
|
|
9
9
|
local Float16 = require (script.codec.primitive.Float16)
|
|
10
|
-
local
|
|
10
|
+
local NumberCodec = require (script.codec.primitive.Number)
|
|
11
11
|
|
|
12
12
|
-- Codec: datatype
|
|
13
|
-
local
|
|
13
|
+
local BufferCodec = require (script.codec.datatype.Buffer)
|
|
14
14
|
local CFrameCodec = require (script.codec.datatype.CFrame)
|
|
15
|
-
local
|
|
15
|
+
local ColorCodec = require (script.codec.datatype.Color)
|
|
16
16
|
local InstanceCodec = require (script.codec.datatype.Instance)
|
|
17
|
-
local
|
|
17
|
+
local IntVectorCodec = require (script.codec.datatype.IntVector)
|
|
18
18
|
local NumberRangeCodec = require (script.codec.datatype.NumberRange)
|
|
19
19
|
local RayCodec = require (script.codec.datatype.Ray)
|
|
20
20
|
local RectCodec = require (script.codec.datatype.Rect)
|
|
21
|
-
local
|
|
22
|
-
local
|
|
23
|
-
local
|
|
21
|
+
local RegionCodec = require (script.codec.datatype.Region)
|
|
22
|
+
local SequenceCodec = require (script.codec.datatype.Sequence)
|
|
23
|
+
local StringCodec = require (script.codec.datatype.String)
|
|
24
24
|
local UDimCodec = require (script.codec.datatype.UDim)
|
|
25
|
-
local
|
|
25
|
+
local VectorCodec = require (script.codec.datatype.Vector)
|
|
26
26
|
|
|
27
27
|
-- Codec: composite
|
|
28
28
|
local Array = require (script.codec.composite.Array)
|
|
@@ -43,10 +43,14 @@ local Unknown = require (script.codec.meta.Unknown)
|
|
|
43
43
|
|
|
44
44
|
-- Internal
|
|
45
45
|
local Channel = require (script.internal.Channel)
|
|
46
|
-
local Gate = require (script.transport.Gate)
|
|
47
46
|
local Middleware = require (script.internal.Middleware)
|
|
48
47
|
local Pool = require (script.internal.Pool)
|
|
49
48
|
|
|
49
|
+
-- Transport
|
|
50
|
+
local Client = require (script.transport.Client)
|
|
51
|
+
local Gate = require (script.transport.Gate)
|
|
52
|
+
local Server = require (script.transport.Server)
|
|
53
|
+
|
|
50
54
|
-- API
|
|
51
55
|
local Group = require (script.api.Group)
|
|
52
56
|
local Namespace = require (script.api.Namespace)
|
|
@@ -54,14 +58,12 @@ local Packet = require (script.api.Packet)
|
|
|
54
58
|
local Query = require (script.api.Query)
|
|
55
59
|
local Scope = require (script.api.Scope)
|
|
56
60
|
|
|
57
|
-
--
|
|
58
|
-
local Client = require (script.transport.Client)
|
|
59
|
-
local Server = require (script.transport.Server)
|
|
60
|
-
|
|
61
|
-
-- Sentinels --------------------------------------------------------------
|
|
61
|
+
-- Constants ----------------------------------------------------------
|
|
62
62
|
|
|
63
63
|
local ALL = table.freeze ({ _tag = "all" })
|
|
64
64
|
|
|
65
|
+
-- Private ------------------------------------------------------------
|
|
66
|
+
|
|
65
67
|
local function except (...: any): any
|
|
66
68
|
local count = select ("#", ...)
|
|
67
69
|
local set = {} :: { [Player]: true }
|
|
@@ -71,8 +73,6 @@ local function except (...: any): any
|
|
|
71
73
|
return { _tag = "except", _set = set }
|
|
72
74
|
end
|
|
73
75
|
|
|
74
|
-
-- Public -----------------------------------------------------------------
|
|
75
|
-
|
|
76
76
|
local function start (): ()
|
|
77
77
|
if RunService:IsServer () then
|
|
78
78
|
Server.start ()
|
|
@@ -81,8 +81,10 @@ local function start (): ()
|
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
+
-- Public -------------------------------------------------------------
|
|
85
|
+
|
|
84
86
|
local Lync = {
|
|
85
|
-
VERSION = "1.4.
|
|
87
|
+
VERSION = "1.4.1",
|
|
86
88
|
|
|
87
89
|
-- Lifecycle
|
|
88
90
|
start = start,
|
|
@@ -93,37 +95,37 @@ local Lync = {
|
|
|
93
95
|
defineNamespace = Namespace.define,
|
|
94
96
|
|
|
95
97
|
-- Primitives
|
|
96
|
-
u8 =
|
|
97
|
-
u16 =
|
|
98
|
-
u32 =
|
|
99
|
-
i8 =
|
|
100
|
-
i16 =
|
|
101
|
-
i32 =
|
|
102
|
-
f32 =
|
|
103
|
-
f64 =
|
|
98
|
+
u8 = NumberCodec.u8,
|
|
99
|
+
u16 = NumberCodec.u16,
|
|
100
|
+
u32 = NumberCodec.u32,
|
|
101
|
+
i8 = NumberCodec.i8,
|
|
102
|
+
i16 = NumberCodec.i16,
|
|
103
|
+
i32 = NumberCodec.i32,
|
|
104
|
+
f32 = NumberCodec.f32,
|
|
105
|
+
f64 = NumberCodec.f64,
|
|
104
106
|
bool = BoolCodec.bool,
|
|
105
107
|
f16 = Float16.f16,
|
|
106
108
|
|
|
107
109
|
-- Datatypes
|
|
108
|
-
string =
|
|
109
|
-
boundedString =
|
|
110
|
-
vec2 =
|
|
111
|
-
vec3 =
|
|
110
|
+
string = StringCodec.string,
|
|
111
|
+
boundedString = StringCodec.bounded,
|
|
112
|
+
vec2 = VectorCodec.vec2,
|
|
113
|
+
vec3 = VectorCodec.vec3,
|
|
112
114
|
cframe = CFrameCodec.cframe,
|
|
113
|
-
color3 =
|
|
115
|
+
color3 = ColorCodec.color3,
|
|
114
116
|
inst = InstanceCodec.inst,
|
|
115
|
-
buff =
|
|
117
|
+
buff = BufferCodec.buff,
|
|
116
118
|
udim = UDimCodec.udim,
|
|
117
119
|
udim2 = UDimCodec.udim2,
|
|
118
120
|
numberRange = NumberRangeCodec.numberRange,
|
|
119
121
|
rect = RectCodec.rect,
|
|
120
|
-
vec2int16 =
|
|
121
|
-
vec3int16 =
|
|
122
|
-
region3 =
|
|
123
|
-
region3int16 =
|
|
122
|
+
vec2int16 = IntVectorCodec.vec2int16,
|
|
123
|
+
vec3int16 = IntVectorCodec.vec3int16,
|
|
124
|
+
region3 = RegionCodec.region3,
|
|
125
|
+
region3int16 = RegionCodec.region3int16,
|
|
124
126
|
ray = RayCodec.ray,
|
|
125
|
-
numberSequence =
|
|
126
|
-
colorSequence =
|
|
127
|
+
numberSequence = SequenceCodec.numberSequence,
|
|
128
|
+
colorSequence = SequenceCodec.colorSequence,
|
|
127
129
|
|
|
128
130
|
-- Composites
|
|
129
131
|
struct = Struct.struct,
|
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
--!optimize 2
|
|
3
3
|
-- Read-side baseline cache keyed by source (player or client sentinel).
|
|
4
4
|
|
|
5
|
-
-- State
|
|
5
|
+
-- State --------------------------------------------------------------
|
|
6
6
|
|
|
7
7
|
local _readKey = false :: any
|
|
8
8
|
local _readCaches = {} :: { [any]: { [number]: any } }
|
|
9
9
|
|
|
10
|
-
-- Public
|
|
10
|
+
-- Public -------------------------------------------------------------
|
|
11
11
|
|
|
12
12
|
local Baseline = {}
|
|
13
13
|
|
|
14
|
+
-- One-way latch: set to true on first delta write, never reset. This
|
|
15
|
+
-- avoids a setReadKey call on every non-delta frame at the cost of a
|
|
16
|
+
-- cheap branch once deltas are first used in the session.
|
|
14
17
|
Baseline.hasDelta = false
|
|
15
18
|
|
|
16
19
|
function Baseline.setReadKey (key: any): ()
|
|
@@ -38,4 +41,5 @@ function Baseline.clearSource (key: any): ()
|
|
|
38
41
|
_readCaches[key] = nil
|
|
39
42
|
end
|
|
40
43
|
|
|
44
|
+
-- Not frozen: hasDelta is mutated at runtime by setCache.
|
|
41
45
|
return Baseline
|