brainy/src/browserFramework.ts
David Snelling 52a43d51d4 refactor: simplify build system and improve model loading flexibility
- Remove Rollup bundling in favor of direct TypeScript compilation
- Move from bundled models to dynamic model loading with configurable paths
- Add Docker deployment examples and documentation
- Implement robust model loader with fallback mechanisms
- Update storage adapters for better cross-environment compatibility
- Add comprehensive tests for model loading and package installation
- Simplify package.json scripts and remove complex build configurations
- Clean up deprecated demo files and old bundling scripts

BREAKING CHANGE: Models are no longer bundled with the package. They are now loaded dynamically from CDN or custom paths.
2025-08-05 16:09:30 -07:00

37 lines
No EOL
1.2 KiB
TypeScript

/**
* Browser Framework Entry Point for Brainy
* Optimized for modern frameworks like Angular, React, Vue, etc.
* Auto-detects environment and uses optimal storage (OPFS in browsers)
*/
import { BrainyData, BrainyDataConfig } from './brainyData.js'
import { VerbType, NounType } from './types/graphTypes.js'
/**
* Create a BrainyData instance optimized for browser frameworks
* Auto-detects environment and selects optimal storage and settings
*/
export async function createBrowserBrainyData(config: Partial<BrainyDataConfig> = {}): Promise<BrainyData> {
// BrainyData already has environment detection and will automatically:
// - Use OPFS storage in browsers with fallback to Memory
// - Use FileSystem storage in Node.js
// - Request persistent storage when appropriate
const browserConfig: BrainyDataConfig = {
storage: {
requestPersistentStorage: true // Request persistent storage for better performance
},
...config
}
const brainyData = new BrainyData(browserConfig)
await brainyData.init()
return brainyData
}
// Re-export types and constants for framework use
export { VerbType, NounType, BrainyData }
export type { BrainyDataConfig }
// Default export for easy importing
export default createBrowserBrainyData