tinybase 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/checkpoints.js +1 -1
- package/lib/checkpoints.js.gz +0 -0
- package/lib/debug/checkpoints.js +1 -1
- package/lib/debug/indexes.js +1 -1
- package/lib/debug/metrics.js +1 -1
- package/lib/debug/persisters.js +1 -1
- package/lib/debug/relationships.js +1 -1
- package/lib/debug/store.js +1 -1
- package/lib/debug/tinybase.js +2 -1021
- package/lib/debug/{react.d.ts → ui-react.d.ts} +1 -1
- package/lib/debug/{react.js → ui-react.js} +4 -4
- package/lib/indexes.js +1 -1
- package/lib/indexes.js.gz +0 -0
- package/lib/metrics.js +1 -1
- package/lib/metrics.js.gz +0 -0
- package/lib/persisters.js +1 -1
- package/lib/persisters.js.gz +0 -0
- package/lib/relationships.js +1 -1
- package/lib/relationships.js.gz +0 -0
- package/lib/store.js +1 -1
- package/lib/store.js.gz +0 -0
- package/lib/tinybase.js +1 -1
- package/lib/tinybase.js.gz +0 -0
- package/lib/{react.d.ts → ui-react.d.ts} +1 -1
- package/lib/ui-react.js +1 -0
- package/lib/ui-react.js.gz +0 -0
- package/lib/umd/checkpoints.js +1 -1
- package/lib/umd/checkpoints.js.gz +0 -0
- package/lib/umd/indexes.js +1 -1
- package/lib/umd/indexes.js.gz +0 -0
- package/lib/umd/metrics.js +1 -1
- package/lib/umd/metrics.js.gz +0 -0
- package/lib/umd/persisters.js +1 -1
- package/lib/umd/persisters.js.gz +0 -0
- package/lib/umd/relationships.js +1 -1
- package/lib/umd/relationships.js.gz +0 -0
- package/lib/umd/store.js +1 -1
- package/lib/umd/store.js.gz +0 -0
- package/lib/umd/tinybase.js +1 -1
- package/lib/umd/tinybase.js.gz +0 -0
- package/lib/umd/ui-react.js +1 -0
- package/lib/umd/ui-react.js.gz +0 -0
- package/package.json +10 -5
- package/readme.md +4 -4
- package/lib/react.js +0 -1
- package/lib/react.js.gz +0 -0
- package/lib/umd/react.js +0 -1
- package/lib/umd/react.js.gz +0 -0
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<section id="hero"><h2 id="a-tiny-reactive-javascript-library-for-structured-state-and-tabular-data">A tiny, reactive JavaScript library for <em>structured state</em> and <em>tabular data</em>.</h2><ul><li>Set and get <a href="#set-and-get-tables-rows-and-cells">tables, rows, and cells</a>. Register <a href="#register-listeners-at-any-granularity">listeners</a> at any granularity.</li><li>Call React <a href="#call-react-hooks-to-bind-to-data">hooks</a> to bind to data. Use <a href="#use-components-to-make-reactive-apps">components</a> to make reactive apps.</li><li>Apply <a href="#apply-schemas-to-tables">schemas</a> to tables. <a href="#persist-data-to-browser-file-or-server">Persist</a> data to browser, file, or server.</li><li>Define <a href="#define-metrics-and-aggregations">metrics</a> and aggregations. Create <a href="#create-indexes-for-fast-lookups">indexes</a> for fast lookups.</li><li>Model <a href="#configure-relationships-between-tables">relationships</a> between tables. Set <a href="#use-checkpoints-for-an-easy-undo-stack">checkpoints</a> for an undo stack.</li></ul><ul><li><a href="#did-we-say-tiny"><em>2.6kB -
|
|
1
|
+
<section id="hero"><h2 id="a-tiny-reactive-javascript-library-for-structured-state-and-tabular-data">A tiny, reactive JavaScript library for <em>structured state</em> and <em>tabular data</em>.</h2><ul><li>Set and get <a href="#set-and-get-tables-rows-and-cells">tables, rows, and cells</a>. Register <a href="#register-listeners-at-any-granularity">listeners</a> at any granularity.</li><li>Call React <a href="#call-react-hooks-to-bind-to-data">hooks</a> to bind to data. Use <a href="#use-components-to-make-reactive-apps">components</a> to make reactive apps.</li><li>Apply <a href="#apply-schemas-to-tables">schemas</a> to tables. <a href="#persist-data-to-browser-file-or-server">Persist</a> data to browser, file, or server.</li><li>Define <a href="#define-metrics-and-aggregations">metrics</a> and aggregations. Create <a href="#create-indexes-for-fast-lookups">indexes</a> for fast lookups.</li><li>Model <a href="#configure-relationships-between-tables">relationships</a> between tables. Set <a href="#use-checkpoints-for-an-easy-undo-stack">checkpoints</a> for an undo stack.</li></ul><ul><li><a href="#did-we-say-tiny"><em>2.6kB - 5.5kB </em>in size</a> when compressed, and with zero dependencies.</li><li><a href="#well-tested-and-documented"><em>100.0%</em> test coverage</a>, extensive guides, demos, and API <a href="https://tinybase.org/guides/getting-started">documentation</a>.</li><li><a href="https://www.npmjs.com/package/tinybase/v/0.9.2"><em>v0.9.2</em> on NPM</a>, and open source on <a href="https://github.com/tinyplex/tinybase">GitHub</a> with the MIT license.</li></ul></section><hr><p><a id="start" href="https://tinybase.org/guides/the-basics/getting-started">Get started</a></p><p><a href="https://tinybase.org/demos">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/other/store/">Read the docs</a></p><hr><section><h2 id="set-and-get-tables-rows-and-cells">Set and get tables, rows, and cells.</h2><p><a href="https://tinybase.org/guides/the-basics/creating-a-store">Creating a Store</a> requires just a simple call to the <a href="https://tinybase.org/api/store/functions/other/createstore"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://tinybase.org/api/store/type-aliases/store/table"><code>Table</code></a>, <a href="https://tinybase.org/api/store/type-aliases/store/row"><code>Row</code></a>, or <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> values by their <a href="https://tinybase.org/api/common/type-aliases/identity/id"><code>Id</code></a>. And of course you can easily get the values back out again.</p><p>Read more about setting and changing data in <a href="https://tinybase.org/guides/the-basics">The Basics</a> guide.</p></section>
|
|
2
2
|
|
|
3
3
|
```js
|
|
4
4
|
const store = createStore()
|
|
@@ -22,7 +22,7 @@ store.setCell('pets', 'fido', 'sold', false);
|
|
|
22
22
|
store.delListener(listenerId);
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
<section><h2 id="call-react-hooks-to-bind-to-data">Call React hooks to bind to data.</h2><p>If you're using React in your application, the optional
|
|
25
|
+
<section><h2 id="call-react-hooks-to-bind-to-data">Call React hooks to bind to data.</h2><p>If you're using React in your application, the optional react module provides hooks to bind to the data in a <a href="https://tinybase.org/api/store/interfaces/other/store"><code>Store</code></a>.</p><p>More magic! The useCell hook in this example fetches the dog's color. But it also registers a listener on that cell that will fire and re-render the component whenever the value changes.</p><p>Basically you simply describe what data you want in your user interface and TinyBase will take care of the whole lifecycle of updating it for you.</p><p>Read more about the using hooks in the <a href="https://tinybase.org/guides/building-uis/using-react-hooks">Using React Hooks</a> guide.</p></section>
|
|
26
26
|
|
|
27
27
|
```jsx
|
|
28
28
|
const App1 = () => {
|
|
@@ -40,7 +40,7 @@ console.log(app.innerHTML);
|
|
|
40
40
|
// -> 'Color: walnut'
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
<section><h2 id="use-components-to-make-reactive-apps">Use components to make reactive apps.</h2><p>The
|
|
43
|
+
<section><h2 id="use-components-to-make-reactive-apps">Use components to make reactive apps.</h2><p>The react module provides simple React components with bindings that make it easy to create a fully reactive user interface based on a <a href="https://tinybase.org/api/store/interfaces/other/store"><code>Store</code></a>.</p><p>In this example, the library's RowView component just needs a reference to the <a href="https://tinybase.org/api/store/interfaces/other/store"><code>Store</code></a>, the <code>tableId</code>, and the <code>rowId</code> in order to render the contents of that row. An optional <code>cellComponent</code> prop lets you override how you want each <a href="https://tinybase.org/api/store/type-aliases/store/cell"><code>Cell</code></a> rendered. Again, all the listeners and updates are taken care of for you.</p><p>The module also includes a context Provider that sets up default for an entire app to use, reducing the need to drill all your props down into your app's hierarchy.</p><p>Most of the demos showcase the use of these React hooks and components. Take a look at <a href="https://tinybase.org/demos/todo-app/todo-app-v1-the-basics">Todo App v1 (the basics)</a> to see these user interface binding patterns in action.</p><p>Read more about the react module in the <a href="https://tinybase.org/guides/building-uis">Building UIs</a> guides.</p></section>
|
|
44
44
|
|
|
45
45
|
```jsx
|
|
46
46
|
const CellComponent = (props) => (
|
|
@@ -192,4 +192,4 @@ console.log(store.getCell('pets', 'felix', 'sold'));
|
|
|
192
192
|
// -> false
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
-
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store"><code>store</code></a> module alone, you'll only add a gzipped <em>2.6kB</em> to your app. You can incrementally add the other modules as you need more functionality, or
|
|
195
|
+
<section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://tinybase.org/api/store"><code>store</code></a> module alone, you'll only add a gzipped <em>2.6kB</em> to your app. You can incrementally add the other modules as you need more functionality, or get it all for <em>5.5kB</em>. The <code>ui-react</code> adaptor is just another <em>2.5kB</em>.</p><p>Life's easy when you have zero dependencies.</p><p>Read more about how TinyBase is structured in the <a href="https://tinybase.org/guides/how-tinybase-is-built/architecture">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>.js.gz</th><th>.js</th><th>debug.js</th><th>.d.ts</th></tr><tr><th class="right"><a href="https://tinybase.org/api/store">store</a></th><td>2.6kB</td><td>5.8kB</td><td>23.8kB</td><td>83.8kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/indexes">indexes</a></th><td>1.5kB</td><td>2.9kB</td><td>12.7kB</td><td>28.6kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/metrics">metrics</a></th><td>1.5kB</td><td>3.0kB</td><td>12.3kB</td><td>25.2kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/relationships">relationships</a></th><td>1.5kB</td><td>3.1kB</td><td>14.3kB</td><td>38.0kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/checkpoints">checkpoints</a></th><td>1.3kB</td><td>2.4kB</td><td>10.0kB</td><td>30.1kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/persisters">persisters</a></th><td>0.8kB</td><td>1.6kB</td><td>4.9kB</td><td>19.9kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/tinybase">tinybase</a></th><td>5.5kB</td><td>12.9kB</td><td>53.6kB</td><td>0.3kB</td></tr><tr><th class="right"><a href="https://tinybase.org/api/ui-react">ui-react</a></th><td>2.5kB</td><td>7.6kB</td><td>24.2kB</td><td>260.5kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible to get up and running.</p><p>Read more about how TinyBase is tested in the <a href="https://tinybase.org/guides/how-tinybase-is-built/unit-testing">Unit Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>929</td><td>929</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>1,013</td><td>1,013</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>365</td><td>365</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>335</td><td>335</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">1,686</td></tr><tr><th class="right">Assertions</th><td colspan="3">7,781</td></tr></tbody></table></div><hr><p><a id="start" href="https://tinybase.org/guides/the-basics/getting-started">Get started</a></p><p><a href="https://tinybase.org/demos">Try the demos</a></p><p><a href="https://tinybase.org/api/store/interfaces/other/store/">Read the docs</a></p><hr><section><h2 id="follow">Follow</h2><ul><li>News and updates on <a href="https://twitter.com/tinybasejs">Twitter</a> and <a href="https://facebook.com/tinybasejs">Facebook</a>.</li><li><a href="https://github.com/tinyplex/tinybase/issues">Issues</a> and <a href="https://github.com/tinyplex/tinybase/releases">release notes</a> on <a href="https://github.com/tinyplex/tinybase">GitHub</a></li><li>Packages on <a href="https://www.npmjs.com/package/tinybase/v/0.9.2">NPM</a>.</li></ul></section><section><h2 id="about">About</h2><p>Building TinyBase was an interesting exercise in API design, minification, and documentation. It's not <a href="https://www.linkedin.com/in/jamespearce">my day job</a>, but I do intend to maintain it, so please provide feedback. I hope you enjoy using it!</p></section>
|
package/lib/react.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"react";const o=e=>typeof e,t=o(""),d=(e,o)=>e.map(o),s=e=>null==e,r=(e,o,t)=>s(e)?t?.():o(e),n=()=>{},{createContext:i,useContext:l}=e??{},I=i?.([]),c=(e,o)=>{const t=l(I);return s(e)?t[o]:((e,o)=>r(e,(e=>e[o])))(t[o+1],e)},a=(e,d)=>{const r=c(e,d);return s(e)||(e=>o(e)==t)(e)?r:e},p=e=>c(e,0),u=e=>c(e,2),b=e=>c(e,4),g=e=>c(e,6),w=e=>c(e,8),C=e=>a(e,0),m=e=>a(e,2),k=e=>a(e,4),R=e=>a(e,6),h=e=>a(e,8),{useCallback:v,useEffect:y,useMemo:T,useState:x}=e??{},P=(e,o,t=[])=>T((()=>o(e)),[e,...t]),L=(e,o,t,...d)=>{const s=o?.["get"+e]??(()=>t),r=s(...d),[,n]=x(r);return y((()=>{const t=o?.[`add${e}Listener`]?.(...d,(()=>n(s(...d))),!1);return()=>o?.delListener(t)}),[o,e,n,s,...d]),r},S=(e,o,t,d=[],s,...r)=>{y((()=>{const d=o?.[`add${e}Listener`]?.(...r,t,s);return()=>o?.delListener(d)}),[o,e,...d,s,...r])},B=(e,o,t,d=[],s=n,i=[],...l)=>{const I=C(e);return v((e=>r(I,(d=>r(t(e,d),(e=>s(d["set"+o](...l,e),e)))))),[I,o,...d,...i,...l])},f=(e,o,t=n,d=[],...s)=>{const r=C(e);return v((()=>t(r?.["del"+o](...s))),[r,o,...d,...s])},M=(e,o,t)=>{const d=h(e);return v((()=>d?.[o](t)),[d,o,t])},A=(e,o=[])=>T(e,o),E=e=>L("Tables",C(e),{}),$=e=>L("TableIds",C(e),[]),F=(e,o)=>L("Table",C(o),{},e),j=(e,o)=>L("RowIds",C(o),[],e),q=(e,o,t)=>L("Row",C(t),{},e,o),z=(e,o,t)=>L("CellIds",C(t),[],e,o),D=(e,o,t,d)=>L("Cell",C(d),void 0,e,o,t),G=(e,o,t,d,s)=>B(t,"Tables",e,o,d,s),H=(e,o,t,d,s,r)=>B(d,"Table",o,t,s,r,e),J=(e,o,t,d,s,r,n)=>B(s,"Row",t,d,r,n,e,o),K=(e,o,t=[],d,s=n,i=[])=>{const l=C(d);return v((t=>r(l,(d=>r(o(t,d),(o=>s(d.addRow(e,o),d,o)))))),[l,e,...t,...i])},N=(e,o,t,d,s,r,n)=>B(s,"PartialRow",t,d,r,n,e,o),O=(e,o,t,d,s,r,n,i)=>B(r,"Cell",d,s,n,i,e,o,t),Q=(e,o,t)=>f(e,"Tables",o,t),U=(e,o,t,d)=>f(o,"Table",t,d,e),V=(e,o,t,d,s)=>f(t,"Row",d,s,e,o),W=(e,o,t,d,s,r,n)=>f(s,"Cell",r,n,e,o,t,d),X=(e,o,t,d)=>S("Tables",C(d),e,o,t),Y=(e,o,t,d)=>S("TableIds",C(d),e,o,t),Z=(e,o,t,d,s)=>S("Table",C(s),o,t,d,e),_=(e,o,t,d,s)=>S("RowIds",C(s),o,t,d,e),ee=(e,o,t,d,s,r)=>S("Row",C(r),t,d,s,e,o),oe=(e,o,t,d,s,r)=>S("CellIds",C(r),t,d,s,e,o),te=(e,o,t,d,s,r,n)=>S("Cell",C(n),d,s,r,e,o,t),de=(e,o,t)=>P(e,o,t),se=(e,o)=>L("Metric",m(o),void 0,e),re=(e,o,t,d)=>S("Metric",m(d),o,t,void 0,e),ne=(e,o,t)=>P(e,o,t),ie=(e,o)=>L("SliceIds",k(o),[],e),le=(e,o,t)=>L("SliceRowIds",k(t),[],e,o),Ie=(e,o,t,d)=>S("SliceIds",k(d),o,t,void 0,e),ce=(e,o,t,d,s)=>S("SliceRowIds",k(s),t,d,void 0,e,o),ae=(e,o,t)=>P(e,o,t),pe=(e,o,t)=>L("RemoteRowId",R(t),void 0,e,o),ue=(e,o,t)=>L("LocalRowIds",R(t),[],e,o),be=(e,o,t)=>L("LinkedRowIds",R(t),[],e,o),ge=(e,o,t,d,s)=>S("RemoteRowId",R(s),t,d,void 0,e,o),we=(e,o,t,d,s)=>S("LocalRowIds",R(s),t,d,void 0,e,o),Ce=(e,o,t,d,s)=>S("LinkedRowIds",R(s),t,d,void 0,e,o),me=(e,o,t)=>P(e,o,t),ke=e=>L("CheckpointIds",h(e),[[],void 0,[]]),Re=(e,o)=>L("Checkpoint",h(o),void 0,e),he=(e=n,o=[],t,d=n,s=[])=>{const i=h(t);return v((o=>r(i,(t=>{const s=e(o);d(t.addCheckpoint(s),t,s)}))),[i,...o,...s])},ve=e=>M(e,"goBackward"),ye=e=>M(e,"goForward"),Te=(e,o=[],t,d=n,s=[])=>{const i=h(t);return v((o=>r(i,(t=>r(e(o),(e=>d(t.goTo(e),e)))))),[i,...o,...s])},xe=e=>{const o=h(e),[t,d]=ke(o);return[(s=t,!(0==(e=>e.length)(s))),ve(o),d,r(d,(e=>o?.getCheckpoint(e)))??""];var s},Pe=e=>{const o=h(e),[,,[t]]=ke(o);return[!s(t),ye(o),t,r(t,(e=>o?.getCheckpoint(e)))??""]},Le=(e,o,t)=>S("CheckpointIds",h(t),e,o),Se=(e,o,t,d)=>S("Checkpoint",h(d),o,t,void 0,e),Be=(e,o,t=[],d,s=[])=>{const[,r]=x(),n=T((()=>o(e)),[e,...t]);return y((()=>{(async()=>{await(d?.(n)),r(1)})()}),[n,...s]),n},{createElement:fe,useMemo:Me}=e??{},Ae=e=>{const o=R(e);return[o,o?.getStore()]},Ee=({relationshipId:e,relationships:o,rowComponent:t=De,getRowComponentProps:s,separator:r,debugIds:n},i,l)=>{const[I,c]=Ae(o),a=I?.getLocalTableId(e),p=i(e,l,I);return qe(d(p,(e=>fe(t,{...Fe(s,e),key:e,tableId:a,rowId:e,store:c,debugIds:n}))),r,n,l)},$e=e=>({checkpoints:o,checkpointComponent:t=Ve,getCheckpointComponentProps:s,separator:r,debugIds:n})=>{const i=h(o);return qe(d(e(ke(i)),(e=>fe(t,{...Fe(s,e),key:e,checkpoints:i,checkpointId:e,debugIds:n}))),r)},Fe=(e,o)=>s(e)?{}:e(o),je=({store:e,storesById:o,metrics:t,metricsById:d,indexes:s,indexesById:r,relationships:n,relationshipsById:i,checkpoints:l,checkpointsById:c,children:a})=>fe(I.Provider,{value:Me((()=>[e,o,t,d,s,r,n,i,l,c]),[e,o,t,d,s,r,n,i,l,c])},a),qe=(e,o,t,r)=>{const n=s(o)||!Array.isArray(e)?e:d(e,((e,t)=>t>0?[o,e]:e));return t?[r,":{",n,"}"]:n},ze=({tableId:e,rowId:o,cellId:t,store:d,debugIds:s})=>qe(""+(D(e,o,t,d)??""),void 0,s,t),De=({tableId:e,rowId:o,store:t,cellComponent:s=ze,getCellComponentProps:r,separator:n,debugIds:i})=>qe(d(z(e,o,t),(d=>fe(s,{...Fe(r,d),key:d,tableId:e,rowId:o,cellId:d,store:t,debugIds:i}))),n,i,o),Ge=({tableId:e,store:o,rowComponent:t=De,getRowComponentProps:s,separator:r,debugIds:n})=>qe(d(j(e,o),(d=>fe(t,{...Fe(s,d),key:d,tableId:e,rowId:d,store:o,debugIds:n}))),r,n,e),He=({store:e,tableComponent:o=Ge,getTableComponentProps:t,separator:s,debugIds:r})=>qe(d($(e),(d=>fe(o,{...Fe(t,d),key:d,tableId:d,store:e,debugIds:r}))),s),Je=({metricId:e,metrics:o,debugIds:t})=>qe(se(e,o)??"",void 0,t,e),Ke=({indexId:e,sliceId:o,indexes:t,rowComponent:s=De,getRowComponentProps:r,separator:n,debugIds:i})=>{const l=k(t),I=l?.getStore(),c=l?.getTableId(e),a=le(e,o,l);return qe(d(a,(e=>fe(s,{...Fe(r,e),key:e,tableId:c,rowId:e,store:I,debugIds:i}))),n,i,o)},Ne=({indexId:e,indexes:o,sliceComponent:t=Ke,getSliceComponentProps:s,separator:r,debugIds:n})=>qe(d(ie(e,o),(d=>fe(t,{...Fe(s,d),key:d,indexId:e,sliceId:d,indexes:o,debugIds:n}))),r,n,e),Oe=({relationshipId:e,localRowId:o,relationships:t,rowComponent:d=De,getRowComponentProps:r,debugIds:n})=>{const[i,l]=Ae(t),I=i?.getRemoteTableId(e),c=pe(e,o,i);return qe(s(I)||s(c)?null:fe(d,{...Fe(r,c),key:c,tableId:I,rowId:c,store:l,debugIds:n}),void 0,n,o)},Qe=e=>Ee(e,ue,e.remoteRowId),Ue=e=>Ee(e,be,e.firstRowId),Ve=({checkpoints:e,checkpointId:o,debugIds:t})=>qe(Re(o,e)??"",void 0,t,o),We=$e((e=>e[0])),Xe=$e((e=>s(e[1])?[]:[e[1]])),Ye=$e((e=>e[2]));export{We as BackwardCheckpointsView,ze as CellView,Ve as CheckpointView,Xe as CurrentCheckpointView,Ye as ForwardCheckpointsView,Ne as IndexView,Ue as LinkedRowsView,Qe as LocalRowsView,Je as MetricView,je as Provider,Oe as RemoteRowView,De as RowView,Ke as SliceView,Ge as TableView,He as TablesView,K as useAddRowCallback,D as useCell,z as useCellIds,oe as useCellIdsListener,te as useCellListener,Re as useCheckpoint,ke as useCheckpointIds,Le as useCheckpointIdsListener,Se as useCheckpointListener,w as useCheckpoints,me as useCreateCheckpoints,ne as useCreateIndexes,de as useCreateMetrics,Be as useCreatePersister,ae as useCreateRelationships,A as useCreateStore,W as useDelCellCallback,V as useDelRowCallback,U as useDelTableCallback,Q as useDelTablesCallback,ve as useGoBackwardCallback,ye as useGoForwardCallback,Te as useGoToCallback,b as useIndexes,be as useLinkedRowIds,Ce as useLinkedRowIdsListener,ue as useLocalRowIds,we as useLocalRowIdsListener,se as useMetric,re as useMetricListener,u as useMetrics,Pe as useRedoInformation,g as useRelationships,pe as useRemoteRowId,ge as useRemoteRowIdListener,q as useRow,j as useRowIds,_ as useRowIdsListener,ee as useRowListener,O as useSetCellCallback,he as useSetCheckpointCallback,N as useSetPartialRowCallback,J as useSetRowCallback,H as useSetTableCallback,G as useSetTablesCallback,ie as useSliceIds,Ie as useSliceIdsListener,le as useSliceRowIds,ce as useSliceRowIdsListener,p as useStore,F as useTable,$ as useTableIds,Y as useTableIdsListener,Z as useTableListener,E as useTables,X as useTablesListener,xe as useUndoInformation};
|
package/lib/react.js.gz
DELETED
|
Binary file
|
package/lib/umd/react.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e,s;e=this,s=function(e,s){"use strict";const o=e=>typeof e,t=o(""),d=(e,s)=>e.map(s),r=e=>null==e,n=(e,s,o)=>r(e)?o?.():s(e),i=()=>{},{createContext:l,useContext:a}=s??{},c=l?.([]),u=(e,s)=>{const o=a(c);return r(e)?o[s]:((e,s)=>n(e,(e=>e[s])))(o[s+1],e)},I=(e,s)=>{const d=u(e,s);return r(e)||(e=>o(e)==t)(e)?d:e},p=e=>I(e,0),w=e=>I(e,2),b=e=>I(e,4),C=e=>I(e,6),k=e=>I(e,8),{useCallback:R,useEffect:g,useMemo:h,useState:m}=s??{},T=(e,s,o=[])=>h((()=>s(e)),[e,...o]),L=(e,s,o,...t)=>{const d=s?.["get"+e]??(()=>o),r=d(...t),[,n]=m(r);return g((()=>{const o=s?.[`add${e}Listener`]?.(...t,(()=>n(d(...t))),!1);return()=>s?.delListener(o)}),[s,e,n,d,...t]),r},y=(e,s,o,t=[],d,...r)=>{g((()=>{const t=s?.[`add${e}Listener`]?.(...r,o,d);return()=>s?.delListener(t)}),[s,e,...t,d,...r])},v=(e,s,o,t=[],d=i,r=[],...l)=>{const a=p(e);return R((e=>n(a,(t=>n(o(e,t),(e=>d(t["set"+s](...l,e),e)))))),[a,s,...t,...r,...l])},S=(e,s,o=i,t=[],...d)=>{const r=p(e);return R((()=>o(r?.["del"+s](...d))),[r,s,...t,...d])},f=(e,s,o)=>{const t=k(e);return R((()=>t?.[s](o)),[t,s,o])},x=e=>L("TableIds",p(e),[]),P=(e,s)=>L("RowIds",p(s),[],e),V=(e,s,o)=>L("CellIds",p(o),[],e,s),M=(e,s,o,t)=>L("Cell",p(t),void 0,e,s,o),B=(e,s)=>L("Metric",w(s),void 0,e),D=(e,s)=>L("SliceIds",b(s),[],e),A=(e,s,o)=>L("SliceRowIds",b(o),[],e,s),F=(e,s,o)=>L("RemoteRowId",C(o),void 0,e,s),G=(e,s,o)=>L("LocalRowIds",C(o),[],e,s),j=(e,s,o)=>L("LinkedRowIds",C(o),[],e,s),E=e=>L("CheckpointIds",k(e),[[],void 0,[]]),$=(e,s)=>L("Checkpoint",k(s),void 0,e),_=e=>f(e,"goBackward"),q=e=>f(e,"goForward"),{createElement:O,useMemo:U}=s??{},z=e=>{const s=C(e);return[s,s?.getStore()]},H=({relationshipId:e,relationships:s,rowComponent:o=W,getRowComponentProps:t,separator:r,debugIds:n},i,l)=>{const[a,c]=z(s),u=a?.getLocalTableId(e),I=i(e,l,a);return N(d(I,(e=>O(o,{...K(t,e),key:e,tableId:u,rowId:e,store:c,debugIds:n}))),r,n,l)},J=e=>({checkpoints:s,checkpointComponent:o=Z,getCheckpointComponentProps:t,separator:r,debugIds:n})=>{const i=k(s);return N(d(e(E(i)),(e=>O(o,{...K(t,e),key:e,checkpoints:i,checkpointId:e,debugIds:n}))),r)},K=(e,s)=>r(e)?{}:e(s),N=(e,s,o,t)=>{const n=r(s)||!Array.isArray(e)?e:d(e,((e,o)=>o>0?[s,e]:e));return o?[t,":{",n,"}"]:n},Q=({tableId:e,rowId:s,cellId:o,store:t,debugIds:d})=>N(""+(M(e,s,o,t)??""),void 0,d,o),W=({tableId:e,rowId:s,store:o,cellComponent:t=Q,getCellComponentProps:r,separator:n,debugIds:i})=>N(d(V(e,s,o),(d=>O(t,{...K(r,d),key:d,tableId:e,rowId:s,cellId:d,store:o,debugIds:i}))),n,i,s),X=({tableId:e,store:s,rowComponent:o=W,getRowComponentProps:t,separator:r,debugIds:n})=>N(d(P(e,s),(d=>O(o,{...K(t,d),key:d,tableId:e,rowId:d,store:s,debugIds:n}))),r,n,e),Y=({indexId:e,sliceId:s,indexes:o,rowComponent:t=W,getRowComponentProps:r,separator:n,debugIds:i})=>{const l=b(o),a=l?.getStore(),c=l?.getTableId(e),u=A(e,s,l);return N(d(u,(e=>O(t,{...K(r,e),key:e,tableId:c,rowId:e,store:a,debugIds:i}))),n,i,s)},Z=({checkpoints:e,checkpointId:s,debugIds:o})=>N($(s,e)??"",void 0,o,s),ee=J((e=>e[0])),se=J((e=>r(e[1])?[]:[e[1]])),oe=J((e=>e[2]));e.BackwardCheckpointsView=ee,e.CellView=Q,e.CheckpointView=Z,e.CurrentCheckpointView=se,e.ForwardCheckpointsView=oe,e.IndexView=({indexId:e,indexes:s,sliceComponent:o=Y,getSliceComponentProps:t,separator:r,debugIds:n})=>N(d(D(e,s),(d=>O(o,{...K(t,d),key:d,indexId:e,sliceId:d,indexes:s,debugIds:n}))),r,n,e),e.LinkedRowsView=e=>H(e,j,e.firstRowId),e.LocalRowsView=e=>H(e,G,e.remoteRowId),e.MetricView=({metricId:e,metrics:s,debugIds:o})=>N(B(e,s)??"",void 0,o,e),e.Provider=({store:e,storesById:s,metrics:o,metricsById:t,indexes:d,indexesById:r,relationships:n,relationshipsById:i,checkpoints:l,checkpointsById:a,children:u})=>O(c.Provider,{value:U((()=>[e,s,o,t,d,r,n,i,l,a]),[e,s,o,t,d,r,n,i,l,a])},u),e.RemoteRowView=({relationshipId:e,localRowId:s,relationships:o,rowComponent:t=W,getRowComponentProps:d,debugIds:n})=>{const[i,l]=z(o),a=i?.getRemoteTableId(e),c=F(e,s,i);return N(r(a)||r(c)?null:O(t,{...K(d,c),key:c,tableId:a,rowId:c,store:l,debugIds:n}),void 0,n,s)},e.RowView=W,e.SliceView=Y,e.TableView=X,e.TablesView=({store:e,tableComponent:s=X,getTableComponentProps:o,separator:t,debugIds:r})=>N(d(x(e),(t=>O(s,{...K(o,t),key:t,tableId:t,store:e,debugIds:r}))),t),e.useAddRowCallback=(e,s,o=[],t,d=i,r=[])=>{const l=p(t);return R((o=>n(l,(t=>n(s(o,t),(s=>d(t.addRow(e,s),t,s)))))),[l,e,...o,...r])},e.useCell=M,e.useCellIds=V,e.useCellIdsListener=(e,s,o,t,d,r)=>y("CellIds",p(r),o,t,d,e,s),e.useCellListener=(e,s,o,t,d,r,n)=>y("Cell",p(n),t,d,r,e,s,o),e.useCheckpoint=$,e.useCheckpointIds=E,e.useCheckpointIdsListener=(e,s,o)=>y("CheckpointIds",k(o),e,s),e.useCheckpointListener=(e,s,o,t)=>y("Checkpoint",k(t),s,o,void 0,e),e.useCheckpoints=e=>u(e,8),e.useCreateCheckpoints=(e,s,o)=>T(e,s,o),e.useCreateIndexes=(e,s,o)=>T(e,s,o),e.useCreateMetrics=(e,s,o)=>T(e,s,o),e.useCreatePersister=(e,s,o=[],t,d=[])=>{const[,r]=m(),n=h((()=>s(e)),[e,...o]);return g((()=>{(async()=>{await(t?.(n)),r(1)})()}),[n,...d]),n},e.useCreateRelationships=(e,s,o)=>T(e,s,o),e.useCreateStore=(e,s=[])=>h(e,s),e.useDelCellCallback=(e,s,o,t,d,r,n)=>S(d,"Cell",r,n,e,s,o,t),e.useDelRowCallback=(e,s,o,t,d)=>S(o,"Row",t,d,e,s),e.useDelTableCallback=(e,s,o,t)=>S(s,"Table",o,t,e),e.useDelTablesCallback=(e,s,o)=>S(e,"Tables",s,o),e.useGoBackwardCallback=_,e.useGoForwardCallback=q,e.useGoToCallback=(e,s=[],o,t=i,d=[])=>{const r=k(o);return R((s=>n(r,(o=>n(e(s),(e=>t(o.goTo(e),e)))))),[r,...s,...d])},e.useIndexes=e=>u(e,4),e.useLinkedRowIds=j,e.useLinkedRowIdsListener=(e,s,o,t,d)=>y("LinkedRowIds",C(d),o,t,void 0,e,s),e.useLocalRowIds=G,e.useLocalRowIdsListener=(e,s,o,t,d)=>y("LocalRowIds",C(d),o,t,void 0,e,s),e.useMetric=B,e.useMetricListener=(e,s,o,t)=>y("Metric",w(t),s,o,void 0,e),e.useMetrics=e=>u(e,2),e.useRedoInformation=e=>{const s=k(e),[,,[o]]=E(s);return[!r(o),q(s),o,n(o,(e=>s?.getCheckpoint(e)))??""]},e.useRelationships=e=>u(e,6),e.useRemoteRowId=F,e.useRemoteRowIdListener=(e,s,o,t,d)=>y("RemoteRowId",C(d),o,t,void 0,e,s),e.useRow=(e,s,o)=>L("Row",p(o),{},e,s),e.useRowIds=P,e.useRowIdsListener=(e,s,o,t,d)=>y("RowIds",p(d),s,o,t,e),e.useRowListener=(e,s,o,t,d,r)=>y("Row",p(r),o,t,d,e,s),e.useSetCellCallback=(e,s,o,t,d,r,n,i)=>v(r,"Cell",t,d,n,i,e,s,o),e.useSetCheckpointCallback=(e=i,s=[],o,t=i,d=[])=>{const r=k(o);return R((s=>n(r,(o=>{const d=e(s);t(o.addCheckpoint(d),o,d)}))),[r,...s,...d])},e.useSetPartialRowCallback=(e,s,o,t,d,r,n)=>v(d,"PartialRow",o,t,r,n,e,s),e.useSetRowCallback=(e,s,o,t,d,r,n)=>v(d,"Row",o,t,r,n,e,s),e.useSetTableCallback=(e,s,o,t,d,r)=>v(t,"Table",s,o,d,r,e),e.useSetTablesCallback=(e,s,o,t,d)=>v(o,"Tables",e,s,t,d),e.useSliceIds=D,e.useSliceIdsListener=(e,s,o,t)=>y("SliceIds",b(t),s,o,void 0,e),e.useSliceRowIds=A,e.useSliceRowIdsListener=(e,s,o,t,d)=>y("SliceRowIds",b(d),o,t,void 0,e,s),e.useStore=e=>u(e,0),e.useTable=(e,s)=>L("Table",p(s),{},e),e.useTableIds=x,e.useTableIdsListener=(e,s,o,t)=>y("TableIds",p(t),e,s,o),e.useTableListener=(e,s,o,t,d)=>y("Table",p(d),s,o,t,e),e.useTables=e=>L("Tables",p(e),{}),e.useTablesListener=(e,s,o,t)=>y("Tables",p(t),e,s,o),e.useUndoInformation=e=>{const s=k(e),[o,t]=E(s);return[(d=o,!(0==(e=>e.length)(d))),_(s),t,n(t,(e=>s?.getCheckpoint(e)))??""];var d},Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBaseReact={},e.React);
|
package/lib/umd/react.js.gz
DELETED
|
Binary file
|