json-as 1.2.1 → 1.2.2-beta.1

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.
Files changed (79) hide show
  1. package/package.json +1 -1
  2. package/.github/FUNDING.yml +0 -1
  3. package/.github/dependabot.yml +0 -11
  4. package/.github/workflows/benchmark.yml +0 -72
  5. package/.github/workflows/release-package.yml +0 -47
  6. package/.github/workflows/tests.yml +0 -25
  7. package/.prettierignore +0 -9
  8. package/.prettierrc.json +0 -7
  9. package/.trunk/configs/.markdownlint.yaml +0 -2
  10. package/.trunk/configs/.shellcheckrc +0 -7
  11. package/.trunk/configs/.yamllint.yaml +0 -7
  12. package/.trunk/trunk.yaml +0 -37
  13. package/CHANGELOG.md +0 -334
  14. package/SECURITY.md +0 -32
  15. package/asconfig.json +0 -7
  16. package/assembly/__benches__/abc.bench.ts +0 -28
  17. package/assembly/__benches__/large.bench.ts +0 -238
  18. package/assembly/__benches__/lib/bench.ts +0 -85
  19. package/assembly/__benches__/medium.bench.ts +0 -128
  20. package/assembly/__benches__/small.bench.ts +0 -46
  21. package/assembly/__benches__/throughput.ts +0 -172
  22. package/assembly/__benches__/vec3.bench.ts +0 -37
  23. package/assembly/__tests__/arbitrary.spec.ts +0 -35
  24. package/assembly/__tests__/array.spec.ts +0 -145
  25. package/assembly/__tests__/bool.spec.ts +0 -12
  26. package/assembly/__tests__/box.spec.ts +0 -27
  27. package/assembly/__tests__/custom.spec.ts +0 -56
  28. package/assembly/__tests__/date.spec.ts +0 -36
  29. package/assembly/__tests__/enum.spec.ts +0 -35
  30. package/assembly/__tests__/float.spec.ts +0 -42
  31. package/assembly/__tests__/generics.spec.ts +0 -49
  32. package/assembly/__tests__/hierarchy.spec.ts +0 -61
  33. package/assembly/__tests__/integer.spec.ts +0 -26
  34. package/assembly/__tests__/lib/index.ts +0 -41
  35. package/assembly/__tests__/map.spec.ts +0 -7
  36. package/assembly/__tests__/namespace.spec.ts +0 -63
  37. package/assembly/__tests__/null.spec.ts +0 -12
  38. package/assembly/__tests__/raw.spec.ts +0 -23
  39. package/assembly/__tests__/resolving.spec.ts +0 -55
  40. package/assembly/__tests__/staticarray.spec.ts +0 -12
  41. package/assembly/__tests__/string.spec.ts +0 -30
  42. package/assembly/__tests__/struct.spec.ts +0 -163
  43. package/assembly/__tests__/test.spec.ts +0 -3
  44. package/assembly/__tests__/types.spec.ts +0 -27
  45. package/assembly/__tests__/types.ts +0 -98
  46. package/assembly/test.tmp.ts +0 -133
  47. package/bench/abc.bench.ts +0 -25
  48. package/bench/large.bench.ts +0 -127
  49. package/bench/lib/bench.d.ts +0 -27
  50. package/bench/lib/bench.js +0 -53
  51. package/bench/lib/chart.ts +0 -217
  52. package/bench/medium.bench.ts +0 -68
  53. package/bench/runners/assemblyscript.js +0 -34
  54. package/bench/small.bench.ts +0 -34
  55. package/bench/throughput.ts +0 -87
  56. package/bench/tsconfig.json +0 -13
  57. package/bench/vec3.bench.ts +0 -30
  58. package/bench.ts +0 -18
  59. package/ci/bench/lib/bench.ts +0 -42
  60. package/ci/bench/runners/assemblyscript.js +0 -29
  61. package/ci/run-bench.as.sh +0 -63
  62. package/publish.sh +0 -78
  63. package/run-bench.as.sh +0 -60
  64. package/run-bench.js.sh +0 -36
  65. package/run-tests.sh +0 -51
  66. package/scripts/build-chart01.ts +0 -38
  67. package/scripts/build-chart02.ts +0 -38
  68. package/scripts/build-chart03.ts +0 -139
  69. package/scripts/build-chart05.ts +0 -47
  70. package/scripts/generate-as-class.ts +0 -50
  71. package/scripts/lib/bench-utils.ts +0 -308
  72. package/transform/src/builder.ts +0 -1375
  73. package/transform/src/index.ts +0 -1486
  74. package/transform/src/linkers/alias.ts +0 -58
  75. package/transform/src/linkers/custom.ts +0 -32
  76. package/transform/src/linkers/imports.ts +0 -22
  77. package/transform/src/types.ts +0 -300
  78. package/transform/src/util.ts +0 -128
  79. package/transform/src/visitor.ts +0 -530
