mudlet-map-renderer 1.0.0 → 1.2.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.
Files changed (106) hide show
  1. package/README.md +520 -0
  2. package/dist/AreaMapRenderer.d.ts +125 -0
  3. package/dist/CullingManager.d.ts +15 -0
  4. package/dist/ExitRenderer.d.ts +109 -0
  5. package/dist/InteractionHandler.d.ts +47 -0
  6. package/dist/MapGraph.d.ts +28 -0
  7. package/dist/MapReader-mU_4JWv_.js +224 -0
  8. package/dist/MapReader-mU_4JWv_.js.map +1 -0
  9. package/dist/MapState.d.ts +110 -0
  10. package/dist/PathData.d.ts +18 -0
  11. package/dist/PathFinder.d.ts +12 -0
  12. package/dist/ScenePipeline.d.ts +226 -0
  13. package/dist/SvgTypes.d.ts +21 -0
  14. package/dist/TypedEventEmitter.d.ts +17 -0
  15. package/dist/binary/BinaryMapReader.d.ts +36 -0
  16. package/dist/binary/index.d.ts +2 -0
  17. package/dist/binary.mjs +34 -0
  18. package/dist/binary.mjs.map +1 -0
  19. package/dist/camera/Camera.d.ts +118 -0
  20. package/dist/coord/CoordFn.d.ts +13 -0
  21. package/dist/directions.d.ts +25 -0
  22. package/dist/draw/DrawCommand.d.ts +104 -0
  23. package/dist/draw/DrawCommandBuilder.d.ts +19 -0
  24. package/dist/export/CanvasExporter.d.ts +71 -0
  25. package/dist/export/Exporter.d.ts +58 -0
  26. package/dist/export/PngExporter.d.ts +23 -0
  27. package/dist/export/SvgExporter.d.ts +19 -0
  28. package/dist/export/canvasToBytes.d.ts +19 -0
  29. package/dist/export/clipSceneToViewport.d.ts +48 -0
  30. package/dist/export/flushSceneShapes.d.ts +21 -0
  31. package/dist/export/sceneBounds.d.ts +24 -0
  32. package/dist/hit/HitTester.d.ts +101 -0
  33. package/dist/index.d.ts +61 -0
  34. package/dist/index.mjs +6670 -0
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/lens/ExplorationLens.d.ts +29 -0
  37. package/dist/lens/RoomLens.d.ts +47 -0
  38. package/dist/lens/composeLenses.d.ts +31 -0
  39. package/dist/lens/index.d.ts +5 -0
  40. package/dist/overlay/AmbientLightOverlay.d.ts +32 -0
  41. package/dist/overlay/LiveEffect.d.ts +33 -0
  42. package/dist/overlay/SceneOverlay.d.ts +68 -0
  43. package/dist/reader/Area.d.ts +63 -0
  44. package/dist/reader/Exit.d.ts +15 -0
  45. package/dist/reader/MapReader.d.ts +34 -0
  46. package/dist/reader/Plane.d.ts +33 -0
  47. package/dist/render/CanvasRenderer.d.ts +17 -0
  48. package/dist/render/RecordingLayer.d.ts +158 -0
  49. package/dist/render/SvgRenderer.d.ts +7 -0
  50. package/dist/render/shapeToRecording.d.ts +3 -0
  51. package/dist/rendering/KonvaRenderBackend.d.ts +122 -0
  52. package/dist/rendering/MapRenderer.d.ts +213 -0
  53. package/dist/rendering/SceneManager.d.ts +54 -0
  54. package/dist/scene/AmbientLightStyle.d.ts +29 -0
  55. package/dist/scene/GridStyle.d.ts +21 -0
  56. package/dist/scene/InnerExitStyle.d.ts +24 -0
  57. package/dist/scene/OverlayStyle.d.ts +47 -0
  58. package/dist/scene/RoomStyle.d.ts +32 -0
  59. package/dist/scene/Shape.d.ts +151 -0
  60. package/dist/scene/SpecialExitStyle.d.ts +37 -0
  61. package/dist/scene/StubStyle.d.ts +15 -0
  62. package/dist/scene/elements/ExitLayout.d.ts +22 -0
  63. package/dist/scene/elements/GridLayout.d.ts +24 -0
  64. package/dist/scene/elements/LabelLayout.d.ts +11 -0
  65. package/dist/scene/elements/OverlayLayout.d.ts +14 -0
  66. package/dist/scene/elements/RoomLayout.d.ts +19 -0
  67. package/dist/scene/elements/SpecialExitLayout.d.ts +19 -0
  68. package/dist/scene/elements/StubLayout.d.ts +19 -0
  69. package/dist/style/Style.d.ts +60 -0
  70. package/dist/style/applyStyle.d.ts +3 -0
  71. package/dist/style/index.d.ts +21 -0
  72. package/dist/style/shape/BlueprintStyle.d.ts +11 -0
  73. package/dist/style/shape/ConstructionStyle.d.ts +17 -0
  74. package/dist/style/shape/IsometricStyle.d.ts +32 -0
  75. package/dist/style/shape/NeonStyle.d.ts +17 -0
  76. package/dist/style/shape/ParchmentStyle.d.ts +13 -0
  77. package/dist/style/shape/SciFiStyle.d.ts +16 -0
  78. package/dist/style/shape/SketchyStyle.d.ts +22 -0
  79. package/dist/style/shape/index.d.ts +25 -0
  80. package/dist/style/shape/paintMap.d.ts +25 -0
  81. package/dist/style/shape/wobble.d.ts +24 -0
  82. package/{src/types/MapData.ts → dist/types/MapData.d.ts} +70 -90
  83. package/dist/types/Settings.d.ts +206 -0
  84. package/dist/utils/color.d.ts +12 -0
  85. package/dist/utils/textMeasure.d.ts +38 -0
  86. package/package.json +67 -37
  87. package/demo/colors.json +0 -1
  88. package/demo/index.html +0 -102
  89. package/demo/main.ts +0 -389
  90. package/demo/mapExport.json +0 -1
  91. package/demo/tsconfig.json +0 -11
  92. package/src/ExitRenderer.ts +0 -275
  93. package/src/PathFinder.ts +0 -93
  94. package/src/PathRenderer.ts +0 -129
  95. package/src/Renderer.ts +0 -374
  96. package/src/directions.ts +0 -66
  97. package/src/index.ts +0 -4
  98. package/src/reader/Area.ts +0 -96
  99. package/src/reader/Exit.ts +0 -36
  100. package/src/reader/ExplorationArea.ts +0 -132
  101. package/src/reader/MapReader.ts +0 -123
  102. package/src/reader/Plane.ts +0 -42
  103. package/tsconfig.json +0 -17
  104. package/vercel.json +0 -5
  105. package/vite.config.ts +0 -29
  106. package/vite.demo.config.ts +0 -15
