@caido/sdk-frontend 0.41.1-beta.2 → 0.41.1-beta.4

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.
@@ -1,10 +1,41 @@
1
+ import type { Icon } from "./utils";
2
+ /**
3
+ * Utilities to interact with the sidebar.
4
+ * @category Sidebar
5
+ */
6
+ export type SidebarSDK = {
7
+ /**
8
+ * Register a sidebar item.
9
+ * @param name The name of the sidebar item.
10
+ * @param path The path that the user will be navigated to when the sidebar item is clicked.
11
+ * @param options Options for the sidebar item.
12
+ * @param options.icon The {@link Icon} of the sidebar item.
13
+ * @param options.group The group the sidebar item belongs to.
14
+ * @param options.isExternal Whether the path points to an external URL.
15
+ * @returns The created sidebar item.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * sdk.sidebar.registerItem("My Plugin", "/my-plugin-page", {
20
+ * icon: "fas fa-rocket",
21
+ * });
22
+ * ```
23
+ */
24
+ registerItem: (name: string, path: string, options?: {
25
+ icon?: Icon;
26
+ group?: string;
27
+ isExternal?: boolean;
28
+ }) => SidebarItem;
29
+ };
1
30
  /**
2
31
  * Represents a sidebar item.
32
+ * @category Sidebar
3
33
  */
4
- export type SidebarItem = {
34
+ type SidebarItem = {
5
35
  /**
6
36
  * Set the value of a notification badge next to the sidebar item.
7
37
  * @param count - The number to display in the badge. A value of 0 will hide the badge.
8
38
  */
9
39
  setCount: (count: number) => void;
10
40
  };
41
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { JSONCompatible, JSONValue } from "./utils";
2
+ /**
3
+ * Utilities to interact with frontend-plugin storage.
4
+ * @category Storage
5
+ */
6
+ export type StorageSDK = {
7
+ /**
8
+ * Get the storage.
9
+ * @returns The storage.
10
+ */
11
+ get: () => JSONValue;
12
+ /**
13
+ * Set the storage.
14
+ * @param value The value to set the storage to
15
+ * @returns A promise that resolves when the storage has been set.
16
+ */
17
+ set: <T>(value: JSONCompatible<T>) => Promise<void>;
18
+ /**
19
+ * Subscribe to storage changes.
20
+ * @param callback The callback to call when the storage changes.
21
+ */
22
+ onChange: (callback: (value: JSONValue) => void) => void;
23
+ };
@@ -0,0 +1,71 @@
1
+ import type { HTTPRequestEditor, HTTPResponseEditor } from "./editor";
2
+ import type { Icon } from "./utils";
3
+ /**
4
+ * Utilities to create UI components.
5
+ * @category UI
6
+ */
7
+ export type UISDK = {
8
+ /**
9
+ * Create a button.
10
+ * @param options Options for the button.
11
+ * @param options.variant The variant of the button.
12
+ * @param options.label The label of the button.
13
+ * @param options.leadingIcon The leading icon of the button.
14
+ * @param options.trailingIcon The trailing icon of the button.
15
+ * @param options.size The size of the button.
16
+ * @returns The button element.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const deleteButton = sdk.ui.button({
21
+ * variant: "primary",
22
+ * label: "Delete",
23
+ * trailingIcon: "fas fa-trash-can",
24
+ * size: "small",
25
+ * });
26
+ * ```
27
+ */
28
+ button: (options?: {
29
+ variant?: "primary" | "secondary" | "tertiary";
30
+ label?: string;
31
+ leadingIcon?: Icon;
32
+ trailingIcon?: Icon;
33
+ size?: "small" | "medium" | "large";
34
+ }) => HTMLElement;
35
+ /**
36
+ * Create a card.
37
+ * @param options Options for the card.
38
+ * @param options.header The header of the card.
39
+ * @param options.body The body of the card.
40
+ * @param options.footer The footer of the card.
41
+ * @returns The card element.
42
+ */
43
+ card: (options?: {
44
+ header?: HTMLElement;
45
+ body?: HTMLElement;
46
+ footer?: HTMLElement;
47
+ }) => HTMLElement;
48
+ /**
49
+ * Create a well.
50
+ * @param options Options for the well.
51
+ * @param options.header The header of the well.
52
+ * @param options.body The body of the well.
53
+ * @param options.footer The footer of the well.
54
+ * @returns The well element.
55
+ */
56
+ well: (options?: {
57
+ header?: HTMLElement;
58
+ body?: HTMLElement;
59
+ footer?: HTMLElement;
60
+ }) => HTMLElement;
61
+ /**
62
+ * Create an HTTP request editor
63
+ * @returns The HTTP request editor.
64
+ */
65
+ httpRequestEditor: () => HTTPRequestEditor;
66
+ /**
67
+ * Create an HTTP response editor
68
+ * @returns The HTTP response editor.
69
+ */
70
+ httpResponseEditor: () => HTTPResponseEditor;
71
+ };
@@ -1,4 +1,24 @@
1
1
  type JSONPrimitive = string | number | boolean | null | undefined;
2
+ /**
3
+ * A unique Caido identifier per type.
4
+ */
5
+ export type ID = string & {
6
+ __id?: never;
7
+ };
8
+ /**
9
+ * A unique command identifier.
10
+ * @example "my-super-command"
11
+ */
12
+ export type CommandID = string & {
13
+ __commandId?: never;
14
+ };
15
+ /**
16
+ * A {@link https://fontawesome.com/icons|FontAwesome} icon class.
17
+ * @example "fas fa-rocket"
18
+ */
19
+ export type Icon = string & {
20
+ __icon?: never;
21
+ };
2
22
  export type JSONValue = JSONPrimitive | JSONValue[] | {
3
23
  [key: string]: JSONValue;
4
24
  };
@@ -0,0 +1,23 @@
1
+ import type { Editor } from "./editor";
2
+ /**
3
+ * Utilities to interact with the active page.
4
+ * @category Window
5
+ */
6
+ export type WindowSDK = {
7
+ /**
8
+ * Get the active editor.
9
+ * @returns The active editor.
10
+ */
11
+ getActiveEditor: () => Editor | undefined;
12
+ /**
13
+ * Show a toast message.
14
+ * @param message The message to show.
15
+ * @param options Options for the toast message.
16
+ * @param options.variant The variant of the toast message.
17
+ * @param options.duration The duration of the toast message in milliseconds.
18
+ */
19
+ showToast: (message: string, options?: {
20
+ variant?: "success" | "error" | "warning" | "info";
21
+ duration?: number;
22
+ }) => void;
23
+ };