Skip to Content
👋 Добро пожаловать в документацию lite-fsm!
APIGraph API

Graph API

@lite-fsm/graph строит неизменяемый IR для машин, менеджеров и инструментов анализа. Пакет находится в alpha-версии.

Основная точка входа

import { analyzeLiteFsmGraph, compileLiteFsmGraph, compileLiteFsmGraphProject, selectMachineGraph, } from "@lite-fsm/graph";
APIНазначение
compileLiteFsmGraph(source, opts)Построить LiteFsmGraphDocument из строки source
compileLiteFsmGraphProject(opts)Построить project graph из входного файла через host
selectMachineGraph(doc, selector?)Выбрать одну machine из document
analyzeLiteFsmGraph(doc, opts?)Запустить semantic analyzer поверх IR

Project compiler

const project = compileLiteFsmGraphProject({ entryFileName: "/repo/store/index.ts", projectRoot: "/repo", host, });

LiteFsmGraphProjectHost отвечает за чтение файлов и module resolution. Это позволяет использовать graph package в CLI, IDE integrations и тестах без жесткой привязки к Node FS.

Точка входа simulator

import { createGraphSimulator, createMachineGraphSimulator } from "@lite-fsm/graph/simulator";
APIНазначение
createGraphSimulator(document, options?)Simulator для document, manager или machine scope
createMachineGraphSimulator(document, machineId, options?)Simulator, ограниченный одной machine

Simulator не исполняет пользовательский reducer/effect/guard code. Он работает символически поверх graph IR.

Точка входа view-model

import { buildGraphVisualizerModel, buildMachineFlowModel, buildMachineWorkbenchModel, } from "@lite-fsm/graph/view-model";
APIНазначение
buildGraphVisualizerModel(doc, opts?)L1/L2/L3 projection: machines, managers, topics, diagnostics
buildMachineWorkbenchModel(machine, opts?)Workbench model одной machine
buildMachineFlowModel(input)Semantic state graph для canvas/flow renderer

Основные типы

LiteFsmGraphDocument, LiteFsmGraphMachine, LiteFsmGraphManager, GraphTransition, GraphEmission, GraphDiagnostic, GraphAnalysisResult, GraphSimulator, GraphSimulationSnapshot, GraphVisualizerModel, MachineFlowModel.

Подробное описание пакета: @lite-fsm/graph.

Last updated on