@finos/legend-application 13.0.10 → 14.0.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.
Files changed (103) hide show
  1. package/lib/application/LegendApplication.d.ts +0 -2
  2. package/lib/application/LegendApplication.d.ts.map +1 -1
  3. package/lib/application/LegendApplication.js +3 -38
  4. package/lib/application/LegendApplication.js.map +1 -1
  5. package/lib/application/LegendApplicationDocumentation.d.ts +1 -9
  6. package/lib/application/LegendApplicationDocumentation.d.ts.map +1 -1
  7. package/lib/application/LegendApplicationDocumentation.js +0 -8
  8. package/lib/application/LegendApplicationDocumentation.js.map +1 -1
  9. package/lib/components/ApplicationStoreProvider.d.ts +1 -1
  10. package/lib/components/ApplicationStoreProvider.d.ts.map +1 -1
  11. package/lib/components/ApplicationStoreProvider.js +19 -5
  12. package/lib/components/ApplicationStoreProvider.js.map +1 -1
  13. package/lib/components/VirtualAssistant.d.ts.map +1 -1
  14. package/lib/components/VirtualAssistant.js +6 -8
  15. package/lib/components/VirtualAssistant.js.map +1 -1
  16. package/lib/components/shared/DocumentationLink.js +1 -1
  17. package/lib/components/shared/DocumentationLink.js.map +1 -1
  18. package/lib/components/shared/{TextSearchAdvancedConfigMenu.d.ts → FuzzySearchAdvancedConfigMenu.d.ts} +4 -4
  19. package/lib/components/shared/FuzzySearchAdvancedConfigMenu.d.ts.map +1 -0
  20. package/lib/components/shared/{TextSearchAdvancedConfigMenu.js → FuzzySearchAdvancedConfigMenu.js} +8 -8
  21. package/lib/components/shared/FuzzySearchAdvancedConfigMenu.js.map +1 -0
  22. package/lib/{components/execution-plan-viewer/ExecutionPlanViewer.d.ts → components.d.ts} +6 -13
  23. package/lib/components.d.ts.map +1 -0
  24. package/lib/{components/shared/TextInputEditor.d.ts → components.js} +6 -13
  25. package/lib/components.js.map +1 -0
  26. package/lib/const.d.ts +3 -3
  27. package/lib/const.d.ts.map +1 -1
  28. package/lib/const.js +19 -17
  29. package/lib/const.js.map +1 -1
  30. package/lib/index.css +2 -2
  31. package/lib/index.css.map +1 -1
  32. package/lib/index.d.ts +2 -15
  33. package/lib/index.d.ts.map +1 -1
  34. package/lib/index.js +4 -16
  35. package/lib/index.js.map +1 -1
  36. package/lib/package.json +7 -12
  37. package/lib/stores/ApplicationStore.d.ts +3 -1
  38. package/lib/stores/ApplicationStore.d.ts.map +1 -1
  39. package/lib/stores/ApplicationStore.js +22 -1
  40. package/lib/stores/ApplicationStore.js.map +1 -1
  41. package/lib/stores/AssistantService.d.ts +3 -3
  42. package/lib/stores/AssistantService.d.ts.map +1 -1
  43. package/lib/stores/AssistantService.js +3 -4
  44. package/lib/stores/AssistantService.js.map +1 -1
  45. package/lib/stores/Core_LegendApplicationPlugin.d.ts +2 -1
  46. package/lib/stores/Core_LegendApplicationPlugin.d.ts.map +1 -1
  47. package/lib/stores/Core_LegendApplicationPlugin.js +69 -1
  48. package/lib/stores/Core_LegendApplicationPlugin.js.map +1 -1
  49. package/lib/stores/LegendApplicationPlugin.d.ts +12 -1
  50. package/lib/stores/LegendApplicationPlugin.d.ts.map +1 -1
  51. package/lib/stores/LegendApplicationPlugin.js.map +1 -1
  52. package/lib/stores/pure-language/{PureLanguageTextEditorSupport.d.ts → PureLanguageCodeEditorSupport.d.ts} +1 -1
  53. package/lib/stores/pure-language/{PureLanguageTextEditorSupport.d.ts.map → PureLanguageCodeEditorSupport.d.ts.map} +1 -1
  54. package/lib/stores/pure-language/{PureLanguageTextEditorSupport.js → PureLanguageCodeEditorSupport.js} +1 -1
  55. package/lib/stores/pure-language/{PureLanguageTextEditorSupport.js.map → PureLanguageCodeEditorSupport.js.map} +1 -1
  56. package/lib/stores/pure-language/PureLanguageSupport.d.ts +1 -2
  57. package/lib/stores/pure-language/PureLanguageSupport.d.ts.map +1 -1
  58. package/lib/stores/pure-language/PureLanguageSupport.js +7 -71
  59. package/lib/stores/pure-language/PureLanguageSupport.js.map +1 -1
  60. package/lib/stores/shared/{TextSearchAdvancedConfigState.d.ts → FuzzySearchAdvancedConfigState.d.ts} +5 -5
  61. package/lib/stores/shared/FuzzySearchAdvancedConfigState.d.ts.map +1 -0
  62. package/lib/stores/shared/{TextSearchAdvancedConfigState.js → FuzzySearchAdvancedConfigState.js} +14 -14
  63. package/lib/stores/shared/FuzzySearchAdvancedConfigState.js.map +1 -0
  64. package/package.json +11 -16
  65. package/src/application/{LegendApplication.tsx → LegendApplication.ts} +4 -60
  66. package/src/application/LegendApplicationDocumentation.ts +0 -8
  67. package/src/components/ApplicationStoreProvider.tsx +31 -12
  68. package/src/components/VirtualAssistant.tsx +9 -13
  69. package/src/components/shared/DocumentationLink.tsx +1 -1
  70. package/src/components/shared/{TextSearchAdvancedConfigMenu.tsx → FuzzySearchAdvancedConfigMenu.tsx} +14 -14
  71. package/src/components.ts +23 -0
  72. package/src/const.ts +5 -3
  73. package/src/index.ts +7 -19
  74. package/src/stores/ApplicationStore.ts +31 -0
  75. package/src/stores/AssistantService.ts +5 -5
  76. package/src/stores/Core_LegendApplicationPlugin.ts +100 -1
  77. package/src/stores/LegendApplicationPlugin.ts +16 -1
  78. package/src/stores/pure-language/PureLanguageSupport.ts +8 -77
  79. package/src/stores/shared/{TextSearchAdvancedConfigState.ts → FuzzySearchAdvancedConfigState.ts} +8 -8
  80. package/tsconfig.json +6 -9
  81. package/lib/components/execution-plan-viewer/ExecutionPlanViewer.d.ts.map +0 -1
  82. package/lib/components/execution-plan-viewer/ExecutionPlanViewer.js +0 -182
  83. package/lib/components/execution-plan-viewer/ExecutionPlanViewer.js.map +0 -1
  84. package/lib/components/execution-plan-viewer/SQLExecutionNodeViewer.d.ts +0 -31
  85. package/lib/components/execution-plan-viewer/SQLExecutionNodeViewer.d.ts.map +0 -1
  86. package/lib/components/execution-plan-viewer/SQLExecutionNodeViewer.js +0 -32
  87. package/lib/components/execution-plan-viewer/SQLExecutionNodeViewer.js.map +0 -1
  88. package/lib/components/shared/TextInputEditor.d.ts.map +0 -1
  89. package/lib/components/shared/TextInputEditor.js +0 -109
  90. package/lib/components/shared/TextInputEditor.js.map +0 -1
  91. package/lib/components/shared/TextSearchAdvancedConfigMenu.d.ts.map +0 -1
  92. package/lib/components/shared/TextSearchAdvancedConfigMenu.js.map +0 -1
  93. package/lib/stores/ExecutionPlanState.d.ts +0 -61
  94. package/lib/stores/ExecutionPlanState.d.ts.map +0 -1
  95. package/lib/stores/ExecutionPlanState.js +0 -118
  96. package/lib/stores/ExecutionPlanState.js.map +0 -1
  97. package/lib/stores/shared/TextSearchAdvancedConfigState.d.ts.map +0 -1
  98. package/lib/stores/shared/TextSearchAdvancedConfigState.js.map +0 -1
  99. package/src/components/execution-plan-viewer/ExecutionPlanViewer.tsx +0 -543
  100. package/src/components/execution-plan-viewer/SQLExecutionNodeViewer.tsx +0 -46
  101. package/src/components/shared/TextInputEditor.tsx +0 -153
  102. package/src/stores/ExecutionPlanState.ts +0 -153
  103. /package/src/stores/pure-language/{PureLanguageTextEditorSupport.ts → PureLanguageCodeEditorSupport.ts} +0 -0
