rbxts-chrono 2.0.0-experimental.5 → 2.0.0-experimental.7

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 +76 -58
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rbxts-chrono",
3
- "version": "2.0.0-experimental.5",
3
+ "version": "2.0.0-experimental.7",
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
@@ -29,6 +29,23 @@ type ConfigName =
29
29
  | "MAX_TOTAL_BYTES_PER_FRAME_PER_PLAYER"
30
30
  | "SEND_FULL_ROTATION";
31
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
+
32
49
  // Event system types
33
50
  interface Connection {
34
51
  Disconnect(): void;
@@ -142,98 +159,100 @@ interface EntityConstructor {
142
159
  ): Entity;
143
160
 
144
161
  /** Sets or changes the model for an entity */
145
- SetModel(
162
+ SetModel: (
146
163
  entity: Entity,
147
164
  model?: Model | BasePart | string,
148
165
  modelReplicationMode?: ModelReplicationMode,
149
166
  noDestroy?: boolean,
150
- ): void;
167
+ ) => void;
151
168
 
152
169
  /** Sets the entity configuration type */
153
- SetConfig(entity: Entity, entityConfig: string): void;
170
+ SetConfig: (entity: Entity, entityConfig: string) => void;
154
171
 
155
172
  /** Sets the broad phase collision bounds */
156
- SetBroadPhase(entity: Entity, broadPhase?: Vector3): void;
173
+ SetBroadPhase: (entity: Entity, broadPhase?: Vector3) => void;
157
174
 
158
175
  /** Gets custom data associated with an entity */
159
- GetData<T = unknown>(entity: Entity): T;
176
+ GetData: <T = unknown>(entity: Entity) => T;
160
177
 
161
178
  /** Gets the model associated with an entity */
162
- GetModel(entity: Entity): Model | BasePart | undefined;
179
+ GetModel: (entity: Entity) => Model | BasePart | undefined;
163
180
 
164
181
  /** Sets custom data for an entity */
165
- SetData(entity: Entity, data: unknown): void;
182
+ SetData: (entity: Entity, data: unknown) => void;
166
183
 
167
184
  /** Clears the mount relationship */
168
- ClearMount(entity: Entity): void;
185
+ ClearMount: (entity: Entity) => void;
169
186
 
170
187
  /** Mounts an entity to a parent entity with optional offset */
171
- SetMount(entity: Entity, parent?: Entity, offset?: CFrame): void;
188
+ SetMount: (entity: Entity, parent?: Entity, offset?: CFrame) => void;
172
189
 
173
190
  /** Sets the network owner (player who controls this entity) */
174
- SetNetworkOwner(entity: Entity, player?: Player): void;
191
+ SetNetworkOwner: (entity: Entity, player?: Player) => void;
175
192
 
176
193
  /** Clears the entity's snapshot buffer */
177
- Clear(entity: Entity): void;
194
+ Clear: (entity: Entity) => void;
178
195
 
179
196
  /** Pauses replication for an entity */
180
- PauseReplication(entity: Entity): void;
197
+ PauseReplication: (entity: Entity) => void;
181
198
 
182
199
  /** Resumes replication for an entity */
183
- ResumeReplication(entity: Entity): void;
200
+ ResumeReplication: (entity: Entity) => void;
184
201
 
185
202
  /** Pushes a new CFrame snapshot at the given time */
186
- Push(entity: Entity, time: number, value: CFrame): boolean;
203
+ Push: (entity: Entity, time: number, value: CFrame) => boolean;
187
204
 
188
205
  /** Gets the interpolated CFrame at a specific time */
189
- GetAt(entity: Entity, time: number): CFrame | undefined;
206
+ GetAt: (entity: Entity, time: number) => CFrame | undefined;
190
207
 
191
208
  /** Gets the target render time for interpolation */
192
- GetTargetRenderTime(entity: Entity): number;
209
+ GetTargetRenderTime: (entity: Entity) => number;
193
210
 
194
211
  /** Sets whether position updates automatically */
195
- SetAutoUpdatePos(entity: Entity, autoUpdate: boolean): void;
212
+ SetAutoUpdatePos: (entity: Entity, autoUpdate: boolean) => void;
196
213
 
197
214
  /** Gets the current CFrame */
198
- GetCFrame(entity: Entity): CFrame | undefined;
215
+ GetCFrame: (entity: Entity) => CFrame | undefined;
199
216
 
200
217
  /** Sets the current CFrame */
201
- SetCFrame(entity: Entity, cframe: CFrame): void;
218
+ SetCFrame: (entity: Entity, cframe: CFrame) => void;
202
219
 
203
220
  /** Gets the primary part of the model */
204
- GetPrimaryPart(entity: Entity): BasePart | undefined;
221
+ GetPrimaryPart: (entity: Entity) => BasePart | undefined;
205
222
 
206
223
  /** Locks native server CFrame replication */
207
- LockNativeServerCFrameReplication(entity: Entity): void;
224
+ LockNativeServerCFrameReplication: (entity: Entity) => void;
208
225
 
209
226
  /** Unlocks native server CFrame replication */
210
- UnlockNativeServerCFrameReplication(entity: Entity): void;
227
+ UnlockNativeServerCFrameReplication: (entity: Entity) => void;
211
228
 
212
229
  /** Destroys an entity */
213
- Destroy(entity: Entity): void;
230
+ Destroy: (entity: Entity) => void;
214
231
 
215
232
  /** Gets an event by name */
216
- GetEvent(entity: Entity, name: "Destroying"): ChronoEvent<(entity: Entity) => void>;
217
- GetEvent(
218
- entity: Entity,
219
- name: "NetworkOwnerChanged",
220
- ): ChronoEvent<(entity: Entity, newOwner: Player | undefined, prevOwner: Player | undefined) => void>;
221
- GetEvent(
222
- entity: Entity,
223
- name: "PushedSnapShot",
224
- ): ChronoEvent<(entity: Entity, time: number, value: CFrame, isNewest: boolean) => void>;
225
- GetEvent(
226
- entity: Entity,
227
- name: "TickChanged",
228
- ): ChronoEvent<(entity: Entity, newTickType: "NONE" | "HALF" | "NORMAL") => void>;
229
- GetEvent(entity: Entity, name: "DataChanged"): ChronoEvent<(entity: Entity, data: unknown) => void>;
230
- GetEvent(entity: Entity, name: "Ticked"): ChronoEvent<(entity: Entity, dt: number) => void>;
231
- GetEvent(
232
- entity: Entity,
233
- name: "ModelChanged",
234
- ): ChronoEvent<(entity: Entity, newModel: Model | BasePart | undefined, oldModel: Model | BasePart | undefined) => void>;
235
- GetEvent(entity: Entity, name: "LockChanged"): ChronoEvent<(entity: Entity, isLocked: boolean) => void>;
236
- GetEvent(entity: Entity, name: EntityEventName): ChronoEvent;
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
+ ((
239
+ 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);
237
256
  }
238
257
 
239
258
  // Replication rule types
@@ -308,20 +327,7 @@ declare namespace Chrono {
308
327
  /** Configuration functions */
309
328
  namespace Config {
310
329
  /** Sets a configuration value (must be called before Start) */
311
- function SetConfig(name: "MIN_BUFFER", value: number): void;
312
- function SetConfig(name: "MAX_BUFFER", value: number): void;
313
- function SetConfig(name: "SHOW_WARNINGS", value: boolean): void;
314
- function SetConfig(name: "MAX_SNAPSHOT_COUNT", value: number): void;
315
- function SetConfig(name: "CHECK_NEW_VERSION", value: boolean): void;
316
- function SetConfig(name: "DEFAULT_NORMAL_TICK_DISTANCE", value: number): void;
317
- function SetConfig(name: "DEFAULT_HALF_TICK_DISTANCE", value: number): void;
318
- function SetConfig(name: "DEFAULT_MODEL_REPLICATION_MODE", value: ModelReplicationMode): void;
319
- function SetConfig(name: "PLAYER_REPLICATION", value: PlayerReplicationMode): void;
320
- function SetConfig(name: "REPLICATE_DEATHS", value: ReplicationFilterMode): void;
321
- function SetConfig(name: "REPLICATE_CFRAME_SETTERS", value: ReplicationFilterMode): void;
322
- function SetConfig(name: "MAX_TOTAL_BYTES_PER_FRAME_PER_PLAYER", value: number): void;
323
- function SetConfig(name: "SEND_FULL_ROTATION", value: boolean): void;
324
- function SetConfig(name: ConfigName, value: unknown): void;
330
+ function SetConfig<K extends ConfigName>(name: K, value: ConfigValueMap[K]): void;
325
331
 
326
332
  /** Registers a custom entity type configuration */
327
333
  function RegisterEntityType(name: string, config: EntityConfigInput): void;
@@ -395,6 +401,18 @@ declare namespace Chrono {
395
401
  ) => Value,
396
402
  ): Snapshot<Value, Velocity>;
397
403
  }
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;
398
416
  }
399
417
 
400
418
  export = Chrono;