@yamcs/opi 1.4.2 → 1.4.4

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.
@@ -4,8 +4,14 @@ export interface DialogHandler {
4
4
  openWarningDialog(title: string, message: string): void;
5
5
  openErrorDialog(title: string, message: string): void;
6
6
  openPasswordDialog(title: string, message: string, password: string): boolean;
7
+ openConfirmDialogAsync?(title: string, message: string): Promise<boolean>;
8
+ openPasswordDialogAsync?(title: string, message: string, password: string): Promise<boolean>;
7
9
  }
10
+ export declare function confirmAsync(dialogHandler: DialogHandler, title: string, message: string): Promise<boolean>;
11
+ export declare function passwordAsync(dialogHandler: DialogHandler, title: string, message: string, password: string): Promise<boolean>;
8
12
  export declare class DefaultDialogHandler implements DialogHandler {
13
+ openConfirmDialogAsync(title: string, message: string): Promise<boolean>;
14
+ openPasswordDialogAsync(title: string, message: string, password: string): Promise<boolean>;
9
15
  openConfirmDialog(title: string, message: string): boolean;
10
16
  openInformationDialog(title: string, message: string): void;
11
17
  openWarningDialog(title: string, message: string): void;
@@ -78,6 +78,7 @@ export declare class Display {
78
78
  private imageLoader;
79
79
  private consoleHandler;
80
80
  private dialogHandler;
81
+ private pendingTask?;
81
82
  formatter: Formatter;
82
83
  private repaintRequested;
83
84
  private _editMode;
@@ -127,6 +128,14 @@ export declare class Display {
127
128
  getConsoleHandler(): ConsoleHandler;
128
129
  setDialogHandler(dialogHandler: DialogHandler): void;
129
130
  getDialogHandler(): DialogHandler;
131
+ /**
132
+ * Runs a user-triggered task (an action, a confirmed write). A task may
133
+ * wait on a non-blocking dialog by returning a promise. Tasks run in
134
+ * order: while one is waiting, later tasks wait too, as they would behind
135
+ * a blocking dialog. Without a waiting task, a task runs immediately.
136
+ */
137
+ runSequenced(task: () => void | Promise<void>): void;
138
+ private trackTask;
130
139
  setFontResolver(fontResolver: FontResolver): void;
131
140
  getFontResolver(): FontResolver | undefined;
132
141
  private step;
@@ -137,7 +146,7 @@ export declare class Display {
137
146
  */
138
147
  requestRepaint(): void;
139
148
  setTooltip(tooltip: string | undefined): void;
140
- createWidget(kind: string, parent: AbstractContainerWidget): ActionButton | Arc | ArrayWidget | BooleanButton | BooleanSwitch | ByteMonitor | CheckBox | ChoiceButton | Combo | Ellipse | Gauge | GridLayout | GroupingContainer | ImageBooleanButton | ImageBooleanIndicator | ImageWidget | IntensityGraph | Knob | LED | Label | LinkingContainer | MenuButton | Meter | Polygon | Polyline | ProgressBar | RadioBox | Rectangle | RoundedRectangle | SashContainer | ScaledSlider | Scrollbar | Spinner | TabbedContainer | Table | Tank | TextInput | TextUpdate | Thermometer | ThumbWheel | WebBrowser | XYGraph | undefined;
149
+ createWidget(kind: string, parent: AbstractContainerWidget): ArrayWidget | ActionButton | Arc | BooleanButton | BooleanSwitch | ByteMonitor | CheckBox | ChoiceButton | Combo | Ellipse | Gauge | GridLayout | GroupingContainer | ImageWidget | ImageBooleanButton | ImageBooleanIndicator | IntensityGraph | Knob | Label | LED | LinkingContainer | MenuButton | Meter | Polygon | Polyline | ProgressBar | RadioBox | Rectangle | RoundedRectangle | SashContainer | ScaledSlider | Scrollbar | Spinner | TabbedContainer | Table | Tank | TextInput | TextUpdate | Thermometer | ThumbWheel | WebBrowser | XYGraph | undefined;
141
150
  /**
142
151
  * Releases everything this Display holds outside of its own instance:
143
152
  * the repaint loop, the resize observer, canvas/document event
@@ -147,7 +156,21 @@ export declare class Display {
147
156
  * calls on a Display that keeps running.
148
157
  */
149
158
  destroy(): void;
159
+ /**
160
+ * Resolves a path as written in an OPI file. Relative paths are resolved
161
+ * against the OPI file that defines the widget (which may be a linked OPI
162
+ * in another folder), the same as Yamcs Studio.
163
+ *
164
+ * The result is an absolute URL, so it keeps its meaning when passed on
165
+ * (for example to a loader or to the host application).
166
+ */
150
167
  resolvePath(path: string, widget?: Widget): string;
168
+ /**
169
+ * Expresses a resolved URL as a path from the display root (absPrefix),
170
+ * for example "/folder/display.opi". Returns undefined if the URL is not
171
+ * located under the display root.
172
+ */
173
+ toRootPath(url: string): string | undefined;
151
174
  setSource(href: string, args?: {
152
175
  [key: string]: string;
153
176
  }): Promise<void>;
@@ -0,0 +1,15 @@
1
+ import { DefaultDialogHandler } from "./DialogHandler";
2
+ /**
3
+ * Shows non-blocking dialogs in the outer application, via postMessage.
4
+ *
5
+ * Blocking dialogs remain native browser dialogs (inherited), because only
6
+ * those can block the calling script.
7
+ */
8
+ export declare class PostMessageDialogHandler extends DefaultDialogHandler {
9
+ private nextId;
10
+ private pending;
11
+ openConfirmDialogAsync(title: string, message: string): Promise<boolean>;
12
+ openPasswordDialogAsync(title: string, message: string, password: string): Promise<boolean>;
13
+ receiveResult(id: number, result: boolean): void;
14
+ private request;
15
+ }
@@ -5,7 +5,7 @@ export declare abstract class Action {
5
5
  properties: PropertySet;
6
6
  constructor();
7
7
  parseNode(node: XMLNode): void;
8
- abstract execute(widget: Widget): void;
8
+ abstract execute(widget: Widget): void | Promise<void>;
9
9
  get description(): string;
10
10
  getDescription(): string;
11
11
  getDefaultDescription(): string;
@@ -2,7 +2,8 @@ import { Widget } from "../Widget";
2
2
  import { Action } from "./Action";
3
3
  export declare class RunCommandAction extends Action {
4
4
  constructor();
5
- execute(widget: Widget): void;
5
+ execute(widget: Widget): Promise<void> | undefined;
6
+ private run;
6
7
  get command(): string;
7
8
  get args(): {
8
9
  [key: string]: string;
@@ -2,7 +2,8 @@ import { Widget } from "../Widget";
2
2
  import { Action } from "./Action";
3
3
  export declare class RunProcedureAction extends Action {
4
4
  constructor();
5
- execute(widget: Widget): void;
5
+ execute(widget: Widget): Promise<void> | undefined;
6
+ private run;
6
7
  get procedure(): string;
7
8
  get args(): {
8
9
  [key: string]: string;
@@ -2,7 +2,8 @@ import { Widget } from "../Widget";
2
2
  import { Action } from "./Action";
3
3
  export declare class RunStackAction extends Action {
4
4
  constructor();
5
- execute(widget: Widget): void;
5
+ execute(widget: Widget): Promise<void> | undefined;
6
+ private run;
6
7
  get path(): string;
7
8
  get confirmMessage(): string;
8
9
  getDefaultDescription(): string;
@@ -2,7 +2,8 @@ import { Widget } from "../Widget";
2
2
  import { Action } from "./Action";
3
3
  export declare class WritePVAction extends Action {
4
4
  constructor();
5
- execute(widget: Widget): void;
5
+ execute(widget: Widget): Promise<void> | undefined;
6
+ private run;
6
7
  get pvName(): string;
7
8
  get value(): string;
8
9
  get timeout(): number;
@@ -4,7 +4,7 @@ export declare class ActionSet {
4
4
  hookFirstActionToClick: boolean;
5
5
  hookAllActionsToClick: boolean;
6
6
  add(action: Action | null): void;
7
- isClickable(): 0 | boolean;
7
+ isClickable(): boolean | 0;
8
8
  getAction(index: number): Action | null | undefined;
9
9
  toString(): string;
10
10
  }
@@ -21,6 +21,7 @@ export interface SelectionEvent extends OPIEvent {
21
21
  */
22
22
  export interface OpenDisplayEvent extends OPIEvent {
23
23
  path: string;
24
+ absolutePath?: string;
24
25
  replace: boolean;
25
26
  args?: {
26
27
  [key: string]: string;
@@ -51,6 +52,7 @@ export interface RunCommandEvent extends OPIEvent {
51
52
  */
52
53
  export interface RunStackEvent extends OPIEvent {
53
54
  path: string;
55
+ absolutePath?: string;
54
56
  }
55
57
  /**
56
58
  * A script or a button requested to run a procedure.
@@ -7,6 +7,7 @@ export { FontResolver } from "./FontResolver";
7
7
  export { DefaultImageLoader, ImageLoader } from "./ImageLoader";
8
8
  export { DefaultPathResolver, PathResolver } from "./PathResolver";
9
9
  export { Dimension, NullablePoint, Point } from "./positioning";
10
+ export { PostMessageDialogHandler } from "./PostMessageDialogHandler";
10
11
  export { PostMessageImageLoader } from "./PostMessageImageLoader";
11
12
  export { PostMessageScriptLoader } from "./PostMessageScriptLoader";
12
13
  export { CompiledFormula, DataSourceStatus, } from "./pv/formulas/CompiledFormula";
@@ -4,7 +4,7 @@ import { Sample } from "./Sample";
4
4
  export type LocalPVType = "VDouble" | "VDoubleArray" | "VString" | "VStringArray";
5
5
  export declare class LocalPV extends PV {
6
6
  type?: LocalPVType | undefined;
7
- readonly initializer?: any;
8
- constructor(name: string, pvEngine: PVEngine, type?: LocalPVType | undefined, initializer?: any);
7
+ readonly initializer?: any | undefined;
8
+ constructor(name: string, pvEngine: PVEngine, type?: LocalPVType | undefined, initializer?: any | undefined);
9
9
  setSample(sample: Sample): void;
10
10
  }
@@ -1,11 +1,11 @@
1
+ declare const peg$allowedStartRules: string[];
1
2
  declare class peg$SyntaxError extends SyntaxError {
3
+ static buildMessage(expected: any, found: any): string;
4
+ constructor(message: any, expected: any, found: any, location: any);
2
5
  expected: any;
3
6
  found: any;
4
7
  location: any;
5
- constructor(message: any, expected: any, found: any, location: any);
6
8
  format(sources: any): string;
7
- static buildMessage(expected: any, found: any): string;
8
9
  }
9
10
  declare function peg$parse(input: any, options: any): any;
10
- declare const peg$allowedStartRules: string[];
11
11
  export { peg$allowedStartRules as StartRules, peg$SyntaxError as SyntaxError, peg$parse as parse };
@@ -1,6 +1,11 @@
1
1
  import { Display } from "../Display";
2
+ import { ScriptEngine } from "./ScriptEngine";
3
+ import { WidgetWrapper } from "./WidgetWrapper";
2
4
  export declare class FileUtil {
3
5
  private display;
4
- constructor(display: Display);
5
- readTextFile(filePath: string): string;
6
+ private scriptEngine;
7
+ constructor(display: Display, scriptEngine: ScriptEngine);
8
+ readTextFile(filePath: string, widget?: WidgetWrapper | null): string;
9
+ readTextFileAsync(filePath: string, widget: WidgetWrapper | null | undefined, onSuccess: (text: string) => void, onError?: (message: string) => void): void;
10
+ private fail;
6
11
  }
@@ -1,11 +1,15 @@
1
1
  import { Display } from "../Display";
2
+ import { ScriptEngine } from "./ScriptEngine";
2
3
  export declare class GUIUtil {
3
4
  private display;
4
- constructor(display: Display);
5
+ private scriptEngine;
6
+ constructor(display: Display, scriptEngine: ScriptEngine);
5
7
  fullScreen(): void;
6
8
  openConfirmDialog(message: string): boolean;
9
+ openConfirmDialogAsync(message: string, onResult: (confirmed: boolean) => void): void;
7
10
  openInformationDialog(message: string): void;
8
11
  openWarningDialog(message: string): void;
9
12
  openErrorDialog(message: string): void;
10
13
  openPasswordDialog(message: string, password: string): boolean;
14
+ openPasswordDialogAsync(message: string, password: string, onResult: (correct: boolean) => void): void;
11
15
  }
@@ -18,7 +18,7 @@ export declare function createJavaBridge(scriptEngine: ScriptEngine): {
18
18
  }) => void;
19
19
  Thread: {
20
20
  (runnable: any): void;
21
- sleep: (delay: number) => void;
21
+ sleep(delay: number): void;
22
22
  };
23
23
  };
24
24
  util: {
@@ -16,7 +16,7 @@ export declare class PVUtil {
16
16
  getStringArray(pv: PVWrapper): string[];
17
17
  getTimeInMilliseconds(pv: PVWrapper): number;
18
18
  getTimeString(pv: PVWrapper, format?: string): string | null;
19
- getSeverity(pv: PVWrapper): -1 | 0 | 1 | 2;
19
+ getSeverity(pv: PVWrapper): 1 | 2 | 0 | -1;
20
20
  getSeverityString(pv: PVWrapper): string;
21
21
  getStatus(pv: PVWrapper): string;
22
22
  getUnits(pv: PVWrapper): string | null;
@@ -1,7 +1,8 @@
1
1
  import { Display } from "../Display";
2
+ import { WidgetWrapper } from "./WidgetWrapper";
2
3
  export declare class ScriptUtil {
3
4
  private display;
4
5
  constructor(display: Display);
5
- openOPI(widget: any, path: string, target: number, macrosInput: any): void;
6
+ openOPI(widget: WidgetWrapper | null, path: string, target: number, macrosInput: any): void;
6
7
  closeCurrentOPI(): void;
7
8
  }
@@ -11,6 +11,7 @@ export declare class BooleanButton extends Widget {
11
11
  constructor(display: Display, parent: AbstractContainerWidget);
12
12
  init(): void;
13
13
  private openConfirmDialog;
14
+ private confirmThen;
14
15
  private toggleOn;
15
16
  private toggleOff;
16
17
  get booleanValue(): boolean;
@@ -9,6 +9,7 @@ export declare class BooleanSwitch extends Widget {
9
9
  constructor(display: Display, parent: AbstractContainerWidget);
10
10
  init(): void;
11
11
  private openConfirmDialog;
12
+ private confirmThen;
12
13
  private toggleOn;
13
14
  private toggleOff;
14
15
  get booleanValue(): boolean;
@@ -13,6 +13,7 @@ export declare class ImageBooleanButton extends Widget {
13
13
  constructor(display: Display, parent: AbstractContainerWidget);
14
14
  init(): void;
15
15
  private openConfirmDialog;
16
+ private confirmThen;
16
17
  private toggleOn;
17
18
  private toggleOff;
18
19
  get booleanValue(): boolean;
@@ -7,11 +7,18 @@ export declare class TextInput extends Widget {
7
7
  private areaRegion?;
8
8
  private inputEl?;
9
9
  private editing;
10
+ private confirming;
10
11
  private scratchCanvas?;
11
12
  private scratchCtx?;
12
13
  constructor(display: Display, parent: AbstractContainerWidget);
13
14
  init(): void;
14
15
  private clampToLimits;
16
+ /**
17
+ * Used when the PV has no value, or a string value. The text is written
18
+ * as-is, except when it is a decimal number outside of the configured
19
+ * limits. Then the nearest limit is written instead.
20
+ */
21
+ private coerceText;
15
22
  private finishEditing;
16
23
  private cancelInput;
17
24
  private computeDisplayText;
@@ -7,8 +7,10 @@ import { AbstractContainerWidget } from "../others/AbstractContainerWidget";
7
7
  export declare class Polygon extends Widget {
8
8
  private zeroDegreePoints;
9
9
  private originPoints?;
10
+ private updatingPoints;
10
11
  constructor(display: Display, parent: AbstractContainerWidget);
11
12
  init(): void;
13
+ private setPointsInternal;
12
14
  private updateZeroDegreePoints;
13
15
  /**
14
16
  * Mirrors AbstractPolyModel#doScale() in the Java reference, which is a
@@ -6,8 +6,10 @@ import { AbstractContainerWidget } from "../others/AbstractContainerWidget";
6
6
  export declare class Polyline extends Widget {
7
7
  private zeroDegreePoints;
8
8
  private originPoints?;
9
+ private updatingPoints;
9
10
  constructor(display: Display, parent: AbstractContainerWidget);
10
11
  init(): void;
12
+ private setPointsInternal;
11
13
  private updateZeroDegreePoints;
12
14
  /**
13
15
  * Mirrors AbstractPolyModel#doScale() in the Java reference, which is a
@@ -27,6 +29,10 @@ export declare class Polyline extends Widget {
27
29
  * makes a keep_wh_ratio polyline barely move at all under
28
30
  * non-uniform scaling, clustering near its design position instead
29
31
  * of tracking the layout.
32
+ *
33
+ * originPoints must be latched *before* the base autoScale call below:
34
+ * that call writes x/y, which synchronously fires the x/y listeners
35
+ * above and translates PROP_POINTS as a side effect.
30
36
  */
31
37
  autoScale(widthRatio: number, heightRatio: number): void;
32
38
  draw(g: Graphics): void;
@@ -26,6 +26,16 @@ export declare class LinearScale {
26
26
  timeFormat: number;
27
27
  length: number;
28
28
  margin: number;
29
+ /**
30
+ * If true, the range is shifted by less than one pixel, such that a value
31
+ * keeps the same sub-pixel offset when the range scrolls. This avoids
32
+ * anti-aliasing flicker of scrolling plots.
33
+ */
34
+ snapToPixels: boolean;
35
+ /**
36
+ * Device pixels per coordinate unit, used by snapToPixels.
37
+ */
38
+ pixelRatio: number;
29
39
  constructor(formatter: Formatter, scale: number, scaleFont: Font, minimum: number, maximum: number, logScale: boolean, majorTickStepHint: number, foregroundColor: Color, showMinorTicks: boolean, showScale: boolean);
30
40
  get scaleLength(): number;
31
41
  /** Only available post-draw */
@@ -39,6 +49,7 @@ export declare class LinearScale {
39
49
  * getValuePosition to work.
40
50
  */
41
51
  setDimensions(x: number, y: number, length: number, horizontal: boolean): void;
52
+ private snapRange;
42
53
  getValuePosition(value: number): number;
43
54
  getMinMax(): Range;
44
55
  getPositionValue(absolutePosition: number): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamcs/opi",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "OPI Display Renderer",
5
5
  "author": "Yamcs Team <yamcs@spaceapplications.com>",
6
6
  "repository": {