@molecule/app-feature-graph-view-svelte 0.0.0-stage → 1.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 +202 -0
- package/README.md +402 -2
- package/dist/GraphView.svelte +151 -0
- package/dist/GraphView.svelte.d.ts +5 -0
- package/dist/GraphView.svelte.d.ts.map +1 -0
- package/dist/components.d.ts +8 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +7 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/layout.d.ts +101 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +238 -0
- package/dist/types.d.ts +80 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +75 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ForceLayoutOptions } from './layout.js';
|
|
3
|
+
/**
|
|
4
|
+
* Graph-view types: nodes, edges, layout choice and renderer hooks for
|
|
5
|
+
* `<GraphView>`.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/** A 2-D point in graph (world) coordinates. */
|
|
10
|
+
export interface GraphPoint {
|
|
11
|
+
/** X coordinate. */
|
|
12
|
+
x: number;
|
|
13
|
+
/** Y coordinate. */
|
|
14
|
+
y: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Single node in the graph.
|
|
18
|
+
*
|
|
19
|
+
* `group` is an opaque grouping discriminator (e.g. tag, folder) the
|
|
20
|
+
* caller can use for colouring; `weight` scales the rendered radius.
|
|
21
|
+
*/
|
|
22
|
+
export interface GraphNode {
|
|
23
|
+
/** Unique node id. */
|
|
24
|
+
id: string;
|
|
25
|
+
/** Human-readable label rendered next to the node. */
|
|
26
|
+
label: string;
|
|
27
|
+
/** Optional grouping discriminator (e.g. tag id). */
|
|
28
|
+
group?: string;
|
|
29
|
+
/** Optional weight; default 1. Scales the rendered radius. */
|
|
30
|
+
weight?: number;
|
|
31
|
+
}
|
|
32
|
+
/** Edge connecting two nodes by id. */
|
|
33
|
+
export interface GraphEdge {
|
|
34
|
+
/** Unique edge id. */
|
|
35
|
+
id: string;
|
|
36
|
+
/** Source node id. */
|
|
37
|
+
source: string;
|
|
38
|
+
/** Target node id. */
|
|
39
|
+
target: string;
|
|
40
|
+
/** Optional weight; default 1. Stronger edges pull harder under force layout. */
|
|
41
|
+
weight?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Available layout strategies. */
|
|
44
|
+
export type GraphLayout = 'force' | 'circular' | 'grid';
|
|
45
|
+
/**
|
|
46
|
+
* Internal positioned node used by the renderer; the `x`/`y` coordinates
|
|
47
|
+
* are in world (graph) space, with `(0, 0)` at the canvas centre.
|
|
48
|
+
*/
|
|
49
|
+
export interface PositionedNode extends GraphNode {
|
|
50
|
+
/** World-space X coordinate. */
|
|
51
|
+
x: number;
|
|
52
|
+
/** World-space Y coordinate. */
|
|
53
|
+
y: number;
|
|
54
|
+
}
|
|
55
|
+
/** Renderer for an individual node: a snippet receiving the positioned node. */
|
|
56
|
+
export type GraphNodeRenderer = Snippet<[PositionedNode]>;
|
|
57
|
+
/** Renderer for an individual edge: a snippet receiving the edge plus both endpoints. */
|
|
58
|
+
export type GraphEdgeRenderer = Snippet<[GraphEdge, PositionedNode, PositionedNode]>;
|
|
59
|
+
/** `<GraphView>` props. */
|
|
60
|
+
export interface GraphViewProps {
|
|
61
|
+
/** Nodes to render. */
|
|
62
|
+
nodes: GraphNode[];
|
|
63
|
+
/** Edges to render. */
|
|
64
|
+
edges: GraphEdge[];
|
|
65
|
+
/** Fired when the user clicks (or activates) a node. */
|
|
66
|
+
onNodeClick?: (node: GraphNode) => void;
|
|
67
|
+
/** Currently-selected node id (highlighted in the view). */
|
|
68
|
+
selectedNodeId?: string;
|
|
69
|
+
/** Layout strategy. Defaults to `'force'`. */
|
|
70
|
+
layout?: GraphLayout;
|
|
71
|
+
/** Custom node renderer (overrides the default circle + label). */
|
|
72
|
+
nodeRenderer?: GraphNodeRenderer;
|
|
73
|
+
/** Custom edge renderer (overrides the default `<line>`). */
|
|
74
|
+
edgeRenderer?: GraphEdgeRenderer;
|
|
75
|
+
/** Force-layout tunables; ignored for non-force layouts. */
|
|
76
|
+
forceOptions?: ForceLayoutOptions;
|
|
77
|
+
/** Extra classes merged onto the outer wrapper. */
|
|
78
|
+
className?: string;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD;;;;;GAKG;AAEH,gDAAgD;AAChD,MAAM,WAAW,UAAU;IACzB,oBAAoB;IACpB,CAAC,EAAE,MAAM,CAAA;IACT,oBAAoB;IACpB,CAAC,EAAE,MAAM,CAAA;CACV;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,sBAAsB;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;IACb,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,uCAAuC;AACvC,MAAM,WAAW,SAAS;IACxB,sBAAsB;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,mCAAmC;AACnC,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAA;AAEvD;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,gCAAgC;IAChC,CAAC,EAAE,MAAM,CAAA;IACT,gCAAgC;IAChC,CAAC,EAAE,MAAM,CAAA;CACV;AAED,gFAAgF;AAChF,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAA;AAEzD,yFAAyF;AACzF,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,CAAC,SAAS,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;AAEpF,2BAA2B;AAC3B,MAAM,WAAW,cAAc;IAC7B,uBAAuB;IACvB,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,uBAAuB;IACvB,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,wDAAwD;IACxD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACvC,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,mEAAmE;IACnE,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAChC,6DAA6D;IAC7D,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAChC,4DAA4D;IAC5D,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,77 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-feature-graph-view-svelte",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Force-directed graph view (Obsidian-style) for visualizing note / page linkages",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-feature-graph-view-svelte",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"svelte": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"svelte": "./dist/index.js",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"!dist/**/__tests__",
|
|
21
|
+
"!dist/**/*.test.*",
|
|
22
|
+
"!dist/**/*.spec.*",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings && svelte-package --input src --output dist --tsconfig ./tsconfig.json",
|
|
27
|
+
"dev": "svelte-package --input src --output dist --tsconfig ./tsconfig.json --watch",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"test:watch": "vitest"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"molecule",
|
|
33
|
+
"graph",
|
|
34
|
+
"force-directed",
|
|
35
|
+
"visualization",
|
|
36
|
+
"obsidian",
|
|
37
|
+
"notes",
|
|
38
|
+
"svelte"
|
|
39
|
+
],
|
|
40
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
41
|
+
"license": "Apache-2.0",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
45
|
+
"directory": "packages/app/features/feature-graph-view-svelte"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=20"
|
|
49
|
+
},
|
|
50
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@molecule/app-svelte": "^3.5.0",
|
|
56
|
+
"@molecule/app-ui": "^1.0.1",
|
|
57
|
+
"@molecule/app-ui-svelte": "^1.1.0",
|
|
58
|
+
"svelte": "^5.0.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@molecule/app-framework-conformance": "0.0.0",
|
|
62
|
+
"@molecule/app-i18n": "1.2.2",
|
|
63
|
+
"@molecule/app-icons": "1.0.4",
|
|
64
|
+
"@molecule/app-svelte": "3.9.0",
|
|
65
|
+
"@molecule/app-ui": "1.5.0",
|
|
66
|
+
"@molecule/app-ui-svelte": "1.2.1",
|
|
67
|
+
"@sveltejs/package": "3.0.2",
|
|
68
|
+
"@sveltejs/vite-plugin-svelte": "7.1.2",
|
|
69
|
+
"@types/node": "26.6.5",
|
|
70
|
+
"jsdom": "30.1.3",
|
|
71
|
+
"svelte": "5.57.2",
|
|
72
|
+
"svelte-check": "4.7.7",
|
|
73
|
+
"typescript": "6.0.3",
|
|
74
|
+
"vite": "8.3.5",
|
|
75
|
+
"vitest": "4.1.12"
|
|
76
|
+
}
|
|
77
|
+
}
|