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
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 0.4.25-alpha.0 to 0.4.25-alpha.1

2

lib/codegen/csharp.js

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

property += " " + langType + " " + prop.name;
return "\t" + indent + "[Type(" + typeArgs + ")]\n\t" + indent + property + " = " + initializer + ";";
return "\t" + indent + "[Type(" + prop.index + ", " + typeArgs + ")]\n\t" + indent + property + " = " + initializer + ";";
}

@@ -7,4 +7,3 @@ "use strict";

var currentClass;
var currentProperty;
function inspectNode(node, classes, decoratorName) {
function inspectNode(node, context, decoratorName) {
switch (node.kind) {

@@ -17,3 +16,3 @@ case ts.SyntaxKind.ClassDeclaration:

}
classes.push(currentClass);
context.addClass(currentClass);
break;

@@ -36,20 +35,20 @@ // case ts.SyntaxKind.PropertyDeclaration:

})).expression;
currentProperty = new types_1.Property();
currentProperty.name = prop.name.escapedText;
currentClass.properties.push(currentProperty);
var property = new types_1.Property();
property.name = prop.name.escapedText;
currentClass.addProperty(property);
var typeArgument = typeDecorator.arguments[0];
if (ts.isIdentifier(typeArgument)) {
currentProperty.type = "ref";
currentProperty.childType = typeArgument.text;
property.type = "ref";
property.childType = typeArgument.text;
}
else if (typeArgument.kind == ts.SyntaxKind.ObjectLiteralExpression) {
currentProperty.type = "map";
currentProperty.childType = typeArgument.properties[0].initializer.text;
property.type = "map";
property.childType = typeArgument.properties[0].initializer.text;
}
else if (typeArgument.kind == ts.SyntaxKind.ArrayLiteralExpression) {
currentProperty.type = "array";
currentProperty.childType = typeArgument.elements[0].text;
property.type = "array";
property.childType = typeArgument.elements[0].text;
}
else {
currentProperty.type = typeArgument.text;
property.type = typeArgument.text;
}

@@ -62,13 +61,13 @@ }

}
ts.forEachChild(node, function (n) { return inspectNode(n, classes, decoratorName); });
ts.forEachChild(node, function (n) { return inspectNode(n, context, decoratorName); });
}
function parseFiles(fileNames, decoratorName) {
if (decoratorName === void 0) { decoratorName = "type"; }
var classes = [];
var context = new types_1.Context();
fileNames.forEach(function (fileName) {
var sourceFile = ts.createSourceFile(fileName, fs_1.readFileSync(fileName).toString(), ts.ScriptTarget.ES2018, true);
inspectNode(sourceFile, classes, decoratorName);
inspectNode(sourceFile, context, decoratorName);
});
return classes.filter(function (klass) { return klass.properties.length > 0; });
return context.classes.filter(function (klass) { return klass.properties.length > 0; });
}
exports.parseFiles = parseFiles;
export declare function getCommentHeader(singleLineComment?: string): string;
export declare class Property {
name: string;
type: string;
childType: string;
export declare class Context {
classes: Class[];
addClass(currentClass: Class): void;
}
export declare class Class {
context: Context;
name: string;
properties: Property[];
extends: string;
addProperty(property: Property): void;
}
export declare class Property {
index: number;
name: string;
type: string;
childType: string;
}
export interface File {

@@ -13,0 +20,0 @@ name: string;

@@ -11,8 +11,13 @@ "use strict";

exports.getCommentHeader = getCommentHeader;
var Property = /** @class */ (function () {
function Property() {
var Context = /** @class */ (function () {
function Context() {
this.classes = [];
}
return Property;
Context.prototype.addClass = function (currentClass) {
currentClass.context = this;
this.classes.push(currentClass);
};
return Context;
}());
exports.Property = Property;
exports.Context = Context;
var Class = /** @class */ (function () {

@@ -22,4 +27,18 @@ function Class() {

}
Class.prototype.addProperty = function (property) {
var parentKlass = this;
property.index = this.properties.length;
while ((parentKlass = this.context.classes.find(function (k) { return k.name === parentKlass.extends; }))) {
property.index += parentKlass.properties.length;
}
this.properties.push(property);
};
return Class;
}());
exports.Class = Class;
var Property = /** @class */ (function () {
function Property() {
}
return Property;
}());
exports.Property = Property;

@@ -41,8 +41,2 @@ "use strict";

}
function _str(bytes, it, length) {
var value = utf8Read(bytes, it.offset, length);
it.offset += length;
return value;
}
;
function int8(bytes, it) {

@@ -125,3 +119,19 @@ return uint8(bytes, it) << 24 >> 24;

var prefix = bytes[it.offset++];
return _str(bytes, it, prefix & 0x1f);
var length;
if (prefix < 0xc0) {
// fixstr
length = prefix & 0x1f;
}
else if (prefix === 0xd9) {
length = uint8(bytes, it);
}
else if (prefix === 0xda) {
length = uint16(bytes, it);
}
else if (prefix === 0xdb) {
length = uint32(bytes, it);
}
var value = utf8Read(bytes, it.offset, length);
it.offset += length;
return value;
}

@@ -128,0 +138,0 @@ exports.string = string;

@@ -179,3 +179,4 @@ "use strict";

else if (length < 0x100) {
bytes.push(0xd9, length);
bytes.push(0xd9);
uint8(bytes, length);
size = 2;

@@ -185,3 +186,4 @@ }

else if (length < 0x10000) {
bytes.push(0xda, length >> 8, length);
bytes.push(0xda);
uint16(bytes, length);
size = 3;

@@ -191,3 +193,4 @@ }

else if (length < 0x100000000) {
bytes.push(0xdb, length >> 24, length >> 16, length >> 8, length);
bytes.push(0xdb);
uint32(bytes, length);
size = 5;

@@ -198,3 +201,2 @@ }

}
// defers.push({ _str: value, _length: length, _offset: bytes.length });
utf8Write(bytes, bytes.length, value);

@@ -201,0 +203,0 @@ return size + length;

@@ -138,2 +138,6 @@ "use strict";

var totalBytes = bytes.length;
// skip TYPE_ID of existing instances
if (bytes[it.offset] === spec_1.TYPE_ID) {
it.offset += 2;
}
var _loop_1 = function () {

@@ -140,0 +144,0 @@ var index = bytes[it.offset++];

{
"name": "@colyseus/schema",
"version": "0.4.25-alpha.0",
"version": "0.4.25-alpha.1",
"description": "Schema-based binary serializer / de-serializer.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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