v1.2.2 - Fix network error on background, auto-retry streaming with reconnect

This commit is contained in:
admin
2026-05-19 15:50:45 +04:00
Unverified
parent 2e327317e4
commit 1026259a20
3831 changed files with 384316 additions and 39 deletions

16
node_modules/node-localstorage/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,16 @@
Copyright (c) 2011 Lawrence S. Maccherone, Jr.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

354
node_modules/node-localstorage/LocalStorage.js generated vendored Normal file
View File

@@ -0,0 +1,354 @@
// Generated by CoffeeScript 1.12.7
(function() {
var JSONStorage, KEY_FOR_EMPTY_STRING, LocalStorage, MetaKey, QUOTA_EXCEEDED_ERR, StorageEvent, _emptyDirectory, _escapeKey, _rm, createMap, events, fs, path, writeSync,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
path = require('path');
fs = require('fs');
events = require('events');
writeSync = require('write-file-atomic').sync;
KEY_FOR_EMPTY_STRING = '---.EMPTY_STRING.---';
_emptyDirectory = function(target) {
var i, len, p, ref, results;
ref = fs.readdirSync(target);
results = [];
for (i = 0, len = ref.length; i < len; i++) {
p = ref[i];
results.push(_rm(path.join(target, p)));
}
return results;
};
_rm = function(target) {
if (fs.statSync(target).isDirectory()) {
_emptyDirectory(target);
return fs.rmdirSync(target);
} else {
return fs.unlinkSync(target);
}
};
_escapeKey = function(key) {
var newKey;
if (key === '') {
newKey = KEY_FOR_EMPTY_STRING;
} else {
newKey = "" + key;
}
return newKey;
};
QUOTA_EXCEEDED_ERR = (function(superClass) {
extend(QUOTA_EXCEEDED_ERR, superClass);
function QUOTA_EXCEEDED_ERR(message) {
this.message = message != null ? message : 'Unknown error.';
QUOTA_EXCEEDED_ERR.__super__.constructor.call(this);
if (Error.captureStackTrace != null) {
Error.captureStackTrace(this, this.constructor);
}
this.name = this.constructor.name;
}
QUOTA_EXCEEDED_ERR.prototype.toString = function() {
return this.name + ": " + this.message;
};
return QUOTA_EXCEEDED_ERR;
})(Error);
StorageEvent = (function() {
function StorageEvent(key1, oldValue1, newValue1, url, storageArea) {
this.key = key1;
this.oldValue = oldValue1;
this.newValue = newValue1;
this.url = url;
this.storageArea = storageArea != null ? storageArea : 'localStorage';
}
return StorageEvent;
})();
MetaKey = (function() {
function MetaKey(key1, index1) {
this.key = key1;
this.index = index1;
if (!(this instanceof MetaKey)) {
return new MetaKey(this.key, this.index);
}
}
return MetaKey;
})();
createMap = function() {
var Map;
Map = function() {};
Map.prototype = Object.create(null);
return new Map();
};
LocalStorage = (function(superClass) {
var instanceMap;
extend(LocalStorage, superClass);
instanceMap = {};
function LocalStorage(_location, quota) {
var handler;
this._location = _location;
this.quota = quota != null ? quota : 5 * 1024 * 1024;
LocalStorage.__super__.constructor.call(this);
if (!(this instanceof LocalStorage)) {
return new LocalStorage(this._location, this.quota);
}
this._location = path.resolve(this._location);
if (instanceMap[this._location] != null) {
return instanceMap[this._location];
}
this.length = 0;
this._bytesInUse = 0;
this._keys = [];
this._metaKeyMap = createMap();
this._eventUrl = "pid:" + process.pid;
this._init();
this._QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR;
if (typeof Proxy !== "undefined" && Proxy !== null) {
handler = {
set: (function(_this) {
return function(receiver, key, value) {
if (_this[key] != null) {
return _this[key] = value;
} else {
return _this.setItem(key, value);
}
};
})(this),
get: (function(_this) {
return function(receiver, key) {
if (_this[key] != null) {
return _this[key];
} else {
return _this.getItem(key);
}
};
})(this)
};
instanceMap[this._location] = new Proxy(this, handler);
return instanceMap[this._location];
}
instanceMap[this._location] = this;
return instanceMap[this._location];
}
LocalStorage.prototype._init = function() {
var _MetaKey, _decodedKey, _keys, e, i, index, k, len, stat;
try {
stat = fs.statSync(this._location);
if ((stat != null) && !stat.isDirectory()) {
throw new Error("A file exists at the location '" + this._location + "' when trying to create/open localStorage");
}
this._bytesInUse = 0;
this.length = 0;
_keys = fs.readdirSync(this._location);
for (index = i = 0, len = _keys.length; i < len; index = ++i) {
k = _keys[index];
_decodedKey = decodeURIComponent(k);
this._keys.push(_decodedKey);
_MetaKey = new MetaKey(k, index);
this._metaKeyMap[_decodedKey] = _MetaKey;
stat = this._getStat(k);
if ((stat != null ? stat.size : void 0) != null) {
_MetaKey.size = stat.size;
this._bytesInUse += stat.size;
}
}
this.length = _keys.length;
} catch (error) {
e = error;
if (e.code !== "ENOENT") {
throw e;
}
try {
fs.mkdirSync(this._location, {
recursive: true
});
} catch (error) {
e = error;
if (e.code !== "EEXIST") {
throw e;
}
}
}
};
LocalStorage.prototype.setItem = function(key, value) {
var encodedKey, evnt, existsBeforeSet, filename, hasListeners, metaKey, oldLength, oldValue, valueString, valueStringLength;
hasListeners = this.listenerCount('storage');
oldValue = null;
if (hasListeners) {
oldValue = this.getItem(key);
}
key = _escapeKey(key);
encodedKey = encodeURIComponent(key).replace(/[!'()]/g, escape).replace(/\*/g, "%2A");
filename = path.join(this._location, encodedKey);
valueString = "" + value;
valueStringLength = valueString.length;
metaKey = this._metaKeyMap[key];
existsBeforeSet = !!metaKey;
if (existsBeforeSet) {
oldLength = metaKey.size;
} else {
oldLength = 0;
}
if (this._bytesInUse - oldLength + valueStringLength > this.quota) {
throw new QUOTA_EXCEEDED_ERR();
}
writeSync(filename, valueString, {
encoding: 'utf8'
});
if (!existsBeforeSet) {
metaKey = new MetaKey(encodedKey, (this._keys.push(key)) - 1);
metaKey.size = valueStringLength;
this._metaKeyMap[key] = metaKey;
this.length += 1;
this._bytesInUse += valueStringLength;
}
if (hasListeners) {
evnt = new StorageEvent(key, oldValue, value, this._eventUrl);
return this.emit('storage', evnt);
}
};
LocalStorage.prototype.getItem = function(key) {
var filename, metaKey;
key = _escapeKey(key);
metaKey = this._metaKeyMap[key];
if (!!metaKey) {
filename = path.join(this._location, metaKey.key);
return fs.readFileSync(filename, 'utf8');
} else {
return null;
}
};
LocalStorage.prototype._getStat = function(key) {
var filename;
key = _escapeKey(key);
filename = path.join(this._location, encodeURIComponent(key));
try {
return fs.statSync(filename);
} catch (error) {
return null;
}
};
LocalStorage.prototype.removeItem = function(key) {
var evnt, filename, hasListeners, k, meta, metaKey, oldValue, ref, v;
key = _escapeKey(key);
metaKey = this._metaKeyMap[key];
if (!!metaKey) {
hasListeners = this.listenerCount('storage');
oldValue = null;
if (hasListeners) {
oldValue = this.getItem(key);
}
delete this._metaKeyMap[key];
this.length -= 1;
this._bytesInUse -= metaKey.size;
filename = path.join(this._location, metaKey.key);
this._keys.splice(metaKey.index, 1);
ref = this._metaKeyMap;
for (k in ref) {
v = ref[k];
meta = this._metaKeyMap[k];
if (meta.index > metaKey.index) {
meta.index -= 1;
}
}
_rm(filename);
if (hasListeners) {
evnt = new StorageEvent(key, oldValue, null, this._eventUrl);
return this.emit('storage', evnt);
}
}
};
LocalStorage.prototype.key = function(n) {
var rawKey;
rawKey = this._keys[n];
if (rawKey === KEY_FOR_EMPTY_STRING) {
return '';
} else {
return rawKey;
}
};
LocalStorage.prototype.clear = function() {
var evnt;
_emptyDirectory(this._location);
this._metaKeyMap = createMap();
this._keys = [];
this.length = 0;
this._bytesInUse = 0;
if (this.listenerCount('storage')) {
evnt = new StorageEvent(null, null, null, this._eventUrl);
return this.emit('storage', evnt);
}
};
LocalStorage.prototype._getBytesInUse = function() {
return this._bytesInUse;
};
LocalStorage.prototype._deleteLocation = function() {
delete instanceMap[this._location];
_rm(this._location);
this._metaKeyMap = {};
this._keys = [];
this.length = 0;
return this._bytesInUse = 0;
};
return LocalStorage;
})(events.EventEmitter);
JSONStorage = (function(superClass) {
extend(JSONStorage, superClass);
function JSONStorage() {
return JSONStorage.__super__.constructor.apply(this, arguments);
}
JSONStorage.prototype.setItem = function(key, value) {
var newValue;
newValue = JSON.stringify(value);
return JSONStorage.__super__.setItem.call(this, key, newValue);
};
JSONStorage.prototype.getItem = function(key) {
return JSON.parse(JSONStorage.__super__.getItem.call(this, key));
};
return JSONStorage;
})(LocalStorage);
exports.LocalStorage = LocalStorage;
exports.JSONStorage = JSONStorage;
exports.QUOTA_EXCEEDED_ERR = QUOTA_EXCEEDED_ERR;
}).call(this);

128
node_modules/node-localstorage/README.md generated vendored Normal file
View File

@@ -0,0 +1,128 @@
[![build status](https://secure.travis-ci.org/lmaccherone/node-localstorage.png)](http://travis-ci.org/lmaccherone/node-localstorage)
# node-localstorage #
Copyright (c) 2012, Lawrence S. Maccherone, Jr.
_A drop-in substitute for the browser native localStorage API that runs on node.js._
### Fully implements the localStorage specfication including: ###
* All methods in the [localStorage spec](http://www.w3.org/TR/webstorage/#storage)
interface including:
* length
* setItem(key, value)
* getItem(key)
* removeItem(key)
* key(n)
* clear()
* Serializes to disk in the location specified during instantiation
* Supports the setting of a quota (default 5MB)
* Events. Follows the spec in all ways that make sense for node.js.
However, the spec states that events are NOT supposed to be emitted to the
browser window that took the action that triggered the event in the first place.
Since we don't really have the equivalent of a browser window in node.js, we trigger
events in the current process.
* Associative array `localStorage['myKey'] = 'myValue'` and dot property `localStorage.myKey = 'myValue'`
syntax. If you are in an ES6 supported environment.
### Limitations:
* When using Associative array or dot property syntax, you cannot use keys that
collide with my "private" properties and methods including keys that start
with "_" like "_init"
* If you specify a location that already has files in it when you create an
instance, you might already exceed the quota or might do so sooner than you
expect. This is intentional because we want it to behave like the browser
and persist the storage even after your program is restarted.
## Credits ##
Author: [Larry Maccherone](http://maccherone.com)
## Usage ##
### CoffeeScript ###
```coffee
unless localStorage?
{LocalStorage} = require('../') # require('node-localstorage') for you
localStorage = new LocalStorage('./scratch')
localStorage.setItem('myFirstKey', 'myFirstValue')
console.log(localStorage.getItem('myFirstKey'))
# myFirstValue
localStorage._deleteLocation() # cleans up ./scratch created during doctest
```
### ReactJs ###
Open or create `src/setupTests.js` and add these two lines:
``` JavaScript
// /src/setupTests.js
import { LocalStorage } from "node-localstorage";
global.localStorage = new LocalStorage('./scratch');
```
### JavaScript ###
```JavaScript
if (typeof localStorage === "undefined" || localStorage === null) {
var LocalStorage = require('node-localstorage').LocalStorage;
localStorage = new LocalStorage('./scratch');
}
localStorage.setItem('myFirstKey', 'myFirstValue');
console.log(localStorage.getItem('myFirstKey'));
```
### Polyfill on Node.js ###
Polyfil your node.js environment with this as the global localStorage when launching your own code
```sh
node -r node-localstorage/register my-code.js
```
## Installation ##
`npm install node-localstorage`
## Changelog ##
* 2.2.1 - 2021-06-04 - Fixed serveral small issues reported by users
* 2.1.7 - 2020-06-08 - Fixed stringifying null and undefined (thanks @gamesaucer)
* 2.1.6 - 2020-04-10 - Fix backward compatibility bug (thanks @WillBartee)
* 2.1.5 - 2019-12-02 - Fixed empty string key(n) return (@appy-one, thanks for reporting)
* 2.1.2 thru 2.1.4 - 2019-11-17 - Upgrading and testing npm publish scripts
* 2.1.1 - 2019-11-17 - npm publish cleanup
* 2.1.0 - 2019-11-17 - Added back dot-property and associative-array syntax using ES6 Proxy
* 2.0.0 - 2019-11-17 - Updated all the depdendencies, added ability to register as polyfill (thanks @dy)
* 1.3.1 - 2018-03-19 - Resolves issue #32 (thanks, plamens)
* 1.3.0 - 2016-04-09 - **Possibly backward breaking if you were using experimental syntax** Reverted experimental
associative array and dot-property syntax. The API for Proxy changed with node.js v6.x which broke it. Then when
I switched to the new syntax, it broke the EventEmitter functionality. Will restore once I know how to fix that.
* 1.2.0 - 2016-04-09 - Atomic writes (thanks, mvayngrib)
* 1.1.2 - 2016-01-08 - Resolves issue #17 (thanks, evilaliv3)
* 1.1.1 - 2016-01-04 - Smarter associative array and dot-property syntax support
* 1.1.0 - 2016-01-03 - **Backward breaking** if you used any of the non-standard methods. They are now all preceded with
an underscore. Big upgrade for this version is experimental support for associative array and dot-property syntax.
* 1.0.0 - 2016-01-03 - Fixed bug with empty string key (thanks, tinybike)
* 0.6.0 - 2015-09-11 - Removed references to deprecated fs.existsSync() (thanks, josephbosire)
* 0.5.2 - 2015-08-01 - Fixed defect where keys were not being updated correctly by removeItem() (thanks, ed69140)
* 0.5.1 - 2015-06-01 - Added support for events
* 0.5.0 - 2015-02-02 - Added JSONStorage class which allows you set and get native JSON
* 0.4.1 - 2015-02-02 - More robust publishing/tagging (like Lumenize)
* 0.4.0 - 2015-02-02 - Uses more efficient fs.statSync to set initial size (thanks, sudheer594)
* 0.3.6 - 2014-12-24 - Allows usage without `new`
* 0.3.5 - 2014-12-23 - Fixed toString() for QuotaExceededError
* 0.3.4 - 2013-07-07 - Moved CoffeeScript to devDependencies
* 0.3.3 - 2013-04-05 - Added support for '/' in keys by escaping before creating file names
* 0.3.2 - 2013-01-19 - Renamed QuotaExceededError to QUOTA_EXCEEDED_ERR to match most browsers
* 0.3.1 - 2013-01-19 - Fixed bug where it threw plain old Error instead of new QuotaExceededError
* 0.3.0 - 2013-01-19 - Added QuotaExceededError support
* 0.2.0 - 2013-01-03 - Added quota support
* 0.1.2 - 2012-11-02 - Finally got Travis CI working
* 0.1.1 - 2012-10-29 - Update to support Travis CI
* 0.1.0 - 2012-10-29 - Original version

48
node_modules/node-localstorage/package.json generated vendored Normal file
View File

@@ -0,0 +1,48 @@
{
"name": "node-localstorage",
"version": "2.2.1",
"main": "./LocalStorage",
"description": "A drop-in substitute for the browser native localStorage API that runs on node.js.",
"keywords": [
"localStorage",
"Web Storage",
"node.js"
],
"author": {
"name": "Larry Maccherone",
"url": "http://maccherone.com"
},
"homepage": "https://github.com/lmaccherone/node-localstorage",
"engines": {
"node": ">=0.12"
},
"repository": {
"type": "git",
"url": "http://github.com/lmaccherone/node-localstorage.git"
},
"preferGlobal": false,
"devDependencies": {
"coffeescript": "^1.12.7",
"coffeetape": "^2.0.0",
"lodash": "^4.17.15",
"nyc": "^14.1.1",
"tap-nyc": "^1.0.3",
"tap-spec": "^5.0.0"
},
"scripts": {
"test": "npm run build && coffeetape test/*.coffee | tap-spec",
"coverage": "npm run build && nyc --reporter=lcov coffeetape test/*.coffee | tap-nyc",
"coverage:summary": "nyc report --reporter=text-summary",
"coverage:report": "python3 -m http.server 3000 -d coverage/lcov-report",
"publish:patch": "npm run test && npm version patch && npm publish",
"publish:minor": "npm run test && npm version minor && npm publish",
"publish:major": "npm run test && npm version major && npm publish",
"postpublish": "git push --tags",
"build": "coffee -c LocalStorage.coffee",
"prepublishOnly": "coffee -c LocalStorage.coffee"
},
"license": "MIT",
"dependencies": {
"write-file-atomic": "^1.1.4"
}
}

4
node_modules/node-localstorage/register.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
if (typeof localStorage === "undefined" || localStorage === null) {
var LocalStorage = require('node-localstorage').LocalStorage;
global.localStorage = new LocalStorage('./scratch');
}