Skip to content

Commit

Permalink
Revert "refactor: lazy load surrealdb.wasm"
Browse files Browse the repository at this point in the history
This reverts commit 72515de.
  • Loading branch information
macjuul committed Jul 11, 2024
1 parent 12f5fbd commit 8f72b02
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/screens/database/connection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import posthog from "posthog-js";
import { surrealdbWasmEngines } from 'surrealdb.wasm';
import { Surreal, QueryResult, ScopeAuth, UUID, decodeCbor, VersionRetrievalFailure, UnsupportedVersion } from 'surrealdb.js';
import { AuthDetails, ConnectionOptions, Protocol, QueryResponse } from '~/types';
import { useDatabaseStore } from '~/stores/database';
Expand All @@ -23,7 +24,7 @@ export interface UserQueryOptions {
override?: string;
}

let instance = new Surreal();
let instance = createSurreal();

const LQ_SUPPORTED = new Set<Protocol>(['ws', 'wss', 'mem', 'indxdb']);
const LIVE_QUERIES = new Map<string, Set<UUID>>();
Expand All @@ -42,7 +43,7 @@ export async function openConnection(options?: ConnectOptions) {
}

await closeConnection();
instance = await createSurreal();
instance = createSurreal();

const { setIsConnected, setIsConnecting, setVersion } = useDatabaseStore.getState();
const rpcEndpoint = connectionUri(connection);
Expand Down Expand Up @@ -369,9 +370,7 @@ export function composeAuthentication(connection: ConnectionOptions): AuthDetail
}
}

async function createSurreal() {
const { surrealdbWasmEngines } = await import("surrealdb.wasm");

function createSurreal() {
const surreal = new Surreal({
engines: surrealdbWasmEngines() as any
});
Expand Down

0 comments on commit 8f72b02

Please sign in to comment.