**feat(patch): enhance TextEncoder/TextDecoder compatibility for TensorFlow.js**
- Refactored `applyTensorFlowPatch` in `textEncoding.ts` to introduce a unified `Platform` class supporting both Node.js and browser environments with native `TextEncoder`/`TextDecoder`. - Modified global object handling to target `PlatformNode` in Node.js and `PlatformBrowser` in browser environments. - Added `getTextEncoder` and `getTextDecoder` utility functions to simplify text encoding/decoding across platforms. - Introduced `setup.ts` to apply environment patches before other modules load. - Updated CLI entry points (`cli.ts`, `rollup.config.js`) to ensure patching precedes TensorFlow.js usage. - Enhanced test coverage for TextEncoder compatibility with `test-fix.js`. - Adjusted imports in `test-tensorflow-textencoder.ts` to align with the updated `./utils/textEncoding.js`. - Streamlined constructor definitions in `Platform` for improved maintainability. This update ensures robust compatibility for TensorFlow.js by patching and standardizing text encoding/decoding functionality across environments.
This commit is contained in:
parent
f0db5b471f
commit
bcd75b4b61
7 changed files with 142 additions and 84 deletions
|
|
@ -5,6 +5,11 @@
|
|||
* A command-line interface for interacting with the Brainy vector database
|
||||
*/
|
||||
|
||||
// Import the setup file for its side-effects.
|
||||
// This MUST be the very first import to ensure patches are applied
|
||||
// before any other module (like TensorFlow.js) is loaded.
|
||||
import './setup.js'
|
||||
|
||||
// Log environment information
|
||||
console.log('Brainy running in Node.js environment')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue