New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@colyseus/schema

Package Overview
Dependencies
Maintainers
0
Versions
337
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@colyseus/schema - npm Package Compare versions

Comparing version 3.0.0-alpha.50 to 3.0.0

7

lib/codegen/languages/csharp.js

@@ -53,4 +53,11 @@ "use strict";

using Colyseus.Schema;
#if UNITY_5_3_OR_NEWER
using UnityEngine.Scripting;
#endif
${namespace ? `\nnamespace ${namespace} {` : ""}
${indent}public partial class ${klass.name} : ${klass.extends} {
#if UNITY_5_3_OR_NEWER
[Preserve]
#endif
public ${klass.name}() { }
${klass.properties.map((prop) => generateProperty(prop, indent)).join("\n\n")}

@@ -57,0 +64,0 @@ ${indent}}

13

lib/encoder/Encoder.js

@@ -9,7 +9,6 @@ "use strict";

const Root_1 = require("./Root");
const utils_1 = require("../utils");
class Encoder {
static { this.BUFFER_SIZE = 8 * 1024; } // 8KB
static { this.BUFFER_SIZE = Buffer.poolSize ?? 8 * 1024; } // 8KB
constructor(state) {
this.sharedBuffer = Buffer.allocUnsafeSlow(Encoder.BUFFER_SIZE);
this.sharedBuffer = Buffer.allocUnsafe(Encoder.BUFFER_SIZE);
//

@@ -87,3 +86,6 @@ // TODO: cache and restore "Context" based on root schema

if (it.offset > buffer.byteLength) {
const newSize = (0, utils_1.getNextPowerOf2)(buffer.byteLength * 2);
// we can assume that n + 1 poolSize will suffice given that we are likely done with encoding at this point
// multiples of poolSize are faster to allocate than arbitrary sizes
// if we are on an older platform that doesn't implement pooling use 8kb as poolSize (that's the default for node)
const newSize = Math.ceil(it.offset / (Buffer.poolSize ?? 8 * 1024)) * (Buffer.poolSize ?? 8 * 1024);
console.warn(`@colyseus/schema buffer overflow. Encoded state is higher than default BUFFER_SIZE. Use the following to increase default BUFFER_SIZE:

@@ -96,4 +98,5 @@

// resize buffer and re-encode (TODO: can we avoid re-encoding here?)
// -> No we probably can't unless we catch the need for resize before encoding which is likely more computationally expensive than resizing on demand
//
buffer = Buffer.alloc(newSize);
buffer = Buffer.alloc(newSize, buffer); // fill with buffer here to memcpy previous encoding steps beyond the initialOffset
// assign resized buffer to local sharedBuffer

@@ -100,0 +103,0 @@ if (buffer === this.sharedBuffer) {

@@ -25,3 +25,3 @@ import { $decoder, $deleteByIndex, $encoder, $filter, $getByIndex } from "../symbols";

at(index: number): V | undefined;
entries(): IterableIterator<[number, V]>;
entries(): MapIterator<[number, V]>;
delete(item: V): boolean;

@@ -31,3 +31,3 @@ clear(): void;

forEach(callbackfn: (value: V, key: K, collection: CollectionSchema<V>) => void): void;
values(): IterableIterator<V>;
values(): MapIterator<V>;
get size(): number;

@@ -34,0 +34,0 @@ /** Iterator */

@@ -34,5 +34,5 @@ import { $changes, $decoder, $deleteByIndex, $onEncodeEnd, $encoder, $filter, $getByIndex } from "../symbols";

forEach(callbackfn: (value: V, key: string, map: Map<string, V>) => void): void;
entries(): IterableIterator<[string, V]>;
keys(): IterableIterator<string>;
values(): IterableIterator<V>;
entries(): MapIterator<[string, V]>;
keys(): MapIterator<string>;
values(): MapIterator<V>;
get size(): number;

@@ -39,0 +39,0 @@ protected setIndex(index: number, key: string): void;

@@ -23,3 +23,3 @@ import { $decoder, $deleteByIndex, $encoder, $filter, $getByIndex } from "../symbols";

add(value: V): number | false;
entries(): IterableIterator<[number, V]>;
entries(): MapIterator<[number, V]>;
delete(item: V): boolean;

@@ -29,3 +29,3 @@ clear(): void;

forEach(callbackfn: (value: V, key: number, collection: SetSchema<V>) => void): void;
values(): IterableIterator<V>;
values(): MapIterator<V>;
get size(): number;

@@ -32,0 +32,0 @@ /** Iterator */

{
"name": "@colyseus/schema",
"version": "3.0.0-alpha.50",
"version": "3.0.0",
"description": "Binary state serializer with delta encoding for games",

@@ -5,0 +5,0 @@ "bin": {

@@ -62,4 +62,11 @@ import {

using Colyseus.Schema;
#if UNITY_5_3_OR_NEWER
using UnityEngine.Scripting;
#endif
${namespace ? `\nnamespace ${namespace} {` : ""}
${indent}public partial class ${klass.name} : ${klass.extends} {
#if UNITY_5_3_OR_NEWER
[Preserve]
#endif
public ${klass.name}() { }
${klass.properties.map((prop) => generateProperty(prop, indent)).join("\n\n")}

@@ -66,0 +73,0 @@ ${indent}}

@@ -16,4 +16,4 @@ import type { Schema } from "../Schema";

export class Encoder<T extends Schema = any> {
static BUFFER_SIZE = 8 * 1024;// 8KB
sharedBuffer = Buffer.allocUnsafeSlow(Encoder.BUFFER_SIZE);
static BUFFER_SIZE = Buffer.poolSize ?? 8 * 1024; // 8KB
sharedBuffer = Buffer.allocUnsafe(Encoder.BUFFER_SIZE);

@@ -120,3 +120,7 @@ context: TypeContext;

if (it.offset > buffer.byteLength) {
const newSize = getNextPowerOf2(buffer.byteLength * 2);
// we can assume that n + 1 poolSize will suffice given that we are likely done with encoding at this point
// multiples of poolSize are faster to allocate than arbitrary sizes
// if we are on an older platform that doesn't implement pooling use 8kb as poolSize (that's the default for node)
const newSize = Math.ceil(it.offset / (Buffer.poolSize ?? 8 * 1024)) * (Buffer.poolSize ?? 8 * 1024);
console.warn(`@colyseus/schema buffer overflow. Encoded state is higher than default BUFFER_SIZE. Use the following to increase default BUFFER_SIZE:

@@ -130,4 +134,5 @@

// resize buffer and re-encode (TODO: can we avoid re-encoding here?)
// -> No we probably can't unless we catch the need for resize before encoding which is likely more computationally expensive than resizing on demand
//
buffer = Buffer.alloc(newSize);
buffer = Buffer.alloc(newSize, buffer); // fill with buffer here to memcpy previous encoding steps beyond the initialOffset

@@ -134,0 +139,0 @@ // assign resized buffer to local sharedBuffer

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc