json-as 1.0.0-alpha.1 → 1.0.0-alpha.2
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/.gitmodules +0 -0
- package/CHANGELOG +11 -0
- package/README.md +3 -2
- package/assembly/__benches__/misc.bench.ts +0 -19
- package/assembly/deserialize/simple/object.ts +2 -3
- package/assembly/index.ts +2 -7
- package/assembly/serialize/simd/string.ts +1 -1
- package/assembly/serialize/simple/array.ts +1 -1
- package/assembly/serialize/simple/bool.ts +1 -1
- package/assembly/serialize/simple/date.ts +1 -1
- package/assembly/serialize/simple/float.ts +1 -1
- package/assembly/serialize/simple/integer.ts +1 -1
- package/assembly/serialize/simple/map.ts +1 -1
- package/assembly/serialize/simple/string.ts +2 -2
- package/assembly/test.ts +8 -13
- package/modules/as-bs/LICENSE +21 -0
- package/modules/as-bs/README.md +95 -0
- package/modules/{bs → as-bs/assembly}/index.ts +11 -12
- package/modules/as-bs/assembly/tsconfig.json +97 -0
- package/modules/as-bs/index.ts +1 -0
- package/modules/as-bs/package.json +32 -0
- package/package.json +4 -5
- package/transform/lib/builder.js +1262 -1340
- package/transform/lib/index.js +512 -572
- package/transform/lib/index.js.map +1 -1
- package/transform/lib/linker.js +10 -12
- package/transform/lib/types.js +19 -18
- package/transform/lib/types.js.map +1 -1
- package/transform/lib/util.js +34 -34
- package/transform/lib/visitor.js +526 -529
- package/transform/package.json +2 -1
- package/transform/src/index.ts +19 -8
- package/transform/src/types.ts +1 -0
- package/modules/tsconfig.json +0 -8
- package/transform/lib/index.old.js +0 -404
- package/transform/lib/index.old.js.map +0 -1
package/.gitmodules
ADDED
|
File without changes
|
package/CHANGELOG
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## UNRELEASED
|
|
4
4
|
|
|
5
|
+
## 2025-01-20 - 1.0.0-alpha.2
|
|
6
|
+
|
|
7
|
+
- fix: disable SIMD in generated transform code by default
|
|
8
|
+
- fix: re-add as-bs dependency so that it will not break in non-local environments
|
|
9
|
+
- fix: remove AS201 'conversion from type usize to i32' warning
|
|
10
|
+
- fix: add as-bs to peer dependencies so only one version is installed
|
|
11
|
+
- fix: point as-bs imports to submodule
|
|
12
|
+
- fix: remove submodule in favor of static module
|
|
13
|
+
- fix: bs.ensureSize would not grow and thus cause memory faults
|
|
14
|
+
- fix: bs.ensureSize triggering unintentionally
|
|
15
|
+
|
|
5
16
|
## 2025-01-20 - 1.0.0-alpha.1
|
|
6
17
|
|
|
7
18
|
- feat: finish implementation of arbitrary data serialization and deserialization using JSON.Value
|
package/README.md
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
7
7
|
█████ ███████ ██████ ██ ████ ██ ██ ███████
|
|
8
8
|
</span>
|
|
9
|
-
AssemblyScript - v1.0.0-alpha.
|
|
9
|
+
AssemblyScript - v1.0.0-alpha.2
|
|
10
10
|
</pre>
|
|
11
11
|
</h5>
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm install json-as@1.0.0-alpha.
|
|
16
|
+
npm install json-as@1.0.0-alpha.2
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Add the `--transform` to your `asc` command (e.g. in package.json)
|
|
@@ -56,6 +56,7 @@ class Player {
|
|
|
56
56
|
lastActive!: i32[];
|
|
57
57
|
// Drop in a code block, function, or expression that evaluates to a boolean
|
|
58
58
|
@omitif((age) => age < 18)
|
|
59
|
+
@omitif('this.age <= 0')
|
|
59
60
|
age!: i32;
|
|
60
61
|
@omitnull()
|
|
61
62
|
pos!: Vec3 | null;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { bench } from "as-bench/assembly/bench";
|
|
2
|
-
import { bs } from "../../modules/bs";
|
|
3
|
-
import { deserializeString_SIMD } from "../deserialize/simd/string";
|
|
4
|
-
import { deserializeString } from "../deserialize/simple/string";
|
|
5
|
-
import { bytes } from "../util/bytes";
|
|
6
|
-
const str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()\\\"\t\r\f\n\u0000';
|
|
7
|
-
const str2 = '"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()\\\\\\"\\t\\r\\f\\n\\u0000"';
|
|
8
|
-
const srcStart = changetype<usize>(str);
|
|
9
|
-
const srcEnd = srcStart + bytes(str);
|
|
10
|
-
bs.ensureSize(2048);
|
|
11
|
-
bench("Deserialize String (Simple)", () => {
|
|
12
|
-
deserializeStrin(str2);
|
|
13
|
-
});
|
|
14
|
-
// bench("Deserialize String (SIMD)", () => {
|
|
15
|
-
// (str2, bs.buffer);
|
|
16
|
-
// });
|
|
17
|
-
bench("Deserialize String (SIMD)", () => {
|
|
18
|
-
deserializeString_SIMD(str2, srcStart, srcEnd, __new(158, idof<string>()));
|
|
19
|
-
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BACK_SLASH, COMMA, CHAR_F, BRACE_LEFT, BRACKET_LEFT, CHAR_N, QUOTE, BRACE_RIGHT, BRACKET_RIGHT, CHAR_T
|
|
1
|
+
import { BACK_SLASH, COMMA, CHAR_F, BRACE_LEFT, BRACKET_LEFT, CHAR_N, QUOTE, BRACE_RIGHT, BRACKET_RIGHT, CHAR_T } from "../../custom/chars";
|
|
2
2
|
import { isSpace } from "../../util";
|
|
3
|
-
import { ptrToStr } from "../../util/ptrToStr";
|
|
4
3
|
|
|
5
4
|
export function deserializeObject<T>(srcStart: usize, srcEnd: usize, dst: usize): T {
|
|
6
5
|
const out = changetype<nonnull<T>>(dst || __new(offsetof<T>(), idof<T>()));
|
|
@@ -9,7 +8,7 @@ export function deserializeObject<T>(srcStart: usize, srcEnd: usize, dst: usize)
|
|
|
9
8
|
let keyEnd: usize = 0;
|
|
10
9
|
let isKey = false;
|
|
11
10
|
let depth = 0;
|
|
12
|
-
let lastIndex = 0;
|
|
11
|
+
let lastIndex: usize = 0;
|
|
13
12
|
|
|
14
13
|
// while (srcStart < srcEnd && isSpace(load<u16>(srcStart))) srcStart += 2;
|
|
15
14
|
// while (srcEnd > srcStart && isSpace(load<u16>(srcEnd))) srcEnd -= 2;
|
package/assembly/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path="./index.d.ts" />
|
|
2
|
-
import { bs } from "../modules/bs";
|
|
2
|
+
import { bs } from "../modules/as-bs";
|
|
3
3
|
|
|
4
4
|
import { serializeString } from "./serialize/simple/string";
|
|
5
5
|
import { serializeArray } from "./serialize/simple/array";
|
|
@@ -23,7 +23,6 @@ import { serializeFloat } from "./serialize/simple/float";
|
|
|
23
23
|
import { serializeObject } from "./serialize/simple/object";
|
|
24
24
|
import { ptrToStr } from "./util/ptrToStr";
|
|
25
25
|
import { bytes } from "./util";
|
|
26
|
-
import { serializeString_SIMD } from "./serialize/simd/string";
|
|
27
26
|
|
|
28
27
|
export type Raw = string;
|
|
29
28
|
|
|
@@ -375,11 +374,7 @@ export namespace JSON {
|
|
|
375
374
|
store<u64>(bs.offset, 30399761348886638);
|
|
376
375
|
bs.offset += 8;
|
|
377
376
|
} else if (isString<nonnull<T>>()) {
|
|
378
|
-
|
|
379
|
-
serializeString_SIMD(src as string);
|
|
380
|
-
} else {
|
|
381
|
-
serializeString(src as string);
|
|
382
|
-
}
|
|
377
|
+
serializeString(src as string);
|
|
383
378
|
// @ts-ignore: Supplied by transform
|
|
384
379
|
} else if (isDefined(src.__SERIALIZE)) {
|
|
385
380
|
// @ts-ignore
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSON } from "../..";
|
|
2
2
|
import { BRACE_LEFT, BRACE_RIGHT, COLON, COMMA } from "../../custom/chars";
|
|
3
|
-
import { bs } from "../../../modules/bs";
|
|
3
|
+
import { bs } from "../../../modules/as-bs";
|
|
4
4
|
|
|
5
5
|
export function serializeMap<T extends Map<any, any>>(src: T): void {
|
|
6
6
|
const srcSize = src.size;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _intTo16 } from "../../custom/util";
|
|
2
2
|
import { bytes } from "../../util/bytes";
|
|
3
|
-
import { bs } from "../../../modules/bs";
|
|
3
|
+
import { bs } from "../../../modules/as-bs";
|
|
4
4
|
import { BACK_SLASH, QUOTE } from "../../custom/chars";
|
|
5
5
|
import { SERIALIZE_ESCAPE_TABLE } from "../../globals/tables";
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ export function serializeString(src: string): void {
|
|
|
18
18
|
store<u16>(bs.offset, QUOTE);
|
|
19
19
|
bs.offset += 2;
|
|
20
20
|
|
|
21
|
-
let lastPtr:
|
|
21
|
+
let lastPtr: usize = srcPtr;
|
|
22
22
|
while (srcPtr < srcEnd) {
|
|
23
23
|
const code = load<u16>(srcPtr);
|
|
24
24
|
if (code == 34 || code == 92 || code < 32) {
|
package/assembly/test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JSON } from ".";
|
|
2
|
+
|
|
2
3
|
// @json or @serializable work here
|
|
3
4
|
@json
|
|
4
5
|
class Vec3 {
|
|
@@ -10,22 +11,18 @@ class Vec3 {
|
|
|
10
11
|
|
|
11
12
|
@json
|
|
12
13
|
class Player {
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
@alias("first name")
|
|
14
16
|
firstName!: string;
|
|
15
17
|
lastName!: string;
|
|
16
18
|
lastActive!: i32[];
|
|
17
19
|
// Drop in a code block, function, or expression that evaluates to a boolean
|
|
18
|
-
@omitif((self: Player): boolean => self.age
|
|
20
|
+
@omitif((self: Player): boolean => self.age <= 18)
|
|
19
21
|
age!: i32;
|
|
20
|
-
|
|
22
|
+
|
|
23
|
+
@omitnull()
|
|
21
24
|
pos!: Vec3 | null;
|
|
22
25
|
isVerified!: boolean;
|
|
23
|
-
@inline __INITIALIZE(): this {
|
|
24
|
-
this.firstName = "";
|
|
25
|
-
this.lastName = "";
|
|
26
|
-
this.pos = changetype<nonnull<Vec3 | null>>(__new(offsetof<nonnull<Vec3 | null>>(), idof<nonnull<Vec3 | null>>())).__INITIALIZE();
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
26
|
}
|
|
30
27
|
|
|
31
28
|
const player: Player = {
|
|
@@ -43,7 +40,5 @@ const player: Player = {
|
|
|
43
40
|
|
|
44
41
|
const stringified = JSON.stringify<Player>(player);
|
|
45
42
|
console.log("Serialized: " + stringified);
|
|
46
|
-
const parsed = JSON.parse<Player>(
|
|
47
|
-
console.log("Deserialized: " + JSON.stringify<Player>(
|
|
48
|
-
|
|
49
|
-
console.log("Deserialized: " + JSON.stringify(JSON.parse<i32[]>("[1,2,3]")))
|
|
43
|
+
// const parsed = JSON.parse<Player>('{"pos":{"x":3.4,"y":1.2,"z":8.3},"first name":"Jairus","lastName":"Tanaka","lastActive":[1,20,2025],"age":18,"isVerified":true}');
|
|
44
|
+
console.log("Deserialized: " + JSON.stringify<Player>(JSON.parse<Player>('{"pos":{"x":3.4,"y":1.2,"z":8.3},"first name":"Jairus","lastName":"Tanaka","lastActive":[1,20,2025],"age":18,"isVerified":true}')));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jairus Tanaka <me@jairus.dev>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<h5 align="center">
|
|
2
|
+
<pre>
|
|
3
|
+
<span style="font-size: 0.5em;">██████ ██ ██ ███████ ███████ ███████ ██████ ███████ ██ ███ ██ ██ ██
|
|
4
|
+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██
|
|
5
|
+
██████ ██ ██ █████ █████ █████ ██████ ███████ ██ ██ ██ ██ █████
|
|
6
|
+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
7
|
+
██████ ██████ ██ ██ ███████ ██ ██ ███████ ██ ██ ████ ██ ██
|
|
8
|
+
</span>
|
|
9
|
+
AssemblyScript - v1.0.1
|
|
10
|
+
</pre>
|
|
11
|
+
</h5>
|
|
12
|
+
|
|
13
|
+
## About
|
|
14
|
+
|
|
15
|
+
This library provides a centralized buffer for managing memory in AssemblyScript. It keeps track of a single buffer, the current offset, and handles allocations. Using a singular buffer essentially eliminates the need for any calls to `memory.copy()` as well as any `malloc()` or `realloc()`-type calls. Highly unsafe, but extremely useful for extraordinarily high-performance scenarios.
|
|
16
|
+
|
|
17
|
+
[This library](https://github.com/JairusSW/as-bs) is what makes [as-json](https://github.com/JairusSW/as-json) operate in the multi-gigabyte-per-second ranges
|
|
18
|
+
|
|
19
|
+
To take a look at some practical uses of as-bs, check out the functions [here](https://github.com/JairusSW/as-json/tree/master/assembly/serialize/simple)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install as-bs
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**🚨 IMPORTANT 🚨**
|
|
28
|
+
|
|
29
|
+
To make sure we all depend on the same version of as-bs, please modify your package.json to meet the following
|
|
30
|
+
|
|
31
|
+
Forgoing this will result in fragmentation and just a lot of problems.
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"as-bs": "latest"
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Here's an example taken out of [as-json](https://github.com/JairusSW/as-json/tree/master/assembly/serialize/simple/string.ts)
|
|
42
|
+
|
|
43
|
+
This is an example of as-bs used right
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import { bs } from "as-bs";
|
|
47
|
+
|
|
48
|
+
function serializeString(src: string): string {
|
|
49
|
+
const srcSize = bytes(src);
|
|
50
|
+
bs.ensureSize(srcSize + 4);
|
|
51
|
+
|
|
52
|
+
let srcPtr = changetype<usize>(src);
|
|
53
|
+
|
|
54
|
+
const srcEnd = srcPtr + srcSize;
|
|
55
|
+
|
|
56
|
+
store<u16>(bs.offset, QUOTE);
|
|
57
|
+
|
|
58
|
+
bs.offset += 2;
|
|
59
|
+
|
|
60
|
+
let lastPtr: i32 = srcPtr;
|
|
61
|
+
while (srcPtr < srcEnd) {
|
|
62
|
+
const code = load<u16>(srcPtr);
|
|
63
|
+
if (code == 34 || code == 92 || code < 32) {
|
|
64
|
+
const remBytes = srcPtr - lastPtr;
|
|
65
|
+
memory.copy(bs.offset, lastPtr, remBytes);
|
|
66
|
+
bs.offset += remBytes;
|
|
67
|
+
const escaped = load<u32>(SERIALIZE_ESCAPE_TABLE + (code << 2));
|
|
68
|
+
if ((escaped & 0xffff) != BACK_SLASH) {
|
|
69
|
+
bs.ensureCapacity(12);
|
|
70
|
+
store<u64>(bs.offset, 13511005048209500, 0);
|
|
71
|
+
store<u32>(bs.offset, escaped, 8);
|
|
72
|
+
bs.offset += 12;
|
|
73
|
+
} else {
|
|
74
|
+
bs.ensureCapacity(4);
|
|
75
|
+
store<u32>(bs.offset, escaped, 0);
|
|
76
|
+
bs.offset += 4;
|
|
77
|
+
}
|
|
78
|
+
lastPtr = srcPtr + 2;
|
|
79
|
+
}
|
|
80
|
+
srcPtr += 2;
|
|
81
|
+
}
|
|
82
|
+
const remBytes = srcEnd - lastPtr;
|
|
83
|
+
memory.copy(bs.offset, lastPtr, remBytes);
|
|
84
|
+
bs.offset += remBytes;
|
|
85
|
+
store<u16>(bs.offset, QUOTE);
|
|
86
|
+
bs.offset += 2;
|
|
87
|
+
return bs.out<string>();
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
If you use this project in your codebase, consider dropping a [star](https://github.com/JairusSW/as-bs). I would really appreciate it!
|
|
92
|
+
|
|
93
|
+
## Issues
|
|
94
|
+
|
|
95
|
+
Please submit an issue to https://github.com/JairusSW/as-bs/issues if you find anything wrong with this library
|
|
@@ -20,10 +20,10 @@ export namespace bs {
|
|
|
20
20
|
* @param data - The data object to set as the buffer.
|
|
21
21
|
*/
|
|
22
22
|
// @ts-ignore: Decorator valid here
|
|
23
|
-
@inline export function setBuffer<T>(data: T
|
|
23
|
+
@inline export function setBuffer<T>(data: T): void {
|
|
24
24
|
buffer = changetype<usize>(data);
|
|
25
25
|
offset = changetype<usize>(data);
|
|
26
|
-
byteLength =
|
|
26
|
+
byteLength = bytes(data);
|
|
27
27
|
maxOffset = byteLength + buffer;
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -34,8 +34,8 @@ export namespace bs {
|
|
|
34
34
|
*/
|
|
35
35
|
// @ts-ignore: Decorator valid here
|
|
36
36
|
@inline export function ensureCapacity(size: u32): void {
|
|
37
|
-
const newSize = offset + size;
|
|
38
|
-
if (newSize >
|
|
37
|
+
const newSize: usize = offset + size;
|
|
38
|
+
if (newSize > byteLength) {
|
|
39
39
|
const newPtr = __renew(buffer, (byteLength = nextPowerOf2(newSize - buffer)));
|
|
40
40
|
offset = offset - buffer + newPtr;
|
|
41
41
|
maxOffset = newPtr + byteLength;
|
|
@@ -50,9 +50,10 @@ export namespace bs {
|
|
|
50
50
|
*/
|
|
51
51
|
// @ts-ignore: Decorator valid here
|
|
52
52
|
@inline export function ensureSize(size: u32): void {
|
|
53
|
-
const newSize = offset + size;
|
|
53
|
+
const newSize: usize = offset + size;
|
|
54
54
|
if (newSize > maxOffset) {
|
|
55
|
-
|
|
55
|
+
byteLength += size;
|
|
56
|
+
const newPtr = __renew(buffer, byteLength);
|
|
56
57
|
offset = offset - buffer + newPtr;
|
|
57
58
|
maxOffset = newPtr + byteLength;
|
|
58
59
|
buffer = newPtr;
|
|
@@ -98,11 +99,9 @@ export namespace bs {
|
|
|
98
99
|
*/
|
|
99
100
|
// @ts-ignore: Decorator valid here
|
|
100
101
|
@inline export function shrink(): void {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
maxOffset = byteLength + buffer;
|
|
105
|
-
}
|
|
102
|
+
byteLength = offset - buffer;
|
|
103
|
+
buffer = __renew(buffer, byteLength);
|
|
104
|
+
maxOffset = byteLength + buffer;
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
/**
|
|
@@ -164,4 +163,4 @@ export namespace bs {
|
|
|
164
163
|
} else {
|
|
165
164
|
ERROR("Cannot convert type " + nameof<T>() + " to bytes!");
|
|
166
165
|
}
|
|
167
|
-
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "assemblyscript/std/assembly.json",
|
|
3
|
+
"include": ["./**/*.ts"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
6
|
+
/* Projects */
|
|
7
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
8
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
9
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
10
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
11
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
12
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
+
"experimentalDecorators": true /* Enable experimental support for TC39 stage 2 draft decorators. */,
|
|
18
|
+
"emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */,
|
|
19
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
+
/* Modules */
|
|
27
|
+
"module": "commonjs" /* Specify what module code is generated. */,
|
|
28
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
29
|
+
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
30
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
31
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
32
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
33
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
34
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
35
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
36
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
37
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
38
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
39
|
+
/* JavaScript Support */
|
|
40
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
41
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
42
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
43
|
+
/* Emit */
|
|
44
|
+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
45
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
46
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
47
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
48
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
49
|
+
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
50
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
51
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
52
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
53
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
54
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
55
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
56
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
57
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
58
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
59
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
60
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
61
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
62
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
63
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
64
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
65
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
66
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
67
|
+
/* Interop Constraints */
|
|
68
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
69
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
70
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
71
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
72
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
73
|
+
/* Type Checking */
|
|
74
|
+
"strict": false /* Enable all strict type-checking options. */,
|
|
75
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
76
|
+
"strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
|
|
77
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
78
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
79
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
80
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
81
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
82
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
83
|
+
"noUnusedLocals": true /* Enable error reporting when local variables aren't read. */,
|
|
84
|
+
"noUnusedParameters": true /* Raise an error when a function parameter isn't read. */,
|
|
85
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
86
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
87
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
88
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
89
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
90
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
91
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
92
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
93
|
+
/* Completeness */
|
|
94
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
95
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { bs } from "./assembly/index";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "as-bs",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Near zero-alloc centralized buffer for high performance applications",
|
|
5
|
+
"types": "assembly/index.ts",
|
|
6
|
+
"author": "Jairus Tanaka",
|
|
7
|
+
"contributors": [],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"scripts": {},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"assemblyscript": "^0.27.31"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/JairusSW/as-bs.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"assemblyscript",
|
|
20
|
+
"fast",
|
|
21
|
+
"memory",
|
|
22
|
+
"buffer"
|
|
23
|
+
],
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/JairusSW/as-bs/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/JairusSW/as-bs#readme",
|
|
28
|
+
"type": "module",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"@JairusSW:registry": "https://npm.pkg.github.com"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-as",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
4
|
"author": "Jairus Tanaka",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"main": "transform/lib/index.js",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"
|
|
11
|
+
"as-bs": "./modules/as-bs/",
|
|
12
12
|
"@assemblyscript/wasi-shim": "^0.1.0",
|
|
13
13
|
"@types/node": "latest",
|
|
14
14
|
"as-bench": "^0.0.0-alpha",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"as-test": "^0.3.5",
|
|
17
17
|
"assemblyscript": "^0.27.31",
|
|
18
18
|
"assemblyscript-prettier": "^3.0.1",
|
|
19
|
-
"minimatch": "^10.0.1",
|
|
20
19
|
"prettier": "^3.4.2",
|
|
21
20
|
"typescript": "latest",
|
|
22
21
|
"visitor-as": "^0.11.4"
|
|
@@ -58,8 +57,8 @@
|
|
|
58
57
|
"scripts": {
|
|
59
58
|
"test": "rm -rf ./build/ && ast test",
|
|
60
59
|
"build:bench": "rm -rf ./build/ && asc assembly/__benches__/misc.bench.ts -o ./build/bench.wasm --textFile ./build/bench.wat --transform ./transform --optimizeLevel 3 --shrinkLevel 0 --converge --noAssert --uncheckedBehavior always --runtime incremental --enable simd --enable bulk-memory",
|
|
61
|
-
"build:test": "rm -rf ./build/ && JSON_DEBUG=true asc assembly/test.ts --transform ./transform -o ./build/test.wasm --textFile ./build/test.wat --optimizeLevel 3 --shrinkLevel 0
|
|
62
|
-
"build:test:simd": "rm -rf ./build/ && JSON_DEBUG=true asc assembly/test.ts --transform ./transform -o ./build/test.wasm --textFile ./build/test.wat --optimizeLevel 3 --shrinkLevel 0 --enable simd
|
|
60
|
+
"build:test": "rm -rf ./build/ && JSON_DEBUG=true asc assembly/test.ts --transform ./transform -o ./build/test.wasm --textFile ./build/test.wat --optimizeLevel 3 --shrinkLevel 0",
|
|
61
|
+
"build:test:simd": "rm -rf ./build/ && JSON_DEBUG=true asc assembly/test.ts --transform ./transform -o ./build/test.wasm --textFile ./build/test.wat --optimizeLevel 3 --shrinkLevel 0 --enable simd",
|
|
63
62
|
"test:wasmtime": "wasmtime ./build/test.wasm",
|
|
64
63
|
"test:wasmer": "wasmer ./build/test.wasm",
|
|
65
64
|
"build:transform": "tsc -p ./transform",
|