diff options
author | Kristóf Marussy <marussy@mit.bme.hu> | 2021-10-02 16:53:46 +0200 |
---|---|---|
committer | Kristóf Marussy <marussy@mit.bme.hu> | 2021-10-02 16:58:31 +0200 |
commit | ea509702b6ed88951a1b7b109b5dc597ee81112d (patch) | |
tree | 241b9732e7094ef22e7860a9e97a9f67b5b63509 /language-web/src/main/js/editor | |
parent | perf(web): split off CodeMirror chunks (diff) | |
download | refinery-ea509702b6ed88951a1b7b109b5dc597ee81112d.tar.gz refinery-ea509702b6ed88951a1b7b109b5dc597ee81112d.tar.zst refinery-ea509702b6ed88951a1b7b109b5dc597ee81112d.zip |
feat(web): add client-side logging support
Also modified langauge-web/src/main/js/xtext/ServiceBuilder.js to make
sure the new logger is used as soon as xtext is initialized.
Diffstat (limited to 'language-web/src/main/js/editor')
-rw-r--r-- | language-web/src/main/js/editor/EditorArea.tsx | 3 | ||||
-rw-r--r-- | language-web/src/main/js/editor/EditorStore.ts | 13 |
2 files changed, 13 insertions, 3 deletions
diff --git a/language-web/src/main/js/editor/EditorArea.tsx b/language-web/src/main/js/editor/EditorArea.tsx index f07a0ad8..531a57c9 100644 --- a/language-web/src/main/js/editor/EditorArea.tsx +++ b/language-web/src/main/js/editor/EditorArea.tsx | |||
@@ -15,8 +15,7 @@ export const EditorArea = observer(() => { | |||
15 | onChange={(e) => editorStore.updateValue(e.target.value)} | 15 | onChange={(e) => editorStore.updateValue(e.target.value)} |
16 | ref={fallbackTextarea} | 16 | ref={fallbackTextarea} |
17 | className={`problem-fallback-editor cm-s-${editorStore.codeMirrorTheme}`} | 17 | className={`problem-fallback-editor cm-s-${editorStore.codeMirrorTheme}`} |
18 | > | 18 | /> |
19 | </textarea> | ||
20 | ); | 19 | ); |
21 | } | 20 | } |
22 | 21 | ||
diff --git a/language-web/src/main/js/editor/EditorStore.ts b/language-web/src/main/js/editor/EditorStore.ts index 1ac2e79f..8b9432dd 100644 --- a/language-web/src/main/js/editor/EditorStore.ts +++ b/language-web/src/main/js/editor/EditorStore.ts | |||
@@ -8,8 +8,11 @@ import { | |||
8 | import type { IXtextOptions, IXtextServices } from 'xtext/xtext-codemirror'; | 8 | import type { IXtextOptions, IXtextServices } from 'xtext/xtext-codemirror'; |
9 | 9 | ||
10 | import type { IEditorChunk } from './editor'; | 10 | import type { IEditorChunk } from './editor'; |
11 | import { getLogger } from '../logging'; | ||
11 | import type { ThemeStore } from '../theme/ThemeStore'; | 12 | import type { ThemeStore } from '../theme/ThemeStore'; |
12 | 13 | ||
14 | const log = getLogger('EditorStore'); | ||
15 | |||
13 | const xtextLang = 'problem'; | 16 | const xtextLang = 'problem'; |
14 | 17 | ||
15 | const xtextOptions: IXtextOptions = { | 18 | const xtextOptions: IXtextOptions = { |
@@ -52,12 +55,20 @@ export class EditorStore { | |||
52 | xtextServices: observable.ref, | 55 | xtextServices: observable.ref, |
53 | initialSelection: false, | 56 | initialSelection: false, |
54 | }); | 57 | }); |
58 | this.loadChunk(); | ||
59 | } | ||
60 | |||
61 | private loadChunk(): void { | ||
62 | const loadingStartMillis = Date.now(); | ||
63 | log.info('Requesting editor chunk'); | ||
55 | import('./editor').then(({ editorChunk }) => { | 64 | import('./editor').then(({ editorChunk }) => { |
56 | runInAction(() => { | 65 | runInAction(() => { |
57 | this.chunk = editorChunk; | 66 | this.chunk = editorChunk; |
58 | }); | 67 | }); |
68 | const loadingDurationMillis = Date.now() - loadingStartMillis; | ||
69 | log.info('Loaded editor chunk in', loadingDurationMillis, 'ms'); | ||
59 | }).catch((error) => { | 70 | }).catch((error) => { |
60 | console.warn('Error while loading editor', error); | 71 | log.error('Error while loading editor', error); |
61 | }); | 72 | }); |
62 | } | 73 | } |
63 | 74 | ||