@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.
Files changed (40) hide show
  1. package/README.md +24 -24
  2. package/package.json +1 -1
  3. package/src/Types.luau +13 -2
  4. package/src/api/Group.luau +3 -5
  5. package/src/api/Namespace.luau +6 -6
  6. package/src/api/Packet.luau +9 -8
  7. package/src/api/Query.luau +11 -9
  8. package/src/api/Scope.luau +2 -2
  9. package/src/api/Signal.luau +10 -4
  10. package/src/codec/Base.luau +7 -3
  11. package/src/codec/composite/Array.luau +18 -15
  12. package/src/codec/composite/Map.luau +45 -31
  13. package/src/codec/composite/Optional.luau +3 -2
  14. package/src/codec/composite/Shared.luau +7 -5
  15. package/src/codec/composite/Struct.luau +6 -4
  16. package/src/codec/composite/Tagged.luau +6 -6
  17. package/src/codec/composite/Tuple.luau +9 -7
  18. package/src/codec/datatype/Buffer.luau +3 -2
  19. package/src/codec/datatype/CFrame.luau +2 -1
  20. package/src/codec/datatype/Instance.luau +3 -2
  21. package/src/codec/datatype/Sequence.luau +3 -4
  22. package/src/codec/datatype/String.luau +3 -6
  23. package/src/codec/meta/Auto.luau +77 -72
  24. package/src/codec/meta/Bitfield.luau +5 -4
  25. package/src/codec/meta/Enum.luau +6 -5
  26. package/src/codec/meta/Quantized.luau +5 -4
  27. package/src/codec/meta/Unknown.luau +5 -1
  28. package/src/codec/primitive/Float16.luau +5 -4
  29. package/src/codec/primitive/Varint.luau +2 -2
  30. package/src/init.luau +39 -37
  31. package/src/internal/Baseline.luau +6 -2
  32. package/src/internal/Channel.luau +11 -6
  33. package/src/internal/Middleware.luau +13 -12
  34. package/src/internal/Pool.luau +5 -5
  35. package/src/internal/Registry.luau +4 -4
  36. package/src/transport/Bridge.luau +4 -3
  37. package/src/transport/Client.luau +4 -3
  38. package/src/transport/Gate.luau +5 -5
  39. package/src/transport/Reader.luau +3 -3
  40. package/src/transport/Server.luau +7 -8
@@ -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 Buffer = require (script.Parent.Parent.datatype.Buffer)
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 alloc = Channel.alloc
9
- local BoolCodec = require (script.Parent.Parent.primitive.Bool)
10
- local Color = require (script.Parent.Parent.datatype.Color)
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 Region = require (script.Parent.Parent.datatype.Region)
17
- local Sequence = require (script.Parent.Parent.datatype.Sequence)
18
- local String = require (script.Parent.Parent.datatype.String)
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 Vector = require (script.Parent.Parent.datatype.Vector)
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] = Number.u8,
62
- [TAG_U16] = Number.u16,
63
- [TAG_U32] = Number.u32,
64
- [TAG_I8] = Number.i8,
65
- [TAG_I16] = Number.i16,
66
- [TAG_I32] = Number.i32,
67
- [TAG_F32] = Number.f32,
68
- [TAG_F64] = Number.f64,
69
- [TAG_STRING] = String.string,
70
- [TAG_VEC2] = Vector.vec2,
71
- [TAG_VEC3] = Vector.vec3,
72
- [TAG_COLOR3] = Color.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] = Buffer.buff,
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] = IntVector.vec2int16,
80
- [TAG_VEC3INT16] = IntVector.vec3int16,
81
- [TAG_REGION3] = Region.region3,
82
- [TAG_REGION3INT16] = Region.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] = Sequence.numberSequence,
85
- [TAG_COLORSEQUENCE] = Sequence.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 = String.string, size = nil, dw = nil },
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 = Vector.vec2,
99
+ codec = VectorCodec.vec2,
94
100
  size = 8,
95
- dw = (Vector.vec2 :: any)._directWrite,
101
+ dw = extractDw (VectorCodec.vec2),
96
102
  },
97
103
  Vector3 = {
98
104
  tag = TAG_VEC3,
99
- codec = Vector.vec3,
105
+ codec = VectorCodec.vec3,
100
106
  size = 12,
101
- dw = (Vector.vec3 :: any)._directWrite,
107
+ dw = extractDw (VectorCodec.vec3),
102
108
  },
103
109
  Color3 = {
104
110
  tag = TAG_COLOR3,
105
- codec = Color.color3,
111
+ codec = ColorCodec.color3,
106
112
  size = 3,
107
- dw = (Color.color3 :: any)._directWrite,
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 :: any)._directWrite,
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 :: any)._directWrite,
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 :: any)._directWrite,
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 :: any)._directWrite,
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 :: any)._directWrite,
143
+ dw = extractDw (RectCodec.rect),
139
144
  },
