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.49 to 3.0.0-alpha.50

64

lib/encoder/Encoder.js

@@ -38,4 +38,2 @@ "use strict";

const changeTree = changeTrees[i];
// // Root#removeChangeFromChangeSet() is now removing instead of setting to "undefined"
// if (changeTree === undefined) { continue; }
const operations = changeTree[changeSetName];

@@ -47,8 +45,2 @@ const ref = changeTree.ref;

const metadata = ctor[Symbol.metadata];
// try { throw new Error(); } catch (e) {
// // only print if not coming from Reflection.ts
// if (!e.stack.includes("src/Reflection.ts")) {
// console.log("ChangeTree:", { refId: changeTree.refId, ref: ref.constructor.name });
// }
// }
if (hasView) {

@@ -88,20 +80,8 @@ if (!view.items.has(changeTree)) {

}
// try { throw new Error(); } catch (e) {
// // only print if not coming from Reflection.ts
// if (!e.stack.includes("src/Reflection.ts")) {
// console.log("WILL ENCODE", {
// ref: changeTree.ref.constructor.name,
// fieldIndex,
// operation: OPERATION[operation],
// });
// }
// }
// console.log("encode...", { ref: changeTree.ref.constructor.name, refId: changeTree.refId, fieldIndex, operation });
encoder(this, buffer, changeTree, fieldIndex, operation, it, isEncodeAll, hasView, metadata);
}
if (shouldDiscardChanges) {
changeTree.discard();
// Not a new instance anymore
changeTree.isNew = false;
}
// if (shouldDiscardChanges) {
// changeTree.discard();
// changeTree.isNew = false; // Not a new instance anymore
// }
}

