feat: add universal adapters for browser compatibility
- Create universal adapters for cross-platform support (browser/Node/serverless) - Replace Node.js-specific imports with universal implementations - Add OPFS support for browser persistent storage - Maintain same BrainyData interface across all environments - Enable real Brainy usage in browser console UI - Keep package size optimized (no bloat) Universal adapters in /src/universal/: - uuid.ts: Cross-platform UUID generation - crypto.ts: Browser/Node crypto operations - fs.ts: OPFS/FileSystem/Memory storage adapter - path.ts: Universal path operations - events.ts: EventEmitter compatibility layer This enables 'write once, run anywhere' for Brainy while maintaining the exact same API. No breaking changes to existing code.
This commit is contained in:
parent
6e8869ecb7
commit
93804be354
31 changed files with 2120 additions and 2028 deletions
28
src/universal/index.ts
Normal file
28
src/universal/index.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Universal adapters for cross-environment compatibility
|
||||
* Provides consistent APIs across Browser, Node.js, and Serverless environments
|
||||
*/
|
||||
|
||||
// UUID adapter
|
||||
export * from './uuid.js'
|
||||
export { default as uuid } from './uuid.js'
|
||||
|
||||
// Crypto adapter
|
||||
export * from './crypto.js'
|
||||
export { default as crypto } from './crypto.js'
|
||||
|
||||
// File system adapter
|
||||
export * from './fs.js'
|
||||
export { default as fs } from './fs.js'
|
||||
|
||||
// Path adapter
|
||||
export * from './path.js'
|
||||
export { default as path } from './path.js'
|
||||
|
||||
// Events adapter
|
||||
export * from './events.js'
|
||||
export { default as events } from './events.js'
|
||||
|
||||
// Convenience re-exports for common patterns
|
||||
export { v4 as uuidv4 } from './uuid.js'
|
||||
export { EventEmitter } from './events.js'
|
||||
Loading…
Add table
Add a link
Reference in a new issue