feat(core): Add Bun and Deno runtime support, unify core loader, unix-socket support and cross-runtime streaming/tests

This commit is contained in:
2025-11-16 22:50:19 +00:00
parent 32332309dc
commit 6211acd60b
22 changed files with 1447 additions and 92 deletions

View File

@@ -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;