feat(core): Add Bun and Deno runtime support, unify core loader, unix-socket support and cross-runtime streaming/tests
This commit is contained in:
@@ -5,12 +5,22 @@ export * from '../core_base/types.js';
|
||||
|
||||
const smartenvInstance = new plugins.smartenv.Smartenv();
|
||||
|
||||
// Dynamically load the appropriate implementation
|
||||
// Dynamically load the appropriate implementation based on runtime
|
||||
let CoreRequest: any;
|
||||
let CoreResponse: any;
|
||||
|
||||
if (smartenvInstance.isNode) {
|
||||
// In Node.js, load the node implementation
|
||||
if (smartenvInstance.isDeno) {
|
||||
// In Deno, load the Deno implementation with HttpClient-based unix socket support
|
||||
const impl = await import('../core_deno/index.js');
|
||||
CoreRequest = impl.CoreRequest;
|
||||
CoreResponse = impl.CoreResponse;
|
||||
} else if (smartenvInstance.isBun) {
|
||||
// In Bun, load the Bun implementation with native fetch unix socket support
|
||||
const impl = await import('../core_bun/index.js');
|
||||
CoreRequest = impl.CoreRequest;
|
||||
CoreResponse = impl.CoreResponse;
|
||||
} else if (smartenvInstance.isNode) {
|
||||
// In Node.js, load the Node.js implementation with native http/https unix socket support
|
||||
const modulePath = plugins.smartpath.join(
|
||||
plugins.smartpath.dirname(import.meta.url),
|
||||
'../core_node/index.js',
|
||||
@@ -19,7 +29,7 @@ if (smartenvInstance.isNode) {
|
||||
CoreRequest = impl.CoreRequest;
|
||||
CoreResponse = impl.CoreResponse;
|
||||
} else {
|
||||
// In browser, load the fetch implementation
|
||||
// In browser, load the fetch implementation (no unix socket support)
|
||||
const impl = await import('../core_fetch/index.js');
|
||||
CoreRequest = impl.CoreRequest;
|
||||
CoreResponse = impl.CoreResponse;
|
||||
|
||||
Reference in New Issue
Block a user