@scm-js/plugin-api 1.42.0 → 1.43.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 +137 -105
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -979,6 +979,127 @@ export interface LocationPatch {
|
|
|
979
979
|
bottom?: number;
|
|
980
980
|
elevationFlags?: number;
|
|
981
981
|
}
|
|
982
|
+
export interface WireListChange<T> {
|
|
983
|
+
index: number;
|
|
984
|
+
before: T | null;
|
|
985
|
+
after: T | null;
|
|
986
|
+
}
|
|
987
|
+
export interface WireLocationChange {
|
|
988
|
+
index: number;
|
|
989
|
+
after: LocationRecord;
|
|
990
|
+
/** The name as text (`after.nameIndex` is resolved again where it lands); null for none. */
|
|
991
|
+
name: string | null;
|
|
992
|
+
/** The slot was empty before: a new location, which moves to a free slot if someone else took this one. */
|
|
993
|
+
created: boolean;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* One undo step's worth of terrain and objects. The grids are flat number lists: terrain
|
|
997
|
+
* `[at, mtxm, tile, …]`, the others `[at, value, …]`. `reverse` marks the undo of an edit:
|
|
998
|
+
* its parts go in the reverse of the usual order, as undo walks them.
|
|
999
|
+
*/
|
|
1000
|
+
export interface SyncEditOp {
|
|
1001
|
+
kind: "edit";
|
|
1002
|
+
label: string;
|
|
1003
|
+
/** The map size the cells index; a grid part is skipped on a map of another size. */
|
|
1004
|
+
width: number;
|
|
1005
|
+
height: number;
|
|
1006
|
+
reverse?: boolean;
|
|
1007
|
+
terrain?: number[];
|
|
1008
|
+
isom?: number[];
|
|
1009
|
+
doodadTiles?: number[];
|
|
1010
|
+
fog?: number[];
|
|
1011
|
+
/** The whole ISOM lattice (base64 of the u16 cells) the edit gave the map, or null for taking it away. */
|
|
1012
|
+
isomWhole?: string | null;
|
|
1013
|
+
maskWhole?: string | null;
|
|
1014
|
+
units?: WireListChange<UnitRecord>[];
|
|
1015
|
+
doodads?: WireListChange<DoodadRecord>[];
|
|
1016
|
+
sprites?: WireListChange<SpriteRecord>[];
|
|
1017
|
+
locations?: WireLocationChange[];
|
|
1018
|
+
}
|
|
1019
|
+
declare const SYNC_FIELDS: readonly [
|
|
1020
|
+
"type",
|
|
1021
|
+
"fileVersion",
|
|
1022
|
+
"nameIndex",
|
|
1023
|
+
"descriptionIndex",
|
|
1024
|
+
"playerTypes",
|
|
1025
|
+
"editorPlayerTypes",
|
|
1026
|
+
"playerRaces",
|
|
1027
|
+
"playerColors",
|
|
1028
|
+
"playerRgb",
|
|
1029
|
+
"forces",
|
|
1030
|
+
"unitSettings",
|
|
1031
|
+
"unitAvailability",
|
|
1032
|
+
"upgradeSettings",
|
|
1033
|
+
"upgradeRestrictions",
|
|
1034
|
+
"techSettings",
|
|
1035
|
+
"techRestrictions",
|
|
1036
|
+
"wavs",
|
|
1037
|
+
"cuwp",
|
|
1038
|
+
"cuwpUsed",
|
|
1039
|
+
"triggers",
|
|
1040
|
+
"briefing",
|
|
1041
|
+
"switchNames"
|
|
1042
|
+
];
|
|
1043
|
+
export type SyncField = (typeof SYNC_FIELDS)[number];
|
|
1044
|
+
export interface SyncFieldsOp {
|
|
1045
|
+
kind: "fields";
|
|
1046
|
+
/** Each changed field's new value, packed (`pack`). */
|
|
1047
|
+
set: Partial<Record<SyncField, unknown>>;
|
|
1048
|
+
/** String slots that changed: `[index, before, after]`. */
|
|
1049
|
+
strings?: [
|
|
1050
|
+
number,
|
|
1051
|
+
string | null,
|
|
1052
|
+
string | null
|
|
1053
|
+
][];
|
|
1054
|
+
/** The table's length afterwards (trailing blank slots are dropped). */
|
|
1055
|
+
stringsLength?: number;
|
|
1056
|
+
/** The table's width and text encoding, when they changed. */
|
|
1057
|
+
stringsFormat?: {
|
|
1058
|
+
extended: boolean;
|
|
1059
|
+
encoding: TextEncoding;
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
export interface SyncExtrasOp {
|
|
1063
|
+
kind: "extras";
|
|
1064
|
+
/** `[member name, base64 bytes]`, or null bytes for a member taken out. */
|
|
1065
|
+
set: [
|
|
1066
|
+
string,
|
|
1067
|
+
string | null
|
|
1068
|
+
][];
|
|
1069
|
+
}
|
|
1070
|
+
export interface SyncResetOp {
|
|
1071
|
+
kind: "reset";
|
|
1072
|
+
label: string;
|
|
1073
|
+
/** The whole scenario, base64. */
|
|
1074
|
+
chk: string;
|
|
1075
|
+
}
|
|
1076
|
+
export type SyncOp = SyncEditOp | SyncFieldsOp | SyncExtrasOp | SyncResetOp;
|
|
1077
|
+
export type ListField = "triggers" | "briefing";
|
|
1078
|
+
export type ValueField = Exclude<SyncField, ListField>;
|
|
1079
|
+
export interface StringsFormat {
|
|
1080
|
+
extended: boolean;
|
|
1081
|
+
encoding: TextEncoding;
|
|
1082
|
+
}
|
|
1083
|
+
export interface Change<T> {
|
|
1084
|
+
before: T;
|
|
1085
|
+
after: T;
|
|
1086
|
+
}
|
|
1087
|
+
/** What one dialog commit changed, each part with both of its sides. */
|
|
1088
|
+
export interface TablesEdit {
|
|
1089
|
+
/** The changed tables as JSON text (`pack`ed). */
|
|
1090
|
+
values?: Partial<Record<ValueField, Change<string>>>;
|
|
1091
|
+
lists?: Partial<Record<ListField, Change<TriggerRecord[]>>>;
|
|
1092
|
+
/** String slots that changed: `[index, before, after]`. */
|
|
1093
|
+
strings?: [
|
|
1094
|
+
number,
|
|
1095
|
+
string | null,
|
|
1096
|
+
string | null
|
|
1097
|
+
][];
|
|
1098
|
+
stringsLength?: Change<number>;
|
|
1099
|
+
stringsFormat?: Change<StringsFormat>;
|
|
1100
|
+
/** The archive's files, when the commit changed them too (the Sound Editor). */
|
|
1101
|
+
extras?: Change<Map<string, Uint8Array>>;
|
|
1102
|
+
}
|
|
982
1103
|
/** The change lists of one edit; `HistoryEntry` adds the label. */
|
|
983
1104
|
export interface HistoryEdit {
|
|
984
1105
|
changes: TileChange[];
|
|
@@ -1017,10 +1138,16 @@ export interface HistoryEdit {
|
|
|
1017
1138
|
* on such a map). Undo removes the section again.
|
|
1018
1139
|
*/
|
|
1019
1140
|
createdMask?: Uint8Array;
|
|
1141
|
+
/**
|
|
1142
|
+
* What a dialog wrote — settings, triggers, the briefing, strings (editor/tableHistory.ts).
|
|
1143
|
+
* An entry with this part has no other: `applyEntry` leaves it alone, and the undo and
|
|
1144
|
+
* redo atoms apply it with `applyTables`.
|
|
1145
|
+
*/
|
|
1146
|
+
tables?: TablesEdit;
|
|
1020
1147
|
}
|
|
1021
1148
|
/**
|
|
1022
1149
|
* Why the map changed: an edit recorded in the history, an undo or redo of one, a dialog
|
|
1023
|
-
* writing its tables (settings, triggers, strings
|
|
1150
|
+
* writing its tables (settings, triggers, strings), a change to the
|
|
1024
1151
|
* whole document (resize, tileset change, raw section edit), or other people's edits on a
|
|
1025
1152
|
* shared map.
|
|
1026
1153
|
*/
|
|
@@ -1217,7 +1344,7 @@ export interface StackedLine {
|
|
|
1217
1344
|
pieces: number;
|
|
1218
1345
|
}
|
|
1219
1346
|
/** Every built-in dialog, by the id `openDialogAtom` takes; `DialogHost` maps each to its component. */
|
|
1220
|
-
export type DialogId = "newMap" | "openMap" | "saveAs" | "exportImage" | "mapProperties" | "resizeMap" | "mapRevision" | "playerSettings" | "forceSettings" | "playerColors" | "unitSettings" | "upgradeSettings" | "techSettings" | "stringEditor" | "soundEditor" | "switches" | "locationList" | "unitProperties" | "locationProperties" | "spriteProperties" | "triggerEditor" | "missionBriefing" | "cuwpEditor" | "replaceTerrain" | "autoStarts" | "testMap" | "symmetry" | "gridSettings" | "preferences" | "shortcuts" | "validateMap" | "statistics" | "importTriggers" | "exportTriggers" | "importStrings" | "exportStrings" | "find" | "about" | "confirmClose" | "recovery" | "previousVersions" | "plugins" | "confirmPlugin" | "pluginDialog" | "gameData" | "update";
|
|
1347
|
+
export type DialogId = "newMap" | "openMap" | "saveAs" | "exportImage" | "mapProperties" | "resizeMap" | "mapRevision" | "playerSettings" | "forceSettings" | "playerColors" | "unitSettings" | "upgradeSettings" | "techSettings" | "stringEditor" | "soundEditor" | "switches" | "locationList" | "unitProperties" | "locationProperties" | "spriteProperties" | "triggerEditor" | "missionBriefing" | "cuwpEditor" | "replaceTerrain" | "autoStarts" | "testMap" | "symmetry" | "gridSettings" | "preferences" | "shortcuts" | "validateMap" | "statistics" | "importTriggers" | "exportTriggers" | "importStrings" | "exportStrings" | "find" | "about" | "confirmClose" | "recovery" | "previousVersions" | "plugins" | "confirmPlugin" | "pluginDialog" | "gameData" | "update" | "whatsNew";
|
|
1221
1348
|
export interface MapImageOptions {
|
|
1222
1349
|
/** Output pixels per map tile. 32 matches the game's art 1:1; 1 is a minimap. */
|
|
1223
1350
|
pixelsPerTile: number;
|
|
@@ -1854,101 +1981,6 @@ export interface ChangeTilesetResult {
|
|
|
1854
1981
|
spritesDropped: number;
|
|
1855
1982
|
refilled: boolean;
|
|
1856
1983
|
}
|
|
1857
|
-
export interface WireListChange<T> {
|
|
1858
|
-
index: number;
|
|
1859
|
-
before: T | null;
|
|
1860
|
-
after: T | null;
|
|
1861
|
-
}
|
|
1862
|
-
export interface WireLocationChange {
|
|
1863
|
-
index: number;
|
|
1864
|
-
after: LocationRecord;
|
|
1865
|
-
/** The name as text (`after.nameIndex` is resolved again where it lands); null for none. */
|
|
1866
|
-
name: string | null;
|
|
1867
|
-
/** The slot was empty before: a new location, which moves to a free slot if someone else took this one. */
|
|
1868
|
-
created: boolean;
|
|
1869
|
-
}
|
|
1870
|
-
/**
|
|
1871
|
-
* One undo step's worth of terrain and objects. The grids are flat number lists: terrain
|
|
1872
|
-
* `[at, mtxm, tile, …]`, the others `[at, value, …]`. `reverse` marks the undo of an edit:
|
|
1873
|
-
* its parts go in the reverse of the usual order, as undo walks them.
|
|
1874
|
-
*/
|
|
1875
|
-
export interface SyncEditOp {
|
|
1876
|
-
kind: "edit";
|
|
1877
|
-
label: string;
|
|
1878
|
-
/** The map size the cells index; a grid part is skipped on a map of another size. */
|
|
1879
|
-
width: number;
|
|
1880
|
-
height: number;
|
|
1881
|
-
reverse?: boolean;
|
|
1882
|
-
terrain?: number[];
|
|
1883
|
-
isom?: number[];
|
|
1884
|
-
doodadTiles?: number[];
|
|
1885
|
-
fog?: number[];
|
|
1886
|
-
/** The whole ISOM lattice (base64 of the u16 cells) the edit gave the map, or null for taking it away. */
|
|
1887
|
-
isomWhole?: string | null;
|
|
1888
|
-
maskWhole?: string | null;
|
|
1889
|
-
units?: WireListChange<UnitRecord>[];
|
|
1890
|
-
doodads?: WireListChange<DoodadRecord>[];
|
|
1891
|
-
sprites?: WireListChange<SpriteRecord>[];
|
|
1892
|
-
locations?: WireLocationChange[];
|
|
1893
|
-
}
|
|
1894
|
-
declare const SYNC_FIELDS: readonly [
|
|
1895
|
-
"type",
|
|
1896
|
-
"fileVersion",
|
|
1897
|
-
"nameIndex",
|
|
1898
|
-
"descriptionIndex",
|
|
1899
|
-
"playerTypes",
|
|
1900
|
-
"editorPlayerTypes",
|
|
1901
|
-
"playerRaces",
|
|
1902
|
-
"playerColors",
|
|
1903
|
-
"playerRgb",
|
|
1904
|
-
"forces",
|
|
1905
|
-
"unitSettings",
|
|
1906
|
-
"unitAvailability",
|
|
1907
|
-
"upgradeSettings",
|
|
1908
|
-
"upgradeRestrictions",
|
|
1909
|
-
"techSettings",
|
|
1910
|
-
"techRestrictions",
|
|
1911
|
-
"wavs",
|
|
1912
|
-
"cuwp",
|
|
1913
|
-
"cuwpUsed",
|
|
1914
|
-
"triggers",
|
|
1915
|
-
"briefing",
|
|
1916
|
-
"switchNames"
|
|
1917
|
-
];
|
|
1918
|
-
export type SyncField = (typeof SYNC_FIELDS)[number];
|
|
1919
|
-
export interface SyncFieldsOp {
|
|
1920
|
-
kind: "fields";
|
|
1921
|
-
/** Each changed field's new value, packed (`pack`). */
|
|
1922
|
-
set: Partial<Record<SyncField, unknown>>;
|
|
1923
|
-
/** String slots that changed: `[index, before, after]`. */
|
|
1924
|
-
strings?: [
|
|
1925
|
-
number,
|
|
1926
|
-
string | null,
|
|
1927
|
-
string | null
|
|
1928
|
-
][];
|
|
1929
|
-
/** The table's length afterwards (trailing blank slots are dropped). */
|
|
1930
|
-
stringsLength?: number;
|
|
1931
|
-
/** The table's width and text encoding, when they changed. */
|
|
1932
|
-
stringsFormat?: {
|
|
1933
|
-
extended: boolean;
|
|
1934
|
-
encoding: TextEncoding;
|
|
1935
|
-
};
|
|
1936
|
-
}
|
|
1937
|
-
export interface SyncExtrasOp {
|
|
1938
|
-
kind: "extras";
|
|
1939
|
-
/** `[member name, base64 bytes]`, or null bytes for a member taken out. */
|
|
1940
|
-
set: [
|
|
1941
|
-
string,
|
|
1942
|
-
string | null
|
|
1943
|
-
][];
|
|
1944
|
-
}
|
|
1945
|
-
export interface SyncResetOp {
|
|
1946
|
-
kind: "reset";
|
|
1947
|
-
label: string;
|
|
1948
|
-
/** The whole scenario, base64. */
|
|
1949
|
-
chk: string;
|
|
1950
|
-
}
|
|
1951
|
-
export type SyncOp = SyncEditOp | SyncFieldsOp | SyncExtrasOp | SyncResetOp;
|
|
1952
1984
|
export type SymmetryMode = "none" | "h" | "v" | "hv" | "rot180" | "rot90" | "diag" | "adiag";
|
|
1953
1985
|
export type StartLayout = "ring" | "corners";
|
|
1954
1986
|
export interface StartPlacementResult {
|
|
@@ -2678,16 +2710,16 @@ export interface DocumentApi {
|
|
|
2678
2710
|
*/
|
|
2679
2711
|
edit<R>(label: string, build: (tx: EditTransaction) => Sync<R>): EditResult;
|
|
2680
2712
|
/**
|
|
2681
|
-
* The second kind of write: the tables and settings
|
|
2682
|
-
*
|
|
2683
|
-
*
|
|
2684
|
-
*
|
|
2685
|
-
* what
|
|
2713
|
+
* The second kind of write: the tables and settings the dialogs edit — triggers, the
|
|
2714
|
+
* string table, switch names, the scenario's own properties — as one transaction, the
|
|
2715
|
+
* way a settings dialog's OK applies its whole form at once. Operations apply as they
|
|
2716
|
+
* are called; the commit marks the map modified, bumps what the chrome reads and
|
|
2717
|
+
* records what changed as one undo entry under `label`.
|
|
2686
2718
|
* `build` is synchronous, as `edit`'s is, and closed when it returns.
|
|
2687
2719
|
*
|
|
2688
|
-
*
|
|
2689
|
-
*
|
|
2690
|
-
*
|
|
2720
|
+
* An update is not rolled back, so a builder that throws leaves what it wrote: the
|
|
2721
|
+
* sections it touched are committed — the map is modified, the chrome re-reads, the
|
|
2722
|
+
* undo entry holds what was written — and the error reaches you.
|
|
2691
2723
|
*
|
|
2692
2724
|
* @example
|
|
2693
2725
|
* api.document.update("Rename", (tx) => {
|