@capacitor-community/sqlite 3.4.1-3 → 3.4.1-4

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,33 @@
28
28
 
29
29
  ## CAPACITOR 3 (Master)
30
30
 
31
+ 🚨 Since release 3.4.1-4 ->> 🚨
32
+ MacOS only, databases location for Electron can be set in `the config.config.ts` as followed:
33
+ plugins: {
34
+ CapacitorSQLite: {
35
+ electronMacLocation: "/YOUR_DATABASES_PATH"
36
+ }
37
+ }
38
+ For existing databases, YOU MUST COPY old databases to the new location
39
+ You MUST remove the Electron folder and add it again with
40
+ ```
41
+ npx cap add @capacitor-community/electron
42
+ npm run build
43
+ cd electron
44
+ npm i --save sqlite3
45
+ npm i --save @types:sqlite3
46
+ npm run rebuild
47
+ cd ..
48
+ npx cap sync @capacitor-community/electron
49
+ npm run build
50
+ npx cap copy @capacitor-community/electron
51
+ npx cap open @capacitor-community/electron
52
+ 🚨 Since release 3.4.1-4 <<- 🚨
53
+
31
54
  🚨 Since release 3.4.1-1 ->> 🚨
32
55
 
33
56
  - 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.
57
+ When your application use only `non-encrypted databases` set those parameter to false then iOS KeyChain & Android MasterKey are not defined.
35
58
 
36
59
  🚨 Since release 3.4.1-1 <<- 🚨
37
60
 
@@ -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
  /**