Skip to content

Commit

Permalink
release v0.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Dec 15, 2023
1 parent f05ae3f commit 985e983
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
run: yarn build:test

- name: Perform tests
run: yarn run test:aspect
run: yarn run test
9 changes: 6 additions & 3 deletions assembly/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { JSON } from "./src/json";

// @ts-ignore
@json

class Vec3 {
x: f64 = 3.4;
y: f64 = 1.2;
Expand All @@ -10,7 +10,7 @@ class Vec3 {

// @ts-ignore
@json
class Player {
class Player extends Vec3 {
firstName: string;
lastName: string;
lastActive: Date;
Expand All @@ -32,6 +32,9 @@ const player: Player = {
z: 8.3,
},
isVerified: true,
x: 1,
y: 3,
z: 3
}

let out = "";
Expand All @@ -44,7 +47,7 @@ console.log("Implemented: " + JSON.stringify(JSON.parse<Vec3>('{}', true)));

console.log("Original: " + JSON.stringify(player));
//console.log("Revised: " + vec.__JSON_Deserialize('{"x":3,"y":1,"z":8}').__JSON_Serialize());
console.log("Implemented: " + JSON.stringify(JSON.parse<Player>('{"firstName":"Emmet","lastName":"West","lastActive":"2023-11-16T04:06:35.108285303Z","age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}')));
console.log("Implemented: " + JSON.stringify(JSON.parse<Player>('{"firstName":"Emmet","lastName":"West","lastActive":"2023-11-16T04:06:35.108285303Z","age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true,"x":5","y":4","z":3}')));

@serializable
class Wrapper<T> {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "json-as",
"version": "0.6.5",
"version": "0.6.6",
"description": "JSON encoder/decoder for AssemblyScript",
"types": "assembly/index.ts",
"author": "Jairus Tanaka",
Expand All @@ -14,7 +14,7 @@
],
"license": "MIT",
"scripts": {
"test:aspect": "asp",
"test": "asp",
"bench:astral": "astral --optimizeLevel 3 --shrinkLevel 0 --converge --noAssert --uncheckedBehavior never --runtime stub",
"build:test": "asc assembly/test.ts -o build/test.wasm --transform ./transform --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json --optimizeLevel 0 --shrinkLevel 0 --noAssert --uncheckedBehavior always --runtime stub",
"build:bench": "asc bench/benchmark.ts -o bench/benchmark.wasm --transform ./transform --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json --optimizeLevel 3 --shrinkLevel 0 --converge --noAssert --uncheckedBehavior always --runtime stub",
Expand Down
9 changes: 9 additions & 0 deletions transform/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,14 @@ export default class Transformer extends Transform {
transformer.visit(source);
}
}
// Check that every parent and child class is hooked up correctly
const schemas = transformer.schemasList;
for (const schema of schemas) {
if (schema.parent) {
const parent = schemas.find((v) => v.name === schema.parent);
if (!parent)
throw new Error(`Class ${schema.name} extends its parent class ${schema.parent}, but ${schema.parent} does not include a @json or @serializable decorator! Add the decorator and rebuild.`);
}
}
}
}
2 changes: 1 addition & 1 deletion transform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@json-as/transform",
"version": "0.6.5",
"version": "0.6.6",
"description": "JSON encoder/decoder for AssemblyScript",
"main": "./lib/index.js",
"author": "Jairus Tanaka",
Expand Down
8 changes: 8 additions & 0 deletions transform/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,13 @@ export default class Transformer extends Transform {
transformer.visit(source);
}
}
// Check that every parent and child class is hooked up correctly
const schemas = transformer.schemasList;
for (const schema of schemas) {
if (schema.parent) {
const parent = schemas.find((v) => v.name === schema.parent);
if (!parent) throw new Error(`Class ${schema.name} extends its parent class ${schema.parent}, but ${schema.parent} does not include a @json or @serializable decorator! Add the decorator and rebuild.`);
}
}
}
}

0 comments on commit 985e983

Please sign in to comment.