Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudutour committed Oct 11, 2023
1 parent 84273a0 commit 36efcae
Show file tree
Hide file tree
Showing 25 changed files with 2,835 additions and 719 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"import/no-unresolved": [2, { "ignore": ["@raycast/api"] }]
"import/no-unresolved": [2, { "ignore": ["@raycast/api"] }],
"@typescript-eslint/no-explicit-any": "warn"
},
"overrides": [
{
Expand Down
3,321 changes: 2,685 additions & 636 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@
"signal-exit": "^4.0.2"
},
"devDependencies": {
"@raycast/api": "^1.51.0",
"@types/content-type": "^1.1.5",
"@raycast/api": "1.52.0",
"@types/content-type": "^1.1.6",
"@types/media-typer": "^1.1.1",
"@types/object-hash": "^3.0.2",
"@types/signal-exit": "^3.0.1",
"@typescript-eslint/eslint-plugin": "5.26.0",
"@typescript-eslint/parser": "5.26.0",
"eslint": "8.16.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jest": "26.2.2",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-react-hooks": "4.5.0",
"typescript": "4.7.2"
"@types/object-hash": "^3.0.4",
"@types/signal-exit": "^3.0.2",
"@typescript-eslint/eslint-plugin": "6.7.5",
"@typescript-eslint/parser": "6.7.5",
"eslint": "8.51.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-jest": "27.4.2",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-react-hooks": "4.6.0",
"typescript": "5.2.2"
}
}
8 changes: 4 additions & 4 deletions src/exec-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type SpawnedPromise = Promise<{

export function getSpawnedPromise(
spawned: childProcess.ChildProcessWithoutNullStreams,
{ timeout }: { timeout?: number } = {}
{ timeout }: { timeout?: number } = {},
): SpawnedPromise {
const spawnedPromise: SpawnedPromise = new Promise((resolve, reject) => {
spawned.on("exit", (exitCode, signal) => {
Expand Down Expand Up @@ -95,7 +95,7 @@ function bufferStream<T extends string | Buffer>(options: { encoding: BufferEnco

async function getStream<T extends string | Buffer>(
inputStream: Stream.Readable,
options: { encoding: BufferEncoding | "buffer" }
options: { encoding: BufferEncoding | "buffer" },
) {
const stream = bufferStream<T>(options);

Expand Down Expand Up @@ -143,7 +143,7 @@ async function getBufferedData<T extends string | Buffer>(stream: Stream.Readabl
export async function getSpawnedResult<T extends string | Buffer>(
{ stdout, stderr }: childProcess.ChildProcessWithoutNullStreams,
{ encoding }: { encoding: BufferEncoding | "buffer" },
processDone: SpawnedPromise
processDone: SpawnedPromise,
) {
const stdoutPromise = getStream<T>(stdout, { encoding });
const stderrPromise = getStream<T>(stderr, { encoding });
Expand Down Expand Up @@ -273,7 +273,7 @@ const makeError = ({
export type ParseExecOutputHandler<
T,
DecodedOutput extends string | Buffer = string | Buffer,
Options = unknown
Options = unknown,
> = (args: {
/** The output of the process on stdout. */
stdout: DecodedOutput;
Expand Down
6 changes: 3 additions & 3 deletions src/handle-error-toast-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ export const handleErrorToastAction = (error: unknown): Toast.ActionOptions => {
} else {
open(
`https://github.com/raycast/extensions/issues/new?&labels=extension%2Cbug&template=extension_bug_report.yml&title=${encodeURIComponent(
title
title,
)}&extension-url=${encodeURI(extensionURL)}&description=${encodeURIComponent(
`#### Error:
\`\`\`
${stack}
\`\`\`
`
)}`
`,
)}`,
);
}
},
Expand Down
6 changes: 3 additions & 3 deletions src/icon/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function getAvatarIcon(
* @default true
*/
gradient?: boolean;
}
},
): Image.Asset {
const words = name.trim().split(" ");
let initials: string;
Expand Down Expand Up @@ -127,8 +127,8 @@ export function getAvatarIcon(
: ""
}
<circle cx="50" cy="50" r="${radius}" fill="${
options?.gradient !== false ? "url(#Gradient)" : backgroundColor
}" />
options?.gradient !== false ? "url(#Gradient)" : backgroundColor
}" />
${
initials
? `<text x="50" y="80" font-size="${
Expand Down
2 changes: 1 addition & 1 deletion src/icon/favicon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function getFavicon(
* A {@link Image.Mask} to apply to the Favicon.
*/
mask?: Image.Mask;
}
},
): Image.ImageLike {
try {
const urlObj = typeof url === "string" ? new URL(url) : url;
Expand Down
8 changes: 4 additions & 4 deletions src/icon/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function describeArc(x: number, y: number, radius: number, startAngle: number, e
export function getProgressIcon(
progress: number,
color: Color | string = Color.Red,
options?: { background?: Color | string; backgroundOpacity?: number }
options?: { background?: Color | string; backgroundOpacity?: number },
): Image.Asset {
const background = options?.background || (environment.appearance === "light" ? "black" : "white");
const backgroundOpacity = options?.backgroundOpacity || 0.1;
Expand All @@ -48,16 +48,16 @@ export function getProgressIcon(

const svg = `<svg width="100px" height="100px">
<circle cx="50" cy="50" r="${radius}" stroke-width="${stroke}" stroke="${
progress < 1 ? background : color
}" opacity="${progress < 1 ? backgroundOpacity : "1"}" fill="none" />
progress < 1 ? background : color
}" opacity="${progress < 1 ? backgroundOpacity : "1"}" fill="none" />
${
progress > 0 && progress < 1
? `<path d="${describeArc(
50,
50,
radius,
0,
progress * 360
progress * 360,
)}" stroke="${color}" stroke-width="${stroke}" fill="none" />`
: ""
}
Expand Down
8 changes: 4 additions & 4 deletions src/run-applescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function runAppleScript<T = string>(
script: string,
options?: AppleScriptOptions & {
parseOutput?: ParseExecOutputHandler<T, string, AppleScriptOptions>;
}
},
): Promise<string>;
export async function runAppleScript<T = string>(
script: string,
Expand All @@ -70,7 +70,7 @@ export async function runAppleScript<T = string>(
args: string[],
options?: AppleScriptOptions & {
parseOutput?: ParseExecOutputHandler<T, string, AppleScriptOptions>;
}
},
): Promise<string>;
export async function runAppleScript<T = string>(
script: string,
Expand All @@ -81,7 +81,7 @@ export async function runAppleScript<T = string>(
}),
options?: AppleScriptOptions & {
parseOutput?: ParseExecOutputHandler<T, string, AppleScriptOptions>;
}
},
): Promise<string> {
const { humanReadableOutput, language, timeout, ...execOptions } = Array.isArray(optionsOrArgs)
? options || {}
Expand All @@ -106,7 +106,7 @@ export async function runAppleScript<T = string>(
const [{ error, exitCode, signal, timedOut }, stdoutResult, stderrResult] = await getSpawnedResult<string>(
spawned,
{ encoding: "utf8" },
spawnedPromise
spawnedPromise,
);
const stdout = handleOutput({ stripFinalNewline: true }, stdoutResult);
const stderr = handleOutput({ stripFinalNewline: true }, stderrResult);
Expand Down
6 changes: 3 additions & 3 deletions src/showFailureToast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ const handleErrorToastAction = (error: unknown): Toast.ActionOptions => {
} else {
open(
`https://github.com/raycast/extensions/issues/new?&labels=extension%2Cbug&template=extension_bug_report.yml&title=${encodeURIComponent(
title
title,
)}&extension-url=${encodeURI(extensionURL)}&description=${encodeURIComponent(
`#### Error:
\`\`\`
${stack}
\`\`\`
`
)}`
`,
)}`,
);
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type MutatePromise<T, U = T, V = any> = (
optimisticUpdate?: (data: T | U) => T;
rollbackOnError?: boolean | ((data: T | U) => T);
shouldRevalidateAfter?: boolean;
}
},
) => Promise<V>;

export type UsePromiseReturnType<T> = AsyncState<T> & {
Expand Down
4 changes: 2 additions & 2 deletions src/useAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function useAI(
* Whether to stream the answer or only update the data when the entire answer has been received.
*/
stream?: boolean;
} & Omit<PromiseOptions<FunctionReturningPromise>, "abortable"> = {}
} & Omit<PromiseOptions<FunctionReturningPromise>, "abortable"> = {},
) {
const { creativity, stream, model, ...usePromiseOptions } = options;
const [data, setData] = useState("");
Expand All @@ -53,7 +53,7 @@ export function useAI(
}
},
[prompt, creativity, stream],
{ ...usePromiseOptions, abortable }
{ ...usePromiseOptions, abortable },
);

return { isLoading, data, error, revalidate };
Expand Down
10 changes: 5 additions & 5 deletions src/useCachedPromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ export type CachedPromiseOptions<T extends FunctionReturningPromise, U> = Promis
* ```
*/
export function useCachedPromise<T extends FunctionReturningPromise<[]>>(
fn: T
fn: T,
): UseCachedPromiseReturnType<Awaited<ReturnType<T>>, undefined>;
export function useCachedPromise<T extends FunctionReturningPromise, U = undefined>(
fn: T,
args: Parameters<T>,
options?: CachedPromiseOptions<T, U>
options?: CachedPromiseOptions<T, U>,
): UseCachedPromiseReturnType<Awaited<ReturnType<T>>, U>;
export function useCachedPromise<T extends FunctionReturningPromise, U = undefined>(
fn: T,
args?: Parameters<T>,
options?: CachedPromiseOptions<T, U>
options?: CachedPromiseOptions<T, U>,
) {
const { initialData, keepPreviousData, ...usePromiseOptions } = options || {};
const lastUpdateFrom = useRef<"cache" | "promise">();
Expand All @@ -79,7 +79,7 @@ export function useCachedPromise<T extends FunctionReturningPromise, U = undefin
emptyCache,
{
cacheNamespace: hash(fn),
}
},
);

// Use a ref to store previous returned data. Use the inital data as its inital value from the cache.
Expand Down Expand Up @@ -153,7 +153,7 @@ export function useCachedPromise<T extends FunctionReturningPromise, U = undefin
throw err;
}
},
[mutateCache, _mutate, latestData, laggyDataRef, lastUpdateFrom]
[mutateCache, _mutate, latestData, laggyDataRef, lastUpdateFrom],
);

useEffect(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/useCachedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ const cacheMap = new Map<string | symbol, Cache>();
export function useCachedState<T>(
key: string,
initialState: T,
config?: { cacheNamespace?: string }
config?: { cacheNamespace?: string },
): [T, Dispatch<SetStateAction<T>>];
export function useCachedState<T = undefined>(key: string): [T | undefined, Dispatch<SetStateAction<T | undefined>>];
export function useCachedState<T>(
key: string,
initialState?: T,
config?: { cacheNamespace?: string }
config?: { cacheNamespace?: string },
): [T, Dispatch<SetStateAction<T>>] {
const cacheKey = config?.cacheNamespace || rootCache;
const cache =
Expand Down Expand Up @@ -97,7 +97,7 @@ export function useCachedState<T>(
}
return newValue;
},
[cache, keyRef, stateRef]
[cache, keyRef, stateRef],
);

return [state, setStateAndCache];
Expand Down
14 changes: 7 additions & 7 deletions src/useExec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ export function useExec<T = Buffer, U = undefined>(
parseOutput?: ParseExecOutputHandler<T, Buffer, ExecOptions>;
} & ExecOptions & {
encoding: "buffer";
} & ExecCachedPromiseOptions<T, U>
} & ExecCachedPromiseOptions<T, U>,
): UseCachedPromiseReturnType<T, U>;
export function useExec<T = string, U = undefined>(
command: string,
options?: {
parseOutput?: ParseExecOutputHandler<T, string, ExecOptions>;
} & ExecOptions & {
encoding?: BufferEncoding;
} & ExecCachedPromiseOptions<T, U>
} & ExecCachedPromiseOptions<T, U>,
): UseCachedPromiseReturnType<T, U>;
export function useExec<T = Buffer, U = undefined>(
file: string,
Expand All @@ -141,7 +141,7 @@ export function useExec<T = Buffer, U = undefined>(
parseOutput?: ParseExecOutputHandler<T, Buffer, ExecOptions>;
} & ExecOptions & {
encoding: "buffer";
} & ExecCachedPromiseOptions<T, U>
} & ExecCachedPromiseOptions<T, U>,
): UseCachedPromiseReturnType<T, U>;
export function useExec<T = string, U = undefined>(
file: string,
Expand All @@ -155,7 +155,7 @@ export function useExec<T = string, U = undefined>(
parseOutput?: ParseExecOutputHandler<T, string, ExecOptions>;
} & ExecOptions & {
encoding?: BufferEncoding;
} & ExecCachedPromiseOptions<T, U>
} & ExecCachedPromiseOptions<T, U>,
): UseCachedPromiseReturnType<T, U>;
export function useExec<T, U = undefined>(
command: string,
Expand All @@ -168,7 +168,7 @@ export function useExec<T, U = undefined>(
options?: {
parseOutput?: ParseExecOutputHandler<T, Buffer, ExecOptions> | ParseExecOutputHandler<T, string, ExecOptions>;
} & ExecOptions &
ExecCachedPromiseOptions<T, U>
ExecCachedPromiseOptions<T, U>,
): UseCachedPromiseReturnType<T, U> {
const { parseOutput, input, onData, onWillExecute, initialData, execute, keepPreviousData, onError, ...execOptions } =
Array.isArray(optionsOrArgs) ? options || {} : optionsOrArgs || {};
Expand Down Expand Up @@ -209,7 +209,7 @@ export function useExec<T, U = undefined>(
const [{ error, exitCode, signal, timedOut }, stdoutResult, stderrResult] = await getSpawnedResult(
spawned,
options,
spawnedPromise
spawnedPromise,
);
const stdout = handleOutput(options, stdoutResult);
const stderr = handleOutput(options, stderrResult);
Expand All @@ -228,7 +228,7 @@ export function useExec<T, U = undefined>(
parentError: new Error(),
}) as T;
},
[parseOutputRef]
[parseOutputRef],
);

// @ts-expect-error T can't be a Promise so it's actually the same
Expand Down
4 changes: 2 additions & 2 deletions src/useFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function useFetch<T = unknown, U = undefined>(
options?: RequestInit & { parseResponse?: (response: Response) => Promise<T> } & Omit<
CachedPromiseOptions<(url: RequestInfo, options?: RequestInit) => Promise<T>, U>,
"abortable"
>
>,
): UseCachedPromiseReturnType<T, U> {
const { parseResponse, initialData, execute, keepPreviousData, onError, onData, onWillExecute, ...fetchOptions } =
options || {};
Expand All @@ -95,7 +95,7 @@ export function useFetch<T = unknown, U = undefined>(
const res = await fetch(url, { signal: abortable.current?.signal, ...options });
return (await parseResponseRef.current(res)) as T;
},
[parseResponseRef]
[parseResponseRef],
);

// @ts-expect-error T can't be a Promise so it's actually the same
Expand Down
Loading

0 comments on commit 36efcae

Please sign in to comment.