Skip to content

Commit

Permalink
Update: Fix the output log & reduce .wasm size.
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptonerdcn committed Jul 19, 2023
1 parent 4b5074f commit 0cde989
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion theme/js/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ window.runFunc = async (cairo_program) => {
});

worker.onmessage = function(e) {
resolve(e.data);
resolve(e.data.substring(e.data.indexOf('\n') + 1));
};

worker.onerror = function(error) {
Expand Down
8 changes: 5 additions & 3 deletions theme/pkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

<h1><code>WASM-Cairo</code></h1>

<strong>A suite of development tools and an environment for Cairo 1.10, all based on WebAssembly.</strong>
<strong>A suite of development tools and an environment for Cairo, all based on WebAssembly.</strong>

[Github](https://github.com/cryptonerdcn/wasm-cairo)

<sub>Built with 🦀🕸 by <a href="https://twitter.com/cryptonerdcn">cryptonerdcn from Starknet Astro</a></sub>
</div>
Expand All @@ -15,13 +17,13 @@
With Modules

```
wasm-pack build --release --target --out-dir ./pkg
wasm-pack build --release --target web --out-dir ./pkg/module --out-name wasm-cairo
```

No Modules

```
wasm-pack build --release --target no-modules --out-dir ./pkg
wasm-pack build --release --target no-modules --out-dir ./pkg/no_module --out-name wasm-cairo
```

You will find `wasm-cairo_bg.wasm` and `wasm-cairo.js` in `pkg` folder.
Expand Down
6 changes: 3 additions & 3 deletions theme/pkg/wasm-cairo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ declare interface InitOutput {
readonly runCairoProgram: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
readonly compileStarknetContract: (a: number, b: number, c: number, d: number) => void;
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
readonly __wbindgen_export_0: (a: number, b: number) => number;
readonly __wbindgen_export_1: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_export_2: (a: number, b: number, c: number) => void;
}

/**
Expand Down
16 changes: 8 additions & 8 deletions theme/pkg/wasm-cairo.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ let wasm_bindgen;
let deferred2_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
const len0 = WASM_VECTOR_LEN;
wasm.greet(retptr, ptr0, len0);
var r0 = getInt32Memory0()[retptr / 4 + 0];
Expand All @@ -107,7 +107,7 @@ let wasm_bindgen;
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
}
};

Expand Down Expand Up @@ -140,7 +140,7 @@ __exports.compileCairoProgram = function(cairo_program, replace_ids) {
let deferred3_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(cairo_program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const ptr0 = passStringToWasm0(cairo_program, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
const len0 = WASM_VECTOR_LEN;
wasm.compileCairoProgram(retptr, ptr0, len0, replace_ids);
var r0 = getInt32Memory0()[retptr / 4 + 0];
Expand All @@ -158,7 +158,7 @@ __exports.compileCairoProgram = function(cairo_program, replace_ids) {
return getStringFromWasm0(ptr2, len2);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
}
};

Expand All @@ -177,7 +177,7 @@ __exports.runCairoProgram = function(cairo_program, available_gas, print_full_me
let deferred3_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(cairo_program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const ptr0 = passStringToWasm0(cairo_program, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
const len0 = WASM_VECTOR_LEN;
wasm.runCairoProgram(retptr, ptr0, len0, !isLikeNone(available_gas), isLikeNone(available_gas) ? 0 : available_gas, print_full_memory, use_dbg_print_hint);
var r0 = getInt32Memory0()[retptr / 4 + 0];
Expand All @@ -195,7 +195,7 @@ __exports.runCairoProgram = function(cairo_program, available_gas, print_full_me
return getStringFromWasm0(ptr2, len2);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
}
};

Expand All @@ -209,7 +209,7 @@ __exports.compileStarknetContract = function(starknet_contract, replace_ids) {
let deferred3_1;
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(starknet_contract, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const ptr0 = passStringToWasm0(starknet_contract, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
const len0 = WASM_VECTOR_LEN;
wasm.compileStarknetContract(retptr, ptr0, len0, replace_ids);
var r0 = getInt32Memory0()[retptr / 4 + 0];
Expand All @@ -227,7 +227,7 @@ __exports.compileStarknetContract = function(starknet_contract, replace_ids) {
return getStringFromWasm0(ptr2, len2);
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
}
};

Expand Down
Binary file modified theme/pkg/wasm-cairo_bg.wasm
Binary file not shown.
6 changes: 3 additions & 3 deletions theme/pkg/wasm-cairo_bg.wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export function compileCairoProgram(a: number, b: number, c: number, d: number):
export function runCairoProgram(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void;
export function compileStarknetContract(a: number, b: number, c: number, d: number): void;
export function __wbindgen_add_to_stack_pointer(a: number): number;
export function __wbindgen_malloc(a: number, b: number): number;
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
export function __wbindgen_free(a: number, b: number, c: number): void;
export function __wbindgen_export_0(a: number, b: number): number;
export function __wbindgen_export_1(a: number, b: number, c: number, d: number): number;
export function __wbindgen_export_2(a: number, b: number, c: number): void;

0 comments on commit 0cde989

Please sign in to comment.