rbxts-chrono 2.0.0-experimental.6 → 2.0.0-experimental.8

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.d.ts +231 -239
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rbxts-chrono",
3
- "version": "2.0.0-experimental.6",
3
+ "version": "2.0.0-experimental.8",
4
4
  "description": "TypeScript types for Chrono - Custom Character Replication for Roblox",
5
5
  "main": "src/init.lua",
6
6
  "types": "src/index.d.ts",
package/src/index.d.ts CHANGED
@@ -4,252 +4,257 @@
4
4
  * @see https://github.com/Parihsz/Chrono
5
5
  */
6
6
 
7
- // Model replication modes
8
- type ModelReplicationMode = "NATIVE" | "NATIVE_WITH_LOCK" | "CUSTOM";
9
-
10
- // Player replication modes
11
- type PlayerReplicationMode = "AUTOMATIC" | "CUSTOM";
12
-
13
- // Replication filter modes (used for REPLICATE_DEATHS and REPLICATE_CFRAME_SETTERS)
14
- type ReplicationFilterMode = "NONE" | "PLAYER_ENTITIES" | "PLAYER_CHARACTERS";
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
- | "SEND_FULL_ROTATION";
31
-
32
- // Event system types
33
- interface Connection {
34
- Disconnect(): void;
35
- Connected: boolean;
36
- }
37
-
38
- interface ChronoEvent<T extends Callback = Callback> {
39
- Connect(callback: T, defer?: boolean): Connection;
40
- Once(callback: T, defer?: boolean): Connection;
41
- Wait(defer?: boolean): LuaTuple<Parameters<T>>;
42
- }
43
-
44
- // Snapshot types
45
- interface SnapshotData<Value, Velocity> {
46
- t: number;
47
- value: Value;
48
- velocity: Velocity;
49
- }
50
-
51
- interface Snapshot<Value, Velocity> {
52
- Push(timeStamp: number, value: Value, velocity: Velocity): void;
53
- GetLatest(): SnapshotData<Value, Velocity> | undefined;
54
- GetAt(at: number, bypassLock?: boolean): Value | undefined;
55
- Clear(): void;
56
- }
57
-
58
- // Entity configuration input
59
- interface EntityConfigInput {
60
- BUFFER: number;
61
- TICK_RATE: number;
62
- FULL_ROTATION?: boolean;
63
- AUTO_UPDATE_POSITION?: boolean;
64
- STORE_SNAPSHOTS?: boolean;
65
- MODEL_REPLICATION_MODE?: ModelReplicationMode;
66
- NORMAL_TICK_DISTANCE?: number;
67
- HALF_TICK_DISTANCE?: number;
68
- CUSTOM_INTERPOLATION?: boolean;
69
- }
70
-
71
- // Stats interfaces
72
- interface ClientStats {
73
- TOTAL_ENTITIES_CULLED: number;
74
- ENTITIES_MOVED_THIS_FRAME: number;
75
- TOTAL_CLIENT_ENTITIES_CHECKED_THIS_FRAME: number;
76
- TOTAL_CLIENT_ENTITIES: number;
77
- AVG_INTERPOLATION_TIME_MS: number;
78
- BYTES_RECEIVED_PER_SEC: number;
79
- NEW_ENTITIES_PER_SEC: number;
80
- ENTITY_CHANGES_PER_SEC: number;
81
- ENTITY_REMOVALS_PER_SEC: number;
82
- }
83
-
84
- interface ServerStats {
85
- AVG_TICKER_TIME_MS: number;
86
- ENTITY_GRID_UPDATE_TIME_MS: number;
87
- GRID_UPDATE_SECTIONS: number;
88
- NUMBER_OF_ENTITIES: number;
89
- NON_TICKED: number;
90
- ENTITIES_FULL_TICKED: number;
91
- ENTITIES_HALF_TICKED: number;
92
- REPLICATE_PLAYER_TIME_MS: number;
93
- BYTES_RECEIVED_PER_SEC: number;
94
- BYTES_SENT_PER_SEC: number;
95
- PACKETS_SENT_PER_SEC: number;
96
- }
97
-
98
- // Entity event names
99
- type EntityEventName =
100
- | "Destroying"
101
- | "NetworkOwnerChanged"
102
- | "PushedSnapShot"
103
- | "TickChanged"
104
- | "DataChanged"
105
- | "Ticked"
106
- | "ModelChanged"
107
- | "LockChanged";
108
-
109
- // Entity interface (data only - methods are static on EntityConstructor)
110
- interface Entity {
111
- /** Unique identifier for this entity */
112
- readonly id: number;
113
-
114
- /** Whether this entity is registered with the system */
115
- readonly registered: boolean;
116
-
117
- /** Whether this entity has been destroyed */
118
- readonly destroyed: boolean;
119
-
120
- /** The player who owns this entity (controls its movement) */
121
- readonly networkOwner: Player | undefined;
122
-
123
- /** Whether the current context (client/server) is the network owner */
124
- readonly isContextOwner: boolean;
125
-
126
- /** The model associated with this entity */
127
- readonly model: Model | BasePart | undefined;
128
-
129
- /** Whether replication is paused for this entity */
130
- readonly paused: boolean;
131
-
132
- /** The most recent CFrame value */
133
- readonly latestCFrame: CFrame | undefined;
134
- }
135
-
136
- interface EntityConstructor {
137
- new (
138
- entityConfig?: string,
139
- model?: Model | BasePart | string,
140
- modelReplicationMode?: ModelReplicationMode,
141
- initCFrame?: CFrame,
142
- ): Entity;
143
-
144
- /** Sets or changes the model for an entity */
145
- SetModel: (
146
- entity: Entity,
147
- model?: Model | BasePart | string,
148
- modelReplicationMode?: ModelReplicationMode,
149
- noDestroy?: boolean,
150
- ) => void;
151
-
152
- /** Sets the entity configuration type */
153
- SetConfig: (entity: Entity, entityConfig: string) => void;
154
-
155
- /** Sets the broad phase collision bounds */
156
- SetBroadPhase: (entity: Entity, broadPhase?: Vector3) => void;
157
-
158
- /** Gets custom data associated with an entity */
159
- GetData: <T = unknown>(entity: Entity) => T;
160
-
161
- /** Gets the model associated with an entity */
162
- GetModel: (entity: Entity) => Model | BasePart | undefined;
163
-
164
- /** Sets custom data for an entity */
165
- SetData: (entity: Entity, data: unknown) => void;
7
+ declare namespace Chrono {
8
+ // ===== Type Aliases =====
9
+ export type ModelReplicationMode = "NATIVE" | "NATIVE_WITH_LOCK" | "CUSTOM";
10
+ export type PlayerReplicationMode = "AUTOMATIC" | "CUSTOM";
11
+ export type ReplicationFilterMode = "NONE" | "PLAYER_ENTITIES" | "PLAYER_CHARACTERS";
12
+
13
+ export type ConfigName =
14
+ | "MIN_BUFFER"
15
+ | "MAX_BUFFER"
16
+ | "SHOW_WARNINGS"
17
+ | "MAX_SNAPSHOT_COUNT"
18
+ | "CHECK_NEW_VERSION"
19
+ | "DEFAULT_NORMAL_TICK_DISTANCE"
20
+ | "DEFAULT_HALF_TICK_DISTANCE"
21
+ | "DEFAULT_MODEL_REPLICATION_MODE"
22
+ | "PLAYER_REPLICATION"
23
+ | "REPLICATE_DEATHS"
24
+ | "REPLICATE_CFRAME_SETTERS"
25
+ | "MAX_TOTAL_BYTES_PER_FRAME_PER_PLAYER"
26
+ | "SEND_FULL_ROTATION";
27
+
28
+ export type EntityEventName =
29
+ | "Destroying"
30
+ | "NetworkOwnerChanged"
31
+ | "PushedSnapShot"
32
+ | "TickChanged"
33
+ | "DataChanged"
34
+ | "Ticked"
35
+ | "ModelChanged"
36
+ | "LockChanged";
37
+
38
+ export type RuleFn = (entity: Entity, viewer: Player, viewerEntityId?: number) => boolean;
39
+ export type MiddleManFn = (player: Player, entity: Entity, cframe: CFrame, arriveTime: number) => boolean;
40
+
41
+ // ===== Interfaces =====
42
+ export interface ConfigValueMap {
43
+ MIN_BUFFER: number;
44
+ MAX_BUFFER: number;
45
+ SHOW_WARNINGS: boolean;
46
+ MAX_SNAPSHOT_COUNT: number;
47
+ CHECK_NEW_VERSION: boolean;
48
+ DEFAULT_NORMAL_TICK_DISTANCE: number;
49
+ DEFAULT_HALF_TICK_DISTANCE: number;
50
+ DEFAULT_MODEL_REPLICATION_MODE: ModelReplicationMode;
51
+ PLAYER_REPLICATION: PlayerReplicationMode;
52
+ REPLICATE_DEATHS: ReplicationFilterMode;
53
+ REPLICATE_CFRAME_SETTERS: ReplicationFilterMode;
54
+ MAX_TOTAL_BYTES_PER_FRAME_PER_PLAYER: number;
55
+ SEND_FULL_ROTATION: boolean;
56
+ }
166
57
 
167
- /** Clears the mount relationship */
168
- ClearMount: (entity: Entity) => void;
58
+ export interface Connection {
59
+ Disconnect(): void;
60
+ Connected: boolean;
61
+ }
169
62
 
170
- /** Mounts an entity to a parent entity with optional offset */
171
- SetMount: (entity: Entity, parent?: Entity, offset?: CFrame) => void;
63
+ export interface ChronoEvent<T extends Callback = Callback> {
64
+ Connect(callback: T, defer?: boolean): Connection;
65
+ Once(callback: T, defer?: boolean): Connection;
66
+ Wait(defer?: boolean): LuaTuple<Parameters<T>>;
67
+ }
172
68
 
173
- /** Sets the network owner (player who controls this entity) */
174
- SetNetworkOwner: (entity: Entity, player?: Player) => void;
69
+ export interface SnapshotData<Value, Velocity> {
70
+ t: number;
71
+ value: Value;
72
+ velocity: Velocity;
73
+ }
175
74
 
176
- /** Clears the entity's snapshot buffer */
177
- Clear: (entity: Entity) => void;
75
+ export interface Snapshot<Value, Velocity> {
76
+ Push(timeStamp: number, value: Value, velocity: Velocity): void;
77
+ GetLatest(): SnapshotData<Value, Velocity> | undefined;
78
+ GetAt(at: number, bypassLock?: boolean): Value | undefined;
79
+ Clear(): void;
80
+ }
178
81
 
179
- /** Pauses replication for an entity */
180
- PauseReplication: (entity: Entity) => void;
82
+ export interface EntityConfigInput {
83
+ BUFFER: number;
84
+ TICK_RATE: number;
85
+ FULL_ROTATION?: boolean;
86
+ AUTO_UPDATE_POSITION?: boolean;
87
+ STORE_SNAPSHOTS?: boolean;
88
+ MODEL_REPLICATION_MODE?: ModelReplicationMode;
89
+ NORMAL_TICK_DISTANCE?: number;
90
+ HALF_TICK_DISTANCE?: number;
91
+ CUSTOM_INTERPOLATION?: boolean;
92
+ }
181
93
 
182
- /** Resumes replication for an entity */
183
- ResumeReplication: (entity: Entity) => void;
94
+ export interface ClientStats {
95
+ TOTAL_ENTITIES_CULLED: number;
96
+ ENTITIES_MOVED_THIS_FRAME: number;
97
+ TOTAL_CLIENT_ENTITIES_CHECKED_THIS_FRAME: number;
98
+ TOTAL_CLIENT_ENTITIES: number;
99
+ AVG_INTERPOLATION_TIME_MS: number;
100
+ BYTES_RECEIVED_PER_SEC: number;
101
+ NEW_ENTITIES_PER_SEC: number;
102
+ ENTITY_CHANGES_PER_SEC: number;
103
+ ENTITY_REMOVALS_PER_SEC: number;
104
+ }
184
105
 
185
- /** Pushes a new CFrame snapshot at the given time */
186
- Push: (entity: Entity, time: number, value: CFrame) => boolean;
106
+ export interface ServerStats {
107
+ AVG_TICKER_TIME_MS: number;
108
+ ENTITY_GRID_UPDATE_TIME_MS: number;
109
+ GRID_UPDATE_SECTIONS: number;
110
+ NUMBER_OF_ENTITIES: number;
111
+ NON_TICKED: number;
112
+ ENTITIES_FULL_TICKED: number;
113
+ ENTITIES_HALF_TICKED: number;
114
+ REPLICATE_PLAYER_TIME_MS: number;
115
+ BYTES_RECEIVED_PER_SEC: number;
116
+ BYTES_SENT_PER_SEC: number;
117
+ PACKETS_SENT_PER_SEC: number;
118
+ }
187
119
 
188
- /** Gets the interpolated CFrame at a specific time */
189
- GetAt: (entity: Entity, time: number) => CFrame | undefined;
120
+ export interface Entity {
121
+ /** Unique identifier for this entity */
122
+ readonly id: number;
190
123
 
191
- /** Gets the target render time for interpolation */
192
- GetTargetRenderTime: (entity: Entity) => number;
124
+ /** Whether this entity is registered with the system */
125
+ readonly registered: boolean;
193
126
 
194
- /** Sets whether position updates automatically */
195
- SetAutoUpdatePos: (entity: Entity, autoUpdate: boolean) => void;
127
+ /** Whether this entity has been destroyed */
128
+ readonly destroyed: boolean;
196
129
 
197
- /** Gets the current CFrame */
198
- GetCFrame: (entity: Entity) => CFrame | undefined;
130
+ /** The player who owns this entity (controls its movement) */
131
+ readonly networkOwner: Player | undefined;
199
132
 
200
- /** Sets the current CFrame */
201
- SetCFrame: (entity: Entity, cframe: CFrame) => void;
133
+ /** Whether the current context (client/server) is the network owner */
134
+ readonly isContextOwner: boolean;
202
135
 
203
- /** Gets the primary part of the model */
204
- GetPrimaryPart: (entity: Entity) => BasePart | undefined;
136
+ /** The model associated with this entity */
137
+ readonly model: Model | BasePart | undefined;
205
138
 
206
- /** Locks native server CFrame replication */
207
- LockNativeServerCFrameReplication: (entity: Entity) => void;
139
+ /** Whether replication is paused for this entity */
140
+ readonly paused: boolean;
208
141
 
209
- /** Unlocks native server CFrame replication */
210
- UnlockNativeServerCFrameReplication: (entity: Entity) => void;
142
+ /** The most recent CFrame value */
143
+ readonly latestCFrame: CFrame | undefined;
144
+ }
211
145
 
212
- /** Destroys an entity */
213
- Destroy: (entity: Entity) => void;
146
+ export interface EntityConstructor {
147
+ new (
148
+ entityConfig?: string,
149
+ model?: Model | BasePart | string,
150
+ modelReplicationMode?: ModelReplicationMode,
151
+ initCFrame?: CFrame,
152
+ ): Entity;
214
153
 
215
- /** Gets an event by name */
216
- GetEvent: ((entity: Entity, name: "Destroying") => ChronoEvent<(entity: Entity) => void>) &
217
- ((
218
- entity: Entity,
219
- name: "NetworkOwnerChanged",
220
- ) => ChronoEvent<(entity: Entity, newOwner: Player | undefined, prevOwner: Player | undefined) => void>) &
221
- ((
222
- entity: Entity,
223
- name: "PushedSnapShot",
224
- ) => ChronoEvent<(entity: Entity, time: number, value: CFrame, isNewest: boolean) => void>) &
225
- ((
226
- entity: Entity,
227
- name: "TickChanged",
228
- ) => ChronoEvent<(entity: Entity, newTickType: "NONE" | "HALF" | "NORMAL") => void>) &
229
- ((entity: Entity, name: "DataChanged") => ChronoEvent<(entity: Entity, data: unknown) => void>) &
230
- ((entity: Entity, name: "Ticked") => ChronoEvent<(entity: Entity, dt: number) => void>) &
231
- ((
154
+ /** Sets or changes the model for an entity */
155
+ SetModel: (
232
156
  entity: Entity,
233
- name: "ModelChanged",
234
- ) => ChronoEvent<
235
- (entity: Entity, newModel: Model | BasePart | undefined, oldModel: Model | BasePart | undefined) => void
236
- >) &
237
- ((entity: Entity, name: "LockChanged") => ChronoEvent<(entity: Entity, isLocked: boolean) => void>) &
238
- ((entity: Entity, name: EntityEventName) => ChronoEvent);
239
- }
240
-
241
- // Replication rule types
242
- type RuleFn = (entity: Entity, viewer: Player, viewerEntityId?: number) => boolean;
157
+ model?: Model | BasePart | string,
158
+ modelReplicationMode?: ModelReplicationMode,
159
+ noDestroy?: boolean,
160
+ ) => void;
161
+
162
+ /** Sets the entity configuration type */
163
+ SetConfig: (entity: Entity, entityConfig: string) => void;
164
+
165
+ /** Sets the broad phase collision bounds */
166
+ SetBroadPhase: (entity: Entity, broadPhase?: Vector3) => void;
167
+
168
+ /** Gets custom data associated with an entity */
169
+ GetData: <T = unknown>(entity: Entity) => T;
170
+
171
+ /** Gets the model associated with an entity */
172
+ GetModel: (entity: Entity) => Model | BasePart | undefined;
173
+
174
+ /** Sets custom data for an entity */
175
+ SetData: (entity: Entity, data: unknown) => void;
176
+
177
+ /** Clears the mount relationship */
178
+ ClearMount: (entity: Entity) => void;
179
+
180
+ /** Mounts an entity to a parent entity with optional offset */
181
+ SetMount: (entity: Entity, parent?: Entity, offset?: CFrame) => void;
182
+
183
+ /** Sets the network owner (player who controls this entity) */
184
+ SetNetworkOwner: (entity: Entity, player?: Player) => void;
185
+
186
+ /** Clears the entity's snapshot buffer */
187
+ Clear: (entity: Entity) => void;
188
+
189
+ /** Pauses replication for an entity */
190
+ PauseReplication: (entity: Entity) => void;
191
+
192
+ /** Resumes replication for an entity */
193
+ ResumeReplication: (entity: Entity) => void;
194
+
195
+ /** Pushes a new CFrame snapshot at the given time */
196
+ Push: (entity: Entity, time: number, value: CFrame) => boolean;
197
+
198
+ /** Gets the interpolated CFrame at a specific time */
199
+ GetAt: (entity: Entity, time: number) => CFrame | undefined;
200
+
201
+ /** Gets the target render time for interpolation */
202
+ GetTargetRenderTime: (entity: Entity) => number;
203
+
204
+ /** Sets whether position updates automatically */
205
+ SetAutoUpdatePos: (entity: Entity, autoUpdate: boolean) => void;
206
+
207
+ /** Gets the current CFrame */
208
+ GetCFrame: (entity: Entity) => CFrame | undefined;
209
+
210
+ /** Sets the current CFrame */
211
+ SetCFrame: (entity: Entity, cframe: CFrame) => void;
212
+
213
+ /** Gets the primary part of the model */
214
+ GetPrimaryPart: (entity: Entity) => BasePart | undefined;
215
+
216
+ /** Locks native server CFrame replication */
217
+ LockNativeServerCFrameReplication: (entity: Entity) => void;
218
+
219
+ /** Unlocks native server CFrame replication */
220
+ UnlockNativeServerCFrameReplication: (entity: Entity) => void;
221
+
222
+ /** Destroys an entity */
223
+ Destroy: (entity: Entity) => void;
224
+
225
+ /** Gets an event by name */
226
+ GetEvent: ((entity: Entity, name: "Destroying") => ChronoEvent<(entity: Entity) => void>) &
227
+ ((
228
+ entity: Entity,
229
+ name: "NetworkOwnerChanged",
230
+ ) => ChronoEvent<(entity: Entity, newOwner: Player | undefined, prevOwner: Player | undefined) => void>) &
231
+ ((
232
+ entity: Entity,
233
+ name: "PushedSnapShot",
234
+ ) => ChronoEvent<(entity: Entity, time: number, value: CFrame, isNewest: boolean) => void>) &
235
+ ((
236
+ entity: Entity,
237
+ name: "TickChanged",
238
+ ) => ChronoEvent<(entity: Entity, newTickType: "NONE" | "HALF" | "NORMAL") => void>) &
239
+ ((entity: Entity, name: "DataChanged") => ChronoEvent<(entity: Entity, data: unknown) => void>) &
240
+ ((entity: Entity, name: "Ticked") => ChronoEvent<(entity: Entity, dt: number) => void>) &
241
+ ((
242
+ entity: Entity,
243
+ name: "ModelChanged",
244
+ ) => ChronoEvent<
245
+ (entity: Entity, newModel: Model | BasePart | undefined, oldModel: Model | BasePart | undefined) => void
246
+ >) &
247
+ ((entity: Entity, name: "LockChanged") => ChronoEvent<(entity: Entity, isLocked: boolean) => void>) &
248
+ ((entity: Entity, name: EntityEventName) => ChronoEvent);
249
+ }
243
250
 
244
- interface ReplicationRule {
245
- filterType: "include" | "exclude";
246
- filterPlayers?: Player[];
247
- }
251
+ export interface ReplicationRule {
252
+ filterType: "include" | "exclude";
253
+ filterPlayers?: Player[];
254
+ }
248
255
 
249
- // Middleware function type for Receiver
250
- type MiddleManFn = (player: Player, entity: Entity, cframe: CFrame, arriveTime: number) => boolean;
256
+ // ===== Functions and Values =====
251
257
 
252
- declare namespace Chrono {
253
258
  /** Starts the Chrono system */
254
259
  function Start(config?: ModuleScript): void;
255
260
 
@@ -310,20 +315,7 @@ declare namespace Chrono {
310
315
  /** Configuration functions */
311
316
  namespace Config {
312
317
  /** Sets a configuration value (must be called before Start) */
313
- function SetConfig(name: "MIN_BUFFER", value: number): void;
314
- function SetConfig(name: "MAX_BUFFER", value: number): void;
315
- function SetConfig(name: "SHOW_WARNINGS", value: boolean): void;
316
- function SetConfig(name: "MAX_SNAPSHOT_COUNT", value: number): void;
317
- function SetConfig(name: "CHECK_NEW_VERSION", value: boolean): void;
318
- function SetConfig(name: "DEFAULT_NORMAL_TICK_DISTANCE", value: number): void;
319
- function SetConfig(name: "DEFAULT_HALF_TICK_DISTANCE", value: number): void;
320
- function SetConfig(name: "DEFAULT_MODEL_REPLICATION_MODE", value: ModelReplicationMode): void;
321
- function SetConfig(name: "PLAYER_REPLICATION", value: PlayerReplicationMode): void;
322
- function SetConfig(name: "REPLICATE_DEATHS", value: ReplicationFilterMode): void;
323
- function SetConfig(name: "REPLICATE_CFRAME_SETTERS", value: ReplicationFilterMode): void;
324
- function SetConfig(name: "MAX_TOTAL_BYTES_PER_FRAME_PER_PLAYER", value: number): void;
325
- function SetConfig(name: "SEND_FULL_ROTATION", value: boolean): void;
326
- function SetConfig(name: ConfigName, value: unknown): void;
318
+ function SetConfig<K extends ConfigName>(name: K, value: ConfigValueMap[K]): void;
327
319
 
328
320
  /** Registers a custom entity type configuration */
329
321
  function RegisterEntityType(name: string, config: EntityConfigInput): void;