redraft-local 0.7.1 → 0.8.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/README.md +2 -1
- package/dist/CNAME +1 -0
- package/dist-server/cli.mjs +36 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/redraft-local)
|
|
6
6
|
[](https://www.npmjs.com/package/redraft-local)
|
|
7
7
|
[](https://github.com/tcamise-gpsw/redraft/actions/workflows/ci.yml)
|
|
8
|
+
[](https://redraft-docs.dev)
|
|
8
9
|
|
|
9
10
|
ReDraft is a review workspace for markdown documents. It lets teams browse repository docs, discuss them with inline comment threads, and edit them in either a rich-text editor or raw markdown — backed by GitHub in remote mode or the local filesystem in local mode.
|
|
10
11
|
|
|
@@ -33,7 +34,7 @@ Use **View** and **WYSIWYG** modes when you want to read, comment, and make ligh
|
|
|
33
34
|
|
|
34
35
|
Typical workflow:
|
|
35
36
|
|
|
36
|
-
1. Open
|
|
37
|
+
1. Open [redraft-docs.dev](https://redraft-docs.dev).
|
|
37
38
|
2. Enter a fine-grained GitHub PAT and `owner/repo`.
|
|
38
39
|
3. Choose a document from the tree.
|
|
39
40
|
4. Read in **View** mode or switch to **WYSIWYG**.
|
package/dist/CNAME
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
redraft-docs.dev
|
package/dist-server/cli.mjs
CHANGED
|
@@ -916,19 +916,23 @@ async function sendResponse(response, nodeResponse) {
|
|
|
916
916
|
}
|
|
917
917
|
async function startReDraftServer(options) {
|
|
918
918
|
const host = options.host ?? "127.0.0.1";
|
|
919
|
-
const
|
|
919
|
+
const requestedPort = options.port ?? 4200;
|
|
920
920
|
const app = buildReDraftApp(options);
|
|
921
921
|
const hub = new WebSocketHub();
|
|
922
|
+
let actualPort = requestedPort;
|
|
922
923
|
const server = createServer(async (request, response) => {
|
|
923
924
|
const honoResponse = await app.fetch(
|
|
924
|
-
toRequest(
|
|
925
|
+
toRequest(
|
|
926
|
+
request,
|
|
927
|
+
`http://${request.headers.host ?? `${host}:${actualPort}`}`
|
|
928
|
+
)
|
|
925
929
|
);
|
|
926
930
|
await sendResponse(honoResponse, response);
|
|
927
931
|
});
|
|
928
932
|
server.on("upgrade", (request, socket, head) => {
|
|
929
933
|
const url = new URL(
|
|
930
934
|
request.url ?? "/",
|
|
931
|
-
`http://${request.headers.host ?? `${host}:${
|
|
935
|
+
`http://${request.headers.host ?? `${host}:${actualPort}`}`
|
|
932
936
|
);
|
|
933
937
|
if (url.pathname !== "/ws") {
|
|
934
938
|
socket.destroy();
|
|
@@ -936,19 +940,39 @@ async function startReDraftServer(options) {
|
|
|
936
940
|
}
|
|
937
941
|
hub.handleUpgrade(request, socket, head);
|
|
938
942
|
});
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
943
|
+
const MAX_PORT_ATTEMPTS = 10;
|
|
944
|
+
for (let attempt = 0; attempt < MAX_PORT_ATTEMPTS; attempt++) {
|
|
945
|
+
const {
|
|
946
|
+
promise,
|
|
947
|
+
resolve: resolveListen,
|
|
948
|
+
reject: rejectListen
|
|
949
|
+
} = Promise.withResolvers();
|
|
950
|
+
server.listen(actualPort, host, () => resolveListen());
|
|
951
|
+
server.once("error", rejectListen);
|
|
952
|
+
try {
|
|
953
|
+
await promise;
|
|
954
|
+
break;
|
|
955
|
+
} catch (error) {
|
|
956
|
+
const nodeError = error;
|
|
957
|
+
if (nodeError.code !== "EADDRINUSE" || attempt === MAX_PORT_ATTEMPTS - 1) {
|
|
958
|
+
if (nodeError.code === "EADDRINUSE") {
|
|
959
|
+
throw new Error(
|
|
960
|
+
`Could not find a free port in range ${requestedPort}\u2013${actualPort}. Use --port to specify a different starting port.`
|
|
961
|
+
);
|
|
962
|
+
}
|
|
963
|
+
throw error;
|
|
964
|
+
}
|
|
965
|
+
console.log(
|
|
966
|
+
`Port ${actualPort} is in use, trying ${actualPort + 1} instead.`
|
|
967
|
+
);
|
|
968
|
+
actualPort++;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
947
971
|
return {
|
|
948
972
|
app,
|
|
949
973
|
hub,
|
|
950
974
|
server,
|
|
951
|
-
url: `http://${host}:${
|
|
975
|
+
url: `http://${host}:${actualPort}`,
|
|
952
976
|
close: async () => {
|
|
953
977
|
await hub.close();
|
|
954
978
|
const {
|