@@ -118,3 +98,3 @@ if (it.offset > buffer.byteLength) {

//
buffer = Buffer.allocUnsafeSlow(newSize);
buffer = Buffer.alloc(newSize);
// assign resized buffer to local sharedBuffer

@@ -127,11 +107,15 @@ if (buffer === this.sharedBuffer) {

else {
// //
// // only clear changes after making sure buffer resize is not required.
// //
// if (shouldClearChanges) {
// //
// // FIXME: avoid iterating over change trees twice.
// //
// this.onEndEncode(changeTrees);
// }
//
// only clear changes after making sure buffer resize is not required.
//
if (shouldDiscardChanges) {
//
// TODO: avoid iterating over change trees twice.
//
for (let i = 0, numChangeTrees = changeTrees.length; i < numChangeTrees; i++) {
const changeTree = changeTrees[i];
changeTree.discard();
changeTree.isNew = false; // Not a new instance anymore
}
}
return buffer.subarray(0, it.offset);

@@ -141,4 +125,2 @@ }

encodeAll(it = { offset: 0 }, buffer = this.sharedBuffer) {
// console.log(`\nencodeAll(), this.root.allChanges (${(Object.keys(this.root.allChanges).length)})`);
// this.debugChanges("allChanges");
return this.encode(it, undefined, buffer, "allChanges", true);

@@ -148,5 +130,2 @@ }

const viewOffset = it.offset;
// console.log(`\nencodeAllView(), this.root.allFilteredChanges (${(Object.keys(this.root.allFilteredChanges).length)})`);
// this.debugChanges("allFilteredChanges");
// console.log("\n\nENCODE ALL FOR VIEW...\n\n")
// try to encode "filtered" changes

@@ -179,9 +158,4 @@ this.encode(it, view, bytes, "allFilteredChanges", true, viewOffset);

const viewOffset = it.offset;
// console.log(`\nencodeView(), view.changes (${view.changes.size})`);
// this.debugChanges(view.changes);
// console.log(`\nencodeView(), this.root.filteredChanges (${this.root.filteredChanges.size})`);
// this.debugChanges("filteredChanges");
// encode visibility changes (add/remove for this view)
const refIds = Object.keys(view.changes);
// console.log("ENCODE VIEW:", refIds);
for (let i = 0, numRefIds = refIds.length; i < numRefIds; i++) {

@@ -218,3 +192,2 @@ const refId = refIds[i];

view.changes = {};
// console.log("FILTERED CHANGES:", this.root.filteredChanges);
// try to encode "filtered" changes

@@ -242,3 +215,2 @@ this.encode(it, view, bytes, "filteredChanges", false, viewOffset);

discardChanges() {
// console.log("DISCARD CHANGES!");
// discard shared changes

@@ -245,0 +217,0 @@ let length = this.root.changes.length;

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

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

@@ -25,3 +25,2 @@ import type { Schema } from "../Schema";

constructor(state: T) {
//

@@ -64,5 +63,2 @@ // TODO: cache and restore "Context" based on root schema

// // Root#removeChangeFromChangeSet() is now removing instead of setting to "undefined"
// if (changeTree === undefined) { continue; }
const operations = changeTree[changeSetName];

@@ -76,9 +72,2 @@ const ref = changeTree.ref;

// try { throw new Error(); } catch (e) {
// // only print if not coming from Reflection.ts
// if (!e.stack.includes("src/Reflection.ts")) {
// console.log("ChangeTree:", { refId: changeTree.refId, ref: ref.constructor.name });
// }
// }
if (hasView) {

@@ -123,24 +112,9 @@ if (!view.items.has(changeTree)) {

// try { throw new Error(); } catch (e) {
// // only print if not coming from Reflection.ts
// if (!e.stack.includes("src/Reflection.ts")) {
// console.log("WILL ENCODE", {
// ref: changeTree.ref.constructor.name,
// fieldIndex,
// operation: OPERATION[operation],
// });
// }
// }
// console.log("encode...", { ref: changeTree.ref.constructor.name, refId: changeTree.refId, fieldIndex, operation });
encoder(this, buffer, changeTree, fieldIndex, operation, it, isEncodeAll, hasView, metadata);
}
if (shouldDiscardChanges) {
changeTree.discard();
// Not a new instance anymore
changeTree.isNew = false;
}
// if (shouldDiscardChanges) {
// changeTree.discard();
// changeTree.isNew = false; // Not a new instance anymore
// }
}

@@ -159,3 +133,3 @@

//
buffer = Buffer.allocUnsafeSlow(newSize);
buffer = Buffer.alloc(newSize);

@@ -170,11 +144,15 @@ // assign resized buffer to local sharedBuffer

} else {
// //
// // only clear changes after making sure buffer resize is not required.
// //
// if (shouldClearChanges) {
// //
// // FIXME: avoid iterating over change trees twice.
// //
// this.onEndEncode(changeTrees);
// }
//
// only clear changes after making sure buffer resize is not required.
//
if (shouldDiscardChanges) {
//
// TODO: avoid iterating over change trees twice.
//
for (let i = 0, numChangeTrees = changeTrees.length; i < numChangeTrees; i++) {
const changeTree = changeTrees[i];
changeTree.discard();
changeTree.isNew = false; // Not a new instance anymore
}
}

@@ -186,5 +164,2 @@ return buffer.subarray(0, it.offset);

encodeAll(it: Iterator = { offset: 0 }, buffer: Buffer = this.sharedBuffer) {
// console.log(`\nencodeAll(), this.root.allChanges (${(Object.keys(this.root.allChanges).length)})`);
// this.debugChanges("allChanges");
return this.encode(it, undefined, buffer, "allChanges", true);

@@ -196,7 +171,2 @@ }

// console.log(`\nencodeAllView(), this.root.allFilteredChanges (${(Object.keys(this.root.allFilteredChanges).length)})`);
// this.debugChanges("allFilteredChanges");
// console.log("\n\nENCODE ALL FOR VIEW...\n\n")
// try to encode "filtered" changes

@@ -235,11 +205,5 @@ this.encode(it, view, bytes, "allFilteredChanges", true, viewOffset);

// console.log(`\nencodeView(), view.changes (${view.changes.size})`);
// this.debugChanges(view.changes);
// console.log(`\nencodeView(), this.root.filteredChanges (${this.root.filteredChanges.size})`);
// this.debugChanges("filteredChanges");
// encode visibility changes (add/remove for this view)
const refIds = Object.keys(view.changes);
// console.log("ENCODE VIEW:", refIds);
for (let i = 0, numRefIds = refIds.length; i < numRefIds; i++) {

@@ -285,4 +249,2 @@ const refId = refIds[i];

// console.log("FILTERED CHANGES:", this.root.filteredChanges);
// try to encode "filtered" changes

@@ -318,4 +280,2 @@ this.encode(it, view, bytes, "filteredChanges", false, viewOffset);

discardChanges() {
// console.log("DISCARD CHANGES!");
// discard shared changes

@@ -322,0 +282,0 @@ let length = this.root.changes.length;

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

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