10
10
/* global global, require, module */
11
11
12
12
"use strict" ;
13
+
13
14
const appModule = require ( "@nativescript/core/application" ) ;
14
15
const fsModule = require ( "@nativescript/core/file-system" ) ;
15
16
17
+
18
+ //import * as appModule from '@nativescript/core/application';
19
+ //import * as fsModule from '@nativescript/core/file-system';
20
+
16
21
/*jshint undef: true */
17
22
/*global java, android, Promise */
18
23
@@ -245,28 +250,13 @@ function Database(dbname, options, callback) {
245
250
options = options || { } ;
246
251
}
247
252
248
-
249
- //noinspection JSUnresolvedVariable
250
- if ( options && options . multithreading && typeof global . Worker === 'function' ) {
251
- // We don't want this passed into the worker; to try and start another worker (which would fail).
252
- delete options . multithreading ;
253
- if ( ! Database . HAS_COMMERCIAL ) {
254
- throw new Error ( "Commercial only feature; see http://nativescript.tools/product/10" ) ;
255
- }
256
- if ( global . TNS_WEBPACK && global . TNS_WEBPACK >= 5 ) {
257
- console . warn ( "SQLite: Multithreading temporarily disabled on NS 8 because of bug in Webpack" )
258
- } else {
259
- return new Database . _multiSQL ( dbname , options , callback ) ;
260
- }
261
- }
262
- this . _options = options ;
253
+ this . _options = options ;
263
254
264
255
265
256
// Check to see if it has a path, or if it is a relative dbname
266
257
// dbname = "" - Temporary Database
267
258
// dbname = ":memory:" = memory database
268
259
if ( dbname !== "" && dbname !== ":memory:" ) {
269
- //var pkgName = appModule.android.context.getPackageName();
270
260
//noinspection JSUnresolvedFunction
271
261
dbname = _getContext ( ) . getDatabasePath ( dbname ) . getAbsolutePath ( ) . toString ( ) ;
272
262
let path = dbname . substr ( 0 , dbname . lastIndexOf ( '/' ) + 1 ) ;
@@ -837,7 +827,7 @@ Database.prototype.each = function(sql, params, callback, complete) {
837
827
838
828
/***
839
829
* Converts a Mixed Array to a String Array
840
- * @param params
830
+ * @param paramsIn
841
831
* @returns {Array }
842
832
* @private
843
833
*/
@@ -941,7 +931,6 @@ Database.manualBackup = function(name) {
941
931
success = false ;
942
932
}
943
933
944
-
945
934
//Close the streams
946
935
// noinspection JSUnresolvedFunction
947
936
myOutput . flush ( ) ;
@@ -1073,13 +1062,11 @@ function _getContext() {
1073
1062
}
1074
1063
}
1075
1064
} catch ( err ) {
1076
- console . log ( "Using Fallback" ) ;
1077
- /* In some cases Multidex has been the report */
1078
- /* the getNativeApplication calls .getInstance which fails */
1065
+ console . log ( "SQLITE: Using Fallback" ) ;
1066
+ // In some cases Multidex has been the report
1067
+ // the getNativeApplication calls .getInstance which fails
1079
1068
}
1080
1069
1081
-
1082
-
1083
1070
//noinspection JSUnresolvedFunction,JSUnresolvedVariable
1084
1071
let ctx = java . lang . Class . forName ( "android.app.AppGlobals" ) . getMethod ( "getInitialApplication" , null ) . invoke ( null , null ) ;
1085
1072
if ( ctx ) return ctx ;
@@ -1114,8 +1101,8 @@ function UsePlugin(loadedSrc, DBModule) {
1114
1101
1115
1102
function TryLoadingCommercialPlugin ( ) {
1116
1103
try {
1117
- const sqlCom = require ( 'nativescript-sqlite-commercial' ) ;
1118
- UsePlugin ( sqlCom , Database ) ;
1104
+ const sqlCom = require ( 'nativescript-sqlite-commercial' ) ;
1105
+ UsePlugin ( sqlCom , Database ) ;
1119
1106
}
1120
1107
catch ( e ) {
1121
1108
/* Do Nothing if it doesn't exist as it is an optional plugin */
@@ -1124,19 +1111,21 @@ function TryLoadingCommercialPlugin() {
1124
1111
1125
1112
function TryLoadingEncryptionPlugin ( ) {
1126
1113
try {
1127
- const sqlEnc = require ( 'nativescript-sqlite-encrypted' ) ;
1128
- UsePlugin ( sqlEnc , Database ) ;
1114
+ const sqlEnc = require ( 'nativescript-sqlite-encrypted' ) ;
1115
+ UsePlugin ( sqlEnc , Database ) ;
1129
1116
}
1130
- catch ( e ) { /* Do Nothing if it doesn't exist as it is an optional plugin */
1117
+ catch ( e ) {
1118
+ /* Do Nothing if it doesn't exist as it is an optional plugin */
1131
1119
}
1132
1120
}
1133
1121
1134
1122
function TryLoadingSyncPlugin ( ) {
1135
1123
try {
1136
- const sqlSync = require ( 'nativescript-sqlite-sync' ) ;
1137
- UsePlugin ( sqlSync , Database ) ;
1124
+ const sqlSync = require ( 'nativescript-sqlite-sync' ) ;
1125
+ UsePlugin ( sqlSync , Database ) ;
1138
1126
}
1139
- catch ( e ) { /* Do Nothing if it doesn't exist as it is an optional plugin */
1127
+ catch ( e ) {
1128
+ /* Do Nothing if it doesn't exist as it is an optional plugin */
1140
1129
}
1141
1130
}
1142
1131
0 commit comments