Socket
Socket
Sign inDemoInstall

electron-store

Package Overview
Dependencies
19
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.2.0 to 9.0.0

42

index.d.ts

@@ -1,18 +0,16 @@

import {Except} from 'type-fest';
import Conf, {Schema as ConfSchema, Options as ConfOptions} from 'conf';
import {type Except} from 'type-fest';
import Conf, {type Options as ConfigOptions} from 'conf';
declare namespace ElectronStore {
type Schema<T> = ConfSchema<T>;
export {Schema} from 'conf';
type Options<T extends Record<string, any>> = Except<ConfOptions<T>, 'configName' | 'projectName' | 'projectVersion' | 'projectSuffix'> & {
/**
Name of the storage file (without extension).
export type Options<T extends Record<string, any>> = Except<ConfigOptions<T>, 'configName' | 'projectName' | 'projectVersion' | 'projectSuffix'> & {
/**
Name of the storage file (without extension).
This is useful if you want multiple storage files for your app. Or if you're making a reusable Electron module that persists some data, in which case you should **not** use the name `config`.
This is useful if you want multiple storage files for your app. Or if you're making a reusable Electron module that persists some data, in which case you should **not** use the name `config`.
@default 'config'
*/
readonly name?: string;
};
}
@default 'config'
*/
readonly name?: string;
};

@@ -22,4 +20,9 @@ /**

*/
declare class ElectronStore<T extends Record<string, any> = Record<string, unknown>> extends Conf<T> {
export default class ElectronStore<T extends Record<string, any> = Record<string, unknown>> extends Conf<T> {
/**
Initializer to set up the required `ipc` communication channels for the module when a `Store` instance is not created in the main process and you are creating a `Store` instance in the Electron renderer process only.
*/
static initRenderer(): void;
/**
Changes are written to disk atomically, so if the process crashes during a write, it will not corrupt the existing store.

@@ -29,3 +32,3 @@

```
import Store = require('electron-store');
import Store from 'electron-store';

@@ -55,10 +58,5 @@ type StoreType = {

*/
constructor(options?: ElectronStore.Options<T>);
constructor(options?: Options<T>);
/**
Initializer to set up the required `ipc` communication channels for the module when a `Store` instance is not created in the main process and you are creating a `Store` instance in the Electron renderer process only.
*/
static initRenderer(): void;
/**
Open the storage file in the user's editor.

@@ -70,3 +68,1 @@

}
export = ElectronStore;

@@ -1,5 +0,10 @@

'use strict';
const path = require('path');
const {app, ipcMain, ipcRenderer, shell} = require('electron');
const Conf = require('conf');
import process from 'node:process';
import path from 'node:path';
import {
app,
ipcMain,
shell,
} from 'electron'; // eslint-disable-line import/no-duplicates
import electron from 'electron'; // eslint-disable-line import/no-duplicates
import Conf from 'conf';

@@ -16,3 +21,3 @@ let isInitialized = false;

defaultCwd: app.getPath('userData'),
appVersion: app.getVersion()
appVersion: app.getVersion(),
};

@@ -33,3 +38,3 @@

class ElectronStore extends Conf {
export default class ElectronStore extends Conf {
constructor(options) {

@@ -41,4 +46,4 @@ let defaultCwd;

// to get the required data for the module otherwise, we pull from the main process.
if (ipcRenderer) {
const appData = ipcRenderer.sendSync('electron-store-get-data');
if (process.type === 'renderer') {
const appData = electron.ipcRenderer.sendSync('electron-store-get-data');

@@ -56,8 +61,6 @@ if (!appData) {

name: 'config',
...options
...options,
};
if (!options.projectVersion) {
options.projectVersion = appVersion;
}
options.projectVersion ||= appVersion;

@@ -88,3 +91,1 @@ if (options.cwd) {

}
module.exports = ElectronStore;
{
"name": "electron-store",
"version": "8.2.0",
"version": "9.0.0",
"description": "Simple data persistence for your Electron app or module - Save and load user settings, app state, cache, etc",

@@ -13,3 +13,11 @@ "license": "MIT",

},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=20"
},
"scripts": {

@@ -39,11 +47,11 @@ "test": "xo && ava && tsd"

"dependencies": {
"conf": "^10.2.0",
"type-fest": "^2.17.0"
"conf": "^12.0.0",
"type-fest": "^4.18.1"
},
"devDependencies": {
"ava": "^2.4.0",
"electron": "^12.0.4",
"execa": "^5.0.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
"ava": "^6.1.2",
"electron": "^30.0.1",
"execa": "^8.0.1",
"tsd": "^0.31.0",
"xo": "^0.58.0"
},

@@ -55,3 +63,10 @@ "xo": {

]
},
"tsd": {
"compilerOptions": {
"module": "node16",
"moduleResolution": "node16",
"moduleDetection": "force"
}
}
}

@@ -15,8 +15,11 @@ # electron-store

*Requires Electron 11 or later.*
*Requires Electron 30 or later.*
> [!NOTE]
> This package is native [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and no longer provides a CommonJS export. If your project uses CommonJS, you will have to [convert to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). More info about [Electron and ESM](https://www.electronjs.org/docs/latest/tutorial/esm). Please don't open issues for questions regarding CommonJS and ESM.
## Usage
```js
const Store = require('electron-store');
import Store from 'electron-store';

@@ -72,3 +75,3 @@ const store = new Store();

```js
const Store = require('electron-store');
import Store from 'electron-store';

@@ -112,3 +115,3 @@ const schema = {

```js
const Store = require('electron-store');
import Store from 'electron-store';

@@ -153,3 +156,3 @@ const store = new Store({

```js
const Store = require('electron-store');
import Store from 'electron-store';

@@ -252,3 +255,3 @@ console.log = someLogger.log;

```js
const Store = require('electron-store');
import Store from 'electron-store';

@@ -370,3 +373,3 @@ const store = new Store();

```js
const Store = require('electron-store');
import Store from 'electron-store';

@@ -397,3 +400,3 @@ const store = new Store();

```js
const Store = require('electron-store');
import Store from 'electron-store';

@@ -406,3 +409,3 @@ Store.initRenderer();

```js
const Store = require('electron-store');
import Store from 'electron-store';

@@ -427,4 +430,4 @@ const store = new Store();

```js
const Store = require('electron-store');
const yaml = require('js-yaml');
import Store from 'electron-store';
import yaml from 'js-yaml';

@@ -431,0 +434,0 @@ const store = new Store({

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc