Skip to content

Commit 6cc4094

Browse files
authored
Merge pull request #3 from sysdevrun/claude/github-actions-deploy-01Ndqm3jHvw6xyDbq5K6uDuv
fix: Load sql.js WASM from CDN to fix WebAssembly error
2 parents 3a45c00 + 01d20de commit 6cc4094

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

package-lock.json

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@types/node": "^24.10.1",
2727
"@types/react": "^19.2.0",
2828
"@types/react-dom": "^19.2.3",
29+
"@types/sql.js": "^1.4.9",
2930
"@vitejs/plugin-react": "^5.1.1",
3031
"autoprefixer": "^10.4.22",
3132
"eslint": "^9.39.1",

src/workers/gtfs.worker.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import * as Comlink from 'comlink';
2+
import initSqlJs from 'sql.js';
3+
import type { SqlJsStatic } from 'sql.js';
24
import { GtfsSqlJs } from 'gtfs-sqljs';
35
import type {
46
Stop,
@@ -26,6 +28,18 @@ interface ProgressInfo {
2628
}
2729

2830
let gtfsInstance: GtfsSqlJs | null = null;
31+
let sqlInstance: SqlJsStatic | null = null;
32+
33+
// Initialize SQL.js with CDN WASM file
34+
async function getSql(): Promise<SqlJsStatic> {
35+
if (!sqlInstance) {
36+
sqlInstance = await initSqlJs({
37+
locateFile: (file: string) =>
38+
`https://sql.js.org/dist/${file}`,
39+
});
40+
}
41+
return sqlInstance;
42+
}
2943

3044
const gtfsApi = {
3145
async initialize(
@@ -38,8 +52,12 @@ const gtfsApi = {
3852
gtfsInstance = null;
3953
}
4054

55+
// Get SQL.js instance (loads WASM from CDN)
56+
const SQL = await getSql();
57+
4158
gtfsInstance = await GtfsSqlJs.fromZip(url, {
4259
onProgress: Comlink.proxy(onProgress),
60+
SQL,
4361
});
4462
},
4563

0 commit comments

Comments
 (0)