Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Wasm in browser #158

Merged
merged 1 commit into from
Jan 19, 2024
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
8 changes: 5 additions & 3 deletions packages/libsql-client-wasm/examples/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

## Building

Run the following in top-level directory of this repository:
Run the following in the `packages/libsql-client-wasm` directory:

```
npm run build
```

Then run the following in this directory:
Run the following in this directory:

```
npm i
./node_modules/.bin/esbuild --target=safari16 index.js --bundle --outfile=dist/out.js --format=esm
cp ../../../../node_modules/@libsql/libsql-wasm-experimental/sqlite-wasm/jswasm/sqlite3.wasm dist
```

and open the app in browser:

```
npx http-server -o .
npx http-server -o
```
18 changes: 9 additions & 9 deletions packages/libsql-client-wasm/examples/browser/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/libsql-client-wasm/examples/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"@libsql/client": "../../"
"@libsql/client-wasm": "../.."
},
"devDependencies": {
"esbuild": "0.19.11"
Expand Down
34 changes: 0 additions & 34 deletions packages/libsql-client-wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,14 @@
".": {
"types": "./lib-esm/wasm.d.ts",
"import": {
"workerd": "./lib-esm/web.js",
"deno": "./lib-esm/web.js",
"edge-light": "./lib-esm/web.js",
"netlify": "./lib-esm/web.js",
"wasm": "./lib-esm/wasm.js",
"browser": "./lib-esm/web.js",
"default": "./lib-esm/wasm.js"
}
},
"./http": {
"types": "./lib-esm/http.d.ts",
"import": "./lib-esm/http.js"
},
"./ws": {
"types": "./lib-esm/ws.d.ts",
"import": "./lib-esm/ws.js"
},
"./wasm": {
"types": "./lib-esm/wasm.d.ts",
"import": "./lib-esm/wasm.js"
},
"./web": {
"types": "./lib-esm/web.d.ts",
"import": "./lib-esm/web.js"
}
},
"typesVersions": {
"*": {
".": [
"./lib-esm/wasm.d.ts"
],
"http": [
"./lib-esm/http.d.ts"
],
"hrana": [
"./lib-esm/hrana.d.ts"
],
"wasm": [
"./lib-esm/wasm.d.ts"
],
"web": [
"./lib-esm/web.d.ts"
]
}
},
Expand Down
4 changes: 0 additions & 4 deletions packages/libsql-client-wasm/src/wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ function valueFromSql(sqlValue: unknown, intMode: IntMode): Value {
} else {
throw new Error("Invalid value for IntMode");
}
} else if (sqlValue instanceof Buffer) {
return sqlValue.buffer;
}
return sqlValue as Value;
}
Expand Down Expand Up @@ -341,8 +339,6 @@ function valueToSql(value: InValue, intMode: IntMode): SqlValue {
default:
return value ? 1 : 0;
}
} else if (value instanceof ArrayBuffer) {
return Buffer.from(value);
} else if (value instanceof Date) {
return value.valueOf();
} else if (value === undefined) {
Expand Down