miqro 6.2.13 → 7.0.1

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 (217) hide show
  1. package/README.md +9 -17
  2. package/build/editor.bundle.js +11601 -10129
  3. package/build/esm/src/bin/types.js +10 -5
  4. package/build/esm/src/cluster.js +1 -1
  5. package/build/esm/src/common/arguments.d.ts +2 -1
  6. package/build/esm/src/common/arguments.js +42 -18
  7. package/build/esm/src/common/assets.d.ts +1 -1
  8. package/build/esm/src/common/assets.js +34 -13
  9. package/build/esm/src/common/esbuild.d.ts +4 -1
  10. package/build/esm/src/common/esbuild.js +31 -26
  11. package/build/esm/src/common/exit.js +4 -4
  12. package/build/esm/src/common/help.d.ts +1 -1
  13. package/build/esm/src/common/help.js +2 -2
  14. package/build/esm/src/common/jsx.d.ts +2 -3
  15. package/build/esm/src/common/jsx.js +70 -75
  16. package/build/esm/src/common/paths.d.ts +0 -1
  17. package/build/esm/src/common/paths.js +3 -3
  18. package/build/esm/src/common/watch.d.ts +0 -1
  19. package/build/esm/src/common/watch.js +4 -1
  20. package/build/esm/src/inflate/inflate-sea.js +35 -24
  21. package/build/esm/src/inflate/inflate.js +4 -4
  22. package/build/esm/src/inflate/setup-auth.js +1 -1
  23. package/build/esm/src/inflate/setup-cors.js +1 -1
  24. package/build/esm/src/inflate/setup-db.js +2 -2
  25. package/build/esm/src/inflate/setup-error.js +1 -1
  26. package/build/esm/src/inflate/setup-http.js +16 -16
  27. package/build/esm/src/inflate/setup-log.js +1 -1
  28. package/build/esm/src/inflate/setup-middleware.js +1 -1
  29. package/build/esm/src/inflate/setup-server-config.js +1 -1
  30. package/build/esm/src/inflate/setup-ws.js +1 -1
  31. package/build/esm/src/inflate/setup.doc.d.ts +2 -2
  32. package/build/esm/src/inflate/setup.doc.js +23 -2
  33. package/build/esm/src/inflate/utils/sea-utils.js +2 -2
  34. package/build/esm/src/lib.d.ts +10 -1
  35. package/build/esm/src/lib.js +16 -1
  36. package/build/esm/src/main.js +2 -1
  37. package/build/esm/src/services/app.d.ts +1 -0
  38. package/build/esm/src/services/app.js +4 -5
  39. package/build/esm/src/services/migrations.js +2 -2
  40. package/build/esm/src/services/utils/jwt.d.ts +2 -0
  41. package/build/esm/src/services/utils/jwt.js +23 -0
  42. package/build/esm/src/services/utils/middleware.d.ts +9 -0
  43. package/build/esm/src/services/utils/middleware.js +9 -0
  44. package/build/esm/src/services/utils/server-interface.js +33 -4
  45. package/build/esm/src/types.d.ts +50 -83
  46. package/build/lib.cjs +15694 -15619
  47. package/package.json +6 -8
  48. package/sea/basic-compile.base64.sh +1 -1
  49. package/sea/basic-compile.sh +1 -1
  50. package/sea/install-nodejs.sh +1 -1
  51. package/sea/node.version.tag +1 -1
  52. package/.eslintrc +0 -15
  53. package/build/esm/editor/auth.d.ts +0 -6
  54. package/build/esm/editor/auth.js +0 -41
  55. package/build/esm/editor/common/admin-interface.d.ts +0 -36
  56. package/build/esm/editor/common/admin-interface.js +0 -44
  57. package/build/esm/editor/common/constants.d.ts +0 -4
  58. package/build/esm/editor/common/constants.js +0 -20
  59. package/build/esm/editor/common/constants.server.d.ts +0 -2
  60. package/build/esm/editor/common/constants.server.js +0 -4
  61. package/build/esm/editor/common/editor-index.d.ts +0 -2
  62. package/build/esm/editor/common/editor-index.js +0 -14
  63. package/build/esm/editor/common/html-encode.d.ts +0 -1
  64. package/build/esm/editor/common/html-encode.js +0 -14
  65. package/build/esm/editor/common/log-socket.d.ts +0 -15
  66. package/build/esm/editor/common/log-socket.js +0 -70
  67. package/build/esm/editor/common/templates.d.ts +0 -11
  68. package/build/esm/editor/common/templates.js +0 -477
  69. package/build/esm/editor/components/api-preview.d.ts +0 -11
  70. package/build/esm/editor/components/api-preview.js +0 -90
  71. package/build/esm/editor/components/editor.d.ts +0 -16
  72. package/build/esm/editor/components/editor.js +0 -365
  73. package/build/esm/editor/components/file-browser.d.ts +0 -37
  74. package/build/esm/editor/components/file-browser.js +0 -126
  75. package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
  76. package/build/esm/editor/components/file-editor-toolbar.js +0 -93
  77. package/build/esm/editor/components/file-editor.d.ts +0 -32
  78. package/build/esm/editor/components/file-editor.js +0 -59
  79. package/build/esm/editor/components/filter-query.d.ts +0 -1
  80. package/build/esm/editor/components/filter-query.js +0 -22
  81. package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
  82. package/build/esm/editor/components/highlight-text-area.js +0 -125
  83. package/build/esm/editor/components/log-viewer.d.ts +0 -6
  84. package/build/esm/editor/components/log-viewer.js +0 -69
  85. package/build/esm/editor/components/new-file.d.ts +0 -10
  86. package/build/esm/editor/components/new-file.js +0 -117
  87. package/build/esm/editor/components/scroll-query.d.ts +0 -7
  88. package/build/esm/editor/components/scroll-query.js +0 -21
  89. package/build/esm/editor/components/start-page.d.ts +0 -13
  90. package/build/esm/editor/components/start-page.js +0 -30
  91. package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -3
  92. package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -29
  93. package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -5
  94. package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -49
  95. package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -4
  96. package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -39
  97. package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
  98. package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -149
  99. package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
  100. package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -38
  101. package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
  102. package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -46
  103. package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
  104. package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -45
  105. package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
  106. package/build/esm/editor/http/admin/editor/editor.js +0 -7
  107. package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
  108. package/build/esm/editor/http/admin/editor/index.api.js +0 -21
  109. package/build/esm/editor/server.d.ts +0 -3
  110. package/build/esm/editor/server.js +0 -49
  111. package/build/esm/editor/ws.d.ts +0 -3
  112. package/build/esm/editor/ws.js +0 -11
  113. package/build/esm/src/services/globals.d.ts +0 -3
  114. package/build/esm/src/services/globals.js +0 -182
  115. package/build/jsx.dom.js +0 -1587
  116. package/build/postject.base64.cjs +0 -1
  117. package/editor/auth.ts +0 -51
  118. package/editor/common/admin-interface.ts +0 -84
  119. package/editor/common/constants.server.ts +0 -5
  120. package/editor/common/constants.ts +0 -21
  121. package/editor/common/editor-index.tsx +0 -17
  122. package/editor/common/html-encode.ts +0 -14
  123. package/editor/common/log-socket.tsx +0 -85
  124. package/editor/common/templates.ts +0 -481
  125. package/editor/components/api-preview.tsx +0 -116
  126. package/editor/components/editor.tsx +0 -494
  127. package/editor/components/file-browser.tsx +0 -308
  128. package/editor/components/file-editor-toolbar.tsx +0 -191
  129. package/editor/components/file-editor.tsx +0 -122
  130. package/editor/components/filter-query.tsx +0 -22
  131. package/editor/components/highlight-text-area.tsx +0 -145
  132. package/editor/components/log-viewer.tsx +0 -110
  133. package/editor/components/new-file.tsx +0 -169
  134. package/editor/components/scroll-query.tsx +0 -22
  135. package/editor/components/start-page.tsx +0 -49
  136. package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
  137. package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
  138. package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
  139. package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
  140. package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
  141. package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
  142. package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
  143. package/editor/http/admin/editor/editor.tsx +0 -8
  144. package/editor/http/admin/editor/index.api.tsx +0 -39
  145. package/editor/server.ts +0 -57
  146. package/editor/ws.ts +0 -15
  147. package/sea/types.json +0 -1
  148. package/src/bin/compile.ts +0 -35
  149. package/src/bin/doc-md.ts +0 -210
  150. package/src/bin/generate-doc.ts +0 -64
  151. package/src/bin/test.ts +0 -92
  152. package/src/bin/types.ts +0 -29
  153. package/src/cluster.ts +0 -27
  154. package/src/common/arguments.ts +0 -733
  155. package/src/common/assets.ts +0 -128
  156. package/src/common/checksum.ts +0 -58
  157. package/src/common/constants.ts +0 -18
  158. package/src/common/content-type.ts +0 -84
  159. package/src/common/esbuild.ts +0 -94
  160. package/src/common/exit.ts +0 -91
  161. package/src/common/fs.ts +0 -82
  162. package/src/common/help.ts +0 -60
  163. package/src/common/jsx.ts +0 -547
  164. package/src/common/jwt.ts +0 -85
  165. package/src/common/paths.ts +0 -107
  166. package/src/common/watch.ts +0 -85
  167. package/src/inflate/inflate-sea.ts +0 -226
  168. package/src/inflate/inflate.ts +0 -101
  169. package/src/inflate/md.ts +0 -25
  170. package/src/inflate/setup-auth.ts +0 -41
  171. package/src/inflate/setup-cors.ts +0 -41
  172. package/src/inflate/setup-db.ts +0 -117
  173. package/src/inflate/setup-error.ts +0 -44
  174. package/src/inflate/setup-http.ts +0 -704
  175. package/src/inflate/setup-log.ts +0 -45
  176. package/src/inflate/setup-middleware.ts +0 -47
  177. package/src/inflate/setup-server-config.ts +0 -48
  178. package/src/inflate/setup-test.ts +0 -23
  179. package/src/inflate/setup-ws.ts +0 -50
  180. package/src/inflate/setup.doc.ts +0 -68
  181. package/src/inflate/utils/sea-utils.ts +0 -14
  182. package/src/lib.ts +0 -19
  183. package/src/main.ts +0 -100
  184. package/src/services/app.ts +0 -698
  185. package/src/services/editor.tsx +0 -101
  186. package/src/services/globals.ts +0 -186
  187. package/src/services/hot-reload.ts +0 -51
  188. package/src/services/migrations.ts +0 -68
  189. package/src/services/utils/admin-interface.ts +0 -37
  190. package/src/services/utils/cache.ts +0 -88
  191. package/src/services/utils/cluster-cache.ts +0 -230
  192. package/src/services/utils/cluster-ws.ts +0 -202
  193. package/src/services/utils/db-manager.ts +0 -92
  194. package/src/services/utils/get-route.ts +0 -70
  195. package/src/services/utils/log-transport.ts +0 -81
  196. package/src/services/utils/log.ts +0 -92
  197. package/src/services/utils/server-interface.ts +0 -92
  198. package/src/services/utils/websocketmanager.ts +0 -157
  199. package/src/types/@esbuild.d.ts +0 -1
  200. package/src/types/@miqro/core.d.ts +0 -2
  201. package/src/types/@miqro/jsx.d.ts +0 -2
  202. package/src/types/@miqro/parser.d.ts +0 -2
  203. package/src/types/@miqro/query.d.ts +0 -2
  204. package/src/types/@miqro/request.d.ts +0 -2
  205. package/src/types/@miqro/test.d.ts +0 -2
  206. package/src/types/@miqro.d.ts +0 -1
  207. package/src/types/@types.d.ts +0 -1
  208. package/src/types/browser.globals.d.ts +0 -1
  209. package/src/types/cookie.d.ts +0 -2
  210. package/src/types/globals.d.ts +0 -2
  211. package/src/types/jose.d.ts +0 -2
  212. package/src/types/jsx.globals.d.ts +0 -38
  213. package/src/types/miqro.d.ts +0 -228
  214. package/src/types/postject.d.ts +0 -1
  215. package/src/types/server.globals.d.ts +0 -47
  216. package/src/types.ts +0 -304
  217. package/tsconfig.json +0 -35
