hfs 0.53.0-alpha3 → 0.53.0-alpha5
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-D95ycf6f.js → index-D9rdfxGQ.js} +147 -147
- package/admin/assets/{sha512-NegoJIqW.js → sha512-DtDI0h32.js} +1 -1
- package/admin/index.html +1 -1
- package/frontend/assets/{index-legacy-BzpvPuwE.js → index-legacy-BJteGyzW.js} +5 -5
- package/frontend/assets/{sha512-legacy-BaHlAWFl.js → sha512-legacy-FCsosd8m.js} +1 -1
- package/frontend/index.html +1 -1
- package/package.json +1 -1
- package/src/const.js +1 -1
- package/src/plugins.js +13 -2
- package/src/roots.js +8 -8
- package/src/serveGuiFiles.js +1 -0
- package/src/upload.js +34 -30
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
System.register(["./index-legacy-
|
|
1
|
+
System.register(["./index-legacy-BJteGyzW.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/index.html
CHANGED
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
<div id="root"></div>
|
|
12
12
|
<script nomodule>document.getElementById('root').innerText = "Please use a newer browser"</script>
|
|
13
13
|
<script crossorigin id="vite-legacy-polyfill" src="/assets/polyfills-legacy-DMrMt_pQ.js"></script>
|
|
14
|
-
<script crossorigin id="vite-legacy-entry" data-src="/assets/index-legacy-
|
|
14
|
+
<script crossorigin id="vite-legacy-entry" data-src="/assets/index-legacy-BJteGyzW.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
|
|
15
15
|
</body>
|
|
16
16
|
</html>
|
package/package.json
CHANGED
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-05-
|
|
48
|
+
exports.BUILD_TIMESTAMP = "2024-05-16T18:48:59.998Z";
|
|
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/plugins.js
CHANGED
|
@@ -75,6 +75,9 @@ async function stopPlugin(id) {
|
|
|
75
75
|
}
|
|
76
76
|
exports.stopPlugin = stopPlugin;
|
|
77
77
|
async function startPlugin(id) {
|
|
78
|
+
var _a;
|
|
79
|
+
if ((_a = getPluginInfo(id)) === null || _a === void 0 ? void 0 : _a.isTheme)
|
|
80
|
+
await Promise.all(mapPlugins((pl, id) => pl.isTheme && stopPlugin(id)));
|
|
78
81
|
enablePlugin(id);
|
|
79
82
|
await waitRunning(id);
|
|
80
83
|
}
|
|
@@ -204,6 +207,7 @@ class Plugin {
|
|
|
204
207
|
get version() { var _a; return (_a = this.data) === null || _a === void 0 ? void 0 : _a.version; }
|
|
205
208
|
get description() { var _a; return (_a = this.data) === null || _a === void 0 ? void 0 : _a.description; }
|
|
206
209
|
get apiRequired() { var _a; return (_a = this.data) === null || _a === void 0 ? void 0 : _a.apiRequired; }
|
|
210
|
+
get isTheme() { var _a; return (_a = this.data) === null || _a === void 0 ? void 0 : _a.isTheme; }
|
|
207
211
|
get repo() { var _a; return (_a = this.data) === null || _a === void 0 ? void 0 : _a.repo; }
|
|
208
212
|
get depend() { var _a; return (_a = this.data) === null || _a === void 0 ? void 0 : _a.depend; }
|
|
209
213
|
get middleware() {
|
|
@@ -247,6 +251,11 @@ class Plugin {
|
|
|
247
251
|
exports.Plugin = Plugin;
|
|
248
252
|
exports.SERVER_CODE_ID = '.'; // a name that will surely be not found among plugin folders
|
|
249
253
|
const serverCode = (0, config_1.defineConfig)('server_code', '', async (script, { k }) => {
|
|
254
|
+
var _a;
|
|
255
|
+
try {
|
|
256
|
+
(_a = (await serverCode.compiled())) === null || _a === void 0 ? void 0 : _a.unload();
|
|
257
|
+
}
|
|
258
|
+
catch (_b) { }
|
|
250
259
|
const res = {};
|
|
251
260
|
try {
|
|
252
261
|
new Function('exports', script)(res); // parse
|
|
@@ -483,13 +492,15 @@ function deleteModule(id) {
|
|
|
483
492
|
}
|
|
484
493
|
(0, misc_1.onProcessExit)(() => Promise.allSettled(mapPlugins(pl => pl.unload())));
|
|
485
494
|
function parsePluginSource(id, source) {
|
|
486
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
495
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
487
496
|
const pl = { id };
|
|
488
497
|
pl.description = (0, misc_1.tryJson)((_a = /exports.description *= *(".*")/.exec(source)) === null || _a === void 0 ? void 0 : _a[1]);
|
|
489
498
|
pl.repo = (0, misc_1.tryJson)((_b = /exports.repo *= *(.*);? *$/m.exec(source)) === null || _b === void 0 ? void 0 : _b[1]);
|
|
490
499
|
pl.version = (_d = Number((_c = /exports.version *= *(\d*\.?\d+)/.exec(source)) === null || _c === void 0 ? void 0 : _c[1])) !== null && _d !== void 0 ? _d : undefined;
|
|
491
500
|
pl.apiRequired = (_f = (0, misc_1.tryJson)((_e = /exports.apiRequired *= *([ \d.,[\]]+)/.exec(source)) === null || _e === void 0 ? void 0 : _e[1])) !== null && _f !== void 0 ? _f : undefined;
|
|
492
|
-
pl.
|
|
501
|
+
pl.isTheme = (_h = (0, misc_1.tryJson)((_g = /exports.isTheme *= *(true|false|"light"|"dark")/.exec(source)) === null || _g === void 0 ? void 0 : _g[1])) !== null && _h !== void 0 ? _h : (id.endsWith('-theme') || undefined);
|
|
502
|
+
pl.preview = (_k = (0, misc_1.tryJson)((_j = /exports.preview *= *(.+)/.exec(source)) === null || _j === void 0 ? void 0 : _j[1])) !== null && _k !== void 0 ? _k : undefined;
|
|
503
|
+
pl.depend = (_m = (0, misc_1.tryJson)((_l = /exports.depend *= *(\[.*\])/m.exec(source)) === null || _l === void 0 ? void 0 : _l[1])) === null || _m === void 0 ? void 0 : _m.filter((x) => typeof x.repo === 'string' && x.version === undefined || typeof x.version === 'number'
|
|
493
504
|
|| console.warn("plugin dependency discarded", x));
|
|
494
505
|
if (Array.isArray(pl.apiRequired) && (pl.apiRequired.length !== 2 || !pl.apiRequired.every(lodash_1.default.isFinite))) // validate [from,to] form
|
|
495
506
|
pl.apiRequired = undefined;
|
package/src/roots.js
CHANGED
|
@@ -23,14 +23,6 @@ forceAddress.sub((v, { version }) => {
|
|
|
23
23
|
const rootsMiddleware = (ctx, next) => (() => {
|
|
24
24
|
var _a;
|
|
25
25
|
ctx.state.originalPath = ctx.path;
|
|
26
|
-
const root = (_a = exports.roots.compiled()) === null || _a === void 0 ? void 0 : _a(ctx.host);
|
|
27
|
-
if (!ctx.state.skipFilters && forceAddress.get())
|
|
28
|
-
if (root === undefined && !(0, misc_1.isLocalHost)(ctx) && ctx.host !== listen_1.baseUrl.compiled()) {
|
|
29
|
-
(0, connections_1.disconnect)(ctx, forceAddress.key());
|
|
30
|
-
return true; // true will avoid calling next
|
|
31
|
-
}
|
|
32
|
-
if (!root || root === '/')
|
|
33
|
-
return; // not transformation is required
|
|
34
26
|
let params; // undefined if we are not going to work on api parameters
|
|
35
27
|
if (ctx.path.startsWith(misc_1.SPECIAL_URI)) { // special uris should be excluded...
|
|
36
28
|
if (!ctx.path.startsWith(misc_1.API_URI))
|
|
@@ -44,6 +36,14 @@ const rootsMiddleware = (ctx, next) => (() => {
|
|
|
44
36
|
}
|
|
45
37
|
if (lodash_1.default.isEmpty(exports.roots.get()))
|
|
46
38
|
return;
|
|
39
|
+
const root = (_a = exports.roots.compiled()) === null || _a === void 0 ? void 0 : _a(ctx.host);
|
|
40
|
+
if (!ctx.state.skipFilters && forceAddress.get())
|
|
41
|
+
if (root === undefined && !(0, misc_1.isLocalHost)(ctx) && ctx.host !== listen_1.baseUrl.compiled()) {
|
|
42
|
+
(0, connections_1.disconnect)(ctx, forceAddress.key());
|
|
43
|
+
return true; // true will avoid calling next
|
|
44
|
+
}
|
|
45
|
+
if (!root || root === '/')
|
|
46
|
+
return; // not transformation is required
|
|
47
47
|
if (root === '' || root === '/')
|
|
48
48
|
return;
|
|
49
49
|
changeUriParams(v => (0, misc_1.join)(root, v));
|
package/src/serveGuiFiles.js
CHANGED
|
@@ -128,6 +128,7 @@ async function treatIndex(ctx, filesUri, body) {
|
|
|
128
128
|
loadScripts: Object.fromEntries((0, plugins_1.mapPlugins)((p, id) => { var _a; return [id, (_a = p.frontend_js) === null || _a === void 0 ? void 0 : _a.map(f => f.includes('//') ? f : pub + id + '/' + f)]; })),
|
|
129
129
|
prefixUrl: ctx.state.revProxyPath,
|
|
130
130
|
dontOverwriteUploading: upload_1.dontOverwriteUploading.get(),
|
|
131
|
+
forceTheme: (0, plugins_1.mapPlugins)(p => lodash_1.default.isString(p.isTheme) ? p.isTheme : undefined).find(Boolean),
|
|
131
132
|
customHtml: lodash_1.default.omit(Object.fromEntries(customHtml_1.customHtmlState.sections), ['top', 'bottom']),
|
|
132
133
|
...(0, misc_1.newObj)(misc_1.FRONTEND_OPTIONS, (v, k) => (0, config_1.getConfig)(k)),
|
|
133
134
|
lang
|
package/src/upload.js
CHANGED
|
@@ -16,6 +16,8 @@ const connections_1 = require("./connections");
|
|
|
16
16
|
const throttler_1 = require("./throttler");
|
|
17
17
|
const auth_1 = require("./auth");
|
|
18
18
|
const comments_1 = require("./comments");
|
|
19
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
20
|
+
const events_1 = __importDefault(require("./events"));
|
|
19
21
|
exports.deleteUnfinishedUploadsAfter = (0, config_1.defineConfig)('delete_unfinished_uploads_after', 86400);
|
|
20
22
|
exports.minAvailableMb = (0, config_1.defineConfig)('min_available_mb', 100);
|
|
21
23
|
exports.dontOverwriteUploading = (0, config_1.defineConfig)('dont_overwrite_uploading', true);
|
|
@@ -89,43 +91,45 @@ function uploadWriter(base, path, ctx) {
|
|
|
89
91
|
const resuming = resume && resumable;
|
|
90
92
|
if (!resuming)
|
|
91
93
|
resume = 0;
|
|
92
|
-
const
|
|
94
|
+
const writeStream = resuming ? fs_1.default.createWriteStream(resumable, { flags: 'r+', start: resume })
|
|
93
95
|
: fs_1.default.createWriteStream(tempName);
|
|
94
96
|
if (resuming) {
|
|
95
97
|
fs_1.default.rm(tempName, () => { });
|
|
96
98
|
tempName = resumable;
|
|
97
99
|
}
|
|
98
100
|
cancelDeletion(tempName);
|
|
101
|
+
ctx.state.uploadDestinationPath = tempName;
|
|
99
102
|
trackProgress();
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
let i = 1;
|
|
107
|
-
do
|
|
108
|
-
dest = `${base} (${i++})${ext}`;
|
|
109
|
-
while (fs_1.default.existsSync(dest));
|
|
110
|
-
}
|
|
111
|
-
return fs_1.default.rename(tempName, dest, err => {
|
|
112
|
-
setUploadMeta(err ? tempName : dest, ctx);
|
|
113
|
-
if (err)
|
|
114
|
-
console.error("couldn't rename temp to", dest, String(err));
|
|
115
|
-
else if (ctx.query.comment)
|
|
116
|
-
(0, comments_1.setCommentFor)(dest, (0, misc_1.escapeHTML)(String(ctx.query.comment)));
|
|
117
|
-
if (resumable)
|
|
118
|
-
delayedDelete(resumable, 0);
|
|
119
|
-
});
|
|
103
|
+
writeStream.once('close', async () => {
|
|
104
|
+
if (ctx.req.aborted) {
|
|
105
|
+
if (resumable) // we don't want to be left with 2 temp files
|
|
106
|
+
return delayedDelete(tempName, 0);
|
|
107
|
+
const sec = exports.deleteUnfinishedUploadsAfter.get();
|
|
108
|
+
return lodash_1.default.isNumber(sec) && delayedDelete(tempName, sec);
|
|
120
109
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
110
|
+
let dest = fullPath;
|
|
111
|
+
if (exports.dontOverwriteUploading.get() && fs_1.default.existsSync(dest) && !await overwriteAnyway()) {
|
|
112
|
+
const ext = (0, path_1.extname)(dest);
|
|
113
|
+
const base = dest.slice(0, -ext.length);
|
|
114
|
+
let i = 1;
|
|
115
|
+
do
|
|
116
|
+
dest = `${base} (${i++})${ext}`;
|
|
117
|
+
while (fs_1.default.existsSync(dest));
|
|
118
|
+
}
|
|
119
|
+
ctx.state.uploadDestinationPath = dest;
|
|
120
|
+
return fs_1.default.rename(tempName, dest, err => {
|
|
121
|
+
setUploadMeta(err ? tempName : dest, ctx);
|
|
122
|
+
if (err)
|
|
123
|
+
console.error("couldn't rename temp to", dest, String(err));
|
|
124
|
+
else if (ctx.query.comment)
|
|
125
|
+
(0, comments_1.setCommentFor)(dest, (0, misc_1.escapeHTML)(String(ctx.query.comment)));
|
|
126
|
+
if (resumable)
|
|
127
|
+
delayedDelete(resumable, 0);
|
|
128
|
+
});
|
|
127
129
|
});
|
|
128
|
-
|
|
130
|
+
const obj = { ctx, writeStream };
|
|
131
|
+
events_1.default.emit('uploadStart', obj);
|
|
132
|
+
return obj.writeStream;
|
|
129
133
|
async function overwriteAnyway() {
|
|
130
134
|
if (ctx.query.overwrite === undefined // legacy pre-0.52
|
|
131
135
|
&& ctx.query.existing !== 'overwrite')
|
|
@@ -143,13 +147,13 @@ function uploadWriter(base, path, ctx) {
|
|
|
143
147
|
return;
|
|
144
148
|
const h = setInterval(() => {
|
|
145
149
|
const now = Date.now();
|
|
146
|
-
const got =
|
|
150
|
+
const got = writeStream.bytesWritten;
|
|
147
151
|
const inSpeed = (0, throttler_1.roundSpeed)((got - lastGot) / (now - lastGotTime));
|
|
148
152
|
lastGot = got;
|
|
149
153
|
lastGotTime = now;
|
|
150
154
|
(0, connections_1.updateConnection)(conn, { inSpeed, got }, { opProgress: (resume + got) / opTotal });
|
|
151
155
|
}, 1000);
|
|
152
|
-
|
|
156
|
+
writeStream.once('close', () => clearInterval(h));
|
|
153
157
|
}
|
|
154
158
|
function delayedDelete(path, secs, cb) {
|
|
155
159
|
clearTimeout(waitingToBeDeleted[path]);
|