86 lines
9.8 KiB
Plaintext
86 lines
9.8 KiB
Plaintext
page wrnexusplugin {
|
|
seo {
|
|
title = "@wrnexus/plugin"
|
|
description = "Plugin contracts, lifecycle hooks, composition, and framework integration."
|
|
}
|
|
|
|
view {
|
|
<div class="docs-shell">
|
|
<a href="#main" class="skip-link">Skip to content</a>
|
|
<header class="topbar">
|
|
<a class="brand" href="/"><span>W</span> WRNexusJS</a>
|
|
<nav aria-label="Primary"><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="https://component.wrnexusjs.dev/">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav>
|
|
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.8.7</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div>
|
|
</header>
|
|
<div class="mobile-doc-nav"><details><summary>Browse documentation</summary><nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="https://component.wrnexusjs.dev/">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a><a href="/tutorial">Tutorial</a><a href="/guides/project-structure">Guides</a><a href="/examples">Examples</a><a href="/search">Search</a></nav></details></div>
|
|
<main class="portal-main docs-layout">
|
|
<article id="main" class="documentation prose standalone package-document"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span>/</span><a href="/packages">Packages</a><span>/</span><span aria-current="page">@wrnexus/plugin</span></nav><section class="doc-intro"><span class="eyebrow">Core · Package reference</span><h1>@wrnexus/plugin</h1><p>Plugin contracts, lifecycle hooks, composition, and framework integration.</p><div class="doc-meta"><span>v0.8.7</span><span>Private registry</span><span>Core</span></div><section id="access" class="access-callout"><h2>Install the package</h2><p>After WorkRoot approves private registry access, install the release-aligned package:</p><pre><code>bun add @wrnexus/plugin@0.8.7</code><button type="button" class="copy-button" aria-label="Copy installation command">Copy</button></pre><p><a href="/access">Request preview access</a>. Never put registry tokens in source control.</p></section></section><section id="guide"><h3 id="least-privilege-package-permissions">Least-privilege package permissions</h3>
|
|
<p>Package manifests declare every framework capability they register:</p>
|
|
<pre data-language="json"><code>{
|
|
"wrnexus": {
|
|
"permissions": ["routes", "migrations"],
|
|
"routes": [{ "kind": "api", "path": "/api/example", "entry": "./route.ts" }]
|
|
}
|
|
}</code></pre>
|
|
<p>Applications can enable fail-closed grants:</p>
|
|
<pre data-language="ts"><code>export default {
|
|
pluginPermissions: {
|
|
enforce: true,
|
|
grants: { "example-plugin": ["routes"] },
|
|
},
|
|
};</code></pre>
|
|
<p>Discovery rejects used-but-undeclared capabilities with <code>WRN-PLUGIN-PERMISSION-UNDECLARED</code> and ungranted capabilities with <code>WRN-PLUGIN-PERMISSION-DENIED</code>. Permissions cover components, browser runtime, assets, styles, routes, middleware, migrations, config, transforms, diagnostics/tooling, and server/build hooks.</p>
|
|
<h3 id="compatibility-matrices">Compatibility matrices</h3>
|
|
<p>Manifests can add <code>compatibility: { bunMin: "1.3.0", os: ["linux", "darwin"] }</code> alongside <code>runtimes</code> and <code>requires</code>. Use <code>testPluginCompatibility(manifest, targets)</code> in a package test to exercise the complete support matrix. Runtime discovery enforces the same Bun minimum, OS, runtime, and capability declarations used by the test kit.</p>
|
|
<p>Deterministic WRNexusJS plugin contracts for configuration, AST/code transforms, diagnostics, development servers, production builds, and DevToolbar extensions.</p>
|
|
<p>Use <code>definePlugin()</code> and declare <code>enforce</code>, <code>before</code>, or <code>after</code> when ordering matters. Duplicate names and dependency cycles are rejected.</p>
|
|
<h3 id="complete-lifecycle-and-contributions">Complete lifecycle and contributions</h3>
|
|
<p>Plugins may implement <code>setup</code>, <code>configure</code>, <code>configResolved</code>, <code>transformAst</code>, <code>transformCode</code>, <code>diagnostics</code>, <code>routes</code>, <code>configureServer</code>, <code>buildStart</code>, <code>buildEnd</code>, <code>render</code>, <code>deploy</code>, <code>shutdown</code>, and <code>hmrUpdate</code>. The runner preserves resolved plugin order for every hook and executes <code>setup</code> exactly once.</p>
|
|
<p>In addition to components, routes, middleware, assets, styles, runtimes, and migrations, plugins can contribute <code>directives</code>, <code>cliCommands</code>, <code>virtualModules</code>, <code>deploymentAdapters</code>, <code>configSchemas</code>, <code>documentation</code>, and <code>typeDefinitions</code>. Names are collision checked. Configuration schemas run after configuration resolution, CLI commands are callable as normal <code>wrnexus</code> commands, directives participate in AST transformation, and production builds materialize virtual modules and invoke matching contributed adapters.</p></section><section id="api" class="api"><h2>Complete TypeScript API</h2><p>Generated from the exact installed package declarations.</p><pre data-language="typescript"><code>export { PageAst, WrnDiagnostic } from '@wrnexus/syntax';
|
|
import { WrnexusPackageManifest, WrnexusPlugin, PluginInput, PluginContext, PluginRunner } from './types.js';
|
|
export { ClientRuntimeDefinition, ClientRuntimeInject, ClientRuntimeLoad, ClientRuntimeType, PackageAssetDefinition, PackageMigrationDefinition, PackagePluginManifest, PackageRouteDefinition, PackageStyleDefinition, PluginCliCommand, PluginCommand, PluginConfigSchema, PluginContributions, PluginDeploymentAdapter, PluginDevToolbarPanel, PluginDirective, PluginOrder, PluginPermission, PluginVirtualModule, TransformContext } from './types.js';
|
|
export { assertContributionId, contentTypeForPath, defaultClientRuntimePath, defaultPackageAssetPath, definePackageManifest, normalizeClientRuntime, normalizePackageAsset, validateStyleIds } from './manifest.js';
|
|
export { DiscoverPluginOptions, discoverPlugins } from './discovery.js';
|
|
|
|
interface PluginCompatibilityTarget {
|
|
runtime: "bun" | "node" | "edge" | "worker" | "service-worker" | "browser";
|
|
version?: string;
|
|
os?: "win32" | "linux" | "darwin" | string;
|
|
capabilities?: readonly string[];
|
|
}
|
|
interface PluginCompatibilityResult {
|
|
target: PluginCompatibilityTarget;
|
|
ok: boolean;
|
|
issues: Array<{
|
|
code: "WRN-PLUGIN-MATRIX-RUNTIME" | "WRN-PLUGIN-MATRIX-VERSION" | "WRN-PLUGIN-MATRIX-OS" | "WRN-PLUGIN-MATRIX-CAPABILITY";
|
|
message: string;
|
|
}>;
|
|
}
|
|
declare function testPluginCompatibility(manifest: WrnexusPackageManifest, targets: readonly PluginCompatibilityTarget[]): PluginCompatibilityResult[];
|
|
|
|
declare function definePlugin(plugin: WrnexusPlugin): WrnexusPlugin;
|
|
declare function flattenPlugins(input: PluginInput, output?: WrnexusPlugin[]): WrnexusPlugin[];
|
|
|
|
/** Resolve plugin order deterministically and reject duplicates/cycles. */
|
|
declare function resolvePlugins(input: PluginInput): WrnexusPlugin[];
|
|
declare function createPluginRunner(input: PluginInput, context: PluginContext): PluginRunner;
|
|
|
|
export { type PluginCompatibilityResult, type PluginCompatibilityTarget, PluginContext, PluginInput, PluginRunner, WrnexusPackageManifest, WrnexusPlugin, createPluginRunner, definePlugin, flattenPlugins, resolvePlugins, testPluginCompatibility };
|
|
</code></pre></section><section id="examples" class="examples"><h2>Examples</h2><p>Copy-ready examples from the installed package documentation.</p><div class="example-grid"><article class="example-card"><h3>Package manifests declare every framework capability they register</h3><pre data-language="json"><code>{
|
|
"wrnexus": {
|
|
"permissions": ["routes", "migrations"],
|
|
"routes": [{ "kind": "api", "path": "/api/example", "entry": "./route.ts" }]
|
|
}
|
|
}</code></pre></article><article class="example-card"><h3>Applications can enable fail-closed grants</h3><pre data-language="ts"><code>export default {
|
|
pluginPermissions: {
|
|
enforce: true,
|
|
grants: { "example-plugin": ["routes"] },
|
|
},
|
|
};</code></pre></article></div></section></article>
|
|
<aside class="on-this-page"><h2>On this page</h2><nav><a class="toc-level-2" href="#guide">Guide</a><a class="toc-level-3" href="#least-privilege-package-permissions">Least-privilege package permissions</a><a class="toc-level-3" href="#compatibility-matrices">Compatibility matrices</a><a class="toc-level-3" href="#complete-lifecycle-and-contributions">Complete lifecycle and contributions</a><a class="toc-level-2" href="#api">Complete API</a><a class="toc-level-2" href="#examples">Examples</a></nav></aside>
|
|
</main>
|
|
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS 0.8.7</strong><span>Complete API documentation generated from installed package declarations.</span></p></div><nav aria-label="Footer"><a href="/packages">All packages</a><a href="/getting-started">Get started</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Private Developer Preview · Bun-native</p></footer>
|
|
</div>
|
|
}
|
|
}
|