You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This template should help get you started developing with Vue 3 in Vite.
3
+
An interactive JavaScript AST (Abstract Syntax Tree) explorer and query tool, similar to [Regexr](https://regexr.com/) but for the [Astronomical](https://github.com/RetireJS/astronomical) query language.
4
4
5
-
## Recommended IDE Setup
5
+
**🚀 [Try it live](https://erlend.github.io/astronomical-viewer/)**
Astronomical Query Viewer helps you visualize and test [Astronomical](https://github.com/RetireJS/astronomical) queries against JavaScript code. It provides:
-[Turn on Custom Object Formatter in Firefox DevTools](https://fxdx.dev/firefox-devtools-custom-object-formatters/)
11
+
-**Interactive AST Tree View** - See the complete Abstract Syntax Tree of your JavaScript code
12
+
-**Query Testing** - Write and test Astronomical queries in real-time
13
+
-**Visual Feedback** - Matched nodes are highlighted with their ancestors marked for easy navigation
14
+
-**Persistent State** - Your code and queries are saved in localStorage
17
15
18
-
## Type Support for `.vue` Imports in TS
16
+
## Features
19
17
20
-
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
18
+
- 📝 **Dual Pane Editor** - JavaScript code on one side, Astronomical queries on the other
19
+
- 🌳 **Full AST Visualization** - Explore the entire syntax tree with expand/collapse functionality
20
+
- 🎯 **Match Highlighting** - Matched nodes shown in yellow, ancestors in gray
21
+
- 💾 **Auto-Save** - Your work persists across browser sessions
22
+
- 🔍 **Primitive Results** - Shows both matched AST nodes and primitive values (strings, numbers, booleans)
23
+
- ⚡ **Real-time Updates** - Execute queries and see results instantly
21
24
22
-
## Customize configuration
25
+
## What is Astronomical?
23
26
24
-
See [Vite Configuration Reference](https://vite.dev/config/).
27
+
[Astronomical](https://github.com/RetireJS/astronomical) is a query language for JavaScript ASTs, similar to XPath for XML. It allows you to search for specific patterns in JavaScript code using queries like:
25
28
26
-
## Project Setup
29
+
```
30
+
//FunctionDeclaration/:id/:name # Get all function names
31
+
//Identifier[/:name == "exports"] # Find all "exports" identifiers
32
+
//CallExpression[/Identifier/:name == "require"] # Find all require() calls
33
+
```
34
+
35
+
## Usage
36
+
37
+
1.**Paste JavaScript code** into the top textarea
38
+
2.**Write an Astronomical query** in the query field (supports multiline)
39
+
3.**Click "Execute Query"** to see matches
40
+
4.**Explore the AST** - Click nodes to expand/collapse the tree
41
+
42
+
### Example Queries
43
+
44
+
Find all function declarations:
45
+
46
+
```
47
+
//FunctionDeclaration
48
+
```
49
+
50
+
Get all function names:
51
+
52
+
```
53
+
//FunctionDeclaration/:id/:name
54
+
```
55
+
56
+
Find all variable declarations with specific names:
57
+
58
+
Find all variable declarations with specific names:
59
+
60
+
```
61
+
//VariableDeclarator[/:id/:name == "exports"]
62
+
```
63
+
64
+
## Development
65
+
66
+
### Project Setup
27
67
28
68
```sh
29
69
npm install
@@ -46,3 +86,30 @@ npm run build
46
86
```sh
47
87
npm run lint
48
88
```
89
+
90
+
## Technology Stack
91
+
92
+
-**Vue 3** - Progressive JavaScript framework
93
+
-**TypeScript** - Type safety and better developer experience
94
+
-**Vite** - Fast build tool and dev server
95
+
-**Astronomical** - JavaScript AST query engine
96
+
-**Meriyah** - Fast ECMAScript parser (used by Astronomical)
97
+
98
+
## Known Limitations
99
+
100
+
- Astronomical's `/:$object` binding feature may fail for runtime-provided identifiers (like `exports`, `module`, `require` in CommonJS) that aren't explicitly declared in the source code
101
+
- The viewer shows the static AST structure and doesn't have access to runtime context
102
+
103
+
## Contributing
104
+
105
+
Contributions are welcome! Please feel free to submit issues or pull requests.
106
+
107
+
## License
108
+
109
+
This project is open source. See LICENSE file for details.
110
+
111
+
## Related Projects
112
+
113
+
-[Astronomical](https://github.com/RetireJS/astronomical) - The query engine powering this viewer
114
+
-[AST Explorer](https://astexplorer.net/) - General purpose AST visualization tool
115
+
-[Regexr](https://regexr.com/) - Similar interactive tool for regular expressions
0 commit comments