mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 12:04:21 +01:00
Improve JavaScript/Wasm packaging
This commit is contained in:
10
.github/workflows/rust.yml
vendored
10
.github/workflows/rust.yml
vendored
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -11,5 +11,6 @@
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"limbo-wasm": "../pkg"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user