angular-grab 0.1.0 → 0.1.2

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.
Files changed (132) hide show
  1. package/README.md +215 -0
  2. package/examples/angular-19-app/.editorconfig +17 -0
  3. package/examples/angular-19-app/.vscode/extensions.json +4 -0
  4. package/examples/angular-19-app/.vscode/launch.json +20 -0
  5. package/examples/angular-19-app/.vscode/mcp.json +9 -0
  6. package/examples/angular-19-app/.vscode/tasks.json +42 -0
  7. package/examples/angular-19-app/README.md +59 -0
  8. package/examples/angular-19-app/angular.json +74 -0
  9. package/examples/angular-19-app/package.json +44 -0
  10. package/examples/angular-19-app/public/favicon.ico +0 -0
  11. package/examples/angular-19-app/src/app/app.config.ts +13 -0
  12. package/examples/angular-19-app/src/app/app.css +37 -0
  13. package/examples/angular-19-app/src/app/app.html +25 -0
  14. package/examples/angular-19-app/src/app/app.routes.ts +3 -0
  15. package/examples/angular-19-app/src/app/app.spec.ts +23 -0
  16. package/examples/angular-19-app/src/app/app.ts +12 -0
  17. package/examples/angular-19-app/src/app/button/button.component.ts +25 -0
  18. package/examples/angular-19-app/src/app/card/card.component.ts +33 -0
  19. package/examples/angular-19-app/src/app/header/header.component.ts +31 -0
  20. package/examples/angular-19-app/src/app/popover/popover.component.ts +133 -0
  21. package/examples/angular-19-app/src/index.html +13 -0
  22. package/examples/angular-19-app/src/main.ts +6 -0
  23. package/examples/angular-19-app/src/styles.css +1 -0
  24. package/examples/angular-19-app/tsconfig.app.json +15 -0
  25. package/examples/angular-19-app/tsconfig.json +33 -0
  26. package/examples/angular-19-app/tsconfig.spec.json +15 -0
  27. package/package.json +14 -111
  28. package/packages/angular-grab/package.json +96 -0
  29. package/packages/angular-grab/src/angular/__tests__/context-builder.test.ts +216 -0
  30. package/packages/angular-grab/src/angular/angular-grab.service.ts +62 -0
  31. package/packages/angular-grab/src/angular/index.ts +13 -0
  32. package/packages/angular-grab/src/angular/provide-angular-grab.ts +22 -0
  33. package/packages/angular-grab/src/angular/resolvers/component-resolver.ts +71 -0
  34. package/packages/angular-grab/src/angular/resolvers/context-builder.ts +86 -0
  35. package/packages/angular-grab/src/angular/resolvers/ng-utils.ts +14 -0
  36. package/packages/angular-grab/src/angular/resolvers/source-resolver.ts +61 -0
  37. package/packages/angular-grab/src/builder/__tests__/builder.test.ts +72 -0
  38. package/packages/angular-grab/src/builder/builders/application/index.ts +13 -0
  39. package/packages/angular-grab/src/builder/builders/dev-server/index.ts +9 -0
  40. package/packages/angular-grab/src/builder/index.ts +3 -0
  41. package/packages/angular-grab/src/cli/__tests__/cli.test.ts +239 -0
  42. package/packages/angular-grab/src/cli/commands/init.ts +106 -0
  43. package/packages/angular-grab/src/cli/index.ts +15 -0
  44. package/packages/angular-grab/src/cli/utils/detect-project.ts +78 -0
  45. package/packages/angular-grab/src/cli/utils/modify-angular-json.ts +42 -0
  46. package/packages/angular-grab/src/cli/utils/modify-app-config.ts +42 -0
  47. package/packages/angular-grab/src/core/__tests__/generate-snippet.test.ts +149 -0
  48. package/packages/angular-grab/src/core/__tests__/plugin-registry.test.ts +286 -0
  49. package/packages/angular-grab/src/core/__tests__/store.test.ts +118 -0
  50. package/packages/angular-grab/src/core/__tests__/utils.test.ts +85 -0
  51. package/packages/angular-grab/src/core/clipboard/copy.ts +104 -0
  52. package/packages/angular-grab/src/core/clipboard/generate-snippet.ts +38 -0
  53. package/packages/angular-grab/src/core/constants.ts +10 -0
  54. package/packages/angular-grab/src/core/grab.ts +596 -0
  55. package/packages/angular-grab/src/core/index.global.ts +13 -0
  56. package/packages/angular-grab/src/core/index.ts +19 -0
  57. package/packages/angular-grab/src/core/keyboard/keyboard-handler.ts +163 -0
  58. package/packages/angular-grab/src/core/overlay/crosshair.ts +107 -0
  59. package/packages/angular-grab/src/core/overlay/freeze-overlay.ts +239 -0
  60. package/packages/angular-grab/src/core/overlay/overlay-renderer.ts +180 -0
  61. package/packages/angular-grab/src/core/overlay/select-feedback.ts +108 -0
  62. package/packages/angular-grab/src/core/overlay/toast.ts +175 -0
  63. package/packages/angular-grab/src/core/picker/element-picker.ts +114 -0
  64. package/packages/angular-grab/src/core/plugins/plugin-registry.ts +83 -0
  65. package/packages/angular-grab/src/core/store.ts +52 -0
  66. package/packages/angular-grab/src/core/toolbar/actions-menu.ts +178 -0
  67. package/packages/angular-grab/src/core/toolbar/comment-popover.ts +235 -0
  68. package/packages/angular-grab/src/core/toolbar/copy-actions.ts +98 -0
  69. package/packages/angular-grab/src/core/toolbar/history-popover.ts +245 -0
  70. package/packages/angular-grab/src/core/toolbar/theme-manager.ts +188 -0
  71. package/packages/angular-grab/src/core/toolbar/toolbar-icons.ts +29 -0
  72. package/packages/angular-grab/src/core/toolbar/toolbar-renderer.ts +239 -0
  73. package/packages/angular-grab/src/core/types.ts +139 -0
  74. package/packages/angular-grab/src/core/utils.ts +16 -0
  75. package/packages/angular-grab/src/esbuild-plugin/__tests__/transform.test.ts +174 -0
  76. package/packages/angular-grab/src/esbuild-plugin/index.ts +3 -0
  77. package/packages/angular-grab/src/esbuild-plugin/plugin.ts +29 -0
  78. package/packages/angular-grab/src/esbuild-plugin/scan.ts +105 -0
  79. package/packages/angular-grab/src/esbuild-plugin/transform.ts +152 -0
  80. package/packages/angular-grab/src/vite-plugin/__tests__/plugin.test.ts +84 -0
  81. package/packages/angular-grab/src/vite-plugin/index.ts +19 -0
  82. package/packages/angular-grab/src/webpack-plugin/__tests__/plugin.test.ts +72 -0
  83. package/packages/angular-grab/src/webpack-plugin/index.ts +2 -0
  84. package/packages/angular-grab/src/webpack-plugin/loader.ts +15 -0
  85. package/packages/angular-grab/src/webpack-plugin/plugin.ts +20 -0
  86. package/packages/angular-grab/tsconfig.json +15 -0
  87. package/packages/angular-grab/tsup.config.ts +119 -0
  88. package/pnpm-workspace.yaml +3 -0
  89. package/turbo.json +21 -0
  90. package/dist/angular/index.d.ts +0 -151
  91. package/dist/angular/index.js +0 -2811
  92. package/dist/angular/index.js.map +0 -1
  93. package/dist/builder/builders/application/index.js +0 -143
  94. package/dist/builder/builders/application/index.js.map +0 -1
  95. package/dist/builder/builders/dev-server/index.js +0 -139
  96. package/dist/builder/builders/dev-server/index.js.map +0 -1
  97. package/dist/builder/index.js +0 -2
  98. package/dist/builder/index.js.map +0 -1
  99. package/dist/builder/package.json +0 -1
  100. package/dist/cli/index.js +0 -223
  101. package/dist/cli/index.js.map +0 -1
  102. package/dist/core/index.cjs +0 -2589
  103. package/dist/core/index.cjs.map +0 -1
  104. package/dist/core/index.d.cts +0 -139
  105. package/dist/core/index.d.ts +0 -139
  106. package/dist/core/index.global.js +0 -542
  107. package/dist/core/index.js +0 -2560
  108. package/dist/core/index.js.map +0 -1
  109. package/dist/esbuild-plugin/index.cjs +0 -239
  110. package/dist/esbuild-plugin/index.cjs.map +0 -1
  111. package/dist/esbuild-plugin/index.d.cts +0 -26
  112. package/dist/esbuild-plugin/index.d.ts +0 -26
  113. package/dist/esbuild-plugin/index.js +0 -200
  114. package/dist/esbuild-plugin/index.js.map +0 -1
  115. package/dist/vite-plugin/index.d.ts +0 -7
  116. package/dist/vite-plugin/index.js +0 -128
  117. package/dist/vite-plugin/index.js.map +0 -1
  118. package/dist/webpack-plugin/index.cjs +0 -54
  119. package/dist/webpack-plugin/index.cjs.map +0 -1
  120. package/dist/webpack-plugin/index.d.cts +0 -5
  121. package/dist/webpack-plugin/index.d.ts +0 -5
  122. package/dist/webpack-plugin/index.js +0 -23
  123. package/dist/webpack-plugin/index.js.map +0 -1
  124. package/dist/webpack-plugin/loader.cjs +0 -155
  125. package/dist/webpack-plugin/loader.cjs.map +0 -1
  126. package/dist/webpack-plugin/loader.d.cts +0 -3
  127. package/dist/webpack-plugin/loader.d.ts +0 -3
  128. package/dist/webpack-plugin/loader.js +0 -122
  129. package/dist/webpack-plugin/loader.js.map +0 -1
  130. /package/{builders.json → packages/angular-grab/builders.json} +0 -0
  131. /package/{dist → packages/angular-grab/src}/builder/builders/application/schema.json +0 -0
  132. /package/{dist → packages/angular-grab/src}/builder/builders/dev-server/schema.json +0 -0
