Skip to content

Commit e455cd7

Browse files
committed
* publish, add tests, fix bugs
1 parent dbc3e55 commit e455cd7

13 files changed

Lines changed: 444 additions & 48 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,11 @@ jobs:
2424
cache: npm
2525

2626
- run: npm ci
27-
- run: npm run build
28-
- run: npm test
27+
- run: npm run build:release
28+
29+
- name: Upload build artifacts
30+
if: always() && matrix.node-version == 22
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: build-reports
34+
path: build/

.github/workflows/publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish to npm
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
id-token: write
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Use Node.js 22
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 22
21+
cache: npm
22+
registry-url: https://registry.npmjs.org
23+
24+
- run: npm ci
25+
26+
- name: Compute version
27+
id: version
28+
run: |
29+
BASE=$(node -p "const p = require('./package.json'); p.version.split('.').slice(0,2).join('.')")
30+
VERSION="${BASE}.${{ github.run_number }}"
31+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
32+
echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT"
33+
echo "Publishing version: ${VERSION}"
34+
35+
- name: Set version
36+
run: npm version ${{ steps.version.outputs.version }} --no-git-tag-version
37+
38+
- run: npm run build:release
39+
40+
- name: Publish
41+
run: npm publish --provenance --access public
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
45+
- name: Create tag and release
46+
env:
47+
GH_TOKEN: ${{ github.token }}
48+
run: |
49+
git tag ${{ steps.version.outputs.tag }}
50+
git push origin ${{ steps.version.outputs.tag }}
51+
gh release create ${{ steps.version.outputs.tag }} \
52+
--title "${{ steps.version.outputs.tag }}" \
53+
--generate-notes

docs/examples.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,7 @@ Add two arrays of four floats using 128-bit SIMD instructions:
374374
```typescript
375375
import { ModuleBuilder, ValueType } from 'webasmjs';
376376

377-
// SIMD requires disabling the operand stack verifier (v128 not yet supported)
378-
const mod = new ModuleBuilder('simdAdd', { disableVerification: true });
377+
const mod = new ModuleBuilder('simdAdd');
379378
mod.defineMemory(1);
380379

381380
// vec4_add: adds four f32 values starting at [srcA] and [srcB], stores result at [dst]
@@ -437,8 +436,7 @@ Compute a dot product of two 4-element float vectors using SIMD multiply and lan
437436
```typescript
438437
import { ModuleBuilder, ValueType } from 'webasmjs';
439438

440-
// SIMD requires disabling the operand stack verifier (v128 not yet supported)
441-
const mod = new ModuleBuilder('simdDot', { disableVerification: true });
439+
const mod = new ModuleBuilder('simdDot');
442440
mod.defineMemory(1);
443441

444442
// dot4: dot product of two f32x4 vectors in memory

generator/opcodes.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ value,name,mnemonic,friendlyName,immediate,controlflow,pop,push,prefix,feature
1313
16,call,call,call,Function,,"[""Arguments""]","[""Returns""]",,
1414
17,call_indirect,call_indirect,call_indirect,IndirectFunction,,"[""Arguments"",""Int32""]","[""Returns""]",,
1515
26,drop,drop,drop,,,"[""Any""]",,,
16-
27,select,select,select,,,"[""Int32"",""Any"",""Any""]","[""Any""]",,
16+
27,select,select,select,,,"[""Any"",""Any"",""Int32""]","[""Any""]",,
1717
32,get_local,local.get,get_local,Local,,,"[""Any""]",,
1818
33,set_local,local.set,set_local,Local,,"[""Any""]",,,
1919
34,tee_local,local.tee,tee_local,Local,,"[""Any""]","[""Any""]",,

package-lock.json

Lines changed: 49 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
{
22
"name": "webasmjs",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "TypeScript WebAssembly bytecode emitter and module builder",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
7+
"files": [
8+
"lib"
9+
],
710
"scripts": {
8-
"build": "tsc && ts-node playground/build.ts",
11+
"build": "tsc --build",
12+
"clean": "tsc --build --clean",
13+
"clean:build": "rm -rf build",
914
"test": "jest",
10-
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand",
11-
"test:cover": "jest --coverage",
12-
"generate": "ts-node generator/index.ts",
13-
"build:playground": "ts-node playground/build.ts",
14-
"playground": "ts-node playground/build.ts && open playground/index.html",
15+
"test:ci": "jest --ci --coverage --reporters=default --reporters=jest-junit",
16+
"test:coverage": "jest --coverage",
17+
"build:release": "npm run clean:build && npm run build && npm run test:ci",
18+
"examples": "npx tsx examples/showcase/run-examples.ts",
19+
"examples:cdk": "npx tsx examples/aws-cdk-comparison/run-examples.ts",
20+
"examples:all": "npm run examples && npm run examples:cdk",
21+
"playground": "npm run dev --prefix playground",
1522
"prepare": "husky"
1623
},
24+
"jest-junit": {
25+
"outputDirectory": "build/test-results",
26+
"outputName": "junit.xml"
27+
},
1728
"bugs": {
1829
"url": "https://github.com/DevNamedZed/webasmjs/issues",
1930
"email": "devnamedzed@gmail.com"
@@ -41,6 +52,7 @@
4152
"esbuild": "^0.27.3",
4253
"husky": "^9.1.7",
4354
"jest": "^29.7.0",
55+
"jest-junit": "^16.0.0",
4456
"ts-jest": "^29.1.2",
4557
"ts-node": "^10.9.2",
4658
"typescript": "^5.4.0"

playground/playground.bundle.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playground/playground.bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playground/playground.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ log('Final: ' + getCounter());`,
12031203
label: 'SIMD Vector Add',
12041204
group: 'SIMD',
12051205
code: `// SIMD: add two f32x4 vectors in memory
1206-
const mod = new webasmjs.ModuleBuilder('simdAdd', { disableVerification: true });
1206+
const mod = new webasmjs.ModuleBuilder('simdAdd');
12071207
mod.defineMemory(1);
12081208
12091209
// vec4_add(srcA, srcB, dst) — adds two 4-float vectors
@@ -1255,7 +1255,7 @@ for (let i = 0; i < 4; i++) {
12551255
label: 'SIMD Dot Product',
12561256
group: 'SIMD',
12571257
code: `// SIMD dot product: multiply element-wise then sum lanes
1258-
const mod = new webasmjs.ModuleBuilder('simdDot', { disableVerification: true });
1258+
const mod = new webasmjs.ModuleBuilder('simdDot');
12591259
mod.defineMemory(1);
12601260
12611261
mod.defineFunction('dot4', [webasmjs.ValueType.Float32],
@@ -1311,7 +1311,7 @@ log('Expected: ' + (1*5 + 2*6 + 3*7 + 4*8));`,
13111311
label: 'SIMD Splat & Scale',
13121312
group: 'SIMD',
13131313
code: `// SIMD splat: broadcast a scalar to all lanes, then multiply
1314-
const mod = new webasmjs.ModuleBuilder('simdScale', { disableVerification: true });
1314+
const mod = new webasmjs.ModuleBuilder('simdScale');
13151315
mod.defineMemory(1);
13161316
13171317
// scale_vec4(src, dst, scalar) — multiply a vector by a scalar

src/OpCodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const OpCodes = {
9595
value: 27,
9696
mnemonic: "select",
9797
stackBehavior: "PopPush",
98-
popOperands: ["Int32","Any","Any"] as const,
98+
popOperands: ["Any","Any","Int32"] as const,
9999
pushOperands: ["Any"] as const,
100100
},
101101
"get_local": {

0 commit comments

Comments
 (0)