rbxts-chrono 2.0.0-experimental.7 → 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 +230 -254
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rbxts-chrono",
3
- "version": "2.0.0-experimental.7",
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,269 +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
- // Configuration value types mapped to config names
33
- interface ConfigValueMap {
34
- MIN_BUFFER: number;
35
- MAX_BUFFER: number;
36
- SHOW_WARNINGS: boolean;
37
- MAX_SNAPSHOT_COUNT: number;
38
- CHECK_NEW_VERSION: boolean;
39
- DEFAULT_NORMAL_TICK_DISTANCE: number;
40
- DEFAULT_HALF_TICK_DISTANCE: number;
41
- DEFAULT_MODEL_REPLICATION_MODE: ModelReplicationMode;
42
- PLAYER_REPLICATION: PlayerReplicationMode;
43
- REPLICATE_DEATHS: ReplicationFilterMode;
44
- REPLICATE_CFRAME_SETTERS: ReplicationFilterMode;
45
- MAX_TOTAL_BYTES_PER_FRAME_PER_PLAYER: number;
46
- SEND_FULL_ROTATION: boolean;
47
- }
48
-
49
- // Event system types
50
- interface Connection {
51
- Disconnect(): void;
52
- Connected: boolean;
53
- }
54
-
55
- interface ChronoEvent<T extends Callback = Callback> {
56
- Connect(callback: T, defer?: boolean): Connection;
57
- Once(callback: T, defer?: boolean): Connection;
58
- Wait(defer?: boolean): LuaTuple<Parameters<T>>;
59
- }
60
-
61
- // Snapshot types
62
- interface SnapshotData<Value, Velocity> {
63
- t: number;
64
- value: Value;
65
- velocity: Velocity;
66
- }
67
-
68
- interface Snapshot<Value, Velocity> {
69
- Push(timeStamp: number, value: Value, velocity: Velocity): void;
70
- GetLatest(): SnapshotData<Value, Velocity> | undefined;
71
- GetAt(at: number, bypassLock?: boolean): Value | undefined;
72
- Clear(): void;
73
- }
74
-
75
- // Entity configuration input
76
- interface EntityConfigInput {
77
- BUFFER: number;
78
- TICK_RATE: number;
79
- FULL_ROTATION?: boolean;
80
- AUTO_UPDATE_POSITION?: boolean;
81
- STORE_SNAPSHOTS?: boolean;
82
- MODEL_REPLICATION_MODE?: ModelReplicationMode;
83
- NORMAL_TICK_DISTANCE?: number;
84
- HALF_TICK_DISTANCE?: number;
85
- CUSTOM_INTERPOLATION?: boolean;
86
- }
87
-
88
- // Stats interfaces
89
- interface ClientStats {
90
- TOTAL_ENTITIES_CULLED: number;
91
- ENTITIES_MOVED_THIS_FRAME: number;
92
- TOTAL_CLIENT_ENTITIES_CHECKED_THIS_FRAME: number;
93
- TOTAL_CLIENT_ENTITIES: number;
94
- AVG_INTERPOLATION_TIME_MS: number;
95
- BYTES_RECEIVED_PER_SEC: number;
96
- NEW_ENTITIES_PER_SEC: number;
97
- ENTITY_CHANGES_PER_SEC: number;
98
- ENTITY_REMOVALS_PER_SEC: number;
99
- }
100
-
101
- interface ServerStats {
102
- AVG_TICKER_TIME_MS: number;
103
- ENTITY_GRID_UPDATE_TIME_MS: number;
104
- GRID_UPDATE_SECTIONS: number;
105
- NUMBER_OF_ENTITIES: number;
106
- NON_TICKED: number;
107
- ENTITIES_FULL_TICKED: number;
108
- ENTITIES_HALF_TICKED: number;
109
- REPLICATE_PLAYER_TIME_MS: number;
110
- BYTES_RECEIVED_PER_SEC: number;
111
- BYTES_SENT_PER_SEC: number;
112
- PACKETS_SENT_PER_SEC: number;
113
- }
114
-
115
- // Entity event names
116
- type EntityEventName =
117
- | "Destroying"
118
- | "NetworkOwnerChanged"
119
- | "PushedSnapShot"
120
- | "TickChanged"
121
- | "DataChanged"
122
- | "Ticked"
123
- | "ModelChanged"
124
- | "LockChanged";
125
-
126
- // Entity interface (data only - methods are static on EntityConstructor)
127
- interface Entity {
128
- /** Unique identifier for this entity */
129
- readonly id: number;
130
-
131
- /** Whether this entity is registered with the system */
132
- readonly registered: boolean;
133
-
134
- /** Whether this entity has been destroyed */
135
- readonly destroyed: boolean;
136
-
137
- /** The player who owns this entity (controls its movement) */
138
- readonly networkOwner: Player | undefined;
139
-
140
- /** Whether the current context (client/server) is the network owner */
141
- readonly isContextOwner: boolean;
142
-
143
- /** The model associated with this entity */
144
- readonly model: Model | BasePart | undefined;
145
-
146
- /** Whether replication is paused for this entity */
147
- readonly paused: boolean;
148
-
149
- /** The most recent CFrame value */
150
- readonly latestCFrame: CFrame | undefined;
151
- }
152
-
153
- interface EntityConstructor {
154
- new (
155
- entityConfig?: string,
156
- model?: Model | BasePart | string,
157
- modelReplicationMode?: ModelReplicationMode,
158
- initCFrame?: CFrame,
159
- ): Entity;
160
-
161
- /** Sets or changes the model for an entity */
162
- SetModel: (
163
- entity: Entity,
164
- model?: Model | BasePart | string,
165
- modelReplicationMode?: ModelReplicationMode,
166
- noDestroy?: boolean,
167
- ) => void;
168
-
169
- /** Sets the entity configuration type */
170
- SetConfig: (entity: Entity, entityConfig: string) => void;
171
-
172
- /** Sets the broad phase collision bounds */
173
- SetBroadPhase: (entity: Entity, broadPhase?: Vector3) => void;
174
-
175
- /** Gets custom data associated with an entity */
176
- GetData: <T = unknown>(entity: Entity) => T;
177
-
178
- /** Gets the model associated with an entity */
179
- GetModel: (entity: Entity) => Model | BasePart | undefined;
180
-
181
- /** Sets custom data for an entity */
182
- 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
+ }
183
57
 
