hfs 0.26.4 → 0.26.5
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/README.md +1 -1
- package/admin/assets/{index.18284abb.js → index.3129dad1.js} +38 -38
- package/admin/assets/{sha512.ae60b35d.js → sha512.e9b1ee42.js} +1 -1
- package/admin/index.html +1 -1
- package/frontend/assets/{index.bbe713bb.js → index.1151988f.js} +17 -17
- package/frontend/assets/{sha512.666674ae.js → sha512.bb881250.js} +1 -1
- package/frontend/index.html +1 -1
- package/package.json +1 -2
- package/src/util-files.js +11 -9
- package/src/vfs.js +38 -28
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as SF}from"./index.
|
|
1
|
+
import{c as SF}from"./index.1151988f.js";function OF(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 yF={exports:{}};/*
|
|
2
2
|
* [js-sha512]{@link https://github.com/emn178/js-sha512}
|
|
3
3
|
*
|
|
4
4
|
* @version 0.8.0
|
package/frontend/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<link href="fontello.css" rel="stylesheet" />
|
|
7
7
|
<script>SESSION = _HFS_SESSION_</script>
|
|
8
8
|
<title>File Server</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index.
|
|
9
|
+
<script type="module" crossorigin src="/assets/index.1151988f.js"></script>
|
|
10
10
|
<link rel="stylesheet" href="/assets/index.93366732.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hfs",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.5",
|
|
4
4
|
"description": "HTTP File Server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file server",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"dist-bin": "npm run dist-modules && cd dist && pkg . -C gzip && mv -f hfs-win-x64.exe hfs.exe && zip hfs-windows.zip hfs.exe -r plugins && cp -f hfs-linux-x64 hfs && zip hfs-linux.zip hfs -r plugins && cp -f hfs-macos-x64 hfs && zip hfs-mac.zip hfs -r plugins && cp -f hfs-macos-arm64 hfs && zip hfs-mac-arm.zip hfs -r plugins && rm hfs",
|
|
31
31
|
"dist-modules": "cp package*.json dist && cd dist && npm ci --omit=dev && npm i -f --no-save --omit=dev @node-rs/crc32-win32-x64-msvc && rm package-lock.json && cd .. && node prune_modules",
|
|
32
32
|
"dist-win": "npm run dist-modules && cd dist && pkg . -C gzip -t node16-win-x64 && zip hfs-windows.zip hfs.exe -r plugins",
|
|
33
|
-
"dist-mac": "cd dist && pkg . -C gzip -t node16-mac-arm64",
|
|
34
33
|
"dist-node": "npm run dist-modules && cd dist && zip hfs-node.zip -r * -x *.zip *.exe hfs-* *.log logs"
|
|
35
34
|
},
|
|
36
35
|
"engines": {
|
package/src/util-files.js
CHANGED
|
@@ -91,23 +91,25 @@ function adjustStaticPathForGlob(path) {
|
|
|
91
91
|
return fast_glob_1.default.escapePath(path.replace(/\\/g, '/'));
|
|
92
92
|
}
|
|
93
93
|
exports.adjustStaticPathForGlob = adjustStaticPathForGlob;
|
|
94
|
-
async function* dirStream(path) {
|
|
95
|
-
|
|
96
|
-
if (!stats.isDirectory())
|
|
94
|
+
async function* dirStream(path, deep) {
|
|
95
|
+
if (!await isDirectory(path))
|
|
97
96
|
throw Error('ENOTDIR');
|
|
98
|
-
const dirStream = fast_glob_1.default.stream('*', {
|
|
97
|
+
const dirStream = fast_glob_1.default.stream(deep ? '**/*' : '*', {
|
|
99
98
|
cwd: path,
|
|
100
99
|
dot: true,
|
|
100
|
+
deep,
|
|
101
101
|
onlyFiles: false,
|
|
102
102
|
suppressErrors: true,
|
|
103
|
+
objectMode: true,
|
|
103
104
|
});
|
|
104
105
|
const skip = await getItemsToSkip(path);
|
|
105
|
-
for await (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (skip === null || skip === void 0 ? void 0 : skip.includes(path))
|
|
106
|
+
for await (const entry of dirStream) {
|
|
107
|
+
let { path, dirent } = entry;
|
|
108
|
+
if (!dirent.isDirectory() && !dirent.isFile())
|
|
109
109
|
continue;
|
|
110
|
-
|
|
110
|
+
path = String(path);
|
|
111
|
+
if (!(skip === null || skip === void 0 ? void 0 : skip.includes(path)))
|
|
112
|
+
yield path;
|
|
111
113
|
}
|
|
112
114
|
async function getItemsToSkip(path) {
|
|
113
115
|
if (!const_1.IS_WINDOWS)
|
package/src/vfs.js
CHANGED
|
@@ -114,7 +114,19 @@ function hasPermission(node, perm, ctx) {
|
|
|
114
114
|
&& (perm !== 'can_see' || hasPermission(node, 'can_read', ctx)); // for can_see you must also can_read
|
|
115
115
|
}
|
|
116
116
|
exports.hasPermission = hasPermission;
|
|
117
|
+
/* redev: 1322k716 8.6s
|
|
118
|
+
-temp 6.43s
|
|
119
|
+
*/
|
|
120
|
+
setTimeout(async () => {
|
|
121
|
+
let n = 0;
|
|
122
|
+
console.time('asd');
|
|
123
|
+
for await (const x of walkNode({ source: '/Users/rejetto/redev' }, undefined, Infinity))
|
|
124
|
+
++n;
|
|
125
|
+
console.timeEnd('asd');
|
|
126
|
+
console.log({ n });
|
|
127
|
+
}, 3000);
|
|
117
128
|
async function* walkNode(parent, ctx, depth = 0, prefixPath = '') {
|
|
129
|
+
var _a;
|
|
118
130
|
const { children, source } = parent;
|
|
119
131
|
if (children)
|
|
120
132
|
for (let idx = 0; idx < children.length; idx++) {
|
|
@@ -122,60 +134,58 @@ async function* walkNode(parent, ctx, depth = 0, prefixPath = '') {
|
|
|
122
134
|
yield* workItem({
|
|
123
135
|
...child,
|
|
124
136
|
name: prefixPath ? (prefixPath + getNodeName(child)) : child.name
|
|
125
|
-
});
|
|
137
|
+
}, depth > 0 && await nodeIsDirectory(child).catch(() => false));
|
|
126
138
|
}
|
|
127
139
|
if (!source)
|
|
128
140
|
return;
|
|
129
141
|
try {
|
|
130
|
-
for await (const path of (0, misc_1.dirStream)(source)) {
|
|
131
|
-
if (ctx.req.aborted)
|
|
142
|
+
for await (const path of (0, misc_1.dirStream)(source, depth)) {
|
|
143
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.req.aborted)
|
|
132
144
|
return;
|
|
133
|
-
|
|
134
|
-
const renamed = rename === null || rename === void 0 ? void 0 : rename[path];
|
|
145
|
+
const renamed = (_a = parent.rename) === null || _a === void 0 ? void 0 : _a[path];
|
|
135
146
|
yield* workItem({
|
|
136
|
-
name:
|
|
147
|
+
name: prefixPath + (renamed || path),
|
|
137
148
|
source: (0, path_1.join)(source, path),
|
|
138
|
-
rename: renameUnderPath(rename, path),
|
|
149
|
+
rename: renameUnderPath(parent.rename, path),
|
|
139
150
|
});
|
|
140
151
|
}
|
|
141
152
|
}
|
|
142
153
|
catch (e) {
|
|
143
154
|
console.debug('glob', source, e); // ENOTDIR, or lacking permissions
|
|
144
155
|
}
|
|
145
|
-
|
|
156
|
+
// item will be changed, so be sure to pass a temp node
|
|
157
|
+
async function* workItem(item, recur = false) {
|
|
158
|
+
const name = getNodeName(item);
|
|
146
159
|
// we basename for depth>0 where we already have the rest of the path in the parent's url, and would be duplicated
|
|
147
|
-
const
|
|
148
|
-
const url = (0, misc_1.enforceFinal)('/', parent.url || '') +
|
|
149
|
-
|
|
150
|
-
...item,
|
|
160
|
+
const virtualBasename = (0, path_1.basename)(name);
|
|
161
|
+
const url = (0, misc_1.enforceFinal)('/', parent.url || '') + virtualBasename;
|
|
162
|
+
Object.assign(item, {
|
|
151
163
|
isTemp: true,
|
|
152
164
|
url,
|
|
153
165
|
parents: [...parent.parents || [], parent],
|
|
154
166
|
});
|
|
155
|
-
|
|
156
|
-
|
|
167
|
+
inheritFromParent(parent, item);
|
|
168
|
+
applyMasks(item, parent, virtualBasename);
|
|
169
|
+
if (ctx && !hasPermission(item, 'can_see', ctx))
|
|
157
170
|
return;
|
|
158
|
-
yield
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
yield* walkNode(temp, ctx, depth - 1, getNodeName(temp) + '/');
|
|
164
|
-
}
|
|
165
|
-
catch (_a) { } // stat failed in nodeIsDirectory, ignore
|
|
171
|
+
yield item;
|
|
172
|
+
if (!recur)
|
|
173
|
+
return;
|
|
174
|
+
inheritMasks(item, parent, virtualBasename);
|
|
175
|
+
yield* walkNode(item, ctx, depth - 1, name + '/');
|
|
166
176
|
}
|
|
167
177
|
}
|
|
168
178
|
exports.walkNode = walkNode;
|
|
169
|
-
function applyMasks(item, parent,
|
|
179
|
+
function applyMasks(item, parent, virtualBasename) {
|
|
170
180
|
const { masks } = parent;
|
|
171
181
|
if (!masks)
|
|
172
182
|
return;
|
|
173
183
|
for (const k in masks)
|
|
174
|
-
if (k.startsWith('**/') && (0, micromatch_1.isMatch)(
|
|
175
|
-
|| !k.includes('/') && (0, micromatch_1.isMatch)(
|
|
184
|
+
if (k.startsWith('**/') && (0, micromatch_1.isMatch)(virtualBasename, k.slice(3))
|
|
185
|
+
|| !k.includes('/') && (0, micromatch_1.isMatch)(virtualBasename, k))
|
|
176
186
|
Object.assign(item, masks[k]);
|
|
177
187
|
}
|
|
178
|
-
function inheritMasks(item, parent,
|
|
188
|
+
function inheritMasks(item, parent, virtualBasename) {
|
|
179
189
|
const { masks } = parent;
|
|
180
190
|
if (!masks)
|
|
181
191
|
return;
|
|
@@ -183,8 +193,8 @@ function inheritMasks(item, parent, name) {
|
|
|
183
193
|
for (const k in masks)
|
|
184
194
|
if (k.startsWith('**/'))
|
|
185
195
|
o[k.slice(3)] = masks[k];
|
|
186
|
-
else if (k.startsWith(
|
|
187
|
-
o[k.slice(
|
|
196
|
+
else if (k.startsWith(virtualBasename + '/'))
|
|
197
|
+
o[k.slice(virtualBasename.length + 1)] = masks[k];
|
|
188
198
|
if (Object.keys(o).length)
|
|
189
199
|
item.masks = o;
|
|
190
200
|
}
|