@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.
- package/LICENSE +21 -0
- package/README.md +302 -299
- package/Types.luau +215 -0
- package/api/Define.luau +154 -0
- package/api/Lifecycle.luau +119 -0
- package/api/Packet.luau +108 -0
- package/api/Query.luau +149 -0
- package/api/Set.luau +189 -0
- package/channel/Blocks.luau +124 -0
- package/channel/Group.luau +118 -0
- package/channel/Link.luau +135 -0
- package/channel/Outbox.luau +261 -0
- package/channel/Recipients.luau +129 -0
- package/channel/Transport.luau +138 -0
- package/codec/Base.luau +236 -0
- package/codec/Composites.luau +128 -0
- package/codec/Datatypes.luau +162 -0
- package/codec/Legality.luau +61 -0
- package/codec/Scalars.luau +72 -0
- package/codec/Text.luau +89 -0
- package/codec/init.luau +39 -0
- package/index.d.ts +285 -0
- package/init.luau +91 -0
- package/kernel/Bits.luau +16 -0
- package/kernel/Catalog.luau +121 -0
- package/kernel/Heap.luau +80 -0
- package/kernel/Listeners.luau +95 -0
- package/kernel/Log.luau +197 -0
- package/kernel/Tally.luau +128 -0
- package/kernel/Threads.luau +44 -0
- package/kernel/Wide.luau +267 -0
- package/package.json +15 -32
- package/runtime/Boundary.luau +180 -0
- package/runtime/Dispatch.luau +91 -0
- package/runtime/Handles.luau +114 -0
- package/runtime/Handshake.luau +90 -0
- package/runtime/Pending.luau +196 -0
- package/runtime/Router.luau +379 -0
- package/runtime/Session.luau +731 -0
- package/shape/Compile.luau +340 -0
- package/shape/Folds.luau +332 -0
- package/shape/Frames.luau +170 -0
- package/shape/Grid.luau +169 -0
- package/shape/Ir.luau +540 -0
- package/shape/Joins.luau +125 -0
- package/shape/Legality.luau +273 -0
- package/shape/Lower.luau +419 -0
- package/shape/Order.luau +64 -0
- package/shape/Regions.luau +113 -0
- package/shape/Rotation.luau +472 -0
- package/shape/Serial.luau +258 -0
- package/shape/Words.luau +89 -0
- package/shape/emit/Block.luau +453 -0
- package/shape/emit/Column.luau +338 -0
- package/shape/emit/Leaf.luau +462 -0
- package/shape/emit/Word.luau +234 -0
- package/shape/emit/init.luau +222 -0
- package/shape/init.luau +78 -0
- package/state/Apply.luau +330 -0
- package/state/Audience.luau +126 -0
- package/state/Catchup.luau +218 -0
- package/state/Coalesce.luau +43 -0
- package/state/Fieldset.luau +177 -0
- package/state/Newest.luau +339 -0
- package/state/Plan.luau +441 -0
- package/state/Sections.luau +468 -0
- package/state/Store.luau +188 -0
- package/state/Sync.luau +762 -0
- package/wire/Bytes.luau +118 -0
- package/wire/Clock.luau +37 -0
- package/wire/Protocol.luau +110 -0
- package/wire/Sequence.luau +40 -0
- package/wire/Varint.luau +124 -0
- package/src/Types.luau +0 -180
- package/src/api/Group.luau +0 -156
- package/src/api/Packet.luau +0 -319
- package/src/api/Query.luau +0 -338
- package/src/api/Scope.luau +0 -90
- package/src/api/Signal.luau +0 -188
- package/src/codec/Base.luau +0 -136
- package/src/codec/composite/Array.luau +0 -456
- package/src/codec/composite/Map.luau +0 -469
- package/src/codec/composite/Optional.luau +0 -54
- package/src/codec/composite/Shared.luau +0 -291
- package/src/codec/composite/Struct.luau +0 -494
- package/src/codec/composite/Tagged.luau +0 -103
- package/src/codec/composite/Tuple.luau +0 -143
- package/src/codec/datatype/Buffer.luau +0 -66
- package/src/codec/datatype/CFrame.luau +0 -109
- package/src/codec/datatype/Color.luau +0 -32
- package/src/codec/datatype/Instance.luau +0 -52
- package/src/codec/datatype/IntVector.luau +0 -39
- package/src/codec/datatype/NumberRange.luau +0 -39
- package/src/codec/datatype/Ray.luau +0 -36
- package/src/codec/datatype/Rect.luau +0 -31
- package/src/codec/datatype/Region.luau +0 -62
- package/src/codec/datatype/Sequence.luau +0 -184
- package/src/codec/datatype/String.luau +0 -94
- package/src/codec/datatype/UDim.luau +0 -46
- package/src/codec/datatype/Vector.luau +0 -130
- package/src/codec/meta/Auto.luau +0 -318
- package/src/codec/meta/Bitfield.luau +0 -147
- package/src/codec/meta/Custom.luau +0 -33
- package/src/codec/meta/DeltaScalar.luau +0 -390
- package/src/codec/meta/Enum.luau +0 -50
- package/src/codec/meta/Float.luau +0 -38
- package/src/codec/meta/Nothing.luau +0 -13
- package/src/codec/meta/Unknown.luau +0 -41
- package/src/codec/primitive/Bool.luau +0 -26
- package/src/codec/primitive/Float16.luau +0 -99
- package/src/codec/primitive/Int.luau +0 -59
- package/src/codec/primitive/Number.luau +0 -24
- package/src/codec/primitive/Signed.luau +0 -32
- package/src/codec/primitive/Varint.luau +0 -165
- package/src/codec/primitive/Zint.luau +0 -99
- package/src/index.d.ts +0 -423
- package/src/init.luau +0 -362
- package/src/internal/Baseline.luau +0 -57
- package/src/internal/Channel.luau +0 -390
- package/src/internal/Middleware.luau +0 -100
- package/src/internal/Pool.luau +0 -65
- package/src/internal/Registry.luau +0 -119
- package/src/internal/Transport.luau +0 -28
- package/src/transport/Bridge.luau +0 -110
- package/src/transport/Client.luau +0 -97
- package/src/transport/Gate.luau +0 -488
- package/src/transport/Reader.luau +0 -331
- package/src/transport/Server.luau +0 -211
- package/src/util/Array.luau +0 -18
- package/src/util/Buffer.luau +0 -90
- package/src/util/Constants.luau +0 -30
- package/src/util/Log.luau +0 -68
- package/src/util/Player.luau +0 -14
- package/src/util/Quantize.luau +0 -84
- package/src/util/Quat.luau +0 -124
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
--!native
|
|
3
|
+
--!optimize 2
|
|
4
|
+
-- One field of a set across many records, as the pair of closures that lay that column down.
|
|
5
|
+
|
|
6
|
+
local Catalog = require (script.Parent.Parent.Parent.kernel.Catalog)
|
|
7
|
+
local Grid = require (script.Parent.Parent.Grid)
|
|
8
|
+
local Ir = require (script.Parent.Parent.Ir)
|
|
9
|
+
local Leaf = require (script.Parent.Leaf)
|
|
10
|
+
local Log = require (script.Parent.Parent.Parent.kernel.Log)
|
|
11
|
+
local Serial = require (script.Parent.Parent.Serial)
|
|
12
|
+
local Types = require (script.Parent.Parent.Parent.Types)
|
|
13
|
+
local Varint = require (script.Parent.Parent.Parent.wire.Varint)
|
|
14
|
+
local Word = require (script.Parent.Word)
|
|
15
|
+
|
|
16
|
+
local Column = {}
|
|
17
|
+
|
|
18
|
+
-- Constants -----------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
-- Types ---------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
--[[
|
|
23
|
+
A column, and the arrays either end of it. The values are positional, so a caller reads its slot
|
|
24
|
+
list once to gather and once to scatter. A closure that gathered for itself would owe the reader
|
|
25
|
+
a rule for a slot the receiver does not hold, and scattering what it holds is that rule with no
|
|
26
|
+
branch in it.
|
|
27
|
+
]]
|
|
28
|
+
export type Write = (b: buffer, pos: number, from: { any }, at: { number }, count: number) -> number
|
|
29
|
+
export type Read = (
|
|
30
|
+
b: buffer,
|
|
31
|
+
pos: number,
|
|
32
|
+
into: { any },
|
|
33
|
+
at: { number },
|
|
34
|
+
count: number,
|
|
35
|
+
ctx: Types.ValidateContext
|
|
36
|
+
) -> number
|
|
37
|
+
|
|
38
|
+
export type Gain = (
|
|
39
|
+
b: buffer,
|
|
40
|
+
pos: number,
|
|
41
|
+
from: { any },
|
|
42
|
+
slots: { number },
|
|
43
|
+
was: { [number]: number },
|
|
44
|
+
at: { number },
|
|
45
|
+
count: number
|
|
46
|
+
) -> number
|
|
47
|
+
|
|
48
|
+
export type Regain = (
|
|
49
|
+
b: buffer,
|
|
50
|
+
pos: number,
|
|
51
|
+
into: { any },
|
|
52
|
+
slots: { number },
|
|
53
|
+
was: { [number]: number },
|
|
54
|
+
at: { number },
|
|
55
|
+
count: number
|
|
56
|
+
) -> number
|
|
57
|
+
|
|
58
|
+
-- Private -------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
local function reject (code: Catalog.Code, tag: Ir.Tag, got: any): never
|
|
61
|
+
return Log.reject (code, { pathId = tag.pathId, expectId = tag.expectId, got = got })
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
-- Public --------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
-- A field whose values are points on a grid, as one packed run of their indices.
|
|
67
|
+
function Column.grid (
|
|
68
|
+
tag: Ir.Tag,
|
|
69
|
+
paths: Serial.Interner,
|
|
70
|
+
expected: Serial.Interner,
|
|
71
|
+
of: Grid.Grid
|
|
72
|
+
): (Write, Read)
|
|
73
|
+
local toIndex, fromIndex = of.toIndex, of.fromIndex
|
|
74
|
+
local width, span = of.width, of.span
|
|
75
|
+
|
|
76
|
+
local function write (
|
|
77
|
+
b: buffer,
|
|
78
|
+
pos: number,
|
|
79
|
+
from: { any },
|
|
80
|
+
at: { number },
|
|
81
|
+
count: number
|
|
82
|
+
): number
|
|
83
|
+
for place = 1, count do
|
|
84
|
+
local one = toIndex (from[place])
|
|
85
|
+
if one == nil then Word.refusedAt (tag, paths, expected, from[place]) end
|
|
86
|
+
|
|
87
|
+
at[place] = one :: number
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
return Leaf.packed (b, pos, width, count, at)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
local function read (
|
|
94
|
+
b: buffer,
|
|
95
|
+
pos: number,
|
|
96
|
+
into: { any },
|
|
97
|
+
at: { number },
|
|
98
|
+
count: number,
|
|
99
|
+
_ctx: Types.ValidateContext
|
|
100
|
+
): number
|
|
101
|
+
local after, clean = Leaf.unpacked (b, pos, width, count, at)
|
|
102
|
+
if not clean then reject (Catalog.PAD, tag, count) end
|
|
103
|
+
|
|
104
|
+
for place = 1, count do
|
|
105
|
+
local one = at[place]
|
|
106
|
+
if one > span then reject (Catalog.TAG, tag, one) end
|
|
107
|
+
|
|
108
|
+
into[place] = fromIndex (one)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
return after
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
return write, read
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
--[[
|
|
118
|
+
A run of the small numbers the protocol names for itself, which is a delta's presence run and a
|
|
119
|
+
keyframe's generations. Every pattern of the width is a value, so the only thing this can turn
|
|
120
|
+
away is a pad. It carries a phrase rather than a tag, because neither number is at a place in a
|
|
121
|
+
schema and a rejection would name a path out of whichever field's table was reached for.
|
|
122
|
+
]]
|
|
123
|
+
function Column.bits (width: number, said: string): (Write, Read)
|
|
124
|
+
local function write (
|
|
125
|
+
b: buffer,
|
|
126
|
+
pos: number,
|
|
127
|
+
from: { any },
|
|
128
|
+
_at: { number },
|
|
129
|
+
count: number
|
|
130
|
+
): number
|
|
131
|
+
return Leaf.packed (b, pos, width, count, from :: any)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
local function read (
|
|
135
|
+
b: buffer,
|
|
136
|
+
pos: number,
|
|
137
|
+
into: { any },
|
|
138
|
+
_at: { number },
|
|
139
|
+
count: number,
|
|
140
|
+
_ctx: Types.ValidateContext
|
|
141
|
+
): number
|
|
142
|
+
local after, clean = Leaf.unpacked (b, pos, width, count, into :: any)
|
|
143
|
+
if not clean then Log.reject (Catalog.SECTION, { said = said }) end
|
|
144
|
+
|
|
145
|
+
return after
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
return write, read
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
--[[
|
|
152
|
+
A field that is no run, as its own pair called once per record, and saying nothing about where
|
|
153
|
+
its values sit on a grid.
|
|
154
|
+
]]
|
|
155
|
+
local function apiece (writeOne: Ir.Write, readOne: Ir.Read): (Write, Read)
|
|
156
|
+
local function write (
|
|
157
|
+
b: buffer,
|
|
158
|
+
pos: number,
|
|
159
|
+
from: { any },
|
|
160
|
+
_at: { number },
|
|
161
|
+
count: number
|
|
162
|
+
): number
|
|
163
|
+
local at = pos
|
|
164
|
+
for place = 1, count do
|
|
165
|
+
at = writeOne (b, at, from[place])
|
|
166
|
+
end
|
|
167
|
+
return at
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
local function read (
|
|
171
|
+
b: buffer,
|
|
172
|
+
pos: number,
|
|
173
|
+
into: { any },
|
|
174
|
+
_at: { number },
|
|
175
|
+
count: number,
|
|
176
|
+
ctx: Types.ValidateContext
|
|
177
|
+
): number
|
|
178
|
+
local at = pos
|
|
179
|
+
for place = 1, count do
|
|
180
|
+
at, into[place] = readOne (b, at, ctx)
|
|
181
|
+
end
|
|
182
|
+
return at
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
return write, read
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
-- The same field, stating where each of its values sits on its grid.
|
|
189
|
+
local function stated (writeOne: Ir.Write, readOne: Ir.Read, of: Grid.Grid): (Write, Read)
|
|
190
|
+
local toIndex = of.toIndex
|
|
191
|
+
|
|
192
|
+
local function write (
|
|
193
|
+
b: buffer,
|
|
194
|
+
pos: number,
|
|
195
|
+
from: { any },
|
|
196
|
+
at: { number },
|
|
197
|
+
count: number
|
|
198
|
+
): number
|
|
199
|
+
local held = pos
|
|
200
|
+
for place = 1, count do
|
|
201
|
+
local one = from[place]
|
|
202
|
+
held = writeOne (b, held, one)
|
|
203
|
+
at[place] = toIndex (one) :: number
|
|
204
|
+
end
|
|
205
|
+
return held
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
local function read (
|
|
209
|
+
b: buffer,
|
|
210
|
+
pos: number,
|
|
211
|
+
into: { any },
|
|
212
|
+
at: { number },
|
|
213
|
+
count: number,
|
|
214
|
+
ctx: Types.ValidateContext
|
|
215
|
+
): number
|
|
216
|
+
local held = pos
|
|
217
|
+
for place = 1, count do
|
|
218
|
+
local one: any
|
|
219
|
+
held, one = readOne (b, held, ctx)
|
|
220
|
+
|
|
221
|
+
into[place] = one
|
|
222
|
+
at[place] = toIndex (one) :: number
|
|
223
|
+
end
|
|
224
|
+
return held
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
return write, read
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
--[[
|
|
231
|
+
A field that is no run, as its own pair called once per record, which is a constant stride when
|
|
232
|
+
the field is a byte field and whatever the field is otherwise.
|
|
233
|
+
]]
|
|
234
|
+
function Column.each (writeOne: Ir.Write, readOne: Ir.Read, of: Grid.Grid?): (Write, Read)
|
|
235
|
+
if of == nil then return apiece (writeOne, readOne) end
|
|
236
|
+
return stated (writeOne, readOne, of)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
--[[
|
|
240
|
+
A field against what the other machine already holds, as one varint of the difference each. The
|
|
241
|
+
guess is the caller's, since a last value and an extrapolation differ only in how they are
|
|
242
|
+
computed. A slot with no baseline is one this receiver does not hold, and its element is read
|
|
243
|
+
for its width and dropped.
|
|
244
|
+
]]
|
|
245
|
+
function Column.gain (
|
|
246
|
+
tag: Ir.Tag,
|
|
247
|
+
paths: Serial.Interner,
|
|
248
|
+
expected: Serial.Interner,
|
|
249
|
+
of: Grid.Grid,
|
|
250
|
+
signed: boolean
|
|
251
|
+
): (Gain, Regain)
|
|
252
|
+
local toIndex, fromIndex = of.toIndex, of.fromIndex
|
|
253
|
+
local span = of.span
|
|
254
|
+
|
|
255
|
+
local points = if of.wrap then span + 1 else 0
|
|
256
|
+
local half = if signed then points // 2 else 0
|
|
257
|
+
|
|
258
|
+
local put = if signed then Varint.writeSigned else Varint.write
|
|
259
|
+
local take = if signed then Varint.readSigned else Varint.read
|
|
260
|
+
|
|
261
|
+
local function write (
|
|
262
|
+
b: buffer,
|
|
263
|
+
pos: number,
|
|
264
|
+
from: { any },
|
|
265
|
+
slots: { number },
|
|
266
|
+
was: { [number]: number },
|
|
267
|
+
at: { number },
|
|
268
|
+
count: number
|
|
269
|
+
): number
|
|
270
|
+
local held = pos
|
|
271
|
+
|
|
272
|
+
for place = 1, count do
|
|
273
|
+
local one = toIndex (from[place])
|
|
274
|
+
if one == nil then Word.refusedAt (tag, paths, expected, from[place]) end
|
|
275
|
+
|
|
276
|
+
local now = one :: number
|
|
277
|
+
local step = now - was[slots[place] ]
|
|
278
|
+
if points > 0 then step = (step + half) % points - half end
|
|
279
|
+
|
|
280
|
+
at[place] = now
|
|
281
|
+
held = put (b, held, step)
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
return held
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
local function walk (
|
|
288
|
+
b: buffer,
|
|
289
|
+
pos: number,
|
|
290
|
+
into: { any },
|
|
291
|
+
slots: { number },
|
|
292
|
+
was: { [number]: number },
|
|
293
|
+
at: { number },
|
|
294
|
+
count: number
|
|
295
|
+
): number
|
|
296
|
+
local held = pos
|
|
297
|
+
|
|
298
|
+
for place = 1, count do
|
|
299
|
+
local step, after = take (b, held)
|
|
300
|
+
held = after
|
|
301
|
+
|
|
302
|
+
local base = was[slots[place] ]
|
|
303
|
+
if base == nil then continue end
|
|
304
|
+
|
|
305
|
+
local now = base + step
|
|
306
|
+
if points > 0 then
|
|
307
|
+
now %= points
|
|
308
|
+
end
|
|
309
|
+
if not (now >= 0 and now <= span) then reject (Catalog.TAG, tag, now) end
|
|
310
|
+
|
|
311
|
+
at[place] = now
|
|
312
|
+
into[place] = fromIndex (now)
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
return held
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
local function read (
|
|
319
|
+
b: buffer,
|
|
320
|
+
pos: number,
|
|
321
|
+
into: { any },
|
|
322
|
+
slots: { number },
|
|
323
|
+
was: { [number]: number },
|
|
324
|
+
at: { number },
|
|
325
|
+
count: number
|
|
326
|
+
): number
|
|
327
|
+
local ok, after = pcall (walk, b, pos, into, slots, was, at, count)
|
|
328
|
+
if ok then return after :: number end
|
|
329
|
+
|
|
330
|
+
-- Passed along rather than raised again, which is why it does not take the door.
|
|
331
|
+
if typeof (after) == "table" then error (after, 0) end
|
|
332
|
+
return reject (Catalog.VARINT, tag, after)
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
return write, read
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
return table.freeze (Column)
|