@scm-js/plugin-api 1.28.0 → 1.30.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 +92 -6
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -477,10 +477,10 @@ declare const ScoreType: {
477
477
  readonly Custom: 7;
478
478
  };
479
479
  declare const UnitClass: {
480
- readonly Any: 228;
481
- readonly Men: 229;
482
- readonly Buildings: 230;
483
- readonly Factories: 231;
480
+ readonly Any: 229;
481
+ readonly Men: 230;
482
+ readonly Buildings: 231;
483
+ readonly Factories: 232;
484
484
  };
485
485
  declare const ConditionFlag: {
486
486
  /** Game bookkeeping. */
@@ -1855,11 +1855,55 @@ export interface Preferences {
1855
1855
  * is replaced by the first map opened rather than kept beside it.
1856
1856
  */
1857
1857
  multipleMaps: boolean;
1858
- /** What File ▸ New and the startup map start with. */
1858
+ /**
1859
+ * What File ▸ New and the startup map start with. `version` is the file's revision:
1860
+ * Brood War (VER 205, what every build reads) or Remastered (206, 32-bit strings).
1861
+ */
1859
1862
  newMap: {
1860
1863
  tileset: TilesetId;
1861
1864
  width: number;
1862
1865
  height: number;
1866
+ version: NewMapVersion;
1867
+ };
1868
+ /**
1869
+ * Startup: `reopenLast` opens the most recent file again in place of the blank map
1870
+ * (the desktop app straight away; a browser needs a click first, so it asks in a
1871
+ * notice), and `recents` is how many File ▸ Open Recent keeps.
1872
+ */
1873
+ startup: {
1874
+ reopenLast: boolean;
1875
+ recents: number;
1876
+ };
1877
+ /**
1878
+ * What the Save dialog starts from: the options the file was opened with
1879
+ * (`"asOpened"`, the default), or one of its presets. `compression` is for a map with
1880
+ * no origin — new, or opened from a bare .chk — where there is nothing to follow;
1881
+ * `"asOpened"` there means StarEdit's PKWARE.
1882
+ */
1883
+ save: {
1884
+ start: "asOpened" | "everything" | "smallest";
1885
+ compression: "asOpened" | ArchiveCompression;
1886
+ };
1887
+ /** How many edits Undo keeps per map (SCMDraft keeps 200). */
1888
+ undoLevels: number;
1889
+ /**
1890
+ * The mouse wheel over the map: scrolling, with Ctrl+wheel zooming (the default), or
1891
+ * zooming, with Shift+wheel scrolling sideways. `zoomToCursor` keeps the tile under the
1892
+ * pointer in place when the wheel zooms; the menu and keyboard keep the centre.
1893
+ */
1894
+ view: {
1895
+ wheel: "scroll" | "zoom";
1896
+ zoomToCursor: boolean;
1897
+ };
1898
+ /**
1899
+ * What the palettes start on: the owner of placed units and sprites (0 = player 1),
1900
+ * the brush size (1–7), and the size of a location the Locations palette's New makes,
1901
+ * in tiles.
1902
+ */
1903
+ placement: {
1904
+ owner: number;
1905
+ brushSize: number;
1906
+ locationTiles: number;
1863
1907
  };
1864
1908
  /** Initial View ▸ Animate Water / Animate Units. */
1865
1909
  animateWater: boolean;
@@ -1912,6 +1956,8 @@ export interface Preferences {
1912
1956
  }
1913
1957
  /** See `Preferences.plugins.updates`. */
1914
1958
  export type PluginUpdateMode = "notify" | "manual" | "auto";
1959
+ /** The revisions a new map can start on; the two older ones are for opening old files, not making new ones. */
1960
+ export type NewMapVersion = Extract<MapVersion, "broodwar" | "remastered">;
1915
1961
  /**
1916
1962
  * The version a host provides; a manifest that asks for a newer one is refused. It stays
1917
1963
  * at 1 while the API is only used by the plugins in the scm-js organisation and grows
@@ -3811,7 +3857,7 @@ export interface NamedValue {
3811
3857
  * the editor's own tables — the same names StarEdit shows.
3812
3858
  */
3813
3859
  export interface NamesApi {
3814
- /** StarEdit's name for a units.dat id; `Any unit` / `Men` / `Buildings` / `Factories` for the trigger classes 228–231. */
3860
+ /** StarEdit's name for a units.dat id; `Any unit` / `Men` / `Buildings` / `Factories` for the trigger classes 229–232 (228 is the game's `None`). */
3815
3861
  unit(id: number): string;
3816
3862
  units(): NamedValue[];
3817
3863
  upgrade(id: number): string;
@@ -4077,6 +4123,40 @@ export interface DialogSlotHost {
4077
4123
  export interface DialogSlotSpec {
4078
4124
  mount(body: HTMLElement, host: DialogSlotHost): void | (() => void);
4079
4125
  }
4126
+ /**
4127
+ * A page of the plugin's own in Edit ▸ Preferences, listed under Plugins by the plugin's
4128
+ * name — where a user looks for a setting, instead of a menu item per plugin. One page per
4129
+ * plugin; registering again replaces it. `mount` runs the first time the page is shown
4130
+ * while the dialog is open and the page then stays mounted until the dialog closes, so
4131
+ * what the user changed is still there when OK or Apply calls `apply`; the cleanup runs
4132
+ * on close. A page with no `apply` writes its settings as they change (`api.storage`),
4133
+ * which is the simpler shape when nothing needs undoing on Cancel.
4134
+ *
4135
+ * @example
4136
+ * api.ui.preferencesPage({
4137
+ * mount(body) {
4138
+ * const w = api.ui.widgets;
4139
+ * const dock = w.select([{ value: "float", label: "Floating" }, { value: "right", label: "Docked" }], { value: settings.dock });
4140
+ * body.append(w.form([{ label: "Panel", field: dock }]), w.hint("Where the panel opens."));
4141
+ * pending = () => save({ dock: dock.value });
4142
+ * },
4143
+ * apply: () => pending?.(),
4144
+ * });
4145
+ */
4146
+ export interface PreferencesPageSpec {
4147
+ /** Fill `body` with the page's controls; return a cleanup if you need one. */
4148
+ mount(body: HTMLElement, page: PreferencesPageHost): void | (() => void);
4149
+ /** Called on OK and Apply while the dialog is open and the page has been shown. */
4150
+ apply?(): void;
4151
+ /** Called by Reset to defaults while the page is the one showing. */
4152
+ reset?(): void;
4153
+ }
4154
+ /** What a preferences page's `mount` is handed. */
4155
+ export interface PreferencesPageHost {
4156
+ readonly plugin: PluginInfo;
4157
+ /** Close the Preferences dialog. */
4158
+ close(): void;
4159
+ }
4080
4160
  /**
4081
4161
  * What `view.flash` highlights: a tile rect, or units / locations by index. The
4082
4162
  * highlight fades over `ms` (600 by default) and never blocks or takes the pointer; it is
@@ -4286,6 +4366,12 @@ export interface UiApi {
4286
4366
  * });
4287
4367
  */
4288
4368
  dialogSlot(dialog: DialogSlotId, spec: DialogSlotSpec): Disposable;
4369
+ /**
4370
+ * A page of the plugin's own in Edit ▸ Preferences, under Plugins — see
4371
+ * `PreferencesPageSpec`. `ui.open("preferences", { page: "plugin:<id>" })` opens it.
4372
+ * Returns the registration; it leaves with `dispose()` or the plugin.
4373
+ */
4374
+ preferencesPage(spec: PreferencesPageSpec): Disposable;
4289
4375
  /**
4290
4376
  * Take over the pointer on the map until `stop()`, Esc, a right-click, a map change
4291
4377
  * or another tool. One tool runs at a time — starting one stops the previous — and a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/plugin-api",
3
- "version": "1.28.0",
3
+ "version": "1.30.0",
4
4
  "description": "Type declarations for the scmJS plugin API",
5
5
  "license": "MIT",
6
6
  "types": "index.d.ts",