This commit is contained in:
parent
fa2be029a2
commit
724d70e58b
3339 changed files with 1075535 additions and 0 deletions
125
frontend/node_modules/tus-js-client/lib.es5/browser/urlStorage.js
generated
vendored
Normal file
125
frontend/node_modules/tus-js-client/lib.es5/browser/urlStorage.js
generated
vendored
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.canStoreURLs = exports.WebStorageUrlStorage = void 0;
|
||||
function _typeof(o) {
|
||||
"@babel/helpers - typeof";
|
||||
|
||||
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
||||
return typeof o;
|
||||
} : function (o) {
|
||||
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
||||
}, _typeof(o);
|
||||
}
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
function _defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
||||
}
|
||||
}
|
||||
function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
Object.defineProperty(Constructor, "prototype", {
|
||||
writable: false
|
||||
});
|
||||
return Constructor;
|
||||
}
|
||||
function _toPropertyKey(t) {
|
||||
var i = _toPrimitive(t, "string");
|
||||
return "symbol" == _typeof(i) ? i : i + "";
|
||||
}
|
||||
function _toPrimitive(t, r) {
|
||||
if ("object" != _typeof(t) || !t) return t;
|
||||
var e = t[Symbol.toPrimitive];
|
||||
if (void 0 !== e) {
|
||||
var i = e.call(t, r || "default");
|
||||
if ("object" != _typeof(i)) return i;
|
||||
throw new TypeError("@@toPrimitive must return a primitive value.");
|
||||
}
|
||||
return ("string" === r ? String : Number)(t);
|
||||
}
|
||||
var hasStorage = false;
|
||||
try {
|
||||
// Note: localStorage does not exist in the Web Worker's context, so we must use window here.
|
||||
hasStorage = 'localStorage' in window;
|
||||
|
||||
// Attempt to store and read entries from the local storage to detect Private
|
||||
// Mode on Safari on iOS (see #49)
|
||||
// If the key was not used before, we remove it from local storage again to
|
||||
// not cause confusion where the entry came from.
|
||||
var key = 'tusSupport';
|
||||
var originalValue = localStorage.getItem(key);
|
||||
localStorage.setItem(key, originalValue);
|
||||
if (originalValue === null) localStorage.removeItem(key);
|
||||
} catch (e) {
|
||||
// If we try to access localStorage inside a sandboxed iframe, a SecurityError
|
||||
// is thrown. When in private mode on iOS Safari, a QuotaExceededError is
|
||||
// thrown (see #49)
|
||||
if (e.code === e.SECURITY_ERR || e.code === e.QUOTA_EXCEEDED_ERR) {
|
||||
hasStorage = false;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
var canStoreURLs = exports.canStoreURLs = hasStorage;
|
||||
var WebStorageUrlStorage = exports.WebStorageUrlStorage = /*#__PURE__*/function () {
|
||||
function WebStorageUrlStorage() {
|
||||
_classCallCheck(this, WebStorageUrlStorage);
|
||||
}
|
||||
return _createClass(WebStorageUrlStorage, [{
|
||||
key: "findAllUploads",
|
||||
value: function findAllUploads() {
|
||||
var results = this._findEntries('tus::');
|
||||
return Promise.resolve(results);
|
||||
}
|
||||
}, {
|
||||
key: "findUploadsByFingerprint",
|
||||
value: function findUploadsByFingerprint(fingerprint) {
|
||||
var results = this._findEntries("tus::".concat(fingerprint, "::"));
|
||||
return Promise.resolve(results);
|
||||
}
|
||||
}, {
|
||||
key: "removeUpload",
|
||||
value: function removeUpload(urlStorageKey) {
|
||||
localStorage.removeItem(urlStorageKey);
|
||||
return Promise.resolve();
|
||||
}
|
||||
}, {
|
||||
key: "addUpload",
|
||||
value: function addUpload(fingerprint, upload) {
|
||||
var id = Math.round(Math.random() * 1e12);
|
||||
var key = "tus::".concat(fingerprint, "::").concat(id);
|
||||
localStorage.setItem(key, JSON.stringify(upload));
|
||||
return Promise.resolve(key);
|
||||
}
|
||||
}, {
|
||||
key: "_findEntries",
|
||||
value: function _findEntries(prefix) {
|
||||
var results = [];
|
||||
for (var i = 0; i < localStorage.length; i++) {
|
||||
var _key = localStorage.key(i);
|
||||
if (_key.indexOf(prefix) !== 0) continue;
|
||||
try {
|
||||
var upload = JSON.parse(localStorage.getItem(_key));
|
||||
upload.urlStorageKey = _key;
|
||||
results.push(upload);
|
||||
} catch (_e) {
|
||||
// The JSON parse error is intentionally ignored here, so a malformed
|
||||
// entry in the storage cannot prevent an upload.
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}]);
|
||||
}();
|
||||
Reference in a new issue