You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2022/03/30 08:06:00 UTC
[cordova-plugin-file] branch master updated: chore!: removed old platform code & lint cleanup (#519)
This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-file.git
The following commit(s) were added to refs/heads/master by this push:
new f85373b chore!: removed old platform code & lint cleanup (#519)
f85373b is described below
commit f85373b3251458abc0a7992bf6aa25875d9a7acb
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Wed Mar 30 17:05:55 2022 +0900
chore!: removed old platform code & lint cleanup (#519)
* style: apply lint fix
* test: remove old windows related platform code
* test: remove old blackberry related platform code
* test: remove old amazon-fireos related platform code
* style: remove eslint-disable-line no-undef & add globals
* chore!: remove old windows8 code
* chore!: remove old windowsphone code
---
.eslintrc.yml | 10 ++++++++--
tests/tests.js | 17 ++++++-----------
www/Entry.js | 4 ++--
www/FileReader.js | 2 +-
www/FileWriter.js | 6 +-----
www/android/Entry.js | 12 ++++++------
www/android/FileSystem.js | 2 +-
www/browser/FileSystem.js | 2 +-
www/browser/Preparing.js | 10 +++++-----
www/requestFileSystem.js | 2 +-
www/resolveLocalFileSystemURI.js | 6 +++---
11 files changed, 35 insertions(+), 38 deletions(-)
diff --git a/.eslintrc.yml b/.eslintrc.yml
index b6f153d..781c366 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -2,9 +2,15 @@ root: true
extends: '@cordova/eslint-config/browser'
globals:
cordova: true
+ LocalFileSystem: true
+ FileError: true
+ DirectoryEntry: true
+ FileWriter: true
+ Flags: true
+ Metadata: true
+ FileSystem: true
+ resolveLocalFileSystemURL: true
overrides:
- files: [tests/**/*.js]
extends: '@cordova/eslint-config/node-tests'
- globals:
- cordova: true
diff --git a/tests/tests.js b/tests/tests.js
index b442cd9..c12216d 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -29,7 +29,7 @@ exports.defineAutoTests = function () {
var isIE = isBrowser && (window.msIndexedDB);
var isIndexedDBShim = isBrowser && !isChrome; // Firefox and IE for example
- var isWindows = (cordova.platformId === 'windows' || cordova.platformId === 'windows8');
+ var isWindows = cordova.platformId === 'windows';
/* eslint-enable no-undef */
var MEDIUM_TIMEOUT = 15000;
@@ -417,7 +417,7 @@ exports.defineAutoTests = function () {
});
it('file.spec.11 should error (NOT_FOUND_ERR) when resolving (non-existent) invalid file name', function (done) {
- var fileName = cordova.platformId === 'windowsphone' ? root.toURL() + '/' + 'this.is.not.a.valid.file.txt' : joinURL(root.toURL(), 'this.is.not.a.valid.file.txt'); // eslint-disable-line no-undef
+ var fileName = joinURL(root.toURL(), 'this.is.not.a.valid.file.txt');
var fail = function (error) {
expect(error).toBeDefined();
if (isChrome) {
@@ -2453,7 +2453,7 @@ exports.defineAutoTests = function () {
// FileReader
describe('Read method', function () {
it('file.spec.82 should error out on non-existent file', function (done) {
- var fileName = cordova.platformId === 'windowsphone' ? root.toURL() + '/' + 'somefile.txt' : 'somefile.txt'; // eslint-disable-line no-undef
+ var fileName = 'somefile.txt';
var verifier = function (evt) {
expect(evt).toBeDefined();
if (isChrome) {
@@ -3440,8 +3440,6 @@ exports.defineAutoTests = function () {
if (cordova.platformId === 'android') {
// Starting from Cordova-Android 10.x, the app content is served from the https scheme
pathExpect = 'https://';
- } else if (cordova.platformId === 'windowsphone') {
- pathExpect = '//nativ';
} else if (isChrome) {
pathExpect = 'filesystem:http://';
}
@@ -3788,14 +3786,12 @@ exports.defineAutoTests = function () {
it('file.spec.129 cordova.file.*Directory are set', function () {
var expectedPaths = ['applicationDirectory', 'applicationStorageDirectory', 'dataDirectory', 'cacheDirectory'];
/* eslint-disable no-undef */
- if (cordova.platformId === 'android' || cordova.platformId === 'amazon-fireos') {
+ if (cordova.platformId === 'android') {
if (cordova.file.externalApplicationStorageDirectory !== null) {
// https://issues.apache.org/jira/browse/CB-10411
// If external storage can't be mounted, the cordova.file.external* properties are null.
expectedPaths.push('externalApplicationStorageDirectory', 'externalRootDirectory', 'externalCacheDirectory', 'externalDataDirectory');
}
- } else if (cordova.platformId === 'blackberry10') {
- expectedPaths.push('externalRootDirectory', 'sharedDirectory');
} else if (cordova.platformId === 'ios') {
expectedPaths.push('syncedDataDirectory', 'documentsDirectory', 'tempDirectory');
} else if (cordova.platformId === 'osx') {
@@ -3817,10 +3813,10 @@ exports.defineAutoTests = function () {
var cdvfileApplicationDirectoryFsRootNameURL;
if (cordova.platformId === 'android') {
cdvfileApplicationDirectoryFsRootName = 'assets';
- cdvfileApplicationDirectoryFsRootNameURL = 'https://localhost/__cdvfile_' + cdvfileApplicationDirectoryFsRootName + '__/'
+ cdvfileApplicationDirectoryFsRootNameURL = 'https://localhost/__cdvfile_' + cdvfileApplicationDirectoryFsRootName + '__/';
} else if (cordova.platformId === 'ios') {
cdvfileApplicationDirectoryFsRootName = 'bundle';
- cdvfileApplicationDirectoryFsRootNameURL = 'cdvfile://localhost/' + cdvfileApplicationDirectoryFsRootName + '/'
+ cdvfileApplicationDirectoryFsRootNameURL = 'cdvfile://localhost/' + cdvfileApplicationDirectoryFsRootName + '/';
} else {
pending();
}
@@ -4206,7 +4202,6 @@ exports.defineManualTests = function (contentEl, createActionButton) {
ios: 'library,library-nosync,documents,documents-nosync,cache,bundle,root,private',
osx: 'library,library-nosync,documents,documents-nosync,cache,bundle,root,private',
android: 'files,files-external,documents,sdcard,cache,cache-external,assets,root',
- 'amazon-fireos': 'files,files-external,documents,sdcard,cache,cache-external,root',
windows: 'temporary,persistent'
};
diff --git a/www/Entry.js b/www/Entry.js
index a67be96..abe33d5 100644
--- a/www/Entry.js
+++ b/www/Entry.js
@@ -117,7 +117,7 @@ Entry.prototype.moveTo = function (parent, newName, successCallback, errorCallba
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 fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' });
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);
}
@@ -159,7 +159,7 @@ Entry.prototype.copyTo = function (parent, newName, successCallback, errorCallba
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 fs = newFSName ? new FileSystem(newFSName, { name: '', fullPath: '/' }) : new FileSystem(parent.filesystem.name, { name: '', fullPath: '/' });
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);
}
diff --git a/www/FileReader.js b/www/FileReader.js
index 1211206..bef9596 100644
--- a/www/FileReader.js
+++ b/www/FileReader.js
@@ -137,7 +137,7 @@ function readSuccessCallback (readType, encoding, offset, totalSize, accumulate,
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
+ CHUNK_SIZE = cordova.platformId === 'windows' ? totalSize
: (
// Calculate new chunk size for data URLs to be multiply of 3
// Otherwise concatenated base64 chunks won't be valid base64 data
diff --git a/www/FileWriter.js b/www/FileWriter.js
index c25eef6..0b942e5 100644
--- a/www/FileWriter.js
+++ b/www/FileWriter.js
@@ -112,7 +112,7 @@ 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 isProxySupportBlobNatively = cordova.platformId === 'windows';
var isBinary;
// Check to see if the incoming data is a blob
@@ -154,10 +154,6 @@ FileWriter.prototype.write = function (data, isPendingBlobReadResult) {
// 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) {
diff --git a/www/android/Entry.js b/www/android/Entry.js
index d9f180d..00555a4 100644
--- a/www/android/Entry.js
+++ b/www/android/Entry.js
@@ -20,14 +20,14 @@
*/
module.exports = {
- /**
+ /**
* 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 http(s)://(localhost) URL.
*/
- toURL: function () {
- return window.location.origin.includes('file://')
- ? this.nativeURL
- : this.toInternalURL();
- }
+ toURL: function () {
+ return window.location.origin.includes('file://')
+ ? this.nativeURL
+ : this.toInternalURL();
+ }
};
diff --git a/www/android/FileSystem.js b/www/android/FileSystem.js
index 679aeef..bf424d4 100644
--- a/www/android/FileSystem.js
+++ b/www/android/FileSystem.js
@@ -30,7 +30,7 @@ module.exports = {
// 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
+ path = FileSystem.encodeURIPath(fullPath);
if (!/^\//.test(path)) {
path = '/' + path;
}
diff --git a/www/browser/FileSystem.js b/www/browser/FileSystem.js
index a7c1d6c..53af21f 100644
--- a/www/browser/FileSystem.js
+++ b/www/browser/FileSystem.js
@@ -25,6 +25,6 @@ FILESYSTEM_PREFIX = 'file:///';
module.exports = {
__format__: function (fullPath) {
- return (FILESYSTEM_PREFIX + this.name + (fullPath[0] === '/' ? '' : '/') + FileSystem.encodeURIPath(fullPath)); // eslint-disable-line no-undef
+ return (FILESYSTEM_PREFIX + this.name + (fullPath[0] === '/' ? '' : '/') + FileSystem.encodeURIPath(fullPath));
}
};
diff --git a/www/browser/Preparing.js b/www/browser/Preparing.js
index 513833c..210ee81 100644
--- a/www/browser/Preparing.js
+++ b/www/browser/Preparing.js
@@ -30,7 +30,7 @@
var channel = require('cordova/channel');
var FileError = require('./FileError');
var PERSISTENT_FS_QUOTA = 5 * 1024 * 1024;
- var filePluginIsReadyEvent = new Event('filePluginIsReady'); // eslint-disable-line no-undef
+ var filePluginIsReadyEvent = new Event('filePluginIsReady');
var entryFunctionsCreated = false;
var quotaWasRequested = false;
@@ -75,8 +75,8 @@
For example, filesystem:file:///persistent/somefile.txt,
filesystem:http://localhost:8080/persistent/somefile.txt. */
var prefix = 'filesystem:file:///';
- if (location.protocol !== 'file:') { // eslint-disable-line no-undef
- prefix = 'filesystem:' + location.origin + '/'; // eslint-disable-line no-undef
+ if (location.protocol !== 'file:') {
+ prefix = 'filesystem:' + location.origin + '/';
}
var result;
@@ -146,10 +146,10 @@
var originalWrite = writer.write;
var writerProto = Object.getPrototypeOf(writer);
writerProto.write = function (blob) {
- if (blob instanceof Blob) { // eslint-disable-line no-undef
+ if (blob instanceof Blob) {
originalWrite.apply(this, [blob]);
} else {
- var realBlob = new Blob([blob]); // eslint-disable-line no-undef
+ var realBlob = new Blob([blob]);
originalWrite.apply(this, [realBlob]);
}
};
diff --git a/www/requestFileSystem.js b/www/requestFileSystem.js
index d9110cd..c912166 100644
--- a/www/requestFileSystem.js
+++ b/www/requestFileSystem.js
@@ -22,7 +22,7 @@
(function () {
// For browser platform: not all browsers use this file.
function checkBrowser () {
- if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef
+ if (cordova.platformId === 'browser' && require('./isChrome')()) {
module.exports = window.requestFileSystem || window.webkitRequestFileSystem;
return true;
}
diff --git a/www/resolveLocalFileSystemURI.js b/www/resolveLocalFileSystemURI.js
index abe275f..224bd27 100644
--- a/www/resolveLocalFileSystemURI.js
+++ b/www/resolveLocalFileSystemURI.js
@@ -21,7 +21,7 @@
(function () {
// For browser platform: not all browsers use overrided `resolveLocalFileSystemURL`.
function checkBrowser () {
- if (cordova.platformId === 'browser' && require('./isChrome')()) { // eslint-disable-line no-undef
+ if (cordova.platformId === 'browser' && require('./isChrome')()) {
module.exports.resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || window.webkitResolveLocalFileSystemURL;
return true;
}
@@ -65,11 +65,11 @@
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
+ var fsName = entry.filesystemName || (entry.filesystem && entry.filesystem.name) || (entry.filesystem === window.PERSISTENT ? 'persistent' : 'temporary');
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
+ fs = new FileSystem(fsName, { name: '', fullPath: '/' });
}
var result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath, fs, entry.nativeURL) : new FileEntry(entry.name, entry.fullPath, fs, entry.nativeURL);
successCallback(result);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org