@@ -3,7 +3,9 @@ import { base64ToBytes, bytesToBase64 } from "./bytesToBase64"
33
44export function getCompressedBase64SnippetString ( text : string ) {
55 // Compress the input string
6- const compressedData = gzipSync ( strToU8 ( text ) )
6+ const compressedData = gzipSync ( strToU8 ( text . trim ( ) ) , {
7+ mtime : 1739063707691 , // Date.now() when i wrote this line, ensures consistent output
8+ } )
79
810 // Convert to base64
911 const base64Data = bytesToBase64 ( compressedData )
@@ -12,7 +14,7 @@ export function getCompressedBase64SnippetString(text: string) {
1214}
1315
1416export function getBase64PoundSnippetString ( text : string ) {
15- const base64Data = getCompressedBase64SnippetString ( text )
17+ const base64Data = getCompressedBase64SnippetString ( text . trim ( ) )
1618 return `#data:application/gzip;base64,${ base64Data } `
1719}
1820
@@ -33,6 +35,22 @@ export function createSvgUrl(
3335 return `https://svg.tscircuit.com/?svg_type=${ svgType } &code=${ encodeURIComponent ( base64Data ) } `
3436}
3537
38+ export function createBrowserPreviewUrl (
39+ tscircuitCode : string ,
40+ view ?: "pcb" | "schematic" | "3d" ,
41+ ) {
42+ const base64Data = getCompressedBase64SnippetString ( tscircuitCode )
43+ return `https://browser-preview.tscircuit.com/?view=${ view } &code=${ encodeURIComponent ( base64Data ) } `
44+ }
45+
46+ export function createPngUrl (
47+ tscircuitCode : string ,
48+ view : "pcb" | "schematic" | "3d" ,
49+ ) {
50+ const base64Data = getCompressedBase64SnippetString ( tscircuitCode )
51+ return `https://png.tscircuit.com/?view=${ view } &code=${ encodeURIComponent ( base64Data ) } `
52+ }
53+
3654export function createSnippetUrl ( text : string , snippet_type ?: string ) : string {
3755 // Construct the URL
3856 const typeParam = snippet_type ? `&snippet_type=${ snippet_type } ` : ""
0 commit comments