pushy-electron 1.0.7 → 1.0.10

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
@@ -6,20 +6,21 @@
6
6
  "main": "lib/Pushy.js",
7
7
  "typings": "lib/Pushy.d.ts",
8
8
  "//": "Also update version in config.js",
9
- "version": "1.0.7",
9
+ "version": "1.0.10",
10
10
  "scripts": {
11
11
  "dev": "electron electron.js"
12
12
  },
13
13
  "dependencies": {
14
14
  "electron-store": "^5.1.0",
15
- "mqtt": "^3.0.0",
16
- "node-fetch": "^2.6.0"
15
+ "mqtt": "^4.3.7",
16
+ "node-fetch": "^2.6.7",
17
+ "packpath": "^0.1.0"
17
18
  },
18
19
  "devDependencies": {
19
- "electron": "^7.1.2"
20
+ "electron": "^15.5.5"
20
21
  },
21
22
  "bugs": {
22
- "url": "https://github.com/pushy-me/pushy-electron/issues"
23
+ "url": "https://github.com/pushy/pushy-electron/issues"
23
24
  },
24
- "homepage": "https://github.com/pushy-me/pushy-electron#readme"
25
+ "homepage": "https://github.com/pushy/pushy-electron#readme"
25
26
  }
package/util/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const config = require('../config');
2
- const fetch = require('node-fetch').default; // Workaround for #2: https://github.com/pushy-me/pushy-electron/issues/2
3
- const localStorage = new (require('electron-store'))();
2
+ const localStorage = require('./storage');
3
+ const fetch = require('node-fetch').default; // Workaround for #2: https://github.com/pushy/pushy-electron/issues/2
4
4
 
5
5
  module.exports = {
6
6
  async get(path, options) {
package/util/mqtt.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const config = require('../config');
2
+ const localStorage = require('./storage');
2
3
  const mqtt = require('mqtt/lib/connect');
3
- const localStorage = new (require('electron-store'))();
4
4
 
5
5
  module.exports = {
6
6
  connect(Pushy) {
@@ -0,0 +1,46 @@
1
+ const path = require('path');
2
+ const packpath = require('packpath');
3
+ const Store = require('electron-store');
4
+
5
+ // Cached electron-store object
6
+ let localStorage;
7
+
8
+ // Expose getter & setter methods
9
+ module.exports = {
10
+ get(key) {
11
+ return getLocalStorage().get(key);
12
+ },
13
+ set(key, value) {
14
+ return getLocalStorage().set(key, value);
15
+ }
16
+ };
17
+
18
+ function getLocalStorage() {
19
+ // Already cached?
20
+ if (localStorage) {
21
+ return localStorage;
22
+ }
23
+
24
+ // Default electron-store options
25
+ const options = {};
26
+
27
+ try {
28
+ // Get Node.js package name from package.json
29
+ const packageJson = require(path.join(packpath.parent(), 'package.json'));
30
+
31
+ // Use name specified in package.json for electron-store config file name
32
+ if (packageJson && packageJson.name) {
33
+ options.name = packageJson.name;
34
+ }
35
+ }
36
+ catch (exc) {
37
+ // Ignore errors if unable to find package.json
38
+ // Defaults to 'config.json'
39
+ }
40
+
41
+ // Cache electron-store object for subsequent calls
42
+ localStorage = new Store(options);
43
+
44
+ // All done
45
+ return localStorage;
46
+ };