@@ -1,34 +0,0 @@
1
- const bytes = readbuffer("./build/" + arguments[0]);
2
- const module = new WebAssembly.Module(bytes);
3
- let memory = null;
4
- const { exports } = new WebAssembly.Instance(module, {
5
- env: {
6
- abort: (msg, file, line) => {
7
- console.log("abort: " + __liftString(msg) + " in " + __liftString(file) + ":" + __liftString(line));
8
- },
9
- "console.log": (ptr) => {
10
- console.log(__liftString(ptr));
11
- },
12
- "Date.now": () => Date.now(),
13
- "performance.now": () => performance.now(),
14
- "writeFile": (fileName, data) => {
15
- fileName = __liftString(fileName)
16
- data = __liftString(data);
17
- writeFile(fileName, data);
18
- }
19
- },
20
- });
21
-
22
- memory = exports.memory;
23
-
24
- function __liftString(pointer) {
25
- if (!pointer) return null;
26
- const end = (pointer + new Uint32Array(memory.buffer)[(pointer - 4) >>> 2]) >>> 1,
27
- memoryU16 = new Uint16Array(memory.buffer);
28
- let start = pointer >>> 1,
29
- string = "";
30
- while (end - start > 1024) string += String.fromCharCode(...memoryU16.subarray(start, (start += 1024)));
31
- return string + String.fromCharCode(...memoryU16.subarray(start, end));
32
- }
33
-
34
- exports.start();
@@ -1,34 +0,0 @@
1
- import { bench, blackbox, dumpToFile } from "./lib/bench.js";
2
-
3
- class SmallJSON {
4
- public id!: number;
5
- public name!: string;
6
- public active!: boolean;
7
- }
8
-
9
- const v1: SmallJSON = {
10
- id: 1,
11
- name: "Small Object",
12
- active: true,
13
- };
14
- const v2 = '{"id":1,"name":"Small Object","active":true}';
15
-
16
- bench(
17
- "Serialize Small Object",
18
- () => {
19
- blackbox(JSON.stringify(v1));
20
- },
21
- 16_000_00,
22
- v2.length << 1
23
- );
24
- dumpToFile("small", "serialize")
25
-
26
- bench(
27
- "Deserialize Small Object",
28
- () => {
29
- blackbox(JSON.parse(v2));
30
- },
31
- 16_000_00,
32
- v2.length << 1
33
- );
34
- dumpToFile("small", "deserialize")
@@ -1,87 +0,0 @@
1
- import { bench, blackbox, dumpToFile } from "./lib/bench";
2
-
3
- const objSmall = { a: 1 };
4
- const objMedium = { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8 };
5
- const objLarge = Object.fromEntries(Array.from({ length: 100 }, (_, i) => [`key${i}`, i]));
6
-
7
- const arrSmall = [1, 2, 3];
8
- const arrMedium = Array.from({ length: 100 }, (_, i) => i);
9
- const arrLarge = Array.from({ length: 1000 }, (_, i) => i);
10
-
11
- const strSmall = 'abc';
12
- const strMedium = 'abcdefghijklmnopqrstuvwxyz'.repeat(10);
13
- const strLarge = 'abcdefghijklmnopqrstuvwxyz'.repeat(100);
14
-
15
- const ITERATIONS = 1_000_000;
16
-
17
- const objSmallStr = JSON.stringify(objSmall);
18
- const objMediumStr = JSON.stringify(objMedium);
19
- const objLargeStr = JSON.stringify(objLarge);
20
-
21
- const arrSmallStr = JSON.stringify(arrSmall);
22
- const arrMediumStr = JSON.stringify(arrMedium);
23
- const arrLargeStr = JSON.stringify(arrLarge);
24
-
25
- const strSmallStr = JSON.stringify(strSmall);
26
- const strMediumStr = JSON.stringify(strMedium);
27
- const strLargeStr = JSON.stringify(strLarge);
28
-
29
- // Objects
30
- bench('Serialize Small Object', () => blackbox(JSON.stringify(objSmall)), ITERATIONS, objSmallStr.length << 1);
31
- dumpToFile('small-obj', 'serialize');
32
-
33
- bench('Serialize Medium Object', () => blackbox(JSON.stringify(objMedium)), ITERATIONS, objMediumStr.length << 1);
34
- dumpToFile('medium-obj', 'serialize');
35
-
36
- bench('Serialize Large Object', () => blackbox(JSON.stringify(objLarge)), ITERATIONS, objLargeStr.length << 1);
37
- dumpToFile('large-obj', 'serialize');
38
-
39
- // Arrays
40
- bench('Serialize Small Array', () => blackbox(JSON.stringify(arrSmall)), ITERATIONS, arrSmallStr.length << 1);
41
- dumpToFile('small-arr', 'serialize');
42
-
43
- bench('Serialize Medium Array', () => blackbox(JSON.stringify(arrMedium)), ITERATIONS, arrMediumStr.length << 1);
44
- dumpToFile('medium-arr', 'serialize');
45
-
46
- bench('Serialize Large Array', () => blackbox(JSON.stringify(arrLarge)), ITERATIONS, arrLargeStr.length << 1);
47
- dumpToFile('large-arr', 'serialize');
48
-
49
- // Strings
50
- bench('Serialize Small String', () => blackbox(JSON.stringify(strSmall)), ITERATIONS, strSmallStr.length << 1);
51
- dumpToFile('small-str', 'serialize');
52
-
53
- bench('Serialize Medium String', () => blackbox(JSON.stringify(strMedium)), ITERATIONS, strMediumStr.length << 1);
54
- dumpToFile('medium-str', 'serialize');
55
-
56
- bench('Serialize Large String', () => blackbox(JSON.stringify(strLarge)), ITERATIONS, strLargeStr.length << 1);
57
- dumpToFile('large-str', 'serialize');
58
-
59
- // Objects
60
- bench('Deserialize Small Object', () => blackbox(JSON.parse(objSmallStr)), ITERATIONS, objSmallStr.length << 1);
61
- dumpToFile('small-obj', 'deserialize');
62
-
63
- bench('Deserialize Medium Object', () => blackbox(JSON.parse(objMediumStr)), ITERATIONS, objMediumStr.length << 1);
64
- dumpToFile('medium-obj', 'deserialize');
65
-
66
- bench('Deserialize Large Object', () => blackbox(JSON.parse(objLargeStr)), ITERATIONS, objLargeStr.length << 1);
67
- dumpToFile('large-obj', 'deserialize');
68
-
69
- // Arrays
70
- bench('Deserialize Small Array', () => blackbox(JSON.parse(arrSmallStr)), ITERATIONS, arrSmallStr.length << 1);
71
- dumpToFile('small-arr', 'deserialize');
72
-
73
- bench('Deserialize Medium Array', () => blackbox(JSON.parse(arrMediumStr)), ITERATIONS, arrMediumStr.length << 1);
74
- dumpToFile('medium-arr', 'deserialize');
75
-
76
- bench('Deserialize Large Array', () => blackbox(JSON.parse(arrLargeStr)), ITERATIONS, arrLargeStr.length << 1);
77
- dumpToFile('large-arr', 'deserialize');
78
-
79
- // Strings
80
- bench('Deserialize Small String', () => blackbox(JSON.parse(strSmallStr)), ITERATIONS, strSmallStr.length << 1);
81
- dumpToFile('small-str', 'deserialize');
82
-
83
- bench('Deserialize Medium String', () => blackbox(JSON.parse(strMediumStr)), ITERATIONS, strMediumStr.length << 1);
84
- dumpToFile('medium-str', 'deserialize');
85
-
86
- bench('Deserialize Large String', () => blackbox(JSON.parse(strLargeStr)), ITERATIONS, strLargeStr.length << 1);
87
- dumpToFile('large-str', 'deserialize');
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ES2020",
5
- "moduleResolution": "Node",
6
- "removeComments": true,
7
- "types": ["node"],
8
- "outDir": "../build",
9
- "sourceMap": false,
10
- "allowJs": true
11
- },
12
- "include": ["./*.ts", "./lib/*.ts", "lib/bench.js"]
13
- }
@@ -1,30 +0,0 @@
1
- import { bench, blackbox, dumpToFile } from "./lib/bench.js";
2
-
3
- class Vec3 {
4
- public x!: number;
5
- public y!: number;
6
- public z!: number;
7
- }
8
-
9
- const v1: Vec3 = { x: 1, y: 2, z: 3 };
10
- const v2 = '{"x":1,"y":2,"z":3}';
11
-
12
- bench(
13
- "Serialize Vec3",
14
- () => {
15
- blackbox(JSON.stringify(v1));
16
- },
17
- 16_000_00,
18
- v2.length << 1
19
- );
20
- dumpToFile("vec3", "serialize")
21
-
22
- bench(
23
- "Deserialize Vec3",
24
- () => {
25
- blackbox(JSON.parse(v2));
26
- },
27
- 16_000_00,
28
- v2.length << 1
29
- );
30
- dumpToFile("vec3", "deserialize")
package/bench.ts DELETED
@@ -1,18 +0,0 @@
1
- import { Bench } from "tinybench";
2
-
3
- const bench = new Bench({ time: 1000 });
4
-
5
- const v1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
6
- const v2 = '"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"';
7
-
8
- bench.add("Serialize Alphabet", () => {
9
- JSON.stringify("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
10
- });
11
-
12
- bench.add("Deserialize Alphabet", () => {
13
- JSON.parse('"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"');
14
- });
15
-
16
- bench.run().then(() => {
17
- console.table(bench.table());
18
- });
@@ -1,42 +0,0 @@
1
- export function bench(description: string, routine: () => void, ops: number = 1_000_000, bytesPerOp: number = 0): void {
2
- console.log(" - Benchmarking " + description);
3
-
4
- let warmup = Math.floor(ops / 10);
5
- while (warmup-- > 0) {
6
- routine();
7
- }
8
-
9
- const start = performance.now();
10
-
11
- let count = ops;
12
- while (count-- > 0) {
13
- routine();
14
- }
15
-
16
- const end = performance.now();
17
- const elapsed = Math.max(1, end - start);
18
-
19
- const opsPerSecond = (ops * 1000) / elapsed;
20
-
21
- let log = ` Completed benchmark in ${formatNumber(Math.round(elapsed))}ms at ${formatNumber(Math.round(opsPerSecond))} ops/s`;
22
-
23
- if (bytesPerOp > 0) {
24
- const totalBytes = bytesPerOp * ops;
25
- const mbPerSec = totalBytes / (elapsed / 1000) / (1000 * 1000);
26
- log += ` @ ${formatNumber(Math.round(mbPerSec))}MB/s`;
27
- }
28
-
29
- console.log(log + "\n");
30
- }
31
-
32
- function formatNumber(n: number): string {
33
- let str = n.toString();
34
- let len = str.length;
35
- let result = "";
36
- let commaOffset = len % 3;
37
- for (let i = 0; i < len; i++) {
38
- if (i > 0 && (i - commaOffset) % 3 === 0) result += ",";
39
- result += str.charAt(i);
40
- }
41
- return result;
42
- }
@@ -1,29 +0,0 @@
1
- const bytes = readbuffer("./build/" + arguments[0]);
2
- const module = new WebAssembly.Module(bytes);
3
- let memory = null;
4
- const { exports } = new WebAssembly.Instance(module, {
5
- env: {
6
- abort: (msg, file, line) => {
7
- console.log("abort: " + __liftString(msg) + " in " + __liftString(file) + ":" + __liftString(line));
8
- },
9
- "console.log": (ptr) => {
10
- console.log(__liftString(ptr));
11
- },
12
- "Date.now": () => Date.now(),
13
- "performance.now": () => performance.now(),
14
- },
15
- });
16
-
17
- memory = exports.memory;
18
-
19
- function __liftString(pointer) {
20
- if (!pointer) return null;
21
- const end = (pointer + new Uint32Array(memory.buffer)[(pointer - 4) >>> 2]) >>> 1,
22
- memoryU16 = new Uint16Array(memory.buffer);
23
- let start = pointer >>> 1,
24
- string = "";
25
- while (end - start > 1024) string += String.fromCharCode(...memoryU16.subarray(start, (start += 1024)));
26
- return string + String.fromCharCode(...memoryU16.subarray(start, end));
27
- }
28
-
29
- exports.start();
@@ -1,63 +0,0 @@
1
- #!/bin/bash
2
- RUNTIMES=${RUNTIMES:-"incremental"}
3
- ENGINES=${ENGINES:-"turbofan"}
4
- for file in ../assembly/__benches__/*.bench.ts; do
5
- filename=$(basename -- "$file")
6
- for runtime in $RUNTIMES; do
7
- output="./build/${filename%.ts}.${runtime}"
8
-
9
- npx asc "$file" --transform ../transform -o "${output}.1" -O3 --converge --noAssert --uncheckedBehavior always --runtime $runtime --enable bulk-memory --exportStart start || {
10
- echo "Build failed"
11
- exit 1
12
- }
13
-
14
- wasm-opt --enable-bulk-memory --enable-nontrapping-float-to-int --enable-tail-call -tnh -iit -ifwl -s 0 -O4 "${output}.1" -o "${output}.wasm"
15
- rm "${output}.1"
16
-
17
- npx asc "$file" --transform ../transform -o "${output}.1" -O3 --converge --noAssert --uncheckedBehavior always --runtime $runtime --enable bulk-memory --enable simd --exportStart start || {
18
- echo "Build failed"
19
- exit 1
20
- }
21
-
22
- wasm-opt --enable-bulk-memory --enable-simd --enable-nontrapping-float-to-int --enable-tail-call -tnh -iit -ifwl -s 0 -O4 "${output}.1" -o "${output}.simd.wasm"
23
- rm "${output}.1"
24
-
25
- for engine in $ENGINES; do
26
- echo -e "$filename (asc/$runtime/$engine)\n"
27
-
28
- arg="${filename%.ts}.${runtime}.wasm"
29
- argSimd="${filename%.ts}.${runtime}.simd.wasm"
30
- if [[ "$engine" == "ignition" ]]; then
31
- v8 --no-opt --module ./bench/runners/assemblyscript.js -- $arg
32
- echo -e "$filename (asc/$runtime/$engine/simd)\n"
33
- v8 --no-opt --module ./bench/runners/assemblyscript.js -- $argSimd
34
- fi
35
-
36
- if [[ "$engine" == "liftoff" ]]; then
37
- v8 --liftoff-only --no-opt --module ./bench/runners/assemblyscript.js -- $arg
38
- echo -e "$filename (asc/$runtime/$engine/simd)\n"
39
- v8 --liftoff-only --no-opt --module ./bench/runners/assemblyscript.js -- $argSimd
40
- fi
41
-
42
- if [[ "$engine" == "sparkplug" ]]; then
43
- v8 --sparkplug --always-sparkplug --no-opt --module ./bench/runners/assemblyscript.js -- $arg
44
- echo -e "$filename (asc/$runtime/$engine/simd)\n"
45
- v8 --sparkplug --always-sparkplug --no-opt --module ./bench/runners/assemblyscript.js -- $argSimd
46
- fi
47
-
48
- if [[ "$engine" == "turbofan" ]]; then
49
- v8 --no-liftoff --no-wasm-tier-up --module ./bench/runners/assemblyscript.js -- $arg
50
- echo -e "$filename (asc/$runtime/$engine/simd)\n"
51
- v8 --no-liftoff --no-wasm-tier-up --module ./bench/runners/assemblyscript.js -- $argSimd
52
- fi
53
-
54
- if [[ "$engine" == "llvm" ]]; then
55
- wasmer run --cranelift --enable-simd --enable-bulk-memory "${output}.wasi.wasm"
56
- echo -e "$filename (asc/$runtime/$engine/simd)\n"
57
- wasmer run --cranelift --enable-simd --enable-bulk-memory "${output}.wasi.simd.wasm"
58
- fi
59
- done
60
- done
61
- done
62
-
63
- echo "Finished benchmarks"
package/publish.sh DELETED
@@ -1,78 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- PACKAGE_NAME="json-as"
6
-
7
- echo -e "\n🔧 Building transform..."
8
- if ! npm run build:transform; then
9
- echo "❌ Build failed. Exiting."
10
- exit 1
11
- fi
12
-
13
- read -r -p "✨ Do you want to format the code before publishing? [Y/n] " FORMAT_RESP
14
- FORMAT_RESP=${FORMAT_RESP,,}
15
-
16
- if [[ "$FORMAT_RESP" =~ ^(yes|y| ) || -z "$FORMAT_RESP" ]]; then
17
- echo "🧹 Formatting code..."
18
- npm run format
19
- fi
20
-
21
- echo -e "\n🧪 Running tests"
22
- if ! npm run test; then
23
- echo "❌ Tests failed. Exiting."
24
- exit 1
25
- fi
26
-
27
- VERSION=$(node -p "require('./package.json').version")
28
- echo -e "\n📦 Current version: $VERSION"
29
-
30
- if [[ "$VERSION" == *"-preview."* ]]; then
31
- TAG="preview"
32
- elif [[ "$VERSION" == *"-"* ]]; then
33
- echo "⚠️ Unknown pre-release format. Not publishing."
34
- exit 1
35
- else
36
- TAG="latest"
37
- fi
38
-
39
- echo ""
40
-
41
- read -r -p "✅ All checks passed. Ready to publish $PACKAGE_NAME@$VERSION with tag '$TAG'? [Y/n] " PUBLISH_RESP
42
- PUBLISH_RESP=${PUBLISH_RESP,,}
43
-
44
- if [[ "$PUBLISH_RESP" =~ ^(n|no)$ ]]; then
45
- echo "❌ Publish canceled by user. Exiting."
46
- exit 0
47
- fi
48
-
49
- echo -e "\n🚀 Publishing $PACKAGE_NAME@$VERSION with tag '$TAG'...\n"
50
- npm publish --tag "$TAG"
51
- echo -e "\n✅ Published successfully."
52
-
53
- echo -e "\n🧹 Cleaning up old dist-tags..."
54
- npm dist-tag rm "$PACKAGE_NAME" alpha 2>/dev/null || true
55
- npm dist-tag rm "$PACKAGE_NAME" beta 2>/dev/null || true
56
-
57
- echo ""
58
- read -r -p "❓ Do you want to deprecate all alpha/beta versions? [Y/n] " DEPRECATE_RESP
59
- DEPRECATE_RESP=${DEPRECATE_RESP,,}
60
-
61
- if [[ "$DEPRECATE_RESP" =~ ^(n|no)$ ]]; then
62
- echo -e "\n❌ Skipping deprecation."
63
- else
64
- echo -e "\n📦 Deprecating alpha/beta versions...\n"
65
-
66
- VERSIONS=$(npm show "$PACKAGE_NAME" versions --json | jq -r '.[]')
67
-
68
- for VER in $VERSIONS; do
69
- if [[ "$VER" == *"alpha"* || "$VER" == *"beta"* ]]; then
70
- echo "⚠️ Deprecating $PACKAGE_NAME@$VER..."
71
- npm deprecate "$PACKAGE_NAME@$VER" "Deprecated: use latest or preview release."
72
- fi
73
- done
74
-
75
- echo -e "\n✅ Deprecation complete."
76
- fi
77
-
78
- echo -e "\n🎉 Done."
package/run-bench.as.sh DELETED
@@ -1,60 +0,0 @@
1
- #!/bin/bash
2
- RUNTIMES=${RUNTIMES:-"incremental"} # incremental minimal stub
3
- ENGINES=${ENGINES:-"turbofan"} # liftoff ignition sparkplug turbofan
4
- mkdir -p ./build/logs/as/simd
5
- mkdir -p ./build/logs/as/swar
6
- for file in ./assembly/__benches__/*.bench.ts; do
7
- filename=$(basename -- "$file")
8
- for runtime in $RUNTIMES; do
9
- output="./build/${filename%.ts}.${runtime}"
10
-
11
- npx asc "$file" --transform ./transform -o "${output}.1" -O3 --converge --noAssert --uncheckedBehavior always --runtime $runtime --enable bulk-memory --exportStart start || {
12
- echo "Build failed"
13
- exit 1
14
- }
15
-
16
- wasm-opt --enable-bulk-memory --enable-nontrapping-float-to-int --enable-tail-call -tnh -iit -ifwl -s 0 -O4 "${output}.1" -o "${output}.wasm"
17
- rm "${output}.1"
18
-
19
- npx asc "$file" --transform ./transform -o "${output}.1" -O3 --converge --noAssert --uncheckedBehavior always --runtime $runtime --enable bulk-memory --enable simd --exportStart start || {
20
- echo "Build failed"
21
- exit 1
22
- }
23
-
24
- wasm-opt --enable-bulk-memory --enable-simd --enable-nontrapping-float-to-int --enable-tail-call -tnh -iit -ifwl -s 0 -O4 "${output}.1" -o "${output}.simd.wasm"
25
- rm "${output}.1"
26
-
27
- for engine in $ENGINES; do
28
- echo -e "$filename (asc/$runtime/$engine/swar)\n"
29
-
30
- arg="${filename%.ts}.${runtime}.wasm"
31
-
32
- argSimd="${filename%.ts}.${runtime}.simd.wasm"
33
- if [[ "$engine" == "ignition" ]]; then
34
- v8 --no-opt --module ./bench/runners/assemblyscript.js -- $arg
35
- echo -e "$filename (asc/$runtime/$engine/simd)\n"
36
- v8 --no-opt --module ./bench/runners/assemblyscript.js -- $argSimd
37
- fi
38
-
39
- if [[ "$engine" == "liftoff" ]]; then
40
- v8 --liftoff-only --no-opt --module ./bench/runners/assemblyscript.js -- $arg
41
- echo -e "$filename (asc/$runtime/$engine/simd)\n"
42
- v8 --liftoff-only --no-opt --module ./bench/runners/assemblyscript.js -- $argSimd
43
- fi
44
-
45
- if [[ "$engine" == "sparkplug" ]]; then
46
- v8 --sparkplug --always-sparkplug --no-opt --module ./bench/runners/assemblyscript.js -- $arg
47
- echo -e "$filename (asc/$runtime/$engine/simd)\n"
48
- v8 --sparkplug --always-sparkplug --no-opt --module ./bench/runners/assemblyscript.js -- $argSimd
49
- fi
50
-
51
- if [[ "$engine" == "turbofan" ]]; then
52
- v8 --no-liftoff --no-wasm-tier-up --module ./bench/runners/assemblyscript.js -- $arg
53
- echo -e "$filename (asc/$runtime/$engine/simd)\n"
54
- v8 --no-liftoff --no-wasm-tier-up --module ./bench/runners/assemblyscript.js -- $argSimd
55
- fi
56
- done
57
- done
58
- done
59
-
60
- echo "Finished benchmarks"
package/run-bench.js.sh DELETED
@@ -1,36 +0,0 @@
1
- #!/bin/bash
2
- RUNTIMES=${RUNTIMES:-"turbofan"}
3
- npx tsc -p ./bench > /dev/null 2>&1
4
- cp ./bench/lib/bench.js ./build/lib/bench.js
5
- mkdir -p ./build/logs/js
6
- for file in ./bench/*.bench.ts; do
7
- filename=$(basename -- "$file")
8
- file_js="${filename%.ts}.js"
9
-
10
- output="./build/${filename%.ts}.wasm"
11
-
12
- for rt in $RUNTIMES; do
13
- runtime=$(echo $rt | cut -d'-' -f1)
14
- engine=$(echo $rt | cut -d'-' -f2-)
15
- echo -e "$filename (js/$runtime/$engine)\n"
16
-
17
- arg="${filename%.ts}.${runtime}.ts"
18
- if [[ "$engine" == "ignition" ]]; then
19
- v8 --no-opt --allow-natives-syntax --module ./build/$file_js -- $arg
20
- fi
21
-
22
- if [[ "$engine" == "liftoff" ]]; then
23
- v8 --liftoff-only --no-opt --allow-natives-syntax --module ./build/$file_js -- $arg
24
- fi
25
-
26
- if [[ "$engine" == "sparkplug" ]]; then
27
- v8 --sparkplug --always-sparkplug --allow-natives-syntax --no-opt --module ./build/$file_js -- $arg
28
- fi
29
-
30
- if [[ "$engine" == "turbofan" ]]; then
31
- v8 --no-liftoff --no-wasm-tier-up --allow-natives-syntax --module ./build/$file_js -- $arg
32
- fi
33
- done
34
- done
35
-
36
- echo "Finished benchmarks"
package/run-tests.sh DELETED
@@ -1,51 +0,0 @@
1
- #!/bin/bash
2
-
3
- mkdir -p ./build
4
-
5
- for file in ./assembly/__tests__/*.spec.ts; do
6
- filename=$(basename -- "$file")
7
- if [ -z "$1" ] || [ "$1" = "$filename" ]; then
8
- for mode in swar simd; do
9
- output="./build/${filename%.ts}.${mode}.wasm"
10
-
11
- start_time=$(date +%s%3N)
12
-
13
- if [ "$mode" = "simd" ]; then
14
- npx asc "$file" \
15
- --transform ./transform \
16
- -o "$output" \
17
- --runtime incremental \
18
- --enable simd \
19
- --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json \
20
- --debug \
21
- --disableWarning 226 || { echo "Tests failed ($mode)"; exit 1; }
22
- else
23
- npx asc "$file" \
24
- --transform ./transform \
25
- -o "$output" \
26
- --runtime incremental \
27
- --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json \
28
- --debug \
29
- --disableWarning 226 || { echo "Tests failed ($mode)"; exit 1; }
30
- fi
31
-
32
- end_time=$(date +%s%3N)
33
- build_time=$((end_time - start_time))
34
-
35
- if [ "$build_time" -ge 60000 ]; then
36
- formatted_time="$(bc <<< "scale=2; $build_time/60000")m"
37
- elif [ "$build_time" -ge 1000 ]; then
38
- formatted_time="$(bc <<< "scale=2; $build_time/1000")s"
39
- else
40
- formatted_time="${build_time}ms"
41
- fi
42
-
43
- echo " -> $filename ($mode build in $formatted_time)"
44
- wasmtime "$output" || { echo "Tests failed ($mode)"; exit 1; }
45
- done
46
- else
47
- echo " -> $filename (skipped)"
48
- fi
49
- done
50
-
51
- echo "All tests passed"
@@ -1,38 +0,0 @@
1
- import {
2
- getBenchResults,
3
- createBarChart,
4
- generateChart,
5
- type BenchKind
6
- } from "./lib/bench-utils";
7
-
8
- const PAYLOADS: Record<string, string> = {
9
- abc: "Alphabet (104b)",
10
- vec3: "3D Vector (38b)",
11
- small: "Small Payload (88b)",
12
- medium: "Medium Payload (2.1kb)",
13
- large: "Large Payload (10.5kb)"
14
- };
15
-
16
- const KIND: BenchKind = "serialize";
17
- const OUTPUT_FILE = "./data/chart01.svg";
18
-
19
- const allResults = getBenchResults(Object.keys(PAYLOADS));
20
-
21
- const chartData: Record<string, any> = {};
22
-
23
- for (const payload of Object.keys(PAYLOADS)) {
24
- chartData[payload] = allResults[payload][KIND];
25
- }
26
-
27
- const config = createBarChart(chartData, PAYLOADS, {
28
- title: "Serialization Throughput by Payload Size",
29
- yLabel: "Throughput (MB/s)",
30
- xLabel: "Payload",
31
- datasetLabels: [
32
- "Built-in JSON (JS)",
33
- "JSON-AS (SWAR)",
34
- "JSON-AS (SIMD)"
35
- ]
36
- });
37
-
38
- generateChart(config, OUTPUT_FILE);
@@ -1,38 +0,0 @@
1
- import {
2
- getBenchResults,
3
- createBarChart,
4
- generateChart,
5
- type BenchKind
6
- } from "./lib/bench-utils";
7
-
8
- const PAYLOADS: Record<string, string> = {
9
- abc: "Alphabet (104b)",
10
- vec3: "3D Vector (38b)",
11
- small: "Small Payload (88b)",
12
- medium: "Medium Payload (2.1kb)",
13
- large: "Large Payload (10.5kb)"
14
- };
15
-
16
- const KIND: BenchKind = "deserialize";
17
- const OUTPUT_FILE = "./data/chart02.svg";
18
-
19
- const allResults = getBenchResults(Object.keys(PAYLOADS));
20
-
21
- const chartData: Record<string, any> = {};
22
-
23
- for (const payload of Object.keys(PAYLOADS)) {
24
- chartData[payload] = allResults[payload][KIND];
25
- }
26
-
27
- const config = createBarChart(chartData, PAYLOADS, {
28
- title: "Deserialization Throughput by Payload Size",
29
- yLabel: "Throughput (MB/s)",
30
- xLabel: "Payload",
31
- datasetLabels: [
32
- "Built-in JSON (JS)",
33
- "JSON-AS (SWAR)",
34
- "JSON-AS (SIMD)"
35
- ]
36
- });
37
-
38
- generateChart(config, OUTPUT_FILE);