Files
WRNexusJSDoc/app/pages/packages/store.wrn
T

69 lines
7.0 KiB
Plaintext

page wrnexusstore {
seo {
title = "@wrnexus/store"
description = "Application state stores shared across server and browser runtimes."
}
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/store</span></nav><section class="doc-intro"><span class="eyebrow">Data · Package reference</span><h1>@wrnexus/store</h1><p>Application state stores shared across server and browser runtimes.</p><div class="doc-meta"><span>v0.8.7</span><span>Private registry</span><span>Data</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/store@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"><p>Typed global and page-scoped WRNexusJS stores with runtime-specific state, computed values, actions, lifecycle hooks, persistence, SSR isolation, and HMR support.</p>
<p>Use <code>defineStore()</code> to declare a store and <code>createStoreContainer()</code> to create an isolated request or browser container. Store definitions are framework helpers and do not require UI components.</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>import &#123; StoreMutation, StoreFunction, StoreDefinition, StoreInstance, StoreCombinedState &#125; from './types.js';
export &#123; PersistenceStorage, StoreActionContext, StoreActionDefinition, StoreInstanceCore, StoreKind, StoreLifecycleContext, StorePersistenceConfig, StoreRuntime &#125; from './types.js';
declare function defineStore&lt;S extends object, C extends object = Record&lt;string, never&gt;, A extends Record&lt;string, StoreFunction&gt; = Record&lt;string, StoreFunction&gt;, CS extends object = Record&lt;string, never&gt;, SS extends object = Record&lt;string, never&gt;&gt;(definition: StoreDefinition&lt;S, C, A, CS, SS&gt;): StoreDefinition&lt;S, C, A, CS, SS&gt;;
interface StoreContainerOptions &#123;
runtime: &quot;server&quot; | &quot;client&quot;;
request?: unknown;
routeId?: string;
hydration?: Record&lt;string, unknown&gt;;
onMutation?: (mutation: StoreMutation) =&gt; void;
&#125;
declare class StoreContainer &#123;
readonly runtime: &quot;server&quot; | &quot;client&quot;;
readonly request?: unknown;
readonly routeId?: string;
private readonly instances;
private readonly hydration;
private readonly onMutation?;
private readonly lastMutations;
constructor(options: StoreContainerOptions);
use&lt;S extends object, C extends object, A extends Record&lt;string, StoreFunction&gt;, CS extends object, SS extends object&gt;(definition: StoreDefinition&lt;S, C, A, CS, SS&gt;): Promise&lt;StoreInstance&lt;StoreCombinedState&lt;S, CS, SS&gt;, C, A&gt;&gt;;
serialize(): Record&lt;string, unknown&gt;;
inspect(): Array&lt;&#123;
name: string;
kind: &quot;global&quot; | &quot;page&quot;;
state: Readonly&lt;Record&lt;string, unknown&gt;&gt;;
computed: Readonly&lt;Record&lt;string, unknown&gt;&gt;;
lastAction?: string;
changed: string[];
hydrationSource: &quot;server&quot; | &quot;persistence&quot; | &quot;initial&quot;;
&#125;&gt;;
hotUpdate&lt;S extends object, C extends object, A extends Record&lt;string, StoreFunction&gt;, CS extends object, SS extends object&gt;(definition: StoreDefinition&lt;S, C, A, CS, SS&gt;): Promise&lt;&#123;
preserved: string[];
reset: string[];
&#125;&gt;;
disposePageStores(): Promise&lt;void&gt;;
dispose(): Promise&lt;void&gt;;
&#125;
declare function createStoreContainer(options: StoreContainerOptions): StoreContainer;
declare function createStoreInstance&lt;S extends object, C extends object, A extends Record&lt;string, StoreFunction&gt;, CS extends object, SS extends object&gt;(definition: StoreDefinition&lt;S, C, A, CS, SS&gt;, options: Omit&lt;StoreContainerOptions, &quot;hydration&quot;&gt; &amp; &#123;
hydration?: unknown;
&#125;): StoreInstance&lt;StoreCombinedState&lt;S, CS, SS&gt;, C, A&gt;;
export &#123; StoreCombinedState, StoreContainer, type StoreContainerOptions, StoreDefinition, StoreFunction, StoreInstance, StoreMutation, createStoreContainer, createStoreInstance, defineStore &#125;;
</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>Install @wrnexus/store</h3><pre data-language="sh"><code>bun add @wrnexus/store</code></pre></article><article class="example-card"><h3>Import @wrnexus/store</h3><pre data-language="ts"><code>import * as store from &quot;@wrnexus/store&quot;;</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-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>
}
}