mudlet-map-renderer 0.36.0-konva → 0.37.1-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: