hfs 0.52.0-beta5 → 0.52.0-beta8

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.
Files changed (46) hide show
  1. package/admin/assets/index-4CQRk-yB.css +1 -0
  2. package/admin/assets/index-fBO0hASK.js +810 -0
  3. package/admin/assets/{sha512-NNyCyWLU.js → sha512-7pY8ZA1q.js} +1 -1
  4. package/admin/index.html +2 -2
  5. package/frontend/assets/index-m18RVJZD.css +1 -0
  6. package/frontend/assets/index-z5aJG4U-.js +101 -0
  7. package/frontend/assets/{sha512-cwI-f2AA.js → sha512-uRXql0UJ.js} +1 -1
  8. package/frontend/index.html +2 -3
  9. package/package.json +2 -2
  10. package/src/acme.js +42 -24
  11. package/src/adminApis.js +5 -2
  12. package/src/api.get_file_list.js +2 -1
  13. package/src/api.monitor.js +3 -1
  14. package/src/api.net.js +3 -1
  15. package/src/api.plugins.js +1 -1
  16. package/src/api.vfs.js +6 -1
  17. package/src/apiMiddleware.js +3 -1
  18. package/src/comments.js +28 -16
  19. package/src/config.js +1 -1
  20. package/src/const.js +1 -1
  21. package/src/cross.js +5 -2
  22. package/src/debounceAsync.js +4 -2
  23. package/src/frontEndApis.js +3 -3
  24. package/src/index.js +1 -1
  25. package/src/langs/hfs-lang-es.json +66 -21
  26. package/src/langs/hfs-lang-fi.json +23 -5
  27. package/src/langs/hfs-lang-it.json +3 -3
  28. package/src/langs/hfs-lang-nl.json +20 -3
  29. package/src/langs/hfs-lang-ru.json +21 -3
  30. package/src/langs/hfs-lang-vi.json +68 -22
  31. package/src/langs/hfs-lang-zh.json +13 -5
  32. package/src/listen.js +2 -2
  33. package/src/perm.js +1 -1
  34. package/src/plugins.js +2 -1
  35. package/src/selfCheck.js +4 -5
  36. package/src/serveGuiAndSharedFiles.js +6 -6
  37. package/src/serveGuiFiles.js +55 -44
  38. package/src/update.js +7 -6
  39. package/src/upload.js +8 -3
  40. package/src/util-os.js +53 -15
  41. package/src/vfs.js +7 -4
  42. package/src/watchLoad.js +2 -2
  43. package/admin/assets/index-9rqMB1NK.css +0 -1
  44. package/admin/assets/index-r5-fb-BA.js +0 -809
  45. package/frontend/assets/index-Q_GrPW0f.js +0 -101
  46. package/frontend/assets/index-tFXsZ4SK.css +0 -1
