@scm-js/plugin-api 1.24.0 → 1.26.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 +80 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1141,6 +1141,15 @@ export interface MapImageOptions {
|
|
|
1141
1141
|
*/
|
|
1142
1142
|
rect?: Rect | null;
|
|
1143
1143
|
}
|
|
1144
|
+
export type TestRoute = "desktop" | "folder" | "download";
|
|
1145
|
+
export interface TestMapOutcome {
|
|
1146
|
+
route: TestRoute;
|
|
1147
|
+
/** The file's name, or its full path when the desktop wrote it. */
|
|
1148
|
+
path: string;
|
|
1149
|
+
launched: boolean;
|
|
1150
|
+
/** Why the game did not start, when it was asked to. */
|
|
1151
|
+
message?: string;
|
|
1152
|
+
}
|
|
1144
1153
|
/** What the registry knows about a section name, sized for one map. */
|
|
1145
1154
|
export interface SectionKnowledge {
|
|
1146
1155
|
name: string;
|
|
@@ -1670,6 +1679,13 @@ export interface SaveOptions {
|
|
|
1670
1679
|
/** Drop bytes after the last section header the file could parse. */
|
|
1671
1680
|
dropTrailing: boolean;
|
|
1672
1681
|
}
|
|
1682
|
+
/** A step as the manifest remembers it. */
|
|
1683
|
+
export interface BuiltBy {
|
|
1684
|
+
/** `plugin id/step id`. */
|
|
1685
|
+
id: string;
|
|
1686
|
+
/** The step's label when it ran, for a notice about a step that is no longer there. */
|
|
1687
|
+
label: string;
|
|
1688
|
+
}
|
|
1673
1689
|
export interface ChangeTilesetResult {
|
|
1674
1690
|
from: number;
|
|
1675
1691
|
to: number;
|
|
@@ -2104,6 +2120,12 @@ export interface ExportOptions {
|
|
|
2104
2120
|
* an opened one), so the bytes are what Save would write unless you say otherwise.
|
|
2105
2121
|
*/
|
|
2106
2122
|
saveOptions?: Partial<Omit<SaveOptions, "format">>;
|
|
2123
|
+
/**
|
|
2124
|
+
* False gives the map without its build steps (`document.buildSteps`): the scenario as the
|
|
2125
|
+
* editor holds it. By default the file is the one Save would write, steps run — except
|
|
2126
|
+
* from inside a step, where it is always the map without them.
|
|
2127
|
+
*/
|
|
2128
|
+
built?: boolean;
|
|
2107
2129
|
}
|
|
2108
2130
|
/** `document.save` / `saveAs`. */
|
|
2109
2131
|
export interface SaveDocumentOptions {
|
|
@@ -2117,6 +2139,51 @@ export interface ChangeTilesetOptions {
|
|
|
2117
2139
|
/** Keep the tile numbers and change only ERA (what SCMDraft's switch does). */
|
|
2118
2140
|
keepTiles?: boolean;
|
|
2119
2141
|
}
|
|
2142
|
+
/** Why the map is leaving the editor: File ▸ Save (and its copies), Tools ▸ Test Map, or `document.export`. */
|
|
2143
|
+
export type BuildPurpose = "save" | "test" | "export";
|
|
2144
|
+
export interface BuildStepInput {
|
|
2145
|
+
/**
|
|
2146
|
+
* The map as Save would write it without the steps, or the step before this one's
|
|
2147
|
+
* output: an `.scx` / `.scm` archive, the archive extras inside.
|
|
2148
|
+
*/
|
|
2149
|
+
map: Uint8Array;
|
|
2150
|
+
fileName: string;
|
|
2151
|
+
purpose: BuildPurpose;
|
|
2152
|
+
/** Aborted when the user chooses to save without waiting. */
|
|
2153
|
+
signal: AbortSignal;
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2156
|
+
* A compiler that stands between the map and the disk. The editor keeps showing the map
|
|
2157
|
+
* the user edits; whenever the map leaves — Save, Test Map, `export` — every step that
|
|
2158
|
+
* `applies` is run over the bytes, in the order the plugins were activated, and what the
|
|
2159
|
+
* last one returns is what is written. The editor stores the map as it was *before* the
|
|
2160
|
+
* steps inside the same file and gives that back on open, so a step's output (generated
|
|
2161
|
+
* triggers, a payload in the string table) never shows up in the editor.
|
|
2162
|
+
*
|
|
2163
|
+
* A step that throws, or that the user stops waiting for, does not stop a save: the map is
|
|
2164
|
+
* written without the steps and a notice says why. Test Map stops instead, since a map
|
|
2165
|
+
* without its built part is not the one to test. A bare `.chk` is never built.
|
|
2166
|
+
*/
|
|
2167
|
+
export interface BuildStepSpec {
|
|
2168
|
+
/** Unique within the plugin; the file remembers `plugin id/id`. */
|
|
2169
|
+
id: string;
|
|
2170
|
+
/** What the notice says is running: "eudplib". */
|
|
2171
|
+
label: string;
|
|
2172
|
+
/** Whether the open map has anything for this step. Cheap and synchronous; false leaves Save exactly as it was. */
|
|
2173
|
+
applies(): boolean;
|
|
2174
|
+
/**
|
|
2175
|
+
* Build. Return an archive (or a bare scenario) — the editor takes the scenario and any
|
|
2176
|
+
* *new* members from it and lays the final file out with the user's save options; the
|
|
2177
|
+
* map's own members are written as they were. Throw an `Error` whose message says what
|
|
2178
|
+
* is wrong in the user's terms.
|
|
2179
|
+
*/
|
|
2180
|
+
run(input: BuildStepInput): Promise<Uint8Array>;
|
|
2181
|
+
}
|
|
2182
|
+
export interface BuildStepsApi {
|
|
2183
|
+
add(spec: BuildStepSpec): Disposable;
|
|
2184
|
+
/** The steps behind the file the open map came from or was last saved to; null for a plain map. */
|
|
2185
|
+
builtBy(): BuiltBy[] | null;
|
|
2186
|
+
}
|
|
2120
2187
|
/**
|
|
2121
2188
|
* The files stored in the map archive next to `staredit\scenario.chk`: custom sounds,
|
|
2122
2189
|
* graphics, and anything a plugin wants to keep with the map. Names are archive paths
|
|
@@ -2309,6 +2376,18 @@ export interface DocumentApi {
|
|
|
2309
2376
|
* a map, null.
|
|
2310
2377
|
*/
|
|
2311
2378
|
renderImage(options?: Partial<MapImageOptions>): Promise<Blob | null>;
|
|
2379
|
+
/**
|
|
2380
|
+
* Tools ▸ Test Map for bytes of the plugin's own — a built map that is not the open
|
|
2381
|
+
* one. On the desktop the file is written into the game's `Maps\scmJS` folder and, with
|
|
2382
|
+
* `launch` (the preference when omitted), the game is started; in a browser it is
|
|
2383
|
+
* written into the test folder the user picked once. It never downloads: a browser
|
|
2384
|
+
* with no folder answers null, so a plugin that has already saved the file says "open
|
|
2385
|
+
* it with Test Map" instead of handing out a second copy. `fileName` gets an archive's
|
|
2386
|
+
* extension if it lacks one.
|
|
2387
|
+
*/
|
|
2388
|
+
test(bytes: Uint8Array, fileName: string, options?: {
|
|
2389
|
+
launch?: boolean;
|
|
2390
|
+
}): Promise<TestMapOutcome | null>;
|
|
2312
2391
|
/**
|
|
2313
2392
|
* Scenario ▸ Resize / Crop Map: a transaction outside the undo model that drops both
|
|
2314
2393
|
* history stacks (as the dialog does). Content keeps its place relative to `anchor`
|
|
@@ -2326,6 +2405,7 @@ export interface DocumentApi {
|
|
|
2326
2405
|
changeTileset(options: ChangeTilesetOptions): Promise<ChangeTilesetResult | null>;
|
|
2327
2406
|
readonly extras: ExtrasApi;
|
|
2328
2407
|
readonly sections: SectionsApi;
|
|
2408
|
+
readonly buildSteps: BuildStepsApi;
|
|
2329
2409
|
}
|
|
2330
2410
|
/** What a raw section edit reported: the parser's remarks about the file it produced. */
|
|
2331
2411
|
export interface RawEditResult {
|