Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
5481e8f
initialized and transferred the code
ddroid Jul 12, 2025
a6e720e
changed structure for graph-explorer
ddroid Jul 13, 2025
980f9fc
fixed upscroll bug
ddroid Jul 13, 2025
179cdaf
fixed the 2hubs bug
ddroid Jul 15, 2025
f80d9fd
Added Static Position of list on expanding
ddroid Jul 15, 2025
5dc7c95
Added basic docs
ddroid Jul 15, 2025
bca5a53
fixed mistake
ddroid Jul 15, 2025
306f4e4
added reset to wand
ddroid Jul 18, 2025
e43f792
quick fixes according to feedback
ddroid Jul 18, 2025
896e4c6
added instance selection
ddroid Jul 18, 2025
eb9588b
drive runtime vars
ddroid Jul 18, 2025
9e6bb82
drive runtime vars part 2
ddroid Jul 22, 2025
dc974a9
multiple selection while holding ctrl
ddroid Jul 22, 2025
64f450d
added confirmed and uncofirmed instances
ddroid Jul 22, 2025
9a681c7
fixed scroll persistance and removed all of static entry code
ddroid Jul 24, 2025
7e5d0d4
static entry position while expanding or collapsing
ddroid Jul 24, 2025
de4a9f8
added commented sections
ddroid Jul 24, 2025
9e47479
reversed the onclicks for toggle hubs and subs
ddroid Jul 24, 2025
eaf7f4f
tweaked styles and bundled
ddroid Jul 24, 2025
50d538c
Delete instructions.md
ddroid Jul 24, 2025
247e800
tweaked box drawing logic and styles
ddroid Jul 26, 2025
901f900
moved prefix to CSS
ddroid Jul 26, 2025
7c903ce
fixed fast scroll issue
ddroid Jul 26, 2025
38ed6a8
bundled
ddroid Jul 26, 2025
4e67aae
added error throwing inside console for debugging
ddroid Jul 27, 2025
6c9e52d
object based prams
ddroid Jul 27, 2025
3592567
added static entry functionality when container not full
ddroid Jul 27, 2025
2470b53
upgraded the static entry logic
ddroid Jul 27, 2025
29aab86
bundled
ddroid Jul 27, 2025
577446e
added node_height in drive
ddroid Jul 28, 2025
2b5dd05
added logic to remove spacer when scrollup
ddroid Jul 28, 2025
51d1410
added more comments to sections and in involved stuff
ddroid Jul 28, 2025
038b26f
bundled
ddroid Jul 28, 2025
ae76c15
Added Search Feature
ddroid Jul 30, 2025
dffecec
Fixed the previous search effecting new view issue
ddroid Jul 30, 2025
4d07f05
Added new different variable for search states
ddroid Jul 30, 2025
7e40a5a
disable toggle expand nodes during search mode
ddroid Jul 30, 2025
61e33ef
bundled
ddroid Jul 30, 2025
d5d9603
Debug the event listners on first click
ddroid Jul 31, 2025
b19f37f
Add automatic switch between modes once an entry is selected
ddroid Jul 31, 2025
54fc97a
Fix prefix bugs
ddroid Jul 31, 2025
c628beb
Add Drive Persistance across search
ddroid Jul 31, 2025
36c5341
bundled
ddroid Jul 31, 2025
1494e04
formatting using prettier standard
ddroid Aug 15, 2025
0c074ac
simplyfied code according to feedback and replaced repeating code wit…
ddroid Aug 19, 2025
55c0e73
replaced more repeating code with functions and simplified some of th…
ddroid Aug 19, 2025
67692df
bold matching letters in search mode
ddroid Aug 19, 2025
6e727e2
changed color and moved bar under explorer
ddroid Aug 20, 2025
71cb990
bundled
ddroid Aug 20, 2025
bdc94c9
removed some of the anomlies
ddroid Aug 20, 2025
558ff96
fixed the spacer element bug
ddroid Aug 21, 2025
f4525a9
Added manipulation in search mode
ddroid Aug 23, 2025
d910986
Fixed Prefix bugs & Created pipe_calculate func
ddroid Aug 27, 2025
26a2340
split `calculate_prefix()` to improve performance and simplicity
ddroid Aug 27, 2025
e060bbe
Some more pipe related fixes
ddroid Aug 27, 2025
3889ee4
bundled
ddroid Aug 27, 2025
e2455ca
Fixed the pipes bug
ddroid Aug 28, 2025
f49ce07
Added Reset for Search mode & did some tweaks
ddroid Aug 29, 2025
0a3249c
Added Selection to search mode
ddroid Aug 29, 2025
2df0367
Added Multiselect
ddroid Aug 29, 2025
5299c7a
Add ui-tweaks for mobile devices
ddroid Aug 29, 2025
5f828b0
Added Standardx
ddroid Aug 29, 2025
f5a4576
Implemented `on[type](params)`
ddroid Aug 29, 2025
506f936
Jump to already opened hubs of entries
ddroid Aug 29, 2025
7dc1d74
bundled
ddroid Aug 29, 2025
c4716b1
Increase the expand subs trigger to include prefix and pipes before e…
ddroid Aug 31, 2025
0dae901
Add drive based bold styling
ddroid Aug 31, 2025
246dd36
move the searchbar to a new div above menubar
ddroid Aug 31, 2025
c2fa80c
Add ^ button to all the repeating entries and relocate position next …
ddroid Aug 31, 2025
21d206e
Added Cycling through entries with jump to already opened
ddroid Aug 31, 2025
cd3d2ed
Replace current implementation with container queries instead
ddroid Aug 31, 2025
1bf182c
Make the last clicked node look different
ddroid Aug 31, 2025
bfd0154
Add Select Between for bulk toggle selecting
ddroid Aug 31, 2025
35d313a
lint & bundled
ddroid Aug 31, 2025
73dbe0a
Fixed the mapping & admin errors
ddroid Sep 14, 2025
e73bd4d
Added color for matching entries and changed logic for appearance of …
ddroid Sep 14, 2025
d5295f9
change the position of ^ button to wand column
ddroid Sep 14, 2025
d37c2a0
disable prevent duplicate in search mode & bar styling
ddroid Sep 14, 2025
5f31823
Added flag for hubs
ddroid Sep 14, 2025
e41fb79
use {type, message} inside update_drive_state
ddroid Sep 14, 2025
4e687b1
bundled
ddroid Sep 14, 2025
c3a43ab
Removed `query` in js & !important in CSS
ddroid Sep 20, 2025
0e4335d
Move the Jump Button to next match on clicking
ddroid Sep 20, 2025
160334a
maintain the same vertical position on screen during jump
ddroid Sep 20, 2025
4d4333d
Finished the functionality for Last Clicked
ddroid Sep 20, 2025
c7459c9
Replace wand with jump button
ddroid Sep 20, 2025
ad1a3c6
First Instance of duplicates is intractive
ddroid Sep 20, 2025
5ebdefc
bundled
ddroid Sep 20, 2025
f1637b8
applied container queries
ddroid Sep 21, 2025
d1f4ef9
Replaced Anonymous Functions
ddroid Sep 21, 2025
e5c8412
Added true Intraction based order for duplicate_map
ddroid Sep 21, 2025
aaccad1
Add view_order_tracking to drive
ddroid Sep 21, 2025
6a8c1c7
bundled
ddroid Sep 21, 2025
e444892
Fixed Last-Clicked inside search mode
ddroid Sep 23, 2025
8f220cc
temp fix for prefix in search mode
ddroid Sep 23, 2025
60bdb4f
bundled
ddroid Sep 23, 2025
06a181c
Fixed multi-select in search mode
ddroid Sep 26, 2025
3a537fa
Fixed Select Between in search mode
ddroid Sep 26, 2025
f5655e6
Added contrast to last-clicked in search mode
ddroid Sep 26, 2025
4cfca78
Defined all the anonymous functions for foreach loops
ddroid Sep 26, 2025
6d482d6
bundled
ddroid Sep 26, 2025
9fcdcbe
Added flag to disable selected entries
ddroid Sep 27, 2025
8e294cb
Fixed toggle subs/hubs glitch when there is no query
ddroid Sep 27, 2025
4b4d84b
Added flag to either collapse entries subs & hubs on parent level or …
ddroid Sep 27, 2025
a808d8f
Added Duplicate detection inside search mode
ddroid Sep 27, 2025
51a0cab
bundled
ddroid Sep 27, 2025
e205d86
fixed the jump bug in search mode
ddroid Sep 28, 2025
2363441
Added all flags to menubar
ddroid Sep 28, 2025
f31b28a
Added Basic Keyboard Navigation for Graph Explorer
ddroid Sep 28, 2025
32b4f62
Bundled
ddroid Sep 28, 2025
2e55887
Updated according to feedback
ddroid Sep 29, 2025
5405c9a
Bundled
ddroid Sep 29, 2025
9029511
Added Base Protocol and Messages
ddroid Sep 30, 2025
f975200
Added Docs for Protocol
ddroid Sep 30, 2025
905c64a
Replaced all_entries with DB
ddroid Sep 30, 2025
a1e6ba2
Add Jump button to last clicked if duplicate
ddroid Sep 30, 2025
fc38ba5
Updated Docs
ddroid Sep 30, 2025
cd88159
Bundled
ddroid Sep 30, 2025
176ff3a
a mistake
ddroid Sep 30, 2025
5a76827
bundled
ddroid Sep 30, 2025
fa4b818
Added Undo Feature
ddroid Oct 11, 2025
e1d6378
small tweaks
ddroid Oct 11, 2025
e9ab987
bundled
ddroid Oct 20, 2025
c970abf
Added graphdb via protocol
ddroid Oct 28, 2025
1492433
Bundled
ddroid Oct 28, 2025
6226f83
Change message structure to standard
ddroid Oct 29, 2025
29131b9
upgrade datashell
serapath Nov 24, 2025
1120f7f
update bundle
serapath Nov 24, 2025
8c9c023
Merge pull request #1 from serapath/main
ddroid Nov 24, 2025
c66519b
Updated Protocol Docs
ddroid Nov 28, 2025
75f4277
Added Usage docs and commented wrapper code
ddroid Nov 28, 2025
4f7133f
fix array syntax error
ddroid Dec 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules/*
/package-lock.json
/npm-debug.log
/package-lock.json
/.idea
251 changes: 249 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,249 @@
# graph-explorer
a hierarchical file tree explorer, but with the ability to not just expand sub entries, but also multiple super entries
# `graph-explorer`

A lightweight, high-performance frontend component for rendering and exploring interactive, hierarchical graph data. It uses a virtual scrolling technique to efficiently display large datasets with thousands of nodes without sacrificing performance.

## Features

- **Virtual Scrolling:** Renders only the visible nodes, ensuring smooth scrolling and interaction even with very large graphs.
- **Interactive Exploration:** Allows users to expand and collapse both hierarchical children (`subs`) and related connections (`hubs`).
- **Standard Protocol:** Implements the standard bidirectional message-based communication protocol for seamless integration.
- **Drive-based Data Flow:** Uses the drive system for efficient data management and real-time updates.

## Quick Start

The graph explorer requires data to be supplied through a drive system and communicates via the standard protocol:

```javascript
const graph_explorer = require('graph-explorer')

// Provide `opts` and optional `protocol` as parameters
const graph = await graph_explorer(opts, protocol)

// Append the element to your application's body or another container
document.body.appendChild(graph)
```
For detailed usage instructions, see [USAGE.md](./guide/USAGE.md).

## Protocol System

The graph explorer implements the **standard bidirectional message-based communication protocol** that allows parent modules to:
- Control the graph explorer programmatically (change modes, select nodes, expand/collapse, etc.)
- Receive notifications about user interactions and state changes

All messages follow the standard format:
```javascript
{
head: [sender_id, receiver_id, message_id],
refs: { cause: parent_message_head },
type: "message_type",
data: { ... }
}
```

For complete protocol documentation, see [PROTOCOL.md](./guide/PROTOCOL.md).

## Data Flow

The graph explorer uses a drive-based data system for efficient data management:

### Required Drive Datasets

1. **`entries/entries.json`** - Core graph data (see format below)
2. **`theme/style.css`** - CSS styles for the component
3. **`mode/`** - Current mode and search state
4. **`flags/`** - Configuration flags
5. **`keybinds/`** - Keyboard navigation bindings

### Data Integration Pattern

The recommended approach is to use the `graph_explorer` which handles:
- Drive data watching and processing
- Protocol communication setup
- Database initialization
- Message routing between parent and graph explorer

```javascript
const graph_explorer = require('graph-explorer')
const graph = await graph_explorer(opts, protocol)
```

### 1. `entries`

The `entries` dataset provides the core graph data. It should be stored in `entries/entries.json` as an object where each key is a unique path identifier for a node, and the value is an object describing that node's properties.

**Example `entries` Object:**

```json
{
"/": {
"name": "Root Directory",
"type": "root",
"subs": ["/src", "/assets", "/README.md"],
"hubs": ["/LICENSE"]
},
"/src": {
"name": "src",
"type": "folder",
"subs": ["/src/index.js", "/src/styles.css"]
},
"/assets": {
"name": "assets",
"type": "folder",
"subs": []
},
"/README.md": {
"name": "README.md",
"type": "file"
},
"/LICENSE": {
"name": "LICENSE",
"type": "file"
},
"/src/index.js": {
"name": "index.js",
"type": "js-file"
},
"/src/styles.css": {
"name": "styles.css",
"type": "css-file"
}
}
```

**Node Properties:**

- `name` (String): The display name of the node.
- `type` (String): A type identifier used for styling (e.g., `folder`, `file`, `js-file`). The component will add a `type-<your-type>` class to the node element. And these classes can be used to append `.icon::before` css property to show an icon before name.
- `subs` (Array<String>): An array of paths to child nodes. An empty array indicates no children.
- `hubs` (Array<String>): An array of paths to related, non-hierarchical nodes.

### 2. `theme`

The `theme` dataset provides CSS styles and should be stored in `theme/style.css`. The styles are injected directly into the component's Shadow DOM for full visual control.

**Example `style` Data:**

```css
.graph-container {
color: #abb2bf;
background-color: #282c34;
padding: 10px;
height: 100vh;
overflow: auto;
}
.node {
display: flex;
align-items: center;
white-space: nowrap;
cursor: default;
height: 22px;
/*
This height is crucial for virtual scrolling calculations and it should match the height of javascript variable i.e

const node_height = 22

*/
}
.clickable {
cursor: pointer;
}
.node.type-folder > .icon::before { content: '📁'; }
.node.type-js-file > .icon::before { content: '📜'; }
/* these use `type` to inject icon */
/* ... more custom styles */
```

## How It Works

The component maintains a complete `view` array representing the flattened, visible graph structure. It uses an `IntersectionObserver` with two sentinel elements at the top and bottom of the scrollable container.

When a sentinel becomes visible, the component dynamically renders the next or previous "chunk" of nodes and removes nodes that have scrolled far out of view. This ensures that the number of DOM elements remains small and constant, providing excellent performance regardless of the total number of nodes in the graph.

## Modes

The graph explorer supports three distinct modes that change how users interact with the component:

### default
The standard navigation mode where users can:
- Click to expand/collapse nodes
- Navigate the graph
- Select individual nodes

### menubar
An enhanced mode with a visible menubar providing gui based quick access to:
- Mode switching button
- Flag toggles
- Multi-select control
- Select-between control

### search
A specialized mode for finding and filtering nodes:
- Displays a search input bar
- Filters the view to show only matching nodes
- Supports multi-select and select-between operations on search results

**Mode State Management:**
- Current mode is stored in `drive` at `mode/current_mode.json`
- Previous mode is tracked in `mode/previous_mode.json` (used when exiting search)
- Search query is persisted in `mode/search_query.json`

## Flags

Flags control behaviors of the graph explorer. They are stored in the `flags/` dataset:

### hubs (`flags/hubs.json`)
Controls the display of hub connections (non-hierarchical relationships):
- `"default"` - Hubs are collapsed by default
- `"true"` - All hubs are expanded
- `"false"` - All hubs are hidden

Toggle through values using the menubar button in menubar mode.

### selection (`flags/selection.json`)
Enables or disables node selection functionality:
- `true` - Users can select nodes (default)
- `false` - Selection is disabled

### recursive_collapse (`flags/recursive_collapse.json`)
Controls collapse behavior for hierarchical nodes:
- `true` - Collapsing a node also collapses all its descendants (default)
- `false` - Only the clicked node is collapsed

## Keybinds

The graph explorer supports keyboard navigation and actions. Keybinds are defined in `keybinds/navigation.json` and can be customized through the drive system.

### Default Keybinds

| Key Combination | Action | Description |
|----------------|--------|-------------|
| `ArrowUp` | Navigate Up | Move focus to the previous visible node |
| `ArrowDown` | Navigate Down | Move focus to the next visible node |
| `Control+ArrowDown` | Toggle Subs | Expand/collapse child nodes (subs) of the current node |
| `Control+ArrowUp` | Toggle Hubs | Expand/collapse hub connections of the current node |
| `Alt+s` | Multi-select | Add/remove the current node to/from the selection |
| `Alt+b` | Select Between | Select all nodes between the last clicked and current node |
| `Control+m` | Toggle Search | Switch between current mode and search mode |
| `Alt+j` | Jump to Next Duplicate | Navigate to the next occurrence of a duplicate node |

**Customizing Keybinds:**

Keybinds can be customized by updating the `keybinds/navigation.json` file in the drive with a JSON object mapping key combinations to action names:

```javascript
{
"ArrowUp": "navigate_up_current_node",
"ArrowDown": "navigate_down_current_node",
"Control+ArrowDown": "toggle_subs_for_current_node",
"Control+ArrowUp": "toggle_hubs_for_current_node",
"Alt+s": "multiselect_current_node",
"Alt+b": "select_between_current_node",
"Control+m": "toggle_search_mode",
"Alt+j": "jump_to_next_duplicate"
}
```

**Key Combination Format:**
- Modifier keys: `Control+`, `Alt+`, `Shift+`
- Can combine multiple modifiers: `Control+Shift+Key`
- Key names follow standard JavaScript `event.key` values
Loading