This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Many Updates!

- Using babel-preset-env instead of babel-preset-latest
- Safari 11.1 is marked as bugged and will use the fallback
  script instead of installing the service worker
- mime-types was replaced with a generated JSON based on
  mime-db which allowed to reduce the build size
- The Service Worker script is now build to support only
  browsers which supports service workers and streams
- Because of the above the uglify plugin was replaced with
  tenser, which support new ES6+ syntax
- The megajs library was updated to the current alpha version
  (which requires compiling with babel)
- Bandwidth errors are now being correctly handled
- Connection errors are now being handled
- File not found in folders errors are being handled
- Using HTTP range causes errors on Chrome when restarting
  an interrupted download. As it's a browser caused bug the
  readme was updated to note that this feature will not be
  enabled as default.
  • Loading branch information...
qgustavor committed May 20, 2018
1 parent 75fe0df commit dcacd6237643811f18b4c583270c43677de0d395
Showing with 2,683 additions and 1,438 deletions.
  1. +5 −4 .babelrc
  2. +3 −0 .gitignore
  3. +4 −3 README.md
  4. +5 −1 dist/main.js
  5. +10 −0 generate-mime-types.js
  6. +2,594 −1,401 package-lock.json
  7. +5 −4 package.json
  8. +4 −3 rollup.fallback.js
  9. +4 −3 rollup.splitter.js
  10. +11 −3 rollup.sw.js
  11. +38 −16 src/sw.js
View
@@ -1,9 +1,10 @@
{
"presets": [
["latest", {
"es2015": {
"modules": false
}
["env", {
"targets": {
"browsers": "defaults"
},
"modules": false
}]
],
"plugins": ["external-helpers"]
View
@@ -56,3 +56,6 @@ typings/
# dotenv environment variables file
.env
# mime-types.json is generated from mime-db
src/mime-types.json
View
@@ -30,14 +30,15 @@ button and starts download immediately, so it's *almost* direct.
**A:** It works using JavaScript, so no. If you open it in any download manager it will only download an HTML page and nothing else.
* **Q:** How it works?
**A:** Downloading like the image shows uses Service Workers and Streams API.
Currently only [Google Chrome / Chromium](https://www.chromestatus.com/feature/4531143755956224) supports that.
Currently few browsers supports that, like [Google Chrome / Chromium](https://www.chromestatus.com/feature/4531143755956224).
In other browsers it uses `Blob` and `a[download]` (similar to MEGA).
## Extra arguments
* `&use-http-range`: uses the HTTP Range header which allows video and music seeking
(disabled by default until bugs get fixed)
(disabled by default as it can cause bugs and currently have bad performance)
* `&start=X`: starts downloading from the X part of the file (default unit: byte)
* `&end=X`: stops downloading at the X part of the file (default unit: byte)
* `&name=X`: rename files downloaded
* `&cipher`: downloads the encrypted file
* `&cipher`: downloads the encrypted file, [in most cases](https://directme.ga/view?F!g4FlSYTZ!!MwEgnajY&c=kaban.png)
it's not needed and will cause bugs
View
@@ -12,7 +12,11 @@
var identifier = (location.hash.length > 2 ? location.hash : location.search || '').substr(1)
var hasFile = identifier.startsWith('!') || identifier.startsWith('F!')
var compatible = typeof ReadableStream === 'function'
var compatible = typeof ReadableStream === 'function' &&
// Issue #17: Safari 11.1 downloads the HTML page instead of the Worker generated response
// It's impossible to detect using feature detection, so user agent sniffing is used
!navigator.userAgent.includes('Version/11.1 Safari')
if (compatible) {
try {
;(new window.ReadableStream()).getReader().read()
View
@@ -0,0 +1,10 @@
const mime = require('mime-db')
const fs = require('fs')
const minifiedMimes = Object.entries(mime).reduce((result, [mime, entry]) => {
if (!entry.extensions) return result
for (let extension of entry.extensions) result[extension] = mime
return result
}, {})
fs.writeFileSync('src/mime-types.json', JSON.stringify(minifiedMimes))
Oops, something went wrong.

0 comments on commit dcacd62

Please sign in to comment.