Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add /p/pflow/metamodel package and /r/stackdump/home realm #3778

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

stackdump
Copy link

@stackdump stackdump commented Feb 19, 2025

This build adds my home realm: /r/stackdump/home which is also an example usage of the /p/pflow/metamodel package.

The primary goal of the package is to provide a useful state machine library that can be visualized using gno.land web.

This is accomplished by generating mardown links and images using base64 encoded image data:

pflow

[![pflow](https://pflow.dev/img/?b=eyJtb2RlbFR5cGUiOiJwZXRyaU5ldCIsInZlcnNpb24iOiJ2MCIsInBsYWNlcyI6eyJwbGFjZTAiOnsib2Zmc2V0IjowLCJpbml0aWFsIjoxLCJjYXBhY2l0eSI6MywieCI6MTMwLCJ5IjoyMDd9fSwidHJhbnNpdGlvbnMiOnsidHhuMCI6eyJ4Ijo0NiwieSI6MTE2fSwidHhuMSI6eyJ4IjoyMjcsInkiOjExMn0sInR4bjIiOnsieCI6NDMsInkiOjMwN30sInR4bjMiOnsieCI6MjM1LCJ5IjozMDZ9fSwiYXJjcyI6W3sic291cmNlIjoidHhuMCIsInRhcmdldCI6InBsYWNlMCIsIndlaWdodCI6MX0seyJzb3VyY2UiOiJwbGFjZTAiLCJ0YXJnZXQiOiJ0eG4xIiwid2VpZ2h0IjozfSx7InNvdXJjZSI6InR4bjIiLCJ0YXJnZXQiOiJwbGFjZTAiLCJ3ZWlnaHQiOjMsImluaGliaXQiOnRydWV9LHsic291cmNlIjoicGxhY2UwIiwidGFyZ2V0IjoidHhuMyIsIndlaWdodCI6MSwiaW5oaWJpdCI6dHJ1ZX1dfQ==)](https://pflow.dev/?b=eyJtb2RlbFR5cGUiOiJwZXRyaU5ldCIsInZlcnNpb24iOiJ2MCIsInBsYWNlcyI6eyJwbGFjZTAiOnsib2Zmc2V0IjowLCJpbml0aWFsIjoxLCJjYXBhY2l0eSI6MywieCI6MTMwLCJ5IjoyMDd9fSwidHJhbnNpdGlvbnMiOnsidHhuMCI6eyJ4Ijo0NiwieSI6MTE2fSwidHhuMSI6eyJ4IjoyMjcsInkiOjExMn0sInR4bjIiOnsieCI6NDMsInkiOjMwN30sInR4bjMiOnsieCI6MjM1LCJ5IjozMDZ9fSwiYXJjcyI6W3sic291cmNlIjoidHhuMCIsInRhcmdldCI6InBsYWNlMCIsIndlaWdodCI6MX0seyJzb3VyY2UiOiJwbGFjZTAiLCJ0YXJnZXQiOiJ0eG4xIiwid2VpZ2h0IjozfSx7InNvdXJjZSI6InR4bjIiLCJ0YXJnZXQiOiJwbGFjZTAiLCJ3ZWlnaHQiOjMsImluaGliaXQiOnRydWV9LHsic291cmNlIjoicGxhY2UwIiwidGFyZ2V0IjoidHhuMyIsIndlaWdodCI6MSwiaW5oaWJpdCI6dHJ1ZX1dfQ==)

This package uses base64 encoded data URLs to allow SVG images to be rendered.

I'd like to confirm that this behavior is considered good practice? or is there a better way to accomplish image rendering using gno?

Here's an example usage I'd expect from users of the package.

import (
	mm "gno.land/p/pflow/metamodel"
)

// define model
var m = exampleModel()

// Use m.ToLinkMarkdown() to embed the petri net in markdown
// ![Petri-net](https://pflow.dev/img/b=<BASE64DATA>
_ := m.ToLinkMarkdown()

// define petri net model using metamodel package
func exampleModel() *mm.Pflow {
	return &mm.Pflow{
		Places: map[string]mm.Place{
			"place0": {Offset: 0, Initial: 1, Capacity:[ 3](http://127.0.0.1:8888/r/stackdump/home#L3), X: 130, Y: 207},
		},
		Transitions: map[string]mm.Transition{
			"txn0": {X:[ 4](http://127.0.0.1:8888/r/stackdump/home#L4)6, Y: 116},
			"txn1": {X: 227, Y: 112},
			"txn2": {X: 43, Y: 307},
			"txn3": {X: 235, Y: 306},
		},
		Arrows: []mm.Arrow{
			{Source: "txn0", Target: "place0"},
			{Source: "place0", Target: "txn1", Weight: 3},
			{Source: "txn2", Target: "place0", Weight: 3, Inhibit: true},
			{Source: "place0", Target: "txn3", Inhibit: true},
		},
	}
}

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Feb 19, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Feb 19, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: stackdump/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission
The pull request description provides enough details

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)
    └── 🟢 Not (🔴 Pull request author is user: dependabot[bot])

Can be checked by

  • team core-contributors

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@stackdump
Copy link
Author

I've overwritten this w/ a new version - now trying to satisfy the CI/CD requirements

@stackdump stackdump changed the title Stackdump realm feat: add /p/pflow/metamodel package and /r/stackdump/home realm Feb 22, 2025
@stackdump stackdump requested a review from leohhhn February 22, 2025 18:19
@stackdump stackdump marked this pull request as ready for review February 22, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: Triage
Development

Successfully merging this pull request may close these issues.

2 participants