@scm-js/plugin-api 1.47.0 → 1.48.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 (2) hide show
  1. package/index.d.ts +44 -0
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -5029,6 +5029,39 @@ export interface FileTypeSpec {
5029
5029
  extensions: string[];
5030
5030
  open(files: File[]): void | Promise<void>;
5031
5031
  }
5032
+ /**
5033
+ * Another way to look at a map, shown where the map is drawn (`ui.mapView`): a replay's
5034
+ * game played out, a 3D view, a picture of something else entirely. The editor gives the
5035
+ * view one element for its whole life and never moves it — an iframe in it is not loaded
5036
+ * again when the view is hidden and shown — and lays it over the map, rulers and all.
5037
+ */
5038
+ export interface MapViewSpec {
5039
+ /** What the switch over the map calls it ("Game"). The map itself is "Map". */
5040
+ title: string;
5041
+ /**
5042
+ * Called once, with the element the view lives in. Fill it as you like; it is as large as
5043
+ * the map's area and in the page from the first time the view is shown. Return a function
5044
+ * to be called when the view goes (the plugin stops, or `dispose`).
5045
+ */
5046
+ mount(element: HTMLElement): void | (() => void);
5047
+ }
5048
+ export interface MapViewHandle extends Disposable {
5049
+ /**
5050
+ * Offer the view on a map (by `OpenDocumentInfo.id`; the one in front when left out), or
5051
+ * stop offering it there. A map that offers views has a switch over it, the map's own
5052
+ * view first. Nothing is offered until you say so.
5053
+ */
5054
+ offer(on: boolean, documentId?: number): void;
5055
+ /** Show the view in that map's place (offering it there if it was not), or the map again. */
5056
+ show(on: boolean, documentId?: number): void;
5057
+ /** Whether the view is what the map in front shows now. */
5058
+ isShown(): boolean;
5059
+ /**
5060
+ * Whether the view is shown changed for the map in front: the person used the switch,
5061
+ * `show` was called, or another map came to the front.
5062
+ */
5063
+ onChange(listener: (shown: boolean) => void): Disposable;
5064
+ }
5032
5065
  export interface PanelHandle {
5033
5066
  close(): void;
5034
5067
  isOpen(): boolean;
@@ -5409,6 +5442,17 @@ export interface UiApi {
5409
5442
  * api.ui.fileType({ name: "StarCraft replay", extensions: [".rep"], open: (files) => loadReplays(files) });
5410
5443
  */
5411
5444
  fileType(spec: FileTypeSpec): Disposable;
5445
+ /**
5446
+ * Another way to look at the maps you choose, in the map's place, with a switch over the
5447
+ * map between it and the map itself (see `MapViewSpec`). A map shows one view at a time;
5448
+ * each map keeps the one it was left on. Ends with the plugin, or with `dispose`.
5449
+ *
5450
+ * @example
5451
+ * const game = api.ui.mapView({ title: "Game", mount: (el) => { el.append(frame); } });
5452
+ * // A map just opened is the one in front.
5453
+ * if (await api.document.open(map, "replay.scx", { viewOnly: { label: "Replay" } })) game.show(true);
5454
+ */
5455
+ mapView(spec: MapViewSpec): MapViewHandle;
5412
5456
  /**
5413
5457
  * A cell of your own in the status bar. One line of text beside the plugin's icon, a
5414
5458
  * spinner while `busy`, a click. Keep the handle and `set` it as things move; it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/plugin-api",
3
- "version": "1.47.0",
3
+ "version": "1.48.0",
4
4
  "description": "Type declarations for the scmJS plugin API",
5
5
  "license": "MIT",
6
6
  "types": "index.d.ts",