Improve JavaScript/Wasm packaging

This commit is contained in:
Pekka Enberg
2024-03-03 14:10:36 +02:00
parent 227afd6c6f
commit 5eb9ec0d03
4 changed files with 20 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ env:
CARGO_TERM_COLOR: always
jobs:
build:
build-native:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
@@ -23,3 +23,11 @@ jobs:
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
build-wasm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- run: wasm-pack build --target nodejs bindings/wasm

View File

@@ -1,3 +1,5 @@
import limbo from "../pkg/limbo_wasm.js";
import { Database } from 'limbo-wasm';
const db = limbo.Database.open();
const db = new Database(':memory:');
db.exec("SELECT 'hello, world' AS message");

View File

@@ -11,5 +11,6 @@
"author": "",
"license": "MIT",
"dependencies": {
"limbo-wasm": "../pkg"
}
}

View File

@@ -9,12 +9,17 @@ pub struct Database {
#[wasm_bindgen]
impl Database {
pub fn open(_path: &str) -> Database {
#[wasm_bindgen(constructor)]
pub fn new(_path: &str) -> Database {
let io = Rc::new(IO {});
let page_source = limbo_core::PageSource::from_io(Rc::new(PageIO {}));
let inner = limbo_core::Database::open(io, page_source).unwrap();
Database { _inner: inner }
}
#[wasm_bindgen]
pub fn exec(&self, _sql: &str) {
}
}
pub struct IO {}