@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.
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 -317
  77. package/src/api/Query.luau +0 -338
  78. package/src/api/Scope.luau +0 -90
  79. package/src/api/Signal.luau +0 -193
  80. package/src/codec/Base.luau +0 -136
  81. package/src/codec/composite/Array.luau +0 -473
  82. package/src/codec/composite/Map.luau +0 -485
  83. package/src/codec/composite/Optional.luau +0 -54
  84. package/src/codec/composite/Shared.luau +0 -311
  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 -160
  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 -484
  120. package/src/internal/Middleware.luau +0 -100
  121. package/src/internal/Pool.luau +0 -66
  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 -233
  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,311 +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. Full scrub on reuse so any codec that
101
- reads framing fields (lastId/singleMode/itemCount/countPos) on scratch
102
- sees a clean state, not stale bytes from the previous owner.
103
- ]]
104
- function Shared.acquireScratch(): Types.ChannelState
105
- _scratchDepth += 1
106
- local ch = _scratchStack[_scratchDepth]
107
- if ch then
108
- ch.cursor = 0
109
- ch.refCount = 0
110
- ch.lastId = -1
111
- ch.countPos = -1
112
- ch.itemCount = 0
113
- ch.singleMode = false
114
- ch.singlePos = 0
115
- ch.currentPacket = nil
116
- if next(ch.deltas) ~= nil then
117
- table.clear(ch.deltas)
118
- end
119
- return ch
120
- end
121
- ch = Channel.create()
122
- _scratchStack[_scratchDepth] = ch
123
- return ch
124
- end
125
-
126
- function Shared.releaseScratch(): ()
127
- _scratchDepth -= 1
128
- end
129
-
130
- --[[
131
- Reset module-private state. Called by Sandbox in tests so that a thrown
132
- codec.write (which skips releaseScratch and leaves depth inflated) can't
133
- leak into the next test's scratch acquisition. Also resets the deltaId
134
- counter so test ordering doesn't bleed.
135
- ]]
136
- function Shared.reset(): ()
137
- _scratchDepth = 0
138
- _nextDeltaId = 0
139
- for i = 1, #_scratchStack do
140
- local ch = _scratchStack[i]
141
- ch.cursor = 0
142
- ch.refCount = 0
143
- if ch.refCount > 0 then
144
- table.clear(ch.refs)
145
- end
146
- table.clear(ch.deltas)
147
- end
148
- end
149
-
150
- --[[
151
- Split a struct schema into (dataKeys, dataCodecs, boolKeys), each sorted
152
- alphabetically for deterministic wire layout.
153
- ]]
154
- function Shared.extractFields(
155
- schema: { [string]: Types.InternalCodec<any> }
156
- ): ({ string }, { Types.InternalCodec<any> }, { string })
157
- local dataKeys: { string } = {}
158
- local boolKeys: { string } = {}
159
-
160
- for key, codec in schema do
161
- if codec._isBool then
162
- table.insert(boolKeys, key)
163
- else
164
- table.insert(dataKeys, key)
165
- end
166
- end
167
-
168
- Log.assert(#dataKeys > 0 or #boolKeys > 0, "requires at least one field")
169
-
170
- table.sort(dataKeys)
171
- table.sort(boolKeys)
172
-
173
- local dataCount = #dataKeys
174
- local dataCodecs = table.create(dataCount)
175
- for i = 1, dataCount do
176
- dataCodecs[i] = schema[dataKeys[i]]
177
- end
178
-
179
- table.freeze(dataKeys)
180
- table.freeze(dataCodecs)
181
- table.freeze(boolKeys)
182
- return dataKeys, dataCodecs, boolKeys
183
- end
184
-
185
- -- `byteCount` is `(boolCount + 7) // 8`; callers with it cached pass it through.
186
- function Shared.packBools(
187
- ch: Types.ChannelState,
188
- value: { [string]: any },
189
- boolKeys: { string },
190
- boolCount: number,
191
- byteCount: number?
192
- ): ()
193
- if boolCount == 0 then
194
- return
195
- end
196
-
197
- local bc = byteCount or (boolCount + 7) // 8
198
- local cursor = ch.cursor
199
- if cursor + bc > ch.size then
200
- alloc(ch, bc)
201
- end
202
-
203
- local idx = 1
204
- local b = ch.buff
205
- for byteIdx = 0, bc - 1 do
206
- local packed = 0
207
- local remaining = boolCount - idx + 1
208
- local limit = if remaining >= 8 then 8 else remaining
209
- for bit = 0, limit - 1 do
210
- if value[boolKeys[idx]] then
211
- packed = bor(packed, lshift(1, bit))
212
- end
213
- idx += 1
214
- end
215
- writeu8(b, cursor + byteIdx, packed)
216
- end
217
-
218
- ch.cursor = cursor + bc
219
- end
220
-
221
- --[[
222
- Integer-indexed bool-array pack. Split from packBools to skip the
223
- per-bit string-key getter on the bool-array hot path.
224
- ]]
225
- function Shared.packBoolArray(
226
- ch: Types.ChannelState,
227
- value: { boolean },
228
- count: number,
229
- byteCount: number?
230
- ): ()
231
- if count == 0 then
232
- return
233
- end
234
-
235
- local bc = byteCount or (count + 7) // 8
236
- local cursor = ch.cursor
237
- if cursor + bc > ch.size then
238
- alloc(ch, bc)
239
- end
240
-
241
- local idx = 1
242
- local b = ch.buff
243
- for byteIdx = 0, bc - 1 do
244
- local packed = 0
245
- local remaining = count - idx + 1
246
- local limit = if remaining >= 8 then 8 else remaining
247
- for bit = 0, limit - 1 do
248
- if value[idx] then
249
- packed = bor(packed, lshift(1, bit))
250
- end
251
- idx += 1
252
- end
253
- writeu8(b, cursor + byteIdx, packed)
254
- end
255
-
256
- ch.cursor = cursor + bc
257
- end
258
-
259
- function Shared.unpackBools(
260
- src: buffer,
261
- pos: number,
262
- boolKeys: { string },
263
- boolCount: number,
264
- result: { [string]: any },
265
- byteCount: number?
266
- ): number
267
- if boolCount == 0 then
268
- return 0
269
- end
270
-
271
- local bc = byteCount or (boolCount + 7) // 8
272
- local idx = 1
273
- for byteIdx = 0, bc - 1 do
274
- local byte = readu8(src, pos + byteIdx)
275
- local remaining = boolCount - idx + 1
276
- local limit = if remaining >= 8 then 8 else remaining
277
- for bit = 0, limit - 1 do
278
- result[boolKeys[idx]] = band(byte, lshift(1, bit)) ~= 0
279
- idx += 1
280
- end
281
- end
282
- return bc
283
- end
284
-
285
- -- Fills `result[1..count]` in place.
286
- function Shared.unpackBoolArray(
287
- src: buffer,
288
- pos: number,
289
- count: number,
290
- result: { boolean },
291
- byteCount: number?
292
- ): number
293
- if count == 0 then
294
- return 0
295
- end
296
-
297
- local bc = byteCount or (count + 7) // 8
298
- local idx = 1
299
- for byteIdx = 0, bc - 1 do
300
- local byte = readu8(src, pos + byteIdx)
301
- local remaining = count - idx + 1
302
- local limit = if remaining >= 8 then 8 else remaining
303
- for bit = 0, limit - 1 do
304
- result[idx] = band(byte, lshift(1, bit)) ~= 0
305
- idx += 1
306
- end
307
- end
308
- return bc
309
- end
310
-
311
- return table.freeze(Shared)