184
- /** Clears the mount relationship */
185
- ClearMount: (entity: Entity) => void;
58
+ export interface Connection {
59
+ Disconnect(): void;
60
+ Connected: boolean;
61
+ }
186
62
 
187
- /** Mounts an entity to a parent entity with optional offset */
188
- 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
+ }
189
68
 
190
- /** Sets the network owner (player who controls this entity) */
191
- SetNetworkOwner: (entity: Entity, player?: Player) => void;
69
+ export interface SnapshotData<Value, Velocity> {
70
+ t: number;
71
+ value: Value;
72
+ velocity: Velocity;
73
+ }
192
74
 
193
- /** Clears the entity's snapshot buffer */
194
- 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
+ }
195
81
 
196
- /** Pauses replication for an entity */
197
- 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
+ }
198
93
 
199
- /** Resumes replication for an entity */
200
- 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
+ }
201
105
 
202
- /** Pushes a new CFrame snapshot at the given time */
203
- 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
+ }
204
119
 
205
- /** Gets the interpolated CFrame at a specific time */
206
- GetAt: (entity: Entity, time: number) => CFrame | undefined;
120
+ export interface Entity {
121
+ /** Unique identifier for this entity */
122
+ readonly id: number;
207
123
 
208
- /** Gets the target render time for interpolation */
209
- GetTargetRenderTime: (entity: Entity) => number;
124
+ /** Whether this entity is registered with the system */
125
+ readonly registered: boolean;
210
126
 
211
- /** Sets whether position updates automatically */
212
- SetAutoUpdatePos: (entity: Entity, autoUpdate: boolean) => void;
127
+ /** Whether this entity has been destroyed */
128
+ readonly destroyed: boolean;
213
129
 
214
- /** Gets the current CFrame */
215
- GetCFrame: (entity: Entity) => CFrame | undefined;
130
+ /** The player who owns this entity (controls its movement) */
131
+ readonly networkOwner: Player | undefined;
216
132
 
217
- /** Sets the current CFrame */
218
- SetCFrame: (entity: Entity, cframe: CFrame) => void;
133
+ /** Whether the current context (client/server) is the network owner */
134
+ readonly isContextOwner: boolean;
219
135
 
220
- /** Gets the primary part of the model */
221
- GetPrimaryPart: (entity: Entity) => BasePart | undefined;
136
+ /** The model associated with this entity */
137
+ readonly model: Model | BasePart | undefined;
222
138
 
223
- /** Locks native server CFrame replication */
224
- LockNativeServerCFrameReplication: (entity: Entity) => void;
139
+ /** Whether replication is paused for this entity */
140
+ readonly paused: boolean;
225
141
 
226
- /** Unlocks native server CFrame replication */
227
- UnlockNativeServerCFrameReplication: (entity: Entity) => void;
142
+ /** The most recent CFrame value */
143
+ readonly latestCFrame: CFrame | undefined;
144
+ }
228
145
 
