Buckets:
| /** | |
| * Converts the built gradio-widget.html file to a TypeScript constant | |
| * Usage: node scripts/html-to-ts.js | |
| */ | |
| import { readFileSync, writeFileSync } from 'fs'; | |
| import { fileURLToPath } from 'url'; | |
| import { dirname, join } from 'path'; | |
| const __filename = fileURLToPath(import.meta.url); | |
| const __dirname = dirname(__filename); | |
| // Paths | |
| const htmlPath = join(__dirname, '../dist/web/gradio-widget.html'); | |
| const outputPath = join(__dirname, '../src/server/resources/gradio-widget-content.ts'); | |
| try { | |
| // Read the HTML file | |
| const htmlContent = readFileSync(htmlPath, 'utf-8'); | |
| // Escape backticks and ${} in the HTML content | |
| const escapedContent = htmlContent | |
| .replace(/\\/g, '\\\\') | |
| .replace(/`/g, '\\`') | |
| .replace(/\$/g, '\\$'); | |
| // Generate TypeScript file content | |
| const tsContent = `/** | |
| * Auto-generated file - DO NOT EDIT | |
| * Generated from dist/web/gradio-widget.html | |
| * Run 'pnpm run build:gradio-widget' to regenerate | |
| */ | |
| export const GRADIO_WIDGET_HTML = \`${escapedContent}\`; | |
| `; | |
| // Write the TypeScript file | |
| writeFileSync(outputPath, tsContent, 'utf-8'); | |
| console.log(`✓ Generated ${outputPath}`); | |
| console.log(` HTML size: ${htmlContent.length.toLocaleString()} bytes`); | |
| } catch (error) { | |
| console.error('Failed to convert HTML to TypeScript:', error); | |
| process.exit(1); | |
| } | |
Xet Storage Details
- Size:
- 1.33 kB
- Xet hash:
- 5973927b8bfe63251fa7ddd338bc7b9ac065225b0780cea2f6c9f643013e1b95
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.