json-as 0.5.20 → 0.5.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Jairus Tanaka <jairus.v.tanaka@outlook.com>
3
+ Copyright (c) 2023 Jairus Tanaka <jairus.v.tanaka@outlook.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/asconfig.json CHANGED
@@ -12,6 +12,9 @@
12
12
  "options": {
13
13
  "transform": [
14
14
  "./transform"
15
- ]
16
- }
15
+ ],
16
+ "bindings": "esm",
17
+ "exportStart": "_start"
18
+ },
19
+ "extends": "./node_modules/@assemblyscript/wasi-shim/asconfig.json"
17
20
  }
@@ -486,7 +486,7 @@ function parseArrayArray<T extends unknown[][]>(data: string): T {
486
486
  const result = instantiate<T>();
487
487
  let char = 0;
488
488
  let lastPos = 0;
489
- let depth = 1;
489
+ let depth = 0;
490
490
  let i = 1;
491
491
  // Find start of bracket
492
492
  //for (; unsafeCharCodeAt(data, i) !== leftBracketCode; i++) {}
@@ -494,14 +494,14 @@ function parseArrayArray<T extends unknown[][]>(data: string): T {
494
494
  for (; i < data.length - 1; i++) {
495
495
  char = unsafeCharCodeAt(data, i);
496
496
  if (char === leftBracketCode) {
497
- if (depth === 1) {
497
+ if (depth === 0) {
498
498
  lastPos = i;
499
499
  }
500
500
  // Shifting is 6% faster than incrementing
501
- depth = depth << 1;
501
+ depth++;
502
502
  } else if (char === rightBracketCode) {
503
- depth = depth >> 1;
504
- if (depth === 1) {
503
+ depth--;
504
+ if (depth === 0) {
505
505
  i++;
506
506
  result.push(JSON.parse<valueof<T>>(data.slice(lastPos, i)));
507
507
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-as",
3
- "version": "0.5.20",
3
+ "version": "0.5.21",
4
4
  "description": "JSON encoder/decoder for AssemblyScript",
5
5
  "types": "assembly/index.ts",
6
6
  "author": "Jairus Tanaka",
@@ -27,14 +27,14 @@
27
27
  "@assemblyscript/wasi-shim": "^0.1.0",
28
28
  "assemblyscript": "^0.27.0",
29
29
  "assemblyscript-prettier": "^1.0.7",
30
- "prettier": "^2.8.3",
30
+ "prettier": "^2.8.4",
31
31
  "typescript": "^4.9.5",
32
32
  "visitor-as": "^0.11.4"
33
33
  },
34
34
  "dependencies": {
35
- "as-string-sink": "^0.5.0",
36
- "as-variant": "^0.4.1",
37
- "as-bignum": "^0.2.23"
35
+ "as-bignum": "^0.2.23",
36
+ "as-string-sink": "^0.5.3",
37
+ "as-variant": "^0.4.1"
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",
@@ -85,7 +85,9 @@ class AsJSONTransform extends BaseVisitor {
85
85
  console.error("Class extends " + this.currentClass.parent + ", but parent class not found. Maybe add the @json decorator over parent class?");
86
86
  }
87
87
  }
88
- this.visit(node.members);
88
+ const parentSchema = this.schemasList.find((v) => v.name == this.currentClass.parent);
89
+ const members = [...node.members, ...(parentSchema ? parentSchema.node.members : [])];
90
+ this.visit(members);
89
91
  let serializeFunc = "";
90
92
  if (this.currentClass.encodeStmts.length > 0) {
91
93
  const stmt = this.currentClass.encodeStmts[this.currentClass.encodeStmts.length - 1];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-as/transform",
3
- "version": "0.5.20",
3
+ "version": "0.5.21",
4
4
  "description": "JSON encoder/decoder for AssemblyScript",
5
5
  "main": "./lib/index.js",
6
6
  "author": "Jairus Tanaka",
@@ -94,7 +94,9 @@ class AsJSONTransform extends BaseVisitor {
94
94
  }
95
95
  }
96
96
 
97
- this.visit(node.members);
97
+ const parentSchema = this.schemasList.find((v) => v.name == this.currentClass.parent);
98
+ const members = [...node.members, ...(parentSchema ? parentSchema.node.members : [])]
99
+ this.visit(members);
98
100
 
99
101
  let serializeFunc = "";
100
102