@@ -3,7 +3,9 @@ import { base64ToBytes, bytesToBase64 } from "./bytesToBase64"
3
3
4
4
export function getCompressedBase64SnippetString ( text : string ) {
5
5
// 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
+ } )
7
9
8
10
// Convert to base64
9
11
const base64Data = bytesToBase64 ( compressedData )
@@ -12,7 +14,7 @@ export function getCompressedBase64SnippetString(text: string) {
12
14
}
13
15
14
16
export function getBase64PoundSnippetString ( text : string ) {
15
- const base64Data = getCompressedBase64SnippetString ( text )
17
+ const base64Data = getCompressedBase64SnippetString ( text . trim ( ) )
16
18
return `#data:application/gzip;base64,${ base64Data } `
17
19
}
18
20
@@ -33,6 +35,22 @@ export function createSvgUrl(
33
35
return `https://svg.tscircuit.com/?svg_type=${ svgType } &code=${ encodeURIComponent ( base64Data ) } `
34
36
}
35
37
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
+
36
54
export function createSnippetUrl ( text : string , snippet_type ?: string ) : string {
37
55
// Construct the URL
38
56
const typeParam = snippet_type ? `&snippet_type=${ snippet_type } ` : ""
0 commit comments