@scm-js/plugin-api 1.15.0 → 1.17.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 +87 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -2409,6 +2409,16 @@ export interface EditTransaction {
|
|
|
2409
2409
|
* Returns records converted.
|
|
2410
2410
|
*/
|
|
2411
2411
|
convertDoodads(indices: number[]): number;
|
|
2412
|
+
/**
|
|
2413
|
+
* Stamp a `Clip` with its top-left tile at (tx, ty) inside this transaction — the
|
|
2414
|
+
* clipboard's paste without the clipboard: the clip can come from anywhere (`clipboard.copy`,
|
|
2415
|
+
* a library, a file), the user's own clip is left alone, and several stamps, or a stamp
|
|
2416
|
+
* and the strokes around it, make one undo step. Every part the clip carries is laid down
|
|
2417
|
+
* unless `parts` says otherwise; `mode` is `"merge"` unless given. Terrain and doodads
|
|
2418
|
+
* from another tileset are refused, as a paste refuses them, and anything off the map is
|
|
2419
|
+
* skipped, both said in the result's `notes`.
|
|
2420
|
+
*/
|
|
2421
|
+
paste(clip: Clip, tx: number, ty: number, options?: PasteOptionsSpec): PasteResult;
|
|
2412
2422
|
/** A location in the lowest free slot (pixel bounds); returns the slot, or -1 when the table is full. */
|
|
2413
2423
|
addLocation(bounds: Bounds, name?: string, elevationFlags?: number): number;
|
|
2414
2424
|
editLocation(index: number, patch: LocationPatch): boolean;
|
|
@@ -2855,6 +2865,17 @@ export interface ViewApi {
|
|
|
2855
2865
|
visible(): Rect;
|
|
2856
2866
|
/** Scroll so a tile is in the middle of the viewport. */
|
|
2857
2867
|
center(x: number, y: number): void;
|
|
2868
|
+
/**
|
|
2869
|
+
* Bring a tile rect onto the screen, gliding there by the shortest way rather than
|
|
2870
|
+
* jumping, and leaving the view alone when the rect is already visible. With `fit` the
|
|
2871
|
+
* view zooms out (never in) as far as the rect needs. Resolves once the view is there;
|
|
2872
|
+
* `false` when the user, or another request, moved it first — a plugin that follows its
|
|
2873
|
+
* own work around the map takes that as its cue to stop.
|
|
2874
|
+
*
|
|
2875
|
+
* @example
|
|
2876
|
+
* if (!(await api.view.reveal(rect))) following = false;
|
|
2877
|
+
*/
|
|
2878
|
+
reveal(rect: Rect, options?: RevealOptions): Promise<boolean>;
|
|
2858
2879
|
/** Scroll to an object (and select it, for a unit, sprite or location). */
|
|
2859
2880
|
goTo(target: GoTo): void;
|
|
2860
2881
|
/** The tile under the pointer, as the status bar shows it. */
|
|
@@ -2879,6 +2900,15 @@ export interface ViewApi {
|
|
|
2879
2900
|
*/
|
|
2880
2901
|
flash(target: FlashTarget): void;
|
|
2881
2902
|
}
|
|
2903
|
+
/** How `view.reveal` brings a rect on screen. */
|
|
2904
|
+
export interface RevealOptions {
|
|
2905
|
+
/** Zoom out to the zoom control's nearest step that fits the rect (plus the margin); never zooms in. Off by default. */
|
|
2906
|
+
fit?: boolean;
|
|
2907
|
+
/** Glide rather than jump. On by default. */
|
|
2908
|
+
animate?: boolean;
|
|
2909
|
+
/** Tiles kept clear between the rect and the viewport's edge when the view has to move. 1 by default. */
|
|
2910
|
+
margin?: number;
|
|
2911
|
+
}
|
|
2882
2912
|
export interface CommandSpec {
|
|
2883
2913
|
/**
|
|
2884
2914
|
* The command's id. One without a dot is namespaced under the plugin
|
|
@@ -2956,6 +2986,12 @@ export interface PluginImage {
|
|
|
2956
2986
|
width: number;
|
|
2957
2987
|
height: number;
|
|
2958
2988
|
}
|
|
2989
|
+
export interface RenderClipOptions {
|
|
2990
|
+
/** Pixels per tile; 32 (the game's own) by default. A thumbnail wants 4–8. */
|
|
2991
|
+
pixelsPerTile?: number;
|
|
2992
|
+
/** Which parts to draw; every part the clip carries by default. */
|
|
2993
|
+
parts?: Partial<ClipParts>;
|
|
2994
|
+
}
|
|
2959
2995
|
/**
|
|
2960
2996
|
* The pictures the viewport draws, for a plugin's own lists and previews: the same
|
|
2961
2997
|
* cached canvases, so asking for one costs nothing after the first time. Everything is
|
|
@@ -2990,6 +3026,17 @@ export interface GraphicsApi {
|
|
|
2990
3026
|
* tile rect. Everything it needs is loaded first; null without a map or a canvas.
|
|
2991
3027
|
*/
|
|
2992
3028
|
renderRect(rect: Rect, options?: Partial<MapImageOptions>): Promise<Blob | null>;
|
|
3029
|
+
/**
|
|
3030
|
+
* A `Clip` drawn as the clipboard layer's paste ghost draws it: the picture (its own
|
|
3031
|
+
* tiles, or the catalogue's for a doodad-only clip), then units, sprites and doodad
|
|
3032
|
+
* overlays with the viewport's own graphics, then location boxes — a thumbnail for a
|
|
3033
|
+
* list of clips, or the ghost under the pointer while a plugin stamps one. It is drawn
|
|
3034
|
+
* with the graphics of the clip's *own* tileset (`clip.era`), which are in memory for
|
|
3035
|
+
* the open map once loaded and otherwise not, so a clip from another tileset answers
|
|
3036
|
+
* null; so does a missing tileset or a page with no canvas. Synchronous and uncached:
|
|
3037
|
+
* keep the result while the clip and the tileset stay the same.
|
|
3038
|
+
*/
|
|
3039
|
+
renderClip(clip: Clip, options?: RenderClipOptions): PluginImage | null;
|
|
2993
3040
|
/** The colour a player's units are drawn in, `#rrggbb`. */
|
|
2994
3041
|
playerColor(owner: number): string;
|
|
2995
3042
|
/**
|
|
@@ -3393,6 +3440,14 @@ export interface ClipboardApi {
|
|
|
3393
3440
|
* nothing to copy.
|
|
3394
3441
|
*/
|
|
3395
3442
|
copy(source?: ClipSource): Clip | null;
|
|
3443
|
+
/**
|
|
3444
|
+
* The clip `copy` would take, handed back instead of put on the clipboard — for a
|
|
3445
|
+
* plugin keeping clips of its own without disturbing the user's. `parts` overrides
|
|
3446
|
+
* `parts()` for this one capture. Null when there is nothing to take.
|
|
3447
|
+
*/
|
|
3448
|
+
capture(source?: ClipSource, options?: {
|
|
3449
|
+
parts?: Partial<ClipParts>;
|
|
3450
|
+
}): Clip | null;
|
|
3396
3451
|
/** Copy, then remove the source's objects as one undo step (terrain and fog stay). Null when there was nothing. */
|
|
3397
3452
|
cut(source?: ClipSource): Clip | null;
|
|
3398
3453
|
/**
|
|
@@ -3659,6 +3714,15 @@ export interface PanelSpec {
|
|
|
3659
3714
|
title: string;
|
|
3660
3715
|
/** In CSS pixels; 260 by default. The panel is as tall as its content, up to the map's height. Ignored when docked. */
|
|
3661
3716
|
width?: number;
|
|
3717
|
+
/** Floating only: a height in CSS pixels instead of the content's own; the body then scrolls, or fills, as its content asks. */
|
|
3718
|
+
height?: number;
|
|
3719
|
+
/**
|
|
3720
|
+
* Floating only: a grip at the bottom-right corner lets the user resize the panel, and
|
|
3721
|
+
* the size is remembered with the position for the session. The body is a column flex
|
|
3722
|
+
* box, so a root element with `flex: 1; min-height: 0` fills whatever size it has —
|
|
3723
|
+
* what a code editor or a long list beside the map wants.
|
|
3724
|
+
*/
|
|
3725
|
+
resizable?: boolean;
|
|
3662
3726
|
/**
|
|
3663
3727
|
* Where the panel lives. `"float"` (the default) is a frame over the map the user drags
|
|
3664
3728
|
* about. `"right"` puts it in the right dock as a panel of its own, under Minimap, Layers
|
|
@@ -3875,6 +3939,17 @@ export interface PickOptions {
|
|
|
3875
3939
|
/** Shown in the viewport's HUD while the user picks; also the status line. */
|
|
3876
3940
|
prompt?: string;
|
|
3877
3941
|
}
|
|
3942
|
+
/** What `ui.pickObject` can pick. */
|
|
3943
|
+
export type PickObjectKind = "unit" | "location";
|
|
3944
|
+
export interface PickObjectOptions extends PickOptions {
|
|
3945
|
+
/** Which kinds count; every kind when omitted. Under the pointer, a unit wins over a location. */
|
|
3946
|
+
kinds?: PickObjectKind[];
|
|
3947
|
+
}
|
|
3948
|
+
/** What the user picked: the record's index in `document.scenario().units` or `.locations`. */
|
|
3949
|
+
export interface PickedObject {
|
|
3950
|
+
kind: PickObjectKind;
|
|
3951
|
+
index: number;
|
|
3952
|
+
}
|
|
3878
3953
|
export interface PickFilesOptions {
|
|
3879
3954
|
/** `accept` for the file input, e.g. `"image/*"` or `".png,.jpg"`. */
|
|
3880
3955
|
accept?: string;
|
|
@@ -3957,6 +4032,12 @@ export interface UiApi {
|
|
|
3957
4032
|
x: number;
|
|
3958
4033
|
y: number;
|
|
3959
4034
|
} | null>;
|
|
4035
|
+
/**
|
|
4036
|
+
* As `pickTile`, for an object: the user clicks a unit or a location. The viewport
|
|
4037
|
+
* outlines and names what is under the pointer as it moves; a click on nothing keeps
|
|
4038
|
+
* picking. Resolves with the kind and the record's index, or null as `pickArea` does.
|
|
4039
|
+
*/
|
|
4040
|
+
pickObject(options?: PickObjectOptions): Promise<PickedObject | null>;
|
|
3960
4041
|
/**
|
|
3961
4042
|
* Decode a picture: a `File` / `Blob`, a `data:` URL, or an `http(s)` URL (fetched, and
|
|
3962
4043
|
* when the site refuses cross-origin reads, loaded through an `<img>` with
|
|
@@ -4464,7 +4545,12 @@ export interface StorageApi {
|
|
|
4464
4545
|
* api.storage.set("options", { ...opts, showGrid: false });
|
|
4465
4546
|
*/
|
|
4466
4547
|
get<T>(key: string, fallback: T): T;
|
|
4467
|
-
|
|
4548
|
+
/**
|
|
4549
|
+
* Store a value. False when the browser refused the write — its storage quota is a few
|
|
4550
|
+
* megabytes for the whole editor — so a plugin keeping something the user made can say
|
|
4551
|
+
* so instead of losing it silently.
|
|
4552
|
+
*/
|
|
4553
|
+
set(key: string, value: unknown): boolean;
|
|
4468
4554
|
remove(key: string): void;
|
|
4469
4555
|
}
|
|
4470
4556
|
/** A slug for storage keys and log prefixes. */
|