graphgarden-web 0.1.0
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/LICENSE +21 -0
- package/README.md +68 -0
- package/dist/graphgarden.iife.js +434 -0
- package/dist/graphgarden.iife.js.map +7 -0
- package/dist/graphgarden.js +434 -0
- package/dist/graphgarden.js.map +7 -0
- package/dist/index.d.ts +67 -0
- package/dist/test-setup.d.ts +0 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import Graph from "graphology";
|
|
2
|
+
import Sigma from "sigma";
|
|
3
|
+
export interface GraphGardenConfig {
|
|
4
|
+
localNodeColor: string;
|
|
5
|
+
friendNodeColor: string;
|
|
6
|
+
internalEdgeColor: string;
|
|
7
|
+
friendEdgeColor: string;
|
|
8
|
+
labelColor: string;
|
|
9
|
+
nodeSize: number;
|
|
10
|
+
edgeSize: number;
|
|
11
|
+
labelSize: number;
|
|
12
|
+
iterations: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const DEFAULT_CONFIG: GraphGardenConfig;
|
|
15
|
+
export interface GraphGardenNode {
|
|
16
|
+
url: string;
|
|
17
|
+
title: string;
|
|
18
|
+
}
|
|
19
|
+
export interface GraphGardenEdge {
|
|
20
|
+
source: string;
|
|
21
|
+
target: string;
|
|
22
|
+
type: "internal" | "friend";
|
|
23
|
+
}
|
|
24
|
+
export interface GraphGardenSite {
|
|
25
|
+
title: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
language?: string;
|
|
28
|
+
}
|
|
29
|
+
/** The top-level shape of a `graphgarden.json` file. */
|
|
30
|
+
export interface GraphGardenFile {
|
|
31
|
+
version: string;
|
|
32
|
+
generated_at: string;
|
|
33
|
+
base_url: string;
|
|
34
|
+
site: GraphGardenSite;
|
|
35
|
+
nodes: GraphGardenNode[];
|
|
36
|
+
edges: GraphGardenEdge[];
|
|
37
|
+
}
|
|
38
|
+
/** Runtime check that `value` matches the {@link GraphGardenFile} shape. */
|
|
39
|
+
export declare function isGraphGardenFile(value: unknown): value is GraphGardenFile;
|
|
40
|
+
/** Build a graphology `Graph` from a parsed {@link GraphGardenFile}. */
|
|
41
|
+
export declare function buildGraph(file: GraphGardenFile, config: GraphGardenConfig): Graph;
|
|
42
|
+
/**
|
|
43
|
+
* Assign random initial positions then run ForceAtlas2 to compute
|
|
44
|
+
* a stable layout. Mutates node `x`/`y` attributes in place.
|
|
45
|
+
*/
|
|
46
|
+
export declare function assignLayout(graph: Graph, iterations: number): void;
|
|
47
|
+
/** Fetch friend sites' graphs and merge their nodes and edges into `graph`. */
|
|
48
|
+
export declare function fetchFriendGraphs(graph: Graph, config: GraphGardenConfig): Promise<Graph>;
|
|
49
|
+
/**
|
|
50
|
+
* `<graph-garden>` custom element — fetches the site's own
|
|
51
|
+
* `graphgarden.json`, builds a graphology `Graph`, merges friend
|
|
52
|
+
* graphs, and renders an interactive force-directed visualisation
|
|
53
|
+
* via Sigma.js.
|
|
54
|
+
*/
|
|
55
|
+
export declare class GraphGarden extends HTMLElement {
|
|
56
|
+
static readonly tagName: "graph-garden";
|
|
57
|
+
/** The local graph built from the protocol file, or `null` before loading. */
|
|
58
|
+
graph: Graph | null;
|
|
59
|
+
/** The Sigma renderer instance, or `null` before rendering. */
|
|
60
|
+
renderer: Sigma | null;
|
|
61
|
+
/** Shadow DOM container for the Sigma canvas. */
|
|
62
|
+
private container;
|
|
63
|
+
connectedCallback(): Promise<void>;
|
|
64
|
+
disconnectedCallback(): void;
|
|
65
|
+
private resolveConfig;
|
|
66
|
+
private initRenderer;
|
|
67
|
+
}
|
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "graphgarden-web",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Web component that renders an interactive GraphGarden node graph",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/bruits/graphgarden",
|
|
9
|
+
"directory": "packages/graphgarden-web"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/graphgarden.js",
|
|
16
|
+
"module": "dist/graphgarden.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/graphgarden.js",
|
|
22
|
+
"default": "./dist/graphgarden.js"
|
|
23
|
+
},
|
|
24
|
+
"./iife": "./dist/graphgarden.iife.js"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"graphology": "^0.25",
|
|
28
|
+
"graphology-layout-forceatlas2": "^0.10",
|
|
29
|
+
"sigma": "^3"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"esbuild": "^0.25",
|
|
33
|
+
"happy-dom": "^18",
|
|
34
|
+
"tsx": "^4",
|
|
35
|
+
"typescript": "^5",
|
|
36
|
+
"vitest": "^3"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsx build.ts && tsc",
|
|
40
|
+
"dev": "tsx watch build.ts",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"test:watch": "vitest"
|
|
43
|
+
}
|
|
44
|
+
}
|