@makoai/app-sdk 2.9.0 → 2.9.1

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 (3) hide show
  1. package/index.d.ts +12 -0
  2. package/index.js +36 -1
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -365,3 +365,15 @@ export function useSearchParams(): [
365
365
  ) => void,
366
366
  ];
367
367
  export function navigate(to: string, opts?: { replace?: boolean }): void;
368
+ /**
369
+ * The Mako shortcut a keydown stands for ("mod+k" for Cmd/Ctrl+K), or null.
370
+ * Inside Mako the SDK forwards these to the host, because a cross-origin
371
+ * app frame keeps its keystrokes from Mako's own listeners.
372
+ */
373
+ export function hostShortcutFor(event: {
374
+ key: string;
375
+ metaKey: boolean;
376
+ ctrlKey: boolean;
377
+ altKey: boolean;
378
+ shiftKey: boolean;
379
+ }): "mod+k" | null;
package/index.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
  * in a page (or this export) says which SDK a deployed app actually runs.
33
33
  * Kept in step with package.json by snapshot.test.mjs.
34
34
  */
35
- export const SDK_VERSION = "2.9.0";
35
+ export const SDK_VERSION = "2.9.1";
36
36
  if (typeof window !== "undefined") {
37
37
  try {
38
38
  window.__MAKO_APP_SDK__ = SDK_VERSION;
@@ -790,6 +790,41 @@ export function navigate(to, opts) {
790
790
  }
791
791
  }
792
792
 
793
+ // ---------------------------------------------------------------------------
794
+ // Host shortcuts — keys that belong to Mako, not the app.
795
+ //
796
+ // On its own origin (<appId>.makousercontent.com) the app is a cross-origin
797
+ // frame: a keydown while it has focus reaches only this document, so Mako's
798
+ // Cmd/Ctrl+K never fired. Hand the shortcut to the host instead, the same
799
+ // way navigate() hands over the query. Capture phase, so an app's own
800
+ // handlers cannot swallow it first.
801
+ // ---------------------------------------------------------------------------
802
+ export function hostShortcutFor(event) {
803
+ if (!(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey) {
804
+ return null;
805
+ }
806
+ return typeof event.key === "string" && event.key.toLowerCase() === "k"
807
+ ? "mod+k"
808
+ : null;
809
+ }
810
+
811
+ if (typeof window !== "undefined" && window.parent !== window) {
812
+ window.addEventListener(
813
+ "keydown",
814
+ event => {
815
+ const key = hostShortcutFor(event);
816
+ if (!key) return;
817
+ event.preventDefault();
818
+ try {
819
+ window.parent.postMessage({ type: "mako-app:shortcut", key }, "*");
820
+ } catch {
821
+ // A host that is not Mako: nothing to tell.
822
+ }
823
+ },
824
+ true,
825
+ );
826
+ }
827
+
793
828
  export function useLocation() {
794
829
  const [loc, setLoc] = React.useState(readLocation);
795
830
  React.useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makoai/app-sdk",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "description": "Mako app SDK: data bindings (useQuery/useDuckDB), URL state, theme, and the house dashboard kit (/ui).",
5
5
  "license": "MIT",
6
6
  "repository": {