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

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.16",
4
4
  "description": "Typing for the Caido Frontend SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "license": "MIT",
@@ -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
  };
@@ -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
+ };