consolidation

This commit is contained in:
overcuriousity
2025-07-25 12:48:06 +02:00
parent b7fea4f31f
commit bd7f93167c
5 changed files with 32 additions and 56 deletions

View File

@@ -1,5 +1,6 @@
/**
* Tool utility functions for consistent tool operations across the app
* CONSOLIDATED Tool utility functions for consistent tool operations across the app
* Works in both server (Node.js) and client (browser) environments
*/
export interface Tool {
@@ -65,4 +66,26 @@ export function getToolCategory(tool: Tool): 'concept' | 'method' | 'hosted' | '
if (isToolHosted(tool)) return 'hosted';
if (tool.license && tool.license !== 'Proprietary') return 'oss';
return 'proprietary';
}
// BROWSER COMPATIBILITY LAYER
// Only assign to window if we're in a browser environment
if (typeof window !== 'undefined') {
// Make functions available globally for existing code compatibility
window.createToolSlug = createToolSlug;
window.findToolByIdentifier = findToolByIdentifier;
window.isToolHosted = isToolHosted;
console.log('[toolHelpers] Consolidated tool utilities loaded and assigned to window');
}
// LEGACY NODE.JS COMPATIBILITY
// Support for older require() patterns if needed
if (typeof module !== 'undefined' && module.exports) {
module.exports = {
createToolSlug,
findToolByIdentifier,
isToolHosted,
getToolCategory
};
}