@@ -15,13 +15,5 @@
15
15
  */
16
16
 
17
17
  export enum LEGEND_APPLICATION_DOCUMENTATION_KEY {
18
- TUTORIAL_QUERY_BUILDER = 'tutorial.query.builder',
19
18
  QUESTION_HOW_TO_USE_ADVANCED_SEARCH_SYNTAX = 'question.how-to-use-advanced-search-syntax',
20
- QUESTION_WHEN_TO_CONFIGURE_PLATFORM_VERSIONS = 'question.when-to-configure-project-platform-dependencies-versions',
21
- QUESTION_HOW_TO_WRITE_A_SERVICE_TEST = 'question.how-to-write-a-service-test',
22
- QUESTION_WHY_DO_I_SEE_ERROR_WITH_ASSOCIATION_PROPERTY_TYPE = 'question.why-do-i-see-error-with-association-property-type',
23
- QUESTION_HOW_TO_ADD_PARAMETERS_TO_QUERY = 'question.how-to-add-parameters-to-query',
24
- QUESTION_HOW_TO_ADD_CONSTANTS_TO_QUERY = 'question.how-to-add-constants-to-query',
25
- QUESTION_HOW_TO_WRITE_SERVICE_CONNECTION_TEST_DATA = 'question.how-to-write-service-connection-test-data',
26
- QUESTION_HOW_TO_CREATE_A_DATA_ELEMENT = 'question.how-to-create-a-data-element',
27
19
  }
