cordova-plugin-wkwebview-engine-nextgen
Advanced tools
Comparing version 1.0.1-dev to 1.0.1
{ | ||
"name": "cordova-plugin-wkwebview-engine-nextgen", | ||
"version": "1.0.1-dev", | ||
"version": "1.0.1", | ||
"description": "Cordova WKWebView next generation", | ||
@@ -18,2 +18,5 @@ "main": "index.js", | ||
"author": "Apache Cordova", | ||
"contributors": [{ | ||
"name": "Mendix B.V" | ||
}], | ||
"license": "Apache-2.0", | ||
@@ -20,0 +23,0 @@ "devDependencies": { |
@@ -20,5 +20,3 @@ <!-- | ||
[](https://travis-ci.org/apache/cordova-plugin-wkwebview-engine) | ||
Cordova WKWebView Engine | ||
Cordova WKWebView Engine NextGen | ||
====== | ||
@@ -28,3 +26,4 @@ | ||
In iOS 9, Apple has fixed the [issue](http://www.openradar.me/18039024) present through iOS 8 where you cannot load locale files using file://, and must resort to using a local webserver. **However, you are still not able to use XHR from the file:// protocol without [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) enabled on your server.** | ||
In iOS 9, Apple has fixed the [issue](http://www.openradar.me/18039024) present through iOS 8 where you cannot load locale files using file://, and must resort to using a local webserver. As all the XMLHttpRequests are no longer handled by WKWebView but are processed in native code you don't need to enable CORS on you server. When you need to download files to the device and want WKWebView to be able | ||
to get them by a request (e.g, for images and scripts) you can do that by downloading them to `cordova.wkwebview.storageDir`. | ||
@@ -41,11 +40,4 @@ Installation | ||
cordova platform add ios@4 | ||
cordova plugin add cordova-plugin-wkwebview-engine | ||
cordova plugin add cordova-plugin-wkwebview-engine-nextgen | ||
To test the development version: | ||
cordova create wkwvtest my.project.id wkwvtest | ||
cd wkwvtest | ||
cordova platform add https://github.com/apache/cordova-ios.git#master | ||
cordova plugin add https://github.com/apache/cordova-plugin-wkwebview-engine.git#master | ||
You also must have Xcode 7 (iOS 9 SDK) installed. Check your Xcode version by running: | ||
@@ -82,3 +74,3 @@ | ||
If you are upgrading from UIWebView, please note the limitations of using WKWebView as outlined in our [issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20labels%20%3D%20wkwebview-known-issues). | ||
If you are upgrading from UIWebView, please note there are a number of limitations of using WKWebView. These can be find at [apache cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20labels%20%3D%20wkwebview-known-issues). | ||
@@ -85,0 +77,0 @@ Apple Issues |
@@ -98,10 +98,30 @@ | ||
if (data instanceof window.FormData) { | ||
writeBlobEntries(data).then(function(result) { | ||
this.__tempFiles = result.filter(function(entry) { | ||
return !!entry.fileName; | ||
}).map(function(entry) { | ||
return entry.value; | ||
var splittedformData = data.__entries.reduce(function(acc, entry) { | ||
if (entry.fileName) { | ||
acc.files.push(entry); | ||
} else { | ||
acc.data.push(entry); | ||
} | ||
return acc; | ||
}, { | ||
data: [], | ||
files:[] | ||
}); | ||
writeBlobEntries(splittedformData.files).then(function(savedBlobEntries) { | ||
this.__tempFiles = savedBlobEntries.map(function(blobEntry) { | ||
return blobEntry.fileEntry; | ||
}); | ||
scheduleXHRRequest(this, method, url, headers, result); | ||
scheduleXHRRequest(this, method, url, headers, { | ||
data: splittedformData.data, | ||
files: savedBlobEntries.map(function (blobEntry) { | ||
return { | ||
name: blobEntry.name, | ||
fileName: blobEntry.fileName, | ||
fileUrl: blobEntry.fileEntry.toURL() | ||
}; | ||
}) | ||
}); | ||
}.bind(this)); | ||
@@ -111,7 +131,6 @@ } else { | ||
} | ||
return; | ||
} else { | ||
var original = this[originalInstanceKey]; | ||
original.send.apply(original, arguments); | ||
} | ||
var original = this[originalInstanceKey]; | ||
return original.send.apply(original, arguments); | ||
}; | ||
@@ -201,13 +220,11 @@ | ||
function writeBlobEntries(formData) { | ||
return Promise.all(formData.__entries.map(function(entry) { | ||
if (!(entry.value instanceof Blob)) { | ||
return Promise.resolve(entry); | ||
} else { | ||
return writeBlob(entry.value).then(function(fileURL) { | ||
entry.value = fileURL; | ||
return entry; | ||
}); | ||
} | ||
function writeBlobEntries(entries) { | ||
return Promise.all(entries.map(function(entry) { | ||
return writeBlob(entry.value).then(function(fileEntry) { | ||
return { | ||
name: entry.name, | ||
fileName: entry.fileName, | ||
fileEntry: fileEntry | ||
}; | ||
}); | ||
})); | ||
@@ -220,4 +237,4 @@ } | ||
window.resolveLocalFileSystemURL(cordova.file.tempDirectory, function(dir) { | ||
var fileName = "tmp_" + (+ new Date()) + sequence++; | ||
dir.getFile(fileName, { create:true }, function(fileEntry) { | ||
var fileName = "wkwebview_upload_" + (+new Date()) + sequence++; | ||
dir.getFile(fileName, { create: true }, function(fileEntry) { | ||
fileEntry.createWriter(function(fileWriter) { | ||
@@ -230,3 +247,3 @@ var fileSize = blob.size; | ||
var sz = Math.min(blockSize, fileSize - written); | ||
var block = blob.slice(written, written+sz); | ||
var block = blob.slice(written, written + sz); | ||
@@ -242,3 +259,3 @@ fileWriter.seek(written); | ||
} else { | ||
resolve(fileEntry.toURL()); | ||
resolve(fileEntry); | ||
} | ||
@@ -255,8 +272,2 @@ }; | ||
function writeFileEntry(fileEntry) { | ||
return new Promise(function(resolve, reject) { | ||
}); | ||
} | ||
function handleXHRResponse(id, status, body) { | ||
@@ -271,6 +282,4 @@ var context = requests[id]; | ||
if (context.__tempFiles) { | ||
context.__tempFiles.forEach(function(fileURL) { | ||
window.resolveLocalFileSystemURL(fileURL, function (fileEntry) { | ||
fileEntry.remove(); | ||
}); | ||
context.__tempFiles.forEach(function(fileEntry) { | ||
fileEntry.remove(); | ||
}); | ||
@@ -277,0 +286,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
80988
20
436
1
0
84