@lightdash/query-sdk 3.338.0 → 3.340.0

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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Forwards the Lightdash editor's capture hotkey (mod+shift+X) to the host.
3
+ *
4
+ * The app runs in a sandboxed iframe, so once the user clicks inside it the
5
+ * host page stops seeing key presses and its own hotkey goes dead. This is the
6
+ * one combination the SDK passes on. Nothing else the user types leaves the
7
+ * app, and the message carries no detail about the key press.
8
+ *
9
+ * The host decides what the message means. Hosts that do not offer capture
10
+ * ignore it.
11
+ */
12
+ export declare const CAPTURE_HOTKEY_MESSAGE = "lightdash:sdk:capture-hotkey";
13
+ /**
14
+ * Called by `createClient()` when the postMessage transport is detected. One
15
+ * listener per bundle: mounting again replaces the previous listener.
16
+ */
17
+ export declare function mountCaptureHotkey(targetWindow: Window): () => void;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Forwards the Lightdash editor's capture hotkey (mod+shift+X) to the host.
3
+ *
4
+ * The app runs in a sandboxed iframe, so once the user clicks inside it the
5
+ * host page stops seeing key presses and its own hotkey goes dead. This is the
6
+ * one combination the SDK passes on. Nothing else the user types leaves the
7
+ * app, and the message carries no detail about the key press.
8
+ *
9
+ * The host decides what the message means. Hosts that do not offer capture
10
+ * ignore it.
11
+ */
12
+ export const CAPTURE_HOTKEY_MESSAGE = 'lightdash:sdk:capture-hotkey';
13
+ // Same match as the host's own `mod+shift+X` binding: ctrl or cmd, shift, no
14
+ // alt. `code` covers layouts where shift or cmd changes the typed character.
15
+ const isCaptureHotkey = (event) => (event.ctrlKey || event.metaKey) &&
16
+ event.shiftKey &&
17
+ !event.altKey &&
18
+ (event.key.toLowerCase() === 'x' || event.code === 'KeyX');
19
+ let activeCleanup = null;
20
+ /**
21
+ * Called by `createClient()` when the postMessage transport is detected. One
22
+ * listener per bundle: mounting again replaces the previous listener.
23
+ */
24
+ export function mountCaptureHotkey(targetWindow) {
25
+ if (typeof window === 'undefined')
26
+ return () => { };
27
+ const message = { type: CAPTURE_HOTKEY_MESSAGE };
28
+ const handler = (event) => {
29
+ if (!isCaptureHotkey(event))
30
+ return;
31
+ // The host handles the combination, as it does on its own page.
32
+ event.preventDefault();
33
+ if (event.repeat)
34
+ return;
35
+ // Wildcard for the same reason as every other outbound bridge message:
36
+ // the sandboxed iframe has an opaque origin and can't derive the
37
+ // parent's.
38
+ targetWindow.postMessage(message, '*');
39
+ };
40
+ activeCleanup?.();
41
+ // Capture phase, so app code that stops key events can't swallow it.
42
+ window.addEventListener('keydown', handler, true);
43
+ const cleanup = () => {
44
+ window.removeEventListener('keydown', handler, true);
45
+ if (activeCleanup === cleanup)
46
+ activeCleanup = null;
47
+ };
48
+ activeCleanup = cleanup;
49
+ return cleanup;
50
+ }
package/dist/client.js CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import { createApiTransport } from './apiTransport';
8
8
  import { getAppStateStore } from './appState';
9
+ import { mountCaptureHotkey } from './captureHotkey';
9
10
  import { applyColorSchemeSeed, mountColorScheme } from './colorScheme';
10
11
  import { mountInspector } from './inspector';
11
12
  import { mountInsights } from './insights';
@@ -105,6 +106,7 @@ export function createClient() {
105
106
  mountLineage(window.parent);
106
107
  mountColorScheme(window.parent);
107
108
  mountInsights(window.parent);
109
+ mountCaptureHotkey(window.parent);
108
110
  return new LightdashClient({ apiKey: '', baseUrl: '', projectUuid }, createPostMessageTransport({
109
111
  targetWindow: window.parent,
110
112
  projectUuid,
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "3.338.0";
1
+ export declare const SDK_VERSION = "3.340.0";
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/generateSdkVersion.mjs (prebuild) — do not edit.
2
- export const SDK_VERSION = '3.338.0';
2
+ export const SDK_VERSION = '3.340.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/query-sdk",
3
- "version": "3.338.0",
3
+ "version": "3.340.0",
4
4
  "private": false,
5
5
  "description": "SDK for building custom data apps against the Lightdash semantic layer",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "devDependencies": {
29
- "@lightdash/common": "3.338.0",
29
+ "@lightdash/common": "3.340.0",
30
30
  "@types/node": "22.13.1",
31
31
  "@types/react": "19.3.0",
32
32
  "@types/react-dom": "19.3.0",