@nativewrappers/redm 0.0.157 → 0.0.159

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.
@@ -11,6 +11,9 @@ export declare class Net {
11
11
  export declare class NetServer extends Net {
12
12
  static emitNet(eventName: string, source: number, ...args: any[]): void;
13
13
  static emitProto<T>(source: number, message: MessageTypeEncoder<T>): void;
14
+ static broadcastProto<T>(sources: Iterable<number>, message: MessageTypeEncoder<T>): void;
15
+ static broadcast(sources: Iterable<number>, eventName: string, ...args: any[]): void;
16
+ static broadcastRaw(sources: Iterable<number>, eventName: string, data: Uint8Array): void;
14
17
  static emitRawNet(eventName: string, source: number, data: Uint8Array): void;
15
18
  }
16
19
  export declare class NetClient extends Net {
package/common/net/Net.js CHANGED
@@ -33,6 +33,21 @@ class NetServer extends Net {
33
33
  const encoded = message.encode(message);
34
34
  NetServer.emitRawNet(message.name, source, encoded);
35
35
  }
36
+ static broadcastProto(sources, message) {
37
+ const encoded = message.encode(message);
38
+ NetServer.broadcastRaw(sources, message.name, encoded);
39
+ }
40
+ static broadcast(sources, eventName, ...args) {
41
+ const packed = msgpack_pack(...args);
42
+ for (const source of sources) {
43
+ TriggerClientEventInternal(eventName, source, packed, packed.length);
44
+ }
45
+ }
46
+ static broadcastRaw(sources, eventName, data) {
47
+ for (const source of sources) {
48
+ NetServer.emitRawNet(eventName, source, data);
49
+ }
50
+ }
36
51
  static emitRawNet(eventName, source, data) {
37
52
  TriggerClientEventInternal(eventName, source, data, data.byteLength);
38
53
  }
@@ -1,6 +1,5 @@
1
1
  import type { MsgpackBuffer } from "../types";
2
2
  import { ClassTypes } from "./ClassTypes";
3
- declare const size: unique symbol;
4
3
  /**
5
4
  * Represents a 2-dimensional vector.
6
5
  */
@@ -211,7 +210,7 @@ declare abstract class Vector {
211
210
  */
212
211
  static Length<T extends VectorType, U extends VectorLike>(this: T, obj: U): number;
213
212
  type: unknown;
214
- [size]: number;
213
+ vec_size: number;
215
214
  x: number;
216
215
  y: number;
217
216
  z: number | undefined;
@@ -314,7 +313,7 @@ declare abstract class Vector {
314
313
  */
315
314
  export declare class Vector2 extends Vector {
316
315
  readonly type = ClassTypes.Vector2;
317
- readonly [size]: number;
316
+ readonly vec_size: number;
318
317
  static readonly Zero: Vector2;
319
318
  /**
320
319
  * Constructs a new 2D vector.
@@ -335,7 +334,7 @@ export declare class Vector2 extends Vector {
335
334
  */
336
335
  export declare class Vector3 extends Vector implements Vec3 {
337
336
  readonly type = ClassTypes.Vector3;
338
- readonly [size]: number;
337
+ readonly vec_size: number;
339
338
  z: number;
340
339
  static readonly Zero: Vector3;
341
340
  static readonly UnitX: Vector3;
@@ -384,7 +383,7 @@ export declare class Vector3 extends Vector implements Vec3 {
384
383
  */
385
384
  export declare class Vector4 extends Vector {
386
385
  readonly type = ClassTypes.Vector4;
387
- readonly [size]: number;
386
+ readonly vec_size: number;
388
387
  z: number;
389
388
  w: number;
390
389
  static readonly Zero: Vector4;
@@ -4,15 +4,14 @@ import { ClassTypes } from "./ClassTypes";
4
4
  const EXT_VECTOR2 = 20;
5
5
  const EXT_VECTOR3 = 21;
6
6
  const EXT_VECTOR4 = 22;
7
- const size = Symbol("size");
8
7
  class Vector {
9
8
  static {
10
9
  __name(this, "Vector");
11
10
  }
12
11
  static create(x, y = x, z, w) {
13
12
  if (typeof x === "object") ({ x, y, z, w } = x);
14
- const size2 = this instanceof Vector && this.size || [x, y, z, w].filter((arg) => arg !== void 0).length;
15
- switch (size2) {
13
+ const size = this instanceof Vector && this.size || [x, y, z, w].filter((arg) => arg !== void 0).length;
14
+ switch (size) {
16
15
  case 1:
17
16
  case 2:
18
17
  return new Vector2(x, y);
@@ -21,7 +20,7 @@ class Vector {
21
20
  case 4:
22
21
  return new Vector4(x, y, z, w);
23
22
  default:
24
- throw new Error(`Cannot instantiate Vector with size of ${size2}.`);
23
+ throw new Error(`Cannot instantiate Vector with size of ${size}.`);
25
24
  }
26
25
  }
27
26
  /**
@@ -263,7 +262,7 @@ class Vector {
263
262
  return Math.sqrt(sum);
264
263
  }
265
264
  type;
266
- [size] = 2;
265
+ vec_size = 2;
267
266
  x = 0;
268
267
  y = 0;
269
268
  z;
@@ -293,7 +292,7 @@ class Vector {
293
292
  if (this.w !== void 0) yield this.w;
294
293
  }
295
294
  get size() {
296
- return this[size];
295
+ return this.vec_size;
297
296
  }
298
297
  toString() {
299
298
  return `vector${this.size}(${this.toArray().join(", ")})`;
@@ -432,7 +431,7 @@ class Vector2 extends Vector {
432
431
  // DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
433
432
  // TO EXIST, CHANGING IT WILL BREAK STUFF
434
433
  type = ClassTypes.Vector2;
435
- [size] = 2;
434
+ vec_size = 2;
436
435
  static Zero = new Vector2(0, 0);
437
436
  /**
438
437
  * Constructs a new 2D vector.
@@ -460,7 +459,7 @@ class Vector3 extends Vector {
460
459
  // DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
461
460
  // TO EXIST, CHANGING IT WILL BREAK STUFF
462
461
  type = ClassTypes.Vector3;
463
- [size] = 3;
462
+ vec_size = 3;
464
463
  z = 0;
465
464
  static Zero = new Vector3(0, 0, 0);
466
465
  static UnitX = new Vector3(1, 0, 0);
@@ -523,7 +522,7 @@ class Vector4 extends Vector {
523
522
  // DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
524
523
  // TO EXIST, CHANGING IT WILL BREAK STUFF
525
524
  type = ClassTypes.Vector4;
526
- [size] = 4;
525
+ vec_size = 4;
527
526
  z = 0;
528
527
  w = 0;
529
528
  static Zero = new Vector4(0, 0, 0, 0);
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.157",
11
+ "version": "0.0.159",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"