@scm-js/plugin-api 1.16.0 → 1.18.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 +82 -7
- 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;
|
|
@@ -2738,6 +2748,22 @@ export interface TriggersApi {
|
|
|
2738
2748
|
* deactivation; call `refresh()` after a rebuild so the editors ask `locate` again.
|
|
2739
2749
|
*/
|
|
2740
2750
|
claim(spec: TriggerClaimSpec): TriggerClaimHandle;
|
|
2751
|
+
/**
|
|
2752
|
+
* Every plugin's claims as located in `list` (TRIG as it stands, when omitted), first
|
|
2753
|
+
* run first — what an editor of the trigger list needs to fence or lock the generated
|
|
2754
|
+
* runs. A claim whose `locate` finds nothing, or throws, is left out.
|
|
2755
|
+
*/
|
|
2756
|
+
claims(list?: TriggerRecord[]): TriggerClaimRange[];
|
|
2757
|
+
}
|
|
2758
|
+
/** One claimed run as `triggers.claims` located it. */
|
|
2759
|
+
export interface TriggerClaimRange {
|
|
2760
|
+
pluginId: string;
|
|
2761
|
+
/** `TriggerClaimSpec.label`: what generated the run, as a sentence would use it. */
|
|
2762
|
+
label: string;
|
|
2763
|
+
/** The badge word the trigger list shows; the plugin's id by default. */
|
|
2764
|
+
badge: string;
|
|
2765
|
+
start: number;
|
|
2766
|
+
count: number;
|
|
2741
2767
|
}
|
|
2742
2768
|
/**
|
|
2743
2769
|
* A run of triggers a plugin generates and owns. It is found by *content*: the
|
|
@@ -2976,6 +3002,12 @@ export interface PluginImage {
|
|
|
2976
3002
|
width: number;
|
|
2977
3003
|
height: number;
|
|
2978
3004
|
}
|
|
3005
|
+
export interface RenderClipOptions {
|
|
3006
|
+
/** Pixels per tile; 32 (the game's own) by default. A thumbnail wants 4–8. */
|
|
3007
|
+
pixelsPerTile?: number;
|
|
3008
|
+
/** Which parts to draw; every part the clip carries by default. */
|
|
3009
|
+
parts?: Partial<ClipParts>;
|
|
3010
|
+
}
|
|
2979
3011
|
/**
|
|
2980
3012
|
* The pictures the viewport draws, for a plugin's own lists and previews: the same
|
|
2981
3013
|
* cached canvases, so asking for one costs nothing after the first time. Everything is
|
|
@@ -3010,6 +3042,17 @@ export interface GraphicsApi {
|
|
|
3010
3042
|
* tile rect. Everything it needs is loaded first; null without a map or a canvas.
|
|
3011
3043
|
*/
|
|
3012
3044
|
renderRect(rect: Rect, options?: Partial<MapImageOptions>): Promise<Blob | null>;
|
|
3045
|
+
/**
|
|
3046
|
+
* A `Clip` drawn as the clipboard layer's paste ghost draws it: the picture (its own
|
|
3047
|
+
* tiles, or the catalogue's for a doodad-only clip), then units, sprites and doodad
|
|
3048
|
+
* overlays with the viewport's own graphics, then location boxes — a thumbnail for a
|
|
3049
|
+
* list of clips, or the ghost under the pointer while a plugin stamps one. It is drawn
|
|
3050
|
+
* with the graphics of the clip's *own* tileset (`clip.era`), which are in memory for
|
|
3051
|
+
* the open map once loaded and otherwise not, so a clip from another tileset answers
|
|
3052
|
+
* null; so does a missing tileset or a page with no canvas. Synchronous and uncached:
|
|
3053
|
+
* keep the result while the clip and the tileset stay the same.
|
|
3054
|
+
*/
|
|
3055
|
+
renderClip(clip: Clip, options?: RenderClipOptions): PluginImage | null;
|
|
3013
3056
|
/** The colour a player's units are drawn in, `#rrggbb`. */
|
|
3014
3057
|
playerColor(owner: number): string;
|
|
3015
3058
|
/**
|
|
@@ -3413,6 +3456,14 @@ export interface ClipboardApi {
|
|
|
3413
3456
|
* nothing to copy.
|
|
3414
3457
|
*/
|
|
3415
3458
|
copy(source?: ClipSource): Clip | null;
|
|
3459
|
+
/**
|
|
3460
|
+
* The clip `copy` would take, handed back instead of put on the clipboard — for a
|
|
3461
|
+
* plugin keeping clips of its own without disturbing the user's. `parts` overrides
|
|
3462
|
+
* `parts()` for this one capture. Null when there is nothing to take.
|
|
3463
|
+
*/
|
|
3464
|
+
capture(source?: ClipSource, options?: {
|
|
3465
|
+
parts?: Partial<ClipParts>;
|
|
3466
|
+
}): Clip | null;
|
|
3416
3467
|
/** Copy, then remove the source's objects as one undo step (terrain and fog stay). Null when there was nothing. */
|
|
3417
3468
|
cut(source?: ClipSource): Clip | null;
|
|
3418
3469
|
/**
|
|
@@ -3655,6 +3706,19 @@ export interface DialogSpec {
|
|
|
3655
3706
|
* (a code editor dismissing its own popups), judged by the element it landed on.
|
|
3656
3707
|
*/
|
|
3657
3708
|
keepOpenOnEscape?: (target: EventTarget | null) => boolean;
|
|
3709
|
+
/**
|
|
3710
|
+
* Offer a slot of this dialog's own, so other plugins can add to it with `ui.dialogSlot`
|
|
3711
|
+
* the way they add to a built-in dialog: `id` is what they name (`"<plugin>.<name>"`),
|
|
3712
|
+
* `fields` the working copy lent to them, read live, and `payload` what the dialog was
|
|
3713
|
+
* opened with. The Text Trigger Editor plugin offers `"trigedit.text"` with a `text` field.
|
|
3714
|
+
*/
|
|
3715
|
+
slot?: DialogSlotOffer;
|
|
3716
|
+
}
|
|
3717
|
+
/** A slot a plugin dialog offers to other plugins; see `DialogSpec.slot`. */
|
|
3718
|
+
export interface DialogSlotOffer {
|
|
3719
|
+
id: string;
|
|
3720
|
+
payload?: Record<string, unknown>;
|
|
3721
|
+
fields?: Record<string, DialogField>;
|
|
3658
3722
|
}
|
|
3659
3723
|
export interface DialogHandle {
|
|
3660
3724
|
close(): void;
|
|
@@ -3736,10 +3800,15 @@ export interface StatusItemHandle {
|
|
|
3736
3800
|
* not yet applied to the map — so a slot's button can fill it in and leave OK to them.
|
|
3737
3801
|
*
|
|
3738
3802
|
* - `mapProperties`: `name`, `description`.
|
|
3739
|
-
* - `textTriggerEditor`: `text` (the whole editor); `payload.briefing` says which list.
|
|
3740
3803
|
* - `triggerEditor`, `stringEditor`, `playerSettings`, `missionBriefing`: no fields, a slot only.
|
|
3804
|
+
*
|
|
3805
|
+
* A plugin's own dialog can offer a slot too (`DialogSpec.slot`), under an id of its
|
|
3806
|
+
* choosing — `"trigedit.text"` is the Text Trigger Editor's, lending `text` with
|
|
3807
|
+
* `payload.briefing` — and another plugin adds to it with the same `dialogSlot` call.
|
|
3741
3808
|
*/
|
|
3742
|
-
export type SlottedDialogId = "mapProperties" | "
|
|
3809
|
+
export type SlottedDialogId = "mapProperties" | "triggerEditor" | "stringEditor" | "playerSettings" | "missionBriefing";
|
|
3810
|
+
/** A slot id: one of the editor's dialogs, or the id a plugin dialog offers (`"<plugin>.<name>"` by convention). */
|
|
3811
|
+
export type DialogSlotId = SlottedDialogId | (string & {});
|
|
3743
3812
|
/** A form field a dialog lends to a slot: read it, set it, hear it change. */
|
|
3744
3813
|
export interface DialogField {
|
|
3745
3814
|
get(): string;
|
|
@@ -3747,7 +3816,7 @@ export interface DialogField {
|
|
|
3747
3816
|
}
|
|
3748
3817
|
/** What a slot's `mount` is handed: which dialog, its payload, its fields, and a way to close it. */
|
|
3749
3818
|
export interface DialogSlotHost {
|
|
3750
|
-
readonly dialog:
|
|
3819
|
+
readonly dialog: DialogSlotId;
|
|
3751
3820
|
readonly payload: Readonly<Record<string, unknown>>;
|
|
3752
3821
|
readonly fields: Readonly<Record<string, DialogField>>;
|
|
3753
3822
|
close(): void;
|
|
@@ -3956,8 +4025,9 @@ export interface UiApi {
|
|
|
3956
4025
|
/**
|
|
3957
4026
|
* Add to a built-in dialog. `mount` runs in a row at the left of the dialog's footer each
|
|
3958
4027
|
* time that dialog opens, with the dialog's working-copy fields to read and fill
|
|
3959
|
-
* (`SlottedDialogId` lists which dialogs and fields)
|
|
3960
|
-
*
|
|
4028
|
+
* (`SlottedDialogId` lists which dialogs and fields) — or to another plugin's dialog,
|
|
4029
|
+
* by the id its `DialogSpec.slot` offers. Returns the registration; it leaves with
|
|
4030
|
+
* `dispose()` or the plugin.
|
|
3961
4031
|
*
|
|
3962
4032
|
* @example
|
|
3963
4033
|
* api.ui.dialogSlot("mapProperties", {
|
|
@@ -3968,7 +4038,7 @@ export interface UiApi {
|
|
|
3968
4038
|
* },
|
|
3969
4039
|
* });
|
|
3970
4040
|
*/
|
|
3971
|
-
dialogSlot(dialog:
|
|
4041
|
+
dialogSlot(dialog: DialogSlotId, spec: DialogSlotSpec): Disposable;
|
|
3972
4042
|
/**
|
|
3973
4043
|
* Take over the pointer on the map until `stop()`, Esc, a right-click, a map change
|
|
3974
4044
|
* or another tool. One tool runs at a time — starting one stops the previous — and a
|
|
@@ -4510,7 +4580,12 @@ export interface StorageApi {
|
|
|
4510
4580
|
* api.storage.set("options", { ...opts, showGrid: false });
|
|
4511
4581
|
*/
|
|
4512
4582
|
get<T>(key: string, fallback: T): T;
|
|
4513
|
-
|
|
4583
|
+
/**
|
|
4584
|
+
* Store a value. False when the browser refused the write — its storage quota is a few
|
|
4585
|
+
* megabytes for the whole editor — so a plugin keeping something the user made can say
|
|
4586
|
+
* so instead of losing it silently.
|
|
4587
|
+
*/
|
|
4588
|
+
set(key: string, value: unknown): boolean;
|
|
4514
4589
|
remove(key: string): void;
|
|
4515
4590
|
}
|
|
4516
4591
|
/** A slug for storage keys and log prefixes. */
|