@caido/sdk-frontend 0.51.2-beta.15 → 0.51.2-beta.17

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido/sdk-frontend",
3
- "version": "0.51.2-beta.15",
3
+ "version": "0.51.2-beta.17",
4
4
  "description": "Typing for the Caido Frontend SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "license": "MIT",
@@ -15,5 +15,6 @@ export type { EnvironmentVariable } from "./types/environment";
15
15
  export type { Workflow, WorkflowKind, OnCreatedWorkflowCallback, OnUpdatedWorkflowCallback, OnDeletedWorkflowCallback, } from "./types/workflows";
16
16
  export type { ListenerHandle } from "./types/utils";
17
17
  export type { AIProvider } from "./types/ai";
18
+ export type { SelectedProjectChangeEvent } from "./types/projects";
18
19
  export type { API } from "./sdks";
19
20
  export { Routes } from "./types/navigation";
@@ -16,6 +16,7 @@ import type { InterceptSDK } from "./intercept";
16
16
  import type { MatchReplaceSDK } from "./matchReplace";
17
17
  import type { MenuSDK } from "./menu";
18
18
  import type { NavigationSDK } from "./navigation";
19
+ import type { ProjectsSDK } from "./projects";
19
20
  import type { ReplaySDK } from "./replay";
20
21
  import type { RuntimeSDK } from "./runtime";
21
22
  import type { ScopesSDK } from "./scopes";
@@ -68,6 +69,10 @@ export type API<T extends BackendEndpoints = Record<string, never>, E extends Ba
68
69
  * Utilities to interact with navigation.
69
70
  */
70
71
  navigation: NavigationSDK;
72
+ /**
73
+ * Utilities to interact with projects.
74
+ */
75
+ projects: ProjectsSDK;
71
76
  /**
72
77
  * Utilities to interact with the active page.
73
78
  */
@@ -1,4 +1,5 @@
1
- import { type Routes } from "../types/navigation";
1
+ import { type PageChangeEvent, type Routes } from "../types/navigation";
2
+ import { type ListenerHandle } from "../types/utils";
2
3
  /**
3
4
  * Utilities to interact with navigation.
4
5
  * @category Navigation
@@ -31,4 +32,21 @@ export type NavigationSDK = {
31
32
  topbar?: HTMLElement;
32
33
  onEnter?: () => void;
33
34
  }) => void;
35
+ /**
36
+ * Subscribe to page changes.
37
+ * @param callback The callback to call when the page changes.
38
+ * @returns An object with a `stop` method that can be called to stop listening to page changes.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const handler = sdk.navigation.onPageChange((event) => {
43
+ * console.log('Page changed to:', event.routeId);
44
+ * console.log('- path:', event.path);
45
+ * });
46
+ *
47
+ * // Later, stop listening
48
+ * handler.stop();
49
+ * ```
50
+ */
51
+ onPageChange: (callback: (route: PageChangeEvent) => void) => ListenerHandle;
34
52
  };
@@ -0,0 +1,24 @@
1
+ import { type SelectedProjectChangeEvent } from "../types/projects";
2
+ import { type ListenerHandle } from "../types/utils";
3
+ /**
4
+ * Utilities to interact with projects.
5
+ * @category Projects
6
+ */
7
+ export type ProjectsSDK = {
8
+ /**
9
+ * Subscribe to selected project changes.
10
+ * @param callback The callback to call when the selected project changes.
11
+ * @returns An object with a `stop` method that can be called to stop listening to project changes.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const handler = sdk.projects.onCurrentProjectChange((event) => {
16
+ * console.log('Selected project changed to:', event.projectId);
17
+ * });
18
+ *
19
+ * // Later, stop listening
20
+ * handler.stop();
21
+ * ```
22
+ */
23
+ onCurrentProjectChange: (callback: (event: SelectedProjectChangeEvent) => void) => ListenerHandle;
24
+ };
@@ -23,3 +23,11 @@ export declare const Routes: {
23
23
  readonly Settings: "Settings";
24
24
  };
25
25
  export type Routes = (typeof Routes)[keyof typeof Routes];
26
+ export type PageChangeEvent = {
27
+ type: "Core";
28
+ routeId: Routes;
29
+ path: string;
30
+ } | {
31
+ type: "Plugin";
32
+ path: string;
33
+ };
@@ -0,0 +1,8 @@
1
+ import { type ID } from "./utils";
2
+ /**
3
+ * Event fired when the selected project changes.
4
+ * @category Projects
5
+ */
6
+ export type SelectedProjectChangeEvent = {
7
+ projectId: ID | undefined;
8
+ };