Environment Capabilities and Channels
Environment capability injection:
$sendwrapper (the underlying bridge$_sendis an internal implementation, held in the init.js closure and not exposed globally), channel descriptions, runtime configuration (plugins/Yeow/runtime/config.yml).
Environment Capability Injection
PluginThread registers a single underlying function in the JS context; init.js holds it in a closure and immediately removes it from the global object — plugin code can only use the wrapped $send:
| Function | Signature | Description |
|---|---|---|
$_send(channel, t, p) | (string, string | null, string | null) => string | number | null | The sole JS→Java communication entry (internal implementation, not exposed globally) |
Supported message channels:
| Channel | Purpose | Handling Location |
|---|---|---|
task | Game tasks (requests/get blocks/teleport, etc.) | Main thread scheduler |
timer | Timers (setTimeout/setInterval) | Plugin thread Timer thread pool |
fs | File system read/write | Plugin thread handles directly |
http | HTTP server/client | Plugin thread handles directly |
assets | Plugin built-in resource reading | Plugin thread handles directly |
service | Service registration/request/subscribe/publish | ServiceManager |
debug | Error reporting / heartbeat ping-pong | Plugin thread handles directly |
log | Console logging (auto-adds [PluginName] prefix) | Plugin thread handles directly |
env | Runtime environment info (static snapshot; no timestamp) | Plugin thread handles directly |
lifecycle | Lifecycle confirmation (unloadDone) | Plugin thread handles directly |
$send Wrapper Layer
init.js wraps $_send into $send(channel, t, p): channel is the namespace, t the operation/type (nullable) and p the params object (nullable); JSON conversion is automatic. $_send only exists within the init.js closure — plugin code (including dependency packages) that calls $_send directly will receive a ReferenceError:
// $send(channel, t, p) (the only usable entry point for plugins)
$send('task', 'player.get', { params: { identifier: 'uuid' } });Channel Descriptions
task channel — Game tasks, routed through the main thread scheduler. Frame: t = task type, p = { params, cb?, priority? }:
$send('task', 'player.get', { params: { identifier: 'uuid' } }); // sync
$send('task', 'player.get', { params: { identifier: 'uuid' }, cb: 'cb_1' }); // async
$send('task', null, { tasks: [{ type: 'server.getVersion' }] }); // batch (t empty)Synchronous tasks (no cb) block and wait for the result; asynchronous tasks (with cb) resolve via callback Promise.
timer channel — Replaces $timeout/$interval. Frame: t = timeout / interval / clear, p = { cb, delay? }:
$send('timer', 'timeout', { cb: 'cb_1', delay: 1000 });
$send('timer', 'interval', { cb: 'cb_2', delay: 5000 });
$send('timer', 'clear', { cb: 'cb_1' });log channel — Console logging auto-adds the [PluginName] prefix:
console.log('hello'); // → [MyPlugin] hello
console.warn('warning'); // → [MyPlugin] warningreportError channel — Manually report errors to dev-server source-map resolution:
import { logError } from 'yeow-api';
try { riskyOp(); } catch (e) { logError(e, 'custom context'); }lifecycle channel — Lifecycle confirmation (used internally by plugins):
$send('lifecycle', 'unloadDone'); // Confirmation of disable or hot-reload completionThe JS side sends $send('lifecycle', 'unloadDone') to the Java side for confirmation after the onUnload callback has finished executing. Upon receiving the confirmation, the Java side sets running = false, and the message loop exits naturally.
Wrapper Layer
init.js wraps $_send into a standard JS API:
$_send(channel, t, p) ← The only Java-native function (held in init.js closure, not exposed globally)
↓
init.js wrapper layer
├── $send(channel, t, p) ← Automatic JSON conversion (the only usable entry point for plugins)
├── console.log/warn/error ← Auto-adds [pluginName] prefix
├── setTimeout / clearTimeout
├── setInterval / clearInterval
├── fetch ← HTTP fetch (Promise)
└── $hm ← Message dispatcherRuntime Configuration
For the complete reference of plugins/Yeow/runtime/config.yml (auto-generated on first startup), including the Folia section and warning configuration, see Operations - Runtime Configuration; for warning thresholds and dynamic scaling, see Runtime Warning Guide.