aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Beltran del Rio <jj@r.bdr.sh>2025-12-15 12:04:57 +0100
committerRuben Beltran del Rio <jj@r.bdr.sh>2025-12-15 22:16:29 +0100
commit8daa7da7acc6809056249261ad50cd3896625886 (patch)
tree8f81dfc4f2b0c33a953622e97c18a5712dddb8ba
parentcd3d83d8a852d98e934ebc13b067e0971e30a995 (diff)
Add types, update license style, and readme links
-rw-r--r--Makefile3
-rw-r--r--README.md6
-rw-r--r--dist/index.d.ts134
-rw-r--r--package.json3
-rw-r--r--tsconfig.json9
5 files changed, 151 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 2ed83f8..1e0f3d6 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,9 @@ prepare:
# Code Quality
+types:
+ tsc
+
test:
node --test
diff --git a/README.md b/README.md
index 1ca023c..b8941c3 100644
--- a/README.md
+++ b/README.md
@@ -117,7 +117,7 @@ make coverage
## See Also
- [wmap specification](doc/wmap-spec.ebnf) - Formal grammar
-- [wmap specification](https://git.sr.ht:~rbdr/wmap-parser-rust) - Rust wmap-parser
-- [wmap specification](https://git.sr.ht:~rbdr/wmap-parser-c) - ANSI C wmap-parser
-- [wmap specification](https://git.sr.ht:~rbdr/wmap-parser-swift) - Swift wmap-parser
+- [wmap-parser-rust](https://git.sr.ht:~rbdr/wmap-parser-rust) - Rust wmap-parser
+- [wmap-parser-c](https://git.sr.ht:~rbdr/wmap-parser-c) - ANSI C wmap-parser
+- [wmap-parser-swift](https://git.sr.ht:~rbdr/wmap-parser-swift) - Swift wmap-parser
- [Wardley Maps](https://wardleymaps.com/) - Learn about Wardley Mapping
diff --git a/dist/index.d.ts b/dist/index.d.ts
new file mode 100644
index 0000000..bff2dc2
--- /dev/null
+++ b/dist/index.d.ts
@@ -0,0 +1,134 @@
+/**
+ * wmap format Wardley Map parser.
+ * @param {string} source - The wmap source code to parse
+ * @returns {Map} - Parsed map with separate arrays for each entity type
+ */
+export function parse(source: string): Map;
+/**
+ * A parsed wardley map.
+ */
+export type Map = {
+ /**
+ * - List of components
+ */
+ components: Component[];
+ /**
+ * - List of dependencies
+ */
+ dependencies: Dependency[];
+ /**
+ * - List of notes
+ */
+ notes: Note[];
+ /**
+ * - List of stages
+ */
+ stages: Stage[];
+ /**
+ * - List of groups
+ */
+ groups: Group[];
+ /**
+ * - List of inertias
+ */
+ inertias: Inertia[];
+ /**
+ * - List of evolutions
+ */
+ evolutions: Evolution[];
+};
+/**
+ * Any of the potential shapes in a component.
+ */
+export type Shape = "x" | "square" | "triangle" | "circle";
+/**
+ * A component in the map.
+ */
+export type Component = {
+ /**
+ * - Component label
+ */
+ label: string;
+ /**
+ * - X and Y coordinates
+ */
+ coordinates: [number, number];
+ /**
+ * - Shape of the component
+ */
+ shape: Shape;
+};
+/**
+ * A dependency between two components.
+ */
+export type Dependency = {
+ /**
+ * - Source component label
+ */
+ from: string;
+ /**
+ * - Target component label
+ */
+ to: string;
+ /**
+ * - Whether the dependency is directed (->) or undirected (--)
+ */
+ isDirected: boolean;
+};
+/**
+ * A note.
+ */
+export type Note = {
+ /**
+ * - X and Y coordinates
+ */
+ coordinates: [number, number];
+ /**
+ * - Note text content
+ */
+ text: string;
+};
+/**
+ * An override for the width of an evolution stage.
+ */
+export type Stage = {
+ /**
+ * - Stage number (i, ii, iii, iv)
+ */
+ stage: string;
+ /**
+ * - Stage value
+ */
+ value: number;
+};
+/**
+ * A group of components.
+ */
+export type Group = {
+ /**
+ * - Array of component labels in the group
+ */
+ components: string[];
+};
+/**
+ * Inertia associated with a component.
+ */
+export type Inertia = {
+ /**
+ * - Component label with inertia
+ */
+ component: string;
+};
+/**
+ * Evolution associated with a component.
+ */
+export type Evolution = {
+ /**
+ * - Component label
+ */
+ component: string;
+ /**
+ * - Evolution value
+ */
+ value: number;
+};
diff --git a/package.json b/package.json
index 99af0c1..0991b0e 100644
--- a/package.json
+++ b/package.json
@@ -4,10 +4,11 @@
"description": "Parser for wmap formatted Wardley Map files.",
"type": "module",
"main": "src/index.js",
+ "types": "dist/index.d.ts",
"scripts": {},
"keywords": ["Wardley Maps", "Wardley", "wmap", "Wardley Mapping"],
"author": "Rubén Beltrán del Río <wmap.parser@r.bdr.sh>",
- "license": "AGPL-v3",
+ "license": "AGPL-3.0",
"packageManager": "pnpm@10.12.1",
"devDependencies": {
"@eslint/js": "^9.39.1",
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..440d298
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "compilerOptions": {
+ "allowJs": true,
+ "declaration": true,
+ "emitDeclarationOnly": true,
+ "outDir": "dist"
+ },
+ "include": ["src/**/*.js"]
+}