@scm-js/plugin-api 1.35.0 → 1.36.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 +23 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -2249,6 +2249,25 @@ export interface PluginApi {
|
|
|
2249
2249
|
readonly storage: StorageApi;
|
|
2250
2250
|
/** `console.log` with the plugin's name in front. */
|
|
2251
2251
|
log(...args: unknown[]): void;
|
|
2252
|
+
/**
|
|
2253
|
+
* A child of this API with a lifetime of its own. Everything registered through
|
|
2254
|
+
* `scope.api` — menu items, hotkeys, event listeners, panels, dialogs, overlays, map
|
|
2255
|
+
* tools, commands, services, trigger claims — goes when `scope.dispose()` is called, and
|
|
2256
|
+
* with the plugin if it is turned off first. After the dispose, the child's document
|
|
2257
|
+
* writes are refused as a turned-off plugin's are, so a timer or a fetch that outlives
|
|
2258
|
+
* the scope cannot change the map. Scopes nest.
|
|
2259
|
+
*
|
|
2260
|
+
* It is for a plugin that runs other code for a while and then takes it all back: the
|
|
2261
|
+
* API Playground runs each snippet in one. The child speaks as the same plugin — same
|
|
2262
|
+
* id, storage and log name.
|
|
2263
|
+
*/
|
|
2264
|
+
scope(): PluginScope;
|
|
2265
|
+
}
|
|
2266
|
+
/** A child API that can be taken back as a whole (`PluginApi.scope`). */
|
|
2267
|
+
export interface PluginScope extends Disposable {
|
|
2268
|
+
readonly api: PluginApi;
|
|
2269
|
+
/** True once `dispose` has run, or once the plugin that made the scope was turned off. */
|
|
2270
|
+
readonly disposed: boolean;
|
|
2252
2271
|
}
|
|
2253
2272
|
export interface DocumentInfo {
|
|
2254
2273
|
name: string;
|
|
@@ -2473,8 +2492,9 @@ export interface DocumentApi {
|
|
|
2473
2492
|
*
|
|
2474
2493
|
* @example
|
|
2475
2494
|
* // One undo entry called "Fill", however many operations it takes.
|
|
2495
|
+
* const ground = api.terrain.types()[1].id; // the tileset's second flat terrain
|
|
2476
2496
|
* const result = api.document.edit("Fill", (tx) => {
|
|
2477
|
-
* tx.stampTerrain({ x0: 0, y0: 0, x1: 8, y1: 8 },
|
|
2497
|
+
* tx.stampTerrain({ x0: 0, y0: 0, x1: 8, y1: 8 }, ground);
|
|
2478
2498
|
* tx.placeUnit(api.consts.unit.startLocation, 0, 4 * api.consts.tile, 4 * api.consts.tile);
|
|
2479
2499
|
* });
|
|
2480
2500
|
* api.ui.status(`${result.tiles} tiles, ${result.units} units`);
|
|
@@ -3298,7 +3318,8 @@ export interface ViewApi {
|
|
|
3298
3318
|
* clean up.
|
|
3299
3319
|
*
|
|
3300
3320
|
* @example
|
|
3301
|
-
* const
|
|
3321
|
+
* const rect = { x0: 4, y0: 4, x1: 12, y1: 12 };
|
|
3322
|
+
* const r = api.document.edit("Fill", (tx) => tx.fillFlat(rect, api.terrain.types()[1].id));
|
|
3302
3323
|
* if (r.changed) api.view.flash({ rect });
|
|
3303
3324
|
*/
|
|
3304
3325
|
flash(target: FlashTarget): void;
|