hfs 0.48.0-alpha2 → 0.48.0-beta6
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-d266c6e7.js +536 -0
- package/admin/assets/{sha512-136b5a7c.js → sha512-7fcb77a2.js} +1 -1
- package/admin/index.html +1 -1
- package/frontend/assets/index-ad985b09.js +94 -0
- package/frontend/assets/{sha512-549e6c3a.js → sha512-ff90a9e0.js} +1 -1
- package/frontend/fontello.css +2 -11
- package/frontend/fontello.woff2 +0 -0
- package/frontend/index.html +1 -1
- package/package.json +4 -3
- package/plugins/list-uploader/plugin.js +1 -0
- package/plugins/list-uploader/public/main.js +3 -2
- package/src/QuickZipStream.js +1 -0
- package/src/api.file_list.js +38 -37
- package/src/api.net.js +150 -46
- package/src/api.plugins.js +25 -20
- package/src/config.js +2 -3
- package/src/const.js +4 -3
- package/src/cross.js +30 -1
- package/src/debounceAsync.js +13 -4
- package/src/frontEndApis.js +6 -12
- package/src/github.js +33 -45
- package/src/index.js +2 -0
- package/src/langs/embedded.js +2 -1
- package/src/langs/hfs-lang-fi.json +131 -0
- package/src/langs/hfs-lang-it.json +2 -0
- package/src/langs/hfs-lang-ru.json +11 -5
- package/src/listen.js +31 -16
- package/src/log.js +4 -5
- package/src/middlewares.js +2 -2
- package/src/misc.js +30 -3
- package/src/upload.js +1 -1
- package/src/util-files.js +3 -7
- package/src/watchLoad.js +5 -5
- package/admin/assets/index-344723f8.js +0 -520
- package/frontend/assets/index-12411ff6.js +0 -94
package/src/misc.js
CHANGED
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.asyncGeneratorToReadable = exports.stream2string = exports.same = exports.matches = exports.makeMatcher = exports.makeNetMatcher = exports.isLocalHost = exports.onOff = exports.pattern2filter = exports.onFirstEvent = exports.onProcessExit = exports.debounceAsync = void 0;
|
|
21
|
+
exports.apiAssertTypes = exports.AsapStream = exports.asyncGeneratorToReadable = exports.stream2string = exports.same = exports.matches = exports.makeMatcher = exports.makeNetMatcher = exports.isLocalHost = exports.onOff = exports.pattern2filter = exports.onFirstEvent = exports.onProcessExit = exports.debounceAsync = void 0;
|
|
22
22
|
const path_1 = require("path");
|
|
23
23
|
const lodash_1 = __importDefault(require("lodash"));
|
|
24
24
|
const assert_1 = __importDefault(require("assert"));
|
|
@@ -30,6 +30,8 @@ const micromatch_1 = require("micromatch");
|
|
|
30
30
|
const node_net_1 = require("node:net");
|
|
31
31
|
const debounceAsync_1 = __importDefault(require("./debounceAsync"));
|
|
32
32
|
exports.debounceAsync = debounceAsync_1.default;
|
|
33
|
+
const apiMiddleware_1 = require("./apiMiddleware");
|
|
34
|
+
const const_1 = require("./const");
|
|
33
35
|
const cbs = new Set();
|
|
34
36
|
function onProcessExit(cb) {
|
|
35
37
|
cbs.add(cb);
|
|
@@ -67,7 +69,7 @@ function onOff(em, events) {
|
|
|
67
69
|
}
|
|
68
70
|
exports.onOff = onOff;
|
|
69
71
|
function isLocalHost(c) {
|
|
70
|
-
const ip = c.socket.remoteAddress; // don't use Context.ip as it is subject to proxied ips, and that's no use for localhost detection
|
|
72
|
+
const ip = typeof c === 'string' ? c : c.socket.remoteAddress; // don't use Context.ip as it is subject to proxied ips, and that's no use for localhost detection
|
|
71
73
|
return ip && (ip === '::1' || ip.endsWith('127.0.0.1'));
|
|
72
74
|
}
|
|
73
75
|
exports.isLocalHost = isLocalHost;
|
|
@@ -83,7 +85,7 @@ function makeNetMatcher(mask, emptyMaskReturns = false) {
|
|
|
83
85
|
all[0] = all[0].slice(1);
|
|
84
86
|
const bl = new node_net_1.BlockList();
|
|
85
87
|
for (const x of all) {
|
|
86
|
-
const m = /^([.:\
|
|
88
|
+
const m = /^([.:\da-f]+)(?:\/(\d+)|-(.+)|)$/i.exec(x);
|
|
87
89
|
if (!m) {
|
|
88
90
|
console.warn("error in network mask", x);
|
|
89
91
|
continue;
|
|
@@ -147,3 +149,28 @@ function asyncGeneratorToReadable(generator) {
|
|
|
147
149
|
});
|
|
148
150
|
}
|
|
149
151
|
exports.asyncGeneratorToReadable = asyncGeneratorToReadable;
|
|
152
|
+
// produces as soon as a promise resolves, not sequentially
|
|
153
|
+
class AsapStream extends stream_1.Readable {
|
|
154
|
+
constructor(promises) {
|
|
155
|
+
super({ objectMode: true });
|
|
156
|
+
this.promises = promises;
|
|
157
|
+
this.finished = false;
|
|
158
|
+
}
|
|
159
|
+
_read() {
|
|
160
|
+
if (this.finished)
|
|
161
|
+
return;
|
|
162
|
+
this.finished = true;
|
|
163
|
+
for (const p of this.promises)
|
|
164
|
+
p.then(data => this.push(data), e => this.emit('error', e));
|
|
165
|
+
Promise.allSettled(this.promises).then(() => this.push(null));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.AsapStream = AsapStream;
|
|
169
|
+
function apiAssertTypes(paramsByType) {
|
|
170
|
+
for (const [types, params] of Object.entries(paramsByType))
|
|
171
|
+
for (const type of types.split('_'))
|
|
172
|
+
for (const [name, val] of Object.entries(params))
|
|
173
|
+
if (typeof val !== type)
|
|
174
|
+
throw new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST, 'bad ' + name);
|
|
175
|
+
}
|
|
176
|
+
exports.apiAssertTypes = apiAssertTypes;
|
package/src/upload.js
CHANGED
|
@@ -26,7 +26,7 @@ function getUploadMeta(path) {
|
|
|
26
26
|
exports.getUploadMeta = getUploadMeta;
|
|
27
27
|
function setUploadMeta(path, ctx) {
|
|
28
28
|
return (0, misc_1.storeFileAttr)(path, ATTR_UPLOADER, {
|
|
29
|
-
username: (0, perm_1.getCurrentUsername)(ctx),
|
|
29
|
+
username: (0, perm_1.getCurrentUsername)(ctx) || undefined,
|
|
30
30
|
ip: ctx.ip,
|
|
31
31
|
});
|
|
32
32
|
}
|
package/src/util-files.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.loadFileAttr = exports.storeFileAttr = exports.isValidFileName = exports.createFileWithPath = exports.prepareFolder = exports.unzip = exports.dirStream = exports.adjustStaticPathForGlob = exports.
|
|
7
|
+
exports.loadFileAttr = exports.storeFileAttr = exports.isValidFileName = exports.createFileWithPath = exports.prepareFolder = exports.unzip = exports.dirStream = exports.adjustStaticPathForGlob = exports.dirTraversal = exports.watchDir = exports.readFileBusy = exports.isDirectory = void 0;
|
|
8
8
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
9
|
const misc_1 = require("./misc");
|
|
10
10
|
const util_1 = require("util");
|
|
@@ -77,10 +77,6 @@ function dirTraversal(s) {
|
|
|
77
77
|
return s && /(^|[/\\])\.\.($|[/\\])/.test(s);
|
|
78
78
|
}
|
|
79
79
|
exports.dirTraversal = dirTraversal;
|
|
80
|
-
function isWindowsDrive(s) {
|
|
81
|
-
return s && /^[a-zA-Z]:$/.test(s);
|
|
82
|
-
}
|
|
83
|
-
exports.isWindowsDrive = isWindowsDrive;
|
|
84
80
|
// apply this to paths that may contain \ as separator (not supported by fast-glob) and other special chars to be escaped (parenthesis)
|
|
85
81
|
function adjustStaticPathForGlob(path) {
|
|
86
82
|
return fast_glob_1.default.escapePath(path.replace(/\\/g, '/'));
|
|
@@ -139,7 +135,7 @@ exports.unzip = unzip;
|
|
|
139
135
|
async function prepareFolder(path, dirnameIt = true) {
|
|
140
136
|
if (dirnameIt)
|
|
141
137
|
path = (0, path_1.dirname)(path);
|
|
142
|
-
if (isWindowsDrive(path))
|
|
138
|
+
if ((0, misc_1.isWindowsDrive)(path))
|
|
143
139
|
return;
|
|
144
140
|
try {
|
|
145
141
|
await promises_1.default.mkdir(path, { recursive: true });
|
|
@@ -152,7 +148,7 @@ async function prepareFolder(path, dirnameIt = true) {
|
|
|
152
148
|
exports.prepareFolder = prepareFolder;
|
|
153
149
|
function createFileWithPath(path, options) {
|
|
154
150
|
const folder = (0, path_1.dirname)(path);
|
|
155
|
-
if (!isWindowsDrive(folder))
|
|
151
|
+
if (!(0, misc_1.isWindowsDrive)(folder))
|
|
156
152
|
try {
|
|
157
153
|
(0, fs_1.mkdirSync)(folder, { recursive: true });
|
|
158
154
|
}
|
package/src/watchLoad.js
CHANGED
|
@@ -18,11 +18,11 @@ function watchLoad(path, parser, { failedOnFirstAttempt, immediateFirst } = {})
|
|
|
18
18
|
install(true);
|
|
19
19
|
return {
|
|
20
20
|
unwatch: uninstall,
|
|
21
|
-
save(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
saving = undefined)
|
|
25
|
-
}
|
|
21
|
+
save: (data) => Promise.resolve(saving).catch(() => { }).then(() => {
|
|
22
|
+
console.debug('writing', path);
|
|
23
|
+
return saving = promises_1.default.writeFile(path, data, 'utf8').finally(() => // save but also keep track of the current operation
|
|
24
|
+
saving = undefined);
|
|
25
|
+
}) // clear
|
|
26
26
|
};
|
|
27
27
|
function install(first = false) {
|
|
28
28
|
try {
|