@@ -1,145 +0,0 @@
1
- //import hljs from "../lib/highlight/core.min.js"
2
- import hljs from 'highlight.js/lib/core';
3
- import javascript from 'highlight.js/lib/languages/javascript';
4
- import xml from "highlight.js/lib/languages/xml";
5
- import css from "highlight.js/lib/languages/css";
6
- import scss from "highlight.js/lib/languages/scss";
7
- import markdown from "highlight.js/lib/languages/markdown";
8
- import dockerfile from "highlight.js/lib/languages/dockerfile";
9
- import yaml from "highlight.js/lib/languages/yaml";
10
- import typescript from "highlight.js/lib/languages/typescript";
11
- import c from "highlight.js/lib/languages/c";
12
- import cpp from "highlight.js/lib/languages/cpp";
13
- import bash from "highlight.js/lib/languages/bash";
14
- import python from "highlight.js/lib/languages/python";
15
- import text from "highlight.js/lib/languages/plaintext";
16
- import json from "highlight.js/lib/languages/json";
17
-
18
- // Then register the languages you need
19
- hljs.registerLanguage('text', text);
20
- hljs.registerLanguage('dockerfile', dockerfile);
21
- hljs.registerLanguage('yaml', yaml);
22
- hljs.registerLanguage('javascript', javascript);
23
- hljs.registerLanguage('xml', xml);
24
- hljs.registerLanguage('html', xml);
25
- hljs.registerLanguage('css', css);
26
- hljs.registerLanguage('scss', scss);
27
- hljs.registerLanguage('markdown', markdown);
28
- hljs.registerLanguage('typescript', typescript);
29
- hljs.registerLanguage('c', c);
30
- hljs.registerLanguage('cpp', cpp);
31
- hljs.registerLanguage('bash', bash);
32
- hljs.registerLanguage('python', python);
33
- hljs.registerLanguage('json', json);
34
-
35
- /*!
36
- Theme: GitHub Dark
37
- Description: Dark theme as seen on github.com
38
- Author: github.com
39
- Maintainer: @Hirse
40
- Updated: 2021-05-15
41
-
42
- Outdated base version: https://github.com/primer/github-syntax-dark
43
- Current colors taken from GitHub's CSS
44
- */
45
- const STYLE = `pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}code{outline: 0px solid rgba(0, 0, 0, 0.263);caret-color: red;}.hljs-name{color: #e8910d;}.hljs-tag .hljs-attr, .hljs-tag .hljs-name{color: #e8910d;}`;
46
- const POSTTYLE = "pre{padding:0; margin:0;} code { background-color: #000000; color: #ffffff; }";
47
- const TAG_NAME = "HIGHLIGHT-TEXT-AREA";
48
-
49
- function runHighlight(content: string | null, language: string) {
50
- const now = Date.now();
51
- console.log("runHighlight [%s]", language);
52
- const value = hljs.highlight(String(content), {
53
- language,
54
- ignoreIllegals: true
55
- }).value;
56
- console.log("runHighlight [%s] took [%s]ms", language, Date.now() - now);
57
- return value;
58
- }
59
-
60
- function emitEvents(elementRef: any, topMost: any, content: string, oncontentchange?: (ev: CustomEvent) => void) {
61
- if (elementRef.current && topMost.current) {
62
- const currentContent = elementRef.current.textContent as any;
63
- const webComponentElement = (topMost.current as HTMLElement).parentNode as HTMLElement;
64
- const event = new CustomEvent("contentchange", { detail: currentContent });
65
- if (webComponentElement && webComponentElement instanceof HTMLElement && webComponentElement.tagName === TAG_NAME) {
66
- try {
67
- webComponentElement.dispatchEvent(event);
68
- } catch (e) {
69
- console.error(e);
70
- }
71
- }
72
- if (typeof oncontentchange === "function") {
73
- try {
74
- oncontentchange(event);
75
- } catch (e) {
76
- console.error(e);
77
- }
78
- }
79
- }
80
- }
81
-
82
- export function HighlightTextArea({ content, language, oncontentchange, tabChar, disabled }:
83
- { language: string; content: string; disabled?: string; tabChar?: string; oncontentchange?: (ev: CustomEvent) => void }
84
- ) {
85
- const elementRef = jsx.useRef();
86
- const topMost = jsx.useRef();
87
- const [lastLanguage, setlastLanguage] = jsx.useState(language);
88
-
89
- // effect to watch changes to language
90
- jsx.useEffect(() => {
91
- if (elementRef.current && (lastLanguage !== language || elementRef.current.textContent !== content)) {
92
- setlastLanguage(language);
93
- elementRef.current.innerHTML = runHighlight(content, language);
94
- }
95
- }, [lastLanguage, language, elementRef.current, content])
96
-
97
- return <pre ref={topMost}>
98
- <style innerHTML={STYLE + POSTTYLE} />
99
- <code
100
- autocomplete="off"
101
- autocorrect="off"
102
- autocapitalize="off"
103
- spellcheck="false"
104
- contenteditable={disabled ? "false" : "true"}
105
- ref={elementRef}
106
- tabindex="0"
107
- innerHTML={!elementRef.current ? runHighlight(content, language) : null}
108
- onfocusout={async (ev) => {
109
- ev.preventDefault();
110
- if (elementRef.current) {
111
- if (content !== elementRef.current.textContent) {
112
- //setlastContent(String(elementRef.current.textContent));
113
- //elementRef.current.innerHTML = runHighlight(elementRef.current.textContent, language);
114
- }
115
- elementRef.current.innerHTML = runHighlight(elementRef.current.textContent, language);
116
- }
117
- }}
118
- onkeydown={ev => {
119
- if (ev.keyCode === 9) {
120
- ev.preventDefault();
121
- // now insert four non-breaking spaces for the tab key
122
- const sel = document.getSelection();
123
- if (sel && topMost.current) {
124
- if ((topMost.current as any).contains(sel.anchorNode)) {
125
- const range = sel.getRangeAt(0);
126
- const tabNode = document.createTextNode(tabChar ? tabChar : "\t");
127
- range.insertNode(tabNode);
128
- range.setStartAfter(tabNode);
129
- range.setEndAfter(tabNode);
130
- sel.removeAllRanges();
131
- sel.addRange(range);
132
- }
133
- }
134
- emitEvents(elementRef, topMost, content, oncontentchange);
135
- }
136
- }}
137
- oninput={ev => {
138
- ev.preventDefault();
139
- emitEvents(elementRef, topMost, content, oncontentchange);
140
- }} />
141
- </pre>
142
- }
143
-
144
- HighlightTextArea.asFragment = true;
145
- HighlightTextArea.shadowInit = false;
@@ -1,110 +0,0 @@
1
- import { LogSocket } from "../common/log-socket.js";
2
-
3
- function getUniqueIdentifiers(lines: {
4
- out: string;
5
- identifier: string;
6
- }[]) {
7
- const identifiersCache = {};
8
- return lines.map(l => l.identifier).filter(identifier => {
9
- const filter = !identifiersCache[identifier];
10
- identifiersCache[identifier] = true;
11
- return filter;
12
- });
13
- }
14
-
15
- const LOG_LEVEL_MAP =
16
- {
17
- "none": 0,
18
- "error": 1,
19
- "warn": 2,
20
- "info": 3,
21
- "debug": 4,
22
- "trace": 5,
23
- };
24
-
25
- interface LogViewerProps {
26
- socket: LogSocket;
27
- }
28
-
29
- export function LogViewer(props: LogViewerProps) {
30
- const { lines, clearLog, getMaxlogsize, setMaxLogSize } = props.socket;
31
-
32
- const maxLogSize = getMaxlogsize();
33
-
34
- const refresh = jsx.useRefresh();
35
-
36
- jsx.useEffect(() => {
37
- refresh();
38
- }, [maxLogSize]);
39
-
40
- const [identifier, setidentifier] = jsx.useState<string>("");
41
- const [level, setlevel] = jsx.useState<string>("debug");
42
- const [filter, setfilter] = jsx.useState<string>("");
43
- const identifiers = getUniqueIdentifiers(lines).sort();
44
- //console.log(identifiers);
45
-
46
- return <div class="log-viewer">
47
- <div class="log-viewer-toolbar">
48
- <button
49
- class="btn"
50
- onclick={e => {
51
- e.preventDefault();
52
- clearLog();
53
- }}>clear log</button>
54
- <select
55
- value={maxLogSize}
56
- oninput={ev => {
57
- ev.preventDefault();
58
- if (ev.target.value === "unlimited") {
59
- setMaxLogSize("unlimited");
60
- } else {
61
- setMaxLogSize(parseInt(ev.target.value, 10));
62
- }
63
- }}
64
- style="margin: 0; padding: 0; margin-left:auto; margin-right: 0;">
65
- {["10", "1000", "5000", "10000", "15000", "20000", "25000", "50000", "100000", "500000", "1000000", "1500000", "5000000"].map(l => <option value={l}>{l}</option>)}
66
- <option value="unlimited">unlimited</option>
67
- </select>
68
- <select
69
- value={level}
70
- oninput={ev => {
71
- ev.preventDefault();
72
- setlevel(ev.target.value);
73
- }}
74
- style="margin: 0; padding: 0; margin-left:var(--file-browser-separation); margin-right: 0;">
75
- {["error", "warn", "info", "debug", "trace"].map(l => <option value={l}>{l}</option>)}
76
- <option value="">all</option>
77
- </select>
78
- <select
79
- value={identifier}
80
- oninput={ev => {
81
- ev.preventDefault();
82
- setidentifier(ev.target.value);
83
- }}
84
- style="margin: 0; padding: 0; margin-left:var(--file-browser-separation); margin-right: 0;">
85
- {identifiers.map(identifier => <option value={identifier}>{identifier}</option>)}
86
- <option value=""></option>
87
- </select>
88
- <input
89
- style="margin: 0; padding: 0; margin-left:var(--file-browser-separation); margin-right: 0;"
90
- value={filter}
91
- oninput={ev => {
92
- ev.preventDefault();
93
- setfilter(ev.target.value);
94
- }}
95
- type="text"
96
- placeholder="..filter.." />
97
- </div>
98
- <div class="log-viewer-log">
99
- {lines
100
- .filter(line => identifier === "" || line.identifier === identifier)
101
- .filter(line => filter === "" || line.out.indexOf(filter) !== -1)
102
- .filter(line => {
103
- return (level === "" || LOG_LEVEL_MAP[level] >= LOG_LEVEL_MAP[line.level]);
104
- })
105
- .map(line =>
106
- <p style="margin: 0; padding: 0; border-radius: 0; font-size: 12px;" class={line.level === "error" ? "info-danger" : line.level === "warn" ? "info-warn" : line.level === "trace" ? "info-success" : line.level === "debug" ? "info-info" : ""}>{line.out}</p>
107
- ).reverse()}
108
- </div>
109
- </div>
110
- }
@@ -1,169 +0,0 @@
1
- import { BASEEDITOR_PATH } from "../common/constants.js";
2
- import { TEMPLATES } from "../common/templates.js";
3
- import { HighlightTextArea } from "./highlight-text-area.js";
4
-
5
- export function NewFile(props: { migrations: string[]; services: string[]; open: boolean; ondone: (file?: string) => void; }) {
6
-
7
- const [template, settemplate] = jsx.useState("EMPTY");
8
-
9
- const refresh = jsx.useRefresh();
10
-
11
- const [service, setservice] = jsx.useState(props.services[0]);
12
-
13
- const nameInput = jsx.useRef();
14
- //const open = dialog ? dialog.open : false;
15
-
16
- /*jsx.useEffect(() => {
17
- if (dialog) {
18
- //console.log((dialogRef.current as any).open);
19
- if (open !== props.open) {
20
- if (nameInput.current) {
21
- nameInput.current.value = "";
22
- nameInput.current.focus();
23
- }
24
- if (props.open) {
25
- console.log("showModal");
26
- dialog.showModal();
27
- //(dialogRef.current as any).show();
28
- } else {
29
- console.log("closeModal");
30
- //dialog.close();
31
- }
32
- }
33
- }
34
- }, [dialog, open, props.open]);*/
35
- jsx.useEffect(() => {
36
-
37
- if (nameInput.current) {
38
- nameInput.current.value = "";
39
- nameInput.current.focus();
40
- }
41
- }, [nameInput.current]);
42
-
43
- function close(file?: string) {
44
- //console.log("closeModal");
45
- if (props.ondone) {
46
- props.ondone(file);
47
- }
48
- }
49
-
50
-
51
- let nextMigrationNumber = 1;
52
- if (props.migrations.length > 0) {
53
- const lastMigration = props.migrations[props.migrations.length - 1];
54
- const indexOfDash = lastMigration.indexOf("-");
55
- if (indexOfDash !== -1) {
56
- nextMigrationNumber = parseInt(lastMigration.substring(0, indexOfDash), 10) + 1;
57
- }
58
- }
59
-
60
- const httpPath = (TEMPLATES[template].filename ? TEMPLATES[template].filename : nameInput.current?.value) + (TEMPLATES[template].httpSufix ? TEMPLATES[template].httpSufix : "");
61
-
62
- const filename = (service ? service + "/" : "") + (service && TEMPLATES[template].prefix ? TEMPLATES[template].prefix + "/" : "") + (template === "MIGRATION" ? nextMigrationNumber + "-" : "") + (TEMPLATES[template].filename ? TEMPLATES[template].filename : nameInput.current?.value) + (TEMPLATES[template].sufix ? TEMPLATES[template].sufix : "");
63
-
64
- async function createNewFile() {
65
- if ((nameInput.current && nameInput.current.value) || TEMPLATES[template].filename) {
66
- const t = TEMPLATES[template];
67
- await fetch(BASEEDITOR_PATH + "/api/fs/write", {
68
- method: "POST",
69
- headers: {
70
- ["content-type"]: "application/json"
71
- },
72
- body: JSON.stringify({
73
- path: filename,
74
- contents: t.template ? t.template(filename, httpPath) : ""
75
- })
76
- });
77
- return filename;
78
- }
79
- }
80
-
81
- return <>
82
- {props.open ? <dialog
83
- class="new-dialog"
84
- open="">
85
- <div class="dialog-header">
86
- <h1>Create new File</h1>
87
- </div>
88
- <div class="dialog-body">
89
- <select
90
- value={service}
91
- oninput={ev => {
92
- ev.preventDefault();
93
- ev.stopPropagation();
94
- console.log(ev.target.value);
95
- setservice(ev.target.value);
96
- }}
97
- style="margin: 0; padding: 0; margin-left:auto; margin-right: var(--file-browser-separation); width: 100%; margin-top: var(--file-browser-separation); margin-bottom: var(--file-browser-separation);">
98
- <option value={""}></option>
99
- {props.services.map(service => <option value={service}>{service}</option>)}
100
- </select>
101
- <p
102
- style="margin: 0; margin-bottom: var(--file-browser-separation);"
103
- >{filename}</p>
104
- {!TEMPLATES[template].filename ? <form
105
- style="width: 100%;"
106
- onsubmit={async (ev) => {
107
- ev.preventDefault();
108
- ev.stopPropagation();
109
- const path = await createNewFile();
110
- close(path);
111
- }}>
112
- <input
113
- style="width: 100%;"
114
- onkeydown={ev => {
115
- if (ev.keyCode === 27) {
116
- // catch esc
117
- ev.stopPropagation();
118
- ev.preventDefault();
119
- close();
120
- }
121
- refresh();
122
- }}
123
- ref={nameInput}
124
- type="text"
125
- placeholder="...filename..." />
126
- </form> : <></>}
127
- <select
128
- value={template}
129
- oninput={ev => {
130
- ev.preventDefault();
131
- ev.stopPropagation();
132
- console.log(ev.target.value);
133
- settemplate(ev.target.value);
134
- }}
135
- style="margin: 0; padding: 0; margin-left:auto; margin-right: var(--file-browser-separation); width: 100%; margin-top: var(--file-browser-separation);">
136
- {Object.keys(TEMPLATES).map(templateName => <option value={templateName}>{TEMPLATES[templateName].displayName}</option>)}
137
- </select>
138
- {TEMPLATES[template].template ? <div
139
- class="new-dialog-preview">
140
- <HighlightTextArea
141
- content={TEMPLATES[template].template(filename, httpPath)}
142
- language={TEMPLATES[template].language}
143
- disabled="true" />
144
- </div> : <></>}
145
- </div>
146
- <div class="dialog-footer">
147
- <button
148
- class="btn danger"
149
- onclick={ev => {
150
- ev.preventDefault();
151
- ev.stopPropagation();
152
- close();
153
- }}>cancel</button>
154
- <button
155
- style="margin-left: auto;"
156
- class="btn active"
157
- onclick={async (ev) => {
158
- ev.preventDefault();
159
- ev.stopPropagation();
160
- const path = await createNewFile();
161
- close(path);
162
- }}>create</button>
163
- </div>
164
- </dialog> : <></>}
165
- </>
166
- }
167
-
168
- NewFile.asFragment = true;
169
- NewFile.shadowInit = false;
@@ -1,22 +0,0 @@
1
- let scrollTimeout2: any = null;
2
-
3
- export function useScroll(): [{ scrollTop: string; scrollLeft: string }, (newScroll: { scrollTop: number; scrollLeft: number; }, inmediate?: boolean) => void] {
4
- const [scrollTop, setscrollTop] = jsx.useQuery("scrollTop", "0");
5
- const [scrollLeft, setscrollLeft] = jsx.useQuery("scrollLeft", "0");
6
-
7
- return [{
8
- scrollTop: scrollTop as string,
9
- scrollLeft: scrollLeft as string
10
- }, (newScroll: { scrollTop: number; scrollLeft: number; }, inmediate?: boolean) => {
11
- clearTimeout(scrollTimeout2);
12
- if (inmediate) {
13
- setscrollTop(String(newScroll.scrollTop));
14
- setscrollLeft(String(newScroll.scrollLeft));
15
- } else {
16
- scrollTimeout2 = setTimeout(() => {
17
- setscrollTop(String(newScroll.scrollTop));
18
- setscrollLeft(String(newScroll.scrollLeft));
19
- }, 1000);
20
- }
21
- }]
22
- }
@@ -1,49 +0,0 @@
1
- interface StartPageProps {
2
- togglePanel: (panel: string) => void;
3
- isPanelVisible: (panel: string) => boolean;
4
- disableLog?: boolean; disablePreview?: boolean; disableReload?: boolean;
5
- }
6
-
7
- export function StartPage(props: StartPageProps) {
8
-
9
- jsx.useEffect(() => {
10
- if (!props.isPanelVisible("left")) {
11
- props.togglePanel("left");
12
- }
13
- }, []);
14
-
15
- return <div class={`start-page`}>
16
- <div class="row center">
17
- <h1>Start Page</h1>
18
- </div>
19
- <br />
20
- <div class="row center">
21
- <div class="row">
22
- <div class={`toggle-panel-button left-side-panel-button ${props.isPanelVisible("left") ? "active" : ""}`}
23
- onclick={ev => {
24
- ev.preventDefault();
25
- props.togglePanel("left");
26
- }}
27
- ></div>
28
- <br />
29
- {props.disableLog ? <></> : <div class={`toggle-panel-button bottom-side-panel-button ${props.isPanelVisible("bottom") ? "active" : ""}`}
30
- onclick={ev => {
31
- ev.preventDefault();
32
- props.togglePanel("bottom");
33
- }}
34
- ></div>}
35
- <br />
36
- {props.disablePreview ? <></> : <div class={`toggle-panel-button right-side-panel-button ${props.isPanelVisible("right") ? "active" : ""}`}
37
- onclick={ev => {
38
- ev.preventDefault();
39
- props.togglePanel("right");
40
- }}
41
- ></div>}
42
- </div>
43
- </div>
44
- <br />
45
- </div>;
46
- }
47
-
48
- StartPage.asFragment = true;
49
- StartPage.shadowInit = false;
@@ -1,32 +0,0 @@
1
- import { APIRoute } from "@miqro/core";
2
- import { unlinkSync } from "node:fs";
3
- import { getPath } from "./read.api.js";
4
-
5
- export default {
6
- description: "admin editor file deletion endpoint",
7
- method: "POST",
8
- path: "/delete",
9
- middleware: [server.middleware.json()],
10
- request: {
11
- body: {
12
- path: "string"
13
- }
14
- },
15
- response: {
16
- status: [200, 400],
17
- body: {
18
- message: "string"
19
- }
20
- },
21
- handler: async (req, res) => {
22
- const { path } = req.body;
23
- await deleteFile(path);
24
- return res?.json({
25
- message: "OK"
26
- });
27
- }
28
- } as APIRoute;
29
-
30
- function deleteFile(path: string) {
31
- unlinkSync(getPath(path));
32
- }
@@ -1,55 +0,0 @@
1
- import { APIRoute } from "@miqro/core";
2
- import { readFileSync } from "node:fs";
3
- import { SUPPORTED_LANGUAGES } from "../../../../../common/constants.js";
4
- import { relative, resolve } from "node:path";
5
- import { getLanguage } from "./scan.api.js";
6
- import { BASE_PATH } from "../../../../../common/constants.server.js";
7
-
8
- export default {
9
- method: "POST",
10
- path: "/read",
11
- description: "admin editor file read endpoint",
12
- middleware: [server.middleware.json()],
13
- request: {
14
- body: {
15
- path: "string"
16
- }
17
- },
18
- response: {
19
- status: [200, 400],
20
- body: {
21
- contents: "string",
22
- path: "string"
23
- }
24
- },
25
- handler: async (req, res) => {
26
- const { path } = req.body;
27
- const contents = readFile(path);
28
- return res?.json({
29
- contents,
30
- path
31
- });
32
- }
33
- } as APIRoute;
34
-
35
- export function readFile(path: string) {
36
- const filePath = getPath(path);
37
- const language = getLanguage(filePath);
38
- if (SUPPORTED_LANGUAGES.includes(language)) {
39
- const contents = readFileSync(filePath).toString();
40
- return contents;
41
- } else {
42
- throw new Error("unsupported file format");
43
- }
44
-
45
- }
46
-
47
- export function getPath(path: string) {
48
- const realPath = resolve(BASE_PATH, path);
49
-
50
- if (relative(BASE_PATH, realPath).startsWith("..")) {
51
- throw new Error("invalid path! [" + path + "]");
52
- }
53
-
54
- return realPath;
55
- }
@@ -1,41 +0,0 @@
1
- import { APIRoute } from "@miqro/core";
2
- import { existsSync, mkdirSync, renameSync } from "node:fs";
3
- import { getPath } from "./read.api.js";
4
- import { dirname } from "node:path";
5
-
6
- export default {
7
- middleware: [server.middleware.json()],
8
- method: "POST",
9
- description: "admin editor file rename endpoint",
10
- path: "/rename",
11
- request: {
12
- body: {
13
- path: "string",
14
- newName: "string"
15
- }
16
- },
17
- response: {
18
- status: [200, 400],
19
- body: {
20
- message: "string"
21
- }
22
- },
23
- handler: async (req, res) => {
24
- const { path, newName } = req.body;
25
- await rename(path, newName);
26
- return res?.json({
27
- message: "OK"
28
- });
29
- }
30
- } as APIRoute;
31
-
32
- export async function rename(path: string, newName: string) {
33
- if (existsSync(path) && !existsSync(newName)) {
34
- mkdirSync(dirname(getPath(newName)), {
35
- recursive: true
36
- });
37
- renameSync(getPath(path), getPath(newName));
38
- } else {
39
- throw new Error("invalid paths");
40
- }
41
- }