UNPKG

sandai-react

Version:

React components and utilities for the Sandai 3D AI Characters.

97 lines (92 loc) 19.6 kB
<!DOCTYPE html><html class="default" lang="en" data-base="."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>sandai-react - v0.0.5</title><meta name="description" content="Documentation for sandai-react"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/icons.js" id="tsd-icons-script"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">sandai-react - v0.0.5</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><h1>sandai-react - v0.0.5</h1></div><div class="tsd-panel tsd-typography"><a id="sandai-react" class="tsd-anchor"></a><h1 class="tsd-anchor-link">sandai-react<a href="#sandai-react" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h1><p>React components and utilities for the Sandai 3D AI Characters.</p> <a id="installation" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Installation<a href="#installation" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>To use <strong>sandai-react</strong>, install it via npm:</p> <pre><code class="sh"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">install</span><span class="hl-1"> </span><span class="hl-2">sandai-react</span> </code><button type="button">Copy</button></pre> <a id="components" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Components<a href="#components" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><a id="ai3dcharacter" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code>AI3DCharacter</code><a href="#ai3dcharacter" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>A React component that renders a 3D AI character using Sandai.</p> <a id="ai3dcharacter-props" class="tsd-anchor"></a><h4 class="tsd-anchor-link">AI3DCharacter Props<a href="#ai3dcharacter-props" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h4><table> <thead> <tr> <th>Prop</th> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>url</code></td> <td><code>string</code></td> <td>The base URL for the Sandai AI 3D character chat interface.</td> </tr> <tr> <td><code>onLoad</code></td> <td><code>(client: SandaiClient) =&gt; void</code></td> <td>Callback function triggered when the SandaiClient is loaded.</td> </tr> <tr> <td><code>vrmUrl</code></td> <td><code>string</code> <em>(optional)</em></td> <td>URL for the VRM model to be loaded as the 3D character.</td> </tr> <tr> <td><code>voiceName</code></td> <td><code>VoiceNames</code> <em>(optional)</em></td> <td>Name of the voice to be used by the 3D character.</td> </tr> <tr> <td><code>showControls</code></td> <td><code>boolean</code> <em>(optional)</em></td> <td>Determines if controls should be displayed in the interface.</td> </tr> </tbody> </table> <a id="ai3dcharacter-example-usage" class="tsd-anchor"></a><h4 class="tsd-anchor-link">AI3DCharacter Example Usage<a href="#ai3dcharacter-example-usage" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="tsx"><span class="hl-3">import</span><span class="hl-1"> { </span><span class="hl-4">AI3DCharacter</span><span class="hl-1"> } </span><span class="hl-3">from</span><span class="hl-1"> </span><span class="hl-2">&quot;sandai-react&quot;</span><span class="hl-1">;</span><br/><br/><span class="hl-5">const</span><span class="hl-1"> </span><span class="hl-0">handleLoad</span><span class="hl-1"> = (</span><span class="hl-4">client</span><span class="hl-1">) </span><span class="hl-5">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-4">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">&quot;Sandai Client Loaded&quot;</span><span class="hl-1">, </span><span class="hl-4">client</span><span class="hl-1">);</span><br/><span class="hl-1">};</span><br/><br/><span class="hl-6">&lt;</span><span class="hl-7">AI3DCharacter</span><br/><span class="hl-1"> </span><span class="hl-8">url</span><span class="hl-1">=</span><span class="hl-2">&quot;https://sandai.org/chat&quot;</span><br/><span class="hl-1"> </span><span class="hl-8">onLoad</span><span class="hl-1">=</span><span class="hl-5">{</span><span class="hl-4">handleLoad</span><span class="hl-5">}</span><br/><span class="hl-1"> </span><span class="hl-8">vrmUrl</span><span class="hl-1">=</span><span class="hl-2">&quot;https://example.com/model.vrm&quot;</span><br/><span class="hl-1"> </span><span class="hl-8">voiceName</span><span class="hl-1">=</span><span class="hl-2">&quot;ruri&quot;</span><br/><span class="hl-1"> </span><span class="hl-8">showControls</span><span class="hl-1">=</span><span class="hl-5">{true}</span><br/><span class="hl-6">/&gt;</span> </code><button type="button">Copy</button></pre> <hr> <a id="ai3dcharacterdocs" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code>AI3DCharacterDocs</code><a href="#ai3dcharacterdocs" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>A React component that renders interactive documentation for functions exposed by the <code>SandaiClient</code> instance.</p> <a id="ai3dcharacterdocs-props" class="tsd-anchor"></a><h4 class="tsd-anchor-link">AI3DCharacterDocs Props<a href="#ai3dcharacterdocs-props" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h4><table> <thead> <tr> <th>Prop</th> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>client</code></td> <td><code>SandaiClient</code></td> <td>The SandaiClient instance retrieved from the <code>onLoad</code> callback of <code>AI3DCharacter</code>.</td> </tr> </tbody> </table> <a id="ai3dcharacterdocs-example-usage" class="tsd-anchor"></a><h4 class="tsd-anchor-link">AI3DCharacterDocs Example Usage<a href="#ai3dcharacterdocs-example-usage" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="tsx"><span class="hl-3">import</span><span class="hl-1"> { </span><span class="hl-4">AI3DCharacter</span><span class="hl-1">, </span><span class="hl-4">AI3DCharacterDocs</span><span class="hl-1"> } </span><span class="hl-3">from</span><span class="hl-1"> </span><span class="hl-2">&quot;sandai-react&quot;</span><span class="hl-1">;</span><br/><span class="hl-3">import</span><span class="hl-1"> { </span><span class="hl-4">useState</span><span class="hl-1"> } </span><span class="hl-3">from</span><span class="hl-1"> </span><span class="hl-2">&quot;react&quot;</span><span class="hl-1">;</span><br/><br/><span class="hl-5">const</span><span class="hl-1"> </span><span class="hl-0">App</span><span class="hl-1"> = () </span><span class="hl-5">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-5">const</span><span class="hl-1"> [</span><span class="hl-9">client</span><span class="hl-1">, </span><span class="hl-9">setClient</span><span class="hl-1">] = </span><span class="hl-0">useState</span><span class="hl-1">(</span><span class="hl-5">null</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-3">return</span><span class="hl-1"> (</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;&gt;</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;</span><span class="hl-7">AI3DCharacter</span><br/><span class="hl-1"> </span><span class="hl-8">url</span><span class="hl-1">=</span><span class="hl-2">&quot;https://sandai.org/chat&quot;</span><br/><span class="hl-1"> </span><span class="hl-8">onLoad</span><span class="hl-1">=</span><span class="hl-5">{</span><span class="hl-4">setClient</span><span class="hl-5">}</span><br/><span class="hl-1"> </span><span class="hl-8">showControls</span><br/><span class="hl-1"> </span><span class="hl-6">/&gt;</span><br/><span class="hl-1"> </span><span class="hl-5">{</span><span class="hl-4">client</span><span class="hl-10"> </span><span class="hl-1">&amp;&amp;</span><span class="hl-10"> </span><span class="hl-6">&lt;</span><span class="hl-7">AI3DCharacterDocs</span><span class="hl-10"> </span><span class="hl-8">client</span><span class="hl-1">=</span><span class="hl-5">{</span><span class="hl-4">client</span><span class="hl-5">}</span><span class="hl-10"> </span><span class="hl-6">/&gt;</span><span class="hl-5">}</span><br/><span class="hl-1"> </span><span class="hl-6">&lt;/&gt;</span><br/><span class="hl-1"> );</span><br/><span class="hl-1">};</span> </code><button type="button">Copy</button></pre> <hr> <a id="functiontester" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><code>FunctionTester</code><a href="#functiontester" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h3><p>A reusable form component that dynamically generates input fields based on a schema and executes a function when submitted.</p> <a id="functiontester-props" class="tsd-anchor"></a><h4 class="tsd-anchor-link">FunctionTester Props<a href="#functiontester-props" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h4><table> <thead> <tr> <th>Prop</th> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>func</code></td> <td><code>Function</code></td> <td>The function to be tested, receiving input values as arguments.</td> </tr> <tr> <td><code>schema</code></td> <td><code>SchemaType[]</code></td> <td>An array of schema objects defining the function parameters.</td> </tr> </tbody> </table> <a id="functiontester-example-usage" class="tsd-anchor"></a><h4 class="tsd-anchor-link">FunctionTester Example Usage<a href="#functiontester-example-usage" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="tsx"><span class="hl-3">import</span><span class="hl-1"> { </span><span class="hl-4">FunctionTester</span><span class="hl-1"> } </span><span class="hl-3">from</span><span class="hl-1"> </span><span class="hl-2">&quot;sandai-react&quot;</span><span class="hl-1">;</span><br/><br/><span class="hl-5">const</span><span class="hl-1"> </span><span class="hl-0">myFunction</span><span class="hl-1"> = (</span><span class="hl-4">name</span><span class="hl-1">, </span><span class="hl-4">age</span><span class="hl-1">) </span><span class="hl-5">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-4">console</span><span class="hl-1">.</span><span class="hl-0">log</span><span class="hl-1">(</span><span class="hl-2">`Name: </span><span class="hl-5">${</span><span class="hl-4">name</span><span class="hl-5">}</span><span class="hl-2">, Age: </span><span class="hl-5">${</span><span class="hl-4">age</span><span class="hl-5">}</span><span class="hl-2">`</span><span class="hl-1">);</span><br/><span class="hl-1">};</span><br/><br/><span class="hl-5">const</span><span class="hl-1"> </span><span class="hl-9">schema</span><span class="hl-1"> = [</span><br/><span class="hl-1"> { </span><span class="hl-4">id:</span><span class="hl-1"> </span><span class="hl-2">&quot;name&quot;</span><span class="hl-1">, </span><span class="hl-4">type:</span><span class="hl-1"> </span><span class="hl-2">&quot;text&quot;</span><span class="hl-1">, </span><span class="hl-4">label:</span><span class="hl-1"> </span><span class="hl-2">&quot;Name&quot;</span><span class="hl-1"> },</span><br/><span class="hl-1"> { </span><span class="hl-4">id:</span><span class="hl-1"> </span><span class="hl-2">&quot;age&quot;</span><span class="hl-1">, </span><span class="hl-4">type:</span><span class="hl-1"> </span><span class="hl-2">&quot;number&quot;</span><span class="hl-1">, </span><span class="hl-4">label:</span><span class="hl-1"> </span><span class="hl-2">&quot;Age&quot;</span><span class="hl-1"> }</span><br/><span class="hl-1">];</span><br/><br/><span class="hl-6">&lt;</span><span class="hl-7">FunctionTester</span><span class="hl-1"> </span><span class="hl-8">func</span><span class="hl-1">=</span><span class="hl-5">{</span><span class="hl-4">myFunction</span><span class="hl-5">}</span><span class="hl-1"> </span><span class="hl-8">schema</span><span class="hl-1">=</span><span class="hl-5">{</span><span class="hl-4">schema</span><span class="hl-5">}</span><span class="hl-1"> </span><span class="hl-6">/&gt;</span><span class="hl-1">;</span> </code><button type="button">Copy</button></pre> <hr> <a id="contributing" class="tsd-anchor"></a><h2 class="tsd-anchor-link">Contributing<a href="#contributing" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>Contributions are welcome! If you have suggestions or find issues, feel free to open a pull request.</p> <a id="license" class="tsd-anchor"></a><h2 class="tsd-anchor-link">License<a href="#license" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="assets/icons.svg#icon-anchor"></use></svg></a></h2><p>This project is licensed under the MIT License. See the <code>LICENSE</code> file for details.</p> </div></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><a href="#sandai-react"><span>sandai-<wbr/>react</span></a><ul><li><a href="#installation"><span>Installation</span></a></li><li><a href="#components"><span>Components</span></a></li><li><ul><li><a href="#ai3dcharacter"><span>AI3DCharacter</span></a></li><li><ul><li><a href="#ai3dcharacter-props"><span>AI3DCharacter <wbr/>Props</span></a></li><li><a href="#ai3dcharacter-example-usage"><span>AI3DCharacter <wbr/>Example <wbr/>Usage</span></a></li></ul></li><li><a href="#ai3dcharacterdocs"><span>AI3DCharacter<wbr/>Docs</span></a></li><li><ul><li><a href="#ai3dcharacterdocs-props"><span>AI3DCharacter<wbr/>Docs <wbr/>Props</span></a></li><li><a href="#ai3dcharacterdocs-example-usage"><span>AI3DCharacter<wbr/>Docs <wbr/>Example <wbr/>Usage</span></a></li></ul></li><li><a href="#functiontester"><span>Function<wbr/>Tester</span></a></li><li><ul><li><a href="#functiontester-props"><span>Function<wbr/>Tester <wbr/>Props</span></a></li><li><a href="#functiontester-example-usage"><span>Function<wbr/>Tester <wbr/>Example <wbr/>Usage</span></a></li></ul></li></ul></li><li><a href="#contributing"><span>Contributing</span></a></li><li><a href="#license"><span>License</span></a></li></ul></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="modules.html">sandai-react - v0.0.5</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>