Skip to content

Commit

Permalink
fix(preprocess): adapt regex to find react on 1.2.32 (#2863)
Browse files Browse the repository at this point in the history
  • Loading branch information
rxri authored Feb 27, 2024
1 parent 5213509 commit c20c485
Show file tree
Hide file tree
Showing 6 changed files with 398 additions and 680 deletions.
287 changes: 0 additions & 287 deletions globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1581,91 +1581,6 @@ declare namespace Spicetify {
*/
onOutside?: (event: React.MouseEvent<HTMLButtonElement>) => void;
};
type PanelSkeletonProps = {
/**
* Aria label for the panel. Does not set the panel header content.
*/
label?: string;
/**
* Item URI of the panel. Used as reference for Spotify's internal Event Factory.
*
* @deprecated Since Spotify `1.2.17`
*/
itemUri?: string;
/**
* Additional class name to apply to the panel.
*
* @deprecated Since Spotify `1.2.12`
*/
className?: string;
/**
* Additional styles to apply to the panel.
*/
style?: React.CSSProperties;
/**
* Children to render inside the panel.
*/
children?: React.ReactNode;
};
type PanelContentProps = {
/**
* Additional class name to apply to the panel.
*/
className?: string;
/**
* Children to render inside the panel.
*/
children?: React.ReactNode;
};
type PanelHeaderProps = {
/**
* Href for the header link.
* Can be either a URI for a path within the app, or a URL for an external link.
*/
link?: string;
/**
* Title of the header.
*/
title?: string;
/**
* Panel ID. Used to toggle panel open/closed state.
*/
panel: number;
/**
* Whether or not the panel contains advertisements.
* @default false
*/
isAdvert?: boolean;
/**
* Actions to render in the header.
*/
actions?: React.ReactNode | React.ReactNode[];
/**
* Function to call when clicking on the close button.
* Called before the panel is closed.
*/
onClose?: () => void;
/**
* Prevent the panel from closing when clicking on the header close button.
* @default false
*/
preventDefaultClose?: boolean;
/**
* Function to call when clicking on the header back button.
* If not provided, the back button will not be rendered.
*/
onBack?: (event: React.MouseEvent<HTMLButtonElement>) => void;
/**
* Font variant for the header title.
* @default "balladBold"
*/
titleVariant?: Variant;
/**
* Semantic color name for the header title.
* @default "textBase"
*/
titleSemanticColor?: SemanticColor;
};
type SliderProps = {
/**
* Label for the slider.
Expand Down Expand Up @@ -1861,27 +1776,6 @@ declare namespace Spicetify {
* @see Spicetify.ReactComponent.ConfirmDialogProps
*/
const ConfirmDialog: any;
/**
* Component to render Spotify-style panel skeleton
*
* Props:
* @see Spicetify.ReactComponent.PanelSkeletonProps
*/
const PanelSkeleton: any;
/**
* Component to render Spotify-style panel content
*
* Props:
* @see Spicetify.ReactComponent.PanelContentProps
*/
const PanelContent: any;
/**
* Component to render Spotify-style panel header
*
* Props:
* @see Spicetify.ReactComponent.PanelHeaderProps
*/
const PanelHeader: any;
/**
* Component to render Spotify slider
*
Expand Down Expand Up @@ -2203,13 +2097,6 @@ declare namespace Spicetify {
dropOriginUri?: string
): (event: React.DragEvent, uris?: string[], label?: string, contextUri?: string, sectionIndex?: number) => void;

/**
* React Hook to use panel state
* @param id ID of the panel to use
* @return Object with methods of the panel
*/
function usePanelState(id: number): { toggle: () => void; isActive: boolean };

/**
* React Hook to use extracted color from GraphQL
*
Expand All @@ -2227,180 +2114,6 @@ declare namespace Spicetify {
function useExtractedColor(uri: string, fallbackColor?: string, variant?: "colorRaw" | "colorLight" | "colorDark"): string;
}

/**
* An API wrapper to interact with Spotify's Panel/right sidebar.
*/
namespace Panel {
/**
* Properties that are used by the `registerPanel` function.
*/
type PanelProps = {
/**
* Label of the Panel.
*/
label?: string;
/**
* Children to render inside the Panel.
* Must be a React Component.
* Will be passed a `panel` prop with the Panel ID.
*/
children: React.ReactNode;
/**
* Determine if the children passed is a custom Panel.
* If true, the children will be rendered as is.
* Note: All passed props except `children` will be ignored if enabled.
*
* @default false
*/
isCustom?: boolean;
/**
* Inline styles to apply to the Panel skeleton.
*/
style?: React.CSSProperties;
/**
* Additional class name to apply to the Panel content wrapper.
*/
wrapperClassname?: string;
/**
* Additional class name to apply to the Panel header.
*/
headerClassname?: string;
/**
* Font variant for the Panel header title.
* @default "balladBold"
*/
headerVariant?: Variant;
/**
* Semantic color name for the Panel header title.
* @default "textBase"
*/
headerSemanticColor?: SemanticColor;
/**
* Href for the header link.
* Can be either a URI for a path within the app, or a URL for an external link.
*/
headerLink?: string;
/**
* Additional actions to render in the header.
* Will be rendered next to the close button.
*/
headerActions?: React.ReactNode | React.ReactNode[];
/**
* Function to call when clicking on the header close button.
* Called before the panel is closed.
*/
headerOnClose?: () => void;
/**
* Prevent the panel from closing when clicking on the header close button.
* @default false
*/
headerPreventDefaultClose?: boolean;
/**
* Function to call when clicking on the header back button.
* If not provided, the back button will not be rendered.
* @param event Event object
*/
headerOnBack?: (event: React.MouseEvent<HTMLButtonElement>) => void;
};

/**
* An object of reserved panel IDs used by Spotify.
*/
const reservedPanelIds: Record<string | number, string | number>;
/**
* Collection of React Components used by Spotify in the Panel.
*/
const Components: {
/**
* React Component for the Panel's skeleton.
*
* Props:
* @see Spicetify.ReactComponent.PanelSkeletonProps
*/
PanelSkeleton: any;
/**
* React Component for the Panel's content.
*
* Props:
* @see Spicetify.ReactComponent.PanelContentProps
*/
PanelContent: any;
/**
* React Component for the Panel's header.
*
* Props:
* @see Spicetify.ReactComponent.PanelHeaderProps
*/
PanelHeader: any;
};
/**
* Check whether or not a Panel with the provided ID is registered.
* @param id Panel ID to check
* @return Whether or not a Panel with the provided ID is registered
*/
function hasPanel(id: number): boolean;
/**
* Get the Panel with the provided ID.
* @param id Panel ID to get
* @return Panel with the provided ID
*/
function getPanel(id: number): React.ReactNode | undefined;
/**
* Set the Panel with the provided ID.
* If the ID is not registered, it will be set to `0`.
* @param id Panel ID to set
*/
function setPanel(id: number): Promise<void>;
/**
* Subscribe to Panel changes.
* @param callback Callback to call when Panel changes
*/
function subPanelState(callback: (id: number) => void): void;
/**
* Register a new Panel.
* An ID will be automatically assigned to the Panel.
*
* To make it easier and convenient for developers to use the Panel API, this method by default wraps the children passed into a Panel skeleton and content wrapper.
*
* If you wish to customize the Panel, you can pass `isCustom` as `true` to disable the default wrapper.
*
* @param props Properties of the Panel
* @return Methods and properties of the Panel
*/
function registerPanel(props: PanelProps): {
/**
* Assigned ID of the Panel.
*/
id: number;
/**
* Function to toggle the Panel open/closed state.
*/
toggle: () => Promise<void>;
/**
* Method to subscribe to the related Panel state.
* Only fires when the related Panel open/closed state changes.
*/
onStateChange: (callback: (isActive: boolean) => void) => void;
/**
* Boolean to determine if the Panel is open.
*/
isActive: boolean;
};
/**
* Function to render a Panel of the current ID.
* If the ID is not registered or is reserved by Spotify, the function will return `null`.
*
* Used as a hook for Spotify internal component.
* @return Panel of the current ID
*/
function render(): React.ReactNode | null;
/**
* ID of the current Panel.
* @return ID of the current Panel
*/
const currentPanel: number;
}

/**
* react-flip-toolkit
* @description A lightweight magic-move library for configurable layout transitions.
Expand Down
Loading

0 comments on commit c20c485

Please sign in to comment.