@riebeckite/graph 0.0.0-stage → 0.0.36

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.
@@ -0,0 +1,8 @@
1
+ import type { GraphNode } from "./types.js";
2
+ export type RevealEntry = {
3
+ id: string;
4
+ at: number;
5
+ dated: boolean;
6
+ };
7
+ export declare function buildRevealSchedule(nodes: readonly GraphNode[]): RevealEntry[];
8
+ export declare function hasDatedNodes(nodes: readonly GraphNode[]): boolean;
@@ -0,0 +1,31 @@
1
+ import type { GraphDocument } from "./types.js";
2
+ export type GraphSourceLink = {
3
+ raw: string;
4
+ slug: string | null;
5
+ kind: string;
6
+ };
7
+ export type GraphSourceAsset = {
8
+ path: string;
9
+ sourcePath?: string;
10
+ };
11
+ export type GraphSourceEntry = {
12
+ slug: string;
13
+ title: string;
14
+ permalink: string;
15
+ tags?: readonly string[];
16
+ links?: readonly GraphSourceLink[];
17
+ assets?: readonly GraphSourceAsset[];
18
+ date?: string | null;
19
+ };
20
+ export type BuildGraphDocumentOptions = {
21
+ centerSlug?: string | null;
22
+ includeTags?: boolean;
23
+ includeAttachments?: boolean;
24
+ includeUnresolved?: boolean;
25
+ };
26
+ export declare function buildGraphDocument(entries: readonly GraphSourceEntry[], options?: BuildGraphDocumentOptions): GraphDocument;
27
+ export type SliceGraphDocumentResult = {
28
+ document: GraphDocument;
29
+ truncated: boolean;
30
+ };
31
+ export declare function sliceGraphDocument(document: GraphDocument, centerId: string, depth: number, maxNodes?: number): SliceGraphDocumentResult;
@@ -0,0 +1,14 @@
1
+ import type { GraphNode } from "./types.js";
2
+ export type GraphQueryField = "text" | "file" | "path" | "tag" | "unsupported";
3
+ export type GraphQueryTerm = {
4
+ field: GraphQueryField;
5
+ value: string;
6
+ negated: boolean;
7
+ };
8
+ export type ParsedGraphQuery = {
9
+ terms: GraphQueryTerm[];
10
+ unsupportedOperators: string[];
11
+ };
12
+ export declare function parseGraphQuery(input: string): ParsedGraphQuery;
13
+ export declare function matchesGraphQuery(node: GraphNode, query: ParsedGraphQuery): boolean;
14
+ export declare function normalizeGraphText(value: string): string;
@@ -0,0 +1,52 @@
1
+ import type { GraphSettings } from "./types.js";
2
+ export declare const GRAPH_SETTINGS_RANGES: {
3
+ readonly depth: {
4
+ readonly min: 0;
5
+ readonly max: 5;
6
+ readonly step: 1;
7
+ };
8
+ readonly textFade: {
9
+ readonly min: 0;
10
+ readonly max: 1;
11
+ readonly step: 0.05;
12
+ };
13
+ readonly nodeSize: {
14
+ readonly min: 0.5;
15
+ readonly max: 2.5;
16
+ readonly step: 0.1;
17
+ };
18
+ readonly linkThickness: {
19
+ readonly min: 0.25;
20
+ readonly max: 3;
21
+ readonly step: 0.05;
22
+ };
23
+ readonly centerForce: {
24
+ readonly min: 0;
25
+ readonly max: 1;
26
+ readonly step: 0.05;
27
+ };
28
+ readonly repelForce: {
29
+ readonly min: 0;
30
+ readonly max: 2000;
31
+ readonly step: 10;
32
+ };
33
+ readonly linkForce: {
34
+ readonly min: 0;
35
+ readonly max: 1;
36
+ readonly step: 0.05;
37
+ };
38
+ readonly linkDistance: {
39
+ readonly min: 30;
40
+ readonly max: 500;
41
+ readonly step: 5;
42
+ };
43
+ };
44
+ export declare const DEFAULT_GRAPH_SETTINGS: GraphSettings;
45
+ export declare function mergeGraphSettings(base: GraphSettings, patch: Partial<GraphSettings>): GraphSettings;
46
+ export declare function normalizeGraphSettings(value: unknown): GraphSettings;
47
+ export declare function readStoredGraphSettings(storage: {
48
+ getItem(key: string): string | null;
49
+ }, key: string): GraphSettings | null;
50
+ export declare function writeStoredGraphSettings(storage: {
51
+ setItem(key: string, value: string): void;
52
+ }, key: string, settings: GraphSettings): void;
@@ -0,0 +1,38 @@
1
+ import type { GraphLink } from "./types.js";
2
+ export type SimulationOptions = {
3
+ centerForce: number;
4
+ repelForce: number;
5
+ linkForce: number;
6
+ linkDistance: number;
7
+ };
8
+ export type SimulationNode = {
9
+ id: string;
10
+ x: number;
11
+ y: number;
12
+ vx: number;
13
+ vy: number;
14
+ fx: number | null;
15
+ fy: number | null;
16
+ };
17
+ export type GraphSimulation = {
18
+ nodes: readonly SimulationNode[];
19
+ tick(): boolean;
20
+ reheat(alpha?: number): void;
21
+ setOptions(options: SimulationOptions): void;
22
+ fix(id: string, x: number, y: number): void;
23
+ release(id: string): void;
24
+ stop(): void;
25
+ isActive(): boolean;
26
+ getAlpha(): number;
27
+ };
28
+ export type CreateSimulationInput = {
29
+ nodeIds: readonly string[];
30
+ links: readonly GraphLink[];
31
+ options: SimulationOptions;
32
+ positions?: ReadonlyMap<string, {
33
+ x: number;
34
+ y: number;
35
+ }>;
36
+ centerId?: string | null;
37
+ };
38
+ export declare function createGraphSimulation(input: CreateSimulationInput): GraphSimulation;
@@ -0,0 +1,56 @@
1
+ export type GraphNodeKind = "note" | "unresolved" | "attachment" | "tag";
2
+ export type GraphNode = {
3
+ id: string;
4
+ kind: GraphNodeKind;
5
+ slug: string | null;
6
+ title: string;
7
+ permalink: string | null;
8
+ path: string;
9
+ tags: string[];
10
+ date: string | null;
11
+ };
12
+ export type GraphLink = {
13
+ source: string;
14
+ target: string;
15
+ };
16
+ export type GraphDocument = {
17
+ nodes: GraphNode[];
18
+ links: GraphLink[];
19
+ centerId: string | null;
20
+ };
21
+ export type GraphGroup = {
22
+ id: string;
23
+ query: string;
24
+ color: string;
25
+ };
26
+ export type GraphSettings = {
27
+ search: string;
28
+ showTags: boolean;
29
+ showAttachments: boolean;
30
+ existingOnly: boolean;
31
+ showOrphans: boolean;
32
+ depth: number;
33
+ arrows: boolean;
34
+ textFade: number;
35
+ nodeSize: number;
36
+ linkThickness: number;
37
+ animate: boolean;
38
+ centerForce: number;
39
+ repelForce: number;
40
+ linkForce: number;
41
+ linkDistance: number;
42
+ groups: GraphGroup[];
43
+ };
44
+ export type GraphMode = "local" | "global";
45
+ export type VisibleGraphNode = GraphNode & {
46
+ degree: number;
47
+ radius: number;
48
+ color: string;
49
+ groupId: string | null;
50
+ };
51
+ export type VisibleGraph = {
52
+ nodes: VisibleGraphNode[];
53
+ links: GraphLink[];
54
+ centerId: string | null;
55
+ unsupportedOperators: string[];
56
+ };
@@ -0,0 +1,9 @@
1
+ import type { GraphDocument, GraphMode, GraphSettings, VisibleGraph } from "./types.js";
2
+ export type BuildVisibleGraphInput = {
3
+ document: GraphDocument;
4
+ settings: GraphSettings;
5
+ mode: GraphMode;
6
+ centerId?: string | null;
7
+ };
8
+ export declare function buildVisibleGraph(input: BuildVisibleGraphInput): VisibleGraph;
9
+ export declare function collectLocalNodeIds(adjacency: ReadonlyMap<string, readonly string[]>, centerId: string | null, depth: number): Set<string>;
package/dist/ui.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { GraphDocument, GraphMode, GraphNode, GraphSettings } from "./index.js";
2
+ export type GraphViewProps = {
3
+ document: GraphDocument;
4
+ mode?: GraphMode;
5
+ centerId?: string | null;
6
+ initialSettings?: Partial<GraphSettings>;
7
+ storageKey?: string;
8
+ search?: string;
9
+ onSearchChange?: (value: string) => void;
10
+ selectedId?: string | null;
11
+ onSelect?: (node: GraphNode | null) => void;
12
+ onOpen?: (node: GraphNode) => void;
13
+ onShowLocal?: (node: GraphNode) => void;
14
+ expandable?: boolean;
15
+ showHeader?: boolean;
16
+ showModeLabel?: boolean;
17
+ heading?: string;
18
+ maxDepth?: number;
19
+ class?: string;
20
+ };
21
+ export default function GraphView(props: GraphViewProps): import("hono/jsx/jsx-dev-runtime").JSX.Element;