mezon-js-protobuf 1.8.87 → 1.8.88

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.
@@ -533,7 +533,7 @@ export const ListValue = {
533
533
  },
534
534
  };
535
535
 
536
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
536
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
537
537
 
538
538
  export type DeepPartial<T> = T extends Builtin ? T
539
539
  : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
@@ -37,7 +37,7 @@ export interface FloatValue {
37
37
  */
38
38
  export interface Int64Value {
39
39
  /** The int64 value. */
40
- value: number;
40
+ value: bigint;
41
41
  }
42
42
 
43
43
  /**
@@ -47,7 +47,7 @@ export interface Int64Value {
47
47
  */
48
48
  export interface UInt64Value {
49
49
  /** The uint64 value. */
50
- value: number;
50
+ value: bigint;
51
51
  }
52
52
 
53
53
  /**
@@ -215,13 +215,16 @@ export const FloatValue = {
215
215
  };
216
216
 
217
217
  function createBaseInt64Value(): Int64Value {
218
- return { value: 0 };
218
+ return { value: 0n };
219
219
  }
220
220
 
221
221
  export const Int64Value = {
222
222
  encode(message: Int64Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
223
- if (message.value !== 0) {
224
- writer.uint32(8).int64(message.value);
223
+ if (message.value !== 0n) {
224
+ if (BigInt.asIntN(64, message.value) !== message.value) {
225
+ throw new globalThis.Error("value provided for field message.value of type int64 too large");
226
+ }
227
+ writer.uint32(8).int64(message.value.toString());
225
228
  }
226
229
  return writer;
227
230
  },
@@ -238,7 +241,7 @@ export const Int64Value = {
238
241
  break;
239
242
  }
240
243
 
241
- message.value = longToNumber(reader.int64() as Long);
244
+ message.value = longToBigint(reader.int64() as Long);
242
245
  continue;
243
246
  }
244
247
  if ((tag & 7) === 4 || tag === 0) {
@@ -250,13 +253,13 @@ export const Int64Value = {
250
253
  },
251
254
 
252
255
  fromJSON(object: any): Int64Value {
253
- return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 };
256
+ return { value: isSet(object.value) ? BigInt(object.value) : 0n };
254
257
  },
255
258
 
256
259
  toJSON(message: Int64Value): unknown {
257
260
  const obj: any = {};
258
- if (message.value !== 0) {
259
- obj.value = Math.round(message.value);
261
+ if (message.value !== 0n) {
262
+ obj.value = message.value.toString();
260
263
  }
261
264
  return obj;
262
265
  },
@@ -266,19 +269,22 @@ export const Int64Value = {
266
269
  },
267
270
  fromPartial<I extends Exact<DeepPartial<Int64Value>, I>>(object: I): Int64Value {
268
271
  const message = createBaseInt64Value();
269
- message.value = object.value ?? 0;
272
+ message.value = object.value ?? 0n;
270
273
  return message;
271
274
  },
272
275
  };
273
276
 
274
277
  function createBaseUInt64Value(): UInt64Value {
275
- return { value: 0 };
278
+ return { value: 0n };
276
279
  }
277
280
 
278
281
  export const UInt64Value = {
279
282
  encode(message: UInt64Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
280
- if (message.value !== 0) {
281
- writer.uint32(8).uint64(message.value);
283
+ if (message.value !== 0n) {
284
+ if (BigInt.asUintN(64, message.value) !== message.value) {
285
+ throw new globalThis.Error("value provided for field message.value of type uint64 too large");
286
+ }
287
+ writer.uint32(8).uint64(message.value.toString());
282
288
  }
283
289
  return writer;
284
290
  },
@@ -295,7 +301,7 @@ export const UInt64Value = {
295
301
  break;
296
302
  }
297
303
 
298
- message.value = longToNumber(reader.uint64() as Long);
304
+ message.value = longToBigint(reader.uint64() as Long);
299
305
  continue;
300
306
  }
301
307
  if ((tag & 7) === 4 || tag === 0) {
@@ -307,13 +313,13 @@ export const UInt64Value = {
307
313
  },
308
314
 
309
315
  fromJSON(object: any): UInt64Value {
310
- return { value: isSet(object.value) ? globalThis.Number(object.value) : 0 };
316
+ return { value: isSet(object.value) ? BigInt(object.value) : 0n };
311
317
  },
312
318
 
313
319
  toJSON(message: UInt64Value): unknown {
314
320
  const obj: any = {};
315
- if (message.value !== 0) {
316
- obj.value = Math.round(message.value);
321
+ if (message.value !== 0n) {
322
+ obj.value = message.value.toString();
317
323
  }
318
324
  return obj;
319
325
  },
@@ -323,7 +329,7 @@ export const UInt64Value = {
323
329
  },
324
330
  fromPartial<I extends Exact<DeepPartial<UInt64Value>, I>>(object: I): UInt64Value {
325
331
  const message = createBaseUInt64Value();
326
- message.value = object.value ?? 0;
332
+ message.value = object.value ?? 0n;
327
333
  return message;
328
334
  },
329
335
  };
@@ -638,7 +644,7 @@ function base64FromBytes(arr: Uint8Array): string {
638
644
  }
639
645
  }
640
646
 
641
- type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
647
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
642
648
 
643
649
  export type DeepPartial<T> = T extends Builtin ? T
644
650
  : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
@@ -650,14 +656,8 @@ type KeysOfUnion<T> = T extends T ? keyof T : never;
650
656
  export type Exact<P, I extends P> = P extends Builtin ? P
651
657
  : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
652
658
 
653
- function longToNumber(long: Long): number {
654
- if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) {
655
- throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
656
- }
657
- if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) {
658
- throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
659
- }
660
- return long.toNumber();
659
+ function longToBigint(long: Long) {
660
+ return BigInt(long.toString());
661
661
  }
662
662
 
663
663
  if (_m0.util.Long !== Long) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js-protobuf",
3
- "version": "1.8.87",
3
+ "version": "1.8.88",
4
4
  "description": "Websocket adapter adding protocol buffer support to the Mezon Javascript client.",
5
5
  "main": "dist/mezon-js-protobuf.cjs.js",
6
6
  "module": "dist/mezon-js-protobuf.esm.mjs",
@@ -26,13 +26,13 @@
26
26
  "mezon",
27
27
  "realtime",
28
28
  "realtime chat"
29
- ]
30
- ,
29
+ ],
31
30
  "repository": "https://github.com/nccasia/mezon-js",
32
31
  "homepage": "https://mezon.vn",
33
32
  "bugs": "https://github.com/nccasia/mezon-js/issues",
34
33
  "license": "Apache-2.0",
35
34
  "dependencies": {
36
- "@scarf/scarf": "^1.1.1"
35
+ "@scarf/scarf": "^1.1.1",
36
+ "typescript": "^4.9.5"
37
37
  }
38
38
  }