Remove WebSQL provider (last supported in v0.0.44)

This commit is contained in:
David Humphrey 2019-01-02 13:12:18 -05:00
parent bc861bfd4a
commit 1ad81f9bae
11 changed files with 59 additions and 335 deletions

View File

@ -60,7 +60,6 @@ The default provider is `Memory`, and you can switch it like so:
* tests/index.html?filer-provider=memory * tests/index.html?filer-provider=memory
* tests/index.html?filer-provider=indexeddb * tests/index.html?filer-provider=indexeddb
* tests/index.html?filer-provider=websql
If you're writing tests, make sure you write them in the same style as existing tests, which are If you're writing tests, make sure you write them in the same style as existing tests, which are
provider agnostic. See [`tests/lib/test-utils.js`](tests/lib/test-utils.js) and how it gets used provider agnostic. See [`tests/lib/test-utils.js`](tests/lib/test-utils.js) and how it gets used

View File

@ -4,23 +4,23 @@
### Filer ### Filer
Filer is a POSIX-like file system for browsers. Filer is a drop-in replacement for node's `fs` module, a POSIX-like file system
for browsers.
### Compatibility ### Compatibility
Filer is known to work in the following browsers/versions, with the specified [Storage Providers](#providers): Filer uses [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
and is [known to work in the following browsers/versions](https://caniuse.com/#feat=indexeddb):
* node.js: v0.10.*+ * node.js: v0.10.*+
* IE: 10+ (IndexedDB) * IE: 10+
* Firefox: 26+ (IndexedDB) * Edge: 12+
* Chrome: 31+ (IndexedDB, WebSQL) * Firefox: 10+
* Safari: 7.0+ (WebSQL) * Chrome: 23+
* Opera: 19+ (IndexedDB, WebSQL) * Safari: 10+
* iOS: 3.2+ (WebSQL) * Opera: 15+
* Android Browser: 2.1-4.4 (WebSQL), 4.4+ (IndexedDB) * iOS: 10+
* Android Browser: 4.4+
NOTE: if you're interested in maximum compatibility, use the `Fallback` provider instead of `Default`.
See the section on [Storage Providers](#providers).
### Contributing ### Contributing
@ -31,7 +31,7 @@ Want to join the fun? We'd love to have you! See [CONTRIBUTING](https://github.c
Filer can be obtained in a number of ways: Filer can be obtained in a number of ways:
1. Via npm: `npm install filer` 1. Via npm: `npm install filer`
3. Via unpkg: `<script src="https://unpkg.com/filer"></script>` or specify a version directly, for example: [https://unpkg.com/filer@1.0.1/dist/filer.min.js](https://unpkg.com/filer@1.0.1/dist/filer.min.js) 1. Via unpkg: `<script src="https://unpkg.com/filer"></script>` or specify a version directly, for example: [https://unpkg.com/filer@1.0.1/dist/filer.min.js](https://unpkg.com/filer@1.0.1/dist/filer.min.js)
### Loading and Usage ### Loading and Usage
@ -76,11 +76,11 @@ they are invoked. Ensure proper ordering by chaining operations in callbacks.
To create a new file system or open an existing one, create a new `FileSystem` To create a new file system or open an existing one, create a new `FileSystem`
instance. By default, a new [IndexedDB](https://developer.mozilla.org/en/docs/IndexedDB) instance. By default, a new [IndexedDB](https://developer.mozilla.org/en/docs/IndexedDB)
database is created for each file system. The file system can also use other database is created for each file system. The file system can also use other
backend storage providers, for example [WebSQL](http://en.wikipedia.org/wiki/Web_SQL_Database) backend storage providers, for example `Memory`. See the section on [Storage Providers](#providers).
or even RAM (i.e., for temporary storage). See the section on [Storage Providers](#providers).
<a name="overviewExample"></a> <a name="overviewExample"></a>
```javascript ```js
var fs = new Filer.FileSystem(); var fs = new Filer.FileSystem();
fs.open('/myfile', 'w+', function(err, fd) { fs.open('/myfile', 'w+', function(err, fd) {
if (err) throw err; if (err) throw err;
@ -162,15 +162,17 @@ it becomes ready.
#### Filer.FileSystem.providers - Storage Providers<a name="providers"></a> #### Filer.FileSystem.providers - Storage Providers<a name="providers"></a>
Filer can be configured to use a number of different storage providers. The provider object encapsulates all aspects Filer can be configured to use a number of different storage providers. The provider object encapsulates all aspects of data access, making it possible to swap in different backend storage options. There are currently 2 providers to choose from:
of data access, making it possible to swap in different backend storage options. There are currently 4 different
providers to choose from:
* `FileSystem.providers.IndexedDB()` - uses IndexedDB * `FileSystem.providers.IndexedDB()` - uses IndexedDB
* `FileSystem.providers.WebSQL()` - uses WebSQL if necessary
* `FileSystem.providers.Fallback()` - attempts to use IndexedDB if possible, falling-back to WebSQL if necessary
* `FileSystem.providers.Memory()` - uses memory (not suitable for data that needs to survive the current session) * `FileSystem.providers.Memory()` - uses memory (not suitable for data that needs to survive the current session)
**NOTE**: previous versions of Filer also supported `FileSystem.providers.WebSQL()` and
`FileSystem.providers.Fallback()`, which could be used in browsers that supported
WebSQL but not IndexedDB. [WebSQL has been deprecated](https://www.w3.org/TR/webdatabase/),
and this functionality was removed in `v1.0.0`. If for some reason you still need it, use [`v0.0.44`](https://github.com/filerjs/filer/releases/tag/v0.0.44).
You can choose your provider when creating a `FileSystem`: You can choose your provider when creating a `FileSystem`:
```javascript ```javascript
@ -180,28 +182,20 @@ var providers = FileSystem.providers;
// Example 1: Use the default provider (currently IndexedDB) // Example 1: Use the default provider (currently IndexedDB)
var fs1 = new FileSystem(); var fs1 = new FileSystem();
// Example 2: Explicitly use IndexedDB // Example 2: Use the Memory provider
var fs2 = new FileSystem({ provider: new providers.IndexedDB() }); var fs2 = new FileSystem({ provider: new providers.Memory() });
// Example 3: Use one of IndexedDB or WebSQL, whichever is supported
var fs3 = new FileSystem({ provider: new providers.Fallback() });
``` ```
Every provider has an `isSupported()` method, which returns `true` if the browser supports this provider: Every provider has an `isSupported()` method, which returns `true` if the browser supports this provider:
```javascript ```javascript
if( Filer.FileSystem.providers.WebSQL.isSupported() ) { if( Filer.FileSystem.providers.IndexedDB.isSupported() ) {
// WebSQL provider will work in current environment... // IndexedDB provider will work in current environment...
} }
``` ```
You can also write your own provider if you need a different backend. See the code in `src/providers` for details. You can also write your own provider if you need a different backend. See the code in `src/providers` for details.
A number of other providers have been written, including:
* node.js fs provider: https://github.com/humphd/filer-fs
* node.js Amazon S3 provider: https://github.com/alicoding/filer-s3
#### Filer.Buffer<a name="FilerBuffer"></a> #### Filer.Buffer<a name="FilerBuffer"></a>
When reading and writing data, Filer follows node.js and uses [`Buffer`](http://nodejs.org/api/buffer.html). When reading and writing data, Filer follows node.js and uses [`Buffer`](http://nodejs.org/api/buffer.html).

53
package-lock.json generated
View File

@ -1402,7 +1402,7 @@
}, },
"util": { "util": {
"version": "0.10.3", "version": "0.10.3",
"resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -2453,7 +2453,8 @@
"base64-arraybuffer": { "base64-arraybuffer": {
"version": "0.1.5", "version": "0.1.5",
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz",
"integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=" "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=",
"dev": true
}, },
"base64-js": { "base64-js": {
"version": "1.3.0", "version": "1.3.0",
@ -2635,7 +2636,7 @@
}, },
"browserify-aes": { "browserify-aes": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -2672,7 +2673,7 @@
}, },
"browserify-rsa": { "browserify-rsa": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3389,7 +3390,7 @@
}, },
"concat-stream": { "concat-stream": {
"version": "1.6.2", "version": "1.6.2",
"resolved": "http://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3819,7 +3820,7 @@
}, },
"create-hash": { "create-hash": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -3832,7 +3833,7 @@
}, },
"create-hmac": { "create-hmac": {
"version": "1.1.7", "version": "1.1.7",
"resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -4307,7 +4308,7 @@
}, },
"diffie-hellman": { "diffie-hellman": {
"version": "5.0.3", "version": "5.0.3",
"resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
"integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -7095,7 +7096,7 @@
}, },
"is-accessor-descriptor": { "is-accessor-descriptor": {
"version": "0.1.6", "version": "0.1.6",
"resolved": "http://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
"integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -7174,7 +7175,7 @@
}, },
"is-data-descriptor": { "is-data-descriptor": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "http://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
"integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -7976,7 +7977,7 @@
}, },
"media-typer": { "media-typer": {
"version": "0.3.0", "version": "0.3.0",
"resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
"dev": true "dev": true
}, },
@ -9880,7 +9881,7 @@
}, },
"os-homedir": { "os-homedir": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
"dev": true "dev": true
}, },
@ -9896,7 +9897,7 @@
}, },
"os-tmpdir": { "os-tmpdir": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=",
"dev": true "dev": true
}, },
@ -10005,7 +10006,7 @@
}, },
"pako": { "pako": {
"version": "0.2.9", "version": "0.2.9",
"resolved": "http://registry.npmjs.org/pako/-/pako-0.2.9.tgz", "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
"integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=",
"dev": true "dev": true
}, },
@ -10086,7 +10087,7 @@
}, },
"parse-asn1": { "parse-asn1": {
"version": "5.1.1", "version": "5.1.1",
"resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz",
"integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -10151,7 +10152,7 @@
}, },
"path-browserify": { "path-browserify": {
"version": "0.0.0", "version": "0.0.0",
"resolved": "http://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz",
"integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=",
"dev": true "dev": true
}, },
@ -10235,7 +10236,7 @@
}, },
"pify": { "pify": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true "dev": true
}, },
@ -11343,7 +11344,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -11802,7 +11803,7 @@
}, },
"safe-regex": { "safe-regex": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -11948,7 +11949,7 @@
}, },
"sha.js": { "sha.js": {
"version": "2.4.11", "version": "2.4.11",
"resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -12322,7 +12323,7 @@
}, },
"sprintf-js": { "sprintf-js": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "http://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
"dev": true "dev": true
}, },
@ -12392,7 +12393,7 @@
}, },
"stream-browserify": { "stream-browserify": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "http://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz",
"integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=",
"dev": true, "dev": true,
"requires": { "requires": {
@ -12443,7 +12444,7 @@
}, },
"string_decoder": { "string_decoder": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -12644,7 +12645,7 @@
}, },
"through": { "through": {
"version": "2.3.8", "version": "2.3.8",
"resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
"dev": true "dev": true
}, },
@ -12780,7 +12781,7 @@
}, },
"tty-browserify": { "tty-browserify": {
"version": "0.0.0", "version": "0.0.0",
"resolved": "http://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
"integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=",
"dev": true "dev": true
}, },
@ -13198,7 +13199,7 @@
}, },
"vm-browserify": { "vm-browserify": {
"version": "0.0.4", "version": "0.0.4",
"resolved": "http://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz",
"integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=",
"dev": true, "dev": true,
"requires": { "requires": {

View File

@ -46,7 +46,6 @@
"url": "https://github.com/filerjs/filer.git" "url": "https://github.com/filerjs/filer.git"
}, },
"dependencies": { "dependencies": {
"base64-arraybuffer": "^0.1.5",
"es6-promisify": "^6.0.1", "es6-promisify": "^6.0.1",
"minimatch": "^3.0.4" "minimatch": "^3.0.4"
}, },

View File

@ -1,35 +1,8 @@
var IndexedDB = require('./indexeddb.js'); const IndexedDB = require('./indexeddb.js');
var WebSQL = require('./websql.js'); const Memory = require('./memory.js');
var Memory = require('./memory.js');
module.exports = { module.exports = {
IndexedDB: IndexedDB, IndexedDB: IndexedDB,
WebSQL: WebSQL,
Memory: Memory,
/**
* Convenience Provider references
*/
// The default provider to use when none is specified
Default: IndexedDB, Default: IndexedDB,
Memory: Memory
// The Fallback provider does automatic fallback checks
Fallback: (function() {
if(IndexedDB.isSupported()) {
return IndexedDB;
}
if(WebSQL.isSupported()) {
return WebSQL;
}
function NotSupported() {
throw '[Filer Error] Your browser doesn\'t support IndexedDB or WebSQL.';
}
NotSupported.isSupported = function() {
return false;
};
return NotSupported;
}())
}; };

View File

@ -1,170 +0,0 @@
var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME;
var FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME;
var WSQL_VERSION = require('../constants.js').WSQL_VERSION;
var WSQL_SIZE = require('../constants.js').WSQL_SIZE;
var WSQL_DESC = require('../constants.js').WSQL_DESC;
var Errors = require('../errors.js');
var base64ArrayBuffer = require('base64-arraybuffer');
function WebSQLContext(db, isReadOnly) {
var that = this;
this.getTransaction = function(callback) {
if(that.transaction) {
callback(that.transaction);
return;
}
// Either do readTransaction() (read-only) or transaction() (read/write)
db[isReadOnly ? 'readTransaction' : 'transaction'](function(transaction) {
that.transaction = transaction;
callback(transaction);
});
};
}
WebSQLContext.prototype.clear = function(callback) {
function onError(transaction, error) {
callback(error);
}
function onSuccess() {
callback(null);
}
this.getTransaction(function(transaction) {
transaction.executeSql('DELETE FROM ' + FILE_STORE_NAME + ';',
[], onSuccess, onError);
});
};
function _get(getTransaction, key, callback) {
function onSuccess(transaction, result) {
// If the key isn't found, return null
var value = result.rows.length === 0 ? null : result.rows.item(0).data;
callback(null, value);
}
function onError(transaction, error) {
callback(error);
}
getTransaction(function(transaction) {
transaction.executeSql('SELECT data FROM ' + FILE_STORE_NAME + ' WHERE id = ? LIMIT 1;',
[key], onSuccess, onError);
});
}
WebSQLContext.prototype.getObject = function(key, callback) {
_get(this.getTransaction, key, function(err, result) {
if(err) {
return callback(err);
}
try {
if(result) {
result = JSON.parse(result);
}
} catch(e) {
return callback(e);
}
callback(null, result);
});
};
WebSQLContext.prototype.getBuffer = function(key, callback) {
_get(this.getTransaction, key, function(err, result) {
if(err) {
return callback(err);
}
// Deal with zero-length ArrayBuffers, which will be encoded as ''
if(result || result === '') {
var arrayBuffer = base64ArrayBuffer.decode(result);
result = Buffer.from(arrayBuffer);
}
callback(null, result);
});
};
function _put(getTransaction, key, value, callback) {
function onSuccess() {
callback(null);
}
function onError(transaction, error) {
callback(error);
}
getTransaction(function(transaction) {
transaction.executeSql('INSERT OR REPLACE INTO ' + FILE_STORE_NAME + ' (id, data) VALUES (?, ?);',
[key, value], onSuccess, onError);
});
}
WebSQLContext.prototype.putObject = function(key, value, callback) {
var json = JSON.stringify(value);
_put(this.getTransaction, key, json, callback);
};
WebSQLContext.prototype.putBuffer = function(key, uint8BackedBuffer, callback) {
var base64 = base64ArrayBuffer.encode(uint8BackedBuffer.buffer);
_put(this.getTransaction, key, base64, callback);
};
WebSQLContext.prototype.delete = function(key, callback) {
function onSuccess() {
callback(null);
}
function onError(transaction, error) {
callback(error);
}
this.getTransaction(function(transaction) {
transaction.executeSql('DELETE FROM ' + FILE_STORE_NAME + ' WHERE id = ?;',
[key], onSuccess, onError);
});
};
function WebSQL(name) {
this.name = name || FILE_SYSTEM_NAME;
this.db = null;
}
WebSQL.isSupported = function() {
return !!global.openDatabase;
};
WebSQL.prototype.open = function(callback) {
var that = this;
// Bail if we already have a db open
if(that.db) {
return callback();
}
var db = global.openDatabase(that.name, WSQL_VERSION, WSQL_DESC, WSQL_SIZE);
if(!db) {
callback('[WebSQL] Unable to open database.');
return;
}
function onError(transaction, error) {
if (error.code === 5) {
callback(new Errors.EINVAL('WebSQL cannot be accessed. If private browsing is enabled, disable it.'));
}
callback(error);
}
function onSuccess() {
that.db = db;
callback();
}
// Create the table and index we'll need to store the fs data.
db.transaction(function(transaction) {
function createIndex(transaction) {
transaction.executeSql('CREATE INDEX IF NOT EXISTS idx_' + FILE_STORE_NAME + '_id' +
' on ' + FILE_STORE_NAME + ' (id);',
[], onSuccess, onError);
}
transaction.executeSql('CREATE TABLE IF NOT EXISTS ' + FILE_STORE_NAME + ' (id unique, data TEXT);',
[], createIndex, onError);
});
};
WebSQL.prototype.getReadOnlyContext = function() {
return new WebSQLContext(this.db, true);
};
WebSQL.prototype.getReadWriteContext = function() {
return new WebSQLContext(this.db, false);
};
module.exports = WebSQL;

View File

@ -52,7 +52,6 @@ require('./spec/fs.copyFile.spec');
// Filer.FileSystem.providers.* // Filer.FileSystem.providers.*
require('./spec/providers/providers.spec'); require('./spec/providers/providers.spec');
require('./spec/providers/providers.indexeddb.spec'); require('./spec/providers/providers.indexeddb.spec');
require('./spec/providers/providers.websql.spec');
require('./spec/providers/providers.memory.spec'); require('./spec/providers/providers.memory.spec');
require('./spec/providers/serializable-memory-provider.spec'); require('./spec/providers/serializable-memory-provider.spec');

View File

@ -1,6 +1,5 @@
var Filer = require('../../src'); var Filer = require('../../src');
var IndexedDBTestProvider = require('./indexeddb.js'); var IndexedDBTestProvider = require('./indexeddb.js');
var WebSQLTestProvider = require('./websql.js');
var MemoryTestProvider = require('./memory.js'); var MemoryTestProvider = require('./memory.js');
var Url = require('url'); var Url = require('url');
@ -16,13 +15,8 @@ function uniqueName() {
function findBestProvider() { function findBestProvider() {
var providers = Filer.FileSystem.providers; var providers = Filer.FileSystem.providers;
if(providers.IndexedDB.isSupported()) { return providers.IndexedDB.isSupported() ?
return IndexedDBTestProvider; IndexedDBTestProvider : MemoryTestProvider;
}
if(providers.WebSQL.isSupported()) {
return WebSQLTestProvider;
}
return MemoryTestProvider;
} }
function getUrlParams() { function getUrlParams() {
@ -61,9 +55,6 @@ function setup(callback) {
case 'indexeddb': case 'indexeddb':
_provider = new IndexedDBTestProvider(name); _provider = new IndexedDBTestProvider(name);
break; break;
case 'websql':
_provider = new WebSQLTestProvider(name);
break;
case 'memory': case 'memory':
_provider = new MemoryTestProvider(name); _provider = new MemoryTestProvider(name);
break; break;
@ -158,7 +149,6 @@ module.exports = {
provider: provider, provider: provider,
providers: { providers: {
IndexedDB: IndexedDBTestProvider, IndexedDB: IndexedDBTestProvider,
WebSQL: WebSQLTestProvider,
Memory: MemoryTestProvider Memory: MemoryTestProvider
}, },
cleanup: cleanup, cleanup: cleanup,

View File

@ -1,49 +0,0 @@
var Filer = require('../../src');
var needsCleanup = [];
if(global.addEventListener) {
global.addEventListener('beforeunload', function() {
needsCleanup.forEach(function(f) { f(); });
});
}
function WebSQLTestProvider(name) {
var _done = false;
var that = this;
function cleanup(callback) {
callback = callback || function(){};
if(!that.provider || _done) {
return callback();
}
// Provider is there, but db was never touched
if(!that.provider.db) {
return callback();
}
var context = that.provider.getReadWriteContext();
context.clear(function() {
that.provider = null;
_done = true;
callback();
});
}
function init() {
if(that.provider) {
return;
}
that.provider = new Filer.FileSystem.providers.WebSQL(name);
needsCleanup.push(cleanup);
}
this.init = init;
this.cleanup = cleanup;
}
WebSQLTestProvider.isSupported = function() {
return Filer.FileSystem.providers.WebSQL.isSupported();
};
module.exports = WebSQLTestProvider;

View File

@ -10,10 +10,6 @@ describe('Filer.FileSystem.providers', function() {
expect(Filer.FileSystem.providers.IndexedDB).to.be.a('function'); expect(Filer.FileSystem.providers.IndexedDB).to.be.a('function');
}); });
it('has WebSQL constructor', function() {
expect(Filer.FileSystem.providers.WebSQL).to.be.a('function');
});
it('has Memory constructor', function() { it('has Memory constructor', function() {
expect(Filer.FileSystem.providers.Memory).to.be.a('function'); expect(Filer.FileSystem.providers.Memory).to.be.a('function');
}); });
@ -21,8 +17,4 @@ describe('Filer.FileSystem.providers', function() {
it('has a Default constructor', function() { it('has a Default constructor', function() {
expect(Filer.FileSystem.providers.Default).to.be.a('function'); expect(Filer.FileSystem.providers.Default).to.be.a('function');
}); });
it('has Fallback constructor', function() {
expect(Filer.FileSystem.providers.Fallback).to.be.a('function');
});
}); });

View File

@ -1,4 +0,0 @@
var util = require('../../lib/test-utils.js');
var providerBase = require('./providers.base.js');
providerBase('WebSQL', util.providers.WebSQL);