@utsp/core 0.14.0 → 0.14.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/dist/benchmark.cjs +8 -5
- package/dist/benchmark.d.ts +37 -29
- package/dist/benchmark.mjs +8 -5
- package/dist/index.cjs +8 -5
- package/dist/index.d.ts +90 -54
- package/dist/index.mjs +8 -5
- package/package.json +2 -2
package/dist/benchmark.d.ts
CHANGED
|
@@ -7265,38 +7265,22 @@ declare class Core {
|
|
|
7265
7265
|
*
|
|
7266
7266
|
* This method:
|
|
7267
7267
|
* 1. Encodes displays and layers of each user into binary packets
|
|
7268
|
-
* 2.
|
|
7269
|
-
* 3.
|
|
7268
|
+
* 2. Only sends layers that have called commit() (optimization)
|
|
7269
|
+
* 3. Separates static and dynamic layers for network optimization
|
|
7270
|
+
* 4. Increments tick counter
|
|
7271
|
+
* 5. Returns a Map with split packets ready to send
|
|
7270
7272
|
*
|
|
7271
|
-
*
|
|
7272
|
-
*
|
|
7273
|
-
*
|
|
7274
|
-
*
|
|
7275
|
-
* @example
|
|
7276
|
-
* ```typescript
|
|
7277
|
-
* const packets = engine.endTick();
|
|
7278
|
-
* packets.forEach((packet, userId) => {
|
|
7279
|
-
* networkSend(userId, packet);
|
|
7280
|
-
* });
|
|
7281
|
-
* ```
|
|
7282
|
-
*/
|
|
7283
|
-
endTick(): Map<string, Uint8Array>;
|
|
7284
|
-
/**
|
|
7285
|
-
* Ends tick and generates SEPARATE packets for static and dynamic layers
|
|
7286
|
-
*
|
|
7287
|
-
* This method allows sending:
|
|
7288
|
-
* - STATIC Layers on a reliable Socket.IO channel (guaranteed delivery)
|
|
7289
|
-
* - DYNAMIC Layers on a volatile Socket.IO channel (can drop packets)
|
|
7290
|
-
*
|
|
7291
|
-
* Optimization: Static layers (background, pattern) must arrive,
|
|
7292
|
-
* but dynamic layers (particles, trail) can skip frames.
|
|
7273
|
+
* Network strategy:
|
|
7274
|
+
* - STATIC Layers → Reliable channel (guaranteed delivery)
|
|
7275
|
+
* - DYNAMIC Layers → Volatile channel (can drop packets for performance)
|
|
7276
|
+
* - Audio/Vibration/Macro/PostProcess orders → Only in dynamic packet
|
|
7293
7277
|
*
|
|
7294
7278
|
* @returns Map<userId, { static: Uint8Array | null, dynamic: Uint8Array | null }>
|
|
7295
7279
|
*
|
|
7296
7280
|
* @example
|
|
7297
7281
|
* ```typescript
|
|
7298
|
-
* const
|
|
7299
|
-
*
|
|
7282
|
+
* const packets = engine.endTick();
|
|
7283
|
+
* packets.forEach(({ static: staticPacket, dynamic: dynamicPacket }, userId) => {
|
|
7300
7284
|
* if (staticPacket) {
|
|
7301
7285
|
* network.sendToClient(userId, 'update-static', staticPacket); // Reliable
|
|
7302
7286
|
* }
|
|
@@ -7306,7 +7290,7 @@ declare class Core {
|
|
|
7306
7290
|
* });
|
|
7307
7291
|
* ```
|
|
7308
7292
|
*/
|
|
7309
|
-
|
|
7293
|
+
endTick(): Map<string, {
|
|
7310
7294
|
static: Uint8Array | null;
|
|
7311
7295
|
dynamic: Uint8Array | null;
|
|
7312
7296
|
}>;
|
|
@@ -7589,6 +7573,25 @@ declare class Core {
|
|
|
7589
7573
|
* @returns Array of encoded MacroLoad packets
|
|
7590
7574
|
*/
|
|
7591
7575
|
generateMacroLoadPackets(userId: string): Uint8Array[];
|
|
7576
|
+
/**
|
|
7577
|
+
* Generates an initial update packet for a specific user (SERVER-SIDE)
|
|
7578
|
+
*
|
|
7579
|
+
* This is used to send any pending PostProcessCommands (like switchPalette)
|
|
7580
|
+
* that were created during initUser() but before the first regular tick.
|
|
7581
|
+
*
|
|
7582
|
+
* @param userId - Target user ID
|
|
7583
|
+
* @returns Encoded update packet, or null if no pending commands
|
|
7584
|
+
*
|
|
7585
|
+
* @example
|
|
7586
|
+
* ```typescript
|
|
7587
|
+
* // Server side - after initUser and load packets
|
|
7588
|
+
* const initialPacket = core.generateInitialUpdatePacket(clientId);
|
|
7589
|
+
* if (initialPacket) {
|
|
7590
|
+
* socket.emit('update', initialPacket);
|
|
7591
|
+
* }
|
|
7592
|
+
* ```
|
|
7593
|
+
*/
|
|
7594
|
+
generateInitialUpdatePacket(userId: string): Uint8Array | null;
|
|
7592
7595
|
/**
|
|
7593
7596
|
* Applies Input Bindings to a user (CLIENT-SIDE)
|
|
7594
7597
|
*
|
|
@@ -8763,14 +8766,19 @@ declare class Layer {
|
|
|
8763
8766
|
* ```
|
|
8764
8767
|
*/
|
|
8765
8768
|
commit(): void;
|
|
8769
|
+
/**
|
|
8770
|
+
* Returns a breakdown of order types for debugging
|
|
8771
|
+
* @internal
|
|
8772
|
+
*/
|
|
8773
|
+
private getOrdersBreakdown;
|
|
8766
8774
|
/**
|
|
8767
8775
|
* Checks if layer needs to be sent
|
|
8768
|
-
* @internal - Used by Core.
|
|
8776
|
+
* @internal - Used by Core.endTick()
|
|
8769
8777
|
*/
|
|
8770
8778
|
getNeedsCommit(): boolean;
|
|
8771
8779
|
/**
|
|
8772
8780
|
* Resets commit flag after sending
|
|
8773
|
-
* @internal - Used by Core.
|
|
8781
|
+
* @internal - Used by Core.endTick()
|
|
8774
8782
|
*/
|
|
8775
8783
|
resetCommit(): void;
|
|
8776
8784
|
}
|