miqro 6.1.2 → 6.1.4
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/build/editor.bundle.js +16 -0
- package/build/esm/editor/auth.d.ts +6 -0
- package/build/esm/editor/auth.js +41 -0
- package/build/esm/editor/common/admin-interface.d.ts +36 -0
- package/build/esm/editor/common/admin-interface.js +44 -0
- package/build/esm/editor/common/constants.d.ts +4 -0
- package/build/esm/editor/common/constants.js +20 -0
- package/build/esm/editor/common/constants.server.d.ts +2 -0
- package/build/esm/editor/common/constants.server.js +4 -0
- package/build/esm/editor/common/editor-index.d.ts +2 -0
- package/build/esm/editor/common/editor-index.js +14 -0
- package/build/esm/editor/common/html-encode.d.ts +1 -0
- package/build/esm/editor/common/html-encode.js +14 -0
- package/build/esm/editor/common/log-socket.d.ts +15 -0
- package/build/esm/editor/common/log-socket.js +70 -0
- package/build/esm/editor/common/templates.d.ts +11 -0
- package/build/esm/editor/common/templates.js +477 -0
- package/build/esm/editor/components/api-preview.d.ts +11 -0
- package/build/esm/editor/components/api-preview.js +90 -0
- package/build/esm/editor/components/editor.d.ts +16 -0
- package/build/esm/editor/components/editor.js +357 -0
- package/build/esm/editor/components/file-browser.d.ts +37 -0
- package/build/esm/editor/components/file-browser.js +126 -0
- package/build/esm/editor/components/file-editor-toolbar.d.ts +22 -0
- package/build/esm/editor/components/file-editor-toolbar.js +93 -0
- package/build/esm/editor/components/file-editor.d.ts +32 -0
- package/build/esm/editor/components/file-editor.js +59 -0
- package/build/esm/editor/components/filter-query.d.ts +1 -0
- package/build/esm/editor/components/filter-query.js +22 -0
- package/build/esm/editor/components/highlight-text-area.d.ts +11 -0
- package/build/esm/editor/components/highlight-text-area.js +124 -0
- package/build/esm/editor/components/log-viewer.d.ts +6 -0
- package/build/esm/editor/components/log-viewer.js +69 -0
- package/build/esm/editor/components/new-file.d.ts +10 -0
- package/build/esm/editor/components/new-file.js +117 -0
- package/build/esm/editor/components/scroll-query.d.ts +7 -0
- package/build/esm/editor/components/scroll-query.js +21 -0
- package/build/esm/editor/components/start-page.d.ts +13 -0
- package/build/esm/editor/components/start-page.js +30 -0
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +3 -0
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +29 -0
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +5 -0
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +49 -0
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +4 -0
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +39 -0
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +26 -0
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +149 -0
- package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +3 -0
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +38 -0
- package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +10 -0
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +46 -0
- package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +10 -0
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +45 -0
- package/build/esm/editor/http/admin/editor/editor.d.ts +1 -0
- package/build/esm/editor/http/admin/editor/editor.js +7 -0
- package/build/esm/editor/http/admin/editor/index.api.d.ts +3 -0
- package/build/esm/editor/http/admin/editor/index.api.js +21 -0
- package/build/esm/editor/server.d.ts +3 -0
- package/build/esm/editor/server.js +49 -0
- package/build/esm/editor/ws.d.ts +3 -0
- package/build/esm/editor/ws.js +11 -0
- package/build/esm/src/bin/types.js +8 -0
- package/build/esm/src/common/arguments.d.ts +7 -1
- package/build/esm/src/common/arguments.js +72 -10
- package/build/esm/src/common/help.d.ts +1 -1
- package/build/esm/src/common/help.js +33 -29
- package/build/esm/src/inflate/setup-ws.d.ts +1 -1
- package/build/esm/src/inflate/setup-ws.js +2 -2
- package/build/esm/src/main.js +3 -1
- package/build/esm/src/services/app.d.ts +2 -0
- package/build/esm/src/services/app.js +2 -2
- package/build/esm/src/services/utils/log-transport.d.ts +2 -2
- package/build/esm/src/services/utils/log-transport.js +8 -3
- package/build/esm/src/services/utils/server-interface.d.ts +1 -1
- package/build/esm/src/services/utils/server-interface.js +19 -14
- package/build/lib.cjs +23 -21
- package/editor/auth.ts +51 -0
- package/editor/common/admin-interface.ts +84 -0
- package/editor/common/constants.server.ts +5 -0
- package/editor/common/constants.ts +21 -0
- package/editor/common/editor-index.tsx +17 -0
- package/editor/common/html-encode.ts +14 -0
- package/editor/common/log-socket.tsx +85 -0
- package/editor/common/templates.ts +481 -0
- package/editor/components/api-preview.tsx +116 -0
- package/editor/components/editor.tsx +486 -0
- package/editor/components/file-browser.tsx +308 -0
- package/editor/components/file-editor-toolbar.tsx +191 -0
- package/editor/components/file-editor.tsx +122 -0
- package/editor/components/filter-query.tsx +22 -0
- package/editor/components/highlight-text-area.tsx +144 -0
- package/editor/components/log-viewer.tsx +110 -0
- package/editor/components/new-file.tsx +169 -0
- package/editor/components/scroll-query.tsx +22 -0
- package/editor/components/start-page.tsx +49 -0
- package/editor/http/admin/editor/api/fs/delete.api.tsx +32 -0
- package/editor/http/admin/editor/api/fs/read.api.tsx +55 -0
- package/editor/http/admin/editor/api/fs/rename.api.tsx +41 -0
- package/editor/http/admin/editor/api/fs/scan.api.tsx +181 -0
- package/editor/http/admin/editor/api/fs/write.api.tsx +41 -0
- package/editor/http/admin/editor/api/server/reload.api.ts +53 -0
- package/editor/http/admin/editor/api/server/restart.api.tsx +52 -0
- package/editor/http/admin/editor/editor.tsx +8 -0
- package/editor/http/admin/editor/index.api.tsx +39 -0
- package/editor/server.ts +57 -0
- package/editor/ws.ts +15 -0
- package/package.json +1 -1
- package/sea/install-nodejs.sh +1 -1
- package/sea/node.version.tag +1 -1
- package/src/bin/compile.ts +35 -0
- package/src/bin/doc-md.ts +210 -0
- package/src/bin/generate-doc.ts +64 -0
- package/src/bin/test.ts +92 -0
- package/src/bin/types.ts +29 -0
- package/src/cluster.ts +27 -0
- package/src/common/arguments.ts +576 -0
- package/src/common/assets.ts +128 -0
- package/src/common/checksum.ts +58 -0
- package/src/common/constants.ts +18 -0
- package/src/common/content-type.ts +84 -0
- package/src/common/esbuild.ts +94 -0
- package/src/common/exit.ts +91 -0
- package/src/common/fs.ts +17 -0
- package/src/common/help.ts +55 -0
- package/src/common/jsx.ts +512 -0
- package/src/common/paths.ts +158 -0
- package/src/common/watch.ts +85 -0
- package/src/inflate/inflate-sea.ts +206 -0
- package/src/inflate/inflate.ts +99 -0
- package/src/inflate/md.ts +25 -0
- package/src/inflate/setup-auth.ts +40 -0
- package/src/inflate/setup-cors.ts +40 -0
- package/src/inflate/setup-db.ts +115 -0
- package/src/inflate/setup-error.ts +43 -0
- package/src/inflate/setup-http.ts +655 -0
- package/src/inflate/setup-log.ts +44 -0
- package/src/inflate/setup-middleware.ts +46 -0
- package/src/inflate/setup-server-config.ts +47 -0
- package/src/inflate/setup-test.ts +23 -0
- package/src/inflate/setup-ws.ts +49 -0
- package/src/inflate/setup.doc.ts +68 -0
- package/src/inflate/utils/sea-utils.ts +14 -0
- package/src/lib.ts +19 -0
- package/src/main.ts +89 -0
- package/src/services/app.ts +660 -0
- package/src/services/editor.tsx +101 -0
- package/src/services/globals.ts +143 -0
- package/src/services/hot-reload.ts +48 -0
- package/src/services/migrations.ts +66 -0
- package/src/services/utils/admin-interface.ts +37 -0
- package/src/services/utils/cache.ts +88 -0
- package/src/services/utils/cluster-cache.ts +230 -0
- package/src/services/utils/cluster-ws.ts +197 -0
- package/src/services/utils/db-manager.ts +92 -0
- package/src/services/utils/get-route.ts +70 -0
- package/src/services/utils/log-transport.ts +81 -0
- package/src/services/utils/log.ts +92 -0
- package/src/services/utils/server-interface.ts +179 -0
- package/src/services/utils/websocketmanager.ts +149 -0
- package/src/types/@esbuild.d.ts +1 -0
- package/src/types/@miqro/core.d.ts +2 -0
- package/src/types/@miqro/jsx.d.ts +2 -0
- package/src/types/@miqro/parser.d.ts +2 -0
- package/src/types/@miqro/query.d.ts +2 -0
- package/src/types/@miqro/request.d.ts +2 -0
- package/src/types/@miqro/test.d.ts +2 -0
- package/src/types/@miqro.d.ts +1 -0
- package/src/types/@types.d.ts +1 -0
- package/src/types/browser.globals.d.ts +9 -0
- package/src/types/globals.d.ts +2 -0
- package/src/types/jsx.globals.d.ts +37 -0
- package/src/types/miqro.d.ts +129 -0
- package/src/types/postject.d.ts +1 -0
- package/src/types/server.globals.d.ts +72 -0
- package/src/types.ts +222 -0
package/build/editor.bundle.js
CHANGED
|
@@ -9577,6 +9577,22 @@ export default {
|
|
|
9577
9577
|
]
|
|
9578
9578
|
}
|
|
9579
9579
|
}
|
|
9580
|
+
`
|
|
9581
|
+
},
|
|
9582
|
+
MIQROJSON: {
|
|
9583
|
+
prefix: "",
|
|
9584
|
+
sufix: ".json",
|
|
9585
|
+
filename: "miqro",
|
|
9586
|
+
displayName: "miqro.json file",
|
|
9587
|
+
language: "json",
|
|
9588
|
+
template: () => `{
|
|
9589
|
+
"services": ["src/"],
|
|
9590
|
+
"inflateDir": "build/",
|
|
9591
|
+
"name": "server",
|
|
9592
|
+
"browser": true,
|
|
9593
|
+
"logFile": false,
|
|
9594
|
+
"port": "3000"
|
|
9595
|
+
}
|
|
9580
9596
|
`
|
|
9581
9597
|
},
|
|
9582
9598
|
MINIFIEDJSX: {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AuthConfig } from "../src/types.js";
|
|
2
|
+
export declare const ADMIN_EDITOR_AUTH_KEY = "$$ADMIN_EDITOR_AUTH_KEY$$";
|
|
3
|
+
export declare const ADMIN_EDITOR_AUTH_QUERY = "key";
|
|
4
|
+
export declare const ADMIN_EDITOR_AUTH_COOKIE = "$$ADMIN_EDITOR_AUTH_KEY$$";
|
|
5
|
+
declare const _default: AuthConfig;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const ADMIN_EDITOR_AUTH_KEY = "$$ADMIN_EDITOR_AUTH_KEY$$";
|
|
2
|
+
export const ADMIN_EDITOR_AUTH_QUERY = "key";
|
|
3
|
+
export const ADMIN_EDITOR_AUTH_COOKIE = ADMIN_EDITOR_AUTH_KEY;
|
|
4
|
+
export default {
|
|
5
|
+
authService: {
|
|
6
|
+
verify: async (args) => {
|
|
7
|
+
const adminInterface = args.req.editor;
|
|
8
|
+
const serverInterface = args.req.server;
|
|
9
|
+
const KEY = (adminInterface ? adminInterface.getCache() : serverInterface.cache).get(ADMIN_EDITOR_AUTH_KEY);
|
|
10
|
+
const validSesson = {
|
|
11
|
+
username: "username",
|
|
12
|
+
account: "account",
|
|
13
|
+
groups: [],
|
|
14
|
+
token: args.token
|
|
15
|
+
};
|
|
16
|
+
const queryToken = args.req.query[ADMIN_EDITOR_AUTH_QUERY];
|
|
17
|
+
const cookieToken = args.req.cookies[ADMIN_EDITOR_AUTH_COOKIE];
|
|
18
|
+
//console.log("\n\nqueryToken[%s] cookieToken[%s] KEY[%s]\n\n", queryToken, cookieToken, KEY);
|
|
19
|
+
if (queryToken) {
|
|
20
|
+
if (queryToken === KEY) {
|
|
21
|
+
args.res.setCookie(ADMIN_EDITOR_AUTH_COOKIE, KEY, {
|
|
22
|
+
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 31 * 12 * 500),
|
|
23
|
+
httpOnly: true,
|
|
24
|
+
//secure: true,
|
|
25
|
+
path: "/",
|
|
26
|
+
//sameSite: "strict"
|
|
27
|
+
});
|
|
28
|
+
args.req.searchParams.delete(ADMIN_EDITOR_AUTH_QUERY);
|
|
29
|
+
const queryString = args.req.searchParams.toString();
|
|
30
|
+
const redirect = args.req.path + (queryString ? "?" + queryString : "");
|
|
31
|
+
await args.res.redirect(redirect);
|
|
32
|
+
return validSesson;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if (cookieToken) {
|
|
36
|
+
return cookieToken === KEY ? validSesson : null;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RouterHandlerOptions } from "@miqro/core";
|
|
2
|
+
import { CacheInterface, ServerRequest } from "../../src/types.js";
|
|
3
|
+
import { MigrationModule } from "../../src/inflate/setup-db.js";
|
|
4
|
+
export interface EditorAdminInterface {
|
|
5
|
+
getCache: () => CacheInterface;
|
|
6
|
+
getMigrations(): MigrationModule[];
|
|
7
|
+
stop: () => Promise<void>;
|
|
8
|
+
reload: () => Promise<null | {
|
|
9
|
+
filePath: string;
|
|
10
|
+
error: Error;
|
|
11
|
+
}[]>;
|
|
12
|
+
restart: () => Promise<null | {
|
|
13
|
+
filePath: string;
|
|
14
|
+
error: Error;
|
|
15
|
+
}[]>;
|
|
16
|
+
getHotReloadHTML(): string;
|
|
17
|
+
getInflateErrors(): null | {
|
|
18
|
+
filePath: string;
|
|
19
|
+
error: Error;
|
|
20
|
+
}[];
|
|
21
|
+
getServices(): string[];
|
|
22
|
+
getRouteFileMap(): {
|
|
23
|
+
[filePath: string]: {
|
|
24
|
+
routes: {
|
|
25
|
+
path?: string;
|
|
26
|
+
method?: string | null;
|
|
27
|
+
options?: RouterHandlerOptions;
|
|
28
|
+
inflatePath?: string;
|
|
29
|
+
}[];
|
|
30
|
+
previewMethod: "api" | "html" | null;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface AdminRequest extends ServerRequest {
|
|
35
|
+
editor?: EditorAdminInterface;
|
|
36
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/*let currentAdminInterface: EditorAdminInterface | null = null;
|
|
3
|
+
function createFakeAdminInterface(server: any): EditorAdminInterface {
|
|
4
|
+
return {
|
|
5
|
+
getCache: () => {
|
|
6
|
+
return server.cache;
|
|
7
|
+
},
|
|
8
|
+
stop: async () => {
|
|
9
|
+
|
|
10
|
+
},
|
|
11
|
+
restart: async () => {
|
|
12
|
+
return null;
|
|
13
|
+
},
|
|
14
|
+
reload: async () => {
|
|
15
|
+
return null;
|
|
16
|
+
},
|
|
17
|
+
getHotReloadHTML: () => {
|
|
18
|
+
return "";
|
|
19
|
+
},
|
|
20
|
+
getMigrations: () => {
|
|
21
|
+
return [];
|
|
22
|
+
},
|
|
23
|
+
getServices: () => {
|
|
24
|
+
return ["."];
|
|
25
|
+
},
|
|
26
|
+
getRouteFileMap: () => {
|
|
27
|
+
return {};
|
|
28
|
+
},
|
|
29
|
+
getInflateErrors: () => {
|
|
30
|
+
return [];
|
|
31
|
+
},
|
|
32
|
+
inflateJSX: async function inflateJSX(path, minify: boolean = true) {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function getEditorAdmin(server): EditorAdminInterface {
|
|
39
|
+
return currentAdminInterface ? currentAdminInterface : createFakeAdminInterface(server);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function setEditorAdmin(admin: EditorAdminInterface): void {
|
|
43
|
+
currentAdminInterface = admin;
|
|
44
|
+
}*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const BASEEDITOR_PATH = "/admin/editor";
|
|
2
|
+
export const LOG_SOCKET_PATH = "/admin/socket";
|
|
3
|
+
export const LOG_WRITE_EVENT = "LogWrite";
|
|
4
|
+
export const SUPPORTED_LANGUAGES = [
|
|
5
|
+
"text",
|
|
6
|
+
"json",
|
|
7
|
+
"javascript",
|
|
8
|
+
"typescript",
|
|
9
|
+
"dockerfile",
|
|
10
|
+
"yaml",
|
|
11
|
+
"xml",
|
|
12
|
+
"html",
|
|
13
|
+
"css",
|
|
14
|
+
"scss",
|
|
15
|
+
"markdown",
|
|
16
|
+
"c",
|
|
17
|
+
"cpp",
|
|
18
|
+
"bash",
|
|
19
|
+
"python"
|
|
20
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { scanDir } from "../http/admin/editor/api/fs/scan.api.js";
|
|
2
|
+
import { parseInflateErrors } from "../http/admin/editor/api/server/restart.api.js";
|
|
3
|
+
import { HTMLEncode } from "./html-encode.js";
|
|
4
|
+
export function EditorIndex(editorCSS, editorJS, enableHotReload) {
|
|
5
|
+
return async function editorIndex(req, res) {
|
|
6
|
+
const admin = req.editor;
|
|
7
|
+
const errors = parseInflateErrors(admin ? admin.getInflateErrors() : []);
|
|
8
|
+
const files = scanDir(req);
|
|
9
|
+
const migrations = admin ? admin.getMigrations().map(m => m.name) : [];
|
|
10
|
+
const services = admin ? admin.getServices() : ["."];
|
|
11
|
+
const hotReload = enableHotReload ? (admin ? admin.getHotReloadHTML() : "") : "";
|
|
12
|
+
res.html(`<!DOCTYPE html><html><body><style>${editorCSS}</style><script type="module">${editorJS}</script><editor-component class="main-container" reloadstring="${req.uuid}" migrations="${HTMLEncode(JSON.stringify(migrations))}" services="${HTMLEncode(JSON.stringify(services))}" errors="${HTMLEncode(JSON.stringify(errors))}" files="${HTMLEncode(JSON.stringify(files))}"><noscript>Enable JavaScript</noscript></editor-component>${hotReload}</body></html>`);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function HTMLEncode(str: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function HTMLEncode(str) {
|
|
2
|
+
let i = str.length;
|
|
3
|
+
const aRet = [];
|
|
4
|
+
while (i--) {
|
|
5
|
+
const iC = str[i].charCodeAt(0);
|
|
6
|
+
if (iC < 65 || iC > 127 || (iC > 90 && iC < 97)) {
|
|
7
|
+
aRet[i] = '&#' + iC + ';';
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
aRet[i] = str[i];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return aRet.join('');
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface LogLine {
|
|
2
|
+
out: string;
|
|
3
|
+
identifier: string;
|
|
4
|
+
level: "error" | "warn" | "debug" | "trace" | "info";
|
|
5
|
+
}
|
|
6
|
+
export interface LogSocket {
|
|
7
|
+
lines: LogLine[];
|
|
8
|
+
clearLog: () => void;
|
|
9
|
+
getMaxlogsize: () => number | "unlimited";
|
|
10
|
+
setMaxLogSize: (val: number | "unlimited") => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function useLogSocket(options: {
|
|
13
|
+
disableLog?: boolean;
|
|
14
|
+
}): LogSocket;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export function useLogSocket(options) {
|
|
2
|
+
const [_, setmaxLogSize, getMaxlogsize] = jsx.useState(1000000);
|
|
3
|
+
const [__, setlines, getLines] = jsx.useState([]);
|
|
4
|
+
const refresh = jsx.useRefresh();
|
|
5
|
+
jsx.useEffect(() => {
|
|
6
|
+
let timeout;
|
|
7
|
+
function setupSocket() {
|
|
8
|
+
try {
|
|
9
|
+
if (options.disableLog) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
console.log("setting up log socket");
|
|
13
|
+
const socket = new WebSocket("/admin/socket");
|
|
14
|
+
socket.addEventListener("error", (err) => {
|
|
15
|
+
console.error(err);
|
|
16
|
+
clearTimeout(timeout);
|
|
17
|
+
timeout = setTimeout(() => {
|
|
18
|
+
setupSocket();
|
|
19
|
+
}, 1000);
|
|
20
|
+
});
|
|
21
|
+
socket.addEventListener("open", () => {
|
|
22
|
+
console.log("log socket open");
|
|
23
|
+
clearTimeout(timeout);
|
|
24
|
+
socket.addEventListener("message", (msg) => {
|
|
25
|
+
const lines = getLines();
|
|
26
|
+
const data = JSON.parse(msg.data);
|
|
27
|
+
//console.log(data.out);
|
|
28
|
+
const maxLogSize = getMaxlogsize();
|
|
29
|
+
if (maxLogSize !== "unlimited" && lines.length >= maxLogSize) {
|
|
30
|
+
lines.splice(0, (lines.length - maxLogSize) + 1);
|
|
31
|
+
}
|
|
32
|
+
lines.push(data);
|
|
33
|
+
setlines(lines);
|
|
34
|
+
refresh();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
socket.addEventListener("close", () => {
|
|
38
|
+
console.log("log socket close");
|
|
39
|
+
clearTimeout(timeout);
|
|
40
|
+
timeout = setTimeout(() => {
|
|
41
|
+
setupSocket();
|
|
42
|
+
}, 1000);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
console.error(e);
|
|
47
|
+
clearTimeout(timeout);
|
|
48
|
+
timeout = setTimeout(() => {
|
|
49
|
+
setupSocket();
|
|
50
|
+
}, 1000);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
setupSocket();
|
|
54
|
+
}, []);
|
|
55
|
+
return {
|
|
56
|
+
lines: getLines(),
|
|
57
|
+
clearLog: () => {
|
|
58
|
+
setlines([]);
|
|
59
|
+
},
|
|
60
|
+
getMaxlogsize,
|
|
61
|
+
setMaxLogSize: (newValue) => {
|
|
62
|
+
if (newValue === "unlimited") {
|
|
63
|
+
setmaxLogSize(newValue);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
setmaxLogSize(newValue);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|