From a9746980c8c874642e08feee3ff6c044e7fe3173 Mon Sep 17 00:00:00 2001 From: stackdump Date: Tue, 21 Nov 2023 04:13:47 -0600 Subject: [PATCH] show inhibitors in snapshots --- TODO.md | 5 +++-- package-lock.json | 4 ++-- package.json | 2 +- snapshot.ts | 10 +++++----- test/snapshot.test.ts | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/TODO.md b/TODO.md index f0c1bea..3ac3b33 100644 --- a/TODO.md +++ b/TODO.md @@ -7,17 +7,18 @@ WIP --- - [ ] add better tests for all net types (workflows, etc) -- [ ] build comparison of the statefulness of radio buttons... odly this would make good blog +- [ ] fix snapshot to work with inhibitor arcs ICEBOX ------ +- [ ] build comparison of the stateful-ness of radio buttons... oddly this would make good blog - [ ] something wrong w/ src map in @pflow-dev/metamodel DONE ---- -- [x] build/test browser targ +- [x] build/test browser target - [x] fix build scripts & publish to NPM - [x] support SVG generation & output - [x] support Stream of multiple models diff --git a/package-lock.json b/package-lock.json index abb45fa..6ebb7c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@pflow-dev/metamodel", - "version": "0.3.3", + "version": "0.3.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@pflow-dev/metamodel", - "version": "0.3.2", + "version": "0.3.4", "license": "MIT", "devDependencies": { "@babel/core": "^7.14.3", diff --git a/package.json b/package.json index 1c566e0..8055281 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pflow-dev/metamodel", - "version": "0.3.3", + "version": "0.3.4", "main": "/index.js", "types": "/index.d.ts", "description": "create workflows and petriNets with a DSL", diff --git a/snapshot.ts b/snapshot.ts index e9cbd21..7d545f5 100644 --- a/snapshot.ts +++ b/snapshot.ts @@ -113,16 +113,16 @@ export function snapshot(model: Model, options?: { hashChar?: HashChar }) { }); let arcTags = ""; transitions.forEach((t) => { - for (const label in t.guards) { - const place = places.get(label); - const pts = getArcPoints({source: t, target: place}); + t.guards.forEach((v, k) => { + const place = places.get(k); + const pts = getArcPoints({source: place, target: t}); arcTags += arcTemplate({ ...pts, stroke: "black", markerEnd: `url(${hashChar}markerInhibit1)`, - weight: Math.abs(t.guards.get(label).delta[place.offset]) + weight: Math.abs(v.delta[place.offset]) }); - } + }); }); // TODO: support snapshot while running transitions.forEach((t) => { diff --git a/test/snapshot.test.ts b/test/snapshot.test.ts index 1da7ed5..677a540 100644 --- a/test/snapshot.test.ts +++ b/test/snapshot.test.ts @@ -1,8 +1,8 @@ import {newModel, snapshot} from "../"; -import {tictactoe} from "./examples"; +import {inhibitTest} from "./examples"; it("should render a snapshot", () => { - const m = newModel({schema: "game", declaration: tictactoe}); + const m = newModel({schema: "game", declaration: inhibitTest}); const svg = snapshot(m); expect(svg.startsWith("")).toBeTruthy();