Skip to content

Commit

Permalink
add starbase embed
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Oct 8, 2024
1 parent 1ade4b8 commit 2f09465
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/app/(theme)/embed/starbase/page-client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use client";
import { Studio } from "@/components/gui/studio";
import { IframeSQLiteDriver } from "@/drivers/iframe-driver";
import { useSearchParams } from "next/navigation";
import { useEffect, useMemo } from "react";

export default function EmbedPageClient() {
const searchParams = useSearchParams();
const driver = useMemo(
() => new IframeSQLiteDriver({ supportPragmaList: false }),
[]
);

useEffect(() => {
return driver.listen();
}, [driver]);

return (
<Studio
driver={driver}
name={searchParams.get("name") || "Unnamed Connection"}
color={searchParams.get("color") || "blue"}
/>
);
}
10 changes: 10 additions & 0 deletions src/app/(theme)/embed/starbase/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import ThemeLayout from "../../theme_layout";
import EmbedPageClient from "./page-client";

export default async function EmbedPage() {
return (
<ThemeLayout overrideTheme={"dark"} disableToggle={true}>
<EmbedPageClient />
</ThemeLayout>
);
}
7 changes: 7 additions & 0 deletions src/drivers/iframe-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ class IframeConnection {
export class IframeSQLiteDriver extends SqliteLikeBaseDriver {
protected conn = new IframeConnection();

constructor(options?: { supportPragmaList: boolean }) {
super();
if (options?.supportPragmaList) {
this.supportPragmaList = true;
}
}

listen() {
this.conn.listen();
}
Expand Down

0 comments on commit 2f09465

Please sign in to comment.