@antelopejs/interface-core
This package holds the primitives every AntelopeJS interface is built from. It provides proxies that cross module boundaries, decorator factories, module lifecycle events, structured logging, and project configuration.
What it offers
InterfaceFunctiondeclares a contract function.ImplementInterfaceattaches a module's implementation to it, typed byInterfaceToImpl. Calls made before the implementation attaches wait in a queue.AsyncProxy,EventProxyandRegisteringProxycarry calls, events and registrations between modules, and detach when a module unloads.@antelopejs/interface-core/decoratorsbuilds typed class, method, property and parameter decorators.@antelopejs/interface-core/modulesexposes lifecycle events and module management functions.@antelopejs/interface-core/loggingwrites structured logs on named channels.@antelopejs/interface-core/configprovidesdefineConfigforantelope.config.ts.
Implementations
| Module | Notes |
|---|---|
@antelopejs/core | The AntelopeJS runtime and ajs CLI implement this interface |
Install
Add the package to every module that declares or implements an interface:
pnpm add @antelopejs/interface-core
You need no extra module, because @antelopejs/core provides the implementation.
Quick start
Declare a contract:
// src/interface/index.ts
import { InterfaceFunction } from "@antelopejs/interface-core";
export const GetGreeting = InterfaceFunction<(name: string) => string>();
Implement it and call it from a module:
// src/index.ts
import { ImplementInterface } from "@antelopejs/interface-core";
import { Logging } from "@antelopejs/interface-core/logging";
import * as Greeting from "./interface";
export function construct() {
ImplementInterface(Greeting, {
GetGreeting: (name: string) => `Hello, ${name}`,
});
}
export async function start() {
Logging.Info(await Greeting.GetGreeting("Ada"));
}
An interface function always returns a promise, even when the implementation is synchronous.
Documentation
- Introduction
- Proxies, attachment leases and errors
- Decorators
- Metadata
- Modules
- Logging
- Configuration
- Runtime
Compatibility
@antelopejs/core implements this package. Each core release declares the @antelopejs/interface-core range it works with in the dependencies of its package.json.
Contributing
Read CONTRIBUTING.md before you open a pull request. The local checks are:
pnpm install
pnpm lint
pnpm test