@@ -1,4 +1,4 @@
1
- import{g as OF,c as UF}from"./index-Q_GrPW0f.js";function gF(sF,hF){for(var eF=0;eF<hF.length;eF++){const tF=hF[eF];if(typeof tF!="string"&&!Array.isArray(tF)){for(const w in tF)if(w!=="default"&&!(w in sF)){const lF=Object.getOwnPropertyDescriptor(tF,w);lF&&Object.defineProperty(sF,w,lF.get?lF:{enumerable:!0,get:()=>tF[w]})}}}return Object.freeze(Object.defineProperty(sF,Symbol.toStringTag,{value:"Module"}))}var dF={exports:{}};/*
1
+ import{g as OF,c as UF}from"./index-z5aJG4U-.js";function gF(sF,hF){for(var eF=0;eF<hF.length;eF++){const tF=hF[eF];if(typeof tF!="string"&&!Array.isArray(tF)){for(const w in tF)if(w!=="default"&&!(w in sF)){const lF=Object.getOwnPropertyDescriptor(tF,w);lF&&Object.defineProperty(sF,w,lF.get?lF:{enumerable:!0,get:()=>tF[w]})}}}return Object.freeze(Object.defineProperty(sF,Symbol.toStringTag,{value:"Module"}))}var dF={exports:{}};/*
2
2
  * [js-sha512]{@link https://github.com/emn178/js-sha512}
3
3
  *
4
4
  * @version 0.8.0
@@ -4,9 +4,8 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0" />
6
6
  <link href="/fontello.css" rel="stylesheet" />
7
- <script src="//polyfill.io/v3/polyfill.min.js?features=es2022%2Ces2021%2Ces2020%2Ces2019%2Ces2018%2Ces2017"></script>
8
- <script type="module" crossorigin src="/assets/index-Q_GrPW0f.js"></script>
9
- <link rel="stylesheet" crossorigin href="/assets/index-tFXsZ4SK.css">
7
+ <script type="module" crossorigin src="/assets/index-z5aJG4U-.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-m18RVJZD.css">
10
9
  </head>
11
10
  <body>
12
11
  <noscript>You need to enable JavaScript to run this app.</noscript>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hfs",
3
- "version": "0.52.0-beta5",
3
+ "version": "0.52.0-beta8",
4
4
  "description": "HTTP File Server",
5
5
  "keywords": [
6
6
  "file server",
@@ -15,7 +15,7 @@
15
15
  "watch-server-proxied": "cross-env FRONTEND_PROXY=3005 ADMIN_PROXY=3006 npm run watch-server",
16
16
  "start-frontend": "npm run start --workspace=frontend",
17
17
  "start-admin": "npm run start --workspace=admin",
18
- "build-all": "npm audit --omit=dev --audit-level=moderate && rm -rf dist && npm i && npm run build-server & npm run build-frontend & npm run build-admin & wait && echo COMPLETED",
18
+ "build-all": "npm audit --omit=dev --audit-level=moderate && rm -rf dist && npm i && npm run build-server && npm run build-frontend && npm run build-admin && echo COMPLETED",
19
19
  "build-server": "rm -rf dist/src dist/plugins && tsc --target es2018 && touch package.json && cp -v -r package.json central.json README* LICENSE* plugins dist && find dist \\( -name .DS_Store -o -name storage \\) -delete && node afterbuild.js",
20
20
  "build-frontend": "npm run build --workspace=frontend",
21
21
  "build-admin": "npm run build --workspace=admin",
package/src/acme.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeCert = exports.acmeMiddleware = void 0;
7
- const cross_1 = require("./cross");
7
+ const misc_1 = require("./misc");
8
8
  const http_1 = require("http");
9
9
  const nat_1 = require("./nat");
10
10
  const listen_1 = require("./listen");
@@ -15,48 +15,61 @@ const promises_1 = __importDefault(require("fs/promises"));
15
15
  const config_1 = require("./config");
16
16
  const events_1 = __importDefault(require("./events"));
17
17
  const selfCheck_1 = require("./selfCheck");
18
- let acmeMiddlewareEnabled = false;
18
+ let acmeOngoing = false;
19
19
  const acmeTokens = {};
20
20
  const acmeListener = (req, res) => {
21
21
  var _a;
22
22
  const BASE = '/.well-known/acme-challenge/';
23
23
  if (!((_a = req.url) === null || _a === void 0 ? void 0 : _a.startsWith(BASE)))
24
- return res.end('HFS'); // to satisfy self-check with the temporary server
24
+ return;
25
25
  const token = req.url.slice(BASE.length);
26
26
  console.debug("got http challenge", token);
27
- res.statusCode = cross_1.HTTP_OK;
27
+ res.statusCode = misc_1.HTTP_OK;
28
28
  res.end(acmeTokens[token]);
29
- return true;
29
+ return true; // true = responded
30
30
  };
31
31
  const acmeMiddleware = (ctx, next) => {
32
- if (!acmeMiddlewareEnabled || !Boolean(acmeListener(ctx.req, ctx.res)))
32
+ if (!acmeOngoing || !acmeListener(ctx.req, ctx.res))
33
33
  return next();
34
34
  };
35
35
  exports.acmeMiddleware = acmeMiddleware;
36
+ const TEMP_MAP = { private: 80, public: { host: '', port: 80 }, description: 'hfs temporary', ttl: 5000 }; // from my tests (zyxel VMG8825), lower values won't make a working mapping
37
+ (0, misc_1.repeat)(misc_1.MINUTE, async (stop) => {
38
+ await nat_1.upnpClient.getGateway(); // without this, the next call will break upnp support
39
+ const res = await nat_1.upnpClient.getMappings();
40
+ const leftover = res.find(x => x.description === TEMP_MAP.description); // in case the process is interrupted
41
+ if (!leftover)
42
+ return void stop(); // we are good
43
+ if (acmeOngoing)
44
+ return; // it doesn't count, as we are in the middle of something. Retry later
45
+ stop();
46
+ return nat_1.upnpClient.removeMapping(TEMP_MAP);
47
+ });
36
48
  async function generateSSLCert(domain, email, altNames) {
37
49
  // will answer challenge through our koa app (if on port 80) or must we spawn a dedicated server?
38
50
  const nat = await (0, nat_1.getNatInfo)();
39
51
  const { http } = await (0, listen_1.getServerStatus)();
40
- const tempSrv = nat.externalPort === 80 || http.listening && http.port === 80 ? undefined : (0, http_1.createServer)(acmeListener);
52
+ const tempSrv = nat.externalPort === 80 || http.listening && http.port === 80 ? undefined
53
+ : (0, http_1.createServer)((req, res) => acmeListener(req, res) || res.end('HFS')); // also satisfy self-check
41
54
  if (tempSrv)
42
55
  await new Promise(resolve => tempSrv.listen(80, resolve).on('error', (e) => {
43
56
  console.debug("cannot listen on 80", e.code || e);
44
57
  resolve(); // go on anyway
45
58
  }));
46
- acmeMiddlewareEnabled = true;
47
- console.debug('acme challenge server ready');
59
+ acmeOngoing = true;
60
+ console.debug("acme challenge server ready");
48
61
  let tempMap;
49
62
  try {
50
- const checkUrl = `http://${domain}`;
63
+ const checkUrl = `http://${domain.split(',')[0]}`;
51
64
  let check = await (0, selfCheck_1.selfCheck)(checkUrl); // some check services may not consider the domain, but we already verified that
52
- if (check && !check.success && nat.upnp && !nat.mapped80) {
65
+ if ((check === null || check === void 0 ? void 0 : check.success) === false && nat.upnp && !nat.mapped80) {
53
66
  console.debug("setting temporary port forward");
54
- tempMap = await nat_1.upnpClient.createMapping({ private: 80, public: { host: '', port: 80 }, description: 'hfs temporary', ttl: 0 }).catch(() => { });
67
+ tempMap = await (0, misc_1.haveTimeout)(10000, nat_1.upnpClient.createMapping(TEMP_MAP).catch(() => { })).catch(() => { });
55
68
  check = await (0, selfCheck_1.selfCheck)(checkUrl); // repeat test
56
69
  }
57
70
  //if (!check) throw new ApiError(HTTP_FAILED_DEPENDENCY, "couldn't test port 80")
58
- if (!(check === null || check === void 0 ? void 0 : check.success))
59
- throw new apiMiddleware_1.ApiError(cross_1.HTTP_FAILED_DEPENDENCY, "port 80 is not working on the specified domain");
71
+ if ((check === null || check === void 0 ? void 0 : check.success) === false)
72
+ throw new apiMiddleware_1.ApiError(misc_1.HTTP_FAILED_DEPENDENCY, "port 80 is not working on the specified domain");
60
73
  const acmeClient = new acme_client_1.default.Client({
61
74
  accountKey: await acme_client_1.default.crypto.createPrivateKey(),
62
75
  directoryUrl: acme_client_1.default.directory.letsencrypt.production
@@ -72,14 +85,15 @@ async function generateSSLCert(domain, email, altNames) {
72
85
  async challengeCreateFn(_, c, ka) { acmeTokens[c.token] = ka; },
73
86
  async challengeRemoveFn(_, c) { delete acmeTokens[c.token]; },
74
87
  });
88
+ console.log("acme certificate generated");
75
89
  return { key, cert };
76
90
  }
77
91
  finally {
78
92
  if (tempMap) {
79
93
  console.debug("removing temporary port forward");
80
- nat_1.upnpClient.removeMapping({ public: { host: '', port: 80 } }).catch(() => { });
94
+ nat_1.upnpClient.removeMapping(TEMP_MAP).catch(() => { }); // clean after ourselves
81
95
  }
82
- acmeMiddlewareEnabled = false;
96
+ acmeOngoing = false;
83
97
  if (tempSrv)
84
98
  await new Promise(res => tempSrv.close(res));
85
99
  console.debug('acme terminated');
@@ -87,8 +101,12 @@ async function generateSSLCert(domain, email, altNames) {
87
101
  }
88
102
  exports.makeCert = (0, debounceAsync_1.debounceAsync)(async (domain, email, altNames) => {
89
103
  if (!domain)
90
- return new apiMiddleware_1.ApiError(cross_1.HTTP_BAD_REQUEST, 'bad params');
91
- const res = await generateSSLCert(domain, email, altNames);
104
+ return new apiMiddleware_1.ApiError(misc_1.HTTP_BAD_REQUEST, 'bad params');
105
+ const res = await generateSSLCert(domain, email, altNames).catch(e => {
106
+ var _a;
107
+ throw !((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes('not match this challenge')) ? e // another acme server?
108
+ : Error("a different server is responding on port 80 of your domain(s)");
109
+ });
92
110
  const CERT_FILE = 'acme.cer';
93
111
  const KEY_FILE = 'acme.key';
94
112
  await promises_1.default.writeFile(CERT_FILE, res.cert);
@@ -99,10 +117,10 @@ exports.makeCert = (0, debounceAsync_1.debounceAsync)(async (domain, email, altN
99
117
  const acmeDomain = (0, config_1.defineConfig)('acme_domain', '');
100
118
  const acmeEmail = (0, config_1.defineConfig)('acme_email', '');
101
119
  const acmeRenew = (0, config_1.defineConfig)('acme_renew', false); // handle config changes
102
- events_1.default.once('https ready', () => (0, cross_1.repeat)(cross_1.HOUR, renewCert));
120
+ events_1.default.once('https ready', () => (0, misc_1.repeat)(misc_1.HOUR, renewCert));
103
121
  // checks if the cert is near expiration date, and if so renews it
104
122
  const renewCert = (0, debounceAsync_1.debounceAsync)(async () => {
105
- const domain = acmeDomain.get();
123
+ const [domain, ...altNames] = acmeDomain.get().split(',');
106
124
  if (!acmeRenew.get() || !domain)
107
125
  return;
108
126
  const cert = (0, listen_1.getCertObject)();
@@ -111,8 +129,8 @@ const renewCert = (0, debounceAsync_1.debounceAsync)(async () => {
111
129
  const now = new Date();
112
130
  const validTo = new Date(cert.validTo);
113
131
  // not expiring in a month
114
- if (now > new Date(cert.validFrom) && now < validTo && validTo.getTime() - now.getTime() >= 30 * cross_1.DAY)
132
+ if (now > new Date(cert.validFrom) && now < validTo && validTo.getTime() - now.getTime() >= 30 * misc_1.DAY)
115
133
  return console.log("certificate still good");
116
- await (0, exports.makeCert)(domain, acmeEmail.get())
117
- .catch(e => console.log("error renewing certificate: ", String(e)));
118
- }, 0, { retain: cross_1.DAY, retainFailure: cross_1.HOUR });
134
+ await (0, exports.makeCert)(domain, acmeEmail.get(), altNames)
135
+ .catch(e => console.log("error renewing certificate: ", String(e.message || e)));
136
+ }, 0, { retain: misc_1.DAY, retainFailure: misc_1.HOUR });
package/src/adminApis.js CHANGED
@@ -64,7 +64,10 @@ exports.adminApis = {
64
64
  };
65
65
  },
66
66
  set_config_text: ({ text }) => config_1.configFile.save(text, { reparse: true }),
67
- update: ({ tag }) => (0, update_1.update)(tag),
67
+ update: ({ tag }) => (0, update_1.update)(tag).catch(e => {
68
+ var _a, _b;
69
+ throw ((_a = e.cause) === null || _a === void 0 ? void 0 : _a.statusCode) ? new apiMiddleware_1.ApiError((_b = e.cause) === null || _b === void 0 ? void 0 : _b.statusCode) : e;
70
+ }),
68
71
  async check_update() {
69
72
  return { options: await (0, update_1.getUpdates)() };
70
73
  },
@@ -103,7 +106,7 @@ exports.adminApis = {
103
106
  ips: await (0, listen_1.getIps)(false),
104
107
  baseUrl: (0, listen_1.getBaseUrlOrDefault)(),
105
108
  roots: roots_1.roots.get(),
106
- updatePossible: !(0, update_1.updateSupported)() ? false : await (0, update_1.localUpdateAvailable)() ? 'local' : true,
109
+ updatePossible: !await (0, update_1.updateSupported)() ? false : (await (0, update_1.localUpdateAvailable)()) ? 'local' : true,
107
110
  proxyDetected: (0, middlewares_1.getProxyDetected)(),
108
111
  frpDetected: exports.localhostAdmin.get() && !(0, middlewares_1.getProxyDetected)()
109
112
  && (0, connections_1.getConnections)().every(misc_1.isLocalHost)
@@ -37,7 +37,8 @@ const get_file_list = async ({ uri = '/', offset, limit, search, c, onlyFolders,
37
37
  const can_archive = admin || (0, vfs_1.hasPermission)(node, 'can_archive', ctx);
38
38
  const can_comment = can_upload && (0, comments_1.areCommentsEnabled)();
39
39
  const can_overwrite = can_upload && (can_delete || !upload_1.dontOverwriteUploading.get());
40
- const props = { can_archive, can_upload, can_delete, can_overwrite, accept: node.accept, can_comment };
40
+ const comment = await (0, comments_1.getCommentFor)(node.source);
41
+ const props = { can_archive, can_upload, can_delete, can_overwrite, can_comment, comment, accept: node.accept };
41
42
  ctx.state.browsing = uri.replace(/\/{2,}/g, '/');
42
43
  (0, connections_1.updateConnectionForCtx)(ctx);
43
44
  if (!list)
@@ -81,12 +81,14 @@ exports.default = {
81
81
  },
82
82
  async *get_connection_stats() {
83
83
  while (1) {
84
+ const filtered = (0, connections_1.getConnections)().filter(x => !ignore(x));
84
85
  yield {
85
86
  outSpeed: throttler_1.totalOutSpeed,
86
87
  inSpeed: throttler_1.totalInSpeed,
87
88
  got: throttler_1.totalGot,
88
89
  sent: throttler_1.totalSent,
89
- connections: lodash_1.default.sumBy((0, connections_1.getConnections)(), x => ignore(x) ? 0 : 1),
90
+ connections: filtered.length,
91
+ ips: lodash_1.default.uniqBy(filtered, x => x.ip).length,
90
92
  };
91
93
  await (0, misc_1.wait)(1000);
92
94
  }
package/src/api.net.js CHANGED
@@ -75,7 +75,9 @@ const apis = {
75
75
  return results.length ? results : new apiMiddleware_1.ApiError(const_1.HTTP_SERVICE_UNAVAILABLE);
76
76
  },
77
77
  async make_cert({ domain, email, altNames }) {
78
- await (0, acme_1.makeCert)(domain, email, altNames);
78
+ await (0, acme_1.makeCert)(domain, email, altNames).catch(e => {
79
+ throw new apiMiddleware_1.ApiError(const_1.HTTP_SERVER_ERROR, e.message || String(e));
80
+ });
79
81
  return {};
80
82
  },
81
83
  get_cert() {
@@ -147,7 +147,7 @@ const apis = {
147
147
  await (0, plugins_1.stopPlugin)(id);
148
148
  await (0, github_1.downloadPlugin)(found.repo, { branch: online.branch, overwrite: true });
149
149
  if (enabled)
150
- (0, plugins_1.startPlugin)(id).then(); // don't wait, in case it fails to start
150
+ void (0, plugins_1.startPlugin)(id); // don't wait, in case it fails to start
151
151
  return {};
152
152
  },
153
153
  async uninstall_plugin({ id }) {
package/src/api.vfs.js CHANGED
@@ -170,6 +170,7 @@ const apis = {
170
170
  await (0, promises_1.mkdir)(path, { recursive: true });
171
171
  return {};
172
172
  },
173
+ get_disk_spaces: util_os_1.getDiskSpaces,
173
174
  get_ls({ path, files = true, fileMask }, ctx) {
174
175
  return new SendList_1.SendListReadable({
175
176
  async doAtStart(list) {
@@ -183,6 +184,10 @@ const apis = {
183
184
  }
184
185
  return;
185
186
  }
187
+ try {
188
+ list.props((0, util_os_1.getDiskSpaceSync)(path));
189
+ }
190
+ catch (_a) { } // continue anyway
186
191
  try {
187
192
  const matching = (0, misc_1.makeMatcher)(fileMask);
188
193
  path = (0, misc_1.isWindowsDrive)(path) ? path + '\\' : (0, path_1.resolve)(path || '/');
@@ -202,7 +207,7 @@ const apis = {
202
207
  k: isDir ? 'd' : undefined,
203
208
  });
204
209
  }
205
- catch (_a) { } // just ignore entries we can't stat
210
+ catch (_b) { } // just ignore entries we can't stat
206
211
  }
207
212
  list.close();
208
213
  }
@@ -51,8 +51,10 @@ function apiMiddleware(apis) {
51
51
  }
52
52
  }
53
53
  catch (e) {
54
+ if (typeof e === 'string') // message meant to be transmitted
55
+ return send(const_1.HTTP_BAD_REQUEST, e);
54
56
  if (typeof e === 'number')
55
- e = new ApiError(const_1.HTTP_NOT_FOUND);
57
+ e = new ApiError(e);
56
58
  res = e;
57
59
  }
58
60
  if (isAsyncGenerator(res))
package/src/comments.js CHANGED
@@ -8,7 +8,7 @@ const config_1 = require("./config");
8
8
  const path_1 = require("path");
9
9
  const cross_1 = require("./cross");
10
10
  const util_files_1 = require("./util-files");
11
- const promises_1 = require("fs/promises");
11
+ const fs_1 = require("fs");
12
12
  const misc_1 = require("./misc");
13
13
  const lodash_1 = __importDefault(require("lodash"));
14
14
  const iconv_lite_1 = __importDefault(require("iconv-lite"));
@@ -32,29 +32,41 @@ exports.setCommentFor = (0, misc_1.singleWorkerFromBatchWorker)(async (jobs) =>
32
32
  comments.set(file, comment);
33
33
  }
34
34
  // encode comments in descript.ion format
35
- let txt = '';
36
- comments.forEach((c, f) => txt += (f.includes(' ') ? `"${f}"` : f) + ' ' + (c.includes('\n') ? c.replaceAll('\n', '\\n') + MULTILINE_SUFFIX : c) + '\n');
37
- const buffer = iconv_lite_1.default.encode(txt, descriptIonEncoding.get());
38
- await (0, promises_1.writeFile)((0, path_1.join)(folder, exports.DESCRIPT_ION), buffer);
35
+ const ws = (0, fs_1.createWriteStream)((0, path_1.join)(folder, exports.DESCRIPT_ION));
36
+ comments.forEach((comment, filename) => {
37
+ const multiline = comment.includes('\n');
38
+ const line = (filename.includes(' ') ? `"${filename}"` : filename)
39
+ + ' ' + (multiline ? comment.replaceAll('\n', '\\n') : comment);
40
+ ws.write(iconv_lite_1.default.encode(line, descriptIonEncoding.get()));
41
+ if (multiline)
42
+ ws.write(MULTILINE_SUFFIX, 'binary');
43
+ ws.write('\n');
44
+ });
39
45
  }));
40
46
  });
41
47
  function areCommentsEnabled() {
42
48
  return exports.descriptIon.get();
43
49
  }
44
50
  exports.areCommentsEnabled = areCommentsEnabled;
45
- const MULTILINE_SUFFIX = '\x04\xc2';
51
+ const MULTILINE_SUFFIX = Buffer.from([4, 0xC2]);
46
52
  function readDescription(path) {
47
- return (0, util_files_1.parseFile)((0, path_1.join)(path, exports.DESCRIPT_ION), raw =>
48
53
  // decoding could also be done with native TextDecoder.decode, but we need iconv for the encoding anyway
49
- new Map(iconv_lite_1.default.decode(raw, descriptIonEncoding.get()).split('\n').map(line => {
50
- const quoted = line[0] === '"' ? 1 : 0;
51
- const i = quoted ? line.indexOf('"', 2) + 1 : line.indexOf(' ');
52
- const fn = line.slice(quoted, i - quoted);
53
- let comment = line.slice(i + 1);
54
- if (comment.endsWith(MULTILINE_SUFFIX))
55
- comment = comment.slice(0, -2).replaceAll('\\n', '\n');
56
- return [fn, comment];
57
- })));
54
+ return (0, util_files_1.parseFile)((0, path_1.join)(path, exports.DESCRIPT_ION), raw => {
55
+ // for simplicity we "remove" the sequence MULTILINE_SUFFIX before iconv.decode messes it up
56
+ for (let i = 0; i < raw.length; i++)
57
+ if (raw[i] === MULTILINE_SUFFIX[0] && raw[i + 1] === MULTILINE_SUFFIX[1] && [undefined, 13, 10].includes(raw[i + 2]))
58
+ raw[i] = raw[i + 1] = 10;
59
+ const decoded = iconv_lite_1.default.decode(raw, descriptIonEncoding.get());
60
+ const ret = new Map(decoded.split('\n').map(line => {
61
+ const quoted = line[0] === '"' ? 1 : 0;
62
+ const i = quoted ? line.indexOf('"', 2) + 1 : line.indexOf(' ');
63
+ const fn = line.slice(quoted, i - quoted);
64
+ const comment = line.slice(i + 1).replaceAll('\\n', '\n');
65
+ return [fn, comment];
66
+ }));
67
+ ret.delete('');
68
+ return ret;
69
+ });
58
70
  }
59
71
  descriptIonEncoding.sub(() => {
60
72
  for (const k of util_files_1.parseFileCache.keys())
package/src/config.js CHANGED
@@ -180,7 +180,7 @@ const saveDebounced = (0, misc_1.debounceAsync)(async () => {
180
180
  await exports.configFile.save(stringify({ ...state, version: const_1.VERSION }))
181
181
  .catch(err => console.error('Failed at saving config file, please ensure it is writable.', String(err)));
182
182
  });
183
- const saveConfigAsap = () => void (saveDebounced());
183
+ const saveConfigAsap = () => void saveDebounced();
184
184
  exports.saveConfigAsap = saveConfigAsap;
185
185
  function stringify(obj) {
186
186
  return yaml_1.default.stringify(obj, { lineWidth: 1000 });
package/src/const.js CHANGED
@@ -45,7 +45,7 @@ exports.DEV = process.env.DEV || exports.argv.dev ? 'DEV' : '';
45
45
  exports.ORIGINAL_CWD = process.cwd();
46
46
  exports.HFS_STARTED = new Date();
47
47
  const PKG_PATH = (0, path_1.join)(__dirname, '..', 'package.json');
48
- exports.BUILD_TIMESTAMP = "2024-02-24T18:13:41.294Z";
48
+ exports.BUILD_TIMESTAMP = "2024-03-31T10:37:17.876Z";
49
49
  const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
50
50
  exports.VERSION = pkg.version;
51
51
  exports.RUNNING_BETA = exports.VERSION.includes('-');
package/src/cross.js CHANGED
@@ -305,10 +305,13 @@ exports.asyncGeneratorToArray = asyncGeneratorToArray;
305
305
  function repeat(everyMs, cb) {
306
306
  let stop = false;
307
307
  setTimeout(async () => {
308
- while (!stop && await Promise.allSettled([cb()]))
308
+ while (!stop && await Promise.allSettled([cb(stopIt)]))
309
309
  await wait(everyMs);
310
310
  });
311
- return () => stop = true;
311
+ return stopIt;
312
+ function stopIt() {
313
+ stop = true;
314
+ }
312
315
  }
313
316
  exports.repeat = repeat;
314
317
  function formatTimestamp(x) {
@@ -37,8 +37,10 @@ function debounceAsync(callback, wait = 100, options = {}) {
37
37
  const waitFor = Math.min(waitingCap, leading ? wait - (now - started) : wait);
38
38
  if (waitFor > 0)
39
39
  await new Promise(resolve => setTimeout(resolve, waitFor));
40
- if (!whoIsWaiting) // canceled
41
- return void (waitingSince = 0);
40
+ if (!whoIsWaiting) { // canceled
41
+ waitingSince = 0;
42
+ return undefined;
43
+ }
42
44
  if (whoIsWaiting !== args) // another fresher call is waiting
43
45
  return latestDebouncer;
44
46
  return exec();
@@ -98,7 +98,7 @@ exports.frontEndApis = {
98
98
  throw new apiMiddleware_1.ApiError(const_1.HTTP_UNAUTHORIZED);
99
99
  try {
100
100
  await (0, promises_1.rm)(node.source, { recursive: true });
101
- (0, comments_1.setCommentFor)(node.source, '').then();
101
+ void (0, comments_1.setCommentFor)(node.source, '');
102
102
  return {};
103
103
  }
104
104
  catch (e) {
@@ -125,8 +125,8 @@ exports.frontEndApis = {
125
125
  (0, comments_1.getCommentFor)(node.source).then(c => {
126
126
  if (!c)
127
127
  return;
128
- (0, comments_1.setCommentFor)(node.source, '').then();
129
- (0, comments_1.setCommentFor)(destSource, c).then();
128
+ void (0, comments_1.setCommentFor)(node.source, '');
129
+ void (0, comments_1.setCommentFor)(destSource, c);
130
130
  });
131
131
  }
132
132
  return {};
package/src/index.js CHANGED
@@ -38,8 +38,8 @@ const keys = ((_a = process.env.COOKIE_SIGN_KEYS) === null || _a === void 0 ? vo
38
38
  exports.app = new koa_1.default({ keys });
39
39
  exports.app.use(middlewares_1.sessionMiddleware)
40
40
  .use(selfCheck_1.selfCheckMiddleware)
41
- .use(middlewares_1.someSecurity)
42
41
  .use(acme_1.acmeMiddleware)
42
+ .use(middlewares_1.someSecurity)
43
43
  .use(middlewares_1.prepareState)
44
44
  .use(geo_1.geoFilter)
45
45
  .use(middlewares_1.gzipper)
@@ -1,7 +1,7 @@
1
1
  {
2
- "author": "Eidy Estupiñan Varona",
3
- "version": 1.0,
4
- "hfs_version": "0.46.0",
2
+ "author": "Eidy Estupiñan Varona, Arturo Fernández Rivas",
3
+ "version": 1.2,
4
+ "hfs_version": "0.52.0",
5
5
  "translate": {
6
6
  "Select": "Seleccionar",
7
7
  "n_files": "{n,plural,one{# archivo} other {# archivos}}",
@@ -10,9 +10,9 @@
10
10
  "select_count": "{n,plural, one{# seleccionado} other{# seleccionados}}",
11
11
  "filter_placeholder": "Escriba aquí para filtrar la lista a continuación",
12
12
  "Select some files": "Seleccione algunos archivos",
13
- "zip_checkboxes": "Use casillas de verificación para seleccionar los archivos, luego puede usar la opción Zip nuevamente",
13
+ "zip_checkboxes": "Use las casillas de verificación para seleccionar los archivos, luego puede usar la opción Zip nuevamente",
14
14
  "zip_tooltip_selected": "Descargue los elementos seleccionados como un solo archivo zip",
15
- "zip_tooltip_whole": "Descargue la lista completa (sin filtrar) como un solo archivo zip. Si selecciona algunos elementos, solo se descargarán esos.",
15
+ "zip_tooltip_whole": "Descargue la lista completa (sin filtrar) o los archivos seleccionados, como un solo archivo zip.",
16
16
  "zip_confirm_search": "¿Descargar TODOS los resultados de esta búsqueda como archivo ZIP?",
17
17
  "zip_confirm_folder": "¿Descargar toda la carpeta como archivo Zip?",
18
18
  "select_tooltip": "La selección se aplica a \"Zip\" y \"Eliminar\" (cuando esté disponible), pero también puede filtrar la lista",
@@ -25,37 +25,37 @@
25
25
  "Options": "Opciones",
26
26
  "Search": "Buscar",
27
27
  "Zip": "Zip",
28
- "search_msg": "Buscar esta carpeta y subcarpetas",
28
+ "search_msg": "Buscar en esta carpeta y subcarpetas",
29
29
  "Searching": "Buscando",
30
30
  "Searched": "Buscado",
31
31
  "Clear search": "Limpiar búsqueda",
32
32
  "Interrupted": "Interrumpido",
33
33
  "stopped_before": "stopped_before",
34
- "empty_list": "Lista vacia",
34
+ "empty_list": "Lista vacía",
35
35
  "filter_none": "No filtrado",
36
36
  "Admin-panel": "Administración",
37
37
  "Login": "Acceder",
38
38
  "Username": "Usuario",
39
39
  "Password": "Contraseña",
40
- "login_untrusted": "Acceso abortado: la identidad del servidor no es confiable",
40
+ "login_untrusted": "Acceso cancelado: la identidad del servidor no es confiable",
41
41
  "login_bad_credentials": "Credenciales no válidas",
42
42
  "login_bad_cookies": "Las Cookies no funcionan - acceso fallido",
43
43
  "User panel": "Panel de usuario",
44
44
  "Change password": "Cambiar contraseña",
45
45
  "enter_pass": "Nueva contraseña",
46
- "enter_pass2": "Confirmación",
47
- "pass2_mismatch": "Error: Las contraseñas no coinciden. cambio abortado.",
46
+ "enter_pass2": "Confirme contraseña",
47
+ "pass2_mismatch": "Error: Las contraseñas no coinciden.",
48
48
  "password_changed": "Contraseña cambiada",
49
49
  "Logout": "Salir",
50
50
  "connection error": "Error de conexión",
51
51
  "Full timestamp:": "Fecha - Hora completa",
52
52
  "Search was interrupted": "La búsqueda fue interrumpida",
53
53
  "Stop list": "Detener Lista",
54
- "upload_starting": "Su descarga debería iniciar ahora",
55
- "wrong_account": "La cuenta {u} no tiene acceso, prueba otra",
54
+ "upload_starting": "Su descarga debería iniciarse ahora",
55
+ "wrong_account": "La cuenta {u} no tiene acceso.",
56
56
  "no_upload_here": "No tiene permisos para subir a la carpeta actual",
57
57
  "Create folder": "Crear carpeta",
58
- "Pick files": "Seleccioanr archivo",
58
+ "Pick files": "Seleccionar archivo",
59
59
  "Pick folder": "Seleccionar carpeta",
60
60
  "send_files": "Enviar {n,plural,one {# archivo} other{# archivos}}, {size}",
61
61
  "Clear": "Limpiar",
@@ -64,16 +64,16 @@
64
64
  "file too large": "archivo demasiado grande",
65
65
  "Enter folder name": "Nombre de la carpeta",
66
66
  "Successfully created": "Creado satisfactoriamente",
67
- "enter_folder": "Entre la carpeta",
67
+ "enter_folder": "Introduzca carpeta",
68
68
  "folder_exists": "Ya existe una carpeta con ese nombre",
69
69
  "Sort by": "Ordenar por",
70
70
  "name": "nombre",
71
71
  "extension": "extensión",
72
72
  "size": "tamaño",
73
73
  "time": "fecha",
74
- "Invert order": "Invertir orden",
75
- "Folders first": "Carpetas primero",
76
- "Numeric names": "Nombres numéricos",
74
+ "Invert order": "Orden descendente",
75
+ "Folders first": "Mostrar primero las carpetas",
76
+ "Numeric names": "Ordenar números",
77
77
  "theme:": "Tema",
78
78
  "auto": "auto",
79
79
  "light": "Claro",
@@ -85,11 +85,11 @@
85
85
  "Don't": "Cancelar",
86
86
  "Warning": "Alerta",
87
87
  "Error": "Error",
88
- "Info": "Info",
88
+ "Info": "Información",
89
89
  "Unauthorized": "No autorizado",
90
90
  "Forbidden": "Denegado",
91
91
  "Not found": "No encontrado",
92
- "Server error": "Server error",
92
+ "Server error": "Error de servidor",
93
93
  "Upload": "Subir",
94
94
  "upload_concluded": "Subida completada",
95
95
  "upload_finished": "{n} completado ({size})",
@@ -106,13 +106,58 @@
106
106
  "Skip existing files": "Saltar archivos existentes",
107
107
  "Size": "Tamaño",
108
108
  "Timestamp": "Fecha - Hora",
109
- "Show": "Mostrar",
109
+ "Show": "Visualizar",
110
110
  "Loading failed": "Carga fallida",
111
111
  "Rename": "Renombrar",
112
112
  "Tiles mode:": "Cantidad elementos",
113
113
  "off": "Apagado",
114
114
  "Operation successful": "Operación Completada",
115
115
  "Uploader": "Subido por",
116
- "Download counter": "Contador de descargas"
116
+ "Download counter": "Contador de descargas",
117
+ "Switch zoom mode": "Cambiar modo de zoom",
118
+ "Full screen": "Pantalla completa",
119
+ "File Show help": "Ayuda",
120
+ "showHelpMain": "Puede usar el teclado para algunas acciones:",
121
+ "showHelp_←/→": "←/→",
122
+ "showHelp_↑/↓": "↑/↓",
123
+ "showHelp_space": "barra espaciadora",
124
+ "showHelp_←/→_body": "ir al archivo anterior/siguiente",
125
+ "showHelp_↑/↓_body": "scroll miniaturas",
126
+ "showHelp_space_body": "seleccionar",
127
+ "showHelp_D_body": "descargar",
128
+ "showHelp_Z_body": "modos de zoom",
129
+ "showHelp_F_body": "pantalla completa",
130
+ "Destination": "Destino",
131
+ "in_queue": "{n} en cola",
132
+ "enter_comment": "Descripción para {name}",
133
+ "Comment": "Descripción",
134
+ "upload_dd_hint": "Puede cargar archivos arrastrando y soltando en la lista de archivos",
135
+ "Upload not available": "Carga no disponible",
136
+ "Cut": "Cortar",
137
+ "n_items": "{n,plural, one{# elemento} other{# elementos}}",
138
+ "good_bad": "{good} movido, {bad} fallado",
139
+ "after_cut": "Su selección está ahora en el portapapeles.\nVaya a la carpeta de destino para pegar.",
140
+ "Cancel clipboard": "Cancelar portapapeles",
141
+ "to_clipboard_source": "A la carpeta",
142
+ "Paste": "Pegar",
143
+ "clipboard_list": "Elementos en el portapapeles:",
144
+ "Close": "Cerrar",
145
+ "Folder": "Carpeta",
146
+ "Web page": "Página web",
147
+ "Link": "Enlace",
148
+ "Auto-play": "Auto-reproducir",
149
+ "autoplay_seconds": "Segundos entre imágenes",
150
+ "Select all": "Seleccionar todo",
151
+ "go_first": "Ir al principio",
152
+ "go_last": "Ir al final",
153
+ "Shuffle": "Aleatorio",
154
+ "Repeat": "Repetir",
155
+ "showHelpListShortcut": "En la lista de archivos, haga clic manteniendo pulsada {key} para Mostrar rápidamente",
156
+ "Invalid value": "Valor no válido",
157
+ "upload_skipped": "Se salta {n}",
158
+ "Overwrite policy": "Reglas para sobreescribir",
159
+ "Rename to avoid overwriting": "Renombrar para evitar sobrescribir",
160
+ "Overwrite existing files": "Sobrescribir archivos existentes",
161
+ "Menu": "Menú"
117
162
  }
118
163
  }