mudlet-map-renderer 0.35.0-konva → 0.37.0-konva

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/README.md CHANGED
@@ -279,9 +279,17 @@ Writing a new exporter — e.g. PDF — means shipping a class that implements
279
279
 
280
280
  ### Headless rendering (no DOM)
281
281
 
282
- For server-side or offscreen rendering, omit the container argument:
282
+ For server-side or offscreen rendering (Node.js), install [`canvas`](https://www.npmjs.com/package/canvas) alongside this package and import Konva's canvas backend once at startup. `canvas` is a peer dependency — it isn't shipped transitively because browsers don't need it.
283
+
284
+ ```bash
285
+ yarn add canvas
286
+ ```
283
287
 
284
288
  ```ts
289
+ import "konva/canvas-backend"; // must run before creating a MapRenderer
290
+ import { MapRenderer, createSettings, SvgExporter, PngBytesExporter } from "mudlet-map-renderer";
291
+
292
+ // Omit the container argument for headless rendering.
285
293
  const renderer = new MapRenderer(mapReader, createSettings());
286
294
 
287
295
  renderer.drawArea(42, 0);
@@ -291,6 +299,8 @@ const svg = renderer.export(new SvgExporter({ padding: 5 }));
291
299
  const png = renderer.export(new PngBytesExporter({ width: 1920, height: 1080 }));
292
300
  ```
293
301
 
302
+ SVG export doesn't actually hit Konva, so if you only need SVG you can skip both the `canvas` install and the `konva/canvas-backend` import. PNG / canvas exporters and anything that builds a Konva stage do require them.
303
+
294
304
  ### Overlays
295
305
 
296
306
  Two kinds, picked by what you need:
@@ -115,6 +115,7 @@ export declare class CanvasBackend implements DrawingBackend {
115
115
  addRect(parent: GroupNode, config: RectConfig): void;
116
116
  addCircle(parent: GroupNode, config: CircleConfig): void;
117
117
  addLine(parent: GroupNode, config: LineConfig): void;
118
+ addGridLine(parent: GroupNode, config: LineConfig): void;
118
119
  addPolygon(parent: GroupNode, config: PolygonConfig): void;
119
120
  addText(parent: GroupNode, config: TextConfig): void;
120
121
  addImage(parent: GroupNode, config: ImageConfig): void;
@@ -103,6 +103,15 @@ export interface DrawingBackend {
103
103
  addRect(parent: GroupNode, config: RectConfig): void;
104
104
  addCircle(parent: GroupNode, config: CircleConfig): void;
105
105
  addLine(parent: GroupNode, config: LineConfig): void;
106
+ /**
107
+ * Draw an infrastructure line (grid). Base backends render this identically
108
+ * to {@link addLine}. Style decorators only override it when their effect
109
+ * is meaningful for grid (e.g. IsometricStyle projects coordinates). Purely
110
+ * decorative decorators (SketchyStyle, ParchmentStyle) do not override and
111
+ * fall through to {@link BaseStyle}'s passthrough default, keeping grid
112
+ * rendering cheap.
113
+ */
114
+ addGridLine(parent: GroupNode, config: LineConfig): void;
106
115
  addPolygon(parent: GroupNode, config: PolygonConfig): void;
107
116
  addText(parent: GroupNode, config: TextConfig): void;
108
117
  addImage(parent: GroupNode, config: ImageConfig): void;
@@ -142,6 +151,7 @@ export declare abstract class BaseStyle<Inner extends DrawingBackend = DrawingBa
142
151
  addRect(parent: GroupNode, config: RectConfig): void;
143
152
  addCircle(parent: GroupNode, config: CircleConfig): void;
144
153
  addLine(parent: GroupNode, config: LineConfig): void;
154
+ addGridLine(parent: GroupNode, config: LineConfig): void;
145
155
  addPolygon(parent: GroupNode, config: PolygonConfig): void;
146
156
  addText(parent: GroupNode, config: TextConfig): void;
147
157
  addImage(parent: GroupNode, config: ImageConfig): void;
@@ -31,6 +31,7 @@ export declare class KonvaBackend implements DrawingBackend {
31
31
  addRect(parent: GroupNode, config: RectConfig): void;
32
32
  addCircle(parent: GroupNode, config: CircleConfig): void;
33
33
  addLine(parent: GroupNode, config: LineConfig): void;
34
+ addGridLine(parent: GroupNode, config: LineConfig): void;
34
35
  addPolygon(parent: GroupNode, config: PolygonConfig): void;
35
36
  addText(parent: GroupNode, config: TextConfig): void;
36
37
  addImage(parent: GroupNode, config: ImageConfig): void;
@@ -40,6 +40,7 @@ export declare class SvgBackend implements DrawingBackend {
40
40
  addRect(parent: GroupNode, config: RectConfig): void;
41
41
  addCircle(parent: GroupNode, config: CircleConfig): void;
42
42
  addLine(parent: GroupNode, config: LineConfig): void;
43
+ addGridLine(parent: GroupNode, config: LineConfig): void;
43
44
  addPolygon(parent: GroupNode, config: PolygonConfig): void;
44
45
  addText(parent: GroupNode, config: TextConfig): void;
45
46
  addImage(parent: GroupNode, config: ImageConfig): void;
package/dist/index.d.ts CHANGED
@@ -11,9 +11,9 @@ export type { DrawingBackend, GroupNode, LayerNode, CoordFn, RectConfig, CircleC
11
11
  export { BaseStyle, compose, identityStyle, IDENTITY_TRANSFORM } from './backend/DrawingBackend';
12
12
  export { CanvasBackend } from './backend/CanvasBackend';
13
13
  export { SvgBackend, SvgGroupNode, SvgLayerNode } from './backend/SvgBackend';
14
- export { SketchyStyle, ParchmentStyle, BlueprintStyle, NeonStyle, IsometricStyle, } from './style';
14
+ export { SketchyStyle, ParchmentStyle, BlueprintStyle, NeonStyle, ChaosStyle, IsometricStyle, } from './style';
15
15
  export type { IsometricRotation } from './style';
16
- export { Parchment, Blueprint, Neon, Sketchy, Isometric, } from './style';
16
+ export { Parchment, Blueprint, Neon, Chaos, Sketchy, Isometric, } from './style';
17
17
  export type { SketchyOptions, IsometricOptions } from './style';
18
18
  export type { Exporter, ExportContext, ExportCanvas } from './export/Exporter';
19
19
  export { SvgExporter } from './export/SvgExporter';