This commit is contained in:
tiago.kayaya
2021-01-27 14:13:17 +01:00
parent 247daffbeb
commit 585f5a1fb0
55 changed files with 223 additions and 5834 deletions
Binary file not shown.
Binary file not shown.
+4 -4
View File
@@ -31,15 +31,15 @@
<exclude-output />
<content url="file://$MODULE_DIR$/../../../app">
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/renderscript_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/aidl_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/renderscript_source_output_dir/debug/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/res/google-services/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/res/rs/debug" type="java-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/ap_generated_sources/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/renderscript_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/aidl_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/renderscript_source_output_dir/debugAndroidTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/res/rs/androidTest/debug" type="java-test-resource" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/ap_generated_sources/debugUnitTest/out" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/src/debug/res" type="java-resource" />
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
#Mon Jan 25 12:12:31 WAT 2021
#Wed Jan 27 14:07:50 WAT 2021
C\:\\Users\\tiago.kayaya\\development\\gabinete-digital\\android\\app\\src\\main\\res\\drawable-port-xhdpi\\splash.png=C\:\\Users\\tiago.kayaya\\development\\gabinete-digital\\android\\app\\build\\intermediates\\res\\merged\\debug\\drawable-port-xhdpi_splash.png.flat
C\:\\Users\\tiago.kayaya\\development\\gabinete-digital\\android\\app\\src\\main\\res\\mipmap-mdpi\\ic_launcher_foreground.png=C\:\\Users\\tiago.kayaya\\development\\gabinete-digital\\android\\app\\build\\intermediates\\res\\merged\\debug\\mipmap-mdpi_ic_launcher_foreground.png.flat
C\:\\Users\\tiago.kayaya\\development\\gabinete-digital\\android\\app\\src\\main\\res\\mipmap-xxhdpi\\ic_launcher.png=C\:\\Users\\tiago.kayaya\\development\\gabinete-digital\\android\\app\\build\\intermediates\\res\\merged\\debug\\mipmap-xxhdpi_ic_launcher.png.flat
@@ -1,4 +1,4 @@
#Tue Jan 26 15:33:16 WAT 2021
#Wed Jan 27 14:08:17 WAT 2021
path.3=classes_1.dex
path.2=classes_0.dex
path.1=classes.dex
File diff suppressed because it is too large Load Diff
@@ -1,264 +0,0 @@
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
{
"id": "cordova-plugin-camera.Camera",
"file": "plugins/cordova-plugin-camera/www/CameraConstants.js",
"pluginId": "cordova-plugin-camera",
"clobbers": [
"Camera"
]
},
{
"id": "cordova-plugin-camera.CameraPopoverHandle",
"file": "plugins/cordova-plugin-camera/www/CameraPopoverHandle.js",
"pluginId": "cordova-plugin-camera",
"clobbers": [
"CameraPopoverHandle"
]
},
{
"id": "cordova-plugin-camera.CameraPopoverOptions",
"file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js",
"pluginId": "cordova-plugin-camera",
"clobbers": [
"CameraPopoverOptions"
]
},
{
"id": "cordova-plugin-inappbrowser.inappbrowser",
"file": "plugins/cordova-plugin-inappbrowser/www/inappbrowser.js",
"pluginId": "cordova-plugin-inappbrowser",
"clobbers": [
"cordova.InAppBrowser.open"
]
},
{
"id": "cordova-plugin-device.device",
"file": "plugins/cordova-plugin-device/www/device.js",
"pluginId": "cordova-plugin-device",
"clobbers": [
"device"
]
},
{
"id": "cordova-plugin-camera.camera",
"file": "plugins/cordova-plugin-camera/www/Camera.js",
"pluginId": "cordova-plugin-camera",
"clobbers": [
"navigator.camera"
]
},
{
"id": "cordova-sqlite-storage.SQLitePlugin",
"file": "plugins/cordova-sqlite-storage/www/SQLitePlugin.js",
"pluginId": "cordova-sqlite-storage",
"clobbers": [
"SQLitePlugin"
]
},
{
"id": "cordova-plugin-file.DirectoryEntry",
"file": "plugins/cordova-plugin-file/www/DirectoryEntry.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.DirectoryEntry"
]
},
{
"id": "cordova-plugin-file.DirectoryReader",
"file": "plugins/cordova-plugin-file/www/DirectoryReader.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.DirectoryReader"
]
},
{
"id": "cordova-plugin-file.Entry",
"file": "plugins/cordova-plugin-file/www/Entry.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.Entry"
]
},
{
"id": "cordova-plugin-file.File",
"file": "plugins/cordova-plugin-file/www/File.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.File"
]
},
{
"id": "cordova-plugin-file.FileEntry",
"file": "plugins/cordova-plugin-file/www/FileEntry.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.FileEntry"
]
},
{
"id": "cordova-plugin-file.FileError",
"file": "plugins/cordova-plugin-file/www/FileError.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.FileError"
]
},
{
"id": "cordova-plugin-filepath.FilePath",
"file": "plugins/cordova-plugin-filepath/www/FilePath.js",
"pluginId": "cordova-plugin-filepath",
"clobbers": [
"window.FilePath"
]
},
{
"id": "cordova-plugin-file.FileReader",
"file": "plugins/cordova-plugin-file/www/FileReader.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.FileReader"
]
},
{
"id": "cordova-plugin-file.FileSystem",
"file": "plugins/cordova-plugin-file/www/FileSystem.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.FileSystem"
]
},
{
"id": "cordova-plugin-file.FileUploadOptions",
"file": "plugins/cordova-plugin-file/www/FileUploadOptions.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.FileUploadOptions"
]
},
{
"id": "cordova-plugin-file.FileUploadResult",
"file": "plugins/cordova-plugin-file/www/FileUploadResult.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.FileUploadResult"
]
},
{
"id": "cordova-plugin-file.FileWriter",
"file": "plugins/cordova-plugin-file/www/FileWriter.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.FileWriter"
]
},
{
"id": "cordova-plugin-file.Flags",
"file": "plugins/cordova-plugin-file/www/Flags.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.Flags"
]
},
{
"id": "cordova-plugin-file.LocalFileSystem",
"file": "plugins/cordova-plugin-file/www/LocalFileSystem.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.LocalFileSystem"
],
"merges": [
"window"
]
},
{
"id": "cordova-plugin-file.Metadata",
"file": "plugins/cordova-plugin-file/www/Metadata.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.Metadata"
]
},
{
"id": "cordova-plugin-file.ProgressEvent",
"file": "plugins/cordova-plugin-file/www/ProgressEvent.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.ProgressEvent"
]
},
{
"id": "cordova-plugin-file.requestFileSystem",
"file": "plugins/cordova-plugin-file/www/requestFileSystem.js",
"pluginId": "cordova-plugin-file",
"clobbers": [
"window.requestFileSystem"
]
},
{
"id": "cordova-plugin-statusbar.statusbar",
"file": "plugins/cordova-plugin-statusbar/www/statusbar.js",
"pluginId": "cordova-plugin-statusbar",
"clobbers": [
"window.StatusBar"
]
},
{
"id": "cordova-plugin-file.fileSystems",
"file": "plugins/cordova-plugin-file/www/fileSystems.js",
"pluginId": "cordova-plugin-file"
},
{
"id": "cordova-plugin-file.isChrome",
"file": "plugins/cordova-plugin-file/www/browser/isChrome.js",
"pluginId": "cordova-plugin-file",
"runs": true
},
{
"id": "cordova-plugin-file.fileSystems-roots",
"file": "plugins/cordova-plugin-file/www/fileSystems-roots.js",
"pluginId": "cordova-plugin-file",
"runs": true
},
{
"id": "cordova-plugin-file.fileSystemPaths",
"file": "plugins/cordova-plugin-file/www/fileSystemPaths.js",
"pluginId": "cordova-plugin-file",
"merges": [
"cordova"
],
"runs": true
},
{
"id": "cordova-plugin-file.androidFileSystem",
"file": "plugins/cordova-plugin-file/www/android/FileSystem.js",
"pluginId": "cordova-plugin-file",
"merges": [
"FileSystem"
]
},
{
"id": "cordova-plugin-file.resolveLocalFileSystemURI",
"file": "plugins/cordova-plugin-file/www/resolveLocalFileSystemURI.js",
"pluginId": "cordova-plugin-file",
"merges": [
"window"
]
}
];
module.exports.metadata =
// TOP OF METADATA
{
"cordova-plugin-camera": "5.0.1",
"cordova-plugin-file": "6.0.2",
"cordova-plugin-filepath": "1.5.8",
"cordova-sqlite-storage": "5.1.0",
"cordova-plugin-device": "2.0.2",
"cordova-plugin-inappbrowser": "4.0.0",
"cordova-plugin-statusbar": "2.4.2",
"cordova-plugin-whitelist": "1.3.3"
};
// BOTTOM OF METADATA
});
@@ -1,187 +0,0 @@
cordova.define("cordova-plugin-camera.camera", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var argscheck = require('cordova/argscheck');
var exec = require('cordova/exec');
var Camera = require('./Camera');
// XXX: commented out
// CameraPopoverHandle = require('./CameraPopoverHandle');
/**
* @namespace navigator
*/
/**
* @exports camera
*/
var cameraExport = {};
// Tack on the Camera Constants to the base camera plugin.
for (var key in Camera) {
cameraExport[key] = Camera[key];
}
/**
* Callback function that provides an error message.
* @callback module:camera.onError
* @param {string} message - The message is provided by the device's native code.
*/
/**
* Callback function that provides the image data.
* @callback module:camera.onSuccess
* @param {string} imageData - Base64 encoding of the image data, _or_ the image file URI, depending on [`cameraOptions`]{@link module:camera.CameraOptions} in effect.
* @example
* // Show image
* //
* function cameraCallback(imageData) {
* var image = document.getElementById('myImage');
* image.src = "data:image/jpeg;base64," + imageData;
* }
*/
/**
* Optional parameters to customize the camera settings.
* * [Quirks](#CameraOptions-quirks)
* @typedef module:camera.CameraOptions
* @type {Object}
* @property {number} [quality=50] - Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.)
* @property {module:Camera.DestinationType} [destinationType=FILE_URI] - Choose the format of the return value.
* @property {module:Camera.PictureSourceType} [sourceType=CAMERA] - Set the source of the picture.
* @property {Boolean} [allowEdit=false] - Allow simple editing of image before selection.
* @property {module:Camera.EncodingType} [encodingType=JPEG] - Choose the returned image file's encoding.
* @property {number} [targetWidth] - Width in pixels to scale image. Must be used with `targetHeight`. Aspect ratio remains constant.
* @property {number} [targetHeight] - Height in pixels to scale image. Must be used with `targetWidth`. Aspect ratio remains constant.
* @property {module:Camera.MediaType} [mediaType=PICTURE] - Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`.
* @property {Boolean} [correctOrientation] - Rotate the image to correct for the orientation of the device during capture.
* @property {Boolean} [saveToPhotoAlbum] - Save the image to the photo album on the device after capture.
* @property {module:CameraPopoverOptions} [popoverOptions] - iOS-only options that specify popover location in iPad.
* @property {module:Camera.Direction} [cameraDirection=BACK] - Choose the camera to use (front- or back-facing).
*/
/**
* @description Takes a photo using the camera, or retrieves a photo from the device's
* image gallery. The image is passed to the success callback as a
* Base64-encoded `String`, or as the URI for the image file.
*
* The `camera.getPicture` function opens the device's default camera
* application that allows users to snap pictures by default - this behavior occurs,
* when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`]{@link module:Camera.PictureSourceType}.
* Once the user snaps the photo, the camera application closes and the application is restored.
*
* If `Camera.sourceType` is `Camera.PictureSourceType.PHOTOLIBRARY` or
* `Camera.PictureSourceType.SAVEDPHOTOALBUM`, then a dialog displays
* that allows users to select an existing image.
*
* The return value is sent to the [`cameraSuccess`]{@link module:camera.onSuccess} callback function, in
* one of the following formats, depending on the specified
* `cameraOptions`:
*
* - A `String` containing the Base64-encoded photo image.
* - A `String` representing the image file location on local storage (default).
*
* You can do whatever you want with the encoded image or URI, for
* example:
*
* - Render the image in an `<img>` tag, as in the example below
* - Save the data locally (`LocalStorage`, [Lawnchair](http://brianleroux.github.com/lawnchair/), etc.)
* - Post the data to a remote server
*
* __NOTE__: Photo resolution on newer devices is quite good. Photos
* selected from the device's gallery are not downscaled to a lower
* quality, even if a `quality` parameter is specified. To avoid common
* memory problems, set `Camera.destinationType` to `FILE_URI` rather
* than `DATA_URL`.
*
* __Supported Platforms__
*
* - Android
* - BlackBerry
* - Browser
* - Firefox
* - FireOS
* - iOS
* - Windows
* - WP8
* - Ubuntu
*
* More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks).
*
* @example
* navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);
* @param {module:camera.onSuccess} successCallback
* @param {module:camera.onError} errorCallback
* @param {module:camera.CameraOptions} options CameraOptions
*/
cameraExport.getPicture = function (successCallback, errorCallback, options) {
argscheck.checkArgs('fFO', 'Camera.getPicture', arguments);
options = options || {};
var getValue = argscheck.getValue;
var quality = getValue(options.quality, 50);
var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI);
var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA);
var targetWidth = getValue(options.targetWidth, -1);
var targetHeight = getValue(options.targetHeight, -1);
var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG);
var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
var allowEdit = !!options.allowEdit;
var correctOrientation = !!options.correctOrientation;
var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
var popoverOptions = getValue(options.popoverOptions, null);
var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection];
exec(successCallback, errorCallback, 'Camera', 'takePicture', args);
// XXX: commented out
// return new CameraPopoverHandle();
};
/**
* Removes intermediate image files that are kept in temporary storage
* after calling [`camera.getPicture`]{@link module:camera.getPicture}. Applies only when the value of
* `Camera.sourceType` equals `Camera.PictureSourceType.CAMERA` and the
* `Camera.destinationType` equals `Camera.DestinationType.FILE_URI`.
*
* __Supported Platforms__
*
* - iOS
*
* @example
* navigator.camera.cleanup(onSuccess, onFail);
*
* function onSuccess() {
* console.log("Camera cleanup success.")
* }
*
* function onFail(message) {
* alert('Failed because: ' + message);
* }
*/
cameraExport.cleanup = function (successCallback, errorCallback) {
exec(successCallback, errorCallback, 'Camera', 'cleanup', []);
};
module.exports = cameraExport;
});
@@ -1,94 +0,0 @@
cordova.define("cordova-plugin-camera.Camera", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* @module Camera
*/
module.exports = {
/**
* @description
* Defines the output format of `Camera.getPicture` call.
*
* @enum {number}
*/
DestinationType: {
/** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI if possible */
DATA_URL: 0,
/** Return file uri (content://media/external/images/media/2 for Android) */
FILE_URI: 1
},
/**
* @enum {number}
*/
EncodingType: {
/** Return JPEG encoded image */
JPEG: 0,
/** Return PNG encoded image */
PNG: 1
},
/**
* @enum {number}
*/
MediaType: {
/** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */
PICTURE: 0,
/** Allow selection of video only, ONLY RETURNS URL */
VIDEO: 1,
/** Allow selection from all media types */
ALLMEDIA: 2
},
/**
* @description
* Defines the output format of `Camera.getPicture` call.
*
* @enum {number}
*/
PictureSourceType: {
/** Choose image from the device's photo library (same as SAVEDPHOTOALBUM for Android) */
PHOTOLIBRARY: 0,
/** Take picture from camera */
CAMERA: 1,
/** Choose image only from the device's Camera Roll album (same as PHOTOLIBRARY for Android) */
SAVEDPHOTOALBUM: 2
},
/**
* Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover.
* @enum {number}
*/
PopoverArrowDirection: {
ARROW_UP: 1,
ARROW_DOWN: 2,
ARROW_LEFT: 4,
ARROW_RIGHT: 8,
ARROW_ANY: 15
},
/**
* @enum {number}
*/
Direction: {
/** Use the back-facing camera */
BACK: 0,
/** Use the front-facing camera */
FRONT: 1
}
};
});
@@ -1,34 +0,0 @@
cordova.define("cordova-plugin-camera.CameraPopoverHandle", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* @ignore in favour of iOS' one
* A handle to an image picker popover.
*/
var CameraPopoverHandle = function () {
this.setPosition = function (popoverOptions) {
console.log('CameraPopoverHandle.setPosition is only supported on iOS.');
};
};
module.exports = CameraPopoverHandle;
});
@@ -1,58 +0,0 @@
cordova.define("cordova-plugin-camera.CameraPopoverOptions", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var Camera = require('./Camera');
/**
* @namespace navigator
*/
/**
* iOS-only parameters that specify the anchor element location and arrow
* direction of the popover when selecting images from an iPad's library
* or album.
* Note that the size of the popover may change to adjust to the
* direction of the arrow and orientation of the screen. Make sure to
* account for orientation changes when specifying the anchor element
* location.
* @module CameraPopoverOptions
* @param {Number} [x=0] - x pixel coordinate of screen element onto which to anchor the popover.
* @param {Number} [y=32] - y pixel coordinate of screen element onto which to anchor the popover.
* @param {Number} [width=320] - width, in pixels, of the screen element onto which to anchor the popover.
* @param {Number} [height=480] - height, in pixels, of the screen element onto which to anchor the popover.
* @param {module:Camera.PopoverArrowDirection} [arrowDir=ARROW_ANY] - Direction the arrow on the popover should point.
* @param {Number} [popoverWidth=0] - width of the popover (0 or not specified will use apple's default width).
* @param {Number} [popoverHeight=0] - height of the popover (0 or not specified will use apple's default height).
*/
var CameraPopoverOptions = function (x, y, width, height, arrowDir, popoverWidth, popoverHeight) {
// information of rectangle that popover should be anchored to
this.x = x || 0;
this.y = y || 32;
this.width = width || 320;
this.height = height || 480;
this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
this.popoverWidth = popoverWidth || 0;
this.popoverHeight = popoverHeight || 0;
};
module.exports = CameraPopoverOptions;
});
@@ -1,85 +0,0 @@
cordova.define("cordova-plugin-device.device", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var argscheck = require('cordova/argscheck');
var channel = require('cordova/channel');
var utils = require('cordova/utils');
var exec = require('cordova/exec');
var cordova = require('cordova');
channel.createSticky('onCordovaInfoReady');
// Tell cordova channel to wait on the CordovaInfoReady event
channel.waitForInitialization('onCordovaInfoReady');
/**
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
* phone, etc.
* @constructor
*/
function Device () {
this.available = false;
this.platform = null;
this.version = null;
this.uuid = null;
this.cordova = null;
this.model = null;
this.manufacturer = null;
this.isVirtual = null;
this.serial = null;
var me = this;
channel.onCordovaReady.subscribe(function () {
me.getInfo(function (info) {
// ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
// TODO: CB-5105 native implementations should not return info.cordova
var buildLabel = cordova.version;
me.available = true;
me.platform = info.platform;
me.version = info.version;
me.uuid = info.uuid;
me.cordova = buildLabel;
me.model = info.model;
me.isVirtual = info.isVirtual;
me.manufacturer = info.manufacturer || 'unknown';
me.serial = info.serial || 'unknown';
channel.onCordovaInfoReady.fire();
}, function (e) {
me.available = false;
utils.alert('[ERROR] Error initializing Cordova: ' + e);
});
});
}
/**
* Get device info
*
* @param {Function} successCallback The function to call when the heading data is available
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
*/
Device.prototype.getInfo = function (successCallback, errorCallback) {
argscheck.checkArgs('fF', 'Device.getInfo', arguments);
exec(successCallback, errorCallback, 'Device', 'getDeviceInfo', []);
};
module.exports = new Device();
});
@@ -1,119 +0,0 @@
cordova.define("cordova-plugin-file.DirectoryEntry", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var argscheck = require('cordova/argscheck');
var utils = require('cordova/utils');
var exec = require('cordova/exec');
var Entry = require('./Entry');
var FileError = require('./FileError');
var DirectoryReader = require('./DirectoryReader');
/**
* An interface representing a directory on the file system.
*
* {boolean} isFile always false (readonly)
* {boolean} isDirectory always true (readonly)
* {DOMString} name of the directory, excluding the path leading to it (readonly)
* {DOMString} fullPath the absolute full path to the directory (readonly)
* {FileSystem} filesystem on which the directory resides (readonly)
*/
var DirectoryEntry = function (name, fullPath, fileSystem, nativeURL) {
// add trailing slash if it is missing
if ((fullPath) && !/\/$/.test(fullPath)) {
fullPath += '/';
}
// add trailing slash if it is missing
if (nativeURL && !/\/$/.test(nativeURL)) {
nativeURL += '/';
}
DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath, fileSystem, nativeURL);
};
utils.extend(DirectoryEntry, Entry);
/**
* Creates a new DirectoryReader to read entries from this directory
*/
DirectoryEntry.prototype.createReader = function () {
return new DirectoryReader(this.toInternalURL());
};
/**
* Creates or looks up a directory
*
* @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
* @param {Flags} options to create or exclusively create the directory
* @param {Function} successCallback is called with the new entry
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback) {
argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
var fs = this.filesystem;
var win = successCallback && function (result) {
var entry = new DirectoryEntry(result.name, result.fullPath, fs, result.nativeURL);
successCallback(entry);
};
var fail = errorCallback && function (code) {
errorCallback(new FileError(code));
};
exec(win, fail, 'File', 'getDirectory', [this.toInternalURL(), path, options]);
};
/**
* Deletes a directory and all of it's contents
*
* @param {Function} successCallback is called with no parameters
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCallback) {
argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
var fail = errorCallback && function (code) {
errorCallback(new FileError(code));
};
exec(successCallback, fail, 'File', 'removeRecursively', [this.toInternalURL()]);
};
/**
* Creates or looks up a file
*
* @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
* @param {Flags} options to create or exclusively create the file
* @param {Function} successCallback is called with the new entry
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback) {
argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
var fs = this.filesystem;
var win = successCallback && function (result) {
var FileEntry = require('./FileEntry');
var entry = new FileEntry(result.name, result.fullPath, fs, result.nativeURL);
successCallback(entry);
};
var fail = errorCallback && function (code) {
errorCallback(new FileError(code));
};
exec(win, fail, 'File', 'getFile', [this.toInternalURL(), path, options]);
};
module.exports = DirectoryEntry;
});
@@ -1,74 +0,0 @@
cordova.define("cordova-plugin-file.DirectoryReader", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var exec = require('cordova/exec');
var FileError = require('./FileError');
/**
* An interface that lists the files and directories in a directory.
*/
function DirectoryReader (localURL) {
this.localURL = localURL || null;
this.hasReadEntries = false;
}
/**
* Returns a list of entries from a directory.
*
* @param {Function} successCallback is called with a list of entries
* @param {Function} errorCallback is called with a FileError
*/
DirectoryReader.prototype.readEntries = function (successCallback, errorCallback) {
// If we've already read and passed on this directory's entries, return an empty list.
if (this.hasReadEntries) {
successCallback([]);
return;
}
var reader = this;
var win = typeof successCallback !== 'function' ? null : function (result) {
var retVal = [];
for (var i = 0; i < result.length; i++) {
var entry = null;
if (result[i].isDirectory) {
entry = new (require('./DirectoryEntry'))();
} else if (result[i].isFile) {
entry = new (require('./FileEntry'))();
}
entry.isDirectory = result[i].isDirectory;
entry.isFile = result[i].isFile;
entry.name = result[i].name;
entry.fullPath = result[i].fullPath;
entry.filesystem = new (require('./FileSystem'))(result[i].filesystemName);
entry.nativeURL = result[i].nativeURL;
retVal.push(entry);
}
reader.hasReadEntries = true;
successCallback(retVal);
};
var fail = typeof errorCallback !== 'function' ? null : function (code) {
errorCallback(new FileError(code));
};
exec(win, fail, 'File', 'readEntries', [this.localURL]);
};
module.exports = DirectoryReader;
});
@@ -1,262 +0,0 @@
cordova.define("cordova-plugin-file.Entry", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var argscheck = require('cordova/argscheck');
var exec = require('cordova/exec');
var FileError = require('./FileError');
var Metadata = require('./Metadata');
/**
* Represents a file or directory on the local file system.
*
* @param isFile
* {boolean} true if Entry is a file (readonly)
* @param isDirectory
* {boolean} true if Entry is a directory (readonly)
* @param name
* {DOMString} name of the file or directory, excluding the path
* leading to it (readonly)
* @param fullPath
* {DOMString} the absolute full path to the file or directory
* (readonly)
* @param fileSystem
* {FileSystem} the filesystem on which this entry resides
* (readonly)
* @param nativeURL
* {DOMString} an alternate URL which can be used by native
* webview controls, for example media players.
* (optional, readonly)
*/
function Entry (isFile, isDirectory, name, fullPath, fileSystem, nativeURL) {
this.isFile = !!isFile;
this.isDirectory = !!isDirectory;
this.name = name || '';
this.fullPath = fullPath || '';
this.filesystem = fileSystem || null;
this.nativeURL = nativeURL || null;
}
/**
* Look up the metadata of the entry.
*
* @param successCallback
* {Function} is called with a Metadata object
* @param errorCallback
* {Function} is called with a FileError
*/
Entry.prototype.getMetadata = function (successCallback, errorCallback) {
argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);
var success = successCallback && function (entryMetadata) {
var metadata = new Metadata({
size: entryMetadata.size,
modificationTime: entryMetadata.lastModifiedDate
});
successCallback(metadata);
};
var fail = errorCallback && function (code) {
errorCallback(new FileError(code));
};
exec(success, fail, 'File', 'getFileMetadata', [this.toInternalURL()]);
};
/**
* Set the metadata of the entry.
*
* @param successCallback
* {Function} is called with a Metadata object
* @param errorCallback
* {Function} is called with a FileError
* @param metadataObject
* {Object} keys and values to set
*/
Entry.prototype.setMetadata = function (successCallback, errorCallback, metadataObject) {
argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
exec(successCallback, errorCallback, 'File', 'setMetadata', [this.toInternalURL(), metadataObject]);
};
/**
* Move a file or directory to a new location.
*
* @param parent
* {DirectoryEntry} the directory to which to move this entry
* @param newName
* {DOMString} new name of the entry, defaults to the current name
* @param successCallback
* {Function} called with the new DirectoryEntry object
* @param errorCallback
* {Function} called with a FileError
*/
Entry.prototype.moveTo = function (parent, newName, successCallback, errorCallback) {
argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
var fail = errorCallback && function (code) {
errorCallback(new FileError(code));
};
var srcURL = this.toInternalURL();
// entry name
var name = newName || this.name;
var success = function (entry) {
if (entry) {
if (successCallback) {
// create appropriate Entry object
var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name);
var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef
var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL);
successCallback(result);
}
} else {
// no Entry object returned
if (fail) {
fail(FileError.NOT_FOUND_ERR);
}
}
};
// copy
exec(success, fail, 'File', 'moveTo', [srcURL, parent.toInternalURL(), name]);
};
/**
* Copy a directory to a different location.
*
* @param parent
* {DirectoryEntry} the directory to which to copy the entry
* @param newName
* {DOMString} new name of the entry, defaults to the current name
* @param successCallback
* {Function} called with the new Entry object
* @param errorCallback
* {Function} called with a FileError
*/
Entry.prototype.copyTo = function (parent, newName, successCallback, errorCallback) {
argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
var fail = errorCallback && function (code) {
errorCallback(new FileError(code));
};
var srcURL = this.toInternalURL();
// entry name
var name = newName || this.name;
// success callback
var success = function (entry) {
if (entry) {
if (successCallback) {
// create appropriate Entry object
var newFSName = entry.filesystemName || (entry.filesystem && entry.filesystem.name);
var fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' }); // eslint-disable-line no-undef
var result = (entry.isDirectory) ? new (require('./DirectoryEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL) : new (require('cordova-plugin-file.FileEntry'))(entry.name, entry.fullPath, fs, entry.nativeURL);
successCallback(result);
}
} else {
// no Entry object returned
if (fail) {
fail(FileError.NOT_FOUND_ERR);
}
}
};
// copy
exec(success, fail, 'File', 'copyTo', [srcURL, parent.toInternalURL(), name]);
};
/**
* Return a URL that can be passed across the bridge to identify this entry.
*/
Entry.prototype.toInternalURL = function () {
if (this.filesystem && this.filesystem.__format__) {
return this.filesystem.__format__(this.fullPath, this.nativeURL);
}
};
/**
* Return a URL that can be used to identify this entry.
* Use a URL that can be used to as the src attribute of a <video> or
* <audio> tag. If that is not possible, construct a cdvfile:// URL.
*/
Entry.prototype.toURL = function () {
if (this.nativeURL) {
return this.nativeURL;
}
// fullPath attribute may contain the full URL in the case that
// toInternalURL fails.
return this.toInternalURL() || 'file://localhost' + this.fullPath;
};
/**
* Backwards-compatibility: In v1.0.0 - 1.0.2, .toURL would only return a
* cdvfile:// URL, and this method was necessary to obtain URLs usable by the
* webview.
* See CB-6051, CB-6106, CB-6117, CB-6152, CB-6199, CB-6201, CB-6243, CB-6249,
* and CB-6300.
*/
Entry.prototype.toNativeURL = function () {
console.log("DEPRECATED: Update your code to use 'toURL'");
return this.toURL();
};
/**
* Returns a URI that can be used to identify this entry.
*
* @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
* @return uri
*/
Entry.prototype.toURI = function (mimeType) {
console.log("DEPRECATED: Update your code to use 'toURL'");
return this.toURL();
};
/**
* Remove a file or directory. It is an error to attempt to delete a
* directory that is not empty. It is an error to attempt to delete a
* root directory of a file system.
*
* @param successCallback {Function} called with no parameters
* @param errorCallback {Function} called with a FileError
*/
Entry.prototype.remove = function (successCallback, errorCallback) {
argscheck.checkArgs('FF', 'Entry.remove', arguments);
var fail = errorCallback && function (code) {
errorCallback(new FileError(code));
};
exec(successCallback, fail, 'File', 'remove', [this.toInternalURL()]);
};
/**
* Look up the parent DirectoryEntry of this entry.
*
* @param successCallback {Function} called with the parent DirectoryEntry object
* @param errorCallback {Function} called with a FileError
*/
Entry.prototype.getParent = function (successCallback, errorCallback) {
argscheck.checkArgs('FF', 'Entry.getParent', arguments);
var fs = this.filesystem;
var win = successCallback && function (result) {
var DirectoryEntry = require('./DirectoryEntry');
var entry = new DirectoryEntry(result.name, result.fullPath, fs, result.nativeURL);
successCallback(entry);
};
var fail = errorCallback && function (code) {
errorCallback(new FileError(code));
};
exec(win, fail, 'File', 'getParent', [this.toInternalURL()]);
};
module.exports = Entry;
});
@@ -1,80 +0,0 @@
cordova.define("cordova-plugin-file.File", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* Constructor.
* name {DOMString} name of the file, without path information
* fullPath {DOMString} the full path of the file, including the name
* type {DOMString} mime type
* lastModifiedDate {Date} last modified date
* size {Number} size of the file in bytes
*/
var File = function (name, localURL, type, lastModifiedDate, size) {
this.name = name || '';
this.localURL = localURL || null;
this.type = type || null;
this.lastModified = lastModifiedDate || null;
// For backwards compatibility, store the timestamp in lastModifiedDate as well
this.lastModifiedDate = lastModifiedDate || null;
this.size = size || 0;
// These store the absolute start and end for slicing the file.
this.start = 0;
this.end = this.size;
};
/**
* Returns a "slice" of the file. Since Cordova Files don't contain the actual
* content, this really returns a File with adjusted start and end.
* Slices of slices are supported.
* start {Number} The index at which to start the slice (inclusive).
* end {Number} The index at which to end the slice (exclusive).
*/
File.prototype.slice = function (start, end) {
var size = this.end - this.start;
var newStart = 0;
var newEnd = size;
if (arguments.length) {
if (start < 0) {
newStart = Math.max(size + start, 0);
} else {
newStart = Math.min(size, start);
}
}
if (arguments.length >= 2) {
if (end < 0) {
newEnd = Math.max(size + end, 0);
} else {
newEnd = Math.min(end, size);
}
}
var newFile = new File(this.name, this.localURL, this.type, this.lastModified, this.size);
newFile.start = this.start + newStart;
newFile.end = this.start + newEnd;
return newFile;
};
module.exports = File;
});
@@ -1,94 +0,0 @@
cordova.define("cordova-plugin-file.FileEntry", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var utils = require('cordova/utils');
var exec = require('cordova/exec');
var Entry = require('./Entry');
var FileWriter = require('./FileWriter');
var File = require('./File');
var FileError = require('./FileError');
/**
* An interface representing a file on the file system.
*
* {boolean} isFile always true (readonly)
* {boolean} isDirectory always false (readonly)
* {DOMString} name of the file, excluding the path leading to it (readonly)
* {DOMString} fullPath the absolute full path to the file (readonly)
* {FileSystem} filesystem on which the file resides (readonly)
*/
var FileEntry = function (name, fullPath, fileSystem, nativeURL) {
// remove trailing slash if it is present
if (fullPath && /\/$/.test(fullPath)) {
fullPath = fullPath.substring(0, fullPath.length - 1);
}
if (nativeURL && /\/$/.test(nativeURL)) {
nativeURL = nativeURL.substring(0, nativeURL.length - 1);
}
FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath, fileSystem, nativeURL]);
};
utils.extend(FileEntry, Entry);
/**
* Creates a new FileWriter associated with the file that this FileEntry represents.
*
* @param {Function} successCallback is called with the new FileWriter
* @param {Function} errorCallback is called with a FileError
*/
FileEntry.prototype.createWriter = function (successCallback, errorCallback) {
this.file(function (filePointer) {
var writer = new FileWriter(filePointer);
if (writer.localURL === null || writer.localURL === '') {
if (errorCallback) {
errorCallback(new FileError(FileError.INVALID_STATE_ERR));
}
} else {
if (successCallback) {
successCallback(writer);
}
}
}, errorCallback);
};
/**
* Returns a File that represents the current state of the file that this FileEntry represents.
*
* @param {Function} successCallback is called with the new File object
* @param {Function} errorCallback is called with a FileError
*/
FileEntry.prototype.file = function (successCallback, errorCallback) {
var localURL = this.toInternalURL();
var win = successCallback && function (f) {
var file = new File(f.name, localURL, f.type, f.lastModifiedDate, f.size);
successCallback(file);
};
var fail = errorCallback && function (code) {
errorCallback(new FileError(code));
};
exec(win, fail, 'File', 'getFileMetadata', [localURL]);
};
module.exports = FileEntry;
});
@@ -1,48 +0,0 @@
cordova.define("cordova-plugin-file.FileError", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* FileError
*/
function FileError (error) {
this.code = error || null;
}
// File error codes
// Found in DOMException
FileError.NOT_FOUND_ERR = 1;
FileError.SECURITY_ERR = 2;
FileError.ABORT_ERR = 3;
// Added by File API specification
FileError.NOT_READABLE_ERR = 4;
FileError.ENCODING_ERR = 5;
FileError.NO_MODIFICATION_ALLOWED_ERR = 6;
FileError.INVALID_STATE_ERR = 7;
FileError.SYNTAX_ERR = 8;
FileError.INVALID_MODIFICATION_ERR = 9;
FileError.QUOTA_EXCEEDED_ERR = 10;
FileError.TYPE_MISMATCH_ERR = 11;
FileError.PATH_EXISTS_ERR = 12;
module.exports = FileError;
});
@@ -1,300 +0,0 @@
cordova.define("cordova-plugin-file.FileReader", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var exec = require('cordova/exec');
var modulemapper = require('cordova/modulemapper');
var utils = require('cordova/utils');
var FileError = require('./FileError');
var ProgressEvent = require('./ProgressEvent');
var origFileReader = modulemapper.getOriginalSymbol(window, 'FileReader');
/**
* This class reads the mobile device file system.
*
* For Android:
* The root directory is the root of the file system.
* To read from the SD card, the file name is "sdcard/my_file.txt"
* @constructor
*/
var FileReader = function () {
this._readyState = 0;
this._error = null;
this._result = null;
this._progress = null;
this._localURL = '';
this._realReader = origFileReader ? new origFileReader() : {}; // eslint-disable-line new-cap
};
/**
* Defines the maximum size to read at a time via the native API. The default value is a compromise between
* minimizing the overhead of many exec() calls while still reporting progress frequently enough for large files.
* (Note attempts to allocate more than a few MB of contiguous memory on the native side are likely to cause
* OOM exceptions, while the JS engine seems to have fewer problems managing large strings or ArrayBuffers.)
*/
FileReader.READ_CHUNK_SIZE = 256 * 1024;
// States
FileReader.EMPTY = 0;
FileReader.LOADING = 1;
FileReader.DONE = 2;
utils.defineGetter(FileReader.prototype, 'readyState', function () {
return this._localURL ? this._readyState : this._realReader.readyState;
});
utils.defineGetter(FileReader.prototype, 'error', function () {
return this._localURL ? this._error : this._realReader.error;
});
utils.defineGetter(FileReader.prototype, 'result', function () {
return this._localURL ? this._result : this._realReader.result;
});
function defineEvent (eventName) {
utils.defineGetterSetter(FileReader.prototype, eventName, function () {
return this._realReader[eventName] || null;
}, function (value) {
this._realReader[eventName] = value;
});
}
defineEvent('onloadstart'); // When the read starts.
defineEvent('onprogress'); // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)
defineEvent('onload'); // When the read has successfully completed.
defineEvent('onerror'); // When the read has failed (see errors).
defineEvent('onloadend'); // When the request has completed (either in success or failure).
defineEvent('onabort'); // When the read has been aborted. For instance, by invoking the abort() method.
function initRead (reader, file) {
// Already loading something
if (reader.readyState === FileReader.LOADING) {
throw new FileError(FileError.INVALID_STATE_ERR);
}
reader._result = null;
reader._error = null;
reader._progress = 0;
reader._readyState = FileReader.LOADING;
if (typeof file.localURL === 'string') {
reader._localURL = file.localURL;
} else {
reader._localURL = '';
return true;
}
if (reader.onloadstart) {
reader.onloadstart(new ProgressEvent('loadstart', {target: reader}));
}
}
/**
* Callback used by the following read* functions to handle incremental or final success.
* Must be bound to the FileReader's this along with all but the last parameter,
* e.g. readSuccessCallback.bind(this, "readAsText", "UTF-8", offset, totalSize, accumulate)
* @param readType The name of the read function to call.
* @param encoding Text encoding, or null if this is not a text type read.
* @param offset Starting offset of the read.
* @param totalSize Total number of bytes or chars to read.
* @param accumulate A function that takes the callback result and accumulates it in this._result.
* @param r Callback result returned by the last read exec() call, or null to begin reading.
*/
function readSuccessCallback (readType, encoding, offset, totalSize, accumulate, r) {
if (this._readyState === FileReader.DONE) {
return;
}
var CHUNK_SIZE = FileReader.READ_CHUNK_SIZE;
if (readType === 'readAsDataURL') {
// Windows proxy does not support reading file slices as Data URLs
// so read the whole file at once.
CHUNK_SIZE = cordova.platformId === 'windows' ? totalSize : // eslint-disable-line no-undef
// Calculate new chunk size for data URLs to be multiply of 3
// Otherwise concatenated base64 chunks won't be valid base64 data
FileReader.READ_CHUNK_SIZE - (FileReader.READ_CHUNK_SIZE % 3) + 3;
}
if (typeof r !== 'undefined') {
accumulate(r);
this._progress = Math.min(this._progress + CHUNK_SIZE, totalSize);
if (typeof this.onprogress === 'function') {
this.onprogress(new ProgressEvent('progress', {loaded: this._progress, total: totalSize}));
}
}
if (typeof r === 'undefined' || this._progress < totalSize) {
var execArgs = [
this._localURL,
offset + this._progress,
offset + this._progress + Math.min(totalSize - this._progress, CHUNK_SIZE)];
if (encoding) {
execArgs.splice(1, 0, encoding);
}
exec(
readSuccessCallback.bind(this, readType, encoding, offset, totalSize, accumulate),
readFailureCallback.bind(this),
'File', readType, execArgs);
} else {
this._readyState = FileReader.DONE;
if (typeof this.onload === 'function') {
this.onload(new ProgressEvent('load', {target: this}));
}
if (typeof this.onloadend === 'function') {
this.onloadend(new ProgressEvent('loadend', {target: this}));
}
}
}
/**
* Callback used by the following read* functions to handle errors.
* Must be bound to the FileReader's this, e.g. readFailureCallback.bind(this)
*/
function readFailureCallback (e) {
if (this._readyState === FileReader.DONE) {
return;
}
this._readyState = FileReader.DONE;
this._result = null;
this._error = new FileError(e);
if (typeof this.onerror === 'function') {
this.onerror(new ProgressEvent('error', {target: this}));
}
if (typeof this.onloadend === 'function') {
this.onloadend(new ProgressEvent('loadend', {target: this}));
}
}
/**
* Abort reading file.
*/
FileReader.prototype.abort = function () {
if (origFileReader && !this._localURL) {
return this._realReader.abort();
}
this._result = null;
if (this._readyState === FileReader.DONE || this._readyState === FileReader.EMPTY) {
return;
}
this._readyState = FileReader.DONE;
// If abort callback
if (typeof this.onabort === 'function') {
this.onabort(new ProgressEvent('abort', {target: this}));
}
// If load end callback
if (typeof this.onloadend === 'function') {
this.onloadend(new ProgressEvent('loadend', {target: this}));
}
};
/**
* Read text file.
*
* @param file {File} File object containing file properties
* @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)
*/
FileReader.prototype.readAsText = function (file, encoding) {
if (initRead(this, file)) {
return this._realReader.readAsText(file, encoding);
}
// Default encoding is UTF-8
var enc = encoding || 'UTF-8';
var totalSize = file.end - file.start;
readSuccessCallback.bind(this)('readAsText', enc, file.start, totalSize, function (r) {
if (this._progress === 0) {
this._result = '';
}
this._result += r;
}.bind(this));
};
/**
* Read file and return data as a base64 encoded data url.
* A data url is of the form:
* data:[<mediatype>][;base64],<data>
*
* @param file {File} File object containing file properties
*/
FileReader.prototype.readAsDataURL = function (file) {
if (initRead(this, file)) {
return this._realReader.readAsDataURL(file);
}
var totalSize = file.end - file.start;
readSuccessCallback.bind(this)('readAsDataURL', null, file.start, totalSize, function (r) {
var commaIndex = r.indexOf(',');
if (this._progress === 0) {
this._result = r;
} else {
this._result += r.substring(commaIndex + 1);
}
}.bind(this));
};
/**
* Read file and return data as a binary data.
*
* @param file {File} File object containing file properties
*/
FileReader.prototype.readAsBinaryString = function (file) {
if (initRead(this, file)) {
return this._realReader.readAsBinaryString(file);
}
var totalSize = file.end - file.start;
readSuccessCallback.bind(this)('readAsBinaryString', null, file.start, totalSize, function (r) {
if (this._progress === 0) {
this._result = '';
}
this._result += r;
}.bind(this));
};
/**
* Read file and return data as a binary data.
*
* @param file {File} File object containing file properties
*/
FileReader.prototype.readAsArrayBuffer = function (file) {
if (initRead(this, file)) {
return this._realReader.readAsArrayBuffer(file);
}
var totalSize = file.end - file.start;
readSuccessCallback.bind(this)('readAsArrayBuffer', null, file.start, totalSize, function (r) {
var resultArray = (this._progress === 0 ? new Uint8Array(totalSize) : new Uint8Array(this._result));
resultArray.set(new Uint8Array(r), this._progress);
this._result = resultArray.buffer;
}.bind(this));
};
module.exports = FileReader;
});
@@ -1,57 +0,0 @@
cordova.define("cordova-plugin-file.FileSystem", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var DirectoryEntry = require('./DirectoryEntry');
/**
* An interface representing a file system
*
* @constructor
* {DOMString} name the unique name of the file system (readonly)
* {DirectoryEntry} root directory of the file system (readonly)
*/
var FileSystem = function (name, root) {
this.name = name;
if (root) {
this.root = new DirectoryEntry(root.name, root.fullPath, this, root.nativeURL);
} else {
this.root = new DirectoryEntry(this.name, '/', this);
}
};
FileSystem.prototype.__format__ = function (fullPath, nativeUrl) {
return fullPath;
};
FileSystem.prototype.toJSON = function () {
return '<FileSystem: ' + this.name + '>';
};
// Use instead of encodeURI() when encoding just the path part of a URI rather than an entire URI.
FileSystem.encodeURIPath = function (path) {
// Because # is a valid filename character, it must be encoded to prevent part of the
// path from being parsed as a URI fragment.
return encodeURI(path).replace(/#/g, '%23');
};
module.exports = FileSystem;
});
@@ -1,43 +0,0 @@
cordova.define("cordova-plugin-file.FileUploadOptions", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* Options to customize the HTTP request used to upload files.
* @constructor
* @param fileKey {String} Name of file request parameter.
* @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
* @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.
* @param params {Object} Object with key: value params to send to the server.
* @param headers {Object} Keys are header names, values are header values. Multiple
* headers of the same name are not supported.
*/
var FileUploadOptions = function (fileKey, fileName, mimeType, params, headers, httpMethod) {
this.fileKey = fileKey || null;
this.fileName = fileName || null;
this.mimeType = mimeType || null;
this.params = params || null;
this.headers = headers || null;
this.httpMethod = httpMethod || null;
};
module.exports = FileUploadOptions;
});
@@ -1,32 +0,0 @@
cordova.define("cordova-plugin-file.FileUploadResult", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* FileUploadResult
* @constructor
*/
module.exports = function FileUploadResult (size, code, content) {
this.bytesSent = size;
this.responseCode = code;
this.response = content;
};
});
@@ -1,327 +0,0 @@
cordova.define("cordova-plugin-file.FileWriter", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var exec = require('cordova/exec');
var FileError = require('./FileError');
var FileReader = require('./FileReader');
var ProgressEvent = require('./ProgressEvent');
/**
* This class writes to the mobile device file system.
*
* For Android:
* The root directory is the root of the file system.
* To write to the SD card, the file name is "sdcard/my_file.txt"
*
* @constructor
* @param file {File} File object containing file properties
* @param append if true write to the end of the file, otherwise overwrite the file
*/
var FileWriter = function (file) {
this.fileName = '';
this.length = 0;
if (file) {
this.localURL = file.localURL || file;
this.length = file.size || 0;
}
// default is to write at the beginning of the file
this.position = 0;
this.readyState = 0; // EMPTY
this.result = null;
// Error
this.error = null;
// Event handlers
this.onwritestart = null; // When writing starts
this.onprogress = null; // While writing the file, and reporting partial file data
this.onwrite = null; // When the write has successfully completed.
this.onwriteend = null; // When the request has completed (either in success or failure).
this.onabort = null; // When the write has been aborted. For instance, by invoking the abort() method.
this.onerror = null; // When the write has failed (see errors).
};
// States
FileWriter.INIT = 0;
FileWriter.WRITING = 1;
FileWriter.DONE = 2;
/**
* Abort writing file.
*/
FileWriter.prototype.abort = function () {
// check for invalid state
if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
throw new FileError(FileError.INVALID_STATE_ERR);
}
// set error
this.error = new FileError(FileError.ABORT_ERR);
this.readyState = FileWriter.DONE;
// If abort callback
if (typeof this.onabort === 'function') {
this.onabort(new ProgressEvent('abort', {'target': this}));
}
// If write end callback
if (typeof this.onwriteend === 'function') {
this.onwriteend(new ProgressEvent('writeend', {'target': this}));
}
};
/**
* Writes data to the file
*
* @param data text or blob to be written
* @param isPendingBlobReadResult {Boolean} true if the data is the pending blob read operation result
*/
FileWriter.prototype.write = function (data, isPendingBlobReadResult) {
var that = this;
var supportsBinary = (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined');
/* eslint-disable no-undef */
var isProxySupportBlobNatively = (cordova.platformId === 'windows8' || cordova.platformId === 'windows');
var isBinary;
// Check to see if the incoming data is a blob
if (data instanceof File || (!isProxySupportBlobNatively && supportsBinary && data instanceof Blob)) {
var fileReader = new FileReader();
/* eslint-enable no-undef */
fileReader.onload = function () {
// Call this method again, with the arraybuffer as argument
FileWriter.prototype.write.call(that, this.result, true /* isPendingBlobReadResult */);
};
fileReader.onerror = function () {
// DONE state
that.readyState = FileWriter.DONE;
// Save error
that.error = this.error;
// If onerror callback
if (typeof that.onerror === 'function') {
that.onerror(new ProgressEvent('error', {'target': that}));
}
// If onwriteend callback
if (typeof that.onwriteend === 'function') {
that.onwriteend(new ProgressEvent('writeend', {'target': that}));
}
};
// WRITING state
this.readyState = FileWriter.WRITING;
if (supportsBinary) {
fileReader.readAsArrayBuffer(data);
} else {
fileReader.readAsText(data);
}
return;
}
// Mark data type for safer transport over the binary bridge
isBinary = supportsBinary && (data instanceof ArrayBuffer);
if (isBinary && cordova.platformId === 'windowsphone') { // eslint-disable-line no-undef
// create a plain array, using the keys from the Uint8Array view so that we can serialize it
data = Array.apply(null, new Uint8Array(data));
}
// Throw an exception if we are already writing a file
if (this.readyState === FileWriter.WRITING && !isPendingBlobReadResult) {
throw new FileError(FileError.INVALID_STATE_ERR);
}
// WRITING state
this.readyState = FileWriter.WRITING;
var me = this;
// If onwritestart callback
if (typeof me.onwritestart === 'function') {
me.onwritestart(new ProgressEvent('writestart', {'target': me}));
}
// Write file
exec(
// Success callback
function (r) {
// If DONE (cancelled), then don't do anything
if (me.readyState === FileWriter.DONE) {
return;
}
// position always increases by bytes written because file would be extended
me.position += r;
// The length of the file is now where we are done writing.
me.length = me.position;
// DONE state
me.readyState = FileWriter.DONE;
// If onwrite callback
if (typeof me.onwrite === 'function') {
me.onwrite(new ProgressEvent('write', {'target': me}));
}
// If onwriteend callback
if (typeof me.onwriteend === 'function') {
me.onwriteend(new ProgressEvent('writeend', {'target': me}));
}
},
// Error callback
function (e) {
// If DONE (cancelled), then don't do anything
if (me.readyState === FileWriter.DONE) {
return;
}
// DONE state
me.readyState = FileWriter.DONE;
// Save error
me.error = new FileError(e);
// If onerror callback
if (typeof me.onerror === 'function') {
me.onerror(new ProgressEvent('error', {'target': me}));
}
// If onwriteend callback
if (typeof me.onwriteend === 'function') {
me.onwriteend(new ProgressEvent('writeend', {'target': me}));
}
}, 'File', 'write', [this.localURL, data, this.position, isBinary]);
};
/**
* Moves the file pointer to the location specified.
*
* If the offset is a negative number the position of the file
* pointer is rewound. If the offset is greater than the file
* size the position is set to the end of the file.
*
* @param offset is the location to move the file pointer to.
*/
FileWriter.prototype.seek = function (offset) {
// Throw an exception if we are already writing a file
if (this.readyState === FileWriter.WRITING) {
throw new FileError(FileError.INVALID_STATE_ERR);
}
if (!offset && offset !== 0) {
return;
}
// See back from end of file.
if (offset < 0) {
this.position = Math.max(offset + this.length, 0);
// Offset is bigger than file size so set position
// to the end of the file.
} else if (offset > this.length) {
this.position = this.length;
// Offset is between 0 and file size so set the position
// to start writing.
} else {
this.position = offset;
}
};
/**
* Truncates the file to the size specified.
*
* @param size to chop the file at.
*/
FileWriter.prototype.truncate = function (size) {
// Throw an exception if we are already writing a file
if (this.readyState === FileWriter.WRITING) {
throw new FileError(FileError.INVALID_STATE_ERR);
}
// WRITING state
this.readyState = FileWriter.WRITING;
var me = this;
// If onwritestart callback
if (typeof me.onwritestart === 'function') {
me.onwritestart(new ProgressEvent('writestart', {'target': this}));
}
// Write file
exec(
// Success callback
function (r) {
// If DONE (cancelled), then don't do anything
if (me.readyState === FileWriter.DONE) {
return;
}
// DONE state
me.readyState = FileWriter.DONE;
// Update the length of the file
me.length = r;
me.position = Math.min(me.position, r);
// If onwrite callback
if (typeof me.onwrite === 'function') {
me.onwrite(new ProgressEvent('write', {'target': me}));
}
// If onwriteend callback
if (typeof me.onwriteend === 'function') {
me.onwriteend(new ProgressEvent('writeend', {'target': me}));
}
},
// Error callback
function (e) {
// If DONE (cancelled), then don't do anything
if (me.readyState === FileWriter.DONE) {
return;
}
// DONE state
me.readyState = FileWriter.DONE;
// Save error
me.error = new FileError(e);
// If onerror callback
if (typeof me.onerror === 'function') {
me.onerror(new ProgressEvent('error', {'target': me}));
}
// If onwriteend callback
if (typeof me.onwriteend === 'function') {
me.onwriteend(new ProgressEvent('writeend', {'target': me}));
}
}, 'File', 'truncate', [this.localURL, size]);
};
module.exports = FileWriter;
});
@@ -1,38 +0,0 @@
cordova.define("cordova-plugin-file.Flags", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* Supplies arguments to methods that lookup or create files and directories.
*
* @param create
* {boolean} file or directory if it doesn't exist
* @param exclusive
* {boolean} used with create; if true the command will fail if
* target path exists
*/
function Flags (create, exclusive) {
this.create = create || false;
this.exclusive = exclusive || false;
}
module.exports = Flags;
});
@@ -1,25 +0,0 @@
cordova.define("cordova-plugin-file.LocalFileSystem", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
exports.TEMPORARY = 0;
exports.PERSISTENT = 1;
});
@@ -1,42 +0,0 @@
cordova.define("cordova-plugin-file.Metadata", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/**
* Information about the state of the file or directory
*
* {Date} modificationTime (readonly)
*/
var Metadata = function (metadata) {
if (typeof metadata === 'object') {
this.modificationTime = new Date(metadata.modificationTime);
this.size = metadata.size || 0;
} else if (typeof metadata === 'undefined') {
this.modificationTime = null;
this.size = 0;
} else {
/* Backwards compatiblity with platforms that only return a timestamp */
this.modificationTime = new Date(metadata);
}
};
module.exports = Metadata;
});
@@ -1,69 +0,0 @@
cordova.define("cordova-plugin-file.ProgressEvent", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
// Feature test: See if we can instantiate a native ProgressEvent;
// if so, use that approach,
// otherwise fill-in with our own implementation.
//
// NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.
var ProgressEvent = (function () {
/*
var createEvent = function(data) {
var event = document.createEvent('Events');
event.initEvent('ProgressEvent', false, false);
if (data) {
for (var i in data) {
if (data.hasOwnProperty(i)) {
event[i] = data[i];
}
}
if (data.target) {
// TODO: cannot call <some_custom_object>.dispatchEvent
// need to first figure out how to implement EventTarget
}
}
return event;
};
try {
var ev = createEvent({type:"abort",target:document});
return function ProgressEvent(type, data) {
data.type = type;
return createEvent(data);
};
} catch(e){
*/
return function ProgressEvent (type, dict) {
this.type = type;
this.bubbles = false;
this.cancelBubble = false;
this.cancelable = false;
this.lengthComputable = false;
this.loaded = dict && dict.loaded ? dict.loaded : 0;
this.total = dict && dict.total ? dict.total : 0;
this.target = dict && dict.target ? dict.target : null;
};
// }
})();
module.exports = ProgressEvent;
});
@@ -1,50 +0,0 @@
cordova.define("cordova-plugin-file.androidFileSystem", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
FILESYSTEM_PROTOCOL = 'cdvfile'; // eslint-disable-line no-undef
module.exports = {
__format__: function (fullPath, nativeUrl) {
var path;
var contentUrlMatch = /^content:\/\//.exec(nativeUrl);
if (contentUrlMatch) {
// When available, use the path from a native content URL, which was already encoded by Android.
// This is necessary because JavaScript's encodeURI() does not encode as many characters as
// Android, which can result in permission exceptions when the encoding of a content URI
// doesn't match the string for which permission was originally granted.
path = nativeUrl.substring(contentUrlMatch[0].length - 1);
} else {
path = FileSystem.encodeURIPath(fullPath); // eslint-disable-line no-undef
if (!/^\//.test(path)) {
path = '/' + path;
}
var m = /\?.*/.exec(nativeUrl);
if (m) {
path += m[0];
}
}
return FILESYSTEM_PROTOCOL + '://localhost/' + this.name + path; // eslint-disable-line no-undef
}
};
});
@@ -1,28 +0,0 @@
cordova.define("cordova-plugin-file.isChrome", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
module.exports = function () {
// window.webkitRequestFileSystem and window.webkitResolveLocalFileSystemURL are available only in Chrome and
// possibly a good flag to indicate that we're running in Chrome
return window.webkitRequestFileSystem && window.webkitResolveLocalFileSystemURL;
};
});
@@ -1,64 +0,0 @@
cordova.define("cordova-plugin-file.fileSystemPaths", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
var exec = require('cordova/exec');
var channel = require('cordova/channel');
exports.file = {
// Read-only directory where the application is installed.
applicationDirectory: null,
// Root of app's private writable storage
applicationStorageDirectory: null,
// Where to put app-specific data files.
dataDirectory: null,
// Cached files that should survive app restarts.
// Apps should not rely on the OS to delete files in here.
cacheDirectory: null,
// Android: the application space on external storage.
externalApplicationStorageDirectory: null,
// Android: Where to put app-specific data files on external storage.
externalDataDirectory: null,
// Android: the application cache on external storage.
externalCacheDirectory: null,
// Android: the external storage (SD card) root.
externalRootDirectory: null,
// iOS: Temp directory that the OS can clear at will.
tempDirectory: null,
// iOS: Holds app-specific files that should be synced (e.g. to iCloud).
syncedDataDirectory: null,
// iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files)
documentsDirectory: null,
// BlackBerry10: Files globally available to all apps
sharedDirectory: null
};
channel.waitForInitialization('onFileSystemPathsReady');
channel.onCordovaReady.subscribe(function () {
function after (paths) {
for (var k in paths) {
exports.file[k] = paths[k];
}
channel.initializationComplete('onFileSystemPathsReady');
}
exec(after, null, 'File', 'requestAllPaths', []);
});
});
@@ -1,48 +0,0 @@
cordova.define("cordova-plugin-file.fileSystems-roots", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
// Map of fsName -> FileSystem.
var fsMap = null;
var FileSystem = require('./FileSystem');
var exec = require('cordova/exec');
// Overridden by Android, BlackBerry 10 and iOS to populate fsMap.
require('./fileSystems').getFs = function (name, callback) {
function success (response) {
fsMap = {};
for (var i = 0; i < response.length; ++i) {
var fsRoot = response[i];
if (fsRoot) {
var fs = new FileSystem(fsRoot.filesystemName, fsRoot);
fsMap[fs.name] = fs;
}
}
callback(fsMap[name]);
}
if (fsMap) {
callback(fsMap[name]);
} else {
exec(success, null, 'File', 'requestAllFileSystems', []);
}
};
});
@@ -1,27 +0,0 @@
cordova.define("cordova-plugin-file.fileSystems", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
// Overridden by Android, BlackBerry 10 and iOS to populate fsMap.
module.exports.getFs = function (name, callback) {
callback(null);
};
});
@@ -1,83 +0,0 @@
cordova.define("cordova-plugin-file.requestFileSystem", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
(function () {
// For browser platform: not all browsers use this file.
function checkBrowser () {
if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef
module.exports = window.requestFileSystem || window.webkitRequestFileSystem;
return true;
}
return false;
}
if (checkBrowser()) {
return;
}
var argscheck = require('cordova/argscheck');
var FileError = require('./FileError');
var FileSystem = require('./FileSystem');
var exec = require('cordova/exec');
var fileSystems = require('./fileSystems');
/**
* Request a file system in which to store application data.
* @param type local file system type
* @param size indicates how much storage space, in bytes, the application expects to need
* @param successCallback invoked with a FileSystem object
* @param errorCallback invoked if error occurs retrieving file system
*/
var requestFileSystem = function (type, size, successCallback, errorCallback) {
argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);
var fail = function (code) {
if (errorCallback) {
errorCallback(new FileError(code));
}
};
if (type < 0) {
fail(FileError.SYNTAX_ERR);
} else {
// if successful, return a FileSystem object
var success = function (file_system) {
if (file_system) {
if (successCallback) {
fileSystems.getFs(file_system.name, function (fs) {
// This should happen only on platforms that haven't implemented requestAllFileSystems (windows)
if (!fs) {
fs = new FileSystem(file_system.name, file_system.root);
}
successCallback(fs);
});
}
} else {
// no FileSystem object returned
fail(FileError.NOT_FOUND_ERR);
}
};
exec(success, fail, 'File', 'requestFileSystem', [type, size]);
}
};
module.exports = requestFileSystem;
})();
});
@@ -1,93 +0,0 @@
cordova.define("cordova-plugin-file.resolveLocalFileSystemURI", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
(function () {
// For browser platform: not all browsers use overrided `resolveLocalFileSystemURL`.
function checkBrowser () {
if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef
module.exports.resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;
return true;
}
return false;
}
if (checkBrowser()) {
return;
}
var argscheck = require('cordova/argscheck');
var DirectoryEntry = require('./DirectoryEntry');
var FileEntry = require('./FileEntry');
var FileError = require('./FileError');
var exec = require('cordova/exec');
var fileSystems = require('./fileSystems');
/**
* Look up file system Entry referred to by local URI.
* @param {DOMString} uri URI referring to a local file or directory
* @param successCallback invoked with Entry object corresponding to URI
* @param errorCallback invoked if error occurs retrieving file system entry
*/
module.exports.resolveLocalFileSystemURL = module.exports.resolveLocalFileSystemURL || function (uri, successCallback, errorCallback) {
argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);
// error callback
var fail = function (error) {
if (errorCallback) {
errorCallback(new FileError(error));
}
};
// sanity check for 'not:valid:filename' or '/not:valid:filename'
// file.spec.12 window.resolveLocalFileSystemURI should error (ENCODING_ERR) when resolving invalid URI with leading /.
if (!uri || uri.split(':').length > 2) {
setTimeout(function () {
fail(FileError.ENCODING_ERR);
}, 0);
return;
}
// if successful, return either a file or directory entry
var success = function (entry) {
if (entry) {
if (successCallback) {
// create appropriate Entry object
var fsName = entry.filesystemName || (entry.filesystem && entry.filesystem.name) || (entry.filesystem === window.PERSISTENT ? 'persistent' : 'temporary'); // eslint-disable-line no-undef
fileSystems.getFs(fsName, function (fs) {
// This should happen only on platforms that haven't implemented requestAllFileSystems (windows)
if (!fs) {
fs = new FileSystem(fsName, {name: '', fullPath: '/'}); // eslint-disable-line no-undef
}
var result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath, fs, entry.nativeURL) : new FileEntry(entry.name, entry.fullPath, fs, entry.nativeURL);
successCallback(result);
});
}
} else {
// no Entry object returned
fail(FileError.NOT_FOUND_ERR);
}
};
exec(success, fail, 'File', 'resolveLocalFileSystemURI', [uri]);
};
module.exports.resolveLocalFileSystemURI = function () {
console.log('resolveLocalFileSystemURI is deprecated. Please call resolveLocalFileSystemURL instead.');
module.exports.resolveLocalFileSystemURL.apply(this, arguments);
};
})();
});
@@ -1,16 +0,0 @@
cordova.define("cordova-plugin-filepath.FilePath", function(require, exports, module) {
var exec = require('cordova/exec');
module.exports = {
/**
* Resolve native path for given content URL/path.
* @param {String} path Content URL/path.
* @param successCallback invoked with a native filesystem path string
* @param errorCallback invoked if error occurs
*/
resolveNativePath: function(path, successCallback, errorCallback) {
exec(successCallback, errorCallback, "FilePath", "resolveNativePath", [path]);
}
};
});
@@ -1,121 +0,0 @@
cordova.define("cordova-plugin-inappbrowser.inappbrowser", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
(function () {
var exec = require('cordova/exec');
var channel = require('cordova/channel');
var modulemapper = require('cordova/modulemapper');
var urlutil = require('cordova/urlutil');
function InAppBrowser () {
this.channels = {
'beforeload': channel.create('beforeload'),
'loadstart': channel.create('loadstart'),
'loadstop': channel.create('loadstop'),
'loaderror': channel.create('loaderror'),
'exit': channel.create('exit'),
'customscheme': channel.create('customscheme'),
'message': channel.create('message')
};
}
InAppBrowser.prototype = {
_eventHandler: function (event) {
if (event && (event.type in this.channels)) {
if (event.type === 'beforeload') {
this.channels[event.type].fire(event, this._loadAfterBeforeload);
} else {
this.channels[event.type].fire(event);
}
}
},
_loadAfterBeforeload: function (strUrl) {
strUrl = urlutil.makeAbsolute(strUrl);
exec(null, null, 'InAppBrowser', 'loadAfterBeforeload', [strUrl]);
},
close: function (eventname) {
exec(null, null, 'InAppBrowser', 'close', []);
},
show: function (eventname) {
exec(null, null, 'InAppBrowser', 'show', []);
},
hide: function (eventname) {
exec(null, null, 'InAppBrowser', 'hide', []);
},
addEventListener: function (eventname, f) {
if (eventname in this.channels) {
this.channels[eventname].subscribe(f);
}
},
removeEventListener: function (eventname, f) {
if (eventname in this.channels) {
this.channels[eventname].unsubscribe(f);
}
},
executeScript: function (injectDetails, cb) {
if (injectDetails.code) {
exec(cb, null, 'InAppBrowser', 'injectScriptCode', [injectDetails.code, !!cb]);
} else if (injectDetails.file) {
exec(cb, null, 'InAppBrowser', 'injectScriptFile', [injectDetails.file, !!cb]);
} else {
throw new Error('executeScript requires exactly one of code or file to be specified');
}
},
insertCSS: function (injectDetails, cb) {
if (injectDetails.code) {
exec(cb, null, 'InAppBrowser', 'injectStyleCode', [injectDetails.code, !!cb]);
} else if (injectDetails.file) {
exec(cb, null, 'InAppBrowser', 'injectStyleFile', [injectDetails.file, !!cb]);
} else {
throw new Error('insertCSS requires exactly one of code or file to be specified');
}
}
};
module.exports = function (strUrl, strWindowName, strWindowFeatures, callbacks) {
// Don't catch calls that write to existing frames (e.g. named iframes).
if (window.frames && window.frames[strWindowName]) {
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
return origOpenFunc.apply(window, arguments);
}
strUrl = urlutil.makeAbsolute(strUrl);
var iab = new InAppBrowser();
callbacks = callbacks || {};
for (var callbackName in callbacks) {
iab.addEventListener(callbackName, callbacks[callbackName]);
}
var cb = function (eventname) {
iab._eventHandler(eventname);
};
strWindowFeatures = strWindowFeatures || '';
exec(cb, cb, 'InAppBrowser', 'open', [strUrl, strWindowName, strWindowFeatures]);
return iab;
};
})();
});
@@ -1,115 +0,0 @@
cordova.define("cordova-plugin-statusbar.statusbar", function(require, exports, module) {
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/* global cordova */
var exec = require('cordova/exec');
var namedColors = {
"black": "#000000",
"darkGray": "#A9A9A9",
"lightGray": "#D3D3D3",
"white": "#FFFFFF",
"gray": "#808080",
"red": "#FF0000",
"green": "#00FF00",
"blue": "#0000FF",
"cyan": "#00FFFF",
"yellow": "#FFFF00",
"magenta": "#FF00FF",
"orange": "#FFA500",
"purple": "#800080",
"brown": "#A52A2A"
};
var StatusBar = {
isVisible: true,
overlaysWebView: function (doOverlay) {
exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
},
styleDefault: function () {
// dark text ( to be used on a light background )
exec(null, null, "StatusBar", "styleDefault", []);
},
styleLightContent: function () {
// light text ( to be used on a dark background )
exec(null, null, "StatusBar", "styleLightContent", []);
},
styleBlackTranslucent: function () {
// #88000000 ? Apple says to use lightContent instead
exec(null, null, "StatusBar", "styleBlackTranslucent", []);
},
styleBlackOpaque: function () {
// #FF000000 ? Apple says to use lightContent instead
exec(null, null, "StatusBar", "styleBlackOpaque", []);
},
backgroundColorByName: function (colorname) {
return StatusBar.backgroundColorByHexString(namedColors[colorname]);
},
backgroundColorByHexString: function (hexString) {
if (hexString.charAt(0) !== "#") {
hexString = "#" + hexString;
}
if (hexString.length === 4) {
var split = hexString.split("");
hexString = "#" + split[1] + split[1] + split[2] + split[2] + split[3] + split[3];
}
exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
},
hide: function () {
exec(null, null, "StatusBar", "hide", []);
StatusBar.isVisible = false;
},
show: function () {
exec(null, null, "StatusBar", "show", []);
StatusBar.isVisible = true;
}
};
// prime it. setTimeout so that proxy gets time to init
window.setTimeout(function () {
exec(function (res) {
if (typeof res == 'object') {
if (res.type == 'tap') {
cordova.fireWindowEvent('statusTap');
}
} else {
StatusBar.isVisible = res;
}
}, null, "StatusBar", "_ready", []);
}, 0);
module.exports = StatusBar;
});
@@ -1,918 +0,0 @@
cordova.define("cordova-sqlite-storage.SQLitePlugin", function(require, exports, module) {
(function() {
var DB_STATE_INIT, DB_STATE_OPEN, READ_ONLY_REGEX, SQLiteFactory, SQLitePlugin, SQLitePluginTransaction, SelfTest, argsArray, dblocations, iosLocationMap, newSQLError, nextTick, root, txLocks;
root = this;
READ_ONLY_REGEX = /^(\s|;)*(?:alter|create|delete|drop|insert|reindex|replace|update)/i;
DB_STATE_INIT = "INIT";
DB_STATE_OPEN = "OPEN";
txLocks = {};
newSQLError = function(error, code) {
var sqlError;
sqlError = error;
if (!code) {
code = 0;
}
if (!sqlError) {
sqlError = new Error("a plugin had an error but provided no response");
sqlError.code = code;
}
if (typeof sqlError === "string") {
sqlError = new Error(error);
sqlError.code = code;
}
if (!sqlError.code && sqlError.message) {
sqlError.code = code;
}
if (!sqlError.code && !sqlError.message) {
sqlError = new Error("an unknown error was returned: " + JSON.stringify(sqlError));
sqlError.code = code;
}
return sqlError;
};
nextTick = window.setImmediate || function(fun) {
window.setTimeout(fun, 0);
};
/*
Utility that avoids leaking the arguments object. See
https://www.npmjs.org/package/argsarray
*/
argsArray = function(fun) {
return function() {
var args, i, len;
len = arguments.length;
if (len) {
args = [];
i = -1;
while (++i < len) {
args[i] = arguments[i];
}
return fun.call(this, args);
} else {
return fun.call(this, []);
}
};
};
SQLitePlugin = function(openargs, openSuccess, openError) {
var dbname;
if (!(openargs && openargs['name'])) {
throw newSQLError("Cannot create a SQLitePlugin db instance without a db name");
}
dbname = openargs.name;
if (typeof dbname !== 'string') {
throw newSQLError('sqlite plugin database name must be a string');
}
this.openargs = openargs;
this.dbname = dbname;
this.openSuccess = openSuccess;
this.openError = openError;
this.openSuccess || (this.openSuccess = function() {
console.log("DB opened: " + dbname);
});
this.openError || (this.openError = function(e) {
console.log(e.message);
});
this.open(this.openSuccess, this.openError);
};
SQLitePlugin.prototype.databaseFeatures = {
isSQLitePluginDatabase: true
};
SQLitePlugin.prototype.openDBs = {};
SQLitePlugin.prototype.addTransaction = function(t) {
if (!txLocks[this.dbname]) {
txLocks[this.dbname] = {
queue: [],
inProgress: false
};
}
txLocks[this.dbname].queue.push(t);
if (this.dbname in this.openDBs && this.openDBs[this.dbname] !== DB_STATE_INIT) {
this.startNextTransaction();
} else {
if (this.dbname in this.openDBs) {
console.log('new transaction is queued, waiting for open operation to finish');
} else {
console.log('database is closed, new transaction is [stuck] waiting until db is opened again!');
}
}
};
SQLitePlugin.prototype.transaction = function(fn, error, success) {
if (!this.openDBs[this.dbname]) {
error(newSQLError('database not open'));
return;
}
this.addTransaction(new SQLitePluginTransaction(this, fn, error, success, true, false));
};
SQLitePlugin.prototype.readTransaction = function(fn, error, success) {
if (!this.openDBs[this.dbname]) {
error(newSQLError('database not open'));
return;
}
this.addTransaction(new SQLitePluginTransaction(this, fn, error, success, false, true));
};
SQLitePlugin.prototype.startNextTransaction = function() {
var self;
self = this;
nextTick((function(_this) {
return function() {
var txLock;
if (!(_this.dbname in _this.openDBs) || _this.openDBs[_this.dbname] !== DB_STATE_OPEN) {
console.log('cannot start next transaction: database not open');
return;
}
txLock = txLocks[self.dbname];
if (!txLock) {
console.log('cannot start next transaction: database connection is lost');
return;
} else if (txLock.queue.length > 0 && !txLock.inProgress) {
txLock.inProgress = true;
txLock.queue.shift().start();
}
};
})(this));
};
SQLitePlugin.prototype.abortAllPendingTransactions = function() {
var j, len1, ref, tx, txLock;
txLock = txLocks[this.dbname];
if (!!txLock && txLock.queue.length > 0) {
ref = txLock.queue;
for (j = 0, len1 = ref.length; j < len1; j++) {
tx = ref[j];
tx.abortFromQ(newSQLError('Invalid database handle'));
}
txLock.queue = [];
txLock.inProgress = false;
}
};
SQLitePlugin.prototype.open = function(success, error) {
var openerrorcb, opensuccesscb, step2;
if (this.dbname in this.openDBs) {
console.log('database already open: ' + this.dbname);
nextTick((function(_this) {
return function() {
success(_this);
};
})(this));
} else {
console.log('OPEN database: ' + this.dbname);
opensuccesscb = (function(_this) {
return function() {
var txLock;
console.log('OPEN database: ' + _this.dbname + ' - OK');
if (!_this.openDBs[_this.dbname]) {
console.log('database was closed during open operation');
}
if (_this.dbname in _this.openDBs) {
_this.openDBs[_this.dbname] = DB_STATE_OPEN;
}
if (!!success) {
success(_this);
}
txLock = txLocks[_this.dbname];
if (!!txLock && txLock.queue.length > 0 && !txLock.inProgress) {
_this.startNextTransaction();
}
};
})(this);
openerrorcb = (function(_this) {
return function() {
console.log('OPEN database: ' + _this.dbname + ' FAILED, aborting any pending transactions');
if (!!error) {
error(newSQLError('Could not open database'));
}
delete _this.openDBs[_this.dbname];
_this.abortAllPendingTransactions();
};
})(this);
this.openDBs[this.dbname] = DB_STATE_INIT;
step2 = (function(_this) {
return function() {
cordova.exec(opensuccesscb, openerrorcb, "SQLitePlugin", "open", [_this.openargs]);
};
})(this);
cordova.exec(step2, step2, 'SQLitePlugin', 'close', [
{
path: this.dbname
}
]);
}
};
SQLitePlugin.prototype.close = function(success, error) {
if (this.dbname in this.openDBs) {
if (txLocks[this.dbname] && txLocks[this.dbname].inProgress) {
console.log('cannot close: transaction is in progress');
error(newSQLError('database cannot be closed while a transaction is in progress'));
return;
}
console.log('CLOSE database: ' + this.dbname);
delete this.openDBs[this.dbname];
if (txLocks[this.dbname]) {
console.log('closing db with transaction queue length: ' + txLocks[this.dbname].queue.length);
} else {
console.log('closing db with no transaction lock state');
}
cordova.exec(success, error, "SQLitePlugin", "close", [
{
path: this.dbname
}
]);
} else {
console.log('cannot close: database is not open');
if (error) {
nextTick(function() {
return error();
});
}
}
};
SQLitePlugin.prototype.executeSql = function(statement, params, success, error) {
var myerror, myfn, mysuccess;
mysuccess = function(t, r) {
if (!!success) {
return success(r);
}
};
myerror = function(t, e) {
if (!!error) {
return error(e);
}
};
myfn = function(tx) {
tx.addStatement(statement, params, mysuccess, myerror);
};
this.addTransaction(new SQLitePluginTransaction(this, myfn, null, null, false, false));
};
SQLitePlugin.prototype.sqlBatch = function(sqlStatements, success, error) {
var batchList, j, len1, myfn, st;
if (!sqlStatements || sqlStatements.constructor !== Array) {
throw newSQLError('sqlBatch expects an array');
}
batchList = [];
for (j = 0, len1 = sqlStatements.length; j < len1; j++) {
st = sqlStatements[j];
if (st.constructor === Array) {
if (st.length === 0) {
throw newSQLError('sqlBatch array element of zero (0) length');
}
batchList.push({
sql: st[0],
params: st.length === 0 ? [] : st[1]
});
} else {
batchList.push({
sql: st,
params: []
});
}
}
myfn = function(tx) {
var elem, k, len2, results;
results = [];
for (k = 0, len2 = batchList.length; k < len2; k++) {
elem = batchList[k];
results.push(tx.addStatement(elem.sql, elem.params, null, null));
}
return results;
};
this.addTransaction(new SQLitePluginTransaction(this, myfn, error, success, true, false));
};
SQLitePluginTransaction = function(db, fn, error, success, txlock, readOnly) {
if (typeof fn !== "function") {
/*
This is consistent with the implementation in Chrome -- it
throws if you pass anything other than a function. This also
prevents us from stalling our txQueue if somebody passes a
false value for fn.
*/
throw newSQLError("transaction expected a function");
}
this.db = db;
this.fn = fn;
this.error = error;
this.success = success;
this.txlock = txlock;
this.readOnly = readOnly;
this.executes = [];
if (txlock) {
this.addStatement("BEGIN", [], null, function(tx, err) {
throw newSQLError("unable to begin transaction: " + err.message, err.code);
});
} else {
this.addStatement("SELECT 1", [], null, null);
}
};
SQLitePluginTransaction.prototype.start = function() {
var err;
try {
this.fn(this);
this.run();
} catch (error1) {
err = error1;
txLocks[this.db.dbname].inProgress = false;
this.db.startNextTransaction();
if (this.error) {
this.error(newSQLError(err));
}
}
};
SQLitePluginTransaction.prototype.executeSql = function(sql, values, success, error) {
if (this.finalized) {
throw {
message: 'InvalidStateError: DOM Exception 11: This transaction is already finalized. Transactions are committed after its success or failure handlers are called. If you are using a Promise to handle callbacks, be aware that implementations following the A+ standard adhere to run-to-completion semantics and so Promise resolution occurs on a subsequent tick and therefore after the transaction commits.',
code: 11
};
return;
}
if (this.readOnly && READ_ONLY_REGEX.test(sql)) {
this.handleStatementFailure(error, {
message: 'invalid sql for a read-only transaction'
});
return;
}
this.addStatement(sql, values, success, error);
};
SQLitePluginTransaction.prototype.addStatement = function(sql, values, success, error) {
var j, len1, params, sqlStatement, t, v;
sqlStatement = typeof sql === 'string' ? sql : sql.toString();
params = [];
if (!!values && values.constructor === Array) {
for (j = 0, len1 = values.length; j < len1; j++) {
v = values[j];
t = typeof v;
params.push((v === null || v === void 0 ? null : t === 'number' || t === 'string' ? v : v.toString()));
}
}
this.executes.push({
success: success,
error: error,
sql: sqlStatement,
params: params
});
};
SQLitePluginTransaction.prototype.handleStatementSuccess = function(handler, response) {
var payload, rows;
if (!handler) {
return;
}
rows = response.rows || [];
payload = {
rows: {
item: function(i) {
return rows[i];
},
length: rows.length
},
rowsAffected: response.rowsAffected || 0,
insertId: response.insertId || void 0
};
handler(this, payload);
};
SQLitePluginTransaction.prototype.handleStatementFailure = function(handler, response) {
if (!handler) {
throw newSQLError("a statement with no error handler failed: " + response.message, response.code);
}
if (handler(this, response) !== false) {
throw newSQLError("a statement error callback did not return false: " + response.message, response.code);
}
};
SQLitePluginTransaction.prototype.run = function() {
var batchExecutes, handlerFor, i, mycb, mycbmap, request, tropts, tx, txFailure, waiting;
txFailure = null;
tropts = [];
batchExecutes = this.executes;
waiting = batchExecutes.length;
this.executes = [];
tx = this;
handlerFor = function(index, didSucceed) {
return function(response) {
var err;
if (!txFailure) {
try {
if (didSucceed) {
tx.handleStatementSuccess(batchExecutes[index].success, response);
} else {
tx.handleStatementFailure(batchExecutes[index].error, newSQLError(response));
}
} catch (error1) {
err = error1;
txFailure = newSQLError(err);
}
}
if (--waiting === 0) {
if (txFailure) {
tx.executes = [];
tx.abort(txFailure);
} else if (tx.executes.length > 0) {
tx.run();
} else {
tx.finish();
}
}
};
};
mycbmap = {};
i = 0;
while (i < batchExecutes.length) {
request = batchExecutes[i];
mycbmap[i] = {
success: handlerFor(i, true),
error: handlerFor(i, false)
};
tropts.push({
sql: request.sql,
params: request.params
});
i++;
}
mycb = function(result) {
var j, q, r, ref, res, resultIndex, type;
for (resultIndex = j = 0, ref = result.length - 1; 0 <= ref ? j <= ref : j >= ref; resultIndex = 0 <= ref ? ++j : --j) {
r = result[resultIndex];
type = r.type;
res = r.result;
q = mycbmap[resultIndex];
if (q) {
if (q[type]) {
q[type](res);
}
}
}
};
cordova.exec(mycb, null, "SQLitePlugin", "backgroundExecuteSqlBatch", [
{
dbargs: {
dbname: this.db.dbname
},
executes: tropts
}
]);
};
SQLitePluginTransaction.prototype.abort = function(txFailure) {
var failed, succeeded, tx;
if (this.finalized) {
return;
}
tx = this;
succeeded = function(tx) {
txLocks[tx.db.dbname].inProgress = false;
tx.db.startNextTransaction();
if (tx.error && typeof tx.error === 'function') {
tx.error(txFailure);
}
};
failed = function(tx, err) {
txLocks[tx.db.dbname].inProgress = false;
tx.db.startNextTransaction();
if (tx.error && typeof tx.error === 'function') {
tx.error(newSQLError('error while trying to roll back: ' + err.message, err.code));
}
};
this.finalized = true;
if (this.txlock) {
this.addStatement("ROLLBACK", [], succeeded, failed);
this.run();
} else {
succeeded(tx);
}
};
SQLitePluginTransaction.prototype.finish = function() {
var failed, succeeded, tx;
if (this.finalized) {
return;
}
tx = this;
succeeded = function(tx) {
txLocks[tx.db.dbname].inProgress = false;
tx.db.startNextTransaction();
if (tx.success && typeof tx.success === 'function') {
tx.success();
}
};
failed = function(tx, err) {
txLocks[tx.db.dbname].inProgress = false;
tx.db.startNextTransaction();
if (tx.error && typeof tx.error === 'function') {
tx.error(newSQLError('error while trying to commit: ' + err.message, err.code));
}
};
this.finalized = true;
if (this.txlock) {
this.addStatement("COMMIT", [], succeeded, failed);
this.run();
} else {
succeeded(tx);
}
};
SQLitePluginTransaction.prototype.abortFromQ = function(sqlerror) {
if (this.error) {
this.error(sqlerror);
}
};
dblocations = ["docs", "libs", "nosync"];
iosLocationMap = {
'default': 'nosync',
'Documents': 'docs',
'Library': 'libs'
};
SQLiteFactory = {
/*
NOTE: this function should NOT be translated from Javascript
back to CoffeeScript by js2coffee.
If this function is edited in Javascript then someone will
have to translate it back to CoffeeScript by hand.
*/
openDatabase: argsArray(function(args) {
var dblocation, errorcb, okcb, openargs;
if (args.length < 1 || !args[0]) {
throw newSQLError('Sorry missing mandatory open arguments object in openDatabase call');
}
if (args[0].constructor === String) {
throw newSQLError('Sorry first openDatabase argument must be an object');
}
openargs = args[0];
if (!openargs.name) {
throw newSQLError('Database name value is missing in openDatabase call');
}
if (!openargs.iosDatabaseLocation && !openargs.location && openargs.location !== 0) {
throw newSQLError('Database location or iosDatabaseLocation setting is now mandatory in openDatabase call.');
}
if (!!openargs.location && !!openargs.iosDatabaseLocation) {
throw newSQLError('AMBIGUOUS: both location and iosDatabaseLocation settings are present in openDatabase call. Please use either setting, not both.');
}
dblocation = !!openargs.location && openargs.location === 'default' ? iosLocationMap['default'] : !!openargs.iosDatabaseLocation ? iosLocationMap[openargs.iosDatabaseLocation] : dblocations[openargs.location];
if (!dblocation) {
throw newSQLError('Valid iOS database location could not be determined in openDatabase call');
}
openargs.dblocation = dblocation;
if (!!openargs.createFromLocation && openargs.createFromLocation === 1) {
openargs.createFromResource = "1";
}
if (!!openargs.androidDatabaseProvider && !!openargs.androidDatabaseImplementation) {
throw newSQLError('AMBIGUOUS: both androidDatabaseProvider and deprecated androidDatabaseImplementation settings are present in openDatabase call. Please drop androidDatabaseImplementation in favor of androidDatabaseProvider.');
}
if (openargs.androidDatabaseProvider !== void 0 && openargs.androidDatabaseProvider !== 'default' && openargs.androidDatabaseProvider !== 'system') {
throw newSQLError("Incorrect androidDatabaseProvider value. Valid values are: 'default', 'system'");
}
if (!!openargs.androidDatabaseProvider && openargs.androidDatabaseProvider === 'system') {
openargs.androidOldDatabaseImplementation = 1;
}
if (!!openargs.androidDatabaseImplementation && openargs.androidDatabaseImplementation === 2) {
openargs.androidOldDatabaseImplementation = 1;
}
if (!!openargs.androidLockWorkaround && openargs.androidLockWorkaround === 1) {
openargs.androidBugWorkaround = 1;
}
okcb = null;
errorcb = null;
if (args.length >= 2) {
okcb = args[1];
if (args.length > 2) {
errorcb = args[2];
}
}
return new SQLitePlugin(openargs, okcb, errorcb);
}),
deleteDatabase: function(first, success, error) {
var args, dblocation, dbname;
args = {};
if (first.constructor === String) {
throw newSQLError('Sorry first deleteDatabase argument must be an object');
} else {
if (!(first && first['name'])) {
throw new Error("Please specify db name");
}
dbname = first.name;
if (typeof dbname !== 'string') {
throw newSQLError('delete database name must be a string');
}
args.path = dbname;
}
if (!first.iosDatabaseLocation && !first.location && first.location !== 0) {
throw newSQLError('Database location or iosDatabaseLocation setting is now mandatory in deleteDatabase call.');
}
if (!!first.location && !!first.iosDatabaseLocation) {
throw newSQLError('AMBIGUOUS: both location and iosDatabaseLocation settings are present in deleteDatabase call. Please use either setting value, not both.');
}
dblocation = !!first.location && first.location === 'default' ? iosLocationMap['default'] : !!first.iosDatabaseLocation ? iosLocationMap[first.iosDatabaseLocation] : dblocations[first.location];
if (!dblocation) {
throw newSQLError('Valid iOS database location could not be determined in deleteDatabase call');
}
args.dblocation = dblocation;
delete SQLitePlugin.prototype.openDBs[args.path];
return cordova.exec(success, error, "SQLitePlugin", "delete", [args]);
}
};
SelfTest = {
DBNAME: '___$$$___litehelpers___$$$___test___$$$___.db',
start: function(successcb, errorcb) {
SQLiteFactory.deleteDatabase({
name: SelfTest.DBNAME,
location: 'default'
}, (function() {
return SelfTest.step1(successcb, errorcb);
}), (function() {
return SelfTest.step1(successcb, errorcb);
}));
},
step1: function(successcb, errorcb) {
SQLiteFactory.openDatabase({
name: SelfTest.DBNAME,
location: 'default'
}, function(db) {
var check1;
check1 = false;
db.transaction(function(tx) {
tx.executeSql('SELECT UPPER("Test") AS upperText', [], function(ignored, resutSet) {
if (!resutSet.rows) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows');
}
if (!resutSet.rows.length) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows.length');
}
if (resutSet.rows.length !== 1) {
return SelfTest.finishWithError(errorcb, "Incorrect resutSet.rows.length value: " + resutSet.rows.length + " (expected: 1)");
}
if (!resutSet.rows.item(0).upperText) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows.item(0).upperText');
}
if (resutSet.rows.item(0).upperText !== 'TEST') {
return SelfTest.finishWithError(errorcb, "Incorrect resutSet.rows.item(0).upperText value: " + (resutSet.rows.item(0).upperText) + " (expected: 'TEST')");
}
check1 = true;
}, function(ignored, tx_sql_err) {
return SelfTest.finishWithError(errorcb, "TX SQL error: " + tx_sql_err);
});
}, function(tx_err) {
return SelfTest.finishWithError(errorcb, "TRANSACTION error: " + tx_err);
}, function() {
if (!check1) {
return SelfTest.finishWithError(errorcb, 'Did not get expected upperText result data');
}
db.executeSql('BEGIN', null, function(ignored) {
return nextTick(function() {
delete db.openDBs[SelfTest.DBNAME];
delete txLocks[SelfTest.DBNAME];
nextTick(function() {
db.transaction(function(tx2) {
tx2.executeSql('SELECT 1');
}, function(tx_err) {
if (!tx_err) {
return SelfTest.finishWithError(errorcb, 'Missing error object');
}
SelfTest.step2(successcb, errorcb);
}, function() {
return SelfTest.finishWithError(errorcb, 'Missing error object');
});
});
});
});
});
}, function(open_err) {
return SelfTest.finishWithError(errorcb, "Open database error: " + open_err);
});
},
step2: function(successcb, errorcb) {
SQLiteFactory.openDatabase({
name: SelfTest.DBNAME,
location: 'default'
}, function(db) {
db.transaction(function(tx) {
tx.executeSql('SELECT ? AS myResult', [null], function(ignored, resutSet) {
if (!resutSet.rows) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows');
}
if (!resutSet.rows.length) {
return SelfTest.finishWithError(errorcb, 'Missing resutSet.rows.length');
}
if (resutSet.rows.length !== 1) {
return SelfTest.finishWithError(errorcb, "Incorrect resutSet.rows.length value: " + resutSet.rows.length + " (expected: 1)");
}
SelfTest.step3(successcb, errorcb);
});
}, function(txError) {
return SelfTest.finishWithError(errorcb, "UNEXPECTED TRANSACTION ERROR: " + txError);
});
}, function(open_err) {
return SelfTest.finishWithError(errorcb, "Open database error: " + open_err);
});
},
step3: function(successcb, errorcb) {
SQLiteFactory.openDatabase({
name: SelfTest.DBNAME,
location: 'default'
}, function(db) {
return db.sqlBatch(['CREATE TABLE TestTable(id integer primary key autoincrement unique, data);', ['INSERT INTO TestTable (data) VALUES (?);', ['test-value']]], function() {
var firstid;
firstid = -1;
return db.executeSql('SELECT id, data FROM TestTable', [], function(resutSet) {
if (!resutSet.rows) {
SelfTest.finishWithError(errorcb, 'Missing resutSet.rows');
return;
}
if (!resutSet.rows.length) {
SelfTest.finishWithError(errorcb, 'Missing resutSet.rows.length');
return;
}
if (resutSet.rows.length !== 1) {
SelfTest.finishWithError(errorcb, "Incorrect resutSet.rows.length value: " + resutSet.rows.length + " (expected: 1)");
return;
}
if (resutSet.rows.item(0).id === void 0) {
SelfTest.finishWithError(errorcb, 'Missing resutSet.rows.item(0).id');
return;
}
firstid = resutSet.rows.item(0).id;
if (!resutSet.rows.item(0).data) {
SelfTest.finishWithError(errorcb, 'Missing resutSet.rows.item(0).data');
return;
}
if (resutSet.rows.item(0).data !== 'test-value') {
SelfTest.finishWithError(errorcb, "Incorrect resutSet.rows.item(0).data value: " + (resutSet.rows.item(0).data) + " (expected: 'test-value')");
return;
}
return db.transaction(function(tx) {
return tx.executeSql('UPDATE TestTable SET data = ?', ['new-value']);
}, function(tx_err) {
return SelfTest.finishWithError(errorcb, "UPDATE transaction error: " + tx_err);
}, function() {
var readTransactionFinished;
readTransactionFinished = false;
return db.readTransaction(function(tx2) {
return tx2.executeSql('SELECT id, data FROM TestTable', [], function(ignored, resutSet2) {
if (!resutSet2.rows) {
throw newSQLError('Missing resutSet2.rows');
}
if (!resutSet2.rows.length) {
throw newSQLError('Missing resutSet2.rows.length');
}
if (resutSet2.rows.length !== 1) {
throw newSQLError("Incorrect resutSet2.rows.length value: " + resutSet2.rows.length + " (expected: 1)");
}
if (!resutSet2.rows.item(0).id) {
throw newSQLError('Missing resutSet2.rows.item(0).id');
}
if (resutSet2.rows.item(0).id !== firstid) {
throw newSQLError("resutSet2.rows.item(0).id value " + (resutSet2.rows.item(0).id) + " does not match previous primary key id value (" + firstid + ")");
}
if (!resutSet2.rows.item(0).data) {
throw newSQLError('Missing resutSet2.rows.item(0).data');
}
if (resutSet2.rows.item(0).data !== 'new-value') {
throw newSQLError("Incorrect resutSet2.rows.item(0).data value: " + (resutSet2.rows.item(0).data) + " (expected: 'test-value')");
}
return readTransactionFinished = true;
});
}, function(tx2_err) {
return SelfTest.finishWithError(errorcb, "readTransaction error: " + tx2_err);
}, function() {
if (!readTransactionFinished) {
SelfTest.finishWithError(errorcb, 'readTransaction did not finish');
return;
}
return db.transaction(function(tx3) {
tx3.executeSql('DELETE FROM TestTable');
return tx3.executeSql('INSERT INTO TestTable (data) VALUES(?)', [123]);
}, function(tx3_err) {
return SelfTest.finishWithError(errorcb, "DELETE transaction error: " + tx3_err);
}, function() {
var secondReadTransactionFinished;
secondReadTransactionFinished = false;
return db.readTransaction(function(tx4) {
return tx4.executeSql('SELECT id, data FROM TestTable', [], function(ignored, resutSet3) {
if (!resutSet3.rows) {
throw newSQLError('Missing resutSet3.rows');
}
if (!resutSet3.rows.length) {
throw newSQLError('Missing resutSet3.rows.length');
}
if (resutSet3.rows.length !== 1) {
throw newSQLError("Incorrect resutSet3.rows.length value: " + resutSet3.rows.length + " (expected: 1)");
}
if (!resutSet3.rows.item(0).id) {
throw newSQLError('Missing resutSet3.rows.item(0).id');
}
if (resutSet3.rows.item(0).id === firstid) {
throw newSQLError("resutSet3.rows.item(0).id value " + (resutSet3.rows.item(0).id) + " incorrectly matches previous unique key id value value (" + firstid + ")");
}
if (!resutSet3.rows.item(0).data) {
throw newSQLError('Missing resutSet3.rows.item(0).data');
}
if (resutSet3.rows.item(0).data !== 123) {
throw newSQLError("Incorrect resutSet3.rows.item(0).data value: " + (resutSet3.rows.item(0).data) + " (expected 123)");
}
return secondReadTransactionFinished = true;
});
}, function(tx4_err) {
return SelfTest.finishWithError(errorcb, "second readTransaction error: " + tx4_err);
}, function() {
if (!secondReadTransactionFinished) {
SelfTest.finishWithError(errorcb, 'second readTransaction did not finish');
return;
}
db.close(function() {
SelfTest.cleanupAndFinish(successcb, errorcb);
}, function(close_err) {
SelfTest.finishWithError(errorcb, "close error: " + close_err);
});
});
});
});
});
}, function(select_err) {
return SelfTest.finishWithError(errorcb, "SELECT error: " + select_err);
});
}, function(batch_err) {
return SelfTest.finishWithError(errorcb, "sql batch error: " + batch_err);
});
}, function(open_err) {
return SelfTest.finishWithError(errorcb, "Open database error: " + open_err);
});
},
cleanupAndFinish: function(successcb, errorcb) {
SQLiteFactory.deleteDatabase({
name: SelfTest.DBNAME,
location: 'default'
}, successcb, function(cleanup_err) {
SelfTest.finishWithError(errorcb, "CLEANUP DELETE ERROR: " + cleanup_err);
});
},
finishWithError: function(errorcb, message) {
console.log("selfTest ERROR with message: " + message);
SQLiteFactory.deleteDatabase({
name: SelfTest.DBNAME,
location: 'default'
}, function() {
errorcb(newSQLError(message));
}, function(err2) {
console.log("selfTest CLEANUP DELETE ERROR " + err2);
errorcb(newSQLError("CLEANUP DELETE ERROR: " + err2 + " for error: " + message));
});
}
};
root.sqlitePlugin = {
sqliteFeatures: {
isSQLitePlugin: true
},
echoTest: function(okcb, errorcb) {
var error, ok;
ok = function(s) {
if (s === 'test-string') {
return okcb();
} else {
return errorcb("Mismatch: got: '" + s + "' expected 'test-string'");
}
};
error = function(e) {
return errorcb(e);
};
return cordova.exec(ok, error, "SQLitePlugin", "echoStringValue", [
{
value: 'test-string'
}
]);
},
selfTest: SelfTest.start,
openDatabase: SQLiteFactory.openDatabase,
deleteDatabase: SQLiteFactory.deleteDatabase
};
}).call(this);
});
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -88,20 +88,7 @@ let ChatService = class ChatService {
getAllConnectedUsers() {
return this.http.get(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'users.presence', this.options);
}
//Check whether user is online or offline
getUserPresence(id) {
let params = new _angular_common_http__WEBPACK_IMPORTED_MODULE_1__["HttpParams"]();
params = params.set("userId", id);
let opts = {
headers: this.headers,
params: params
};
return this.http.get(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'users.getPresence', opts);
}
//Load messages from roomId
loadJoinedRooms() {
return this.http.get(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'im.list', this.options);
}
getAllDirectMessages() {
return this.http.get(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'im.list', this.options);
}
@@ -216,6 +203,9 @@ let ChatService = class ChatService {
};
return this.http.get(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'groups.info', opts);
}
renameGroup(body) {
return this.http.post(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'groups.rename', body, this.options);
}
};
ChatService.ctorParameters = () => [
{ type: _angular_common_http__WEBPACK_IMPORTED_MODULE_1__["HttpClient"] },
File diff suppressed because one or more lines are too long
@@ -153,25 +153,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
key: "getAllConnectedUsers",
value: function getAllConnectedUsers() {
return this.http.get(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'users.presence', this.options);
} //Check whether user is online or offline
}, {
key: "getUserPresence",
value: function getUserPresence(id) {
var params = new _angular_common_http__WEBPACK_IMPORTED_MODULE_1__["HttpParams"]();
params = params.set("userId", id);
var opts = {
headers: this.headers,
params: params
};
return this.http.get(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'users.getPresence', opts);
} //Load messages from roomId
}, {
key: "loadJoinedRooms",
value: function loadJoinedRooms() {
return this.http.get(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'im.list', this.options);
}
}, {
key: "getAllDirectMessages",
value: function getAllDirectMessages() {
@@ -324,6 +307,11 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
};
return this.http.get(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'groups.info', opts);
}
}, {
key: "renameGroup",
value: function renameGroup(body) {
return this.http.post(src_environments_environment__WEBPACK_IMPORTED_MODULE_6__["environment"].apiChatUrl + 'groups.rename', body, this.options);
}
}]);
return ChatService;
File diff suppressed because one or more lines are too long