You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: better docs and types for the API (nasa#7796)
* docs: fix type imports in openmct.js * docs: fix type imports * docs: fix types for eventHelpers * docs: types for TypeRegistry * docs: types for StatusAPI * docs: fix ObjectAPI types and docs * docs: more types * docs: improved types for main entry * docs: improved types * fix: unbreak the linting * chore: remove EventEmitter webpack alias as it hide types * fix: return type * fix: parameter type * fix: types for composables * chore: add webpack consts to eslintrc * fix: remove usage of deprecated timeAPI methods and add a ton of docs and types * docs: update README.md * lint: clean up API.md * chore: upgrade eventemitter to v5.0.2 * refactor: update imports for EventEmitter to remove alias * format: lint * docs: update types for Views and ViewProviders * docs: expose common types at the base import level * docs(types): remove unnecessary tsconfig options * docs: ActionAPI * docs: AnnotationAPI * docs: import common types from the same origin * docs: FormsAPI & TelemetryAPI types * docs: FormController, IndicatorAPI * docs: MenuAPI, ActionsAPI * docs: `@memberof` is not supported by `tsc` and JSDoc generation so remove it * docs: RootRegistry and RootObjectProvider * docs: Transaction + Overlay * lint: words for the word god * fix: review comments
Formats implement the following interface (provided here as TypeScript for simplicity):
693
701
694
-
695
702
Formats are registered with the Telemetry API using the `addFormat` function. eg.
696
703
697
704
```javascript
@@ -763,8 +770,8 @@ state of the application, and emits events to inform listeners when the state ch
763
770
764
771
Because the data displayed tends to be time domain data, Open MCT must always
765
772
have at least one time system installed and activated. When you download Open
766
-
MCT, it will be pre-configured to use the UTC time system, which is installed and activated,
767
-
along with other default plugins, in `index.html`. Installing and activating a time system
773
+
MCT, it will be pre-configured to use the UTC time system, which is installed and activated,
774
+
along with other default plugins, in `index.html`. Installing and activating a time system
768
775
is simple, and is covered [in the next section](#defining-and-registering-time-systems).
769
776
770
777
### Time Systems and Bounds
@@ -817,7 +824,7 @@ numbers in UTC terrestrial time.
817
824
#### Getting and Setting the Active Time System
818
825
819
826
Once registered, a time system can be activated by calling `setTimeSystem` with
820
-
the timeSystem `key` or an instance of the time system. You can also specify
827
+
the timeSystem `key` or an instance of the time system. You can also specify
821
828
valid [bounds](#time-bounds) for the timeSystem.
822
829
823
830
```javascript
@@ -841,10 +848,9 @@ Setting the active time system will trigger a [`'timeSystemChanged'`](#time-even
841
848
event. If you supplied bounds, a [`'boundsChanged'`](#time-events) event will be triggered afterwards with your newly supplied bounds.
842
849
843
850
> ⚠️ **Deprecated**
851
+
>
844
852
> - The method `timeSystem()` is deprecated. Please use `getTimeSystem()` and `setTimeSystem()` as a replacement.
845
853
846
-
847
-
848
854
#### Time Bounds
849
855
850
856
The TimeAPI provides a getter and setter for querying and setting time bounds. Time
@@ -875,15 +881,16 @@ To respond to bounds change events, listen for the [`'boundsChanged'`](#time-eve
875
881
event.
876
882
877
883
> ⚠️ **Deprecated**
884
+
>
878
885
> - The method `bounds()` is deprecated and will be removed in a future release. Please use `getBounds()` and `setBounds()` as a replacement.
879
886
880
887
### Clocks
881
888
882
-
The Time API requires a clock source which will cause the bounds to be updated
883
-
automatically whenever the clock source "ticks". A clock is simply an object that
884
-
supports registration of listeners and periodically invokes its listeners with a
885
-
number. Open MCT supports registration of new clock sources that tick on almost
886
-
anything. A tick occurs when the clock invokes callback functions registered by its
889
+
The Time API requires a clock source which will cause the bounds to be updated
890
+
automatically whenever the clock source "ticks". A clock is simply an object that
891
+
supports registration of listeners and periodically invokes its listeners with a
892
+
number. Open MCT supports registration of new clock sources that tick on almost
893
+
anything. A tick occurs when the clock invokes callback functions registered by its
887
894
listeners with a new time value.
888
895
889
896
An example of a clock source is the [LocalClock](https://github.com/nasa/openmct/blob/master/src/plugins/utcTimeSystem/LocalClock.js)
@@ -972,6 +979,7 @@ openmct.time.getClock();
972
979
```
973
980
974
981
> ⚠️ **Deprecated**
982
+
>
975
983
> - The method `clock()` is deprecated and will be removed in a future release. Please use `getClock()` and `setClock()` as a replacement.
976
984
977
985
#### ⚠️ [DEPRECATED] Stopping an active clock
@@ -986,12 +994,13 @@ openmct.time.stopClock();
986
994
```
987
995
988
996
> ⚠️ **Deprecated**
997
+
>
989
998
> - The method `stopClock()` is deprecated and will be removed in a future release.
990
999
991
1000
#### Clock Offsets
992
1001
993
-
When in Real-time [mode](#time-modes), the time bounds of the application will be updated automatically each time the
994
-
clock "ticks". The bounds are calculated based on the current value provided by
1002
+
When in Real-time [mode](#time-modes), the time bounds of the application will be updated automatically each time the
1003
+
clock "ticks". The bounds are calculated based on the current value provided by
995
1004
the active clock (via its `tick` event, or its `currentValue()` method).
996
1005
997
1006
Unlike bounds, which represent absolute time values, clock offsets represent
@@ -1026,13 +1035,14 @@ new bounds will be calculated based on the `currentValue()` of the active clock.
1026
1035
Clock offsets are only relevant when in Real-time [mode](#time-modes).
1027
1036
1028
1037
> ⚠️ **Deprecated**
1038
+
>
1029
1039
> - The method `clockOffsets()` is deprecated and will be removed in a future release. Please use `getClockOffsets()` and `setClockOffsets()` as a replacement.
1030
1040
1031
1041
### Time Modes
1032
1042
1033
-
There are two time modes in Open MCT, "Fixed" and "Real-time". In Real-time mode the
1043
+
There are two time modes in Open MCT, "Fixed" and "Real-time". In Real-time mode the
1034
1044
time bounds of the application will be updated automatically each time the clock "ticks".
1035
-
The bounds are calculated based on the current value provided by the active clock. In
1045
+
The bounds are calculated based on the current value provided by the active clock. In
1036
1046
Fixed mode, the time bounds are set for a specified time range. When Open MCT is first
1037
1047
initialized, it will be in Real-time mode.
1038
1048
@@ -1120,6 +1130,7 @@ The events emitted by the Time API are:
1120
1130
- `mode`: A string representation of the current time mode, either `'realtime'` or `'fixed'`.
1121
1131
1122
1132
> ⚠️ **Deprecated Events** (These will be removed in a future release):
1133
+
>
1123
1134
> - `bounds` → `boundsChanged`
1124
1135
> - `timeSystem` → `timeSystemChanged`
1125
1136
> - `clock` → `clockChanged`
@@ -1262,7 +1273,7 @@ Returns the currently set text as a `string`.
may be used here, or a custom CSS class can be provided. Returns the currently defined CSS
1264
1275
class as a `string`.
1265
-
- `.statusClass([className])`: Gets or sets the CSS class used to determine status. Accepts an __optional__
1276
+
- `.statusClass([className])`: Gets or sets the CSS class used to determine status. Accepts an **optional**
1266
1277
`string` parameter to be used to set a status class applied to the indicator. May be used to apply
1267
1278
different colors to indicate status.
1268
1279
@@ -1312,7 +1323,7 @@ can be used to manage user information and roles.
1312
1323
1313
1324
### Example
1314
1325
1315
-
Open MCT provides an example [user](example/exampleUser/exampleUserCreator.js) and [user provider](example/exampleUser/ExampleUserProvider.js) which
1326
+
Open MCT provides an example [user](example/exampleUser/exampleUserCreator.js) and [user provider](example/exampleUser/ExampleUserProvider.js) which
1316
1327
can be used as a starting point for creating a custom user provider.
1317
1328
1318
1329
## Visibility-Based Rendering in View Providers
@@ -1335,10 +1346,10 @@ Here’s the signature for the show function:
1335
1346
1336
1347
`show(element, isEditing, viewOptions)`
1337
1348
1338
-
*`element` (HTMLElement) - The DOM element where the view should be rendered.
1339
-
*`isEditing` (boolean) - Indicates whether the view is in editing mode.
1340
-
*`viewOptions` (Object) - An object with configuration options for the view, including:
1341
-
*`renderWhenVisible` (Function) - This function wraps the `requestAnimationFrame` and only triggers the provided render logic when the view is visible in the viewport.
1349
+
-`element` (HTMLElement) - The DOM element where the view should be rendered.
1350
+
-`isEditing` (boolean) - Indicates whether the view is in editing mode.
1351
+
-`viewOptions` (Object) - An object with configuration options for the view, including:
1352
+
-`renderWhenVisible` (Function) - This function wraps the `requestAnimationFrame` and only triggers the provided render logic when the view is visible in the viewport.
1342
1353
1343
1354
### Example
1344
1355
@@ -1367,8 +1378,6 @@ const myViewProvider = {
1367
1378
};
1368
1379
```
1369
1380
1370
-
1371
1381
Note that `renderWhenVisible` defers rendering while the view is not visible and caters to the latest execution call. This provides responsiveness for dynamic content while ensuring performance optimizations.
1372
1382
1373
1383
Ensure your view logic is prepared to handle potentially multiple deferrals if using this API, as only the last call to renderWhenVisible will be queued for execution upon the view becoming visible.
0 commit comments