Skip to content

Commit

Permalink
v5.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgpearce committed Dec 4, 2024
1 parent a2637d7 commit 72d01de
Show file tree
Hide file tree
Showing 167 changed files with 686 additions and 451 deletions.
2 changes: 1 addition & 1 deletion coverage.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"tests":7461,"assertions":33209,"lines":{"total":2286,"covered":2286,"skipped":0,"pct":100},"statements":{"total":2468,"covered":2468,"skipped":0,"pct":100},"functions":{"total":986,"covered":986,"skipped":0,"pct":100},"branches":{"total":854,"covered":854,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
{"tests":7463,"assertions":33200,"lines":{"total":2288,"covered":2288,"skipped":0,"pct":100},"statements":{"total":2472,"covered":2472,"skipped":0,"pct":100},"functions":{"total":988,"covered":988,"skipped":0,"pct":100},"branches":{"total":854,"covered":854,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
32 changes: 27 additions & 5 deletions docs/api/all.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@
<span class="comment">// On the server:</span>
<span class="keyword">const</span> webSocketServer <span class="operator">=</span> <span class="keyword">new</span> <span class="class-name">WebSocketServer</span><span class="punctuation">(</span><span class="punctuation">{</span><span class="literal-property">port</span><span class="operator">:</span> <span class="number">8047</span><span class="punctuation">}</span><span class="punctuation">)</span><span class="punctuation">;</span>
webSocketServer<span class="punctuation">.</span><span class="function">on</span><span class="punctuation">(</span><span class="string">'connection'</span><span class="punctuation">,</span> <span class="punctuation">(</span><span class="parameter">_<span class="punctuation">,</span> request</span><span class="punctuation">)</span> <span class="operator">=></span> <span class="punctuation">{</span>
console<span class="punctuation">.</span><span class="function">log</span><span class="punctuation">(</span><span class="string">'Client address: '</span> <span class="operator">+</span> request<span class="punctuation">.</span>socket<span class="punctuation">.</span>remoteAddress<span class="punctuation">)</span><span class="punctuation">;</span>
<span class="keyword">const</span> clientAddress <span class="operator">=</span> request<span class="punctuation">.</span>socket<span class="punctuation">.</span>remoteAddress<span class="punctuation">;</span>
<span class="keyword">if</span> <span class="punctuation">(</span>clientAddress <span class="operator">==</span> <span class="string">'::1'</span> <span class="operator">||</span> clientAddress <span class="operator">==</span> <span class="string">'::ffff:127.0.0.1'</span><span class="punctuation">)</span> <span class="punctuation">{</span>
console<span class="punctuation">.</span><span class="function">log</span><span class="punctuation">(</span><span class="string">'Local client connected'</span><span class="punctuation">)</span><span class="punctuation">;</span>
<span class="punctuation">}</span>
<span class="punctuation">}</span><span class="punctuation">)</span><span class="punctuation">;</span>
<span class="keyword">const</span> server <span class="operator">=</span> <span class="function"><a href="/api/synchronizer-ws-server/functions/creation/createwsserver/">createWsServer</a></span><span class="punctuation">(</span>webSocketServer<span class="punctuation">)</span><span class="punctuation">;</span>

Expand All @@ -156,7 +159,7 @@
<span class="function"><a href="/api/mergeable-store/functions/creation/createmergeablestore/">createMergeableStore</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span>
<span class="keyword">new</span> <span class="class-name">WebSocket</span><span class="punctuation">(</span><span class="string">'ws://localhost:8047'</span><span class="punctuation">)</span><span class="punctuation">,</span>
<span class="punctuation">)</span><span class="punctuation">;</span>
<span class="comment">// -> 'Client address: ::1'</span>
<span class="comment">// -> 'Local client connected'</span>

synchronizer<span class="punctuation">.</span><span class="function"><a href="/api/synchronizer-ws-server/interfaces/server/wsserver/methods/getter/destroy/">destroy</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
server<span class="punctuation">.</span><span class="function"><a href="/api/synchronizer-ws-server/interfaces/server/wsserver/methods/getter/destroy/">destroy</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@
<span class="comment">// On the server:</span>
<span class="keyword">const</span> webSocketServer <span class="operator">=</span> <span class="keyword">new</span> <span class="class-name">WebSocketServer</span><span class="punctuation">(</span><span class="punctuation">{</span><span class="literal-property">port</span><span class="operator">:</span> <span class="number">8047</span><span class="punctuation">}</span><span class="punctuation">)</span><span class="punctuation">;</span>
webSocketServer<span class="punctuation">.</span><span class="function">on</span><span class="punctuation">(</span><span class="string">'connection'</span><span class="punctuation">,</span> <span class="punctuation">(</span><span class="parameter">_<span class="punctuation">,</span> request</span><span class="punctuation">)</span> <span class="operator">=></span> <span class="punctuation">{</span>
console<span class="punctuation">.</span><span class="function">log</span><span class="punctuation">(</span><span class="string">'Client address: '</span> <span class="operator">+</span> request<span class="punctuation">.</span>socket<span class="punctuation">.</span>remoteAddress<span class="punctuation">)</span><span class="punctuation">;</span>
<span class="keyword">const</span> clientAddress <span class="operator">=</span> request<span class="punctuation">.</span>socket<span class="punctuation">.</span>remoteAddress<span class="punctuation">;</span>
<span class="keyword">if</span> <span class="punctuation">(</span>clientAddress <span class="operator">==</span> <span class="string">'::1'</span> <span class="operator">||</span> clientAddress <span class="operator">==</span> <span class="string">'::ffff:127.0.0.1'</span><span class="punctuation">)</span> <span class="punctuation">{</span>
console<span class="punctuation">.</span><span class="function">log</span><span class="punctuation">(</span><span class="string">'Local client connected'</span><span class="punctuation">)</span><span class="punctuation">;</span>
<span class="punctuation">}</span>
<span class="punctuation">}</span><span class="punctuation">)</span><span class="punctuation">;</span>
<span class="keyword">const</span> server <span class="operator">=</span> <span class="function"><a href="/api/synchronizer-ws-server/functions/creation/createwsserver/">createWsServer</a></span><span class="punctuation">(</span>webSocketServer<span class="punctuation">)</span><span class="punctuation">;</span>

Expand All @@ -156,7 +159,7 @@
<span class="function"><a href="/api/mergeable-store/functions/creation/createmergeablestore/">createMergeableStore</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">,</span>
<span class="keyword">new</span> <span class="class-name">WebSocket</span><span class="punctuation">(</span><span class="string">'ws://localhost:8047'</span><span class="punctuation">)</span><span class="punctuation">,</span>
<span class="punctuation">)</span><span class="punctuation">;</span>
<span class="comment">// -> 'Client address: ::1'</span>
<span class="comment">// -> 'Local client connected'</span>

synchronizer<span class="punctuation">.</span><span class="function"><a href="/api/synchronizer-ws-server/interfaces/server/wsserver/methods/getter/destroy/">destroy</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
server<span class="punctuation">.</span><span class="function"><a href="/api/synchronizer-ws-server/interfaces/server/wsserver/methods/getter/destroy/">destroy</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/article.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/store-hooks/article.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/store-hooks/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/store-hooks/nav.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/store-hooks/usecell/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/store-hooks/usecell/nav.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/store-hooks/usehasrow/nav.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/store-hooks/userow/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/store-hooks/userow/nav.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/store-hooks/userowids/nav.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/ui-react/functions/store-hooks/usestore/nav.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions docs/api/ui-react/functions/store-hooks/usestores/article.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<nav><ul><li><a href="/">TinyBase</a></li><li><a href="/api/">API</a></li><li><a href="/api/ui-react/"><code>ui-react</code></a></li><li><a href="/api/ui-react/functions/">Functions</a></li><li><a href="/api/ui-react/functions/store-hooks/">Store hooks</a></li><li><a href="/api/ui-react/functions/store-hooks/usestores/"><code>useStores</code></a></li></ul></nav><section class="s1" id="/api/ui-react/functions/store-hooks/usestores/" data-id="uS2"><h1><code>useStores</code></h1><p>The <code>useStores</code> hook is used to get a reference to all the <a href="/api/store/interfaces/store/store/"><code>Store</code></a> objects named by <a href="/api/common/type-aliases/identity/id/"><code>Id</code></a> within a <a href="/api/ui-react/functions/context-components/provider/"><code>Provider</code></a> component context.</p><pre><code><span class="function"><a href="/api/ui-react/functions/store-hooks/usestores/">useStores</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="operator">:</span> <span class="punctuation">{</span><span class="punctuation">[</span>storeId<span class="operator">:</span> <span class="type"><a href="/api/common/type-aliases/identity/id/">Id</a></span><span class="punctuation">]</span><span class="operator">:</span> <span class="type"><a href="/api/store/interfaces/store/store/">Store</a></span><span class="punctuation">}</span></code></pre><div class="table"><table><tr><th class="right">returns</th><td><code><span class="punctuation">{</span><span class="punctuation">[</span>storeId<span class="operator">:</span> <span class="type"><a href="/api/common/type-aliases/identity/id/">Id</a></span><span class="punctuation">]</span><span class="operator">:</span> <span class="type"><a href="/api/store/interfaces/store/store/">Store</a></span><span class="punctuation">}</span></code></td><td><p></p><p>An object containing all the <a href="/api/store/interfaces/store/store/"><code>Store</code></a> objects named by <a href="/api/common/type-aliases/identity/id/"><code>Id</code></a>.</p><p></p></td></tr></table></div><p>A <a href="/api/ui-react/functions/context-components/provider/"><code>Provider</code></a> component is used to wrap part of an application in a context. It can contain a default <a href="/api/store/interfaces/store/store/"><code>Store</code></a> (or a set of <a href="/api/store/interfaces/store/store/"><code>Store</code></a> objects named by <a href="/api/common/type-aliases/identity/id/"><code>Id</code></a>) that can be easily accessed without having to be passed down as props through every component.</p><p>The <code>useStores</code> hook lets you get a reference to the latter as an object.</p><section class="s2"><h2>Example</h2><p>This example creates a Provider context into which a <a href="/api/store/interfaces/store/store/"><code>Store</code></a> is provided, named by <a href="/api/common/type-aliases/identity/id/"><code>Id</code></a>. A component within it then uses the <code>useStores</code> hook to get a reference to the <a href="/api/store/interfaces/store/store/"><code>Store</code></a> again.</p><pre><code><span class="keyword">import</span> <span class="punctuation">{</span>Provider<span class="punctuation">,</span> useStores<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'tinybase/ui-react'</span><span class="punctuation">;</span>
<span class="keyword">import</span> React <span class="keyword">from</span> <span class="string">'react'</span><span class="punctuation">;</span>
<span class="keyword">import</span> <span class="punctuation">{</span>createRoot<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'react-dom/client'</span><span class="punctuation">;</span>
<span class="keyword">import</span> <span class="punctuation">{</span>createStore<span class="punctuation">}</span> <span class="keyword">from</span> <span class="string">'tinybase'</span><span class="punctuation">;</span>

<span class="keyword">const</span> <span class="function-variable">App</span> <span class="operator">=</span> <span class="punctuation">(</span><span class="parameter"><span class="punctuation">{</span>store<span class="punctuation">}</span></span><span class="punctuation">)</span> <span class="operator">=></span> <span class="punctuation">(</span>
<span class="tag"><span class="tag"><span class="punctuation">&lt;</span><span class="class-name"><a href="/api/ui-react/functions/context-components/provider/">Provider</a></span></span> <span class="attr-name">storesById</span><span class="script"><span class="script-punctuation">=</span><span class="punctuation">{</span><span class="punctuation">{</span><span class="literal-property">petStore</span><span class="operator">:</span> store<span class="punctuation">}</span><span class="punctuation">}</span></span><span class="punctuation">></span></span><span class="plain-text">
</span><span class="tag"><span class="tag"><span class="punctuation">&lt;</span><span class="class-name">Pane</span></span> <span class="punctuation">/></span></span><span class="plain-text">
</span><span class="tag"><span class="tag"><span class="punctuation">&lt;/</span><span class="class-name"><a href="/api/ui-react/functions/context-components/provider/">Provider</a></span></span><span class="punctuation">></span></span>
<span class="punctuation">)</span><span class="punctuation">;</span>
<span class="keyword">const</span> <span class="function-variable">Pane</span> <span class="operator">=</span> <span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">=></span> <span class="punctuation">(</span>
<span class="tag"><span class="tag"><span class="punctuation">&lt;</span>span</span><span class="punctuation">></span></span><span class="punctuation">{</span><span class="function"><a href="/api/ui-react/functions/store-hooks/usestores/">useStores</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">[</span><span class="string">'petStore'</span><span class="punctuation">]</span><span class="punctuation">.</span><span class="function"><a href="/api/store/interfaces/store/store/methods/development/getlistenerstats/">getListenerStats</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">.</span>tables<span class="punctuation">}</span><span class="tag"><span class="tag"><span class="punctuation">&lt;/</span>span</span><span class="punctuation">></span></span>
<span class="punctuation">)</span><span class="punctuation">;</span>

<span class="keyword">const</span> store <span class="operator">=</span> <span class="function"><a href="/api/store/functions/creation/createstore/">createStore</a></span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
<span class="keyword">const</span> app <span class="operator">=</span> document<span class="punctuation">.</span><span class="function">createElement</span><span class="punctuation">(</span><span class="string">'div'</span><span class="punctuation">)</span><span class="punctuation">;</span>
<span class="function">createRoot</span><span class="punctuation">(</span>app<span class="punctuation">)</span><span class="punctuation">.</span><span class="function">render</span><span class="punctuation">(</span><span class="tag"><span class="tag"><span class="punctuation">&lt;</span><span class="class-name">App</span></span> <span class="attr-name">store</span><span class="script"><span class="script-punctuation">=</span><span class="punctuation">{</span>store<span class="punctuation">}</span></span> <span class="punctuation">/></span></span><span class="punctuation">)</span><span class="punctuation">;</span>
console<span class="punctuation">.</span><span class="function">log</span><span class="punctuation">(</span>app<span class="punctuation">.</span>innerHTML<span class="punctuation">)</span><span class="punctuation">;</span>
<span class="comment">// -> '&lt;span>0&lt;/span>'</span>
</code></pre></section><section class="s2"><h2>Since</h2><p>v5.4.1</p></section></section>
20 changes: 20 additions & 0 deletions docs/api/ui-react/functions/store-hooks/usestores/index.html

Large diffs are not rendered by default.

Loading

0 comments on commit 72d01de

Please sign in to comment.