@axpecter/lync 2.1.2 → 2.2.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.
Files changed (56) hide show
  1. package/README.md +241 -349
  2. package/package.json +1 -1
  3. package/src/Types.luau +53 -13
  4. package/src/api/Group.luau +41 -51
  5. package/src/api/Packet.luau +163 -152
  6. package/src/api/Query.luau +224 -211
  7. package/src/api/Scope.luau +36 -38
  8. package/src/api/Signal.luau +68 -94
  9. package/src/codec/Base.luau +43 -23
  10. package/src/codec/composite/Array.luau +161 -152
  11. package/src/codec/composite/Map.luau +37 -53
  12. package/src/codec/composite/Optional.luau +15 -21
  13. package/src/codec/composite/Shared.luau +78 -41
  14. package/src/codec/composite/Struct.luau +64 -125
  15. package/src/codec/composite/Tagged.luau +15 -25
  16. package/src/codec/composite/Tuple.luau +15 -20
  17. package/src/codec/datatype/Buffer.luau +44 -51
  18. package/src/codec/datatype/CFrame.luau +72 -104
  19. package/src/codec/datatype/Color.luau +14 -10
  20. package/src/codec/datatype/Instance.luau +32 -42
  21. package/src/codec/datatype/IntVector.luau +24 -22
  22. package/src/codec/datatype/NumberRange.luau +21 -12
  23. package/src/codec/datatype/Ray.luau +13 -7
  24. package/src/codec/datatype/Rect.luau +13 -7
  25. package/src/codec/datatype/Region.luau +25 -22
  26. package/src/codec/datatype/Sequence.luau +144 -118
  27. package/src/codec/datatype/String.luau +29 -59
  28. package/src/codec/datatype/UDim.luau +29 -30
  29. package/src/codec/datatype/Vector.luau +89 -105
  30. package/src/codec/meta/Auto.luau +194 -246
  31. package/src/codec/meta/Bitfield.luau +37 -36
  32. package/src/codec/meta/Custom.luau +10 -10
  33. package/src/codec/meta/Enum.luau +8 -11
  34. package/src/codec/meta/Float.luau +16 -20
  35. package/src/codec/meta/Nothing.luau +2 -2
  36. package/src/codec/meta/Unknown.luau +22 -32
  37. package/src/codec/primitive/Bool.luau +9 -5
  38. package/src/codec/primitive/Float16.luau +13 -23
  39. package/src/codec/primitive/Int.luau +20 -28
  40. package/src/codec/primitive/Number.luau +6 -10
  41. package/src/codec/primitive/Signed.luau +32 -0
  42. package/src/codec/primitive/Varint.luau +59 -28
  43. package/src/index.d.ts +8 -2
  44. package/src/init.luau +133 -143
  45. package/src/internal/Baseline.luau +17 -18
  46. package/src/internal/Channel.luau +143 -212
  47. package/src/internal/Middleware.luau +37 -47
  48. package/src/internal/Pool.luau +10 -10
  49. package/src/internal/Registry.luau +38 -34
  50. package/src/internal/Transport.luau +28 -0
  51. package/src/internal/Util.luau +26 -0
  52. package/src/transport/Bridge.luau +32 -24
  53. package/src/transport/Client.luau +51 -53
  54. package/src/transport/Gate.luau +183 -113
  55. package/src/transport/Reader.luau +95 -66
  56. package/src/transport/Server.luau +130 -125
@@ -3,35 +3,37 @@
3
3
  -- Vector2int16 (4 bytes) and Vector3int16 (6 bytes) codecs.
4
4
 
5
5
  local Base = require(script.Parent.Parent.Base)
6
+ local Signed = require(script.Parent.Parent.primitive.Signed)
6
7
 
7
- -- Private -------------------------------------------------------------
8
+ -- Private ----------------------------------------------------------------
8
9
 
9
- local function writeI16(b: buffer, off: number, v: number): ()
10
- buffer.writeu16(b, off, if v < 0 then v + 0x10000 else v)
11
- end
12
-
13
- local function readI16(b: buffer, off: number): number
14
- local raw = buffer.readu16(b, off)
15
- return if raw >= 0x8000 then raw - 0x10000 else raw
16
- end
17
-
18
- -- Public --------------------------------------------------------------
10
+ local writeI16 = Signed.writeI16
11
+ local readi16 = buffer.readi16
19
12
 
