@scm-js/plugin-api 1.45.0 → 1.47.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.
- package/index.d.ts +59 -8
- 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
|
}
|
|
@@ -2565,6 +2567,8 @@ export interface DocumentInfo {
|
|
|
2565
2567
|
version: number;
|
|
2566
2568
|
fileName: string | null;
|
|
2567
2569
|
modified: boolean;
|
|
2570
|
+
/** Open to look at only (`OpenDocumentOptions.viewOnly`): every write throws and it is never saved. */
|
|
2571
|
+
viewOnly: boolean;
|
|
2568
2572
|
}
|
|
2569
2573
|
/** What one `document.edit` changed, per list. */
|
|
2570
2574
|
export interface EditResult {
|
|
@@ -2741,6 +2745,20 @@ export interface ResizeDocumentOptions {
|
|
|
2741
2745
|
export type OpenInto = "new" | "current";
|
|
2742
2746
|
export interface OpenDocumentOptions {
|
|
2743
2747
|
into?: OpenInto;
|
|
2748
|
+
/**
|
|
2749
|
+
* Open the map to look at, not to change — a replay's map, a preview. It always opens
|
|
2750
|
+
* beside the open map (`into` is ignored), so nothing is replaced and nothing is asked.
|
|
2751
|
+
* Panning, zooming, the layers and selecting work; every tool, menu and dialog that
|
|
2752
|
+
* would change it is off, and every write throws — `edit`, `update`, `sections` (except
|
|
2753
|
+
* `replaceFile(…, { asOpened: true })`, a reading of the file rather than an edit), `resize`,
|
|
2754
|
+
* `changeTileset`, `extras`, the clipboard's `cut` and `paste`, `save` and `saveAs` unless
|
|
2755
|
+
* as a copy, `sync.start`. It is never kept in Open Recent, and closing it asks nothing. File ▸ Edit a Copy
|
|
2756
|
+
* opens an ordinary copy. `label` is what the tab and the status bar call it ("Replay");
|
|
2757
|
+
* `true` is the plain "View only".
|
|
2758
|
+
*/
|
|
2759
|
+
viewOnly?: boolean | {
|
|
2760
|
+
label?: string;
|
|
2761
|
+
};
|
|
2744
2762
|
}
|
|
2745
2763
|
/** One open map, as `document.list()` reports it. `active` marks the one in front — the one every other call reads and writes. */
|
|
2746
2764
|
export interface OpenDocumentInfo {
|
|
@@ -2754,6 +2772,8 @@ export interface OpenDocumentInfo {
|
|
|
2754
2772
|
height: number;
|
|
2755
2773
|
modified: boolean;
|
|
2756
2774
|
active: boolean;
|
|
2775
|
+
/** Open to look at only; see `OpenDocumentOptions.viewOnly`. */
|
|
2776
|
+
viewOnly: boolean;
|
|
2757
2777
|
}
|
|
2758
2778
|
/** File ▸ New's form: size, tileset, and the two strings the dialog asks for. */
|
|
2759
2779
|
export interface NewDocumentOptions {
|
|
@@ -2869,11 +2889,14 @@ export interface DocumentApi {
|
|
|
2869
2889
|
* In place of a map with unsaved changes, when Preferences say to ask, the Close
|
|
2870
2890
|
* Scenario dialog comes first and the user may cancel. Resolves true once the file is
|
|
2871
2891
|
* the map in front, false when the user kept the current map or the file could not be
|
|
2872
|
-
* read (the status bar says why).
|
|
2892
|
+
* read (the status bar says why). `options.viewOnly` opens it to look at only.
|
|
2873
2893
|
*
|
|
2874
2894
|
* @example
|
|
2875
2895
|
* const [file] = await api.ui.pickFiles({ accept: ".scx,.scm,.chk" });
|
|
2876
2896
|
* if (file) await api.document.open(file, file.name, { into: "new" });
|
|
2897
|
+
* @example
|
|
2898
|
+
* // A replay's map, to draw over and not to change.
|
|
2899
|
+
* await api.document.open(chk, "Lost Temple.scx", { viewOnly: { label: "Replay" } });
|
|
2877
2900
|
*/
|
|
2878
2901
|
open(file: File | Blob | Uint8Array, fileName?: string, options?: OpenDocumentOptions): Promise<boolean>;
|
|
2879
2902
|
/**
|
|
@@ -4961,7 +4984,11 @@ export interface PanelSpec {
|
|
|
4961
4984
|
title: string;
|
|
4962
4985
|
/** In CSS pixels; 260 by default. The panel is as tall as its content, up to the map's height. Ignored when docked. */
|
|
4963
4986
|
width?: number;
|
|
4964
|
-
/**
|
|
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
|
+
*/
|
|
4965
4992
|
height?: number;
|
|
4966
4993
|
/**
|
|
4967
4994
|
* Floating only: a grip at the bottom-right corner lets the user resize the panel, and
|
|
@@ -4976,9 +5003,11 @@ export interface PanelSpec {
|
|
|
4976
5003
|
* and Properties, with the same head and hide button the built-in panels have — the
|
|
4977
5004
|
* choice for anything the user keeps open while working, such as an assistant or a
|
|
4978
5005
|
* readout. A docked panel shows the dock even when the user has hidden every built-in
|
|
4979
|
-
* 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.
|
|
4980
5009
|
*/
|
|
4981
|
-
dock?: "float" | "right";
|
|
5010
|
+
dock?: "float" | "right" | "bottom";
|
|
4982
5011
|
/** A docked panel that takes the dock's spare height (a transcript, a long list); off by default. */
|
|
4983
5012
|
grow?: boolean;
|
|
4984
5013
|
/** Floating only: the body runs edge to edge, without the panel's padding — for content that draws its own frame. */
|
|
@@ -4988,6 +5017,18 @@ export interface PanelSpec {
|
|
|
4988
5017
|
/** The panel closed, whichever way. */
|
|
4989
5018
|
onClose?: () => void;
|
|
4990
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
|
+
}
|
|
4991
5032
|
export interface PanelHandle {
|
|
4992
5033
|
close(): void;
|
|
4993
5034
|
isOpen(): boolean;
|
|
@@ -5354,10 +5395,20 @@ export interface UiApi {
|
|
|
5354
5395
|
} | null>;
|
|
5355
5396
|
dialog(spec: DialogSpec): DialogHandle;
|
|
5356
5397
|
/**
|
|
5357
|
-
* Open a panel: floating over the map,
|
|
5358
|
-
* (`spec.dock`). As many as you like; each closes with the plugin.
|
|
5398
|
+
* Open a panel: floating over the map, docked at the right with the built-in panels, or
|
|
5399
|
+
* in the strip under the map (`spec.dock`). As many as you like; each closes with the plugin.
|
|
5359
5400
|
*/
|
|
5360
5401
|
panel(spec: PanelSpec): PanelHandle;
|
|
5402
|
+
/**
|
|
5403
|
+
* Claim a kind of file: dropped on the editor or picked in File ▸ Open, a file with one of
|
|
5404
|
+
* `spec.extensions` is handed to `spec.open` instead of being opened as a map. A plugin
|
|
5405
|
+
* that claims what another already has is not given it (the first stays); none can claim
|
|
5406
|
+
* the editor's own `.scm`, `.scx` or `.chk`. Ends with the plugin, or with `dispose`.
|
|
5407
|
+
*
|
|
5408
|
+
* @example
|
|
5409
|
+
* api.ui.fileType({ name: "StarCraft replay", extensions: [".rep"], open: (files) => loadReplays(files) });
|
|
5410
|
+
*/
|
|
5411
|
+
fileType(spec: FileTypeSpec): Disposable;
|
|
5361
5412
|
/**
|
|
5362
5413
|
* A cell of your own in the status bar. One line of text beside the plugin's icon, a
|
|
5363
5414
|
* spinner while `busy`, a click. Keep the handle and `set` it as things move; it
|