140
145
  Vector2int16 = {
141
146
  tag = TAG_VEC2INT16,
142
- codec = IntVector.vec2int16,
147
+ codec = IntVectorCodec.vec2int16,
143
148
  size = 4,
144
- dw = (IntVector.vec2int16 :: any)._directWrite,
149
+ dw = extractDw (IntVectorCodec.vec2int16),
145
150
  },
146
151
  Vector3int16 = {
147
152
  tag = TAG_VEC3INT16,
148
- codec = IntVector.vec3int16,
153
+ codec = IntVectorCodec.vec3int16,
149
154
  size = 6,
150
- dw = (IntVector.vec3int16 :: any)._directWrite,
155
+ dw = extractDw (IntVectorCodec.vec3int16),
151
156
  },
152
157
  Region3 = {
153
158
  tag = TAG_REGION3,
154
- codec = Region.region3,
159
+ codec = RegionCodec.region3,
155
160
  size = 24,
156
- dw = (Region.region3 :: any)._directWrite,
161
+ dw = extractDw (RegionCodec.region3),
157
162
  },
158
163
  Region3int16 = {
159
164
  tag = TAG_REGION3INT16,
160
- codec = Region.region3int16,
165
+ codec = RegionCodec.region3int16,
161
166
  size = 12,
162
- dw = (Region.region3int16 :: any)._directWrite,
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 :: any)._directWrite,
173
+ dw = extractDw (RayCodec.ray),
169
174
  },
170
175
  NumberSequence = {
171
176
  tag = TAG_NUMBERSEQUENCE,
172
- codec = Sequence.numberSequence,
177
+ codec = SequenceCodec.numberSequence,
173
178
  size = nil,
174
179
  dw = nil,
175
180
  },
176
181
  ColorSequence = {
177
182
  tag = TAG_COLORSEQUENCE,
178
- codec = Sequence.colorSequence,
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, Number.u8, 1 },
191
- { TAG_U16, Number.u16, 2 },
192
- { TAG_U32, Number.u32, 4 },
193
- { TAG_I8, Number.i8, 1 },
194
- { TAG_I16, Number.i16, 2 },
195
- { TAG_I32, Number.i32, 4 },
196
- { TAG_F32, Number.f32, 4 },
197
- { TAG_F64, Number.f64, 8 },
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] :: any)._directWrite
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 dw = entry.dw
316
- local size = entry.size
317
- if dw and size then
318
- local totalSize = 1 + size
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
- dw (b, c + 1, value)
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
- -- Constants --------------------------------------------------------------
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
 
@@ -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
- -- Public -----------------------------------------------------------------
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: \"{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: \"{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: \"{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
- -- Constants --------------------------------------------------------------
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: any, value: any): ()
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 Number = require (script.codec.primitive.Number)
10
+ local NumberCodec = require (script.codec.primitive.Number)
11
11
 
12
12
  -- Codec: datatype
13
- local Buffer = require (script.codec.datatype.Buffer)
13
+ local BufferCodec = require (script.codec.datatype.Buffer)
14
14
  local CFrameCodec = require (script.codec.datatype.CFrame)
15
- local Color = require (script.codec.datatype.Color)
15
+ local ColorCodec = require (script.codec.datatype.Color)
16
16
  local InstanceCodec = require (script.codec.datatype.Instance)
17
- local IntVector = require (script.codec.datatype.IntVector)
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 Region = require (script.codec.datatype.Region)
22
- local Sequence = require (script.codec.datatype.Sequence)
23
- local String = require (script.codec.datatype.String)
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 Vector = require (script.codec.datatype.Vector)
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
- -- Transport
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.0",
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 = Number.u8,
97
- u16 = Number.u16,
98
- u32 = Number.u32,
99
- i8 = Number.i8,
100
- i16 = Number.i16,
101
- i32 = Number.i32,
102
- f32 = Number.f32,
103
- f64 = Number.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 = String.string,
109
- boundedString = String.bounded,
110
- vec2 = Vector.vec2,
111
- vec3 = Vector.vec3,
110
+ string = StringCodec.string,
111
+ boundedString = StringCodec.bounded,
112
+ vec2 = VectorCodec.vec2,
113
+ vec3 = VectorCodec.vec3,
112
114
  cframe = CFrameCodec.cframe,
113
- color3 = Color.color3,
115
+ color3 = ColorCodec.color3,
114
116
  inst = InstanceCodec.inst,
115
- buff = Buffer.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 = IntVector.vec2int16,
121
- vec3int16 = IntVector.vec3int16,
122
- region3 = Region.region3,
123
- region3int16 = Region.region3int16,
122
+ vec2int16 = IntVectorCodec.vec2int16,
123
+ vec3int16 = IntVectorCodec.vec3int16,
124
+ region3 = RegionCodec.region3,
125
+ region3int16 = RegionCodec.region3int16,
124
126
  ray = RayCodec.ray,
125
- numberSequence = Sequence.numberSequence,
126
- colorSequence = Sequence.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