tinybase 5.0.0-beta.23 → 5.0.0-beta.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "5.0.0-beta.23",
3
+ "version": "5.0.0-beta.24",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -15,9 +15,6 @@
15
15
  "react"
16
16
  ],
17
17
  "type": "module",
18
- "bin": {
19
- "tinybase": "./cli/index.js"
20
- },
21
18
  "browser": {
22
19
  "fs": false
23
20
  },
@@ -29,12 +26,13 @@
29
26
  "@sqlite.org/sqlite-wasm": "^3.46.0-build2",
30
27
  "@vlcn.io/crsqlite-wasm": "^0.16.0",
31
28
  "electric-sql": "^0.12.0",
32
- "expo-sqlite": "^14.0.3",
29
+ "expo": "^51.0.0",
30
+ "expo-sqlite": "^14.0.0",
33
31
  "partykit": "^0.0.105",
34
32
  "partysocket": "^1.0.1",
35
33
  "prettier": "^3.3.2",
36
- "react": "^18.3.1",
37
- "react-dom": "^18.3.1",
34
+ "react": "^18.2.0",
35
+ "react-dom": "^18.2.0",
38
36
  "sqlite3": "^5.1.7",
39
37
  "ws": "^8.17.0",
40
38
  "yjs": "^13.6.16"
@@ -86,6 +84,9 @@
86
84
  "optional": true
87
85
  }
88
86
  },
87
+ "bin": {
88
+ "tinybase": "./cli/index.js"
89
+ },
89
90
  "main": "./index.js",
90
91
  "types": "./@types/index.d.ts",
