npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

workflow-layout

v2.0.0

Published

Workflow layout package.

Downloads

6

Readme

The Workflow Layout Package

The purpose of the layout package is to decouple the interface for writing layouts and implementing windows manager adapters. This package takes a flow defined in the form of an abstract flow tree (AFT) and transform it into a concrete flow tree (CFT). The CFT is the common interface which is supported by all windows manager adapter, while an AFT is more expressive and eases writing layouts.

This package is replaceable as long as the replacement produces a tree which adheres to the rules of the CFT.

Usage

const { WorkflowLayout } = require("workflow-layout");

cont workflow = require("workflow-core").workflow({
  layout: new WorkflowLayout(),
  ...
});

const screen = { top: 0, left: 0, width: 1024, height: 768 };

const cft = workflow.layout(aft, {screen});

The Abstract Flow Tree

The abstract flow tree consists of three types of nodes. The root node is a workspace node, it can contain one or more layout nodes as children, or a single app node. Each of the layout nodes can contain one or more layout or app nodes. The app nodes are the leaf nodes, they are free to contain child nodes, but these are not managed by the layout package.

The notable differences between the nodes in the AFT and the CFT are the custom, relative, and absolute layout nodes. The absolute and relative nodes are for absolute and relative positioning respectively and are translated into float nodes in the CFT. The custom is used to implement layout abstractions. See workflow-layout-yoga for an example of using the custom node to support css Flexbox using Yoga. All custom nodes implement a function which returns a sub-tree with nodes adhering to the rules of the AFT. The AFT is recursively evaluated to generate a valid CFT.

const workspace = {
  type: "workspace",
  children: fill | app | splith | splitv | [ absolute ],
}

const custom = {
  type: "layout",
  layout: () => fill | splith | splitv | relative | absolute
}

const fill = {
  type: "layout",
  layout: "fill",
  percent: 1.0, // If parent is splith | splitv
  children: [ splith | splitv | custom | *relative | app, *absolute ]
};

const splith = {
  type: "layout",
  layout: "splith",
  percent: 1.0, // If parent is splith | splitv
  children: [ *(splith{percent} | splitv{percent} | fill{percent} | app{percent} | custom{percent}), *absolute ], // sum(percent) === 1
};

const splitv = {
  type: "layout",
  layout: "splitv",
  percent: 1.0, // If parent is splith | splitv
  children: [ *(splith{percent} | splitv{percent} | fill{percent} | app{percent} | custom{percent}), *absolute ], // sum(percent) === 1
};

const relative = {
  type: "layout",
  layout: "relative",
  position: { top: 0, left: 0, width: 100, height: 100 }, // relative to parent
  children: [ fill | app | split | splitv | custom, *absolute ],
};

const absolute = {
  type: "layout",
  layout: "absolute",
  percent: 1.0, // If parent is splith | splitv
  position: { top: 0, left: 0, width: 100, height: 100 } // relative to workspace
  children: [ fill | app | split | splitv | custom, *absolute ],
};

const app = {
  type: "app",
  open: <>,
  percent: 1.0, // If parent is splith | splitv
  children: [<>],
}

The Concrete Flow Tree

All nodes in the concrete flow tree contains the absolute position of the node on the screen.

const workspace = {
  type: "workspace",
  position: { top, left, width, height }, // absolute
  children: [ fill | app | splith | splitv, *float ],
}

const fill = {
  type: "layout",
  layout: "fill",
  percent: 1.0, // If parent is splith | splitv
  position: { top, left, width, height }, // absolute
  children: [ splith | splitv | *float | app ]
};

const splith = {
  type: "layout",
  layout: "splith",
  percent: 1.0, // If parent is splith | splitv
  position: { top, left, width, height }, // absolute
  children: [ *(splith{percent} | splitv{percent} | fill{percent} | app{percent}) ], // sum(percent) === 1
};

const splitv = {
  type: "layout",
  layout: "splitv",
  percent: 1.0, // If parent is splith | splitv
  position: { top, left, width, height }, // absolute
  children: [ *(splith{percent} | splitv{percent} | fill{percent} | app{percent}) ], // sum(percent) === 1
};

const float = {
  type: "layout",
  layout: "float",
  percent: 1.0, // If parent is splith | splitv,
  position: { top, left, width, height } // absolute
  children: [ fill | app | splith | splitv ],
};

const app = {
  type: "app",
  open: <>
  percent: 1.0, // If parent is splith | splitv,
  position: { top, left, width, height } // absolute
  children: [<>],
}