@@ -14,8 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { createContext, useContext } from 'react';
18
- import { useLocalObservable } from 'mobx-react-lite';
17
+ import { createContext, useContext, useEffect } from 'react';
18
+ import { observer, useLocalObservable } from 'mobx-react-lite';
19
19
  import {
20
20
  ApplicationStore,
21
21
  type GenericLegendApplicationStore,
@@ -30,6 +30,34 @@ const ApplicationStoreContext = createContext<
30
30
  GenericLegendApplicationStore | undefined
31
31
  >(undefined);
32
32
 
33
+ export const useApplicationStore = <
34
+ T extends LegendApplicationConfig,
35
+ V extends LegendApplicationPluginManager<LegendApplicationPlugin>,
36
+ >(): ApplicationStore<T, V> =>
37
+ guaranteeNonNullable(
38
+ useContext(ApplicationStoreContext) as ApplicationStore<T, V> | undefined,
39
+ `Can't find application store in context`,
40
+ );
41
+
42
+ const ApplicationContent = observer(
43
+ (props: { children: React.ReactNode }): React.ReactElement => {
44
+ const { children } = props;
45
+ const applicationStore = useApplicationStore();
46
+
47
+ useEffect(() => {
48
+ applicationStore.initialize().catch(applicationStore.alertUnhandledError);
49
+ }, [applicationStore]);
50
+
51
+ if (!applicationStore.initState.hasSucceeded) {
52
+ return <></>;
53
+ }
54
+ // TODO: would be great if we can have <React.StrictMode> here but since Mobx React is not ready for
55
+ // concurrency yet, we would have to wait
56
+ // See https://github.com/mobxjs/mobx/issues/2526
57
+ return <>{children}</>;
58
+ },
59
+ );
60
+
33
61
  export const ApplicationStoreProvider = <
34
62
  T extends LegendApplicationConfig,
35
63
  V extends LegendApplicationPluginManager<LegendApplicationPlugin>,
@@ -48,16 +76,7 @@ export const ApplicationStoreProvider = <
48
76
  );
49
77
  return (
50
78
  <ApplicationStoreContext.Provider value={applicationStore}>
51
- {children}
79
+ <ApplicationContent>{children}</ApplicationContent>
52
80
  </ApplicationStoreContext.Provider>
53
81
  );
54
82
  };
55
-
56
- export const useApplicationStore = <
57
- T extends LegendApplicationConfig,
58
- V extends LegendApplicationPluginManager<LegendApplicationPlugin>,
59
- >(): ApplicationStore<T, V> =>
60
- guaranteeNonNullable(
61
- useContext(ApplicationStoreContext) as ApplicationStore<T, V> | undefined,
62
- `Can't find application store in context`,
63
- );
@@ -31,12 +31,13 @@ import {
31
31
  SunglassesIcon,
32
32
  WizardHatIcon,
33
33
  FaceLaughWinkIcon,
34
- VerticalDragHandleThinIcon,
34
+ ThinVerticalDragHandleIcon,
35
35
  CircleIcon,
36
36
  PanelLoadingIndicator,
37
37
  BasePopover,
38
38
  FaceSadTearIcon,
39
39
  CogIcon,
40
+ Draggable,
40
41
  } from '@finos/legend-art';
