Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solid-primitives/storage

Package Overview
Dependencies
Maintainers
3
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solid-primitives/storage - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

15

dist/index.d.ts

@@ -224,2 +224,15 @@ import { Accessor, Setter, Signal } from 'solid-js';

/**
* tauriStorage: an asynchronous Storage API based on tauri-plugin-store
*
* requires store permissions to be set: https://beta.tauri.app/features/store/
*
* In order to use in a isomorphic setting (web/tauri), use:
* ```ts
* const isFallback = !window.__TAURI_INTERNALS__;
* const storage = isFallback ? localStorage : tauriStorage();
* ````
*/
declare function tauriStorage(name?: string): AsyncStorage;
/**
* adds a `.clear` method to a Storage without one only using `.key`/`.removeItem`

@@ -373,2 +386,2 @@ */

export { type AnyStorageProps, type AsyncStorage, type AsyncStorageObject, type AsyncStorageSetter, type AsyncStorageWithOptions, type CookieOptions, type PersistenceBaseOptions, type PersistenceOptions, type PersistenceSyncAPI, type PersistenceSyncCallback, type PersistenceSyncData, type StorageDeserializer, type StorageObject, type StorageProps, type StorageSerializer, type StorageSetter, type StorageSignalProps, type StorageWithOptions, type StringStorageProps, addClearMethod, addWithOptionsMethod, cookieStorage, createAsyncStorage, createCookieStorage, createLocalStorage, createSessionStorage, createStorage, createStorageSignal, makePersisted, messageSync, multiplexStorage, multiplexSync, storageSync, wsSync };
export { type AnyStorageProps, type AsyncStorage, type AsyncStorageObject, type AsyncStorageSetter, type AsyncStorageWithOptions, type CookieOptions, type PersistenceBaseOptions, type PersistenceOptions, type PersistenceSyncAPI, type PersistenceSyncCallback, type PersistenceSyncData, type StorageDeserializer, type StorageObject, type StorageProps, type StorageSerializer, type StorageSetter, type StorageSignalProps, type StorageWithOptions, type StringStorageProps, addClearMethod, addWithOptionsMethod, cookieStorage, createAsyncStorage, createCookieStorage, createLocalStorage, createSessionStorage, createStorage, createStorageSignal, makePersisted, messageSync, multiplexStorage, multiplexSync, storageSync, tauriStorage, wsSync };

@@ -531,2 +531,20 @@ import { createHydratableSignal } from '@solid-primitives/utils';

var createCookieStorage = (props) => createStorage({ ...props, api: cookieStorage });
// src/tauri.ts
function tauriStorage(name = "solid-storage.dat") {
const api = {
_store: null,
_getStore: async () => api._store || (api._store = new (await import('@tauri-apps/plugin-store')).Store(name)),
getItem: async (key) => await (await api._getStore()).get(key) ?? null,
setItem: async (key, value) => await (await api._getStore()).set(key, value),
removeItem: async (key) => await (await api._getStore()).delete(key),
clear: async () => await (await api._getStore()).clear(),
key: async (index) => (await (await api._getStore()).keys())[index],
getLength: async () => (await api._getStore()).length(),
get length() {
return api.getLength();
}
};
return api;
}
function makePersisted(signal, options = {}) {

@@ -634,2 +652,2 @@ const storage = options.storage || globalThis.localStorage;

export { addClearMethod, addWithOptionsMethod, cookieStorage, createAsyncStorage, createCookieStorage, createLocalStorage, createSessionStorage, createStorage, createStorageSignal, makePersisted, messageSync, multiplexStorage, multiplexSync, storageSync, wsSync };
export { addClearMethod, addWithOptionsMethod, cookieStorage, createAsyncStorage, createCookieStorage, createLocalStorage, createSessionStorage, createStorage, createStorageSignal, makePersisted, messageSync, multiplexStorage, multiplexSync, storageSync, tauriStorage, wsSync };

9

package.json
{
"name": "@solid-primitives/storage",
"version": "3.3.0",
"version": "3.4.0",
"description": "Primitive that provides reactive wrappers for storage access",

@@ -21,2 +21,3 @@ "author": "Alex Lohr <alex.lohr@logmein.com>",

"cookieStorage",
"tauriStorage",
"multiplexStorage",

@@ -63,3 +64,4 @@ "storageSync",

"peerDependencies": {
"solid-js": "^1.6.12"
"solid-js": "^1.6.12",
"@tauri-apps/plugin-store": "*"
},

@@ -69,2 +71,5 @@ "peerDependenciesMeta": {

"optional": true
},
"@tauri-apps/plugin-store": {
"optional": true
}

@@ -71,0 +76,0 @@ },

@@ -102,2 +102,44 @@ <p>

#### TauriStorage
[Tauri](https://tauri.app) is a lightweight run-time for desktop (and soon also mobile) applications utilizing web front-end frameworks. While it supports `localStorage` and `sessionStorage`, it also has its own store plugin with the benefit of improved stability. To use it, install the required modules both on the side of JavaScript and Rust after setting up the project with the help of their command-line interface:
```bash
npm run tauri add store
```
Also, it requires a few permissions in `capabilities/default.json`:
```js
{
// other defaults
"permissions": [
// other permissions
"store:allow-get",
"store:allow-set",
"store:allow-delete",
"store:allow-keys",
"store:allow-clear"
]
}
```
Lastly, initialize the plugin in the setup:
```rs
fn main() {
tauri::Builder::default()
// initialize store plugin:
.plugin(tauri_plugin_store::Builder::new().build())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
```
Once these preparations are finished, `tauriStorage(name?: string)` can be used as another storage option. To fallback to localStorage if the app does not run within tauri, you can check for `window.__TAURI_INTERNALS__`:
```ts
const storage = window.__TAURI_INTERNALS__ ? tauriStorage() : localStorage;
```
#### IndexedDB, WebSQL

@@ -104,0 +146,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc