Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .eslintrc.json

This file was deleted.

9 changes: 5 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: mymindstorm/setup-emsdk@v11
- name: Verify
- name: Verify Emscripten
run: emcc --version
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: "latest"
node-version: "lts/*"
registry-url: "https://registry.npmjs.org"
- run: npm ci --legacy-peer-deps
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm publish
env:
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: Run unit tests
name: CI
on: [ pull_request, push ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "lts/*"

- uses: mymindstorm/setup-emsdk@v11
- name: Verify Emscripten
run: emcc --version

- run: npm ci --legacy-peer-deps
- run: npm run test
- run: npm ci
- run: npm run lint
- run: npm run test
- run: npm run build
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ bower_components
build/Release

# Dependency directories
node_modules/
jspm_packages/
**/node_modules/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
Expand Down Expand Up @@ -131,4 +131,6 @@ dist

# IDE
.vscode/
playground/
playground/
.venv/
.claude/
28 changes: 16 additions & 12 deletions compile_wasm.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#!/bin/bash
emcc --bind wasm/sort.cpp -Oz -o src/wasm/sort.js \
-s EXPORT_ES6=1 \
-s MODULARIZE=1 \
-s EXPORT_NAME=loadWasm \
emcc wasm/sort.cpp -Oz -o src/wasm/sort.js \
-s EXPORTED_FUNCTIONS="[_sort, _malloc, _free]" \
-s SINGLE_FILE=1 \
-s EXPORTED_RUNTIME_METHODS="[HEAPF32, HEAPU32, HEAPU8]" \
-s ALLOW_MEMORY_GROWTH=1 \
-s ENVIRONMENT=worker

emcc --bind wasm/data.cpp -Oz -o src/wasm/data.js \
-s EXPORT_ES6=1 \
-s MODULARIZE=1 \
-s EXPORT_NAME=loadWasm \
-s EXPORTED_FUNCTIONS="[_pack, _malloc, _free]" \
-s EXPORT_ES6=1 \
-s EXPORT_NAME=createSortModule \
-s ENVIRONMENT=worker \
-s SINGLE_FILE=1 \
-s WASM_ASYNC_COMPILATION=0

emcc wasm/data.cpp -Oz -o src/wasm/data.js \
-s EXPORTED_FUNCTIONS="[_pack, _malloc, _free]" \
-s EXPORTED_RUNTIME_METHODS="[HEAPF32, HEAPU32, HEAPU8]" \
-s ALLOW_MEMORY_GROWTH=1 \
-s ENVIRONMENT=worker
-s MODULARIZE=1 \
-s EXPORT_ES6=1 \
-s EXPORT_NAME=createDataModule \
-s ENVIRONMENT=worker \
-s SINGLE_FILE=1 \
-s WASM_ASYNC_COMPILATION=0
137 changes: 137 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import js from '@eslint/js';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsparser from '@typescript-eslint/parser';
import prettier from 'eslint-plugin-prettier';
import prettierConfig from 'eslint-config-prettier';

export default [
// Base JavaScript config
js.configs.recommended,

// TypeScript files
{
files: ['src/**/*.ts', 'examples/**/*.ts'],
languageOptions: {
parser: tsparser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
// Node.js globals
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
global: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',

// Browser globals
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
requestAnimationFrame: 'readonly',
cancelAnimationFrame: 'readonly',
fetch: 'readonly',
Response: 'readonly',
Request: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
Blob: 'readonly',
File: 'readonly',
FileReader: 'readonly',
XMLHttpRequest: 'readonly',

// HTML Elements
HTMLElement: 'readonly',
HTMLCanvasElement: 'readonly',
HTMLDialogElement: 'readonly',
HTMLProgressElement: 'readonly',
HTMLButtonElement: 'readonly',
HTMLInputElement: 'readonly',
HTMLDivElement: 'readonly',

// Events
Event: 'readonly',
MouseEvent: 'readonly',
KeyboardEvent: 'readonly',
WheelEvent: 'readonly',
TouchEvent: 'readonly',
PointerEvent: 'readonly',

// WebGL
WebGLRenderingContext: 'readonly',
WebGL2RenderingContext: 'readonly',
WebGLProgram: 'readonly',
WebGLShader: 'readonly',
WebGLBuffer: 'readonly',
WebGLTexture: 'readonly',
WebGLUniformLocation: 'readonly',
WebGLVertexArrayObject: 'readonly',
WebGLFramebuffer: 'readonly',
WebGLRenderbuffer: 'readonly',

// Web Workers
Worker: 'readonly',
self: 'readonly',
importScripts: 'readonly',

// Text processing
TextEncoder: 'readonly',
TextDecoder: 'readonly',

// Other Web APIs
performance: 'readonly',
Image: 'readonly',
ImageData: 'readonly',
OffscreenCanvas: 'readonly',
createImageBitmap: 'readonly'
}
},
plugins: {
'@typescript-eslint': tseslint,
prettier: prettier
},
rules: {
...tseslint.configs.recommended.rules,
...prettierConfig.rules,

// TypeScript specific rules
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'off', // Allow any for WASM modules
'@typescript-eslint/no-non-null-assertion': 'off', // Allow non-null assertions for production code
'@typescript-eslint/ban-ts-comment': 'warn',

// Prettier integration
'prettier/prettier': 'error',

// General rules
'no-console': 'off',
'no-debugger': 'warn',
'no-unused-vars': 'off', // Use TypeScript version instead
'no-undef': 'error',

// Allow worker imports with special syntax
'import/no-unresolved': 'off'
}
},

// Ignore patterns
{
ignores: [
'node_modules/**',
'dist/**',
'build/**',
'*.js',
'*.mjs',
'*.d.ts',
'examples/**/node_modules/**',
'examples/**/dist/**',
'src/wasm/*.js' // Generated WASM files
]
}
];
Loading