hfs 0.55.0-alpha1 → 0.55.0-alpha2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/assets/index-CjuGUtTj.js +809 -0
- package/admin/assets/{index-Cb8rIGrO.css → index-CrbMquLL.css} +1 -1
- package/admin/assets/{sha512-D0CcX9QB.js → sha512-DAt8ySU7.js} +1 -1
- package/admin/index.html +2 -3
- package/frontend/assets/index-legacy-XBchFTt7.js +60 -0
- package/frontend/assets/{sha512-legacy-DorGKuF4.js → sha512-legacy-B6NU-5wp.js} +1 -1
- package/frontend/fontello.css +2 -1
- package/frontend/fontello.woff2 +0 -0
- package/frontend/index.html +1 -1
- package/package.json +5 -3
- package/src/adminApis.js +2 -9
- package/src/api.cert.js +36 -0
- package/src/api.get_file_list.js +2 -2
- package/src/api.plugins.js +4 -2
- package/src/apiMiddleware.js +1 -1
- package/src/consoleLog.js +2 -1
- package/src/const.js +4 -3
- package/src/cross.js +30 -8
- package/src/github.js +3 -3
- package/src/index.js +1 -1
- package/src/lang.js +1 -1
- package/src/langs/embedded.js +2 -1
- package/src/langs/hfs-lang-ar.json +168 -0
- package/src/listen.js +1 -0
- package/src/log.js +1 -1
- package/src/plugins.js +20 -19
- package/src/serveGuiAndSharedFiles.js +9 -7
- package/src/upload.js +5 -6
- package/src/vfs.js +4 -5
- package/admin/assets/index-DMflfZ7E.js +0 -808
- package/frontend/assets/index-legacy-DuGmuNu8.js +0 -60
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
System.register(["./index-legacy-
|
|
1
|
+
System.register(["./index-legacy-XBchFTt7.js"],(function(h,t){"use strict";var i,s;return{setters:[function(h){i=h.g,s=h.c}],execute:function(){function t(h,t){for(var i=function(){var i=t[s];if("string"!=typeof i&&!Array.isArray(i)){var r=function(t){if("default"!==t&&!(t in h)){var s=Object.getOwnPropertyDescriptor(i,t);s&&Object.defineProperty(h,t,s.get?s:{enumerable:!0,get:function(){return i[t]}})}};for(var e in i)r(e)}},s=0;s<t.length;s++)i();return Object.freeze(Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}))}var r={exports:{}};
|
|
2
2
|
/*
|
|
3
3
|
* [js-sha512]{@link https://github.com/emn178/js-sha512}
|
|
4
4
|
*
|
package/frontend/fontello.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: 'fontello';
|
|
3
|
-
src: url('fontello.woff2?
|
|
3
|
+
src: url('fontello.woff2?74614144') format('woff2');
|
|
4
4
|
font-weight: normal;
|
|
5
5
|
font-style: normal;
|
|
6
6
|
}
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
.fa-reload:before { content: '\e818'; } /* '' */
|
|
67
67
|
.fa-cut:before { content: '\e819'; } /* '' */
|
|
68
68
|
.fa-shuffle:before { content: '\e81a'; } /* '' */
|
|
69
|
+
.fa-info:before { content: '\e81b'; } /* '' */
|
|
69
70
|
.fa-spin6:before { content: '\e839'; } /* '' */
|
|
70
71
|
.fa-crown:before { content: '\e844'; } /* '' */
|
|
71
72
|
.fa-download:before { content: '\f02e'; } /* '' */
|
package/frontend/fontello.woff2
CHANGED
|
Binary file
|
package/frontend/index.html
CHANGED
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
<style class="removeAtBoot">@media (prefers-color-scheme: dark) { html { background-color: #000; color: #888; } }</style>
|
|
11
11
|
<div id="root">Wait for loading or <a href="?get=basic">use basic interface now</a></div>
|
|
12
12
|
<script crossorigin id="vite-legacy-polyfill" src="/assets/polyfills-legacy-DMrMt_pQ.js"></script>
|
|
13
|
-
<script crossorigin id="vite-legacy-entry" data-src="/assets/index-legacy-
|
|
13
|
+
<script crossorigin id="vite-legacy-entry" data-src="/assets/index-legacy-XBchFTt7.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
|
|
14
14
|
</body>
|
|
15
15
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hfs",
|
|
3
|
-
"version": "0.55.0-
|
|
3
|
+
"version": "0.55.0-alpha2",
|
|
4
4
|
"description": "HTTP File Server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file server",
|
|
@@ -91,9 +91,10 @@
|
|
|
91
91
|
"lodash": "^4.17.21",
|
|
92
92
|
"minimist": "^1.2.6",
|
|
93
93
|
"nat-upnp-rejetto": "^2.1.0",
|
|
94
|
+
"node-forge": "^1.3.1",
|
|
94
95
|
"open": "^8.4.0",
|
|
95
|
-
"qr-creator": "^1.0.0",
|
|
96
96
|
"picomatch": "^3.0.1",
|
|
97
|
+
"qr-creator": "^1.0.0",
|
|
97
98
|
"tssrp6a": "^3.0.0",
|
|
98
99
|
"unzip-stream": "^0.3.4",
|
|
99
100
|
"valtio": "^1.10.3",
|
|
@@ -113,15 +114,16 @@
|
|
|
113
114
|
"@types/minimist": "^1.2.2",
|
|
114
115
|
"@types/mocha": "^9.0.0",
|
|
115
116
|
"@types/node": "^18.17.14",
|
|
117
|
+
"@types/node-forge": "^1.3.11",
|
|
116
118
|
"@types/picomatch": "^2.3.3",
|
|
117
119
|
"@types/tough-cookie": "^4.0.2",
|
|
118
120
|
"@types/unzipper": "^0.10.5",
|
|
121
|
+
"@yao-pkg/pkg": "^5.15.0",
|
|
119
122
|
"cross-env": "^7.0.3",
|
|
120
123
|
"koa-better-http-proxy": "^0.2.9",
|
|
121
124
|
"mocha": "^9.1.3",
|
|
122
125
|
"nm-prune": "^5.0.0",
|
|
123
126
|
"nodemon": "^2.0.15",
|
|
124
|
-
"@yao-pkg/pkg": "^5.15.0",
|
|
125
127
|
"tough-cookie": "^4.0.0",
|
|
126
128
|
"ts-node": "^10.4.0"
|
|
127
129
|
}
|
package/src/adminApis.js
CHANGED
|
@@ -16,11 +16,11 @@ const api_monitor_1 = __importDefault(require("./api.monitor"));
|
|
|
16
16
|
const api_lang_1 = __importDefault(require("./api.lang"));
|
|
17
17
|
const api_net_1 = __importDefault(require("./api.net"));
|
|
18
18
|
const api_log_1 = __importDefault(require("./api.log"));
|
|
19
|
+
const api_cert_1 = __importDefault(require("./api.cert"));
|
|
19
20
|
const connections_1 = require("./connections");
|
|
20
21
|
const misc_1 = require("./misc");
|
|
21
22
|
const perm_1 = require("./perm");
|
|
22
23
|
const middlewares_1 = require("./middlewares");
|
|
23
|
-
const promises_1 = require("fs/promises");
|
|
24
24
|
const child_process_1 = require("child_process");
|
|
25
25
|
const util_1 = require("util");
|
|
26
26
|
const customHtml_1 = require("./customHtml");
|
|
@@ -43,6 +43,7 @@ exports.adminApis = {
|
|
|
43
43
|
...api_lang_1.default,
|
|
44
44
|
...api_net_1.default,
|
|
45
45
|
...api_log_1.default,
|
|
46
|
+
...api_cert_1.default,
|
|
46
47
|
get_dynamic_dns_error: ddns_1.get_dynamic_dns_error,
|
|
47
48
|
async set_config({ values }) {
|
|
48
49
|
var _a;
|
|
@@ -127,14 +128,6 @@ exports.adminApis = {
|
|
|
127
128
|
&& await frpDebounced(),
|
|
128
129
|
};
|
|
129
130
|
},
|
|
130
|
-
async save_pem({ cert, private_key, name = 'self' }) {
|
|
131
|
-
if (!cert || !private_key)
|
|
132
|
-
return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST);
|
|
133
|
-
const files = { cert: name + '.cer', private_key: name + '.key' };
|
|
134
|
-
await (0, promises_1.writeFile)(files.private_key, private_key);
|
|
135
|
-
await (0, promises_1.writeFile)(files.cert, cert);
|
|
136
|
-
return files;
|
|
137
|
-
},
|
|
138
131
|
async add_block({ merge, ip, expire, comment }) {
|
|
139
132
|
(0, misc_1.apiAssertTypes)({
|
|
140
133
|
string: { ip },
|
package/src/api.cert.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const misc_1 = require("./misc");
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const node_forge_1 = require("node-forge");
|
|
6
|
+
const config_1 = require("./config");
|
|
7
|
+
exports.default = {
|
|
8
|
+
async make_self_signed_cert({ attributes, fileName }) {
|
|
9
|
+
(0, misc_1.apiAssertTypes)({
|
|
10
|
+
object_undefined: { attributes },
|
|
11
|
+
string_undefined: { fileName },
|
|
12
|
+
});
|
|
13
|
+
const keys = node_forge_1.pki.rsa.generateKeyPair(2048);
|
|
14
|
+
const cert = node_forge_1.pki.createCertificate();
|
|
15
|
+
cert.publicKey = keys.publicKey;
|
|
16
|
+
cert.serialNumber = '01';
|
|
17
|
+
cert.validity.notBefore = new Date();
|
|
18
|
+
cert.validity.notAfter = new Date();
|
|
19
|
+
cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 1);
|
|
20
|
+
const attrs = Object.entries(attributes || {}).map(x => ({ name: x[0], value: x[1] }));
|
|
21
|
+
cert.setSubject(attrs);
|
|
22
|
+
cert.setIssuer(attrs);
|
|
23
|
+
cert.sign(keys.privateKey);
|
|
24
|
+
const ret = {
|
|
25
|
+
cert: node_forge_1.pki.certificateToPem(cert),
|
|
26
|
+
private_key: node_forge_1.pki.privateKeyToPem(keys.privateKey),
|
|
27
|
+
};
|
|
28
|
+
if (!fileName)
|
|
29
|
+
return ret;
|
|
30
|
+
const configs = { cert: fileName + '.cer', private_key: fileName + '.key' };
|
|
31
|
+
await (0, promises_1.writeFile)(configs.private_key, ret.private_key);
|
|
32
|
+
await (0, promises_1.writeFile)(configs.cert, ret.cert);
|
|
33
|
+
(0, config_1.setConfig)(configs);
|
|
34
|
+
return configs;
|
|
35
|
+
}
|
|
36
|
+
};
|
package/src/api.get_file_list.js
CHANGED
|
@@ -14,7 +14,7 @@ const connections_1 = require("./connections");
|
|
|
14
14
|
const adminApis_1 = require("./adminApis");
|
|
15
15
|
const upload_1 = require("./upload");
|
|
16
16
|
const SendList_1 = require("./SendList");
|
|
17
|
-
const get_file_list = async ({ uri = '/', offset, limit, search, wild, c, onlyFolders, admin }, ctx) => {
|
|
17
|
+
const get_file_list = async ({ uri = '/', offset, limit, search, wild, c, onlyFolders, onlyFiles, admin }, ctx) => {
|
|
18
18
|
var _a;
|
|
19
19
|
const node = await (0, vfs_1.urlToNode)(uri, ctx);
|
|
20
20
|
const list = ctx.get('accept') === 'text/event-stream' ? new SendList_1.SendListReadable() : undefined;
|
|
@@ -33,7 +33,7 @@ const get_file_list = async ({ uri = '/', offset, limit, search, wild, c, onlyFo
|
|
|
33
33
|
search = String(search || '').toLocaleLowerCase();
|
|
34
34
|
const filter = wild === 'no' ? (s) => s.includes(search)
|
|
35
35
|
: (0, misc_1.pattern2filter)(search);
|
|
36
|
-
const walker = (0, vfs_1.walkNode)(node, { ctx: admin ? undefined : ctx, onlyFolders, depth: search ? Infinity : 0 });
|
|
36
|
+
const walker = (0, vfs_1.walkNode)(node, { ctx: admin ? undefined : ctx, onlyFolders, onlyFiles, depth: search ? Infinity : 0 });
|
|
37
37
|
const onDirEntryHandlers = (0, plugins_1.mapPlugins)(plug => plug.onDirEntry);
|
|
38
38
|
const can_upload = admin || (0, vfs_1.hasPermission)(node, 'can_upload', ctx);
|
|
39
39
|
const fakeChild = await (0, vfs_1.applyParentToChild)({ source: 'dummy-file' }, node); // used to check permission; simple but but can produce false results
|
package/src/api.plugins.js
CHANGED
|
@@ -72,8 +72,10 @@ const apis = {
|
|
|
72
72
|
async start_plugin({ id }) {
|
|
73
73
|
if ((0, plugins_1.isPluginRunning)(id))
|
|
74
74
|
return { msg: 'already running' };
|
|
75
|
+
if (plugins_1.suspendPlugins.get())
|
|
76
|
+
return new apiMiddleware_1.ApiError(misc_1.HTTP_PRECONDITION_FAILED, 'all plugins suspended');
|
|
75
77
|
await (0, plugins_1.stopPlugin)(id);
|
|
76
|
-
return (0, plugins_1.startPlugin)(id).then(() =>
|
|
78
|
+
return (0, plugins_1.startPlugin)(id).then(() => ({}), e => new apiMiddleware_1.ApiError(const_1.HTTP_SERVER_ERROR, e.message));
|
|
77
79
|
},
|
|
78
80
|
async stop_plugin({ id }) {
|
|
79
81
|
if (!(0, plugins_1.isPluginRunning)(id))
|
|
@@ -162,7 +164,7 @@ const apis = {
|
|
|
162
164
|
if (deleteConfig)
|
|
163
165
|
(0, plugins_1.setPluginConfig)(id, null);
|
|
164
166
|
return {};
|
|
165
|
-
}
|
|
167
|
+
},
|
|
166
168
|
};
|
|
167
169
|
exports.default = apis;
|
|
168
170
|
function serialize(p) {
|
package/src/apiMiddleware.js
CHANGED
|
@@ -29,7 +29,7 @@ function apiMiddleware(apis) {
|
|
|
29
29
|
const apiName = ctx.path;
|
|
30
30
|
console.debug('API', ctx.method, apiName, { ...params });
|
|
31
31
|
const noBrowser = (_a = ctx.get('user-agent')) === null || _a === void 0 ? void 0 : _a.startsWith('curl');
|
|
32
|
-
const safe =
|
|
32
|
+
const safe = noBrowser || isPost && ctx.get('x-hfs-anti-csrf') // POST is safe because browser will enforce SameSite cookie
|
|
33
33
|
|| apiName.startsWith('get_'); // "get_" apis are safe because they make no change
|
|
34
34
|
if (!safe)
|
|
35
35
|
return send(const_1.HTTP_FOOL, "missing header x-hfs-anti-csrf=1");
|
package/src/consoleLog.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.consoleLog = void 0;
|
|
7
7
|
const events_1 = __importDefault(require("./events"));
|
|
8
|
+
const cross_1 = require("./cross");
|
|
8
9
|
exports.consoleLog = [];
|
|
9
10
|
for (const k of ['log', 'warn', 'error']) {
|
|
10
11
|
const original = console[k];
|
|
@@ -15,6 +16,6 @@ for (const k of ['log', 'warn', 'error']) {
|
|
|
15
16
|
if (exports.consoleLog.length > 100000) // limit to avoid infinite space
|
|
16
17
|
exports.consoleLog.splice(0, 1000);
|
|
17
18
|
events_1.default.emit('console', rec);
|
|
18
|
-
return original(
|
|
19
|
+
return original((0, cross_1.formatTime)(ts), ...args); // bundled nodejs doesn't have locales (and apparently uses en-US)
|
|
19
20
|
};
|
|
20
21
|
}
|
package/src/const.js
CHANGED
|
@@ -36,8 +36,9 @@ const fs = __importStar(require("fs"));
|
|
|
36
36
|
const os_1 = require("os");
|
|
37
37
|
const lodash_1 = __importDefault(require("lodash"));
|
|
38
38
|
const path_1 = require("path");
|
|
39
|
+
const cross_1 = require("./cross");
|
|
39
40
|
__exportStar(require("./cross-const"), exports);
|
|
40
|
-
exports.API_VERSION = 10;
|
|
41
|
+
exports.API_VERSION = 10.1;
|
|
41
42
|
exports.COMPATIBLE_API_VERSION = 1; // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
|
|
42
43
|
exports.HFS_REPO = 'rejetto/hfs';
|
|
43
44
|
exports.argv = (0, minimist_1.default)(process.argv.slice(2));
|
|
@@ -54,7 +55,7 @@ exports.DEV = process.env.DEV || exports.argv.dev ? 'DEV' : '';
|
|
|
54
55
|
exports.ORIGINAL_CWD = process.cwd();
|
|
55
56
|
exports.HFS_STARTED = new Date();
|
|
56
57
|
const PKG_PATH = (0, path_1.join)(__dirname, '..', 'package.json');
|
|
57
|
-
exports.BUILD_TIMESTAMP = "2024-
|
|
58
|
+
exports.BUILD_TIMESTAMP = "2024-12-06T09:04:29.634Z";
|
|
58
59
|
const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
|
|
59
60
|
exports.VERSION = pkg.version;
|
|
60
61
|
exports.RUNNING_BETA = exports.VERSION.includes('-');
|
|
@@ -72,7 +73,7 @@ else
|
|
|
72
73
|
console.debug = () => { };
|
|
73
74
|
console.log(`HFS ~ HTTP File Server`);
|
|
74
75
|
console.log(`© Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt`);
|
|
75
|
-
console.log('started', exports.HFS_STARTED
|
|
76
|
+
console.log('started', (0, cross_1.formatTimestamp)(exports.HFS_STARTED), exports.DEV);
|
|
76
77
|
console.log('version', exports.VERSION || '-');
|
|
77
78
|
console.log('build', exports.BUILD_TIMESTAMP || '-');
|
|
78
79
|
console.debug('arguments', exports.argv);
|
package/src/cross.js
CHANGED
|
@@ -17,8 +17,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
21
|
-
exports.shortenAgent = exports.popKey = exports.safeDecodeURIComponent = exports.callable = exports.mapFilter = exports.inCommon = exports.replace = exports.matches = exports.makeMatcher = exports.runAt = exports.pathEncode = exports.promiseBestEffort = exports.escapeHTML = exports.ipForUrl = exports.isIpLan = exports.isIpLocalHost = exports.xlate = exports.isEqualLax = exports.isTimestampString = exports.isWindowsDrive = exports.isIP = exports.isPrimitive = exports.isNumeric = exports.formatTimestamp = exports.repeat = exports.asyncGeneratorToArray = exports.filterMapGenerator = exports.throw_ = exports.hasProp = exports.typedEntries = exports.typedKeys = exports.objRenameKey = exports.randomId = void 0;
|
|
20
|
+
exports.waitFor = exports.newObj = exports.findDefined = exports.isOrderedEqual = exports.swap = exports.tryJson = exports.dirname = exports.basename = exports.pendingPromise = exports._dbg = exports._log = exports.wantArray = exports.formatPerc = exports.with_ = exports.try_ = exports.setHidden = exports.onlyTruthy = exports.truthy = exports.stringAfter = exports.splitAt = exports.strinsert = exports.removeStarting = exports.enforceStarting = exports.enforceFinal = exports.objFromKeys = exports.objSameKeys = exports.haveTimeout = exports.wait = exports.join = exports.prefix = exports.formatSpeed = exports.formatBytes = exports.isWhoObject = exports.PERM_KEYS = exports.defaultPerms = exports.WHO_ANY_ACCOUNT = exports.WHO_NO_ONE = exports.WHO_ANYONE = exports.LIST = exports.CFG = exports.THEME_OPTIONS = exports.SORT_BY_OPTIONS = exports.FRONTEND_OPTIONS = exports.MAX_TILE_SIZE = exports.DAY = exports.HOUR = exports.MINUTE = exports.WIKI_URL = exports.REPO_URL = exports.WEBSITE = void 0;
|
|
21
|
+
exports.shortenAgent = exports.popKey = exports.safeDecodeURIComponent = exports.callable = exports.mapFilter = exports.inCommon = exports.replace = exports.matches = exports.makeMatcher = exports.runAt = exports.pathEncode = exports.promiseBestEffort = exports.escapeHTML = exports.ipForUrl = exports.isIpLan = exports.isIpLocalHost = exports.xlate = exports.isEqualLax = exports.isTimestampString = exports.isWindowsDrive = exports.isIP = exports.isPrimitive = exports.isNumeric = exports.formatDate = exports.formatTime = exports.formatTimestamp = exports.repeat = exports.asyncGeneratorToArray = exports.filterMapGenerator = exports.throw_ = exports.hasProp = exports.typedEntries = exports.typedKeys = exports.objRenameKey = exports.randomId = exports.getOrSet = void 0;
|
|
22
22
|
// This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
|
|
23
23
|
// all content here is shared between client and server
|
|
24
24
|
const lodash_1 = __importDefault(require("lodash"));
|
|
@@ -46,7 +46,7 @@ exports.THEME_OPTIONS = { auto: '', light: 'light', dark: 'dark' };
|
|
|
46
46
|
exports.CFG = constMap(['geo_enable', 'geo_allow', 'geo_list', 'geo_allow_unknown', 'dynamic_dns_url',
|
|
47
47
|
'log', 'error_log', 'log_rotation', 'dont_log_net', 'log_gui', 'log_api', 'log_ua', 'log_spam', 'track_ips',
|
|
48
48
|
'max_downloads', 'max_downloads_per_ip', 'max_downloads_per_account', 'roots', 'force_address', 'split_uploads',
|
|
49
|
-
'allow_session_ip_change']);
|
|
49
|
+
'allow_session_ip_change', 'force_lang', 'suspend_plugins']);
|
|
50
50
|
exports.LIST = { add: '+', remove: '-', update: '=', props: 'props', ready: 'ready', error: 'e' };
|
|
51
51
|
exports.WHO_ANYONE = true;
|
|
52
52
|
exports.WHO_NO_ONE = false;
|
|
@@ -110,6 +110,10 @@ function objSameKeys(src, newValue) {
|
|
|
110
110
|
return Object.fromEntries(Object.entries(src).map(([k, v]) => [k, newValue(v, k)]));
|
|
111
111
|
}
|
|
112
112
|
exports.objSameKeys = objSameKeys;
|
|
113
|
+
function objFromKeys(src, getValue) {
|
|
114
|
+
return Object.fromEntries(src.map(k => [k, getValue(k)]));
|
|
115
|
+
}
|
|
116
|
+
exports.objFromKeys = objFromKeys;
|
|
113
117
|
function enforceFinal(sub, s, evenEmpty = false) {
|
|
114
118
|
return (s ? !s.endsWith(sub) : evenEmpty) ? s + sub : s;
|
|
115
119
|
}
|
|
@@ -335,9 +339,21 @@ function repeat(everyMs, cb) {
|
|
|
335
339
|
}
|
|
336
340
|
exports.repeat = repeat;
|
|
337
341
|
function formatTimestamp(x) {
|
|
338
|
-
|
|
342
|
+
if (!x)
|
|
343
|
+
return '';
|
|
344
|
+
if (!(x instanceof Date))
|
|
345
|
+
x = new Date(x);
|
|
346
|
+
return formatDate(x) + ' ' + formatTime(x);
|
|
339
347
|
}
|
|
340
348
|
exports.formatTimestamp = formatTimestamp;
|
|
349
|
+
function formatTime(d) {
|
|
350
|
+
return [d.getHours(), d.getMinutes(), d.getSeconds()].map(x => x.toString().padStart(2, '0')).join(':'); // bundled nodejs doesn't have locales
|
|
351
|
+
}
|
|
352
|
+
exports.formatTime = formatTime;
|
|
353
|
+
function formatDate(d) {
|
|
354
|
+
return [d.getFullYear(), d.getMonth() + 1, d.getDate()].map(x => x.toString().padStart(2, '0')).join('-');
|
|
355
|
+
}
|
|
356
|
+
exports.formatDate = formatDate;
|
|
341
357
|
function isNumeric(x) {
|
|
342
358
|
return lodash_1.default.isNumber(x) || lodash_1.default.isString(x) && !isNaN(Number(x));
|
|
343
359
|
}
|
|
@@ -514,12 +530,18 @@ Object.defineProperties(Object.prototype, {
|
|
|
514
530
|
_L: {
|
|
515
531
|
enumerable: false,
|
|
516
532
|
writable: true,
|
|
517
|
-
value(
|
|
533
|
+
value(msg = '') {
|
|
518
534
|
const val = this instanceof Number || this instanceof String || this instanceof Boolean ? this.valueOf() : this;
|
|
519
|
-
|
|
520
|
-
debugger;
|
|
521
|
-
console.log(val);
|
|
535
|
+
console.log('**', msg, val);
|
|
522
536
|
return val;
|
|
523
537
|
}
|
|
538
|
+
},
|
|
539
|
+
_D: {
|
|
540
|
+
enumerable: false,
|
|
541
|
+
writable: true,
|
|
542
|
+
value(msg = '') {
|
|
543
|
+
debugger;
|
|
544
|
+
return this._L(msg);
|
|
545
|
+
}
|
|
524
546
|
}
|
|
525
547
|
});
|
package/src/github.js
CHANGED
|
@@ -89,8 +89,8 @@ async function downloadPlugin(repo, { branch = '', overwrite = false } = {}) {
|
|
|
89
89
|
return (0, promises_1.rm)(dest, { force: true }).then(() => dest, () => false);
|
|
90
90
|
});
|
|
91
91
|
// ready to replace
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
92
|
+
const wasRunning = (0, plugins_1.isPluginRunning)(folder);
|
|
93
|
+
if (wasRunning)
|
|
94
94
|
await (0, plugins_1.stopPlugin)(folder); // stop old
|
|
95
95
|
let retry = 3;
|
|
96
96
|
while (retry--) { // move data, and consider late release of the resource, up to a few seconds
|
|
@@ -107,7 +107,7 @@ async function downloadPlugin(repo, { branch = '', overwrite = false } = {}) {
|
|
|
107
107
|
// final replace
|
|
108
108
|
await (0, promises_1.rename)(tempInstallPath, installPath)
|
|
109
109
|
.catch(e => { throw e.code !== 'ENOENT' ? e : new apiMiddleware_1.ApiError(const_1.HTTP_NOT_ACCEPTABLE, "missing main file"); });
|
|
110
|
-
if (
|
|
110
|
+
if (wasRunning)
|
|
111
111
|
void (0, plugins_1.startPlugin)(folder) // don't wait, in case it fails to start. We still use startPlugin instead of enablePlugin, as it will take care of disabling other themes.
|
|
112
112
|
.catch(() => { }); // it will possibly fail (with 'miss') because the plugin has probably not been loaded yet.
|
|
113
113
|
events_1.default.emit('pluginDownloaded', { id: folder, repo });
|
package/src/index.js
CHANGED
|
@@ -65,7 +65,7 @@ function errorHandler(err) {
|
|
|
65
65
|
|| code === 'HPE_INVALID_METHOD' // cannot serve you like that
|
|
66
66
|
|| code === 'HPE_INVALID_EOF_STATE')
|
|
67
67
|
return; // someone interrupted, don't care
|
|
68
|
-
console.error(
|
|
68
|
+
console.error('server error', err);
|
|
69
69
|
}
|
|
70
70
|
process.on('uncaughtException', (err) => {
|
|
71
71
|
if (err.syscall !== 'watch' && err.code !== 'ECONNRESET')
|
package/src/lang.js
CHANGED
|
@@ -63,7 +63,7 @@ async function getLangData(ctx) {
|
|
|
63
63
|
exports.getLangData = getLangData;
|
|
64
64
|
let forceLangData;
|
|
65
65
|
let undo;
|
|
66
|
-
(0, config_1.defineConfig)(
|
|
66
|
+
(0, config_1.defineConfig)(misc_1.CFG.force_lang, '', v => {
|
|
67
67
|
undo === null || undo === void 0 ? void 0 : undo();
|
|
68
68
|
if (!v)
|
|
69
69
|
return forceLangData = undefined;
|
package/src/langs/embedded.js
CHANGED
|
@@ -24,4 +24,5 @@ const hfs_lang_ja_json_1 = __importDefault(require("./hfs-lang-ja.json"));
|
|
|
24
24
|
const hfs_lang_tr_json_1 = __importDefault(require("./hfs-lang-tr.json"));
|
|
25
25
|
const hfs_lang_th_json_1 = __importDefault(require("./hfs-lang-th.json"));
|
|
26
26
|
const hfs_lang_uk_json_1 = __importDefault(require("./hfs-lang-uk.json"));
|
|
27
|
-
|
|
27
|
+
const hfs_lang_ar_json_1 = __importDefault(require("./hfs-lang-ar.json"));
|
|
28
|
+
exports.default = { it: hfs_lang_it_json_1.default, zh: hfs_lang_zh_json_1.default, ru: hfs_lang_ru_json_1.default, sr: hfs_lang_sr_json_1.default, ko: hfs_lang_ko_json_1.default, ms: hfs_lang_ms_json_1.default, 'zh-tw': hfs_lang_zh_tw_json_1.default, fr: hfs_lang_fr_json_1.default, 'pt-br': hfs_lang_pt_br_json_1.default, vi: hfs_lang_vi_json_1.default, es: hfs_lang_es_json_1.default, nl: hfs_lang_nl_json_1.default, el: hfs_lang_el_json_1.default, de: hfs_lang_de_json_1.default, fi: hfs_lang_fi_json_1.default, hu: hfs_lang_hu_json_1.default, ja: hfs_lang_ja_json_1.default, ro: hfs_lang_ro_json_1.default, tr: hfs_lang_tr_json_1.default, th: hfs_lang_th_json_1.default, uk: hfs_lang_uk_json_1.default, ar: hfs_lang_ar_json_1.default };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "Hussein M. Alghazal (hmg3099)",
|
|
3
|
+
"version": 1.0,
|
|
4
|
+
"hfs_version": "0.54.0",
|
|
5
|
+
"translate": {
|
|
6
|
+
"Select": "اختر",
|
|
7
|
+
"n_files": "{n,plural,one{# file} other{# files}}",
|
|
8
|
+
"n_folders": "{n,plural,one{# folder} other{# folders}}",
|
|
9
|
+
"filter_count": "{n,plural, one{# filtered} other{# filtered}}",
|
|
10
|
+
"select_count": "{n,plural, one{# selected} other{# selected}}",
|
|
11
|
+
"filter_placeholder": "اكتب هنا لتصفية القائمة أدناه",
|
|
12
|
+
"Select some files": "اختر بعض الملفات",
|
|
13
|
+
"zip_checkboxes": "استخدم مربعات الاختيار لتحديد الملفات، ثم يمكنك استخدام ضغط الملفات مجددًا",
|
|
14
|
+
"zip_tooltip_selected": "تنزيل العناصر المحددة كملف مضغوط واحد",
|
|
15
|
+
"zip_tooltip_whole": "تنزيل القائمة الكاملة (غير المُرشحة) كملف مضغوط. إذا حددت بعض العناصر، فسيتم تنزيلها فقط.",
|
|
16
|
+
"zip_confirm_search": "تنزيل جميع نتائج هذا البحث كأرشيف ZIP؟",
|
|
17
|
+
"zip_confirm_folder": "تنزيل المجلد الكامل كأرشيف ZIP؟",
|
|
18
|
+
"select_tooltip": "التحديد ينطبق على 'الضغط' و'الحذف' (إذا كان متاحًا)، ويمكنك أيضًا تصفية القائمة",
|
|
19
|
+
"delete_hint": "لحذف العناصر، اضغط أولاً على 'اختر'",
|
|
20
|
+
"delete_confirm": "Delete {n,plural, one{# item} other{# items}}?",
|
|
21
|
+
"delete_completed": "تم الحذف: {n}",
|
|
22
|
+
"delete_failed": ", {n,plural, one{# failed} other{# failed}}",
|
|
23
|
+
"delete_select": "حدد شيئًا للحذف",
|
|
24
|
+
"Delete": "حذف",
|
|
25
|
+
"Options": "خيارات",
|
|
26
|
+
"Search": "بحث",
|
|
27
|
+
"Zip": "ضغط",
|
|
28
|
+
"search_msg": "ابحث في هذا المجلد والمجلدات الفرعية",
|
|
29
|
+
"Searching": "جاري البحث",
|
|
30
|
+
"Searched": "تم البحث",
|
|
31
|
+
"Clear search": "مسح البحث",
|
|
32
|
+
"Interrupted": "مُتوقف",
|
|
33
|
+
"stopped_before": "تم التوقف قبل العثور على أي شيء",
|
|
34
|
+
"empty_list": "لا يوجد شيء هنا",
|
|
35
|
+
"filter_none": "لا يوجد تطابق لهذا الفلتر",
|
|
36
|
+
"Admin-panel": "لوحة الإدارة",
|
|
37
|
+
"Login": "تسجيل الدخول",
|
|
38
|
+
"Username": "اسم المستخدم",
|
|
39
|
+
"Password": "كلمة المرور",
|
|
40
|
+
"login_untrusted": "تم إيقاف تسجيل الدخول: لا يمكن الوثوق بهوية الخادم",
|
|
41
|
+
"login_bad_credentials": "بيانات اعتماد غير صالحة",
|
|
42
|
+
"login_bad_cookies": "الكوكيز لا تعمل - فشل تسجيل الدخول",
|
|
43
|
+
"User panel": "لوحة المستخدم",
|
|
44
|
+
"Change password": "تغيير كلمة المرور",
|
|
45
|
+
"enter_pass": "أدخل كلمة مرور جديدة",
|
|
46
|
+
"enter_pass2": "أعد إدخال نفس كلمة المرور الجديدة",
|
|
47
|
+
"pass2_mismatch": "كلمة المرور الثانية التي أدخلتها لا تتطابق مع الأولى. تم إلغاء الإجراء.",
|
|
48
|
+
"password_changed": "تم تغيير كلمة المرور",
|
|
49
|
+
"Logout": "تسجيل الخروج",
|
|
50
|
+
"connection error": "خطأ في الاتصال",
|
|
51
|
+
"Full timestamp:": "الطابع الزمني الكامل:",
|
|
52
|
+
"Search was interrupted": "تم إيقاف البحث",
|
|
53
|
+
"Stop list": "إيقاف القائمة",
|
|
54
|
+
"download_starting": "يجب أن يبدأ التنزيل الآن",
|
|
55
|
+
"wrong_account": "الحساب {u} لا يمتلك صلاحية الوصول، جرب حسابًا آخر",
|
|
56
|
+
"no_upload_here": "لا توجد صلاحية رفع في هذا المجلد الحالي",
|
|
57
|
+
"Create folder": "إنشاء مجلد",
|
|
58
|
+
"Pick files": "اختر ملفات",
|
|
59
|
+
"Pick folder": "اختر مجلدًا",
|
|
60
|
+
"send_files": "Send {n,plural,one{# file} other{# files}}, {size}",
|
|
61
|
+
"Clear": "مسح",
|
|
62
|
+
"failed_upload": "تعذر رفع {name}",
|
|
63
|
+
"confirm_resume": "استئناف الرفع؟",
|
|
64
|
+
"file too large": "الملف كبير جدًا",
|
|
65
|
+
"Enter folder name": "أدخل اسم المجلد",
|
|
66
|
+
"Successfully created": "تم الإنشاء بنجاح",
|
|
67
|
+
"enter_folder": "أدخل المجلد",
|
|
68
|
+
"folder_exists": "مجلد بنفس الاسم موجود بالفعل",
|
|
69
|
+
"Sort by:": "الترتيب حسب: {by}",
|
|
70
|
+
"name": "الاسم",
|
|
71
|
+
"extension": "الامتداد",
|
|
72
|
+
"size": "الحجم",
|
|
73
|
+
"time": "الوقت",
|
|
74
|
+
"Invert order": "عكس الترتيب",
|
|
75
|
+
"Folders first": "المجلدات أولاً",
|
|
76
|
+
"Numeric names": "أسماء رقمية",
|
|
77
|
+
"theme:": "الثيم:",
|
|
78
|
+
"auto": "تلقائي",
|
|
79
|
+
"light": "فاتح",
|
|
80
|
+
"dark": "غامق",
|
|
81
|
+
"parent folder": "المجلد الرئيسي",
|
|
82
|
+
"home": "الرئيسية",
|
|
83
|
+
"Continue": "استمر",
|
|
84
|
+
"Confirm": "تأكيد",
|
|
85
|
+
"Don't": "لا",
|
|
86
|
+
"Warning": "تحذير",
|
|
87
|
+
"Error": "خطأ",
|
|
88
|
+
"Info": "معلومة",
|
|
89
|
+
"Unauthorized": "غير مصرح",
|
|
90
|
+
"Forbidden": "ممنوع",
|
|
91
|
+
"Not found": "غير موجود",
|
|
92
|
+
"Server error": "خطأ في الخادم",
|
|
93
|
+
"Upload": "رفع",
|
|
94
|
+
"upload_concluded": "تم الانتهاء من الرفع:",
|
|
95
|
+
"upload_finished": "{n} تم رفعه ({size})",
|
|
96
|
+
"upload_errors": "{n} فشلوا",
|
|
97
|
+
"upload_file_rejected": "بعض الملفات لم تُقبل",
|
|
98
|
+
"File menu": "قائمة الملف",
|
|
99
|
+
"Folder menu": "قائمة المجلد",
|
|
100
|
+
"Name": "الاسم",
|
|
101
|
+
"file_open": "فتح",
|
|
102
|
+
"Download": "تنزيل",
|
|
103
|
+
"Missing permission": "الصلاحية مفقودة",
|
|
104
|
+
"Reload": "إعادة تحميل",
|
|
105
|
+
"Get list": "الحصول على القائمة",
|
|
106
|
+
"Skip existing files": "تخطى الملفات الموجودة",
|
|
107
|
+
"Size": "الحجم",
|
|
108
|
+
"Timestamp": "الطابع الزمني",
|
|
109
|
+
"Show": "عرض",
|
|
110
|
+
"Loading failed": "فشل التحميل",
|
|
111
|
+
"Rename": "إعادة تسمية",
|
|
112
|
+
"Tiles mode:": "وضع الشبكة:",
|
|
113
|
+
"off": "إيقاف",
|
|
114
|
+
"Operation successful": "العملية ناجحة",
|
|
115
|
+
"Uploader": "الرافع",
|
|
116
|
+
"Download counter": "عداد التنزيل",
|
|
117
|
+
"Switch zoom mode": "تبديل وضع التكبير",
|
|
118
|
+
"Full screen": "شاشة كاملة",
|
|
119
|
+
"File Show help": "عرض مساعدة الملف",
|
|
120
|
+
"showHelpMain": "يمكنك استخدام لوحة المفاتيح لبعض الإجراءات:",
|
|
121
|
+
"showHelp_←/→": "←/→",
|
|
122
|
+
"showHelp_↑/↓": "↑/↓",
|
|
123
|
+
"showHelp_space": "مسافة",
|
|
124
|
+
"showHelp_←/→_body": "انتقل إلى الملف السابق/التالي",
|
|
125
|
+
"showHelp_↑/↓_body": "تمرير الصور الطويلة",
|
|
126
|
+
"Destination": "الوجهة",
|
|
127
|
+
"in_queue": "{n} في قائمة الانتظار",
|
|
128
|
+
"enter_comment": "تعليق لـ {name}",
|
|
129
|
+
"Comment": "تعليق",
|
|
130
|
+
"upload_dd_hint": "يمكنك رفع الملفات بالسحب والإفلات على قائمة الملفات",
|
|
131
|
+
"Upload not available": "الرفع غير متاح",
|
|
132
|
+
"Cut": "قص",
|
|
133
|
+
"n_items": "{n,plural, one{# item} other{# items}}",
|
|
134
|
+
"good_bad": "{good} تم نقلهم، {bad} فشلوا",
|
|
135
|
+
"after_cut": "تم وضع التحديد الآن في الحافظة. انتقل إلى المجلد الوجهة للصق.",
|
|
136
|
+
"Cancel clipboard": "إلغاء الحافظة",
|
|
137
|
+
"to_clipboard_source": "العودة إلى المجلد المصدر",
|
|
138
|
+
"Paste": "لصق",
|
|
139
|
+
"clipboard_list": "عناصر في الحافظة:",
|
|
140
|
+
"Close": "إغلاق",
|
|
141
|
+
"Folder": "مجلد",
|
|
142
|
+
"Web page": "صفحة ويب",
|
|
143
|
+
"Link": "رابط",
|
|
144
|
+
"Auto-play": "تشغيل تلقائي",
|
|
145
|
+
"autoplay_seconds": "ثوانٍ للانتظار على الصور",
|
|
146
|
+
"Select all": "اختيار الكل",
|
|
147
|
+
"go_first": "انتقل إلى العنصر الأول",
|
|
148
|
+
"go_last": "انتقل إلى العنصر الأخير",
|
|
149
|
+
"Shuffle": "تبديل",
|
|
150
|
+
"Repeat": "تكرار",
|
|
151
|
+
"showHelpListShortcut": "من قائمة الملفات، اضغط مع الاستمرار على {key} للعرض بسرعة",
|
|
152
|
+
"Invalid value": "قيمة غير صالحة",
|
|
153
|
+
"upload_skipped": "{n} تم تجاوزهم",
|
|
154
|
+
"Overwrite policy": "سياسة الكتابة فوق",
|
|
155
|
+
"Rename to avoid overwriting": "إعادة التسمية لتجنب الكتابة فوق",
|
|
156
|
+
"Overwrite existing files": "الكتابة فوق الملفات الموجودة",
|
|
157
|
+
"Menu": "القائمة",
|
|
158
|
+
"clipboard": "الحافظة ({content})",
|
|
159
|
+
"to_clipboard_source_tooltip": "انتقل إلى المجلد حيث توجد محتويات الحافظة",
|
|
160
|
+
"more_items": "{n} عنصر/عناصر إضافية",
|
|
161
|
+
"Show details": "عرض التفاصيل",
|
|
162
|
+
"upload_conflict": "موجود بالفعل",
|
|
163
|
+
"Logged in": "تم تسجيل الدخول",
|
|
164
|
+
"Logged out": "تم تسجيل الخروج",
|
|
165
|
+
"Cancel": "إلغاء",
|
|
166
|
+
"allow_session_ip_change": "السماح بتغيير IP خلال هذه الجلسة"
|
|
167
|
+
}
|
|
168
|
+
}
|
package/src/listen.js
CHANGED
|
@@ -180,6 +180,7 @@ for (const cfg of httpsNeeds) {
|
|
|
180
180
|
httpsOptions[k] = '';
|
|
181
181
|
unwatch = (0, watchLoad_1.watchLoad)(v, async (data) => {
|
|
182
182
|
httpsOptions[k] = data;
|
|
183
|
+
await (0, misc_1.wait)(500); // when a file is written, give some time for the other to be ready
|
|
183
184
|
await considerHttps();
|
|
184
185
|
}, { immediateFirst: true }).unwatch;
|
|
185
186
|
await considerHttps();
|
package/src/log.js
CHANGED
|
@@ -169,7 +169,7 @@ debugLogFile.once('open', () => {
|
|
|
169
169
|
console.error = function (...args) {
|
|
170
170
|
was.apply(this, args);
|
|
171
171
|
args = args.map(x => { var _a; return typeof x === 'string' ? x : ((_a = (0, misc_1.tryJson)(x)) !== null && _a !== void 0 ? _a : String(x)); });
|
|
172
|
-
debugLogFile.write(new Date
|
|
172
|
+
debugLogFile.write((0, misc_1.formatTimestamp)(new Date) + ' - ' + args.join(' ') + '\n');
|
|
173
173
|
};
|
|
174
174
|
// limit log size
|
|
175
175
|
const LIMIT = 1000000;
|