mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-30 13:24:22 +01:00
Merge 'hack imports of wasm due to the issues in Vite and Next.js build systems' from Nikita Sivukhin
This tries to establish smooth as possible experience for browser
packages in web.
In order to do that this PR do the following tricks:
1. export `./vite` entry-point which should be used like `import {
connect } from "@tursodatabase/database-browser/vite"` for Vite bundler
* This entrypoint has fix for the issue
https://github.com/vitejs/vite/issues/8427 which breaks package in the
dev-server mode
* In order to overcome this we do 2 tricks:
- Inline WASM module in order to avoid loading it from the separate
file
- Use same file as entry-point for main thread and for the web
worker
* Note, that we do these tricks only for `development` build and
produce build will be chunked and optimized as usual with Vite and will
treat worker and WASM modules as separate fiels
3. export `./turbopack` entry-point which should be used like `import {
connect } from @tursodatabase/database-browser/turbopack"` for Turbopack
(Next.js) bundler
* This entrypoint has fix for the issue
https://github.com/vercel/next.js/issues/82520'
* In order to overcome this for now we always inline WASM for Next.js
4. Bundle browser libraries in order to easily consume them without need
for bundlers:
* e.g. `import { connect } from
"https://unpkg.com/@tursodatabase/database-browser/bundle/main.es.js";`
5. We vendor `@napi-rs/wasm-runtime` for now in order to fix runtime
errors due to accesses to `process.env.NODE_DEBUG_NATIVE` env var (not
defined in web)
* This should be very temporary solution because I already fixed
wasm-util dependency which cause this error
(https://github.com/toyobayashi/wasm-util/issues/4) and hope that napi-
rs PR will be merged soon: https://github.com/napi-rs/napi-rs/pull/2921
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Closes #3017
This commit is contained in:
1
bindings/javascript/.gitignore
vendored
1
bindings/javascript/.gitignore
vendored
@@ -198,3 +198,4 @@ Cargo.lock
|
||||
*.wasm
|
||||
|
||||
npm
|
||||
bundle
|
||||
|
||||
320
bindings/javascript/package-lock.json
generated
320
bindings/javascript/package-lock.json
generated
@@ -13,7 +13,8 @@
|
||||
"packages/browser-common",
|
||||
"sync/packages/common",
|
||||
"sync/packages/native",
|
||||
"sync/packages/browser"
|
||||
"sync/packages/browser",
|
||||
"packages/wasm-runtime"
|
||||
]
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
@@ -194,51 +195,6 @@
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/@inquirer/core/node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@inquirer/core/node_modules/is-fullwidth-code-point": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/@inquirer/core/node_modules/string-width": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^8.0.0",
|
||||
"is-fullwidth-code-point": "^3.0.0",
|
||||
"strip-ansi": "^6.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/@inquirer/core/node_modules/strip-ansi": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^5.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/@inquirer/core/node_modules/wrap-ansi": {
|
||||
"version": "6.2.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
|
||||
@@ -497,6 +453,70 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping": {
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||
"integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.5.0",
|
||||
"@jridgewell/trace-mapping": "^0.3.24"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping/node_modules/@jridgewell/trace-mapping": {
|
||||
"version": "0.3.31",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
|
||||
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/resolve-uri": "^3.1.0",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.14"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/resolve-uri": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
|
||||
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/source-map": {
|
||||
"version": "0.3.11",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz",
|
||||
"integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/gen-mapping": "^0.3.5",
|
||||
"@jridgewell/trace-mapping": "^0.3.25"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/source-map/node_modules/@jridgewell/trace-mapping": {
|
||||
"version": "0.3.31",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
|
||||
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/resolve-uri": "^3.1.0",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.14"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/sourcemap-codec": {
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
|
||||
@@ -781,7 +801,9 @@
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.0.3.tgz",
|
||||
"integrity": "sha512-rZxtMsLwjdXkMUGC3WwsPwLNVqVqnTJT6MNIB6e+5fhMcSCPP0AOsNWuMQ5mdCq6HNjs/ZeWAEchpqeprqBD2Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@emnapi/core": "^1.4.5",
|
||||
"@emnapi/runtime": "^1.4.5",
|
||||
@@ -1127,14 +1149,13 @@
|
||||
"resolved": "sync/packages/common",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@tursodatabase/wasm-runtime": {
|
||||
"resolved": "packages/wasm-runtime",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@tybys/wasm-util": {
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.0.tgz",
|
||||
"integrity": "sha512-VyyPYFlOMNylG45GoAe0xDoLwWuowvf92F9kySqzYh8vmYm7D2u4iUJKa1tOUpS70Ku13ASrOkS4ScXFsTaCNQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
"resolved": "packages/wasm-util",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@types/aria-query": {
|
||||
"version": "5.0.4",
|
||||
@@ -1338,6 +1359,21 @@
|
||||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.15.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
|
||||
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-escapes": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz",
|
||||
@@ -1417,6 +1453,15 @@
|
||||
"dev": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/buffer-from": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
||||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/cac": {
|
||||
"version": "6.7.14",
|
||||
"resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz",
|
||||
@@ -1514,6 +1559,15 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "2.20.3",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
||||
@@ -1574,6 +1628,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/es-module-lexer": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz",
|
||||
@@ -1725,6 +1786,21 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/fsevents": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
@@ -1738,6 +1814,16 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-fullwidth-code-point": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/js-tokens": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz",
|
||||
@@ -1955,6 +2041,21 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright/node_modules/fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.6",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
|
||||
@@ -2102,6 +2203,18 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||
@@ -2112,6 +2225,19 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-support": {
|
||||
"version": "0.5.21",
|
||||
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
|
||||
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"buffer-from": "^1.0.0",
|
||||
"source-map": "^0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/stackback": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",
|
||||
@@ -2126,6 +2252,34 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
|
||||
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"emoji-regex": "^8.0.0",
|
||||
"is-fullwidth-code-point": "^3.0.0",
|
||||
"strip-ansi": "^6.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/strip-ansi": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-regex": "^5.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/strip-literal": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.0.0.tgz",
|
||||
@@ -2139,6 +2293,27 @@
|
||||
"url": "https://github.com/sponsors/antfu"
|
||||
}
|
||||
},
|
||||
"node_modules/terser": {
|
||||
"version": "5.44.0",
|
||||
"resolved": "https://registry.npmjs.org/terser/-/terser-5.44.0.tgz",
|
||||
"integrity": "sha512-nIVck8DK+GM/0Frwd+nIhZ84pR/BX7rmXMfYwyg+Sri5oGVE99/E3KvXqpC2xHFxyqXyGHTKBSioxxplrO4I4w==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@jridgewell/source-map": "^0.3.3",
|
||||
"acorn": "^8.15.0",
|
||||
"commander": "^2.20.0",
|
||||
"source-map-support": "~0.5.20"
|
||||
},
|
||||
"bin": {
|
||||
"terser": "bin/terser"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/tinybench": {
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",
|
||||
@@ -2508,7 +2683,6 @@
|
||||
"version": "0.2.0-pre.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@napi-rs/wasm-runtime": "^1.0.3",
|
||||
"@tursodatabase/database-browser-common": "^0.2.0-pre.1",
|
||||
"@tursodatabase/database-common": "^0.2.0-pre.1"
|
||||
},
|
||||
@@ -2517,6 +2691,7 @@
|
||||
"@vitest/browser": "^3.2.4",
|
||||
"playwright": "^1.55.0",
|
||||
"typescript": "^5.9.2",
|
||||
"vite": "^7.1.5",
|
||||
"vitest": "^3.2.4"
|
||||
}
|
||||
},
|
||||
@@ -2524,6 +2699,9 @@
|
||||
"name": "@tursodatabase/database-browser-common",
|
||||
"version": "0.2.0-pre.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tursodatabase/wasm-runtime": "^0.2.0-pre.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.9.2"
|
||||
}
|
||||
@@ -2536,15 +2714,6 @@
|
||||
"typescript": "^5.9.2"
|
||||
}
|
||||
},
|
||||
"packages/core": {
|
||||
"name": "@tursodatabase/database-core",
|
||||
"version": "0.1.5-pre.3",
|
||||
"extraneous": true,
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.9.2"
|
||||
}
|
||||
},
|
||||
"packages/native": {
|
||||
"name": "@tursodatabase/database",
|
||||
"version": "0.2.0-pre.1",
|
||||
@@ -2559,12 +2728,34 @@
|
||||
"vitest": "^3.2.4"
|
||||
}
|
||||
},
|
||||
"packages/wasm-runtime": {
|
||||
"name": "@tursodatabase/wasm-runtime",
|
||||
"version": "0.2.0-pre.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@emnapi/core": "^1.4.5",
|
||||
"@emnapi/runtime": "^1.4.5",
|
||||
"@tybys/wasm-util": "^0.10.1"
|
||||
}
|
||||
},
|
||||
"packages/wasm-runtime/node_modules/@tybys/wasm-util": {
|
||||
"version": "0.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz",
|
||||
"integrity": "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"packages/wasm-util": {
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"sync/packages/browser": {
|
||||
"name": "@tursodatabase/sync-browser",
|
||||
"version": "0.2.0-pre.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@napi-rs/wasm-runtime": "^1.0.3",
|
||||
"@tursodatabase/database-browser-common": "^0.2.0-pre.1",
|
||||
"@tursodatabase/database-common": "^0.2.0-pre.1",
|
||||
"@tursodatabase/sync-common": "^0.2.0-pre.1"
|
||||
@@ -2574,6 +2765,7 @@
|
||||
"@vitest/browser": "^3.2.4",
|
||||
"playwright": "^1.55.0",
|
||||
"typescript": "^5.9.2",
|
||||
"vite": "^7.1.5",
|
||||
"vitest": "^3.2.4"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
{
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "npm run build --workspaces",
|
||||
"tsc-build": "npm run tsc-build --workspaces",
|
||||
"test": "npm run test --workspaces"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/wasm-runtime",
|
||||
"packages/common",
|
||||
"packages/native",
|
||||
"packages/browser",
|
||||
"packages/browser-common",
|
||||
"packages/browser",
|
||||
"sync/packages/common",
|
||||
"sync/packages/native",
|
||||
"sync/packages/browser"
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
import {
|
||||
createOnMessage as __wasmCreateOnMessageForFsProxy,
|
||||
getDefaultContext as __emnapiGetDefaultContext,
|
||||
instantiateNapiModule as __emnapiInstantiateNapiModule,
|
||||
WASI as __WASI,
|
||||
instantiateNapiModuleSync,
|
||||
MessageHandler
|
||||
} from '@tursodatabase/wasm-runtime'
|
||||
|
||||
function getUint8ArrayFromMemory(memory: WebAssembly.Memory, ptr: number, len: number): Uint8Array {
|
||||
ptr = ptr >>> 0;
|
||||
return new Uint8Array(memory.buffer).subarray(ptr, ptr + len);
|
||||
@@ -197,7 +206,7 @@ class OpfsDirectory {
|
||||
}
|
||||
}
|
||||
|
||||
var workerRequestId = 0;
|
||||
let workerRequestId = 0;
|
||||
function waitForWorkerResponse(worker: Worker, id: number): Promise<any> {
|
||||
let waitResolve, waitReject;
|
||||
const callback = msg => {
|
||||
@@ -236,4 +245,103 @@ function unregisterFileAtWorker(worker: Worker, path: string): Promise<void> {
|
||||
return promise;
|
||||
}
|
||||
|
||||
export { OpfsDirectory, workerImports, MainDummyImports, waitForWorkerResponse, registerFileAtWorker, unregisterFileAtWorker }
|
||||
function isWebWorker(): boolean {
|
||||
return typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
||||
}
|
||||
|
||||
function setupWebWorker() {
|
||||
let opfs = new OpfsDirectory();
|
||||
let memory = null;
|
||||
|
||||
const handler = new MessageHandler({
|
||||
onLoad({ wasmModule, wasmMemory }) {
|
||||
memory = wasmMemory;
|
||||
const wasi = new __WASI({
|
||||
print: function () {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log.apply(console, arguments)
|
||||
},
|
||||
printErr: function () {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error.apply(console, arguments)
|
||||
},
|
||||
})
|
||||
return instantiateNapiModuleSync(wasmModule, {
|
||||
childThread: true,
|
||||
wasi,
|
||||
overwriteImports(importObject) {
|
||||
importObject.env = {
|
||||
...importObject.env,
|
||||
...importObject.napi,
|
||||
...importObject.emnapi,
|
||||
...workerImports(opfs, memory),
|
||||
memory: wasmMemory,
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
globalThis.onmessage = async function (e) {
|
||||
if (e.data.__turso__ == 'register') {
|
||||
try {
|
||||
await opfs.registerFile(e.data.path);
|
||||
self.postMessage({ id: e.data.id });
|
||||
} catch (error) {
|
||||
self.postMessage({ id: e.data.id, error: error });
|
||||
}
|
||||
return;
|
||||
} else if (e.data.__turso__ == 'unregister') {
|
||||
try {
|
||||
await opfs.unregisterFile(e.data.path);
|
||||
self.postMessage({ id: e.data.id });
|
||||
} catch (error) {
|
||||
self.postMessage({ id: e.data.id, error: error });
|
||||
}
|
||||
return;
|
||||
}
|
||||
handler.handle(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function setupMainThread(wasmFile: ArrayBuffer, factory: () => Worker): Promise<any> {
|
||||
const __emnapiContext = __emnapiGetDefaultContext()
|
||||
const __wasi = new __WASI({
|
||||
version: 'preview1',
|
||||
})
|
||||
const __sharedMemory = new WebAssembly.Memory({
|
||||
initial: 4000,
|
||||
maximum: 65536,
|
||||
shared: true,
|
||||
})
|
||||
const {
|
||||
instance: __napiInstance,
|
||||
module: __wasiModule,
|
||||
napiModule: __napiModule,
|
||||
} = await __emnapiInstantiateNapiModule(wasmFile, {
|
||||
context: __emnapiContext,
|
||||
asyncWorkPoolSize: 1,
|
||||
wasi: __wasi,
|
||||
onCreateWorker() { return factory() },
|
||||
overwriteImports(importObject) {
|
||||
importObject.env = {
|
||||
...importObject.env,
|
||||
...importObject.napi,
|
||||
...importObject.emnapi,
|
||||
...MainDummyImports,
|
||||
memory: __sharedMemory,
|
||||
}
|
||||
return importObject
|
||||
},
|
||||
beforeInit({ instance }) {
|
||||
for (const name of Object.keys(instance.exports)) {
|
||||
if (name.startsWith('__napi_register__')) {
|
||||
instance.exports[name]()
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
return __napiModule;
|
||||
}
|
||||
|
||||
export { OpfsDirectory, workerImports, MainDummyImports, waitForWorkerResponse, registerFileAtWorker, unregisterFileAtWorker, isWebWorker, setupWebWorker, setupMainThread }
|
||||
@@ -21,5 +21,8 @@
|
||||
"tsc-build": "npm exec tsc",
|
||||
"build": "npm run tsc-build",
|
||||
"test": "echo 'no tests'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tursodatabase/wasm-runtime": "^0.2.0-pre.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
"skipLibCheck": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"module": "esnext",
|
||||
"module": "nodenext",
|
||||
"target": "esnext",
|
||||
"moduleResolution": "nodenext",
|
||||
"outDir": "dist/",
|
||||
"lib": [
|
||||
"es2020",
|
||||
|
||||
24
bindings/javascript/packages/browser/index-bundle.ts
Normal file
24
bindings/javascript/packages/browser/index-bundle.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { setupMainThread } from "@tursodatabase/database-browser-common";
|
||||
//@ts-ignore
|
||||
import TursoWorker from "./worker.js?worker&inline";
|
||||
|
||||
const __wasmUrl = new URL('./turso.wasm32-wasi.wasm', import.meta.url).href;
|
||||
const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
|
||||
|
||||
export let MainWorker = null;
|
||||
const napiModule = await setupMainThread(__wasmFile, () => {
|
||||
const worker = new TursoWorker({
|
||||
name: 'turso-database',
|
||||
type: 'module',
|
||||
})
|
||||
MainWorker = worker;
|
||||
return worker
|
||||
});
|
||||
|
||||
export default napiModule.exports
|
||||
export const Database = napiModule.exports.Database
|
||||
export const Opfs = napiModule.exports.Opfs
|
||||
export const OpfsFile = napiModule.exports.OpfsFile
|
||||
export const Statement = napiModule.exports.Statement
|
||||
export const connect = napiModule.exports.connect
|
||||
export const initThreadPool = napiModule.exports.initThreadPool
|
||||
22
bindings/javascript/packages/browser/index-default.ts
Normal file
22
bindings/javascript/packages/browser/index-default.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { setupMainThread } from "@tursodatabase/database-browser-common";
|
||||
|
||||
const __wasmUrl = new URL('./turso.wasm32-wasi.wasm', import.meta.url).href;
|
||||
const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
|
||||
|
||||
export let MainWorker = null;
|
||||
const napiModule = await setupMainThread(__wasmFile, () => {
|
||||
const worker = new Worker(new URL('./worker.js', import.meta.url), {
|
||||
name: 'turso-database',
|
||||
type: 'module',
|
||||
})
|
||||
MainWorker = worker;
|
||||
return worker
|
||||
});
|
||||
|
||||
export default napiModule.exports
|
||||
export const Database = napiModule.exports.Database
|
||||
export const Opfs = napiModule.exports.Opfs
|
||||
export const OpfsFile = napiModule.exports.OpfsFile
|
||||
export const Statement = napiModule.exports.Statement
|
||||
export const connect = napiModule.exports.connect
|
||||
export const initThreadPool = napiModule.exports.initThreadPool
|
||||
25
bindings/javascript/packages/browser/index-turbopack-hack.ts
Normal file
25
bindings/javascript/packages/browser/index-turbopack-hack.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { setupMainThread } from "@tursodatabase/database-browser-common";
|
||||
import { tursoWasm } from "./wasm-inline.js";
|
||||
|
||||
// Next (turbopack) has issues with loading wasm module: https://github.com/vercel/next.js/issues/82520
|
||||
// So, we inline wasm binary in the source code in order to avoid issues with loading it from the file
|
||||
const __wasmFile = await tursoWasm();
|
||||
|
||||
export let MainWorker = null;
|
||||
|
||||
const napiModule = await setupMainThread(__wasmFile, () => {
|
||||
const worker = new Worker(new URL('./worker.js', import.meta.url), {
|
||||
name: 'turso-database',
|
||||
type: 'module',
|
||||
})
|
||||
MainWorker = worker;
|
||||
return worker
|
||||
});
|
||||
|
||||
export default napiModule.exports
|
||||
export const Database = napiModule.exports.Database
|
||||
export const Opfs = napiModule.exports.Opfs
|
||||
export const OpfsFile = napiModule.exports.OpfsFile
|
||||
export const Statement = napiModule.exports.Statement
|
||||
export const connect = napiModule.exports.connect
|
||||
export const initThreadPool = napiModule.exports.initThreadPool
|
||||
41
bindings/javascript/packages/browser/index-vite-dev-hack.ts
Normal file
41
bindings/javascript/packages/browser/index-vite-dev-hack.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { isWebWorker, setupMainThread, setupWebWorker } from "@tursodatabase/database-browser-common";
|
||||
import { tursoWasm } from "./wasm-inline.js";
|
||||
|
||||
let napiModule = {
|
||||
exports: {
|
||||
Database: {} as any,
|
||||
Opfs: {} as any,
|
||||
OpfsFile: {} as any,
|
||||
Statement: {} as any,
|
||||
connect: {} as any,
|
||||
initThreadPool: {} as any,
|
||||
}
|
||||
};
|
||||
|
||||
export let MainWorker = null;
|
||||
if (isWebWorker()) {
|
||||
setupWebWorker();
|
||||
} else {
|
||||
// Vite has issues with loading wasm modules and worker in dev server: https://github.com/vitejs/vite/issues/8427
|
||||
// So, the mitigation for dev server only is:
|
||||
// 1. inline wasm binary in the source code in order to avoid issues with loading it from the file
|
||||
// 2. use same file as worker entry point
|
||||
const __wasmFile = await tursoWasm();
|
||||
|
||||
napiModule = await setupMainThread(__wasmFile, () => {
|
||||
const worker = new Worker(import.meta.url, {
|
||||
name: 'turso-database',
|
||||
type: 'module',
|
||||
})
|
||||
MainWorker = worker;
|
||||
return worker
|
||||
});
|
||||
}
|
||||
|
||||
export default napiModule.exports
|
||||
export const Database = napiModule.exports.Database
|
||||
export const Opfs = napiModule.exports.Opfs
|
||||
export const OpfsFile = napiModule.exports.OpfsFile
|
||||
export const Statement = napiModule.exports.Statement
|
||||
export const connect = napiModule.exports.connect
|
||||
export const initThreadPool = napiModule.exports.initThreadPool
|
||||
@@ -1,68 +0,0 @@
|
||||
import {
|
||||
createOnMessage as __wasmCreateOnMessageForFsProxy,
|
||||
getDefaultContext as __emnapiGetDefaultContext,
|
||||
instantiateNapiModule as __emnapiInstantiateNapiModule,
|
||||
WASI as __WASI,
|
||||
} from '@napi-rs/wasm-runtime'
|
||||
|
||||
import { MainDummyImports } from "@tursodatabase/database-browser-common";
|
||||
|
||||
|
||||
const __wasi = new __WASI({
|
||||
version: 'preview1',
|
||||
})
|
||||
|
||||
const __wasmUrl = new URL('./turso.wasm32-wasi.wasm', import.meta.url).href
|
||||
const __emnapiContext = __emnapiGetDefaultContext()
|
||||
|
||||
|
||||
const __sharedMemory = new WebAssembly.Memory({
|
||||
initial: 4000,
|
||||
maximum: 65536,
|
||||
shared: true,
|
||||
})
|
||||
|
||||
const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
|
||||
|
||||
export let MainWorker = null;
|
||||
|
||||
const {
|
||||
instance: __napiInstance,
|
||||
module: __wasiModule,
|
||||
napiModule: __napiModule,
|
||||
} = await __emnapiInstantiateNapiModule(__wasmFile, {
|
||||
context: __emnapiContext,
|
||||
asyncWorkPoolSize: 1,
|
||||
wasi: __wasi,
|
||||
onCreateWorker() {
|
||||
const worker = new Worker(new URL('./worker.mjs', import.meta.url), {
|
||||
type: 'module',
|
||||
})
|
||||
MainWorker = worker;
|
||||
return worker
|
||||
},
|
||||
overwriteImports(importObject) {
|
||||
importObject.env = {
|
||||
...importObject.env,
|
||||
...importObject.napi,
|
||||
...importObject.emnapi,
|
||||
...MainDummyImports,
|
||||
memory: __sharedMemory,
|
||||
}
|
||||
return importObject
|
||||
},
|
||||
beforeInit({ instance }) {
|
||||
for (const name of Object.keys(instance.exports)) {
|
||||
if (name.startsWith('__napi_register__')) {
|
||||
instance.exports[name]()
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
export default __napiModule.exports
|
||||
export const Database = __napiModule.exports.Database
|
||||
export const Opfs = __napiModule.exports.Opfs
|
||||
export const OpfsFile = __napiModule.exports.OpfsFile
|
||||
export const Statement = __napiModule.exports.Statement
|
||||
export const connect = __napiModule.exports.connect
|
||||
export const initThreadPool = __napiModule.exports.initThreadPool
|
||||
@@ -7,25 +7,40 @@
|
||||
},
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"main": "dist/promise.js",
|
||||
"main": "./dist/promise-default.js",
|
||||
"packageManager": "yarn@4.9.2",
|
||||
"files": [
|
||||
"index.js",
|
||||
"worker.mjs",
|
||||
"turso.wasm32-wasi.wasm",
|
||||
"dist/**",
|
||||
"bundle/**",
|
||||
"README.md"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/promise-default.js"
|
||||
},
|
||||
"./bundle": {
|
||||
"default": "./bundle/main.es.js"
|
||||
},
|
||||
"./vite": {
|
||||
"development": "./dist/promise-vite-dev-hack.js",
|
||||
"default": "./dist/promise-default.js"
|
||||
},
|
||||
"./turbopack": {
|
||||
"default": "./dist/promise-turbopack-hack.js"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "^3.1.5",
|
||||
"@vitest/browser": "^3.2.4",
|
||||
"playwright": "^1.55.0",
|
||||
"typescript": "^5.9.2",
|
||||
"vite": "^7.1.5",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"scripts": {
|
||||
"napi-build": "napi build --features browser --release --platform --target wasm32-wasip1-threads --no-js --manifest-path ../../Cargo.toml --output-dir . && rm index.d.ts turso.wasi* wasi* browser.js",
|
||||
"tsc-build": "npm exec tsc",
|
||||
"tsc-build": "npm exec tsc && cp turso.wasm32-wasi.wasm ./dist/turso.wasm32-wasi.wasm && WASM_FILE=turso.wasm32-wasi.wasm JS_FILE=./dist/wasm-inline.js node ../../scripts/inline-wasm-base64.js && npm run bundle",
|
||||
"bundle": "vite build",
|
||||
"build": "npm run napi-build && npm run tsc-build",
|
||||
"test": "CI=1 vitest --browser=chromium --run && CI=1 vitest --browser=firefox --run"
|
||||
},
|
||||
@@ -35,11 +50,7 @@
|
||||
"wasm32-wasip1-threads"
|
||||
]
|
||||
},
|
||||
"imports": {
|
||||
"#index": "./index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@napi-rs/wasm-runtime": "^1.0.3",
|
||||
"@tursodatabase/database-browser-common": "^0.2.0-pre.1",
|
||||
"@tursodatabase/database-common": "^0.2.0-pre.1"
|
||||
}
|
||||
|
||||
22
bindings/javascript/packages/browser/promise-bundle.ts
Normal file
22
bindings/javascript/packages/browser/promise-bundle.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { DatabaseOpts, SqliteError, } from "@tursodatabase/database-common"
|
||||
import { connect as promiseConnect, Database } from "./promise.js";
|
||||
import { connect as nativeConnect, initThreadPool, MainWorker } from "./index-bundle.js";
|
||||
|
||||
/**
|
||||
* Creates a new database connection asynchronously.
|
||||
*
|
||||
* @param {string} path - Path to the database file.
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(path: string, opts: DatabaseOpts = {}): Promise<Database> {
|
||||
return await promiseConnect(path, opts, nativeConnect, async () => {
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not initialized");
|
||||
}
|
||||
return MainWorker;
|
||||
});
|
||||
}
|
||||
|
||||
export { connect, Database, SqliteError }
|
||||
22
bindings/javascript/packages/browser/promise-default.ts
Normal file
22
bindings/javascript/packages/browser/promise-default.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { DatabaseOpts, SqliteError, } from "@tursodatabase/database-common"
|
||||
import { connect as promiseConnect, Database } from "./promise.js";
|
||||
import { connect as nativeConnect, initThreadPool, MainWorker } from "./index-default.js";
|
||||
|
||||
/**
|
||||
* Creates a new database connection asynchronously.
|
||||
*
|
||||
* @param {string} path - Path to the database file.
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(path: string, opts: DatabaseOpts = {}): Promise<Database> {
|
||||
return await promiseConnect(path, opts, nativeConnect, async () => {
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not initialized");
|
||||
}
|
||||
return MainWorker;
|
||||
});
|
||||
}
|
||||
|
||||
export { connect, Database, SqliteError }
|
||||
@@ -0,0 +1,22 @@
|
||||
import { DatabaseOpts, SqliteError, } from "@tursodatabase/database-common"
|
||||
import { connect as promiseConnect, Database } from "./promise.js";
|
||||
import { connect as nativeConnect, initThreadPool, MainWorker } from "./index-turbopack-hack.js";
|
||||
|
||||
/**
|
||||
* Creates a new database connection asynchronously.
|
||||
*
|
||||
* @param {string} path - Path to the database file.
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(path: string, opts: DatabaseOpts = {}): Promise<Database> {
|
||||
return await promiseConnect(path, opts, nativeConnect, async () => {
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not initialized");
|
||||
}
|
||||
return MainWorker;
|
||||
});
|
||||
}
|
||||
|
||||
export { connect, Database, SqliteError }
|
||||
@@ -0,0 +1,22 @@
|
||||
import { DatabaseOpts, SqliteError, } from "@tursodatabase/database-common"
|
||||
import { connect as promiseConnect, Database } from "./promise.js";
|
||||
import { connect as nativeConnect, initThreadPool, MainWorker } from "./index-vite-dev-hack.js";
|
||||
|
||||
/**
|
||||
* Creates a new database connection asynchronously.
|
||||
*
|
||||
* @param {string} path - Path to the database file.
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(path: string, opts: DatabaseOpts = {}): Promise<Database> {
|
||||
return await promiseConnect(path, opts, nativeConnect, async () => {
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not initialized");
|
||||
}
|
||||
return MainWorker;
|
||||
});
|
||||
}
|
||||
|
||||
export { connect, Database, SqliteError }
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect, test, afterEach } from 'vitest'
|
||||
import { connect } from './promise.js'
|
||||
import { connect } from './promise-default.js'
|
||||
|
||||
test('in-memory db', async () => {
|
||||
const db = await connect(":memory:");
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
import { registerFileAtWorker, unregisterFileAtWorker } from "@tursodatabase/database-browser-common"
|
||||
import { DatabasePromise, NativeDatabase, DatabaseOpts, SqliteError, } from "@tursodatabase/database-common"
|
||||
import { connect as nativeConnect, initThreadPool, MainWorker } from "#index";
|
||||
|
||||
class Database extends DatabasePromise {
|
||||
path: string | null;
|
||||
constructor(db: NativeDatabase, fsPath: string | null, opts: DatabaseOpts = {}) {
|
||||
worker: Worker | null;
|
||||
constructor(db: NativeDatabase, worker: Worker | null, fsPath: string | null, opts: DatabaseOpts = {}) {
|
||||
super(db, opts)
|
||||
this.path = fsPath;
|
||||
this.worker = worker;
|
||||
}
|
||||
async close() {
|
||||
if (this.path != null) {
|
||||
if (this.path != null && this.worker != null) {
|
||||
await Promise.all([
|
||||
unregisterFileAtWorker(MainWorker, this.path),
|
||||
unregisterFileAtWorker(MainWorker, `${this.path}-wal`)
|
||||
unregisterFileAtWorker(this.worker, this.path),
|
||||
unregisterFileAtWorker(this.worker, `${this.path}-wal`)
|
||||
]);
|
||||
}
|
||||
this.db.close();
|
||||
@@ -26,21 +27,18 @@ class Database extends DatabasePromise {
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(path: string, opts: DatabaseOpts = {}): Promise<Database> {
|
||||
async function connect(path: string, opts: DatabaseOpts, connect: any, init: () => Promise<Worker>): Promise<Database> {
|
||||
if (path == ":memory:") {
|
||||
const db = await nativeConnect(path, { tracing: opts.tracing });
|
||||
return new Database(db, null, opts);
|
||||
}
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not set");
|
||||
const db = await connect(path, { tracing: opts.tracing });
|
||||
return new Database(db, null, null, opts);
|
||||
}
|
||||
const worker = await init();
|
||||
await Promise.all([
|
||||
registerFileAtWorker(MainWorker, path),
|
||||
registerFileAtWorker(MainWorker, `${path}-wal`)
|
||||
registerFileAtWorker(worker, path),
|
||||
registerFileAtWorker(worker, `${path}-wal`)
|
||||
]);
|
||||
const db = await nativeConnect(path, { tracing: opts.tracing });
|
||||
return new Database(db, path, opts);
|
||||
const db = await connect(path, { tracing: opts.tracing });
|
||||
return new Database(db, worker, path, opts);
|
||||
}
|
||||
|
||||
export { connect, Database, SqliteError }
|
||||
|
||||
@@ -11,12 +11,7 @@
|
||||
"es2020",
|
||||
"DOM",
|
||||
"WebWorker"
|
||||
],
|
||||
"paths": {
|
||||
"#index": [
|
||||
"./index.js"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"*"
|
||||
|
||||
0
bindings/javascript/packages/browser/vite
Normal file
0
bindings/javascript/packages/browser/vite
Normal file
19
bindings/javascript/packages/browser/vite.config.js
Normal file
19
bindings/javascript/packages/browser/vite.config.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { resolve } from 'path';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
base: './',
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'promise-bundle.ts'),
|
||||
name: 'database-browser',
|
||||
fileName: format => `main.${format}.js`,
|
||||
formats: ['es'],
|
||||
},
|
||||
rollupOptions: {
|
||||
output: {
|
||||
dir: 'bundle',
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
9
bindings/javascript/packages/browser/wasm-inline.ts
Normal file
9
bindings/javascript/packages/browser/wasm-inline.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
const tursoWasmBase64 = '__PLACEHOLDER__';
|
||||
async function convertBase64ToBinary(base64Url: string): Promise<ArrayBuffer> {
|
||||
const blob = await fetch(base64Url).then(res => res.blob());
|
||||
return await blob.arrayBuffer();
|
||||
}
|
||||
|
||||
export async function tursoWasm(): Promise<ArrayBuffer> {
|
||||
return await convertBase64ToBinary(tursoWasmBase64);
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
|
||||
import { OpfsDirectory, workerImports } from '@tursodatabase/database-browser-common';
|
||||
|
||||
var opfs = new OpfsDirectory();
|
||||
var memory = null;
|
||||
|
||||
const handler = new MessageHandler({
|
||||
onLoad({ wasmModule, wasmMemory }) {
|
||||
memory = wasmMemory;
|
||||
const wasi = new WASI({
|
||||
print: function () {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log.apply(console, arguments)
|
||||
},
|
||||
printErr: function () {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error.apply(console, arguments)
|
||||
},
|
||||
})
|
||||
return instantiateNapiModuleSync(wasmModule, {
|
||||
childThread: true,
|
||||
wasi,
|
||||
overwriteImports(importObject) {
|
||||
importObject.env = {
|
||||
...importObject.env,
|
||||
...importObject.napi,
|
||||
...importObject.emnapi,
|
||||
...workerImports(opfs, memory),
|
||||
memory: wasmMemory,
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
globalThis.onmessage = async function (e) {
|
||||
if (e.data.__turso__ == 'register') {
|
||||
try {
|
||||
await opfs.registerFile(e.data.path);
|
||||
self.postMessage({ id: e.data.id });
|
||||
} catch (error) {
|
||||
self.postMessage({ id: e.data.id, error: error });
|
||||
}
|
||||
return;
|
||||
} else if (e.data.__turso__ == 'unregister') {
|
||||
try {
|
||||
await opfs.unregisterFile(e.data.path);
|
||||
self.postMessage({ id: e.data.id });
|
||||
} catch (error) {
|
||||
self.postMessage({ id: e.data.id, error: error });
|
||||
}
|
||||
return;
|
||||
}
|
||||
handler.handle(e)
|
||||
}
|
||||
2
bindings/javascript/packages/browser/worker.ts
Normal file
2
bindings/javascript/packages/browser/worker.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
import { setupWebWorker } from "@tursodatabase/database-browser-common";
|
||||
setupWebWorker();
|
||||
@@ -81,8 +81,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-android-arm64')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-android-arm64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -97,8 +97,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-android-arm-eabi')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-android-arm-eabi/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -117,8 +117,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-win32-x64-msvc')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-win32-x64-msvc/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -133,8 +133,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-win32-ia32-msvc')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-win32-ia32-msvc/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -149,8 +149,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-win32-arm64-msvc')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-win32-arm64-msvc/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -168,8 +168,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-darwin-universal')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-darwin-universal/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -184,8 +184,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-darwin-x64')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-darwin-x64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -200,8 +200,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-darwin-arm64')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-darwin-arm64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -220,8 +220,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-freebsd-x64')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-freebsd-x64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -236,8 +236,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-freebsd-arm64')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-freebsd-arm64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -257,8 +257,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-linux-x64-musl')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-linux-x64-musl/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -273,8 +273,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-linux-x64-gnu')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-linux-x64-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -291,8 +291,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-linux-arm64-musl')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-linux-arm64-musl/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -307,8 +307,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-linux-arm64-gnu')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-linux-arm64-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -325,8 +325,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-linux-arm-musleabihf')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-linux-arm-musleabihf/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -341,8 +341,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-linux-arm-gnueabihf')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-linux-arm-gnueabihf/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -359,8 +359,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-linux-riscv64-musl')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-linux-riscv64-musl/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -375,8 +375,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-linux-riscv64-gnu')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-linux-riscv64-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -392,8 +392,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-linux-ppc64-gnu')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-linux-ppc64-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -408,8 +408,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-linux-s390x-gnu')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-linux-s390x-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -428,8 +428,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-openharmony-arm64')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-openharmony-arm64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -444,8 +444,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-openharmony-x64')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-openharmony-x64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -460,8 +460,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/database-openharmony-arm')
|
||||
const bindingPackageVersion = require('@tursodatabase/database-openharmony-arm/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
|
||||
1
bindings/javascript/packages/wasm-runtime/.gitignore
vendored
Normal file
1
bindings/javascript/packages/wasm-runtime/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!dist
|
||||
44
bindings/javascript/packages/wasm-runtime/LICENSE
Normal file
44
bindings/javascript/packages/wasm-runtime/LICENSE
Normal file
@@ -0,0 +1,44 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-present LongYinan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
264
bindings/javascript/packages/wasm-runtime/dist/fs-proxy.cjs
vendored
Normal file
264
bindings/javascript/packages/wasm-runtime/dist/fs-proxy.cjs
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
'use strict';
|
||||
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* @param {unknown} value
|
||||
*/
|
||||
const getType = (value) => {
|
||||
if (value === undefined) return 0
|
||||
if (value === null) return 1
|
||||
const t = typeof value;
|
||||
if (t === 'boolean') return 2
|
||||
if (t === 'number') return 3
|
||||
if (t === 'string') return 4
|
||||
if (t === 'object') return 6
|
||||
if (t === 'bigint') return 9
|
||||
return -1
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {import('memfs').IFs} memfs
|
||||
* @param {any} value
|
||||
* @param {ReturnType<typeof getType>} type
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
const encodeValue = (memfs, value, type) => {
|
||||
switch (type) {
|
||||
case 0:
|
||||
case 1:
|
||||
return new Uint8Array(0)
|
||||
case 2: {
|
||||
const view = new Int32Array(1);
|
||||
view[0] = value ? 1 : 0;
|
||||
return new Uint8Array(view.buffer)
|
||||
}
|
||||
case 3: {
|
||||
const view = new Float64Array(1);
|
||||
view[0] = value;
|
||||
return new Uint8Array(view.buffer)
|
||||
}
|
||||
case 4: {
|
||||
const view = new TextEncoder().encode(value);
|
||||
return view
|
||||
}
|
||||
case 6: {
|
||||
function storeConstructor(obj, memfs, processed = new WeakSet()) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return
|
||||
}
|
||||
|
||||
if (processed.has(obj)) {
|
||||
return
|
||||
}
|
||||
|
||||
processed.add(obj);
|
||||
|
||||
const [entry] =
|
||||
Object.entries(memfs).filter(([_, v]) => v === obj.constructor)[0] ??
|
||||
[];
|
||||
if (entry) {
|
||||
Object.defineProperty(obj, '__constructor__', {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
value: entry,
|
||||
});
|
||||
}
|
||||
|
||||
for (const value of Object.values(obj)) {
|
||||
storeConstructor(value, memfs, processed);
|
||||
}
|
||||
}
|
||||
|
||||
storeConstructor(value, memfs);
|
||||
|
||||
const json = JSON.stringify(value, (_, value) => {
|
||||
if (typeof value === 'bigint') {
|
||||
return `BigInt(${String(value)})`
|
||||
}
|
||||
if (value instanceof Error) {
|
||||
return {
|
||||
...value,
|
||||
message: value.message,
|
||||
stack: value.stack,
|
||||
__error__: value.constructor.name,
|
||||
}
|
||||
}
|
||||
return value
|
||||
});
|
||||
const view = new TextEncoder().encode(json);
|
||||
return view
|
||||
}
|
||||
case 9: {
|
||||
const view = new BigInt64Array(1);
|
||||
view[0] = value;
|
||||
return new Uint8Array(view.buffer)
|
||||
}
|
||||
case -1:
|
||||
default:
|
||||
throw new Error('unsupported data')
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {typeof import('memfs')} memfs
|
||||
* @param {Uint8Array} payload
|
||||
* @param {number} type
|
||||
* @returns {any}
|
||||
*/
|
||||
const decodeValue = (memfs, payload, type) => {
|
||||
if (type === 0) return undefined
|
||||
if (type === 1) return null
|
||||
if (type === 2)
|
||||
return Boolean(new Int32Array(payload.buffer, payload.byteOffset, 1)[0])
|
||||
if (type === 3)
|
||||
return new Float64Array(payload.buffer, payload.byteOffset, 1)[0]
|
||||
if (type === 4) return new TextDecoder().decode(payload.slice())
|
||||
if (type === 6) {
|
||||
const obj = JSON.parse(
|
||||
new TextDecoder().decode(payload.slice()),
|
||||
(_key, value) => {
|
||||
if (typeof value === 'string') {
|
||||
const matched = value.match(/^BigInt\((-?\d+)\)$/);
|
||||
if (matched && matched[1]) {
|
||||
return BigInt(matched[1])
|
||||
}
|
||||
}
|
||||
return value
|
||||
},
|
||||
);
|
||||
|
||||
function loadConstructor(obj, memfs, processed = new WeakSet()) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return
|
||||
}
|
||||
|
||||
if (processed.has(obj)) {
|
||||
return
|
||||
}
|
||||
|
||||
processed.add(obj);
|
||||
|
||||
if (obj.__constructor__) {
|
||||
const ctor = obj.__constructor__;
|
||||
delete obj.__constructor__;
|
||||
Object.setPrototypeOf(obj, memfs[ctor].prototype);
|
||||
}
|
||||
|
||||
for (const value of Object.values(obj)) {
|
||||
loadConstructor(value, memfs, processed);
|
||||
}
|
||||
}
|
||||
|
||||
loadConstructor(obj, memfs);
|
||||
|
||||
if (obj.__error__) {
|
||||
const name = obj.__error__;
|
||||
const ErrorConstructor = globalThis[name] || Error;
|
||||
delete obj.__error__;
|
||||
const err = new ErrorConstructor(obj.message);
|
||||
Object.defineProperty(err, 'stack', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: err.stack,
|
||||
});
|
||||
Object.defineProperty(err, Symbol.toStringTag, {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: name,
|
||||
});
|
||||
for (const [k, v] of Object.entries(obj)) {
|
||||
if (k === 'message' || k === 'stack') continue
|
||||
err[k] = v;
|
||||
}
|
||||
return err
|
||||
}
|
||||
return obj
|
||||
}
|
||||
if (type === 9)
|
||||
return new BigInt64Array(payload.buffer, payload.byteOffset, 1)[0]
|
||||
throw new Error('unsupported data')
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {import('memfs').IFs} fs
|
||||
* @returns {(e: { data: { __fs__: { sab: Int32Array, type: keyof import('memfs').IFs, payload: any[] } } }) => void}
|
||||
*/
|
||||
// oxlint-disable-next-line no-unused-vars -- fixed in an upcoming release
|
||||
const createOnMessage = (fs) =>
|
||||
function onMessage(e) {
|
||||
if (e.data.__fs__) {
|
||||
/**
|
||||
* 0..4 status(int32_t): 21(waiting) 0(success) 1(error)
|
||||
* 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) -1(unsupported)
|
||||
* 9..16 payload_size(uint32_t) <= 1024
|
||||
* 16..16 + payload_size payload_content
|
||||
*/
|
||||
const { sab, type, payload } = e.data.__fs__;
|
||||
const fn = fs[type];
|
||||
try {
|
||||
const ret = fn.apply(fs, payload);
|
||||
const t = getType(ret);
|
||||
Atomics.store(sab, 1, t);
|
||||
const v = encodeValue(fs, ret, t);
|
||||
Atomics.store(sab, 2, v.length);
|
||||
new Uint8Array(sab.buffer).set(v, 16);
|
||||
Atomics.store(sab, 0, 0); // success
|
||||
} catch (/** @type {any} */ err) {
|
||||
const t = getType(err);
|
||||
Atomics.store(sab, 1, t);
|
||||
const v = encodeValue(fs, err, t);
|
||||
Atomics.store(sab, 2, v.length);
|
||||
new Uint8Array(sab.buffer).set(v, 16);
|
||||
Atomics.store(sab, 0, 1); // error
|
||||
} finally {
|
||||
Atomics.notify(sab, 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {typeof import('memfs')} memfs
|
||||
*/
|
||||
const createFsProxy = (memfs) =>
|
||||
new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_target, p, _receiver) {
|
||||
/**
|
||||
* @param {any[]} args
|
||||
*/
|
||||
return function (...args) {
|
||||
const sab = new SharedArrayBuffer(16 + 10240);
|
||||
const i32arr = new Int32Array(sab);
|
||||
Atomics.store(i32arr, 0, 21);
|
||||
|
||||
postMessage({
|
||||
__fs__: {
|
||||
sab: i32arr,
|
||||
type: p,
|
||||
payload: args,
|
||||
},
|
||||
});
|
||||
|
||||
Atomics.wait(i32arr, 0, 21);
|
||||
|
||||
const status = Atomics.load(i32arr, 0);
|
||||
const type = Atomics.load(i32arr, 1);
|
||||
const size = Atomics.load(i32arr, 2);
|
||||
const content = new Uint8Array(sab, 16, size);
|
||||
const value = decodeValue(memfs, content, type);
|
||||
if (status === 1) {
|
||||
throw value
|
||||
}
|
||||
return value
|
||||
}
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
exports.createFsProxy = createFsProxy;
|
||||
exports.createOnMessage = createOnMessage;
|
||||
24204
bindings/javascript/packages/wasm-runtime/dist/fs.js
vendored
Normal file
24204
bindings/javascript/packages/wasm-runtime/dist/fs.js
vendored
Normal file
File diff suppressed because one or more lines are too long
259
bindings/javascript/packages/wasm-runtime/fs-proxy.js
Normal file
259
bindings/javascript/packages/wasm-runtime/fs-proxy.js
Normal file
@@ -0,0 +1,259 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* @param {unknown} value
|
||||
*/
|
||||
const getType = (value) => {
|
||||
if (value === undefined) return 0
|
||||
if (value === null) return 1
|
||||
const t = typeof value
|
||||
if (t === 'boolean') return 2
|
||||
if (t === 'number') return 3
|
||||
if (t === 'string') return 4
|
||||
if (t === 'object') return 6
|
||||
if (t === 'bigint') return 9
|
||||
return -1
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('memfs').IFs} memfs
|
||||
* @param {any} value
|
||||
* @param {ReturnType<typeof getType>} type
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
const encodeValue = (memfs, value, type) => {
|
||||
switch (type) {
|
||||
case 0:
|
||||
case 1:
|
||||
return new Uint8Array(0)
|
||||
case 2: {
|
||||
const view = new Int32Array(1)
|
||||
view[0] = value ? 1 : 0
|
||||
return new Uint8Array(view.buffer)
|
||||
}
|
||||
case 3: {
|
||||
const view = new Float64Array(1)
|
||||
view[0] = value
|
||||
return new Uint8Array(view.buffer)
|
||||
}
|
||||
case 4: {
|
||||
const view = new TextEncoder().encode(value)
|
||||
return view
|
||||
}
|
||||
case 6: {
|
||||
function storeConstructor(obj, memfs, processed = new WeakSet()) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return
|
||||
}
|
||||
|
||||
if (processed.has(obj)) {
|
||||
return
|
||||
}
|
||||
|
||||
processed.add(obj)
|
||||
|
||||
const [entry] =
|
||||
Object.entries(memfs).filter(([_, v]) => v === obj.constructor)[0] ??
|
||||
[]
|
||||
if (entry) {
|
||||
Object.defineProperty(obj, '__constructor__', {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
value: entry,
|
||||
})
|
||||
}
|
||||
|
||||
for (const value of Object.values(obj)) {
|
||||
storeConstructor(value, memfs, processed)
|
||||
}
|
||||
}
|
||||
|
||||
storeConstructor(value, memfs)
|
||||
|
||||
const json = JSON.stringify(value, (_, value) => {
|
||||
if (typeof value === 'bigint') {
|
||||
return `BigInt(${String(value)})`
|
||||
}
|
||||
if (value instanceof Error) {
|
||||
return {
|
||||
...value,
|
||||
message: value.message,
|
||||
stack: value.stack,
|
||||
__error__: value.constructor.name,
|
||||
}
|
||||
}
|
||||
return value
|
||||
})
|
||||
const view = new TextEncoder().encode(json)
|
||||
return view
|
||||
}
|
||||
case 9: {
|
||||
const view = new BigInt64Array(1)
|
||||
view[0] = value
|
||||
return new Uint8Array(view.buffer)
|
||||
}
|
||||
case -1:
|
||||
default:
|
||||
throw new Error('unsupported data')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {typeof import('memfs')} memfs
|
||||
* @param {Uint8Array} payload
|
||||
* @param {number} type
|
||||
* @returns {any}
|
||||
*/
|
||||
const decodeValue = (memfs, payload, type) => {
|
||||
if (type === 0) return undefined
|
||||
if (type === 1) return null
|
||||
if (type === 2)
|
||||
return Boolean(new Int32Array(payload.buffer, payload.byteOffset, 1)[0])
|
||||
if (type === 3)
|
||||
return new Float64Array(payload.buffer, payload.byteOffset, 1)[0]
|
||||
if (type === 4) return new TextDecoder().decode(payload.slice())
|
||||
if (type === 6) {
|
||||
const obj = JSON.parse(
|
||||
new TextDecoder().decode(payload.slice()),
|
||||
(_key, value) => {
|
||||
if (typeof value === 'string') {
|
||||
const matched = value.match(/^BigInt\((-?\d+)\)$/)
|
||||
if (matched && matched[1]) {
|
||||
return BigInt(matched[1])
|
||||
}
|
||||
}
|
||||
return value
|
||||
},
|
||||
)
|
||||
|
||||
function loadConstructor(obj, memfs, processed = new WeakSet()) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return
|
||||
}
|
||||
|
||||
if (processed.has(obj)) {
|
||||
return
|
||||
}
|
||||
|
||||
processed.add(obj)
|
||||
|
||||
if (obj.__constructor__) {
|
||||
const ctor = obj.__constructor__
|
||||
delete obj.__constructor__
|
||||
Object.setPrototypeOf(obj, memfs[ctor].prototype)
|
||||
}
|
||||
|
||||
for (const value of Object.values(obj)) {
|
||||
loadConstructor(value, memfs, processed)
|
||||
}
|
||||
}
|
||||
|
||||
loadConstructor(obj, memfs)
|
||||
|
||||
if (obj.__error__) {
|
||||
const name = obj.__error__
|
||||
const ErrorConstructor = globalThis[name] || Error
|
||||
delete obj.__error__
|
||||
const err = new ErrorConstructor(obj.message)
|
||||
Object.defineProperty(err, 'stack', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: err.stack,
|
||||
})
|
||||
Object.defineProperty(err, Symbol.toStringTag, {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: name,
|
||||
})
|
||||
for (const [k, v] of Object.entries(obj)) {
|
||||
if (k === 'message' || k === 'stack') continue
|
||||
err[k] = v
|
||||
}
|
||||
return err
|
||||
}
|
||||
return obj
|
||||
}
|
||||
if (type === 9)
|
||||
return new BigInt64Array(payload.buffer, payload.byteOffset, 1)[0]
|
||||
throw new Error('unsupported data')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('memfs').IFs} fs
|
||||
* @returns {(e: { data: { __fs__: { sab: Int32Array, type: keyof import('memfs').IFs, payload: any[] } } }) => void}
|
||||
*/
|
||||
// oxlint-disable-next-line no-unused-vars -- fixed in an upcoming release
|
||||
export const createOnMessage = (fs) =>
|
||||
function onMessage(e) {
|
||||
if (e.data.__fs__) {
|
||||
/**
|
||||
* 0..4 status(int32_t): 21(waiting) 0(success) 1(error)
|
||||
* 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) -1(unsupported)
|
||||
* 9..16 payload_size(uint32_t) <= 1024
|
||||
* 16..16 + payload_size payload_content
|
||||
*/
|
||||
const { sab, type, payload } = e.data.__fs__
|
||||
const fn = fs[type]
|
||||
try {
|
||||
const ret = fn.apply(fs, payload)
|
||||
const t = getType(ret)
|
||||
Atomics.store(sab, 1, t)
|
||||
const v = encodeValue(fs, ret, t)
|
||||
Atomics.store(sab, 2, v.length)
|
||||
new Uint8Array(sab.buffer).set(v, 16)
|
||||
Atomics.store(sab, 0, 0) // success
|
||||
} catch (/** @type {any} */ err) {
|
||||
const t = getType(err)
|
||||
Atomics.store(sab, 1, t)
|
||||
const v = encodeValue(fs, err, t)
|
||||
Atomics.store(sab, 2, v.length)
|
||||
new Uint8Array(sab.buffer).set(v, 16)
|
||||
Atomics.store(sab, 0, 1) // error
|
||||
} finally {
|
||||
Atomics.notify(sab, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {typeof import('memfs')} memfs
|
||||
*/
|
||||
export const createFsProxy = (memfs) =>
|
||||
new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_target, p, _receiver) {
|
||||
/**
|
||||
* @param {any[]} args
|
||||
*/
|
||||
return function (...args) {
|
||||
const sab = new SharedArrayBuffer(16 + 10240)
|
||||
const i32arr = new Int32Array(sab)
|
||||
Atomics.store(i32arr, 0, 21)
|
||||
|
||||
postMessage({
|
||||
__fs__: {
|
||||
sab: i32arr,
|
||||
type: p,
|
||||
payload: args,
|
||||
},
|
||||
})
|
||||
|
||||
Atomics.wait(i32arr, 0, 21)
|
||||
|
||||
const status = Atomics.load(i32arr, 0)
|
||||
const type = Atomics.load(i32arr, 1)
|
||||
const size = Atomics.load(i32arr, 2)
|
||||
const content = new Uint8Array(sab, 16, size)
|
||||
const value = decodeValue(memfs, content, type)
|
||||
if (status === 1) {
|
||||
throw value
|
||||
}
|
||||
return value
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
46
bindings/javascript/packages/wasm-runtime/package.json
Normal file
46
bindings/javascript/packages/wasm-runtime/package.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "@tursodatabase/wasm-runtime",
|
||||
"version": "0.2.0-pre.1",
|
||||
"type": "module",
|
||||
"description": "Runtime and polyfill for wasm targets",
|
||||
"author": {
|
||||
"name": "LongYinan",
|
||||
"url": "https://github.com/Brooooooklyn"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/napi-rs/napi-rs.git",
|
||||
"directory": "wasi-runtime"
|
||||
},
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
"access": "public"
|
||||
},
|
||||
"files": [
|
||||
"runtime.cjs",
|
||||
"runtime.js",
|
||||
"fs-proxy.js",
|
||||
"dist/*.cjs",
|
||||
"dist/*.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@emnapi/core": "^1.4.5",
|
||||
"@emnapi/runtime": "^1.4.5",
|
||||
"@tybys/wasm-util": "^0.10.1"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "echo 'nothing to build'",
|
||||
"tsc-build": "echo 'nothing to tsc-build'",
|
||||
"test": "echo 'nothing to test'"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./runtime.js",
|
||||
"require": "./runtime.cjs"
|
||||
},
|
||||
"./fs": {
|
||||
"import": "./dist/fs.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
bindings/javascript/packages/wasm-runtime/runtime.cjs
Normal file
15
bindings/javascript/packages/wasm-runtime/runtime.cjs
Normal file
@@ -0,0 +1,15 @@
|
||||
const { MessageHandler, instantiateNapiModuleSync, instantiateNapiModule } = require('@emnapi/core')
|
||||
const { getDefaultContext } = require('@emnapi/runtime')
|
||||
const { WASI } = require('@tybys/wasm-util')
|
||||
|
||||
const { createFsProxy, createOnMessage } = require('./dist/fs-proxy.cjs')
|
||||
|
||||
module.exports = {
|
||||
MessageHandler,
|
||||
instantiateNapiModule,
|
||||
instantiateNapiModuleSync,
|
||||
getDefaultContext,
|
||||
WASI,
|
||||
createFsProxy,
|
||||
createOnMessage,
|
||||
}
|
||||
8
bindings/javascript/packages/wasm-runtime/runtime.js
Normal file
8
bindings/javascript/packages/wasm-runtime/runtime.js
Normal file
@@ -0,0 +1,8 @@
|
||||
export {
|
||||
instantiateNapiModuleSync,
|
||||
instantiateNapiModule,
|
||||
MessageHandler,
|
||||
} from '@emnapi/core'
|
||||
export { getDefaultContext } from '@emnapi/runtime'
|
||||
export * from '@tybys/wasm-util'
|
||||
export { createOnMessage, createFsProxy } from './fs-proxy.js'
|
||||
@@ -1,11 +1,48 @@
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/wasm-runtime/package.json
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/common/package.json
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/native/package.json
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/package.json
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser-common/package.json
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/common/package.json
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/native/package.json
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/package.json
|
||||
|
||||
sed -i "s/$VERSION_FROM/$VERSION_TO/g" packages/wasm-runtime/package.json
|
||||
sed -i "s/$VERSION_FROM/$VERSION_TO/g" packages/common/package.json
|
||||
sed -i "s/$VERSION_FROM/$VERSION_TO/g" packages/native/package.json
|
||||
sed -i "s/$VERSION_FROM/$VERSION_TO/g" packages/browser/package.json
|
||||
sed -i "s/$VERSION_FROM/$VERSION_TO/g" packages/browser-common/package.json
|
||||
sed -i "s/$VERSION_FROM/$VERSION_TO/g" sync/packages/common/package.json
|
||||
sed -i "s/$VERSION_FROM/$VERSION_TO/g" sync/packages/native/package.json
|
||||
sed -i "s/$VERSION_FROM/$VERSION_TO/g" sync/packages/browser/package.json
|
||||
|
||||
sed -i "s/$NAME_FROM\/database-common/$NAME_TO\/database-common/g" packages/native/promise.ts
|
||||
sed -i "s/$NAME_FROM\/database-common/$NAME_TO\/database-common/g" packages/native/compat.ts
|
||||
sed -i "s/$NAME_FROM\/database-common/$NAME_TO\/database-common/g" packages/browser/promise.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/native/promise.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/native/compat.ts
|
||||
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser-common/index.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/promise.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/promise-bundle.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/promise-default.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/promise-vite-dev-hack.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/promise-turbopack-hack.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/index-default.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/index-bundle.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/index-vite-dev-hack.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/index-turbopack-hack.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/browser/worker.ts
|
||||
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/native/promise.ts
|
||||
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/promise.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/promise-bundle.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/promise-default.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/promise-vite-dev-hack.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/promise-turbopack-hack.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/index-default.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/index-bundle.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/index-vite-dev-hack.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/index-turbopack-hack.ts
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" sync/packages/browser/worker.ts
|
||||
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/wasm-runtime/runtime.cjs
|
||||
sed -i "s/$NAME_FROM/$NAME_TO/g" packages/wasm-runtime/runtime.js
|
||||
|
||||
8
bindings/javascript/scripts/inline-wasm-base64.js
Normal file
8
bindings/javascript/scripts/inline-wasm-base64.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
|
||||
const data = readFileSync(process.env.WASM_FILE);
|
||||
const b64 = data.toString("base64");
|
||||
const dataUrl = "data:application/wasm;base64," + b64;
|
||||
const inlined = readFileSync(process.env.JS_FILE).toString("utf8");
|
||||
const replaced = inlined.replace("__PLACEHOLDER__", dataUrl);
|
||||
writeFileSync(process.env.JS_FILE, replaced);
|
||||
33
bindings/javascript/sync/packages/browser/index-bundle.ts
Normal file
33
bindings/javascript/sync/packages/browser/index-bundle.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { setupMainThread } from "@tursodatabase/database-browser-common";
|
||||
//@ts-ignore
|
||||
import TursoWorker from "./worker.js?worker&inline";
|
||||
|
||||
export let MainWorker = null;
|
||||
|
||||
const __wasmUrl = new URL('./sync.wasm32-wasi.wasm', import.meta.url).href;
|
||||
const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
|
||||
|
||||
const napiModule = await setupMainThread(__wasmFile, () => {
|
||||
const worker = new TursoWorker({
|
||||
name: 'turso-database-sync',
|
||||
type: 'module',
|
||||
})
|
||||
MainWorker = worker;
|
||||
return worker
|
||||
});
|
||||
|
||||
export default napiModule.exports
|
||||
export const Database = napiModule.exports.Database
|
||||
export const Statement = napiModule.exports.Statement
|
||||
export const Opfs = napiModule.exports.Opfs
|
||||
export const OpfsFile = napiModule.exports.OpfsFile
|
||||
export const connect = napiModule.exports.connect
|
||||
export const initThreadPool = napiModule.exports.initThreadPool
|
||||
export const GeneratorHolder = napiModule.exports.GeneratorHolder
|
||||
export const JsDataCompletion = napiModule.exports.JsDataCompletion
|
||||
export const JsProtocolIo = napiModule.exports.JsProtocolIo
|
||||
export const JsProtocolRequestBytes = napiModule.exports.JsProtocolRequestBytes
|
||||
export const SyncEngine = napiModule.exports.SyncEngine
|
||||
export const DatabaseChangeTypeJs = napiModule.exports.DatabaseChangeTypeJs
|
||||
export const SyncEngineProtocolVersion = napiModule.exports.SyncEngineProtocolVersion
|
||||
|
||||
31
bindings/javascript/sync/packages/browser/index-default.ts
Normal file
31
bindings/javascript/sync/packages/browser/index-default.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { isWebWorker, setupWebWorker, setupMainThread } from "@tursodatabase/database-browser-common";
|
||||
|
||||
export let MainWorker = null;
|
||||
|
||||
const __wasmUrl = new URL('./sync.wasm32-wasi.wasm', import.meta.url).href;
|
||||
const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
|
||||
|
||||
const napiModule = await setupMainThread(__wasmFile, () => {
|
||||
const worker = new Worker(new URL('./worker.js', import.meta.url), {
|
||||
name: 'turso-database-sync',
|
||||
type: 'module',
|
||||
})
|
||||
MainWorker = worker;
|
||||
return worker
|
||||
});
|
||||
|
||||
export default napiModule.exports
|
||||
export const Database = napiModule.exports.Database
|
||||
export const Statement = napiModule.exports.Statement
|
||||
export const Opfs = napiModule.exports.Opfs
|
||||
export const OpfsFile = napiModule.exports.OpfsFile
|
||||
export const connect = napiModule.exports.connect
|
||||
export const initThreadPool = napiModule.exports.initThreadPool
|
||||
export const GeneratorHolder = napiModule.exports.GeneratorHolder
|
||||
export const JsDataCompletion = napiModule.exports.JsDataCompletion
|
||||
export const JsProtocolIo = napiModule.exports.JsProtocolIo
|
||||
export const JsProtocolRequestBytes = napiModule.exports.JsProtocolRequestBytes
|
||||
export const SyncEngine = napiModule.exports.SyncEngine
|
||||
export const DatabaseChangeTypeJs = napiModule.exports.DatabaseChangeTypeJs
|
||||
export const SyncEngineProtocolVersion = napiModule.exports.SyncEngineProtocolVersion
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { setupMainThread } from "@tursodatabase/database-browser-common";
|
||||
import { tursoWasm } from "./wasm-inline.js";
|
||||
|
||||
// Next (turbopack) has issues with loading wasm module: https://github.com/vercel/next.js/issues/82520
|
||||
// So, we inline wasm binary in the source code in order to avoid issues with loading it from the file
|
||||
const __wasmFile = await tursoWasm();
|
||||
|
||||
export let MainWorker = null;
|
||||
|
||||
const napiModule = await setupMainThread(__wasmFile, () => {
|
||||
const worker = new Worker(new URL('./worker.js', import.meta.url), {
|
||||
name: 'turso-database-sync',
|
||||
type: 'module',
|
||||
})
|
||||
MainWorker = worker;
|
||||
return worker
|
||||
});
|
||||
|
||||
export default napiModule.exports
|
||||
export const Database = napiModule.exports.Database
|
||||
export const Statement = napiModule.exports.Statement
|
||||
export const Opfs = napiModule.exports.Opfs
|
||||
export const OpfsFile = napiModule.exports.OpfsFile
|
||||
export const connect = napiModule.exports.connect
|
||||
export const initThreadPool = napiModule.exports.initThreadPool
|
||||
export const GeneratorHolder = napiModule.exports.GeneratorHolder
|
||||
export const JsDataCompletion = napiModule.exports.JsDataCompletion
|
||||
export const JsProtocolIo = napiModule.exports.JsProtocolIo
|
||||
export const JsProtocolRequestBytes = napiModule.exports.JsProtocolRequestBytes
|
||||
export const SyncEngine = napiModule.exports.SyncEngine
|
||||
export const DatabaseChangeTypeJs = napiModule.exports.DatabaseChangeTypeJs
|
||||
export const SyncEngineProtocolVersion = napiModule.exports.SyncEngineProtocolVersion
|
||||
@@ -0,0 +1,56 @@
|
||||
import { isWebWorker, setupMainThread, setupWebWorker } from "@tursodatabase/database-browser-common";
|
||||
import { tursoWasm } from "./wasm-inline.js";
|
||||
|
||||
let napiModule = {
|
||||
exports: {
|
||||
Database: {} as any,
|
||||
Opfs: {} as any,
|
||||
OpfsFile: {} as any,
|
||||
Statement: {} as any,
|
||||
connect: {} as any,
|
||||
initThreadPool: {} as any,
|
||||
GeneratorHolder: {} as any,
|
||||
JsDataCompletion: {} as any,
|
||||
JsProtocolIo: {} as any,
|
||||
JsProtocolRequestBytes: {} as any,
|
||||
SyncEngine: {} as any,
|
||||
DatabaseChangeTypeJs: {} as any,
|
||||
SyncEngineProtocolVersion: {} as any,
|
||||
}
|
||||
};
|
||||
|
||||
export let MainWorker = null;
|
||||
if (isWebWorker()) {
|
||||
setupWebWorker();
|
||||
} else {
|
||||
// Vite has issues with loading wasm modules and worker in dev server: https://github.com/vitejs/vite/issues/8427
|
||||
// So, the mitigation for dev server only is:
|
||||
// 1. inline wasm binary in the source code in order to avoid issues with loading it from the file
|
||||
// 2. use same file as worker entry point
|
||||
const __wasmFile = await tursoWasm();
|
||||
|
||||
napiModule = await setupMainThread(__wasmFile, () => {
|
||||
const worker = new Worker(import.meta.url, {
|
||||
name: 'turso-database-sync',
|
||||
type: 'module',
|
||||
})
|
||||
MainWorker = worker;
|
||||
return worker
|
||||
});
|
||||
}
|
||||
|
||||
export default napiModule.exports
|
||||
export const Database = napiModule.exports.Database
|
||||
export const Statement = napiModule.exports.Statement
|
||||
export const Opfs = napiModule.exports.Opfs
|
||||
export const OpfsFile = napiModule.exports.OpfsFile
|
||||
export const connect = napiModule.exports.connect
|
||||
export const initThreadPool = napiModule.exports.initThreadPool
|
||||
export const GeneratorHolder = napiModule.exports.GeneratorHolder
|
||||
export const JsDataCompletion = napiModule.exports.JsDataCompletion
|
||||
export const JsProtocolIo = napiModule.exports.JsProtocolIo
|
||||
export const JsProtocolRequestBytes = napiModule.exports.JsProtocolRequestBytes
|
||||
export const SyncEngine = napiModule.exports.SyncEngine
|
||||
export const DatabaseChangeTypeJs = napiModule.exports.DatabaseChangeTypeJs
|
||||
export const SyncEngineProtocolVersion = napiModule.exports.SyncEngineProtocolVersion
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
import {
|
||||
createOnMessage as __wasmCreateOnMessageForFsProxy,
|
||||
getDefaultContext as __emnapiGetDefaultContext,
|
||||
instantiateNapiModule as __emnapiInstantiateNapiModule,
|
||||
WASI as __WASI,
|
||||
} from '@napi-rs/wasm-runtime'
|
||||
|
||||
import { MainDummyImports } from "@tursodatabase/database-browser-common";
|
||||
|
||||
|
||||
const __wasi = new __WASI({
|
||||
version: 'preview1',
|
||||
})
|
||||
|
||||
const __wasmUrl = new URL('./sync.wasm32-wasi.wasm', import.meta.url).href
|
||||
const __emnapiContext = __emnapiGetDefaultContext()
|
||||
|
||||
|
||||
const __sharedMemory = new WebAssembly.Memory({
|
||||
initial: 4000,
|
||||
maximum: 65536,
|
||||
shared: true,
|
||||
})
|
||||
|
||||
const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
|
||||
|
||||
export let MainWorker = null;
|
||||
|
||||
const {
|
||||
instance: __napiInstance,
|
||||
module: __wasiModule,
|
||||
napiModule: __napiModule,
|
||||
} = await __emnapiInstantiateNapiModule(__wasmFile, {
|
||||
context: __emnapiContext,
|
||||
asyncWorkPoolSize: 1,
|
||||
wasi: __wasi,
|
||||
onCreateWorker() {
|
||||
const worker = new Worker(new URL('./worker.mjs', import.meta.url), {
|
||||
type: 'module',
|
||||
})
|
||||
MainWorker = worker;
|
||||
return worker
|
||||
},
|
||||
overwriteImports(importObject) {
|
||||
importObject.env = {
|
||||
...importObject.env,
|
||||
...importObject.napi,
|
||||
...importObject.emnapi,
|
||||
...MainDummyImports,
|
||||
memory: __sharedMemory,
|
||||
}
|
||||
return importObject
|
||||
},
|
||||
beforeInit({ instance }) {
|
||||
for (const name of Object.keys(instance.exports)) {
|
||||
if (name.startsWith('__napi_register__')) {
|
||||
instance.exports[name]()
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
export default __napiModule.exports
|
||||
export const Database = __napiModule.exports.Database
|
||||
export const Statement = __napiModule.exports.Statement
|
||||
export const Opfs = __napiModule.exports.Opfs
|
||||
export const OpfsFile = __napiModule.exports.OpfsFile
|
||||
export const connect = __napiModule.exports.connect
|
||||
export const initThreadPool = __napiModule.exports.initThreadPool
|
||||
export const GeneratorHolder = __napiModule.exports.GeneratorHolder
|
||||
export const JsDataCompletion = __napiModule.exports.JsDataCompletion
|
||||
export const JsProtocolIo = __napiModule.exports.JsProtocolIo
|
||||
export const JsProtocolRequestBytes = __napiModule.exports.JsProtocolRequestBytes
|
||||
export const SyncEngine = __napiModule.exports.SyncEngine
|
||||
export const DatabaseChangeTypeJs = __napiModule.exports.DatabaseChangeTypeJs
|
||||
export const SyncEngineProtocolVersion = __napiModule.exports.SyncEngineProtocolVersion
|
||||
|
||||
@@ -10,22 +10,37 @@
|
||||
"main": "dist/promise.js",
|
||||
"packageManager": "yarn@4.9.2",
|
||||
"files": [
|
||||
"index.js",
|
||||
"worker.mjs",
|
||||
"sync.wasm32-wasi.wasm",
|
||||
"dist/**",
|
||||
"bundle/**",
|
||||
"README.md"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/promise-default.js"
|
||||
},
|
||||
"./bundle": {
|
||||
"default": "./bundle/main.es.js"
|
||||
},
|
||||
"./vite": {
|
||||
"development": "./dist/promise-vite-dev-hack.js",
|
||||
"default": "./dist/promise-default.js"
|
||||
},
|
||||
"./turbopack": {
|
||||
"default": "./dist/promise-turbopack-hack.js"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "^3.1.5",
|
||||
"@vitest/browser": "^3.2.4",
|
||||
"playwright": "^1.55.0",
|
||||
"typescript": "^5.9.2",
|
||||
"vite": "^7.1.5",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"scripts": {
|
||||
"napi-build": "napi build --features browser --release --platform --target wasm32-wasip1-threads --no-js --manifest-path ../../Cargo.toml --output-dir . && rm index.d.ts sync.wasi* wasi* browser.js",
|
||||
"tsc-build": "npm exec tsc",
|
||||
"tsc-build": "npm exec tsc && cp sync.wasm32-wasi.wasm ./dist/sync.wasm32-wasi.wasm && WASM_FILE=sync.wasm32-wasi.wasm JS_FILE=./dist/wasm-inline.js node ../../../scripts/inline-wasm-base64.js && npm run bundle",
|
||||
"bundle": "vite build",
|
||||
"build": "npm run napi-build && npm run tsc-build",
|
||||
"test": "VITE_TURSO_DB_URL=http://b--a--a.localhost:10000 CI=1 vitest --browser=chromium --run && VITE_TURSO_DB_URL=http://b--a--a.localhost:10000 CI=1 vitest --browser=firefox --run"
|
||||
},
|
||||
@@ -39,7 +54,6 @@
|
||||
"#index": "./index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@napi-rs/wasm-runtime": "^1.0.3",
|
||||
"@tursodatabase/database-browser-common": "^0.2.0-pre.1",
|
||||
"@tursodatabase/database-common": "^0.2.0-pre.1",
|
||||
"@tursodatabase/sync-common": "^0.2.0-pre.1"
|
||||
|
||||
23
bindings/javascript/sync/packages/browser/promise-bundle.ts
Normal file
23
bindings/javascript/sync/packages/browser/promise-bundle.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { SyncOpts, DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult } from "@tursodatabase/sync-common";
|
||||
import { connect as promiseConnect, Database } from "./promise.js";
|
||||
import { SyncEngine, initThreadPool, MainWorker } from "./index-bundle.js";
|
||||
|
||||
/**
|
||||
* Creates a new database connection asynchronously.
|
||||
*
|
||||
* @param {string} path - Path to the database file.
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(opts: SyncOpts): Promise<Database> {
|
||||
return await promiseConnect(opts, x => new SyncEngine(x), async () => {
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not initialized");
|
||||
}
|
||||
return MainWorker;
|
||||
});
|
||||
}
|
||||
|
||||
export { connect, Database, }
|
||||
export type { DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult }
|
||||
23
bindings/javascript/sync/packages/browser/promise-default.ts
Normal file
23
bindings/javascript/sync/packages/browser/promise-default.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { SyncOpts, DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult } from "@tursodatabase/sync-common";
|
||||
import { connect as promiseConnect, Database } from "./promise.js";
|
||||
import { SyncEngine, initThreadPool, MainWorker } from "./index-default.js";
|
||||
|
||||
/**
|
||||
* Creates a new database connection asynchronously.
|
||||
*
|
||||
* @param {string} path - Path to the database file.
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(opts: SyncOpts): Promise<Database> {
|
||||
return await promiseConnect(opts, x => new SyncEngine(x), async () => {
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not initialized");
|
||||
}
|
||||
return MainWorker;
|
||||
});
|
||||
}
|
||||
|
||||
export { connect, Database, }
|
||||
export type { DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult }
|
||||
@@ -0,0 +1,23 @@
|
||||
import { SyncOpts, DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult } from "@tursodatabase/sync-common";
|
||||
import { connect as promiseConnect, Database } from "./promise.js";
|
||||
import { SyncEngine, initThreadPool, MainWorker } from "./index-turbopack-hack.js";
|
||||
|
||||
/**
|
||||
* Creates a new database connection asynchronously.
|
||||
*
|
||||
* @param {string} path - Path to the database file.
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(opts: SyncOpts): Promise<Database> {
|
||||
return await promiseConnect(opts, x => new SyncEngine(x), async () => {
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not initialized");
|
||||
}
|
||||
return MainWorker;
|
||||
});
|
||||
}
|
||||
|
||||
export { connect, Database, }
|
||||
export type { DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult }
|
||||
@@ -0,0 +1,23 @@
|
||||
import { SyncOpts, DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult } from "@tursodatabase/sync-common";
|
||||
import { connect as promiseConnect, Database } from "./promise.js";
|
||||
import { SyncEngine, initThreadPool, MainWorker } from "./index-vite-dev-hack.js";
|
||||
|
||||
/**
|
||||
* Creates a new database connection asynchronously.
|
||||
*
|
||||
* @param {string} path - Path to the database file.
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(opts: SyncOpts): Promise<Database> {
|
||||
return await promiseConnect(opts, x => new SyncEngine(x), async () => {
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not initialized");
|
||||
}
|
||||
return MainWorker;
|
||||
});
|
||||
}
|
||||
|
||||
export { connect, Database, }
|
||||
export type { DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult }
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from 'vitest'
|
||||
import { connect, DatabaseRowMutation, DatabaseRowTransformResult } from './promise.js'
|
||||
import { connect, DatabaseRowMutation, DatabaseRowTransformResult } from './promise-default.js'
|
||||
|
||||
const localeCompare = (a, b) => a.x.localeCompare(b.x);
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { registerFileAtWorker, unregisterFileAtWorker } from "@tursodatabase/database-browser-common"
|
||||
import { DatabasePromise, DatabaseOpts, NativeDatabase } from "@tursodatabase/database-common"
|
||||
import { ProtocolIo, run, SyncOpts, RunOpts, DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult, memoryIO } from "@tursodatabase/sync-common";
|
||||
import { connect as nativeConnect, initThreadPool, MainWorker } from "#index";
|
||||
import { Database as NativeDB, SyncEngine } from "#index";
|
||||
import { ProtocolIo, run, SyncOpts, RunOpts, memoryIO } from "@tursodatabase/sync-common";
|
||||
|
||||
let BrowserIo: ProtocolIo = {
|
||||
async read(path: string): Promise<Buffer | Uint8Array | null> {
|
||||
@@ -24,13 +22,15 @@ class Database extends DatabasePromise {
|
||||
runOpts: RunOpts;
|
||||
engine: any;
|
||||
io: ProtocolIo;
|
||||
worker: Worker | null;
|
||||
fsPath: string | null;
|
||||
constructor(db: NativeDatabase, io: ProtocolIo, runOpts: RunOpts, engine: any, fsPath: string | null, opts: DatabaseOpts = {}) {
|
||||
constructor(db: NativeDatabase, io: ProtocolIo, worker: Worker | null, runOpts: RunOpts, engine: any, fsPath: string | null, opts: DatabaseOpts = {}) {
|
||||
super(db, opts)
|
||||
this.io = io;
|
||||
this.worker = worker;
|
||||
this.runOpts = runOpts;
|
||||
this.engine = engine;
|
||||
this.fsPath = fsPath;
|
||||
this.io = io;
|
||||
}
|
||||
async sync() {
|
||||
await run(this.runOpts, this.io, this.engine, this.engine.sync());
|
||||
@@ -50,13 +50,13 @@ class Database extends DatabasePromise {
|
||||
override async close(): Promise<void> {
|
||||
this.db.close();
|
||||
this.engine.close();
|
||||
if (this.fsPath != null) {
|
||||
if (this.fsPath != null && this.worker != null) {
|
||||
await Promise.all([
|
||||
unregisterFileAtWorker(MainWorker, this.fsPath),
|
||||
unregisterFileAtWorker(MainWorker, `${this.fsPath}-wal`),
|
||||
unregisterFileAtWorker(MainWorker, `${this.fsPath}-revert`),
|
||||
unregisterFileAtWorker(MainWorker, `${this.fsPath}-info`),
|
||||
unregisterFileAtWorker(MainWorker, `${this.fsPath}-changes`),
|
||||
unregisterFileAtWorker(this.worker, this.fsPath),
|
||||
unregisterFileAtWorker(this.worker, `${this.fsPath}-wal`),
|
||||
unregisterFileAtWorker(this.worker, `${this.fsPath}-revert`),
|
||||
unregisterFileAtWorker(this.worker, `${this.fsPath}-info`),
|
||||
unregisterFileAtWorker(this.worker, `${this.fsPath}-changes`),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -69,8 +69,8 @@ class Database extends DatabasePromise {
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(opts: SyncOpts): Promise<Database> {
|
||||
const engine = new SyncEngine({
|
||||
async function connect(opts: SyncOpts, connect: (any) => any, init: () => Promise<Worker>): Promise<Database> {
|
||||
const engine = connect({
|
||||
path: opts.path,
|
||||
clientName: opts.clientName,
|
||||
tablesIgnore: opts.tablesIgnore,
|
||||
@@ -90,24 +90,19 @@ async function connect(opts: SyncOpts): Promise<Database> {
|
||||
const isMemory = opts.path == ':memory:';
|
||||
let io = isMemory ? memoryIO() : BrowserIo;
|
||||
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not set");
|
||||
}
|
||||
const worker = await init();
|
||||
if (!isMemory) {
|
||||
await Promise.all([
|
||||
registerFileAtWorker(MainWorker, opts.path),
|
||||
registerFileAtWorker(MainWorker, `${opts.path}-wal`),
|
||||
registerFileAtWorker(MainWorker, `${opts.path}-revert`),
|
||||
registerFileAtWorker(MainWorker, `${opts.path}-info`),
|
||||
registerFileAtWorker(MainWorker, `${opts.path}-changes`),
|
||||
registerFileAtWorker(worker, opts.path),
|
||||
registerFileAtWorker(worker, `${opts.path}-wal`),
|
||||
registerFileAtWorker(worker, `${opts.path}-revert`),
|
||||
registerFileAtWorker(worker, `${opts.path}-info`),
|
||||
registerFileAtWorker(worker, `${opts.path}-changes`),
|
||||
]);
|
||||
}
|
||||
await run(runOpts, io, engine, engine.init());
|
||||
|
||||
const nativeDb = engine.open();
|
||||
return new Database(nativeDb as any, io, runOpts, engine, isMemory ? null : opts.path, {});
|
||||
return new Database(nativeDb as any, io, worker, runOpts, engine, isMemory ? null : opts.path, {});
|
||||
}
|
||||
|
||||
export { connect, Database, }
|
||||
export type { DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult }
|
||||
export { connect, Database }
|
||||
|
||||
19
bindings/javascript/sync/packages/browser/vite.config.js
Normal file
19
bindings/javascript/sync/packages/browser/vite.config.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { resolve } from 'path';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
base: './',
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'promise-bundle.ts'),
|
||||
name: 'sync-browser',
|
||||
fileName: format => `main.${format}.js`,
|
||||
formats: ['es'],
|
||||
},
|
||||
rollupOptions: {
|
||||
output: {
|
||||
dir: 'bundle',
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
9
bindings/javascript/sync/packages/browser/wasm-inline.ts
Normal file
9
bindings/javascript/sync/packages/browser/wasm-inline.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
const tursoWasmBase64 = '__PLACEHOLDER__';
|
||||
async function convertBase64ToBinary(base64Url: string): Promise<ArrayBuffer> {
|
||||
const blob = await fetch(base64Url).then(res => res.blob());
|
||||
return await blob.arrayBuffer();
|
||||
}
|
||||
|
||||
export async function tursoWasm(): Promise<ArrayBuffer> {
|
||||
return await convertBase64ToBinary(tursoWasmBase64);
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
|
||||
import { OpfsDirectory, workerImports } from "@tursodatabase/database-browser-common";
|
||||
|
||||
var opfs = new OpfsDirectory();
|
||||
var memory = null;
|
||||
|
||||
const handler = new MessageHandler({
|
||||
onLoad({ wasmModule, wasmMemory }) {
|
||||
memory = wasmMemory;
|
||||
const wasi = new WASI({
|
||||
print: function () {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log.apply(console, arguments)
|
||||
},
|
||||
printErr: function () {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error.apply(console, arguments)
|
||||
},
|
||||
})
|
||||
return instantiateNapiModuleSync(wasmModule, {
|
||||
childThread: true,
|
||||
wasi,
|
||||
overwriteImports(importObject) {
|
||||
importObject.env = {
|
||||
...importObject.env,
|
||||
...importObject.napi,
|
||||
...importObject.emnapi,
|
||||
...workerImports(opfs, memory),
|
||||
memory: wasmMemory,
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
globalThis.onmessage = async function (e) {
|
||||
if (e.data.__turso__ == 'register') {
|
||||
try {
|
||||
await opfs.registerFile(e.data.path);
|
||||
self.postMessage({ id: e.data.id });
|
||||
} catch (error) {
|
||||
self.postMessage({ id: e.data.id, error: error });
|
||||
}
|
||||
return;
|
||||
} else if (e.data.__turso__ == 'unregister') {
|
||||
try {
|
||||
await opfs.unregisterFile(e.data.path);
|
||||
self.postMessage({ id: e.data.id });
|
||||
} catch (error) {
|
||||
self.postMessage({ id: e.data.id, error: error });
|
||||
}
|
||||
return;
|
||||
}
|
||||
handler.handle(e)
|
||||
}
|
||||
2
bindings/javascript/sync/packages/browser/worker.ts
Normal file
2
bindings/javascript/sync/packages/browser/worker.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
import { setupWebWorker } from "@tursodatabase/database-browser-common";
|
||||
setupWebWorker();
|
||||
@@ -81,8 +81,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-android-arm64')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-android-arm64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -97,8 +97,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-android-arm-eabi')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-android-arm-eabi/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -117,8 +117,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-win32-x64-msvc')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-win32-x64-msvc/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -133,8 +133,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-win32-ia32-msvc')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-win32-ia32-msvc/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -149,8 +149,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-win32-arm64-msvc')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-win32-arm64-msvc/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -168,8 +168,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-darwin-universal')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-darwin-universal/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -184,8 +184,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-darwin-x64')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-darwin-x64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -200,8 +200,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-darwin-arm64')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-darwin-arm64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -220,8 +220,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-freebsd-x64')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-freebsd-x64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -236,8 +236,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-freebsd-arm64')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-freebsd-arm64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -257,8 +257,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-linux-x64-musl')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-linux-x64-musl/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -273,8 +273,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-linux-x64-gnu')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-linux-x64-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -291,8 +291,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-linux-arm64-musl')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-linux-arm64-musl/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -307,8 +307,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-linux-arm64-gnu')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-linux-arm64-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -325,8 +325,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-linux-arm-musleabihf')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-linux-arm-musleabihf/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -341,8 +341,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-linux-arm-gnueabihf')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-linux-arm-gnueabihf/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -359,8 +359,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-linux-riscv64-musl')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-linux-riscv64-musl/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -375,8 +375,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-linux-riscv64-gnu')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-linux-riscv64-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -392,8 +392,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-linux-ppc64-gnu')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-linux-ppc64-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -408,8 +408,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-linux-s390x-gnu')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-linux-s390x-gnu/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -428,8 +428,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-openharmony-arm64')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-openharmony-arm64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -444,8 +444,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-openharmony-x64')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-openharmony-x64/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
@@ -460,8 +460,8 @@ function requireNative() {
|
||||
try {
|
||||
const binding = require('@tursodatabase/sync-openharmony-arm')
|
||||
const bindingPackageVersion = require('@tursodatabase/sync-openharmony-arm/package.json').version
|
||||
if (bindingPackageVersion !== '0.1.5' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
if (bindingPackageVersion !== '0.2.0-pre.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
||||
throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
||||
}
|
||||
return binding
|
||||
} catch (e) {
|
||||
|
||||
@@ -910,7 +910,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@napi-rs/wasm-runtime@npm:^1.0.1, @napi-rs/wasm-runtime@npm:^1.0.3":
|
||||
"@napi-rs/wasm-runtime@npm:^1.0.1":
|
||||
version: 1.0.3
|
||||
resolution: "@napi-rs/wasm-runtime@npm:1.0.3"
|
||||
dependencies:
|
||||
@@ -1398,6 +1398,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@tursodatabase/database-browser-common@workspace:packages/browser-common"
|
||||
dependencies:
|
||||
"@tursodatabase/wasm-runtime": "npm:^0.2.0-pre.1"
|
||||
typescript: "npm:^5.9.2"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@@ -1407,12 +1408,12 @@ __metadata:
|
||||
resolution: "@tursodatabase/database-browser@workspace:packages/browser"
|
||||
dependencies:
|
||||
"@napi-rs/cli": "npm:^3.1.5"
|
||||
"@napi-rs/wasm-runtime": "npm:^1.0.3"
|
||||
"@tursodatabase/database-browser-common": "npm:^0.2.0-pre.1"
|
||||
"@tursodatabase/database-common": "npm:^0.2.0-pre.1"
|
||||
"@vitest/browser": "npm:^3.2.4"
|
||||
playwright: "npm:^1.55.0"
|
||||
typescript: "npm:^5.9.2"
|
||||
vite: "npm:^7.1.5"
|
||||
vitest: "npm:^3.2.4"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@@ -1442,13 +1443,13 @@ __metadata:
|
||||
resolution: "@tursodatabase/sync-browser@workspace:sync/packages/browser"
|
||||
dependencies:
|
||||
"@napi-rs/cli": "npm:^3.1.5"
|
||||
"@napi-rs/wasm-runtime": "npm:^1.0.3"
|
||||
"@tursodatabase/database-browser-common": "npm:^0.2.0-pre.1"
|
||||
"@tursodatabase/database-common": "npm:^0.2.0-pre.1"
|
||||
"@tursodatabase/sync-common": "npm:^0.2.0-pre.1"
|
||||
"@vitest/browser": "npm:^3.2.4"
|
||||
playwright: "npm:^1.55.0"
|
||||
typescript: "npm:^5.9.2"
|
||||
vite: "npm:^7.1.5"
|
||||
vitest: "npm:^3.2.4"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@@ -1474,12 +1475,22 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@tybys/wasm-util@npm:^0.10.0":
|
||||
version: 0.10.0
|
||||
resolution: "@tybys/wasm-util@npm:0.10.0"
|
||||
"@tursodatabase/wasm-runtime@npm:^0.2.0-pre.1, @tursodatabase/wasm-runtime@workspace:packages/wasm-runtime":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@tursodatabase/wasm-runtime@workspace:packages/wasm-runtime"
|
||||
dependencies:
|
||||
"@emnapi/core": "npm:^1.4.5"
|
||||
"@emnapi/runtime": "npm:^1.4.5"
|
||||
"@tybys/wasm-util": "npm:^0.10.1"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@tybys/wasm-util@npm:^0.10.0, @tybys/wasm-util@npm:^0.10.1":
|
||||
version: 0.10.1
|
||||
resolution: "@tybys/wasm-util@npm:0.10.1"
|
||||
dependencies:
|
||||
tslib: "npm:^2.4.0"
|
||||
checksum: 10c0/044feba55c1e2af703aa4946139969badb183ce1a659a75ed60bc195a90e73a3f3fc53bcd643497c9954597763ddb051fec62f80962b2ca6fc716ba897dc696e
|
||||
checksum: 10c0/b255094f293794c6d2289300c5fbcafbb5532a3aed3a5ffd2f8dc1828e639b88d75f6a376dd8f94347a44813fd7a7149d8463477a9a49525c8b2dcaa38c2d1e8
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -3118,7 +3129,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"vite@npm:^5.0.0 || ^6.0.0 || ^7.0.0-0":
|
||||
"vite@npm:^5.0.0 || ^6.0.0 || ^7.0.0-0, vite@npm:^7.1.5":
|
||||
version: 7.1.5
|
||||
resolution: "vite@npm:7.1.5"
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user