This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

202
node_modules/@expo/websql/LICENSE generated vendored Normal file
View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed 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.

268
node_modules/@expo/websql/README.md generated vendored Normal file
View File

@ -0,0 +1,268 @@
NOTE: This is [Expo](http://expo.io)'s fork without the `'sqlite3'` dependency which is unused in React Native.
node-websql [![Build Status](https://travis-ci.org/nolanlawson/node-websql.svg?branch=master)](https://travis-ci.org/nolanlawson/node-websql) [![Coverage Status](https://coveralls.io/repos/github/nolanlawson/node-websql/badge.svg?branch=master&nonce=foo)](https://coveralls.io/github/nolanlawson/node-websql?branch=master)
====
The [WebSQL Database API][websql], implemented for Node
using [sqlite3](https://github.com/mapbox/node-sqlite3). In the browser, it falls back to `window.openDatabase`.
Install
----
npm install websql
Usage
----
```js
var openDatabase = require('websql');
```
Create a SQLite3 database called `mydb.db`:
```js
var db = openDatabase('mydb.db', '1.0', 'description', 1);
```
Create an in-memory database:
```js
var db = openDatabase(':memory:', '1.0', 'description', 1);
```
API
---
### openDatabase(name, version, description, size [, callback])
The `name` is the name of the database. It's passed verbatim to [sqlite3][].
The `version` is the database version (_currently ignored - see below_).
The `description` and `size` attributes are ignored, but they are required for
compatibility with the WebSQL API.
The `callback` just returns the same database object returned
synchronously (_migrations currently aren't supported - see below_).
For more information how to use the WebSQL API, see [the spec][websql] or
[various](http://www.html5rocks.com/en/tutorials/webdatabase/todo/) [tutorials](html5doctor.com/introducing-web-sql-databases/).
For more information on `sqlite3`, see [the SQLite3 readme](sqlite3).
### In the browser
You can also use this module in the browser (via Browserify/Webpack/etc.),
in which case it will just use
`window.openDatabase`, meaning you are subject to [browser WebSQL support](http://caniuse.com/#feat=sql-storage).
### readTransaction() vs transaction()
Both `readTransaction()` (read-only) and `transaction()` (read-write) are supported.
`readTransaction()` has some small performance optimizations, so it's worthwhile to
use if you're not writing any data in a transaction.
Goals
----
The [WebSQL Database API][websql] is a deprecated
standard, but in many cases it's useful to reuse legacy code
designed for browsers that support WebSQL. Also, it allows you to quickly
test WebSQL-based code in Node, which can be convenient.
The goal of this API is to exactly match the existing WebSQL API, as implemented
in browsers. If there's any difference between browsers (e.g. `rows[0]` is supported
in Chrome, whereas only `rows.item(0)` is supported in Safari), then the lowest-common
denominator version is exported by this library.
This library has a robust test suite, and has been known to pass the PouchDB
test suite as well.
Non-Goals
---
This library is _not_ designed to:
- Invent new APIs, e.g. deleting databases, supporting `BLOB`s, encryption, etc.
- Support WebSQL in Firefox, IE, or other non-WebSQL browsers
In other words, the goal is not to carry the torch of WebSQL,
but rather to bridge the gap from existing WebSQL-based code to Node.js.
Custom SQLite3 bindings
----
This library is designed to allow swappable SQLite3 implementations, beyond
just [node-sqlite3](https://github.com/mapbox/node-sqlite3). Examples:
* [node-websql itself](https://github.com/nolanlawson/node-websql/blob/7c6327c2bbcf48bb0ac26f8f689206b7227baf81/lib/sqlite/SQLiteDatabase.js)
* [Cordova SQLite Plugin 2](https://github.com/nolanlawson/cordova-plugin-sqlite-2/blob/6bc32a4e71a3eea28fbc98c4da7e87c56156d094/src/javascript/SQLiteDatabase.js)
* [React Native SQLite 2](https://github.com/noradaiko/react-native-sqlite-2)
To create your own custom implementation, use this API:
```js
var customOpenDatabase = require('websql/custom');
var openDatabase = customOpenDatabase(SQLiteDatabase);
```
This `SQLiteDatabase` implementation needs to be a constructor-style function
with a constructor signature like so:
```js
// takes a single argument: the database name
var db = new SQLiteDatabase('dbname');
```
Then it implements a single function, `exec()`, like so:
```js
function exec(queries, readOnly, callback) {
// queries: an array of SQL statements and queries, with a key "sql" and "args"
// readOnly: whether or not these queries are in "read only" mode
// callback: callback to be called with results (first arg is error, second arg is results)
}
```
Here is the full specification:
### SQLiteDatabase(name (String))
Construct a new `SQLiteDatbase` object, with the given string name.
### exec(queries (Array<SQLQuery>), readOnly (boolean), callback (function))
Execute the list of `SQLQuery`s. If we are in `readOnly` mode, then any
non-`SELECT` queries need to throw an error without executing. This function calls the Node-style
callback with an error as the first argument or the `Array<SQLResult>` as
the second argument.
### SQLQuery
A SQL query and bindings to execute. This can be a plain JavaScript object or a custom class,
as long as it has the following members:
#### sql (String)
The SQL query to execute.
#### args (Array<String>)
The arguments to bind the query.
E.g.:
```js
{
sql: 'INSERT INTO foo values (?, ?)',
args: ['bar', 'baz']
}
```
### SQLResult
A result returned by a SQL query. This can be a plain JavaScript object or a custom class,
as long as it has the following members:
#### error
A JavaScript `Error` object, or `undefined` if the `SQLQuery` did not throw an error. If `error` is truthy, then it's assumed `insertId`, `rowsAffected`, and `rows` are falsy (they will be ignored anyway).
#### insertId (number)
An insertion ID representing the new row number, or `undefined` if nothing was inserted.
#### rowsAffected (number)
The number of rows affected by the query, or 0 if none.
#### rows (Array&lt;object&gt;)
The rows returned by a `SELECT` query, or empty if none.
Each object is a mapping of keys (columns) to values (value fetched).
E.g.:
```js
{
insertId: undefined,
rowsAffected: 0,
rows: [
{'foo': 'bar'},
{'foo': 'baz'},
]
}
```
Or:
```js
{
error: new Error('whoopsie')
}
```
For an example implementation (and the one used by this module)
see `lib/sqlite/SQLiteDatabase.js`.
TODOs
---
The versioning and migration APIs
(i.e. [`changeVersion()`](https://www.w3.org/TR/webdatabase/#dom-database-changeversion))
are not supported. Pull requests welcome!
Limitations
----
1. With the restrictions of the [node-sqlite3 API](https://github.com/mapbox/node-sqlite3/wiki/API)
on database names ("Valid values are filenames, ":memory:" for an anonymous
in-memory database and an empty string for an anonymous disk-based
database") and our lack of interest to enforce a particular mapping that
honors the [WebSQL spec](https://www.w3.org/TR/webdatabase/#dom-opendatabase)
in its indicating that "All strings including the empty string are valid database
names" (and that they are case-sensitive), consumers will need to do their
own mapping for strings in order to 1) avoid problems with invalid filenames or
filenames on case insensitive file systems, and to 2) avoid user databases being
given special treatment if the empty string or the string ":memory:" is used;
another special purpose form of string supported by SQLite that may call for
escaping are [`file::memory:...`](https://sqlite.org/inmemorydb.html)
[URLs](https://sqlite.org/uri.html#uri_format).
2. Although neither the WebSQL spec nor SQLite speaks to this matter,
`node-sqlite3` has the following additional
[limitations](https://github.com/mapbox/node-sqlite3/wiki/API#databaseexecsql-callback)
which are surfaced for our users: namely, that statements will only be
executed up to the first NULL byte and [SQL comments](https://sqlite.org/lang_comment.html)
will lead to runtime errors.
Testing
----
First:
npm install
Main test suite:
npm test
Linter:
npm run lint
Test in debug mode (e.g. with the `node-inspector`):
npm run test-debug
Run the test suite against actual WebSQL in a browser:
npm run test-local
Run the actual-WebSQL test against PhantomJS:
npm run test-phantom
[websql]: https://www.w3.org/TR/webdatabase/
[sqlite3]: https://github.com/mapbox/node-sqlite3

1
node_modules/@expo/websql/custom/index.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('../lib/custom');

3
node_modules/@expo/websql/lib/browser.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
'use strict';
module.exports = global.openDatabase;

41
node_modules/@expo/websql/lib/custom.js generated vendored Normal file
View File

@ -0,0 +1,41 @@
'use strict';
var immediate = require('immediate');
var argsarray = require('argsarray');
var WebSQLDatabase = require('./websql/WebSQLDatabase');
function customOpenDatabase(SQLiteDatabase) {
function createDb(dbName, dbVersion) {
var sqliteDatabase = new SQLiteDatabase(dbName);
return new WebSQLDatabase(dbVersion, sqliteDatabase);
}
function openDatabase(args) {
if (args.length < 4) {
throw new Error('Failed to execute \'openDatabase\': ' +
'4 arguments required, but only ' + args.length + ' present');
}
var dbName = args[0];
var dbVersion = args[1];
// db description and size are ignored
var callback = args[4];
var db = createDb(dbName, dbVersion);
if (typeof callback === 'function') {
immediate(function () {
callback(db);
});
}
return db;
}
return argsarray(openDatabase);
}
module.exports = customOpenDatabase;

6
node_modules/@expo/websql/lib/index.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
'use strict';
var SQLiteDatabase = require('./sqlite/SQLiteDatabase');
var customOpenDatabase = require('./custom');
module.exports = customOpenDatabase(SQLiteDatabase);

88
node_modules/@expo/websql/lib/sqlite/SQLiteDatabase.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
'use strict';
var sqlite3 = require('sqlite3');
var SQLiteResult = require('./SQLiteResult');
var READ_ONLY_ERROR = new Error(
'could not prepare statement (23 not authorized)');
function SQLiteDatabase(name) {
this._db = new sqlite3.Database(name);
}
function runSelect(db, sql, args, cb) {
db.all(sql, args, function (err, rows) {
if (err) {
return cb(new SQLiteResult(err));
}
var insertId = void 0;
var rowsAffected = 0;
var resultSet = new SQLiteResult(null, insertId, rowsAffected, rows);
cb(resultSet);
});
}
function runNonSelect(db, sql, args, cb) {
db.run(sql, args, function (err) {
if (err) {
return cb(new SQLiteResult(err));
}
/* jshint validthis:true */
var executionResult = this;
var insertId = executionResult.lastID;
var rowsAffected = executionResult.changes;
var rows = [];
var resultSet = new SQLiteResult(null, insertId, rowsAffected, rows);
cb(resultSet);
});
}
SQLiteDatabase.prototype.exec = function exec(queries, readOnly, callback) {
var db = this._db;
var len = queries.length;
var results = new Array(len);
var i = 0;
function checkDone() {
if (++i === len) {
callback(null, results);
} else {
doNext();
}
}
function onQueryComplete(i) {
return function (res) {
results[i] = res;
checkDone();
};
}
function doNext() {
var query = queries[i];
var sql = query.sql;
var args = query.args;
// TODO: It seems like the node-sqlite3 API either allows:
// 1) all(), which returns results but not rowsAffected or lastID
// 2) run(), which doesn't return results, but returns rowsAffected and lastID
// So we try to sniff whether it's a SELECT query or not.
// This is inherently error-prone, although it will probably work in the 99%
// case.
var isSelect = /^\s*SELECT\b/i.test(sql);
if (readOnly && !isSelect) {
onQueryComplete(i)(new SQLiteResult(READ_ONLY_ERROR));
} else if (isSelect) {
runSelect(db, sql, args, onQueryComplete(i));
} else {
runNonSelect(db, sql, args, onQueryComplete(i));
}
}
doNext();
};
module.exports = SQLiteDatabase;

10
node_modules/@expo/websql/lib/sqlite/SQLiteResult.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
'use strict';
function SQLiteResult(error, insertId, rowsAffected, rows) {
this.error = error;
this.insertId = insertId;
this.rowsAffected = rowsAffected;
this.rows = rows;
}
module.exports = SQLiteResult;

102
node_modules/@expo/websql/lib/websql/WebSQLDatabase.js generated vendored Normal file
View File

@ -0,0 +1,102 @@
'use strict';
var Queue = require('tiny-queue');
var immediate = require('immediate');
var noop = require('noop-fn');
var WebSQLTransaction = require('./WebSQLTransaction');
var ROLLBACK = [
{sql: 'ROLLBACK;', args: []}
];
var COMMIT = [
{sql: 'END;', args: []}
];
// v8 likes predictable objects
function TransactionTask(readOnly, txnCallback, errorCallback, successCallback) {
this.readOnly = readOnly;
this.txnCallback = txnCallback;
this.errorCallback = errorCallback;
this.successCallback = successCallback;
}
function WebSQLDatabase(dbVersion, db) {
this.version = dbVersion;
this._db = db;
this._txnQueue = new Queue();
this._running = false;
this._currentTask = null;
}
WebSQLDatabase.prototype._onTransactionComplete = function(err) {
var self = this;
function done() {
if (err) {
self._currentTask.errorCallback(err);
} else {
self._currentTask.successCallback();
}
self._running = false;
self._currentTask = null;
self._runNextTransaction();
}
if (self._currentTask.readOnly) {
done(); // read-only doesn't require a transaction
} else if (err) {
self._db.exec(ROLLBACK, false, done);
} else {
self._db.exec(COMMIT, false, done);
}
};
WebSQLDatabase.prototype._runTransaction = function () {
var self = this;
var txn = new WebSQLTransaction(self);
immediate(function () {
self._currentTask.txnCallback(txn);
txn._checkDone();
});
};
WebSQLDatabase.prototype._runNextTransaction = function() {
if (this._running) {
return;
}
var task = this._txnQueue.shift();
if (!task) {
return;
}
this._currentTask = task;
this._running = true;
this._runTransaction();
};
WebSQLDatabase.prototype._createTransaction = function(
readOnly, txnCallback, errorCallback, successCallback) {
errorCallback = errorCallback || noop;
successCallback = successCallback || noop;
if (typeof txnCallback !== 'function') {
throw new Error('The callback provided as parameter 1 is not a function.');
}
this._txnQueue.push(new TransactionTask(readOnly, txnCallback, errorCallback, successCallback));
this._runNextTransaction();
};
WebSQLDatabase.prototype.transaction = function (txnCallback, errorCallback, successCallback) {
this._createTransaction(false, txnCallback, errorCallback, successCallback);
};
WebSQLDatabase.prototype.readTransaction = function (txnCallback, errorCallback, successCallback) {
this._createTransaction(true, txnCallback, errorCallback, successCallback);
};
module.exports = WebSQLDatabase;

View File

@ -0,0 +1,18 @@
'use strict';
function WebSQLRows(array) {
this._array = array;
this.length = array.length;
}
WebSQLRows.prototype.item = function (i) {
return this._array[i];
};
function WebSQLResultSet(insertId, rowsAffected, rows) {
this.insertId = insertId;
this.rowsAffected = rowsAffected;
this.rows = new WebSQLRows(rows);
}
module.exports = WebSQLResultSet;

View File

@ -0,0 +1,132 @@
'use strict';
var noop = require('noop-fn');
var Queue = require('tiny-queue');
var immediate = require('immediate');
var WebSQLResultSet = require('./WebSQLResultSet');
function errorUnhandled() {
return true; // a non-truthy return indicates error was handled
}
// WebSQL has some bizarre behavior regarding insertId/rowsAffected. To try
// to match the observed behavior of Chrome/Safari as much as possible, we
// sniff the SQL message to try to massage the returned insertId/rowsAffected.
// This helps us pass the tests, although it's error-prone and should
// probably be revised.
function massageSQLResult(sql, insertId, rowsAffected, rows) {
if (/^\s*UPDATE\b/i.test(sql)) {
// insertId is always undefined for "UPDATE" statements
insertId = void 0;
} else if (/^\s*CREATE\s+TABLE\b/i.test(sql)) {
// WebSQL always returns an insertId of 0 for "CREATE TABLE" statements
insertId = 0;
rowsAffected = 0;
} else if (/^\s*DROP\s+TABLE\b/i.test(sql)) {
// WebSQL always returns insertId=undefined and rowsAffected=0
// for "DROP TABLE" statements. Go figure.
insertId = void 0;
rowsAffected = 0;
} else if (!/^\s*INSERT\b/i.test(sql)) {
// for all non-inserts (deletes, etc.) insertId is always undefined
// ¯\_(ツ)_/¯
insertId = void 0;
}
return new WebSQLResultSet(insertId, rowsAffected, rows);
}
function SQLTask(sql, args, sqlCallback, sqlErrorCallback) {
this.sql = sql;
this.args = args;
this.sqlCallback = sqlCallback;
this.sqlErrorCallback = sqlErrorCallback;
}
function runBatch(self, batch) {
function onDone() {
self._running = false;
runAllSql(self);
}
var readOnly = self._websqlDatabase._currentTask.readOnly;
self._websqlDatabase._db.exec(batch, readOnly, function (err, results) {
/* istanbul ignore next */
if (err) {
self._error = err;
return onDone();
}
for (var i = 0; i < results.length; i++) {
var res = results[i];
var batchTask = batch[i];
if (res.error) {
if (batchTask.sqlErrorCallback(self, res.error)) {
// user didn't handle the error
self._error = res.error;
return onDone();
}
} else {
batchTask.sqlCallback(self, massageSQLResult(
batch[i].sql, res.insertId, res.rowsAffected, res.rows));
}
}
onDone();
});
}
function runAllSql(self) {
if (self._running || self._complete) {
return;
}
if (self._error || !self._sqlQueue.length) {
self._complete = true;
return self._websqlDatabase._onTransactionComplete(self._error);
}
self._running = true;
var batch = [];
var task;
while ((task = self._sqlQueue.shift())) {
batch.push(task);
}
runBatch(self, batch);
}
function executeSql(self, sql, args, sqlCallback, sqlErrorCallback) {
self._sqlQueue.push(new SQLTask(sql, args, sqlCallback, sqlErrorCallback));
if (self._runningTimeout) {
return;
}
self._runningTimeout = true;
immediate(function () {
self._runningTimeout = false;
runAllSql(self);
});
}
function WebSQLTransaction(websqlDatabase) {
this._websqlDatabase = websqlDatabase;
this._error = null;
this._complete = false;
this._runningTimeout = false;
this._sqlQueue = new Queue();
if (!websqlDatabase._currentTask.readOnly) {
// Since we serialize all access to the database, there is no need to
// run read-only tasks in a transaction. This is a perf boost.
this._sqlQueue.push(new SQLTask('BEGIN;', [], noop, noop));
}
}
WebSQLTransaction.prototype.executeSql = function (sql, args, sqlCallback, sqlErrorCallback) {
args = Array.isArray(args) ? args : [];
sqlCallback = typeof sqlCallback === 'function' ? sqlCallback : noop;
sqlErrorCallback = typeof sqlErrorCallback === 'function' ? sqlErrorCallback : errorUnhandled;
executeSql(this, sql, args, sqlCallback, sqlErrorCallback);
};
WebSQLTransaction.prototype._checkDone = function () {
runAllSql(this);
};
module.exports = WebSQLTransaction;

81
node_modules/@expo/websql/package.json generated vendored Normal file
View File

@ -0,0 +1,81 @@
{
"name": "@expo/websql",
"version": "1.0.1",
"description": "WebSQL Database API, implemented for Node using sqlite3",
"repository": {
"type": "git",
"url": "git://github.com/nolanlawson/node-websql.git"
},
"bugs": {
"url": "https://github.com/nolanlawson/node-websql/issues"
},
"main": "lib/index.js",
"browser": {
"lib/index.js": "lib/browser.js",
"crypto": false,
"fs": false,
"levelup": false,
"leveldown": false,
"level": false,
"rimraf": false,
"mkdirp": false
},
"keywords": [
"websql",
"sql",
"opendatabase",
"sqlite",
"storage",
"sqlite3",
"database"
],
"scripts": {
"test": "mocha test/test.js",
"lint": "jshint -c .jshintrc lib test",
"test-debug": "mocha --debug-brk test/test.js",
"test-local": "zuul --no-coverage --local 9000 --ui mocha-bdd test/test.js",
"test-phantom": "zuul --no-coverage --phantom --ui mocha-bdd test/test.js",
"test-coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- test/test.js",
"ensure-coverage": "istanbul check-coverage --lines 100 --function 100 --statements 100 --branches 100",
"coverage": "npm run test-coverage && npm run ensure-coverage",
"report-coverage": "npm run test-coverage && istanbul-coveralls --no-rm"
},
"author": "Nolan Lawson <nolan@nolanlawson.com>",
"license": "Apache-2.0",
"dependencies": {
"argsarray": "^0.0.1",
"immediate": "^3.2.2",
"noop-fn": "^1.0.0",
"pouchdb-collections": "^1.0.1",
"tiny-queue": "^0.2.1"
},
"devDependencies": {
"assert": "1.3.0",
"bluebird": "3.3.5",
"chai": "3.5.0",
"chai-as-promised": "5.3.0",
"denodeify": "1.2.1",
"double-ended-queue": "2.1.0-0",
"istanbul": "0.4.3",
"istanbul-coveralls": "1.0.3",
"js-extend": "1.0.1",
"jshint": "2.8.0",
"level-write-stream": "1.0.0",
"levelup": "1.3.1",
"lie": "3.0.2",
"mkdirp": "0.5.1",
"mocha": "2.4.5",
"phantomjs-prebuilt": "2.1.7",
"pouchdb-collate": "1.2.0",
"rimraf": "2.5.2",
"scope-eval": "0.0.3",
"spark-md5": "2.0.2",
"sublevel-pouchdb": "1.0.0",
"vuvuzela": "1.0.3",
"zuul": "3.10.1"
},
"files": [
"lib",
"custom"
]
}