@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
package/src/util/Log.luau DELETED
@@ -1,68 +0,0 @@
1
- --!strict
2
- --!optimize 2
3
- -- Centralized warn/error/assert. Project name + caller source come from here.
4
-
5
- -- State ------------------------------------------------------------------
6
-
7
- -- Module-level so tests mute the whole library without threading a flag.
8
- local _silent = false
9
-
10
- -- Constants --------------------------------------------------------------
11
-
12
- local PREFIX = "[Lync]"
13
-
14
- -- Private ----------------------------------------------------------------
15
-
16
- --[[
17
- Stack levels: 1=this fn, 2=Log.warn/error/assert, 3=user. We want #3 so
18
- the source/line/name point at the actual caller, not at Log.
19
-
20
- Source comes back as a dotted Roblox path (e.g. "ServerScriptService.
21
- MainModule.Lync.codec.primitive.Int" or "...test.unit.api.Packet.spec").
22
- `.spec` is a literal dot in test ModuleScript names, so split-on-dot
23
- would yield the meaningless tail "spec"; check the .spec suffix first
24
- and recover the meaningful segment, then fall back to the last segment.
25
- ]]
26
- local function format(message: string): string
27
- local source, line, name = debug.info(3, "sln")
28
- local file = source:match("([^.]+)%.spec$") or source:match("[^./\\]+$") or source
29
- if name and name ~= "" then
30
- return `{PREFIX} {file}:{line} ({name}) {message}`
31
- end
32
- return `{PREFIX} {file}:{line} {message}`
33
- end
34
-
35
- -- Public -----------------------------------------------------------------
36
-
37
- local Log = {}
38
-
39
- function Log.warn(message: string): ()
40
- if not _silent then
41
- warn(format(message))
42
- end
43
- end
44
-
45
- -- level 2 so the runtime traceback points at the caller, not at Log.
46
- function Log.error(message: string): never
47
- error(format(message), 2)
48
- end
49
-
50
- --[[
51
- NOTE: Luau evaluates args eagerly. `format(message)` runs even when cond
52
- is true, paying one debug.info call per Log.assert call. Use only with
53
- LITERAL strings (no interpolation). For interpolated messages prefer
54
- `if cond then Log.error(...) end`.
55
- ]]
56
- function Log.assert<T>(cond: T, message: string): T
57
- return assert(cond, format(message))
58
- end
59
-
60
- function Log.setSilent(silent: boolean): ()
61
- _silent = silent
62
- end
63
-
64
- function Log.reset(): ()
65
- _silent = false
66
- end
67
-
68
- return table.freeze(Log)
@@ -1,14 +0,0 @@
1
- --!strict
2
- --!optimize 2
3
- -- Player Instance type guard.
4
-
5
- -- Public -----------------------------------------------------------------
6
-
7
- local Player = {}
8
-
9
- -- typeof first: :IsA errors on non-Instances.
10
- function Player.is(value: any): boolean
11
- return typeof(value) == "Instance" and value:IsA("Player")
12
- end
13
-
14
- return table.freeze(Player)
@@ -1,84 +0,0 @@
1
- --!strict
2
- --!optimize 2
3
- -- Fixed-point range quantizer setup shared by float and vector codecs.
4
-
5
- local Log = require(script.Parent.Log)
6
-
7
- -- Private ----------------------------------------------------------------
8
-
9
- local ceil = math.ceil
10
- local maxN = math.max
11
- local minN = math.min
12
-
13
- local writeu8 = buffer.writeu8
14
- local writeu16 = buffer.writeu16
15
- local readu8 = buffer.readu8
16
- local readu16 = buffer.readu16
17
- local band = bit32.band
18
- local bor = bit32.bor
19
- local rshift = bit32.rshift
20
- local lshift = bit32.lshift
21
-
22
- --[[
23
- 24-bit wire form. Splits into u16 + u8 since the buffer API has no native
24
- u24. Saves 1 byte over u32 for ranges needing 17–24 bits of precision.
25
- ]]
26
- local function writeu24(b: buffer, off: number, value: number): ()
27
- writeu16(b, off, band(value, 0xFFFF))
28
- writeu8(b, off + 2, band(rshift(value, 16), 0xFF))
29
- end
30
-
31
- local function readu24(b: buffer, off: number): number
32
- return bor(readu16(b, off), lshift(readu8(b, off + 2), 16))
33
- end
34
-
35
- -- Public -----------------------------------------------------------------
36
-
37
- local Quantize = {}
38
-
39
- --[[
40
- Pick the narrowest u8/u16/u24/u32 wire form for [rangeMin, rangeMax] at
41
- `precision`. Returns (compBytes, wfn, rfn, scale, invScale, delta).
42
- `apiName` shows in error messages so callers see their public surface.
43
- ]]
44
- function Quantize.setup(
45
- apiName: string,
46
- rangeMin: number,
47
- rangeMax: number,
48
- precision: number
49
- ): (
50
- number,
51
- (buffer, number, number) -> (),
52
- (buffer, number) -> number,
53
- number,
54
- number,
55
- number
56
- )
57
- if rangeMin >= rangeMax then
58
- Log.error(`{apiName}: min ({rangeMin}) must be < max ({rangeMax})`)
59
- end
60
- if precision <= 0 then
61
- Log.error(`{apiName}: precision must be positive, got {precision}`)
62
- end
63
-
64
- local delta = rangeMax - rangeMin
65
- -- Clamp to [1, U32_MAX] so wire-form selection has a valid value.
66
- local maxInt = minN(0xFFFFFFFF, maxN(1, ceil(delta / precision)))
67
-
68
- local compBytes: number
69
- local wfn: (buffer, number, number) -> ()
70
- local rfn: (buffer, number) -> number
71
- if maxInt <= 0xFF then
72
- compBytes, wfn, rfn = 1, buffer.writeu8, buffer.readu8
73
- elseif maxInt <= 0xFFFF then
74
- compBytes, wfn, rfn = 2, buffer.writeu16, buffer.readu16
75
- elseif maxInt <= 0xFFFFFF then
76
- compBytes, wfn, rfn = 3, writeu24, readu24
77
- else
78
- compBytes, wfn, rfn = 4, buffer.writeu32, buffer.readu32
79
- end
80
-
81
- return compBytes, wfn, rfn, maxInt / delta, delta / maxInt, delta
82
- end
83
-
84
- return table.freeze(Quantize)
@@ -1,124 +0,0 @@
1
- --!strict
2
- --!native
3
- -- Smallest-three quaternion packing into a single u32 for rotation wire forms.
4
-
5
- -- Constants --------------------------------------------------------------
6
-
7
- local INV_SQRT2 = 1 / math.sqrt(2)
8
- local Q_SCALE = 1023 / (2 * INV_SQRT2)
9
- local Q_INV = (2 * INV_SQRT2) / 1023
10
- local EPSILON_SQ = 5.76e-14
11
-
12
- -- Private ----------------------------------------------------------------
13
-
14
- local abs = math.abs
15
- local clamp = math.clamp
16
- local round = math.round
17
- local sin = math.sin
18
- local cos = math.cos
19
- local acos = math.acos
20
- local sqrt = math.sqrt
21
- local band = bit32.band
22
- local bor = bit32.bor
23
- local lshift = bit32.lshift
24
- local rshift = bit32.rshift
25
-
26
- -- Public -----------------------------------------------------------------
27
-
28
- local Quat = {}
29
-
30
- --[[
31
- Quaternion from a CFrame's rotation portion. Returns (qx, qy, qz, qw)
32
- so callers can pack without rebuilding the conversion table.
33
- ]]
34
- function Quat.fromCFrame(cf: CFrame): (number, number, number, number)
35
- local axis, angle = cf:ToAxisAngle()
36
- local h = angle * 0.5
37
- local s = sin(h)
38
- return axis.X * s, axis.Y * s, axis.Z * s, cos(h)
39
- end
40
-
41
- --[[
42
- Pack a unit quaternion into a single u32:
43
- [largest:2][a:10][b:10][c:10]
44
- Drops the largest |component|; reconstructed from the other three with
45
- the constraint qx²+qy²+qz²+qw² = 1. Forces the dropped value
46
- non-negative so the +sqrt path on decode yields the correct sign.
47
- ]]
48
- function Quat.pack(qx: number, qy: number, qz: number, qw: number): number
49
- local ax, ay, az, aw = abs(qx), abs(qy), abs(qz), abs(qw)
50
- local largest, maxVal = 3, aw
51
- if ax > maxVal then
52
- largest, maxVal = 0, ax
53
- end
54
- if ay > maxVal then
55
- largest, maxVal = 1, ay
56
- end
57
- if az > maxVal then
58
- largest, maxVal = 2, az
59
- end
60
-
61
- local a: number, b: number, c: number
62
- if largest == 0 then
63
- if qx < 0 then
64
- qy, qz, qw = -qy, -qz, -qw
65
- end
66
- a, b, c = qy, qz, qw
67
- elseif largest == 1 then
68
- if qy < 0 then
69
- qx, qz, qw = -qx, -qz, -qw
70
- end
71
- a, b, c = qx, qz, qw
72
- elseif largest == 2 then
73
- if qz < 0 then
74
- qx, qy, qw = -qx, -qy, -qw
75
- end
76
- a, b, c = qx, qy, qw
77
- else
78
- if qw < 0 then
79
- qx, qy, qz = -qx, -qy, -qz
80
- end
81
- a, b, c = qx, qy, qz
82
- end
83
-
84
- local qa = clamp(round((a + INV_SQRT2) * Q_SCALE), 0, 1023)
85
- local qb = clamp(round((b + INV_SQRT2) * Q_SCALE), 0, 1023)
86
- local qc = clamp(round((c + INV_SQRT2) * Q_SCALE), 0, 1023)
87
- return bor(lshift(largest, 30), lshift(qa, 20), lshift(qb, 10), qc)
88
- end
89
-
90
- -- Reverse Quat.pack into a rotation-only CFrame. Identity for near-zero magnitudes.
91
- function Quat.unpack(packed: number): CFrame
92
- local largest = rshift(packed, 30)
93
- local qa = band(rshift(packed, 20), 0x3FF)
94
- local qb = band(rshift(packed, 10), 0x3FF)
95
- local qc = band(packed, 0x3FF)
96
-
97
- local a = qa * Q_INV - INV_SQRT2
98
- local b = qb * Q_INV - INV_SQRT2
99
- local c = qc * Q_INV - INV_SQRT2
100
-
101
- local sqSum = a * a + b * b + c * c
102
- local d = sqrt(if sqSum < 1 then 1 - sqSum else 0)
103
-
104
- local qx: number, qy: number, qz: number, qw: number
105
- if largest == 0 then
106
- qx, qy, qz, qw = d, a, b, c
107
- elseif largest == 1 then
108
- qx, qy, qz, qw = a, d, b, c
109
- elseif largest == 2 then
110
- qx, qy, qz, qw = a, b, d, c
111
- else
112
- qx, qy, qz, qw = a, b, c, d
113
- end
114
-
115
- local sqLen = qx * qx + qy * qy + qz * qz
116
- if sqLen < EPSILON_SQ then
117
- return CFrame.identity
118
- end
119
- local angle = 2 * acos(clamp(qw, -1, 1))
120
- local inv = 1 / sqrt(sqLen)
121
- return CFrame.fromAxisAngle(Vector3.new(qx * inv, qy * inv, qz * inv), angle)
122
- end
123
-
124
- return table.freeze(Quat)