feat: build private preview framework portal

This commit is contained in:
2026-07-12 23:23:31 +05:30
parent 9e8fb14a8c
commit a95766039c
43 changed files with 1125 additions and 131 deletions
+14 -83
View File
@@ -1,90 +1,21 @@
page Languageanddirectives {
page Thewrnlanguage {
seo {
title = "Language and directives"
description = "Complete WRNexusJS language reference for events, directives, loops, conditionals, data, components, forms, realtime, and native behavior."
title = "The .wrn language"
description = "Reference for WRNexusJS .wrn pages, components, layouts, props, state, directives, forms, security, and errors."
canonical = "https://wrnexusjs.dev/language"
}
view {
<a class="skip-link" href="#main">Skip to content</a>
<div class="docs-shell">
<header class="topbar">
<a class="brand" href="/"><span>W</span> WRNexusJS</a>
<nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav>
<button data-wire-theme-toggle class="theme-button" aria-label="Toggle theme">Theme</button>
</header>
<main class="page"><article class="documentation prose standalone language-reference"><span class="eyebrow">Complete reference</span><h1>Language and directives</h1><p>This page documents the .wrn language and declarative browser features that span multiple packages.</p>
<h2 id="file-anatomy">File anatomy</h2><p>A file declares a <code>page</code> or <code>component</code> and can contain metadata, props, state, data, view, style, server functions, APIs, and realtime handlers.</p><pre><code>page Dashboard &#123;
layout = &quot;default&quot;
seo &#123; title = &quot;Dashboard&quot; &#125;
<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="/tutorial">Tutorial</a><a href="/architecture">Architecture</a><a href="/language">.wrn language</a><a href="/packages">Packages</a><a href="/examples">Examples</a><a href="/roadmap">Roadmap</a><a href="/changelog">Changelog</a><a href="/security">Security</a><a href="/support">Support</a><a href="/search">Search</a></nav><a class="preview-pill" href="/access">Private preview · v0.2.15</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme">Theme</button></header>
<div class="mobile-doc-nav"><details><summary>Browse documentation</summary><nav><a href="/getting-started">Get started</a><a href="/tutorial">Tutorial</a><a href="/architecture">Architecture</a><a href="/language">.wrn language</a><a href="/packages">Packages</a><a href="/examples">Examples</a><a href="/roadmap">Roadmap</a><a href="/changelog">Changelog</a><a href="/security">Security</a><a href="/support">Support</a><a href="/search">Search</a></nav></details></div>
<main id="main" class="portal-main"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span aria-hidden="true">/</span><span>Documentation</span><span aria-hidden="true">/</span><span aria-current="page">The .wrn language</span></nav><article class="documentation prose standalone"><span class="status status-beta">Language reference · 0.2.15</span><h1>The <code>.wrn</code> language</h1><nav class="local-toc" aria-label="On this page"><a href="#anatomy">Anatomy</a><a href="#state">Props and state</a><a href="#server">Server control flow</a><a href="#directives">Directives</a><a href="#security">Security</a><a href="#errors">Errors</a></nav><h2 id="anatomy">File anatomy</h2><pre><code>page Account &#123;
layout = "public"
seo &#123; title = "Account" description = "Manage your account." &#125;
state count = 0
view &#123; &lt;button @click=&quot;count++&quot;&gt;&#123;count&#125;&lt;/button&gt; &#125;
style &#123; button &#123; padding: 12px; &#125; &#125;
&#125;</code></pre>
<h2 id="state">State and interpolation</h2><p>State is scoped to the nearest generated <code>data-scope</code>. Text expressions update reactively after hydration.</p><pre><code>state count = 0
state user = &#123; name: &quot;Ada&quot; &#125;
view &#123;
&lt;p&gt;Count: &#123;count&#125;&lt;/p&gt;
&lt;p&gt;&#123;user.name&#125;&lt;/p&gt;
&#125;</code></pre>
<h2 id="events">Events</h2><p>Any DOM event can use <code>@event="statement"</code>. The compiler emits <code>data-on-event</code>. The expression receives <code>event</code> and can mutate state.</p><div class="table-wrap"><table><thead><tr><th>Syntax</th><th>Purpose</th></tr></thead><tbody><tr><td><code>@click</code></td><td>Pointer or keyboard activation.</td></tr><tr><td><code>@input</code></td><td>Read live field values.</td></tr><tr><td><code>@change</code></td><td>React to committed field changes.</td></tr><tr><td><code>@submit</code></td><td>Handle form submission behavior.</td></tr><tr><td><code>@browser-click</code></td><td>Run only in a browser target.</td></tr><tr><td><code>@mobile-click</code></td><td>Run only in a native/mobile target.</td></tr></tbody></table></div><pre><code>&lt;input @input=&quot;name = event.target.value&quot;&gt;
&lt;button @click=&quot;count++&quot;&gt;Add&lt;/button&gt;
&lt;form @submit=&quot;submitted = true&quot;&gt;...&lt;/form&gt;</code></pre>
<h2 id="directives">Reactive data attributes</h2><div class="table-wrap"><table><thead><tr><th>Directive</th><th>Behavior</th></tr></thead><tbody><tr><td><code>data-scope</code></td><td>Declares reactive state for a subtree.</td></tr><tr><td><code>data-text</code></td><td>Synchronizes textContent with an expression.</td></tr><tr><td><code>data-show</code></td><td>Shows or hides an element by truthiness.</td></tr><tr><td><code>data-for</code></td><td>Repeats an element for a client-side list.</td></tr><tr><td><code>data-on-&lt;event&gt;</code></td><td>Compiled form of an event binding.</td></tr><tr><td><code>data-component</code></td><td>Mounts a server-rendered component.</td></tr><tr><td><code>data-slot</code></td><td>Fills a named component or layout slot.</td></tr><tr><td><code>data-wrnexus-csr</code></td><td>Connects generated client data fetching.</td></tr></tbody></table></div>
<h2 id="conditionals">Conditional rendering</h2><h3>Server conditionals</h3><p>Server blocks render only the selected branch into the response.</p><pre><code>&#123;#if user.isAdmin&#125;
&lt;a href=&quot;/admin&quot;&gt;Admin&lt;/a&gt;
&#123;:else if user&#125;
&lt;p&gt;Welcome &#123;user.name&#125;&lt;/p&gt;
&#123;:else&#125;
&lt;a href=&quot;/login&quot;&gt;Sign in&lt;/a&gt;
&#123;/if&#125;</code></pre><h3>Client visibility</h3><pre><code>&lt;section data-show=&quot;open&quot;&gt;Visible while open is true&lt;/section&gt;</code></pre>
<h2 id="loops">Loops and lists</h2><h3>Server each block</h3><pre><code>&#123;#each users as user, i&#125;
&lt;p&gt;&#123;i + 1&#125;. &#123;user.name&#125;&lt;/p&gt;
&#123;:empty&#125;
&lt;p&gt;No users&lt;/p&gt;
&#123;/each&#125;</code></pre><h3>Reactive client loop</h3><pre><code>&lt;li data-for=&quot;item, i in items&quot;&gt;
&lt;span data-text=&quot;item.name&quot;&gt;&lt;/span&gt;
&lt;button data-on-click=&quot;items = items.filter(x =&gt; x !== item)&quot;&gt;Remove&lt;/button&gt;
&lt;/li&gt;</code></pre>
<h2 id="components">Components, props, and slots</h2><pre><code>component Card &#123;
props &#123; title = &quot;Card&quot; &#125;
view &#123;
&lt;article&gt;&lt;h2&gt;&#123;title&#125;&lt;/h2&gt;&lt;slot&gt;&lt;/slot&gt;&lt;/article&gt;
&#125;
&#125;
&lt;div data-component=&quot;card&quot; title=&quot;Profile&quot;&gt;
&lt;p&gt;Card content&lt;/p&gt;
&lt;/div&gt;</code></pre>
<h2 id="data">Server and client data</h2><p>Use named data bindings for SSR data or client hydration. Secrets and database work stay on the server.</p><pre><code>data users &#123;
ssr GET &quot;/api/users&quot;
&#125;
view &#123;
&#123;#each users as user&#125;&lt;p&gt;&#123;user.name&#125;&lt;/p&gt;&#123;/each&#125;
&#125;</code></pre>
<h2 id="forms">Forms and validation</h2><p>Schema-backed forms validate in the browser and on the server with the same descriptor.</p><pre><code>&lt;form data-schema=&quot;login&quot; method=&quot;post&quot; action=&quot;/api/login&quot; data-redirect=&quot;/dashboard&quot;&gt;
&lt;input name=&quot;email&quot; type=&quot;email&quot;&gt;
&lt;span data-error=&quot;email&quot;&gt;&lt;/span&gt;
&lt;button&gt;Sign in&lt;/button&gt;
&lt;p data-success=&quot;Signed in&quot; hidden&gt;&lt;/p&gt;
&lt;/form&gt;</code></pre>
<h2 id="i18n">Internationalization and themes</h2><pre><code>&lt;h1&gt;&#123;t:home.title&#125;&lt;/h1&gt;
&lt;button data-wire-lang-set=&quot;fr&quot;&gt;Français&lt;/button&gt;
&lt;button data-wire-theme-toggle&gt;Toggle theme&lt;/button&gt;
&lt;button data-wire-theme-set=&quot;dark&quot;&gt;Dark&lt;/button&gt;</code></pre>
<h2 id="realtime">Realtime rooms</h2><pre><code>&lt;div data-room=&quot;chat&quot; data-room-user=&quot;Ada&quot;&gt;
&lt;span data-room-status&gt;&lt;/span&gt;
&lt;div data-room-log&gt;&lt;/div&gt;
&lt;template data-room-item=&quot;message&quot;&gt;&lt;p&gt;%user%: %text%&lt;/p&gt;&lt;/template&gt;
&lt;form data-room-send&gt;&lt;input name=&quot;text&quot; data-room-reset&gt;&lt;/form&gt;
&lt;/div&gt;</code></pre>
<h2 id="native">Browser and native directives</h2><pre><code>&lt;button data-native-browser=&quot;share&quot; data-native-mobile=&quot;share&quot;
data-native-options='&#123;&quot;title&quot;:&quot;WRNexusJS&quot;&#125;'&gt;Share&lt;/button&gt;
&lt;nav data-native-only=&quot;mobile&quot;&gt;Mobile navigation&lt;/nav&gt;
&lt;p data-native-only=&quot;browser&quot;&gt;Browser instructions&lt;/p&gt;
&lt;button data-native-requires=&quot;haptics&quot;&gt;Haptic action&lt;/button&gt;</code></pre>
<h2 id="other">Other framework attributes</h2><div class="table-wrap"><table><thead><tr><th>Attribute</th><th>Purpose</th></tr></thead><tbody><tr><td><code>data-error</code></td><td>Field validation error destination.</td></tr><tr><td><code>data-success</code></td><td>Successful form message.</td></tr><tr><td><code>data-redirect</code></td><td>Navigation after form success.</td></tr><tr><td><code>data-room-*</code></td><td>Realtime status, templates, sending, and reset behavior.</td></tr><tr><td><code>data-uploader</code></td><td>Config-driven upload widget.</td></tr><tr><td><code>data-wire-theme-*</code></td><td>Theme selection and toggling.</td></tr><tr><td><code>data-wire-lang*</code></td><td>Language selection.</td></tr><tr><td><code>data-native-*</code></td><td>Cross-platform capability and visibility behavior.</td></tr></tbody></table></div></article></main>
<footer>WRNexusJS 0.2.15 · SSR-first · Bun-native · Documentation generated from published package APIs.</footer>
view &#123; &lt;button @click="count++"&gt;Count &#123;count&#125;&lt;/button&gt; &#125;
&#125;</code></pre><h2 id="state">Pages, components, layouts, props, and state</h2><p>Pages are routes. Components declare default-valued props and may hold state. Layouts provide shared slots. Mount components with <code>data-component</code>; fill default or named slots with <code>data-slot</code>.</p><h2 id="server">Interpolation, conditionals, and loops</h2><p>Interpolation is HTML-escaped. Use server <code>&#123;#if&#125;</code> and <code>&#123;#each&#125;</code> for SSR data. Use <code>data-show</code> for reactive client visibility.</p><h2 id="directives">Events and directives</h2><p><code>@click</code> and other events execute in the reactive scope. Data attributes opt into forms, i18n, themes, realtime, uploader, browser, and mobile behavior. Consult the exact package page because availability varies.</p><h2 id="forms">Forms, i18n, themes, and realtime</h2><p><code>form[data-schema]</code> connects descriptors to client and server validation. Translation keys use <code>&#123;t:key&#125;</code>. Theme toggles use <code>data-wire-theme-toggle</code>. Realtime pages opt into a named room.</p><h2 id="security">Escaping and security</h2><p>Text interpolation is escaped by default. Do not construct trusted HTML from user input. Server-only refinements must be repeated at the authoritative mutation boundary.</p><h2 id="errors">Common compiler errors</h2><ul><li>Use balanced braces; a literal brace must be escaped.</li><li>Declare UI in <code>view</code>, not JSX or hooks.</li><li>Use a valid page, component, or layout declaration matching the file role.</li><li>Keep server loops tied to available SSR bindings.</li><li>Check <a href="/guides/troubleshooting">troubleshooting</a> and <a href="/packages/compiler">compiler API</a> for this release.</li></ul></article></main>
<footer><p><strong>WRNexusJS 0.2.15</strong> · Private Developer Preview · Bun-native</p><nav aria-label="Footer"><a href="/access">Request access</a><a href="/license">License</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p>WRNexusJS is created by <a href="https://workroot.in/">WorkRoot</a>. WRNexus is a separate SaaS product.</p></footer>
</div>
}
}
}