summaryrefslogtreecommitdiffhomepage
path: root/packages/host-bin/src/load-external.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/host-bin/src/load-external.ts')
-rw-r--r--packages/host-bin/src/load-external.ts46
1 files changed, 23 insertions, 23 deletions
diff --git a/packages/host-bin/src/load-external.ts b/packages/host-bin/src/load-external.ts
index 34b8bce..522cff8 100644
--- a/packages/host-bin/src/load-external.ts
+++ b/packages/host-bin/src/load-external.ts
@@ -16,32 +16,32 @@ import type { Extension, Logger } from "@dispatch/kernel";
* boot (defend faults, not adversaries; never leave the system broken).
*/
export async function loadExternalExtensions(
- specifiers: readonly string[],
- logger: Logger,
+ specifiers: readonly string[],
+ logger: Logger,
): Promise<Extension[]> {
- const loaded: Extension[] = [];
- for (const spec of specifiers) {
- try {
- const mod = (await import(spec)) as Record<string, unknown>;
- const candidate = mod.extension ?? mod.default ?? mod;
- if (isExtension(candidate)) {
- loaded.push(candidate);
- logger.info(`Loaded external extension "${candidate.manifest.id}" from ${spec}`);
- } else {
- logger.warn(`External module "${spec}" has no valid extension export; skipped`);
- }
- } catch (err) {
- logger.error(`Failed to load external extension "${spec}"; skipped`, { err });
- }
- }
- return loaded;
+ const loaded: Extension[] = [];
+ for (const spec of specifiers) {
+ try {
+ const mod = (await import(spec)) as Record<string, unknown>;
+ const candidate = mod.extension ?? mod.default ?? mod;
+ if (isExtension(candidate)) {
+ loaded.push(candidate);
+ logger.info(`Loaded external extension "${candidate.manifest.id}" from ${spec}`);
+ } else {
+ logger.warn(`External module "${spec}" has no valid extension export; skipped`);
+ }
+ } catch (err) {
+ logger.error(`Failed to load external extension "${spec}"; skipped`, { err });
+ }
+ }
+ return loaded;
}
/** Structural check that a dynamically-imported value is an `Extension`. */
function isExtension(value: unknown): value is Extension {
- if (!value || typeof value !== "object") return false;
- const e = value as { manifest?: unknown; activate?: unknown };
- if (typeof e.activate !== "function") return false;
- const m = e.manifest as { id?: unknown } | undefined;
- return !!m && typeof m.id === "string";
+ if (!value || typeof value !== "object") return false;
+ const e = value as { manifest?: unknown; activate?: unknown };
+ if (typeof e.activate !== "function") return false;
+ const m = e.manifest as { id?: unknown } | undefined;
+ return !!m && typeof m.id === "string";
}