json-as 0.9.12 → 0.9.14
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 +2 -0
- package/README.md +1 -1
- package/assembly/serialize/string.ts +1 -1
- package/package.json +2 -2
- package/transform/lib/index.js +6 -1
- package/transform/package.json +1 -1
- package/transform/src/index.ts +3 -1
package/CHANGELOG
CHANGED
|
@@ -20,6 +20,8 @@ v0.9.9a - Remove extraneous logs from transform
|
|
|
20
20
|
v0.9.10 - Fix transform type checks. switch to nodekind checks
|
|
21
21
|
v0.9.11 - Remove MpZ--implement custom serializers and deserializers in the works
|
|
22
22
|
v0.9.12 - Add compat with aspect
|
|
23
|
+
v0.9.13 - Fix empty strings not indexing correctly
|
|
24
|
+
v0.9.14 - Ignore properties of type Function
|
|
23
25
|
|
|
24
26
|
[UNRELEASED] v1.0.0
|
|
25
27
|
- Allow nullable primitives
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ import { _intTo16, intTo16 } from "../custom/util";
|
|
|
15
15
|
@inline export function serializeString(data: string): string {
|
|
16
16
|
const len = data.length << 1;
|
|
17
17
|
if (len === 0) {
|
|
18
|
-
bs.
|
|
18
|
+
bs.write_32(2228258); /* "" */
|
|
19
19
|
return bs.out<string>();
|
|
20
20
|
}
|
|
21
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-as",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.14",
|
|
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",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"scripts": {
|
|
18
|
-
"test": "ast test",
|
|
18
|
+
"test": "ast test && rm -rf ./build/",
|
|
19
19
|
"pretest": "rm -rf ./build/ && ast build",
|
|
20
20
|
"build:test": "rm -rf ./build/ && JSON_DEBUG=true asc assembly/test.ts --transform ./transform -o ./build/test.wasm",
|
|
21
21
|
"build:bench": "asc bench/benchmark.ts -o bench/benchmark.wasm --transform ./transform --optimizeLevel 3 --shrinkLevel 0 --converge --noAssert --uncheckedBehavior always --runtime stub --enable simd",
|
package/transform/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FieldDeclaration } from "assemblyscript/dist/assemblyscript.js";
|
|
1
2
|
import { toString, isStdlib } from "visitor-as/dist/utils.js";
|
|
2
3
|
import { BaseVisitor, SimpleParser } from "visitor-as/dist/index.js";
|
|
3
4
|
import { Transform } from "assemblyscript/dist/transform.js";
|
|
@@ -63,10 +64,14 @@ class JSONTransform extends BaseVisitor {
|
|
|
63
64
|
}
|
|
64
65
|
for (const member of members) {
|
|
65
66
|
const name = member.name;
|
|
67
|
+
if (!(member instanceof FieldDeclaration))
|
|
68
|
+
continue;
|
|
66
69
|
if (!member.type) {
|
|
67
70
|
throw new Error("Fields must be strongly typed! Found " + toString(member) + " at " + node.range.source.normalizedPath);
|
|
68
71
|
}
|
|
69
72
|
const type = toString(member.type);
|
|
73
|
+
if (type.startsWith("(") && type.includes("=>"))
|
|
74
|
+
continue;
|
|
70
75
|
const value = member.initializer ? toString(member.initializer) : null;
|
|
71
76
|
if (member.flags == 32 /* CommonFlags.Static */)
|
|
72
77
|
continue;
|
|
@@ -140,7 +145,7 @@ class JSONTransform extends BaseVisitor {
|
|
|
140
145
|
}
|
|
141
146
|
mem.name = name.text;
|
|
142
147
|
}
|
|
143
|
-
const t = mem.node.type.name
|
|
148
|
+
const t = mem.node.type.name?.identifier.text;
|
|
144
149
|
if (this.schemasList.find(v => v.name == t)) {
|
|
145
150
|
mem.initialize = "this." + name.text + " = changetype<nonnull<" + mem.type + ">>(__new(offsetof<nonnull<" + mem.type + ">>(), idof<nonnull<" + mem.type + ">>()));\n changetype<nonnull<" + mem.type + ">>(this." + name.text + ").__INITIALIZE()";
|
|
146
151
|
}
|
package/transform/package.json
CHANGED
package/transform/src/index.ts
CHANGED
|
@@ -88,10 +88,12 @@ class JSONTransform extends BaseVisitor {
|
|
|
88
88
|
|
|
89
89
|
for (const member of members) {
|
|
90
90
|
const name = member.name;
|
|
91
|
+
if (!(member instanceof FieldDeclaration)) continue;
|
|
91
92
|
if (!member.type) {
|
|
92
93
|
throw new Error("Fields must be strongly typed! Found " + toString(member) + " at " + node.range.source.normalizedPath);
|
|
93
94
|
}
|
|
94
95
|
const type = toString(member.type!);
|
|
96
|
+
if (type.startsWith("(") && type.includes("=>")) continue;
|
|
95
97
|
const value = member.initializer ? toString(member.initializer!) : null;
|
|
96
98
|
|
|
97
99
|
if (member.flags == CommonFlags.Static) continue;
|
|
@@ -159,7 +161,7 @@ class JSONTransform extends BaseVisitor {
|
|
|
159
161
|
mem.name = name.text;
|
|
160
162
|
}
|
|
161
163
|
|
|
162
|
-
const t = (mem.node.type as NamedTypeNode).name
|
|
164
|
+
const t = (mem.node.type as NamedTypeNode).name?.identifier.text;
|
|
163
165
|
if (this.schemasList.find(v => v.name == t)) {
|
|
164
166
|
mem.initialize = "this." + name.text + " = changetype<nonnull<" + mem.type + ">>(__new(offsetof<nonnull<" + mem.type + ">>(), idof<nonnull<" + mem.type + ">>()));\n changetype<nonnull<" + mem.type + ">>(this." + name.text + ").__INITIALIZE()";
|
|
165
167
|
} else if (mem.value) {
|