@scm-js/plugin-api 1.46.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 +81 -7
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -38,9 +38,9 @@ export type CombineMode =
38
38
  "overlay"
39
39
  /** Every occurrence's records are kept, in file order. */
40
40
  | "append"
41
- /** Only the last occurrence is used. */
41
+ /** Only the last occurrence is used — of those at least the section's minimum length. */
42
42
  | "last"
43
- /** Only the first occurrence is used. */
43
+ /** Only the first occurrence is used — of those at least the section's minimum length. */
44
44
  | "first";
45
45
  /**
46
46
  * The byte encodings a map's text can be in, and how to tell which one a file used.
@@ -1466,6 +1466,8 @@ export interface SectionKnowledge {
1466
1466
  size: number | null;
1467
1467
  /** The record length of a list section, or null. */
1468
1468
  stride: number | null;
1469
+ /** The shortest copy the game takes, for a "last" or "first" section; shorter ones are passed over. Null when any length is taken. */
1470
+ minimum: number | null;
1469
1471
  /** Whether the editor decodes the section into its model and re-encodes it on save. */
1470
1472
  modelled: boolean;
1471
1473
  }
@@ -4982,7 +4984,11 @@ export interface PanelSpec {
4982
4984
  title: string;
4983
4985
  /** In CSS pixels; 260 by default. The panel is as tall as its content, up to the map's height. Ignored when docked. */
4984
4986
  width?: number;
4985
- /** Floating only: a height in CSS pixels instead of the content's own; the body then scrolls, or fills, as its content asks. */
4987
+ /**
4988
+ * Floating: a height in CSS pixels instead of the content's own; the body then scrolls, or
4989
+ * fills, as its content asks. Bottom dock: the strip's starting height (160 by default),
4990
+ * which the user can then drag.
4991
+ */
4986
4992
  height?: number;
4987
4993
  /**
4988
4994
  * Floating only: a grip at the bottom-right corner lets the user resize the panel, and
@@ -4997,9 +5003,11 @@ export interface PanelSpec {
4997
5003
  * and Properties, with the same head and hide button the built-in panels have — the
4998
5004
  * choice for anything the user keeps open while working, such as an assistant or a
4999
5005
  * readout. A docked panel shows the dock even when the user has hidden every built-in
5000
- * panel in it.
5006
+ * panel in it. `"bottom"` puts it in a strip under the map, as wide as the map, which
5007
+ * the user makes taller or shorter by dragging its top edge — the place for a timeline,
5008
+ * a console or anything read along the width of the map. Several bottom panels stack.
5001
5009
  */
5002
- dock?: "float" | "right";
5010
+ dock?: "float" | "right" | "bottom";
5003
5011
  /** A docked panel that takes the dock's spare height (a transcript, a long list); off by default. */
5004
5012
  grow?: boolean;
5005
5013
  /** Floating only: the body runs edge to edge, without the panel's padding — for content that draws its own frame. */
@@ -5009,6 +5017,51 @@ export interface PanelSpec {
5009
5017
  /** The panel closed, whichever way. */
5010
5018
  onClose?: () => void;
5011
5019
  }
5020
+ /**
5021
+ * A kind of file a plugin opens (`ui.fileType`): replays, a mod's own data. A file whose
5022
+ * name ends in one of `extensions`, dropped on the editor or picked in File ▸ Open, goes
5023
+ * to `open` instead of being read as a map. Several dropped at once arrive together.
5024
+ */
5025
+ export interface FileTypeSpec {
5026
+ /** What the files are, for File ▸ Open's list of types ("StarCraft replay"). */
5027
+ name: string;
5028
+ /** With the dot, any case: `[".rep"]`. */
5029
+ extensions: string[];
5030
+ open(files: File[]): void | Promise<void>;
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
+ }
5012
5065
  export interface PanelHandle {
5013
5066
  close(): void;
5014
5067
  isOpen(): boolean;
@@ -5375,10 +5428,31 @@ export interface UiApi {
5375
5428
  } | null>;
5376
5429
  dialog(spec: DialogSpec): DialogHandle;
5377
5430
  /**
5378
- * Open a panel: floating over the map, or docked at the right with the built-in panels
5379
- * (`spec.dock`). As many as you like; each closes with the plugin.
5431
+ * Open a panel: floating over the map, docked at the right with the built-in panels, or
5432
+ * in the strip under the map (`spec.dock`). As many as you like; each closes with the plugin.
5380
5433
  */
5381
5434
  panel(spec: PanelSpec): PanelHandle;
5435
+ /**
5436
+ * Claim a kind of file: dropped on the editor or picked in File ▸ Open, a file with one of
5437
+ * `spec.extensions` is handed to `spec.open` instead of being opened as a map. A plugin
5438
+ * that claims what another already has is not given it (the first stays); none can claim
5439
+ * the editor's own `.scm`, `.scx` or `.chk`. Ends with the plugin, or with `dispose`.
5440
+ *
5441
+ * @example
5442
+ * api.ui.fileType({ name: "StarCraft replay", extensions: [".rep"], open: (files) => loadReplays(files) });
5443
+ */
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;
5382
5456
  /**
5383
5457
  * A cell of your own in the status bar. One line of text beside the plugin's icon, a
5384
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.46.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",