-
Notifications
You must be signed in to change notification settings - Fork 112
feat(ambient-ui): live preview with visual feedback and BFF proxy #1618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7820d4c
feat(ambient-ui): live preview with visual feedback and BFF proxy
jsell-rh 3665b18
fix(ci): add ambient-ui to stage build pipeline and fix oauth client-id
jsell-rh 628da3d
Merge branch 'main' into jsell/feat/ambient-ui-live-preview
mergify[bot] 5a31f0d
fix(ambient-ui): address CodeQL findings for SSRF and string escaping
jsell-rh 13afc8b
fix(ambient-ui): reconstruct URL from validated components for CodeQL…
jsell-rh c778126
fix(ambient-ui): use webpack for production build
jsell-rh abfb41d
fix(ambient-ui): add symlink for SDK file: dependency in Docker build
jsell-rh 6e38d80
fix(ambient-ui): address CodeRabbit review and Docker build
jsell-rh bafaf5b
fix(ambient-ui): build SDK dist in Docker before npm ci
jsell-rh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /** | ||
| * Ambient UI Preview Bridge | ||
| * | ||
| * Include this script in pages rendered inside the Ambient UI preview iframe | ||
| * to enable cross-origin element capture and hover highlighting. | ||
| * | ||
| * Usage: <script src="/preview-bridge.js"></script> | ||
| * | ||
| * The bridge listens for postMessage requests from the parent frame and | ||
| * responds with element information at the requested coordinates. | ||
| */ | ||
| (function () { | ||
| 'use strict'; | ||
|
|
||
| var currentHighlight = null; | ||
|
|
||
| // Element capture: parent asks for the element at (x, y) | ||
| window.addEventListener('message', function (e) { | ||
| if (!e.data || e.data.type !== 'ambient-capture') return; | ||
|
|
||
| var x = e.data.x; | ||
| var y = e.data.y; | ||
| var el = document.elementFromPoint(x, y); | ||
|
|
||
| if (!el) { | ||
| e.source.postMessage({ type: 'ambient-captured', html: null, rect: null }, '*'); | ||
| return; | ||
| } | ||
|
|
||
| var rect = el.getBoundingClientRect(); | ||
| e.source.postMessage({ | ||
| type: 'ambient-captured', | ||
| html: el.outerHTML.slice(0, 500), | ||
| tagName: el.tagName.toLowerCase(), | ||
| id: el.id || null, | ||
| className: el.className || null, | ||
| textContent: (el.textContent || '').slice(0, 100), | ||
| rect: { x: rect.x, y: rect.y, width: rect.width, height: rect.height } | ||
| }, '*'); | ||
| }); | ||
|
|
||
| // Hover highlight: parent sends cursor position, bridge outlines the element | ||
| window.addEventListener('message', function (e) { | ||
| if (!e.data || e.data.type !== 'ambient-hover') return; | ||
|
|
||
| var el = document.elementFromPoint(e.data.x, e.data.y); | ||
|
|
||
| // Remove previous highlight | ||
| if (currentHighlight) { | ||
| currentHighlight.style.outline = currentHighlight._ambientSavedOutline || ''; | ||
| delete currentHighlight._ambientSavedOutline; | ||
| currentHighlight = null; | ||
| } | ||
|
|
||
| if (el && el !== document.documentElement && el !== document.body) { | ||
| el._ambientSavedOutline = el.style.outline; | ||
| el.style.outline = '2px solid #4394e5'; | ||
| currentHighlight = el; | ||
| } | ||
|
|
||
| if (el) { | ||
| var rect = el.getBoundingClientRect(); | ||
| e.source.postMessage({ | ||
| type: 'ambient-hovered', | ||
| rect: { x: rect.x, y: rect.y, width: rect.width, height: rect.height } | ||
| }, '*'); | ||
| } | ||
| }); | ||
|
|
||
| // Clear hover: remove any active highlight | ||
| window.addEventListener('message', function (e) { | ||
| if (!e.data || e.data.type !== 'ambient-hover-clear') return; | ||
| if (currentHighlight) { | ||
| currentHighlight.style.outline = currentHighlight._ambientSavedOutline || ''; | ||
| delete currentHighlight._ambientSavedOutline; | ||
| currentHighlight = null; | ||
| } | ||
| }); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| })(); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.