@spotlightjs/overlay 0.0.20 → 0.0.21

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/dist/App.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { SpotlightOverlayOptions } from './types';
2
2
  type AppProps = Omit<SpotlightOverlayOptions, 'debug' | 'injectImmediately'> & Required<Pick<SpotlightOverlayOptions, 'sidecarUrl'>>;
3
- export default function App({ openOnInit, showTriggerButton, defaultEventId, integrations, sidecarUrl, anchor, }: AppProps): import("react/jsx-runtime").JSX.Element;
3
+ export default function App({ openOnInit, showTriggerButton, integrations, sidecarUrl, anchor, }: AppProps): import("react/jsx-runtime").JSX.Element;
4
4
  export {};
@@ -1,9 +1,10 @@
1
1
  import { Integration, IntegrationData } from '../integrations/integration';
2
- export default function Debugger({ integrations, isOpen, setOpen, integrationData, isOnline, }: {
2
+ import { NotificationCount } from '../types';
3
+ export default function Debugger({ integrations, isOpen, setOpen, integrationData, isOnline, setTriggerButtonCount: setNotificationCount, }: {
3
4
  integrations: Integration[];
4
5
  isOpen: boolean;
5
6
  setOpen: (value: boolean) => void;
6
- defaultEventId?: string;
7
7
  integrationData: IntegrationData<unknown>;
8
8
  isOnline: boolean;
9
+ setTriggerButtonCount: (count: NotificationCount) => void;
9
10
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,8 @@
1
1
  import { Integration, IntegrationData } from '../integrations/integration';
2
- export default function Overview({ integrations, integrationData, }: {
2
+ import { NotificationCount } from '../types';
3
+ export default function Overview({ integrations, integrationData, setTriggerButtonCount, setOpen, }: {
3
4
  integrations: Integration[];
4
5
  integrationData: IntegrationData<unknown>;
6
+ setTriggerButtonCount: (count: NotificationCount) => void;
7
+ setOpen: (value: boolean) => void;
5
8
  }): import("react/jsx-runtime").JSX.Element;
@@ -4,11 +4,22 @@ export type Props = {
4
4
  * Array of tabs to display.
5
5
  */
6
6
  tabs: IntegrationTab<unknown>[];
7
+ } & (NestedTabsProps | TopLevelTabsProps);
8
+ type NestedTabsProps = {
7
9
  /**
8
10
  * Whether the tabs are nested inside another tab.
9
11
  * If `nested` is `true`, links will be set relative to the parent
10
12
  * tab route instead of absolute to the root.
11
13
  */
12
- nested?: boolean;
14
+ nested: true;
15
+ setOpen?: undefined;
13
16
  };
14
- export default function Tabs({ tabs, nested }: Props): import("react/jsx-runtime").JSX.Element;
17
+ type TopLevelTabsProps = {
18
+ nested?: false;
19
+ /**
20
+ * Setter to control the open state of the overlay
21
+ */
22
+ setOpen: (value: boolean) => void;
23
+ };
24
+ export default function Tabs({ tabs, nested, setOpen }: Props): import("react/jsx-runtime").JSX.Element;
25
+ export {};
@@ -1,9 +1,9 @@
1
- import { TriggerButtonCount } from '../types';
1
+ import { NotificationCount } from '../types';
2
2
  export declare const DEFAULT_ANCHOR = "bottomRight";
3
3
  export type Anchor = 'bottomRight' | 'bottomLeft' | 'centerRight' | 'centerLeft' | 'topLeft' | 'topRight';
4
- export default function Trigger({ isOpen, setOpen, count, anchor, }: {
4
+ export default function Trigger({ isOpen, setOpen, notificationCount, anchor, }: {
5
5
  isOpen: boolean;
6
6
  setOpen: (value: boolean) => void;
7
- count: TriggerButtonCount;
7
+ notificationCount: NotificationCount;
8
8
  anchor?: Anchor;
9
9
  }): import("react/jsx-runtime").JSX.Element;
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { default as viteInspect } from './integrations/vite-inspect/index.ts';
5
5
  /**
6
6
  * Open the Spotlight debugger Window
7
7
  */
8
- export declare function openSpotlight(): Promise<void>;
8
+ export declare function openSpotlight(path?: string | undefined): Promise<void>;
9
9
  /**
10
10
  * Close the Spotlight debugger Window
11
11
  */
@@ -24,4 +24,13 @@ export declare function onOpen(cb: () => void): Promise<void>;
24
24
  * A count of the number of collected severe events is passed to the callback.
25
25
  */
26
26
  export declare function onSevereEvent(cb: (count: number) => void): Promise<void>;
27
- export declare function init({ openOnInit, showTriggerButton, defaultEventId, injectImmediately, sidecarUrl, anchor, debug, integrations, }?: SpotlightOverlayOptions): Promise<void>;
27
+ /**
28
+ * Trigger an event in Spotlight.
29
+ *
30
+ * This is primarily useful for handling an uncaught error/crash, and forcing the debugger
31
+ * to render vs a native error handler.
32
+ *
33
+ * e.g. trigger("sentry.showError", {eventId});
34
+ */
35
+ export declare function trigger(eventName: string, payload: unknown): Promise<void>;
36
+ export declare function init({ openOnInit, showTriggerButton, injectImmediately, sidecarUrl, anchor, debug, integrations, }?: SpotlightOverlayOptions): Promise<void>;
@@ -8,7 +8,9 @@ export default function consoleIntegration(): {
8
8
  }) => {
9
9
  id: string;
10
10
  title: string;
11
- notificationCount: number;
11
+ notificationCount: {
12
+ count: number;
13
+ };
12
14
  content: typeof ConsoleTab;
13
15
  }[];
14
16
  setup: () => void;
@@ -1,4 +1,9 @@
1
1
  import { type ComponentType } from 'react';
2
+ import { NotificationCount } from '../types';
3
+ export type SpotlightContext = {
4
+ open: (path: string | undefined) => void;
5
+ close: () => void;
6
+ };
2
7
  export type Integration<T = any> = {
3
8
  /**
4
9
  * Name of the integration
@@ -23,7 +28,7 @@ export type Integration<T = any> = {
23
28
  *
24
29
  * Use this hook to setup any global state, instrument handlers, etc.
25
30
  */
26
- setup?: () => void | Promise<void>;
31
+ setup?: (context: SpotlightContext) => void | Promise<void> | TeardownFunction;
27
32
  /**
28
33
  * Hook called whenever spotlight forwards a new raw event to this integration.
29
34
  *
@@ -49,7 +54,7 @@ export type IntegrationTab<T> = {
49
54
  * If this property is set, a count badge will be displayed
50
55
  * next to the tab title with the specified value.
51
56
  */
52
- notificationCount?: number;
57
+ notificationCount?: NotificationCount;
53
58
  /**
54
59
  * JSX content of the tab. Go crazy, this is all yours!
55
60
  */
@@ -63,16 +68,6 @@ export type ProcessedEventContainer<T> = {
63
68
  * The processed event data to be passed to your tabs.
64
69
  */
65
70
  event: T;
66
- /**
67
- * A level indicating the impact or severity of the processed event. Set this to
68
- * 'severe' if the event is critical and users should be aware of it (e.g. a thrown error).
69
- *
70
- * If this is set to 'severe', a red notification count badge will be displayed
71
- * next to the spotlight trigger button in the UI.
72
- *
73
- * @default value is 'default'
74
- */
75
- severity?: Severity;
76
71
  };
77
72
  export type Severity = 'default' | 'severe';
78
73
  export type IntegrationData<T> = Record<string, ProcessedEventContainer<T>[]>;
@@ -94,5 +89,6 @@ export type RawEventContext = {
94
89
  */
95
90
  data: string;
96
91
  };
97
- export declare function initIntegrations(integrations?: Integration[]): Promise<Integration[]>;
92
+ type TeardownFunction = () => void | Promise<() => void>;
93
+ export declare function initIntegrations(integrations: Integration<any>[] | undefined, context: SpotlightContext): Promise<[Integration[], TeardownFunction[]]>;
98
94
  export {};
@@ -0,0 +1,5 @@
1
+ export default function Tags({ tags }: {
2
+ tags: {
3
+ [key: string]: string;
4
+ };
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -6,6 +6,7 @@ type TraceSubscription = ['trace', (trace: Trace) => void];
6
6
  type Subscription = OnlineSubscription | EventSubscription | TraceSubscription;
7
7
  declare class SentryDataCache {
8
8
  protected events: SentryEvent[];
9
+ protected eventIds: Set<string>;
9
10
  protected sdks: Sdk[];
10
11
  protected traces: Trace[];
11
12
  protected tracesById: {
@@ -1,23 +1,34 @@
1
1
  import type { Envelope } from '@sentry/types';
2
- import type { RawEventContext, Severity } from '../integration';
2
+ import type { RawEventContext } from '../integration';
3
3
  import ErrorsTab from './tabs/ErrorsTab';
4
4
  import SdksTab from './tabs/SdksTab';
5
+ import TracesTab from './tabs/TracesTab';
5
6
  type SentryIntegrationOptions = {
6
7
  sidecarUrl?: string;
7
8
  };
8
9
  export default function sentryIntegration(options?: SentryIntegrationOptions): {
9
10
  name: string;
10
11
  forwardedContentType: string[];
11
- setup: () => void;
12
+ setup: ({ open }: import("../integration").SpotlightContext) => () => void;
12
13
  processEvent: (event: RawEventContext) => {
13
14
  event: Envelope;
14
- severity: Severity;
15
15
  };
16
16
  tabs: () => ({
17
17
  id: string;
18
18
  title: string;
19
- notificationCount: number;
19
+ notificationCount: {
20
+ count: number;
21
+ severe: boolean;
22
+ };
20
23
  content: typeof ErrorsTab;
24
+ } | {
25
+ id: string;
26
+ title: string;
27
+ notificationCount: {
28
+ count: number;
29
+ severe?: undefined;
30
+ };
31
+ content: typeof TracesTab;
21
32
  } | {
22
33
  id: string;
23
34
  title: string;
@@ -27,6 +38,5 @@ export default function sentryIntegration(options?: SentryIntegrationOptions): {
27
38
  };
28
39
  export declare function processEnvelope({ data }: RawEventContext): {
29
40
  event: Envelope;
30
- severity: Severity;
31
41
  };
32
42
  export {};
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * useKeyPress
3
- * @param {string} key - the name of the key to respond to, compared against event.key
3
+ * @param {string[]} keys - an array of keys to respond to, compared against event.key
4
4
  * @param {function} action - the action to perform on key press
5
+ * @param {boolean} propagate - whether to stop event propagation (default is false)
5
6
  */
6
- export default function useKeyPress(key: string, action: () => void, propagate?: boolean): void;
7
+ export default function useKeyPress(keys: string[], action: () => void, propagate?: boolean): void;