openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
30 lines (29 loc) • 1.21 kB
JavaScript
import { r as createLazyPromiseLoader } from "./lazy-promise-DGqyc4Y4.mjs";
//#region src/shared/lazy-runtime.ts
function createLazyRuntimeSurface(importer, select) {
const loader = createLazyPromiseLoader(() => importer().then(select), { cacheRejections: true });
return Object.assign(loader.load, {
peek: loader.peek,
clear: loader.clear
});
}
/** Cache the raw dynamically imported runtime module behind a stable loader. */
function createLazyRuntimeModule(importer) {
return createLazyRuntimeSurface(importer, (module) => module);
}
/** Cache a single named runtime export without repeating a custom selector closure per caller. */
function createLazyRuntimeNamedExport(importer, key) {
return createLazyRuntimeSurface(importer, (module) => module[key]);
}
function createLazyRuntimeMethod(load, select) {
return async (...args) => {
return await select(await load())(...args);
};
}
function createLazyRuntimeMethodBinder(load) {
return function(select) {
return createLazyRuntimeMethod(load, select);
};
}
//#endregion
export { createLazyRuntimeSurface as a, createLazyRuntimeNamedExport as i, createLazyRuntimeMethodBinder as n, createLazyRuntimeModule as r, createLazyRuntimeMethod as t };