@axpecter/lync 2.3.2 → 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.
Files changed (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +302 -299
  3. package/Types.luau +215 -0
  4. package/api/Define.luau +154 -0
  5. package/api/Lifecycle.luau +119 -0
  6. package/api/Packet.luau +108 -0
  7. package/api/Query.luau +149 -0
  8. package/api/Set.luau +189 -0
  9. package/channel/Blocks.luau +124 -0
  10. package/channel/Group.luau +118 -0
  11. package/channel/Link.luau +135 -0
  12. package/channel/Outbox.luau +261 -0
  13. package/channel/Recipients.luau +129 -0
  14. package/channel/Transport.luau +138 -0
  15. package/codec/Base.luau +236 -0
  16. package/codec/Composites.luau +128 -0
  17. package/codec/Datatypes.luau +162 -0
  18. package/codec/Legality.luau +61 -0
  19. package/codec/Scalars.luau +72 -0
  20. package/codec/Text.luau +89 -0
  21. package/codec/init.luau +39 -0
  22. package/index.d.ts +285 -0
  23. package/init.luau +91 -0
  24. package/kernel/Bits.luau +16 -0
  25. package/kernel/Catalog.luau +121 -0
  26. package/kernel/Heap.luau +80 -0
  27. package/kernel/Listeners.luau +95 -0
  28. package/kernel/Log.luau +197 -0
  29. package/kernel/Tally.luau +128 -0
  30. package/kernel/Threads.luau +44 -0
  31. package/kernel/Wide.luau +267 -0
  32. package/package.json +15 -32
  33. package/runtime/Boundary.luau +180 -0
  34. package/runtime/Dispatch.luau +91 -0
  35. package/runtime/Handles.luau +114 -0
  36. package/runtime/Handshake.luau +90 -0
  37. package/runtime/Pending.luau +196 -0
  38. package/runtime/Router.luau +379 -0
  39. package/runtime/Session.luau +731 -0
  40. package/shape/Compile.luau +340 -0
  41. package/shape/Folds.luau +332 -0
  42. package/shape/Frames.luau +170 -0
  43. package/shape/Grid.luau +169 -0
  44. package/shape/Ir.luau +540 -0
  45. package/shape/Joins.luau +125 -0
  46. package/shape/Legality.luau +273 -0
  47. package/shape/Lower.luau +419 -0
  48. package/shape/Order.luau +64 -0
  49. package/shape/Regions.luau +113 -0
  50. package/shape/Rotation.luau +472 -0
  51. package/shape/Serial.luau +258 -0
  52. package/shape/Words.luau +89 -0
  53. package/shape/emit/Block.luau +453 -0
  54. package/shape/emit/Column.luau +338 -0
  55. package/shape/emit/Leaf.luau +462 -0
  56. package/shape/emit/Word.luau +234 -0
  57. package/shape/emit/init.luau +222 -0
  58. package/shape/init.luau +78 -0
  59. package/state/Apply.luau +330 -0
  60. package/state/Audience.luau +126 -0
  61. package/state/Catchup.luau +218 -0
  62. package/state/Coalesce.luau +43 -0
  63. package/state/Fieldset.luau +177 -0
  64. package/state/Newest.luau +339 -0
  65. package/state/Plan.luau +441 -0
  66. package/state/Sections.luau +468 -0
  67. package/state/Store.luau +188 -0
  68. package/state/Sync.luau +762 -0
  69. package/wire/Bytes.luau +118 -0
  70. package/wire/Clock.luau +37 -0
  71. package/wire/Protocol.luau +110 -0
  72. package/wire/Sequence.luau +40 -0
  73. package/wire/Varint.luau +124 -0
  74. package/src/Types.luau +0 -180
  75. package/src/api/Group.luau +0 -156
  76. package/src/api/Packet.luau +0 -319
  77. package/src/api/Query.luau +0 -338
  78. package/src/api/Scope.luau +0 -90
  79. package/src/api/Signal.luau +0 -188
  80. package/src/codec/Base.luau +0 -136
  81. package/src/codec/composite/Array.luau +0 -456
  82. package/src/codec/composite/Map.luau +0 -469
  83. package/src/codec/composite/Optional.luau +0 -54
  84. package/src/codec/composite/Shared.luau +0 -291
  85. package/src/codec/composite/Struct.luau +0 -494
  86. package/src/codec/composite/Tagged.luau +0 -103
  87. package/src/codec/composite/Tuple.luau +0 -143
  88. package/src/codec/datatype/Buffer.luau +0 -66
  89. package/src/codec/datatype/CFrame.luau +0 -109
  90. package/src/codec/datatype/Color.luau +0 -32
  91. package/src/codec/datatype/Instance.luau +0 -52
  92. package/src/codec/datatype/IntVector.luau +0 -39
  93. package/src/codec/datatype/NumberRange.luau +0 -39
  94. package/src/codec/datatype/Ray.luau +0 -36
  95. package/src/codec/datatype/Rect.luau +0 -31
  96. package/src/codec/datatype/Region.luau +0 -62
  97. package/src/codec/datatype/Sequence.luau +0 -184
  98. package/src/codec/datatype/String.luau +0 -94
  99. package/src/codec/datatype/UDim.luau +0 -46
  100. package/src/codec/datatype/Vector.luau +0 -130
  101. package/src/codec/meta/Auto.luau +0 -318
  102. package/src/codec/meta/Bitfield.luau +0 -147
  103. package/src/codec/meta/Custom.luau +0 -33
  104. package/src/codec/meta/DeltaScalar.luau +0 -390
  105. package/src/codec/meta/Enum.luau +0 -50
  106. package/src/codec/meta/Float.luau +0 -38
  107. package/src/codec/meta/Nothing.luau +0 -13
  108. package/src/codec/meta/Unknown.luau +0 -41
  109. package/src/codec/primitive/Bool.luau +0 -26
  110. package/src/codec/primitive/Float16.luau +0 -99
  111. package/src/codec/primitive/Int.luau +0 -59
  112. package/src/codec/primitive/Number.luau +0 -24
  113. package/src/codec/primitive/Signed.luau +0 -32
  114. package/src/codec/primitive/Varint.luau +0 -165
  115. package/src/codec/primitive/Zint.luau +0 -99
  116. package/src/index.d.ts +0 -423
  117. package/src/init.luau +0 -362
  118. package/src/internal/Baseline.luau +0 -57
  119. package/src/internal/Channel.luau +0 -390
  120. package/src/internal/Middleware.luau +0 -100
  121. package/src/internal/Pool.luau +0 -65
  122. package/src/internal/Registry.luau +0 -119
  123. package/src/internal/Transport.luau +0 -28
  124. package/src/transport/Bridge.luau +0 -110
  125. package/src/transport/Client.luau +0 -97
  126. package/src/transport/Gate.luau +0 -488
  127. package/src/transport/Reader.luau +0 -331
  128. package/src/transport/Server.luau +0 -211
  129. package/src/util/Array.luau +0 -18
  130. package/src/util/Buffer.luau +0 -90
  131. package/src/util/Constants.luau +0 -30
  132. package/src/util/Log.luau +0 -68
  133. package/src/util/Player.luau +0 -14
  134. package/src/util/Quantize.luau +0 -84
  135. package/src/util/Quat.luau +0 -124
@@ -1,291 +0,0 @@
1
- --!strict
2
- --!native
3
- -- Shared composite-codec helpers: delta flags, scratch pool, bool packing.
4
-
5
- local Base = require(script.Parent.Parent.Base)
6
- local Buf = require(script.Parent.Parent.Parent.util.Buffer)
7
- local Channel = require(script.Parent.Parent.Parent.internal.Channel)
8
- local Log = require(script.Parent.Parent.Parent.util.Log)
9
- local Types = require(script.Parent.Parent.Parent.Types)
10
-
11
- -- Constants --------------------------------------------------------------
12
-
13
- --[[
14
- Delta flag base shared by deltaStruct's per-segment scheme:
15
- 0 UNCHANGED
16
- 1..segCount single dirty segment k
17
- segCount + FULL_OFFSET FULL payload
18
- segCount + MULTI_OFFSET MULTI: bitmap + dirty segs in order
19
- deltaArray and deltaMap manage their own flag spaces.
20
- ]]
21
- local DELTA_UNCHANGED = 0
22
- local DELTA_FULL_OFFSET = 1
23
- local DELTA_MULTI_OFFSET = 2
24
-
25
- -- State ------------------------------------------------------------------
26
-
27
- local _nextDeltaId = 0
28
- local _scratchDepth = 0
29
- local _scratchStack: { Types.ChannelState } = {}
30
-
31
- -- Private ----------------------------------------------------------------
32
-
33
- local alloc = Base.alloc
34
- local band = bit32.band
35
- local bor = bit32.bor
36
- local lshift = bit32.lshift
37
- local readu8 = buffer.readu8
38
- local writeu8 = buffer.writeu8
39
- local bufCopy = buffer.copy
40
- local bufLen = buffer.len
41
- local rangeEqual = Buf.rangeEqual
42
- local snapshot = Buf.snapshot
43
-
44
- --[[
45
- Reuse `existing` when it's already large enough, else snapshot via
46
- Buf.snapshot. Avoids per-write buffer allocations on delta caches that
47
- hover at a stable size.
48
- ]]
49
- local function copyToBuf(existing: buffer?, src: buffer, srcOff: number, len: number): buffer
50
- if existing and bufLen(existing) >= len then
51
- bufCopy(existing, 0, src, srcOff, len)
52
- return existing
53
- end
54
- return snapshot(src, len, srcOff)
55
- end
56
-
57
- -- Update a `{raw, len}` cache shape from scratch bytes; reuses raw via copyToBuf.
58
- local function refreshCache(cache: any, src: buffer, len: number): ()
59
- cache.raw = copyToBuf(cache.raw, src, 0, len)
60
- cache.len = len
61
- end
62
-
63
- -- Public -----------------------------------------------------------------
64
-
65
- local Shared = {}
66
-
67
- Shared.DELTA_UNCHANGED = DELTA_UNCHANGED
68
- Shared.DELTA_FULL_OFFSET = DELTA_FULL_OFFSET
69
- Shared.DELTA_MULTI_OFFSET = DELTA_MULTI_OFFSET
70
- Shared.rangeEqual = rangeEqual
71
- Shared.snapshot = snapshot
72
- Shared.refreshCache = refreshCache
73
- Shared.copyToBuf = copyToBuf
74
-
75
- -- True when `c` itself is a delta codec OR contains one in its tree.
76
- function Shared.containsDelta(c: Types.InternalCodec<any>): boolean
77
- return c._isDelta == true or c._hasDelta == true
78
- end
79
-
80
- -- Common bounds check for variable-length container codecs.
81
- function Shared.enforceMaxCount(len: number, maxCount: number?, label: string?): ()
82
- if maxCount and len > maxCount then
83
- Log.error(`{label or "count"} {len} exceeds max {maxCount}`)
84
- end
85
- end
86
-
87
- function Shared.allocDeltaId(): number
88
- _nextDeltaId += 1
89
- return _nextDeltaId
90
- end
91
-
92
- -- 8 bools per byte.
93
- function Shared.boolBytes(n: number): number
94
- return (n + 7) // 8
95
- end
96
-
97
- --[[
98
- Stack-based scratch ChannelState pool. Re-entrant codec serialization
99
- (a codec writing into scratch that triggers another codec's scratch
100
- acquire) works without aliasing.
101
- ]]
102
- function Shared.acquireScratch(): Types.ChannelState
103
- _scratchDepth += 1
104
- local ch = _scratchStack[_scratchDepth]
105
- if ch then
106
- ch.cursor = 0
107
- ch.refCount = 0
108
- return ch
109
- end
110
- ch = Channel.create()
111
- _scratchStack[_scratchDepth] = ch
112
- return ch
113
- end
114
-
115
- function Shared.releaseScratch(): ()
116
- _scratchDepth -= 1
117
- end
118
-
119
- --[[
120
- Reset module-private state. Called by Sandbox in tests so that a thrown
121
- codec.write (which skips releaseScratch and leaves depth inflated) can't
122
- leak into the next test's scratch acquisition. Also resets the deltaId
123
- counter so test ordering doesn't bleed.
124
- ]]
125
- function Shared.reset(): ()
126
- _scratchDepth = 0
127
- _nextDeltaId = 0
128
- for i = 1, #_scratchStack do
129
- local ch = _scratchStack[i]
130
- ch.cursor = 0
131
- ch.refCount = 0
132
- if ch.refCount > 0 then
133
- table.clear(ch.refs)
134
- end
135
- table.clear(ch.deltas)
136
- end
137
- end
138
-
139
- --[[
140
- Split a struct schema into (dataKeys, dataCodecs, boolKeys), each sorted
141
- alphabetically for deterministic wire layout.
142
- ]]
143
- function Shared.extractFields(
144
- schema: { [string]: Types.InternalCodec<any> }
145
- ): ({ string }, { Types.InternalCodec<any> }, { string })
146
- local dataKeys: { string } = {}
147
- local boolKeys: { string } = {}
148
-
149
- for key, codec in schema do
150
- if codec._isBool then
151
- table.insert(boolKeys, key)
152
- else
153
- table.insert(dataKeys, key)
154
- end
155
- end
156
-
157
- Log.assert(#dataKeys > 0 or #boolKeys > 0, "requires at least one field")
158
-
159
- table.sort(dataKeys)
160
- table.sort(boolKeys)
161
-
162
- local dataCount = #dataKeys
163
- local dataCodecs = table.create(dataCount)
164
- for i = 1, dataCount do
165
- dataCodecs[i] = schema[dataKeys[i]]
166
- end
167
-
168
- table.freeze(dataKeys)
169
- table.freeze(dataCodecs)
170
- table.freeze(boolKeys)
171
- return dataKeys, dataCodecs, boolKeys
172
- end
173
-
174
- function Shared.packBools(
175
- ch: Types.ChannelState,
176
- value: { [string]: any },
177
- boolKeys: { string },
178
- boolCount: number
179
- ): ()
180
- if boolCount == 0 then
181
- return
182
- end
183
-
184
- local byteCount = (boolCount + 7) // 8
185
- local cursor = ch.cursor
186
- if cursor + byteCount > ch.size then
187
- alloc(ch, byteCount)
188
- end
189
-
190
- local idx = 1
191
- local b = ch.buff
192
- for byteIdx = 0, byteCount - 1 do
193
- local packed = 0
194
- local remaining = boolCount - idx + 1
195
- local limit = if remaining >= 8 then 8 else remaining
196
- for bit = 0, limit - 1 do
197
- if value[boolKeys[idx]] then
198
- packed = bor(packed, lshift(1, bit))
199
- end
200
- idx += 1
201
- end
202
- writeu8(b, cursor + byteIdx, packed)
203
- end
204
-
205
- ch.cursor = cursor + byteCount
206
- end
207
-
208
- --[[
209
- Integer-indexed bool-array pack. Split from packBools to skip the
210
- per-bit string-key getter on the bool-array hot path.
211
- ]]
212
- function Shared.packBoolArray(ch: Types.ChannelState, value: { boolean }, count: number): ()
213
- if count == 0 then
214
- return
215
- end
216
-
217
- local byteCount = (count + 7) // 8
218
- local cursor = ch.cursor
219
- if cursor + byteCount > ch.size then
220
- alloc(ch, byteCount)
221
- end
222
-
223
- local idx = 1
224
- local b = ch.buff
225
- for byteIdx = 0, byteCount - 1 do
226
- local packed = 0
227
- local remaining = count - idx + 1
228
- local limit = if remaining >= 8 then 8 else remaining
229
- for bit = 0, limit - 1 do
230
- if value[idx] then
231
- packed = bor(packed, lshift(1, bit))
232
- end
233
- idx += 1
234
- end
235
- writeu8(b, cursor + byteIdx, packed)
236
- end
237
-
238
- ch.cursor = cursor + byteCount
239
- end
240
-
241
- function Shared.unpackBools(
242
- src: buffer,
243
- pos: number,
244
- boolKeys: { string },
245
- boolCount: number,
246
- result: { [string]: any }
247
- ): number
248
- if boolCount == 0 then
249
- return 0
250
- end
251
-
252
- local byteCount = (boolCount + 7) // 8
253
- local idx = 1
254
- for byteIdx = 0, byteCount - 1 do
255
- local byte = readu8(src, pos + byteIdx)
256
- local remaining = boolCount - idx + 1
257
- local limit = if remaining >= 8 then 8 else remaining
258
- for bit = 0, limit - 1 do
259
- result[boolKeys[idx]] = band(byte, lshift(1, bit)) ~= 0
260
- idx += 1
261
- end
262
- end
263
- return byteCount
264
- end
265
-
266
- -- Fills `result[1..count]` in place.
267
- function Shared.unpackBoolArray(
268
- src: buffer,
269
- pos: number,
270
- count: number,
271
- result: { boolean }
272
- ): number
273
- if count == 0 then
274
- return 0
275
- end
276
-
277
- local byteCount = (count + 7) // 8
278
- local idx = 1
279
- for byteIdx = 0, byteCount - 1 do
280
- local byte = readu8(src, pos + byteIdx)
281
- local remaining = count - idx + 1
282
- local limit = if remaining >= 8 then 8 else remaining
283
- for bit = 0, limit - 1 do
284
- result[idx] = band(byte, lshift(1, bit)) ~= 0
285
- idx += 1
286
- end
287
- end
288
- return byteCount
289
- end
290
-
291
- return table.freeze(Shared)