docs: publish package usage examples for 0.2.24

This commit is contained in:
2026-07-13 20:58:28 +05:30
parent b07ef5058a
commit 379553bdf7
79 changed files with 1542 additions and 894 deletions
+23 -17
View File
@@ -10,12 +10,12 @@ page wrnexuscsr {
<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="/language">Language</a><a href="/architecture">Architecture</a></nav>
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.2.23</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div>
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.2.24</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="/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="page package-page">
<aside class="sidebar"><a href="/packages">← All packages</a><span class="category">Frontend</span><h2>@wrnexus/csr</h2><p>Reactive, navigation, and realtime browser runtimes.</p><span class="status status-beta">Private preview · 0.2.23</span><nav><a href="#access">Access</a><a href="#guide">Guide</a><a href="#api">Complete API</a></nav></aside>
<article id="main" class="documentation"><section class="doc-intro"><span class="eyebrow">Frontend · Preview</span><h1>@wrnexus/csr</h1><p>Reactive, navigation, and realtime browser runtimes.</p><section id="access" class="access-callout"><h2>Private registry access required</h2><p>This package is not available from the public npm registry. After WorkRoot approves access and supplies private registry instructions, install the release-aligned package:</p><pre><code>bun add @wrnexus/csr@0.2.23</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" class="prose"><blockquote>The browser-side client runtime for WRNexusJS — generic, self-contained JS that hydrates server-rendered pages with reactivity, client-side navigation, and realtime rooms.</blockquote>
<aside class="sidebar"><a href="/packages">← All packages</a><span class="category">Frontend</span><h2>@wrnexus/csr</h2><p>Reactive, navigation, and realtime browser runtimes.</p><span class="status status-beta">Private preview · 0.2.24</span><nav><a href="#access">Access</a><a href="#guide">Guide</a><a href="#api">Complete API</a></nav></aside>
<article id="main" class="documentation"><section class="doc-intro"><span class="eyebrow">Frontend · Preview</span><h1>@wrnexus/csr</h1><p>Reactive, navigation, and realtime browser runtimes.</p><section id="access" class="access-callout"><h2>Private registry access required</h2><p>This package is not available from the public npm registry. After WorkRoot approves access and supplies private registry instructions, install the release-aligned package:</p><pre><code>bun add @wrnexus/csr@0.2.24</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" class="prose"><blockquote>The browser-side client runtime for WRNexusJS — generic, self-contained JS that hydrates server-rendered pages with reactivity, client-side navigation, and realtime rooms.</blockquote>
<p>Part of the <strong>WRNexusJS</strong> framework — an SSR-first, Bun-native full-stack web framework.</p>
<h3 id="overview">Overview</h3>
<p><code>@wrnexus/csr</code> holds the three client runtimes that WRNexusJS serves to the browser. Components are authored as <code>.wrn</code> files and rendered on the <strong>server</strong>; this package provides the single, generic runtime that <strong>hydrates</strong> that HTML in the browser — there are no per-component browser bundles. Each runtime is exported as a plain-JS string (no build step, no imports) intended to be served verbatim from a well-known URL:</p>
@@ -197,18 +197,7 @@ declare function getNavRuntime(): string;
declare function getRealtimeRuntime(): string;
export &#123; NAV_RUNTIME, REACTIVE_RUNTIME, REALTIME_RUNTIME, getNavRuntime, getReactiveRuntime, getRealtimeRuntime &#125;;
</code></pre></section><section id="examples" class="prose examples"><h2>Examples</h2><p>Examples are taken from this package's installed documentation and must be evaluated with its requirements and stability notes.</p><div class="example-grid"><article class="example-card"><h3>Example 1</h3><pre data-language="bash"><code>bun add @wrnexus/csr</code></pre></article><article class="example-card"><h3>Example 2</h3><pre data-language="ts"><code>getReactiveRuntime(): string // → REACTIVE_RUNTIME
getNavRuntime(): string // → NAV_RUNTIME
getRealtimeRuntime(): string // → REALTIME_RUNTIME</code></pre></article><article class="example-card"><h3>Example 3</h3><pre data-language="ts"><code>wire.room(name): Room // open (or reuse) a room connection
wire.bindRooms(root?) // (re)bind declarative [data-room] containers
interface Room &#123;
name: string;
send(obj: object | string): Room; // JSON-stringifies objects; queues until open
on(type: string, cb): Room; // filter by msg.type; &quot;*&quot; or a fn = all messages
on(cb): Room;
close(): Room;
&#125;</code></pre></article><article class="example-card"><h3>Example 4</h3><pre data-language="ts"><code>import &#123; getReactiveRuntime, getNavRuntime, getRealtimeRuntime &#125; from &quot;@wrnexus/csr&quot;;
</code></pre></section><section id="examples" class="prose examples"><h2>Examples</h2><p>Examples are taken from this package's installed documentation and must be evaluated with its requirements and stability notes.</p><div class="example-grid"><article class="example-card"><h3>Server side — serve the runtime strings from your router (example with Bun.serve)</h3><pre data-language="ts"><code>import &#123; getReactiveRuntime, getNavRuntime, getRealtimeRuntime &#125; from &quot;@wrnexus/csr&quot;;
const routes: Record&lt;string, string&gt; = &#123;
&quot;/__wrnexus/reactive.js&quot;: getReactiveRuntime(),
@@ -226,10 +215,27 @@ Bun.serve(&#123;
&#125;
return new Response(&quot;Not found&quot;, &#123; status: 404 &#125;);
&#125;,
&#125;);</code></pre></article></div></section></article>
&#125;);</code></pre></article><article class="example-card"><h3>Browser side — server-rendered HTML that the reactive runtime hydrates</h3><pre data-language="html"><code>&lt;div data-scope=&quot;count: 0&quot;&gt;
&lt;button data-on-click=&quot;count++&quot;&gt;+1&lt;/button&gt;
&lt;span data-text=&quot;count&quot;&gt;&lt;/span&gt;
&lt;p&gt;Total: &#123;&#123;count&#125;&#125;&lt;/p&gt;
&lt;/div&gt;
&lt;script src=&quot;/__wrnexus/reactive.js&quot;&gt;&lt;/script&gt;</code></pre></article><article class="example-card"><h3>A realtime chat, fully declarative</h3><pre data-language="html"><code>&lt;div data-room=&quot;lobby&quot; data-room-user=&quot;ada&quot;&gt;
&lt;div data-room-status&gt;&lt;/div&gt;
&lt;ul data-room-log&gt;&lt;/ul&gt;
&lt;template data-room-item=&quot;chat&quot;&gt;&lt;li&gt;%user%: %text%&lt;/li&gt;&lt;/template&gt;
&lt;form data-room-send&gt;
&lt;input name=&quot;text&quot; data-room-reset /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;type&quot; value=&quot;chat&quot; /&gt;
&lt;button&gt;Send&lt;/button&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;script src=&quot;/__wrnexus/realtime.js&quot;&gt;&lt;/script&gt;</code></pre></article><article class="example-card"><h3>Or drive a room from code</h3><pre data-language="ts"><code>const room = wire.room(&quot;lobby&quot;);
room.on(&quot;chat&quot;, (msg) =&gt; console.log(msg.user, msg.text));
room.send(&#123; type: &quot;chat&quot;, user: &quot;ada&quot;, text: &quot;hi&quot; &#125;);</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="#overview">Overview</a><a class="toc-level-3" href="#api">API</a><a class="toc-level-4" href="#runtime-strings">Runtime strings</a><a class="toc-level-4" href="#accessor-functions">Accessor functions</a><a class="toc-level-4" href="#browser-reactive-directives">Browser: reactive directives</a><a class="toc-level-4" href="#browser-navigation">Browser: navigation</a><a class="toc-level-4" href="#browser-realtime-rooms">Browser: realtime rooms</a><a class="toc-level-3" href="#usage">Usage</a><a class="toc-level-3" href="#requirements-notes">Requirements / Notes</a><a class="toc-level-2" href="#api">Complete API</a><a class="toc-level-2" href="#examples">Examples</a></nav></aside>
</main>
<footer>WRNexusJS 0.2.23 · Private Developer Preview · Bun-native · Documentation generated from installed package APIs.</footer>
<footer>WRNexusJS 0.2.24 · Private Developer Preview · Bun-native · Documentation generated from installed package APIs.</footer>
</div>
}
}