@capacitor-community/sqlite 3.4.1-3 → 3.4.2-1

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/README.md CHANGED
@@ -28,10 +28,55 @@
28
28
 
29
29
  ## CAPACITOR 3 (Master)
30
30
 
31
+ 🚨 Since release 3.4.1 ->> 🚨
32
+ Databases location for Electron can be set in `the config.config.ts` as followed:
33
+
34
+ - for sharing databases between users:
35
+
36
+ ```
37
+ plugins: {
38
+ CapacitorSQLite: {
39
+ electronMacLocation: "/YOUR_DATABASES_PATH",
40
+ electronWindowsLocation: "C:\\ProgramData\\CapacitorDatabases",
41
+ electronLinuxLocation: "/home/CapacitorDatabases"
42
+ }
43
+ }
44
+ ```
45
+
46
+ - for only the user in its Home folder
47
+
48
+ ```
49
+ Plugins: {
50
+ CapacitorSQLite: {
51
+ electronMacLocation: "Databases",
52
+ electronWindowsLocation: "Databases",
53
+ electronLinuxLocation: "Databases"
54
+ }
55
+ }
56
+ ```
57
+
58
+ For existing databases, YOU MUST COPY old databases to the new location
59
+ You MUST remove the Electron folder and add it again with
60
+
61
+ ```
62
+ npx cap add @capacitor-community/electron
63
+ npm run build
64
+ cd electron
65
+ npm i --save sqlite3
66
+ npm i --save @types:sqlite3
67
+ npm run rebuild
68
+ cd ..
69
+ npx cap sync @capacitor-community/electron
70
+ npm run build
71
+ npx cap copy @capacitor-community/electron
72
+ npx cap open @capacitor-community/electron
73
+ ```
74
+ 🚨 Since release 3.4.1 <<- 🚨
75
+
31
76
  🚨 Since release 3.4.1-1 ->> 🚨
32
77
 
33
78
  - add iosIsEncryption, androidIsEncryption in capacitor.config.ts
34
- When your application use only `non-encrypted dzatabases` set those parameter to false then iOS KeyChain & Android MasterKey are not defined.
79
+ When your application use only `non-encrypted databases` set those parameter to false then iOS KeyChain & Android MasterKey are not defined.
35
80
 
36
81
  🚨 Since release 3.4.1-1 <<- 🚨
37
82
 
