json-as 0.9.18 → 0.9.19
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/CHANGELOG +1 -0
- package/README.md +1 -1
- package/package.json +2 -1
- package/transform/lib/index.js +7 -9
- package/transform/package.json +1 -1
- package/transform/src/index.ts +6 -6
package/CHANGELOG
CHANGED
|
@@ -26,6 +26,7 @@ v0.9.15 - Support JSON.Raw blocks
|
|
|
26
26
|
v0.9.16 - JSON.Raw should be completely untouched
|
|
27
27
|
v0.9.17 - A schema's parent's fields should be included properly
|
|
28
28
|
v0.9.18 - Should be able to use @alias and @omit*** or JSON.Raw
|
|
29
|
+
v0.9.19 - Fix arguments in @omitif declarations not working properly
|
|
29
30
|
|
|
30
31
|
[UNRELEASED] v1.0.0
|
|
31
32
|
- Allow nullable primitives
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-as",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.19",
|
|
4
4
|
"description": "The only JSON library you'll need for AssemblyScript. SIMD enabled",
|
|
5
5
|
"types": "assembly/index.ts",
|
|
6
6
|
"author": "Jairus Tanaka",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@assemblyscript/wasi-shim": "^0.1.0",
|
|
33
|
+
"@types/node": "^20.14.12",
|
|
33
34
|
"as-bench": "^0.0.0-alpha",
|
|
34
35
|
"as-console": "^7.0.0",
|
|
35
36
|
"as-test": "0.3.1",
|
package/transform/lib/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FieldDeclaration,
|
|
3
|
-
StringLiteralExpression,
|
|
4
|
-
} from "assemblyscript/dist/assemblyscript.js";
|
|
1
|
+
import { FieldDeclaration } from "assemblyscript/dist/assemblyscript.js";
|
|
5
2
|
import { toString, isStdlib } from "visitor-as/dist/utils.js";
|
|
6
3
|
import { BaseVisitor, SimpleParser } from "visitor-as/dist/index.js";
|
|
7
4
|
import { Transform } from "assemblyscript/dist/transform.js";
|
|
@@ -414,7 +411,6 @@ class Property {
|
|
|
414
411
|
this.type = "";
|
|
415
412
|
this.value = null;
|
|
416
413
|
this.flags = new Map();
|
|
417
|
-
this.args = [];
|
|
418
414
|
this.serialize = null;
|
|
419
415
|
this.deserialize = null;
|
|
420
416
|
this.initialize = null;
|
|
@@ -435,7 +431,11 @@ class Property {
|
|
|
435
431
|
"__DESERIALIZE<" + type + ">(data.substring(value_start, value_end))";
|
|
436
432
|
}
|
|
437
433
|
if (this.flags.has(PropertyFlags.OmitIf)) {
|
|
438
|
-
const condition = this.
|
|
434
|
+
const condition = this.flags.get(PropertyFlags.OmitIf)[0];
|
|
435
|
+
if (!condition)
|
|
436
|
+
throw new Error(
|
|
437
|
+
"Could not find condition when using decorator @omitif! Provide at least one condition",
|
|
438
|
+
);
|
|
439
439
|
this.serialize =
|
|
440
440
|
"${" +
|
|
441
441
|
condition +
|
|
@@ -506,9 +506,7 @@ function getArgs(args) {
|
|
|
506
506
|
if (!args) return [];
|
|
507
507
|
let out = [];
|
|
508
508
|
for (const arg of args) {
|
|
509
|
-
|
|
510
|
-
out.push(arg.value);
|
|
511
|
-
}
|
|
509
|
+
out.push(toString(arg));
|
|
512
510
|
}
|
|
513
511
|
return out;
|
|
514
512
|
}
|
package/transform/package.json
CHANGED
package/transform/src/index.ts
CHANGED
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
ClassDeclaration,
|
|
3
3
|
FieldDeclaration,
|
|
4
4
|
IdentifierExpression,
|
|
5
|
-
StringLiteralExpression,
|
|
6
5
|
Parser,
|
|
7
6
|
Source,
|
|
8
7
|
NodeKind,
|
|
@@ -467,7 +466,6 @@ class Property {
|
|
|
467
466
|
PropertyFlags,
|
|
468
467
|
string[]
|
|
469
468
|
>();
|
|
470
|
-
public args: string[] | null = [];
|
|
471
469
|
|
|
472
470
|
public serialize: string | null = null;
|
|
473
471
|
public deserialize: string | null = null;
|
|
@@ -494,7 +492,11 @@ class Property {
|
|
|
494
492
|
}
|
|
495
493
|
|
|
496
494
|
if (this.flags.has(PropertyFlags.OmitIf)) {
|
|
497
|
-
const condition = this.
|
|
495
|
+
const condition = this.flags.get(PropertyFlags.OmitIf)![0];
|
|
496
|
+
if (!condition)
|
|
497
|
+
throw new Error(
|
|
498
|
+
"Could not find condition when using decorator @omitif! Provide at least one condition",
|
|
499
|
+
);
|
|
498
500
|
this.serialize =
|
|
499
501
|
"${" +
|
|
500
502
|
condition +
|
|
@@ -575,9 +577,7 @@ function getArgs(args: Expression[] | null): string[] {
|
|
|
575
577
|
if (!args) return [];
|
|
576
578
|
let out: string[] = [];
|
|
577
579
|
for (const arg of args) {
|
|
578
|
-
|
|
579
|
-
out.push(arg.value);
|
|
580
|
-
}
|
|
580
|
+
out.push(toString(arg));
|
|
581
581
|
}
|
|
582
582
|
return out;
|
|
583
583
|
}
|