miqro 6.1.1 → 6.1.3

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.
Files changed (167) hide show
  1. package/build/esm/editor/auth.d.ts +6 -0
  2. package/build/esm/editor/auth.js +41 -0
  3. package/build/esm/editor/common/admin-interface.d.ts +36 -0
  4. package/build/esm/editor/common/admin-interface.js +44 -0
  5. package/build/esm/editor/common/constants.d.ts +4 -0
  6. package/build/esm/editor/common/constants.js +20 -0
  7. package/build/esm/editor/common/constants.server.d.ts +2 -0
  8. package/build/esm/editor/common/constants.server.js +4 -0
  9. package/build/esm/editor/common/editor-index.d.ts +2 -0
  10. package/build/esm/editor/common/editor-index.js +14 -0
  11. package/build/esm/editor/common/html-encode.d.ts +1 -0
  12. package/build/esm/editor/common/html-encode.js +14 -0
  13. package/build/esm/editor/common/log-socket.d.ts +15 -0
  14. package/build/esm/editor/common/log-socket.js +70 -0
  15. package/build/esm/editor/common/templates.d.ts +11 -0
  16. package/build/esm/editor/common/templates.js +461 -0
  17. package/build/esm/editor/components/api-preview.d.ts +11 -0
  18. package/build/esm/editor/components/api-preview.js +90 -0
  19. package/build/esm/editor/components/editor.d.ts +16 -0
  20. package/build/esm/editor/components/editor.js +357 -0
  21. package/build/esm/editor/components/file-browser.d.ts +37 -0
  22. package/build/esm/editor/components/file-browser.js +126 -0
  23. package/build/esm/editor/components/file-editor-toolbar.d.ts +22 -0
  24. package/build/esm/editor/components/file-editor-toolbar.js +93 -0
  25. package/build/esm/editor/components/file-editor.d.ts +32 -0
  26. package/build/esm/editor/components/file-editor.js +59 -0
  27. package/build/esm/editor/components/filter-query.d.ts +1 -0
  28. package/build/esm/editor/components/filter-query.js +22 -0
  29. package/build/esm/editor/components/highlight-text-area.d.ts +11 -0
  30. package/build/esm/editor/components/highlight-text-area.js +124 -0
  31. package/build/esm/editor/components/log-viewer.d.ts +6 -0
  32. package/build/esm/editor/components/log-viewer.js +69 -0
  33. package/build/esm/editor/components/new-file.d.ts +10 -0
  34. package/build/esm/editor/components/new-file.js +117 -0
  35. package/build/esm/editor/components/scroll-query.d.ts +7 -0
  36. package/build/esm/editor/components/scroll-query.js +21 -0
  37. package/build/esm/editor/components/start-page.d.ts +13 -0
  38. package/build/esm/editor/components/start-page.js +30 -0
  39. package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +3 -0
  40. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +29 -0
  41. package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +5 -0
  42. package/build/esm/editor/http/admin/editor/api/fs/read.api.js +49 -0
  43. package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +4 -0
  44. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +39 -0
  45. package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +26 -0
  46. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +149 -0
  47. package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +3 -0
  48. package/build/esm/editor/http/admin/editor/api/fs/write.api.js +38 -0
  49. package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +10 -0
  50. package/build/esm/editor/http/admin/editor/api/server/reload.api.js +46 -0
  51. package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +10 -0
  52. package/build/esm/editor/http/admin/editor/api/server/restart.api.js +45 -0
  53. package/build/esm/editor/http/admin/editor/editor.d.ts +1 -0
  54. package/build/esm/editor/http/admin/editor/editor.js +7 -0
  55. package/build/esm/editor/http/admin/editor/index.api.d.ts +3 -0
  56. package/build/esm/editor/http/admin/editor/index.api.js +21 -0
  57. package/build/esm/editor/server.d.ts +3 -0
  58. package/build/esm/editor/server.js +49 -0
  59. package/build/esm/editor/ws.d.ts +3 -0
  60. package/build/esm/editor/ws.js +11 -0
  61. package/build/esm/src/bin/compile.d.ts +3 -0
  62. package/build/esm/src/bin/compile.js +30 -0
  63. package/build/esm/src/bin/doc-md.d.ts +17 -0
  64. package/build/esm/src/bin/doc-md.js +186 -0
  65. package/build/esm/src/bin/generate-doc.d.ts +6 -0
  66. package/build/esm/src/bin/generate-doc.js +53 -0
  67. package/build/esm/src/bin/test.d.ts +3 -0
  68. package/build/esm/src/bin/test.js +67 -0
  69. package/build/esm/src/bin/types.d.ts +3 -0
  70. package/build/esm/src/bin/types.js +20 -0
  71. package/editor/auth.ts +51 -0
  72. package/editor/common/admin-interface.ts +84 -0
  73. package/editor/common/constants.server.ts +5 -0
  74. package/editor/common/constants.ts +21 -0
  75. package/editor/common/editor-index.tsx +17 -0
  76. package/editor/common/html-encode.ts +14 -0
  77. package/editor/common/log-socket.tsx +85 -0
  78. package/editor/common/templates.ts +466 -0
  79. package/editor/components/api-preview.tsx +116 -0
  80. package/editor/components/editor.tsx +486 -0
  81. package/editor/components/file-browser.tsx +308 -0
  82. package/editor/components/file-editor-toolbar.tsx +191 -0
  83. package/editor/components/file-editor.tsx +122 -0
  84. package/editor/components/filter-query.tsx +22 -0
  85. package/editor/components/highlight-text-area.tsx +144 -0
  86. package/editor/components/log-viewer.tsx +110 -0
  87. package/editor/components/new-file.tsx +169 -0
  88. package/editor/components/scroll-query.tsx +22 -0
  89. package/editor/components/start-page.tsx +49 -0
  90. package/editor/http/admin/editor/api/fs/delete.api.tsx +32 -0
  91. package/editor/http/admin/editor/api/fs/read.api.tsx +55 -0
  92. package/editor/http/admin/editor/api/fs/rename.api.tsx +41 -0
  93. package/editor/http/admin/editor/api/fs/scan.api.tsx +181 -0
  94. package/editor/http/admin/editor/api/fs/write.api.tsx +41 -0
  95. package/editor/http/admin/editor/api/server/reload.api.ts +53 -0
  96. package/editor/http/admin/editor/api/server/restart.api.tsx +52 -0
  97. package/editor/http/admin/editor/editor.tsx +8 -0
  98. package/editor/http/admin/editor/index.api.tsx +39 -0
  99. package/editor/server.ts +57 -0
  100. package/editor/ws.ts +15 -0
  101. package/package.json +1 -1
  102. package/src/bin/compile.ts +35 -0
  103. package/src/bin/doc-md.ts +210 -0
  104. package/src/bin/generate-doc.ts +64 -0
  105. package/src/bin/test.ts +92 -0
  106. package/src/bin/types.ts +22 -0
  107. package/src/cluster.ts +27 -0
  108. package/src/common/arguments.ts +503 -0
  109. package/src/common/assets.ts +128 -0
  110. package/src/common/checksum.ts +58 -0
  111. package/src/common/constants.ts +18 -0
  112. package/src/common/content-type.ts +84 -0
  113. package/src/common/esbuild.ts +94 -0
  114. package/src/common/exit.ts +91 -0
  115. package/src/common/fs.ts +17 -0
  116. package/src/common/help.ts +51 -0
  117. package/src/common/jsx.ts +512 -0
  118. package/src/common/paths.ts +158 -0
  119. package/src/common/watch.ts +85 -0
  120. package/src/inflate/inflate-sea.ts +206 -0
  121. package/src/inflate/inflate.ts +99 -0
  122. package/src/inflate/md.ts +25 -0
  123. package/src/inflate/setup-auth.ts +40 -0
  124. package/src/inflate/setup-cors.ts +40 -0
  125. package/src/inflate/setup-db.ts +113 -0
  126. package/src/inflate/setup-error.ts +43 -0
  127. package/src/inflate/setup-http.ts +655 -0
  128. package/src/inflate/setup-log.ts +44 -0
  129. package/src/inflate/setup-middleware.ts +46 -0
  130. package/src/inflate/setup-server-config.ts +47 -0
  131. package/src/inflate/setup-test.ts +23 -0
  132. package/src/inflate/setup-ws.ts +48 -0
  133. package/src/inflate/setup.doc.ts +68 -0
  134. package/src/inflate/utils/sea-utils.ts +14 -0
  135. package/src/lib.ts +19 -0
  136. package/src/main.ts +87 -0
  137. package/src/services/app.ts +658 -0
  138. package/src/services/editor.tsx +101 -0
  139. package/src/services/globals.ts +143 -0
  140. package/src/services/hot-reload.ts +48 -0
  141. package/src/services/migrations.ts +66 -0
  142. package/src/services/utils/admin-interface.ts +37 -0
  143. package/src/services/utils/cache.ts +88 -0
  144. package/src/services/utils/cluster-cache.ts +230 -0
  145. package/src/services/utils/cluster-ws.ts +197 -0
  146. package/src/services/utils/db-manager.ts +92 -0
  147. package/src/services/utils/get-route.ts +70 -0
  148. package/src/services/utils/log-transport.ts +75 -0
  149. package/src/services/utils/log.ts +92 -0
  150. package/src/services/utils/server-interface.ts +172 -0
  151. package/src/services/utils/websocketmanager.ts +149 -0
  152. package/src/types/@esbuild.d.ts +1 -0
  153. package/src/types/@miqro/core.d.ts +2 -0
  154. package/src/types/@miqro/jsx.d.ts +2 -0
  155. package/src/types/@miqro/parser.d.ts +2 -0
  156. package/src/types/@miqro/query.d.ts +2 -0
  157. package/src/types/@miqro/request.d.ts +2 -0
  158. package/src/types/@miqro/test.d.ts +2 -0
  159. package/src/types/@miqro.d.ts +1 -0
  160. package/src/types/@types.d.ts +1 -0
  161. package/src/types/browser.globals.d.ts +9 -0
  162. package/src/types/globals.d.ts +2 -0
  163. package/src/types/jsx.globals.d.ts +37 -0
  164. package/src/types/miqro.d.ts +129 -0
  165. package/src/types/postject.d.ts +1 -0
  166. package/src/types/server.globals.d.ts +72 -0
  167. package/src/types.ts +222 -0
