@rkmodules/rules 0.0.176 → 0.0.177
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +37 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +38 -13
- package/dist/index.esm.mjs.map +1 -1
- package/dist/lib/Engine/index.d.ts +8 -2
- package/dist/lib/hooks/flowState.d.ts +40 -0
- package/dist/lib/hooks/useFlow.d.ts +8 -28
- package/package.json +1 -1
|
@@ -34,8 +34,12 @@ export interface EngineEndEvent extends EngineStartEvent {
|
|
|
34
34
|
endTime: number;
|
|
35
35
|
duration: number;
|
|
36
36
|
}
|
|
37
|
-
export
|
|
38
|
-
|
|
37
|
+
export interface EngineFunctionBuiltEvent {
|
|
38
|
+
name: string;
|
|
39
|
+
fn: PrimitiveFunction;
|
|
40
|
+
}
|
|
41
|
+
export type EngineEvent = EngineStartEvent | EngineEndEvent | EngineFunctionBuiltEvent;
|
|
42
|
+
export type EngineEventName = "result" | "functionCall" | "functionResult" | "functionBuilt";
|
|
39
43
|
export declare class Engine<Env extends Record<string, any> = Record<string, any>> {
|
|
40
44
|
private fnIndex;
|
|
41
45
|
private graphDefinitions;
|
|
@@ -66,9 +70,11 @@ export declare class Engine<Env extends Record<string, any> = Record<string, any
|
|
|
66
70
|
build(node: AnyFunction, id?: string): PrimitiveFunction;
|
|
67
71
|
mount(node: PrimitiveFunction, inputs?: Record<string, VarRef>, options?: RunOptions): void | (() => void) | undefined;
|
|
68
72
|
getContext(): ExecutionContext | null;
|
|
73
|
+
subscribe(eventName: "functionBuilt", listener: (event: EngineFunctionBuiltEvent) => void): () => void;
|
|
69
74
|
subscribe(eventName: "result", listener: (event: EngineEndEvent) => void): () => void;
|
|
70
75
|
subscribe(eventName: "functionCall", listener: (event: EngineStartEvent) => void): () => void;
|
|
71
76
|
subscribe(eventName: "functionResult", listener: (event: EngineEndEvent) => void): () => void;
|
|
77
|
+
fireEvent(eventName: "functionBuilt", event: EngineFunctionBuiltEvent): void;
|
|
72
78
|
fireEvent(eventName: "result", event: EngineEndEvent): void;
|
|
73
79
|
fireEvent(eventName: "functionCall", event: EngineStartEvent): void;
|
|
74
80
|
fireEvent(eventName: "functionResult", event: EngineEndEvent): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Edge } from "@xyflow/react";
|
|
2
|
+
import { Engine, GraphedFunction } from "../Engine";
|
|
3
|
+
import type { FunctionNode } from "../Flow";
|
|
4
|
+
export type PositionData = Record<string, {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}>;
|
|
8
|
+
export interface FlowOptions {
|
|
9
|
+
dragHandle?: string;
|
|
10
|
+
positions?: PositionData;
|
|
11
|
+
onDataChange?: (id: string) => (newData: Partial<FunctionNode["data"]>) => void;
|
|
12
|
+
onIOChange?: (callback: (fn: GraphedFunction) => Partial<GraphedFunction>) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* gets the source and target node and field from an edge by de-referencing the handles
|
|
16
|
+
* the handles are in the format `${nodeId}-${fieldName}`
|
|
17
|
+
* returns an object with the source node id, target node id, source field name and target field name
|
|
18
|
+
*/
|
|
19
|
+
export declare function deRefEdgeHandle(handle: string): {
|
|
20
|
+
node: string;
|
|
21
|
+
field: string;
|
|
22
|
+
};
|
|
23
|
+
interface FlowState {
|
|
24
|
+
engine: Engine | null;
|
|
25
|
+
fn: GraphedFunction | null;
|
|
26
|
+
options: FlowOptions;
|
|
27
|
+
nodes: Record<string, FunctionNode>;
|
|
28
|
+
edges: Edge[];
|
|
29
|
+
setNodes: (updater: (nodes: FunctionNode[]) => FunctionNode[]) => void;
|
|
30
|
+
setEdges: (updater: (edges: Edge[]) => Edge[]) => void;
|
|
31
|
+
setFn: (fn: GraphedFunction, options: FlowOptions) => void;
|
|
32
|
+
refreshFunctions: (name?: string) => void;
|
|
33
|
+
init: (fn: GraphedFunction, engine: Engine, options: FlowOptions) => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* flow state stores nodes and edges for the flow graph these can be updated when the function changes
|
|
37
|
+
* using setFn
|
|
38
|
+
*/
|
|
39
|
+
export declare const createFlowStore: () => import("zustand/vanilla").StoreApi<FlowState>;
|
|
40
|
+
export {};
|
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
import { Edge } from "@xyflow/react";
|
|
2
1
|
import { Engine, GraphedFunction } from "../Engine";
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}>;
|
|
8
|
-
export interface FlowOptions {
|
|
9
|
-
dragHandle?: string;
|
|
10
|
-
positions?: PositionData;
|
|
11
|
-
onDataChange?: (id: string) => (newData: Partial<FunctionNode["data"]>) => void;
|
|
12
|
-
onIOChange?: (callback: (fn: GraphedFunction) => Partial<GraphedFunction>) => void;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* gets the source and target node and field from an edge by de-referencing the handles
|
|
16
|
-
* the handles are in the format `${nodeId}-${fieldName}`
|
|
17
|
-
* returns an object with the source node id, target node id, source field name and target field name
|
|
18
|
-
*/
|
|
19
|
-
export declare function deRefEdgeHandle(handle: string): {
|
|
20
|
-
node: string;
|
|
21
|
-
field: string;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* creates a flow state and provides handlers to update nodes and edges
|
|
25
|
-
*/
|
|
2
|
+
import { FlowOptions } from "./flowState";
|
|
3
|
+
export { deRefEdgeHandle } from "./flowState";
|
|
4
|
+
export type { FlowOptions, PositionData } from "./flowState";
|
|
5
|
+
/** Creates isolated editor state and observes definitions used by its nodes. */
|
|
26
6
|
export declare function useFlow(fn: GraphedFunction, engine: Engine, options: FlowOptions): {
|
|
27
|
-
nodes: FunctionNode[];
|
|
28
|
-
edges: Edge[];
|
|
29
|
-
setNodes: (updater: (nodes: FunctionNode[]) => FunctionNode[]) => void;
|
|
30
|
-
setEdges: (updater: (edges: Edge[]) => Edge[]) => void;
|
|
7
|
+
nodes: import("../Flow").FunctionNode[];
|
|
8
|
+
edges: import("@xyflow/react").Edge[];
|
|
9
|
+
setNodes: (updater: (nodes: import("../Flow").FunctionNode[]) => import("../Flow").FunctionNode[]) => void;
|
|
10
|
+
setEdges: (updater: (edges: import("@xyflow/react").Edge[]) => import("@xyflow/react").Edge[]) => void;
|
|
31
11
|
};
|