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

logicflow-liteflow

v2.0.2

Published

2.0.2:switch分支可以侵入其他分支, 复用其他分支的节点

Downloads

81

Readme

logicflow-liteflow

更新日志

2.0.2:switch分支可以侵入其他分支, 复用其他分支的节点

1716538076831

2.0.1: 修改Switch表达式按照when解析的错误,新增组合节点进行配置的功能,包括id,tag,ignoreError,any,must

2.0.0: 新增与或非表达式和捕获异常表达式,修改循环的实现方式,增加节点的配置(节点和边可以双击配置)

1.0.4: 将logicflow生成的图形数据转化为liteflow规则,支持拖拽和实时预览liteflow规则,支持 then、when、switch和循环节点

使用步骤

项目已上传至npm仓库

  1. 下载
npm install [email protected]
  1. 导入(这里默认注册了需要的组件)
import {LiteFlow} from 'logicflow-liteflow';
  1. 作为LogicFlow插件使用
new LogicFlow({
    ...,
    plugins: [LiteFlow],
})
  1. 使用提供的节点组件

    提供的节点类型有COMMON,SWITCH,IF,GROUP,AND,OR,NOT。可以使用logicflow的dnd插件。也可以自己实现拖拽,在拖入节点时将type赋值为其中一个,并把properties中的nodeId修改为需要展示的id,下面给出了基于HTML拖拽事件的示例

//拖拽开始事件,ScriptNodeDTO是自定义的数据结构
const dragstart_handler = (e: DragEvent, node: ScriptNodeDTO) => {
    e.dataTransfer?.setData("text/plain", JSON.stringify(node));
}

//修改拖拽鼠标经过样式
const onDragOver = (e: DragEvent) => {
    e.preventDefault();
    e.dataTransfer && (e.dataTransfer.dropEffect = "move");
}

//拖拽结束事件
const onDrop = (e: DragEvent) => {
    e.preventDefault();
    const data = e.dataTransfer?.getData("text/plain");
    const node: ScriptNodeDTO = JSON.parse(data as string);

    const point = logicflow.getPointByClient(e.x, e.y);
    if (!point) return;


    logicflow.addNode({
        type: node.type,
        x: point.canvasOverlayPosition.x,
        y: point.canvasOverlayPosition.y,
        text: node.scriptNodeName,
        zIndex: 2,
        properties: {
            nodeId: node.scriptNodeId
        }
    });
}
  1. 解析为liteFlow表达式
import {parse} from 'logicflow-liteflow';

data = lf.getGraphRawData()
parse(data);

自定义节点样式

你可以用任何logicflow支持的方式自定义节点(继承项目中的或是自己写),并注册为项目已有type(COMMON,IF,GROUP,SWITCH,AND,OR,NOT),这会覆盖默认注册的组件,非常建议重写,因为本人写的不好看,可能后面会改吧。

关于与或非表达式

可以想办法把箭头给去掉,因为输入输出锚点是固定位置的,应该会更好看一点(已完成)

1716538076831

运行示例项目

通过gitee直接下载本项目运行试试看。

项目截图

1716537254842

启动步骤

npm install
npm run dev

id生成和数据保存

id从1开始自动递增,和图形数据一起保存在localstorage中,可以自行修改

GROUP 节点

1717742318220

1717742381384

2.0.1 现在的Group节点添加了并行和id,tag的配置,其实原理是将外部连接到GROUP内部的边视为直接连接到GROUP节点,所以你也可以直接这么做)。。。(可能在一些特殊情况你可以使用分组作为最高优先级,比如在switch节点后面紧跟一个when节点等)

2.0.0中更新最大的就是GROUP节点了,循环,与或非表达式,捕获异常表达式都是用的GROUP节点,主要区别在于不同的groupType

1716536810972

后面并行的配置以及id,tag的配置估计也是GROUP,但是还没写。。。

IF 节点的使用

连线上的TRUE和FALSE可以双击进行选择

  1. 最稳妥的使用方式当然是有两个分支,并且连线上标明true和false(false可以省略)

  1. liteFlow中有IF(x,a)的语法,但是从图上不好判断IF节点何时结束,所以用空分支指向结束位置。

  1. 为了方便,当if节点在最后时可以只有一个分支,指定为true img

  2. 可以使用与或非表达式作为if的开始节点

    1716538076831

循环节点的使用

使用分组节点并将分组类型设置为FOR、WHILE、ITERATOR中的一个,连接START边和BREAK边,通过双击边进行选择。(其中FOR配置迭代次数和连接START边只需要进行一项)

1716537828999 1716537861452 1716537905393 1716537805571