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
package/src/util-os.js CHANGED
@@ -1,41 +1,79 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runCmd = exports.getDrives = exports.getFreeDiskSync = void 0;
6
+ exports.RUNNING_AS_SERVICE = exports.runCmd = exports.getDrives = exports.getDiskSpaces = exports.getDiskSpaceSync = void 0;
4
7
  const path_1 = require("path");
5
8
  const child_process_1 = require("child_process");
6
9
  const misc_1 = require("./misc");
10
+ const lodash_1 = __importDefault(require("lodash"));
11
+ const node_process_1 = require("node:process");
7
12
  const util_1 = require("util");
8
13
  const const_1 = require("./const");
9
- function getFreeDiskSync(path) {
10
- var _a;
14
+ function getDiskSpaceSync(path) {
11
15
  if (const_1.IS_WINDOWS) {
12
16
  const drive = (0, path_1.resolve)(path).slice(0, 2).toUpperCase();
13
- const out = (0, child_process_1.execSync)('wmic logicaldisk get FreeSpace,name /format:list').toString().replace(/\r/g, '');
14
- const one = out.split(/\n\n+/).find(x => x.includes('Name=' + drive));
17
+ const out = (0, child_process_1.execSync)('wmic logicaldisk get Size,FreeSpace,Name /format:list').toString().replace(/\r/g, '');
18
+ const one = parseKeyValueObjects(out).find(x => x.Name === drive);
15
19
  if (!one)
16
20
  throw Error('miss');
17
- return Number((_a = /FreeSpace=(\d+)/.exec(one)) === null || _a === void 0 ? void 0 : _a[1]);
21
+ return { free: Number(one.FreeSpace), total: Number(one.Size) };
22
+ }
23
+ const out = (0, misc_1.try_)(() => (0, child_process_1.execSync)(`df -k "${path}"`).toString(), err => { throw err.status === 1 ? Error('miss') : err.status === 127 ? Error('unsupported') : err; });
24
+ if (!(out === null || out === void 0 ? void 0 : out.startsWith('Filesystem')))
25
+ throw Error('unsupported');
26
+ const one = out.split('\n')[1];
27
+ const [used, free] = one.split(/\s+/).slice(2, 4).map(x => Number(x) * 1024);
28
+ return { free, total: used + free };
29
+ }
30
+ exports.getDiskSpaceSync = getDiskSpaceSync;
31
+ async function getDiskSpaces() {
32
+ var _a;
33
+ if (const_1.IS_WINDOWS) {
34
+ const fields = ['Size', 'FreeSpace', 'Name', 'Description'];
35
+ const out = await runCmd(`wmic logicaldisk get ${fields.join()} /format:list`);
36
+ const objs = parseKeyValueObjects(out);
37
+ return (0, misc_1.onlyTruthy)(objs.map(x => x.Size && {
38
+ total: Number(x.Size),
39
+ free: Number(x.FreeSpace),
40
+ name: x.Name,
41
+ description: x.Description
42
+ }));
18
43
  }
19
- const out = (0, misc_1.try_)(() => (0, child_process_1.execSync)(`df -k "${path}"`).toString(), err => {
44
+ const { stdout } = await (0, util_1.promisify)(child_process_1.exec)(`df -k -l`).catch(err => {
20
45
  throw err.status === 1 ? Error('miss')
21
46
  : err.status === 127 ? Error('unsupported')
22
47
  : err;
23
48
  });
24
- if (!(out === null || out === void 0 ? void 0 : out.startsWith('Filesystem')))
49
+ const out = stdout.split('\n');
50
+ if (!((_a = out.shift()) === null || _a === void 0 ? void 0 : _a.startsWith('Filesystem')))
25
51
  throw Error('unsupported');
26
- const one = out.split('\n')[1];
27
- const free = Number(one.split(/\s+/)[3]);
28
- return free * 1024;
52
+ return (0, misc_1.onlyTruthy)(out.map(one => {
53
+ const bits = one.split(/\s+/);
54
+ const name = bits.pop() || bits.shift() || '';
55
+ const [, used = 0, free = 0] = bits.map(x => Number(x) * 1024);
56
+ const total = used + free;
57
+ return total && { free, total, name };
58
+ }));
29
59
  }
30
- exports.getFreeDiskSync = getFreeDiskSync;
60
+ exports.getDiskSpaces = getDiskSpaces;
31
61
  async function getDrives() {
32
- const { stdout } = await (0, util_1.promisify)(child_process_1.exec)('wmic logicaldisk get name');
62
+ const stdout = await runCmd('wmic logicaldisk get name');
33
63
  return stdout.split('\n').slice(1).map(x => x.trim()).filter(Boolean);
34
64
  }
35
65
  exports.getDrives = getDrives;
36
66
  // execute win32 shell commands
37
67
  async function runCmd(cmd, args = []) {
38
- const { stdout, stderr } = await (0, util_1.promisify)(child_process_1.execFile)('cmd', ['/c', cmd, ...args]);
39
- return stderr || stdout;
68
+ const { stdout, stderr } = await (0, util_1.promisify)(child_process_1.exec)(`@chcp 65001 >nul & cmd /c ${cmd} ${args.join(' ')}`, { encoding: 'utf-8' });
69
+ return (stderr || stdout).replace(/\r/g, '');
40
70
  }
41
71
  exports.runCmd = runCmd;
72
+ async function getWindowsServicePids() {
73
+ const res = await runCmd(`wmic service get ProcessId`);
74
+ return lodash_1.default.uniq(res.split('\n').slice(1).map(x => Number(x.trim())));
75
+ }
76
+ exports.RUNNING_AS_SERVICE = const_1.IS_WINDOWS && getWindowsServicePids().then(x => x.includes(node_process_1.pid));
77
+ function parseKeyValueObjects(all, keySep = '=', lineSep = '\n', objectSep = /\n\n+/) {
78
+ return all.split(objectSep).map(obj => Object.fromEntries(obj.split(lineSep).map(kv => (0, misc_1.splitAt)(keySep, kv))));
79
+ }
package/src/vfs.js CHANGED
@@ -47,10 +47,13 @@ function inheritFromParent(parent, child) {
47
47
  return child;
48
48
  }
49
49
  function isSameFilenameAs(name) {
50
- const lc = name.toLowerCase();
51
- return (other) => lc === (typeof other === 'string' ? other : getNodeName(other)).toLowerCase();
50
+ const normalized = normalizeFilename(name);
51
+ return (other) => normalized === normalizeFilename(typeof other === 'string' ? other : getNodeName(other));
52
52
  }
53
53
  exports.isSameFilenameAs = isSameFilenameAs;
54
+ function normalizeFilename(x) {
55
+ return const_1.IS_WINDOWS || const_1.IS_MAC ? x.toLocaleLowerCase() : x;
56
+ }
54
57
  async function applyParentToChild(child, parent, name) {
55
58
  var _a, _b;
56
59
  const ret = {
@@ -216,7 +219,7 @@ async function* walkNode(parent, { ctx, depth = Infinity, prefixPath = '', requi
216
219
  continue;
217
220
  const nodeName = getNodeName(child);
218
221
  const name = prefixPath + nodeName;
219
- took === null || took === void 0 ? void 0 : took.add(name);
222
+ took === null || took === void 0 ? void 0 : took.add(normalizeFilename(name));
220
223
  const item = { ...child, name };
221
224
  if (!canSee(item))
222
225
  continue;
@@ -249,7 +252,7 @@ async function* walkNode(parent, { ctx, depth = Infinity, prefixPath = '', requi
249
252
  if (ctx === null || ctx === void 0 ? void 0 : ctx.req.aborted)
250
253
  return;
251
254
  const name = prefixPath + (((_a = parent.rename) === null || _a === void 0 ? void 0 : _a[path]) || path);
252
- if (took === null || took === void 0 ? void 0 : took.has(name))
255
+ if (took === null || took === void 0 ? void 0 : took.has(normalizeFilename(name)))
253
256
  continue;
254
257
  if (depth) {
255
258
  const dir = (0, path_1.dirname)(name);
package/src/watchLoad.js CHANGED
@@ -26,11 +26,11 @@ function watchLoad(path, parser, { failedOnFirstAttempt, immediateFirst } = {})
26
26
  try {
27
27
  watcher = (0, fs_1.watch)(path, () => {
28
28
  if (!save.isWorking())
29
- debounced().then();
29
+ void debounced();
30
30
  });
31
31
  debounced().catch(x => x);
32
32
  if (immediateFirst)
33
- debounced.flush().then();
33
+ void debounced.flush();
34
34
  }
35
35
  catch (e) {
36
36
  retry = setTimeout(install, 3000); // manual watching until watch is successful
@@ -1 +0,0 @@
1
- .ariaOnly{position:absolute;clip-path:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px)}:root{height:100dvh;--success: #5c5}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;height:100vh;background:#000}#root{min-height:100%;display:flex}main{word-break:break-word}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}img.flag{width:1.5em;height:1em;vertical-align:text-top;margin-top:1px}.icon-w-text{margin-right:.5em}.MuiSvgIcon-root{vertical-align:bottom}.MuiTreeItem-content{box-sizing:border-box}.MuiDataGrid-columnHeaders{background-color:#8882}.MuiDataGrid-cell{line-height:1.1em}.wrap[role=cell]{white-space:normal!important}ol,ul{margin-top:.2em;margin-bottom:.2em;padding-left:1.5em}h2.MuiDialogTitle-root{padding-top:2px;padding-bottom:2px}.dialog-alert .MuiDialogContent-root{max-width:45em;padding:.5em 1em}.animated-dashed-line{width:100%;height:2px;background-image:linear-gradient(to right,currentColor 50%,transparent 50%);background-size:10px 100%;animation:animate-dash 1s alternate linear infinite}@keyframes animate-dash{to{background-position:20px 0}}@keyframes blink{0%{opacity:1}50%{opacity:.2}}@keyframes success{50%{transform:scale(1.5);color:var(--success)}to{transform:inherit;color:inherit}}