91
92
  "typesVersions": {
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://beta.tinybase.org/guides/releases/#v5-0"><em>NEW!</em> v5.0 release</a> <span id="one-with">&quot;The One You Can Sync&quot;</span></p><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app&#x27;s data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions &amp; ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://beta.tinybase.org/api/persister-browser">storage</a>, <a href="https://beta.tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://beta.tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>; and (<em>new!</em>) <a href="https://beta.tinybase.org/api/persister-partykit-client/">PartyKit</a> and <a href="https://electric-sql.com/">ElectricSQL</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.3kB - 12.5kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://beta.tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends!</h2><div><a href="https://beta.tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://beta.tinybase.org/react.svg"> React</a></div><div><a href="https://beta.tinybase.org/api/persister-partykit-client"><img width="48" src="https://beta.tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/expo.svg">Expo SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/electric.svg">ElectricSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/turso.svg">Turso</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/powersync.svg">PowerSync</a></div><div><a href="https://beta.tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://beta.tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://beta.tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://beta.tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://beta.tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://beta.tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://beta.tinybase.org/api/persister-automerge"><img width="48" src="https://beta.tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;label=Twitter&amp;labelColor=%23333&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/5.0.0-beta.22" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://beta.tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://beta.tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://beta.tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
1
+ <section id="hero"><h2 id="the-reactive-data-store-for-local-first-apps">The <em>reactive</em> data store for <span>local-first apps</span>.</h2><p id="copy">Build blisteringly fast web apps that work both online and offline. Manage your state locally, synchronize it to the cloud when you need to, or even make it collaborative. But, most importantly... have fun building stuff again!</p></section><p><a href="https://beta.tinybase.org/guides/releases/#v5-0"><em>NEW!</em> v5.0 release</a> <span id="one-with">&quot;The One You Can Sync&quot;</span></p><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/store/interfaces/store/store/">Read the docs</a></p><hr><ul><li>Manage <a href="#start-with-a-simple-key-value-store">key-value data</a>, <a href="#level-up-to-use-tabular-data">tabular data</a> - or both - with optional <a href="#apply-schemas-to-tables-values">schematization</a> to model your app&#x27;s data structures.</li><li><a href="#register-granular-listeners">Flexibly reactive</a> to reconciled updates, so you only spend rendering cycles on things that change.</li><li><a href="#build-complex-queries-with-tinyql">Powerful query engine</a> to select, join, filter, group, sort and paginate data - reactively - and without SQL.</li><li>Built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, <a href="#model-table-relationships">tabular relationships</a> - and even an <a href="#set-checkpoints-for-an-undo-stack">undo stack</a> for your app state.</li><li>Create <a href="#type-definitions-orm-like-apis">type definitions &amp; ORM-like APIs</a>, from schema or inference. <a href="#an-inspector-for-your-data">Inspect your data</a> (<em>new!</em>) directly in the browser.</li><li>Easily <a href="#persist-to-storage-sqlite-crdts">sync your data</a> to browser <a href="https://beta.tinybase.org/api/persister-browser">storage</a>, <a href="https://beta.tinybase.org/api/persister-indexed-db/">IndexedDB</a>, <a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence/">SQLite</a>, <a href="https://beta.tinybase.org/guides/schemas-and-persistence/synchronizing-data/">CRDTs</a>; and (<em>new!</em>) <a href="https://beta.tinybase.org/api/persister-partykit-client/">PartyKit</a> and <a href="https://electric-sql.com/">ElectricSQL</a>.</li><li>Optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and (<em>new!</em>) <a href="#pre-built-reactive-components">pre-built components</a> that let you easily build fully reactive user interfaces.</li><li>Tiny by name, tiny by nature: <a href="#did-we-say-tiny">5.3kB - 12.5kB</a>, no dependencies. <a href="#well-tested-and-documented">100% tested</a>, <a href="https://beta.tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</li></ul><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends!</h2><div><a href="https://beta.tinybase.org/guides/building-uis/getting-started-with-ui-react"><img width="48" src="https://beta.tinybase.org/react.svg"> React</a></div><div><a href="https://beta.tinybase.org/api/persister-partykit-client"><img width="48" src="https://beta.tinybase.org/partykit.svg"> PartyKit</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/expo.svg">Expo SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/electric.svg">ElectricSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/sqlite.svg"> SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/turso.svg">Turso</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img width="48" src="https://beta.tinybase.org/powersync.svg">PowerSync</a></div><div><a href="https://beta.tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img width="48" src="https://beta.tinybase.org/indexeddb.svg"> IndexedDB</a></div><div><a href="https://beta.tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img width="48" src="https://beta.tinybase.org/yjs.svg"> YJS</a></div><div><a href="https://beta.tinybase.org/api/persister-cr-sqlite-wasm"><img width="48" src="https://beta.tinybase.org/crsqlite.png"> CR-SQLite</a></div><div><a href="https://beta.tinybase.org/api/persister-automerge"><img width="48" src="https://beta.tinybase.org/automerge.svg"> Automerge</a></div></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"> </a><a href="https://twitter.com/tinybasejs" target="_blank"><img src="https://img.shields.io/twitter/follow/tinybasejs?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;label=Twitter&amp;labelColor=%23333&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=jest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/5.0.0-beta.23" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> requires just a simple call to the <a href="https://beta.tinybase.org/api/store/functions/creation/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://beta.tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://beta.tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  import {createStore} from 'tinybase';
package/releases.md CHANGED
@@ -60,7 +60,7 @@ synchronizer2.destroy();
60
60
  server.destroy();
61
61
  ```
62
62
 
63
- <p>This release includes two types of <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a>: the <a href="https://beta.tinybase.org/api/synchronizer-local/interfaces/synchronizer/localsynchronizer/"><code>LocalSynchronizer</code></a> (for demonstrating synchronization on a single local system), and more importantly the <a href="https://beta.tinybase.org/api/synchronizer-ws-client/interfaces/synchronizer/wssynchronizer/"><code>WsSynchronizer</code></a> (that uses WebSockets to communicate between different systems, shown above).</p><p>Notice that the <a href="https://beta.tinybase.org/api/synchronizer-ws-client/interfaces/synchronizer/wssynchronizer/"><code>WsSynchronizer</code></a> assumes that there exists a server that can forward requests to other <a href="https://beta.tinybase.org/api/synchronizer-ws-client/interfaces/synchronizer/wssynchronizer/"><code>WsSynchronizer</code></a> systems. This can be created using the <a href="https://beta.tinybase.org/api/synchronizer-ws-server/functions/creation/createwsserver/"><code>createWsServer</code></a> function that takes a WebSocketServer as also shown above.</p><h3 id="breaking-changes-in-v5-0">Breaking <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/changes/"><code>Changes</code></a> in v5.0</h3><h4 id="module-file-structure">Module File Structure</h4><p>Previously, the distributed package contained a <code>lib</code> folder with both code and type definitions. In v5.0, they have been hoisted to the top level of the package so that less-capable bundlers can find the correct files.</p><p>If you previously had <code>/lib/</code> in your import paths, you should remove it. You also do not have to explicitly specify whether you need the <code>cjs</code> version of <a href="https://beta.tinybase.org/">TinyBase</a> - if you are using a <code>require</code> rather than an <code>import</code>, you will get it automatically.</p><p>The non-minified version of the code is now default and you need to be explicit with you <em>want</em> minified code. Previously you would add <code>/debug</code> to the import path to get non-minified code, but now you add <code>/min</code> to the import path to get <em>minified</em> code.</p><p>Please read the comprehensive <a href="https://beta.tinybase.org/guides/the-basics/importing-tinybase/">Importing TinyBase</a> guide for more details of how to construct the correct import paths in v5.0.</p><h4 id="the-tinybase-inspector">The <a href="https://beta.tinybase.org/">TinyBase</a> Inspector</h4><p>Previously, the React-based inspector (then known as <code>StoreInspector</code>) resided in the debug version of the <a href="https://beta.tinybase.org/api/ui-react-dom/"><code>ui-react-dom</code></a> module. It now lives in its own <a href="https://beta.tinybase.org/api/ui-react-inspector/"><code>ui-react-inspector</code></a> module (so that it can be used against non-debug code) and has been renamed to Inspector.</p><p>Please update your imports and rename the component when used, accordingly. See the API documentation for details, or the <a href="https://beta.tinybase.org/demos/ui-components/inspector/"><inspector></inspector></a>demo, for example.</p><h4 id="api-changes">API <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/changes/"><code>Changes</code></a></h4><p>The following changes have been made to the existing <a href="https://beta.tinybase.org/">TinyBase</a> API for consistency. These are less common parts of the API but should straightforward to correct if you are using them.</p><p>In the type definitions:</p><ul><li>The GetTransactionChanges and GetTransactionLog types have been removed.</li><li>The TransactionChanges type has been renamed as the <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/changes/"><code>Changes</code></a> type.</li><li>The <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/changes/"><code>Changes</code></a> type now uses <code>undefined</code> instead of <code>null</code> to indicate a <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> or <a href="https://beta.tinybase.org/api/store/type-aliases/store/value/"><code>Value</code></a> that has been deleted or that was not present.</li><li>The <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/transactionlog/"><code>TransactionLog</code></a> type is now an array instead of a JavaScript object.</li></ul><p>In the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> interface:</p><ul><li>There is a new <a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/transaction/gettransactionchanges/"><code>getTransactionChanges</code></a> method and a new getTransactionLog method.</li><li>The setTransactionChanges method is renamed as the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/setter/applychanges/"><code>applyChanges</code></a> method.</li><li>A <a href="https://beta.tinybase.org/api/store/type-aliases/callback/dorollback/"><code>DoRollback</code></a> function no longer gets passed arguments. You can use the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/transaction/gettransactionchanges/"><code>getTransactionChanges</code></a> method and <a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/transaction/gettransactionlog/"><code>getTransactionLog</code></a> method directly instead.</li><li>Similarly, a <a href="https://beta.tinybase.org/api/store/type-aliases/listener/transactionlistener/"><code>TransactionListener</code></a> function no longer gets passed arguments.</li></ul><p>In the <a href="https://beta.tinybase.org/api/persisters/"><code>persisters</code></a> module:</p><ul><li>The <a href="https://beta.tinybase.org/api/persisters/functions/creation/createcustompersister/"><code>createCustomPersister</code></a> function now takes a final optional boolean (<code>supportsMergeableStore</code>) to indicate that the <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> can support <a href="https://beta.tinybase.org/api/mergeable-store/interfaces/mergeable/mergeablestore/"><code>MergeableStore</code></a> as well as <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> objects.</li><li>A <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>&#x27;s <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/load/load/"><code>load</code></a> method and <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/load/startautoload/"><code>startAutoLoad</code></a> method now take a <a href="https://beta.tinybase.org/api/store/type-aliases/store/content/"><code>Content</code></a> object as one parameter, rather than <a href="https://beta.tinybase.org/api/store/type-aliases/store/tables/"><code>Tables</code></a> and <a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> as two.</li><li>If you create a custom <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>, the setPersisted method now receives changes made to a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> directly by reference, rather than via a callback. Similarly, the <a href="https://beta.tinybase.org/api/persisters/type-aliases/creation/persisterlistener/"><code>PersisterListener</code></a> you register in your addPersisterListener implementation now takes <a href="https://beta.tinybase.org/api/store/type-aliases/store/content/"><code>Content</code></a> and <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/changes/"><code>Changes</code></a> objects directly rather than via a callback.</li><li>The broadcastTransactionChanges method in the <a href="https://beta.tinybase.org/api/persister-partykit-server/"><code>persister-partykit-server</code></a> module has been renamed to the broadcastChanges method.</li></ul><h2 id="v4-8">v4.8</h2><p>This release includes the new <a href="https://beta.tinybase.org/api/persister-powersync/"><code>persister-powersync</code></a> module, which provides a <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> for <a href="https://www.powersync.com/">PowerSync&#x27;s SQLite</a> database.</p><p>Much like the other SQLite persisters, use it by passing in a PowerSync instance to the <a href="https://beta.tinybase.org/api/persister-powersync/functions/creation/createpowersyncpersister/"><code>createPowerSyncPersister</code></a> function; something like:</p>
63
+ <p>This release includes two types of <a href="https://beta.tinybase.org/api/synchronizers/interfaces/synchronizer/synchronizer/"><code>Synchronizer</code></a>: the <a href="https://beta.tinybase.org/api/synchronizer-local/interfaces/synchronizer/localsynchronizer/"><code>LocalSynchronizer</code></a> (for demonstrating synchronization on a single local system), and more importantly the <a href="https://beta.tinybase.org/api/synchronizer-ws-client/interfaces/synchronizer/wssynchronizer/"><code>WsSynchronizer</code></a> (that uses WebSockets to communicate between different systems, shown above).</p><p>Notice that the <a href="https://beta.tinybase.org/api/synchronizer-ws-client/interfaces/synchronizer/wssynchronizer/"><code>WsSynchronizer</code></a> assumes that there exists a server that can forward requests to other <a href="https://beta.tinybase.org/api/synchronizer-ws-client/interfaces/synchronizer/wssynchronizer/"><code>WsSynchronizer</code></a> systems. This can be created using the <a href="https://beta.tinybase.org/api/synchronizer-ws-server/functions/creation/createwsserver/"><code>createWsServer</code></a> function that takes a WebSocketServer as also shown above.</p><h3 id="breaking-changes-in-v5-0">Breaking <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/changes/"><code>Changes</code></a> in v5.0</h3><h4 id="module-file-structure">Module File Structure</h4><p>Previously, the distributed package contained a <code>lib</code> folder with both code and type definitions. In v5.0, they have been hoisted to the top level of the package so that less-capable bundlers can find the correct files.</p><p>If you previously had <code>/lib/</code> in your import paths, you should remove it. You also do not have to explicitly specify whether you need the <code>cjs</code> version of <a href="https://beta.tinybase.org/">TinyBase</a> - if you are using a <code>require</code> rather than an <code>import</code>, you will get it automatically.</p><p>The non-minified version of the code is now default and you need to be explicit with you <em>want</em> minified code. Previously you would add <code>/debug</code> to the import path to get non-minified code, but now you add <code>/min</code> to the import path to get <em>minified</em> code.</p><p>Please read the comprehensive <a href="https://beta.tinybase.org/guides/the-basics/importing-tinybase/">Importing TinyBase</a> guide for more details of how to construct the correct import paths in v5.0.</p><h4 id="expo-sqlite-persister">Expo SQLite <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a></h4><p>Previously the <a href="https://beta.tinybase.org/api/persister-expo-sqlite/"><code>persister-expo-sqlite</code></a> module supported expo-sqlite v13 and the persister-expo-sqlite-next module supported their modern &#x27;next&#x27; package. In v5.0, the <a href="https://beta.tinybase.org/api/persister-expo-sqlite/"><code>persister-expo-sqlite</code></a> module only supports v14 and later, and the persister-expo-sqlite-next module has been removed.</p><h4 id="the-tinybase-inspector">The <a href="https://beta.tinybase.org/">TinyBase</a> Inspector</h4><p>Previously, the React-based inspector (then known as <code>StoreInspector</code>) resided in the debug version of the <a href="https://beta.tinybase.org/api/ui-react-dom/"><code>ui-react-dom</code></a> module. It now lives in its own <a href="https://beta.tinybase.org/api/ui-react-inspector/"><code>ui-react-inspector</code></a> module (so that it can be used against non-debug code) and has been renamed to Inspector.</p><p>Please update your imports and rename the component when used, accordingly. See the API documentation for details, or the <a href="https://beta.tinybase.org/demos/ui-components/inspector/"><inspector></inspector></a>demo, for example.</p><h4 id="api-changes">API <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/changes/"><code>Changes</code></a></h4><p>The following changes have been made to the existing <a href="https://beta.tinybase.org/">TinyBase</a> API for consistency. These are less common parts of the API but should straightforward to correct if you are using them.</p><p>In the type definitions:</p><ul><li>The GetTransactionChanges and GetTransactionLog types have been removed.</li><li>The TransactionChanges type has been renamed as the <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/changes/"><code>Changes</code></a> type.</li><li>The <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/changes/"><code>Changes</code></a> type now uses <code>undefined</code> instead of <code>null</code> to indicate a <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> or <a href="https://beta.tinybase.org/api/store/type-aliases/store/value/"><code>Value</code></a> that has been deleted or that was not present.</li><li>The <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/transactionlog/"><code>TransactionLog</code></a> type is now an array instead of a JavaScript object.</li></ul><p>In the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> interface:</p><ul><li>There is a new <a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/transaction/gettransactionchanges/"><code>getTransactionChanges</code></a> method and a new getTransactionLog method.</li><li>The setTransactionChanges method is renamed as the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/setter/applychanges/"><code>applyChanges</code></a> method.</li><li>A <a href="https://beta.tinybase.org/api/store/type-aliases/callback/dorollback/"><code>DoRollback</code></a> function no longer gets passed arguments. You can use the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/transaction/gettransactionchanges/"><code>getTransactionChanges</code></a> method and <a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/transaction/gettransactionlog/"><code>getTransactionLog</code></a> method directly instead.</li><li>Similarly, a <a href="https://beta.tinybase.org/api/store/type-aliases/listener/transactionlistener/"><code>TransactionListener</code></a> function no longer gets passed arguments.</li></ul><p>In the <a href="https://beta.tinybase.org/api/persisters/"><code>persisters</code></a> module:</p><ul><li>The <a href="https://beta.tinybase.org/api/persisters/functions/creation/createcustompersister/"><code>createCustomPersister</code></a> function now takes a final optional boolean (<code>supportsMergeableStore</code>) to indicate that the <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> can support <a href="https://beta.tinybase.org/api/mergeable-store/interfaces/mergeable/mergeablestore/"><code>MergeableStore</code></a> as well as <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> objects.</li><li>A <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>&#x27;s <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/load/load/"><code>load</code></a> method and <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/methods/load/startautoload/"><code>startAutoLoad</code></a> method now take a <a href="https://beta.tinybase.org/api/store/type-aliases/store/content/"><code>Content</code></a> object as one parameter, rather than <a href="https://beta.tinybase.org/api/store/type-aliases/store/tables/"><code>Tables</code></a> and <a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> as two.</li><li>If you create a custom <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a>, the setPersisted method now receives changes made to a <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> directly by reference, rather than via a callback. Similarly, the <a href="https://beta.tinybase.org/api/persisters/type-aliases/creation/persisterlistener/"><code>PersisterListener</code></a> you register in your addPersisterListener implementation now takes <a href="https://beta.tinybase.org/api/store/type-aliases/store/content/"><code>Content</code></a> and <a href="https://beta.tinybase.org/api/store/type-aliases/transaction/changes/"><code>Changes</code></a> objects directly rather than via a callback.</li><li>The broadcastTransactionChanges method in the <a href="https://beta.tinybase.org/api/persister-partykit-server/"><code>persister-partykit-server</code></a> module has been renamed to the broadcastChanges method.</li></ul><h2 id="v4-8">v4.8</h2><p>This release includes the new <a href="https://beta.tinybase.org/api/persister-powersync/"><code>persister-powersync</code></a> module, which provides a <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> for <a href="https://www.powersync.com/">PowerSync&#x27;s SQLite</a> database.</p><p>Much like the other SQLite persisters, use it by passing in a PowerSync instance to the <a href="https://beta.tinybase.org/api/persister-powersync/functions/creation/createpowersyncpersister/"><code>createPowerSyncPersister</code></a> function; something like:</p>
64
64
 
65
65
  ```js yolo
66
66
  const powerSync = usePowerSync();
@@ -102,7 +102,7 @@ const persister = createElectricSqlPersister(store, electric, {
102
102
  });
103
103
  ```
104
104
 
105
- <p>This release is accompanied by a <a href="https://github.com/tinyplex/tinybase-ts-react-electricsql">template project</a> to get started quickly with this integration. Enjoy!</p><h2 id="v4-5">v4.5</h2><p>This release includes the new <a href="https://beta.tinybase.org/api/persister-expo-sqlite-next/"><code>persister-expo-sqlite-next</code></a> module, which provides a <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> for the modern version of Expo&#x27;s <a href="https://docs.expo.dev/versions/latest/sdk/sqlite">SQLite</a> library, designated &#x27;next&#x27; as of November 2023. This API should be used if you are installing the <code>expo-sqlite/next</code> module.</p><p>Note that <a href="https://beta.tinybase.org/">TinyBase</a> support for the legacy version of Expo-SQLite (<code>expo-sqlite</code>) is still available in the <a href="https://beta.tinybase.org/api/persister-expo-sqlite/"><code>persister-expo-sqlite</code></a> module.</p><p>Thank you to Expo for providing this functionality!</p><h2 id="v4-4">v4.4</h2><p>This relatively straightforward release adds a selection of new listeners to the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> object, and their respective hooks. These are for listening to changes in the &#x27;existence&#x27; of entities rather than to their value. For example, the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhastablelistener/"><code>addHasTableListener</code></a> method will let you listen for the presence (or not) of a specific table.</p><p>The full set of new existence-listening methods and hooks to work with this is as follows:</p><div class="table"><table><thead><tr><th>Existence of:</th><th>Add Listener</th><th>Hook</th><th>Add Listener Hook</th></tr></thead><tbody><tr><td><a href="https://beta.tinybase.org/api/store/type-aliases/store/tables/"><code>Tables</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhastableslistener/"><code>addHasTablesListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastables/"><code>useHasTables</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastableslistener/"><code>useHasTablesListener</code></a></td></tr><tr><td>A <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhastablelistener/"><code>addHasTableListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastable/"><code>useHasTable</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastablelistener/"><code>useHasTableListener</code></a></td></tr><tr><td>A <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a> <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhastablecelllistener/"><code>addHasTableCellListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastablecell/"><code>useHasTableCell</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastablecelllistener/"><code>useHasTableCellListener</code></a></td></tr><tr><td>A <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhasrowlistener/"><code>addHasRowListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasrow/"><code>useHasRow</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasrowlistener/"><code>useHasRowListener</code></a></td></tr><tr><td>A <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhascelllistener/"><code>addHasCellListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehascell/"><code>useHasCell</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehascelllistener/"><code>useHasCellListener</code></a></td></tr><tr><td><a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhasvalueslistener/"><code>addHasValuesListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasvalues/"><code>useHasValues</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasvalueslistener/"><code>useHasValuesListener</code></a></td></tr><tr><td>A <a href="https://beta.tinybase.org/api/store/type-aliases/store/value/"><code>Value</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhasvaluelistener/"><code>addHasValueListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasvalue/"><code>useHasValue</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasvaluelistener/"><code>useHasValueListener</code></a></td></tr></tbody></table></div><p>These methods may become particularly important in future versions of <a href="https://beta.tinybase.org/">TinyBase</a> that support <code>null</code> as valid Cells and <a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a>.</p><h2 id="v4-3">v4.3</h2><p>We&#x27;re excited to announce <a href="https://beta.tinybase.org/">TinyBase</a> 4.3, which provides an integration with <a href="https://www.partykit.io/">PartyKit</a>, a cloud-based collaboration provider.</p><p>This allows you to enjoy the benefits of both a &quot;local-first&quot; architecture and a &quot;sharing-first&quot; platform. You can have structured data on the client with fast, reactive user experiences, but also benefit from cloud-based persistence and room-based collaboration.</p><p><img src="https://beta.tinybase.org/partykit.gif" alt="PartyKit" title="PartyKit"></p><p>This release includes two new modules:</p><ul><li>The <a href="https://beta.tinybase.org/api/persister-partykit-server/"><code>persister-partykit-server</code></a> module provides a server class for coordinating clients and persisting <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> data to the PartyKit cloud.</li><li>The <a href="https://beta.tinybase.org/api/persister-partykit-client/"><code>persister-partykit-client</code></a> module provides the API to create connections to the server and a binding to your <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a>.</li></ul><p>A <a href="https://beta.tinybase.org/">TinyBase</a> server implementation on PartyKit can be as simple as this:</p>
105
+ <p>This release is accompanied by a <a href="https://github.com/tinyplex/tinybase-ts-react-electricsql">template project</a> to get started quickly with this integration. Enjoy!</p><h2 id="v4-5">v4.5</h2><p>This release includes the new persister-expo-sqlite-next module, which provides a <a href="https://beta.tinybase.org/api/persisters/interfaces/persister/persister/"><code>Persister</code></a> for the modern version of Expo&#x27;s <a href="https://docs.expo.dev/versions/latest/sdk/sqlite">SQLite</a> library, designated &#x27;next&#x27; as of November 2023. This API should be used if you are installing the <code>expo-sqlite/next</code> module.</p><p>Note that <a href="https://beta.tinybase.org/">TinyBase</a> support for the legacy version of Expo-SQLite (<code>expo-sqlite</code>) is still available in the <a href="https://beta.tinybase.org/api/persister-expo-sqlite/"><code>persister-expo-sqlite</code></a> module.</p><p>NB as of <a href="https://beta.tinybase.org/">TinyBase</a> v5.0, this is now the default and legacy support has been removed.</p><p>Thank you to Expo for providing this functionality!</p><h2 id="v4-4">v4.4</h2><p>This relatively straightforward release adds a selection of new listeners to the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> object, and their respective hooks. These are for listening to changes in the &#x27;existence&#x27; of entities rather than to their value. For example, the <a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhastablelistener/"><code>addHasTableListener</code></a> method will let you listen for the presence (or not) of a specific table.</p><p>The full set of new existence-listening methods and hooks to work with this is as follows:</p><div class="table"><table><thead><tr><th>Existence of:</th><th>Add Listener</th><th>Hook</th><th>Add Listener Hook</th></tr></thead><tbody><tr><td><a href="https://beta.tinybase.org/api/store/type-aliases/store/tables/"><code>Tables</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhastableslistener/"><code>addHasTablesListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastables/"><code>useHasTables</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastableslistener/"><code>useHasTablesListener</code></a></td></tr><tr><td>A <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhastablelistener/"><code>addHasTableListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastable/"><code>useHasTable</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastablelistener/"><code>useHasTableListener</code></a></td></tr><tr><td>A <a href="https://beta.tinybase.org/api/store/type-aliases/store/table/"><code>Table</code></a> <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhastablecelllistener/"><code>addHasTableCellListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastablecell/"><code>useHasTableCell</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehastablecelllistener/"><code>useHasTableCellListener</code></a></td></tr><tr><td>A <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhasrowlistener/"><code>addHasRowListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasrow/"><code>useHasRow</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasrowlistener/"><code>useHasRowListener</code></a></td></tr><tr><td>A <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhascelllistener/"><code>addHasCellListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehascell/"><code>useHasCell</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehascelllistener/"><code>useHasCellListener</code></a></td></tr><tr><td><a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhasvalueslistener/"><code>addHasValuesListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasvalues/"><code>useHasValues</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasvalueslistener/"><code>useHasValuesListener</code></a></td></tr><tr><td>A <a href="https://beta.tinybase.org/api/store/type-aliases/store/value/"><code>Value</code></a></td><td><a href="https://beta.tinybase.org/api/store/interfaces/store/store/methods/listener/addhasvaluelistener/"><code>addHasValueListener</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasvalue/"><code>useHasValue</code></a></td><td><a href="https://beta.tinybase.org/api/ui-react/functions/store-hooks/usehasvaluelistener/"><code>useHasValueListener</code></a></td></tr></tbody></table></div><p>These methods may become particularly important in future versions of <a href="https://beta.tinybase.org/">TinyBase</a> that support <code>null</code> as valid Cells and <a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a>.</p><h2 id="v4-3">v4.3</h2><p>We&#x27;re excited to announce <a href="https://beta.tinybase.org/">TinyBase</a> 4.3, which provides an integration with <a href="https://www.partykit.io/">PartyKit</a>, a cloud-based collaboration provider.</p><p>This allows you to enjoy the benefits of both a &quot;local-first&quot; architecture and a &quot;sharing-first&quot; platform. You can have structured data on the client with fast, reactive user experiences, but also benefit from cloud-based persistence and room-based collaboration.</p><p><img src="https://beta.tinybase.org/partykit.gif" alt="PartyKit" title="PartyKit"></p><p>This release includes two new modules:</p><ul><li>The <a href="https://beta.tinybase.org/api/persister-partykit-server/"><code>persister-partykit-server</code></a> module provides a server class for coordinating clients and persisting <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a> data to the PartyKit cloud.</li><li>The <a href="https://beta.tinybase.org/api/persister-partykit-client/"><code>persister-partykit-client</code></a> module provides the API to create connections to the server and a binding to your <a href="https://beta.tinybase.org/api/store/interfaces/store/store/"><code>Store</code></a>.</li></ul><p>A <a href="https://beta.tinybase.org/">TinyBase</a> server implementation on PartyKit can be as simple as this:</p>
106
106
 
107
107
  ```js yolo
108
108
  import {TinyBasePartyKitServer} from 'tinybase/persisters/persister-partykit-server';
@@ -1 +1 @@
1
- var e,n;e=this,n=function(e,n){"use strict";const l=e=>typeof e,t="tinybase",r="",o=",",i=l(r),u=(e,n)=>e.repeat(n),a=Promise,d=clearInterval,s=e=>null==e,c=(e,n,l)=>s(e)?null==l?void 0:l():n(e),v=e=>l(e)==i,y=e=>Array.isArray(e),f=(e,n,l)=>e.slice(n,l),p=e=>e.length,h=e=>{return n=function*(){return a.all(e)},new Promise(((e,l)=>{var t=e=>{try{o(n.next(e))}catch(e){l(e)}},r=e=>{try{o(n.throw(e))}catch(e){l(e)}},o=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,r);o((n=n.apply(void 0,null)).next())}));var n},m=(e,n="")=>e.join(n),b=(e,n)=>e.map(n),E=e=>0==p(e),g=(e,n)=>e.filter(n),O=(e,...n)=>e.push(...n),P=(e,n)=>{var l;return null!=(l=null==e?void 0:e.has(n))&&l},w=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},A=(e,n)=>null==e?void 0:e.delete(n),C=Object,T=e=>C.getPrototypeOf(e),x=C.entries,S=C.keys,N=C.freeze,L=(e=[])=>C.fromEntries(e),R=(...e)=>C.assign({},...e),I=(e,n)=>n in e,D=(e,n)=>b(x(e),(([e,l])=>n(l,e))),j=e=>C.values(e),M=e=>p(S(e)),$=e=>(e=>!s(e)&&c(T(e),(e=>e==C.prototype||s(T(e))),(()=>!0)))(e)&&0==M(e),_=e=>new Map(e),F=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},q=(e,n)=>null==e?void 0:e.get(n),B=(e,n)=>{var l;return b([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>n(l,e)))},H=(e,n,l)=>s(l)?(A(e,n),e):null==e?void 0:e.set(n,l),J=(e,n,l,t)=>(P(e,n)||H(e,n,l()),q(e,n)),Y=(e,n,l,t=H)=>(D(n,((n,t)=>l(e,t,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,l)=>n(l)))})(e,(l=>I(n,l)?0:t(e,l))),e),k="_",G="_id",U=e=>`"${e.replace(/"/g,'""')}"`,W="SELECT",z=e=>new Set(y(e)||s(e)?e:[e]),K=(e,n)=>null==e?void 0:e.add(n);var V=Object.defineProperty,Q=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,ee=(e,n,l)=>n in e?V(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,ne=(e,n)=>{for(var l in n||(n={}))X.call(n,l)&&ee(e,l,n[l]);if(Q)for(var l of Q(n))Z.call(n,l)&&ee(e,l,n[l]);return e},le=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const te="TABLE",re="ALTER "+te,oe="DELETE FROM",ie=W+"*FROM",ue="FROM pragma_table_",ae="WHERE",de=(e,n,l,t)=>{const i=_();return[()=>le(void 0,null,(function*(){return Y(i,L(yield h(b(yield e("SELECT name "+ue+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+ce(n)+")ORDER BY name",n),(n=>le(void 0,[n],(function*({name:n}){return[n,L(b(yield e(W+" name,type "+ue+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,l)=>H(i,n,Y(J(i,n,_),l,((e,n,l)=>{l!=q(e,n)&&H(e,n,l)}),((e,n)=>H(e,n))))),((e,n)=>H(i,n)))})),(n,l)=>le(void 0,null,(function*(){return((e,n)=>!s(q(q(i,e),n)))(n,l)?L(g(b(yield e(ie+U(n)),(e=>{return[e[l],(n=ne({},e),t=l,delete n[t],n)];var n,t})),(([e,n])=>!s(e)&&!$(n)))):{}})),(n,l,u,a,d,c=!1)=>le(void 0,null,(function*(){const v=z();D(null!=u?u:{},(e=>b(S(null!=e?e:{}),(e=>K(v,e)))));const y=w(v);if(!c&&d&&E(y)&&P(i,n))return yield e("DROP "+te+U(n)),void H(i,n);if(E(y)||P(i,n)){const t=q(i,n),o=z(F(t));yield h([...b(y,(l=>le(void 0,null,(function*(){A(o,l)||(yield e(re+U(n)+"ADD"+U(l)),H(t,l,r))})))),...!c&&a?b(w(o),(r=>le(void 0,null,(function*(){r!=l&&(yield e(re+U(n)+"DROP"+U(r)),H(t,r))})))):[]])}else yield e("CREATE "+te+U(n)+"("+U(l)+` PRIMARY KEY ON CONFLICT REPLACE${m(b(y,(e=>o+U(e))))});`),H(i,n,_([[l,r],...b(y,(e=>[e,r]))]));if(c)s(u)?yield e(oe+U(n)+ae+" 1"):yield h(D(u,((r,o)=>le(void 0,null,(function*(){s(r)?yield e(oe+U(n)+ae+U(l)+"=?",[o]):E(y)||(yield se(e,n,l,S(r),[o,...j(r)],t))})))));else if(E(y))P(i,n)&&(yield e(oe+U(n)+ae+" 1"));else{const r=g(F(q(i,n)),(e=>e!=l)),o=[],a=[];D(null!=u?u:{},((e,n)=>{O(o,n,...b(r,(n=>null==e?void 0:e[n]))),O(a,n)})),yield se(e,n,l,r,o,t),yield e(oe+U(n)+ae+U(l)+"NOT IN("+ce(a)+")",a)}})),n=>le(void 0,null,(function*(){let t;yield e("BEGIN");try{t=yield n()}catch(e){null==l||l(e)}return yield e("END"),t}))]},se=(e,n,l,t,i,a=!0)=>le(void 0,null,(function*(){return yield e("INSERT "+(a?r:"OR REPLACE ")+"INTO"+U(n)+"("+U(l)+m(b(t,(e=>o+U(e))))+")VALUES"+f(u(`,(?${u(",?",p(t))})`,p(i)/(p(t)+1)),1)+(a?"ON CONFLICT("+U(l)+")DO UPDATE SET"+m(b(t,(e=>U(e)+"=excluded."+U(e))),o):r),b(i,(e=>null!=e?e:null)))})),ce=e=>m(b(e,(()=>"?")),o);var ve=Object.defineProperty,ye=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,he=(e,n,l)=>n in e?ve(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,me=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const be=_(),Ee=_(),ge=(e,n,l,t,r,o,i,u={},a=[])=>{let d,v,f,p=0,h=0,m=0;J(be,a,(()=>0)),J(Ee,a,(()=>[]));const[b,E,g,P,w]=((e=1,n)=>e>1&&n.isMergeable()?[1,n.getMergeableContent,n.getTransactionMergeableChanges,([[e],[n]])=>!$(e)||!$(n),n.setDefaultContent]:2!=e?[0,n.getContent,n.getTransactionChanges,([e,n])=>!$(e)||!$(n),n.setContent]:(e=>{throw Error("Store type not supported by this Persister")})())(i,e),A=n=>{(b&&y(null==n?void 0:n[0])?1===(null==n?void 0:n[2])?e.applyMergeableChanges:e.setMergeableContent:1===(null==n?void 0:n[2])?e.applyChanges:e.setContent)(n)},C=e=>me(void 0,null,(function*(){return 2!=p&&(p=1,h++,yield L((()=>me(void 0,null,(function*(){try{A(yield n())}catch(n){null==o||o(n),e&&w(e)}p=0}))))),R})),T=()=>(v&&(r(v),v=void 0),R),x=e=>me(void 0,null,(function*(){return 1!=p&&(p=2,m++,yield L((()=>me(void 0,null,(function*(){try{yield l(E,e)}catch(e){null==o||o(e)}p=0}))))),R})),S=()=>(c(f,e.delListener),f=void 0,R),L=(...e)=>me(void 0,null,(function*(){return O(q(Ee,a),...e),yield me(void 0,null,(function*(){if(!q(be,a)){for(H(be,a,1);!s((e=q(Ee,a),d=e.shift()));)try{yield d()}catch(e){null==o||o(e)}H(be,a,0)}var e})),R})),R=((e,n)=>{for(var l in n||(n={}))fe.call(n,l)&&he(e,l,n[l]);if(ye)for(var l of ye(n))pe.call(n,l)&&he(e,l,n[l]);return e})({load:C,startAutoLoad:e=>me(void 0,null,(function*(){return yield T().load(e),v=t(((e,n)=>me(void 0,null,(function*(){n||e?2!=p&&(p=1,h++,A(null!=n?n:e),p=0):yield C()})))),R})),stopAutoLoad:T,isAutoLoading:()=>!s(v),save:x,startAutoSave:()=>me(void 0,null,(function*(){return yield S().save(),f=e.addDidFinishTransactionListener((()=>{const e=g();P(e)&&x(e)})),R})),stopAutoSave:S,isAutoSaving:()=>!s(f),schedule:L,getStore:()=>e,destroy:()=>T().stopAutoSave(),getStats:()=>({loads:h,saves:m})},u);return N(R)};var Oe=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const Pe=(e,n,l,t,r,o,[i,u,a],d,s,c,v)=>{const[y,f,p,h]=de(n,d,r,v);return ge(e,(()=>Oe(void 0,null,(function*(){return yield h((()=>Oe(void 0,null,(function*(){var e,n,l;return yield y(),l=null!=(n=null==(e=(yield f(i,u))[k])?void 0:e[a])?n:"null",JSON.parse(l,((e,n)=>""===n?void 0:n))}))))}))),(e=>Oe(void 0,null,(function*(){return yield h((()=>Oe(void 0,null,(function*(){var n,l;yield y(),yield p(i,u,{[k]:{[a]:(l=null!=(n=e())?n:null,JSON.stringify(l,((e,n)=>void 0===n?"":n)))}},!0,!0)}))))}))),l,t,r,o,{[c]:()=>s},s)};var we=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const Ae=(e,n,l,t,r,o,[i,u,[a,d,c]],v,y,f,p)=>{const[m,b,E,O]=de(n,v,r,p),P=(e,n)=>we(void 0,null,(function*(){return yield h(B(u,((l,t)=>we(void 0,[l,t],(function*([l,t,r,o],i){n&&!I(e,i)||(yield E(l,t,e[i],r,o,n))})))))})),w=(e,n)=>we(void 0,null,(function*(){return d?yield E(c,G,{[k]:e},!0,!0,n):null}));return ge(e,(()=>we(void 0,null,(function*(){return yield O((()=>we(void 0,null,(function*(){yield m();const e=yield we(void 0,null,(function*(){return L(g(yield h(B(i,((e,n)=>we(void 0,[e,n],(function*([e,n],l){return[e,yield b(l,n)]}))))),(e=>!$(e[1]))))})),n=yield we(void 0,null,(function*(){return a?(yield b(c,G))[k]:{}}));return $(e)&&s(n)?void 0:[e,n]}))))}))),((e,n)=>we(void 0,null,(function*(){return yield O((()=>we(void 0,null,(function*(){if(yield m(),s(n)){const[n,l]=e();yield P(n),yield w(l)}else yield P(n[0],!0),yield w(n[1],!0)}))))}))),l,t,r,o,{[f]:()=>y},y)},Ce="ColumnName",Te="store",xe="json",Se=Te+"TableName",Ne=Te+"Id"+Ce,Le=Te+Ce,Re="autoLoadIntervalSeconds",Ie="rowId"+Ce,De="tableId",je="tableName",Me={mode:xe,[Re]:1},$e={load:0,save:0,[je]:t+"_values"},_e=(e,n,l,t,r)=>{const o=_();return D(e,((e,i)=>{const u=f(j(R(n,v(e)?{[l]:e}:e)),0,M(n));s(u[0])||t(i,u[0])||(r(i,u[0]),H(o,i,u))})),o};var Fe=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const qe="pragma_",Be="data_version",He="schema_version";e.createExpoSqlitePersister=(e,l,r,o,i)=>((e,n,l,r,o,i,u,a,s,c="getDb",y)=>{let p,h,m;const[b,E,g,O]=(e=>{var n,l,r;const o=(e=>R(Me,v(e)?{[Se]:e}:null!=e?e:{}))(e),i=o[Re];if(o.mode==xe){const e=null!=(n=o[Se])?n:t;return[1,i,[e,null!=(l=o[Ne])?l:G,null!=(r=o[Le])?r:Te],z(e)]}const{tables:{load:u={},save:a={}}={},values:d={}}=o,s=f(j(R($e,d)),0,M($e)),c=s[2],y=z(c),p=z(c);return[0,i,[_e(u,{[De]:null,[Ie]:G},De,(e=>P(p,e)),(e=>K(y,e))),_e(a,{[je]:null,[Ie]:G,deleteEmptyColumns:0,deleteEmptyTable:0},je,((e,n)=>P(p,n)),((e,n)=>K(y,n))),s],y]})(n);return(b?Pe:Ae)(e,i?(e,n)=>Fe(void 0,null,(function*(){return i(e,n),yield l(e,n)})):l,(e=>{return[(n=()=>Fe(void 0,null,(function*(){try{const[{d:n,s:t,c:r}]=yield l(`SELECT ${Be} d,${He} s,TOTAL_CHANGES() c FROM ${qe}${Be} JOIN ${qe}${He}`);n==(null!=p?p:p=n)&&t==(null!=h?h:h=t)&&r==(null!=m?m:m=r)||(e(),p=n,h=t)}catch(e){}})),t=E,n(),setInterval(n,1e3*t)),r((n=>O.has(n)?e():0))];var n,t}),(([e,n])=>{d(e),p=h=m=null,o(n)}),u,a,g,w(O),s,c,y)})(e,r,((e,...n)=>{return t=[e,...n],r=function*(e,n=[]){return yield l.getAllAsync(e,n)},new Promise(((e,n)=>{var l=e=>{try{i(r.next(e))}catch(e){n(e)}},o=e=>{try{i(r.throw(e))}catch(e){n(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,o);i((r=r.apply(void 0,t)).next())}));var t,r}),(e=>n.addDatabaseChangeListener((({tableName:n})=>e(n)))),(e=>e.remove()),o,i,3,l)},"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("expo-sqlite")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterExpoSqlite={},e.expoSqlite);
1
+ var e,n;e=this,n=function(e,n){"use strict";const l=e=>typeof e,t="tinybase",r="",o=",",i=l(r),u=(e,n)=>e.repeat(n),a=Promise,d=clearInterval,s=e=>null==e,c=(e,n,l)=>s(e)?null==l?void 0:l():n(e),v=e=>l(e)==i,y=e=>Array.isArray(e),f=(e,n,l)=>e.slice(n,l),p=e=>e.length,h=e=>{return n=function*(){return a.all(e)},new Promise(((e,l)=>{var t=e=>{try{o(n.next(e))}catch(e){l(e)}},r=e=>{try{o(n.throw(e))}catch(e){l(e)}},o=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,r);o((n=n.apply(void 0,null)).next())}));var n},m=(e,n="")=>e.join(n),b=(e,n)=>e.map(n),E=e=>0==p(e),g=(e,n)=>e.filter(n),O=(e,...n)=>e.push(...n),P=(e,n)=>{var l;return null!=(l=null==e?void 0:e.has(n))&&l},w=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},A=(e,n)=>null==e?void 0:e.delete(n),C=Object,T=e=>C.getPrototypeOf(e),x=C.entries,S=C.keys,N=C.freeze,L=(e=[])=>C.fromEntries(e),R=(...e)=>C.assign({},...e),I=(e,n)=>n in e,D=(e,n)=>b(x(e),(([e,l])=>n(l,e))),j=e=>C.values(e),M=e=>p(S(e)),$=e=>(e=>!s(e)&&c(T(e),(e=>e==C.prototype||s(T(e))),(()=>!0)))(e)&&0==M(e),_=e=>new Map(e),F=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},q=(e,n)=>null==e?void 0:e.get(n),B=(e,n)=>{var l;return b([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>n(l,e)))},H=(e,n,l)=>s(l)?(A(e,n),e):null==e?void 0:e.set(n,l),J=(e,n,l,t)=>(P(e,n)||H(e,n,l()),q(e,n)),Y=(e,n,l,t=H)=>(D(n,((n,t)=>l(e,t,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,l)=>n(l)))})(e,(l=>I(n,l)?0:t(e,l))),e),k="_",G="_id",U=e=>`"${e.replace(/"/g,'""')}"`,W="SELECT",z=e=>new Set(y(e)||s(e)?e:[e]),K=(e,n)=>null==e?void 0:e.add(n);var V=Object.defineProperty,Q=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,ee=(e,n,l)=>n in e?V(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,ne=(e,n)=>{for(var l in n||(n={}))X.call(n,l)&&ee(e,l,n[l]);if(Q)for(var l of Q(n))Z.call(n,l)&&ee(e,l,n[l]);return e},le=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const te="TABLE",re="ALTER "+te,oe="DELETE FROM",ie=W+"*FROM",ue="FROM pragma_table_",ae="WHERE",de=(e,n,l,t)=>{const i=_();return[()=>le(void 0,null,(function*(){return Y(i,L(yield h(b(yield e("SELECT name "+ue+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+ce(n)+")ORDER BY name",n),(n=>le(void 0,[n],(function*({name:n}){return[n,L(b(yield e(W+" name,type "+ue+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,l)=>H(i,n,Y(J(i,n,_),l,((e,n,l)=>{l!=q(e,n)&&H(e,n,l)}),((e,n)=>H(e,n))))),((e,n)=>H(i,n)))})),(n,l)=>le(void 0,null,(function*(){return((e,n)=>!s(q(q(i,e),n)))(n,l)?L(g(b(yield e(ie+U(n)),(e=>{return[e[l],(n=ne({},e),t=l,delete n[t],n)];var n,t})),(([e,n])=>!s(e)&&!$(n)))):{}})),(n,l,u,a,d,c=!1)=>le(void 0,null,(function*(){const v=z();D(null!=u?u:{},(e=>b(S(null!=e?e:{}),(e=>K(v,e)))));const y=w(v);if(!c&&d&&E(y)&&P(i,n))return yield e("DROP "+te+U(n)),void H(i,n);if(E(y)||P(i,n)){const t=q(i,n),o=z(F(t));yield h([...b(y,(l=>le(void 0,null,(function*(){A(o,l)||(yield e(re+U(n)+"ADD"+U(l)),H(t,l,r))})))),...!c&&a?b(w(o),(r=>le(void 0,null,(function*(){r!=l&&(yield e(re+U(n)+"DROP"+U(r)),H(t,r))})))):[]])}else yield e("CREATE "+te+U(n)+"("+U(l)+` PRIMARY KEY ON CONFLICT REPLACE${m(b(y,(e=>o+U(e))))});`),H(i,n,_([[l,r],...b(y,(e=>[e,r]))]));if(c)s(u)?yield e(oe+U(n)+ae+" 1"):yield h(D(u,((r,o)=>le(void 0,null,(function*(){s(r)?yield e(oe+U(n)+ae+U(l)+"=?",[o]):E(y)||(yield se(e,n,l,S(r),[o,...j(r)],t))})))));else if(E(y))P(i,n)&&(yield e(oe+U(n)+ae+" 1"));else{const r=g(F(q(i,n)),(e=>e!=l)),o=[],a=[];D(null!=u?u:{},((e,n)=>{O(o,n,...b(r,(n=>null==e?void 0:e[n]))),O(a,n)})),yield se(e,n,l,r,o,t),yield e(oe+U(n)+ae+U(l)+"NOT IN("+ce(a)+")",a)}})),n=>le(void 0,null,(function*(){let t;yield e("BEGIN");try{t=yield n()}catch(e){null==l||l(e)}return yield e("END"),t}))]},se=(e,n,l,t,i,a=!0)=>le(void 0,null,(function*(){return yield e("INSERT "+(a?r:"OR REPLACE ")+"INTO"+U(n)+"("+U(l)+m(b(t,(e=>o+U(e))))+")VALUES"+f(u(`,(?${u(",?",p(t))})`,p(i)/(p(t)+1)),1)+(a?"ON CONFLICT("+U(l)+")DO UPDATE SET"+m(b(t,(e=>U(e)+"=excluded."+U(e))),o):r),b(i,(e=>null!=e?e:null)))})),ce=e=>m(b(e,(()=>"?")),o);var ve=Object.defineProperty,ye=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,he=(e,n,l)=>n in e?ve(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,me=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const be=_(),Ee=_(),ge=(e,n,l,t,r,o,i,u={},a=[])=>{let d,v,f,p=0,h=0,m=0;J(be,a,(()=>0)),J(Ee,a,(()=>[]));const[b,E,g,P,w]=((e=1,n)=>e>1&&n.isMergeable()?[1,n.getMergeableContent,n.getTransactionMergeableChanges,([[e],[n]])=>!$(e)||!$(n),n.setDefaultContent]:2!=e?[0,n.getContent,n.getTransactionChanges,([e,n])=>!$(e)||!$(n),n.setContent]:(e=>{throw Error("Store type not supported by this Persister")})())(i,e),A=n=>{(b&&y(null==n?void 0:n[0])?1===(null==n?void 0:n[2])?e.applyMergeableChanges:e.setMergeableContent:1===(null==n?void 0:n[2])?e.applyChanges:e.setContent)(n)},C=e=>me(void 0,null,(function*(){return 2!=p&&(p=1,h++,yield L((()=>me(void 0,null,(function*(){try{A(yield n())}catch(n){null==o||o(n),e&&w(e)}p=0}))))),R})),T=()=>(v&&(r(v),v=void 0),R),x=e=>me(void 0,null,(function*(){return 1!=p&&(p=2,m++,yield L((()=>me(void 0,null,(function*(){try{yield l(E,e)}catch(e){null==o||o(e)}p=0}))))),R})),S=()=>(c(f,e.delListener),f=void 0,R),L=(...e)=>me(void 0,null,(function*(){return O(q(Ee,a),...e),yield me(void 0,null,(function*(){if(!q(be,a)){for(H(be,a,1);!s((e=q(Ee,a),d=e.shift()));)try{yield d()}catch(e){null==o||o(e)}H(be,a,0)}var e})),R})),R=((e,n)=>{for(var l in n||(n={}))fe.call(n,l)&&he(e,l,n[l]);if(ye)for(var l of ye(n))pe.call(n,l)&&he(e,l,n[l]);return e})({load:C,startAutoLoad:e=>me(void 0,null,(function*(){return yield T().load(e),v=t(((e,n)=>me(void 0,null,(function*(){n||e?2!=p&&(p=1,h++,A(null!=n?n:e),p=0):yield C()})))),R})),stopAutoLoad:T,isAutoLoading:()=>!s(v),save:x,startAutoSave:()=>me(void 0,null,(function*(){return yield S().save(),f=e.addDidFinishTransactionListener((()=>{const e=g();P(e)&&x(e)})),R})),stopAutoSave:S,isAutoSaving:()=>!s(f),schedule:L,getStore:()=>e,destroy:()=>T().stopAutoSave(),getStats:()=>({loads:h,saves:m})},u);return N(R)};var Oe=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const Pe=(e,n,l,t,r,o,[i,u,a],d,s,c,v)=>{const[y,f,p,h]=de(n,d,r,v);return ge(e,(()=>Oe(void 0,null,(function*(){return yield h((()=>Oe(void 0,null,(function*(){var e,n,l;return yield y(),l=null!=(n=null==(e=(yield f(i,u))[k])?void 0:e[a])?n:"null",JSON.parse(l,((e,n)=>""===n?void 0:n))}))))}))),(e=>Oe(void 0,null,(function*(){return yield h((()=>Oe(void 0,null,(function*(){var n,l;yield y(),yield p(i,u,{[k]:{[a]:(l=null!=(n=e())?n:null,JSON.stringify(l,((e,n)=>void 0===n?"":n)))}},!0,!0)}))))}))),l,t,r,o,{[c]:()=>s},s)};var we=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const Ae=(e,n,l,t,r,o,[i,u,[a,d,c]],v,y,f,p)=>{const[m,b,E,O]=de(n,v,r,p),P=(e,n)=>we(void 0,null,(function*(){return yield h(B(u,((l,t)=>we(void 0,[l,t],(function*([l,t,r,o],i){n&&!I(e,i)||(yield E(l,t,e[i],r,o,n))})))))})),w=(e,n)=>we(void 0,null,(function*(){return d?yield E(c,G,{[k]:e},!0,!0,n):null}));return ge(e,(()=>we(void 0,null,(function*(){return yield O((()=>we(void 0,null,(function*(){yield m();const e=yield we(void 0,null,(function*(){return L(g(yield h(B(i,((e,n)=>we(void 0,[e,n],(function*([e,n],l){return[e,yield b(l,n)]}))))),(e=>!$(e[1]))))})),n=yield we(void 0,null,(function*(){return a?(yield b(c,G))[k]:{}}));return $(e)&&s(n)?void 0:[e,n]}))))}))),((e,n)=>we(void 0,null,(function*(){return yield O((()=>we(void 0,null,(function*(){if(yield m(),s(n)){const[n,l]=e();yield P(n),yield w(l)}else yield P(n[0],!0),yield w(n[1],!0)}))))}))),l,t,r,o,{[f]:()=>y},y)},Ce="ColumnName",Te="store",xe="json",Se=Te+"TableName",Ne=Te+"Id"+Ce,Le=Te+Ce,Re="autoLoadIntervalSeconds",Ie="rowId"+Ce,De="tableId",je="tableName",Me={mode:xe,[Re]:1},$e={load:0,save:0,[je]:t+"_values"},_e=(e,n,l,t,r)=>{const o=_();return D(e,((e,i)=>{const u=f(j(R(n,v(e)?{[l]:e}:e)),0,M(n));s(u[0])||t(i,u[0])||(r(i,u[0]),H(o,i,u))})),o};var Fe=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const qe="pragma_",Be="data_version",He="schema_version";e.createExpoSqlitePersister=(e,l,r,o,i)=>((e,n,l,r,o,i,u,a,s,c="getDb",y)=>{let p,h,m;const[b,E,g,O]=(e=>{var n,l,r;const o=(e=>R(Me,v(e)?{[Se]:e}:null!=e?e:{}))(e),i=o[Re];if(o.mode==xe){const e=null!=(n=o[Se])?n:t;return[1,i,[e,null!=(l=o[Ne])?l:G,null!=(r=o[Le])?r:Te],z(e)]}const{tables:{load:u={},save:a={}}={},values:d={}}=o,s=f(j(R($e,d)),0,M($e)),c=s[2],y=z(c),p=z(c);return[0,i,[_e(u,{[De]:null,[Ie]:G},De,(e=>P(p,e)),(e=>K(y,e))),_e(a,{[je]:null,[Ie]:G,deleteEmptyColumns:0,deleteEmptyTable:0},je,((e,n)=>P(p,n)),((e,n)=>K(y,n))),s],y]})(n);return(b?Pe:Ae)(e,i?(e,n)=>Fe(void 0,null,(function*(){return i(e,n),yield l(e,n)})):l,(e=>{return[(n=()=>Fe(void 0,null,(function*(){try{const[{d:n,s:t,c:r}]=yield l(`SELECT ${Be} d,${He} s,TOTAL_CHANGES() c FROM ${qe}${Be} JOIN ${qe}${He}`);n==(null!=p?p:p=n)&&t==(null!=h?h:h=t)&&r==(null!=m?m:m=r)||(e(),p=n,h=t)}catch(e){}})),t=E,n(),setInterval(n,1e3*t)),r((n=>O.has(n)?e():0))];var n,t}),(([e,n])=>{d(e),p=h=m=null,o(n)}),u,a,g,w(O),s,c,y)})(e,r,((e,...n)=>{return t=[e,...n],r=function*(e,n=[]){return yield l.getAllAsync(e,n)},new Promise(((e,n)=>{var l=e=>{try{i(r.next(e))}catch(e){n(e)}},o=e=>{try{i(r.throw(e))}catch(e){n(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,o);i((r=r.apply(void 0,t)).next())}));var t,r}),(e=>n.addDatabaseChangeListener((({tableName:n})=>e(n)))),(e=>e.remove()),o,i,3,l)},"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("expo-sqlite")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterExpoSqlite={},e["expo-sqlite"]);
@@ -1 +1 @@
1
- var e,n;e=this,n=function(e,n){"use strict";const l=e=>typeof e,t="tinybase",r="",o=",",i=l(r),u=(e,n)=>e.repeat(n),a=Promise,d=clearInterval,s=e=>null==e,c=(e,n,l)=>s(e)?null==l?void 0:l():n(e),v=e=>l(e)==i,y=e=>Array.isArray(e),f=(e,n,l)=>e.slice(n,l),p=e=>e.length,h=e=>{return n=function*(){return a.all(e)},new Promise(((e,l)=>{var t=e=>{try{o(n.next(e))}catch(e){l(e)}},r=e=>{try{o(n.throw(e))}catch(e){l(e)}},o=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,r);o((n=n.apply(void 0,null)).next())}));var n},m=(e,n="")=>e.join(n),b=(e,n)=>e.map(n),E=e=>0==p(e),g=(e,n)=>e.filter(n),O=(e,...n)=>e.push(...n),P=(e,n)=>{var l;return null!=(l=null==e?void 0:e.has(n))&&l},w=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},A=(e,n)=>null==e?void 0:e.delete(n),C=Object,T=e=>C.getPrototypeOf(e),x=C.entries,S=C.keys,N=C.freeze,L=(e=[])=>C.fromEntries(e),R=(...e)=>C.assign({},...e),I=(e,n)=>n in e,D=(e,n)=>b(x(e),(([e,l])=>n(l,e))),j=e=>C.values(e),M=e=>p(S(e)),$=e=>(e=>!s(e)&&c(T(e),(e=>e==C.prototype||s(T(e))),(()=>!0)))(e)&&0==M(e),_=e=>new Map(e),F=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},q=(e,n)=>null==e?void 0:e.get(n),B=(e,n)=>{var l;return b([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>n(l,e)))},H=(e,n,l)=>s(l)?(A(e,n),e):null==e?void 0:e.set(n,l),J=(e,n,l,t)=>(P(e,n)||H(e,n,l()),q(e,n)),Y=(e,n,l,t=H)=>(D(n,((n,t)=>l(e,t,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,l)=>n(l)))})(e,(l=>I(n,l)?0:t(e,l))),e),k="_",G="_id",U=e=>`"${e.replace(/"/g,'""')}"`,W="SELECT",z=e=>new Set(y(e)||s(e)?e:[e]),K=(e,n)=>null==e?void 0:e.add(n);var V=Object.defineProperty,Q=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,ee=(e,n,l)=>n in e?V(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,ne=(e,n)=>{for(var l in n||(n={}))X.call(n,l)&&ee(e,l,n[l]);if(Q)for(var l of Q(n))Z.call(n,l)&&ee(e,l,n[l]);return e},le=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const te="TABLE",re="ALTER "+te,oe="DELETE FROM",ie=W+"*FROM",ue="FROM pragma_table_",ae="WHERE",de=(e,n,l,t)=>{const i=_();return[()=>le(void 0,null,(function*(){return Y(i,L(yield h(b(yield e("SELECT name "+ue+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+ce(n)+")ORDER BY name",n),(n=>le(void 0,[n],(function*({name:n}){return[n,L(b(yield e(W+" name,type "+ue+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,l)=>H(i,n,Y(J(i,n,_),l,((e,n,l)=>{l!=q(e,n)&&H(e,n,l)}),((e,n)=>H(e,n))))),((e,n)=>H(i,n)))})),(n,l)=>le(void 0,null,(function*(){return((e,n)=>!s(q(q(i,e),n)))(n,l)?L(g(b(yield e(ie+U(n)),(e=>{return[e[l],(n=ne({},e),t=l,delete n[t],n)];var n,t})),(([e,n])=>!s(e)&&!$(n)))):{}})),(n,l,u,a,d,c=!1)=>le(void 0,null,(function*(){const v=z();D(null!=u?u:{},(e=>b(S(null!=e?e:{}),(e=>K(v,e)))));const y=w(v);if(!c&&d&&E(y)&&P(i,n))return yield e("DROP "+te+U(n)),void H(i,n);if(E(y)||P(i,n)){const t=q(i,n),o=z(F(t));yield h([...b(y,(l=>le(void 0,null,(function*(){A(o,l)||(yield e(re+U(n)+"ADD"+U(l)),H(t,l,r))})))),...!c&&a?b(w(o),(r=>le(void 0,null,(function*(){r!=l&&(yield e(re+U(n)+"DROP"+U(r)),H(t,r))})))):[]])}else yield e("CREATE "+te+U(n)+"("+U(l)+` PRIMARY KEY ON CONFLICT REPLACE${m(b(y,(e=>o+U(e))))});`),H(i,n,_([[l,r],...b(y,(e=>[e,r]))]));if(c)s(u)?yield e(oe+U(n)+ae+" 1"):yield h(D(u,((r,o)=>le(void 0,null,(function*(){s(r)?yield e(oe+U(n)+ae+U(l)+"=?",[o]):E(y)||(yield se(e,n,l,S(r),[o,...j(r)],t))})))));else if(E(y))P(i,n)&&(yield e(oe+U(n)+ae+" 1"));else{const r=g(F(q(i,n)),(e=>e!=l)),o=[],a=[];D(null!=u?u:{},((e,n)=>{O(o,n,...b(r,(n=>null==e?void 0:e[n]))),O(a,n)})),yield se(e,n,l,r,o,t),yield e(oe+U(n)+ae+U(l)+"NOT IN("+ce(a)+")",a)}})),n=>le(void 0,null,(function*(){let t;yield e("BEGIN");try{t=yield n()}catch(e){null==l||l(e)}return yield e("END"),t}))]},se=(e,n,l,t,i,a=!0)=>le(void 0,null,(function*(){return yield e("INSERT "+(a?r:"OR REPLACE ")+"INTO"+U(n)+"("+U(l)+m(b(t,(e=>o+U(e))))+")VALUES"+f(u(`,(?${u(",?",p(t))})`,p(i)/(p(t)+1)),1)+(a?"ON CONFLICT("+U(l)+")DO UPDATE SET"+m(b(t,(e=>U(e)+"=excluded."+U(e))),o):r),b(i,(e=>null!=e?e:null)))})),ce=e=>m(b(e,(()=>"?")),o);var ve=Object.defineProperty,ye=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,he=(e,n,l)=>n in e?ve(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,me=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const be=_(),Ee=_(),ge=(e,n,l,t,r,o,i,u={},a=[])=>{let d,v,f,p=0,h=0,m=0;J(be,a,(()=>0)),J(Ee,a,(()=>[]));const[b,E,g,P,w]=((e=1,n)=>e>1&&n.isMergeable()?[1,n.getMergeableContent,n.getTransactionMergeableChanges,([[e],[n]])=>!$(e)||!$(n),n.setDefaultContent]:2!=e?[0,n.getContent,n.getTransactionChanges,([e,n])=>!$(e)||!$(n),n.setContent]:(e=>{throw Error("Store type not supported by this Persister")})())(i,e),A=n=>{(b&&y(null==n?void 0:n[0])?1===(null==n?void 0:n[2])?e.applyMergeableChanges:e.setMergeableContent:1===(null==n?void 0:n[2])?e.applyChanges:e.setContent)(n)},C=e=>me(void 0,null,(function*(){return 2!=p&&(p=1,h++,yield L((()=>me(void 0,null,(function*(){try{A(yield n())}catch(n){null==o||o(n),e&&w(e)}p=0}))))),R})),T=()=>(v&&(r(v),v=void 0),R),x=e=>me(void 0,null,(function*(){return 1!=p&&(p=2,m++,yield L((()=>me(void 0,null,(function*(){try{yield l(E,e)}catch(e){null==o||o(e)}p=0}))))),R})),S=()=>(c(f,e.delListener),f=void 0,R),L=(...e)=>me(void 0,null,(function*(){return O(q(Ee,a),...e),yield me(void 0,null,(function*(){if(!q(be,a)){for(H(be,a,1);!s((e=q(Ee,a),d=e.shift()));)try{yield d()}catch(e){null==o||o(e)}H(be,a,0)}var e})),R})),R=((e,n)=>{for(var l in n||(n={}))fe.call(n,l)&&he(e,l,n[l]);if(ye)for(var l of ye(n))pe.call(n,l)&&he(e,l,n[l]);return e})({load:C,startAutoLoad:e=>me(void 0,null,(function*(){return yield T().load(e),v=t(((e,n)=>me(void 0,null,(function*(){n||e?2!=p&&(p=1,h++,A(null!=n?n:e),p=0):yield C()})))),R})),stopAutoLoad:T,isAutoLoading:()=>!s(v),save:x,startAutoSave:()=>me(void 0,null,(function*(){return yield S().save(),f=e.addDidFinishTransactionListener((()=>{const e=g();P(e)&&x(e)})),R})),stopAutoSave:S,isAutoSaving:()=>!s(f),schedule:L,getStore:()=>e,destroy:()=>T().stopAutoSave(),getStats:()=>({loads:h,saves:m})},u);return N(R)};var Oe=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const Pe=(e,n,l,t,r,o,[i,u,a],d,s,c,v)=>{const[y,f,p,h]=de(n,d,r,v);return ge(e,(()=>Oe(void 0,null,(function*(){return yield h((()=>Oe(void 0,null,(function*(){var e,n,l;return yield y(),l=null!=(n=null==(e=(yield f(i,u))[k])?void 0:e[a])?n:"null",JSON.parse(l,((e,n)=>""===n?void 0:n))}))))}))),(e=>Oe(void 0,null,(function*(){return yield h((()=>Oe(void 0,null,(function*(){var n,l;yield y(),yield p(i,u,{[k]:{[a]:(l=null!=(n=e())?n:null,JSON.stringify(l,((e,n)=>void 0===n?"":n)))}},!0,!0)}))))}))),l,t,r,o,{[c]:()=>s},s)};var we=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const Ae=(e,n,l,t,r,o,[i,u,[a,d,c]],v,y,f,p)=>{const[m,b,E,O]=de(n,v,r,p),P=(e,n)=>we(void 0,null,(function*(){return yield h(B(u,((l,t)=>we(void 0,[l,t],(function*([l,t,r,o],i){n&&!I(e,i)||(yield E(l,t,e[i],r,o,n))})))))})),w=(e,n)=>we(void 0,null,(function*(){return d?yield E(c,G,{[k]:e},!0,!0,n):null}));return ge(e,(()=>we(void 0,null,(function*(){return yield O((()=>we(void 0,null,(function*(){yield m();const e=yield we(void 0,null,(function*(){return L(g(yield h(B(i,((e,n)=>we(void 0,[e,n],(function*([e,n],l){return[e,yield b(l,n)]}))))),(e=>!$(e[1]))))})),n=yield we(void 0,null,(function*(){return a?(yield b(c,G))[k]:{}}));return $(e)&&s(n)?void 0:[e,n]}))))}))),((e,n)=>we(void 0,null,(function*(){return yield O((()=>we(void 0,null,(function*(){if(yield m(),s(n)){const[n,l]=e();yield P(n),yield w(l)}else yield P(n[0],!0),yield w(n[1],!0)}))))}))),l,t,r,o,{[f]:()=>y},y)},Ce="ColumnName",Te="store",xe="json",Se=Te+"TableName",Ne=Te+"Id"+Ce,Le=Te+Ce,Re="autoLoadIntervalSeconds",Ie="rowId"+Ce,De="tableId",je="tableName",Me={mode:xe,[Re]:1},$e={load:0,save:0,[je]:t+"_values"},_e=(e,n,l,t,r)=>{const o=_();return D(e,((e,i)=>{const u=f(j(R(n,v(e)?{[l]:e}:e)),0,M(n));s(u[0])||t(i,u[0])||(r(i,u[0]),H(o,i,u))})),o};var Fe=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const qe="pragma_",Be="data_version",He="schema_version";e.createExpoSqlitePersister=(e,l,r,o,i)=>((e,n,l,r,o,i,u,a,s,c="getDb",y)=>{let p,h,m;const[b,E,g,O]=(e=>{var n,l,r;const o=(e=>R(Me,v(e)?{[Se]:e}:null!=e?e:{}))(e),i=o[Re];if(o.mode==xe){const e=null!=(n=o[Se])?n:t;return[1,i,[e,null!=(l=o[Ne])?l:G,null!=(r=o[Le])?r:Te],z(e)]}const{tables:{load:u={},save:a={}}={},values:d={}}=o,s=f(j(R($e,d)),0,M($e)),c=s[2],y=z(c),p=z(c);return[0,i,[_e(u,{[De]:null,[Ie]:G},De,(e=>P(p,e)),(e=>K(y,e))),_e(a,{[je]:null,[Ie]:G,deleteEmptyColumns:0,deleteEmptyTable:0},je,((e,n)=>P(p,n)),((e,n)=>K(y,n))),s],y]})(n);return(b?Pe:Ae)(e,i?(e,n)=>Fe(void 0,null,(function*(){return i(e,n),yield l(e,n)})):l,(e=>{return[(n=()=>Fe(void 0,null,(function*(){try{const[{d:n,s:t,c:r}]=yield l(`SELECT ${Be} d,${He} s,TOTAL_CHANGES() c FROM ${qe}${Be} JOIN ${qe}${He}`);n==(null!=p?p:p=n)&&t==(null!=h?h:h=t)&&r==(null!=m?m:m=r)||(e(),p=n,h=t)}catch(e){}})),t=E,n(),setInterval(n,1e3*t)),r((n=>O.has(n)?e():0))];var n,t}),(([e,n])=>{d(e),p=h=m=null,o(n)}),u,a,g,w(O),s,c,y)})(e,r,((e,...n)=>{return t=[e,...n],r=function*(e,n=[]){return yield l.getAllAsync(e,n)},new Promise(((e,n)=>{var l=e=>{try{i(r.next(e))}catch(e){n(e)}},o=e=>{try{i(r.throw(e))}catch(e){n(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,o);i((r=r.apply(void 0,t)).next())}));var t,r}),(e=>n.addDatabaseChangeListener((({tableName:n})=>e(n)))),(e=>e.remove()),o,i,3,l)},"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("expo-sqlite")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterExpoSqlite={},e.expoSqlite);
1
+ var e,n;e=this,n=function(e,n){"use strict";const l=e=>typeof e,t="tinybase",r="",o=",",i=l(r),u=(e,n)=>e.repeat(n),a=Promise,d=clearInterval,s=e=>null==e,c=(e,n,l)=>s(e)?null==l?void 0:l():n(e),v=e=>l(e)==i,y=e=>Array.isArray(e),f=(e,n,l)=>e.slice(n,l),p=e=>e.length,h=e=>{return n=function*(){return a.all(e)},new Promise(((e,l)=>{var t=e=>{try{o(n.next(e))}catch(e){l(e)}},r=e=>{try{o(n.throw(e))}catch(e){l(e)}},o=n=>n.done?e(n.value):Promise.resolve(n.value).then(t,r);o((n=n.apply(void 0,null)).next())}));var n},m=(e,n="")=>e.join(n),b=(e,n)=>e.map(n),E=e=>0==p(e),g=(e,n)=>e.filter(n),O=(e,...n)=>e.push(...n),P=(e,n)=>{var l;return null!=(l=null==e?void 0:e.has(n))&&l},w=e=>{var n;return[...null!=(n=null==e?void 0:e.values())?n:[]]},A=(e,n)=>null==e?void 0:e.delete(n),C=Object,T=e=>C.getPrototypeOf(e),x=C.entries,S=C.keys,N=C.freeze,L=(e=[])=>C.fromEntries(e),R=(...e)=>C.assign({},...e),I=(e,n)=>n in e,D=(e,n)=>b(x(e),(([e,l])=>n(l,e))),j=e=>C.values(e),M=e=>p(S(e)),$=e=>(e=>!s(e)&&c(T(e),(e=>e==C.prototype||s(T(e))),(()=>!0)))(e)&&0==M(e),_=e=>new Map(e),F=e=>{var n;return[...null!=(n=null==e?void 0:e.keys())?n:[]]},q=(e,n)=>null==e?void 0:e.get(n),B=(e,n)=>{var l;return b([...null!=(l=null==e?void 0:e.entries())?l:[]],(([e,l])=>n(l,e)))},H=(e,n,l)=>s(l)?(A(e,n),e):null==e?void 0:e.set(n,l),J=(e,n,l,t)=>(P(e,n)||H(e,n,l()),q(e,n)),Y=(e,n,l,t=H)=>(D(n,((n,t)=>l(e,t,n))),((e,n)=>{((e,n)=>{null==e||e.forEach(n)})(e,((e,l)=>n(l)))})(e,(l=>I(n,l)?0:t(e,l))),e),k="_",G="_id",U=e=>`"${e.replace(/"/g,'""')}"`,W="SELECT",z=e=>new Set(y(e)||s(e)?e:[e]),K=(e,n)=>null==e?void 0:e.add(n);var V=Object.defineProperty,Q=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,ee=(e,n,l)=>n in e?V(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,ne=(e,n)=>{for(var l in n||(n={}))X.call(n,l)&&ee(e,l,n[l]);if(Q)for(var l of Q(n))Z.call(n,l)&&ee(e,l,n[l]);return e},le=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const te="TABLE",re="ALTER "+te,oe="DELETE FROM",ie=W+"*FROM",ue="FROM pragma_table_",ae="WHERE",de=(e,n,l,t)=>{const i=_();return[()=>le(void 0,null,(function*(){return Y(i,L(yield h(b(yield e("SELECT name "+ue+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+ce(n)+")ORDER BY name",n),(n=>le(void 0,[n],(function*({name:n}){return[n,L(b(yield e(W+" name,type "+ue+"info(?)",[n]),(({name:e,type:n})=>[e,n])))]})))))),((e,n,l)=>H(i,n,Y(J(i,n,_),l,((e,n,l)=>{l!=q(e,n)&&H(e,n,l)}),((e,n)=>H(e,n))))),((e,n)=>H(i,n)))})),(n,l)=>le(void 0,null,(function*(){return((e,n)=>!s(q(q(i,e),n)))(n,l)?L(g(b(yield e(ie+U(n)),(e=>{return[e[l],(n=ne({},e),t=l,delete n[t],n)];var n,t})),(([e,n])=>!s(e)&&!$(n)))):{}})),(n,l,u,a,d,c=!1)=>le(void 0,null,(function*(){const v=z();D(null!=u?u:{},(e=>b(S(null!=e?e:{}),(e=>K(v,e)))));const y=w(v);if(!c&&d&&E(y)&&P(i,n))return yield e("DROP "+te+U(n)),void H(i,n);if(E(y)||P(i,n)){const t=q(i,n),o=z(F(t));yield h([...b(y,(l=>le(void 0,null,(function*(){A(o,l)||(yield e(re+U(n)+"ADD"+U(l)),H(t,l,r))})))),...!c&&a?b(w(o),(r=>le(void 0,null,(function*(){r!=l&&(yield e(re+U(n)+"DROP"+U(r)),H(t,r))})))):[]])}else yield e("CREATE "+te+U(n)+"("+U(l)+` PRIMARY KEY ON CONFLICT REPLACE${m(b(y,(e=>o+U(e))))});`),H(i,n,_([[l,r],...b(y,(e=>[e,r]))]));if(c)s(u)?yield e(oe+U(n)+ae+" 1"):yield h(D(u,((r,o)=>le(void 0,null,(function*(){s(r)?yield e(oe+U(n)+ae+U(l)+"=?",[o]):E(y)||(yield se(e,n,l,S(r),[o,...j(r)],t))})))));else if(E(y))P(i,n)&&(yield e(oe+U(n)+ae+" 1"));else{const r=g(F(q(i,n)),(e=>e!=l)),o=[],a=[];D(null!=u?u:{},((e,n)=>{O(o,n,...b(r,(n=>null==e?void 0:e[n]))),O(a,n)})),yield se(e,n,l,r,o,t),yield e(oe+U(n)+ae+U(l)+"NOT IN("+ce(a)+")",a)}})),n=>le(void 0,null,(function*(){let t;yield e("BEGIN");try{t=yield n()}catch(e){null==l||l(e)}return yield e("END"),t}))]},se=(e,n,l,t,i,a=!0)=>le(void 0,null,(function*(){return yield e("INSERT "+(a?r:"OR REPLACE ")+"INTO"+U(n)+"("+U(l)+m(b(t,(e=>o+U(e))))+")VALUES"+f(u(`,(?${u(",?",p(t))})`,p(i)/(p(t)+1)),1)+(a?"ON CONFLICT("+U(l)+")DO UPDATE SET"+m(b(t,(e=>U(e)+"=excluded."+U(e))),o):r),b(i,(e=>null!=e?e:null)))})),ce=e=>m(b(e,(()=>"?")),o);var ve=Object.defineProperty,ye=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,he=(e,n,l)=>n in e?ve(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,me=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const be=_(),Ee=_(),ge=(e,n,l,t,r,o,i,u={},a=[])=>{let d,v,f,p=0,h=0,m=0;J(be,a,(()=>0)),J(Ee,a,(()=>[]));const[b,E,g,P,w]=((e=1,n)=>e>1&&n.isMergeable()?[1,n.getMergeableContent,n.getTransactionMergeableChanges,([[e],[n]])=>!$(e)||!$(n),n.setDefaultContent]:2!=e?[0,n.getContent,n.getTransactionChanges,([e,n])=>!$(e)||!$(n),n.setContent]:(e=>{throw Error("Store type not supported by this Persister")})())(i,e),A=n=>{(b&&y(null==n?void 0:n[0])?1===(null==n?void 0:n[2])?e.applyMergeableChanges:e.setMergeableContent:1===(null==n?void 0:n[2])?e.applyChanges:e.setContent)(n)},C=e=>me(void 0,null,(function*(){return 2!=p&&(p=1,h++,yield L((()=>me(void 0,null,(function*(){try{A(yield n())}catch(n){null==o||o(n),e&&w(e)}p=0}))))),R})),T=()=>(v&&(r(v),v=void 0),R),x=e=>me(void 0,null,(function*(){return 1!=p&&(p=2,m++,yield L((()=>me(void 0,null,(function*(){try{yield l(E,e)}catch(e){null==o||o(e)}p=0}))))),R})),S=()=>(c(f,e.delListener),f=void 0,R),L=(...e)=>me(void 0,null,(function*(){return O(q(Ee,a),...e),yield me(void 0,null,(function*(){if(!q(be,a)){for(H(be,a,1);!s((e=q(Ee,a),d=e.shift()));)try{yield d()}catch(e){null==o||o(e)}H(be,a,0)}var e})),R})),R=((e,n)=>{for(var l in n||(n={}))fe.call(n,l)&&he(e,l,n[l]);if(ye)for(var l of ye(n))pe.call(n,l)&&he(e,l,n[l]);return e})({load:C,startAutoLoad:e=>me(void 0,null,(function*(){return yield T().load(e),v=t(((e,n)=>me(void 0,null,(function*(){n||e?2!=p&&(p=1,h++,A(null!=n?n:e),p=0):yield C()})))),R})),stopAutoLoad:T,isAutoLoading:()=>!s(v),save:x,startAutoSave:()=>me(void 0,null,(function*(){return yield S().save(),f=e.addDidFinishTransactionListener((()=>{const e=g();P(e)&&x(e)})),R})),stopAutoSave:S,isAutoSaving:()=>!s(f),schedule:L,getStore:()=>e,destroy:()=>T().stopAutoSave(),getStats:()=>({loads:h,saves:m})},u);return N(R)};var Oe=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const Pe=(e,n,l,t,r,o,[i,u,a],d,s,c,v)=>{const[y,f,p,h]=de(n,d,r,v);return ge(e,(()=>Oe(void 0,null,(function*(){return yield h((()=>Oe(void 0,null,(function*(){var e,n,l;return yield y(),l=null!=(n=null==(e=(yield f(i,u))[k])?void 0:e[a])?n:"null",JSON.parse(l,((e,n)=>""===n?void 0:n))}))))}))),(e=>Oe(void 0,null,(function*(){return yield h((()=>Oe(void 0,null,(function*(){var n,l;yield y(),yield p(i,u,{[k]:{[a]:(l=null!=(n=e())?n:null,JSON.stringify(l,((e,n)=>void 0===n?"":n)))}},!0,!0)}))))}))),l,t,r,o,{[c]:()=>s},s)};var we=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const Ae=(e,n,l,t,r,o,[i,u,[a,d,c]],v,y,f,p)=>{const[m,b,E,O]=de(n,v,r,p),P=(e,n)=>we(void 0,null,(function*(){return yield h(B(u,((l,t)=>we(void 0,[l,t],(function*([l,t,r,o],i){n&&!I(e,i)||(yield E(l,t,e[i],r,o,n))})))))})),w=(e,n)=>we(void 0,null,(function*(){return d?yield E(c,G,{[k]:e},!0,!0,n):null}));return ge(e,(()=>we(void 0,null,(function*(){return yield O((()=>we(void 0,null,(function*(){yield m();const e=yield we(void 0,null,(function*(){return L(g(yield h(B(i,((e,n)=>we(void 0,[e,n],(function*([e,n],l){return[e,yield b(l,n)]}))))),(e=>!$(e[1]))))})),n=yield we(void 0,null,(function*(){return a?(yield b(c,G))[k]:{}}));return $(e)&&s(n)?void 0:[e,n]}))))}))),((e,n)=>we(void 0,null,(function*(){return yield O((()=>we(void 0,null,(function*(){if(yield m(),s(n)){const[n,l]=e();yield P(n),yield w(l)}else yield P(n[0],!0),yield w(n[1],!0)}))))}))),l,t,r,o,{[f]:()=>y},y)},Ce="ColumnName",Te="store",xe="json",Se=Te+"TableName",Ne=Te+"Id"+Ce,Le=Te+Ce,Re="autoLoadIntervalSeconds",Ie="rowId"+Ce,De="tableId",je="tableName",Me={mode:xe,[Re]:1},$e={load:0,save:0,[je]:t+"_values"},_e=(e,n,l,t,r)=>{const o=_();return D(e,((e,i)=>{const u=f(j(R(n,v(e)?{[l]:e}:e)),0,M(n));s(u[0])||t(i,u[0])||(r(i,u[0]),H(o,i,u))})),o};var Fe=(e,n,l)=>new Promise(((t,r)=>{var o=e=>{try{u(l.next(e))}catch(e){r(e)}},i=e=>{try{u(l.throw(e))}catch(e){r(e)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,i);u((l=l.apply(e,n)).next())}));const qe="pragma_",Be="data_version",He="schema_version";e.createExpoSqlitePersister=(e,l,r,o,i)=>((e,n,l,r,o,i,u,a,s,c="getDb",y)=>{let p,h,m;const[b,E,g,O]=(e=>{var n,l,r;const o=(e=>R(Me,v(e)?{[Se]:e}:null!=e?e:{}))(e),i=o[Re];if(o.mode==xe){const e=null!=(n=o[Se])?n:t;return[1,i,[e,null!=(l=o[Ne])?l:G,null!=(r=o[Le])?r:Te],z(e)]}const{tables:{load:u={},save:a={}}={},values:d={}}=o,s=f(j(R($e,d)),0,M($e)),c=s[2],y=z(c),p=z(c);return[0,i,[_e(u,{[De]:null,[Ie]:G},De,(e=>P(p,e)),(e=>K(y,e))),_e(a,{[je]:null,[Ie]:G,deleteEmptyColumns:0,deleteEmptyTable:0},je,((e,n)=>P(p,n)),((e,n)=>K(y,n))),s],y]})(n);return(b?Pe:Ae)(e,i?(e,n)=>Fe(void 0,null,(function*(){return i(e,n),yield l(e,n)})):l,(e=>{return[(n=()=>Fe(void 0,null,(function*(){try{const[{d:n,s:t,c:r}]=yield l(`SELECT ${Be} d,${He} s,TOTAL_CHANGES() c FROM ${qe}${Be} JOIN ${qe}${He}`);n==(null!=p?p:p=n)&&t==(null!=h?h:h=t)&&r==(null!=m?m:m=r)||(e(),p=n,h=t)}catch(e){}})),t=E,n(),setInterval(n,1e3*t)),r((n=>O.has(n)?e():0))];var n,t}),(([e,n])=>{d(e),p=h=m=null,o(n)}),u,a,g,w(O),s,c,y)})(e,r,((e,...n)=>{return t=[e,...n],r=function*(e,n=[]){return yield l.getAllAsync(e,n)},new Promise(((e,n)=>{var l=e=>{try{i(r.next(e))}catch(e){n(e)}},o=e=>{try{i(r.throw(e))}catch(e){n(e)}},i=n=>n.done?e(n.value):Promise.resolve(n.value).then(l,o);i((r=r.apply(void 0,t)).next())}));var t,r}),(e=>n.addDatabaseChangeListener((({tableName:n})=>e(n)))),(e=>e.remove()),o,i,3,l)},"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("expo-sqlite")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).TinyBasePersisterExpoSqlite={},e["expo-sqlite"]);
@@ -5,7 +5,10 @@
5
5
  ? define(['exports', 'expo-sqlite'], factory)
6
6
  : ((global =
7
7
  typeof globalThis !== 'undefined' ? globalThis : global || self),
8
- factory((global.TinyBasePersisterExpoSqlite = {}), global.expoSqlite));
8
+ factory(
9
+ (global.TinyBasePersisterExpoSqlite = {}),
10
+ global['expo-sqlite'],
11
+ ));
9
12
  })(this, function (exports, expoSqlite) {
10
13
  'use strict';
11
14
 
@@ -5,7 +5,10 @@
5
5
  ? define(['exports', 'expo-sqlite'], factory)
6
6
  : ((global =
7
7
  typeof globalThis !== 'undefined' ? globalThis : global || self),
8
- factory((global.TinyBasePersisterExpoSqlite = {}), global.expoSqlite));
8
+ factory(
9
+ (global.TinyBasePersisterExpoSqlite = {}),
10
+ global['expo-sqlite'],
11
+ ));
9
12
  })(this, function (exports, expoSqlite) {
10
13
  'use strict';
11
14
 
@@ -1 +1 @@
1
- var a,t;a=this,t=function(a,t){"use strict";const e=a=>typeof a,s="tinybase",n="",i=",",r=e(n),o=(a,t)=>a.repeat(t),c=Promise,l=clearInterval,y=a=>null==a,w=(a,t,e)=>y(a)?e?.():t(a),d=a=>e(a)==r,u=a=>Array.isArray(a),p=(a,t,e)=>a.slice(t,e),E=a=>a.length,v=async a=>c.all(a),f=(a,t="")=>a.join(t),g=(a,t)=>a.map(t),m=a=>0==E(a),h=(a,t)=>a.filter(t),A=(a,...t)=>a.push(...t),C=(a,t)=>a?.has(t)??!1,T=a=>[...a?.values()??[]],O=(a,t)=>a?.delete(t),b=Object,N=a=>b.getPrototypeOf(a),S=b.entries,L=b.keys,R=b.freeze,D=(a=[])=>b.fromEntries(a),I=(...a)=>b.assign({},...a),M=(a,t)=>t in a,P=(a,t)=>g(S(a),(([a,e])=>t(e,a))),x=a=>b.values(a),$=a=>E(L(a)),_=a=>(a=>!y(a)&&w(N(a),(a=>a==b.prototype||y(N(a))),(()=>!0)))(a)&&0==$(a),F=a=>new Map(a),q=a=>[...a?.keys()??[]],j=(a,t)=>a?.get(t),B=(a,t)=>g([...a?.entries()??[]],(([a,e])=>t(e,a))),H=(a,t,e)=>y(e)?(O(a,t),a):a?.set(t,e),J=(a,t,e,s)=>(C(a,t)||H(a,t,e()),j(a,t)),Y=(a,t,e,s=H)=>(P(t,((t,s)=>e(a,s,t))),((a,t)=>{((a,t)=>{a?.forEach(t)})(a,((a,e)=>t(e)))})(a,(e=>M(t,e)?0:s(a,e))),a),k="_",G="_id",U=a=>`"${a.replace(/"/g,'""')}"`,W="SELECT",z=a=>new Set(u(a)||y(a)?a:[a]),K=(a,t)=>a?.add(t),V="TABLE",Q="ALTER "+V,X="DELETE FROM",Z=W+"*FROM",aa="FROM pragma_table_",ta="WHERE",ea=(a,t,e,s)=>{const r=F();return[async()=>Y(r,D(await v(g(await a("SELECT name "+aa+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+na(t)+")ORDER BY name",t),(async({name:t})=>[t,D(g(await a(W+" name,type "+aa+"info(?)",[t]),(({name:a,type:t})=>[a,t])))])))),((a,t,e)=>H(r,t,Y(J(r,t,F),e,((a,t,e)=>{e!=j(a,t)&&H(a,t,e)}),((a,t)=>H(a,t))))),((a,t)=>H(r,t))),async(t,e)=>((a,t)=>!y(j(j(r,a),t)))(t,e)?D(h(g(await a(Z+U(t)),(a=>{return[a[e],(t={...a},s=e,delete t[s],t)];var t,s})),(([a,t])=>!y(a)&&!_(t)))):{},async(t,e,o,c,l,w=!1)=>{const d=z();P(o??{},(a=>g(L(a??{}),(a=>K(d,a)))));const u=T(d);if(!w&&l&&m(u)&&C(r,t))return await a("DROP "+V+U(t)),void H(r,t);if(m(u)||C(r,t)){const s=j(r,t),i=z(q(s));await v([...g(u,(async e=>{O(i,e)||(await a(Q+U(t)+"ADD"+U(e)),H(s,e,n))})),...!w&&c?g(T(i),(async n=>{n!=e&&(await a(Q+U(t)+"DROP"+U(n)),H(s,n))})):[]])}else await a("CREATE "+V+U(t)+"("+U(e)+` PRIMARY KEY ON CONFLICT REPLACE${f(g(u,(a=>i+U(a))))});`),H(r,t,F([[e,n],...g(u,(a=>[a,n]))]));if(w)y(o)?await a(X+U(t)+ta+" 1"):await v(P(o,(async(n,i)=>{y(n)?await a(X+U(t)+ta+U(e)+"=?",[i]):m(u)||await sa(a,t,e,L(n),[i,...x(n)],s)})));else if(m(u))C(r,t)&&await a(X+U(t)+ta+" 1");else{const n=h(q(j(r,t)),(a=>a!=e)),i=[],c=[];P(o??{},((a,t)=>{A(i,t,...g(n,(t=>a?.[t]))),A(c,t)})),await sa(a,t,e,n,i,s),await a(X+U(t)+ta+U(e)+"NOT IN("+na(c)+")",c)}},async t=>{let s;await a("BEGIN");try{s=await t()}catch(a){e?.(a)}return await a("END"),s}]},sa=async(a,t,e,s,r,c=!0)=>await a("INSERT "+(c?n:"OR REPLACE ")+"INTO"+U(t)+"("+U(e)+f(g(s,(a=>i+U(a))))+")VALUES"+p(o(`,(?${o(",?",E(s))})`,E(r)/(E(s)+1)),1)+(c?"ON CONFLICT("+U(e)+")DO UPDATE SET"+f(g(s,(a=>U(a)+"=excluded."+U(a))),i):n),g(r,(a=>a??null))),na=a=>f(g(a,(()=>"?")),i),ia=F(),ra=F(),oa=(a,t,e,s,n,i,r,o={},c=[])=>{let l,d,p,E=0,v=0,f=0;J(ia,c,(()=>0)),J(ra,c,(()=>[]));const[g,m,h,C,T]=((a=1,t)=>a>1&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[a],[t]])=>!_(a)||!_(t),t.setDefaultContent]:2!=a?[0,t.getContent,t.getTransactionChanges,([a,t])=>!_(a)||!_(t),t.setContent]:(a=>{throw Error("Store type not supported by this Persister")})())(r,a),O=t=>{(g&&u(t?.[0])?1===t?.[2]?a.applyMergeableChanges:a.setMergeableContent:1===t?.[2]?a.applyChanges:a.setContent)(t)},b=async a=>(2!=E&&(E=1,v++,await D((async()=>{try{O(await t())}catch(t){i?.(t),a&&T(a)}E=0}))),I),N=()=>(d&&(n(d),d=void 0),I),S=async a=>(1!=E&&(E=2,f++,await D((async()=>{try{await e(m,a)}catch(a){i?.(a)}E=0}))),I),L=()=>(w(p,a.delListener),p=void 0,I),D=async(...a)=>(A(j(ra,c),...a),await(async()=>{if(!j(ia,c)){for(H(ia,c,1);!y((a=j(ra,c),l=a.shift()));)try{await l()}catch(a){i?.(a)}H(ia,c,0)}var a})(),I),I={load:b,startAutoLoad:async a=>(await N().load(a),d=s((async(a,t)=>{t||a?2!=E&&(E=1,v++,O(t??a),E=0):await b()})),I),stopAutoLoad:N,isAutoLoading:()=>!y(d),save:S,startAutoSave:async()=>(await L().save(),p=a.addDidFinishTransactionListener((()=>{const a=h();C(a)&&S(a)})),I),stopAutoSave:L,isAutoSaving:()=>!y(p),schedule:D,getStore:()=>a,destroy:()=>N().stopAutoSave(),getStats:()=>({loads:v,saves:f}),...o};return R(I)},ca=(a,t,e,s,n,i,[r,o,c],l,y,w,d)=>{const[u,p,E,v]=ea(t,l,n,d);return oa(a,(async()=>await v((async()=>{return await u(),a=(await p(r,o))[k]?.[c]??"null",JSON.parse(a,((a,t)=>""===t?void 0:t));var a}))),(async a=>await v((async()=>{var t;await u(),await E(r,o,{[k]:{[c]:(t=a()??null,JSON.stringify(t,((a,t)=>void 0===t?"":t)))}},!0,!0)}))),e,s,n,i,{[w]:()=>y},y)},la=(a,t,e,s,n,i,[r,o,[c,l,w]],d,u,p,E)=>{const[f,g,m,A]=ea(t,d,n,E),C=async(a,t)=>await v(B(o,(async([e,s,n,i],r)=>{t&&!M(a,r)||await m(e,s,a[r],n,i,t)}))),T=async(a,t)=>l?await m(w,G,{[k]:a},!0,!0,t):null;return oa(a,(async()=>await A((async()=>{await f();const a=await(async()=>D(h(await v(B(r,(async([a,t],e)=>[a,await g(e,t)]))),(a=>!_(a[1])))))(),t=await(async()=>c?(await g(w,G))[k]:{})();return _(a)&&y(t)?void 0:[a,t]}))),(async(a,t)=>await A((async()=>{if(await f(),y(t)){const[t,e]=a();await C(t),await T(e)}else await C(t[0],!0),await T(t[1],!0)}))),e,s,n,i,{[p]:()=>u},u)},ya="ColumnName",wa="store",da="json",ua=wa+"TableName",pa=wa+"Id"+ya,Ea=wa+ya,va="autoLoadIntervalSeconds",fa="rowId"+ya,ga="tableId",ma="tableName",ha={mode:da,[va]:1},Aa={load:0,save:0,[ma]:s+"_values"},Ca=(a,t,e,s,n)=>{const i=F();return P(a,((a,r)=>{const o=p(x(I(t,d(a)?{[e]:a}:a)),0,$(t));y(o[0])||s(r,o[0])||(n(r,o[0]),H(i,r,o))})),i},Ta="pragma_",Oa="data_version",ba="schema_version";a.createExpoSqlitePersister=(a,e,n,i,r)=>((a,t,e,n,i,r,o,c,y,w="getDb",u)=>{let E,v,f;const[g,m,h,A]=(a=>{const t=(a=>I(ha,d(a)?{[ua]:a}:a??{}))(a),e=t[va];if(t.mode==da){const a=t[ua]??s;return[1,e,[a,t[pa]??G,t[Ea]??wa],z(a)]}const{tables:{load:n={},save:i={}}={},values:r={}}=t,o=p(x(I(Aa,r)),0,$(Aa)),c=o[2],l=z(c),y=z(c);return[0,e,[Ca(n,{[ga]:null,[fa]:G},ga,(a=>C(y,a)),(a=>K(l,a))),Ca(i,{[ma]:null,[fa]:G,deleteEmptyColumns:0,deleteEmptyTable:0},ma,((a,t)=>C(y,t)),((a,t)=>K(l,t))),o],l]})(t);return(g?ca:la)(a,r?async(a,t)=>(r(a,t),await e(a,t)):e,(a=>{return[(t=async()=>{try{const[{d:t,s:s,c:n}]=await e(`SELECT ${Oa} d,${ba} s,TOTAL_CHANGES() c FROM ${Ta}${Oa} JOIN ${Ta}${ba}`);t==(E??=t)&&s==(v??=s)&&n==(f??=n)||(a(),E=t,v=s)}catch{}},s=m,t(),setInterval(t,1e3*s)),n((t=>A.has(t)?a():0))];var t,s}),(([a,t])=>{l(a),E=v=f=null,i(t)}),o,c,h,T(A),y,w,u)})(a,n,(async(a,t=[])=>await e.getAllAsync(a,t)),(a=>t.addDatabaseChangeListener((({tableName:t})=>a(t)))),(a=>a.remove()),i,r,3,e)},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("expo-sqlite")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite"],t):t((a="undefined"!=typeof globalThis?globalThis:a||self).TinyBasePersisterExpoSqlite={},a.expoSqlite);
1
+ var a,t;a=this,t=function(a,t){"use strict";const e=a=>typeof a,s="tinybase",n="",i=",",r=e(n),o=(a,t)=>a.repeat(t),c=Promise,l=clearInterval,y=a=>null==a,w=(a,t,e)=>y(a)?e?.():t(a),d=a=>e(a)==r,u=a=>Array.isArray(a),p=(a,t,e)=>a.slice(t,e),E=a=>a.length,v=async a=>c.all(a),f=(a,t="")=>a.join(t),g=(a,t)=>a.map(t),m=a=>0==E(a),h=(a,t)=>a.filter(t),A=(a,...t)=>a.push(...t),C=(a,t)=>a?.has(t)??!1,T=a=>[...a?.values()??[]],O=(a,t)=>a?.delete(t),b=Object,N=a=>b.getPrototypeOf(a),S=b.entries,L=b.keys,R=b.freeze,D=(a=[])=>b.fromEntries(a),I=(...a)=>b.assign({},...a),M=(a,t)=>t in a,P=(a,t)=>g(S(a),(([a,e])=>t(e,a))),x=a=>b.values(a),$=a=>E(L(a)),_=a=>(a=>!y(a)&&w(N(a),(a=>a==b.prototype||y(N(a))),(()=>!0)))(a)&&0==$(a),F=a=>new Map(a),q=a=>[...a?.keys()??[]],j=(a,t)=>a?.get(t),B=(a,t)=>g([...a?.entries()??[]],(([a,e])=>t(e,a))),H=(a,t,e)=>y(e)?(O(a,t),a):a?.set(t,e),J=(a,t,e,s)=>(C(a,t)||H(a,t,e()),j(a,t)),Y=(a,t,e,s=H)=>(P(t,((t,s)=>e(a,s,t))),((a,t)=>{((a,t)=>{a?.forEach(t)})(a,((a,e)=>t(e)))})(a,(e=>M(t,e)?0:s(a,e))),a),k="_",G="_id",U=a=>`"${a.replace(/"/g,'""')}"`,W="SELECT",z=a=>new Set(u(a)||y(a)?a:[a]),K=(a,t)=>a?.add(t),V="TABLE",Q="ALTER "+V,X="DELETE FROM",Z=W+"*FROM",aa="FROM pragma_table_",ta="WHERE",ea=(a,t,e,s)=>{const r=F();return[async()=>Y(r,D(await v(g(await a("SELECT name "+aa+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+na(t)+")ORDER BY name",t),(async({name:t})=>[t,D(g(await a(W+" name,type "+aa+"info(?)",[t]),(({name:a,type:t})=>[a,t])))])))),((a,t,e)=>H(r,t,Y(J(r,t,F),e,((a,t,e)=>{e!=j(a,t)&&H(a,t,e)}),((a,t)=>H(a,t))))),((a,t)=>H(r,t))),async(t,e)=>((a,t)=>!y(j(j(r,a),t)))(t,e)?D(h(g(await a(Z+U(t)),(a=>{return[a[e],(t={...a},s=e,delete t[s],t)];var t,s})),(([a,t])=>!y(a)&&!_(t)))):{},async(t,e,o,c,l,w=!1)=>{const d=z();P(o??{},(a=>g(L(a??{}),(a=>K(d,a)))));const u=T(d);if(!w&&l&&m(u)&&C(r,t))return await a("DROP "+V+U(t)),void H(r,t);if(m(u)||C(r,t)){const s=j(r,t),i=z(q(s));await v([...g(u,(async e=>{O(i,e)||(await a(Q+U(t)+"ADD"+U(e)),H(s,e,n))})),...!w&&c?g(T(i),(async n=>{n!=e&&(await a(Q+U(t)+"DROP"+U(n)),H(s,n))})):[]])}else await a("CREATE "+V+U(t)+"("+U(e)+` PRIMARY KEY ON CONFLICT REPLACE${f(g(u,(a=>i+U(a))))});`),H(r,t,F([[e,n],...g(u,(a=>[a,n]))]));if(w)y(o)?await a(X+U(t)+ta+" 1"):await v(P(o,(async(n,i)=>{y(n)?await a(X+U(t)+ta+U(e)+"=?",[i]):m(u)||await sa(a,t,e,L(n),[i,...x(n)],s)})));else if(m(u))C(r,t)&&await a(X+U(t)+ta+" 1");else{const n=h(q(j(r,t)),(a=>a!=e)),i=[],c=[];P(o??{},((a,t)=>{A(i,t,...g(n,(t=>a?.[t]))),A(c,t)})),await sa(a,t,e,n,i,s),await a(X+U(t)+ta+U(e)+"NOT IN("+na(c)+")",c)}},async t=>{let s;await a("BEGIN");try{s=await t()}catch(a){e?.(a)}return await a("END"),s}]},sa=async(a,t,e,s,r,c=!0)=>await a("INSERT "+(c?n:"OR REPLACE ")+"INTO"+U(t)+"("+U(e)+f(g(s,(a=>i+U(a))))+")VALUES"+p(o(`,(?${o(",?",E(s))})`,E(r)/(E(s)+1)),1)+(c?"ON CONFLICT("+U(e)+")DO UPDATE SET"+f(g(s,(a=>U(a)+"=excluded."+U(a))),i):n),g(r,(a=>a??null))),na=a=>f(g(a,(()=>"?")),i),ia=F(),ra=F(),oa=(a,t,e,s,n,i,r,o={},c=[])=>{let l,d,p,E=0,v=0,f=0;J(ia,c,(()=>0)),J(ra,c,(()=>[]));const[g,m,h,C,T]=((a=1,t)=>a>1&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[a],[t]])=>!_(a)||!_(t),t.setDefaultContent]:2!=a?[0,t.getContent,t.getTransactionChanges,([a,t])=>!_(a)||!_(t),t.setContent]:(a=>{throw Error("Store type not supported by this Persister")})())(r,a),O=t=>{(g&&u(t?.[0])?1===t?.[2]?a.applyMergeableChanges:a.setMergeableContent:1===t?.[2]?a.applyChanges:a.setContent)(t)},b=async a=>(2!=E&&(E=1,v++,await D((async()=>{try{O(await t())}catch(t){i?.(t),a&&T(a)}E=0}))),I),N=()=>(d&&(n(d),d=void 0),I),S=async a=>(1!=E&&(E=2,f++,await D((async()=>{try{await e(m,a)}catch(a){i?.(a)}E=0}))),I),L=()=>(w(p,a.delListener),p=void 0,I),D=async(...a)=>(A(j(ra,c),...a),await(async()=>{if(!j(ia,c)){for(H(ia,c,1);!y((a=j(ra,c),l=a.shift()));)try{await l()}catch(a){i?.(a)}H(ia,c,0)}var a})(),I),I={load:b,startAutoLoad:async a=>(await N().load(a),d=s((async(a,t)=>{t||a?2!=E&&(E=1,v++,O(t??a),E=0):await b()})),I),stopAutoLoad:N,isAutoLoading:()=>!y(d),save:S,startAutoSave:async()=>(await L().save(),p=a.addDidFinishTransactionListener((()=>{const a=h();C(a)&&S(a)})),I),stopAutoSave:L,isAutoSaving:()=>!y(p),schedule:D,getStore:()=>a,destroy:()=>N().stopAutoSave(),getStats:()=>({loads:v,saves:f}),...o};return R(I)},ca=(a,t,e,s,n,i,[r,o,c],l,y,w,d)=>{const[u,p,E,v]=ea(t,l,n,d);return oa(a,(async()=>await v((async()=>{return await u(),a=(await p(r,o))[k]?.[c]??"null",JSON.parse(a,((a,t)=>""===t?void 0:t));var a}))),(async a=>await v((async()=>{var t;await u(),await E(r,o,{[k]:{[c]:(t=a()??null,JSON.stringify(t,((a,t)=>void 0===t?"":t)))}},!0,!0)}))),e,s,n,i,{[w]:()=>y},y)},la=(a,t,e,s,n,i,[r,o,[c,l,w]],d,u,p,E)=>{const[f,g,m,A]=ea(t,d,n,E),C=async(a,t)=>await v(B(o,(async([e,s,n,i],r)=>{t&&!M(a,r)||await m(e,s,a[r],n,i,t)}))),T=async(a,t)=>l?await m(w,G,{[k]:a},!0,!0,t):null;return oa(a,(async()=>await A((async()=>{await f();const a=await(async()=>D(h(await v(B(r,(async([a,t],e)=>[a,await g(e,t)]))),(a=>!_(a[1])))))(),t=await(async()=>c?(await g(w,G))[k]:{})();return _(a)&&y(t)?void 0:[a,t]}))),(async(a,t)=>await A((async()=>{if(await f(),y(t)){const[t,e]=a();await C(t),await T(e)}else await C(t[0],!0),await T(t[1],!0)}))),e,s,n,i,{[p]:()=>u},u)},ya="ColumnName",wa="store",da="json",ua=wa+"TableName",pa=wa+"Id"+ya,Ea=wa+ya,va="autoLoadIntervalSeconds",fa="rowId"+ya,ga="tableId",ma="tableName",ha={mode:da,[va]:1},Aa={load:0,save:0,[ma]:s+"_values"},Ca=(a,t,e,s,n)=>{const i=F();return P(a,((a,r)=>{const o=p(x(I(t,d(a)?{[e]:a}:a)),0,$(t));y(o[0])||s(r,o[0])||(n(r,o[0]),H(i,r,o))})),i},Ta="pragma_",Oa="data_version",ba="schema_version";a.createExpoSqlitePersister=(a,e,n,i,r)=>((a,t,e,n,i,r,o,c,y,w="getDb",u)=>{let E,v,f;const[g,m,h,A]=(a=>{const t=(a=>I(ha,d(a)?{[ua]:a}:a??{}))(a),e=t[va];if(t.mode==da){const a=t[ua]??s;return[1,e,[a,t[pa]??G,t[Ea]??wa],z(a)]}const{tables:{load:n={},save:i={}}={},values:r={}}=t,o=p(x(I(Aa,r)),0,$(Aa)),c=o[2],l=z(c),y=z(c);return[0,e,[Ca(n,{[ga]:null,[fa]:G},ga,(a=>C(y,a)),(a=>K(l,a))),Ca(i,{[ma]:null,[fa]:G,deleteEmptyColumns:0,deleteEmptyTable:0},ma,((a,t)=>C(y,t)),((a,t)=>K(l,t))),o],l]})(t);return(g?ca:la)(a,r?async(a,t)=>(r(a,t),await e(a,t)):e,(a=>{return[(t=async()=>{try{const[{d:t,s:s,c:n}]=await e(`SELECT ${Oa} d,${ba} s,TOTAL_CHANGES() c FROM ${Ta}${Oa} JOIN ${Ta}${ba}`);t==(E??=t)&&s==(v??=s)&&n==(f??=n)||(a(),E=t,v=s)}catch{}},s=m,t(),setInterval(t,1e3*s)),n((t=>A.has(t)?a():0))];var t,s}),(([a,t])=>{l(a),E=v=f=null,i(t)}),o,c,h,T(A),y,w,u)})(a,n,(async(a,t=[])=>await e.getAllAsync(a,t)),(a=>t.addDatabaseChangeListener((({tableName:t})=>a(t)))),(a=>a.remove()),i,r,3,e)},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("expo-sqlite")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite"],t):t((a="undefined"!=typeof globalThis?globalThis:a||self).TinyBasePersisterExpoSqlite={},a["expo-sqlite"]);
@@ -1 +1 @@
1
- var a,t;a=this,t=function(a,t){"use strict";const e=a=>typeof a,s="tinybase",n="",i=",",r=e(n),o=(a,t)=>a.repeat(t),c=Promise,l=clearInterval,y=a=>null==a,w=(a,t,e)=>y(a)?e?.():t(a),d=a=>e(a)==r,u=a=>Array.isArray(a),p=(a,t,e)=>a.slice(t,e),E=a=>a.length,v=async a=>c.all(a),f=(a,t="")=>a.join(t),g=(a,t)=>a.map(t),m=a=>0==E(a),h=(a,t)=>a.filter(t),A=(a,...t)=>a.push(...t),C=(a,t)=>a?.has(t)??!1,T=a=>[...a?.values()??[]],O=(a,t)=>a?.delete(t),b=Object,N=a=>b.getPrototypeOf(a),S=b.entries,L=b.keys,R=b.freeze,D=(a=[])=>b.fromEntries(a),I=(...a)=>b.assign({},...a),M=(a,t)=>t in a,P=(a,t)=>g(S(a),(([a,e])=>t(e,a))),x=a=>b.values(a),$=a=>E(L(a)),_=a=>(a=>!y(a)&&w(N(a),(a=>a==b.prototype||y(N(a))),(()=>!0)))(a)&&0==$(a),F=a=>new Map(a),q=a=>[...a?.keys()??[]],j=(a,t)=>a?.get(t),B=(a,t)=>g([...a?.entries()??[]],(([a,e])=>t(e,a))),H=(a,t,e)=>y(e)?(O(a,t),a):a?.set(t,e),J=(a,t,e,s)=>(C(a,t)||H(a,t,e()),j(a,t)),Y=(a,t,e,s=H)=>(P(t,((t,s)=>e(a,s,t))),((a,t)=>{((a,t)=>{a?.forEach(t)})(a,((a,e)=>t(e)))})(a,(e=>M(t,e)?0:s(a,e))),a),k="_",G="_id",U=a=>`"${a.replace(/"/g,'""')}"`,W="SELECT",z=a=>new Set(u(a)||y(a)?a:[a]),K=(a,t)=>a?.add(t),V="TABLE",Q="ALTER "+V,X="DELETE FROM",Z=W+"*FROM",aa="FROM pragma_table_",ta="WHERE",ea=(a,t,e,s)=>{const r=F();return[async()=>Y(r,D(await v(g(await a("SELECT name "+aa+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+na(t)+")ORDER BY name",t),(async({name:t})=>[t,D(g(await a(W+" name,type "+aa+"info(?)",[t]),(({name:a,type:t})=>[a,t])))])))),((a,t,e)=>H(r,t,Y(J(r,t,F),e,((a,t,e)=>{e!=j(a,t)&&H(a,t,e)}),((a,t)=>H(a,t))))),((a,t)=>H(r,t))),async(t,e)=>((a,t)=>!y(j(j(r,a),t)))(t,e)?D(h(g(await a(Z+U(t)),(a=>{return[a[e],(t={...a},s=e,delete t[s],t)];var t,s})),(([a,t])=>!y(a)&&!_(t)))):{},async(t,e,o,c,l,w=!1)=>{const d=z();P(o??{},(a=>g(L(a??{}),(a=>K(d,a)))));const u=T(d);if(!w&&l&&m(u)&&C(r,t))return await a("DROP "+V+U(t)),void H(r,t);if(m(u)||C(r,t)){const s=j(r,t),i=z(q(s));await v([...g(u,(async e=>{O(i,e)||(await a(Q+U(t)+"ADD"+U(e)),H(s,e,n))})),...!w&&c?g(T(i),(async n=>{n!=e&&(await a(Q+U(t)+"DROP"+U(n)),H(s,n))})):[]])}else await a("CREATE "+V+U(t)+"("+U(e)+` PRIMARY KEY ON CONFLICT REPLACE${f(g(u,(a=>i+U(a))))});`),H(r,t,F([[e,n],...g(u,(a=>[a,n]))]));if(w)y(o)?await a(X+U(t)+ta+" 1"):await v(P(o,(async(n,i)=>{y(n)?await a(X+U(t)+ta+U(e)+"=?",[i]):m(u)||await sa(a,t,e,L(n),[i,...x(n)],s)})));else if(m(u))C(r,t)&&await a(X+U(t)+ta+" 1");else{const n=h(q(j(r,t)),(a=>a!=e)),i=[],c=[];P(o??{},((a,t)=>{A(i,t,...g(n,(t=>a?.[t]))),A(c,t)})),await sa(a,t,e,n,i,s),await a(X+U(t)+ta+U(e)+"NOT IN("+na(c)+")",c)}},async t=>{let s;await a("BEGIN");try{s=await t()}catch(a){e?.(a)}return await a("END"),s}]},sa=async(a,t,e,s,r,c=!0)=>await a("INSERT "+(c?n:"OR REPLACE ")+"INTO"+U(t)+"("+U(e)+f(g(s,(a=>i+U(a))))+")VALUES"+p(o(`,(?${o(",?",E(s))})`,E(r)/(E(s)+1)),1)+(c?"ON CONFLICT("+U(e)+")DO UPDATE SET"+f(g(s,(a=>U(a)+"=excluded."+U(a))),i):n),g(r,(a=>a??null))),na=a=>f(g(a,(()=>"?")),i),ia=F(),ra=F(),oa=(a,t,e,s,n,i,r,o={},c=[])=>{let l,d,p,E=0,v=0,f=0;J(ia,c,(()=>0)),J(ra,c,(()=>[]));const[g,m,h,C,T]=((a=1,t)=>a>1&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[a],[t]])=>!_(a)||!_(t),t.setDefaultContent]:2!=a?[0,t.getContent,t.getTransactionChanges,([a,t])=>!_(a)||!_(t),t.setContent]:(a=>{throw Error("Store type not supported by this Persister")})())(r,a),O=t=>{(g&&u(t?.[0])?1===t?.[2]?a.applyMergeableChanges:a.setMergeableContent:1===t?.[2]?a.applyChanges:a.setContent)(t)},b=async a=>(2!=E&&(E=1,v++,await D((async()=>{try{O(await t())}catch(t){i?.(t),a&&T(a)}E=0}))),I),N=()=>(d&&(n(d),d=void 0),I),S=async a=>(1!=E&&(E=2,f++,await D((async()=>{try{await e(m,a)}catch(a){i?.(a)}E=0}))),I),L=()=>(w(p,a.delListener),p=void 0,I),D=async(...a)=>(A(j(ra,c),...a),await(async()=>{if(!j(ia,c)){for(H(ia,c,1);!y((a=j(ra,c),l=a.shift()));)try{await l()}catch(a){i?.(a)}H(ia,c,0)}var a})(),I),I={load:b,startAutoLoad:async a=>(await N().load(a),d=s((async(a,t)=>{t||a?2!=E&&(E=1,v++,O(t??a),E=0):await b()})),I),stopAutoLoad:N,isAutoLoading:()=>!y(d),save:S,startAutoSave:async()=>(await L().save(),p=a.addDidFinishTransactionListener((()=>{const a=h();C(a)&&S(a)})),I),stopAutoSave:L,isAutoSaving:()=>!y(p),schedule:D,getStore:()=>a,destroy:()=>N().stopAutoSave(),getStats:()=>({loads:v,saves:f}),...o};return R(I)},ca=(a,t,e,s,n,i,[r,o,c],l,y,w,d)=>{const[u,p,E,v]=ea(t,l,n,d);return oa(a,(async()=>await v((async()=>{return await u(),a=(await p(r,o))[k]?.[c]??"null",JSON.parse(a,((a,t)=>""===t?void 0:t));var a}))),(async a=>await v((async()=>{var t;await u(),await E(r,o,{[k]:{[c]:(t=a()??null,JSON.stringify(t,((a,t)=>void 0===t?"":t)))}},!0,!0)}))),e,s,n,i,{[w]:()=>y},y)},la=(a,t,e,s,n,i,[r,o,[c,l,w]],d,u,p,E)=>{const[f,g,m,A]=ea(t,d,n,E),C=async(a,t)=>await v(B(o,(async([e,s,n,i],r)=>{t&&!M(a,r)||await m(e,s,a[r],n,i,t)}))),T=async(a,t)=>l?await m(w,G,{[k]:a},!0,!0,t):null;return oa(a,(async()=>await A((async()=>{await f();const a=await(async()=>D(h(await v(B(r,(async([a,t],e)=>[a,await g(e,t)]))),(a=>!_(a[1])))))(),t=await(async()=>c?(await g(w,G))[k]:{})();return _(a)&&y(t)?void 0:[a,t]}))),(async(a,t)=>await A((async()=>{if(await f(),y(t)){const[t,e]=a();await C(t),await T(e)}else await C(t[0],!0),await T(t[1],!0)}))),e,s,n,i,{[p]:()=>u},u)},ya="ColumnName",wa="store",da="json",ua=wa+"TableName",pa=wa+"Id"+ya,Ea=wa+ya,va="autoLoadIntervalSeconds",fa="rowId"+ya,ga="tableId",ma="tableName",ha={mode:da,[va]:1},Aa={load:0,save:0,[ma]:s+"_values"},Ca=(a,t,e,s,n)=>{const i=F();return P(a,((a,r)=>{const o=p(x(I(t,d(a)?{[e]:a}:a)),0,$(t));y(o[0])||s(r,o[0])||(n(r,o[0]),H(i,r,o))})),i},Ta="pragma_",Oa="data_version",ba="schema_version";a.createExpoSqlitePersister=(a,e,n,i,r)=>((a,t,e,n,i,r,o,c,y,w="getDb",u)=>{let E,v,f;const[g,m,h,A]=(a=>{const t=(a=>I(ha,d(a)?{[ua]:a}:a??{}))(a),e=t[va];if(t.mode==da){const a=t[ua]??s;return[1,e,[a,t[pa]??G,t[Ea]??wa],z(a)]}const{tables:{load:n={},save:i={}}={},values:r={}}=t,o=p(x(I(Aa,r)),0,$(Aa)),c=o[2],l=z(c),y=z(c);return[0,e,[Ca(n,{[ga]:null,[fa]:G},ga,(a=>C(y,a)),(a=>K(l,a))),Ca(i,{[ma]:null,[fa]:G,deleteEmptyColumns:0,deleteEmptyTable:0},ma,((a,t)=>C(y,t)),((a,t)=>K(l,t))),o],l]})(t);return(g?ca:la)(a,r?async(a,t)=>(r(a,t),await e(a,t)):e,(a=>{return[(t=async()=>{try{const[{d:t,s:s,c:n}]=await e(`SELECT ${Oa} d,${ba} s,TOTAL_CHANGES() c FROM ${Ta}${Oa} JOIN ${Ta}${ba}`);t==(E??=t)&&s==(v??=s)&&n==(f??=n)||(a(),E=t,v=s)}catch{}},s=m,t(),setInterval(t,1e3*s)),n((t=>A.has(t)?a():0))];var t,s}),(([a,t])=>{l(a),E=v=f=null,i(t)}),o,c,h,T(A),y,w,u)})(a,n,(async(a,t=[])=>await e.getAllAsync(a,t)),(a=>t.addDatabaseChangeListener((({tableName:t})=>a(t)))),(a=>a.remove()),i,r,3,e)},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("expo-sqlite")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite"],t):t((a="undefined"!=typeof globalThis?globalThis:a||self).TinyBasePersisterExpoSqlite={},a.expoSqlite);
1
+ var a,t;a=this,t=function(a,t){"use strict";const e=a=>typeof a,s="tinybase",n="",i=",",r=e(n),o=(a,t)=>a.repeat(t),c=Promise,l=clearInterval,y=a=>null==a,w=(a,t,e)=>y(a)?e?.():t(a),d=a=>e(a)==r,u=a=>Array.isArray(a),p=(a,t,e)=>a.slice(t,e),E=a=>a.length,v=async a=>c.all(a),f=(a,t="")=>a.join(t),g=(a,t)=>a.map(t),m=a=>0==E(a),h=(a,t)=>a.filter(t),A=(a,...t)=>a.push(...t),C=(a,t)=>a?.has(t)??!1,T=a=>[...a?.values()??[]],O=(a,t)=>a?.delete(t),b=Object,N=a=>b.getPrototypeOf(a),S=b.entries,L=b.keys,R=b.freeze,D=(a=[])=>b.fromEntries(a),I=(...a)=>b.assign({},...a),M=(a,t)=>t in a,P=(a,t)=>g(S(a),(([a,e])=>t(e,a))),x=a=>b.values(a),$=a=>E(L(a)),_=a=>(a=>!y(a)&&w(N(a),(a=>a==b.prototype||y(N(a))),(()=>!0)))(a)&&0==$(a),F=a=>new Map(a),q=a=>[...a?.keys()??[]],j=(a,t)=>a?.get(t),B=(a,t)=>g([...a?.entries()??[]],(([a,e])=>t(e,a))),H=(a,t,e)=>y(e)?(O(a,t),a):a?.set(t,e),J=(a,t,e,s)=>(C(a,t)||H(a,t,e()),j(a,t)),Y=(a,t,e,s=H)=>(P(t,((t,s)=>e(a,s,t))),((a,t)=>{((a,t)=>{a?.forEach(t)})(a,((a,e)=>t(e)))})(a,(e=>M(t,e)?0:s(a,e))),a),k="_",G="_id",U=a=>`"${a.replace(/"/g,'""')}"`,W="SELECT",z=a=>new Set(u(a)||y(a)?a:[a]),K=(a,t)=>a?.add(t),V="TABLE",Q="ALTER "+V,X="DELETE FROM",Z=W+"*FROM",aa="FROM pragma_table_",ta="WHERE",ea=(a,t,e,s)=>{const r=F();return[async()=>Y(r,D(await v(g(await a("SELECT name "+aa+"list WHERE schema='main'AND(type='table'OR type='view')AND name IN("+na(t)+")ORDER BY name",t),(async({name:t})=>[t,D(g(await a(W+" name,type "+aa+"info(?)",[t]),(({name:a,type:t})=>[a,t])))])))),((a,t,e)=>H(r,t,Y(J(r,t,F),e,((a,t,e)=>{e!=j(a,t)&&H(a,t,e)}),((a,t)=>H(a,t))))),((a,t)=>H(r,t))),async(t,e)=>((a,t)=>!y(j(j(r,a),t)))(t,e)?D(h(g(await a(Z+U(t)),(a=>{return[a[e],(t={...a},s=e,delete t[s],t)];var t,s})),(([a,t])=>!y(a)&&!_(t)))):{},async(t,e,o,c,l,w=!1)=>{const d=z();P(o??{},(a=>g(L(a??{}),(a=>K(d,a)))));const u=T(d);if(!w&&l&&m(u)&&C(r,t))return await a("DROP "+V+U(t)),void H(r,t);if(m(u)||C(r,t)){const s=j(r,t),i=z(q(s));await v([...g(u,(async e=>{O(i,e)||(await a(Q+U(t)+"ADD"+U(e)),H(s,e,n))})),...!w&&c?g(T(i),(async n=>{n!=e&&(await a(Q+U(t)+"DROP"+U(n)),H(s,n))})):[]])}else await a("CREATE "+V+U(t)+"("+U(e)+` PRIMARY KEY ON CONFLICT REPLACE${f(g(u,(a=>i+U(a))))});`),H(r,t,F([[e,n],...g(u,(a=>[a,n]))]));if(w)y(o)?await a(X+U(t)+ta+" 1"):await v(P(o,(async(n,i)=>{y(n)?await a(X+U(t)+ta+U(e)+"=?",[i]):m(u)||await sa(a,t,e,L(n),[i,...x(n)],s)})));else if(m(u))C(r,t)&&await a(X+U(t)+ta+" 1");else{const n=h(q(j(r,t)),(a=>a!=e)),i=[],c=[];P(o??{},((a,t)=>{A(i,t,...g(n,(t=>a?.[t]))),A(c,t)})),await sa(a,t,e,n,i,s),await a(X+U(t)+ta+U(e)+"NOT IN("+na(c)+")",c)}},async t=>{let s;await a("BEGIN");try{s=await t()}catch(a){e?.(a)}return await a("END"),s}]},sa=async(a,t,e,s,r,c=!0)=>await a("INSERT "+(c?n:"OR REPLACE ")+"INTO"+U(t)+"("+U(e)+f(g(s,(a=>i+U(a))))+")VALUES"+p(o(`,(?${o(",?",E(s))})`,E(r)/(E(s)+1)),1)+(c?"ON CONFLICT("+U(e)+")DO UPDATE SET"+f(g(s,(a=>U(a)+"=excluded."+U(a))),i):n),g(r,(a=>a??null))),na=a=>f(g(a,(()=>"?")),i),ia=F(),ra=F(),oa=(a,t,e,s,n,i,r,o={},c=[])=>{let l,d,p,E=0,v=0,f=0;J(ia,c,(()=>0)),J(ra,c,(()=>[]));const[g,m,h,C,T]=((a=1,t)=>a>1&&t.isMergeable()?[1,t.getMergeableContent,t.getTransactionMergeableChanges,([[a],[t]])=>!_(a)||!_(t),t.setDefaultContent]:2!=a?[0,t.getContent,t.getTransactionChanges,([a,t])=>!_(a)||!_(t),t.setContent]:(a=>{throw Error("Store type not supported by this Persister")})())(r,a),O=t=>{(g&&u(t?.[0])?1===t?.[2]?a.applyMergeableChanges:a.setMergeableContent:1===t?.[2]?a.applyChanges:a.setContent)(t)},b=async a=>(2!=E&&(E=1,v++,await D((async()=>{try{O(await t())}catch(t){i?.(t),a&&T(a)}E=0}))),I),N=()=>(d&&(n(d),d=void 0),I),S=async a=>(1!=E&&(E=2,f++,await D((async()=>{try{await e(m,a)}catch(a){i?.(a)}E=0}))),I),L=()=>(w(p,a.delListener),p=void 0,I),D=async(...a)=>(A(j(ra,c),...a),await(async()=>{if(!j(ia,c)){for(H(ia,c,1);!y((a=j(ra,c),l=a.shift()));)try{await l()}catch(a){i?.(a)}H(ia,c,0)}var a})(),I),I={load:b,startAutoLoad:async a=>(await N().load(a),d=s((async(a,t)=>{t||a?2!=E&&(E=1,v++,O(t??a),E=0):await b()})),I),stopAutoLoad:N,isAutoLoading:()=>!y(d),save:S,startAutoSave:async()=>(await L().save(),p=a.addDidFinishTransactionListener((()=>{const a=h();C(a)&&S(a)})),I),stopAutoSave:L,isAutoSaving:()=>!y(p),schedule:D,getStore:()=>a,destroy:()=>N().stopAutoSave(),getStats:()=>({loads:v,saves:f}),...o};return R(I)},ca=(a,t,e,s,n,i,[r,o,c],l,y,w,d)=>{const[u,p,E,v]=ea(t,l,n,d);return oa(a,(async()=>await v((async()=>{return await u(),a=(await p(r,o))[k]?.[c]??"null",JSON.parse(a,((a,t)=>""===t?void 0:t));var a}))),(async a=>await v((async()=>{var t;await u(),await E(r,o,{[k]:{[c]:(t=a()??null,JSON.stringify(t,((a,t)=>void 0===t?"":t)))}},!0,!0)}))),e,s,n,i,{[w]:()=>y},y)},la=(a,t,e,s,n,i,[r,o,[c,l,w]],d,u,p,E)=>{const[f,g,m,A]=ea(t,d,n,E),C=async(a,t)=>await v(B(o,(async([e,s,n,i],r)=>{t&&!M(a,r)||await m(e,s,a[r],n,i,t)}))),T=async(a,t)=>l?await m(w,G,{[k]:a},!0,!0,t):null;return oa(a,(async()=>await A((async()=>{await f();const a=await(async()=>D(h(await v(B(r,(async([a,t],e)=>[a,await g(e,t)]))),(a=>!_(a[1])))))(),t=await(async()=>c?(await g(w,G))[k]:{})();return _(a)&&y(t)?void 0:[a,t]}))),(async(a,t)=>await A((async()=>{if(await f(),y(t)){const[t,e]=a();await C(t),await T(e)}else await C(t[0],!0),await T(t[1],!0)}))),e,s,n,i,{[p]:()=>u},u)},ya="ColumnName",wa="store",da="json",ua=wa+"TableName",pa=wa+"Id"+ya,Ea=wa+ya,va="autoLoadIntervalSeconds",fa="rowId"+ya,ga="tableId",ma="tableName",ha={mode:da,[va]:1},Aa={load:0,save:0,[ma]:s+"_values"},Ca=(a,t,e,s,n)=>{const i=F();return P(a,((a,r)=>{const o=p(x(I(t,d(a)?{[e]:a}:a)),0,$(t));y(o[0])||s(r,o[0])||(n(r,o[0]),H(i,r,o))})),i},Ta="pragma_",Oa="data_version",ba="schema_version";a.createExpoSqlitePersister=(a,e,n,i,r)=>((a,t,e,n,i,r,o,c,y,w="getDb",u)=>{let E,v,f;const[g,m,h,A]=(a=>{const t=(a=>I(ha,d(a)?{[ua]:a}:a??{}))(a),e=t[va];if(t.mode==da){const a=t[ua]??s;return[1,e,[a,t[pa]??G,t[Ea]??wa],z(a)]}const{tables:{load:n={},save:i={}}={},values:r={}}=t,o=p(x(I(Aa,r)),0,$(Aa)),c=o[2],l=z(c),y=z(c);return[0,e,[Ca(n,{[ga]:null,[fa]:G},ga,(a=>C(y,a)),(a=>K(l,a))),Ca(i,{[ma]:null,[fa]:G,deleteEmptyColumns:0,deleteEmptyTable:0},ma,((a,t)=>C(y,t)),((a,t)=>K(l,t))),o],l]})(t);return(g?ca:la)(a,r?async(a,t)=>(r(a,t),await e(a,t)):e,(a=>{return[(t=async()=>{try{const[{d:t,s:s,c:n}]=await e(`SELECT ${Oa} d,${ba} s,TOTAL_CHANGES() c FROM ${Ta}${Oa} JOIN ${Ta}${ba}`);t==(E??=t)&&s==(v??=s)&&n==(f??=n)||(a(),E=t,v=s)}catch{}},s=m,t(),setInterval(t,1e3*s)),n((t=>A.has(t)?a():0))];var t,s}),(([a,t])=>{l(a),E=v=f=null,i(t)}),o,c,h,T(A),y,w,u)})(a,n,(async(a,t=[])=>await e.getAllAsync(a,t)),(a=>t.addDatabaseChangeListener((({tableName:t})=>a(t)))),(a=>a.remove()),i,r,3,e)},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("expo-sqlite")):"function"==typeof define&&define.amd?define(["exports","expo-sqlite"],t):t((a="undefined"!=typeof globalThis?globalThis:a||self).TinyBasePersisterExpoSqlite={},a["expo-sqlite"]);
@@ -5,7 +5,10 @@
5
5
  ? define(['exports', 'expo-sqlite'], factory)
6
6
  : ((global =
7
7
  typeof globalThis !== 'undefined' ? globalThis : global || self),
8
- factory((global.TinyBasePersisterExpoSqlite = {}), global.expoSqlite));
8
+ factory(
9
+ (global.TinyBasePersisterExpoSqlite = {}),
10
+ global['expo-sqlite'],
11
+ ));
9
12
  })(this, function (exports, expoSqlite) {
10
13
  'use strict';
11
14
 
@@ -5,7 +5,10 @@
5
5
  ? define(['exports', 'expo-sqlite'], factory)
6
6
  : ((global =
7
7
  typeof globalThis !== 'undefined' ? globalThis : global || self),
8
- factory((global.TinyBasePersisterExpoSqlite = {}), global.expoSqlite));
8
+ factory(
9
+ (global.TinyBasePersisterExpoSqlite = {}),
10
+ global['expo-sqlite'],
11
+ ));
9
12
  })(this, function (exports, expoSqlite) {
10
13
  'use strict';
11
14