mudlet-map-editor 0.9.0 → 0.10.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.
@@ -691,7 +691,7 @@ function st(e) {
691
691
  }
692
692
  //#endregion
693
693
  //#region src/editor/scriptTypes.ts
694
- var ct = "declare type Direction =\n | 'north' | 'south' | 'east' | 'west'\n | 'northeast' | 'northwest' | 'southeast' | 'southwest'\n | 'up' | 'down' | 'in' | 'out';\n\n/** Frozen read-only snapshot of a room. Re-query via room() / findRooms() after mutations to see updates. */\ndeclare interface Room {\n readonly id: number;\n /** X coordinate (raw). */\n readonly x: number;\n /** Y coordinate (raw Mudlet, +y = north). */\n readonly y: number;\n readonly z: number;\n readonly area: number;\n readonly name: string;\n /** Environment / env id (paint colour index). */\n readonly environment: number;\n /** Room symbol / character. */\n readonly symbol: string;\n readonly weight: number;\n readonly isLocked: boolean;\n readonly userData: Readonly<Record<string, string>>;\n readonly doors: Readonly<Record<string, number>>;\n readonly exitWeights: Readonly<Record<string, number>>;\n readonly specialExits: Readonly<Record<string, number>>;\n readonly stubs: readonly number[];\n readonly exitLocks: readonly number[];\n /** Target room id, or -1. */\n readonly north: number;\n readonly south: number;\n readonly east: number;\n readonly west: number;\n readonly northeast: number;\n readonly northwest: number;\n readonly southeast: number;\n readonly southwest: number;\n readonly up: number;\n readonly down: number;\n readonly in: number;\n readonly out: number;\n}\n\ndeclare interface Area {\n readonly id: number;\n readonly name: string;\n}\n\ndeclare interface Env {\n readonly id: number;\n /** True if env has a custom colour override (map.mCustomEnvColors). */\n readonly custom: boolean;\n readonly r: number;\n readonly g: number;\n readonly b: number;\n /** '#rrggbb'. */\n readonly hex: string;\n /** 'rgb(r,g,b)' — same string the renderer uses. */\n readonly rgb: string;\n}\n\ndeclare interface CustomLineColor {\n r: number; g: number; b: number; alpha?: number;\n}\n\ndeclare interface CustomLineOptions {\n color?: string | CustomLineColor;\n style?: 'solid' | 'dash' | 'dot' | 'dashDot' | 'dashDotDot' | number;\n arrow?: boolean;\n}\n\ndeclare interface ConnectOptions {\n direction?: Direction;\n oneWay?: boolean;\n}\n\n// ── Read ───────────────────────────────────────────────────────────────\n\n/** Return a fresh snapshot array of all rooms. */\ndeclare function rooms(): Room[];\n/** Return rooms matching the predicate. */\ndeclare function findRooms(pred: (r: Room) => boolean): Room[];\n/** Return a snapshot of one room, or undefined. */\ndeclare function room(id: number): Room | undefined;\n/** List of all areas. */\ndeclare function areas(): Area[];\n/** Lookup one area by id. */\ndeclare function area(id: number): Area;\n/** List of every environment known to the map (default palette + custom + ids used by rooms). */\ndeclare function envs(): Env[];\n/** Look up one environment by id. Returns undefined if unknown and unused. */\ndeclare function env(id: number): Env | undefined;\n/** Cardinal direction between two rooms, inferred from map coordinates. */\ndeclare function directionBetween(fromId: number, toId: number): Direction | null;\n\n/** The area currently shown in the editor. */\ndeclare const currentAreaId: number | null;\n/** Current z-level shown in the editor. */\ndeclare const currentZ: number;\n/** All cardinal directions. */\ndeclare const DIRS: readonly Direction[];\n\n// ── I/O ────────────────────────────────────────────────────────────────\n\n/** Append to the script Log panel. */\ndeclare function log(...args: any[]): void;\n\ndeclare const console: {\n /** Alias for log(). */\n log(...args: any[]): void;\n};\n\n// ── Write (collected into one undo batch) ──────────────────────────────\n\n/** Set a room name. */\ndeclare function setRoomName(id: number, name: string): void;\n/** Set a room environment (paint colour). */\ndeclare function setRoomEnv(id: number, env: number): void;\n/** Set a room symbol / character. */\ndeclare function setRoomSymbol(id: number, symbol: string): void;\n/** Set a room weight. */\ndeclare function setRoomWeight(id: number, weight: number): void;\n/** Lock / unlock a room. */\ndeclare function setRoomLock(id: number, locked: boolean): void;\n/** Move a room. Coords are raw Mudlet (y = north is +). */\ndeclare function moveRoom(id: number, x: number, y: number, z: number): void;\n/** Set a cardinal exit. toId < 0 removes it. */\ndeclare function setExit(fromId: number, dir: Direction, toId: number): void;\n/** Set door state: 0=none, 1=open, 2=closed, 3=locked. */\ndeclare function setDoor(roomId: number, dir: Direction, value: number): void;\n/** Set exit traversal weight. */\ndeclare function setExitWeight(roomId: number, dir: Direction, value: number): void;\n/** Lock / unlock an exit. */\ndeclare function setExitLock(roomId: number, dir: Direction, locked: boolean): void;\n/** Add / remove a stub. */\ndeclare function setStub(roomId: number, dir: Direction, stub: boolean): void;\n/** Set a room userData entry. Pass null to delete. */\ndeclare function setUserData(roomId: number, key: string, value: string | null): void;\n/** Set a special (named) exit. toId < 0 removes it. */\ndeclare function setSpecialExit(roomId: number, name: string, toId: number): void;\n/** Link two rooms. Direction inferred from coords for 2D cardinals; pass { direction } for up/down/in/out. */\ndeclare function connectRooms(fromId: number, toId: number, options?: ConnectOptions): Direction | null;\n/** Remove a cardinal exit (and its reverse unless oneWay: true). */\ndeclare function disconnect(fromId: number, dir: Direction, options?: { oneWay?: boolean }): void;\n/** Draw a custom line on a room exit. Points are raw Mudlet [x, y] pairs. */\ndeclare function setCustomLine(roomId: number, exitName: string, points: Array<[number, number]>, options?: CustomLineOptions): void;\n/** Remove a custom line from a room exit. */\ndeclare function removeCustomLine(roomId: number, exitName: string): void;", lt = self;
694
+ var ct = "declare type Direction =\n | 'north' | 'south' | 'east' | 'west'\n | 'northeast' | 'northwest' | 'southeast' | 'southwest'\n | 'up' | 'down' | 'in' | 'out';\n\n/** Frozen read-only snapshot of a room. Re-query via room() / findRooms() after mutations to see updates. */\ndeclare interface Room {\n readonly id: number;\n /** X coordinate (raw). */\n readonly x: number;\n /** Y coordinate (raw Mudlet, +y = north). */\n readonly y: number;\n readonly z: number;\n readonly area: number;\n readonly name: string;\n /** Environment / env id (paint colour index). */\n readonly environment: number;\n /** Room symbol / character. */\n readonly symbol: string;\n readonly weight: number;\n readonly isLocked: boolean;\n readonly userData: Readonly<Record<string, string>>;\n readonly doors: Readonly<Record<string, number>>;\n readonly exitWeights: Readonly<Record<string, number>>;\n readonly specialExits: Readonly<Record<string, number>>;\n readonly stubs: readonly number[];\n readonly exitLocks: readonly number[];\n /**\n * Custom lines on this room, keyed by short cardinal direction ('n', 'ne', …)\n * or special-exit name. Use DIR_SHORT to map a full Direction to its short key.\n */\n readonly customLines: Readonly<Record<string, {\n readonly points: readonly (readonly [number, number])[];\n readonly color: { readonly r: number; readonly g: number; readonly b: number; readonly alpha: number; readonly spec: number };\n /** 1 = solid, 2 = dash, 3 = dot, 4 = dashDot, 5 = dashDotDot. */\n readonly style: number;\n readonly arrow: boolean;\n }>>;\n /** Target room id, or -1. */\n readonly north: number;\n readonly south: number;\n readonly east: number;\n readonly west: number;\n readonly northeast: number;\n readonly northwest: number;\n readonly southeast: number;\n readonly southwest: number;\n readonly up: number;\n readonly down: number;\n readonly in: number;\n readonly out: number;\n}\n\ndeclare interface Area {\n readonly id: number;\n readonly name: string;\n}\n\ndeclare interface Env {\n readonly id: number;\n /** True if env has a custom colour override (map.mCustomEnvColors). */\n readonly custom: boolean;\n readonly r: number;\n readonly g: number;\n readonly b: number;\n /** '#rrggbb'. */\n readonly hex: string;\n /** 'rgb(r,g,b)' — same string the renderer uses. */\n readonly rgb: string;\n}\n\ndeclare interface CustomLineColor {\n r: number; g: number; b: number; alpha?: number;\n}\n\ndeclare interface CustomLineOptions {\n color?: string | CustomLineColor;\n style?: 'solid' | 'dash' | 'dot' | 'dashDot' | 'dashDotDot' | number;\n arrow?: boolean;\n}\n\ndeclare interface ConnectOptions {\n direction?: Direction;\n oneWay?: boolean;\n}\n\n// ── Read ───────────────────────────────────────────────────────────────\n\n/** Return a fresh snapshot array of all rooms. */\ndeclare function rooms(): Room[];\n/** Return rooms matching the predicate. */\ndeclare function findRooms(pred: (r: Room) => boolean): Room[];\n/** Return a snapshot of one room, or undefined. */\ndeclare function room(id: number): Room | undefined;\n/** List of all areas. */\ndeclare function areas(): Area[];\n/** Lookup one area by id. */\ndeclare function area(id: number): Area;\n/** List of every environment known to the map (default palette + custom + ids used by rooms). */\ndeclare function envs(): Env[];\n/** Look up one environment by id. Returns undefined if unknown and unused. */\ndeclare function env(id: number): Env | undefined;\n/** Cardinal direction between two rooms, inferred from map coordinates. */\ndeclare function directionBetween(fromId: number, toId: number): Direction | null;\n\n/** The area currently shown in the editor. */\ndeclare const currentAreaId: number | null;\n/** Current z-level shown in the editor. */\ndeclare const currentZ: number;\n/** All cardinal directions. */\ndeclare const DIRS: readonly Direction[];\n/**\n * Full Direction name → short key used to index room.exitWeights / room.doors /\n * room.customLines. E.g. DIR_SHORT.north === 'n', DIR_SHORT.northeast === 'ne'.\n * 'up' / 'down' / 'in' / 'out' map to themselves.\n */\ndeclare const DIR_SHORT: Readonly<Record<Direction, string>>;\n/** Ids of rooms currently selected in the editor. Empty array if no rooms are selected. */\ndeclare function getSelection(): number[];\n\n// ── I/O ────────────────────────────────────────────────────────────────\n\n/** Append to the script Log panel. */\ndeclare function log(...args: any[]): void;\n\ndeclare const console: {\n /** Alias for log(). */\n log(...args: any[]): void;\n};\n\n// ── Write (collected into one undo batch) ──────────────────────────────\n\n/** Set a room name. */\ndeclare function setRoomName(id: number, name: string): void;\n/** Set a room environment (paint colour). */\ndeclare function setRoomEnv(id: number, env: number): void;\n/** Set a room symbol / character. */\ndeclare function setRoomSymbol(id: number, symbol: string): void;\n/** Set a room weight. */\ndeclare function setRoomWeight(id: number, weight: number): void;\n/** Lock / unlock a room. */\ndeclare function setRoomLock(id: number, locked: boolean): void;\n/** Move a room. Coords are raw Mudlet (y = north is +). */\ndeclare function moveRoom(id: number, x: number, y: number, z: number): void;\n/** Set a cardinal exit. toId < 0 removes it. */\ndeclare function setExit(fromId: number, dir: Direction, toId: number): void;\n/** Set door state: 0=none, 1=open, 2=closed, 3=locked. */\ndeclare function setDoor(roomId: number, dir: Direction, value: number): void;\n/** Set exit traversal weight. */\ndeclare function setExitWeight(roomId: number, dir: Direction, value: number): void;\n/** Lock / unlock an exit. */\ndeclare function setExitLock(roomId: number, dir: Direction, locked: boolean): void;\n/** Add / remove a stub. */\ndeclare function setStub(roomId: number, dir: Direction, stub: boolean): void;\n/** Set a room userData entry. Pass null to delete. */\ndeclare function setUserData(roomId: number, key: string, value: string | null): void;\n/** Set a special (named) exit. toId < 0 removes it. */\ndeclare function setSpecialExit(roomId: number, name: string, toId: number): void;\n/** Link two rooms. Direction inferred from coords for 2D cardinals; pass { direction } for up/down/in/out. */\ndeclare function connectRooms(fromId: number, toId: number, options?: ConnectOptions): Direction | null;\n/** Remove a cardinal exit (and its reverse unless oneWay: true). */\ndeclare function disconnect(fromId: number, dir: Direction, options?: { oneWay?: boolean }): void;\n/** Draw a custom line on a room exit. Points are raw Mudlet [x, y] pairs. */\ndeclare function setCustomLine(roomId: number, exitName: string, points: Array<[number, number]>, options?: CustomLineOptions): void;\n/** Remove a custom line from a room exit. */\ndeclare function removeCustomLine(roomId: number, exitName: string): void;", lt = self;
695
695
  lt.__mmeMonacoConfigured ||= (lt.MonacoEnvironment = { getWorker(e, t) {
696
696
  return t === "typescript" || t === "javascript" ? new st() : new ot();
697
697
  } }, q.config({ monaco: nt }), !0), h.setDiagnosticsOptions({
package/dist-lib/index.js CHANGED
@@ -3235,7 +3235,23 @@ function Xe(e) {
3235
3235
  }
3236
3236
  }
3237
3237
  function Ze(e, t) {
3238
- let n = {
3238
+ let n = {}, r = e.customLines ?? {};
3239
+ for (let t of Object.keys(r)) {
3240
+ let i = e.customLinesColor?.[t] ?? {
3241
+ spec: 1,
3242
+ alpha: 255,
3243
+ r: 255,
3244
+ g: 255,
3245
+ b: 255
3246
+ };
3247
+ n[t] = Object.freeze({
3248
+ points: (r[t] ?? []).map((e) => [e[0], e[1]]),
3249
+ color: { ...i },
3250
+ style: e.customLinesStyle?.[t] ?? 1,
3251
+ arrow: e.customLinesArrow?.[t] ?? !1
3252
+ });
3253
+ }
3254
+ let i = {
3239
3255
  id: t,
3240
3256
  x: e.x,
3241
3257
  y: e.y,
@@ -3245,16 +3261,17 @@ function Ze(e, t) {
3245
3261
  environment: e.environment,
3246
3262
  symbol: e.symbol ?? "",
3247
3263
  weight: e.weight,
3248
- isLocked: !!e.isLocked,
3264
+ isLocked: e.isLocked,
3249
3265
  userData: { ...e.userData ?? {} },
3250
3266
  doors: { ...e.doors ?? {} },
3251
3267
  exitWeights: { ...e.exitWeights ?? {} },
3252
3268
  specialExits: { ...e.mSpecialExits ?? {} },
3253
3269
  stubs: [...e.stubs ?? []],
3254
- exitLocks: [...e.exitLocks ?? []]
3270
+ exitLocks: [...e.exitLocks ?? []],
3271
+ customLines: Object.freeze(n)
3255
3272
  };
3256
- for (let t of B) n[t] = e[t];
3257
- return Object.freeze(n);
3273
+ for (let t of B) i[t] = e[t];
3274
+ return Object.freeze(i);
3258
3275
  }
3259
3276
  function Qe(e, t) {
3260
3277
  let n = M.getState(), r = n.map;
@@ -3327,6 +3344,11 @@ function Qe(e, t) {
3327
3344
  currentAreaId: n.currentAreaId,
3328
3345
  currentZ: n.currentZ,
3329
3346
  DIRS: [...B],
3347
+ DIR_SHORT: { ...V },
3348
+ getSelection: () => {
3349
+ let e = M.getState().selection;
3350
+ return e && e.kind === "room" ? [...e.ids] : [];
3351
+ },
3330
3352
  log: d,
3331
3353
  console: { log: d },
3332
3354
  setRoomName: (e, t) => {
@@ -3370,10 +3392,10 @@ function Qe(e, t) {
3370
3392
  });
3371
3393
  },
3372
3394
  setRoomLock: (e, t) => {
3373
- !!c(e).isLocked != !!t && s({
3395
+ c(e).isLocked !== t && s({
3374
3396
  kind: "setRoomLock",
3375
3397
  id: e,
3376
- lock: !!t
3398
+ lock: t
3377
3399
  });
3378
3400
  },
3379
3401
  moveRoom: (e, t, n, r) => {
@@ -3432,20 +3454,20 @@ function Qe(e, t) {
3432
3454
  },
3433
3455
  setExitLock: (e, t, n) => {
3434
3456
  let r = c(e), i = le[t];
3435
- (r.exitLocks?.includes(i) ?? !1) !== !!n && s({
3457
+ (r.exitLocks?.includes(i) ?? !1) !== n && s({
3436
3458
  kind: "setExitLock",
3437
3459
  roomId: e,
3438
3460
  dir: t,
3439
- lock: !!n
3461
+ lock: n
3440
3462
  });
3441
3463
  },
3442
3464
  setStub: (e, t, n) => {
3443
3465
  let r = c(e), i = le[t];
3444
- (r.stubs?.includes(i) ?? !1) !== !!n && s({
3466
+ (r.stubs?.includes(i) ?? !1) !== n && s({
3445
3467
  kind: "setStub",
3446
3468
  roomId: e,
3447
3469
  dir: t,
3448
- stub: !!n
3470
+ stub: n
3449
3471
  });
3450
3472
  },
3451
3473
  setUserData: (e, t, n) => {
@@ -3678,6 +3700,20 @@ var $e = [
3678
3700
  info: "All cardinal directions: 'north', 'south', 'east', 'west', 'northeast', 'northwest', 'southeast', 'southwest', 'up', 'down', 'in', 'out'.",
3679
3701
  returns: "DirectionArray"
3680
3702
  },
3703
+ {
3704
+ name: "DIR_SHORT",
3705
+ kind: "variable",
3706
+ detail: "Record<Direction, string>",
3707
+ info: "Full Direction name → short key used to index room.exitWeights / room.doors / room.customLines (e.g. 'north' → 'n', 'northeast' → 'ne'). 'up'/'down'/'in'/'out' map to themselves."
3708
+ },
3709
+ {
3710
+ name: "getSelection",
3711
+ kind: "function",
3712
+ signature: "getSelection(): number[]",
3713
+ detail: "Read",
3714
+ info: "Ids of rooms currently selected in the editor. Empty array if no rooms are selected (including when the selection is an exit, label, etc.).",
3715
+ returns: "unknown"
3716
+ },
3681
3717
  {
3682
3718
  name: "log",
3683
3719
  kind: "function",
@@ -3986,6 +4022,12 @@ var $e = [
3986
4022
  detail: "number[]",
3987
4023
  info: "Locked exit direction indices."
3988
4024
  },
4025
+ {
4026
+ name: "customLines",
4027
+ kind: "variable",
4028
+ detail: "Record<string, { points, color, style, arrow }>",
4029
+ info: "Custom lines on this room, keyed by short cardinal direction ('n', 'ne', …) or special-exit name. Each entry: { points: [x,y][], color: { r, g, b, alpha, spec }, style: 1–5, arrow: boolean }."
4030
+ },
3989
4031
  {
3990
4032
  name: "north",
3991
4033
  kind: "variable",
@@ -4446,7 +4488,7 @@ function lt({ library: e, currentName: t, onLoad: n, onDelete: r, onClose: a })
4446
4488
  }
4447
4489
  //#endregion
4448
4490
  //#region src/components/panels/ScriptPanel.tsx
4449
- var ut = r(() => import("./ScriptCodeEditor-DYiJp5Tn.js"));
4491
+ var ut = r(() => import("./ScriptCodeEditor-CZAC7bSu.js"));
4450
4492
  function dt() {
4451
4493
  return /* @__PURE__ */ h("div", {
4452
4494
  className: "script-editor-loading",
@@ -15930,7 +15972,7 @@ function io({ plugins: e = [], title: n = "Mudlet Map Editor" }) {
15930
15972
  for (let t of e) await t.onAppReady?.();
15931
15973
  })();
15932
15974
  }, []), i(() => {
15933
- import("./ScriptCodeEditor-DYiJp5Tn.js");
15975
+ import("./ScriptCodeEditor-CZAC7bSu.js");
15934
15976
  }, []);
15935
15977
  let R = o(l);
15936
15978
  i(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mudlet-map-editor",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "Mudlet Map Editor",
6
6
  "keywords": [