@soulcraft/brainy 0.9.29 → 0.9.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/brainy.js +17 -88
- package/dist/brainy.min.js +2 -2
- package/dist/storage/fileSystemStorage.d.ts.map +1 -1
- package/dist/unified.js +17 -88
- package/dist/unified.min.js +2 -2
- package/dist/utils/environment.d.ts +10 -1
- package/dist/utils/environment.d.ts.map +1 -1
- package/dist/utils/tensorflowUtils.d.ts.map +1 -1
- package/dist/utils/version.d.ts +1 -1
- package/package.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileSystemStorage.d.ts","sourceRoot":"","sources":["../../src/storage/fileSystemStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"fileSystemStorage.d.ts","sourceRoot":"","sources":["../../src/storage/fileSystemStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAyBrE;;GAEG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,aAAa,CAAQ;gBAEjB,aAAa,CAAC,EAAE,MAAM;IAelC;;OAEG;IACU,IAAI,IA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,GAAG,IAAI,CAAC;IAqBzD;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BnC;;OAEG;YACW,iBAAiB;IAM/B;;OAEG;YACW,qBAAqB;IASnC;;OAEG;YACW,eAAe;IA2B7B;;OAEG;YACW,qBAAqB;IAanC;;OAEG;IACH,OAAO,CAAC,WAAW;IAWnB;;OAEG;YACW,gBAAgB;IAiC9B;;OAEG;IACU,gBAAgB,IAAI,OAAO,CAAC;QACvC,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAC9B,CAAC;CA4JH"}
|
package/dist/unified.js
CHANGED
|
@@ -2682,9 +2682,9 @@ function isBrowser$1() {
|
|
|
2682
2682
|
* Check if code is running in a Node.js environment
|
|
2683
2683
|
*/
|
|
2684
2684
|
function isNode() {
|
|
2685
|
-
return typeof process !== 'undefined' &&
|
|
2685
|
+
return (typeof process !== 'undefined' &&
|
|
2686
2686
|
process.versions != null &&
|
|
2687
|
-
process.versions.node != null;
|
|
2687
|
+
process.versions.node != null);
|
|
2688
2688
|
}
|
|
2689
2689
|
/**
|
|
2690
2690
|
* Check if Web Workers are available in the current environment
|
|
@@ -2693,26 +2693,21 @@ function areWebWorkersAvailable() {
|
|
|
2693
2693
|
return isBrowser$1() && typeof Worker !== 'undefined';
|
|
2694
2694
|
}
|
|
2695
2695
|
/**
|
|
2696
|
-
*
|
|
2696
|
+
* Synchronous version that doesn't actually try to load the module
|
|
2697
|
+
* This is safer in ES module environments
|
|
2697
2698
|
*/
|
|
2698
|
-
function
|
|
2699
|
+
function areWorkerThreadsAvailableSync() {
|
|
2699
2700
|
if (!isNode())
|
|
2700
2701
|
return false;
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
require('worker_threads');
|
|
2704
|
-
return true;
|
|
2705
|
-
}
|
|
2706
|
-
catch (e) {
|
|
2707
|
-
return false;
|
|
2708
|
-
}
|
|
2702
|
+
// In Node.js 12+, worker_threads is available without requiring a flag
|
|
2703
|
+
return parseInt(process.versions.node.split('.')[0]) >= 12;
|
|
2709
2704
|
}
|
|
2710
2705
|
/**
|
|
2711
2706
|
* Determine if threading is available in the current environment
|
|
2712
2707
|
* Returns true if either Web Workers (browser) or Worker Threads (Node.js) are available
|
|
2713
2708
|
*/
|
|
2714
2709
|
function isThreadingAvailable() {
|
|
2715
|
-
return areWebWorkersAvailable() ||
|
|
2710
|
+
return areWebWorkersAvailable() || areWorkerThreadsAvailableSync();
|
|
2716
2711
|
}
|
|
2717
2712
|
|
|
2718
2713
|
/**
|
|
@@ -9326,41 +9321,11 @@ class BrainyData {
|
|
|
9326
9321
|
}
|
|
9327
9322
|
|
|
9328
9323
|
// Import Node.js built-in modules
|
|
9329
|
-
// Using
|
|
9324
|
+
// Using dynamic imports for compatibility with ES modules
|
|
9330
9325
|
let fs;
|
|
9331
9326
|
let path;
|
|
9332
|
-
//
|
|
9333
|
-
|
|
9334
|
-
process.versions &&
|
|
9335
|
-
process.versions.node) {
|
|
9336
|
-
try {
|
|
9337
|
-
// Use require for Node.js built-in modules
|
|
9338
|
-
fs = require('fs');
|
|
9339
|
-
path = require('path');
|
|
9340
|
-
// Verify that path has the required methods
|
|
9341
|
-
if (!path || typeof path.resolve !== 'function') {
|
|
9342
|
-
throw new Error('path module is missing required methods');
|
|
9343
|
-
}
|
|
9344
|
-
}
|
|
9345
|
-
catch (e) {
|
|
9346
|
-
console.warn('Failed to load Node.js modules with require:', e);
|
|
9347
|
-
// Try using dynamic import as a fallback
|
|
9348
|
-
try {
|
|
9349
|
-
// Use a synchronous approach to ensure modules are loaded before continuing
|
|
9350
|
-
const pathModule = require('node:path');
|
|
9351
|
-
const fsModule = require('node:fs');
|
|
9352
|
-
path = pathModule;
|
|
9353
|
-
fs = fsModule;
|
|
9354
|
-
// Verify that path has the required methods
|
|
9355
|
-
if (!path || typeof path.resolve !== 'function') {
|
|
9356
|
-
throw new Error('path module from node:path is missing required methods');
|
|
9357
|
-
}
|
|
9358
|
-
}
|
|
9359
|
-
catch (nodeImportError) {
|
|
9360
|
-
console.warn('Failed to load Node.js modules with node: prefix:', nodeImportError);
|
|
9361
|
-
}
|
|
9362
|
-
}
|
|
9363
|
-
}
|
|
9327
|
+
// We'll initialize these modules in the init() method
|
|
9328
|
+
// No synchronous loading here to avoid issues with ES modules
|
|
9364
9329
|
// Constants for directory and file names
|
|
9365
9330
|
const ROOT_DIR = 'brainy-data';
|
|
9366
9331
|
const NOUNS_DIR = 'nouns';
|
|
@@ -9406,31 +9371,11 @@ class FileSystemStorage {
|
|
|
9406
9371
|
console.log('Node.js modules not properly loaded, attempting to load them now');
|
|
9407
9372
|
// Try multiple approaches to load the modules
|
|
9408
9373
|
const loadAttempts = [
|
|
9409
|
-
// Attempt 1: Use
|
|
9410
|
-
async () => {
|
|
9411
|
-
console.log('Attempting to load Node.js modules with require()');
|
|
9412
|
-
const fsModule = require('fs');
|
|
9413
|
-
const pathModule = require('path');
|
|
9414
|
-
if (!pathModule || typeof pathModule.resolve !== 'function') {
|
|
9415
|
-
throw new Error('path.resolve is not a function after require()');
|
|
9416
|
-
}
|
|
9417
|
-
return { fs: fsModule, path: pathModule };
|
|
9418
|
-
},
|
|
9419
|
-
// Attempt 2: Use require with node: prefix
|
|
9420
|
-
async () => {
|
|
9421
|
-
console.log('Attempting to load Node.js modules with require("node:...")');
|
|
9422
|
-
const fsModule = require('node:fs');
|
|
9423
|
-
const pathModule = require('node:path');
|
|
9424
|
-
if (!pathModule || typeof pathModule.resolve !== 'function') {
|
|
9425
|
-
throw new Error('path.resolve is not a function after require("node:path")');
|
|
9426
|
-
}
|
|
9427
|
-
return { fs: fsModule, path: pathModule };
|
|
9428
|
-
},
|
|
9429
|
-
// Attempt 3: Use dynamic import
|
|
9374
|
+
// Attempt 1: Use dynamic import
|
|
9430
9375
|
async () => {
|
|
9431
9376
|
console.log('Attempting to load Node.js modules with dynamic import');
|
|
9432
|
-
const fsModule = await
|
|
9433
|
-
const pathModule = await
|
|
9377
|
+
const fsModule = await import('fs');
|
|
9378
|
+
const pathModule = await import('path');
|
|
9434
9379
|
const fsResolved = fsModule.default || fsModule;
|
|
9435
9380
|
const pathResolved = pathModule.default || pathModule;
|
|
9436
9381
|
if (!pathResolved || typeof pathResolved.resolve !== 'function') {
|
|
@@ -9438,7 +9383,7 @@ class FileSystemStorage {
|
|
|
9438
9383
|
}
|
|
9439
9384
|
return { fs: fsResolved, path: pathResolved };
|
|
9440
9385
|
},
|
|
9441
|
-
// Attempt
|
|
9386
|
+
// Attempt 2: Use dynamic import with node: prefix
|
|
9442
9387
|
async () => {
|
|
9443
9388
|
console.log('Attempting to load Node.js modules with dynamic import("node:...")');
|
|
9444
9389
|
const fsModule = await import('node:fs');
|
|
@@ -22019,12 +21964,12 @@ var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({
|
|
|
22019
21964
|
|
|
22020
21965
|
var require$$0 = /*@__PURE__*/getAugmentedNamespace(_nodeResolve_empty$1);
|
|
22021
21966
|
|
|
22022
|
-
var _utilShim = {}; const promises
|
|
21967
|
+
var _utilShim = {}; const promises = {};
|
|
22023
21968
|
|
|
22024
21969
|
var _utilShim$1 = /*#__PURE__*/Object.freeze({
|
|
22025
21970
|
__proto__: null,
|
|
22026
21971
|
default: _utilShim,
|
|
22027
|
-
promises: promises
|
|
21972
|
+
promises: promises
|
|
22028
21973
|
});
|
|
22029
21974
|
|
|
22030
21975
|
var require$$1 = /*@__PURE__*/getAugmentedNamespace(_utilShim$1);
|
|
@@ -87276,22 +87221,6 @@ var universalSentenceEncoder_esm = /*#__PURE__*/Object.freeze({
|
|
|
87276
87221
|
version: version
|
|
87277
87222
|
});
|
|
87278
87223
|
|
|
87279
|
-
var _fsShim = {}; const promises$1 = {};
|
|
87280
|
-
|
|
87281
|
-
var _fsShim$1 = /*#__PURE__*/Object.freeze({
|
|
87282
|
-
__proto__: null,
|
|
87283
|
-
default: _fsShim,
|
|
87284
|
-
promises: promises$1
|
|
87285
|
-
});
|
|
87286
|
-
|
|
87287
|
-
var _pathShim = {}; const promises = {};
|
|
87288
|
-
|
|
87289
|
-
var _pathShim$1 = /*#__PURE__*/Object.freeze({
|
|
87290
|
-
__proto__: null,
|
|
87291
|
-
default: _pathShim,
|
|
87292
|
-
promises: promises
|
|
87293
|
-
});
|
|
87294
|
-
|
|
87295
87224
|
var _child_processShim = /*#__PURE__*/Object.freeze({
|
|
87296
87225
|
__proto__: null
|
|
87297
87226
|
});
|