20
- local IntVectorCodec = {}
21
-
22
- IntVectorCodec.vec2int16 = Base.define(4, function(b: buffer, off: number, value: Vector2int16): ()
13
+ local function writeVec2I16(b: buffer, off: number, value: Vector2int16): ()
23
14
  writeI16(b, off, value.X)
24
15
  writeI16(b, off + 2, value.Y)
25
- end, function(b: buffer, off: number): Vector2int16
26
- return Vector2int16.new(readI16(b, off), readI16(b, off + 2))
27
- end, { _typeCheck = "Vector2int16" })
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
28
21
 
29
- IntVectorCodec.vec3int16 = Base.define(6, function(b: buffer, off: number, value: Vector3int16): ()
22
+ local function writeVec3I16(b: buffer, off: number, value: Vector3int16): ()
30
23
  writeI16(b, off, value.X)
31
24
  writeI16(b, off + 2, value.Y)
32
25
  writeI16(b, off + 4, value.Z)
33
- end, function(b: buffer, off: number): Vector3int16
34
- return Vector3int16.new(readI16(b, off), readI16(b, off + 2), readI16(b, off + 4))
35
- end, { _typeCheck = "Vector3int16" })
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" })
36
38
 
37
- return table.freeze(IntVectorCodec)
39
+ return table.freeze(IntVector)
@@ -4,20 +4,29 @@
4
4
 
5
5
  local Base = require(script.Parent.Parent.Base)
6
6
 
7
- -- Public --------------------------------------------------------------
7
+ -- Private ----------------------------------------------------------------
8
+
9
+ local function writeNumberRange(b: buffer, off: number, value: NumberRange): ()
10
+ buffer.writef32(b, off, value.Min)
11
+ buffer.writef32(b, off + 4, value.Max)
12
+ end
13
+
14
+ local function readNumberRange(b: buffer, off: number): NumberRange
15
+ local minV = buffer.readf32(b, off)
16
+ local maxV = buffer.readf32(b, off + 4)
17
+ -- NumberRange.new requires min <= max; swap on corruption rather than throw.
18
+ if minV > maxV then
19
+ minV, maxV = maxV, minV
20
+ end
21
+ return NumberRange.new(minV, maxV)
22
+ end
23
+
24
+ -- Public -----------------------------------------------------------------
8
25
 
9
26
  local NumberRangeCodec = {}
10
27
 
11
- NumberRangeCodec.numberRange = Base.define(
12
- 8,
13
- function(b: buffer, off: number, value: NumberRange): ()
14
- buffer.writef32(b, off, value.Min)
15
- buffer.writef32(b, off + 4, value.Max)
16
- end,
17
- function(b: buffer, off: number): NumberRange
18
- return NumberRange.new(buffer.readf32(b, off), buffer.readf32(b, off + 4))
19
- end,
20
- { _typeCheck = "NumberRange" }
21
- )
28
+ NumberRangeCodec.numberRange = Base.define(8, writeNumberRange, readNumberRange, {
29
+ _typeCheck = "NumberRange",
30
+ })
22
31
 
23
32
  return table.freeze(NumberRangeCodec)
@@ -1,14 +1,12 @@
1
1
  --!strict
2
2
  --!optimize 2
3
- -- Ray codec. 24 bytes: origin + direction as 6x f32.
3
+ -- Ray codec. 24 bytes: Origin (3x f32) + Direction (3x f32).
4
4
 
5
5
  local Base = require(script.Parent.Parent.Base)
6
6
 
7
- -- Public --------------------------------------------------------------
7
+ -- Private ----------------------------------------------------------------
8
8
 
