-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
374a814
commit cf6cf4f
Showing
13 changed files
with
3,052 additions
and
2,251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
/build*/ | ||
out | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.sb-main-fullscreen #storybook-root { | ||
height: 100svh; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import wasmBinaryUrl from "cxx-frontend/dist/cxx-js.wasm?url"; | ||
import { Parser } from "cxx-frontend"; | ||
|
||
export class CxxFrontendClient { | ||
async load(signal?: AbortSignal) { | ||
const response = await fetch(wasmBinaryUrl, { signal }); | ||
if (!response.ok) throw new Error("failed to load cxx-js.wasm"); | ||
if (signal?.aborted) throw new Error("aborted"); | ||
const data = await response.arrayBuffer(); | ||
const wasmBinary = new Uint8Array(data); | ||
await Parser.init({ wasmBinary }); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from "react"; | ||
import { CxxFrontendClient } from "./CxxFrontendClient"; | ||
|
||
interface CxxFrontendProviderProps { | ||
client: CxxFrontendClient; | ||
fallback?: React.ReactNode; | ||
children: React.ReactNode; | ||
} | ||
|
||
export function CxxFrontendProvider({ | ||
client, | ||
fallback, | ||
children, | ||
}: CxxFrontendProviderProps) { | ||
const [isLoaded, setIsLoaded] = React.useState(false); | ||
|
||
React.useEffect(() => { | ||
if (isLoaded) return; | ||
setIsLoaded(false); | ||
const controller = new AbortController(); | ||
client.load(controller.signal).then(() => setIsLoaded(true)); | ||
return () => controller.abort(); | ||
}, [client, isLoaded]); | ||
|
||
return isLoaded ? <>{children}</> : fallback; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.