@metronforge/concept-map 0.2.0 → 0.2.1
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 +28 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Coffee shop: a map you can play
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
Follow guest → cashier → barista, then switch from **Normal** to **Out of milk**.
|
|
4
6
|
[Open the coffee shop](https://metronforge.github.io/concept-map/examples/coffee/)
|
|
5
7
|
or copy its [HTML and JSON](examples/coffee/).
|
|
@@ -48,30 +50,28 @@ Save this source map as `map.json`. There are no coordinates:
|
|
|
48
50
|
|
|
49
51
|
Load the stylesheet, one module script and one element on an HTML page:
|
|
50
52
|
|
|
53
|
+
<!-- x-release-please-start-version -->
|
|
54
|
+
|
|
51
55
|
```html
|
|
52
56
|
<link
|
|
53
57
|
rel="stylesheet"
|
|
54
|
-
href="https://esm.sh
|
|
58
|
+
href="https://esm.sh/@metronforge/concept-map@0.2.1/css"
|
|
55
59
|
/>
|
|
56
60
|
<script
|
|
57
61
|
type="module"
|
|
58
|
-
src="https://esm.sh
|
|
62
|
+
src="https://esm.sh/@metronforge/concept-map@0.2.1/element"
|
|
59
63
|
></script>
|
|
60
64
|
<concept-map src="./map.json" layout="dagre"></concept-map>
|
|
61
65
|
```
|
|
62
66
|
|
|
67
|
+
<!-- x-release-please-end -->
|
|
68
|
+
|
|
63
69
|
Serve the files over HTTP, for example with `python3 -m http.server 8000`.
|
|
64
70
|
The [complete page](examples/coffee/index.html) adds a title, navigation and host styling.
|
|
65
71
|
The element fetches the JSON, loads dagre when needed and provides scenarios,
|
|
66
72
|
steps, an animated whole-map flow, keyboard controls and reduced-motion support.
|
|
67
73
|
Ready maps with geometry do not download a layout engine.
|
|
68
74
|
|
|
69
|
-
**Before the 0.2.0 release:** these URLs pin a main commit through esm.sh's GitHub
|
|
70
|
-
support. After publication, replace them with
|
|
71
|
-
`https://esm.sh/@metronforge/concept-map@0.2.0/css` and
|
|
72
|
-
`https://esm.sh/@metronforge/concept-map@0.2.0/element`. The current npm release
|
|
73
|
-
does not yet provide this integration.
|
|
74
|
-
|
|
75
75
|
## Three ways to use the package
|
|
76
76
|
|
|
77
77
|
1. **Plain HTML:** use `<concept-map>` as above. It also accepts inline JSON or
|
|
@@ -87,6 +87,26 @@ The last two accept resolved maps. For source maps, call `layout(source, engine)
|
|
|
87
87
|
from `@metronforge/concept-map/layout` first. See [integration](docs/INTEGRATION.md)
|
|
88
88
|
and [automatic layout](docs/LAYOUT.md).
|
|
89
89
|
|
|
90
|
+
## Lay out on the server
|
|
91
|
+
|
|
92
|
+
Install the optional engine with `npm install @dagrejs/dagre`. Read the source
|
|
93
|
+
map, resolve its geometry, then render the complete figure:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
import { readFile } from "node:fs/promises";
|
|
97
|
+
import { layout } from "@metronforge/concept-map/layout";
|
|
98
|
+
import { dagreEngine } from "@metronforge/concept-map/layout/dagre";
|
|
99
|
+
import { renderFigure } from "@metronforge/concept-map";
|
|
100
|
+
|
|
101
|
+
const map = JSON.parse(await readFile("map.json", "utf8"));
|
|
102
|
+
const resolvedMap = await layout(map, dagreEngine);
|
|
103
|
+
const html = renderFigure(resolvedMap);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`dagreEngine` is an object, not a function: pass it directly to `layout`, without
|
|
107
|
+
calling it. Include `html` in the server response and load the package stylesheet.
|
|
108
|
+
Use `mount` in the browser to add interaction.
|
|
109
|
+
|
|
90
110
|
## More examples
|
|
91
111
|
|
|
92
112
|
- [Door: a finite state machine](https://metronforge.github.io/concept-map/examples/door/) —
|