@@ -1,90 +1,70 @@
1
- declare namespace MapData {
2
-
3
- export type direction =
4
- "north"
5
- | "south"
6
- | "east"
7
- | "west"
8
- | "northwest"
9
- | "northeast"
10
- | "southeast"
11
- | "southwest"
12
- | "up"
13
- | "down"
14
- | "in"
15
- | "out"
16
-
17
- export interface Color {
18
- alpha: number;
19
- r: number;
20
- g: number;
21
- b: number;
22
- }
23
-
24
- export interface Line {
25
- points: Point[];
26
- attributes: LineAttribute;
27
- }
28
-
29
- export interface Point {
30
- x: number;
31
- y: number;
32
- }
33
-
34
- export interface LineAttribute {
35
- color: Color;
36
- style: string;
37
- arrow: boolean;
38
- }
39
-
40
- export interface Room {
41
- id: number;
42
- area: number;
43
- x: number;
44
- y: number;
45
- z: number;
46
- areaId: string;
47
- weight: number;
48
- roomChar: string;
49
- name: string;
50
- userData: Record<string, string>;
51
- customLines: Record<string, Line>;
52
- stubs: number[];
53
- hash: string;
54
- env: number;
55
- exits: Record<direction, number>;
56
- doors: Record<string, 1 | 2 | 3>;
57
- specialExits: Record<string, number>;
58
- exitLocks?: number[];
59
- mSpecialExitLocks?: number[];
60
- }
61
-
62
- export interface Label {
63
- labelId: number;
64
- areaId: number;
65
- pixMap: string;
66
- X: number;
67
- Y: number;
68
- Z: number;
69
- Width: number;
70
- Height: number;
71
- Text: string;
72
- FgColor: Color;
73
- BgColor: Color;
74
- }
75
-
76
- export interface Area {
77
- areaName: string;
78
- areaId: string;
79
- rooms: Room[];
80
- labels: Label[];
81
- }
82
-
83
- export type Map = Area[]
84
-
85
- export interface Env {
86
- envId: number;
87
- colors: number[];
88
- }
89
-
90
- }
1
+ declare namespace MapData {
2
+ type direction = "north" | "south" | "east" | "west" | "northwest" | "northeast" | "southeast" | "southwest" | "up" | "down" | "in" | "out";
3
+ interface Color {
4
+ alpha: number;
5
+ r: number;
6
+ g: number;
7
+ b: number;
8
+ }
9
+ interface Line {
10
+ points: Point[];
11
+ attributes: LineAttribute;
12
+ }
13
+ interface Point {
14
+ x: number;
15
+ y: number;
16
+ }
17
+ interface LineAttribute {
18
+ color: Color;
19
+ style: string;
20
+ arrow: boolean;
21
+ }
22
+ interface Room {
23
+ id: number;
24
+ area: number;
25
+ x: number;
26
+ y: number;
27
+ z: number;
28
+ areaId: string;
29
+ weight: number;
30
+ roomChar: string;
31
+ name: string;
32
+ userData: Record<string, string>;
33
+ customLines: Record<string, Line>;
34
+ stubs: number[];
35
+ hash: string;
36
+ env: number;
37
+ exits: Record<direction, number>;
38
+ doors: Record<string, 1 | 2 | 3>;
39
+ specialExits: Record<string, number>;
40
+ exitLocks?: number[];
41
+ exitWeights?: Record<string, number>;
42
+ mSpecialExitLocks?: number[];
43
+ }
44
+ interface Label {
45
+ labelId: number;
46
+ areaId: number;
47
+ pixMap?: string;
48
+ X: number;
49
+ Y: number;
50
+ Z: number;
51
+ Width: number;
52
+ Height: number;
53
+ Text: string;
54
+ FgColor: Color;
55
+ BgColor: Color;
56
+ noScaling?: boolean;
57
+ showOnTop?: boolean;
58
+ }
59
+ interface Area {
60
+ areaName: string;
61
+ areaId: string;
62
+ rooms: Room[];
63
+ labels: Label[];
64
+ }
65
+ type Map = Area[];
66
+ interface Env {
67
+ envId: number;
68
+ colors: number[];
69
+ }
70
+ }
@@ -0,0 +1,206 @@
1
+ export type LabelRenderMode = "image" | "data" | "none";
2
+ export type CullingMode = "none" | "basic" | "indexed";
3
+ export type RoomShape = "rectangle" | "circle" | "roundedRectangle";
4
+ export type RoomContextMenuEventDetail = {
5
+ roomId: number;
6
+ position: {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ };
11
+ export type RoomClickEventDetail = {
12
+ roomId: number;
13
+ position: {
14
+ x: number;
15
+ y: number;
16
+ };
17
+ };
18
+ export type ZoomChangeEventDetail = {
19
+ zoom: number;
20
+ };
21
+ export type AreaExitClickEventDetail = {
22
+ targetRoomId: number;
23
+ position: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ };
28
+ export type ViewportBounds = {
29
+ minX: number;
30
+ maxX: number;
31
+ minY: number;
32
+ maxY: number;
33
+ };
34
+ export type PanEventDetail = ViewportBounds;
35
+ export type RendererEventMap = {
36
+ roomclick: RoomClickEventDetail;
37
+ roomcontextmenu: RoomContextMenuEventDetail;
38
+ areaexitclick: AreaExitClickEventDetail;
39
+ mapclick: undefined;
40
+ pan: PanEventDetail;
41
+ zoom: ZoomChangeEventDetail;
42
+ };
43
+ /**
44
+ * Style configuration for the player position marker.
45
+ * The player marker is a circle that indicates the current player position on the map.
46
+ */
47
+ export type PlayerMarkerStyle = {
48
+ /**
49
+ * Hex color for the marker's stroke/border (e.g., "#00e5b2" for cyan-green).
50
+ */
51
+ strokeColor: string;
52
+ /**
53
+ * Opacity for the stroke/border (0.0 = fully transparent, 1.0 = fully opaque).
54
+ */
55
+ strokeAlpha: number;
56
+ /**
57
+ * Hex color for the marker's fill (e.g., "#00e5b2" for cyan-green).
58
+ */
59
+ fillColor: string;
60
+ /**
61
+ * Opacity for the fill (0.0 = fully transparent, 1.0 = fully opaque).
62
+ * Setting this to 0 creates a hollow circle effect.
63
+ */
64
+ fillAlpha: number;
65
+ /**
66
+ * Width of the marker's stroke/border in map units (typically 0.01-0.3).
67
+ */
68
+ strokeWidth: number;
69
+ /**
70
+ * Size multiplier relative to the room size.
71
+ * - 1.0 = marker radius equals room radius (matches room size)
72
+ * - Values > 1.0 make the marker larger than rooms
73
+ * - Values < 1.0 make the marker smaller than rooms
74
+ *
75
+ * Note: Room circles have radius = roomSize / 2, so sizeFactor is applied to that radius.
76
+ */
77
+ sizeFactor: number;
78
+ /**
79
+ * Dash pattern for the stroke as an array of [dash length, gap length].
80
+ * Example: [0.05, 0.05] creates evenly spaced dashes.
81
+ * Only applied when dashEnabled is true.
82
+ */
83
+ dash?: number[];
84
+ /**
85
+ * Whether to apply the dash pattern to the stroke.
86
+ * When false, the stroke is solid regardless of the dash property.
87
+ */
88
+ dashEnabled: boolean;
89
+ /**
90
+ * When true, the marker shape matches the current roomShape setting
91
+ * (rectangle, circle, or roundedRectangle) instead of always being a circle.
92
+ */
93
+ matchRoomShape: boolean;
94
+ };
95
+ /**
96
+ * Style configuration for room highlights.
97
+ * Highlights are rings drawn around rooms registered via {@link MapRenderer.renderHighlight}.
98
+ * The highlight's color is supplied per-call; this style controls everything else.
99
+ */
100
+ export type HighlightStyle = {
101
+ /**
102
+ * Opacity for the highlight's stroke/ring (0.0 = fully transparent, 1.0 = fully opaque).
103
+ */
104
+ strokeAlpha: number;
105
+ /**
106
+ * Opacity for the fill (0.0 = fully transparent / hollow, 1.0 = fully opaque).
107
+ * The fill uses the per-highlight color. Defaults to 0 to preserve the hollow ring look.
108
+ */
109
+ fillAlpha: number;
110
+ /**
111
+ * Width of the highlight stroke in map units (typically 0.01-0.3).
112
+ */
113
+ strokeWidth: number;
114
+ /**
115
+ * Size multiplier relative to the room size.
116
+ * - 1.0 = highlight matches room size
117
+ * - Values > 1.0 produce a ring outside the room
118
+ * - Values < 1.0 produce a smaller marker inside the room
119
+ */
120
+ sizeFactor: number;
121
+ /**
122
+ * Dash pattern for the stroke as an array of [dash length, gap length].
123
+ * Only applied when dashEnabled is true.
124
+ */
125
+ dash?: number[];
126
+ /**
127
+ * Whether to apply the dash pattern to the stroke.
128
+ * When false, the stroke is solid regardless of the dash property.
129
+ */
130
+ dashEnabled: boolean;
131
+ /**
132
+ * When true, the highlight shape matches the current roomShape setting
133
+ * (rectangle, circle, or roundedRectangle). When false, the highlight is always a circle.
134
+ */
135
+ matchRoomShape: boolean;
136
+ };
137
+ /**
138
+ * Settings for map rendering.
139
+ * All properties can be modified at runtime to change the map's appearance and behavior.
140
+ * Create with {@link createSettings} and pass to the renderer constructor.
141
+ */
142
+ export type Settings = {
143
+ /** Size of each room in map units (width/height for rectangles, diameter for circles). Default: 0.6 */
144
+ roomSize: number;
145
+ /** Width of lines (exit connections, room borders) in map units. Default: 0.025 */
146
+ lineWidth: number;
147
+ /** Color of exit connection lines as RGB string. Default: 'rgb(225, 255, 225)' */
148
+ lineColor: string;
149
+ /** Background color of the map container. Default: '#000000' */
150
+ backgroundColor: string;
151
+ /** When true, map instantly jumps to new position on room change. Default: false */
152
+ instantMapMove: boolean;
153
+ /** When true, highlights the current room and its exits with an overlay. Default: true */
154
+ highlightCurrentRoom: boolean;
155
+ /** Legacy flag for enabling/disabling culling (prefer cullingMode). Default: true */
156
+ cullingEnabled: boolean;
157
+ /** How off-screen elements are culled: "none" | "basic" | "indexed". Default: "indexed" */
158
+ cullingMode: CullingMode;
159
+ /** Custom culling bounds in map coordinates, or null for viewport bounds. Default: null */
160
+ cullingBounds: {
161
+ x: number;
162
+ y: number;
163
+ width: number;
164
+ height: number;
165
+ } | null;
166
+ /** How to render room labels: "image" | "data". Default: "image" */
167
+ labelRenderMode: LabelRenderMode;
168
+ /** When true, room labels have transparent backgrounds. Default: false */
169
+ transparentLabels: boolean;
170
+ /** Shape used to render rooms: "rectangle" | "circle" | "roundedRectangle". Default: "rectangle" */
171
+ roomShape: RoomShape;
172
+ /** Style configuration for the player position marker. */
173
+ playerMarker: PlayerMarkerStyle;
174
+ /** Style configuration for room highlights (added via {@link MapRenderer.renderHighlight}). */
175
+ highlight: HighlightStyle;
176
+ /** Whether to render a background grid. Default: false */
177
+ gridEnabled: boolean;
178
+ /** Grid line spacing in map units. Default: 1 */
179
+ gridSize: number;
180
+ /** Color of grid lines as CSS color string. Default: 'rgba(255, 255, 255, 0.07)' */
181
+ gridColor: string;
182
+ /** Width of grid lines in map units. Default: 0.02 */
183
+ gridLineWidth: number;
184
+ /** Whether to draw borders (strokes) on rooms. Default: true */
185
+ borders: boolean;
186
+ /** When true, rooms use frame rendering: fill=backgroundColor, stroke=envColor. Default: false */
187
+ frameMode: boolean;
188
+ /** When true, rooms use colored rendering: fill=envColor darkened 30%, stroke=envColor. Default: false */
189
+ coloredMode: boolean;
190
+ /** When true, rooms display a 3D emboss effect (rectangle/roundedRectangle only). Default: false */
191
+ emboss: boolean;
192
+ /** When true, displays the area name as a header text on the map. Default: false */
193
+ areaName: boolean;
194
+ /** Font family for the area name header. Default: 'sans-serif' */
195
+ fontFamily: string;
196
+ /** When true, uses bounds from all z-levels for viewport sizing, not just the current level. Default: false */
197
+ uniformLevelSize: boolean;
198
+ /** When true, renders a small text label next to area-exit arrows showing the target area name.
199
+ * Exits leading to the same target area are grouped — one label per area at the cluster centroid. Default: false */
200
+ areaExitLabels: boolean;
201
+ /** Font size (in map units) for area-exit labels. Padding, corner radius, and stroke
202
+ * scale proportionally. Default: 0.3 */
203
+ areaExitLabelFontSize: number;
204
+ };
205
+ /** Creates a new Settings object with default values. */
206
+ export declare function createSettings(): Settings;
@@ -0,0 +1,12 @@
1
+ export declare function colorLightness(color: string): number;
2
+ export declare function darkenColor(color: string, factor: number): string;
3
+ export declare function lightenColor(color: string, factor: number): string;
4
+ /**
5
+ * Apply an alpha value to any CSS colour. Accepts `#rgb`, `#rrggbb`, `rgb(...)`,
6
+ * `rgba(...)` (alphas multiply), and the named colours in {@link NAMED_COLORS}.
7
+ * Falls back to returning the input unchanged for unrecognised formats so the
8
+ * shape stays visible rather than collapsing to black.
9
+ *
10
+ * The name is historical — see also call sites that take any user-supplied colour.
11
+ */
12
+ export declare function hexToRgba(color: string, alpha: number): string;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Pixel-accurate vertical centering helper.
3
+ *
4
+ * The canvas TextMetrics API (actualBoundingBoxAscent / Descent) is unreliable
5
+ * across browsers and fonts. Instead we draw the glyph on an offscreen canvas
6
+ * with a known baseline position, scan the actual rendered pixels to find the
7
+ * true visual top and bottom, and derive the offset we need.
8
+ *
9
+ * We use textBaseline='alphabetic' so that the result is consistent with the
10
+ * original rendering code (which used alphabetic + a hard-coded 0.35em offset).
11
+ * For a typical uppercase letter the function returns ~0.35 (same as the old
12
+ * magic number), but for glyphs that extend below the baseline (e.g. "[]") it
13
+ * returns a smaller value, shifting them up to their true visual centre.
14
+ *
15
+ * Return value: multiply by fontSize and add to room.y; use with
16
+ * ctx.textBaseline = 'alphabetic'
17
+ * ctx.fillText(text, room.x, room.y + result * fontSize)
18
+ */
19
+ export interface BaselineResult {
20
+ /** Offset from room-centre to alphabetic baseline, as a ratio of fontSize (for SVG). */
21
+ baselineRatio: number;
22
+ /**
23
+ * Correction for Konva's built-in verticalAlign='middle', as a ratio of fontSize.
24
+ * Konva centres text using font-wide bounding-box metrics (measured from 'M'),
25
+ * which is wrong for glyphs whose visual extent differs (e.g. "[]").
26
+ * Apply as offsetY = konvaCorrectionRatio * fontSize (positive = shift up).
27
+ */
28
+ konvaCorrectionRatio: number;
29
+ }
30
+ /**
31
+ * Returns the Y offset from room-centre to alphabetic baseline, as a ratio of
32
+ * fontSize, so that the glyph appears visually centred.
33
+ *
34
+ * For a standard uppercase letter (no descenders) this is close to
35
+ * capHeight/2 ≈ 0.35. For characters that extend below the baseline the
36
+ * returned value is smaller, which moves the rendered text upward.
37
+ */
38
+ export declare function measureTextBaselineOffset(text: string, fontFamily: string): BaselineResult;
package/package.json CHANGED
@@ -1,37 +1,67 @@
1
- {
2
- "name": "mudlet-map-renderer",
3
- "version": "1.0.0",
4
- "license": "MIT",
5
- "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.mjs",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.cjs"
14
- }
15
- },
16
- "sideEffects": false,
17
- "scripts": {
18
- "dev": "vite",
19
- "build": "tsc -p tsconfig.json && vite build",
20
- "preview": "vite preview",
21
- "demo:dev": "vite --config vite.demo.config.ts",
22
- "demo:build": "vite build --config vite.demo.config.ts",
23
- "demo:preview": "vite preview --config vite.demo.config.ts"
24
- },
25
- "dependencies": {
26
- "konva": "^10.0.2",
27
- "node-dijkstra": "^2.5.1"
28
- },
29
- "devDependencies": {
30
- "tslib": "^2.8.1",
31
- "tsx": "^4.19.1",
32
- "typescript": "^5.6.3",
33
- "vite": "^5.4.8",
34
- "vite-plugin-dts": "^4.3.0",
35
- "@types/node-dijkstra": "^2.5.6"
36
- }
37
- }
1
+ {
2
+ "name": "mudlet-map-renderer",
3
+ "version": "1.2.0",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "url": "https://github.com/Delwing/mudlet-map-renderer"
7
+ },
8
+ "type": "module",
9
+ "main": "./dist/index.mjs",
10
+ "module": "./dist/index.mjs",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.mjs"
16
+ },
17
+ "./binary": {
18
+ "types": "./dist/binary/index.d.ts",
19
+ "import": "./dist/binary.mjs"
20
+ }
21
+ },
22
+ "sideEffects": false,
23
+ "scripts": {
24
+ "prepublish": "vite build",
25
+ "build": "tsc -p tsconfig.json && vite build",
26
+ "preview": "vite preview",
27
+ "demo:dev": "vite --config vite.demo.config.ts",
28
+ "demo:build": "vite build --config vite.demo.config.ts",
29
+ "demo:preview": "vite preview --config vite.demo.config.ts",
30
+ "demo:headless": "tsx --tsconfig demo/tsconfig.json demo/headless.ts",
31
+ "demo:regenerate": "tsx --tsconfig demo/tsconfig.json demo/regenerate-outputs.ts",
32
+ "snapshot-review": "tsx scripts/snapshot-review.ts",
33
+ "snapshot-review:master": "tsx scripts/snapshot-review.ts --from-master",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest",
36
+ "test:visual": "playwright test",
37
+ "test:visual:update": "playwright test --update-snapshots"
38
+ },
39
+ "dependencies": {
40
+ "konva": "^10.2.4",
41
+ "node-dijkstra": "^2.5.1"
42
+ },
43
+ "peerDependencies": {
44
+ "mudlet-map-binary-reader": ">=0.9.0"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "mudlet-map-binary-reader": {
48
+ "optional": true
49
+ }
50
+ },
51
+ "devDependencies": {
52
+ "@playwright/test": "^1.59.1",
53
+ "@types/node": "^25.6.0",
54
+ "@types/node-dijkstra": "^2.5.6",
55
+ "canvas": "^3.2.3",
56
+ "mudlet-map-binary-reader": "^0.9.0",
57
+ "tslib": "^2.8.1",
58
+ "tsx": "^4.21.0",
59
+ "typescript": "^6.0.2",
60
+ "vite": "^8.0.8",
61
+ "vite-plugin-dts": "^4.5.4",
62
+ "vitest": "^4.1.4"
63
+ },
64
+ "files": [
65
+ "dist"
66
+ ]
67
+ }
package/demo/colors.json DELETED
@@ -1 +0,0 @@
1
- [{"envId":1,"colors":[128,0,0]},{"envId":2,"colors":[0,128,0]},{"envId":3,"colors":[128,128,0]},{"envId":4,"colors":[0,0,128]},{"envId":5,"colors":[128,0,128]},{"envId":6,"colors":[0,128,128]},{"envId":7,"colors":[192,192,192]},{"envId":8,"colors":[0,0,0]},{"envId":9,"colors":[255,0,0]},{"envId":10,"colors":[0,255,0]},{"envId":11,"colors":[255,255,0]},{"envId":12,"colors":[0,0,255]},{"envId":13,"colors":[255,0,255]},{"envId":14,"colors":[0,255,255]},{"envId":15,"colors":[255,255,255]},{"envId":16,"colors":[128,128,128]},{"envId":17,"colors":[0,0,95]},{"envId":18,"colors":[0,0,135]},{"envId":19,"colors":[0,0,175]},{"envId":20,"colors":[0,0,215]},{"envId":21,"colors":[0,0,255]},{"envId":22,"colors":[0,95,0]},{"envId":23,"colors":[0,95,95]},{"envId":24,"colors":[0,95,135]},{"envId":25,"colors":[0,95,175]},{"envId":26,"colors":[0,95,215]},{"envId":27,"colors":[0,95,255]},{"envId":28,"colors":[0,135,0]},{"envId":29,"colors":[0,135,95]},{"envId":30,"colors":[0,135,135]},{"envId":31,"colors":[0,135,175]},{"envId":32,"colors":[0,135,215]},{"envId":33,"colors":[0,135,255]},{"envId":34,"colors":[0,175,0]},{"envId":35,"colors":[0,175,95]},{"envId":36,"colors":[0,175,135]},{"envId":37,"colors":[0,175,175]},{"envId":38,"colors":[0,175,215]},{"envId":39,"colors":[0,175,255]},{"envId":40,"colors":[0,215,0]},{"envId":41,"colors":[0,215,95]},{"envId":42,"colors":[0,215,135]},{"envId":43,"colors":[0,215,175]},{"envId":44,"colors":[0,215,215]},{"envId":45,"colors":[0,215,255]},{"envId":46,"colors":[0,255,0]},{"envId":47,"colors":[0,255,95]},{"envId":48,"colors":[0,255,135]},{"envId":49,"colors":[0,255,175]},{"envId":50,"colors":[0,255,215]},{"envId":51,"colors":[0,255,255]},{"envId":52,"colors":[95,0,0]},{"envId":53,"colors":[95,0,95]},{"envId":54,"colors":[95,0,135]},{"envId":55,"colors":[95,0,175]},{"envId":56,"colors":[95,0,215]},{"envId":57,"colors":[95,0,255]},{"envId":58,"colors":[95,95,0]},{"envId":59,"colors":[95,95,95]},{"envId":60,"colors":[95,95,135]},{"envId":61,"colors":[95,95,175]},{"envId":62,"colors":[95,95,215]},{"envId":63,"colors":[95,95,255]},{"envId":64,"colors":[95,135,0]},{"envId":65,"colors":[95,135,95]},{"envId":66,"colors":[95,135,135]},{"envId":67,"colors":[95,135,175]},{"envId":68,"colors":[95,135,215]},{"envId":69,"colors":[95,135,255]},{"envId":70,"colors":[95,175,0]},{"envId":71,"colors":[95,175,95]},{"envId":72,"colors":[95,175,135]},{"envId":73,"colors":[95,175,175]},{"envId":74,"colors":[95,175,215]},{"envId":75,"colors":[95,175,255]},{"envId":76,"colors":[95,215,0]},{"envId":77,"colors":[95,215,95]},{"envId":78,"colors":[95,215,135]},{"envId":79,"colors":[95,215,175]},{"envId":80,"colors":[95,215,215]},{"envId":81,"colors":[95,215,255]},{"envId":82,"colors":[95,255,0]},{"envId":83,"colors":[95,255,95]},{"envId":84,"colors":[95,255,135]},{"envId":85,"colors":[95,255,175]},{"envId":86,"colors":[95,255,215]},{"envId":87,"colors":[95,255,255]},{"envId":88,"colors":[135,0,0]},{"envId":89,"colors":[135,0,95]},{"envId":90,"colors":[135,0,135]},{"envId":91,"colors":[135,0,175]},{"envId":92,"colors":[135,0,215]},{"envId":93,"colors":[135,0,255]},{"envId":94,"colors":[135,95,0]},{"envId":95,"colors":[135,95,95]},{"envId":96,"colors":[135,95,135]},{"envId":97,"colors":[135,95,175]},{"envId":98,"colors":[135,95,215]},{"envId":99,"colors":[135,95,255]},{"envId":100,"colors":[135,135,0]},{"envId":101,"colors":[135,135,95]},{"envId":102,"colors":[135,135,135]},{"envId":103,"colors":[135,135,175]},{"envId":104,"colors":[135,135,215]},{"envId":105,"colors":[135,135,255]},{"envId":106,"colors":[135,175,0]},{"envId":107,"colors":[135,175,95]},{"envId":108,"colors":[135,175,135]},{"envId":109,"colors":[135,175,175]},{"envId":110,"colors":[135,175,215]},{"envId":111,"colors":[135,175,255]},{"envId":112,"colors":[135,215,0]},{"envId":113,"colors":[135,215,95]},{"envId":114,"colors":[135,215,135]},{"envId":115,"colors":[135,215,175]},{"envId":116,"colors":[135,215,215]},{"envId":117,"colors":[135,215,255]},{"envId":118,"colors":[135,255,0]},{"envId":119,"colors":[135,255,95]},{"envId":120,"colors":[135,255,135]},{"envId":121,"colors":[135,255,175]},{"envId":122,"colors":[135,255,215]},{"envId":123,"colors":[135,255,255]},{"envId":124,"colors":[175,0,0]},{"envId":125,"colors":[175,0,95]},{"envId":126,"colors":[175,0,135]},{"envId":127,"colors":[175,0,175]},{"envId":128,"colors":[175,0,215]},{"envId":129,"colors":[175,0,255]},{"envId":130,"colors":[175,95,0]},{"envId":131,"colors":[175,95,95]},{"envId":132,"colors":[175,95,135]},{"envId":133,"colors":[175,95,175]},{"envId":134,"colors":[175,95,215]},{"envId":135,"colors":[175,95,255]},{"envId":136,"colors":[175,135,0]},{"envId":137,"colors":[175,135,95]},{"envId":138,"colors":[175,135,135]},{"envId":139,"colors":[175,135,175]},{"envId":140,"colors":[175,135,215]},{"envId":141,"colors":[175,135,255]},{"envId":142,"colors":[175,175,0]},{"envId":143,"colors":[175,175,95]},{"envId":144,"colors":[175,175,135]},{"envId":145,"colors":[175,175,175]},{"envId":146,"colors":[175,175,215]},{"envId":147,"colors":[175,175,255]},{"envId":148,"colors":[175,215,0]},{"envId":149,"colors":[175,215,95]},{"envId":150,"colors":[175,215,135]},{"envId":151,"colors":[175,215,175]},{"envId":152,"colors":[175,215,215]},{"envId":153,"colors":[175,215,255]},{"envId":154,"colors":[175,255,0]},{"envId":155,"colors":[175,255,95]},{"envId":156,"colors":[175,255,135]},{"envId":157,"colors":[175,255,175]},{"envId":158,"colors":[175,255,215]},{"envId":159,"colors":[175,255,255]},{"envId":160,"colors":[215,0,0]},{"envId":161,"colors":[215,0,95]},{"envId":162,"colors":[215,0,135]},{"envId":163,"colors":[215,0,175]},{"envId":164,"colors":[215,0,215]},{"envId":165,"colors":[215,0,255]},{"envId":166,"colors":[215,95,0]},{"envId":167,"colors":[215,95,95]},{"envId":168,"colors":[215,95,135]},{"envId":169,"colors":[215,95,175]},{"envId":170,"colors":[215,95,215]},{"envId":171,"colors":[215,95,255]},{"envId":172,"colors":[215,135,0]},{"envId":173,"colors":[215,135,95]},{"envId":174,"colors":[215,135,135]},{"envId":175,"colors":[215,135,175]},{"envId":176,"colors":[215,135,215]},{"envId":177,"colors":[215,135,255]},{"envId":178,"colors":[215,175,0]},{"envId":179,"colors":[215,175,95]},{"envId":180,"colors":[215,175,135]},{"envId":181,"colors":[215,175,175]},{"envId":182,"colors":[215,175,215]},{"envId":183,"colors":[215,175,255]},{"envId":184,"colors":[215,215,0]},{"envId":185,"colors":[215,215,95]},{"envId":186,"colors":[215,215,135]},{"envId":187,"colors":[215,215,175]},{"envId":188,"colors":[215,215,215]},{"envId":189,"colors":[215,215,255]},{"envId":190,"colors":[215,255,0]},{"envId":191,"colors":[215,255,95]},{"envId":192,"colors":[215,255,135]},{"envId":193,"colors":[215,255,175]},{"envId":194,"colors":[215,255,215]},{"envId":195,"colors":[215,255,255]},{"envId":196,"colors":[255,0,0]},{"envId":197,"colors":[255,0,95]},{"envId":198,"colors":[255,0,135]},{"envId":199,"colors":[255,0,175]},{"envId":200,"colors":[0,0,255]},{"envId":201,"colors":[0,255,0]},{"envId":202,"colors":[255,0,0]},{"envId":203,"colors":[165,42,42]},{"envId":204,"colors":[255,95,135]},{"envId":205,"colors":[255,95,175]},{"envId":206,"colors":[255,95,215]},{"envId":207,"colors":[255,95,255]},{"envId":208,"colors":[255,135,0]},{"envId":209,"colors":[255,135,95]},{"envId":210,"colors":[255,135,135]},{"envId":211,"colors":[255,135,175]},{"envId":212,"colors":[255,135,215]},{"envId":213,"colors":[255,135,255]},{"envId":214,"colors":[255,175,0]},{"envId":215,"colors":[255,175,95]},{"envId":216,"colors":[255,175,135]},{"envId":217,"colors":[255,175,175]},{"envId":218,"colors":[255,175,215]},{"envId":219,"colors":[255,175,255]},{"envId":220,"colors":[255,215,0]},{"envId":221,"colors":[255,215,95]},{"envId":222,"colors":[255,215,135]},{"envId":223,"colors":[255,215,175]},{"envId":224,"colors":[255,215,215]},{"envId":225,"colors":[255,215,255]},{"envId":226,"colors":[255,255,0]},{"envId":227,"colors":[255,255,95]},{"envId":228,"colors":[255,255,135]},{"envId":229,"colors":[255,255,175]},{"envId":230,"colors":[255,255,215]},{"envId":231,"colors":[255,255,255]},{"envId":232,"colors":[8,8,8]},{"envId":233,"colors":[18,18,18]},{"envId":234,"colors":[28,28,28]},{"envId":235,"colors":[38,38,38]},{"envId":236,"colors":[48,48,48]},{"envId":237,"colors":[58,58,58]},{"envId":238,"colors":[68,68,68]},{"envId":239,"colors":[78,78,78]},{"envId":240,"colors":[88,88,88]},{"envId":241,"colors":[98,98,98]},{"envId":242,"colors":[108,108,108]},{"envId":243,"colors":[118,118,118]},{"envId":244,"colors":[128,128,128]},{"envId":245,"colors":[138,138,138]},{"envId":246,"colors":[148,148,148]},{"envId":247,"colors":[158,158,158]},{"envId":248,"colors":[168,168,168]},{"envId":249,"colors":[178,178,178]},{"envId":250,"colors":[188,188,188]},{"envId":251,"colors":[198,198,198]},{"envId":252,"colors":[208,208,208]},{"envId":253,"colors":[218,218,218]},{"envId":254,"colors":[228,228,228]},{"envId":255,"colors":[238,238,238]},{"envId":257,"colors":[128,0,0]},{"envId":258,"colors":[0,128,0]},{"envId":259,"colors":[128,128,0]},{"envId":260,"colors":[0,0,128]},{"envId":261,"colors":[128,0,128]},{"envId":262,"colors":[0,128,128]},{"envId":263,"colors":[192,192,192]},{"envId":264,"colors":[0,0,0]},{"envId":265,"colors":[255,0,0]},{"envId":266,"colors":[0,255,0]},{"envId":267,"colors":[255,255,0]},{"envId":268,"colors":[0,0,255]},{"envId":269,"colors":[255,0,255]},{"envId":270,"colors":[0,255,255]},{"envId":271,"colors":[255,255,255]},{"envId":272,"colors":[128,128,128]},{"envId":293,"colors":[0,171,192]},{"envId":294,"colors":[139,255,0]},{"envId":295,"colors":[239,176,73]},{"envId":296,"colors":[163,151,235]},{"envId":297,"colors":[236,167,236]},{"envId":298,"colors":[22,232,196]},{"envId":299,"colors":[0,170,255]},{"envId":300,"colors":[0,196,255]},{"envId":301,"colors":[255,114,14]},{"envId":303,"colors":[170,139,89]},{"envId":400,"colors":[186,112,74]},{"envId":798,"colors":[255,140,0]},{"envId":799,"colors":[230,230,250]},{"envId":800,"colors":[30,144,255]},{"envId":801,"colors":[154,205,50]},{"envId":802,"colors":[85,107,47]},{"envId":803,"colors":[0,255,255]},{"envId":805,"colors":[107,142,35]},{"envId":806,"colors":[0,100,0]},{"envId":810,"colors":[255,0,0]},{"envId":811,"colors":[139,69,19]},{"envId":812,"colors":[230,230,250]},{"envId":813,"colors":[255,255,255]},{"envId":814,"colors":[34,139,34]},{"envId":823,"colors":[255,215,0]},{"envId":824,"colors":[47,79,79]},{"envId":825,"colors":[189,183,107]},{"envId":826,"colors":[184,134,11]},{"envId":830,"colors":[255,69,0]},{"envId":855,"colors":[160,82,45]}]
package/demo/index.html DELETED
@@ -1,102 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8"/>
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
6
- <title>Konva Universal Lib — Demo</title>
7
- <style>
8
- html, body {
9
- width: 100%;
10
- height: 100%;
11
- margin: 0;
12
- font-family: Inter, system-ui, sans-serif;
13
- background-color: #000;
14
- color: #fff;
15
- }
16
-
17
- body {
18
- position: relative;
19
- overflow: hidden;
20
- }
21
-
22
- #stage {
23
- width: 100%;
24
- height: 100%;
25
- }
26
-
27
- #hud {
28
- position: absolute;
29
- top: 1rem;
30
- left: 1rem;
31
- padding: 0.5rem 0.75rem;
32
- background: rgba(0, 0, 0, 0.6);
33
- border-radius: 0.5rem;
34
- font-size: 0.9rem;
35
- line-height: 1.4;
36
- pointer-events: auto;
37
- }
38
-
39
- #controls {
40
- margin-top: 0.5rem;
41
- display: flex;
42
- flex-direction: column;
43
- gap: 0.5rem;
44
- }
45
-
46
- #controls label {
47
- display: flex;
48
- align-items: center;
49
- gap: 0.4rem;
50
- font-weight: 500;
51
- }
52
-
53
- #destination-form {
54
- display: flex;
55
- flex-direction: column;
56
- gap: 0.35rem;
57
- }
58
-
59
- #destination-inputs {
60
- display: flex;
61
- gap: 0.35rem;
62
- }
63
-
64
- #destination-input {
65
- width: 6rem;
66
- }
67
-
68
- #destination-status {
69
- font-size: 0.8rem;
70
- color: #c8f7ff;
71
- }
72
-
73
- #hud strong {
74
- font-weight: 600;
75
- }
76
- </style>
77
- <link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
78
- </head>
79
- <body>
80
- <div id="stage"></div>
81
- <div id="hud">
82
- <div id="status">Loading map…</div>
83
- <div id="walker-status"></div>
84
- <div id="controls">
85
- <label>
86
- <input type="checkbox" id="exploration-toggle" checked>
87
- Exploration overlay
88
- </label>
89
- <form id="destination-form">
90
- <label for="destination-input">Destination room</label>
91
- <div id="destination-inputs">
92
- <input type="number" id="destination-input" min="1" placeholder="Room ID" />
93
- <button type="submit">Set</button>
94
- <button type="button" id="destination-clear">Clear</button>
95
- </div>
96
- <div id="destination-status"></div>
97
- </form>
98
- </div>
99
- </div>
100
- <script type="module" src="/main.ts"></script>
101
- </body>
102
- </html>