@scm-js/plugin-api 1.45.0 → 1.46.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 +22 -1
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -2565,6 +2565,8 @@ export interface DocumentInfo {
2565
2565
  version: number;
2566
2566
  fileName: string | null;
2567
2567
  modified: boolean;
2568
+ /** Open to look at only (`OpenDocumentOptions.viewOnly`): every write throws and it is never saved. */
2569
+ viewOnly: boolean;
2568
2570
  }
2569
2571
  /** What one `document.edit` changed, per list. */
2570
2572
  export interface EditResult {
@@ -2741,6 +2743,20 @@ export interface ResizeDocumentOptions {
2741
2743
  export type OpenInto = "new" | "current";
2742
2744
  export interface OpenDocumentOptions {
2743
2745
  into?: OpenInto;
2746
+ /**
2747
+ * Open the map to look at, not to change — a replay's map, a preview. It always opens
2748
+ * beside the open map (`into` is ignored), so nothing is replaced and nothing is asked.
2749
+ * Panning, zooming, the layers and selecting work; every tool, menu and dialog that
2750
+ * would change it is off, and every write throws — `edit`, `update`, `sections` (except
2751
+ * `replaceFile(…, { asOpened: true })`, a reading of the file rather than an edit), `resize`,
2752
+ * `changeTileset`, `extras`, the clipboard's `cut` and `paste`, `save` and `saveAs` unless
2753
+ * as a copy, `sync.start`. It is never kept in Open Recent, and closing it asks nothing. File ▸ Edit a Copy
2754
+ * opens an ordinary copy. `label` is what the tab and the status bar call it ("Replay");
2755
+ * `true` is the plain "View only".
2756
+ */
2757
+ viewOnly?: boolean | {
2758
+ label?: string;
2759
+ };
2744
2760
  }
2745
2761
  /** One open map, as `document.list()` reports it. `active` marks the one in front — the one every other call reads and writes. */
2746
2762
  export interface OpenDocumentInfo {
@@ -2754,6 +2770,8 @@ export interface OpenDocumentInfo {
2754
2770
  height: number;
2755
2771
  modified: boolean;
2756
2772
  active: boolean;
2773
+ /** Open to look at only; see `OpenDocumentOptions.viewOnly`. */
2774
+ viewOnly: boolean;
2757
2775
  }
2758
2776
  /** File ▸ New's form: size, tileset, and the two strings the dialog asks for. */
2759
2777
  export interface NewDocumentOptions {
@@ -2869,11 +2887,14 @@ export interface DocumentApi {
2869
2887
  * In place of a map with unsaved changes, when Preferences say to ask, the Close
2870
2888
  * Scenario dialog comes first and the user may cancel. Resolves true once the file is
2871
2889
  * 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).
2890
+ * read (the status bar says why). `options.viewOnly` opens it to look at only.
2873
2891
  *
2874
2892
  * @example
2875
2893
  * const [file] = await api.ui.pickFiles({ accept: ".scx,.scm,.chk" });
2876
2894
  * if (file) await api.document.open(file, file.name, { into: "new" });
2895
+ * @example
2896
+ * // A replay's map, to draw over and not to change.
2897
+ * await api.document.open(chk, "Lost Temple.scx", { viewOnly: { label: "Replay" } });
2877
2898
  */
2878
2899
  open(file: File | Blob | Uint8Array, fileName?: string, options?: OpenDocumentOptions): Promise<boolean>;
2879
2900
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/plugin-api",
3
- "version": "1.45.0",
3
+ "version": "1.46.0",
4
4
  "description": "Type declarations for the scmJS plugin API",
5
5
  "license": "MIT",
6
6
  "types": "index.d.ts",