rbxts-chrono 2.0.0-experimental.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tadas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # rbxts-chrono
2
+ TypeScript type definitions for Chrono
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "chrono",
3
+ "tree": {
4
+ "$path": "src"
5
+ }
6
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "rbxts-chrono",
3
+ "version": "2.0.0-experimental.1",
4
+ "description": "TypeScript types for Chrono - Custom Character Replication for Roblox",
5
+ "main": "src/init.lua",
6
+ "types": "src/index.d.ts",
7
+ "files": [
8
+ "src",
9
+ "default.project.json"
10
+ ],
11
+ "keywords": [
12
+ "roblox",
13
+ "roblox-ts",
14
+ "chrono",
15
+ "replication",
16
+ "npc",
17
+ "character"
18
+ ],
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "chrono-lua": "github:Parihsz/Chrono#v2.0.0-experimental"
22
+ },
23
+ "peerDependencies": {
24
+ "@rbxts/types": "*"
25
+ }
26
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,368 @@
1
+ /**
2
+ * TypeScript definitions for Chrono v2.0.0-experimental
3
+ * Custom Character Replication for Roblox
4
+ * @see https://github.com/Parihsz/Chrono
5
+ */
6
+
7
+ // Model replication modes
8
+ type ModelReplicationMode = "NATIVE" | "NATIVE_WITH_LOCK" | "CUSTOM";
9
+
10
+ // Player replication modes
11
+ type PlayerReplicationMode = "AUTOMATIC" | "MANUAL";
12
+
13
+ // Death replication modes
14
+ type ReplicateDeathsMode = "PLAYER_ENTITIES" | "ALL" | "NONE";
15
+
16
+ // Configuration option names
17
+ type ConfigName =
18
+ | "MIN_BUFFER"
19
+ | "MAX_BUFFER"
20
+ | "SHOW_WARNINGS"
21
+ | "MAX_SNAPSHOT_COUNT"
22
+ | "CHECK_NEW_VERSION"
23
+ | "DEFAULT_NORMAL_TICK_DISTANCE"
24
+ | "DEFAULT_HALF_TICK_DISTANCE"
25
+ | "DEFAULT_MODEL_REPLICATION_MODE"
26
+ | "PLAYER_REPLICATION"
27
+ | "REPLICATE_DEATHS"
28
+ | "REPLICATE_CFRAME_SETTERS"
29
+ | "MAX_TOTAL_BYTES_PER_FRAME_PER_PLAYER";
30
+
31
+ // Event system types
32
+ interface Connection {
33
+ Disconnect(): void;
34
+ Connected: boolean;
35
+ }
36
+
37
+ interface ChronoEvent<T extends Callback = Callback> {
38
+ Connect(callback: T): Connection;
39
+ Once(callback: T): Connection;
40
+ Wait(): LuaTuple<Parameters<T>>;
41
+ }
42
+
43
+ // Snapshot types
44
+ interface SnapshotData<Value, Velocity> {
45
+ timeStamp: number;
46
+ value: Value;
47
+ velocity: Velocity;
48
+ }
49
+
50
+ interface Snapshot<Value, Velocity> {
51
+ Push(timeStamp: number, value: Value, velocity: Velocity): void;
52
+ GetLatest(): SnapshotData<Value, Velocity> | undefined;
53
+ GetAt(at: number, bypassLock?: boolean): Value | undefined;
54
+ Clear(): void;
55
+ }
56
+
57
+ // Entity configuration input
58
+ interface EntityConfigInput {
59
+ TICK_RATE?: number;
60
+ CLIENT_CLOCK?: {
61
+ MIN_BUFFER?: number;
62
+ MAX_BUFFER?: number;
63
+ };
64
+ BUFFER?: {
65
+ MIN?: number;
66
+ MAX?: number;
67
+ };
68
+ MODEL_REPLICATION_MODE?: ModelReplicationMode;
69
+ NORMAL_TICK_DISTANCE?: number;
70
+ HALF_TICK_DISTANCE?: number;
71
+ }
72
+
73
+ // Stats interfaces
74
+ interface ClientStats {
75
+ TOTAL_ENTITIES_CULLED: number;
76
+ ENTITIES_MOVED_THIS_FRAME: number;
77
+ TOTAL_CLIENT_ENTITIES_CHECKED_THIS_FRAME: number;
78
+ TOTAL_CLIENT_ENTITIES: number;
79
+ AVG_INTERPOLATION_TIME_MS: number;
80
+ BYTES_RECEIVED_PER_SEC: number;
81
+ NEW_ENTITIES_PER_SEC: number;
82
+ ENTITY_CHANGES_PER_SEC: number;
83
+ ENTITY_REMOVALS_PER_SEC: number;
84
+ }
85
+
86
+ interface ServerStats {
87
+ AVG_TICKER_TIME_MS: number;
88
+ ENTITY_GRID_UPDATE_TIME_MS: number;
89
+ GRID_UPDATE_SECTIONS: number;
90
+ NUMBER_OF_ENTITIES: number;
91
+ NON_TICKED: number;
92
+ ENTITIES_FULL_TICKED: number;
93
+ ENTITIES_HALF_TICKED: number;
94
+ REPLICATE_PLAYER_TIME_MS: number;
95
+ BYTES_RECEIVED_PER_SEC: number;
96
+ BYTES_SENT_PER_SEC: number;
97
+ PACKETS_SENT_PER_SEC: number;
98
+ }
99
+
100
+ // Entity event names
101
+ type EntityEventName =
102
+ | "OnDestroy"
103
+ | "OnModelSet"
104
+ | "OnModelRemoved"
105
+ | "OnCFrameSet"
106
+ | "OnDataSet"
107
+ | "OnMountSet"
108
+ | "OnMountCleared"
109
+ | "OnNetworkOwnerSet"
110
+ | "OnReplicationPaused"
111
+ | "OnReplicationResumed";
112
+
113
+ // Entity interface
114
+ interface Entity {
115
+ /** Sets or changes the model for this entity */
116
+ SetModel(
117
+ model?: Model | BasePart | string,
118
+ modelReplicationMode?: ModelReplicationMode,
119
+ noDestroy?: boolean,
120
+ ): void;
121
+
122
+ /** Sets the entity configuration type */
123
+ SetConfig(entityConfig: string): void;
124
+
125
+ /** Sets the broad phase collision bounds */
126
+ SetBroadPhase(broadPhase?: Vector3): void;
127
+
128
+ /** Gets custom data associated with this entity */
129
+ GetData<T = unknown>(): T;
130
+
131
+ /** Gets the model associated with this entity */
132
+ GetModel(): Model | BasePart | undefined;
133
+
134
+ /** Sets custom data for this entity */
135
+ SetData(data: unknown): void;
136
+
137
+ /** Clears the mount relationship */
138
+ ClearMount(): void;
139
+
140
+ /** Mounts this entity to a parent entity with optional offset */
141
+ SetMount(parent?: Entity, offset?: CFrame): void;
142
+
143
+ /** Sets the network owner (player who controls this entity) */
144
+ SetNetworkOwner(player?: Player): void;
145
+
146
+ /** Clears the entity's snapshot buffer */
147
+ Clear(): void;
148
+
149
+ /** Pauses replication for this entity */
150
+ PauseReplication(): void;
151
+
152
+ /** Resumes replication for this entity */
153
+ ResumeReplication(): void;
154
+
155
+ /** Pushes a new CFrame snapshot at the given time */
156
+ Push(time: number, value: CFrame): boolean;
157
+
158
+ /** Gets the interpolated CFrame at a specific time */
159
+ GetAt(time: number): CFrame | undefined;
160
+
161
+ /** Gets the target render time for interpolation */
162
+ GetTargetRenderTime(): number;
163
+
164
+ /** Sets whether position updates automatically */
165
+ SetAutoUpdatePos(autoUpdate: boolean): void;
166
+
167
+ /** Gets the current CFrame */
168
+ GetCFrame(): CFrame | undefined;
169
+
170
+ /** Sets the current CFrame */
171
+ SetCFrame(cframe: CFrame): void;
172
+
173
+ /** Gets the primary part of the model */
174
+ GetPrimaryPart(): BasePart | undefined;
175
+
176
+ /** Locks native server CFrame replication */
177
+ LockNativeServerCFrameReplication(): void;
178
+
179
+ /** Unlocks native server CFrame replication */
180
+ UnlockNativeServerCFrameReplication(): void;
181
+
182
+ /** Destroys this entity */
183
+ Destroy(): void;
184
+
185
+ /** Gets an event by name */
186
+ GetEvent(name: "OnDestroy"): ChronoEvent<() => void>;
187
+ GetEvent(name: "OnModelSet"): ChronoEvent<(model: Model | BasePart) => void>;
188
+ GetEvent(name: "OnModelRemoved"): ChronoEvent<(model: Model | BasePart) => void>;
189
+ GetEvent(name: "OnCFrameSet"): ChronoEvent<(cframe: CFrame) => void>;
190
+ GetEvent(name: "OnDataSet"): ChronoEvent<(data: unknown) => void>;
191
+ GetEvent(name: "OnMountSet"): ChronoEvent<(parent: Entity, offset: CFrame) => void>;
192
+ GetEvent(name: "OnMountCleared"): ChronoEvent<() => void>;
193
+ GetEvent(name: "OnNetworkOwnerSet"): ChronoEvent<(player: Player | undefined) => void>;
194
+ GetEvent(name: "OnReplicationPaused"): ChronoEvent<() => void>;
195
+ GetEvent(name: "OnReplicationResumed"): ChronoEvent<() => void>;
196
+ GetEvent(name: EntityEventName): ChronoEvent;
197
+ }
198
+
199
+ interface EntityConstructor {
200
+ new (
201
+ entityConfig?: string,
202
+ model?: Model | BasePart | string,
203
+ modelReplicationMode?: ModelReplicationMode,
204
+ initCFrame?: CFrame,
205
+ ): Entity;
206
+ }
207
+
208
+ // Replication rule types
209
+ type RuleFn = (entity: Entity, viewer: Player, viewerEntityId?: number) => boolean;
210
+
211
+ interface ReplicationRule {
212
+ filterType: "include" | "exclude";
213
+ filterPlayers?: Player[];
214
+ }
215
+
216
+ // Middleware function type for Receiver
217
+ type MiddleManFn = (player: Player, entity: Entity, cframe: CFrame, arriveTime: number) => boolean;
218
+
219
+ declare namespace Chrono {
220
+ /** Starts the Chrono system */
221
+ function Start(config?: ModuleScript): void;
222
+
223
+ /** Entity constructor */
224
+ const Entity: EntityConstructor;
225
+
226
+ /** Entity holder/registry functions */
227
+ namespace Holder {
228
+ /** Registers an entity with the system */
229
+ function RegisterEntity(entity: Entity): void;
230
+
231
+ /** Unregisters an entity from the system */
232
+ function UnregisterEntity(entity: Entity): void;
233
+
234
+ /** Gets the storage instance for entities */
235
+ function GetEntityStorageInstance(): Camera;
236
+
237
+ /** Associates a player with an entity as their character */
238
+ function SetAsCharacter(player: Player, entity: Entity): void;
239
+
240
+ /** Removes a player's character association */
241
+ function RemovePlayerCharacter(entity: Entity): void;
242
+
243
+ /** Gets the entity associated with a player */
244
+ function GetEntityFromPlayer(player: Player): Entity | undefined;
245
+
246
+ /** Gets an entity by its ID */
247
+ function GetEntityFromId(id: number): Entity | undefined;
248
+
249
+ /** Gets the entity associated with a model */
250
+ function GetEntityFromModel(model: Model): Entity | undefined;
251
+
252
+ /** Map of entity IDs to entities */
253
+ const idMap: Map<number, Entity>;
254
+ }
255
+
256
+ /** Global events */
257
+ namespace Events {
258
+ /** Fires when an entity is added */
259
+ const EntityAdded: ChronoEvent<(entity: Entity) => void>;
260
+
261
+ /** Fires when an entity is removed */
262
+ const EntityRemoved: ChronoEvent<(entity: Entity) => void>;
263
+
264
+ /** Fires when a player character is registered */
265
+ const PlayerCharacterRegistered: ChronoEvent<(player: Player, entity: Entity) => void>;
266
+
267
+ /** Fires when a player character is unregistered */
268
+ const PlayerCharacterUnregistered: ChronoEvent<(player: Player, entity: Entity) => void>;
269
+
270
+ /** Fires when a player gains ownership of an entity */
271
+ const PlayerOwnedAdded: ChronoEvent<(player: Player, entity: Entity) => void>;
272
+
273
+ /** Fires when a player loses ownership of an entity */
274
+ const PlayerOwnedRemoved: ChronoEvent<(player: Player, entity: Entity) => void>;
275
+ }
276
+
277
+ /** Configuration functions */
278
+ namespace Config {
279
+ /** Sets a configuration value (must be called before Start) */
280
+ function SetConfig(name: "MIN_BUFFER", value: number): void;
281
+ function SetConfig(name: "MAX_BUFFER", value: number): void;
282
+ function SetConfig(name: "SHOW_WARNINGS", value: boolean): void;
283
+ function SetConfig(name: "MAX_SNAPSHOT_COUNT", value: number): void;
284
+ function SetConfig(name: "CHECK_NEW_VERSION", value: boolean): void;
285
+ function SetConfig(name: "DEFAULT_NORMAL_TICK_DISTANCE", value: number): void;
286
+ function SetConfig(name: "DEFAULT_HALF_TICK_DISTANCE", value: number): void;
287
+ function SetConfig(name: "DEFAULT_MODEL_REPLICATION_MODE", value: ModelReplicationMode): void;
288
+ function SetConfig(name: "PLAYER_REPLICATION", value: PlayerReplicationMode): void;
289
+ function SetConfig(name: "REPLICATE_DEATHS", value: ReplicateDeathsMode): void;
290
+ function SetConfig(name: "REPLICATE_CFRAME_SETTERS", value: boolean): void;
291
+ function SetConfig(name: "MAX_TOTAL_BYTES_PER_FRAME_PER_PLAYER", value: number): void;
292
+ function SetConfig(name: ConfigName, value: unknown): void;
293
+
294
+ /** Registers a custom entity type configuration */
295
+ function RegisterEntityType(name: string, config: EntityConfigInput): void;
296
+
297
+ /** Registers a model for an entity type */
298
+ function RegisterEntityModel(name: string, model: Model | BasePart, broadPhase?: Vector3): void;
299
+ }
300
+
301
+ /** Replication rules for controlling entity visibility */
302
+ namespace ReplicationRules {
303
+ /** Sets a replication rule for a target */
304
+ function SetReplicationRule(
305
+ target: Player | Model | number | Entity,
306
+ rule: ReplicationRule | RuleFn,
307
+ ): void;
308
+
309
+ /** Checks if an entity should be replicated to a viewer */
310
+ function Allows(entity: Entity, viewer: Player, viewerEntityId?: number): boolean;
311
+
312
+ /** Creates a rule that only includes specified players */
313
+ function Include(players: Player[]): RuleFn;
314
+
315
+ /** Creates a rule that excludes specified players */
316
+ function Exclude(players: Player[]): RuleFn;
317
+ }
318
+
319
+ /** Statistics and metrics */
320
+ namespace Stats {
321
+ /** Client-side statistics */
322
+ const CLIENT: ClientStats;
323
+
324
+ /** Server-side statistics */
325
+ const SERVER: ServerStats;
326
+
327
+ /** Permission map for stat replication (user IDs to boolean) */
328
+ let REPLICATE_PERMISSIONS: Map<number, boolean> | undefined;
329
+ }
330
+
331
+ /** Server-side receiver middleware (Server only) */
332
+ namespace Receiver {
333
+ /** Registers a middleware function to intercept entity updates */
334
+ function RegisterMiddleMan(name: string, priority: number, func: MiddleManFn): void;
335
+
336
+ /** Unregisters a middleware function */
337
+ function UnregisterMiddleMan(name: string): void;
338
+ }
339
+
340
+ /** Server clock utilities (Server only) */
341
+ namespace ServerClock {
342
+ /** Stores clock synchronization data for a player */
343
+ function Store(player: Player, clientClockTime: number): void;
344
+
345
+ /** Converts a clock value between server and client time */
346
+ function ConvertTo(player: Player, clock: number, environment: "Server" | "Client"): number;
347
+
348
+ /** Removes clock data for a player */
349
+ function Remove(player: Player): void;
350
+ }
351
+
352
+ /** Snapshot utilities */
353
+ namespace Snapshots {
354
+ /** Creates a new snapshot manager with a custom interpolation function */
355
+ function New<Value, Velocity>(
356
+ lerpFunction: (
357
+ v1: Value,
358
+ v2: Value,
359
+ vel1: Velocity,
360
+ vel2: Velocity,
361
+ t: number,
362
+ dt: number,
363
+ ) => Value,
364
+ ): Snapshot<Value, Velocity>;
365
+ }
366
+ }
367
+
368
+ export = Chrono;
package/src/init.lua ADDED
@@ -0,0 +1,5 @@
1
+ -- rbxts-chrono: TypeScript types for Chrono
2
+ -- Re-exports the chrono-lua dependency
3
+
4
+ local Packages = script.Parent.Parent.Parent
5
+ return require(Packages["chrono-lua"].src)