package/README.md ADDED
@@ -0,0 +1,215 @@
1
+ # angular-grab
2
+
3
+ > Grab any element in your Angular app and give it to AI coding agents
4
+
5
+ Point at any element and press **Cmd+C** (Mac) or **Ctrl+C** (Windows/Linux) to copy the component name, file path, and HTML source code to your clipboard. Paste it into Claude, ChatGPT, Copilot, or any AI coding agent for instant context.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npx angular-grab init
11
+ ```
12
+
13
+ Or manually:
14
+
15
+ ```bash
16
+ npm install angular-grab
17
+ ```
18
+
19
+ Then add the provider to your app config:
20
+
21
+ ```typescript
22
+ import { provideAngularGrab } from 'angular-grab/angular';
23
+
24
+ export const appConfig: ApplicationConfig = {
25
+ providers: [
26
+ provideAngularGrab(),
27
+ ],
28
+ };
29
+ ```
30
+
31
+ And update `angular.json` to use the angular-grab builders:
32
+
33
+ ```json
34
+ {
35
+ "architect": {
36
+ "build": {
37
+ "builder": "angular-grab:application"
38
+ },
39
+ "serve": {
40
+ "builder": "angular-grab:dev-server"
41
+ }
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ Once installed, hover over any UI element in your browser and press:
49
+
50
+ - **Cmd+C** on Mac
51
+ - **Ctrl+C** on Windows/Linux
52
+
53
+ This copies the element's context to your clipboard:
54
+
55
+ ```
56
+ <button class="submit-btn">Save</button>
57
+ in SubmitButtonComponent at src/app/submit-button/submit-button.component.ts:12
58
+ in FormComponent at src/app/form/form.component.ts:8
59
+ in AppComponent at src/app/app.component.ts:5
60
+ ```
61
+
62
+ The output includes the cleaned HTML, the full Angular component stack trace, and source file locations.
63
+
64
+ ## Features
65
+
66
+ - **Element selection** via keyboard shortcut or floating toolbar
67
+ - **Component stack trace** -- full Angular component ancestor chain with file paths
68
+ - **Open in VS Code** -- click file paths in the toast to open at the exact line
69
+ - **Freeze mode** -- freeze the page to grab tooltips, dropdowns, and hover menus
70
+ - **Floating toolbar** with selection, history, actions, freeze, theme, and enable controls
71
+ - **History** of previously grabbed elements with one-click re-copy
72
+ - **Dark / light / system theme** for all UI
73
+ - **Plugin system** for custom actions, hooks, and theme overrides
74
+ - **Crosshair guidelines** during selection mode
75
+ - **Zero production impact** -- automatically disabled outside dev mode
76
+
77
+ ## Keyboard Shortcuts
78
+
79
+ | Shortcut | Action |
80
+ |----------|--------|
81
+ | Cmd+C / Ctrl+C (hold) | Activate selection mode |
82
+ | Click | Select element and copy |
83
+ | F (during selection) | Toggle freeze mode |
84
+ | Escape | Cancel comment popover |
85
+
86
+ ## Configuration
87
+
88
+ ```typescript
89
+ provideAngularGrab({
90
+ activationKey: 'Meta+C', // Keyboard shortcut
91
+ activationMode: 'hold', // 'hold' or 'toggle'
92
+ keyHoldDuration: 0, // ms to hold before activating
93
+ maxContextLines: 20, // Max HTML lines in clipboard
94
+ enabled: true, // Master switch
95
+ enableInInputs: false, // Allow in input/textarea
96
+ devOnly: true, // Only active in dev mode
97
+ showToolbar: true, // Show floating toolbar
98
+ themeMode: 'dark', // 'dark' | 'light' | 'system'
99
+ });
100
+ ```
101
+
102
+ ## Toolbar
103
+
104
+ The floating toolbar provides quick access to all features without keyboard shortcuts:
105
+
106
+ | Button | Action |
107
+ |--------|--------|
108
+ | Hand | Toggle selection mode |
109
+ | Clock | Show grab history |
110
+ | Ellipsis | Actions menu (Copy Element, Copy Styles, Copy HTML, Comment, Clear History) |
111
+ | Snowflake | Toggle freeze mode |
112
+ | Sun/Moon | Cycle theme (dark / light / system) |
113
+ | Power | Enable/disable angular-grab |
114
+ | X | Dismiss toolbar |
115
+
116
+ Dismissing the toolbar doesn't disable angular-grab -- keyboard shortcuts still work, and activating selection mode brings the toolbar back.
117
+
118
+ ## Plugin System
119
+
120
+ ```typescript
121
+ import { registerAngularGrabPlugin } from 'angular-grab/angular';
122
+
123
+ registerAngularGrabPlugin({
124
+ name: 'my-plugin',
125
+ hooks: {
126
+ onElementSelect(context) {
127
+ console.log('Selected:', context.selector);
128
+ },
129
+ onCopySuccess(text, context) {
130
+ console.log('Copied:', context.componentName);
131
+ },
132
+ transformCopyContent(text, context) {
133
+ return `// From ${context.componentName}\n${text}`;
134
+ },
135
+ },
136
+ });
137
+ ```
138
+
139
+ ### Plugin Hooks
140
+
141
+ | Hook | Description |
142
+ |------|-------------|
143
+ | `onActivate` | Selection mode activated |
144
+ | `onDeactivate` | Selection mode deactivated |
145
+ | `onElementHover` | Mouse hovers over an element |
146
+ | `onElementSelect` | Element is selected |
147
+ | `onBeforeCopy` | About to copy to clipboard |
148
+ | `onCopySuccess` | Successfully copied |
149
+ | `onCopyError` | Copy failed |
150
+ | `transformCopyContent` | Transform clipboard text before copying |
151
+
152
+ ### Plugin Theme Overrides
153
+
154
+ ```typescript
155
+ registerAngularGrabPlugin({
156
+ name: 'custom-theme',
157
+ theme: {
158
+ overlayBorderColor: '#10b981',
159
+ overlayBgColor: 'rgba(16, 185, 129, 0.1)',
160
+ toolbarBgColor: '#1a1a2e',
161
+ toolbarAccentColor: '#10b981',
162
+ },
163
+ });
164
+ ```
165
+
166
+ ## API
167
+
168
+ Access the API programmatically via Angular's dependency injection:
169
+
170
+ ```typescript
171
+ import { inject } from '@angular/core';
172
+ import { ANGULAR_GRAB_API } from 'angular-grab/angular';
173
+
174
+ const api = inject(ANGULAR_GRAB_API);
175
+ api.activate();
176
+ api.setThemeMode('light');
177
+ ```
178
+
179
+ ### `AngularGrabAPI`
180
+
181
+ | Method | Description |
182
+ |--------|-------------|
183
+ | `activate()` | Enter selection mode |
184
+ | `deactivate()` | Exit selection mode |
185
+ | `toggle()` | Toggle selection mode |
186
+ | `isActive()` | Check if selection mode is active |
187
+ | `setOptions(opts)` | Update options |
188
+ | `registerPlugin(plugin)` | Register a plugin |
189
+ | `unregisterPlugin(name)` | Remove a plugin |
190
+ | `setComponentResolver(fn)` | Custom component resolver |
191
+ | `setSourceResolver(fn)` | Custom source file resolver |
192
+ | `showToolbar()` | Show the floating toolbar |
193
+ | `hideToolbar()` | Hide the floating toolbar |
194
+ | `setThemeMode(mode)` | Set theme ('dark', 'light', 'system') |
195
+ | `getHistory()` | Get grab history entries |
196
+ | `clearHistory()` | Clear grab history |
197
+ | `dispose()` | Clean up everything |
198
+
199
+ ## Subpath Exports
200
+
201
+ The `angular-grab` package provides subpath exports for different build tool integrations:
202
+
203
+ | Import | Description |
204
+ |--------|-------------|
205
+ | `angular-grab` | Core picker engine and types |
206
+ | `angular-grab/angular` | Angular integration (providers, services, resolvers) |
207
+ | `angular-grab/esbuild` | esbuild plugin for source location injection |
208
+ | `angular-grab/vite` | Vite plugin for source location injection |
209
+ | `angular-grab/webpack` | Webpack plugin for source location injection |
210
+ | `angular-grab/builder` | Angular CLI custom builders |
211
+ | `angular-grab/global` | IIFE browser bundle |
212
+
213
+ ## License
214
+
215
+ MIT
@@ -0,0 +1,17 @@
1
+ # Editor configuration, see https://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.ts]
12
+ quote_type = single
13
+ ij_typescript_use_double_quotes = false
14
+
15
+ [*.md]
16
+ max_line_length = off
17
+ trim_trailing_whitespace = false
@@ -0,0 +1,4 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3
+ "recommendations": ["angular.ng-template"]
4
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3
+ "version": "0.2.0",
4
+ "configurations": [
5
+ {
6
+ "name": "ng serve",
7
+ "type": "chrome",
8
+ "request": "launch",
9
+ "preLaunchTask": "npm: start",
10
+ "url": "http://localhost:4200/"
11
+ },
12
+ {
13
+ "name": "ng test",
14
+ "type": "chrome",
15
+ "request": "launch",
16
+ "preLaunchTask": "npm: test",
17
+ "url": "http://localhost:9876/debug.html"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ // For more information, visit: https://angular.dev/ai/mcp
3
+ "servers": {
4
+ "angular-cli": {
5
+ "command": "npx",
6
+ "args": ["-y", "@angular/cli", "mcp"]
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3
+ "version": "2.0.0",
4
+ "tasks": [
5
+ {
6
+ "type": "npm",
7
+ "script": "start",
8
+ "isBackground": true,
9
+ "problemMatcher": {
10
+ "owner": "typescript",
11
+ "pattern": "$tsc",
12
+ "background": {
13
+ "activeOnStart": true,
14
+ "beginsPattern": {
15
+ "regexp": "Changes detected"
16
+ },
17
+ "endsPattern": {
18
+ "regexp": "bundle generation (complete|failed)"
19
+ }
20
+ }
21
+ }
22
+ },
23
+ {
24
+ "type": "npm",
25
+ "script": "test",
26
+ "isBackground": true,
27
+ "problemMatcher": {
28
+ "owner": "typescript",
29
+ "pattern": "$tsc",
30
+ "background": {
31
+ "activeOnStart": true,
32
+ "beginsPattern": {
33
+ "regexp": "Changes detected"
34
+ },
35
+ "endsPattern": {
36
+ "regexp": "bundle generation (complete|failed)"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ]
42
+ }
@@ -0,0 +1,59 @@
1
+ # Angular19App
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.1.1.
4
+
5
+ ## Development server
6
+
7
+ To start a local development server, run:
8
+
9
+ ```bash
10
+ ng serve
11
+ ```
12
+
13
+ Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
14
+
15
+ ## Code scaffolding
16
+
17
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
18
+
19
+ ```bash
20
+ ng generate component component-name
21
+ ```
22
+
23
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
24
+
25
+ ```bash
26
+ ng generate --help
27
+ ```
28
+
29
+ ## Building
30
+
31
+ To build the project run:
32
+
33
+ ```bash
34
+ ng build
35
+ ```
36
+
37
+ This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
38
+
39
+ ## Running unit tests
40
+
41
+ To execute unit tests with the [Vitest](https://vitest.dev/) test runner, use the following command:
42
+
43
+ ```bash
44
+ ng test
45
+ ```
46
+
47
+ ## Running end-to-end tests
48
+
49
+ For end-to-end (e2e) testing, run:
50
+
51
+ ```bash
52
+ ng e2e
53
+ ```
54
+
55
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
56
+
57
+ ## Additional Resources
58
+
59
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
@@ -0,0 +1,74 @@
1
+ {
2
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+ "version": 1,
4
+ "cli": {
5
+ "packageManager": "pnpm",
6
+ "analytics": false
7
+ },
8
+ "newProjectRoot": "projects",
9
+ "projects": {
10
+ "angular-19-app": {
11
+ "projectType": "application",
12
+ "schematics": {},
13
+ "root": "",
14
+ "sourceRoot": "src",
15
+ "prefix": "app",
16
+ "architect": {
17
+ "build": {
18
+ "builder": "angular-grab:application",
19
+ "options": {
20
+ "browser": "src/main.ts",
21
+ "tsConfig": "tsconfig.app.json",
22
+ "assets": [
23
+ {
24
+ "glob": "**/*",
25
+ "input": "public"
26
+ }
27
+ ],
28
+ "styles": [
29
+ "src/styles.css"
30
+ ]
31
+ },
32
+ "configurations": {
33
+ "production": {
34
+ "budgets": [
35
+ {
36
+ "type": "initial",
37
+ "maximumWarning": "500kB",
38
+ "maximumError": "1MB"
39
+ },
40
+ {
41
+ "type": "anyComponentStyle",
42
+ "maximumWarning": "4kB",
43
+ "maximumError": "8kB"
44
+ }
45
+ ],
46
+ "outputHashing": "all"
47
+ },
48
+ "development": {
49
+ "optimization": false,
50
+ "extractLicenses": false,
51
+ "sourceMap": true
52
+ }
53
+ },
54
+ "defaultConfiguration": "production"
55
+ },
56
+ "serve": {
57
+ "builder": "angular-grab:dev-server",
58
+ "configurations": {
59
+ "production": {
60
+ "buildTarget": "angular-19-app:build:production"
61
+ },
62
+ "development": {
63
+ "buildTarget": "angular-19-app:build:development"
64
+ }
65
+ },
66
+ "defaultConfiguration": "development"
67
+ },
68
+ "test": {
69
+ "builder": "@angular/build:unit-test"
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "angular-19-app",
3
+ "version": "0.0.0",
4
+ "scripts": {
5
+ "ng": "ng",
6
+ "start": "ng serve",
7
+ "build": "ng build",
8
+ "watch": "ng build --watch --configuration development",
9
+ "test": "ng test"
10
+ },
11
+ "prettier": {
12
+ "printWidth": 100,
13
+ "singleQuote": true,
14
+ "overrides": [
15
+ {
16
+ "files": "*.html",
17
+ "options": {
18
+ "parser": "angular"
19
+ }
20
+ }
21
+ ]
22
+ },
23
+ "private": true,
24
+ "packageManager": "pnpm@9.15.0",
25
+ "dependencies": {
26
+ "@angular/common": "^21.1.0",
27
+ "@angular/compiler": "^21.1.0",
28
+ "@angular/core": "^21.1.0",
29
+ "@angular/forms": "^21.1.0",
30
+ "@angular/platform-browser": "^21.1.0",
31
+ "@angular/router": "^21.1.0",
32
+ "angular-grab": "workspace:*",
33
+ "rxjs": "~7.8.0",
34
+ "tslib": "^2.3.0"
35
+ },
36
+ "devDependencies": {
37
+ "@angular/build": "^21.1.1",
38
+ "@angular/cli": "^21.1.1",
39
+ "@angular/compiler-cli": "^21.1.0",
40
+ "jsdom": "^27.1.0",
41
+ "typescript": "~5.9.2",
42
+ "vitest": "^4.0.8"
43
+ }
44
+ }
@@ -0,0 +1,13 @@
1
+ import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core';
2
+ import { provideRouter } from '@angular/router';
3
+ import { provideAngularGrab } from 'angular-grab/angular';
4
+
5
+ import { routes } from './app.routes';
6
+
7
+ export const appConfig: ApplicationConfig = {
8
+ providers: [
9
+ provideBrowserGlobalErrorListeners(),
10
+ provideRouter(routes),
11
+ provideAngularGrab(),
12
+ ],
13
+ };
@@ -0,0 +1,37 @@
1
+ .main {
2
+ max-width: 960px;
3
+ margin: 0 auto;
4
+ padding: 32px 24px;
5
+ }
6
+
7
+ .hero {
8
+ text-align: center;
9
+ margin-bottom: 40px;
10
+ }
11
+
12
+ .hero h1 {
13
+ font-size: 2rem;
14
+ font-weight: 700;
15
+ margin: 0 0 12px;
16
+ }
17
+
18
+ .hero p {
19
+ color: #64748b;
20
+ font-size: 1.1rem;
21
+ line-height: 1.6;
22
+ }
23
+
24
+ .hero kbd {
25
+ background: #f1f5f9;
26
+ border: 1px solid #e2e8f0;
27
+ border-radius: 4px;
28
+ padding: 2px 6px;
29
+ font-family: monospace;
30
+ font-size: 0.9rem;
31
+ }
32
+
33
+ .cards {
34
+ display: grid;
35
+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
36
+ gap: 20px;
37
+ }
@@ -0,0 +1,25 @@
1
+ <app-header />
2
+
3
+ <main class="main">
4
+ <section class="hero">
5
+ <h1>angular-grab Demo</h1>
6
+ <p>Hold <kbd>⌘C</kbd> (Mac) or <kbd>Ctrl+C</kbd> (Windows) and hover over any element to grab its context for AI coding agents.</p>
7
+ </section>
8
+
9
+ <section class="cards">
10
+ <app-card
11
+ title="Element Picker"
12
+ body="Hover over any UI element while holding the activation key. A blue overlay highlights the element under your cursor."
13
+ />
14
+ <app-card
15
+ title="Component Resolution"
16
+ body="angular-grab uses Angular's debug APIs to identify which component owns each element, including the component class name."
17
+ />
18
+ <app-card
19
+ title="Source Mapping"
20
+ body="The esbuild plugin injects data-ng-source attributes at build time, mapping each component to its source file and line number."
21
+ />
22
+ </section>
23
+
24
+ <app-popover />
25
+ </main>
@@ -0,0 +1,3 @@
1
+ import { Routes } from '@angular/router';
2
+
3
+ export const routes: Routes = [];
@@ -0,0 +1,23 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+ import { App } from './app';
3
+
4
+ describe('App', () => {
5
+ beforeEach(async () => {
6
+ await TestBed.configureTestingModule({
7
+ imports: [App],
8
+ }).compileComponents();
9
+ });
10
+
11
+ it('should create the app', () => {
12
+ const fixture = TestBed.createComponent(App);
13
+ const app = fixture.componentInstance;
14
+ expect(app).toBeTruthy();
15
+ });
16
+
17
+ it('should render title', async () => {
18
+ const fixture = TestBed.createComponent(App);
19
+ await fixture.whenStable();
20
+ const compiled = fixture.nativeElement as HTMLElement;
21
+ expect(compiled.querySelector('h1')?.textContent).toContain('angular-grab Demo');
22
+ });
23
+ });
@@ -0,0 +1,12 @@
1
+ import { Component } from '@angular/core';
2
+ import { HeaderComponent } from './header/header.component';
3
+ import { CardComponent } from './card/card.component';
4
+ import { PopoverComponent } from './popover/popover.component';
5
+
6
+ @Component({
7
+ selector: 'app-root',
8
+ imports: [HeaderComponent, CardComponent, PopoverComponent],
9
+ templateUrl: './app.html',
10
+ styleUrl: './app.css',
11
+ })
12
+ export class App {}
@@ -0,0 +1,25 @@
1
+ import { Component, Input } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'app-button',
5
+ standalone: true,
6
+ template: `
7
+ <button class="btn" type="button">{{ label }}</button>
8
+ `,
9
+ styles: [`
10
+ .btn {
11
+ padding: 8px 16px;
12
+ background: #3b82f6;
13
+ color: white;
14
+ border: none;
15
+ border-radius: 6px;
16
+ font-size: 0.875rem;
17
+ cursor: pointer;
18
+ transition: background 0.15s;
19
+ }
20
+ .btn:hover { background: #2563eb; }
21
+ `],
22
+ })
23
+ export class ButtonComponent {
24
+ @Input() label = 'Click me';
25
+ }
@@ -0,0 +1,33 @@
1
+ import { Component, Input } from '@angular/core';
2
+ import { ButtonComponent } from '../button/button.component';
3
+
4
+ @Component({
5
+ selector: 'app-card',
6
+ standalone: true,
7
+ template: `
8
+ <div class="card">
9
+ <h2 class="card-title">{{ title }}</h2>
10
+ <p class="card-body">{{ body }}</p>
11
+ <div class="card-footer">
12
+ <app-button [label]="'Learn More'" />
13
+ </div>
14
+ </div>
15
+ `,
16
+ styles: [`
17
+ .card {
18
+ border: 1px solid #e2e8f0;
19
+ border-radius: 8px;
20
+ padding: 20px;
21
+ background: white;
22
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
23
+ }
24
+ .card-title { font-size: 1.1rem; font-weight: 600; margin: 0 0 8px; }
25
+ .card-body { color: #64748b; margin: 0 0 16px; line-height: 1.5; }
26
+ .card-footer { display: flex; justify-content: flex-end; }
27
+ `],
28
+ imports: [ButtonComponent],
29
+ })
30
+ export class CardComponent {
31
+ @Input() title = '';
32
+ @Input() body = '';
33
+ }