Socket
Socket
Sign inDemoInstall

@aire-ux/aire-condensation

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aire-ux/aire-condensation - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

3

dist/condensation.d.ts

@@ -35,2 +35,3 @@ import TypeRegistry from "./type-registry";

export declare function register(...registrations: RegistrationDefinition[]): void;
export declare namespace Condensation { }
export declare namespace Condensation {
}
import TypeRegistry from "./type-registry";
import RemoteRegistry from "./remote-registry";
import { allocate, isPointer, Region, } from "./types";
import { Dynamic, allocate, isPointer, Region, } from "./types";
import { BooleanDeserializer, NumberDeserializer, StringDeserializer, TypeRegistrationDeserializer, } from "./deserializer";

@@ -87,3 +87,9 @@ /**

const doc = args[idx], jsonValue = JSON.parse(doc);
return Condensation.deserializerFor(def.type).read(jsonValue);
if (def.type !== Dynamic) {
const deserializer = Condensation.deserializerFor(def.type);
return deserializer.read(jsonValue);
}
else {
return jsonValue;
}
});

@@ -90,0 +96,0 @@ }

@@ -1,4 +0,4 @@

export { Region, Address, Pointer } from "./types";
export { Region, Address, Pointer, Dynamic } from "./types";
export { Condensation, Context } from "./condensation";
export { Remotable, Receive, Remote } from "./remotable";
export { RootElement, Property } from "./root-element";

@@ -1,4 +0,4 @@

export { Region, Address } from "./types";
export { Region, Address, Dynamic } from "./types";
export { Condensation } from "./condensation";
export { Remotable, Receive, Remote } from "./remotable";
export { RootElement, Property } from "./root-element";

@@ -5,2 +5,4 @@ /**

export declare type Class<T> = new (...args: any[]) => T;
export declare class Dynamic {
}
/**

@@ -7,0 +9,0 @@ *

/**
* alias for a constructor type
*/
export class Dynamic {
}
/**

@@ -5,0 +7,0 @@ * represents a location in a region (memory arena)

{
"name": "@aire-ux/aire-condensation",
"version": "0.1.4",
"version": "0.1.5",
"description": "Client-side serialization library for Aire-UX",

@@ -9,3 +9,4 @@ "main": "dist/index.js",

"test": "npx jest",
"format": "npx prettier --write ."
"format": "npx prettier --write .",
"prepublish": "npx jest && ttsc -p tsconfig.json"
},

@@ -82,3 +83,3 @@ "repository": {

},
"gitHead": "b4dd0240aa16e8a611b8544281b0a80cacf173b9"
"gitHead": "f0913bd1095bb927a69d28347b3482ba34fa0a8c"
}
import TypeRegistry from "@condensation/type-registry";
import RemoteRegistry, { InvocationType } from "@condensation/remote-registry";
import RemoteRegistry, {InvocationType} from "@condensation/remote-registry";
import {Dynamic, Address, allocate, Class, isPointer, Pointer, Region,} from "@condensation/types";
import {
Address,
allocate,
Class,
isPointer,
Pointer,
Region,
} from "@condensation/types";
import {
BooleanDeserializer,

@@ -44,5 +37,5 @@ Deserializer,

invoke<T, U>(
address: Address | Pointer<T>,
op: string,
...args: string[]
address: Address | Pointer<T>,
op: string,
...args: string[]
): U | null;

@@ -64,3 +57,3 @@

static deserializerConfigurations: Map<Class<any>, Deserializer<any>> =
new Map<Class<any>, Deserializer<any>>();
new Map<Class<any>, Deserializer<any>>();

@@ -93,3 +86,4 @@ static get typeRegistry(): TypeRegistry {

class DefaultCondensationContext implements Context {
constructor(readonly region = new Region("default")) {}
constructor(readonly region = new Region("default")) {
}

@@ -108,2 +102,3 @@ create<T>(t: Class<T>, ...args: string[]): Pointer<T> {

}
invokeDirect<T, U>(value: T, op: string, ...args: string[]): U | null {

@@ -125,5 +120,5 @@

invoke<T, U>(
address: Address | Pointer<T>,
op: string,
...args: string[]
address: Address | Pointer<T>,
op: string,
...args: string[]
): U | null {

@@ -138,3 +133,3 @@ let v: Pointer<T>;

throw new Error(
`Null pointer exception at ${address} while trying to invoke ${op}`
`Null pointer exception at ${address} while trying to invoke ${op}`
);

@@ -147,6 +142,6 @@ }

const formals = this.formalParams(
Object.getPrototypeOf(v).constructor,
"method",
op,
...args
Object.getPrototypeOf(v).constructor,
"method",
op,
...args
);

@@ -166,24 +161,30 @@ return operation.apply(v, formals);

public formalParams<T>(
t: Class<T>,
type: InvocationType,
operation: string,
...args: string[]
t: Class<T>,
type: InvocationType,
operation: string,
...args: string[]
): any[] {
const remotes = Condensation.remoteRegistry,
remote = remotes.resolve(t),
ctorArgs = remote.definitions.filter(
(definition) =>
definition.invocationType === type
&& definition.invocationTarget == operation
);
remote = remotes.resolve(t),
ctorArgs = remote.definitions.filter(
(definition) =>
definition.invocationType === type
&& definition.invocationTarget == operation
);
if (ctorArgs.length !== args.length) {
throw new Error(
`Error: ${type} argument count mismatch. Expected ${ctorArgs.length}, got ${args.length}`
`Error: ${type} argument count mismatch. Expected ${ctorArgs.length}, got ${args.length}`
);
}
ctorArgs.sort((lhs, rhs) => lhs.index - rhs.index);
return ctorArgs.map((def, idx) => {
const doc = args[idx],
jsonValue = JSON.parse(doc);
return Condensation.deserializerFor(def.type).read(jsonValue);
jsonValue = JSON.parse(doc);
if (def.type !== Dynamic) {
const deserializer = Condensation.deserializerFor(def.type);
return deserializer.read(jsonValue);
} else {
return jsonValue;
}
});

@@ -205,3 +206,4 @@ }

export namespace Condensation {}
export namespace Condensation {
}
Condensation.registry = new TypeRegistry();

@@ -211,14 +213,14 @@ Condensation.remoteRegistry = new RemoteRegistry();

register(
{
type: String,
deserializer: new StringDeserializer(),
},
{
type: Boolean,
deserializer: new BooleanDeserializer(),
},
{
type: Number,
deserializer: new NumberDeserializer(),
}
{
type: String,
deserializer: new StringDeserializer(),
},
{
type: Boolean,
deserializer: new BooleanDeserializer(),
},
{
type: Number,
deserializer: new NumberDeserializer(),
}
);

@@ -1,4 +0,4 @@

export { Region, Address, Pointer } from "./types";
export { Condensation, Context } from "./condensation";
export { Remotable, Receive, Remote } from "./remotable";
export { RootElement, Property } from "./root-element";
export {Region, Address, Pointer, Dynamic} from "./types";
export {Condensation, Context} from "./condensation";
export {Remotable, Receive, Remote} from "./remotable";
export {RootElement, Property} from "./root-element";

@@ -12,2 +12,3 @@ import {Class} from "@condensation/types";

export function Receive<T>(type: Class<T>) {

@@ -14,0 +15,0 @@ return <U>(target: Class<U>, key: PropertyKey, index: number) => {

@@ -7,2 +7,6 @@ /**

export class Dynamic {
}
/**

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

import { locate } from "@condensation/invoker";
import { Condensation, Receive, Remotable } from "@condensation/index";
import { Receive, Remotable } from "@condensation/index";

@@ -4,0 +4,0 @@ test("an invoker must locate a property correctly", () => {

import {Receive, Remotable, Remote} from "@condensation/remotable";
import {Property, RootElement} from "@condensation/root-element";
import {Condensation} from "@condensation/condensation";
import {Dynamic} from "@condensation/types";
import {customElement, LitElement} from "lit-element";

@@ -186,18 +187,23 @@

const group = Condensation.deserializerFor<Group>(Group).read([
{
name: "Josiah",
},
{
name: "Lisa",
},
{
name: "Alejandro",
},
const group = Condensation.deserializerFor<Group>(Group).read(
{
members: [
{
name: "Josiah",
},
{
name: "Lisa",
},
{
name: "Alejandro",
},
{
name: "Tiff",
},
]);
{
name: "Tiff",
},
]
}
);
expect(group.members?.length).toBe(4);

@@ -286,3 +292,3 @@ expect(group.members?.map((m) => m.name)).toEqual([

@Property(Number)
private height : number | undefined;
private height: number | undefined;

@@ -328,2 +334,58 @@ @Property(String)

test('parsing json to a type should work', () => {
type Whatever = {
hello: string
};
@Remotable
class Test {
readonly whatevers: Whatever[] = [];
@Remote
add(@Receive(Dynamic) whatever: Whatever): void {
this.whatevers.push(whatever)
}
}
let a = new Test();
// @ts-ignore
a.add(`
{"hello": "world"}
`);
expect(a.whatevers.length).toBe(1);
expect(a.whatevers[0].hello).toBe("world");
});
test('parsing json to a list type should work', () => {
type Whatever = {
hello: string
};
@Remotable
class Test {
readonly whatevers: Whatever[] = [];
@Remote
add(@Receive(Dynamic) whatever: Whatever[]): void {
this.whatevers.push(...whatever)
}
}
let a = new Test();
// @ts-ignore
a.add(`[
{"hello": "world"},
{"hello": "jorld"}
]
`);
expect(a.whatevers.length).toBe(2);
expect(a.whatevers[0].hello).toBe("world");
expect(a.whatevers[1].hello).toBe("jorld");
});
test('add all should work', () => {

@@ -344,3 +406,3 @@ @RootElement

@Property(Number)
private height : number | undefined;
private height: number | undefined;

@@ -400,2 +462,4 @@ @Property(String)

expect(vertex.label).toBe("jello");
})
});
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