**feat(tests): add tests for TextEncoder, TensorFlow.js, and fallback mechanisms**

- Introduced `test-fallback-function.js` and `test-fallback-simple.js` to validate `executeInThread` fallback functionality with both named and anonymous compute-intensive functions.
- Added `test-tensorflow-textencoder.js` for TensorFlow.js and TextEncoder tests in a Node.js environment.
- Created `test-tensorflow-textencoder.html` for browser-based TensorFlow.js and TextEncoder tests.
- Implemented cross-environment test support in `cli-package/src/test-tensorflow-textencoder.ts` for CLI functionality.
- Enhanced `src/utils/embedding.ts`, `textEncoding.ts`, and `brainy-wrapper.js` to include updated global `TextEncoder` and `TextDecoder` utilities for compatibility and worker improvements.
- Standardized and expanded utility methods in `PlatformNode` for broader support, including `isFloat32Array` and `isTypedArray` checks.
- Updated Node.js requirement to `>= 24.4.0` across documentation and configuration files for compatibility improvements.

This update introduces comprehensive testing for fallback mechanisms, TensorFlow.js, and TextEncoder across multiple environments, ensuring robustness and compatibility.
This commit is contained in:
David Snelling 2025-07-11 11:11:56 -07:00
parent 04a33b9ae8
commit 5f267b14ed
30 changed files with 1799 additions and 1583 deletions

View file

@ -22,14 +22,22 @@
"./types/augmentations": {
"import": "./dist/types/augmentations.js",
"types": "./dist/types/augmentations.d.ts"
},
"./utils/textEncoding": {
"import": "./dist/utils/textEncoding.js",
"types": "./dist/utils/textEncoding.d.ts"
},
"./dist/utils/textEncoding.js": {
"import": "./dist/utils/textEncoding.js",
"types": "./dist/utils/textEncoding.d.ts"
}
},
"engines": {
"node": ">=24.3.0"
"node": ">=24.4.0"
},
"scripts": {
"prebuild": "node scripts/generate-version.js",
"build": "BUILD_TYPE=unified rollup -c rollup.config.js && node scripts/patch-textencoder.js",
"build": "BUILD_TYPE=unified rollup -c rollup.config.js",
"build:browser": "BUILD_TYPE=browser rollup -c rollup.config.js",
"build:cli": "cd cli-package && npm run build",
"start": "node dist/unified.js",
@ -53,7 +61,9 @@
"postinstall": "echo 'Note: If you encounter dependency conflicts with TensorFlow.js packages, please use: npm install --legacy-peer-deps'",
"dry-run": "npm pack --dry-run",
"test:cli": "node scripts/test-cli-locally.js",
"test:all": "node scripts/test-all-environments.js"
"test:tensorflow": "node test-tensorflow-textencoder.js",
"test:all": "node scripts/test-all-environments.js",
"test": "npm run test:all"
},
"keywords": [
"vector-database",