@lvce-editor/server 0.55.7 → 0.56.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/ThirdPartyNotices.txt +2 -2
- package/package.json +3 -3
- package/src/server.js +10 -6
package/ThirdPartyNotices.txt
CHANGED
|
@@ -2,7 +2,7 @@ This project incorporates components from the projects listed below, that may ha
|
|
|
2
2
|
differing from this project:
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
1) License Notice for static/
|
|
5
|
+
1) License Notice for static/e42ba7d/icons (from https://github.com/microsoft/vscode-icons)
|
|
6
6
|
---------------------------------------
|
|
7
7
|
|
|
8
8
|
Attribution 4.0 International
|
|
@@ -402,7 +402,7 @@ public licenses.
|
|
|
402
402
|
Creative Commons may be contacted at creativecommons.org.
|
|
403
403
|
|
|
404
404
|
|
|
405
|
-
2) License Notice for static/
|
|
405
|
+
2) License Notice for static/e42ba7d/fonts/FiraCode-VariableFont.ttf (from https://github.com/tonsky/FiraCode)
|
|
406
406
|
---------------------------------------
|
|
407
407
|
|
|
408
408
|
Copyright (c) 2014, The Fira Code Project Authors (https://github.com/tonsky/FiraCode)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "Run LVCE Editor as a server.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": "bin/server.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"node": ">=18"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@lvce-editor/shared-process": "0.
|
|
24
|
-
"@lvce-editor/static-server": "0.
|
|
23
|
+
"@lvce-editor/shared-process": "0.56.0",
|
|
24
|
+
"@lvce-editor/static-server": "0.56.0"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/src/server.js
CHANGED
|
@@ -46,7 +46,7 @@ const isStatic = (url) => {
|
|
|
46
46
|
if(url === '/'){
|
|
47
47
|
return true
|
|
48
48
|
}
|
|
49
|
-
if (url.startsWith('/
|
|
49
|
+
if (url.startsWith('/e42ba7d')) {
|
|
50
50
|
return true
|
|
51
51
|
}
|
|
52
52
|
if (url.startsWith('/favicon.ico')) {
|
|
@@ -60,7 +60,7 @@ const isStatic = (url) => {
|
|
|
60
60
|
|
|
61
61
|
const handleRequest = (req, res) => {
|
|
62
62
|
if (isStatic(req.url)) {
|
|
63
|
-
return
|
|
63
|
+
return handleResponseViaStaticServer(req, res, 'StaticServer.getResponse')
|
|
64
64
|
}
|
|
65
65
|
return sendHandleSharedProcess(req, res.socket, 'HandleRequest.handleRequest')
|
|
66
66
|
}
|
|
@@ -288,7 +288,7 @@ const handleMessage = (message) => {
|
|
|
288
288
|
|
|
289
289
|
const hasErrorListener = new WeakSet()
|
|
290
290
|
|
|
291
|
-
const
|
|
291
|
+
const handleResponseViaStaticServer = async (request, res, method, ...params) => {
|
|
292
292
|
request.on('error', handleRequestError)
|
|
293
293
|
if (!hasErrorListener.has(res.socket)) {
|
|
294
294
|
res.socket.on('error', handleSocketError)
|
|
@@ -296,6 +296,7 @@ const sendHandleStaticServerProcess = async (request, res, method, ...params) =>
|
|
|
296
296
|
}
|
|
297
297
|
const staticServerProcess = await getOrCreateStaticServerPathProcess()
|
|
298
298
|
const { id, promise } = registerCallback()
|
|
299
|
+
// TODO use rpc and invoke
|
|
299
300
|
staticServerProcess.send({
|
|
300
301
|
jsonrpc: '2.0',
|
|
301
302
|
id,
|
|
@@ -304,14 +305,17 @@ const sendHandleStaticServerProcess = async (request, res, method, ...params) =>
|
|
|
304
305
|
})
|
|
305
306
|
const response = await promise
|
|
306
307
|
const { result } = response
|
|
307
|
-
const { status, headers, body } = result
|
|
308
|
+
const { status, headers, body, hasBody } = result
|
|
308
309
|
if (!status) {
|
|
309
310
|
throw new Error('invalid status')
|
|
310
311
|
}
|
|
311
312
|
res.statusCode = status
|
|
312
313
|
setHeaders(res, headers)
|
|
313
|
-
|
|
314
|
-
|
|
314
|
+
if (hasBody) {
|
|
315
|
+
res.end(body)
|
|
316
|
+
} else {
|
|
317
|
+
res.end()
|
|
318
|
+
}
|
|
315
319
|
}
|
|
316
320
|
|
|
317
321
|
/**
|