fix: correct SUPPORTED_LANGUAGES import in translate-modal.js
This commit is contained in:
parent
aa62dacb8e
commit
996069a9d9
2 changed files with 70 additions and 2 deletions
|
|
@ -2,8 +2,7 @@
|
|||
import { initializeChunkFiveFont } from "./ui-themes.js";
|
||||
import { getUIText } from "./ui-translations.js";
|
||||
import { extractWebpageContent } from "./content.js";
|
||||
import { handleTranslation } from "./translation.js";
|
||||
import { SUPPORTED_LANGUAGES } from "./languages/index.js";
|
||||
import { translateCurrentPage, translateText, SUPPORTED_LANGUAGES } from "./translation.js";
|
||||
|
||||
// Get USE_CUSTOM_STYLING from window or default
|
||||
const USE_CUSTOM_STYLING = window.UNCLOSEAI_CUSTOM_STYLING !== false;
|
||||
|
|
|
|||
69
validate_exports.js
Normal file
69
validate_exports.js
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
// Quick validation script to check if imports match exports
|
||||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const srcDir = './src';
|
||||
|
||||
async function validateExports() {
|
||||
const files = await fs.readdir(srcDir);
|
||||
const jsFiles = files.filter(f => f.endsWith('.js'));
|
||||
|
||||
console.log('🔍 Validating exports/imports...\n');
|
||||
|
||||
const exportMap = new Map();
|
||||
const importMap = new Map();
|
||||
|
||||
// Extract exports and imports
|
||||
for (const file of jsFiles) {
|
||||
const content = await fs.readFile(path.join(srcDir, file), 'utf-8');
|
||||
|
||||
// Extract exports
|
||||
const exportMatches = content.match(/export\s+(?:async\s+)?(?:function|const|let|var|class)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g);
|
||||
if (exportMatches) {
|
||||
const exports = exportMatches.map(match => {
|
||||
const parts = match.split(/\s+/);
|
||||
return parts[parts.length - 1];
|
||||
});
|
||||
exportMap.set(file, exports);
|
||||
}
|
||||
|
||||
// Extract imports
|
||||
const importMatches = content.match(/import\s+{([^}]+)}\s+from\s+["']\.\/([^"']+)["']/g);
|
||||
if (importMatches) {
|
||||
importMatches.forEach(match => {
|
||||
const parts = match.match(/import\s+{([^}]+)}\s+from\s+["']\.\/([^"']+)["']/);
|
||||
if (parts) {
|
||||
const imports = parts[1].split(',').map(s => s.trim());
|
||||
const fromFile = parts[2];
|
||||
if (!importMap.has(file)) importMap.set(file, []);
|
||||
importMap.get(file).push({ imports, fromFile });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Validate
|
||||
let errors = 0;
|
||||
for (const [file, importData] of importMap) {
|
||||
for (const { imports, fromFile } of importData) {
|
||||
const targetFile = fromFile.endsWith('.js') ? fromFile : fromFile + '.js';
|
||||
const exports = exportMap.get(targetFile) || [];
|
||||
|
||||
for (const importName of imports) {
|
||||
if (!exports.includes(importName)) {
|
||||
console.log(`❌ ${file}: imports '${importName}' from ${targetFile}, but it's not exported`);
|
||||
console.log(` Available exports: ${exports.join(', ') || 'none'}`);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errors === 0) {
|
||||
console.log('✅ All imports match their exports!');
|
||||
} else {
|
||||
console.log(`\n💥 Found ${errors} import/export mismatches`);
|
||||
}
|
||||
}
|
||||
|
||||
validateExports().catch(console.error);
|
||||
Loading…
Add table
Add a link
Reference in a new issue