mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-17 04:45:33 -08:00
Teach the web console to read right inside the desktop app
AI Assisted
This commit is contained in:
1 parent
72043e20fc
commit
c1f41e4a82
25 files changed
+951
-85
No files matched your search
@@ -0,0 +1,19 @@
|
||||
// Plan2Code Web Console - the few messages this page sends the desktop app that frames it; defines only.
|
||||
//
|
||||
// Each one is a named request with no free text in it, so the app decides what
|
||||
// it does: a page can ask for "continue" to be typed, never for anything else.
|
||||
|
||||
/** True inside a frame: the desktop app's window, the only place that frames this page. */
|
||||
export function framed() {
|
||||
return Boolean(window.parent) && window.parent !== window;
|
||||
}
|
||||
|
||||
/** Post `message` to the frame's parent, as `{ plan2code: kind, ...extra }`; nothing outside a frame. */
|
||||
export function tellApp(kind, extra = {}) {
|
||||
if (!framed()) return;
|
||||
try {
|
||||
window.parent.postMessage({ ...extra, plan2code: kind }, "*");
|
||||
} catch {
|
||||
/* no parent to tell */
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user