41
42
  import {
42
43
  ContentType,
@@ -54,10 +55,9 @@ import {
54
55
  VIRTUAL_ASSISTANT_TAB,
55
56
  } from '../stores/AssistantService.js';
56
57
  import { useApplicationStore } from './ApplicationStoreProvider.js';
57
- import Draggable from 'react-draggable';
58
58
  import { DATE_TIME_FORMAT } from '@finos/legend-graph';
59
59
  import { LegendApplicationTelemetryHelper } from '../application/LegendApplicationTelemetry.js';
60
- import { TextSearchAdvancedConfigMenu } from './shared/TextSearchAdvancedConfigMenu.js';
60
+ import { FuzzySearchAdvancedConfigMenu } from './shared/FuzzySearchAdvancedConfigMenu.js';
61
61
 
62
62
  const WIZARD_GREETING = `Bonjour, It's Pierre!`;
63
63
 
@@ -265,7 +265,6 @@ const VirtualAssistantContextualSupportPanel = observer(() => {
265
265
  const VirtualAssistantSearchPanel = observer(() => {
266
266
  const applicationStore = useApplicationStore();
267
267
  const searchInputRef = useRef<HTMLInputElement>(null);
268
- const searchConfigButtonRef = useRef<HTMLButtonElement>(null);
269
268
  const assistantService = applicationStore.assistantService;
270
269
 
271
270
  // search text
@@ -285,6 +284,10 @@ const VirtualAssistantSearchPanel = observer(() => {
285
284
  assistantService.currentDocumentationEntry = undefined;
286
285
  searchInputRef.current?.focus();
287
286
  };
287
+ const toggleSearchConfigMenu = (): void =>
288
+ assistantService.setShowSearchConfigurationMenu(
289
+ !assistantService.showSearchConfigurationMenu,
290
+ );
288
291
 
289
292
  const downloadDocRegistry = (): void => {
290
293
  downloadFileUsingDataURI(
@@ -314,10 +317,6 @@ const VirtualAssistantSearchPanel = observer(() => {
314
317
  ContentType.APPLICATION_JSON,
315
318
  );
316
319
  };
317
- const toggleSearchConfigMenu = (): void =>
318
- assistantService.setShowSearchConfigurationMenu(
319
- !assistantService.showSearchConfigurationMenu,
320
- );
321
320
 
322
321
  useEffect(() => {
323
322
  searchInputRef.current?.focus();
@@ -374,7 +373,6 @@ const VirtualAssistantSearchPanel = observer(() => {
374
373
  </div>
375
374
  )}
376
375
  <button
377
- ref={searchConfigButtonRef}
378
376
  className={clsx('virtual-assistant__search__input__config__trigger', {
379
377
  'virtual-assistant__search__input__config__trigger--toggled':
380
378
  assistantService.showSearchConfigurationMenu,
@@ -410,18 +408,16 @@ const VirtualAssistantSearchPanel = observer(() => {
410
408
  <PanelLoadingIndicator
411
409
  isLoading={assistantService.searchState.isInProgress}
412
410
  />
413
- {/* {assistantService.showSearchConfigurationMenu && ( */}
414
411
  <div
415
412
  className={clsx('virtual-assistant__search__input__config__panel', {
416
413
  'virtual-assistant__search__input__config__panel--toggled':
417
414
  assistantService.showSearchConfigurationMenu,
418
415
  })}
419
416
  >
420
- <TextSearchAdvancedConfigMenu
417
+ <FuzzySearchAdvancedConfigMenu
421
418
  configState={assistantService.searchConfigurationState}
422
419
  />
423
420
  </div>
424
- {/* )} */}
425
421
  {assistantService.currentDocumentationEntry && (
426
422
  <div className="virtual-assistant__search__results">
427
423
  <VirtualAssistantDocumentationEntryViewer
@@ -747,7 +743,7 @@ export const VirtualAssistant = observer(() => {
747
743
  className="virtual-assistant__station__drag-handle__content"
748
744
  title={isDragging ? undefined : 'Grab to drag assistant'}
749
745
  >
750
- <VerticalDragHandleThinIcon />
746
+ <ThinVerticalDragHandleIcon />
751
747
  </div>
752
748
  </ContextMenu>
753
749
  </div>
@@ -15,8 +15,8 @@
15
15
  */
16
16
 
17
17
  import { clsx, QuestionCircleIcon } from '@finos/legend-art';
18
- import { shouldDisplayVirtualAssistantDocumentationEntry } from '../../stores/AssistantService.js';
19
18
  import { useApplicationStore } from '../ApplicationStoreProvider.js';
19
+ import { shouldDisplayVirtualAssistantDocumentationEntry } from '../../stores/AssistantService.js';
20
20
 
21
21
  export const DocumentationLink: React.FC<{
22
22
  documentationKey: string;
@@ -16,22 +16,22 @@
16
16
 
17
17
  import { BaseRadioGroup, InfoCircleIcon } from '@finos/legend-art';
18
18
  import { observer } from 'mobx-react-lite';
19
- import { LEGEND_APPLICATION_DOCUMENTATION_KEY } from '../../application/LegendApplicationDocumentation.js';
20
19
  import {
21
- ADVANCED_TEXT_SEARCH_MODE,
22
- type TextSearchAdvancedConfigState,
23
- } from '../../stores/shared/TextSearchAdvancedConfigState.js';
20
+ ADVANCED_FUZZY_SEARCH_MODE,
21
+ type FuzzySearchAdvancedConfigState,
22
+ } from '../../stores/shared/FuzzySearchAdvancedConfigState.js';
23
+ import { LEGEND_APPLICATION_DOCUMENTATION_KEY } from '../../application/LegendApplicationDocumentation.js';
24
24
  import { useApplicationStore } from '../ApplicationStoreProvider.js';
25
25
 
26
- export const TextSearchAdvancedConfigMenu = observer(
27
- (props: { configState: TextSearchAdvancedConfigState }) => {
26
+ export const FuzzySearchAdvancedConfigMenu = observer(
27
+ (props: { configState: FuzzySearchAdvancedConfigState }) => {
28
28
  const { configState } = props;
29
29
  const applicationStore = useApplicationStore();
30
30
 
31
31
  const handleSearchMode: React.ChangeEventHandler<HTMLInputElement> = (
32
32
  event,
33
33
  ): void => {
34
- const searchMode = event.target.value as ADVANCED_TEXT_SEARCH_MODE;
34
+ const searchMode = event.target.value as ADVANCED_FUZZY_SEARCH_MODE;
35
35
  configState.setCurrentMode(searchMode);
36
36
  };
37
37
  const seeDocumentation = (): void =>
@@ -40,11 +40,11 @@ export const TextSearchAdvancedConfigMenu = observer(
40
40
  );
41
41
 
42
42
  return (
43
- <div className="text-search-advanced-config__panel">
44
- <div className="text-search-advanced-config__panel__header__label">
43
+ <div className="fuzzy-search__advanced-config__panel">
44
+ <div className="fuzzy-search__advanced-config__panel__header__label">
45
45
  search config
46
46
  <button
47
- className="text-search-advanced-config__panel__header__hint"
47
+ className="fuzzy-search__advanced-config__panel__header__hint"
48
48
  tabIndex={-1}
49
49
  onClick={seeDocumentation}
50
50
  title="Click to see more details on advanced search"
@@ -59,10 +59,10 @@ export const TextSearchAdvancedConfigMenu = observer(
59
59
  onChange={handleSearchMode}
60
60
  row={false}
61
61
  options={[
62
- ADVANCED_TEXT_SEARCH_MODE.STANDARD,
63
- ADVANCED_TEXT_SEARCH_MODE.INCLUDE,
64
- ADVANCED_TEXT_SEARCH_MODE.EXACT,
65
- ADVANCED_TEXT_SEARCH_MODE.INVERSE,
62
+ ADVANCED_FUZZY_SEARCH_MODE.STANDARD,
63
+ ADVANCED_FUZZY_SEARCH_MODE.INCLUDE,
64
+ ADVANCED_FUZZY_SEARCH_MODE.EXACT,
65
+ ADVANCED_FUZZY_SEARCH_MODE.INVERSE,
66
66
  ]}
67
67
  size={1}
68
68
  />
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export * from './components/shared/DocumentationLink.js';
18
+
19
+ export * from './components/shared/TabManager.js';
20
+ export * from './stores/shared/TabManagerState.js';
21
+
22
+ export * from './components/shared/FuzzySearchAdvancedConfigMenu.js';
23
+ export * from './stores/shared/FuzzySearchAdvancedConfigState.js';
package/src/const.ts CHANGED
@@ -20,12 +20,14 @@ export const DEFAULT_TYPEAHEAD_SEARCH_LIMIT = 10;
20
20
 
21
21
  export const MONOSPACED_FONT_FAMILY = 'Roboto Mono';
22
22
 
23
- export enum EDITOR_THEME {
24
- LEGEND = 'LEGEND',
23
+ // TODO: to be moved to `@finos/legend-lego`
24
+ export enum CODE_EDITOR_THEME {
25
+ LEGEND = 'legend',
25
26
  TEMPORARY__VSCODE_LIGHT = 'vs',
26
27
  }
27
28
 
28
- export enum EDITOR_LANGUAGE {
29
+ // TODO: to be moved to `@finos/legend-lego`
30
+ export enum CODE_EDITOR_LANGUAGE {
29
31
  TEXT = 'plaintext',
30
32
  PURE = 'pure',
31
33
  JSON = 'json',
package/src/index.ts CHANGED
@@ -20,7 +20,6 @@ export * from './application/LegendApplication.js';
20
20
  export * from './application/LegendApplicationConfig.js';
21
21
  export * from './application/LegendApplicationPluginManager.js';
22
22
  export * from './application/LegendApplicationEvent.js';
23
- export * from './application/LegendApplicationDocumentation.js';
24
23
  export * from './application/LegendApplicationTelemetry.js';
25
24
  export * from './application/LegendApplicationSetting.js';
26
25
  export { LEGEND_APPLICATION_COLOR_THEME } from './application/LegendApplicationTheme.js';
@@ -60,24 +59,13 @@ export * from './stores/ApplicationStoreTestUtils.js';
60
59
  export * from './stores/navigation/WebApplicationRouter.js';
61
60
  export { DISPLAY_ANSI_ESCAPE } from './stores/terminal/Terminal.js';
62
61
 
63
- // ------------------------------------------- Shared components -------------------------------------------
62
+ // ------------------------------------------- TO BE MOVED -------------------------------------------
64
63
 
65
- export * from './components/shared/DocumentationLink.js';
66
-
67
- /**
68
- * To be moved to other packages
69
- * @modularize
70
- */
71
- export * from './components/execution-plan-viewer/ExecutionPlanViewer.js';
72
- export * from './stores/ExecutionPlanState.js';
73
-
74
- export * from './components/shared/TextInputEditor.js';
64
+ // TODO: move to `@finos/legend-lego/code-editor`
65
+ export {
66
+ PURE_GRAMMAR_TOKEN,
67
+ setupPureLanguageService,
68
+ } from './stores/pure-language/PureLanguageSupport.js';
69
+ export * from './stores/pure-language/PureLanguageCodeEditorSupport.js';
75
70
  export * from './components/shared/PackageableElementOptionLabel.js';
76
- export { PURE_GRAMMAR_TOKEN } from './stores/pure-language/PureLanguageSupport.js';
77
- export * from './stores/pure-language/PureLanguageTextEditorSupport.js';
78
71
  export * from './stores/shared/PackageableElementOption.js';
79
-
80
- export * from './components/shared/TabManager.js';
81
- export * from './components/shared/TextSearchAdvancedConfigMenu.js';
82
- export * from './stores/shared/TabManagerState.js';
83
- export * from './stores/shared/TextSearchAdvancedConfigState.js';
@@ -19,6 +19,8 @@ import {
19
19
  LogService,
20
20
  LogEvent,
21
21
  uuid,
22
+ ActionState,
23
+ assertErrorThrown,
22
24
  } from '@finos/legend-shared';
23
25
  import { APPLICATION_EVENT } from '../application/LegendApplicationEvent.js';
24
26
  import type { LegendApplicationConfig } from '../application/LegendApplicationConfig.js';
@@ -56,6 +58,7 @@ export class ApplicationStore<
56
58
 
57
59
  readonly config: T;
58
60
  readonly pluginManager: V;
61
+ readonly initState = ActionState.create();
59
62
 
60
63
  // core
61
64
  readonly timeService: TimeService;
@@ -132,6 +135,34 @@ export class ApplicationStore<
132
135
  this.tracerService.registerPlugins(pluginManager.getTracerServicePlugins());
133
136
  }
134
137
 
138
+ async initialize(): Promise<void> {
139
+ if (!this.initState.isInInitialState) {
140
+ this.notificationService.notifyIllegalState(
141
+ 'Application store is re-initialized',
142
+ );
143
+ return;
144
+ }
145
+ this.initState.inProgress();
146
+
147
+ try {
148
+ await Promise.all(
149
+ this.pluginManager
150
+ .getApplicationPlugins()
151
+ .flatMap((plugin) => plugin.getExtraApplicationSetups?.() ?? [])
152
+ .map((setup) => setup(this)),
153
+ );
154
+ this.initState.pass();
155
+ } catch (error) {
156
+ assertErrorThrown(error);
157
+ this.notificationService.notifyError(error);
158
+ this.logService.error(
159
+ LogEvent.create(APPLICATION_EVENT.APPLICATION_LOAD__FAILURE),
160
+ 'Failed to load Legend application',
161
+ );
162
+ this.initState.fail();
163
+ }
164
+ }
165
+
135
166
  /**
136
167
  * When we call store/state functions from the component, we should handle error thrown at these functions instead
137
168
  * of throwing them to the UI. This enforces that by throwing `IllegalStateError`
@@ -17,15 +17,15 @@
17
17
  import { action, makeObservable, observable, computed } from 'mobx';
18
18
  import type { DocumentationEntry } from './DocumentationService.js';
19
19
  import type { GenericLegendApplicationStore } from './ApplicationStore.js';
20
- import { FuzzySearchEngine } from '@finos/legend-art';
21
20
  import {
22
21
  type MarkdownText,
23
22
  guaranteeNonEmptyString,
24
23
  uuid,
25
24
  isNonNullable,
26
25
  ActionState,
26
+ FuzzySearchEngine,
27
27
  } from '@finos/legend-shared';
28
- import { TextSearchAdvancedConfigState } from './shared/TextSearchAdvancedConfigState.js';
28
+ import { FuzzySearchAdvancedConfigState } from './shared/FuzzySearchAdvancedConfigState.js';
29
29
 
30
30
  export enum VIRTUAL_ASSISTANT_TAB {
31
31
  SEARCH = 'SEARCH',
@@ -113,8 +113,8 @@ export class AssistantService {
113
113
 
114
114
  // search text
115
115
  private readonly searchEngine: FuzzySearchEngine<DocumentationEntry>;
116
- searchConfigurationState: TextSearchAdvancedConfigState;
117
- searchState = ActionState.create();
116
+ searchConfigurationState: FuzzySearchAdvancedConfigState;
117
+ readonly searchState = ActionState.create();
118
118
  searchText = '';
119
119
  searchResults: VirtualAssistantDocumentationEntry[] = [];
120
120
  showSearchConfigurationMenu = false;
@@ -178,7 +178,7 @@ export class AssistantService {
178
178
  useExtendedSearch: true,
179
179
  },
180
180
  );
181
- this.searchConfigurationState = new TextSearchAdvancedConfigState(() => {
181
+ this.searchConfigurationState = new FuzzySearchAdvancedConfigState(() => {
182
182
  this.search();
183
183
  });
184
184
  }
@@ -22,11 +22,89 @@ import {
22
22
  LEGACY_LIGHT_COLOR_THEME,
23
23
  } from '../application/LegendApplicationTheme.js';
24
24
  import type { ColorTheme } from './LayoutService.js';
25
- import { LegendApplicationPlugin } from './LegendApplicationPlugin.js';
25
+ import {
26
+ LegendApplicationPlugin,
27
+ type LegendApplicationSetup,
28
+ } from './LegendApplicationPlugin.js';
26
29
  import {
27
30
  collectSettingConfigurationEntriesFromConfig,
28
31
  type SettingConfigurationEntry,
29
32
  } from './SettingService.js';
33
+ import { configure as configureMobx } from 'mobx';
34
+ import { KeyCode, KeyMod, editor as monacoEditorAPI } from 'monaco-editor';
35
+ import { MONOSPACED_FONT_FAMILY } from '../const.js';
36
+ import { LogEvent } from '@finos/legend-shared';
37
+ import { APPLICATION_EVENT } from '../application/LegendApplicationEvent.js';
38
+ import { configureComponents } from '@finos/legend-art';
39
+ import type { GenericLegendApplicationStore } from './ApplicationStore.js';
40
+
41
+ const configureCodeEditorComponent = async (
42
+ applicationStore: GenericLegendApplicationStore,
43
+ ): Promise<void> => {
44
+ /**
45
+ * Since we use a custom fonts for text-editor, we want to make sure the font is loaded before any text-editor is opened
46
+ * this is to ensure
47
+ */
48
+ const fontLoadFailureErrorMessage = `Monospaced font '${MONOSPACED_FONT_FAMILY}' has not been loaded properly, text editor display problems might occur`;
49
+ await Promise.all(
50
+ [400, 700].map((weight) =>
51
+ document.fonts.load(`${weight} 1em ${MONOSPACED_FONT_FAMILY}`),
52
+ ),
53
+ )
54
+ .then(() => {
55
+ if (document.fonts.check(`1em ${MONOSPACED_FONT_FAMILY}`)) {
56
+ monacoEditorAPI.remeasureFonts();
57
+ applicationStore.logService.info(
58
+ LogEvent.create(APPLICATION_EVENT.LOAD_TEXT_EDITOR_FONT__SUCCESS),
59
+ `Monospaced font '${MONOSPACED_FONT_FAMILY}' has been loaded`,
60
+ );
61
+ } else {
62
+ applicationStore.logService.error(
63
+ LogEvent.create(APPLICATION_EVENT.APPLICATION_SETUP__FAILURE),
64
+ fontLoadFailureErrorMessage,
65
+ );
66
+ }
67
+ })
68
+ .catch(() =>
69
+ applicationStore.logService.error(
70
+ LogEvent.create(APPLICATION_EVENT.APPLICATION_SETUP__FAILURE),
71
+ fontLoadFailureErrorMessage,
72
+ ),
73
+ );
74
+
75
+ // override native hotkeys supported by monaco-editor
76
+ // here we map these keys to a dummy command that would just dispatch the key combination
77
+ // to the application keyboard shortcut service, effectively bypassing the command associated
78
+ // with the native keybinding
79
+ const OVERRIDE_DEFAULT_KEYBINDING_COMMAND =
80
+ 'legend.code-editor.override-default-keybinding';
81
+ monacoEditorAPI.registerCommand(
82
+ OVERRIDE_DEFAULT_KEYBINDING_COMMAND,
83
+ (accessor, ...args) => {
84
+ applicationStore.keyboardShortcutsService.dispatch(args[0]);
85
+ },
86
+ );
87
+ const hotkeyMapping: [number, string][] = [
88
+ [KeyCode.F1, 'F1'], // show command center
89
+ [KeyCode.F8, 'F8'], // show error
90
+ [KeyCode.F9, 'F9'], // toggle debugger breakpoint
91
+ [KeyMod.WinCtrl | KeyCode.KeyG, 'Control+KeyG'], // go-to line command
92
+ [KeyMod.WinCtrl | KeyCode.KeyB, 'Control+KeyB'], // cursor move (core command)
93
+ [KeyMod.WinCtrl | KeyCode.KeyO, 'Control+KeyO'], // cursor move (core command)
94
+ [KeyMod.WinCtrl | KeyCode.KeyD, 'Control+KeyD'], // cursor move (core command)
95
+ [KeyMod.WinCtrl | KeyCode.KeyP, 'Control+KeyP'], // cursor move (core command)
96
+ [KeyMod.Shift | KeyCode.F10, 'Shift+F10'], // show editor context menu
97
+ [KeyMod.WinCtrl | KeyCode.F2, 'Control+F2'], // change all instances
98
+ [KeyMod.WinCtrl | KeyCode.F12, 'Control+F12'], // go-to definition
99
+ ];
100
+ monacoEditorAPI.addKeybindingRules(
101
+ hotkeyMapping.map(([nativeCodeEditorKeyBinding, keyCombination]) => ({
102
+ keybinding: nativeCodeEditorKeyBinding,
103
+ command: OVERRIDE_DEFAULT_KEYBINDING_COMMAND,
104
+ commandArgs: keyCombination,
105
+ })),
106
+ );
107
+ };
30
108
 
31
109
  export class Core_LegendApplicationPlugin extends LegendApplicationPlugin {
32
110
  static NAME = packageJson.extensions.applicationPlugin;
@@ -41,6 +119,27 @@ export class Core_LegendApplicationPlugin extends LegendApplicationPlugin {
41
119
  pluginManager.registerApplicationPlugin(this);
42
120
  }
43
121
 
122
+ override getExtraApplicationSetups(): LegendApplicationSetup[] {
123
+ return [
124
+ async (applicationStore) => {
125
+ // configure `mobx`
126
+ configureMobx({
127
+ // Force state modification to be done via actions
128
+ // Otherwise, warning will be shown in development mode
129
+ // However, no warning will shown in production mode
130
+ // See https://mobx.js.org/configuration.html#enforceactions
131
+ enforceActions: 'observed',
132
+ });
133
+
134
+ // configure code editor
135
+ await configureCodeEditorComponent(applicationStore);
136
+
137
+ // configure UI components
138
+ configureComponents();
139
+ },
140
+ ];
141
+ }
142
+
44
143
  override getExtraColorThemes(): ColorTheme[] {
45
144
  return [LEGACY_LIGHT_COLOR_THEME, HIGH_CONTRAST_LIGHT_COLOR_THEME];
46
145
  }
@@ -24,11 +24,16 @@ import type {
24
24
  } from './DocumentationService.js';
25
25
  import type { ColorTheme } from './LayoutService.js';
26
26
  import type { SettingConfigurationEntry } from './SettingService.js';
27
+ import type { GenericLegendApplicationStore } from './ApplicationStore.js';
27
28
 
28
- export type LegendApplicationSetup = <T extends LegendApplicationPlugin>(
29
+ export type LegendApplicationBootstrap = <T extends LegendApplicationPlugin>(
29
30
  pluginManager: LegendApplicationPluginManager<T>,
30
31
  ) => Promise<void>;
31
32
 
33
+ export type LegendApplicationSetup = (
34
+ applicationStore: GenericLegendApplicationStore,
35
+ ) => Promise<void>;
36
+
32
37
  /**
33
38
  * Prefix URL patterns coming from extensions with `/extensions/`
34
39
  * to avoid potential conflicts with main routes.
@@ -43,10 +48,20 @@ export type ApplicationPageEntry = {
43
48
  };
44
49
 
45
50
  export abstract class LegendApplicationPlugin extends AbstractPlugin {
51
+ /**
52
+ * Get the list of bootstrap procedures to be run when booting up the application.
53
+ *
54
+ * NOTE: The application will call the bootstrap procedures from all extensions concurrently.
55
+ * These procedures should be idempotent and should not depend on each other.
56
+ */
57
+ getExtraApplicationBootstraps?(): LegendApplicationBootstrap[];
58
+
46
59
  /**
47
60
  * Get the list of setup procedures to be run when booting up the application.
48
61
  *
49
62
  * NOTE: The application will call the setup procedures from all extensions concurrently.
63
+ * These procedures should be idempotent and should not depend on each other.
64
+ * They will be called just before the application is rendered.
50
65
  */
51
66
  getExtraApplicationSetups?(): LegendApplicationSetup[];
52
67