mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-18 21:01:19 -08:00
Show on the desktop app's taskbar when Plan2Code needs you
AI Assisted
This commit is contained in:
1 parent
765d2b3536
commit
c602dfed57
25 files changed
+1038
-112
No files matched your search
@@ -23,6 +23,19 @@ export function linkLeavesPage(href, origin) {
|
||||
return (url.protocol === "http:" || url.protocol === "https:") && url.origin !== origin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call `handler(data)` for each `{ plan2code: kind, ... }` message the frame's
|
||||
* parent sends, and for nothing from anywhere else (another frame, the page
|
||||
* itself). The app's only answer today is `taskbar-state`.
|
||||
*/
|
||||
export function onAppMessage(kind, handler) {
|
||||
window.addEventListener("message", (event) => {
|
||||
if (!framed() || event.source !== window.parent) return;
|
||||
const data = event.data;
|
||||
if (data && typeof data === "object" && data.plan2code === kind) handler(data);
|
||||
});
|
||||
}
|
||||
|
||||
/** Post `message` to the frame's parent, as `{ plan2code: kind, ...extra }`; nothing outside a frame. */
|
||||
export function tellApp(kind, extra = {}) {
|
||||
if (!framed()) return;
|
||||
|
||||
Reference in new issue
Block a user