229
- /** Destroys an entity */
230
- 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;
231
153
 
232
- /** Gets an event by name */
233
- GetEvent: ((entity: Entity, name: "Destroying") => ChronoEvent<(entity: Entity) => void>) &
234
- ((
235
- entity: Entity,
236
- name: "NetworkOwnerChanged",
237
- ) => ChronoEvent<(entity: Entity, newOwner: Player | undefined, prevOwner: Player | undefined) => void>) &
238
- ((
154
+ /** Sets or changes the model for an entity */
155
+ SetModel: (
239
156
  entity: Entity,
240
- name: "PushedSnapShot",
241
- ) => ChronoEvent<(entity: Entity, time: number, value: CFrame, isNewest: boolean) => void>) &
242
- ((
243
- entity: Entity,
244
- name: "TickChanged",
245
- ) => ChronoEvent<(entity: Entity, newTickType: "NONE" | "HALF" | "NORMAL") => void>) &
246
- ((entity: Entity, name: "DataChanged") => ChronoEvent<(entity: Entity, data: unknown) => void>) &
247
- ((entity: Entity, name: "Ticked") => ChronoEvent<(entity: Entity, dt: number) => void>) &
248
- ((
249
- entity: Entity,
250
- name: "ModelChanged",
251
- ) => ChronoEvent<
252
- (entity: Entity, newModel: Model | BasePart | undefined, oldModel: Model | BasePart | undefined) => void
253
- >) &
254
- ((entity: Entity, name: "LockChanged") => ChronoEvent<(entity: Entity, isLocked: boolean) => void>) &
255
- ((entity: Entity, name: EntityEventName) => ChronoEvent);
256
- }
257
-
258
- // Replication rule types
259
- 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
+ }
260
250
 
261
- interface ReplicationRule {
262
- filterType: "include" | "exclude";
263
- filterPlayers?: Player[];
264
- }
251
+ export interface ReplicationRule {
252
+ filterType: "include" | "exclude";
253
+ filterPlayers?: Player[];
254
+ }
265
255
 
266
- // Middleware function type for Receiver
267
- type MiddleManFn = (player: Player, entity: Entity, cframe: CFrame, arriveTime: number) => boolean;
256
+ // ===== Functions and Values =====
268
257
 
269
- declare namespace Chrono {
270
258
  /** Starts the Chrono system */
271
259
  function Start(config?: ModuleScript): void;
272
260
 
@@ -401,18 +389,6 @@ declare namespace Chrono {
401
389
  ) => Value,
402
390
  ): Snapshot<Value, Velocity>;
403
391
  }
404
-
405
- // Type exports for external use
406
- export type Entity = globalThis.Entity;
407
- export type ChronoEvent<T extends Callback = Callback> = globalThis.ChronoEvent<T>;
408
- export type Connection = globalThis.Connection;
409
- export type EntityConfigInput = globalThis.EntityConfigInput;
410
- export type Snapshot<Value, Velocity> = globalThis.Snapshot<Value, Velocity>;
411
- export type SnapshotData<Value, Velocity> = globalThis.SnapshotData<Value, Velocity>;
412
- export type ModelReplicationMode = globalThis.ModelReplicationMode;
413
- export type PlayerReplicationMode = globalThis.PlayerReplicationMode;
414
- export type ReplicationFilterMode = globalThis.ReplicationFilterMode;
415
- export type EntityEventName = globalThis.EntityEventName;
416
392
  }
417
393
 
418
394
  export = Chrono;