@lvce-editor/main-process 4.6.0 → 4.7.0
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/dist/mainProcessMain.js +21 -13
- package/package.json +1 -1
package/dist/mainProcessMain.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
import { inspect } from 'node:util';
|
|
6
6
|
import { spawn } from 'node:child_process';
|
|
7
7
|
import { Console } from 'node:console';
|
|
8
|
-
import { createWriteStream, readFileSync, existsSync } from 'node:fs';
|
|
8
|
+
import { createWriteStream, readFileSync, openAsBlob, existsSync } from 'node:fs';
|
|
9
9
|
import { tmpdir, homedir } from 'node:os';
|
|
10
10
|
import * as NodePath from 'node:path';
|
|
11
11
|
import { dirname, join as join$1 } from 'node:path';
|
|
@@ -4187,6 +4187,23 @@ const getElectronFileResponseIpc = async (url, request) => {
|
|
|
4187
4187
|
return response;
|
|
4188
4188
|
};
|
|
4189
4189
|
|
|
4190
|
+
/* eslint-disable n/no-unsupported-features/node-builtins */
|
|
4191
|
+
const getFileResponse = async (absolutePath, headers) => {
|
|
4192
|
+
// TODO support request method head
|
|
4193
|
+
const blob = await openAsBlob(absolutePath);
|
|
4194
|
+
const response = new Response(blob, {
|
|
4195
|
+
headers,
|
|
4196
|
+
status: 200
|
|
4197
|
+
});
|
|
4198
|
+
return response;
|
|
4199
|
+
};
|
|
4200
|
+
|
|
4201
|
+
const getNotFoundResponse = () => {
|
|
4202
|
+
return new Response('Not Found', {
|
|
4203
|
+
status: 404
|
|
4204
|
+
});
|
|
4205
|
+
};
|
|
4206
|
+
|
|
4190
4207
|
let config;
|
|
4191
4208
|
const createConfig = () => {
|
|
4192
4209
|
const configPath = join$1(root, 'config.json');
|
|
@@ -4218,23 +4235,14 @@ const getElectronFileResponseConfig = async (url, request) => {
|
|
|
4218
4235
|
const actual = relative === '/' ? '/index.html' : relative;
|
|
4219
4236
|
const match = files[actual];
|
|
4220
4237
|
if (match === undefined) {
|
|
4221
|
-
return
|
|
4222
|
-
status: 404
|
|
4223
|
-
});
|
|
4238
|
+
return getNotFoundResponse();
|
|
4224
4239
|
}
|
|
4225
4240
|
const responseHeaders = headers[match];
|
|
4226
4241
|
const absolutePath = join$1(root, 'static', actual);
|
|
4227
4242
|
if (!existsSync(absolutePath)) {
|
|
4228
|
-
return
|
|
4229
|
-
status: 404
|
|
4230
|
-
});
|
|
4243
|
+
return getNotFoundResponse();
|
|
4231
4244
|
}
|
|
4232
|
-
|
|
4233
|
-
const response = new Response(content, {
|
|
4234
|
-
headers: responseHeaders,
|
|
4235
|
-
status: 200
|
|
4236
|
-
});
|
|
4237
|
-
return response;
|
|
4245
|
+
return getFileResponse(absolutePath, responseHeaders);
|
|
4238
4246
|
};
|
|
4239
4247
|
|
|
4240
4248
|
const getElectronFileResponse = async (url, request) => {
|