@@ -0,0 +1,486 @@
1
+ import { FileEditor } from "./file-editor.js";
2
+ import { NewFile } from "./new-file.js";
3
+ import { useScroll } from "./scroll-query.js";
4
+ import { useFilterQuery } from "./filter-query.js";
5
+ import { FileBrowser } from "./file-browser.js";
6
+ import { StartPage } from "./start-page.js";
7
+ import { BASEEDITOR_PATH } from "../common/constants.js";
8
+ import { LogViewer } from "./log-viewer.js";
9
+ import { useLogSocket } from "../common/log-socket.js";
10
+
11
+ function InflateError2Map(errors: {
12
+ filePath: string;
13
+ error: string;
14
+ }[]) {
15
+ const errorMap: {
16
+ [filePath: string]: {
17
+ error: string
18
+ };
19
+ } = {};
20
+ for (const e of errors) {
21
+ const filePath = e.filePath;
22
+ const error = e.error;
23
+ errorMap[filePath] = {
24
+ error
25
+ };
26
+ }
27
+ return errorMap;
28
+ }
29
+
30
+ export function Editor(props: { disablelog?: boolean; disablepreview?: boolean; disablereload?: boolean; migrations: string; services: string; reloadstring: string; files: string; initialcurrent: string; classname?: string; errors: string }) {
31
+ //console.dir(props);
32
+ const logSocket = useLogSocket({
33
+ disableLog: (props as any).disablelog === "true" || props.disablelog === true ? true : false
34
+ });
35
+
36
+ const [services, setservices] = jsx.useState<string[]>(JSON.parse(props.services));
37
+ const [collapsed, setCollapsed] = jsx.useState<{
38
+ [dir: string]: boolean
39
+ }>((() => {
40
+ const ret: { [dir: string]: boolean } = {};
41
+ services.forEach(service => {
42
+ ret[`${service}/`] = false;
43
+ })
44
+ return ret;
45
+ })());
46
+
47
+ /*const [panelVisible, setpanelVisible] = jsx.useState<{
48
+ [panel: string]: boolean | undefined;
49
+ }>({ right: false, bottom: false });*/
50
+
51
+ const [rightPanelVisible, setRightPanelVisible] = jsx.useQuery("right-panel", "0");
52
+ const [leftPanelVisible, setLeftPanelVisible] = jsx.useQuery("left-panel", "1");
53
+ const [bottomPanelVisible, setBottomPanelVisible] = jsx.useQuery("bottom-panel", "0");
54
+
55
+ const [migrations, setmigrations] = jsx.useState<string[]>(JSON.parse(props.migrations));
56
+ const [files, setfiles] = jsx.useState(JSON.parse(props.files) as {
57
+ filePath: string;
58
+ language: string;
59
+ previewPath?: string;
60
+ dirs: string[];
61
+ apiPreview?: {
62
+ path: string;
63
+ method: string;
64
+ }[];
65
+ content?: string;
66
+ fileName: string;
67
+ }[]);
68
+ const [reloadString, setreloadString] = jsx.useState<string>(props.reloadstring);
69
+ const [changed, setchanged] = jsx.useState<{
70
+ [filePath: string]: string | null;
71
+ }>({});
72
+ const [errors, seterrors] = jsx.useState<{
73
+ [filePath: string]: {
74
+ error: string
75
+ };
76
+ }>(InflateError2Map(JSON.parse(props.errors)));
77
+ const [newFileDialogShow, setnewFileDialogShow] = jsx.useState<boolean>(false);
78
+ const [filter, setfilter] = useFilterQuery();
79
+
80
+ const refresh = jsx.useRefresh();
81
+ const [opened, setopened] = jsx.useState<{
82
+ [filePath: string]: {
83
+ filePath: string;
84
+ fileName: string;
85
+ language: string;
86
+ previewPath?: string;
87
+ apiPreview?: {
88
+ path: string;
89
+ method: string;
90
+ }[];
91
+ content: string | null;
92
+ error?: {
93
+ message: string;
94
+ }
95
+ }
96
+ }>({});
97
+ const [current, setcurrent] = jsx.useQuery("current", props.initialcurrent ? props.initialcurrent : "");
98
+ const [_, setScroll] = useScroll();
99
+
100
+ if (current instanceof Array) {
101
+ setcurrent(current[0]);
102
+ } else if (current) {
103
+ if (!opened[current]) {
104
+ const file = files.filter(file => file.filePath === current)[0];
105
+ if (!file) {
106
+ setcurrent("");
107
+ } else {
108
+ openFile(file.filePath);
109
+ }
110
+ }
111
+ }
112
+
113
+ /*useEffect(() => {
114
+ for (const service of services) {
115
+ if (collapsed[`${service}/`] === undefined) {
116
+ collapsed[`${service}/`] = true;
117
+ refresh();
118
+ }
119
+ }
120
+ }, services);*/
121
+
122
+ function openFile(filePath: string) {
123
+ console.log("open [%s]", filePath);
124
+ const isOpen = opened[filePath];
125
+ setScroll({
126
+ scrollLeft: 0,
127
+ scrollTop: 0
128
+ });
129
+ if (!isOpen) {
130
+ const file = files.filter(file => file.filePath === filePath)[0];
131
+ if (!file) {
132
+ throw new Error("cannot find reference to file [" + filePath + "]");
133
+ }
134
+ opened[file.filePath] = {
135
+ content: null,
136
+ ...file
137
+ };
138
+ changed[file.filePath] = null;
139
+
140
+ setopened(opened);
141
+
142
+ if (opened[file.filePath].content === null && (globalThis.window) !== undefined) {
143
+ if (opened[file.filePath].language !== "binary") {
144
+ fetch(BASEEDITOR_PATH + "/api/fs/read", {
145
+ method: "POST",
146
+ headers: {
147
+ ["content-type"]: "application/json"
148
+ },
149
+ body: JSON.stringify({
150
+ path: file.filePath
151
+ })
152
+ }).then(response => {
153
+
154
+ if (response.ok) {
155
+ response.json().then(json => {
156
+ const contents = json.contents;
157
+ if (opened[file.filePath]) {
158
+ opened[file.filePath].content = contents;
159
+ changed[file.filePath] = contents;
160
+ setopened(opened);
161
+ setchanged(changed);
162
+ refresh();
163
+ }
164
+ });
165
+ }
166
+ })
167
+ } else {
168
+ opened[file.filePath].content = "";
169
+ changed[file.filePath] = "";
170
+ setopened(opened);
171
+ refresh();
172
+ }
173
+ }
174
+ }
175
+ setcurrent(filePath);
176
+ }
177
+
178
+ function closeFile(filePath: string) {
179
+ setScroll({
180
+ scrollTop: 0,
181
+ scrollLeft: 0
182
+ })
183
+ console.log("closing [%s]", filePath);
184
+ //console.log("current [%s]", current);
185
+ if (filePath === current) {
186
+ setcurrent("");
187
+ }
188
+ delete opened[filePath];
189
+ delete changed[filePath];
190
+ setchanged(changed);
191
+ setopened(opened);
192
+ refresh();
193
+ }
194
+
195
+ async function scanFiles() {
196
+ const r = await fetch(BASEEDITOR_PATH + "/api/fs/scan", {
197
+ method: "GET"
198
+ });
199
+ if (r.ok) {
200
+ const { files, services } = await r.json();
201
+ setfiles(files);
202
+ setservices(services);
203
+ }
204
+ }
205
+
206
+ function isDirCollapsed(dir: string) {
207
+ console.log("isDirCollapsed [%s]", dir);
208
+ if (dir === "" || filter !== "") {
209
+ return false;
210
+ }
211
+ return collapsed[dir] || collapsed[dir] === undefined ? true : false;
212
+ //return collapsed[dir] ? false : true;
213
+ }
214
+
215
+ function toggleCollapseDir(dir: string) {
216
+ console.log("toggleCollapseDir [%s]", dir);
217
+ collapsed[dir] = isDirCollapsed(dir) ? false : true;
218
+ setCollapsed(collapsed);
219
+ refresh();
220
+ }
221
+
222
+ async function deleteFile(file: string) {
223
+ console.log("deleteFile [%s]", file);
224
+ const r = await fetch(BASEEDITOR_PATH + "/api/fs/delete", {
225
+ method: "POST",
226
+ headers: {
227
+ ["content-type"]: "application/json"
228
+ },
229
+ body: JSON.stringify({
230
+ path: file
231
+ })
232
+ });
233
+ if (r.ok) {
234
+ await scanFiles();
235
+ if (opened[file]) {
236
+ closeFile(file);
237
+ }
238
+ }
239
+ }
240
+
241
+ async function renameFile(file: string, newName: string) {
242
+ console.log("renameFile [%s] to [%s]", file, newName);
243
+ if (opened[file]) {
244
+ const r = await fetch(BASEEDITOR_PATH + "/api/fs/rename", {
245
+ method: "POST",
246
+ headers: {
247
+ ["content-type"]: "application/json"
248
+ },
249
+ body: JSON.stringify({
250
+ path: file,
251
+ newName
252
+ })
253
+ });
254
+ if (r.ok) {
255
+ const fileO = opened[file];
256
+ const changeO = changed[file];
257
+ fileO.filePath = newName;
258
+ delete changed[file];
259
+ delete opened[file];
260
+ opened[newName] = fileO;
261
+ changed[newName] = changeO;
262
+
263
+ await scanFiles();
264
+
265
+ setopened(opened);
266
+ setchanged(changed);
267
+ if (current === file) {
268
+ setcurrent(newName);
269
+ }
270
+ refresh();
271
+ }
272
+ }
273
+ }
274
+
275
+ async function saveFile(file: string) {
276
+ console.log("saveFile [%s]", file);
277
+ const contents = changed[file];
278
+ if (opened[file] && contents !== undefined && contents !== null) {
279
+ const r = await fetch(BASEEDITOR_PATH + "/api/fs/write", {
280
+ method: "POST",
281
+ headers: {
282
+ ["content-type"]: "application/json"
283
+ },
284
+ body: JSON.stringify({
285
+ path: file,
286
+ contents,
287
+ override: true
288
+ })
289
+ });
290
+ if (r.ok) {
291
+ opened[file].content = contents;
292
+ setopened(opened);
293
+ setchanged(changed);
294
+ refresh();
295
+ }
296
+ }
297
+ }
298
+
299
+ async function reloadServer() {
300
+ const r = await fetch(BASEEDITOR_PATH + "/api/server/reload", {
301
+ method: "POST"
302
+ });
303
+ if (r.ok) {
304
+ const reloadResponse = await r.json();
305
+ if (reloadResponse.errors && reloadResponse.errors.length > 0) {
306
+ seterrors(InflateError2Map(reloadResponse.errors));
307
+ setreloadString(reloadResponse.reloadString);
308
+ refresh();
309
+ } else {
310
+ setreloadString(reloadResponse.reloadString);
311
+ seterrors({});
312
+ refresh();
313
+ }
314
+ setmigrations(reloadResponse.migrations);
315
+ await scanFiles();
316
+ }
317
+ }
318
+
319
+ function setLanguage(file: string, newLanguage: string) {
320
+ if (opened[file]) {
321
+ opened[file].language = newLanguage;
322
+ setopened(opened);
323
+ refresh();
324
+ }
325
+ }
326
+
327
+ function hasFileContentChanged(filePath: string) {
328
+ if (!opened[filePath]) {
329
+ return false;
330
+ }
331
+ return changed[filePath] !== opened[filePath].content
332
+ }
333
+
334
+ function isPanelVisible(panel: string) {
335
+ switch (panel) {
336
+ case "left":
337
+ return leftPanelVisible === "1";
338
+ case "bottom":
339
+ return bottomPanelVisible === "1";
340
+ case "right":
341
+ return rightPanelVisible === "1";
342
+ default:
343
+ return true;
344
+ }
345
+ //return panelVisible[panel] || panelVisible[panel] === undefined ? true : false;
346
+ }
347
+
348
+ function togglePanel(panel: string) {
349
+ console.log("togglePanel [%s]", panel);
350
+ /*panelVisible[panel] = !isPanelVisible(panel);
351
+ setpanelVisible(panelVisible);
352
+ refresh();*/
353
+ switch (panel) {
354
+ case "left":
355
+ return setLeftPanelVisible(isPanelVisible(panel) ? "0" : "1");
356
+ case "bottom":
357
+ return setBottomPanelVisible(isPanelVisible(panel) ? "0" : "1");
358
+ case "right":
359
+ return setRightPanelVisible(isPanelVisible(panel) ? "0" : "1");
360
+ default:
361
+ return;
362
+ }
363
+ }
364
+
365
+ const openedFile = opened[String(current)];
366
+
367
+ //console.log("Editor [%s]", openedFile?.filePath);
368
+
369
+ return <div class="editor">
370
+ <div class={`editor-firstrow${!isPanelVisible("bottom") ? " bottom-panel-hidden" : ""}`}>
371
+ <NewFile
372
+ migrations={migrations}
373
+ services={services}
374
+ open={newFileDialogShow}
375
+ ondone={async (path) => {
376
+ setnewFileDialogShow(false);
377
+ if (path) {
378
+ await scanFiles();
379
+ //await reloadServer();
380
+ }
381
+ }} />
382
+ <FileBrowser
383
+ disableLog={props.disablelog}
384
+ disablePreview={props.disablepreview}
385
+ disableReload={props.disablereload}
386
+ togglePanel={togglePanel}
387
+ isPanelVisible={isPanelVisible}
388
+ opened={Object.keys(opened).sort().map(o => opened[o])}
389
+ isDirCollapsed={isDirCollapsed}
390
+ toggleCollapseDir={toggleCollapseDir}
391
+ migrations={migrations}
392
+ hasErrors={(file) => errors[file] ? true : false}
393
+ reloadServer={reloadServer}
394
+ closeAll={() => {
395
+ const openedList = Object.keys(opened);
396
+ for (const o of openedList) {
397
+ closeFile(o);
398
+ }
399
+ }}
400
+ closeFile={closeFile}
401
+ current={current ? String(current) : ""}
402
+ files={files}
403
+ filter={filter}
404
+ hasFileContentChanged={hasFileContentChanged}
405
+ isOpen={(file) => opened[file] !== undefined}
406
+ openFile={openFile}
407
+ saveAll={async () => {
408
+ const openedList = Object.keys(opened);
409
+ for (const o of openedList) {
410
+ if (hasFileContentChanged(o)) {
411
+ await saveFile(o);
412
+ }
413
+ }
414
+ //await reloadServer();
415
+ }}
416
+ scanFiles={scanFiles}
417
+ setfilter={setfilter}
418
+ showNewFile={() => {
419
+ setnewFileDialogShow(true);
420
+ }}
421
+ />
422
+ <div class={`file-editor-list${!isPanelVisible("left") ? " left-panel-hidden" : ""}${!isPanelVisible("bottom") ? " bottom-panel-hidden" : ""}`}>
423
+ {!openedFile ?
424
+ <StartPage
425
+ disableLog={props.disablelog}
426
+ disablePreview={props.disablepreview}
427
+ disableReload={props.disablereload}
428
+ isPanelVisible={isPanelVisible}
429
+ togglePanel={togglePanel}
430
+ /> :
431
+ <div class="file-editor-container">
432
+ <FileEditor
433
+ disableLog={props.disablelog}
434
+ disablePreview={props.disablepreview}
435
+ disableReload={props.disablereload}
436
+ isPanelVisible={isPanelVisible}
437
+ togglePanel={togglePanel}
438
+ reloadString={reloadString}
439
+ error={errors[openedFile.filePath]?.error}
440
+ changed={hasFileContentChanged(openedFile.filePath)}
441
+ setlanguage={(newLanguage: string) => setLanguage(openedFile.filePath, newLanguage)}
442
+ deleteFile={async () => {
443
+ await deleteFile(openedFile.filePath);
444
+ //await reloadServer();
445
+ }}
446
+ renameFile={async (newName) => {
447
+ await renameFile(openedFile.filePath, newName);
448
+ //await reloadServer();
449
+ }}
450
+ saveFile={async (reload = false) => {
451
+ await saveFile(openedFile.filePath);
452
+ if (reload) {
453
+ await reloadServer();
454
+ }
455
+ //
456
+ }}
457
+ content={changed[openedFile.filePath] !== null ? changed[openedFile.filePath] : opened[openedFile.filePath].content}
458
+ current={current === openedFile.filePath}
459
+ revertFile={() => {
460
+ changed[openedFile.filePath] = openedFile.content;
461
+ setchanged(changed);
462
+ refresh();
463
+ }}
464
+ contentchange={(content) => {
465
+ changed[openedFile.filePath] = content;
466
+ setopened(opened);
467
+ refresh();
468
+ }}
469
+ closeFile={() => {
470
+ closeFile(openedFile.filePath);
471
+ }}
472
+ path={openedFile.filePath}
473
+ previewPath={openedFile.previewPath}
474
+ apiPreview={openedFile.apiPreview}
475
+ language={opened[openedFile.filePath].language} />
476
+ </div>}
477
+ </div>
478
+ </div>
479
+ <div class="editor-bottom-panel" style={`${!isPanelVisible("bottom") ? "display: none;" : ""}`}>
480
+ <LogViewer socket={logSocket} />
481
+ </div>
482
+ </div>
483
+ }
484
+
485
+ Editor.asFragment = true;
486
+ Editor.shadowInit = false;