mirror of
https://github.com/HeyPuter/puter.git
synced 2026-10-25 08:09:15 +00:00
dead code cleanup (#3441)
This commit is contained in:
1 parent
cade75ac9b
commit
8732494442
25 files changed
+88
-5097
No files matched your search
Generated
+66
-2
@@ -1304,7 +1304,6 @@
|
||||
},
|
||||
"node_modules/@clack/prompts/node_modules/is-unicode-supported": {
|
||||
"version": "1.3.0",
|
||||
"extraneous": true,
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -9933,6 +9932,40 @@
|
||||
"node": ">=10.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-client": {
|
||||
"version": "6.5.4",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.4.tgz",
|
||||
"integrity": "sha512-GeZeeRjpD2qf49cZQ0Wvh/8NJNfeXkXXcoGh+F77oEAgo9gUHwT1fCRxSNU+YEEaysOJTnsFHmM5oAcPy4ntvQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@socket.io/component-emitter": "~3.1.0",
|
||||
"debug": "~4.3.1",
|
||||
"engine.io-parser": "~5.2.1",
|
||||
"ws": "~8.17.1",
|
||||
"xmlhttprequest-ssl": "~2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-client/node_modules/ws": {
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
|
||||
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-parser": {
|
||||
"version": "5.2.3",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz",
|
||||
@@ -15468,6 +15501,12 @@
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/path-browserify": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz",
|
||||
"integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/path-exists": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
|
||||
@@ -17299,6 +17338,21 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-client": {
|
||||
"version": "4.7.2",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.2.tgz",
|
||||
"integrity": "sha512-vtA0uD4ibrYD793SOIAwlo8cj6haOeMHrGvwPxJsxH7CeIksqJ+3Zc06RvWTIFgiSqx4A3sOnTXpfAEE2Zyz6w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@socket.io/component-emitter": "~3.1.0",
|
||||
"debug": "~4.3.2",
|
||||
"engine.io-client": "~6.5.2",
|
||||
"socket.io-parser": "~4.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-parser": {
|
||||
"version": "4.2.6",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.6.tgz",
|
||||
@@ -19190,6 +19244,14 @@
|
||||
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/xmlhttprequest-ssl": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz",
|
||||
"integrity": "sha512-QKxVRxiRACQcVuQEYFsI1hhkrMlrXHPegbbd1yn9UHOmRxY+si12nQYzri3vbzt8VdTTRviqcKxcyllFas5z2A==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
@@ -20194,7 +20256,9 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@heyputer/kv.js": "^0.2.1",
|
||||
"open": "^10.2.0"
|
||||
"open": "^10.2.0",
|
||||
"path-browserify": "1.0.1",
|
||||
"socket.io-client": "4.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.49.0",
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@heyputer/kv.js": "^0.2.1",
|
||||
"open": "^10.2.0"
|
||||
"open": "^10.2.0",
|
||||
"path-browserify": "1.0.1",
|
||||
"socket.io-client": "4.7.2"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import kvjs from '@heyputer/kv.js';
|
||||
import APICallLogger from './lib/APICallLogger.js';
|
||||
import { fetchUrl } from './lib/networkUtils.js';
|
||||
import { isStoredTokenUsableForOrigin } from './lib/authTokenOrigin.js';
|
||||
import path from './lib/path.js';
|
||||
import path from 'path-browserify';
|
||||
import localStorageMemory from './lib/polyfills/localStorage.js';
|
||||
import xhrshim from './lib/polyfills/xhrshim.js';
|
||||
import * as utils from './lib/utils.js';
|
||||
@@ -1673,7 +1673,6 @@ globalThis.addEventListener &&
|
||||
'*',
|
||||
);
|
||||
} else if (event.data.msg === 'puter.token') {
|
||||
// puterDialog.close();
|
||||
// Set the authToken property
|
||||
puter.setAuthToken(event.data.token);
|
||||
// update appID only when token does not include app identity
|
||||
@@ -1686,12 +1685,8 @@ globalThis.addEventListener &&
|
||||
puter.setAppID(fallbackAppID);
|
||||
}
|
||||
}
|
||||
// Remove the event listener to avoid memory leaks
|
||||
// window.removeEventListener('message', messageListener);
|
||||
|
||||
puter.puterAuthState.authGranted = true;
|
||||
// Resolve the promise
|
||||
// resolve();
|
||||
|
||||
// Call onAuth callback
|
||||
if (puter.onAuth && typeof puter.onAuth === 'function') {
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export class RequestError extends Error {
|
||||
constructor (message) {
|
||||
super(message);
|
||||
this.name = 'RequestError'; // thanks minifier
|
||||
}
|
||||
}
|
||||
@@ -1,568 +0,0 @@
|
||||
// import {cwd} from './env.js'
|
||||
let cwd;
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
//'use strict';
|
||||
|
||||
const
|
||||
CHAR_UPPERCASE_A = 65,
|
||||
CHAR_LOWERCASE_A = 97,
|
||||
CHAR_UPPERCASE_Z = 90,
|
||||
CHAR_LOWERCASE_Z = 122,
|
||||
CHAR_DOT = 46,
|
||||
CHAR_FORWARD_SLASH = 47,
|
||||
CHAR_BACKWARD_SLASH = 92,
|
||||
CHAR_COLON = 58,
|
||||
CHAR_QUESTION_MARK = 63;
|
||||
|
||||
function isPathSeparator (code) {
|
||||
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
||||
}
|
||||
|
||||
function isPosixPathSeparator (code) {
|
||||
return code === CHAR_FORWARD_SLASH;
|
||||
}
|
||||
|
||||
// Resolves . and .. elements in a path with directory names
|
||||
function normalizeString (path, allowAboveRoot, separator, isPathSeparator) {
|
||||
let res = '';
|
||||
let lastSegmentLength = 0;
|
||||
let lastSlash = -1;
|
||||
let dots = 0;
|
||||
let code = 0;
|
||||
for ( let i = 0; i <= path.length; ++i ) {
|
||||
if ( i < path.length )
|
||||
{
|
||||
code = path.charCodeAt(i);
|
||||
}
|
||||
else if ( isPathSeparator(code) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
code = CHAR_FORWARD_SLASH;
|
||||
}
|
||||
|
||||
if ( isPathSeparator(code) ) {
|
||||
if ( lastSlash === i - 1 || dots === 1 ) {
|
||||
// NOOP
|
||||
} else if ( dots === 2 ) {
|
||||
if ( res.length < 2 || lastSegmentLength !== 2 ||
|
||||
res.charCodeAt(res.length - 1) !== CHAR_DOT ||
|
||||
res.charCodeAt(res.length - 2) !== CHAR_DOT ) {
|
||||
if ( res.length > 2 ) {
|
||||
const lastSlashIndex = res.lastIndexOf(separator);
|
||||
if ( lastSlashIndex === -1 ) {
|
||||
res = '';
|
||||
lastSegmentLength = 0;
|
||||
} else {
|
||||
res = res.slice(0, lastSlashIndex);
|
||||
lastSegmentLength =
|
||||
res.length - 1 - res.lastIndexOf(res, separator);
|
||||
}
|
||||
lastSlash = i;
|
||||
dots = 0;
|
||||
continue;
|
||||
} else if ( res.length !== 0 ) {
|
||||
res = '';
|
||||
lastSegmentLength = 0;
|
||||
lastSlash = i;
|
||||
dots = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ( allowAboveRoot ) {
|
||||
res += res.length > 0 ? `${separator}..` : '..';
|
||||
lastSegmentLength = 2;
|
||||
}
|
||||
} else {
|
||||
if ( res.length > 0 )
|
||||
{
|
||||
res += `${separator}${path.slice(lastSlash + 1, i)}`;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = path.slice(lastSlash + 1, i);
|
||||
}
|
||||
lastSegmentLength = i - lastSlash - 1;
|
||||
}
|
||||
lastSlash = i;
|
||||
dots = 0;
|
||||
} else if ( code === CHAR_DOT && dots !== -1 ) {
|
||||
++dots;
|
||||
} else {
|
||||
dots = -1;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
const path = {
|
||||
// path.resolve([from ...], to)
|
||||
resolve (...args) {
|
||||
let resolvedPath = '';
|
||||
let resolvedAbsolute = false;
|
||||
|
||||
for ( let i = args.length - 1; i >= -1 && !resolvedAbsolute; i-- ) {
|
||||
// orig const path = i >= 0 ? args[i] : posixCwd();
|
||||
const path = i >= 0 ? args[i] : (cwd !== undefined ? cwd : '/');
|
||||
// const path = i >= 0 ? args[i] : '/';
|
||||
|
||||
// Skip empty entries
|
||||
if ( path.length === 0 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
resolvedPath = `${path}/${resolvedPath}`;
|
||||
resolvedAbsolute =
|
||||
path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
||||
}
|
||||
|
||||
// At this point the path should be resolved to a full absolute path, but
|
||||
// handle relative paths to be safe (might happen when process.cwd() fails)
|
||||
|
||||
// Normalize the path
|
||||
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, '/', isPosixPathSeparator);
|
||||
|
||||
if ( resolvedAbsolute ) {
|
||||
return `/${resolvedPath}`;
|
||||
}
|
||||
return resolvedPath.length > 0 ? resolvedPath : '.';
|
||||
},
|
||||
|
||||
normalize (path) {
|
||||
if ( path.length === 0 )
|
||||
{
|
||||
return '.';
|
||||
}
|
||||
|
||||
const isAbsolute =
|
||||
path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
||||
const trailingSeparator =
|
||||
path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH;
|
||||
|
||||
// Normalize the path
|
||||
path = normalizeString(path, !isAbsolute, '/', isPosixPathSeparator);
|
||||
|
||||
if ( path.length === 0 ) {
|
||||
if ( isAbsolute )
|
||||
{
|
||||
return '/';
|
||||
}
|
||||
return trailingSeparator ? './' : '.';
|
||||
}
|
||||
if ( trailingSeparator )
|
||||
{
|
||||
path += '/';
|
||||
}
|
||||
|
||||
return isAbsolute ? `/${path}` : path;
|
||||
},
|
||||
|
||||
isAbsolute (path) {
|
||||
return path.length > 0 &&
|
||||
path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
||||
},
|
||||
|
||||
join (...args) {
|
||||
if ( args.length === 0 )
|
||||
{
|
||||
return '.';
|
||||
}
|
||||
let joined;
|
||||
for ( let i = 0; i < args.length; ++i ) {
|
||||
const arg = args[i];
|
||||
if ( arg.length > 0 ) {
|
||||
if ( joined === undefined )
|
||||
{
|
||||
joined = arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
joined += `/${arg}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( joined === undefined )
|
||||
{
|
||||
return '.';
|
||||
}
|
||||
return path.normalize(joined);
|
||||
},
|
||||
|
||||
relative (from, to) {
|
||||
if ( from === to )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// Trim leading forward slashes.
|
||||
from = path.resolve(from);
|
||||
to = path.resolve(to);
|
||||
|
||||
if ( from === to )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
const fromStart = 1;
|
||||
const fromEnd = from.length;
|
||||
const fromLen = fromEnd - fromStart;
|
||||
const toStart = 1;
|
||||
const toLen = to.length - toStart;
|
||||
|
||||
// Compare paths to find the longest common path from root
|
||||
const length = (fromLen < toLen ? fromLen : toLen);
|
||||
let lastCommonSep = -1;
|
||||
let i = 0;
|
||||
for ( ; i < length; i++ ) {
|
||||
const fromCode = from.charCodeAt(fromStart + i);
|
||||
if ( fromCode !== to.charCodeAt(toStart + i) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if ( fromCode === CHAR_FORWARD_SLASH )
|
||||
{
|
||||
lastCommonSep = i;
|
||||
}
|
||||
}
|
||||
if ( i === length ) {
|
||||
if ( toLen > length ) {
|
||||
if ( to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH ) {
|
||||
// We get here if `from` is the exact base path for `to`.
|
||||
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
||||
return to.slice(toStart + i + 1);
|
||||
}
|
||||
if ( i === 0 ) {
|
||||
// We get here if `from` is the root
|
||||
// For example: from='/'; to='/foo'
|
||||
return to.slice(toStart + i);
|
||||
}
|
||||
} else if ( fromLen > length ) {
|
||||
if ( from.charCodeAt(fromStart + i) ===
|
||||
CHAR_FORWARD_SLASH ) {
|
||||
// We get here if `to` is the exact base path for `from`.
|
||||
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
||||
lastCommonSep = i;
|
||||
} else if ( i === 0 ) {
|
||||
// We get here if `to` is the root.
|
||||
// For example: from='/foo/bar'; to='/'
|
||||
lastCommonSep = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let out = '';
|
||||
// Generate the relative path based on the path difference between `to`
|
||||
// and `from`.
|
||||
for ( i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i ) {
|
||||
if ( i === fromEnd ||
|
||||
from.charCodeAt(i) === CHAR_FORWARD_SLASH ) {
|
||||
out += out.length === 0 ? '..' : '/..';
|
||||
}
|
||||
}
|
||||
|
||||
// Lastly, append the rest of the destination (`to`) path that comes after
|
||||
// the common path parts.
|
||||
return `${out}${to.slice(toStart + lastCommonSep)}`;
|
||||
},
|
||||
|
||||
toNamespacedPath (path) {
|
||||
// Non-op on posix systems
|
||||
return path;
|
||||
},
|
||||
|
||||
dirname (path) {
|
||||
if ( path.length === 0 )
|
||||
{
|
||||
return '.';
|
||||
}
|
||||
const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
||||
let end = -1;
|
||||
let matchedSlash = true;
|
||||
for ( let i = path.length - 1; i >= 1; --i ) {
|
||||
if ( path.charCodeAt(i) === CHAR_FORWARD_SLASH ) {
|
||||
if ( ! matchedSlash ) {
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// We saw the first non-path separator
|
||||
matchedSlash = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( end === -1 )
|
||||
{
|
||||
return hasRoot ? '/' : '.';
|
||||
}
|
||||
if ( hasRoot && end === 1 )
|
||||
{
|
||||
return '//';
|
||||
}
|
||||
return path.slice(0, end);
|
||||
},
|
||||
|
||||
basename (path, ext) {
|
||||
let start = 0;
|
||||
let end = -1;
|
||||
let matchedSlash = true;
|
||||
|
||||
if ( ext !== undefined && ext.length > 0 && ext.length <= path.length ) {
|
||||
if ( ext === path )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
let extIdx = ext.length - 1;
|
||||
let firstNonSlashEnd = -1;
|
||||
for ( let i = path.length - 1; i >= 0; --i ) {
|
||||
const code = path.charCodeAt(i);
|
||||
if ( code === CHAR_FORWARD_SLASH ) {
|
||||
// If we reached a path separator that was not part of a set of path
|
||||
// separators at the end of the string, stop now
|
||||
if ( ! matchedSlash ) {
|
||||
start = i + 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ( firstNonSlashEnd === -1 ) {
|
||||
// We saw the first non-path separator, remember this index in case
|
||||
// we need it if the extension ends up not matching
|
||||
matchedSlash = false;
|
||||
firstNonSlashEnd = i + 1;
|
||||
}
|
||||
if ( extIdx >= 0 ) {
|
||||
// Try to match the explicit extension
|
||||
if ( code === ext.charCodeAt(extIdx) ) {
|
||||
if ( --extIdx === -1 ) {
|
||||
// We matched the extension, so mark this as the end of our path
|
||||
// component
|
||||
end = i;
|
||||
}
|
||||
} else {
|
||||
// Extension does not match, so our result is the entire path
|
||||
// component
|
||||
extIdx = -1;
|
||||
end = firstNonSlashEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( start === end )
|
||||
{
|
||||
end = firstNonSlashEnd;
|
||||
}
|
||||
else if ( end === -1 )
|
||||
{
|
||||
end = path.length;
|
||||
}
|
||||
return path.slice(start, end);
|
||||
}
|
||||
for ( let i = path.length - 1; i >= 0; --i ) {
|
||||
if ( path.charCodeAt(i) === CHAR_FORWARD_SLASH ) {
|
||||
// If we reached a path separator that was not part of a set of path
|
||||
// separators at the end of the string, stop now
|
||||
if ( ! matchedSlash ) {
|
||||
start = i + 1;
|
||||
break;
|
||||
}
|
||||
} else if ( end === -1 ) {
|
||||
// We saw the first non-path separator, mark this as the end of our
|
||||
// path component
|
||||
matchedSlash = false;
|
||||
end = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( end === -1 )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
return path.slice(start, end);
|
||||
},
|
||||
|
||||
extname (path) {
|
||||
let startDot = -1;
|
||||
let startPart = 0;
|
||||
let end = -1;
|
||||
let matchedSlash = true;
|
||||
// Track the state of characters (if any) we see before our first dot and
|
||||
// after any path separator we find
|
||||
let preDotState = 0;
|
||||
for ( let i = path.length - 1; i >= 0; --i ) {
|
||||
const code = path.charCodeAt(i);
|
||||
if ( code === CHAR_FORWARD_SLASH ) {
|
||||
// If we reached a path separator that was not part of a set of path
|
||||
// separators at the end of the string, stop now
|
||||
if ( ! matchedSlash ) {
|
||||
startPart = i + 1;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ( end === -1 ) {
|
||||
// We saw the first non-path separator, mark this as the end of our
|
||||
// extension
|
||||
matchedSlash = false;
|
||||
end = i + 1;
|
||||
}
|
||||
if ( code === CHAR_DOT ) {
|
||||
// If this is our first dot, mark it as the start of our extension
|
||||
if ( startDot === -1 )
|
||||
{
|
||||
startDot = i;
|
||||
}
|
||||
else if ( preDotState !== 1 )
|
||||
{
|
||||
preDotState = 1;
|
||||
}
|
||||
} else if ( startDot !== -1 ) {
|
||||
// We saw a non-dot and non-path separator before our dot, so we should
|
||||
// have a good chance at having a non-empty extension
|
||||
preDotState = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( startDot === -1 ||
|
||||
end === -1 ||
|
||||
// We saw a non-dot character immediately before the dot
|
||||
preDotState === 0 ||
|
||||
// The (right-most) trimmed path component is exactly '..'
|
||||
(preDotState === 1 &&
|
||||
startDot === end - 1 &&
|
||||
startDot === startPart + 1) ) {
|
||||
return '';
|
||||
}
|
||||
return path.slice(startDot, end);
|
||||
},
|
||||
|
||||
format: _format.bind(null, '/'),
|
||||
|
||||
parse (path) {
|
||||
const ret = { root: '', dir: '', base: '', ext: '', name: '' };
|
||||
if ( path.length === 0 )
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
const isAbsolute =
|
||||
path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
||||
let start;
|
||||
if ( isAbsolute ) {
|
||||
ret.root = '/';
|
||||
start = 1;
|
||||
} else {
|
||||
start = 0;
|
||||
}
|
||||
let startDot = -1;
|
||||
let startPart = 0;
|
||||
let end = -1;
|
||||
let matchedSlash = true;
|
||||
let i = path.length - 1;
|
||||
|
||||
// Track the state of characters (if any) we see before our first dot and
|
||||
// after any path separator we find
|
||||
let preDotState = 0;
|
||||
|
||||
// Get non-dir info
|
||||
for ( ; i >= start; --i ) {
|
||||
const code = path.charCodeAt(i);
|
||||
if ( code === CHAR_FORWARD_SLASH ) {
|
||||
// If we reached a path separator that was not part of a set of path
|
||||
// separators at the end of the string, stop now
|
||||
if ( ! matchedSlash ) {
|
||||
startPart = i + 1;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ( end === -1 ) {
|
||||
// We saw the first non-path separator, mark this as the end of our
|
||||
// extension
|
||||
matchedSlash = false;
|
||||
end = i + 1;
|
||||
}
|
||||
if ( code === CHAR_DOT ) {
|
||||
// If this is our first dot, mark it as the start of our extension
|
||||
if ( startDot === -1 )
|
||||
{
|
||||
startDot = i;
|
||||
}
|
||||
else if ( preDotState !== 1 )
|
||||
{
|
||||
preDotState = 1;
|
||||
}
|
||||
} else if ( startDot !== -1 ) {
|
||||
// We saw a non-dot and non-path separator before our dot, so we should
|
||||
// have a good chance at having a non-empty extension
|
||||
preDotState = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( end !== -1 ) {
|
||||
const start = startPart === 0 && isAbsolute ? 1 : startPart;
|
||||
if ( startDot === -1 ||
|
||||
// We saw a non-dot character immediately before the dot
|
||||
preDotState === 0 ||
|
||||
// The (right-most) trimmed path component is exactly '..'
|
||||
(preDotState === 1 &&
|
||||
startDot === end - 1 &&
|
||||
startDot === startPart + 1) ) {
|
||||
ret.base = ret.name = path.slice(start, end);
|
||||
} else {
|
||||
ret.name = path.slice(start, startDot);
|
||||
ret.base = path.slice(start, end);
|
||||
ret.ext = path.slice(startDot, end);
|
||||
}
|
||||
}
|
||||
|
||||
if ( startPart > 0 )
|
||||
{
|
||||
ret.dir = path.slice(0, startPart - 1);
|
||||
}
|
||||
else if ( isAbsolute )
|
||||
{
|
||||
ret.dir = '/';
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
sep: '/',
|
||||
delimiter: ':',
|
||||
win32: null,
|
||||
posix: null,
|
||||
};
|
||||
|
||||
function _format (sep, pathObject) {
|
||||
validateObject(pathObject, 'pathObject');
|
||||
const dir = pathObject.dir || pathObject.root;
|
||||
const base = pathObject.base ||
|
||||
`${pathObject.name || ''}${pathObject.ext || ''}`;
|
||||
if ( ! dir ) {
|
||||
return base;
|
||||
}
|
||||
return dir === pathObject.root ? `${dir}${base}` : `${dir}${sep}${base}`;
|
||||
}
|
||||
|
||||
export default path;
|
||||
@@ -1,7 +0,0 @@
|
||||
/*!
|
||||
* Socket.IO v4.7.2
|
||||
* (c) 2014-2023 Guillermo Rauch
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
const t=Object.create(null);t.open="0",t.close="1",t.ping="2",t.pong="3",t.message="4",t.upgrade="5",t.noop="6";const e=Object.create(null);Object.keys(t).forEach((s=>{e[t[s]]=s}));const s={type:"error",data:"parser error"},n="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),i="function"==typeof ArrayBuffer,r=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,o=({type:e,data:s},o,h)=>n&&s instanceof Blob?o?h(s):a(s,h):i&&(s instanceof ArrayBuffer||r(s))?o?h(s):a(new Blob([s]),h):h(t[e]+(s||"")),a=(t,e)=>{const s=new FileReader;return s.onload=function(){const t=s.result.split(",")[1];e("b"+(t||""))},s.readAsDataURL(t)};function h(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let c;const u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)p[u.charCodeAt(t)]=t;const l="function"==typeof ArrayBuffer,d=(t,n)=>{if("string"!=typeof t)return{type:"message",data:y(t,n)};const i=t.charAt(0);if("b"===i)return{type:"message",data:f(t.substring(1),n)};return e[i]?t.length>1?{type:e[i],data:t.substring(1)}:{type:e[i]}:s},f=(t,e)=>{if(l){const s=(t=>{let e,s,n,i,r,o=.75*t.length,a=t.length,h=0;"="===t[t.length-1]&&(o--,"="===t[t.length-2]&&o--);const c=new ArrayBuffer(o),u=new Uint8Array(c);for(e=0;e<a;e+=4)s=p[t.charCodeAt(e)],n=p[t.charCodeAt(e+1)],i=p[t.charCodeAt(e+2)],r=p[t.charCodeAt(e+3)],u[h++]=s<<2|n>>4,u[h++]=(15&n)<<4|i>>2,u[h++]=(3&i)<<6|63&r;return c})(t);return y(s,e)}return{base64:!0,data:t}},y=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,g=String.fromCharCode(30);function m(){return new TransformStream({transform(t,e){!function(t,e){n&&t.data instanceof Blob?t.data.arrayBuffer().then(h).then(e):i&&(t.data instanceof ArrayBuffer||r(t.data))?e(h(t.data)):o(t,!1,(t=>{c||(c=new TextEncoder),e(c.encode(t))}))}(t,(s=>{const n=s.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const t=new DataView(i.buffer);t.setUint8(0,126),t.setUint16(1,n)}else{i=new Uint8Array(9);const t=new DataView(i.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(n))}t.data&&"string"!=typeof t.data&&(i[0]|=128),e.enqueue(i),e.enqueue(s)}))}})}let b;function v(t){return t.reduce(((t,e)=>t+e.length),0)}function w(t,e){if(t[0].length===e)return t.shift();const s=new Uint8Array(e);let n=0;for(let i=0;i<e;i++)s[i]=t[0][n++],n===t[0].length&&(t.shift(),n=0);return t.length&&n<t[0].length&&(t[0]=t[0].slice(n)),s}function k(t){if(t)return function(t){for(var e in k.prototype)t[e]=k.prototype[e];return t}(t)}k.prototype.on=k.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},k.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},k.prototype.off=k.prototype.removeListener=k.prototype.removeAllListeners=k.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;i<n.length;i++)if((s=n[i])===e||s.fn===e){n.splice(i,1);break}return 0===n.length&&delete this._callbacks["$"+t],this},k.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(s){n=0;for(var i=(s=s.slice(0)).length;n<i;++n)s[n].apply(this,e)}return this},k.prototype.emitReserved=k.prototype.emit,k.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},k.prototype.hasListeners=function(t){return!!this.listeners(t).length};const _="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function E(t,...e){return e.reduce(((e,s)=>(t.hasOwnProperty(s)&&(e[s]=t[s]),e)),{})}const A=_.setTimeout,O=_.clearTimeout;function T(t,e){e.useNativeTimers?(t.setTimeoutFn=A.bind(_),t.clearTimeoutFn=O.bind(_)):(t.setTimeoutFn=_.setTimeout.bind(_),t.clearTimeoutFn=_.clearTimeout.bind(_))}class R extends Error{constructor(t,e,s){super(t),this.description=e,this.context=s,this.type="TransportError"}}class C extends k{constructor(t){super(),this.writable=!1,T(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,s){return super.emitReserved("error",new R(t,e,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("opLine truncated
|
||||
//# sourceMappingURL=socket.io.esm.min.js.map
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,7 +0,0 @@
|
||||
/*!
|
||||
* Socket.IO v4.7.2
|
||||
* (c) 2014-2023 Guillermo Rauch
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).io=e()}(this,(function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(i=r.key,o=void 0,"symbol"==typeof(o=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(i,"string"))?o:String(o)),r)}var i,o}function r(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i.apply(this,arguments)}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function c(t,e,n){return c=u()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&a(i,n.prototype),i},c.apply(null,arguments)}function h(t){var e="function"==typeof Map?new Map:void 0;return h=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return c(t,arguments,s(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,t)},h(t)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t){var e=u();return function(){var n,r=s(t);if(e){var i=s(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return f(t)}(this,n)}}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););return t}(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},p.apply(this,arguments)}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function y(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return d(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}var v=Object.create(null);v.open="0",v.close="1",v.ping="2",v.pong="3",v.message="4",v.upgrade="5",v.noop="6";var g=Object.create(null);Object.keys(v).forEach((function(t){g[v[t]]=t}));var m,b={type:"error",data:"parser error"},k="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConsLine truncated
|
||||
//# sourceMappingURL=socket.io.min.js.map
|
||||
@@ -1,7 +0,0 @@
|
||||
/*!
|
||||
* Socket.IO v4.7.2
|
||||
* (c) 2014-2023 Guillermo Rauch
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).io=e()}(this,(function(){"use strict";function t(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){if("default"!==n&&!(n in t)){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}))})),Object.freeze(t)}function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(i=r.key,o=void 0,"symbol"==typeof(o=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(i,"string"))?o:String(o)),r)}var i,o}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},o.apply(this,arguments)}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function h(t,e,n){return h=c()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&u(i,n.prototype),i},h.apply(null,arguments)}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return h(t,arguments,a(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,t)},f(t)}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t){var e=c();return function(){var n,r=a(t);if(e){var i=a(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return l(t)}(this,n)}}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},d.apply(this,arguments)}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function v(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}Line truncated
|
||||
//# sourceMappingURL=socket.io.msgpack.min.js.map
|
||||
@@ -254,15 +254,6 @@ function makeDriverMethod (spec) {
|
||||
};
|
||||
}
|
||||
|
||||
async function blob_to_url (blob) {
|
||||
const reader = new (globalThis.FileReader || FileReaderPoly)();
|
||||
return await new Promise((resolve, reject) => {
|
||||
reader.onloadend = () => resolve(reader.result);
|
||||
reader.onerror = reject;
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
}
|
||||
|
||||
function blobToDataUri (blob) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new (globalThis.FileReader || FileReaderPoly)();
|
||||
@@ -276,20 +267,6 @@ function blobToDataUri (blob) {
|
||||
});
|
||||
}
|
||||
|
||||
function arrayBufferToDataUri (arrayBuffer) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const blob = new Blob([arrayBuffer]);
|
||||
const reader = new (globalThis.FileReader || FileReaderPoly)();
|
||||
reader.onload = function (event) {
|
||||
resolve(event.target.result);
|
||||
};
|
||||
reader.onerror = function (error) {
|
||||
reject(error);
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
}
|
||||
|
||||
const VIDEO_EXTENSIONS = ['mp4', 'webm', 'mov', 'mpeg', 'avi', 'mkv', 'm4v', 'ogv'];
|
||||
|
||||
const isVideoInput = (url) => {
|
||||
@@ -300,5 +277,5 @@ const isVideoInput = (url) => {
|
||||
};
|
||||
|
||||
export {
|
||||
arrayBufferToDataUri, blob_to_url, blobToDataUri, handle_error, handle_resp, initXhr, isVideoInput, makeDriverMethod, setupXhrEventHandlers, uuidv4,
|
||||
blobToDataUri, handle_error, initXhr, isVideoInput, makeDriverMethod, setupXhrEventHandlers, uuidv4,
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import path from '../lib/path.js';
|
||||
import path from 'path-browserify';
|
||||
|
||||
/** @typedef {import('../../types/modules/fs-item').FSItem} FSItemType */
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import { fetchUrl } from '../../lib/networkUtils.js';
|
||||
|
||||
export default puter => class Batch {
|
||||
constructor () {
|
||||
this.form = new FormData();
|
||||
this.operations = [];
|
||||
}
|
||||
|
||||
move (source, destination, new_name) {
|
||||
this.operations.push({
|
||||
op: 'move',
|
||||
source,
|
||||
destination,
|
||||
new_name,
|
||||
});
|
||||
return this; // for chaining
|
||||
}
|
||||
|
||||
// alias for `delete`
|
||||
rm (...a) {
|
||||
return this.delete(...a);
|
||||
}
|
||||
|
||||
delete (...paths) {
|
||||
for ( const path of paths ) {
|
||||
this.operations.push({
|
||||
op: 'delete',
|
||||
path,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async send () {
|
||||
// Prepare Form
|
||||
for ( const operation of this.operations ) {
|
||||
this.form.append('operation', JSON.stringify(operation));
|
||||
}
|
||||
|
||||
// Send Request. The Content-Type (multipart boundary) is set by the
|
||||
// transport from the FormData body, so it is not passed explicitly.
|
||||
const res = await fetchUrl(`${puter.APIOrigin}/batch`, {
|
||||
method: 'POST',
|
||||
includePuterAuth: true,
|
||||
body: this.form,
|
||||
});
|
||||
|
||||
return (await res.json())?.results;
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import path from '../../lib/path.js';
|
||||
import io from '../../lib/socket.io/socket.io.esm.min.js';
|
||||
import path from 'path-browserify';
|
||||
import { io } from 'socket.io-client';
|
||||
import * as utils from '../../lib/utils.js';
|
||||
|
||||
// Constants
|
||||
@@ -9,7 +9,6 @@ const LAST_VALID_TS = 'last_valid_ts';
|
||||
|
||||
// Operations
|
||||
import FSItem from '../FSItem.js';
|
||||
import Batch from './Batch.js';
|
||||
import copy from './operations/copy.js';
|
||||
import deleteFSEntry from './operations/deleteFSEntry.js';
|
||||
import getReadURL from './operations/getReadUrl.js';
|
||||
@@ -56,7 +55,6 @@ export class PuterJSFileSystemModule {
|
||||
*/
|
||||
constructor (puter) {
|
||||
this.puter = puter;
|
||||
this.Batch = Batch(puter);
|
||||
this.authToken = puter.authToken;
|
||||
this.APIOrigin = puter.APIOrigin;
|
||||
this.appID = puter.appID;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import path from '../../../lib/path.js';
|
||||
import path from 'path-browserify';
|
||||
import getAbsolutePathForApp from '../utils/getAbsolutePathForApp.js';
|
||||
import { defineOperation, firstDefined } from './scaffold.js';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import path from '../../../lib/path.js';
|
||||
import path from 'path-browserify';
|
||||
import getAbsolutePathForApp from '../utils/getAbsolutePathForApp.js';
|
||||
import { defineOperation, firstDefined } from './scaffold.js';
|
||||
import stat from './stat.js';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Normalize the many accepted `upload()` input shapes into a flat list of
|
||||
// entries, then split that list into the directories and files to create.
|
||||
|
||||
import path from '../../../../lib/path.js';
|
||||
import path from 'path-browserify';
|
||||
|
||||
/**
|
||||
* Split an array into fixed-size chunks. Returns an empty array for empty or
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Invoked with the FileSystem module as `this`.
|
||||
|
||||
import { parseResponse } from '../../../../lib/networkUtils.js';
|
||||
import path from '../../../../lib/path.js';
|
||||
import path from 'path-browserify';
|
||||
import { normalizeThumbnailData } from './thumbnails.js';
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// URLs (single-shot or multipart), then finalized (`/fs/completeBatchWrite`).
|
||||
// Invoked with the FileSystem module as `this`.
|
||||
|
||||
import path from '../../../../lib/path.js';
|
||||
import path from 'path-browserify';
|
||||
import {
|
||||
MAX_THUMBNAIL_BYTES,
|
||||
SIGNED_BATCH_WRITE_CAPABILITY_KEY,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import path from '../../../lib/path.js';
|
||||
import path from 'path-browserify';
|
||||
import getAbsolutePathForApp from '../utils/getAbsolutePathForApp.js';
|
||||
|
||||
/** @typedef {import('../../../../types/modules/filesystem').WriteOptions} WriteOptions */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import path from '../../../lib/path.js';
|
||||
import path from 'path-browserify';
|
||||
|
||||
const getAbsolutePathForApp = (relativePath, puter = globalThis.puter) => {
|
||||
// preserve previous behavior for falsy values when env is gui
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import path from '../../../lib/path.js';
|
||||
import path from 'path-browserify';
|
||||
|
||||
/**
|
||||
* Convert a v2 (camelCase) fsentry from `/fs/readdir` into the v1 snake_case
|
||||
|
||||
@@ -70,7 +70,7 @@ const makeFakePuter = () => ({
|
||||
},
|
||||
});
|
||||
|
||||
// Minimal FileReader for node: only what blobToDataUri / blob_to_url use.
|
||||
// Minimal FileReader for node: only what blobToDataUri uses.
|
||||
class FakeFileReader {
|
||||
readAsDataURL (blob) {
|
||||
blob.arrayBuffer().then((buf) => {
|
||||
|
||||
@@ -13,14 +13,14 @@ const resultToUrl = async (result, error) => {
|
||||
return result;
|
||||
}
|
||||
if ( result instanceof Blob ) {
|
||||
return await utils.blob_to_url(result);
|
||||
return await utils.blobToDataUri(result);
|
||||
}
|
||||
if ( result instanceof ArrayBuffer ) {
|
||||
return await utils.blob_to_url(new Blob([result]));
|
||||
return await utils.blobToDataUri(new Blob([result]));
|
||||
}
|
||||
if ( result && typeof result === 'object' && typeof result.arrayBuffer === 'function' ) {
|
||||
const arrayBuffer = await result.arrayBuffer();
|
||||
return await utils.blob_to_url(new Blob([arrayBuffer], { type: result.type || undefined }));
|
||||
return await utils.blobToDataUri(new Blob([arrayBuffer], { type: result.type || undefined }));
|
||||
}
|
||||
throw error;
|
||||
};
|
||||
@@ -66,7 +66,7 @@ export const toVideoElement = async (result) => {
|
||||
let sourceUrl = null;
|
||||
let mimeType = null;
|
||||
if ( result instanceof Blob ) {
|
||||
sourceUrl = await utils.blob_to_url(result);
|
||||
sourceUrl = await utils.blobToDataUri(result);
|
||||
mimeType = result.type || 'video/mp4';
|
||||
} else if ( typeof result === 'string' ) {
|
||||
sourceUrl = result;
|
||||
|
||||
@@ -494,21 +494,6 @@ export default suite('fs', {
|
||||
);
|
||||
},
|
||||
|
||||
'batch send applies move and delete operations': async (t) => {
|
||||
const dir = `${home(t)}/fs-suite-batch`;
|
||||
await t.puter.fs.mkdir(dir);
|
||||
await t.puter.fs.write(`${dir}/moved.txt`, 'batch move');
|
||||
await t.puter.fs.write(`${dir}/removed.txt`, 'batch delete');
|
||||
const batch = new t.puter.fs.Batch();
|
||||
batch.move(`${dir}/moved.txt`, dir, 'moved-renamed.txt');
|
||||
batch.delete(`${dir}/removed.txt`);
|
||||
const results = await batch.send();
|
||||
t.assert.ok(Array.isArray(results), 'batch should return results');
|
||||
const blob = await t.puter.fs.read(`${dir}/moved-renamed.txt`);
|
||||
t.assert.equal(await blob.text(), 'batch move');
|
||||
await t.assert.rejects(() => t.puter.fs.stat(`${dir}/removed.txt`));
|
||||
},
|
||||
|
||||
'upload stores multiple files into a directory': async (t) => {
|
||||
const dir = `${home(t)}/fs-suite-upload`;
|
||||
await t.puter.fs.mkdir(dir);
|
||||
|
||||
@@ -19,14 +19,13 @@ export default (env = {}) => ({
|
||||
// `--env coverage` instruments every first-party module with istanbul
|
||||
// counters (accumulated on `globalThis.__coverage__`), so the API test
|
||||
// harness can measure SDK coverage in whatever runtime executes the
|
||||
// bundle. Vendored code (socket.io) is left out of the numbers.
|
||||
// bundle.
|
||||
...(env.coverage ? {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
include: path.resolve(__dirname, 'src'),
|
||||
exclude: path.resolve(__dirname, 'src/lib/socket.io'),
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
|
||||
Reference in new issue
Block a user