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
1
Versions
340
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.1 to 3.0.0-alpha.2

2

lib/encoder/ChangeTree.d.ts

@@ -10,3 +10,2 @@ import { OPERATION } from "../encoding/spec";

import type { DecodeOperation } from "../decoder/DecodeOperation";
import type { StateView } from "./StateView";
declare global {

@@ -27,3 +26,2 @@ interface Object {

filteredChanges: Map<ChangeTree<any>, Map<number, OPERATION>>;
views: StateView[];
getNextUniqueId(): number;

@@ -30,0 +28,0 @@ add(changeTree: ChangeTree): void;

@@ -18,3 +18,2 @@ "use strict";

this.filteredChanges = new Map();
this.views = [];
}

@@ -21,0 +20,0 @@ getNextUniqueId() {

9

lib/encoder/Encoder.d.ts

@@ -5,5 +5,4 @@ /// <reference types="node" />

import type { Iterator } from "../encoding/decode";
import { OPERATION } from '../encoding/spec';
import { Root } from "./ChangeTree";
import { StateView } from "./StateView";
import type { StateView } from "./StateView";
export declare class Encoder<T extends Schema = any> {

@@ -14,12 +13,12 @@ static BUFFER_SIZE: number;

state: T;
$root: Root;
root: Root;
constructor(root: T);
protected setRoot(state: T): void;
encode(it?: Iterator, view?: StateView, bytes?: Buffer, changeTrees?: Map<import("./ChangeTree").ChangeTree<any>, Map<number, OPERATION>>): Buffer;
encode(it?: Iterator, view?: StateView, bytes?: Buffer, changeTrees?: Map<import("./ChangeTree").ChangeTree<any>, Map<number, import("../encoding/spec").OPERATION>>): Buffer;
encodeAll(it?: Iterator): Buffer;
encodeAllView(view: StateView, sharedOffset: number, it: Iterator, bytes?: Buffer): Buffer;
encodeView(view: StateView, sharedOffset: number, it: Iterator, bytes?: Buffer): Buffer;
onEndEncode(changeTrees?: Map<import("./ChangeTree").ChangeTree<any>, Map<number, OPERATION>>): void;
onEndEncode(changeTrees?: Map<import("./ChangeTree").ChangeTree<any>, Map<number, import("../encoding/spec").OPERATION>>): void;
discardChanges(): void;
tryEncodeTypeId(bytes: Buffer, baseType: typeof Schema, targetType: typeof Schema, it: Iterator): void;
}

@@ -26,9 +26,9 @@ "use strict";

setRoot(state) {
this.$root = new ChangeTree_1.Root();
this.root = new ChangeTree_1.Root();
this.state = state;
state[symbols_1.$changes].setRoot(this.$root);
state[symbols_1.$changes].setRoot(this.root);
}
encode(it = { offset: 0 }, view, bytes = this.sharedBuffer, changeTrees = this.$root.changes) {
encode(it = { offset: 0 }, view, bytes = this.sharedBuffer, changeTrees = this.root.changes) {
const initialOffset = it.offset; // cache current offset in case we need to resize the buffer
const isEncodeAll = this.$root.allChanges === changeTrees;
const isEncodeAll = this.root.allChanges === changeTrees;
const hasView = (view !== undefined);

@@ -107,3 +107,3 @@ const rootChangeTree = this.state[symbols_1.$changes];

// });
return this.encode(it, undefined, this.sharedBuffer, this.$root.allChanges);
return this.encode(it, undefined, this.sharedBuffer, this.root.allChanges);
}

@@ -115,3 +115,3 @@ encodeAllView(view, sharedOffset, it, bytes = this.sharedBuffer) {

// try to encode "filtered" changes
this.encode(it, view, bytes, this.$root.allFilteredChanges);
this.encode(it, view, bytes, this.root.allFilteredChanges);
return Buffer.concat([

@@ -135,3 +135,3 @@ bytes.slice(0, sharedOffset),

// try to encode "filtered" changes
this.encode(it, view, bytes, this.$root.filteredChanges);
this.encode(it, view, bytes, this.root.filteredChanges);
// encode visibility changes (add/remove for this view)

@@ -168,3 +168,3 @@ const viewChangesIterator = view.changes.entries();

}
onEndEncode(changeTrees = this.$root.changes) {
onEndEncode(changeTrees = this.root.changes) {
const changeTreesIterator = changeTrees.entries();

@@ -177,10 +177,10 @@ for (const [changeTree, _] of changeTreesIterator) {

// discard shared changes
if (this.$root.changes.size > 0) {
this.onEndEncode(this.$root.changes);
this.$root.changes.clear();
if (this.root.changes.size > 0) {
this.onEndEncode(this.root.changes);
this.root.changes.clear();
}
// discard filtered changes
if (this.$root.filteredChanges.size > 0) {
this.onEndEncode(this.$root.filteredChanges);
this.$root.filteredChanges.clear();
if (this.root.filteredChanges.size > 0) {
this.onEndEncode(this.root.filteredChanges);
this.root.filteredChanges.clear();
}

@@ -187,0 +187,0 @@ }

import { ChangeTree, Ref } from "./ChangeTree";
import { OPERATION } from "../encoding/spec";
import type { Schema } from "../Schema";
export declare function createView(root: Schema): void;
export declare class StateView {

@@ -4,0 +6,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StateView = void 0;
exports.StateView = exports.createView = void 0;
const symbols_1 = require("../types/symbols");

@@ -8,2 +8,5 @@ const annotations_1 = require("../annotations");

const Metadata_1 = require("../Metadata");
function createView(root) {
}
exports.createView = createView;
class StateView {

@@ -10,0 +13,0 @@ constructor() {

@@ -23,5 +23,5 @@ /**

*/
/// <reference types="node" />
import type { Iterator } from "./decode";
export type BufferLike = number[] | ArrayBufferLike;
export declare function utf8Length(str: any): number;
export declare function utf8Write(view: any, str: any, it: any): void;

@@ -41,3 +41,3 @@ export declare function int8(bytes: BufferLike, value: number, it: Iterator): void;

export declare function boolean(bytes: BufferLike, value: number, it: Iterator): void;
export declare function string(bytes: Buffer, value: string, it: Iterator): number;
export declare function string(bytes: BufferLike, value: string, it: Iterator): number;
export declare function number(bytes: BufferLike, value: number, it: Iterator): 1 | 2 | 3 | 5 | 9;

@@ -25,3 +25,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.number = exports.string = exports.boolean = exports.writeFloat64 = exports.writeFloat32 = exports.float64 = exports.float32 = exports.uint64 = exports.int64 = exports.uint32 = exports.int32 = exports.uint16 = exports.int16 = exports.uint8 = exports.int8 = exports.utf8Write = void 0;
exports.number = exports.string = exports.boolean = exports.writeFloat64 = exports.writeFloat32 = exports.float64 = exports.float32 = exports.uint64 = exports.int64 = exports.uint32 = exports.int32 = exports.uint16 = exports.int16 = exports.uint8 = exports.int8 = exports.utf8Write = exports.utf8Length = void 0;
/**

@@ -57,2 +57,3 @@ * msgpack implementation highly based on notepack.io

}
exports.utf8Length = utf8Length;
function utf8Write(view, str, it) {

@@ -59,0 +60,0 @@ var c = 0;

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

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

@@ -42,4 +42,2 @@ import { OPERATION } from "../encoding/spec";

views: StateView[] = [];
getNextUniqueId() {

@@ -46,0 +44,0 @@ return this.nextUniqueId++;

@@ -8,7 +8,6 @@ import type { Schema } from "../Schema";

import { OPERATION, SWITCH_TO_STRUCTURE, TYPE_ID } from '../encoding/spec';
import { SWITCH_TO_STRUCTURE, TYPE_ID } from '../encoding/spec';
import { Root } from "./ChangeTree";
import { getNextPowerOf2 } from "../utils";
import { StateView } from "./StateView";
import { Metadata } from "../Metadata";
import type { StateView } from "./StateView";

@@ -22,3 +21,3 @@ export class Encoder<T extends Schema = any> {

$root: Root;
root: Root;

@@ -41,5 +40,5 @@ constructor(root: T) {

protected setRoot(state: T) {
this.$root = new Root();
this.root = new Root();
this.state = state;
state[$changes].setRoot(this.$root);
state[$changes].setRoot(this.root);
}

@@ -51,7 +50,7 @@

bytes = this.sharedBuffer,
changeTrees = this.$root.changes
changeTrees = this.root.changes
): Buffer {
const initialOffset = it.offset; // cache current offset in case we need to resize the buffer
const isEncodeAll = this.$root.allChanges === changeTrees;
const isEncodeAll = this.root.allChanges === changeTrees;
const hasView = (view !== undefined);

@@ -146,3 +145,3 @@ const rootChangeTree = this.state[$changes];

return this.encode(it, undefined, this.sharedBuffer, this.$root.allChanges);
return this.encode(it, undefined, this.sharedBuffer, this.root.allChanges);
}

@@ -157,3 +156,3 @@

// try to encode "filtered" changes
this.encode(it, view, bytes, this.$root.allFilteredChanges);
this.encode(it, view, bytes, this.root.allFilteredChanges);

@@ -182,3 +181,3 @@ return Buffer.concat([

// try to encode "filtered" changes
this.encode(it, view, bytes, this.$root.filteredChanges);
this.encode(it, view, bytes, this.root.filteredChanges);

@@ -224,3 +223,3 @@ // encode visibility changes (add/remove for this view)

onEndEncode(changeTrees = this.$root.changes) {
onEndEncode(changeTrees = this.root.changes) {
const changeTreesIterator = changeTrees.entries();

@@ -234,10 +233,10 @@ for (const [changeTree, _] of changeTreesIterator) {

// discard shared changes
if (this.$root.changes.size > 0) {
this.onEndEncode(this.$root.changes);
this.$root.changes.clear();
if (this.root.changes.size > 0) {
this.onEndEncode(this.root.changes);
this.root.changes.clear();
}
// discard filtered changes
if (this.$root.filteredChanges.size > 0) {
this.onEndEncode(this.$root.filteredChanges);
this.$root.filteredChanges.clear();
if (this.root.filteredChanges.size > 0) {
this.onEndEncode(this.root.filteredChanges);
this.root.filteredChanges.clear();
}

@@ -244,0 +243,0 @@ }

@@ -6,3 +6,7 @@ import { ChangeTree, Ref } from "./ChangeTree";

import { Metadata } from "../Metadata";
import type { Schema } from "../Schema";
export function createView(root: Schema) {
}
export class StateView {

@@ -9,0 +13,0 @@ /**

@@ -38,3 +38,3 @@ /**

function utf8Length(str) {
export function utf8Length(str) {
var c = 0, length = 0;

@@ -166,3 +166,3 @@ for (var i = 0, l = str.length; i < l; i++) {

export function string(bytes: Buffer, value: string, it: Iterator) {
export function string(bytes: BufferLike, value: string, it: Iterator) {
// encode `null` strings as empty.

@@ -169,0 +169,0 @@ if (!value) { value = ""; }

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

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