| 17 | const EDGE_LIB = path.resolve(__dirname, '../netlify/edge-functions/qrcode-lib.js'); |
| 18 | |
| 19 | function extractLibraryCode(filePath) { |
| 20 | const content = fs.readFileSync(filePath, 'utf-8').replace(/\r\n/g, '\n'); |
| 21 | // 提取 'use strict'; 和 export 之间的库代码 |
| 22 | const lines = content.split('\n'); |
| 23 | const libLines = lines.filter(line => |
| 24 | line !== "'use strict';" && |
| 25 | !line.startsWith('// ') && |
| 26 | !line.startsWith('/**') && |
| 27 | !line.startsWith(' * ') && |
| 28 | !line.startsWith(' */') && |
| 29 | line !== '' && |
| 30 | !line.startsWith('export ') |
| 31 | ); |
| 32 | return libLines.join('\n'); |
| 33 | } |
| 34 | |
| 35 | const browserLib = extractLibraryCode(BROWSER_LIB); |
| 36 | const edgeLib = extractLibraryCode(EDGE_LIB); |