forked from mdaines/viz-js
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: #1
- Loading branch information
Showing
12 changed files
with
150 additions
and
40 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ node_modules/ | |
debug/ | ||
|
||
dist/ | ||
/sync/ | ||
/wasm | ||
/worker | ||
|
||
|
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
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
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 @@ | ||
import type { WebAssemblyModule } from "./render"; | ||
|
||
export default function (): WebAssemblyModule; |
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 @@ | ||
// Dummy file for tsc |
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,29 @@ | ||
import type { RenderOptions } from "./types"; | ||
import type { WebAssemblyModule } from "./render"; | ||
|
||
export default function render( | ||
Module: WebAssemblyModule, | ||
src: string, | ||
options: RenderOptions | ||
): string { | ||
for (const { path, data } of options.files) { | ||
Module.vizCreateFile(path, data); | ||
} | ||
|
||
Module.vizSetY_invert(options.yInvert ? 1 : 0); | ||
Module.vizSetNop(options.nop || 0); | ||
|
||
const resultString = Module.vizRenderFromString( | ||
src, | ||
options.format, | ||
options.engine | ||
); | ||
|
||
const errorMessageString = Module.vizLastErrorMessage(); | ||
|
||
if (errorMessageString !== "") { | ||
throw new Error(errorMessageString); | ||
} | ||
|
||
return resultString; | ||
} |
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,23 @@ | ||
import Module from "./asm.mjs"; | ||
import render from "./renderFunction.js"; | ||
|
||
import type { RenderOptions } from "./types"; | ||
|
||
let asmModule; | ||
export default function renderStringSync( | ||
src: string, | ||
options?: RenderOptions | ||
): string { | ||
if (asmModule == null) { | ||
asmModule = Module(); | ||
} | ||
return render(asmModule, src, { | ||
format: "svg", | ||
engine: "dot", | ||
files: [], | ||
images: [], | ||
yInvert: false, | ||
nop: 0, | ||
...(options || {}), | ||
}); | ||
} |
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
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