@@ -5,23 +5,24 @@ import { fileURLToPath } from "url";
55import nacl from "tweetnacl" ;
66import bip39 from "bip39" ;
77
8+ import indexHtml from "./index.html" with { type : "text" } ;
9+ import logoSvg from "./assets/logo.svg" with { type : "text" } ;
10+ import foundersGroteskFontPath from "./assets/founders-grotesk-bold.woff2" with { type : "file" } ;
11+ import nationalFontPath from "./assets/national-regular.woff2" with { type : "file" } ;
12+
813// ESM equivalent of __dirname
914const __filename : string = fileURLToPath ( import . meta. url ) ;
1015const __dirname : string = path . dirname ( __filename ) ;
1116
1217// Embed static assets for executable builds
13- let indexHtml : string = "" ;
14- let logoSvg : string = "" ;
1518let foundersGroteskFont : ArrayBuffer ;
1619let nationalFont : ArrayBuffer ;
1720
1821// Load assets asynchronously
1922async function loadAssets ( ) {
2023 try {
21- indexHtml = await Bun . file ( "index.html" ) . text ( ) ;
22- logoSvg = await Bun . file ( "assets/logo.svg" ) . text ( ) ;
23- foundersGroteskFont = await Bun . file ( "assets/founders-grotesk-bold.woff2" ) . arrayBuffer ( ) ;
24- nationalFont = await Bun . file ( "assets/national-regular.woff2" ) . arrayBuffer ( ) ;
24+ foundersGroteskFont = await Bun . file ( foundersGroteskFontPath ) . arrayBuffer ( ) ;
25+ nationalFont = await Bun . file ( nationalFontPath ) . arrayBuffer ( ) ;
2526 } catch ( error ) {
2627 console . warn ( "Could not load embedded assets:" , error . message ) ;
2728 // Assets will be served from filesystem instead
@@ -231,13 +232,13 @@ function deriveForNetwork(
231232 const coinType : number = networkType === 0 ? 0 : networkType ;
232233
233234 const basePath : number [ ] = [
234- 0x80000000 | 345 , // Purpose
235- 0x80000000 | coinType , // Coin type
236- 0x80000000 | network , // Network
235+ 0x80000000 + 345 , // Purpose
236+ 0x80000000 + coinType , // Coin type
237+ 0x80000000 + network , // Network
237238 ] ;
238239
239- const contractPath : number [ ] = [ 0x80000000 | contract , 0x80000000 | account ] ;
240- const optionalPath : number [ ] = [ 0x80000000 | token , 0x80000000 | subnet ] ;
240+ const contractPath : number [ ] = [ 0x80000000 + contract , 0x80000000 + account ] ;
241+ const optionalPath : number [ ] = [ 0x80000000 + token , 0x80000000 + subnet ] ;
241242 const finalPath : number [ ] = [ index ] ;
242243
243244 const fullPath : number [ ] = [
@@ -609,41 +610,38 @@ function serveEmbeddedAsset(pathname: string): Response | null {
609610 } ) ;
610611 }
611612 break ;
612-
613+
613614 case '/assets/logo.svg' :
614- case '/logo.svg' :
615615 if ( logoSvg ) {
616616 return new Response ( logoSvg , {
617617 headers : { 'Content-Type' : 'image/svg+xml' }
618618 } ) ;
619619 }
620620 break ;
621-
621+
622622 case '/assets/founders-grotesk-bold.woff2' :
623- case '/founders-grotesk-bold.woff2' :
624623 if ( foundersGroteskFont ) {
625624 return new Response ( foundersGroteskFont , {
626- headers : {
625+ headers : {
627626 'Content-Type' : 'font/woff2' ,
628627 'Cache-Control' : 'public, max-age=31536000'
629628 }
630629 } ) ;
631630 }
632631 break ;
633-
632+
634633 case '/assets/national-regular.woff2' :
635- case '/national-regular.woff2' :
636634 if ( nationalFont ) {
637635 return new Response ( nationalFont , {
638- headers : {
636+ headers : {
639637 'Content-Type' : 'font/woff2' ,
640638 'Cache-Control' : 'public, max-age=31536000'
641639 }
642640 } ) ;
643641 }
644642 break ;
645643 }
646-
644+
647645 return null ;
648646}
649647
0 commit comments