@scm-js/plugin-api 1.16.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.
Files changed (2) hide show
  1. package/index.d.ts +41 -1
  2. 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;
@@ -2976,6 +2986,12 @@ export interface PluginImage {
2976
2986
  width: number;
2977
2987
  height: number;
2978
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
+ }
2979
2995
  /**
2980
2996
  * The pictures the viewport draws, for a plugin's own lists and previews: the same
2981
2997
  * cached canvases, so asking for one costs nothing after the first time. Everything is
@@ -3010,6 +3026,17 @@ export interface GraphicsApi {
3010
3026
  * tile rect. Everything it needs is loaded first; null without a map or a canvas.
3011
3027
  */
3012
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;
3013
3040
  /** The colour a player's units are drawn in, `#rrggbb`. */
3014
3041
  playerColor(owner: number): string;
3015
3042
  /**
@@ -3413,6 +3440,14 @@ export interface ClipboardApi {
3413
3440
  * nothing to copy.
3414
3441
  */
3415
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;
3416
3451
  /** Copy, then remove the source's objects as one undo step (terrain and fog stay). Null when there was nothing. */
3417
3452
  cut(source?: ClipSource): Clip | null;
3418
3453
  /**
@@ -4510,7 +4545,12 @@ export interface StorageApi {
4510
4545
  * api.storage.set("options", { ...opts, showGrid: false });
4511
4546
  */
4512
4547
  get<T>(key: string, fallback: T): T;
4513
- set(key: string, value: unknown): void;
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;
4514
4554
  remove(key: string): void;
4515
4555
  }
4516
4556
  /** A slug for storage keys and log prefixes. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/plugin-api",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "Type declarations for the scmJS plugin API",
5
5
  "license": "MIT",
6
6
  "types": "index.d.ts",