@mudlet/mudlet-web 0.4.4 → 0.5.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.
@@ -1,4 +1,4 @@
1
- import type { MudletArea, MudletFont, MudletMap, MudletMapHeader, MudletRoom } from 'mudlet-map-binary-reader';
1
+ import type { MudletArea, MudletColor, MudletFont, MudletLabel, MudletMap, MudletMapHeader, MudletRoom } from 'mudlet-map-binary-reader';
2
2
  import { readerExport } from 'mudlet-map-binary-reader';
3
3
  import { type ExitWeightFilter, type PathfindResult } from './pathfinding';
4
4
  export type { ExitWeightFilter, PathfindResult } from './pathfinding';
@@ -28,6 +28,48 @@ export declare function makeRoom(areaId: number): MudletRoom;
28
28
  */
29
29
  export declare function mudletJsonMapToMudletMap(src: unknown): MudletMap | null;
30
30
  export declare function makeArea(): MudletArea;
31
+ /**
32
+ * A map label as mudix stores it: the binary-map reader's shape plus the fields
33
+ * Mudlet's `TMapLabel` carries that its map file never persists — the font, the
34
+ * outline colour and the `temporary` flag. All optional, so labels read back
35
+ * from a binary map (which have none of them) stay valid without conversion.
36
+ */
37
+ export interface MapLabel extends MudletLabel {
38
+ fontName?: string;
39
+ fontSize?: number;
40
+ temporary?: boolean;
41
+ outlineColor?: MudletColor;
42
+ }
43
+ /**
44
+ * The optional tail of Mudlet's `createMapLabel` — everything after the two
45
+ * colours. Defaults here are Mudlet's own (TLuaInterpreter::createMapLabel),
46
+ * not zero values: omitting them has to produce the label Mudlet would.
47
+ */
48
+ export interface MapLabelOptions {
49
+ /** Map units per rendered pixel; divides the measured text box. Default 30. */
50
+ zoom?: number;
51
+ /** Point size the text is measured at. Default 50. */
52
+ fontSize?: number;
53
+ /** Paint above rooms rather than below them. Default true. */
54
+ showOnTop?: boolean;
55
+ /** Keep a fixed on-screen size instead of scaling with the map. Default true. */
56
+ noScaling?: boolean;
57
+ /** Font family; empty/absent means the default face. */
58
+ fontName?: string;
59
+ /** Foreground (and outline) alpha, 0-255. Default 255. */
60
+ fgAlpha?: number;
61
+ /** Background alpha, 0-255. Default 50 — Mudlet's labels are mostly see-through. */
62
+ bgAlpha?: number;
63
+ /** Excluded from the map save. Default false. */
64
+ temporary?: boolean;
65
+ /** Text outline colour. Defaults to the foreground colour, which is Mudlet's
66
+ * way of saying "no outline" — it only draws one when the two differ. */
67
+ outline?: {
68
+ r: number;
69
+ g: number;
70
+ b: number;
71
+ };
72
+ }
31
73
  export interface MapLabelInfo {
32
74
  X: number;
33
75
  Y: number;
@@ -824,13 +866,17 @@ export declare class MapStore {
824
866
  /**
825
867
  * Mudlet `createMapLabel(areaID, text, posx, posy, posz, fgRed, fgGreen,
826
868
  * fgBlue, bgRed, bgGreen, bgBlue [, zoom [, fontSize [, showOnTop [,
827
- * noScaling]]]])`. Adds a text label to the area and returns its new id, or
828
- * -1 if the area does not exist. (`zoom`/`fontSize` are accepted for
829
- * signature parity — mudix stores labels but the renderer does not yet draw
830
- * them, mirroring how labels loaded from binary maps are kept and queried
831
- * but not painted.)
869
+ * noScaling [, fontName [, foregroundTransparency [, backgroundTransparency
870
+ * [, temporary [, outlineRed, outlineGreen, outlineBlue]]]]]]]]])`. Adds a
871
+ * text label to the area and returns its new id, or -1 if the area does not
872
+ * exist or the text is empty (both are Mudlet's own refusals).
873
+ *
874
+ * `fontName`, `temporary` and the outline colour have nowhere to live in the
875
+ * binary map format, so they are mudix-only fields on the stored label (see
876
+ * `MapLabel`); of the three only `temporary` is visible from Lua, because
877
+ * Mudlet's getMapLabel doesn't publish the other two either.
832
878
  */
833
- createMapLabel(areaId: number, text: string, x: number, y: number, z: number, fgR: number, fgG: number, fgB: number, bgR: number, bgG: number, bgB: number, fontSize?: number, showOnTop?: boolean, noScaling?: boolean): number;
879
+ createMapLabel(areaId: number, text: string, x: number, y: number, z: number, fgR: number, fgG: number, fgB: number, bgR: number, bgG: number, bgB: number, opts?: MapLabelOptions): number;
834
880
  /**
835
881
  * Mudlet `createMapImageLabel(areaID, imagePathFileName, posx, posy, posz,
836
882
  * width, height, zoom [, showOnTop [, noScaling]])`. Adds an image label and
@@ -85,6 +85,15 @@ export interface EngineHost {
85
85
  syncModuleToFile(name: string): Promise<void>;
86
86
  /** Write every module flagged to sync back out to its own file. */
87
87
  saveSyncedModules(): void;
88
+ /** Write the profile out as a Mudlet-format XML save, answering with the
89
+ * full path written. The XML half of `saveProfile([location [, saveName]])`. */
90
+ saveProfileXml(location?: string, saveName?: string): {
91
+ ok: true;
92
+ path: string;
93
+ } | {
94
+ ok: false;
95
+ err: string;
96
+ };
88
97
  reloadModuleFromFile(name: string): boolean;
89
98
  setModuleSync(name: string, sync: boolean): void;
90
99
  getModuleSync(name: string): boolean;
@@ -425,6 +425,15 @@ export declare class ScriptingAPI {
425
425
  /** Write every module flagged to sync back out to its own file. Called by
426
426
  * saveProfile — see the note there. */
427
427
  saveSyncedModules(): void;
428
+ /** Write the profile out as a Mudlet-format XML save. The XML half of
429
+ * `saveProfile([location [, saveName]])` — see ScriptingEngine. */
430
+ saveProfileXml(location?: string, saveName?: string): {
431
+ ok: true;
432
+ path: string;
433
+ } | {
434
+ ok: false;
435
+ err: string;
436
+ };
428
437
  reloadModule(name: string): boolean;
429
438
  enableModuleSync(name: string): void;
430
439
  disableModuleSync(name: string): void;
@@ -147,6 +147,35 @@ export declare class ScriptingEngine implements EngineHost {
147
147
  * now that the folder backend truncates). Mudlet loads the newest such file.
148
148
  */
149
149
  private writeBackLinkedProfile;
150
+ /**
151
+ * The profile as a Mudlet-format `<MudletPackage>` save: `baseXml` with its
152
+ * automation and variable packages replaced by the live store state, and its
153
+ * `<Host>` settings updated in place.
154
+ *
155
+ * Basing on an existing save is what keeps the ~130 `<Host>` fields mudix
156
+ * doesn't model — and any element it doesn't understand — from being dropped
157
+ * on the way out. A profile with no save to base on gets the empty skeleton
158
+ * below, so its `<Host>` carries only the settings mudix does model.
159
+ */
160
+ private buildProfileXml;
161
+ /**
162
+ * The XML half of Mudlet `saveProfile([location [, saveName]])`: write this
163
+ * profile out as a Mudlet-format save and answer with the full path written.
164
+ *
165
+ * Mirrors `Host::saveProfile`'s naming — an empty location means the
166
+ * profile's own `current/`, an empty name means a `YYYY-MM-DD#HH-mm-ss`
167
+ * stamp, and a name without one gains `.xml`. A default-located save also
168
+ * takes over as this session's write-back target, so the automatic flushes
169
+ * keep updating the newest file rather than leaving a stale older one as the
170
+ * save Mudlet would load.
171
+ */
172
+ saveProfileXml(location?: string, saveName?: string): {
173
+ ok: true;
174
+ path: string;
175
+ } | {
176
+ ok: false;
177
+ err: string;
178
+ };
150
179
  /** `_G` entries for the Variables view (user globals nested, built-ins
151
180
  * flagged). Empty until the runtime is up. */
152
181
  listGlobals(): LuaGlobalEntry[];
@@ -27,10 +27,15 @@ export interface MudConnection {
27
27
  * the connection record so the editor can read/write it without mounting the
28
28
  * profile. */
29
29
  charLoginAccount?: string;
30
- /** GMCP `Char.Login` password. ⚠ SECURITY: persisted in **plaintext** in
31
- * localStorage (the app store is not encrypted) — only ever written when the
32
- * user explicitly opts in. Convenient for auto-login but not secure on a
33
- * shared machine. Never logged; relayed straight to the server on login. */
30
+ /** @deprecated The pre-vault plaintext password field. Nothing writes it any
31
+ * more: passwords now live encrypted in the credential vault
32
+ * (`vault/CredentialVault`), because this one sat in localStorage in the
33
+ * clear and the UI offering it had to warn against itself (issue #25).
34
+ *
35
+ * Still *read* (see `utils/storedCredentials`) so an existing saved login
36
+ * keeps working, and folded into the vault — then deleted from here — the
37
+ * first time the user sets one up. Remove the field once enough releases
38
+ * have passed for that migration to have run everywhere. */
34
39
  charLoginPassword?: string;
35
40
  /** Set when this profile was created by linking a Mudlet folder (Link mode):
36
41
  * the folder is the source of truth — its `current/*.xml` is re-read on every