├── examples
├── react
│ ├── index.js
│ ├── src
│ │ ├── binding_test.js
│ │ ├── App.jsx
│ │ ├── main.jsx
│ │ └── worker.js
│ ├── index.html
│ ├── vite.config.js
│ ├── package.json
│ └── eslint.config.js
├── deno
│ ├── src
│ │ ├── binding_test.js
│ │ ├── App.jsx
│ │ ├── main.jsx
│ │ └── worker.js
│ ├── index.html
│ ├── vite.config.js
│ └── deno.json
└── wasm
│ ├── simple.html
│ └── worker.js
├── tests
└── sqllogictest
│ └── Cargo.toml
├── .gitignore
├── .cargo
└── config.toml
├── src
├── executor
│ ├── mod.rs
│ ├── wasm.rs
│ └── tokio.rs
├── lib.rs
├── connection.rs
├── utils.rs
└── db.rs
├── Cargo.toml
├── README.md
└── LICENSE
/examples/react/index.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/sqllogictest/Cargo.toml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | node_modules
3 |
--------------------------------------------------------------------------------
/examples/react/src/binding_test.js:
--------------------------------------------------------------------------------
1 |
2 | new Worker(new URL('./worker.js', import.meta.url));
3 |
4 |
--------------------------------------------------------------------------------
/examples/deno/src/binding_test.js:
--------------------------------------------------------------------------------
1 |
2 | const worker = new Worker(new URL('./worker.js', import.meta.url));
3 |
4 |
--------------------------------------------------------------------------------
/examples/deno/src/App.jsx:
--------------------------------------------------------------------------------
1 |
2 | function App() {
3 |
4 | return (
5 | <>
6 |
Please see output in console
7 | >
8 | )
9 | }
10 |
11 | export default App
12 |
--------------------------------------------------------------------------------
/examples/react/src/App.jsx:
--------------------------------------------------------------------------------
1 |
2 | function App() {
3 |
4 | return (
5 | <>
6 | Please see output in console
7 | >
8 | )
9 | }
10 |
11 | export default App
12 |
--------------------------------------------------------------------------------
/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [target.wasm32-unknown-unknown]
2 | rustflags = ["-C", "target-feature=+atomics,+bulk-memory,+mutable-globals", "--cfg", 'getrandom_backend="wasm_js"']
3 |
4 | [unstable]
5 | build-std = ["panic_abort", "std"]
6 |
--------------------------------------------------------------------------------
/examples/wasm/simple.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/react/src/main.jsx:
--------------------------------------------------------------------------------
1 | import { StrictMode } from 'react'
2 | import { createRoot } from 'react-dom/client'
3 | import App from './App.jsx'
4 | import './binding_test.js'
5 |
6 | createRoot(document.getElementById('root')).render(
7 |
8 |
9 | ,
10 | )
11 |
--------------------------------------------------------------------------------
/examples/deno/src/main.jsx:
--------------------------------------------------------------------------------
1 | // @deno-types="@types/react"
2 | import { StrictMode } from 'react'
3 | // @deno-types="@types/react-dom/client"
4 | import { createRoot } from 'react-dom/client'
5 | import App from './App.jsx'
6 | import './binding_test.js'
7 |
8 | createRoot(document.getElementById('root')).render(
9 |
10 |
11 | ,
12 | )
13 |
--------------------------------------------------------------------------------
/examples/deno/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Tonbolite react example
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/react/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | sqlite-tonbo react example
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/react/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import react from '@vitejs/plugin-react'
3 |
4 | // https://vite.dev/config/
5 | export default defineConfig({
6 | plugins: [react()],
7 | server: {
8 | headers: {
9 | "Cross-Origin-Opener-Policy": "same-origin",
10 | "Cross-Origin-Opener-Policy-Report-Only": "same-origin",
11 | "Cross-Origin-Embedder-Policy": "require-corp"
12 | }
13 | }
14 | })
15 |
--------------------------------------------------------------------------------
/src/executor/mod.rs:
--------------------------------------------------------------------------------
1 | #[cfg(feature = "tokio")]
2 | pub(crate) mod tokio;
3 | #[cfg(feature = "wasm")]
4 | pub(crate) mod wasm;
5 |
6 | use std::future::Future;
7 |
8 | #[cfg(not(feature = "wasm"))]
9 | pub type SQLiteExecutor = tokio::TokioExecutor;
10 | #[cfg(feature = "wasm")]
11 | pub type SQLiteExecutor = tonbo::executor::opfs::OpfsExecutor;
12 |
13 | pub trait BlockOnExecutor: tonbo::executor::Executor {
14 | fn block_on(&self, future: F) -> F::Output;
15 | }
16 |
--------------------------------------------------------------------------------
/examples/deno/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import deno from '@deno/vite-plugin'
3 | import react from '@vitejs/plugin-react'
4 |
5 | // https://vite.dev/config/
6 | export default defineConfig({
7 | plugins: [deno(), react()],
8 | server: {
9 | headers: {
10 | "Cross-Origin-Opener-Policy": "same-origin",
11 | "Cross-Origin-Opener-Policy-Report-Only": "same-origin",
12 | "Cross-Origin-Embedder-Policy": "require-corp"
13 | }
14 | }
15 | })
16 |
--------------------------------------------------------------------------------
/src/executor/wasm.rs:
--------------------------------------------------------------------------------
1 | use crate::executor::BlockOnExecutor;
2 | use fusio::MaybeSend;
3 | use tonbo::executor::Executor;
4 |
5 | use std::future::Future;
6 |
7 | #[derive(Clone, Default)]
8 | pub struct WasmExecutor;
9 |
10 | impl Executor for WasmExecutor {
11 | fn spawn(&self, future: F)
12 | where
13 | F: Future