**chore(deps): update dependencies and Node.js version requirements**
- Updated Node.js version requirement to `>=24.3.0` in `README.md` and `package-lock.json`. - Upgraded `TypeScript` to version `5.4.5` and synced references. - Updated multiple dependencies, including: - `@aws-sdk/client-s3` to `^3.540.0`. - `uuid` to `^9.0.1`. - Development tools such as `eslint` to `^8.57.0`, `typescript-eslint` plugins to `^7.4.0`, and more. - Refreshed transitive dependencies with up-to-date versions for consistency and performance. This update ensures compatibility with the latest Node.js features, aligns TypeScript references, and keeps the project dependencies up-to-date for improved stability and functionality.
This commit is contained in:
parent
be59d0c633
commit
cc3350c578
8 changed files with 593 additions and 788 deletions
|
|
@ -3,8 +3,8 @@
|
|||
<br/><br/>
|
||||
|
||||
[](LICENSE)
|
||||
[](https://nodejs.org/)
|
||||
[](https://www.typescriptlang.org/)
|
||||
[](https://nodejs.org/)
|
||||
[](https://www.typescriptlang.org/)
|
||||
[](CONTRIBUTING.md)
|
||||
[](https://www.npmjs.com/package/@soulcraft/brainy)
|
||||
|
||||
|
|
|
|||
12
cli-package/package-lock.json
generated
12
cli-package/package-lock.json
generated
|
|
@ -1,16 +1,16 @@
|
|||
{
|
||||
"name": "@soulcraft/brainy-cli",
|
||||
"version": "0.9.30",
|
||||
"version": "0.9.34",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@soulcraft/brainy-cli",
|
||||
"version": "0.9.30",
|
||||
"version": "0.9.34",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@soulcraft/brainy": "0.9.30",
|
||||
"@soulcraft/brainy": "0.9.34",
|
||||
"commander": "^14.0.0",
|
||||
"omelette": "^0.4.17"
|
||||
},
|
||||
|
|
@ -2086,9 +2086,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@soulcraft/brainy": {
|
||||
"version": "0.9.30",
|
||||
"resolved": "https://registry.npmjs.org/@soulcraft/brainy/-/brainy-0.9.30.tgz",
|
||||
"integrity": "sha512-CPI0XQLwp2KIy31dK6mzJfbW+F36dx1pG0ORmoY6tDRtRe7w39PaW+fj0Q/p8RpaBxAK5PaBgl/0rN+8bmsrsA==",
|
||||
"version": "0.9.34",
|
||||
"resolved": "https://registry.npmjs.org/@soulcraft/brainy/-/brainy-0.9.34.tgz",
|
||||
"integrity": "sha512-o48XhHzOyb1xDyhxpRStw0+d/MwJQoL8Sd8RNlHC9/cExEK/v9mXTk31axXNsP2nh93Rf3JJxWS0YpDl00h3ZQ==",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@
|
|||
"@rollup/plugin-json": "^6.1.0",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@rollup/plugin-typescript": "^11.1.6",
|
||||
"@types/node": "^20.4.5",
|
||||
"@types/node": "^20.11.30",
|
||||
"@types/omelette": "^0.4.5",
|
||||
"rollup": "^4.12.0",
|
||||
"rollup": "^4.13.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"typescript": "^5.1.6"
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=23.0.0"
|
||||
"node": ">=24.3.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
"scripts": {
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js",
|
||||
"dev": "nodemon --exec node --experimental-specifier-resolution=node --loader ts-node/esm src/index.ts",
|
||||
"dev": "nodemon --exec node --loader ts-node/esm src/index.ts",
|
||||
"deploy:aws": "node scripts/deploy-aws.js",
|
||||
"deploy:gcp": "node scripts/deploy-gcp.js",
|
||||
"deploy:cloudflare": "node scripts/deploy-cloudflare.js"
|
||||
|
|
@ -23,10 +23,10 @@
|
|||
"author": "David Snelling (david@soulcraft.com)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@soulcraft/brainy": "^0.9.2",
|
||||
"@soulcraft/brainy": "^0.9.34",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.19.2",
|
||||
"helmet": "^7.1.0",
|
||||
"morgan": "^1.10.0",
|
||||
"uuid": "^9.0.1",
|
||||
|
|
@ -36,15 +36,15 @@
|
|||
"@types/cors": "^2.8.17",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/morgan": "^1.9.9",
|
||||
"@types/node": "^20.10.5",
|
||||
"@types/uuid": "^9.0.7",
|
||||
"@types/node": "^20.11.30",
|
||||
"@types/uuid": "^9.0.8",
|
||||
"@types/ws": "^8.5.10",
|
||||
"nodemon": "^3.0.2",
|
||||
"nodemon": "^3.1.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.3.3"
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=23.11.0"
|
||||
"node": ">=24.3.0"
|
||||
},
|
||||
"prettier": {
|
||||
"arrowParens": "always",
|
||||
|
|
|
|||
1131
package-lock.json
generated
1131
package-lock.json
generated
File diff suppressed because it is too large
Load diff
20
package.json
20
package.json
|
|
@ -25,7 +25,7 @@
|
|||
}
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=23.0.0"
|
||||
"node": ">=24.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prebuild": "node scripts/generate-version.js",
|
||||
|
|
@ -101,18 +101,18 @@
|
|||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@rollup/plugin-replace": "^5.0.5",
|
||||
"@rollup/plugin-typescript": "^11.1.6",
|
||||
"@types/node": "^20.4.5",
|
||||
"@types/node": "^20.11.30",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
"@typescript-eslint/parser": "^6.0.0",
|
||||
"eslint": "^8.45.0",
|
||||
"rollup": "^4.12.0",
|
||||
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
||||
"@typescript-eslint/parser": "^7.4.0",
|
||||
"eslint": "^8.57.0",
|
||||
"rollup": "^4.13.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.1.6"
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.427.0",
|
||||
"@aws-sdk/client-s3": "^3.540.0",
|
||||
"@tensorflow-models/universal-sentence-encoder": "^1.3.3",
|
||||
"@tensorflow/tfjs": "^4.22.0",
|
||||
"@tensorflow/tfjs-backend-cpu": "^4.22.0",
|
||||
|
|
@ -120,7 +120,7 @@
|
|||
"@tensorflow/tfjs-converter": "^4.22.0",
|
||||
"@tensorflow/tfjs-core": "^4.22.0",
|
||||
"buffer": "^6.0.3",
|
||||
"uuid": "^9.0.0"
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
"prettier": {
|
||||
"arrowParens": "always",
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ export async function areWorkerThreadsAvailable(): Promise<boolean> {
|
|||
export function areWorkerThreadsAvailableSync(): boolean {
|
||||
if (!isNode()) return false
|
||||
|
||||
// In Node.js 12+, worker_threads is available without requiring a flag
|
||||
return parseInt(process.versions.node.split('.')[0]) >= 12
|
||||
// In Node.js 24.3.0+, worker_threads is always available
|
||||
return parseInt(process.versions.node.split('.')[0]) >= 24
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,93 +10,6 @@ import type {
|
|||
PlatformNodeObject
|
||||
} from '../types/tensorflowTypes.js'
|
||||
|
||||
// Flag to track if we're in a Node.js environment
|
||||
const isNodeEnvironment =
|
||||
typeof process !== 'undefined' &&
|
||||
process.versions &&
|
||||
process.versions.node
|
||||
|
||||
// Promise to load Node.js TextEncoder and TextDecoder
|
||||
let nodeUtilPromise: Promise<any> | null = null
|
||||
|
||||
// Function to get TextEncoder based on environment
|
||||
async function getTextEncoder(): Promise<typeof TextEncoder | null> {
|
||||
// First check if TextEncoder is globally available
|
||||
if (typeof TextEncoder !== 'undefined') {
|
||||
return TextEncoder
|
||||
}
|
||||
|
||||
// Then try to get it from Node.js util module
|
||||
if (isNodeEnvironment) {
|
||||
try {
|
||||
// Check if we can access the util module directly (in case it's already loaded)
|
||||
// @ts-ignore - Ignore TypeScript error for global.require
|
||||
if (typeof global !== 'undefined' && global.require && global.require.cache && global.require.cache['util']) {
|
||||
// @ts-ignore - Ignore TypeScript error for global.require
|
||||
const cachedUtil = global.require('util')
|
||||
if (cachedUtil && cachedUtil.TextEncoder) {
|
||||
return cachedUtil.TextEncoder
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, use dynamic import
|
||||
if (!nodeUtilPromise) {
|
||||
nodeUtilPromise = import('util').catch(error => {
|
||||
console.warn('Failed to import from util:', error)
|
||||
return null
|
||||
})
|
||||
}
|
||||
|
||||
const util = await nodeUtilPromise
|
||||
return util?.TextEncoder || null
|
||||
} catch (error) {
|
||||
console.warn('Error accessing TextEncoder:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
// Function to get TextDecoder based on environment
|
||||
async function getTextDecoder(): Promise<typeof TextDecoder | null> {
|
||||
// First check if TextDecoder is globally available
|
||||
if (typeof TextDecoder !== 'undefined') {
|
||||
return TextDecoder
|
||||
}
|
||||
|
||||
// Then try to get it from Node.js util module
|
||||
if (isNodeEnvironment) {
|
||||
try {
|
||||
// Check if we can access the util module directly (in case it's already loaded)
|
||||
// @ts-ignore - Ignore TypeScript error for global.require
|
||||
if (typeof global !== 'undefined' && global.require && global.require.cache && global.require.cache['util']) {
|
||||
// @ts-ignore - Ignore TypeScript error for global.require
|
||||
const cachedUtil = global.require('util')
|
||||
if (cachedUtil && cachedUtil.TextDecoder) {
|
||||
return cachedUtil.TextDecoder
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, use dynamic import
|
||||
if (!nodeUtilPromise) {
|
||||
nodeUtilPromise = import('util').catch(error => {
|
||||
console.warn('Failed to import from util:', error)
|
||||
return null
|
||||
})
|
||||
}
|
||||
|
||||
const util = await nodeUtilPromise
|
||||
return util?.TextDecoder || null
|
||||
} catch (error) {
|
||||
console.warn('Error accessing TextDecoder:', error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
// Define a global PlatformNode class for TensorFlow.js compatibility
|
||||
// This is needed because TensorFlow.js creates its own PlatformNode instance
|
||||
// and we need to ensure it uses the correct TextEncoder/TextDecoder
|
||||
|
|
@ -104,10 +17,10 @@ if (
|
|||
typeof global !== 'undefined' &&
|
||||
typeof process !== 'undefined' &&
|
||||
process.versions &&
|
||||
process.versions.node &&
|
||||
process.versions.node.split('.')[0] >= '23'
|
||||
process.versions.node
|
||||
) {
|
||||
try {
|
||||
// In Node.js v24.3.0+, TextEncoder and TextDecoder are globally available
|
||||
// Define the PlatformNode class that TensorFlow.js will use
|
||||
class PlatformNode {
|
||||
util: any
|
||||
|
|
@ -119,96 +32,13 @@ if (
|
|||
this.util = {
|
||||
isFloat32Array,
|
||||
isTypedArray,
|
||||
// Provide synchronous constructors that return objects with the expected interface
|
||||
// TensorFlow.js expects these to be synchronous
|
||||
TextEncoder: function() {
|
||||
// For Node.js environments, create a direct implementation
|
||||
if (isNodeEnvironment) {
|
||||
return {
|
||||
encode: (str: string) => {
|
||||
try {
|
||||
// Direct implementation for Node.js
|
||||
// Convert string to UTF-8 encoded Uint8Array
|
||||
const buffer = Buffer.from(str, 'utf-8')
|
||||
const uint8Array = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength)
|
||||
return uint8Array
|
||||
} catch (error) {
|
||||
console.warn('Error in Node.js TextEncoder implementation:', error)
|
||||
return new Uint8Array([])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// For browser environments, use the global TextEncoder
|
||||
else if (typeof TextEncoder !== 'undefined') {
|
||||
return new TextEncoder()
|
||||
}
|
||||
// Fallback for other environments
|
||||
else {
|
||||
console.warn('TextEncoder not available in this environment')
|
||||
return {
|
||||
encode: (str: string) => new Uint8Array([])
|
||||
}
|
||||
}
|
||||
},
|
||||
TextDecoder: function() {
|
||||
// For Node.js environments, create a direct implementation
|
||||
if (isNodeEnvironment) {
|
||||
return {
|
||||
decode: (bytes: Uint8Array) => {
|
||||
try {
|
||||
// Direct implementation for Node.js
|
||||
// Convert Uint8Array to string using Buffer
|
||||
const buffer = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
||||
return buffer.toString('utf-8')
|
||||
} catch (error) {
|
||||
console.warn('Error in Node.js TextDecoder implementation:', error)
|
||||
return ''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// For browser environments, use the global TextDecoder
|
||||
else if (typeof TextDecoder !== 'undefined') {
|
||||
return new TextDecoder()
|
||||
}
|
||||
// Fallback for other environments
|
||||
else {
|
||||
console.warn('TextDecoder not available in this environment')
|
||||
return {
|
||||
decode: (bytes: Uint8Array) => ''
|
||||
}
|
||||
}
|
||||
}
|
||||
TextEncoder,
|
||||
TextDecoder
|
||||
}
|
||||
|
||||
// Initialize TextEncoder/TextDecoder
|
||||
this.initializeEncoders()
|
||||
}
|
||||
|
||||
// Initialize TextEncoder and TextDecoder asynchronously
|
||||
async initializeEncoders() {
|
||||
try {
|
||||
const TextEncoderClass = await getTextEncoder()
|
||||
if (TextEncoderClass) {
|
||||
this.textEncoder = new TextEncoderClass()
|
||||
} else {
|
||||
console.warn('TextEncoder is not available in this environment')
|
||||
this.textEncoder = { encode: (str: string) => new Uint8Array([]) }
|
||||
}
|
||||
|
||||
const TextDecoderClass = await getTextDecoder()
|
||||
if (TextDecoderClass) {
|
||||
this.textDecoder = new TextDecoderClass()
|
||||
} else {
|
||||
console.warn('TextDecoder is not available in this environment')
|
||||
this.textDecoder = { decode: (bytes: Uint8Array) => '' }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize encoders:', error)
|
||||
this.textEncoder = { encode: (str: string) => new Uint8Array([]) }
|
||||
this.textDecoder = { decode: (bytes: Uint8Array) => '' }
|
||||
}
|
||||
// Initialize TextEncoder/TextDecoder instances
|
||||
this.textEncoder = new TextEncoder()
|
||||
this.textDecoder = new TextDecoder()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue