Skip to content

Commit 97353ef

Browse files
authored
Merge pull request #11 from torch2424/last-launch-fixes
Last Before Launch Fixes
2 parents 307c635 + 6482c69 commit 97353ef

File tree

8 files changed

+27
-35
lines changed

8 files changed

+27
-35
lines changed

README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,13 @@ You can install as-bind in your project by running the following:
4747

4848
## Quick Start
4949

50-
**1. In your Assemblyscript**
50+
**1. Compiling your Assemblyscript**
5151

52-
Export everything from the asbind assemblyscript library:
52+
To enable as-bind for your AssemblyScript Wasm modules, add the as-bind entrypoint when compiling your module:
5353

54-
```typescript
55-
// This should be in your entry point file for your Assemblyscript project
56-
57-
// '../node_modules/as-bind/*' should be the relative path to this directory in your project
58-
export * from "../node_modules/as-bind/lib/assembly/asbind.ts";
59-
```
54+
`asc ./node_modules/as-bind/lib/assembly/as-bind.ts your-entryfile.ts [...other cli options...]`
6055

61-
After this, let's export an example function we can try:
56+
For **optional testing purposes** , let's export an example function we can try in `your-entryfile.ts`:
6257

6358
```typescript
6459
export function myExportedFunctionThatTakesAString(value: string): string {
@@ -78,7 +73,7 @@ const wasm = fetch("./path-to-my-wasm.wasm");
7873
const asyncTask = async () => {
7974
const asBindInstance = await AsBind.instantiate(wasm);
8075

81-
// You can now use your wasm / asbind instance!
76+
// You can now use your wasm / as-bind instance!
8277
const response = asBindInstance.exports.myExportedFunctionThatTakesAString(
8378
"Hello World!"
8479
);
@@ -98,7 +93,7 @@ const wasm = fs.readFileSync("./path-to-my-wasm.wasm");
9893
const asyncTask = async () => {
9994
const asBindInstance = await AsBind.instantiate(wasm);
10095

101-
// You can now use your wasm / asbind instance!
96+
// You can now use your wasm / as-bind instance!
10297
const response = asBindInstance.exports.myExportedFunctionThatTakesAString(
10398
"Hello World!"
10499
);

examples/markdown-parser/assembly/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// Wasm module to do a basic markdown to HTML
22

3-
// Export asbind
4-
export * from "../../../dist/asbind";
5-
63
import { log } from "./util";
74

85
import { Token } from "./tokenizer/token";

examples/markdown-parser/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { h, render, Component } from "preact";
2-
import asbind from "../../dist/asbind.esm";
2+
import asbind from "../../dist/as-bind.esm";
33

44
// Import our TypeScript equivalent
5-
import { convertMarkdownToHTML } from "../../dist/examples/markdown-parser/assembly/index";
5+
import { convertMarkdownToHTML } from "../../dist/ts/index";
66
import "./index.css";
77

8-
let testMarkdown = `# __asbind__ ~~convert~~ **markdown** to html
8+
let testMarkdown = `# __as-bind__ ~~convert~~ **markdown** to html
99
1010
* Item 1
1111
* Item 2
@@ -15,7 +15,7 @@ let testMarkdown = `# __asbind__ ~~convert~~ **markdown** to html
1515
1616
## And now we are back!
1717
18-
Here is a [link to the source code](https://github.com/torch2424/asbind)
18+
Here is a [link to the source code](https://github.com/torch2424/as-bind)
1919
2020
And an image of the author!
2121
@@ -35,7 +35,7 @@ let testMarkdown = `# __asbind__ ~~convert~~ **markdown** to html
3535
3636
> WebAssembly is cool - Torch2424, 2019
3737
38-
\`npm install asbind\`
38+
\`npm install as-bind\`
3939
4040
\`\`\`
4141
const someCode = "hello world!";
@@ -91,7 +91,7 @@ ${markdown}
9191
9292
------
9393
94-
asbind response:
94+
as-bind response:
9595
9696
${html}
9797
`);
File renamed without changes.

lib/supported-ref-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const SUPPORTED_REF_TYPES = {
1010
return wasmExports.__retain(wasmExports.__allocString(arg));
1111
},
1212
getValueFromRef: (wasmExports, responseRef) => {
13-
return wasmExports.__getString(responseRef).slice(0);
13+
return wasmExports.__getString(responseRef);
1414
}
1515
},
1616
INT8ARRAY: {

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "as-bind",
33
"description": "Isomorphic library to handle passing high-level data structures between AssemblyScript and JavaScript 🤝🚀",
44
"version": "0.1.1",
5-
"main": "dist/asbind.cjs.js",
6-
"module": "dist/asbind.esm.js",
7-
"browser": "dist/asbind.iife.js",
5+
"main": "dist/as-bind.cjs.js",
6+
"module": "dist/as-bind.esm.js",
7+
"browser": "dist/as-bind.iife.js",
88
"scripts": {
99
"build": "run-s lib:wasm:build lib:js:build",
1010
"dev": "run-p lib:watch lib:test:watch",
@@ -15,19 +15,20 @@
1515
"lib:watch": "chokidar --initial \"lib/**/*\" -c \"run-s lib:wasm:build lib:js:build:dev test\"",
1616
"lib:test:watch": "chokidar \"test/**/*.js\" \"test/**/*.ts\" -c \"run-s lib:test:build test\"",
1717
"lib:wasm:build": "run-s lib:wasm:build:debug lib:wasm:build:optimized lib:wasm:build:cp",
18-
"lib:wasm:build:debug": "asc lib/assembly/asbind.ts -b dist/asbind.debug.wasm -t dist/asbind.debug.wat --sourceMap --validate --debug --runtime full",
19-
"lib:wasm:build:optimized": "asc lib/assembly/asbind.ts -b dist/asbind.wasm --sourceMap dist/asbind.wasm.map -t dist/asbind.wat --validate --runtime full -O3",
18+
"lib:wasm:build:debug": "asc lib/assembly/as-bind.ts -b dist/as-bind.debug.wasm -t dist/as-bind.debug.wat --sourceMap --validate --debug --runtime full",
19+
"lib:wasm:build:optimized": "asc lib/assembly/as-bind.ts -b dist/as-bind.wasm --sourceMap dist/as-bind.wasm.map -t dist/as-bind.wat --validate --runtime full -O3",
2020
"lib:wasm:build:cp": "cpy 'lib/assembly/**/*' dist",
2121
"lib:js:build": "rollup -c --environment LIB,PROD",
2222
"lib:js:build:dev": "rollup -c --environment LIB,DEV",
23-
"lib:test:build": "asc test/assembly/test.ts -b test/assembly/test.wasm --validate --runtime full --debug",
23+
"lib:test:build": "asc lib/assembly/as-bind.ts test/assembly/test.ts -b test/assembly/test.wasm --validate --runtime full --debug",
2424
"lib:deploy": "np",
2525
"md:build": "run-s md:wasm:build md:ts:build md:js:build",
26-
"md:dev": "run-p lib:watch md:wasm:watch md:js:watch serve",
26+
"md:dev": "run-p lib:watch md:wasm:watch md:ts:watch md:js:watch serve",
2727
"md:wasm:watch": "chokidar --initial \"examples/markdown-parser/assembly/**/*\" -c \"run-s md:wasm:build\"",
28+
"md:ts:watch": "chokidar --initial \"examples/markdown-parser/assembly/**/*\" -c \"run-s md:ts:build\"",
2829
"md:js:watch": "chokidar --initial \"examples/markdown-parser/**/*\" -c \"rollup -c --environment MD,DEV\"",
29-
"md:wasm:build": "asc examples/markdown-parser/assembly/index.ts -b dist/examples/markdown-parser/index.wasm -t dist/examples/markdown-parser/index.wat --sourceMap dist/examples/markdown-parser/index.wasm.map --validate --runtime full",
30-
"md:ts:build": "tsc --project examples/markdown-parser/assembly/ --outDir dist/ --module \"es2015\"",
30+
"md:wasm:build": "asc lib/assembly/as-bind.ts examples/markdown-parser/assembly/index.ts -b dist/examples/markdown-parser/index.wasm -t dist/examples/markdown-parser/index.wat --sourceMap dist/examples/markdown-parser/index.wasm.map --validate --runtime full",
31+
"md:ts:build": "tsc --project examples/markdown-parser/assembly/ --outDir dist/ts/ --module \"es2015\"",
3132
"md:js:build": "rollup -c --environment MD,PROD",
3233
"md:deploy": "run-s build md:build md:deploy:gh-pages",
3334
"md:deploy:gh-pages": "gh-pages -d dist/examples/markdown-parser"
@@ -75,7 +76,7 @@
7576
},
7677
"repository": {
7778
"type": "git",
78-
"url": "git+https://github.com/torch2424/asbind.git"
79+
"url": "git+https://github.com/torch2424/as-bind.git"
7980
},
8081
"keywords": [
8182
"assemblyscript",
@@ -95,8 +96,8 @@
9596
"author": "Aaron Turner",
9697
"license": "MIT",
9798
"bugs": {
98-
"url": "https://github.com/torch2424/asbind/issues"
99+
"url": "https://github.com/torch2424/as-bind/issues"
99100
},
100-
"homepage": "https://github.com/torch2424/asbind#readme",
101+
"homepage": "https://github.com/torch2424/as-bind#readme",
101102
"dependencies": {}
102103
}

test/assembly/test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// The entry file of your WebAssembly module.
2-
export * from "../../lib/assembly/asbind";
32

43
export function helloWorld(world: string): string {
54
return "Hello " + world + "!";

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fs = require("fs");
22
const assert = require("assert");
3-
const { AsBind } = require("../dist/asbind.cjs");
3+
const { AsBind } = require("../dist/as-bind.cjs");
44

55
const wasmBytes = new Uint8Array(fs.readFileSync("./test/assembly/test.wasm"));
66

0 commit comments

Comments
 (0)