9
- local RayCodec = {}
10
-
11
- RayCodec.ray = Base.define(24, function(b: buffer, off: number, value: Ray): ()
9
+ local function writeRay(b: buffer, off: number, value: Ray): ()
12
10
  local o = value.Origin
13
11
  local d = value.Direction
14
12
  buffer.writef32(b, off, o.X)
@@ -17,7 +15,9 @@ RayCodec.ray = Base.define(24, function(b: buffer, off: number, value: Ray): ()
17
15
  buffer.writef32(b, off + 12, d.X)
18
16
  buffer.writef32(b, off + 16, d.Y)
19
17
  buffer.writef32(b, off + 20, d.Z)
20
- end, function(b: buffer, off: number): Ray
18
+ end
19
+
20
+ local function readRay(b: buffer, off: number): Ray
21
21
  return Ray.new(
22
22
  Vector3.new(buffer.readf32(b, off), buffer.readf32(b, off + 4), buffer.readf32(b, off + 8)),
23
23
  Vector3.new(
@@ -26,6 +26,12 @@ end, function(b: buffer, off: number): Ray
26
26
  buffer.readf32(b, off + 20)
27
27
  )
28
28
  )
29
- end, { _typeCheck = "Ray" })
29
+ end
30
+
31
+ -- Public -----------------------------------------------------------------
32
+
33
+ local RayCodec = {}
34
+
35
+ RayCodec.ray = Base.define(24, writeRay, readRay, { _typeCheck = "Ray" })
30
36
 
31
37
  return table.freeze(RayCodec)
@@ -1,25 +1,31 @@
1
1
  --!strict
2
2
  --!optimize 2
3
- -- Rect codec. 16 bytes: 4x f32.
3
+ -- Rect codec. 16 bytes: 4x f32 (Min.X, Min.Y, Max.X, Max.Y).
4
4
 
5
5
  local Base = require(script.Parent.Parent.Base)
6
6
 
7
- -- Public --------------------------------------------------------------
7
+ -- Private ----------------------------------------------------------------
8
8
 
9
- local RectCodec = {}
10
-
11
- RectCodec.rect = Base.define(16, function(b: buffer, off: number, value: Rect): ()
9
+ local function writeRect(b: buffer, off: number, value: Rect): ()
12
10
  buffer.writef32(b, off, value.Min.X)
13
11
  buffer.writef32(b, off + 4, value.Min.Y)
14
12
  buffer.writef32(b, off + 8, value.Max.X)
15
13
  buffer.writef32(b, off + 12, value.Max.Y)
16
- end, function(b: buffer, off: number): Rect
14
+ end
15
+
16
+ local function readRect(b: buffer, off: number): Rect
17
17
  return Rect.new(
18
18
  buffer.readf32(b, off),
19
19
  buffer.readf32(b, off + 4),
20
20
  buffer.readf32(b, off + 8),
21
21
  buffer.readf32(b, off + 12)
22
22
  )
23
- end, { _typeCheck = "Rect" })
23
+ end
24
+
25
+ -- Public -----------------------------------------------------------------
26
+
27
+ local RectCodec = {}
28
+
29
+ RectCodec.rect = Base.define(16, writeRect, readRect, { _typeCheck = "Rect" })
24
30
 
25
31
  return table.freeze(RectCodec)
@@ -3,23 +3,14 @@
3
3
  -- Region3 (24 bytes) and Region3int16 (12 bytes) codecs.
4
4
 
5
5
  local Base = require(script.Parent.Parent.Base)
6
+ local Signed = require(script.Parent.Parent.primitive.Signed)
6
7
 
7
- -- Private -------------------------------------------------------------
8
+ -- Private ----------------------------------------------------------------
8
9
 
9
- local function writeI16(b: buffer, off: number, v: number): ()
10
- buffer.writeu16(b, off, if v < 0 then v + 0x10000 else v)
11
- end
12
-
13
- local function readI16(b: buffer, off: number): number
14
- local raw = buffer.readu16(b, off)
15
- return if raw >= 0x8000 then raw - 0x10000 else raw
16
- end
17
-
18
- -- Public --------------------------------------------------------------
10
+ local writeI16 = Signed.writeI16
11
+ local readi16 = buffer.readi16
19
12
 
20
- local RegionCodec = {}
21
-
22
- RegionCodec.region3 = Base.define(24, function(b: buffer, off: number, value: Region3): ()
13
+ local function writeRegion3(b: buffer, off: number, value: Region3): ()
23
14
  local pos = value.CFrame.Position
24
15
  local half = value.Size * 0.5
25
16
  local minV = pos - half
@@ -30,7 +21,9 @@ RegionCodec.region3 = Base.define(24, function(b: buffer, off: number, value: Re
30
21
  buffer.writef32(b, off + 12, maxV.X)
31
22
  buffer.writef32(b, off + 16, maxV.Y)
32
23
  buffer.writef32(b, off + 20, maxV.Z)
33
- end, function(b: buffer, off: number): Region3
24
+ end
25
+
26
+ local function readRegion3(b: buffer, off: number): Region3
34
27
  return Region3.new(
35
28
  Vector3.new(buffer.readf32(b, off), buffer.readf32(b, off + 4), buffer.readf32(b, off + 8)),
36
29
  Vector3.new(
@@ -39,9 +32,9 @@ end, function(b: buffer, off: number): Region3
39
32
  buffer.readf32(b, off + 20)
40
33
  )
41
34
  )
42
- end, { _typeCheck = "Region3" })
35
+ end
43
36
 
44
- RegionCodec.region3int16 = Base.define(12, function(b: buffer, off: number, value: Region3int16): ()
37
+ local function writeRegion3I16(b: buffer, off: number, value: Region3int16): ()
45
38
  local minV = value.Min
46
39
  local maxV = value.Max
47
40
  writeI16(b, off, minV.X)
@@ -50,11 +43,21 @@ RegionCodec.region3int16 = Base.define(12, function(b: buffer, off: number, valu
50
43
  writeI16(b, off + 6, maxV.X)
51
44
  writeI16(b, off + 8, maxV.Y)
52
45
  writeI16(b, off + 10, maxV.Z)
53
- end, function(b: buffer, off: number): Region3int16
46
+ end
47
+
48
+ local function readRegion3I16(b: buffer, off: number): Region3int16
54
49
  return Region3int16.new(
55
- Vector3int16.new(readI16(b, off), readI16(b, off + 2), readI16(b, off + 4)),
56
- Vector3int16.new(readI16(b, off + 6), readI16(b, off + 8), readI16(b, off + 10))
50
+ Vector3int16.new(readi16(b, off), readi16(b, off + 2), readi16(b, off + 4)),
51
+ Vector3int16.new(readi16(b, off + 6), readi16(b, off + 8), readi16(b, off + 10))
57
52
  )
58
- end, { _typeCheck = "Region3int16" })
53
+ end
54
+
55
+ -- Public -----------------------------------------------------------------
56
+
57
+ local Region = {}
58
+
59
+ Region.region3 = Base.define(24, writeRegion3, readRegion3, { _typeCheck = "Region3" })
60
+ Region.region3int16 =
61
+ Base.define(12, writeRegion3I16, readRegion3I16, { _typeCheck = "Region3int16" })
59
62
 
60
- return table.freeze(RegionCodec)
63
+ return table.freeze(Region)
@@ -1,136 +1,162 @@
1
1
  --!strict
2
2
  --!optimize 2
3
- -- NumberSequence and ColorSequence codecs with varint count.
3
+ -- NumberSequence (12B/keypoint) and ColorSequence (7B/keypoint) codecs.
4
4
 
5
5
  local Base = require(script.Parent.Parent.Base)
6
6
  local Types = require(script.Parent.Parent.Parent.Types)
7
7
  local Varint = require(script.Parent.Parent.primitive.Varint)
8
8
 
9
- -- Private -------------------------------------------------------------
9
+ -- Constants --------------------------------------------------------------
10
+
11
+ local NUMSEQ_KP_BYTES = 12
12
+ local COLSEQ_KP_BYTES = 7
13
+ local MAX_KEYPOINTS = 20
14
+
15
+ -- Private ----------------------------------------------------------------
10
16
 
11
17
  local alloc = Base.alloc
12
18
  local round = math.round
13
19
  local clamp = math.clamp
14
20
 
15
- -- Public --------------------------------------------------------------
16
-
17
- local SequenceCodec = {}
18
-
19
- SequenceCodec.numberSequence = table.freeze({
20
- _typeCheck = "NumberSequence",
21
-
22
- write = function(ch: Types.ChannelState, value: NumberSequence): ()
23
- local keypoints = value.Keypoints
24
- local count = #keypoints
25
- Varint.write(ch, count)
26
-
27
- if count == 0 then
28
- return
29
- end
30
-
31
- local bytes = count * 12
32
- local cursor = ch.cursor
33
- if cursor + bytes > ch.size then
34
- alloc(ch, bytes)
35
- end
36
- local b = ch.buff
37
-
38
- for i = 1, count do
39
- local kp = keypoints[i]
40
- local off = cursor + (i - 1) * 12
41
- buffer.writef32(b, off, kp.Time)
42
- buffer.writef32(b, off + 4, kp.Value)
43
- buffer.writef32(b, off + 8, kp.Envelope)
44
- end
45
-
46
- ch.cursor = cursor + bytes
47
- end,
48
-
49
- read = function(src: buffer, pos: number, _refs: { Instance }?): (NumberSequence, number)
50
- local count, lenBytes = Varint.read(src, pos)
51
- if count == 0 then
52
- return NumberSequence.new(0), lenBytes
53
- end
54
-
55
- local bytes = count * 12
56
- local dataStart = pos + lenBytes
57
- if dataStart + bytes > buffer.len(src) then
58
- error("[Lync] NumberSequence: data exceeds buffer")
59
- end
60
-
61
- local keypoints = table.create(count)
62
- for i = 1, count do
63
- local off = dataStart + (i - 1) * 12
64
- keypoints[i] = NumberSequenceKeypoint.new(
65
- buffer.readf32(src, off),
66
- buffer.readf32(src, off + 4),
67
- buffer.readf32(src, off + 8)
21
+ local function writeNumberSequence(ch: Types.ChannelState, value: NumberSequence): ()
22
+ local keypoints = value.Keypoints
23
+ local count = #keypoints
24
+ Varint.write(ch, count)
25
+ if count == 0 then
26
+ return
27
+ end
28
+
29
+ local bytes = count * NUMSEQ_KP_BYTES
30
+ local cursor = ch.cursor
31
+ if cursor + bytes > ch.size then
32
+ alloc(ch, bytes)
33
+ end
34
+ local b = ch.buff
35
+
36
+ local off = cursor
37
+ for i = 1, count do
38
+ local kp = keypoints[i]
39
+ buffer.writef32(b, off, kp.Time)
40
+ buffer.writef32(b, off + 4, kp.Value)
41
+ buffer.writef32(b, off + 8, kp.Envelope)
42
+ off += NUMSEQ_KP_BYTES
43
+ end
44
+ ch.cursor = cursor + bytes
45
+ end
46
+
47
+ local function readNumberSequence(
48
+ src: buffer,
49
+ pos: number,
50
+ _refs: { Instance }?
51
+ ): (NumberSequence, number)
52
+ local count, lenBytes = Varint.read(src, pos)
53
+ if count == 0 then
54
+ return NumberSequence.new(0), lenBytes
55
+ end
56
+ if count > MAX_KEYPOINTS then
57
+ error(
58
+ `[Lync] NumberSequence.read: keypoint count {count} exceeds Roblox limit {MAX_KEYPOINTS}`
59
+ )
60
+ end
61
+
62
+ local bytes = count * NUMSEQ_KP_BYTES
63
+ local dataStart = pos + lenBytes
64
+ if dataStart + bytes > buffer.len(src) then
65
+ error("[Lync] NumberSequence.read: data exceeds buffer")
66
+ end
67
+
68
+ local keypoints = table.create(count)
69
+ local off = dataStart
70
+ for i = 1, count do
71
+ keypoints[i] = NumberSequenceKeypoint.new(
72
+ buffer.readf32(src, off),
73
+ buffer.readf32(src, off + 4),
74
+ buffer.readf32(src, off + 8)
75
+ )
76
+ off += NUMSEQ_KP_BYTES
77
+ end
78
+ return NumberSequence.new(keypoints), lenBytes + bytes
79
+ end
80
+
81
+ local function writeColorSequence(ch: Types.ChannelState, value: ColorSequence): ()
82
+ local keypoints = value.Keypoints
83
+ local count = #keypoints
84
+ Varint.write(ch, count)
85
+ if count == 0 then
86
+ return
87
+ end
88
+
89
+ local bytes = count * COLSEQ_KP_BYTES
90
+ local cursor = ch.cursor
91
+ if cursor + bytes > ch.size then
92
+ alloc(ch, bytes)
93
+ end
94
+ local b = ch.buff
95
+
96
+ local off = cursor
97
+ for i = 1, count do
98
+ local kp = keypoints[i]
99
+ local c = kp.Value
100
+ buffer.writef32(b, off, kp.Time)
101
+ buffer.writeu8(b, off + 4, round(clamp(c.R, 0, 1) * 255))
102
+ buffer.writeu8(b, off + 5, round(clamp(c.G, 0, 1) * 255))
103
+ buffer.writeu8(b, off + 6, round(clamp(c.B, 0, 1) * 255))
104
+ off += COLSEQ_KP_BYTES
105
+ end
106
+ ch.cursor = cursor + bytes
107
+ end
108
+
109
+ local function readColorSequence(
110
+ src: buffer,
111
+ pos: number,
112
+ _refs: { Instance }?
113
+ ): (ColorSequence, number)
114
+ local count, lenBytes = Varint.read(src, pos)
115
+ if count == 0 then
116
+ return ColorSequence.new(Color3.new()), lenBytes
117
+ end
118
+ if count > MAX_KEYPOINTS then
119
+ error(
120
+ `[Lync] ColorSequence.read: keypoint count {count} exceeds Roblox limit {MAX_KEYPOINTS}`
121
+ )
122
+ end
123
+
124
+ local bytes = count * COLSEQ_KP_BYTES
125
+ local dataStart = pos + lenBytes
126
+ if dataStart + bytes > buffer.len(src) then
127
+ error("[Lync] ColorSequence.read: data exceeds buffer")
128
+ end
129
+
130
+ local keypoints = table.create(count)
131
+ local off = dataStart
132
+ for i = 1, count do
133
+ keypoints[i] = ColorSequenceKeypoint.new(
134
+ buffer.readf32(src, off),
135
+ Color3.fromRGB(
136
+ buffer.readu8(src, off + 4),
137
+ buffer.readu8(src, off + 5),
138
+ buffer.readu8(src, off + 6)
68
139
  )
69
- end
140
+ )
141
+ off += COLSEQ_KP_BYTES
142
+ end
143
+ return ColorSequence.new(keypoints), lenBytes + bytes
144
+ end
70
145
 
71
- return NumberSequence.new(keypoints), lenBytes + bytes
72
- end,
73
- } :: any)
146
+ -- Public -----------------------------------------------------------------
74
147
 
75
- SequenceCodec.colorSequence = table.freeze({
76
- _typeCheck = "ColorSequence",
148
+ local Sequence = {}
77
149
 
78
- write = function(ch: Types.ChannelState, value: ColorSequence): ()
79
- local keypoints = value.Keypoints
80
- local count = #keypoints
81
- Varint.write(ch, count)
82
-
83
- if count == 0 then
84
- return
85
- end
86
-
87
- local bytes = count * 7
88
- local cursor = ch.cursor
89
- if cursor + bytes > ch.size then
90
- alloc(ch, bytes)
91
- end
92
- local b = ch.buff
93
-
94
- for i = 1, count do
95
- local kp = keypoints[i]
96
- local off = cursor + (i - 1) * 7
97
- local c = kp.Value
98
- buffer.writef32(b, off, kp.Time)
99
- buffer.writeu8(b, off + 4, round(clamp(c.R, 0, 1) * 255))
100
- buffer.writeu8(b, off + 5, round(clamp(c.G, 0, 1) * 255))
101
- buffer.writeu8(b, off + 6, round(clamp(c.B, 0, 1) * 255))
102
- end
103
-
104
- ch.cursor = cursor + bytes
105
- end,
106
-
107
- read = function(src: buffer, pos: number, _refs: { Instance }?): (ColorSequence, number)
108
- local count, lenBytes = Varint.read(src, pos)
109
- if count == 0 then
110
- return ColorSequence.new(Color3.new()), lenBytes
111
- end
112
-
113
- local bytes = count * 7
114
- local dataStart = pos + lenBytes
115
- if dataStart + bytes > buffer.len(src) then
116
- error("[Lync] ColorSequence: data exceeds buffer")
117
- end
118
-
119
- local keypoints = table.create(count)
120
- for i = 1, count do
121
- local off = dataStart + (i - 1) * 7
122
- keypoints[i] = ColorSequenceKeypoint.new(
123
- buffer.readf32(src, off),
124
- Color3.fromRGB(
125
- buffer.readu8(src, off + 4),
126
- buffer.readu8(src, off + 5),
127
- buffer.readu8(src, off + 6)
128
- )
129
- )
130
- end
150
+ Sequence.numberSequence = table.freeze({
151
+ _typeCheck = "NumberSequence",
152
+ write = writeNumberSequence,
153
+ read = readNumberSequence,
154
+ })
131
155
 
132
- return ColorSequence.new(keypoints), lenBytes + bytes
133
- end,
134
- } :: any)
156
+ Sequence.colorSequence = table.freeze({
157
+ _typeCheck = "ColorSequence",
158
+ write = writeColorSequence,
159
+ read = readColorSequence,
160
+ })
135
161
 
136
- return table.freeze(SequenceCodec)
162
+ return table.freeze(Sequence)