@@ -159,6 +159,7 @@ public class CapacitorSQLitePlugin extends Plugin {
159
159
  public void run() {
160
160
  try {
161
161
  implementation.changeEncryptionSecret(call, passphrase, oldpassphrase);
162
+ rHandler.retResult(call, null, null);
162
163
  return;
163
164
  } catch (Exception e) {
164
165
  String msg = "ChangeEncryptionSecret: " + e.getMessage();
@@ -7,6 +7,7 @@ var require$$0$1 = require('path');
7
7
  var require$$1 = require('fs');
8
8
  var require$$2 = require('os');
9
9
  var require$$3 = require('jszip');
10
+ var require$$4 = require('electron');
10
11
 
11
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
13
 
@@ -15,6 +16,7 @@ var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
15
16
  var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
16
17
  var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
17
18
  var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
19
+ var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
18
20
 
19
21
  var src = {};
20
22
 
@@ -2159,6 +2161,7 @@ class UtilsFile {
2159
2161
  this.NodeFs = null;
2160
2162
  this.JSZip = null;
2161
2163
  this.Os = null;
2164
+ this.Electron = null;
2162
2165
  this.AppName = '';
2163
2166
  this.HomeDir = '';
2164
2167
  this.sep = '/';
@@ -2166,15 +2169,38 @@ class UtilsFile {
2166
2169
  this.NodeFs = require$$1__default['default'];
2167
2170
  this.Os = require$$2__default['default'];
2168
2171
  this.JSZip = require$$3__default['default'];
2172
+ this.Electron = require$$4__default['default'];
2169
2173
  this.HomeDir = this.Os.homedir();
2170
2174
  const dir = __dirname;
2171
2175
  const idx = dir.indexOf('\\');
2172
2176
  if (idx != -1)
2173
2177
  this.sep = '\\';
2174
- this.appPath = dir.substring(0, dir.indexOf(`electron${this.sep}`) /* + 8*/);
2178
+ this.appPath = this.Electron.app.getAppPath();
2175
2179
  const rawdata = this.NodeFs.readFileSync(this.Path.resolve(this.appPath, 'package.json'));
2176
2180
  this.AppName = JSON.parse(rawdata).name;
2181
+ const pathToBuild = this.Path.join(this.appPath, 'build');
2182
+ if (this.NodeFs.existsSync(this.Path.join(pathToBuild, 'capacitor.config.js'))) {
2183
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2184
+ this.capConfig = require(this.Path.join(pathToBuild, 'capacitor.config.js')).default;
2185
+ }
2186
+ else {
2187
+ this.capConfig = JSON.parse(this.NodeFs.readFileSync(this.Path.join(this.appPath, 'capacitor.config.json')).toString());
2188
+ }
2177
2189
  this.osType = this.Os.type();
2190
+ switch (this.osType) {
2191
+ case 'Darwin':
2192
+ this.pathDB = this.capConfig.plugins.CapacitorSQLite.electronMacLocation;
2193
+ break;
2194
+ case 'Linux':
2195
+ this.pathDB = this.capConfig.plugins.CapacitorSQLite.electronLinuxLocation;
2196
+ break;
2197
+ case 'Windows_NT':
2198
+ this.pathDB = this.capConfig.plugins.CapacitorSQLite.electronWindowsLocation;
2199
+ break;
2200
+ default:
2201
+ console.log('other operating system');
2202
+ }
2203
+ console.log(`&&& Databases path: ${this.pathDB}`);
2178
2204
  }
2179
2205
  /**
2180
2206
  * IsPathExists
@@ -2213,37 +2239,26 @@ class UtilsFile {
2213
2239
  getFilePath(fileName) {
2214
2240
  return this.Path.join(this.getDatabasesPath(), fileName);
2215
2241
  }
2216
- /**
2217
- * GetCustomerPath
2218
- * get the customer path
2219
- */
2220
- getCustomerPath(custPath) {
2221
- return this.Path.join(this.HomeDir, custPath);
2222
- }
2223
- /**
2224
- * GetCustomerFilePath
2225
- * get the customer file path
2226
- */
2227
- getCustomerFilePath(custPath, file) {
2228
- return this.Path.join(custPath, file);
2229
- }
2230
2242
  /**
2231
2243
  * GetDatabasesPath
2232
2244
  * get the database folder path
2233
2245
  */
2234
2246
  getDatabasesPath() {
2235
2247
  let retPath = '';
2248
+ const sep = this.Path.sep;
2236
2249
  const dbFolder = this.pathDB;
2237
- retPath = this.Path.join(this.HomeDir, dbFolder, this.AppName);
2238
- let retB = this._createFolderIfNotExists(this.Path.join(this.HomeDir, dbFolder));
2239
- if (retB) {
2240
- retB = this._createFolderIfNotExists(this.Path.join(this.HomeDir, dbFolder, this.AppName));
2241
- if (!retB)
2242
- retPath = '';
2250
+ if (dbFolder.includes(sep)) {
2251
+ retPath = dbFolder;
2252
+ if (this.Path.basename(dbFolder) !== this.AppName) {
2253
+ retPath = this.Path.join(dbFolder, this.AppName);
2254
+ }
2243
2255
  }
2244
2256
  else {
2245
- retPath = '';
2257
+ retPath = this.Path.join(this.HomeDir, dbFolder, this.AppName);
2246
2258
  }
2259
+ const retB = this._createFolderIfNotExists(retPath);
2260
+ if (!retB)
2261
+ retPath = '';
2247
2262
  return retPath;
2248
2263
  }
2249
2264
  /**
@@ -2547,9 +2562,10 @@ class UtilsFile {
2547
2562
  * @param directory
2548
2563
  */
2549
2564
  _mkdirSyncRecursive(directory) {
2550
- const path = directory.replace(/\/$/, '').split('/');
2565
+ const sep = this.Path.sep;
2566
+ const path = directory.replace(/\/$/, '').split(sep);
2551
2567
  for (let i = 1; i <= path.length; i++) {
2552
- const segment = path.slice(0, i).join('/');
2568
+ const segment = path.slice(0, i).join(sep);
2553
2569
  segment.length > 0 && !this.NodeFs.existsSync(segment)
2554
2570
  ? this.NodeFs.mkdirSync(segment)
2555
2571
  : null;