58 |
EPILEPSY WARNING
59 |
A very small percentage of individuals may experience epileptic seizures when exposed to certain light patterns or flashing lights. Exposure to certain patterns or backgrounds on a computer screen may induce an epileptic seizure in these individuals. Certain conditions may induce previously undetected epileptic symptoms even in persons who have no history of prior seizures or epilepsy.
60 |
If you experience any of the following symptoms while viewing - dizziness, altered vision, eye or muscle twitches, loss of awareness, disorientation, any involuntary movement, or convulsions - IMMEDIATELY discontinue use and consult your physician.
61 |
(click to continue)
62 |
63 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/interference/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@assemblyscript/interference-example",
3 | "version": "1.0.0",
4 | "license": "Apache-2.0",
5 | "private": true,
6 | "scripts": {
7 | "asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --runtime stub --debug",
8 | "asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat --sourceMap --runtime stub --optimize",
9 | "asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
10 | "start": "npx serve"
11 | },
12 | "devDependencies": {
13 | "assemblyscript": "latest"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/interference/preview.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AssemblyScript/examples/8b23ca8fa2f27cf9a39e5dfe4989d9eeba87d48f/interference/preview.jpg
--------------------------------------------------------------------------------
/libm/README.md:
--------------------------------------------------------------------------------
1 | libm
2 | ====
3 |
4 | An [AssemblyScript](http://assemblyscript.org) example. Exposes AssemblyScript's math routines for double and single precision as a library.
5 |
6 | ```ts
7 | const libm = require("path/to/libm");
8 | const libmf = libm.libmf;
9 | ...
10 | ```
11 |
12 | Both `libm` and `libmf` have the same general interface as JavaScript's `Math`, with `libmf` doing single precision math.
13 |
14 | Instructions
15 | ------------
16 |
17 | First, install the development dependencies:
18 |
19 | ```
20 | $> npm install
21 | ```
22 |
23 | Now, to build [assembly/libm.ts](./assembly/libm.ts) to `build/libm.wasm` respectively [assembly/libmf.ts](./assembly/libmf.ts) to `build/libmf.wasm`, run:
24 |
25 | ```
26 | $> npm run asbuild
27 | ```
28 |
29 | Afterwards, run
30 |
31 | ```
32 | $> npm test
33 | ```
34 |
35 | to verify that it works.
36 |
--------------------------------------------------------------------------------
/libm/assembly/libm.ts:
--------------------------------------------------------------------------------
1 | export const E = Math.E;
2 | export const LN10 = Math.LN10;
3 | export const LN2 = Math.LN2;
4 | export const LOG10E = Math.LOG10E;
5 | export const LOG2E = Math.LOG2E;
6 | export const PI = Math.PI;
7 | export const SQRT1_2 = Math.SQRT1_2;
8 | export const SQRT2 = Math.SQRT2;
9 |
10 | export function abs(x: f64): f64 {
11 | return Math.abs(x);
12 | }
13 |
14 | export function acos(x: f64): f64 {
15 | return Math.acos(x);
16 | }
17 |
18 | export function acosh(x: f64): f64 {
19 | return Math.acosh(x);
20 | }
21 |
22 | export function asin(x: f64): f64 {
23 | return Math.asin(x);
24 | }
25 |
26 | export function asinh(x: f64): f64 {
27 | return Math.asinh(x);
28 | }
29 |
30 | export function atan(x: f64): f64 {
31 | return Math.atan(x);
32 | }
33 |
34 | export function atanh(x: f64): f64 {
35 | return Math.atanh(x);
36 | }
37 |
38 | export function atan2(y: f64, x: f64): f64 {
39 | return Math.atan2(y, x);
40 | }
41 |
42 | export function cbrt(x: f64): f64 {
43 | return Math.cbrt(x);
44 | }
45 |
46 | export function ceil(x: f64): f64 {
47 | return Math.ceil(x);
48 | }
49 |
50 | export function clz32(x: f64): f64 {
51 | return Math.clz32(x);
52 | }
53 |
54 | export function cos(x: f64): f64 {
55 | return Math.cos(x);
56 | }
57 |
58 | export function cosh(x: f64): f64 {
59 | return Math.cosh(x);
60 | }
61 |
62 | export function exp(x: f64): f64 {
63 | return Math.exp(x);
64 | }
65 |
66 | export function expm1(x: f64): f64 {
67 | return Math.expm1(x);
68 | }
69 |
70 | export function floor(x: f64): f64 {
71 | return Math.floor(x);
72 | }
73 |
74 | export function fround(x: f64): f64 {
75 | return Math.fround(x);
76 | }
77 |
78 | export function hypot(a: f64, b: f64): f64 {
79 | return Math.hypot(a, b);
80 | }
81 |
82 | export function imul(a: f64, b: f64): f64 {
83 | return Math.imul(a, b);
84 | }
85 |
86 | export function log(x: f64): f64 {
87 | return Math.log(x);
88 | }
89 |
90 | export function log10(x: f64): f64 {
91 | return Math.log10(x);
92 | }
93 |
94 | export function log1p(x: f64): f64 {
95 | return Math.log1p(x);
96 | }
97 |
98 | export function log2(x: f64): f64 {
99 | return Math.log2(x);
100 | }
101 |
102 | export function max(a: f64, b: f64): f64 {
103 | return Math.max(a, b);
104 | }
105 |
106 | export function min(a: f64, b: f64): f64 {
107 | return Math.min(a, b);
108 | }
109 |
110 | export function pow(x: f64, y: f64): f64 {
111 | return Math.pow(x, y);
112 | }
113 |
114 | export function round(x: f64): f64 {
115 | return Math.round(x);
116 | }
117 |
118 | export function sign(x: f64): f64 {
119 | return Math.sign(x);
120 | }
121 |
122 | export function sin(x: f64): f64 {
123 | return Math.sin(x);
124 | }
125 |
126 | export function sinh(x: f64): f64 {
127 | return Math.sinh(x);
128 | }
129 |
130 | export function sqrt(x: f64): f64 {
131 | return Math.sqrt(x);
132 | }
133 |
134 | export function tan(x: f64): f64 {
135 | return Math.tan(x);
136 | }
137 |
138 | export function tanh(x: f64): f64 {
139 | return Math.tanh(x);
140 | }
141 |
142 | export function trunc(x: f64): f64 {
143 | return Math.trunc(x);
144 | }
145 |
--------------------------------------------------------------------------------
/libm/assembly/libmf.ts:
--------------------------------------------------------------------------------
1 | export const E = Mathf.E;
2 | export const LN10 = Mathf.LN10;
3 | export const LN2 = Mathf.LN2;
4 | export const LOG10E = Mathf.LOG10E;
5 | export const LOG2E = Mathf.LOG2E;
6 | export const PI = Mathf.PI;
7 | export const SQRT1_2 = Mathf.SQRT1_2;
8 | export const SQRT2 = Mathf.SQRT2;
9 |
10 | export function abs(x: f32): f32 {
11 | return Mathf.abs(x);
12 | }
13 |
14 | export function acos(x: f32): f32 {
15 | return Mathf.acos(x);
16 | }
17 |
18 | export function acosh(x: f32): f32 {
19 | return Mathf.acosh(x);
20 | }
21 |
22 | export function asin(x: f32): f32 {
23 | return Mathf.asin(x);
24 | }
25 |
26 | export function asinh(x: f32): f32 {
27 | return Mathf.asinh(x);
28 | }
29 |
30 | export function atan(x: f32): f32 {
31 | return Mathf.atan(x);
32 | }
33 |
34 | export function atanh(x: f32): f32 {
35 | return Mathf.atanh(x);
36 | }
37 |
38 | export function atan2(y: f32, x: f32): f32 {
39 | return Mathf.atan2(y, x);
40 | }
41 |
42 | export function cbrt(x: f32): f32 {
43 | return Mathf.cbrt(x);
44 | }
45 |
46 | export function ceil(x: f32): f32 {
47 | return Mathf.ceil(x);
48 | }
49 |
50 | export function clz32(x: f32): f32 {
51 | return Mathf.clz32(x);
52 | }
53 |
54 | export function cos(x: f32): f32 {
55 | return Mathf.cos(x);
56 | }
57 |
58 | export function cosh(x: f32): f32 {
59 | return Mathf.cosh(x);
60 | }
61 |
62 | export function exp(x: f32): f32 {
63 | return Mathf.exp(x);
64 | }
65 |
66 | export function expm1(x: f32): f32 {
67 | return Mathf.expm1(x);
68 | }
69 |
70 | export function floor(x: f32): f32 {
71 | return Mathf.floor(x);
72 | }
73 |
74 | export function fround(x: f32): f32 {
75 | return Mathf.fround(x);
76 | }
77 |
78 | export function hypot(a: f32, b: f32): f32 {
79 | return Mathf.hypot(a, b);
80 | }
81 |
82 | export function imul(a: f32, b: f32): f32 {
83 | return Mathf.imul(a, b);
84 | }
85 |
86 | export function log(x: f32): f32 {
87 | return Mathf.log(x);
88 | }
89 |
90 | export function log10(x: f32): f32 {
91 | return Mathf.log10(x);
92 | }
93 |
94 | export function log1p(x: f32): f32 {
95 | return Mathf.log1p(x);
96 | }
97 |
98 | export function log2(x: f32): f32 {
99 | return Mathf.log2(x);
100 | }
101 |
102 | export function max(a: f32, b: f32): f32 {
103 | return Mathf.max(a, b);
104 | }
105 |
106 | export function min(a: f32, b: f32): f32 {
107 | return Mathf.min(a, b);
108 | }
109 |
110 | export function pow(x: f32, y: f32): f32 {
111 | return Mathf.pow(x, y);
112 | }
113 |
114 | export function round(x: f32): f32 {
115 | return Mathf.round(x);
116 | }
117 |
118 | export function sign(x: f32): f32 {
119 | return Mathf.sign(x);
120 | }
121 |
122 | export function sin(x: f32): f32 {
123 | return Mathf.sin(x);
124 | }
125 |
126 | export function sinh(x: f32): f32 {
127 | return Mathf.sinh(x);
128 | }
129 |
130 | export function sqrt(x: f32): f32 {
131 | return Mathf.sqrt(x);
132 | }
133 |
134 | export function tan(x: f32): f32 {
135 | return Mathf.tan(x);
136 | }
137 |
138 | export function tanh(x: f32): f32 {
139 | return Mathf.tanh(x);
140 | }
141 |
142 | export function trunc(x: f32): f32 {
143 | return Mathf.trunc(x);
144 | }
145 |
--------------------------------------------------------------------------------
/libm/assembly/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../node_modules/assemblyscript/std/assembly.json",
3 | "include": [
4 | "./**/*.ts"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/libm/build/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/libm/index.d.ts:
--------------------------------------------------------------------------------
1 | declare const libm: typeof Math & { libm: typeof Math, libmf: typeof Math };
2 | export = libm;
3 |
--------------------------------------------------------------------------------
/libm/index.js:
--------------------------------------------------------------------------------
1 | const fs = require("fs");
2 | const libm = new WebAssembly.Instance(new WebAssembly.Module(fs.readFileSync("./build/libm.wasm")), { Math }).exports;
3 | const libmf = new WebAssembly.Instance(new WebAssembly.Module(fs.readFileSync("./build/libmf.wasm")), {}).exports;
4 | module.exports = Object.create(libm, {
5 | libm: { value: libm, enumerable: true },
6 | libmf: { value: libmf, enumerable: true }
7 | });
8 |
--------------------------------------------------------------------------------
/libm/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@assemblyscript/libm-example",
3 | "version": "1.0.0",
4 | "license": "Apache-2.0",
5 | "private": true,
6 | "main": "index.js",
7 | "types": "index.d.ts",
8 | "scripts": {
9 | "asbuild": "npm run asbuild:libm && npm run asbuild:libmf",
10 | "asbuild:libm": "asc assembly/libm.ts -O3 -o build/libm.wasm -t build/libm.wat --runtime stub",
11 | "asbuild:libmf": "asc assembly/libmf.ts -O3 -o build/libmf.wasm -t build/libmf.wat --runtime stub",
12 | "test": "node tests"
13 | },
14 | "files": [
15 | "package.json",
16 | "index.d.ts",
17 | "index.js",
18 | "build/*.wasm",
19 | "README.md"
20 | ],
21 | "devDependencies": {
22 | "assemblyscript": "latest"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/libm/tests/index.js:
--------------------------------------------------------------------------------
1 | const { libm, libmf } = require("..");
2 |
3 | console.log("=== libm ===");
4 | console.log(libm);
5 |
6 | console.log("=== libmf ===");
7 | console.log(libmf);
8 |
--------------------------------------------------------------------------------
/loader/README.md:
--------------------------------------------------------------------------------
1 | Loader Example
2 | ==============
3 |
4 | An [AssemblyScript](http://assemblyscript.org) example. Utilizes the [loader](https://docs.assemblyscript.org/basics/loader) to perform various common tasks on the WebAssembly/JavaScript boundary, like passing along strings and arrays.
5 |
6 | Instructions
7 | ------------
8 |
9 | Install the dependencies, build the WebAssembly module and verify that everything works:
10 |
11 | ```
12 | $> npm install
13 | $> npm run asbuild
14 | $> npm test
15 | ```
16 |
17 | The example consists of several files showing the different perspectives, in recommended reading order:
18 |
19 | * [assembly/index.ts](./assembly/index.ts)