@scm-js/plugin-api 1.44.0 → 1.45.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
|
@@ -2963,6 +2963,24 @@ export interface RawEditResult {
|
|
|
2963
2963
|
/** Warnings from parsing the edited file (a truncated section, no usable DIM, …); empty when it read cleanly. */
|
|
2964
2964
|
warnings: string[];
|
|
2965
2965
|
}
|
|
2966
|
+
/** How `document.sections.replaceFile` installs the bytes. */
|
|
2967
|
+
export interface ReplaceFileOptions {
|
|
2968
|
+
/**
|
|
2969
|
+
* Take the bytes as the file that was opened rather than as an edit: the map stays
|
|
2970
|
+
* unmodified, so closing it does not ask to save, while Save writes the bytes as given.
|
|
2971
|
+
* For a plugin that repairs a map as it opens — nothing the user did changed it. Use it
|
|
2972
|
+
* only right after an `"open"`, or to put back what was opened; anything else would
|
|
2973
|
+
* hide a change from the user. The history is dropped either way.
|
|
2974
|
+
*
|
|
2975
|
+
* @example
|
|
2976
|
+
* api.events.on("document", (e) => {
|
|
2977
|
+
* if (e.reason !== "open") return;
|
|
2978
|
+
* const fixed = repair(api.document.sections.file());
|
|
2979
|
+
* if (fixed) api.document.sections.replaceFile(fixed, { asOpened: true });
|
|
2980
|
+
* });
|
|
2981
|
+
*/
|
|
2982
|
+
asOpened?: boolean;
|
|
2983
|
+
}
|
|
2966
2984
|
/**
|
|
2967
2985
|
* The scenario file at the byte level: every section occurrence in the order Save would
|
|
2968
2986
|
* write them, with the bytes it would write — unsaved edits already encoded — and raw
|
|
@@ -3007,8 +3025,11 @@ export interface SectionsApi {
|
|
|
3007
3025
|
remove(index: number): RawEditResult;
|
|
3008
3026
|
/** Move the occurrence at `from` so that it sits at `to`. */
|
|
3009
3027
|
move(from: number, to: number): RawEditResult;
|
|
3010
|
-
/**
|
|
3011
|
-
|
|
3028
|
+
/**
|
|
3029
|
+
* Replace the whole CHK, the way File ▸ Open reads one. The map is marked modified,
|
|
3030
|
+
* unless `asOpened` says the bytes are a reading of the file as it was opened.
|
|
3031
|
+
*/
|
|
3032
|
+
replaceFile(bytes: Uint8Array, options?: ReplaceFileOptions): RawEditResult;
|
|
3012
3033
|
/**
|
|
3013
3034
|
* The CHK inside a map file — an `.scx` / `.scm` archive's `staredit\scenario.chk`, or
|
|
3014
3035
|
* the bytes themselves for a bare CHK — the way File ▸ Open reads it, for `replaceFile`.
|